Add plugin-based organization quick setup

This commit is contained in:
jason.woltje committed 2026-11-07 21:43:03 -06:00
1 parent bc728e5927
commit c09570d696
15 files changed
+374 -22

No files matched your search

+14
View File
@@ -48,6 +48,20 @@ hold booleans. The harness receives it as data. Modules return named refusals fo
they never return credentials, commands or endpoints. The host rejects an
unknown or ambiguous legacy mapping and validates transport data before use.
### Organization presets
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
`available({ env })` function returning `{ ok: true }` or `{ ok: false,
reason }`, and `overlay({ thinking })` returning `{ plugins, launch,
assistantVars, vars? }`. The loader discovers installed modules; the
organization service rejects duplicate names, invalid metadata, unknown
presets and unsupported thinking levels. Availability reasons are displayed
in the Console and must never contain credential values or private paths.
The fixture provider supplies the legacy `--fixture local` alias; the
Claude Code harness checks its preflight using the Console's environment.
A `search-source` answers the broker's `web.search` (REQ-HARN-2, REQ-PLUG-2, decision 0b81b0c5): `search(settings, query, deps, { signal })` resolves `{ query, total, results: [{ title, url, snippet }] }` or throws a `WebRefusal`; `signal` is an `AbortSignal` the broker fires at its deadline, and a module must stop its request when it does. The kind switches on one module, and the module's name is the source: `searxng-url` queries the operator's SearXNG at the business var `web.searxng`; `searxng-bundled` queries the SearXNG the Stack installs, at a fixed loopback address (the install is REQ-INST-1's first component); `harness-builtin` is served by the harness itself: a granted claude-code role gets WebSearch and WebFetch, the broker serves no web verbs, and `search` only refuses. The choice and every change to it are the `plugins` setting, logged in `changes.jsonl` by the plug-in setter.
Adding a kind, or changing a kind's exports, interface version or switch,
@@ -69,6 +69,19 @@ export function preflight({ env, proxy = null }) {
return null;
}
export function orgPresets() {
return [{ name: 'claude-code', label: "Claude via this machine's sign-in",
description: 'Use Claude Code with the credentials available to this Console.',
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 };
},
overlay: ({ thinking }) => ({ plugins: { channel: ['cli', 'webui'], harness: ['claude-code'] },
launch: { by: 'chief', instances: ['assistant'], models: { opus: { provider: 'anthropic', model: 'claude-opus-5-5' } } },
assistantVars: { harness: 'claude-code', model: 'opus', thinking } }) }];
}
// `claude --version` from the binary sessions run, or null when it doesn't answer.
export function version({ env }) {
const r = spawnSync(env.MOSAIC_CLAUDE_BIN || "claude", ["--version"], { encoding: "utf8", timeout: 10000, env });
@@ -16,6 +16,12 @@ export const FIXTURE_TEMPLATE = Object.freeze({
assistantVars: { harness: 'pi', model: FIXTURE_KEY_NAME, thinking: 'off' },
vars: { 'bus.tester': true },
});
// Organization setup is supplied by this module, alongside its model route.
export function orgPresets() {
return [{ name: 'fixture', label: 'Test model', description: 'Canned replies, no cost.',
thinking: { levels: ['off'], default: 'off' }, available: () => ({ ok: true }),
overlay: ({ thinking }) => ({ ...structuredClone(FIXTURE_TEMPLATE), assistantVars: { ...FIXTURE_TEMPLATE.assistantVars, thinking } }) }];
}
const HARNESSES = Object.freeze(['pi']);
const TRANSPORT = Object.freeze({ routeId: 'fixture', endpoint: 'root', api: 'anthropic-messages', piProvider: 'mosaic-fixture', compat: null });