git mv packages/business -> packages/organization (@mosaic/organization). The old package stays as one-line re-export shims of each moved module, with src/business.mjs re-exporting src/organization-config.mjs and src/cli.mjs forwarding to the moved executable. BusinessError is OrganizationConfigError (one constructor, name kept BusinessError); OrganizationError stays distinct. The bus adapter gains organization-context.mjs (busOrganization), with business.mjs (busBusiness) as the same function. Import consumers, manifests, the lockfile, scripts/mosaic, stack-copy.sh COPY_PATHS (both roots), seat sandbox RUNNER_FILES and the copy closure walker (organization-imports.mjs, both roots required) move to the new path. v1 serialization, v1 writers and the stage A fixtures are unchanged; the stage A contract tests stay where they were and pass as before.
47 lines
2.3 KiB
JavaScript
47 lines
2.3 KiB
JavaScript
// P3: the proxy account is a declared credential source, never a secret value.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { checkAccount, checkModels } from '../src/launch.mjs';
|
|
|
|
test('P3 proxy model validation preserves each explicit wire route and the proxy model id', () => {
|
|
for (const route of ['anthropic', 'glm', 'codex']) {
|
|
const models = { selected: { provider: 'proxy', model: 'proxy-only-id', route } };
|
|
assert.deepEqual(checkModels(models), models, route);
|
|
}
|
|
});
|
|
|
|
test('P3 a proxy model without route refuses proxy-route-missing', () => {
|
|
assert.throws(() => checkModels({ selected: { provider: 'proxy', model: 'proxy-only-id' } }), {
|
|
code: 'proxy-route-missing',
|
|
});
|
|
});
|
|
|
|
test('proxy route syntax is bounded and unknown names are deferred to the provider module', () => {
|
|
for (const route of ['openai-codex', 'unknown']) assert.equal(checkModels({ selected: { provider: 'proxy', model: 'proxy-only-id', route } }).selected.route, route);
|
|
for (const route of ['', null, 7, '../bad']) {
|
|
assert.throws(() => checkModels({ selected: { provider: 'proxy', model: 'proxy-only-id', route } }), {
|
|
code: 'proxy-route-unknown',
|
|
});
|
|
}
|
|
});
|
|
|
|
test('P3 nonproxy models retain their provider/model-only shape and reject route metadata', () => {
|
|
assert.deepEqual(checkModels({ selected: { provider: 'zai', model: 'glm-fixture' } }), {
|
|
selected: { provider: 'zai', model: 'glm-fixture' },
|
|
});
|
|
assert.throws(() => checkModels({ selected: { provider: 'zai', model: 'glm-fixture', route: 'glm' } }), /unsupported/);
|
|
});
|
|
|
|
test('P3 launch.account accepts the proxy credential source without naming host variables', () => {
|
|
assert.deepEqual(checkAccount({ name: 'proxy', credential: 'proxy' }), { name: 'proxy', credential: 'proxy' });
|
|
});
|
|
|
|
test('P3 existing environment-set accounts retain their validated representation', () => {
|
|
for (const credential of ['CLAUDE_CODE_OAUTH_TOKEN', 'ANTHROPIC_API_KEY', 'ANTHROPIC_AUTH_TOKEN+ANTHROPIC_BASE_URL']) {
|
|
assert.deepEqual(checkAccount({ name: 'max', credential }), { name: 'max', credential });
|
|
}
|
|
for (const credential of ['', 'fx332-fake', 'proxy+ANTHROPIC_API_KEY', 'PROXY+proxy']) {
|
|
assert.throws(() => checkAccount({ name: 'proxy', credential }), /launch\.account\.credential/);
|
|
}
|
|
});
|