Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c6082fde1 | ||
|
|
c68440e9da | ||
|
|
2a0d5ecaa1 | ||
|
|
911429fd01 |
No files matched your search
@@ -78,7 +78,7 @@ const isoTime = value => (typeof value === 'string' && /^[0-9]{4}-[0-9]{2}-[0-9]
|
||||
// #1873 ride-default: `riders()` lists the owner's active organizations for Ride all, read locally:
|
||||
// [{id, fixture, cliproxy, changes, call, status}] where `changes` is the text of the organization's
|
||||
// change log, `call(verb, args)` reaches its bus as the owner and `status()` is its bus status. `ownerModels()` answers
|
||||
// {proxy, riding, models} from the riding buses' catalogues. `move(id, models, principal)` moves a
|
||||
// {proxy, riding, models, catalogue?} from the instance owner catalogue or riding buses. `move(id, models, principal)` moves a
|
||||
// stopped fixture organization to the owner's models through the organization service.
|
||||
// #1873 settings-backend A2: a rider may also have `file()`, its organization file as the writer
|
||||
// reads it ({document, revision}), read only. `harnesses()` lists the installed harness programs.
|
||||
@@ -503,7 +503,7 @@ export function createProxyAdmin({ dataRoot, configDir, instance = null, unitDir
|
||||
if (typeof move !== 'function') return { org, moved: false, reason: 'not-available' };
|
||||
const owner = await ownerModels();
|
||||
if (owner?.proxy !== true) return { org, moved: false, reason: 'no-proxy' };
|
||||
if (owner.riding !== true) return { org, moved: false, reason: 'no-riding-bus' };
|
||||
if (owner.riding !== true && owner.catalogue !== 'ready') return { org, moved: false, reason: 'no-riding-bus' };
|
||||
let result;
|
||||
try { result = await move(org, owner.models, principal); }
|
||||
catch (error) { result = { moved: false, reason: failCode(error) }; }
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Console wiring (webui cli.mjs) reads each organization and its bus, and admin-control runs them.
|
||||
import { usableModel } from '../../plugins/model-provider/cliproxy/index.mjs';
|
||||
|
||||
export { usableModel };
|
||||
export { usableModel, ownerModelsAvailable } from '../../plugins/model-provider/cliproxy/index.mjs';
|
||||
const has = (list, name) => Array.isArray(list) && list.includes(name);
|
||||
|
||||
// The model providers one change-log change shows before and after, by the change's path: the
|
||||
@@ -98,12 +98,41 @@ export function readRider({ id, read, readLog, isFixture }) {
|
||||
cliproxy: ok ? (Array.isArray(doc.plugins?.['model-provider']) ? doc.plugins['model-provider'] : []).includes('cliproxy') : undefined, changes };
|
||||
}
|
||||
|
||||
// The owner's models: `proxy` is true when the instance's proxy.json names a port. Each organization
|
||||
// that lists cliproxy is asked for its routes at once, so a hung bus costs one timeout, not one each.
|
||||
// It rides when its bus answers a ready catalogue; the models are the cliproxy rows those
|
||||
// catalogues list, once each.
|
||||
export async function ownerModelsFrom({ proxy, riders }) {
|
||||
// Only organization mode uses the owner transport. Single-business and SSO Consoles keep
|
||||
// reading their riding buses. The CLI and HTTP fixtures share this admission choice.
|
||||
export function ownerModelsReader({ proxy, organizations, ownerProxy, rideRiders, timeoutMs }) {
|
||||
return async () => {
|
||||
let configured = false;
|
||||
try { configured = proxy() === true; } catch {}
|
||||
return ownerModelsFrom({ proxy: configured,
|
||||
riders: configured && !organizations ? await rideRiders() : [],
|
||||
...(organizations ? { ownerCatalogue: () => ownerProxy.catalogue() } : {}),
|
||||
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// The instance owner catalogue is authoritative when supplied: it works before the first
|
||||
// organization and reads the same offered-model rule as the Models page. Never merge it with
|
||||
// stale bus rows or fall back after a refused read. Other callers keep their riding-bus truth.
|
||||
// `catalogue` is read evidence, not persisted state; `riding` still describes a bus catalogue.
|
||||
export async function ownerModelsFrom({ proxy, riders, ownerCatalogue = null, timeoutMs = 5000 }) {
|
||||
if (proxy !== true) return { proxy: false, riding: false, models: [] };
|
||||
if (typeof ownerCatalogue === 'function') {
|
||||
// The bound stops waiting; it does not cancel the owner read.
|
||||
let timer;
|
||||
try {
|
||||
const catalogue = await Promise.race([
|
||||
Promise.resolve().then(ownerCatalogue),
|
||||
new Promise(resolve => { timer = setTimeout(() => resolve(null), timeoutMs); }),
|
||||
]);
|
||||
if (catalogue?.status === 'ready' && Array.isArray(catalogue.models)) return {
|
||||
proxy: true, riding: false, catalogue: 'ready', models: catalogue.models.filter(m => m?.module === 'cliproxy'),
|
||||
};
|
||||
} catch { /* A failed read carries no upstream text and grants no bus fallback. */ }
|
||||
finally { clearTimeout(timer); }
|
||||
return { proxy: true, riding: false, catalogue: 'unavailable', models: [] };
|
||||
}
|
||||
const catalogues = await Promise.all((Array.isArray(riders) ? riders : []).filter(r => r?.cliproxy === true)
|
||||
.map(async r => { try { return (await r.call('routes'))?.catalogue; } catch { return null; } }));
|
||||
const models = new Map(); let riding = false;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// The management client remains bus-only; account metadata comes from its existing owner read.
|
||||
import { releaseState, initState, fenceState, createUnitControl, defaultRun } from './admin.mjs';
|
||||
import { loadProxy } from './settings.mjs';
|
||||
import { offeredProvider } from '../../plugins/model-provider/cliproxy/index.mjs';
|
||||
import { offeredProvider, usesModelService } from '../../plugins/model-provider/cliproxy/index.mjs';
|
||||
|
||||
export async function readService({ configDir, dataRoot, instance, unitDir = null, signal, run = defaultRun }) {
|
||||
const release = releaseState(dataRoot), init = initState(configDir, dataRoot);
|
||||
@@ -16,9 +16,20 @@ export async function readService({ configDir, dataRoot, instance, unitDir = nul
|
||||
return { release, init, unit, fence: { set: !!fence } };
|
||||
}
|
||||
|
||||
// Membership includes the admitted organization document. Unknown documents still need a
|
||||
// check; an invalid member or a failed membership read must never become a silent pass.
|
||||
function proxyMembers(ctx) {
|
||||
const members = ctx.members;
|
||||
if (members?.some(org => org.invalid)) throw Error('organization unavailable');
|
||||
return members?.filter(org => !org.doc || usesModelService(org.doc));
|
||||
}
|
||||
const notNeeded = members => ({ state: 'not-applicable', reason: members.length > 1 ? 'Your organizations answer without the model service.' : 'Your organization answers without the model service.' });
|
||||
|
||||
// The host can supply the instance account reader without requiring an organization.
|
||||
export async function accountState(ctx) {
|
||||
const read = !ctx.members.length && ctx.accounts ? [ctx.accounts] : ctx.members.map(org => async () => {
|
||||
const members = proxyMembers(ctx);
|
||||
if (ctx.members.length && !members.length) return notNeeded(ctx.members);
|
||||
const read = !ctx.members.length && ctx.accounts ? [ctx.accounts] : members.map(org => async () => {
|
||||
const routes = await ctx.read(org, 'routes');
|
||||
if (['unavailable', 'disabled'].includes(routes?.catalogue?.status)) return { catalogue: routes.catalogue };
|
||||
const accounts = await ctx.read(org, 'accounts');
|
||||
@@ -48,6 +59,8 @@ export const setupState = Object.freeze([
|
||||
purpose: "The program on this computer that carries your agents' questions to the models you connect.",
|
||||
fix: { page: '#/settings/model-setup', step: 1, label: 'Set up model service' }, order: { after: [] }, required: true,
|
||||
async check(ctx) {
|
||||
const members = proxyMembers(ctx);
|
||||
if (ctx.members?.length && !members.length) return notNeeded(ctx.members);
|
||||
const s = await ctx.service();
|
||||
if (!s || !s.release || !s.init || !s.unit) throw Error('service state unavailable');
|
||||
if (!s.release.fetched && s.release.problem && s.release.problem !== 'proxy-install-missing') throw Error('release state unavailable');
|
||||
|
||||
@@ -544,3 +544,60 @@ test('the owner models come only from riding buses that answer a ready catalogue
|
||||
assert.deepEqual((await ownerModelsFrom({ proxy: true, riders: [rider('s', true, ready([stale])), rider('a', true, ready([row()]))] })).models, [row()]);
|
||||
assert.deepEqual((await ownerModelsFrom({ proxy: true, riders: [rider('a', true, ready([row()])), rider('s', true, ready([stale]))] })).models, [row()]);
|
||||
});
|
||||
|
||||
test('the owner catalogue answers before the first rider and stays authoritative over stale buses', async () => {
|
||||
let busReads = 0;
|
||||
const ownerCatalogue = async () => ({ status: 'ready', models: [glm] });
|
||||
const first = await ownerModelsFrom({ proxy: true, riders: [], ownerCatalogue });
|
||||
assert.equal(first.catalogue, 'ready');
|
||||
assert.deepEqual(first.models, [glm]);
|
||||
const both = await ownerModelsFrom({ proxy: true, ownerCatalogue, riders: [{ cliproxy: true, call: async () => { busReads++; return { catalogue: { status: 'ready', models: [row()] } }; } }] });
|
||||
assert.deepEqual(both.models, [glm]); assert.equal(busReads, 0);
|
||||
const empty = await ownerModelsFrom({ proxy: true, ownerCatalogue: async () => ({ status: 'ready', models: [] }) });
|
||||
assert.equal(empty.catalogue, 'ready'); assert.deepEqual(empty.models, []);
|
||||
});
|
||||
test('owner catalogue failure and timeout never fall back to a stale riding bus', { timeout: 3000 }, async t => {
|
||||
let release;
|
||||
const stalled = new Promise(resolve => { release = resolve; });
|
||||
// Even a broken deadline must release the synthetic read when the test times out.
|
||||
t.after(() => release({ status: 'unavailable' }));
|
||||
for (const read of [async () => { throw Error('/private token=secret'); }, () => stalled, async () => ({ status: 'unavailable' })]) {
|
||||
const start = Date.now();
|
||||
let busReads = 0;
|
||||
const owner = await ownerModelsFrom({ proxy: true, riders: [{ cliproxy: true, call: async () => { busReads++; return { catalogue: { status: 'ready', models: [row()] } }; } }], ownerCatalogue: read, timeoutMs: 20 });
|
||||
assert.equal(busReads, 0);
|
||||
assert.equal(owner.catalogue, 'unavailable'); assert.deepEqual(owner.models, []);
|
||||
assert.ok(Date.now() - start < 1000); assert.doesNotMatch(JSON.stringify(owner), /private|secret/);
|
||||
}
|
||||
});
|
||||
test('a first stopped fixture moves using the owner catalogue without a riding bus', async t => {
|
||||
const ownerModels = () => ownerModelsFrom({ proxy: true, riders: [], ownerCatalogue: async () => ({ status: 'ready', models: [row()] }) });
|
||||
let moved = 0;
|
||||
const f = admin(t, { riders: async () => [{ id: 'first', fixture: true, cliproxy: false, changes: '', status: async () => ({ pid: null }) }], ownerModels,
|
||||
move: async (_id, models) => { assert.deepEqual(models, [row()]); moved++; return { moved: true, model: row().key }; } });
|
||||
assert.equal((await f.admin.rideMove({ org: 'first' })).moved, true); assert.equal(moved, 1);
|
||||
});
|
||||
|
||||
|
||||
test('owner models reader without organizations never calls the owner catalogue', async () => {
|
||||
const { ownerModelsReader } = await import('../src/ride.mjs');
|
||||
let calls = 0, busReads = 0;
|
||||
const read = ownerModelsReader({ proxy: () => true, ownerProxy: { catalogue: async () => { calls++; return { status: 'ready', models: [glm] }; } },
|
||||
rideRiders: async () => [{ cliproxy: true, call: async () => { busReads++; return { catalogue: { status: 'ready', models: [row()] } }; } }] });
|
||||
const result = await read();
|
||||
assert.equal(calls, 0); assert.equal(busReads, 1);
|
||||
assert.deepEqual(result, { proxy: true, riding: true, models: [row()] });
|
||||
});
|
||||
|
||||
test('owner catalogue default bound stops waiting at exactly 5000 ms', { timeout: 3000 }, async t => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
let done = false;
|
||||
const pending = ownerModelsFrom({ proxy: true, ownerCatalogue: () => new Promise(() => {}) }).then(value => { done = true; return value; });
|
||||
t.mock.timers.tick(4999);
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
assert.equal(done, false);
|
||||
t.mock.timers.tick(1);
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
assert.equal(done, true, 'the default wait ends at 5000 ms');
|
||||
assert.deepEqual(await pending, { proxy: true, riding: false, catalogue: 'unavailable', models: [] });
|
||||
});
|
||||
@@ -3,6 +3,28 @@ import assert from 'node:assert/strict';
|
||||
import { setupState } from '../src/setup-state.mjs';
|
||||
const [service, accounts] = setupState;
|
||||
const ready = { release: { verified: true }, init: { initialized: true }, unit: { active: 'active', healthy: true, listening: true }, fence: { set: false } };
|
||||
test('model service and account checks do not apply to organizations using other model routes', async () => {
|
||||
for (const providers of [[], ['fixture']]) {
|
||||
const ctx = { members: [{ id: 'local', doc: { plugins: { 'model-provider': providers } } }],
|
||||
service: () => { throw Error('must not inspect service'); }, read: () => { throw Error('must not read accounts'); } };
|
||||
for (const row of setupState) assert.deepEqual(await row.check(ctx), { state: 'not-applicable', reason: 'Your organization answers without the model service.' });
|
||||
ctx.members.push({ ...ctx.members[0], id: 'second' });
|
||||
for (const row of setupState) assert.deepEqual(await row.check(ctx), { state: 'not-applicable', reason: 'Your organizations answer without the model service.' });
|
||||
}
|
||||
});
|
||||
for (const withProxy of [false, true]) test(`an invalid member${withProxy ? ' beside a proxy organization' : ''} cannot silently skip the model checks`, async () => {
|
||||
const ctx = { members: [{ id: 'broken', invalid: true }, ...(withProxy ? [{ id: 'proxy', doc: { plugins: { 'model-provider': ['cliproxy'] } } }] : [])],
|
||||
service: async () => ready, read: async () => { throw Error('must not hide invalid membership'); } };
|
||||
for (const row of setupState) await assert.rejects(row.check(ctx), /organization unavailable/);
|
||||
});
|
||||
test('a mixed instance still checks its model service and proxy accounts', async () => {
|
||||
const ctx = { members: [{ id: 'local', doc: { plugins: {} } }, { id: 'proxy', doc: { plugins: { 'model-provider': ['cliproxy'] } } }],
|
||||
service: async () => ready, read: async (org, name) => {
|
||||
assert.equal(org.id, 'proxy');
|
||||
return name === 'accounts' ? { accounts: [{ provider: 'claude', status: 'active' }] } : { catalogue: { status: 'ready', models: [{ upstream: 'claude', available: true }] } };
|
||||
} };
|
||||
for (const row of setupState) assert.equal((await row.check(ctx)).state, 'done');
|
||||
});
|
||||
test('service needs a verified install, active unit and answering port', async () => {
|
||||
assert.equal((await service.check({ service: async () => ready })).state, 'done');
|
||||
for (const unit of [{ active: 'inactive' }, { active: 'failed' }, { active: 'active', healthy: false }]) assert.equal((await service.check({ service: async () => ({ ...ready, unit }) })).state, 'failed');
|
||||
|
||||
@@ -60,7 +60,7 @@ function normalizeDoc(ctx, id, input, existing) {
|
||||
}
|
||||
// Presets are supplied by installed modules; reject malformed or duplicate names
|
||||
// rather than silently choosing a different module's configuration.
|
||||
async function discoverPresets() {
|
||||
async function discoverPresets(context) {
|
||||
const presets = new Map();
|
||||
for (const kind of ['harness', 'model-provider']) {
|
||||
const { modules, refused } = await loadInstalled(kind);
|
||||
@@ -68,7 +68,7 @@ async function discoverPresets() {
|
||||
for (const { module } of modules) {
|
||||
if (module.orgPresets === undefined) continue;
|
||||
if (typeof module.orgPresets !== 'function') fail('org-invalid', 'invalid preset provider');
|
||||
const list = await module.orgPresets();
|
||||
const list = await module.orgPresets(context);
|
||||
if (!Array.isArray(list)) fail('org-invalid', 'invalid preset provider');
|
||||
for (const p of list) {
|
||||
if (!p || typeof p.name !== 'string' || !/^[a-z][a-z0-9-]*$/.test(p.name) || presets.has(p.name) ||
|
||||
@@ -87,7 +87,7 @@ async function discoverPresets() {
|
||||
// {proxy, riding, models}. A preset that does not use it ignores it.
|
||||
// `fixture` (first-run-fixes-1 B2) is what the Console read of the instance's dev fixture: {ready}.
|
||||
export async function orgPresets({ env = process.env, owner, fixture } = {}) {
|
||||
const presets = await discoverPresets();
|
||||
const presets = await discoverPresets({ env, owner, fixture });
|
||||
return Promise.all([...presets.values()].map(async p => {
|
||||
const availability = await p.available({ env, owner, fixture });
|
||||
if (!availability || typeof availability.ok !== 'boolean' || (!availability.ok && (typeof availability.reason !== 'string' || !availability.reason))) fail('org-invalid', 'invalid preset availability');
|
||||
|
||||
@@ -8,25 +8,28 @@ export const setupState = Object.freeze([
|
||||
async check(ctx) {
|
||||
if (!ctx.members.length) return { state: 'next', reason: 'Create an organization first, then choose the models your agents use.' };
|
||||
const answers = await Promise.allSettled(ctx.members.map(async org => {
|
||||
const inOrg = ctx.members.length > 1 ? ` in ${org.id}` : '';
|
||||
const answer = (state, reason, fix) => ({ state, reason: inOrg ? reason.replace(/\.$/, `${inOrg}.`) : reason, ...(fix ? { fix } : {}) });
|
||||
const fix = { page: '#/settings/routing', label: 'Choose models' };
|
||||
const r = await ctx.read(org, 'routes');
|
||||
if (!r?.instances || !Array.isArray(r.harnesses) || !Array.isArray(r.models)) throw Error('routes unavailable');
|
||||
const names = ['assistant', 'chief'].map(name => Object.entries(org.doc?.roles ?? {}).find(([, role]) => role.definition === (name === 'chief' ? 'chief-of-staff' : name))?.[0] ?? name);
|
||||
const chosen = names.map(name => r.instances[name]);
|
||||
if (chosen.some(c => !c?.harness || !c.model || !r.harnesses.includes(c.harness) || !r.models.includes(c.model)))
|
||||
return { state: 'next', reason: 'Choose a model for both your assistant and your chief.', fix };
|
||||
const missing = chosen.map((c, i) => !c?.harness || !c.model || !r.harnesses.includes(c.harness) || !r.models.includes(c.model) ? ['assistant', 'chief'][i] : null).filter(Boolean);
|
||||
if (missing.length) return answer('next', `Choose a model for ${missing.length === 2 ? 'both your assistant and your chief' : `your ${missing[0]}`}.`, fix);
|
||||
const p = await ctx.read(org, 'plugins');
|
||||
if (!Array.isArray(p?.harnessWatch)) throw Error('fit unavailable');
|
||||
const fits = chosen.map(c => p.harnessWatch.find(h => h.name === c.harness));
|
||||
if (fits.some(h => ['red', 'missing'].includes(h?.state))) return { state: 'failed', reason: 'A chosen program did not pass its check. Choose models to check the program.', fix };
|
||||
if (fits.some(h => h?.state === 'unknown')) return { state: 'failed', reason: 'The program check did not finish. Choose models to try again.', fix };
|
||||
if (fits.some(h => !['fit', 'changed'].includes(h?.state) || !h?.checkedAt)) return { state: 'checking', reason: 'The chosen programs have not passed their check yet. Choose models to check them.', fix };
|
||||
return { state: 'done', reason: 'Your assistant and chief have models, and their programs passed the recorded check.' };
|
||||
if (fits.some(h => ['red', 'missing'].includes(h?.state))) return answer('failed', 'A chosen program did not pass its check. Choose models to check the program.', fix);
|
||||
if (fits.some(h => h?.state === 'unknown')) return answer('failed', 'The program check did not finish. Choose models to try again.', fix);
|
||||
if (fits.some(h => !['fit', 'changed'].includes(h?.state) || !h?.checkedAt)) return answer('checking', 'The chosen programs have not passed their check yet. Choose models to check them.', fix);
|
||||
return answer('done', 'Your assistant and chief have models, and their programs passed the recorded check.');
|
||||
}));
|
||||
const found = answers.filter(a => a.status === 'fulfilled').map(a => a.value);
|
||||
const missed = answers.length - found.length;
|
||||
const result = found.find(a => a.state === 'failed') ?? found.find(a => a.state === 'next') ?? found.find(a => a.state === 'checking') ?? found[0];
|
||||
if (!result) return { state: 'next', reason: "Your organizations couldn't be checked. Choose models to check their settings." };
|
||||
if (ctx.members.length > 1 && !missed && result.state === 'done') return { state: 'done', reason: 'Your assistant and chief have models, and their programs passed the recorded check in every organization.' };
|
||||
return { ...result, reason: result.reason + (missed ? " Some organizations couldn't be checked. Choose models to check their settings." : '') };
|
||||
},
|
||||
},
|
||||
|
||||
@@ -9,16 +9,16 @@ test('installed modules supply presets and report availability without credentia
|
||||
const claude = presets.find(p => p.name === 'claude-code');
|
||||
assert.equal(fixture.available.ok, true);
|
||||
assert.equal(claude.available.ok, false);
|
||||
assert.ok(claude.available.reason);
|
||||
assert.equal(claude.available.reason, 'Claude sign-in is not available on this Console.');
|
||||
assert.deepEqual(claude.thinking.levels, ['low', 'medium', 'high', 'xhigh', 'max']);
|
||||
});
|
||||
|
||||
// first-run-fixes-1 (B2): the Console passes what it knows of the instance's dev fixture.
|
||||
test('B2: the Test model preset reads unavailable only when the Console says the fixture is not ready', async () => {
|
||||
const fixtureOf = async fixture => (await service.orgPresets({ env: { PATH: '/usr/bin:/bin' }, fixture })).find(p => p.name === 'fixture').available;
|
||||
assert.deepEqual(await fixtureOf({ ready: false }), { ok: false, reason: 'Developer test fixture is not running.' });
|
||||
assert.deepEqual(await fixtureOf({ ready: true }), { ok: true });
|
||||
assert.deepEqual(await fixtureOf(undefined), { ok: true }, 'no word from the Console keeps it offered');
|
||||
test('the Test model preset is hidden when the Console says the fixture is not ready', async () => {
|
||||
const fixtureOf = async fixture => (await service.orgPresets({ env: { PATH: '/usr/bin:/bin' }, fixture })).find(p => p.name === 'fixture');
|
||||
assert.equal(await fixtureOf({ ready: false }), undefined);
|
||||
assert.deepEqual((await fixtureOf({ ready: true })).available, { ok: true });
|
||||
assert.deepEqual((await fixtureOf(undefined)).available, { ok: true }, 'no word from the Console keeps it offered');
|
||||
const others = async fixture => (await service.orgPresets({ env: { PATH: '/usr/bin:/bin' }, fixture })).filter(p => p.name !== 'fixture').map(p => [p.name, p.available]);
|
||||
assert.deepEqual(await others({ ready: false }), await others(undefined), 'no other preset reads the fixture');
|
||||
});
|
||||
@@ -54,10 +54,10 @@ test('the cliproxy preset is discovered and names each reason it is unavailable'
|
||||
assert.match((await cliproxyOf({ proxy: true, riding: false, models: [row()] })).available.reason, /No organization uses the model proxy yet/);
|
||||
assert.match((await cliproxyOf({ proxy: true, riding: true, models: [] })).available.reason, /lists no model you can use/);
|
||||
for (const bad of [row({ available: false }), row({ reason: 'unverified' }), row({ module: 'fixture' }), row({ harnesses: [] })])
|
||||
assert.match((await cliproxyOf({ proxy: true, riding: true, models: [bad] })).available.reason, /lists no model you can use/);
|
||||
assert.equal((await cliproxyOf({ proxy: true, riding: true, models: [bad] })).available.reason, 'Switch a model on in Model setup.');
|
||||
// first-run-fixes-1 (F5): each reason names the page as the Settings nav does.
|
||||
assert.equal(none.available.reason, 'Set up the model proxy first, on the Model setup page.');
|
||||
assert.equal((await cliproxyOf({ proxy: true, riding: false, models: [row()] })).available.reason, 'No organization uses the model proxy yet, or none answered. Use Ride all on the Model setup page.');
|
||||
assert.equal((await cliproxyOf({ proxy: true, riding: false, models: [row()] })).available.reason, 'No organization uses the model proxy yet, or none answered. Open Model setup to check it.');
|
||||
assert.equal((await cliproxyOf({ proxy: true, riding: true, models: [] })).available.reason, 'The model proxy lists no model you can use. Sign in to an account on the Model setup page.');
|
||||
const ok = await cliproxyOf({ proxy: true, riding: true, models: [row()] });
|
||||
assert.deepEqual(ok.available, { ok: true });
|
||||
@@ -86,3 +86,18 @@ test('existing presets ignore the new model and owner inputs', async () => {
|
||||
assert.equal(presets.find(p => p.name === 'fixture').available.ok, true);
|
||||
assert.equal(presets.find(p => p.name === 'claude-code').available.ok, false);
|
||||
});
|
||||
|
||||
|
||||
test('the first organization uses the owner catalogue and one plain reason for empty or failed reads', async () => {
|
||||
const owner = { proxy: true, riding: false, catalogue: 'ready', models: [row()] };
|
||||
assert.deepEqual((await cliproxyOf(owner)).available, { ok: true });
|
||||
const reason = (await cliproxyOf({ ...owner, models: [] })).available.reason;
|
||||
assert.match(reason, /account on the Model setup page/); assert.doesNotMatch(reason, /organization|Ride all/);
|
||||
const unavailable = (await cliproxyOf({ ...owner, catalogue: 'unavailable', models: [] })).available;
|
||||
assert.equal(unavailable.ok, false); assert.equal(unavailable.reason, 'Your models could not be checked. Open Model setup to try again.');
|
||||
});
|
||||
|
||||
test('a catalogue with only switched-off models names the model switch', async () => {
|
||||
assert.deepEqual((await cliproxyOf({ proxy: true, riding: false, catalogue: 'ready', models: [row({ available: false, reason: 'model-off' })] })).available,
|
||||
{ ok: false, reason: 'Switch a model on in Model setup.' });
|
||||
});
|
||||
@@ -3,12 +3,32 @@ import assert from 'node:assert/strict';
|
||||
import { setupState } from '../src/setup/setup-state.mjs';
|
||||
import { setupState as routes } from '../src/setup/setup-routing.mjs';
|
||||
const org = { id: 'team', doc: { roles: { assistant: { definition: 'assistant' }, chief: { definition: 'chief' } } } };
|
||||
test('routing identifies the missing agent and names the organization only when there are several', async () => {
|
||||
const selected = { harness: 'example', model: 'model' };
|
||||
for (const missing of ['assistant', 'chief', 'both']) for (const multiple of [false, true]) {
|
||||
const members = multiple ? [{ ...org, id: 'ready' }, { ...org, id: 'fxco' }] : [org];
|
||||
const result = await routes[0].check({ members, read: async (member, name) => name === 'plugins'
|
||||
? { harnessWatch: [{ name: 'example', state: 'fit', checkedAt: 'now' }] }
|
||||
: { harnesses: ['example'], models: ['model'], instances: member.id === 'ready' ? { assistant: selected, chief: selected }
|
||||
: Object.fromEntries(['assistant', 'chief'].filter(n => n !== missing && missing !== 'both').map(n => [n, selected])) } });
|
||||
const who = missing === 'both' ? 'both your assistant and your chief' : `your ${missing}`;
|
||||
assert.equal(result.reason, `Choose a model for ${who}${multiple ? ' in fxco' : ''}.`);
|
||||
}
|
||||
});
|
||||
test('organization readiness requires an owner organization and its bus answering', async () => {
|
||||
assert.equal((await setupState[0].check({ members: [], read: async () => {} })).state, 'next');
|
||||
for (const healthy of [true, false]) assert.equal((await setupState[0].check({ members: [org], read: async () => ({ healthy }) })).state, healthy ? 'done' : 'failed');
|
||||
const unavailable = await setupState[0].check({ members: [org], read: async () => { throw Error('private'); } });
|
||||
assert.equal(unavailable.state, 'next'); assert.match(unavailable.reason, /couldn't be checked/); assert.doesNotMatch(unavailable.reason, /private/);
|
||||
});
|
||||
test('routing confirms every organization when all their agents have models and recorded fit', async () => {
|
||||
const selected = { harness: 'example', model: 'model' };
|
||||
const result = await routes[0].check({ members: [{ ...org, id: 'alpha' }, { ...org, id: 'beta' }], read: async (_, name) => name === 'plugins'
|
||||
? { harnessWatch: [{ name: 'example', state: 'fit', checkedAt: 'now' }] }
|
||||
: { harnesses: ['example'], models: ['model'], instances: { assistant: selected, chief: selected } } });
|
||||
assert.equal(result.state, 'done');
|
||||
assert.equal(result.reason, 'Your assistant and chief have models, and their programs passed the recorded check in every organization.');
|
||||
});
|
||||
test('one answering organization completes setup while another cannot be checked', async () => {
|
||||
const result = await setupState[0].check({ members: [{ id: 'broken', invalid: true }, org], read: async member => {
|
||||
if (member.invalid) throw Error('private');
|
||||
|
||||
@@ -50,6 +50,19 @@ unknown or ambiguous legacy mapping and validates transport data before use.
|
||||
|
||||
### Organization presets
|
||||
|
||||
“Your models through the model proxy” reads the instance owner's catalogue for the signed-in
|
||||
root owner in an organization-mode Console. It can create the first organization after an
|
||||
account is connected and a usable model is offered. Availability, model choices and template
|
||||
selection use that same read; a failed read offers nothing. With models switched off, the
|
||||
preset points to the model switches in Model setup; with no model rows, it asks to sign in.
|
||||
The owner catalogue takes precedence
|
||||
over riding buses, so an old bus catalogue cannot restore an unavailable or switched-off model.
|
||||
Other Console modes keep the riding-bus reader. Quick Setup starts the normal organization bus,
|
||||
which registers with the shared model service and issues model keys on launch preflight.
|
||||
Quick Setup gives the chief the routing values the preset assistant defines (harness, model
|
||||
and thinking), without adding the chief to the launch list. Advanced Setup keeps the preset template unchanged. The routing
|
||||
checklist still requires the selected program's existing recorded check to pass.
|
||||
|
||||
A `harness` or `model-provider` module may export `orgPresets()`, returning an
|
||||
array of preset descriptions. Each has a globally unique stable `name`, a
|
||||
`label`, a one-line `description`, `thinking: { levels, default }`, an
|
||||
|
||||
@@ -92,7 +92,7 @@ export function orgPresets() {
|
||||
thinking: { levels: [...LEVELS], default: 'low' },
|
||||
available: ({ env }) => {
|
||||
const problem = preflight({ env });
|
||||
return problem ? { ok: false, reason: problem.code === 'no-session-credential' ? 'No session credential is available to the Console.' : 'Claude Code is not available to the Console.' } : { ok: true };
|
||||
return problem ? { ok: false, reason: problem.code === 'no-session-credential' ? 'Claude sign-in is not available on this Console.' : 'Claude Code is not available on this Console.' } : { ok: true };
|
||||
},
|
||||
overlay: ({ thinking }) => ({ plugins: { channel: ['cli', 'webui'], harness: ['claude-code'] },
|
||||
launch: { by: 'chief', instances: ['assistant'], models: { opus: { provider: 'anthropic', model: 'claude-opus-5-5' } } },
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Provider configuration and transport declarations owned by the proxy module.
|
||||
export const interfaceVersion = 1;
|
||||
// Whether an admitted organization needs this model service for its model routes.
|
||||
export const usesModelService = doc => (doc.plugins?.['model-provider'] ?? []).includes('cliproxy');
|
||||
export const ZAI_URL = 'https://api.z.ai/api/anthropic';
|
||||
// #1873 settings-backend-a3: the one list of providers an account can be added for. The bus proxy
|
||||
// page, the management client and the Console's provider select all read it; a provider not here
|
||||
@@ -143,23 +145,26 @@ export function route({ selection, harness }) {
|
||||
}
|
||||
|
||||
// #1873 ride-default slice 1: a new organization that uses the owner's models through the
|
||||
// instance's model proxy. The Console reads the owner's catalogue from a riding bus and passes
|
||||
// instance's model proxy. The Console reads the instance owner catalogue, or riding buses, and passes
|
||||
// it as `owner`; this module never reaches the proxy itself.
|
||||
const THINKING = Object.freeze(['low', 'medium', 'high', 'xhigh', 'max']);
|
||||
export const usableModel = m => !!m && m.module === 'cliproxy' && m.available === true && m.reason === null
|
||||
&& typeof m.key === 'string' && /^[a-z][a-z0-9-]{0,63}$/.test(m.key) && typeof m.upstream === 'string' && Object.hasOwn(ROUTES, m.upstream)
|
||||
&& typeof m.provider === 'string' && typeof m.model === 'string' && MODEL.test(m.model)
|
||||
&& Array.isArray(m.harnesses) && (m.harnesses.includes('claude-code') || m.harnesses.includes('pi'));
|
||||
export function ownerModelsAvailable(owner) {
|
||||
if (!owner || owner.proxy !== true) return { ok: false, reason: 'Set up the model proxy first, on the Model setup page.' };
|
||||
if (owner.catalogue === 'unavailable') return { ok: false, reason: 'Your models could not be checked. Open Model setup to try again.' };
|
||||
if (owner.catalogue !== 'ready' && owner.riding !== true) return { ok: false, reason: 'No organization uses the model proxy yet, or none answered. Open Model setup to check it.' };
|
||||
if (Array.isArray(owner.models) && owner.models.length && !owner.models.some(usableModel)) return { ok: false, reason: 'Switch a model on in Model setup.' };
|
||||
if (!Array.isArray(owner.models) || !owner.models.some(usableModel)) return { ok: false, reason: 'The model proxy lists no model you can use. Sign in to an account on the Model setup page.' };
|
||||
return { ok: true };
|
||||
}
|
||||
export function orgPresets() {
|
||||
return [{ name: 'cliproxy', label: 'Your models through the model proxy',
|
||||
description: 'Uses a model your model proxy lists. Each reply spends your own account.',
|
||||
thinking: { levels: [...THINKING], default: 'low' },
|
||||
available: ({ owner } = {}) => {
|
||||
if (!owner || owner.proxy !== true) return { ok: false, reason: 'Set up the model proxy first, on the Model setup page.' };
|
||||
if (owner.riding !== true) return { ok: false, reason: 'No organization uses the model proxy yet, or none answered. Use Ride all on the Model setup page.' };
|
||||
if (!Array.isArray(owner.models) || !owner.models.some(usableModel)) return { ok: false, reason: 'The model proxy lists no model you can use. Sign in to an account on the Model setup page.' };
|
||||
return { ok: true };
|
||||
},
|
||||
available: ({ owner } = {}) => ownerModelsAvailable(owner),
|
||||
overlay: ({ thinking, model }) => {
|
||||
if (!usableModel(model)) throw Object.assign(Error('the model proxy lists no such model'), { code: 'org-invalid' });
|
||||
const harness = model.harnesses.includes('claude-code') ? 'claude-code' : 'pi';
|
||||
|
||||
@@ -19,11 +19,12 @@ export const FIXTURE_TEMPLATE = Object.freeze({
|
||||
// Organization setup is supplied by this module, alongside its model route.
|
||||
// first-run-fixes-1 (B2): `fixture` is what the Console knows of the instance's dev fixture
|
||||
// ({ ready }). A chat on this preset has no endpoint to answer it until `mosaic dev fixture init`
|
||||
// runs, so the preset reads unavailable when the Console says it is not ready. With no word from
|
||||
// runs, so the preset is hidden when the Console says it is not ready. With no word from
|
||||
// the Console (a caller that does not read the fixture) it stays offered.
|
||||
// first-run-fixes-1 follow-up: the Console never tells an owner to run a command, so the reason is a plain line.
|
||||
export const FIXTURE_NOT_READY = 'Developer test fixture is not running.';
|
||||
export function orgPresets() {
|
||||
export function orgPresets({ fixture } = {}) {
|
||||
if (fixture?.ready === false) return [];
|
||||
return [{ name: 'fixture', label: 'Test model', description: 'Canned replies, no cost.',
|
||||
thinking: { levels: ['off'], default: 'off' },
|
||||
available: ({ fixture } = {}) => (fixture?.ready === false ? { ok: false, reason: FIXTURE_NOT_READY } : { ok: true }),
|
||||
|
||||
@@ -17,7 +17,9 @@ export const setupState = Object.freeze([
|
||||
purpose: 'Lets agents run code in a container on this computer. Not needed to start. Needs Docker.',
|
||||
fix: null, order: { after: [] }, required: false,
|
||||
async check(ctx) {
|
||||
const [service, account, docker] = await Promise.allSettled([modelSetupState[0].check(ctx), accountState(ctx), (ctx.docker ?? (() => dockerAnswers({ signal: ctx.signal })))()]);
|
||||
// Workers need the instance model service even when organizations answer another way.
|
||||
const instance = { ...ctx, members: [] };
|
||||
const [service, account, docker] = await Promise.allSettled([modelSetupState[0].check(instance), accountState(ctx.accounts ? instance : ctx), (ctx.docker ?? (() => dockerAnswers({ signal: ctx.signal })))()]);
|
||||
const ready = service.status === 'fulfilled' && service.value?.state === 'done';
|
||||
const connected = account.status === 'fulfilled' ? account.value.state === 'done' ? 'connected' : 'not ready' : 'not checked';
|
||||
const model = typeof ctx.system?.execution?.model === 'string' && !!ctx.system.execution.model.trim();
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { setupState, dockerAnswers } from '../src/setup-state.mjs';
|
||||
test('workers still inspect the instance service and account when organizations answer without them', async () => {
|
||||
for (const providers of [[], ['fixture']]) {
|
||||
let accountReads = 0;
|
||||
const ctx = { members: [{ id: 'local', doc: { plugins: { 'model-provider': providers } } }],
|
||||
service: async () => ({ release: { verified: true }, init: { initialized: true }, unit: { active: 'active', healthy: true, listening: true } }),
|
||||
accounts: async () => { accountReads++; return { accounts: [{ provider: 'claude', status: 'active' }], catalogue: { status: 'ready', models: [{ upstream: 'claude', available: true }] } }; },
|
||||
read: () => { throw Error('must use the instance account read'); }, docker: async () => false, runs: () => [] };
|
||||
const row = await setupState[0].check(ctx);
|
||||
assert.match(row.reason, /Model service: ready; Account: connected/);
|
||||
assert.equal(accountReads, 1);
|
||||
const missing = await setupState[0].check({ ...ctx, accounts: async () => ({ accounts: [], catalogue: { status: 'ready', models: [] } }) });
|
||||
assert.match(missing.reason, /Model service: ready; Account: not ready/);
|
||||
}
|
||||
});
|
||||
test('worker readiness is optional and names the requirements actually ready', async () => {
|
||||
const ctx = { system: { execution: { model: 'chosen' } }, members: [], dataRoot: '/unused', service: async () => ({ release: { verified: true }, init: { initialized: true }, unit: { active: 'active', healthy: true, listening: true } }), docker: async () => false, runs: () => [] };
|
||||
const row = await setupState[0].check(ctx);
|
||||
|
||||
@@ -22,7 +22,7 @@ import { listOrgs, resolveOrg } from '../../organization/src/org-registry.mjs';
|
||||
import { showOrg } from '../../organization/src/org-service.mjs';
|
||||
import * as orgService from '../../organization/src/org-service.mjs';
|
||||
import { orgUsesFixture } from '../../cli/src/dev-fixture.mjs';
|
||||
import { moveFixtureOrg, ownerModelsFrom, readRider } from '../../model-proxy/src/ride.mjs';
|
||||
import { moveFixtureOrg, ownerModelsReader, readRider } from '../../model-proxy/src/ride.mjs';
|
||||
import { ownedText } from '../../model-proxy/src/admin.mjs';
|
||||
import { configDir } from '../../organization/src/organization-config.mjs';
|
||||
import { loadRootAgents } from '../../organization/src/agent-levels.mjs';
|
||||
@@ -248,12 +248,12 @@ try {
|
||||
}
|
||||
return out;
|
||||
};
|
||||
// The owner's models (ride.mjs ownerModelsFrom): the proxy is set up when proxy.json names a port.
|
||||
const ownerModels = system && (devOwner || ssoOn) ? async () => {
|
||||
let proxy = false;
|
||||
try { proxy = Number.isInteger(loadProxy(configDir(), system.dataRoot)?.port); } catch {}
|
||||
return ownerModelsFrom({ proxy, riders: proxy ? await rideRiders() : [] });
|
||||
} : null;
|
||||
const ownerProxy = system && (devOwner || ssoOn) ? createOwnerProxy({ dataRoot: system.dataRoot, configDir: configDir() }) : null;
|
||||
// The proxy is set up when proxy.json names a port; organization mode uses the owner catalogue.
|
||||
const ownerModels = system && (devOwner || ssoOn) ? ownerModelsReader({
|
||||
proxy: () => Number.isInteger(loadProxy(configDir(), system.dataRoot)?.port),
|
||||
organizations, ownerProxy, rideRiders,
|
||||
}) : null;
|
||||
// Each active organization's bus `routes` catalogue, every one asked at once, so a hung bus costs
|
||||
// one timeout, not one each. A bus that does not answer gives a catalogue that is not ready, so it
|
||||
// confirms nothing. Triage's route checks and the Worker model card read the same list.
|
||||
@@ -267,7 +267,7 @@ try {
|
||||
}));
|
||||
};
|
||||
const proxyAdmin = system && (devOwner || ssoOn) ? createProxyAdmin({
|
||||
ownerProxy: createOwnerProxy({ dataRoot: system.dataRoot, configDir: configDir() }),
|
||||
ownerProxy,
|
||||
dataRoot: system.dataRoot, configDir: configDir(), instance, unitDir: options.proxyUnitDir ?? null,
|
||||
buses: () => busesStopped({ dataRoot: system.dataRoot, configDir: configDir() }),
|
||||
orgs: async () => {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
// handler returns false for them.
|
||||
|
||||
import { open } from 'node:fs/promises';
|
||||
import { pickModel, usableModel } from '../../model-proxy/src/ride.mjs';
|
||||
import { pickModel, usableModel, ownerModelsAvailable } from '../../model-proxy/src/ride.mjs';
|
||||
import { lstatSync, readFileSync } from 'node:fs';
|
||||
import { checkProject, initProject, projectRepo, recordContext } from '../../project/src/index.mjs';
|
||||
import { refuseInsideAgent } from '../../cli/src/transport.mjs';
|
||||
@@ -342,7 +342,8 @@ export function fixtureState(context) {
|
||||
// `service`, `registry` and `bus` are module objects or functions returning
|
||||
// them (or null when absent). `context()` gives { configDir, dataRoot, instance }.
|
||||
// `ownerModels()` (#1873 ride-default) answers {proxy, riding, models} from the owner's model
|
||||
// proxy, read through the riding buses; without it the cliproxy preset reads unavailable.
|
||||
// proxy: the root owner in organization mode reads the owner catalogue; other callers read
|
||||
// riding buses. An optional `catalogue` names owner read readiness. No read writes setup state.
|
||||
// `rideRemoved(id)` records in the proxy's receipts that a save took cliproxy off the organization,
|
||||
// so Ride all leaves it off; without it such a save is refused.
|
||||
// `devFixture()` (first-run-fixes-1 B2) answers {ready} for the instance's dev fixture; without it
|
||||
@@ -457,7 +458,16 @@ async function route(req, res, { path, search, org, admin, principal, write, log
|
||||
if (path === '/api/org-presets' && !write) {
|
||||
if (new URLSearchParams(search).size) return json(res, 422, { error: 'invalid', message: 'unexpected query parameter' });
|
||||
const service = await need(admin, 'service', res, 'presets'); if (!service) return;
|
||||
try { return json(res, 200, { presets: await service.orgPresets({ owner: await ownerOf(admin), fixture: await fixtureOf(admin) }) }); }
|
||||
try {
|
||||
const owner = await ownerOf(admin);
|
||||
const presets = await service.orgPresets({ owner, fixture: await fixtureOf(admin) });
|
||||
// One read supplies availability and the choices. Put the existing default first.
|
||||
const models = ownerModelsAvailable(owner).ok ? owner.models.filter(usableModel) : [];
|
||||
const chosen = pickModel(models);
|
||||
return json(res, 200, { presets: presets.map(p => p.name === 'cliproxy' && chosen ? { ...p,
|
||||
models: [chosen, ...models.filter(m => m.key !== chosen.key)].map(m => ({ key: m.key, label: m.label || m.model })),
|
||||
} : p) });
|
||||
}
|
||||
catch (e) { return refusal(res, e, { step: 'presets' }); }
|
||||
}
|
||||
if (path === '/api/org-template' && !write) {
|
||||
@@ -472,7 +482,7 @@ async function route(req, res, { path, search, org, admin, principal, write, log
|
||||
let model;
|
||||
if (params.get('preset') === 'cliproxy') {
|
||||
const owner = await ownerOf(admin), models = Array.isArray(owner?.models) ? owner.models : [];
|
||||
model = params.has('model') ? models.find(m => usableModel(m) && m.key === params.get('model')) : (owner?.proxy === true && owner?.riding === true ? pickModel(models) : null);
|
||||
model = !ownerModelsAvailable(owner).ok ? null : params.has('model') ? models.find(m => usableModel(m) && m.key === params.get('model')) : pickModel(models);
|
||||
if (!model) return json(res, 422, { error: 'invalid', step: 'template', errors: [{ path: '$.model', field: 'model', message: params.has('model') ? 'the model proxy lists no such model' : 'the model proxy lists no model you can use' }] });
|
||||
}
|
||||
let doc;
|
||||
|
||||
@@ -165,6 +165,8 @@
|
||||
document.dispatchEvent(new CustomEvent('mosaic-theme-change', {detail: {palette: current.theme, mode: current.mode, stored: true, warning: null, picked: current.theme}}));
|
||||
// The open organization's saved appearance, read again when another organization opens (#1873 SP1).
|
||||
const readBusiness = async () => {
|
||||
await window.MosaicOrg?.ready;
|
||||
if (document.documentElement.hasAttribute('data-organizations') && !window.MosaicOrg?.id) return;
|
||||
try {
|
||||
const { ok, body } = await getJSON('/api/business');
|
||||
if (ok && orgId(body?.business?.id)) return window.MosaicAppearance.organization(body.business.id, body.business.appearance, body.business.id);
|
||||
@@ -505,6 +507,8 @@
|
||||
// good load, from the status `mosaic bus start` left. textContent only. Nothing here retries.
|
||||
async function busDown() {
|
||||
const box = $('bus-down');
|
||||
await window.MosaicOrg?.ready;
|
||||
if (document.documentElement.hasAttribute('data-organizations') && !window.MosaicOrg?.id) { box.hidden = true; return; }
|
||||
// E2E5 review P2: the organization list is read first and on its own, so a failed bus-status read
|
||||
// (likely when the bus is down) still refreshes the list, its banner and the Settings Start control.
|
||||
// #1873 SP1: the dashboard lists every organization's bus on its own rows; this banner is an organization page's.
|
||||
@@ -664,5 +668,5 @@
|
||||
setTimeout(() => { const a = document.activeElement; if (!a || a === document.body || a.disabled || !a.getClientRects().length) line.focus(); });
|
||||
});
|
||||
// Sign out (sage-1347, F7): a plain same-origin form POST to /auth/logout, shown only under --sso.
|
||||
api('/api/config').then(config => { board = config.board || 'unknown'; $('board-url').textContent = config.board ? `Board: ${board}` : 'No board'; window.MosaicFederation?.render(config.federation, $('federation')); if (config.sso === true) { sso = true; $('sign-out').hidden = out(); $('local-sign-out').hidden = true; $('avatar-name').textContent = 'Operator'; $('avatar-button').querySelector('.avatar-initial').textContent = 'O'; } }).catch(err => { if (machine) error(err); }).finally(refresh);
|
||||
api('/api/config').then(config => { board = config.board || 'unknown'; $('board-url').hidden = document.documentElement.hasAttribute('data-organizations'); $('board-url').textContent = $('board-url').hidden ? '' : config.board ? `Board: ${board}` : 'No board'; window.MosaicFederation?.render(config.federation, $('federation')); if (config.sso === true) { sso = true; $('sign-out').hidden = out(); $('local-sign-out').hidden = true; $('avatar-name').textContent = 'Operator'; $('avatar-button').querySelector('.avatar-initial').textContent = 'O'; } }).catch(err => { if (machine) error(err); }).finally(refresh);
|
||||
})();
|
||||
@@ -1582,7 +1582,7 @@
|
||||
const picker = org && rows.length ? `<div class="settings-group org-pick"><label for="org-pick">This organization</label><select id="org-pick">${rows.map(r => `<option value="${txt(r.id)}"${r.id === orgId ? ' selected' : ''}>${txt(r.label)}</option>`).join('')}</select></div>` : `<div class="settings-group">${org ? 'This organization' : 'This business'}</div>`;
|
||||
const links = isTester ? group('Settings', ['appearance','business','routing','agents','names'])
|
||||
: group('You', ['appearance']) + group('Your models', ['model-setup', ...(triageOwner ? ['triage'] : [])]) + group(org ? 'All organizations' : 'This instance', ['organizations','console','about'])
|
||||
+ picker + ['routing','agents','limits','tokens','assistant','business'].map(a).join('');
|
||||
+ (document.documentElement.hasAttribute('data-organizations') && !orgId ? '' : picker + ['routing','agents','limits','tokens','assistant','business'].map(a).join(''));
|
||||
const where = orgName && scoped(page) ? `${txt(orgName)} · ` : '';
|
||||
const title = org && page === 'routing' && orgName ? `${txt(orgName)}'s models` : label;
|
||||
return `${head('Settings','Your models, your organizations and this browser.')}<div class="settings-layout"><div><button type="button" id="settings-disclosure" aria-expanded="false" aria-controls="settings-nav"><small>Section</small><strong>${where}${label}${isDirty(page)?dot:''}</strong><span aria-hidden="true">⌄</span></button><nav id="settings-nav" aria-label="Settings sections">${links}</nav></div><div class="settings-content settings-${page}${readonlyPage(page)?' readonly':''}"><h2 id="settings-page-title" tabindex="-1">${title}</h2><p class="settings-helper">${helper}</p>${readonlyPage(page)?'<p class="settings-readonly">Read only. Saving requires signed-in send mode.</p>':''}${body}</div></div>`;
|
||||
@@ -1590,7 +1590,7 @@
|
||||
async function settingsView(get, page='appearance') {
|
||||
if (page==='business') return businessView(get);
|
||||
if (page==='appearance') return settingsShell(page,appearance(),'These choices apply in this browser only.');
|
||||
if (page==='organizations') { await configRead; return settingsShell(page,window.MosaicOrgCreate.markup,'Create an organization from the template, edit it, and finish its setup. Each step names the command it equals.'); }
|
||||
if (page==='organizations') { await configRead; return settingsShell(page,window.MosaicOrgCreate.markup,'Choose who answers, then create your organization and finish setting it up.'); }
|
||||
if (page==='model-setup') { await configRead; return settingsShell(page,window.MosaicProxy.markup,'Your model service, your accounts and the models they offer. Every organization uses them, including organizations you add later, unless it sets up its own.'); }
|
||||
// #1873 triage-settings: Settings > Triage (triage-settings.js), the instance owner's only; anyone else gets no page.
|
||||
if (page==='triage') { await configRead; if (!triageOwner || !window.MosaicTriageRoute) return notFound(); return settingsShell(page,await window.MosaicTriageRoute.section(),'The model Triage uses, what runs it, and its daily token limit. Only the instance owner sees this page.'); }
|
||||
|
||||
@@ -1172,7 +1172,7 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
// until the chain starts, which clears them before any request is answered.
|
||||
const setup = (() => {
|
||||
const form = $('proxy-setup-init');
|
||||
let state = null, timer = null, enabled = false, sendOk = false, seenFetch = null, loading = false;
|
||||
let state = null, timer = null, enabled = false, sendOk = false, organizationMode = false, seenFetch = null, loading = false;
|
||||
// #1873 settings slice 1 (D1): the steps after "accounts" come from what this page reads itself:
|
||||
// the account count (refresh), the organizations in the status, and the Triage route.
|
||||
let accountCount = null, triageSet = null;
|
||||
@@ -1594,7 +1594,7 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
// Why the list is not known: no organization to ask, the model service off in each one, or
|
||||
// a list that could not be read (a bus or the proxy down).
|
||||
const unread = v.catalogue === 'none' ? 'No organization is active' : v.catalogue === 'disabled' ? 'No organization has the model service on' : 'No organization\'s model list could be read';
|
||||
how.textContent = v.canSave === true ? '' : 'Choosing the worker model on this page is not built yet. To change it, edit execution.provider and execution.model in the config.';
|
||||
how.textContent = v.canSave === true ? '' : 'Choosing the model for background work on this page is not available yet. Ask the person who manages this installation to change it.';
|
||||
list.replaceChildren(...(Array.isArray(v.models) && v.models.length
|
||||
? v.models.map(m => { const li = el('li'); li.append(el('strong', id(m.provider, m.model))); if (m.label && m.label !== id(m.provider, m.model)) li.append(' ', el('span', m.label, 'small muted')); return li; })
|
||||
: [el('li', !v.takesModel ? 'None. This adapter takes no model.' : v.catalogue === 'ready' ? `None. No account serves a model for ${harness} that is switched on and is not a Claude model.` : `Not known. ${unread}.`, 'muted')]));
|
||||
@@ -1603,30 +1603,30 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
setCard('worker', 'done', 'Worker runs use the mock adapter, which takes no model.'); return;
|
||||
}
|
||||
if (!v.using) {
|
||||
using.textContent = 'No worker model is set.'; standing.textContent = 'Worker runs refuse to start until execution.provider and execution.model are set in the config.';
|
||||
setCard('worker', 'bad', 'No worker model is set. Set execution.provider and execution.model in the config.'); return;
|
||||
using.textContent = 'No worker model is set.'; standing.textContent = 'Background work cannot start until the person who manages this installation chooses a model.';
|
||||
setCard('worker', 'bad', 'No model is set for background work. Ask the person who manages this installation to choose one.'); return;
|
||||
}
|
||||
const name = id(v.using.provider, v.using.model);
|
||||
using.replaceChildren(...(v.using.from === 'config'
|
||||
? ['Worker runs use ', el('strong', name), '. The config names it (execution.provider and execution.model), and the config always wins.']
|
||||
: ['Worker runs use ', el('strong', name), ', the choice saved for Model setup, because the config names no worker model.']));
|
||||
? ['Worker runs use ', el('strong', name), '. It is set for this installation and takes priority over a choice saved here.']
|
||||
: ['Worker runs use ', el('strong', name), ', the choice saved here. No model is set for background work in this installation.']));
|
||||
// [card kind, the card's one line after the name, the line in the body]
|
||||
const STANDING = {
|
||||
usable: ['done', '', `An account serves it for ${harness}, and it is switched on.`],
|
||||
off: ['bad', 'It is switched off.', 'It is switched off, so worker runs refuse to start. Switch it on under Accounts and models, Models offered, or name another model in the config.'],
|
||||
off: ['bad', 'It is switched off.', 'It is switched off, so background work cannot start. Switch it on under Accounts and models, Models offered, or ask the person who manages this installation to choose another model.'],
|
||||
'not-served': ['bad', `No account serves it for ${harness}.`, `No account serves it for ${harness} now, so worker runs refuse to start.`],
|
||||
'claude-model': ['bad', 'It is a Claude model.', 'It is a Claude model. Claude models run only in the Claude harness, so worker runs refuse to start.'],
|
||||
unknown: ['off', 'Whether it can run is not known.', `${unread}, so whether it can run now is not known.`],
|
||||
unset: ['bad', 'The config names only half of it.', 'The config names only one of execution.provider and execution.model, so worker runs cannot start.'],
|
||||
unset: ['bad', 'The model choice is incomplete.', 'The model choice is incomplete, so background work cannot start. Ask the person who manages this installation to finish choosing a model.'],
|
||||
};
|
||||
const [kind, short, line] = STANDING[v.using.standing] ?? ['off', 'Whether it can run is not known.', 'Whether it can run now is not known.'];
|
||||
standing.textContent = line;
|
||||
if (v.choice?.state === 'set' && v.using.from === 'config') {
|
||||
choice.hidden = false;
|
||||
choice.textContent = `A choice saved earlier (${id(v.choice.provider, v.choice.model)}) has no effect while the config names a worker model.`;
|
||||
choice.textContent = `A choice saved earlier (${id(v.choice.provider, v.choice.model)}) has no effect while this installation has its own model set for background work.`;
|
||||
} else if (v.choice?.state === 'unreadable') {
|
||||
choice.hidden = false;
|
||||
choice.textContent = v.using.from === 'config' ? 'A choice saved earlier cannot be read. It has no effect while the config names a worker model.' : 'A choice saved earlier cannot be read.';
|
||||
choice.textContent = v.using.from === 'config' ? 'A choice saved earlier cannot be read. It has no effect while this installation has its own model set for background work.' : 'A choice saved earlier cannot be read.';
|
||||
}
|
||||
setCard('worker', kind, short ? `Worker runs use ${name}. ${short}` : `Worker runs use ${name}.`, kind === 'off' ? { badge: ['badge-muted', 'Unknown'] } : {});
|
||||
}
|
||||
@@ -1906,7 +1906,9 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
'not-available': 'Moving is not available on this Console.',
|
||||
fixture: 'It uses stand-in models.',
|
||||
};
|
||||
const rideReason = code => RIDE_REASONS[code] ?? `The change was refused (${code}).`;
|
||||
const rideReason = code => code === 'no-riding-bus' && organizationMode
|
||||
? 'Your models could not be checked. Open Model setup to try again.'
|
||||
: RIDE_REASONS[code] ?? `The change was refused (${code}).`;
|
||||
let rideResult = null;
|
||||
const rideSkips = () => rideResult?.skipped ?? (Array.isArray(state?.ride) ? state.ride : []).filter(r => !['ready', 'already', 'fixture'].includes(r.state)).map(r => ({ id: r.id, reason: r.state }));
|
||||
// What the Ride all box lists that still needs a step: organizations that can ride, skipped ones and
|
||||
@@ -2057,7 +2059,7 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
});
|
||||
root.querySelectorAll('[data-unit]').forEach(button => button.addEventListener('click', () => { if (!button.disabled) unitAction(button.dataset.unit); }));
|
||||
return {
|
||||
start(config) { enabled = true; sendOk = config.proxyAdminSend === true; return load(); },
|
||||
start(config) { enabled = true; organizationMode = Object.hasOwn(config, 'orgSetup'); sendOk = config.proxyAdminSend === true; return load(); },
|
||||
accounts(n) { accountCount = n; if (state) { paintService(); paintRestart(); paintOrgsCard(); paintTriageCard(); } },
|
||||
// A sign-in, a key or a restart can change the next step: read the whole status again.
|
||||
async reread(options) { if (!enabled) return; triageSet = null; await load(options); },
|
||||
|
||||
@@ -7,9 +7,24 @@
|
||||
// E2E6 minor: a command shown as "Same as" wraps between words, never inside a flag such as
|
||||
// --if-revision. Each word is an inline-block; one longer than the line still breaks inside itself.
|
||||
const cmd = v => `<code>${String(v ?? '').split(' ').map(w => `<span class="cmd-word">${txt(w)}</span>`).join(' ')}</code>`;
|
||||
const commandLine = v => `<details class="org-verb"><summary>Command line</summary>${cmd(v)}</details>`;
|
||||
// #1873 P1-6: the remote check a repository receipt records, in one plain line.
|
||||
const CHECKED = { reachable: 'reachable', 'needs-credential': 'needs a credential', unreachable: 'unreachable' };
|
||||
const checkLine = r => `Remote check: ${CHECKED[r.check.result] ?? 'unknown'}, ${r.check.message}. Origin: ${r.origin ?? 'none'}.`;
|
||||
// Quick Setup fills both routes from the selected preset. The advanced template and
|
||||
// launch list stay unchanged; only the three routing values cross between the roles.
|
||||
function quickDocument(doc) {
|
||||
const next = structuredClone(doc), roles = Object.values(next.roles || {});
|
||||
const assistant = roles.find(role => role.definition === 'assistant');
|
||||
const chief = roles.find(role => role.definition === 'chief-of-staff');
|
||||
if (assistant?.vars && chief) {
|
||||
chief.vars = { ...chief.vars };
|
||||
for (const key of ['harness', 'model', 'thinking']) {
|
||||
if (assistant.vars[key] !== undefined) chief.vars[key] = assistant.vars[key];
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}
|
||||
const ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
|
||||
const markup = `<div id="org-admin" class="org-admin">
|
||||
<section class="panel" aria-labelledby="org-start-title" id="org-start">
|
||||
@@ -34,7 +49,8 @@
|
||||
<section id="org-paths" class="panel" hidden aria-labelledby="org-paths-title">
|
||||
<h3 id="org-paths-title">Choose how to set up</h3>
|
||||
<p id="org-preset-none" class="org-help" hidden><span id="org-preset-none-text">Connect a model account first. Agents need one to answer.</span> <a href="#/settings/model-setup">Open Model setup</a></p>
|
||||
<div class="org-field"><label for="org-preset">Who answers?</label><select id="org-preset"></select><span class="org-help" id="org-preset-help"></span></div>
|
||||
<div class="org-field"><label for="org-preset">Who answers?</label><select id="org-preset" aria-describedby="org-preset-help org-preset-unavailable"></select><span class="org-help" id="org-preset-help"></span><span class="org-help" id="org-preset-unavailable"></span></div>
|
||||
<div class="org-field" id="org-model-field" hidden><label for="org-model">Model</label><select id="org-model"></select></div>
|
||||
<div class="org-field"><label for="org-thinking">How much thinking?</label><select id="org-thinking"></select></div>
|
||||
<div class="settings-actions org-path-actions"><button type="button" id="org-quick-open">Quick Setup</button><button type="button" class="org-secondary" id="org-advanced-open">Advanced Setup</button></div>
|
||||
</section>
|
||||
@@ -49,7 +65,7 @@
|
||||
<div class="settings-actions"><button type="button" class="org-primary" id="org-quick-interview" hidden>Start onboarding interview</button><button type="button" class="org-secondary" id="org-quick-open-org" hidden>Open organization</button></div>
|
||||
</section>
|
||||
<section id="org-editor" class="org-editor" hidden aria-labelledby="org-editor-title">
|
||||
<div class="org-editor-head"><h3 id="org-editor-title">New organization</h3><p id="org-editor-verb" class="org-verb"></p></div>
|
||||
<div class="org-editor-head"><h3 id="org-editor-title">New organization</h3><div id="org-editor-verb" class="org-verb"></div></div>
|
||||
<div id="org-errors" class="org-errors" hidden tabindex="-1" aria-labelledby="org-errors-title"><h4 id="org-errors-title">Fix these fields</h4><ul></ul></div>
|
||||
<div class="org-columns">
|
||||
<form id="org-form" class="panel org-form" novalidate aria-label="Organization fields"></form>
|
||||
@@ -67,7 +83,7 @@
|
||||
<section id="org-receipt" class="panel org-receipt" hidden aria-labelledby="org-receipt-title"></section>
|
||||
<section id="org-setup" class="org-setup" hidden aria-labelledby="org-setup-title">
|
||||
<h3 id="org-setup-title">Guided setup</h3>
|
||||
<p class="org-help">Each step shows the command it equals and the receipt it left. A step whose outcome is unknown stays incomplete until it is read back.</p>
|
||||
<p class="org-help">Follow each step to finish setting up your organization. If a result is unknown, check it before trying again.</p>
|
||||
<ol id="org-steps" class="org-steps"></ol>
|
||||
</section>
|
||||
<section id="org-archive" class="panel" hidden aria-labelledby="org-archive-title">
|
||||
@@ -259,7 +275,7 @@
|
||||
$('org-archive').hidden = mode !== 'edit' || state !== 'active'; $('org-archived').hidden = mode !== 'edit' || state !== 'archived';
|
||||
$('org-restore-verb').textContent = state === 'archived' ? `Same as mosaic org restore ${id} --if-revision ${revision}` : '';
|
||||
$('org-editor-title').textContent = mode === 'create' ? `New organization: ${id}` : `Organization: ${id}`;
|
||||
$('org-editor-verb').innerHTML = verb ? `Same as ${cmd(verb)}` : '';
|
||||
$('org-editor-verb').innerHTML = verb ? commandLine(verb) : '';
|
||||
$('org-save').textContent = mode === 'create' ? 'Save organization' : 'Save changes';
|
||||
$('org-errors').hidden = true;
|
||||
renderForm(); renderJSON(true);
|
||||
@@ -272,14 +288,14 @@
|
||||
const input = $('org-new-id'), id = input.value.trim();
|
||||
if (!ID.test(id)) { input.setAttribute('aria-invalid', 'true'); $('org-new-id-help').textContent = 'Organization ID: use 1-64 lowercase letters, digits, dot, dash or underscore, starting with a letter or digit.'; $('org-new-id-help').classList.add('org-field-err'); input.focus(); status('Organization ID is not valid.'); return; }
|
||||
input.removeAttribute('aria-invalid'); $('org-new-id-help').classList.remove('org-field-err'); $('org-new-id-help').textContent = 'Lowercase letters, digits, dot, dash or underscore.';
|
||||
// A new draft's own read outdates any refresh still in flight for the earlier draft.
|
||||
// A new draft reuses the pending read and outdates the earlier draft's rendering.
|
||||
++presetRead;
|
||||
const r = await api('GET', '/api/org-presets');
|
||||
const r = await readPresets();
|
||||
if (!alive) return;
|
||||
if (r.status !== 200) { banner(r.body.message || `Presets could not be read (${r.body.error || r.status}).`); return; }
|
||||
st.id = id; st.mode = 'create'; editorDirty = true;
|
||||
// A new draft starts with fresh controls; an earlier run locked them only for its own draft.
|
||||
$('org-preset').disabled = false; $('org-thinking').disabled = false; $('org-quick-run').disabled = !canWrite; $('org-risk-accept').checked = false; riskError('');
|
||||
$('org-preset').disabled = false; $('org-model').disabled = false; $('org-thinking').disabled = false; $('org-quick-run').disabled = !canWrite; $('org-risk-accept').checked = false; riskError('');
|
||||
renderPresets(r.body.presets, '');
|
||||
$('org-paths').hidden = false; $('org-quick').hidden = true; $('org-editor').hidden = true; $('org-receipt').hidden = true; $('org-setup').hidden = true; $('org-delete').hidden = true; $('org-delete-success').hidden = true; $('org-archive').hidden = true; $('org-archived').hidden = true; resetArchive();
|
||||
$('org-quick-steps').innerHTML = ''; $('org-quick-open-org').hidden = true; $('org-quick-interview').hidden = true; quickDone = null; banner(''); setQuery(null);
|
||||
@@ -288,7 +304,8 @@
|
||||
// first-run-fixes-1 follow-up: keep `keep` selected while it is still available, else take the first available.
|
||||
function renderPresets(list, keep) {
|
||||
presets = list;
|
||||
$('org-preset').innerHTML = presets.map(p => `<option value="${txt(p.name)}"${p.available.ok ? '' : ' disabled'}>${txt(p.label)}${p.available.ok ? '' : ` — ${txt(p.available.reason)}`}</option>`).join('');
|
||||
$('org-preset').innerHTML = presets.map(p => `<option value="${txt(p.name)}"${p.available.ok ? '' : ' disabled'}>${txt(p.label)}</option>`).join('');
|
||||
$('org-preset-unavailable').textContent = presets.filter(p => !p.available.ok).map(p => `${p.label}: ${p.available.reason}`).join(' ');
|
||||
$('org-preset').value = presets.find(p => p.available.ok && p.name === keep)?.name || presets.find(p => p.available.ok)?.name || '';
|
||||
updatePreset();
|
||||
}
|
||||
@@ -296,12 +313,17 @@
|
||||
// the select's focus or when the page shows again. Only an open, unlocked new draft re-reads;
|
||||
// a failed read keeps the list, and only the newest read is used. A choice that is no longer
|
||||
// available is replaced, and the banner says so.
|
||||
let presetRead = 0;
|
||||
let presetRead = 0, pendingPresets = null;
|
||||
// Share the request across drafts and focus events while it is still in flight.
|
||||
function readPresets() {
|
||||
if (!pendingPresets) pendingPresets = api('GET', '/api/org-presets').finally(() => { pendingPresets = null; });
|
||||
return pendingPresets;
|
||||
}
|
||||
const presetsOpen = () => alive && st.mode === 'create' && !$('org-paths').hidden && !$('org-preset').disabled;
|
||||
async function refreshPresets() {
|
||||
if (!presetsOpen()) return;
|
||||
if (!presetsOpen() || pendingPresets) return;
|
||||
const n = ++presetRead;
|
||||
let r; try { r = await api('GET', '/api/org-presets'); } catch { return; }
|
||||
let r; try { r = await readPresets(); } catch { return; }
|
||||
if (n !== presetRead || !presetsOpen() || r.status !== 200 || !Array.isArray(r.body?.presets)) return;
|
||||
if (JSON.stringify(r.body.presets) === JSON.stringify(presets)) return;
|
||||
const keep = $('org-preset').value, was = presets.find(p => p.name === keep)?.label;
|
||||
@@ -319,6 +341,10 @@
|
||||
const none = !presets.some(v => v.available.ok);
|
||||
$('org-preset-none').hidden = !none;
|
||||
$('org-preset-help').textContent = p?.description || '';
|
||||
const previous = $('org-model').value, models = p?.models || [];
|
||||
$('org-model-field').hidden = !models.length;
|
||||
$('org-model').innerHTML = models.map(m => `<option value="${txt(m.key)}">${txt(m.label)}</option>`).join('');
|
||||
if (models.some(m => m.key === previous)) $('org-model').value = previous;
|
||||
$('org-thinking').innerHTML = (p?.thinking.levels || []).map(v => `<option value="${txt(v)}"${v === p.thinking.default ? ' selected' : ''}>${txt(v)}</option>`).join('');
|
||||
$('org-quick-open').disabled = !p || !canWrite; $('org-advanced-open').disabled = !p || !canWrite;
|
||||
// A run locks the select along with the button; only an unlocked draft changes the button here.
|
||||
@@ -329,6 +355,7 @@
|
||||
}
|
||||
async function selectedTemplate() {
|
||||
const q = new URLSearchParams({ id: st.id, preset: $('org-preset').value, thinking: $('org-thinking').value });
|
||||
if ($('org-preset').value === 'cliproxy' && $('org-model').value) q.set('model', $('org-model').value);
|
||||
return api('GET', `/api/org-template?${q}`);
|
||||
}
|
||||
async function openAdvanced() {
|
||||
@@ -363,14 +390,14 @@
|
||||
{ title: 'Initialize project records', verb: `mosaic project init ${id} ${project}` },
|
||||
];
|
||||
const list = $('org-quick-steps');
|
||||
list.innerHTML = steps.map((s, i) => `<li class="panel org-step" data-quick-step="${i}" tabindex="-1"><div class="org-step-head"><h4>${txt(s.title)}</h4><span class="org-pill">Not started</span></div><p class="org-verb">Same as ${cmd(s.verb)}</p><p class="org-field-err" role="alert"></p></li>`).join('');
|
||||
const run = $('org-quick-run'); run.disabled = true; $('org-quick-open').disabled = true; $('org-advanced-open').disabled = true; $('org-preset').disabled = true; $('org-thinking').disabled = true; banner('');
|
||||
list.innerHTML = steps.map((s, i) => `<li class="panel org-step" data-quick-step="${i}" tabindex="-1"><div class="org-step-head"><h4>${txt(s.title)}</h4><span class="org-pill">Not started</span></div><p class="org-field-err" role="alert"></p></li>`).join('');
|
||||
const run = $('org-quick-run'); run.disabled = true; $('org-quick-open').disabled = true; $('org-advanced-open').disabled = true; $('org-preset').disabled = true; $('org-model').disabled = true; $('org-thinking').disabled = true; banner('');
|
||||
let current = 0;
|
||||
try {
|
||||
const template = await selectedTemplate();
|
||||
if (template.status !== 200) throw Error(template.body.message || 'Could not load the template.');
|
||||
if (!template.body.doc || typeof template.body.doc !== 'object') throw Error('The template reply could not be read.');
|
||||
const doc = template.body.doc; doc.projects = { [project]: {} };
|
||||
const doc = quickDocument(template.body.doc); doc.projects = { [project]: {} };
|
||||
const requests = [
|
||||
['/api/orgs', { id, doc }, 'create'],
|
||||
[`/api/orgs/${enc(id)}/setup/queue`, local, 'queue'],
|
||||
@@ -388,8 +415,7 @@
|
||||
if (step === 'chat-project' ? !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(result.body.id || '') : result.body.outcome !== 'done' || result.body.step !== step) throw Error('The reply could not be read, so this step\'s outcome is unknown.');
|
||||
if (step === 'chat-project') quickDone = { org: id, chatProject: result.body.id, repo: project };
|
||||
card.querySelector('.org-pill').textContent = 'Done'; card.classList.add('org-step-done');
|
||||
if (result.body.verb) card.querySelector('code').textContent = result.body.verb;
|
||||
if (step === 'project' && result.body.receipt?.check) card.querySelector('.org-verb').insertAdjacentHTML('afterend', `<p class="org-help" data-remote-check>${txt(checkLine(result.body.receipt))}</p>`);
|
||||
if (step === 'project' && result.body.receipt?.check) card.querySelector('.org-step-head').insertAdjacentHTML('afterend', `<p class="org-help" data-remote-check>${txt(checkLine(result.body.receipt))}</p>`);
|
||||
}
|
||||
editorDirty = false; $('org-new-id').value = ''; $('org-quick-open-org').hidden = false; $('org-quick-interview').hidden = !window.MosaicOnboarding; status('Organization setup complete.');
|
||||
// E1 (P1-5): the sidebar and header list the new organization without a reload.
|
||||
@@ -449,7 +475,7 @@
|
||||
}
|
||||
function showReceipt(title, body) {
|
||||
const box = $('org-receipt');
|
||||
box.innerHTML = `<h3 id="org-receipt-title">${txt(title)}</h3><p>Same as ${cmd(body.verb)}</p><pre class="org-pre">${txt(JSON.stringify(body.receipt, null, 2))}</pre>`;
|
||||
box.innerHTML = `<h3 id="org-receipt-title">${txt(title)}</h3>${commandLine(body.verb)}<pre class="org-pre">${txt(JSON.stringify(body.receipt, null, 2))}</pre>`;
|
||||
box.hidden = false; status(`${title}. Receipt shown.`);
|
||||
}
|
||||
async function refreshList() {
|
||||
@@ -499,7 +525,7 @@
|
||||
const c = st.choice.get(key) || {}, remote = c.mode === 'remote';
|
||||
return `<li class="panel org-step org-step-${cls}" data-step="${txt(key)}" aria-labelledby="org-step-${i}-title">
|
||||
<div class="org-step-head"><h4 id="org-step-${i}-title"><span class="org-step-n">${i + 1}</span> ${txt(title)}</h4><span class="org-pill ${cls}">${txt(stateLabel)}</span></div>
|
||||
<p class="org-verb">Same as ${cmd(s.verb || '')}</p>
|
||||
${commandLine(s.verb || '')}
|
||||
${s.message ? `<p class="org-help">${txt(s.message)}</p>` : ''}
|
||||
${key.startsWith('project:') && s.receipt?.check ? `<p class="org-help" data-remote-check>${txt(checkLine(s.receipt))}</p>` : ''}
|
||||
${s.lastError ? `<p class="org-field-err" role="alert">${txt(s.lastError)}</p>` : ''}
|
||||
@@ -752,5 +778,5 @@
|
||||
}).catch(() => banner('The Console configuration could not be read.'));
|
||||
return () => { alive = false; delete window.MosaicOrgCreate.hasDraft; for (const [el, ev, fn] of handlers) el.removeEventListener(ev, fn); };
|
||||
}
|
||||
window.MosaicOrgCreate = { markup, mount };
|
||||
window.MosaicOrgCreate = { markup, mount, quickDocument };
|
||||
})();
|
||||
@@ -46,6 +46,9 @@
|
||||
}
|
||||
async function refresh() {
|
||||
if (busy || out()) return;
|
||||
await window.MosaicOrg?.ready;
|
||||
if (document.documentElement.hasAttribute('data-organizations') && !window.MosaicOrg?.id) { host.hidden = true; banner.hidden = true; return; }
|
||||
host.hidden = false;
|
||||
const current = ++sequence;
|
||||
try {
|
||||
const [configResponse, stateResponse] = await Promise.all([
|
||||
|
||||
@@ -65,6 +65,13 @@
|
||||
async function mountTree({container,path:route}) {
|
||||
if(!container || document.body.classList.contains('signed-out')) return;
|
||||
const generation=++treeGeneration;
|
||||
await window.MosaicOrg?.ready;
|
||||
if (generation!==treeGeneration || !container.isConnected) return;
|
||||
if (document.documentElement.hasAttribute('data-organizations') && !window.MosaicOrg?.id) {
|
||||
container.textContent = 'Create an organization to see projects here.';
|
||||
delete container.dataset.treePaint;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!treeRead || Date.now()-treeReadAt>10000) {
|
||||
treeReadAt=Date.now();
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
visiting.delete(r.id); seen.add(r.id); ordered.push(r);
|
||||
}
|
||||
rows.forEach(visit);
|
||||
const required = ordered.filter(r => r.required), optional = ordered.filter(r => !r.required);
|
||||
const required = ordered.filter(r => r.required && r.state !== 'not-applicable'), optional = ordered.filter(r => !r.required);
|
||||
required.forEach((r, i) => { r.number = i + 1; });
|
||||
const current = required.find(r => !satisfied(r)) ?? null;
|
||||
const alerts = required.filter(r => r.state === 'failed').map(r => ({ ...r }));
|
||||
@@ -38,7 +38,7 @@
|
||||
}
|
||||
const complete = required.length > 0 && required.every(satisfied);
|
||||
const failures = alerts;
|
||||
return { rows: [...required, ...optional], required, optional, current, total: required.length, done: required.filter(satisfied).length, step: current?.number ?? required.length, complete,
|
||||
return { rows: [...ordered.filter(r => r.required), ...optional], required, optional, current, total: required.length, done: required.filter(satisfied).length, step: current?.number ?? required.length, complete,
|
||||
alertsOnly, failures };
|
||||
}
|
||||
function target(fix) {
|
||||
@@ -48,9 +48,9 @@
|
||||
function oneRow(r, current, alert = false) {
|
||||
const open = current?.id === r.id || alert, failed = r.state === 'failed';
|
||||
const words = { next: 'Next', checking: 'Checking', waiting: `After step ${r.waitStep ?? current?.number ?? 1}`, done: 'Done', failed: "Needs a fix", 'not-applicable': 'Not needed', optional: 'Optional' };
|
||||
const href = target(r.fix), optional = !r.required;
|
||||
const href = r.state === 'not-applicable' ? null : target(r.fix), optional = !r.required;
|
||||
return `<li class="checklist-step ${open ? 'setup-open ' : ''}setup-${esc(r.state)}">
|
||||
<span class="setup-num" aria-hidden="true">${failed ? '!' : r.state === 'done' ? '✓' : r.number ?? '+'}</span>
|
||||
<span class="setup-num" aria-hidden="true">${failed ? '!' : satisfied(r) ? '✓' : r.number ?? '+'}</span>
|
||||
<div class="setup-copy"><div class="setup-title">${esc(r.title)}</div><p class="setup-description">${esc(satisfied(r) || failed && open ? r.reason : r.purpose)}</p></div>
|
||||
<div class="setup-right">${satisfied(r) && href ? `<a href="${esc(href)}">Open</a>` : ''}<span class="setup-pill">${esc(words[r.state] ?? 'Checking')}</span></div>
|
||||
${open ? `<div class="setup-body">${!(failed || satisfied(r)) && r.reason ? `<p>${esc(r.reason)}</p>` : ''}${href ? `<div class="setup-actions"><a class="btn primary" href="${esc(href)}">${esc(r.fix.label)}</a><span class="setup-where">Opens the page for this step</span></div>` : ''}</div>` : ''}
|
||||
@@ -59,7 +59,7 @@
|
||||
}
|
||||
function card(s) {
|
||||
const title = s.current ? `Step ${s.step} of ${s.total}: ${s.current.title.charAt(0).toLowerCase()}${s.current.title.slice(1)}` : 'Setup checks';
|
||||
return `<section class="setup-card" aria-label="Set up Mosaic Stack"><header class="setup-head"><p class="setup-where-am-i">Set up Mosaic Stack</p><h2>${esc(title)}</h2><p>${s.complete ? 'Each check reads current state. Open a finished step to see its settings.' : 'One step at a time. The blue button is the thing to do now.'}</p><div class="setup-bar" aria-label="${s.done} of ${s.total} steps complete">${s.required.map(r => `<i class="${satisfied(r) ? 'on' : r === s.current ? r.state === 'failed' ? 'bad' : 'cur' : ''}"></i>`).join('')}</div></header><ol class="setup-steps">${s.required.map(r => oneRow(r, s.current)).join('')}</ol>${s.optional.length ? `<h3 class="setup-list-split">Later, when you need it</h3><ul class="setup-steps">${s.optional.map(r => oneRow(r, null)).join('')}</ul>` : ''}</section>`;
|
||||
return `<section class="setup-card" aria-label="Set up Mosaic Stack"><header class="setup-head"><p class="setup-where-am-i">Set up Mosaic Stack</p><h2>${esc(title)}</h2><p>${s.complete ? 'Each check reads current state. Open a finished step to see its settings.' : 'One step at a time. The blue button is the thing to do now.'}</p><div class="setup-bar" aria-label="${s.done} of ${s.total} steps complete">${s.required.map(r => `<i class="${satisfied(r) ? 'on' : r === s.current ? r.state === 'failed' ? 'bad' : 'cur' : ''}"></i>`).join('')}</div></header><ol class="setup-steps">${s.rows.filter(r => r.required).map(r => oneRow(r, s.current)).join('')}</ol>${s.optional.length ? `<h3 class="setup-list-split">Later, when you need it</h3><ul class="setup-steps">${s.optional.map(r => oneRow(r, null)).join('')}</ul>` : ''}</section>`;
|
||||
}
|
||||
function render(s, expanded = false) {
|
||||
if (s.complete) return `<section class="setup-strip" aria-label="Setup checks"><span class="setup-ok" aria-hidden="true">✓</span><strong>Setup done.</strong><span>All ${s.total} checks pass.</span><span class="muted">Checked just now.</span><button type="button" class="setup-show" data-setup-show aria-expanded="${expanded}">${expanded ? 'Hide checks' : 'Show checks'}</button></section>${expanded ? card(s) : ''}`;
|
||||
|
||||
@@ -451,6 +451,7 @@
|
||||
<label>Title<input name="title" required maxlength="250" autocomplete="off"></label>
|
||||
<label>Requirement<input name="requirement" required pattern="${REQUIREMENT}" placeholder="REQ-WEB-1" autocomplete="off" aria-describedby="tb-req-note"></label>
|
||||
<p class="tb-field-note" id="tb-req-note">The requirement this task serves, written as REQ-AREA-N.</p>
|
||||
<p class="tb-field-note" id="tb-req-error" role="alert"></p>
|
||||
<div class="tb-row2">${stateSelect('todo')}${prioSelect(0)}<label>Due date<input type="date" name="due_date"></label></div>
|
||||
<div data-tb-roles>${roleBoxes(org.roles, [])}</div>
|
||||
<p class="tb-form-status" role="alert" data-tb-form-status></p>
|
||||
@@ -563,6 +564,23 @@
|
||||
try { await reload(); } catch {}
|
||||
paint();
|
||||
}
|
||||
// Native validation fires before submit. Explain this field inline for both empty
|
||||
// and malformed values, including a screen-reader announcement and focus.
|
||||
document.addEventListener('invalid', e => {
|
||||
const field = e.target;
|
||||
if (field.name !== 'requirement' || !field.closest('[data-tb-form="create"]')) return;
|
||||
e.preventDefault();
|
||||
field.setAttribute('aria-invalid', 'true');
|
||||
field.setAttribute('aria-describedby', 'tb-req-note tb-req-error');
|
||||
field.form.querySelector('#tb-req-error').textContent = 'Type a requirement ID using capital letters and a number, for example REQ-WEB-1.';
|
||||
field.focus();
|
||||
}, true);
|
||||
document.addEventListener('input', e => {
|
||||
const field = e.target;
|
||||
if (field.name !== 'requirement' || !field.closest('[data-tb-form="create"]')) return;
|
||||
field.removeAttribute('aria-invalid'); field.setAttribute('aria-describedby', 'tb-req-note');
|
||||
field.form.querySelector('#tb-req-error').textContent = '';
|
||||
});
|
||||
async function archive(form) {
|
||||
if (form.querySelector('[data-tb-archive]')?.disabled) return;
|
||||
const t = opened && key(opened) === form.dataset.tbKey ? opened : null;
|
||||
|
||||
@@ -19,13 +19,12 @@ process.once('exit', () => { for (const child of live) killGroup(child); });
|
||||
// so by default every page this browser opens starts with Show machine sessions on, as if the
|
||||
// person had turned it on before. Pass { machine: false } to see the page as a first visit does.
|
||||
// `args` adds Chromium flags, for example --host-resolver-rules for a test host name.
|
||||
// #1873 CB5: the system Chromium starts with --disable-extensions, so no host extension (and no
|
||||
// native host it would start) runs in a test. A CHROMIUM launcher is the zoom tests' wrapper, which
|
||||
// loads their one extension with --disable-extensions-except, so it gets no blanket flag.
|
||||
// Disable host extensions for every launch, including a custom zoom launcher. The zoom
|
||||
// launcher also sets the profile's default zoom, so it needs no running extension.
|
||||
export async function browser({ machine = true, args = [] } = {}) {
|
||||
const profile = await mkdtemp(join(tmpdir(), 'dewey-brand-browser-'));
|
||||
const child = spawn(process.env.CHROMIUM || '/usr/bin/chromium', [
|
||||
'--headless', '--no-first-run', '--no-default-browser-check', ...(process.env.CHROMIUM ? [] : ['--disable-extensions']),
|
||||
'--headless', '--no-first-run', '--no-default-browser-check', '--disable-extensions',
|
||||
'--disable-dev-shm-usage', '--remote-debugging-pipe', `--user-data-dir=${profile}`, ...args,
|
||||
], { detached: true, stdio: ['ignore', 'ignore', 'ignore', 'pipe', 'pipe'] });
|
||||
live.add(child);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { startServer } from '../src/serve.mjs';
|
||||
import { createDevOwner } from '../src/dev-owner.mjs';
|
||||
import { setupRoutes } from '../src/setup-http.mjs';
|
||||
import { browser } from './browser.mjs';
|
||||
import { close } from './fixture.mjs';
|
||||
|
||||
test('an empty organization Console makes no organization requests or errors and hides business settings and the board address', { timeout: 30000 }, async t => {
|
||||
const organizations = { list: async () => [], members: async () => [] };
|
||||
const server = await startServer({ port: 0, sso: createDevOwner(), organizations, board: 'http://127.0.0.1:9', log: () => {},
|
||||
routes: [setupRoutes({ organizations, service: async () => ({ release: {}, init: {}, unit: {} }), docker: async () => false, runs: () => [] })] });
|
||||
t.after(() => close(server));
|
||||
const b = await browser({ machine: false }); t.after(() => b.close());
|
||||
const errors = [], reads = [];
|
||||
b.on('Network.responseReceived', ({ response }) => { if (response.status >= 400 && response.status < 500) errors.push([response.status, response.url]); });
|
||||
b.on('Network.requestWillBeSent', ({ request }) => reads.push(new URL(request.url).pathname));
|
||||
await b.call('Network.enable');
|
||||
const wait = expression => b.evaluate(`(async()=>{for(let i=0;i<150;i++){if(${expression})return;await new Promise(r=>setTimeout(r,30))}throw Error(${JSON.stringify(expression)})})()`);
|
||||
await b.navigate(`http://127.0.0.1:${server.address().port}/#/dashboard`);
|
||||
await wait('document.querySelector(".setup-card")');
|
||||
await wait('document.querySelector("#project-tree")?.textContent.includes("Create an organization")');
|
||||
assert.equal(await b.evaluate('document.querySelector("#board-url").getClientRects().length'), 0);
|
||||
assert.doesNotMatch(await b.evaluate('document.body.innerText'), /Projects unavailable|Board: http/);
|
||||
await b.evaluate('location.hash="#/settings/appearance"');
|
||||
await wait('document.querySelector("#settings-nav")');
|
||||
assert.doesNotMatch(await b.evaluate('document.querySelector("#settings-nav").textContent'), /This business|Routing|Launch limits|Token use|Assistant|Business|Agents/);
|
||||
// Cover periodic processing refresh, too.
|
||||
await new Promise(resolve => setTimeout(resolve, 5500));
|
||||
for (const path of ['/api/business', '/api/processing', '/api/chat/projects', '/api/chat/threads', '/api/bus-status']) assert.ok(!reads.includes(path), path);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { firstOrg } from './first-org-fixture.mjs';
|
||||
import { browser } from './browser.mjs';
|
||||
test('the first organization selects the owner model, completes Quick Setup and finishes checklist step three', { timeout: 60000 }, async t => {
|
||||
const f = await firstOrg(t), b = await browser({ machine: false, args: ['--disable-extensions'] }); t.after(() => b.close());
|
||||
const wait = expression => b.evaluate(`(async()=>{for(let n=0;n<150;n++){if(${expression})return;await new Promise(r=>setTimeout(r,40));}throw Error(${JSON.stringify(expression)})})()`);
|
||||
await b.navigate(f.base + '/#/settings/organizations?new=1');
|
||||
await wait('document.querySelector("#org-new-form [data-write]") && !document.querySelector("#org-new-form [data-write]").disabled');
|
||||
await b.evaluate(`document.querySelector('#org-new-id').value='alpha';document.querySelector('#org-new-form [data-write]').click()`);
|
||||
await wait('document.querySelector("#org-paths") && !document.querySelector("#org-paths").hidden');
|
||||
assert.equal(await b.evaluate(`document.querySelector('#org-preset option[value="cliproxy"]').disabled`), false);
|
||||
await b.evaluate(`document.querySelector('#org-preset').value='cliproxy';document.querySelector('#org-preset').dispatchEvent(new Event('change',{bubbles:true}))`);
|
||||
assert.equal(await b.evaluate(`document.querySelector('#org-model').value`), 'claude-claude-opus-5-5');
|
||||
assert.match(await b.evaluate(`document.querySelector('#org-model').textContent`), /claude-opus-5-5/);
|
||||
await b.evaluate(`document.querySelector('#org-quick-open').click();document.querySelector('#org-risk-accept').click();document.querySelector('#org-quick-run').click()`);
|
||||
await wait(`document.querySelector('[data-quick-step="5"] .org-pill')?.textContent === 'Done' || [...document.querySelectorAll('[data-quick-step] .org-pill')].some(e=>e.textContent==='Stopped')`);
|
||||
assert.deepEqual(await b.evaluate(`[...document.querySelectorAll('[data-quick-step] .org-pill')].map(e=>e.textContent)`), Array(6).fill('Done'), await b.evaluate(`document.querySelector('#org-quick-steps').innerText`));
|
||||
const shown = await f.service.showOrg({ ...f.ctx, principal: { provider: 'local-dev', iss: 'local-dev', sub: 'local-dev-owner' } }, 'alpha');
|
||||
assert.deepEqual(shown.doc.roles.chief.vars, shown.doc.roles.assistant.vars);
|
||||
assert.deepEqual(shown.doc.launch.instances, ['assistant'], 'routing the chief must not launch it');
|
||||
const setup = await f.call('GET', '/api/setup');
|
||||
const routed = setup.body.rows.find(r => r.id === 'agents.routed');
|
||||
assert.doesNotMatch(routed.reason, /Choose a model for both/);
|
||||
assert.equal(routed.state, 'checking');
|
||||
assert.equal(routed.reason, 'The chosen programs have not passed their check yet. Choose models to check them.');
|
||||
await b.navigate(f.base + '/#/dashboard');
|
||||
await wait('document.querySelectorAll(".checklist-step").length === 7');
|
||||
assert.equal(await b.evaluate(`document.querySelectorAll('.setup-card ol .checklist-step')[2].classList.contains('setup-done')`), true);
|
||||
assert.doesNotMatch(await b.evaluate(`document.querySelectorAll('.setup-card ol .checklist-step')[3].textContent`), /Choose a model for both/);
|
||||
});
|
||||
@@ -0,0 +1,96 @@
|
||||
// Real organization service and broker, with a scratch-only model service and owner client.
|
||||
import fs from 'node:fs';
|
||||
import http from 'node:http';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { startServer } from '../src/serve.mjs';
|
||||
import { createDevOwner } from '../src/dev-owner.mjs';
|
||||
import { createOrgAdmin } from '../src/org-admin.mjs';
|
||||
import { organizationConsole } from '../src/organizations.mjs';
|
||||
import { setupRoutes } from '../src/setup-http.mjs';
|
||||
import * as service from '../../organization/src/org-service.mjs';
|
||||
import * as registry from '../../organization/src/org-registry.mjs';
|
||||
import { createOwnerProxyRuntime } from '../../bus/src/proxy-owner.mjs';
|
||||
import { startBroker } from '../../bus/src/runtime.mjs';
|
||||
import { Registry } from '../../seat/src/session.mjs';
|
||||
import { bootConfig, orgPaths } from '../../cli/src/config.mjs';
|
||||
import { createProxyAdmin } from '../../model-proxy/src/admin-control.mjs';
|
||||
import { ownerModelsReader } from '../../model-proxy/src/ride.mjs';
|
||||
import { initializeProxy, installPaths } from '../../model-proxy/src/settings.mjs';
|
||||
import { writeOffered } from '../../model-proxy/src/models-offered.mjs';
|
||||
import { PIN } from '../../model-proxy/src/common.mjs';
|
||||
export const bytes = dir => fs.readdirSync(dir, { recursive: true }).sort().map(name => {
|
||||
const file = join(dir, name); return [name, fs.lstatSync(file).isDirectory() ? null : fs.readFileSync(file).toString('base64')];
|
||||
});
|
||||
export async function firstOrg(t, { mode = 'organizations', viewer = 'root', readFailure = null } = {}) {
|
||||
const root = fs.mkdtempSync(join(tmpdir(), 'fo-')), configDir = join(root, 'config'), dataRoot = join(root, 'data');
|
||||
fs.mkdirSync(configDir, { mode: 0o700 }); fs.mkdirSync(dataRoot, { mode: 0o700 });
|
||||
const pendingReads = [];
|
||||
const brokers = new Map(), state = { keys: [], accounts: [{ id: 'fixture', name: 'fixture', auth_index: 'fixture', provider: 'claude', status: 'active' }], models: [{ id: 'claude-opus-5-5' }, { id: 'claude-sonnet-4-6' }], reads: 0 };
|
||||
const key = 'fixture-management-value';
|
||||
const proxy = http.createServer(async (req, res) => {
|
||||
const url = new URL(req.url, 'http://127.0.0.1');
|
||||
if (url.pathname === '/v1/models') { res.writeHead(state.keys.includes(req.headers.authorization?.slice(7)) ? 200 : 401); res.end('{}'); return; }
|
||||
if (req.headers.authorization !== `Bearer ${key}`) { res.writeHead(401); res.end('{}'); return; }
|
||||
if (url.pathname === '/v8/management/config/access/api-keys') {
|
||||
if (req.method === 'PUT') { const parts = []; for await (const p of req) parts.push(p); state.keys = JSON.parse(Buffer.concat(parts)); res.end('{"status":"ok"}'); }
|
||||
else res.end(JSON.stringify(state.keys));
|
||||
return;
|
||||
}
|
||||
const value = url.pathname === '/v8/management/credentials' ? { files: state.accounts }
|
||||
: url.pathname === '/v8/management/credentials/models' ? { models: state.models } : [];
|
||||
res.end(JSON.stringify(value));
|
||||
});
|
||||
let server;
|
||||
t.after(async () => {
|
||||
// Release synthetic stalls so a broken production deadline cannot strand the test process.
|
||||
for (const resolve of pendingReads) resolve({ files: state.accounts });
|
||||
if (server) { server.closeAllConnections(); await new Promise(resolve => server.close(resolve)); }
|
||||
for (const b of brokers.values()) await b.close();
|
||||
proxy.closeAllConnections(); await new Promise(resolve => proxy.close(resolve));
|
||||
fs.rmSync(root, { recursive: true, force: true });
|
||||
});
|
||||
const hash = text => createHash('sha256').update(text).digest('hex');
|
||||
const pin = { ...PIN, binary: { sha256: hash('binary') }, panel: { ...PIN.panel, sha256: hash('panel') } };
|
||||
const paths = installPaths(dataRoot, pin); fs.mkdirSync(join(paths.dir, 'static'), { recursive: true }); fs.writeFileSync(paths.binary, 'binary'); fs.writeFileSync(paths.panel, 'panel');
|
||||
const settings = await initializeProxy({ configDir, dataRoot, key, pin });
|
||||
await new Promise(resolve => proxy.listen(settings.port, '127.0.0.1', resolve));
|
||||
writeOffered(dataRoot, { version: 1, providers: { claude: { on: ['claude-opus-5-5'], seen: ['claude-opus-5-5', 'claude-sonnet-4-6'] } } });
|
||||
const runtime = createOwnerProxyRuntime({ configDir, dataRoot, checkHuman: () => { state.reads++; if (readFailure && readFailure !== 'slow') throw Object.assign(Error('/private/path token=hidden'), { code: readFailure }); }, load: async () => ({
|
||||
getCredentials: async () => readFailure === 'slow' ? new Promise(resolve => pendingReads.push(resolve)) : { files: state.accounts },
|
||||
getCredentialModels: async () => ({ models: state.models }), getUpstreamGroups: async () => [],
|
||||
}) });
|
||||
const ctx = { configDir, dataRoot, instance: 'test' }, projects = [];
|
||||
const bus = {
|
||||
busStatus: async (_ctx, id) => ({ healthy: brokers.has(id), pid: brokers.has(id) ? process.pid : null }),
|
||||
busStart: async (_ctx, id) => {
|
||||
const org = await registry.resolveOrg(ctx, id); new Registry(org.root);
|
||||
const config = bootConfig({ system: { configVersion: 1, environment: 'development', dataRoot, execution: { backend: 'docker', provider: 'zai', model: 'glm-5.3-flash', adapter: 'mock' }, proxy: settings }, businessId: id, orgRoot: org.root, env: { HOME: root, MOSAIC_CONFIG: join(configDir, 'config.json') } });
|
||||
const b = await startBroker(config); brokers.set(id, b); return { healthy: true };
|
||||
},
|
||||
};
|
||||
const options = ({ id }) => ({ send: async () => ({}), bus: { routes: () => ask(id, 'routes') }, proxyCall: (verb, args) => ask(id, verb, args), chat: {
|
||||
projects: async () => projects, threads: async () => [], createProject: async args => { const p = { id: '20000000-0000-4000-8000-000000000002', ...args }; projects.push(p); return p; },
|
||||
} });
|
||||
function ask(id, verb, args) { const b = brokers.get(id); if (!b) throw Error('not started'); return b.broker.request(b.broker.bindHuman({ business: id, human: 'local-dev-owner', via: 'cli', outsideAgent: true }), { verb, args }); }
|
||||
const organizations = mode === 'organizations' ? organizationConsole({ ctx, ...registry, showOrg: service.showOrg, orgPaths, busStatus: bus.busStatus, options }) : null;
|
||||
const ownerModels = ownerModelsReader({ proxy: () => true, organizations, ownerProxy: runtime, rideRiders: async () => [], timeoutMs: 30 });
|
||||
const admin = createOrgAdmin({ service, registry, bus, context: () => ctx, ownerModels, devFixture: async () => ({ ready: false }) });
|
||||
const proxyAdmin = createProxyAdmin({ configDir, dataRoot, ownerProxy: runtime });
|
||||
const owner = createDevOwner();
|
||||
const sso = viewer === 'root' && mode !== 'sso' ? owner : { ...owner, devOwner: false, publicHost: 'console.example', publicOrigin: 'https://console.example', session: () => ({ ...owner.session(), ...(viewer === 'root' ? {} : { rootOwner: false, instanceRole: 'member', ...(viewer === 'member' ? { user: 'member' } : {}) }) }) };
|
||||
server = await startServer({ port: 0, sso, organizations, orgAdmin: admin, proxyAdmin, send: async () => ({}), board: 'http://127.0.0.1:9', log: () => {}, routes: [setupRoutes({ organizations, proxyAdmin, service: async () => ({ release: { verified: true }, init: { initialized: true }, unit: { active: 'active', healthy: true, listening: true } }), docker: async () => false, runs: () => [] })] });
|
||||
const base = `http://127.0.0.1:${server.address().port}`;
|
||||
const call = (method, path, body) => new Promise((resolve, reject) => {
|
||||
const text = body === undefined ? null : JSON.stringify(body);
|
||||
const req = http.request(base + path, { method, headers: {
|
||||
...(sso.publicHost ? { Host: sso.publicHost } : {}),
|
||||
...(text ? { Origin: base, 'sec-fetch-site': 'same-origin', 'content-type': 'application/json', 'content-length': Buffer.byteLength(text) } : {}),
|
||||
} }, res => {
|
||||
let text = ''; res.setEncoding('utf8'); res.on('data', chunk => { text += chunk; });
|
||||
res.on('end', () => { try { resolve({ status: res.statusCode, body: JSON.parse(text) }); } catch (error) { reject(error); } });
|
||||
}); req.on('error', reject); req.end(text);
|
||||
});
|
||||
return { base, call, ctx, configDir, dataRoot, runtime, state, brokers, ask, service };
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { firstOrg, bytes } from './first-org-fixture.mjs';
|
||||
const preset = result => result.body.presets.find(p => p.name === 'cliproxy');
|
||||
test('first organization presets are read-only and Quick Setup boots the shared provider and automatic model key', async t => {
|
||||
const f = await firstOrg(t);
|
||||
const before = [bytes(f.configDir), bytes(f.dataRoot)];
|
||||
for (let i = 0; i < 2; i++) {
|
||||
const r = await f.call('GET', '/api/org-presets'); assert.equal(r.status, 200);
|
||||
assert.deepEqual(preset(r).available, { ok: true });
|
||||
assert.deepEqual(preset(r).models.map(m => m.key), ['claude-claude-opus-5-5'], 'the switched-off Sonnet row stays out');
|
||||
}
|
||||
assert.deepEqual([bytes(f.configDir), bytes(f.dataRoot)], before);
|
||||
const template = await f.call('GET', '/api/org-template?id=alpha&preset=cliproxy'); assert.equal(template.status, 200);
|
||||
const chosen = await f.call('GET', '/api/org-template?id=alpha&preset=cliproxy&model=claude-claude-opus-5-5'); assert.deepEqual(chosen.body.doc, template.body.doc);
|
||||
const made = await f.call('POST', '/api/orgs', { id: 'alpha', doc: template.body.doc }); assert.equal(made.status, 201, JSON.stringify(made));
|
||||
const shown = await f.service.showOrg({ ...f.ctx, principal: { provider: 'local-dev', iss: 'local-dev', sub: 'local-dev-owner' } }, 'alpha');
|
||||
assert.deepEqual(shown.doc.plugins['model-provider'], ['cliproxy']);
|
||||
assert.deepEqual(shown.doc.roles.assistant.vars, { harness: 'claude-code', model: 'claude-claude-opus-5-5', thinking: 'low' });
|
||||
for (const step of ['queue', 'project/work']) {
|
||||
const result = await f.call('POST', `/api/orgs/alpha/setup/${step}`, { mode: 'local-only', acceptLocalLossRisk: true }); assert.equal(result.status, 201, JSON.stringify(result));
|
||||
}
|
||||
const started = await f.call('POST', '/api/orgs/alpha/setup/bus', {}); assert.equal(started.status, 201, JSON.stringify(started));
|
||||
const routes = await f.ask('alpha', 'routes');
|
||||
assert.equal(routes.catalogue.status, 'ready'); assert.equal(routes.instances.assistant.model, 'claude-claude-opus-5-5'); assert.equal(routes.instances.assistant.harness, 'claude-code');
|
||||
assert.equal(f.state.keys.some(k => k.includes('-alpha-sentinel-')), true, 'normal broker boot registers the first organization');
|
||||
const b = f.brokers.get('alpha');
|
||||
const ready = await b.modelPreflight({ business: 'alpha', role: 'assistant' });
|
||||
assert.equal(f.state.keys.includes(ready.key), true, 'normal launch preflight issues the model key without an owner action');
|
||||
const setup = await f.call('GET', '/api/setup'); assert.equal(setup.body.rows.find(r => r.id === 'organization.ready').state, 'done');
|
||||
});
|
||||
test('four other viewer and Console cases never read the owner catalogue', async t => {
|
||||
for (const options of [{ viewer: 'member' }, { viewer: 'org-owner' }, { mode: 'single' }, { mode: 'sso' }]) {
|
||||
const f = await firstOrg(t, options), before = f.state.reads;
|
||||
const r = await f.call('GET', '/api/org-presets');
|
||||
if (options.viewer) assert.equal(r.status, options.viewer === 'member' ? 403 : 404);
|
||||
else { assert.equal(r.status, 200); assert.equal(preset(r).available.ok, false); assert.match(preset(r).available.reason, /No organization uses/); assert.doesNotMatch(preset(r).available.reason, /Ride all/); }
|
||||
assert.equal(f.state.reads, before);
|
||||
}
|
||||
});
|
||||
test('slow, busy, paused and refused catalogue reads leave the form usable and disclose nothing', { timeout: 3000 }, async t => {
|
||||
for (const failure of ['slow', 'proxy-admin-busy', 'human-required', 'paused']) {
|
||||
const f = await firstOrg(t, { readFailure: failure }), before = [bytes(f.configDir), bytes(f.dataRoot)];
|
||||
const start = Date.now(), r = await f.call('GET', '/api/org-presets');
|
||||
assert.equal(r.status, 200); assert.ok(Date.now() - start < 1500);
|
||||
assert.deepEqual(preset(r).available, { ok: false, reason: 'Your models could not be checked. Open Model setup to try again.' });
|
||||
assert.doesNotMatch(JSON.stringify(r.body), /private|hidden|token=|human-required|proxy-admin-busy/);
|
||||
assert.deepEqual([bytes(f.configDir), bytes(f.dataRoot)], before);
|
||||
}
|
||||
const f = await firstOrg(t), before = [bytes(f.configDir), bytes(f.dataRoot)];
|
||||
await f.runtime.withRemoval(async () => assert.equal(preset(await f.call('GET', '/api/org-presets')).available.ok, false));
|
||||
assert.deepEqual([bytes(f.configDir), bytes(f.dataRoot)], before);
|
||||
});
|
||||
test('no account or no offered model shares the account connection reason', async t => {
|
||||
const f = await firstOrg(t);
|
||||
for (const field of ['accounts', 'models']) {
|
||||
const saved = f.state[field]; f.state[field] = [];
|
||||
const p = preset(await f.call('GET', '/api/org-presets'));
|
||||
assert.equal(p.available.ok, false); assert.match(p.available.reason, /account on the Model setup page/); assert.doesNotMatch(p.available.reason, /Ride all|No organization/);
|
||||
f.state[field] = saved;
|
||||
}
|
||||
});
|
||||
@@ -461,7 +461,7 @@ test('the Settings page ships the organization assets', async t => {
|
||||
assert.match(index.raw, /<script src="\/org-create\.js" defer><\/script>/);
|
||||
assert.match(index.raw, /<link rel="stylesheet" href="\/org-create\.css">/);
|
||||
const js = await c.call('GET', '/org-create.js');
|
||||
assert.equal(js.status, 200); assert.match(js.raw, /window\.MosaicOrgCreate = \{ markup, mount \}/);
|
||||
assert.equal(js.status, 200); assert.match(js.raw, /window\.MosaicOrgCreate = \{ markup, mount, quickDocument \}/);
|
||||
assert.equal((await c.call('GET', '/org-create.css')).status, 200);
|
||||
const bus = readFileSync(new URL('../src/public/bus.js', import.meta.url), 'utf8');
|
||||
assert.match(bus, /\['organizations','Organizations'\]/);
|
||||
@@ -586,7 +586,7 @@ test('preset routes expose installed choices and refuse invalid queries', async
|
||||
|
||||
// first-run-fixes-1 (B2): the Test model preset is offered only when the instance's dev fixture
|
||||
// would answer a chat: a record for this instance whose endpoint process still runs.
|
||||
test('B2: the Test model preset reads unavailable until the instance\'s dev fixture runs', async t => {
|
||||
test('B2: the Test model preset is hidden until the instance\'s dev fixture runs', async t => {
|
||||
const { spawn } = await import('node:child_process');
|
||||
const { chmodSync } = await import('node:fs');
|
||||
const { ENDPOINT } = await import('../../cli/src/dev-fixture.mjs');
|
||||
@@ -596,8 +596,8 @@ test('B2: the Test model preset reads unavailable until the instance\'s dev fixt
|
||||
const dataRoot = mkdtempSync(join(tmpdir(), 'b2-fixture-')); t.after(() => rmSync(dataRoot, { recursive: true, force: true }));
|
||||
const context = async () => ({ configDir: '/cfg', dataRoot, instance: 'test' });
|
||||
const c = await console_(t, { orgAdmin: createOrgAdmin({ service, context, devFixture: fixtureState(context) }) });
|
||||
const fixtureOf = async () => { const r = await c.call('GET', '/api/org-presets'); assert.equal(r.status, 200, r.raw); return r.body.presets.find(p => p.name === 'fixture').available; };
|
||||
const notReady = { ok: false, reason: 'Developer test fixture is not running.' };
|
||||
const fixtureOf = async () => { const r = await c.call('GET', '/api/org-presets'); assert.equal(r.status, 200, r.raw); return r.body.presets.find(p => p.name === 'fixture')?.available; };
|
||||
const notReady = undefined;
|
||||
assert.deepEqual(await fixtureOf(), notReady, 'no fixture record');
|
||||
const dir = join(dataRoot, 'dev-fixture'); mkdirSync(dir, { mode: 0o700 });
|
||||
const record = over => { const file = join(dir, 'fixture.json'); writeFileSync(file, JSON.stringify({ fixtureVersion: 1, model: 'deterministic', instance: 'test', entry: FIXTURE_ENTRY, ...over })); chmodSync(file, 0o600); return file; };
|
||||
@@ -623,7 +623,7 @@ test('B2: the Test model preset reads unavailable until the instance\'s dev fixt
|
||||
chmodSync(record(at), 0o644);
|
||||
assert.deepEqual(await fixtureOf(), notReady, 'a record the launcher would refuse');
|
||||
const throws = await console_(t, { orgAdmin: createOrgAdmin({ service, context, devFixture: async () => { throw new Error('read failed'); } }) });
|
||||
assert.deepEqual((await throws.call('GET', '/api/org-presets')).body.presets.find(p => p.name === 'fixture').available, notReady, 'a failing read is not ready');
|
||||
assert.deepEqual((await throws.call('GET', '/api/org-presets')).body.presets.find(p => p.name === 'fixture')?.available, notReady, 'a failing read is not ready');
|
||||
assert.equal(await fixtureState(async () => null)(), undefined, 'no instance context says nothing');
|
||||
assert.equal(typeof defaultOrgAdmin({}).devFixture, 'function', 'the default wiring reads the fixture');
|
||||
});
|
||||
@@ -633,11 +633,11 @@ test('B2: the Test model preset reads unavailable until the instance\'s dev fixt
|
||||
test('the presets response names no command for an owner to run', async t => {
|
||||
const service = await import('../../organization/src/org-service.mjs');
|
||||
const context = async () => ({ configDir: '/cfg', dataRoot: '/data', instance: 'test' });
|
||||
for (const devFixture of [async () => ({ ready: false }), async () => ({ ready: true }), async () => { throw new Error('read failed'); }]) {
|
||||
for (const [devFixture, listed] of [[async () => ({ ready: false }), false], [async () => ({ ready: true }), true], [async () => { throw new Error('read failed'); }, false]]) {
|
||||
const c = await console_(t, { orgAdmin: createOrgAdmin({ service, context, devFixture }) });
|
||||
const r = await c.call('GET', '/api/org-presets');
|
||||
assert.equal(r.status, 200, r.raw);
|
||||
assert.ok(r.body.presets.some(p => p.name === 'fixture'), 'the Test model entry is listed');
|
||||
assert.equal(r.body.presets.some(p => p.name === 'fixture'), listed, 'the Test model entry is listed only while running');
|
||||
assert.doesNotMatch(r.raw, /mosaic |fixture init|fixture start|--instance|`/i);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -21,6 +21,11 @@ test('setup paths and preset controls are visible', { timeout: 45000 }, async t
|
||||
await b.evaluate(`document.querySelector('#org-quick-open').click()`);
|
||||
await wait('!document.querySelector("#org-quick").hidden');
|
||||
for (const selector of ['#org-project', '#org-project-remote', '#org-risk-accept', '#org-quick-run']) assert.equal(await shown(selector), true, selector);
|
||||
await b.evaluate(`document.querySelector('#org-advanced-open').click()`);
|
||||
await wait('!document.querySelector("#org-editor").hidden');
|
||||
assert.equal(await b.evaluate(`document.querySelector('#org-editor-verb details').open`), false);
|
||||
assert.equal(await b.evaluate(`document.querySelector('#org-editor-verb summary').textContent`), 'Command line');
|
||||
assert.match(await b.evaluate(`document.querySelector('#org-editor-verb code').textContent`), /mosaic org/);
|
||||
});
|
||||
|
||||
// first-run-fixes-1 (F6): the walk found the local-only refusal at the top of the panel, scrolled
|
||||
@@ -87,18 +92,18 @@ for (const scenario of ['bus-refused', 'project-refused', 'project-unknown', 'su
|
||||
assert.match(await b.evaluate(`document.querySelector('[data-quick-step="3"]').textContent`), /bus refused/);
|
||||
assert.equal(await b.evaluate('document.activeElement.dataset.quickStep'), '3');
|
||||
}
|
||||
assert.equal(await b.evaluate(`document.querySelector('[data-quick-step="3"] code').textContent`), 'mosaic bus start alpha --dev-local-owner --detach');
|
||||
assert.equal(await b.evaluate(`document.querySelector('[data-quick-step="3"] code')`), null);
|
||||
assert.equal(starts, 1);
|
||||
assert.ok(existsSync(join(dataRoot, 'org-runtime/alpha/checkout/.git')));
|
||||
assert.ok(existsSync(join(dataRoot, 'org-runtime/alpha/projects/work/.git')));
|
||||
if (scenario === 'success') {
|
||||
assert.equal(await b.evaluate(`document.querySelector('[data-quick-step="5"] code').textContent`), 'mosaic project init alpha work');
|
||||
assert.equal(await b.evaluate(`document.querySelector('[data-quick-step="5"] code')`), null);
|
||||
assert.ok(existsSync(join(dataRoot, 'org-runtime/alpha/projects/alpha/work/spec/north-star.md')));
|
||||
const readback = await b.evaluate(`fetch('/api/orgs/alpha/setup/records/work').then(r=>r.json())`);
|
||||
assert.equal(readback.state, 'done'); assert.equal(readback.verb, 'mosaic project init alpha work');
|
||||
}
|
||||
if (scenario !== 'bus-refused') {
|
||||
assert.equal(await b.evaluate(`document.querySelector('[data-quick-step="4"] code').textContent`), 'mosaic project create work --repo work --business alpha');
|
||||
assert.equal(await b.evaluate(`document.querySelector('[data-quick-step="4"] code')`), null);
|
||||
if (scenario !== 'success') {
|
||||
assert.match(await b.evaluate(`document.querySelector('[data-quick-step="4"]').textContent`), scenario === 'project-refused' ? /Project refused/ : /Outcome unknown/i);
|
||||
assert.equal(await b.evaluate('document.activeElement.dataset.quickStep'), '4');
|
||||
@@ -191,13 +196,13 @@ test('quick setup in remote mode sets origin and shows the check', { timeout: 45
|
||||
// A refresh keeps the owner's choice while it stays available, says so when it does not, keeps the
|
||||
// list on a failed read, and does not run once a Quick setup run has locked the select.
|
||||
test('no available preset points to Model setup, and a refocus or a shown page re-reads the list', { timeout: 60000 }, async t => {
|
||||
const on = { claude: false, codex: false }; let reads = 0, failNext = false, note = 'Answers with Claude.';
|
||||
const on = { claude: false, codex: false }; let reads = 0, failNext = false, releaseReads = [], holdRead = false, note = 'Answers with Claude.';
|
||||
const entry = (name, label, description) => ({ name, label, description, thinking: { levels: ['low', 'high'], default: 'low' }, available: on[name] ? { ok: true } : { ok: false, reason: 'No model account is connected.' } });
|
||||
const fixture = { name: 'fixture', label: 'Test model', description: 'A fixed test reply.', thinking: { levels: ['none'], default: 'none' }, available: { ok: false, reason: 'Developer test fixture is not running.' } };
|
||||
const orgPresets = async () => {
|
||||
reads++;
|
||||
if (holdRead) await new Promise(resolve => { releaseReads.push(resolve); });
|
||||
if (failNext) { failNext = false; throw Object.assign(new Error('read failed'), { code: 'org-invalid' }); }
|
||||
return [entry('claude', 'Claude', note), entry('codex', 'Codex', 'Answers with Codex.'), fixture];
|
||||
return [entry('claude', 'Claude', note), entry('codex', 'Codex', 'Answers with Codex.')];
|
||||
};
|
||||
const admin = createOrgAdmin({ service: { ...service, orgPresets }, registry: { listOrgs: async () => [] }, context: async () => ({ configDir: '/cfg', dataRoot: '/data', instance: 'test' }) });
|
||||
const server = await startServer({ port: 0, sso: createDevOwner(), orgAdmin: admin, send: async () => ({}), board: 'http://127.0.0.1:9', log: () => {} }); t.after(() => close(server));
|
||||
@@ -220,9 +225,12 @@ test('no available preset points to Model setup, and a refocus or a shown page r
|
||||
await wait('document.querySelector("#org-paths") && !document.querySelector("#org-paths").hidden');
|
||||
assert.deepEqual(await look(), blocked);
|
||||
assert.equal(await b.evaluate(`[...document.querySelector('#org-preset').options].map(o=>o.textContent).join('|')`),
|
||||
'Claude — No model account is connected.|Codex — No model account is connected.|Test model — Developer test fixture is not running.');
|
||||
'Claude|Codex');
|
||||
assert.equal(await b.evaluate(`document.querySelector('#org-paths').textContent.includes('mosaic ')`), false, 'no command for the owner');
|
||||
|
||||
assert.equal(await b.evaluate(`document.querySelector('#org-preset-unavailable').textContent`), 'Claude: No model account is connected. Codex: No model account is connected.');
|
||||
assert.doesNotMatch(await b.evaluate(`document.querySelector('.settings-helper').textContent`), /command/);
|
||||
|
||||
// Accounts are connected elsewhere; the select's next focus picks them up without a reload.
|
||||
on.claude = on.codex = true;
|
||||
await b.evaluate(refocus);
|
||||
@@ -230,6 +238,19 @@ test('no available preset points to Model setup, and a refocus or a shown page r
|
||||
assert.deepEqual(await look(), ready('claude', 'Answers with Claude.'));
|
||||
assert.equal(await bannerText(), '', 'a first choice is no switch');
|
||||
|
||||
// Focus and visibility events share the pending read, including a second new draft.
|
||||
holdRead = true;
|
||||
let pendingBefore = reads;
|
||||
await b.evaluate(refocus);
|
||||
for (let i = 0; i < 100 && reads === pendingBefore; i++) await new Promise(r => setTimeout(r, 20));
|
||||
assert.equal(reads, pendingBefore + 1);
|
||||
await b.evaluate(`${refocus};window.dispatchEvent(new Event('focus'));document.dispatchEvent(new Event('visibilitychange'));document.querySelector('#org-new-id').value='beta';document.querySelector('#org-new-form [data-write]').click()`);
|
||||
await new Promise(r => setTimeout(r, 200));
|
||||
const pendingReads = reads;
|
||||
holdRead = false; releaseReads.splice(0).forEach(resolve => resolve());
|
||||
await new Promise(r => setTimeout(r, 300));
|
||||
assert.equal(pendingReads, pendingBefore + 1, 'one pending presets request is reused');
|
||||
|
||||
// The owner picks Codex; a changed list that still offers it keeps it.
|
||||
await b.evaluate(`(()=>{const s=document.querySelector('#org-preset');s.value='codex';s.dispatchEvent(new Event('change'))})()`);
|
||||
note = 'Answers with Claude, now faster.';
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import vm from 'node:vm';
|
||||
import * as service from '../../organization/src/org-service.mjs';
|
||||
const context = { window: {}, structuredClone };
|
||||
vm.runInNewContext(readFileSync(new URL('../src/public/org-create.js', import.meta.url), 'utf8'), context);
|
||||
const model = { key: 'claude-claude-opus-5-5', module: 'cliproxy', upstream: 'claude', provider: 'anthropic', model: 'claude-opus-5-5', available: true, reason: null, harnesses: ['claude-code', 'pi'] };
|
||||
test('Quick Setup routes assistant and chief for every installed preset without launching or granting anything', async () => {
|
||||
const presets = await service.orgPresets({ env: { PATH: '/usr/bin:/bin' } });
|
||||
assert.ok(presets.length >= 3);
|
||||
for (const preset of presets) {
|
||||
const advanced = await service.templateRender('alpha', { preset: preset.name, model });
|
||||
const before = structuredClone(advanced);
|
||||
const quick = JSON.parse(JSON.stringify(context.window.MosaicOrgCreate.quickDocument(advanced)));
|
||||
assert.deepEqual(quick.roles.chief.vars, quick.roles.assistant.vars, preset.name);
|
||||
assert.deepEqual(quick.launch, advanced.launch, 'routing does not launch the chief or change the launcher');
|
||||
assert.deepEqual(quick.roles.chief.definition, advanced.roles.chief.definition);
|
||||
const expected = structuredClone(advanced); expected.roles.chief.vars = structuredClone(expected.roles.assistant.vars);
|
||||
assert.deepEqual(quick, expected, 'only chief routing changes');
|
||||
assert.deepEqual(advanced, before, 'Advanced Setup keeps its original template');
|
||||
assert.equal(advanced.roles.chief.vars, undefined);
|
||||
}
|
||||
});
|
||||
|
||||
test('Quick Setup routing completes the existing checklist when its recorded program check has passed', async () => {
|
||||
const { setupState } = await import('../../organization/src/setup/setup-routing.mjs');
|
||||
const template = await service.templateRender('alpha', { preset: 'cliproxy', model });
|
||||
const doc = context.window.MosaicOrgCreate.quickDocument(template);
|
||||
const instances = Object.fromEntries(Object.entries(doc.roles).map(([name, role]) => [name, role.vars]));
|
||||
const member = { id: 'alpha', doc };
|
||||
const result = await setupState[0].check({ members: [member], read: async (_org, name) => name === 'routes'
|
||||
? { harnesses: template.plugins.harness, models: Object.keys(template.launch.models), instances }
|
||||
: { harnessWatch: [{ name: doc.roles.assistant.vars.harness, state: 'fit', checkedAt: '2026-11-22T10:00:00Z' }] } });
|
||||
assert.equal(result.state, 'done');
|
||||
assert.equal(result.reason, 'Your assistant and chief have models, and their programs passed the recorded check.');
|
||||
});
|
||||
|
||||
test('Quick Setup copies route values without copying assistant authority or other role settings', () => {
|
||||
const doc = { roles: {
|
||||
aide: { definition: 'assistant', vars: { harness: 'example', model: 'example-model', thinking: 'medium', 'limits.authority': ['message.send'] } },
|
||||
lead: { definition: 'chief-of-staff', vars: { 'limits.network': 'none' } },
|
||||
}, launch: { by: 'lead', instances: ['aide'] } };
|
||||
const quick = JSON.parse(JSON.stringify(context.window.MosaicOrgCreate.quickDocument(doc)));
|
||||
assert.deepEqual(quick.roles.lead.vars, { 'limits.network': 'none', harness: 'example', model: 'example-model', thinking: 'medium' });
|
||||
assert.deepEqual(quick.launch, doc.launch);
|
||||
});
|
||||
|
||||
|
||||
test('Quick Setup preserves chief route keys the assistant does not define', () => {
|
||||
const doc = { roles: {
|
||||
assistant: { definition: 'assistant', vars: { harness: 'example', model: undefined } },
|
||||
chief: { definition: 'chief-of-staff', vars: { harness: 'old', model: 'kept-model', thinking: 'high' } },
|
||||
} };
|
||||
const quick = context.window.MosaicOrgCreate.quickDocument(doc);
|
||||
assert.deepEqual(JSON.parse(JSON.stringify(quick.roles.chief.vars)), { harness: 'example', model: 'kept-model', thinking: 'high' });
|
||||
assert.equal(doc.roles.chief.vars.harness, 'old');
|
||||
});
|
||||
@@ -14,7 +14,7 @@ test('organization header and footer never display null board values', async t =
|
||||
for (const [width, height] of [[1400, 900], [390, 844]]) {
|
||||
await b.viewport(width, height);
|
||||
await b.navigate(`http://127.0.0.1:${server.address().port}/#/orgs/alpha/`);
|
||||
await b.evaluate(`(async()=>{for(let i=0;i<150;i++){if(/Board:|No board/.test(document.querySelector('#board-url').textContent))return;await new Promise(r=>setTimeout(r,30))}throw Error('footer not loaded')})()`);
|
||||
await b.evaluate(`(async()=>{for(let i=0;i<150;i++){if(document.querySelector('#board-url').hidden)return;await new Promise(r=>setTimeout(r,30))}throw Error('footer not loaded')})()`);
|
||||
const text = await b.evaluate(`document.querySelector('header').textContent + ' ' + document.querySelector('footer').textContent`);
|
||||
assert.doesNotMatch(text, /\b(?:null|undefined)\b/i);
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ import { runInNewContext } from 'node:vm';
|
||||
const source = new URL('../src/public/processing.js', import.meta.url);
|
||||
const GEN = '12345678-1234-4234-8234-123456789abc';
|
||||
const flush = async () => { for (let i = 0; i < 8; i++) await new Promise(resolve => setImmediate(resolve)); };
|
||||
async function fixture({ send = true, halted = false, unknown = false, partial = false, confirm = true } = {}) {
|
||||
async function fixture({ send = true, halted = false, unknown = false, partial = false, confirm = true, organizations = false } = {}) {
|
||||
const nodes = new Map(), requests = [], events = new Map(), classes = new Set(); let confirmations = 0;
|
||||
for (const id of ['processing-controls', 'processing-state', 'processing-halt', 'processing-resume', 'processing-unavailable', 'processing-receipt', 'processing-banner'])
|
||||
nodes.set(id, { id, hidden: false, disabled: false, textContent: '', dataset: {}, listeners: new Map(), addEventListener(name, fn) { this.listeners.set(name, fn); } });
|
||||
const state = { version: 1, generation: GEN, halted, quiescent: !partial, remaining: partial ? 1 : 0, stopped: 0 };
|
||||
runInNewContext(readFileSync(source, 'utf8'), {
|
||||
document: { getElementById: id => nodes.get(id), body: { classList: { contains: name => classes.has(name) } },
|
||||
document: { documentElement: { hasAttribute: name => organizations && name === 'data-organizations' }, getElementById: id => nodes.get(id), body: { classList: { contains: name => classes.has(name) } },
|
||||
addEventListener: (name, fn) => events.set(name, fn),
|
||||
dispatchEvent: event => { if (event.type === 'mosaic-signed-out') classes.add('signed-out'); events.get(event.type)?.(event); } },
|
||||
Event, CustomEvent,
|
||||
@@ -33,6 +33,13 @@ async function fixture({ send = true, halted = false, unknown = false, partial =
|
||||
const click = async id => { await nodes.get(id).listeners.get('click')(); await flush(); };
|
||||
return { nodes, requests, events, state, click, confirmations: () => confirmations };
|
||||
}
|
||||
test('an organization Console without a selected organization never reads processing controls', async () => {
|
||||
const f = await fixture({ organizations: true });
|
||||
await f.events.get('hashchange')(); await flush();
|
||||
assert.deepEqual(f.requests, []);
|
||||
assert.equal(f.nodes.get('processing-controls').hidden, true);
|
||||
assert.equal(f.nodes.get('processing-banner').hidden, true);
|
||||
});
|
||||
test('interim read-only controls show CLI recovery, disable both writes and retain a halted banner across views', async () => {
|
||||
const f = await fixture({ send: false, halted: true });
|
||||
assert.equal(f.nodes.get('processing-halt').disabled, true); assert.equal(f.nodes.get('processing-resume').disabled, true);
|
||||
|
||||
@@ -220,7 +220,8 @@ test('Ride all confirms the stricter admission, paints skips and stand-in organi
|
||||
await wait(`document.querySelector("#proxy-ride-message").textContent===${JSON.stringify('west was not moved. Its bus is running, or its state could not be read. Stop or recover its bus, then move it.')}`);
|
||||
// Round 3 (P3): an SSO Console's org-forbidden in plain words, and the neutral fallback for a code the page does not know.
|
||||
for (const [n, reason, text] of [[2, 'org-forbidden', 'west was not moved. Moving organizations is not available on this Console yet. It works on a local development Console.'],
|
||||
[3, 'frobnicated', 'west was not moved. The change was refused (frobnicated).']]) {
|
||||
[3, 'no-riding-bus', 'west was not moved. No organization uses the model service yet, so no model list was read. Ride all first.'],
|
||||
[4, 'frobnicated', 'west was not moved. The change was refused (frobnicated).']]) {
|
||||
await b.evaluate(`window.__scenario['POST /api/proxy/admin/ride-move'] = { body: ${JSON.stringify({ moved: false, reason })} }`);
|
||||
await wait('document.querySelector("[data-ride-move=west]")?.disabled===false');
|
||||
await b.evaluate('document.querySelector("[data-ride-move=west]").click()');
|
||||
|
||||
@@ -192,6 +192,9 @@ test('settings-s4 review F2: a stand-in organization with its bus stopped reads
|
||||
assert.equal(item, "Gamma Home can't start: it uses stand-in models and its bus is stopped. Move it to your models under Use your models in every organization, then start its bus.");
|
||||
assert.equal(await b.evaluate('document.querySelector("[data-ride-move=gamma]").textContent'), 'Move Gamma Home');
|
||||
assert.equal(await b.evaluate('document.querySelector("[data-ride-move=gamma]").checkVisibility()'), true);
|
||||
await b.evaluate(`window.__s4.posts['/ride-move'] = { body: { moved: false, reason: 'no-riding-bus' } }; window.confirm = () => true; document.querySelector('[data-ride-move=gamma]').click()`);
|
||||
await wait(`document.querySelector('#proxy-ride-message').textContent.includes('was not moved.')`);
|
||||
assert.equal(await text('#proxy-ride-message'), 'Gamma Home was not moved. Your models could not be checked. Open Model setup to try again.');
|
||||
// The organizations that need nothing get no mark.
|
||||
assert.equal(await b.evaluate(mark('acme')), 'bus running');
|
||||
});
|
||||
|
||||
@@ -25,10 +25,16 @@ test('the first unfinished required row is next and failures and checking keep t
|
||||
});
|
||||
test('optional checks never change the count and not applicable is satisfied', () => {
|
||||
const s = derive([row('a', [], 'not-applicable'), row('b', ['a'], 'done'), row('worker', [], 'failed', false)]);
|
||||
assert.equal(s.complete, true); assert.equal(s.total, 2); assert.equal(s.done, 2); assert.equal(s.current, null);
|
||||
assert.equal(s.complete, true); assert.equal(s.total, 1); assert.equal(s.done, 1); assert.equal(s.current, null);
|
||||
assert.match(render(s), /Setup done/); assert.match(render(s), /Show checks/);
|
||||
assert.ok(!render(s).includes('setup-card'));
|
||||
});
|
||||
test('not needed rows stay visible without holding back or numbering later steps', () => {
|
||||
const s = derive([row('service', [], 'not-applicable'), row('account', ['service'], 'not-applicable'), row('org', ['account'], 'done'), row('chat', ['org'])]);
|
||||
assert.equal(s.total, 2); assert.equal(s.step, 2); assert.equal(s.current.id, 'chat');
|
||||
assert.equal(s.rows[0].state, 'not-applicable'); assert.equal(s.rows[1].state, 'not-applicable');
|
||||
assert.match(render(s), /Step 2 of 2/); assert.match(render(s), /Not needed/);
|
||||
});
|
||||
test('the checklist opens exactly one row, has one primary action and preserves completed evidence', () => {
|
||||
const s = derive([row('a'), row('b', ['a']), row('c', ['b'], 'done')]);
|
||||
const html = render(s);
|
||||
|
||||
@@ -5,6 +5,16 @@ import { startServer } from '../src/serve.mjs';
|
||||
import { createDevOwner } from '../src/dev-owner.mjs';
|
||||
|
||||
const row = (id, check) => ({ id, title: 'Check this part', purpose: 'See whether it works.', required: true, order: { after: [] }, fix: null, check });
|
||||
test('a failed members read leaves both model rows unavailable', async () => {
|
||||
const body = await readSetup({ organizations: { members: async () => { throw Error('private fault'); } }, service: async () => ({ release: {}, init: {}, unit: {} }) });
|
||||
for (const id of ['model-service.running', 'model-account.connected']) assert.equal(body.rows.find(r => r.id === id).code, 'setup-check-unavailable');
|
||||
});
|
||||
test('non-proxy organizations skip both model rows without making account or service reads', async () => {
|
||||
const body = await readSetup({ organizations: { members: async () => [{ id: 'local', doc: { plugins: {} } }] },
|
||||
sources: [async () => (await import('../../model-proxy/src/setup-state.mjs')).setupState],
|
||||
service: () => { throw Error('unneeded service'); }, accounts: () => { throw Error('unneeded accounts'); } });
|
||||
for (const id of ['model-service.running', 'model-account.connected']) assert.equal(body.rows.find(r => r.id === id).state, 'not-applicable');
|
||||
});
|
||||
test('setup collects part rows, isolates throws and never reflects exception text', async () => {
|
||||
const sources = [async () => [row('a', () => ({ state: 'done', reason: 'Ready.' })), row('b', () => { throw Error('secret path'); })]];
|
||||
const result = await readSetup({ sources, organizations: { members: async () => [] }, session: {} });
|
||||
@@ -152,12 +162,15 @@ test('an existing organization uses its own proxy truth even when the root owner
|
||||
let orgEntries = [];
|
||||
const org = { id: 'separate', options: async () => ({ bus: { routes: async () => ({ catalogue: { status: 'ready', models: [{ upstream: 'claude', available: true }] } }) }, proxyCall: async () => ({ accounts: orgEntries }) }) };
|
||||
const read = await accountServer(t, { proxyAdmin, organizations: { list: async () => [], members: async () => [org] } });
|
||||
assert.equal(accountRow((await read()).body).state, 'next'); assert.equal(instanceReads, 0);
|
||||
const first = (await read()).body;
|
||||
assert.equal(accountRow(first).state, 'next');
|
||||
assert.match(first.rows.find(r => r.id === 'worker.ready').reason, /Account: connected/);
|
||||
assert.equal(instanceReads, 1, 'only the worker row uses the instance account');
|
||||
// The contribution must also prefer organization truth when both readers are present.
|
||||
const body = await readSetup({ organizations: { members: async () => [org] }, accounts: proxyAdmin.setupAccounts, service: runningService, docker: async () => false, runs: () => [] });
|
||||
assert.equal(accountRow(body).state, 'next'); assert.equal(instanceReads, 0);
|
||||
assert.equal(accountRow(body).state, 'next'); assert.equal(instanceReads, 2);
|
||||
orgEntries = [{ provider: 'claude', status: 'active' }];
|
||||
assert.equal(accountRow((await read()).body).state, 'done'); assert.equal(instanceReads, 0);
|
||||
assert.equal(accountRow((await read()).body).state, 'done'); assert.equal(instanceReads, 3);
|
||||
});
|
||||
test('slow, busy, paused and refused owner reads stay inside the setup deadline and disclose no exception text', async t => {
|
||||
for (const failure of ['slow', 'proxy-admin-busy', 'paused', 'human-required']) {
|
||||
|
||||
@@ -241,6 +241,22 @@ const HOLD_CONFLICT_READ = `(() => {
|
||||
})()`;
|
||||
const SAVE_AS = title => `(() => { const f = document.querySelector("#tb-dialog form"); f.title.value = ${JSON.stringify(title)}; f.requestSubmit(); })()`;
|
||||
const STATUS = 'document.querySelector("#tb-dialog [data-tb-form-status]")?.textContent';
|
||||
test('new tasks explain empty and malformed requirement ids inline and focus the field', async t => {
|
||||
const { b, wait, orgs } = await open(t);
|
||||
await b.evaluate('document.querySelector("[data-tb-new]").click()');
|
||||
await wait('document.querySelector("#tb-dialog").open');
|
||||
for (const value of ['', 'REQ-web-0']) {
|
||||
await b.evaluate(`(()=>{const f=document.querySelector('#tb-dialog form');f.title.value='A task';f.requirement.value=${JSON.stringify(value)};f.requestSubmit()})()`);
|
||||
assert.equal(await b.evaluate('document.activeElement.name'), 'requirement');
|
||||
assert.equal(await b.evaluate('document.querySelector("#tb-req-error").textContent'), 'Type a requirement ID using capital letters and a number, for example REQ-WEB-1.');
|
||||
assert.equal(await b.evaluate('document.querySelector("#tb-req-error").getAttribute("role")'), 'alert');
|
||||
assert.equal(await b.evaluate('document.querySelector("#tb-dialog [name=requirement]").getAttribute("aria-invalid")'), 'true');
|
||||
}
|
||||
assert.deepEqual(orgs.writes, []);
|
||||
await b.evaluate(`(()=>{const f=document.querySelector('#tb-dialog form');f.requirement.value='REQ-WEB-1';f.requestSubmit()})()`);
|
||||
await wait('!document.querySelector("#tb-dialog").open');
|
||||
assert.equal(orgs.writes[0][2].requirement, 'REQ-WEB-1');
|
||||
});
|
||||
|
||||
test('an Archive conflict reopens on the current task and never sends the old digest again', async t => {
|
||||
const { b, wait, orgs } = await open(t);
|
||||
|
||||
@@ -36,7 +36,7 @@ const shot = async (b, name, width) => {
|
||||
await b.evaluate('document.querySelector("#setup-step-worker").scrollIntoView({ block: "start" }); true');
|
||||
await b.screenshot(join(SHOTS, `${name}-${width}.png`));
|
||||
};
|
||||
const HOW = 'Choosing the worker model on this page is not built yet. To change it, edit execution.provider and execution.model in the config.';
|
||||
const HOW = 'Choosing the model for background work on this page is not available yet. Ask the person who manages this installation to change it.';
|
||||
|
||||
test('the owner sees card 5: the config\'s model, that the config wins, the usable list, and no save', { timeout: 90000 }, async t => {
|
||||
for (const width of [1440, 390]) {
|
||||
@@ -48,7 +48,7 @@ test('the owner sees card 5: the config\'s model, that the config wins, the usab
|
||||
const c = await card(b);
|
||||
assert.equal(c.hidden, false); assert.equal(c.badge, 'Done');
|
||||
assert.equal(c.summary, 'Worker runs use zai/glm-5.3.');
|
||||
assert.equal(c.using, 'Worker runs use zai/glm-5.3. The config names it (execution.provider and execution.model), and the config always wins.');
|
||||
assert.equal(c.using, 'Worker runs use zai/glm-5.3. It is set for this installation and takes priority over a choice saved here.');
|
||||
assert.equal(c.standing, 'An account serves it for pi, and it is switched on.');
|
||||
assert.deepEqual(c.models, ['zai/glm-5.3 zai / glm-5.3', 'zai/glm-5.3-air zai / glm-5.3-air']);
|
||||
assert.equal(c.how, HOW);
|
||||
@@ -64,16 +64,19 @@ test('the owner sees card 5: the config\'s model, that the config wins, the usab
|
||||
|
||||
test('a stored choice the config overrides says it has no effect; a model switched off, not served or Claude needs the owner', { timeout: 90000 }, async t => {
|
||||
const cases = [
|
||||
[view({ using: { from: 'config', provider: 'zai', model: null, standing: 'unset' } }), 'bad', 'The model choice is incomplete.',
|
||||
'The model choice is incomplete, so background work cannot start. Ask the person who manages this installation to finish choosing a model.', null],
|
||||
[view({ using: { from: 'choice', provider: 'zai', model: 'glm-5.3', standing: 'usable' } }), 'done', null, null, null],
|
||||
[view({ choice: { state: 'set', provider: 'zai', model: 'glm-5.3-air', revision: 2, updatedAt: null, standing: 'usable' } }), 'done', null, null,
|
||||
'A choice saved earlier (zai/glm-5.3-air) has no effect while the config names a worker model.'],
|
||||
'A choice saved earlier (zai/glm-5.3-air) has no effect while this installation has its own model set for background work.'],
|
||||
[view({ using: { from: 'config', provider: 'zai', model: 'glm-5.3-flash', standing: 'off' } }), 'bad', 'It is switched off.',
|
||||
'It is switched off, so worker runs refuse to start. Switch it on under Accounts and models, Models offered, or name another model in the config.', null],
|
||||
'It is switched off, so background work cannot start. Switch it on under Accounts and models, Models offered, or ask the person who manages this installation to choose another model.', null],
|
||||
[view({ using: { from: 'config', provider: 'zai', model: 'gone', standing: 'not-served' } }), 'bad', 'No account serves it for pi.', 'No account serves it for pi now, so worker runs refuse to start.', null],
|
||||
[view({ using: { from: 'config', provider: 'anthropic', model: 'claude-opus-5-5', standing: 'claude-model' } }), 'bad', 'It is a Claude model.',
|
||||
'It is a Claude model. Claude models run only in the Claude harness, so worker runs refuse to start.', null],
|
||||
[view({ using: { from: 'config', provider: 'zai', model: 'glm-5.3', standing: 'unknown' }, catalogue: 'unavailable', models: [] }), 'off', 'Whether it can run is not known.',
|
||||
'No organization\'s model list could be read, so whether it can run now is not known.', null],
|
||||
[view({ choice: { state: 'unreadable' } }), 'done', null, null, 'A choice saved earlier cannot be read. It has no effect while the config names a worker model.'],
|
||||
[view({ choice: { state: 'unreadable' } }), 'done', null, null, 'A choice saved earlier cannot be read. It has no effect while this installation has its own model set for background work.'],
|
||||
[view({ using: { from: 'config', provider: 'zai', model: 'glm-5.3', standing: 'unknown' }, catalogue: 'none', models: [] }), 'off', 'Whether it can run is not known.',
|
||||
'No organization is active, so whether it can run now is not known.', null],
|
||||
[view({ using: { from: 'config', provider: 'zai', model: 'glm-5.3', standing: 'unknown' }, catalogue: 'disabled', models: [] }), 'off', 'Whether it can run is not known.',
|
||||
@@ -87,10 +90,12 @@ test('a stored choice the config overrides says it has no effect; a model switch
|
||||
const c = await card(b);
|
||||
if (standing) {
|
||||
assert.equal(c.standing, standing);
|
||||
assert.equal(c.summary, `Worker runs use ${worker.using.provider}/${worker.using.model}. ${short}`);
|
||||
assert.equal(c.summary, `Worker runs use ${worker.using.provider ?? '(none)'}/${worker.using.model ?? '(none)'}. ${short}`);
|
||||
}
|
||||
assert.equal(c.choice, choice);
|
||||
assert.equal(c.how, HOW);
|
||||
assert.doesNotMatch([c.using, c.standing, c.choice, c.how].join(' '), /execution\.|\bconfig\b|\.json/);
|
||||
if (worker.using.from === 'choice') assert.equal(c.using, 'Worker runs use zai/glm-5.3, the choice saved here. No model is set for background work in this installation.');
|
||||
const why = { none: 'No organization is active', disabled: 'No organization has the model service on' }[worker.catalogue] ?? 'No organization\'s model list could be read';
|
||||
if (worker.catalogue !== 'ready') assert.deepEqual(c.models, [`Not known. ${why}.`]);
|
||||
if (worker.using.standing === 'off') { await shot(b, 'worker-config-off', 1440); await b.viewport(390, 844); await shot(b, 'worker-config-off', 390); }
|
||||
@@ -103,7 +108,7 @@ test('a stored choice the config overrides says it has no effect; a model switch
|
||||
test('the mock adapter, no model at all, and a view that could not be read', { timeout: 90000 }, async t => {
|
||||
const cases = [
|
||||
[view({ harness: 'mock', takesModel: false, using: { from: 'config', provider: 'fixture', model: 'fixture-deterministic', standing: 'unused' }, models: [] }), 'done', 'Worker runs use the mock adapter, which takes no model.', ['None. This adapter takes no model.']],
|
||||
[view({ using: null }), 'bad', 'No worker model is set. Set execution.provider and execution.model in the config.', null],
|
||||
[view({ using: null }), 'bad', 'No model is set for background work. Ask the person who manages this installation to choose one.', null],
|
||||
[view({ models: [] }), 'done', 'Worker runs use zai/glm-5.3.', ['None. No account serves a model for pi that is switched on and is not a Claude model.']],
|
||||
[null, 'off', 'The worker model could not be read.', null],
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user