@ai-ecoverse/slicc-agent 7.34.3 → 7.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -11
- package/dist/agent.js +4 -0
- package/dist/agent.js.map +2 -2
- package/dist/approvals/index.js +4 -1
- package/dist/approvals/index.js.map +2 -2
- package/dist/approvals/judge.js +2 -1
- package/dist/approvals/judge.js.map +2 -2
- package/dist/approvals/owner-tools.js +165 -0
- package/dist/approvals/owner-tools.js.map +7 -0
- package/dist/approvals/policy.js +22 -3
- package/dist/approvals/policy.js.map +2 -2
- package/dist/approvals/record.js +1 -1
- package/dist/approvals/record.js.map +2 -2
- package/dist/control.js.map +2 -2
- package/dist/freezer/v6.js +3 -2
- package/dist/freezer/v6.js.map +2 -2
- package/dist/guests/guard.js +12 -8
- package/dist/guests/guard.js.map +2 -2
- package/dist/host.js +5 -1
- package/dist/host.js.map +2 -2
- package/dist/index.js.map +2 -2
- package/dist/kernel/agent-users.js +43 -3
- package/dist/kernel/agent-users.js.map +2 -2
- package/dist/local.js +159 -0
- package/dist/local.js.map +7 -0
- package/dist/main.js +25 -14
- package/dist/main.js.map +2 -2
- package/dist/providers.js +29 -1
- package/dist/providers.js.map +2 -2
- package/dist/scoops/index.js +30 -16
- package/dist/scoops/index.js.map +2 -2
- package/dist/secrets/credentials.js +4 -2
- package/dist/secrets/credentials.js.map +2 -2
- package/dist/services.js +4 -0
- package/dist/services.js.map +2 -2
- package/dist/settings.js +50 -13
- package/dist/settings.js.map +2 -2
- package/dist/spectrum/approvals-port.js +4 -1
- package/dist/spectrum/approvals-port.js.map +2 -2
- package/dist/types/agent.d.ts +2 -0
- package/dist/types/approvals/judge.d.ts +3 -3
- package/dist/types/approvals/owner-tools.d.ts +39 -0
- package/dist/types/approvals/policy.d.ts +6 -0
- package/dist/types/approvals/record.d.ts +7 -3
- package/dist/types/control.d.ts +1 -1
- package/dist/types/guests/guard.d.ts +3 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/kernel/agent-users.d.ts +3 -1
- package/dist/types/local.d.ts +38 -0
- package/dist/types/main.d.ts +20 -0
- package/dist/types/providers.d.ts +3 -1
- package/dist/types/scoops/index.d.ts +10 -3
- package/dist/types/secrets/credentials.d.ts +1 -1
- package/dist/types/services.d.ts +6 -2
- package/dist/types/settings.d.ts +1 -0
- package/dist/types/spectrum/approvals-port.d.ts +1 -0
- package/package.json +2 -2
package/dist/scoops/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/scoops/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { Harness, Registry, ToolRegistration } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport { type Agents, live } from '../agents.ts';\nimport type { ProcessGroups } from '../kernel/groups.ts';\nimport { type Layout, LEGACY } from '../layout.ts';\nimport type { Licks } from '../licks/licks.ts';\nimport {\n DEFAULT_LIMITS,\n loadRoles,\n PACKAGE_ROOTS,\n packageDirs,\n type Roles,\n} from '../roles/roles.ts';\nimport type { Choosable } from '../selection.ts';\nimport { cliCommand, setupWorkflows, workflowEngine } from '../workflow/index.ts';\nimport { type CliOptions, createCli, RUN_DIR } from './cli.ts';\nimport { scoopsExtension, scoopTasks } from './extension.ts';\nimport {\n CONTROL_DIR,\n type ControlPlane,\n controlPlane,\n type PlaneOptions,\n PROTOCOL_MARK,\n} from './requests.ts';\nimport { choosable, createScoops, type Scoops, type ScoopsHost } from './service.ts';\n\nexport const BUILTIN_ROLES = ['scout', 'worker', 'reviewer', 'oracle', 'delegate', 'gelatiere'];\nexport const PNPM_HOME = '/home/.local/share/pnpm';\nexport const BIN_DIR = '/usr/local/bin';\n\nexport type Assets = (path: string) => Promise<string>;\n\nexport function packageAssets(base: URL = new URL('../../', import.meta.url)): Assets {\n return async (path) => {\n const response = await fetch(new URL(path, base));\n if (!response.ok) throw new Error(`${path}: ${response.status}`);\n return response.text();\n };\n}\n\nexport interface AttachOptions {\n harness: Harness;\n agents: Agents;\n groups: ProcessGroups;\n env: ExecutionEnv;\n home: string;\n assets?: Assets;\n binDir?: string;\n controlDir?: string;\n sweepEvery?: number;\n alive?: (pid: number) => Promise<boolean>;\n memory?: CliOptions['memory'];\n gelatiere?: CliOptions['gelatiere'];\n freezer?: CliOptions['freezer'];\n models?: CliOptions['models'];\n panel?: CliOptions['panel'];\n webhook?: CliOptions['webhook'];\n sprinkle?: CliOptions['sprinkle'];\n mcp?: (names: readonly string[]) => ToolRegistration[];\n layout?: Layout;\n spools?: Spools;\n agentDir?: string;\n}\n\nexport interface Spools {\n users(): readonly string[];\n prepare(user: string, dir: string, context: Context): Promise<void>;\n}\n\nexport interface ScoopsRuntime {\n roles(context: Context): Promise<Roles>;\n plane: ControlPlane;\n close(context: Context): Promise<void>;\n}\n\nexport interface ScoopsSetup {\n scoops: Scoops;\n choosable: Choosable;\n attach(options: AttachOptions, context: Context): Promise<ScoopsRuntime>;\n}\n\nexport const COMMANDS = ['agent', 'subagent', 'memory', 'gelatiere', 'freezer', 'models', 'panel'];\n\nexport const RETIRED_COMMANDS = ['sprinkle'];\n\nexport async function pnpmHomeOf(env: ExecutionEnv, context: Context): Promise<string> {\n let out = '';\n const ran = await env\n .exec(\n 'printf %s \"$PNPM_HOME\"',\n {\n onOutput: (text) => {\n out += text;\n },\n },\n context\n )\n .catch(() => undefined);\n return ran?.ok && ran.value.exitCode === 0 && /^\\/\\S*$/.test(out) ? out : PNPM_HOME;\n}\n\nexport interface Installed {\n done: boolean;\n skipped: string[];\n}\n\nasync function theirs(env: ExecutionEnv, path: string, context: Context): Promise<boolean> {\n const found = await env.fileInfo(path, context);\n if (!found.ok) return found.error.code !== 'not_found';\n if (found.value.kind !== 'file') return true;\n const read = await env.readTextFile(path, context);\n return !read.ok || !read.value.includes(PROTOCOL_MARK);\n}\n\nasync function install(\n env: ExecutionEnv,\n script: string,\n binDir: string,\n context: Context\n): Promise<Installed> {\n const skipped: string[] = [];\n if (!(await env.createDir(binDir, { recursive: true }, context)).ok)\n return { done: false, skipped };\n for (const name of COMMANDS) {\n const path = `${binDir}/${name}`;\n if (await theirs(env, path, context)) {\n skipped.push(name);\n continue;\n }\n if (!(await env.writeFile(path, script, context)).ok) return { done: false, skipped };\n const mode = await env.exec(['chmod', '755', path], undefined, context);\n if (!mode.ok || mode.value.exitCode !== 0) return { done: false, skipped };\n }\n for (const name of RETIRED_COMMANDS) {\n const text = await env.readTextFile(`${binDir}/${name}`, context);\n if (text.ok && text.value.includes(PROTOCOL_MARK))\n await env.remove(`${binDir}/${name}`, { force: true }, context);\n }\n return { done: true, skipped };\n}\n\nexport async function installCommands(\n env: ExecutionEnv,\n script: string,\n binDir: string,\n context: Context,\n warn: (message: string) => void = (message) => console.warn(message)\n): Promise<Installed> {\n const installed = await install(env, script, binDir, context).catch(\n (): Installed => ({ done: false, skipped: [] })\n );\n if (installed.skipped.length) {\n const paths = installed.skipped.map((name) => `${binDir}/${name}`).join(', ');\n warn(`slicc-agent: left ${paths} alone, because it isn't slicc-agent's command`);\n }\n if (installed.done) await retire(env, binDir, context).catch(() => undefined);\n return installed;\n}\n\nexport async function retire(env: ExecutionEnv, binDir: string, context: Context) {\n const old = `${await pnpmHomeOf(env, context)}/bin`;\n if (old === binDir) return;\n for (const name of [...COMMANDS, ...RETIRED_COMMANDS]) {\n const path = `${old}/${name}`;\n const text = await env.readTextFile(path, context);\n if (text.ok && text.value.includes(PROTOCOL_MARK))\n await env.remove(path, { force: true }, context);\n }\n}\n\nfunction mirror(agents: Agents, env: ExecutionEnv) {\n return async (context: Context) => {\n for (const [id, record] of Object.entries(agents.state().scoops)) {\n const state = record.gone ? 'gone' : live(record) ? 'live' : 'stopped';\n const metadata = {\n handle: record.folder,\n id,\n name: record.name,\n role: record.role,\n cone: record.cone,\n state,\n };\n await env.writeFile(\n `${RUN_DIR}/${record.folder}/metadata.json`,\n `${JSON.stringify(metadata, null, 2)}\\n`,\n context\n );\n }\n };\n}\n\nfunction planeOf(\n env: ExecutionEnv,\n cli: ReturnType<typeof createCli>,\n options: AttachOptions,\n context: Context\n): ControlPlane {\n const common: PlaneOptions & { dir: string } = {\n ...(options.sweepEvery ? { sweepEvery: options.sweepEvery } : {}),\n mirror: mirror(options.agents, env),\n dir: options.controlDir ?? CONTROL_DIR,\n };\n if (!options.spools) return controlPlane(env, cli, common);\n return spooled(env, cli, options.spools, options.agents, common, context);\n}\n\nfunction spooled(\n env: ExecutionEnv,\n cli: ReturnType<typeof createCli>,\n spools: Spools,\n agents: Agents,\n options: PlaneOptions & { dir: string },\n context: Context\n): ControlPlane {\n const planes = new Map<string, Promise<ControlPlane | undefined>>();\n let off: () => void = () => undefined;\n let chain: Promise<unknown> = Promise.resolve();\n const open = async (user: string): Promise<ControlPlane | undefined> => {\n const dir = `${options.dir}/${user}`;\n try {\n await spools.prepare(user, dir, context);\n const plane = controlPlane(env, cli, { ...options, dir, user });\n await plane.start(context);\n return plane;\n } catch {\n planes.delete(user);\n return undefined;\n }\n };\n const sync = () => {\n const step = async () => {\n const wanted = new Set(spools.users());\n for (const user of wanted)\n if (!planes.has(user)) {\n const opened = open(user);\n planes.set(user, opened);\n await opened;\n }\n for (const [user, plane] of [...planes])\n if (!wanted.has(user)) {\n planes.delete(user);\n await (await plane)?.close(context);\n }\n };\n chain = chain.then(step, step);\n return chain;\n };\n const all = async () =>\n (await Promise.all(planes.values())).filter((plane): plane is ControlPlane => !!plane);\n return {\n async start() {\n off = agents.onChange(() => void sync());\n await sync();\n },\n async sweep(using) {\n for (const plane of await all()) await plane.sweep(using);\n },\n async close(using) {\n off();\n await chain;\n for (const plane of await all()) await plane.close(using);\n planes.clear();\n },\n };\n}\n\nexport function setupScoops(\n registry: Registry,\n licks: Licks,\n fileTools: readonly ToolRegistration[] = []\n): ScoopsSetup {\n let bind: (host: ScoopsHost) => void = () => undefined;\n const host = new Promise<ScoopsHost>((resolve) => {\n bind = resolve;\n });\n const lookup = () => host;\n const tasks = scoopTasks(lookup);\n const scoops = createScoops(host, () => tasks);\n let cached: Roles = { roles: [], warnings: [], limits: { ...DEFAULT_LIMITS } };\n let layout = LEGACY;\n registry.install(scoopsExtension(tasks, () => layout));\n const workflows = setupWorkflows(registry);\n return {\n scoops,\n choosable: choosable(fileTools),\n async attach(options, context) {\n const { harness, agents, groups, env, home } = options;\n const assets = options.assets ?? packageAssets();\n layout = options.layout ?? LEGACY;\n bind({\n harness,\n agents,\n licks,\n tools: fileTools,\n groups,\n files: env,\n layout,\n exclude: [workflows.extension],\n ...(options.mcp ? { mcp: options.mcp } : {}),\n });\n const builtin = async () => {\n const out: { path: string; text: string }[] = [];\n for (const name of BUILTIN_ROLES) {\n const path = `packages/vfs-root/agents/${name}.md`;\n out.push({ path: `builtin:${name}`, text: await assets(path) });\n }\n return out;\n };\n const roles = async (using: Context) => {\n cached = await loadRoles(\n {\n files: env,\n builtin,\n dirs: [\n ...(await packageDirs(env, PACKAGE_ROOTS, using)).map((dir) => ({\n source: 'package' as const,\n dir,\n })),\n { source: 'user', dir: `${options.agentDir ?? `${home}/.pi/agent`}/agents` },\n ],\n settingsPath: `${options.agentDir ?? `${home}/.pi/agent`}/settings.json`,\n },\n using\n );\n return cached;\n };\n await roles(context).catch(() => cached);\n const script = await assets('bin/agent').catch(() => undefined);\n if (script) {\n const binDir = options.binDir ?? BIN_DIR;\n await installCommands(env, script, binDir, context);\n }\n const cli = createCli({\n env,\n harness,\n agents,\n scoops,\n roles: () => roles(context),\n ...(options.alive ? { alive: options.alive } : {}),\n ...(options.memory ? { memory: options.memory } : {}),\n ...(options.gelatiere ? { gelatiere: options.gelatiere } : {}),\n ...(options.freezer ? { freezer: options.freezer } : {}),\n ...(options.models ? { models: options.models } : {}),\n layout,\n ...(options.panel ? { panel: options.panel } : {}),\n ...(options.webhook ? { webhook: options.webhook } : {}),\n sprinkle: options.sprinkle,\n workflow: cliCommand(workflows.workflows, layout, env, agents),\n licks,\n });\n workflows.attach({\n harness,\n agents,\n scoops,\n roles,\n env,\n layout,\n engine: workflowEngine(),\n envFor: async (user, using) => (await layout.envFor(user, using)) ?? env,\n });\n const plane = planeOf(env, cli, options, context);\n await plane.start(context);\n return { roles, plane, close: (using) => plane.close(using) };\n },\n };\n}\n\nexport type { Rewound, Scoops } from './service.ts';\n"],
|
|
5
|
-
"mappings": "AAGA,SAAsB,YAAY;AAElC,SAAsB,cAAc;AAEpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,YAAY,gBAAgB,sBAAsB;AAC3D,SAA0B,WAAW,eAAe;AACpD,SAAS,iBAAiB,kBAAkB;AAC5C;AAAA,EACE;AAAA,EAEA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,WAAW,oBAAkD;AAE/D,MAAM,gBAAgB,CAAC,SAAS,UAAU,YAAY,UAAU,YAAY,WAAW;AACvF,MAAM,YAAY;AAClB,MAAM,UAAU;AAIhB,SAAS,cAAc,OAAY,IAAI,IAAI,UAAU,YAAY,GAAG,GAAW;AACpF,SAAO,OAAO,SAAS;AACrB,UAAM,WAAW,MAAM,MAAM,IAAI,IAAI,MAAM,IAAI,CAAC;AAChD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,GAAG,IAAI,KAAK,SAAS,MAAM,EAAE;AAC/D,WAAO,SAAS,KAAK;AAAA,EACvB;AACF;
|
|
4
|
+
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { Harness, Registry, ToolRegistration } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport { type Agents, live } from '../agents.ts';\nimport type { ProcessGroups } from '../kernel/groups.ts';\nimport { type Layout, LEGACY } from '../layout.ts';\nimport type { Licks } from '../licks/licks.ts';\nimport {\n DEFAULT_LIMITS,\n loadRoles,\n PACKAGE_ROOTS,\n packageDirs,\n type Roles,\n} from '../roles/roles.ts';\nimport type { Choosable } from '../selection.ts';\nimport { cliCommand, setupWorkflows, workflowEngine } from '../workflow/index.ts';\nimport { type CliOptions, createCli, RUN_DIR } from './cli.ts';\nimport { scoopsExtension, scoopTasks } from './extension.ts';\nimport {\n CONTROL_DIR,\n type ControlPlane,\n controlPlane,\n type PlaneOptions,\n PROTOCOL_MARK,\n} from './requests.ts';\nimport { choosable, createScoops, type Scoops, type ScoopsHost } from './service.ts';\n\nexport const BUILTIN_ROLES = ['scout', 'worker', 'reviewer', 'oracle', 'delegate', 'gelatiere'];\nexport const PNPM_HOME = '/home/.local/share/pnpm';\nexport const BIN_DIR = '/usr/local/bin';\n\nexport type Assets = (path: string) => Promise<string>;\n\nexport function packageAssets(base: URL = new URL('../../', import.meta.url)): Assets {\n return async (path) => {\n const response = await fetch(new URL(path, base));\n if (!response.ok) throw new Error(`${path}: ${response.status}`);\n return response.text();\n };\n}\n\nexport interface AttachOptions {\n harness: Harness;\n agents: Agents;\n groups: ProcessGroups;\n env: ExecutionEnv;\n home: string;\n assets?: Assets;\n binDir?: string;\n controlDir?: string;\n sweepEvery?: number;\n alive?: (pid: number) => Promise<boolean>;\n memory?: CliOptions['memory'];\n gelatiere?: CliOptions['gelatiere'];\n freezer?: CliOptions['freezer'];\n models?: CliOptions['models'];\n panel?: CliOptions['panel'];\n webhook?: CliOptions['webhook'];\n sprinkle?: CliOptions['sprinkle'];\n mcp?: (names: readonly string[]) => ToolRegistration[];\n layout?: Layout;\n spools?: Spools;\n agentDir?: string;\n}\n\nexport interface Spool {\n user: string;\n dir: string;\n}\n\nexport interface Spools {\n users(): readonly string[];\n prepare(spools: readonly Spool[], context: Context): Promise<void>;\n}\n\nexport interface ScoopsRuntime {\n roles(context: Context): Promise<Roles>;\n plane: ControlPlane;\n close(context: Context): Promise<void>;\n}\n\nexport interface ScoopsSetup {\n scoops: Scoops;\n choosable: Choosable;\n attach(options: AttachOptions, context: Context): Promise<ScoopsRuntime>;\n}\n\nexport const COMMANDS = ['agent', 'subagent', 'memory', 'gelatiere', 'freezer', 'models', 'panel'];\n\nexport const RETIRED_COMMANDS = ['sprinkle'];\n\nexport async function pnpmHomeOf(env: ExecutionEnv, context: Context): Promise<string> {\n let out = '';\n const ran = await env\n .exec(\n 'printf %s \"$PNPM_HOME\"',\n {\n onOutput: (text) => {\n out += text;\n },\n },\n context\n )\n .catch(() => undefined);\n return ran?.ok && ran.value.exitCode === 0 && /^\\/\\S*$/.test(out) ? out : PNPM_HOME;\n}\n\nexport interface Installed {\n done: boolean;\n skipped: string[];\n}\n\ntype Placed = 'theirs' | 'current' | 'stale';\n\nasync function placed(\n env: ExecutionEnv,\n path: string,\n script: string,\n context: Context\n): Promise<Placed> {\n const found = await env.fileInfo(path, context);\n if (!found.ok) return found.error.code === 'not_found' ? 'stale' : 'theirs';\n if (found.value.kind !== 'file') return 'theirs';\n const read = await env.readTextFile(path, context);\n if (!read.ok || !read.value.includes(PROTOCOL_MARK)) return 'theirs';\n return read.value === script ? 'current' : 'stale';\n}\n\nasync function install(\n env: ExecutionEnv,\n script: string,\n binDir: string,\n context: Context\n): Promise<Installed> {\n const skipped: string[] = [];\n if (!(await env.createDir(binDir, { recursive: true }, context)).ok)\n return { done: false, skipped };\n const ours: string[] = [];\n for (const name of COMMANDS) {\n const path = `${binDir}/${name}`;\n const found = await placed(env, path, script, context);\n if (found === 'theirs') {\n skipped.push(name);\n continue;\n }\n if (found === 'stale' && !(await env.writeFile(path, script, context)).ok)\n return { done: false, skipped };\n ours.push(path);\n }\n if (ours.length) {\n const mode = await env.exec(['chmod', '755', ...ours], undefined, context);\n if (!mode.ok || mode.value.exitCode !== 0) return { done: false, skipped };\n }\n for (const name of RETIRED_COMMANDS) {\n const text = await env.readTextFile(`${binDir}/${name}`, context);\n if (text.ok && text.value.includes(PROTOCOL_MARK))\n await env.remove(`${binDir}/${name}`, { force: true }, context);\n }\n return { done: true, skipped };\n}\n\nexport async function installCommands(\n env: ExecutionEnv,\n script: string,\n binDir: string,\n context: Context,\n warn: (message: string) => void = (message) => console.warn(message)\n): Promise<Installed> {\n const installed = await install(env, script, binDir, context).catch(\n (): Installed => ({ done: false, skipped: [] })\n );\n if (installed.skipped.length) {\n const paths = installed.skipped.map((name) => `${binDir}/${name}`).join(', ');\n warn(`slicc-agent: left ${paths} alone, because it isn't slicc-agent's command`);\n }\n if (installed.done) await retire(env, binDir, context).catch(() => undefined);\n return installed;\n}\n\nexport async function retire(env: ExecutionEnv, binDir: string, context: Context) {\n const old = `${await pnpmHomeOf(env, context)}/bin`;\n if (old === binDir) return;\n for (const name of [...COMMANDS, ...RETIRED_COMMANDS]) {\n const path = `${old}/${name}`;\n const text = await env.readTextFile(path, context);\n if (text.ok && text.value.includes(PROTOCOL_MARK))\n await env.remove(path, { force: true }, context);\n }\n}\n\nfunction mirror(agents: Agents, env: ExecutionEnv) {\n return async (context: Context) => {\n for (const [id, record] of Object.entries(agents.state().scoops)) {\n const state = record.gone ? 'gone' : live(record) ? 'live' : 'stopped';\n const metadata = {\n handle: record.folder,\n id,\n name: record.name,\n role: record.role,\n cone: record.cone,\n state,\n };\n await env.writeFile(\n `${RUN_DIR}/${record.folder}/metadata.json`,\n `${JSON.stringify(metadata, null, 2)}\\n`,\n context\n );\n }\n };\n}\n\nfunction planeOf(\n env: ExecutionEnv,\n cli: ReturnType<typeof createCli>,\n options: AttachOptions,\n context: Context\n): ControlPlane {\n const common: PlaneOptions & { dir: string } = {\n ...(options.sweepEvery ? { sweepEvery: options.sweepEvery } : {}),\n mirror: mirror(options.agents, env),\n dir: options.controlDir ?? CONTROL_DIR,\n };\n if (!options.spools) return controlPlane(env, cli, common);\n return spooled(env, cli, options.spools, options.agents, common, context);\n}\n\nexport function spooled(\n env: ExecutionEnv,\n cli: ReturnType<typeof createCli>,\n spools: Spools,\n agents: Agents,\n options: PlaneOptions & { dir: string },\n context: Context\n): ControlPlane {\n const planes = new Map<string, Promise<ControlPlane | undefined>>();\n let off: () => void = () => undefined;\n let chain: Promise<unknown> = Promise.resolve();\n const open = async (user: string, prepared: Promise<void>): Promise<ControlPlane | undefined> => {\n const dir = `${options.dir}/${user}`;\n try {\n await prepared;\n const plane = controlPlane(env, cli, { ...options, dir, user });\n await plane.start(context);\n return plane;\n } catch {\n planes.delete(user);\n return undefined;\n }\n };\n const sync = () => {\n const step = async () => {\n const wanted = new Set(spools.users());\n const fresh = [...wanted].filter((user) => !planes.has(user));\n const prepared = spools.prepare(\n fresh.map((user) => ({ user, dir: `${options.dir}/${user}` })),\n context\n );\n prepared.catch(() => undefined);\n const opening = fresh.map((user) => {\n const opened = open(user, prepared);\n planes.set(user, opened);\n return opened;\n });\n await Promise.all(opening);\n for (const [user, plane] of [...planes])\n if (!wanted.has(user)) {\n planes.delete(user);\n await (await plane)?.close(context);\n }\n };\n chain = chain.then(step, step);\n return chain;\n };\n const all = async () =>\n (await Promise.all(planes.values())).filter((plane): plane is ControlPlane => !!plane);\n return {\n async start() {\n off = agents.onChange(() => void sync());\n await sync();\n },\n async sweep(using) {\n for (const plane of await all()) await plane.sweep(using);\n },\n async close(using) {\n off();\n await chain;\n for (const plane of await all()) await plane.close(using);\n planes.clear();\n },\n };\n}\n\nexport function setupScoops(\n registry: Registry,\n licks: Licks,\n fileTools: readonly ToolRegistration[] = []\n): ScoopsSetup {\n let bind: (host: ScoopsHost) => void = () => undefined;\n const host = new Promise<ScoopsHost>((resolve) => {\n bind = resolve;\n });\n const lookup = () => host;\n const tasks = scoopTasks(lookup);\n const scoops = createScoops(host, () => tasks);\n let cached: Roles = { roles: [], warnings: [], limits: { ...DEFAULT_LIMITS } };\n let layout = LEGACY;\n registry.install(scoopsExtension(tasks, () => layout));\n const workflows = setupWorkflows(registry);\n return {\n scoops,\n choosable: choosable(fileTools),\n async attach(options, context) {\n const { harness, agents, groups, env, home } = options;\n const assets = options.assets ?? packageAssets();\n layout = options.layout ?? LEGACY;\n bind({\n harness,\n agents,\n licks,\n tools: fileTools,\n groups,\n files: env,\n layout,\n exclude: [workflows.extension],\n ...(options.mcp ? { mcp: options.mcp } : {}),\n });\n const builtin = async () => {\n const out: { path: string; text: string }[] = [];\n for (const name of BUILTIN_ROLES) {\n const path = `packages/vfs-root/agents/${name}.md`;\n out.push({ path: `builtin:${name}`, text: await assets(path) });\n }\n return out;\n };\n const roles = async (using: Context) => {\n cached = await loadRoles(\n {\n files: env,\n builtin,\n dirs: [\n ...(await packageDirs(env, PACKAGE_ROOTS, using)).map((dir) => ({\n source: 'package' as const,\n dir,\n })),\n { source: 'user', dir: `${options.agentDir ?? `${home}/.pi/agent`}/agents` },\n ],\n settingsPath: `${options.agentDir ?? `${home}/.pi/agent`}/settings.json`,\n },\n using\n );\n return cached;\n };\n await roles(context).catch(() => cached);\n const script = await assets('bin/agent').catch(() => undefined);\n if (script) {\n const binDir = options.binDir ?? BIN_DIR;\n await installCommands(env, script, binDir, context);\n }\n const cli = createCli({\n env,\n harness,\n agents,\n scoops,\n roles: () => roles(context),\n ...(options.alive ? { alive: options.alive } : {}),\n ...(options.memory ? { memory: options.memory } : {}),\n ...(options.gelatiere ? { gelatiere: options.gelatiere } : {}),\n ...(options.freezer ? { freezer: options.freezer } : {}),\n ...(options.models ? { models: options.models } : {}),\n layout,\n ...(options.panel ? { panel: options.panel } : {}),\n ...(options.webhook ? { webhook: options.webhook } : {}),\n sprinkle: options.sprinkle,\n workflow: cliCommand(workflows.workflows, layout, env, agents),\n licks,\n });\n workflows.attach({\n harness,\n agents,\n scoops,\n roles,\n env,\n layout,\n engine: workflowEngine(),\n envFor: async (user, using) => (await layout.envFor(user, using)) ?? env,\n });\n const plane = planeOf(env, cli, options, context);\n await plane.start(context);\n return { roles, plane, close: (using) => plane.close(using) };\n },\n };\n}\n\nexport type { Rewound, Scoops } from './service.ts';\n"],
|
|
5
|
+
"mappings": "AAGA,SAAsB,YAAY;AAElC,SAAsB,cAAc;AAEpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,YAAY,gBAAgB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"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CODEX_ACCOUNT } from "../sign-ins.js";
|
|
2
2
|
const RECORD_ENV = [CODEX_ACCOUNT];
|
|
3
3
|
const KEYS_IN_VAULT = "model keys are kept in seven's vault: enter them in Settings \u203A Accounts";
|
|
4
|
-
function vaultCredentials(records, env = () => void 0, ready = () => true) {
|
|
4
|
+
function vaultCredentials(records, env = () => void 0, ready = () => true, keyless = () => []) {
|
|
5
5
|
return {
|
|
6
6
|
async read(providerId) {
|
|
7
7
|
const record = records.model(providerId);
|
|
8
|
+
if (!record && keyless().includes(providerId))
|
|
9
|
+
return { type: "api_key", env: { ...env(providerId) } };
|
|
8
10
|
if (!record || !ready(providerId)) return void 0;
|
|
9
11
|
const carried = Object.fromEntries(
|
|
10
12
|
RECORD_ENV.flatMap((name) => {
|
|
@@ -21,7 +23,7 @@ function vaultCredentials(records, env = () => void 0, ready = () => true) {
|
|
|
21
23
|
},
|
|
22
24
|
async list() {
|
|
23
25
|
const providers = records.state.value.filter((record) => record.kind === "model" && record.provider !== void 0).map((record) => record.provider).filter(ready);
|
|
24
|
-
return [
|
|
26
|
+
return [.../* @__PURE__ */ new Set([...providers, ...keyless()])].map(
|
|
25
27
|
(providerId) => ({ providerId, type: "api_key" })
|
|
26
28
|
);
|
|
27
29
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/secrets/credentials.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Credential, CredentialInfo, CredentialStore } from '@earendil-works/pi-ai';\nimport { CODEX_ACCOUNT } from '../sign-ins.ts';\nimport type { VaultRecords } from './records.ts';\n\nconst RECORD_ENV: readonly string[] = [CODEX_ACCOUNT];\n\nexport const KEYS_IN_VAULT =\n \"model keys are kept in seven's vault: enter them in Settings \u203A Accounts\";\n\nexport type FieldsOf = (providerId: string) => Readonly<Record<string, string>> | undefined;\n\nexport function vaultCredentials(\n records: Pick<VaultRecords, 'model' | 'state'>,\n env: FieldsOf = () => undefined,\n ready: (providerId: string) => boolean = () => true\n): CredentialStore {\n return {\n async read(providerId) {\n const record = records.model(providerId);\n if (!record || !ready(providerId)) return undefined;\n const carried = Object.fromEntries(\n RECORD_ENV.flatMap((name) => {\n const value = record.settings?.[name];\n return value ? [[name, value]] : [];\n })\n );\n const extra = { ...carried, ...env(providerId) };\n return {\n type: 'api_key',\n key: record.placeholder,\n ...(Object.keys(extra).length ? { env: extra } : {}),\n } satisfies Credential;\n },\n async list() {\n const providers = records.state.value\n .filter((record) => record.kind === 'model' && record.provider !== undefined)\n .map((record) => record.provider as string)\n .filter(ready);\n return [...new Set(providers)].map(\n (providerId): CredentialInfo => ({ providerId, type: 'api_key' })\n );\n },\n async modify() {\n throw new Error(KEYS_IN_VAULT);\n },\n async delete() {\n throw new Error(KEYS_IN_VAULT);\n },\n };\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,qBAAqB;AAG9B,MAAM,aAAgC,CAAC,aAAa;AAE7C,MAAM,gBACX;AAIK,SAAS,iBACd,SACA,MAAgB,MAAM,QACtB,QAAyC,MAAM,
|
|
4
|
+
"sourcesContent": ["import type { Credential, CredentialInfo, CredentialStore } from '@earendil-works/pi-ai';\nimport { CODEX_ACCOUNT } from '../sign-ins.ts';\nimport type { VaultRecords } from './records.ts';\n\nconst RECORD_ENV: readonly string[] = [CODEX_ACCOUNT];\n\nexport const KEYS_IN_VAULT =\n \"model keys are kept in seven's vault: enter them in Settings \u203A Accounts\";\n\nexport type FieldsOf = (providerId: string) => Readonly<Record<string, string>> | undefined;\n\nexport function vaultCredentials(\n records: Pick<VaultRecords, 'model' | 'state'>,\n env: FieldsOf = () => undefined,\n ready: (providerId: string) => boolean = () => true,\n keyless: () => readonly string[] = () => []\n): CredentialStore {\n return {\n async read(providerId) {\n const record = records.model(providerId);\n if (!record && keyless().includes(providerId))\n return { type: 'api_key', env: { ...env(providerId) } } satisfies Credential;\n if (!record || !ready(providerId)) return undefined;\n const carried = Object.fromEntries(\n RECORD_ENV.flatMap((name) => {\n const value = record.settings?.[name];\n return value ? [[name, value]] : [];\n })\n );\n const extra = { ...carried, ...env(providerId) };\n return {\n type: 'api_key',\n key: record.placeholder,\n ...(Object.keys(extra).length ? { env: extra } : {}),\n } satisfies Credential;\n },\n async list() {\n const providers = records.state.value\n .filter((record) => record.kind === 'model' && record.provider !== undefined)\n .map((record) => record.provider as string)\n .filter(ready);\n return [...new Set([...providers, ...keyless()])].map(\n (providerId): CredentialInfo => ({ providerId, type: 'api_key' })\n );\n },\n async modify() {\n throw new Error(KEYS_IN_VAULT);\n },\n async delete() {\n throw new Error(KEYS_IN_VAULT);\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,qBAAqB;AAG9B,MAAM,aAAgC,CAAC,aAAa;AAE7C,MAAM,gBACX;AAIK,SAAS,iBACd,SACA,MAAgB,MAAM,QACtB,QAAyC,MAAM,MAC/C,UAAmC,MAAM,CAAC,GACzB;AACjB,SAAO;AAAA,IACL,MAAM,KAAK,YAAY;AACrB,YAAM,SAAS,QAAQ,MAAM,UAAU;AACvC,UAAI,CAAC,UAAU,QAAQ,EAAE,SAAS,UAAU;AAC1C,eAAO,EAAE,MAAM,WAAW,KAAK,EAAE,GAAG,IAAI,UAAU,EAAE,EAAE;AACxD,UAAI,CAAC,UAAU,CAAC,MAAM,UAAU,EAAG,QAAO;AAC1C,YAAM,UAAU,OAAO;AAAA,QACrB,WAAW,QAAQ,CAAC,SAAS;AAC3B,gBAAM,QAAQ,OAAO,WAAW,IAAI;AACpC,iBAAO,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC;AAAA,QACpC,CAAC;AAAA,MACH;AACA,YAAM,QAAQ,EAAE,GAAG,SAAS,GAAG,IAAI,UAAU,EAAE;AAC/C,aAAO;AAAA,QACL,MAAM;AAAA,QACN,KAAK,OAAO;AAAA,QACZ,GAAI,OAAO,KAAK,KAAK,EAAE,SAAS,EAAE,KAAK,MAAM,IAAI,CAAC;AAAA,MACpD;AAAA,IACF;AAAA,IACA,MAAM,OAAO;AACX,YAAM,YAAY,QAAQ,MAAM,MAC7B,OAAO,CAAC,WAAW,OAAO,SAAS,WAAW,OAAO,aAAa,MAAS,EAC3E,IAAI,CAAC,WAAW,OAAO,QAAkB,EACzC,OAAO,KAAK;AACf,aAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE;AAAA,QAChD,CAAC,gBAAgC,EAAE,YAAY,MAAM,UAAU;AAAA,MACjE;AAAA,IACF;AAAA,IACA,MAAM,SAAS;AACb,YAAM,IAAI,MAAM,aAAa;AAAA,IAC/B;AAAA,IACA,MAAM,SAAS;AACb,YAAM,IAAI,MAAM,aAAa;AAAA,IAC/B;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/services.js
CHANGED
|
@@ -43,6 +43,8 @@ const CONTROL_METHODS = keys({
|
|
|
43
43
|
guestOpen: true,
|
|
44
44
|
guestRevoke: true,
|
|
45
45
|
guestAlwaysForget: true,
|
|
46
|
+
ownerAlways: true,
|
|
47
|
+
ownerAlwaysForget: true,
|
|
46
48
|
approvalPolicySet: true,
|
|
47
49
|
decide: true,
|
|
48
50
|
approvalRun: true,
|
|
@@ -57,6 +59,8 @@ const OWNER_DEVICE_METHODS = [
|
|
|
57
59
|
"guestOpen",
|
|
58
60
|
"guestRevoke",
|
|
59
61
|
"guestAlwaysForget",
|
|
62
|
+
"ownerAlways",
|
|
63
|
+
"ownerAlwaysForget",
|
|
60
64
|
"approvalPolicySet"
|
|
61
65
|
];
|
|
62
66
|
const CONTROL_READS = [
|
package/dist/services.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/services.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context, JsonValue, RemoteContract, ReplicatedState } from '@earendil-works/chord';\nimport type { BlockedReason, ConversationView } from '@earendil-works/pi-durable';\nimport type { Approval, ApprovalDecided, ApprovalDecision } from './approvals/index.ts';\nimport type {\n ApprovalPolicy,\n ApprovalPolicyChange,\n ApprovalPolicySet,\n} from './approvals/policy.ts';\nimport type { RunAnswer } from './approvals/run.ts';\nimport type { NoticeAnswer, RunNotice } from './approvals/run-notice.ts';\nimport type { Runnable } from './approvals/runnable.ts';\nimport type { AgentSudo } from './approvals/sudo.ts';\nimport type { SendAttachment, ShownAttachment } from './attachments.ts';\nimport type { ChangesView } from './changes/git.ts';\nimport type { FrozenCone } from './freezer/index.ts';\nimport type { ImportProgress, ImportResult } from './freezer/v6.ts';\nimport type { GuestOpened, Proposed, ProposeRequest } from './guests/index.ts';\nimport type { GuestDraft, GuestGates, GuestSeat } from './guests/seats.ts';\nimport type { MemoryEntry, MemoryScope, MemoryTag } from './memory/format.ts';\nimport type { EntriesPage, EntriesRequest } from './remote/history.ts';\nimport type { AgentRemote } from './remote/host.ts';\nimport type { AgentPages } from './remote/pages.ts';\nimport type { VaultState } from './secrets/vault.ts';\nimport { contract } from './serving.ts';\nimport type { DeviceSignIn } from './sign-ins.ts';\nimport type { SkillPackage, SkillSource } from './skills/skills.ts';\nimport type { Sprinkle } from './sprinkles/kind.ts';\n\nexport type SendMode = 'steer' | 'followUp' | 'reject';\n\nexport interface SendRequest {\n text: string;\n whenBusy: SendMode;\n requestId: string | null;\n agentId?: string | null;\n attachments?: SendAttachment[];\n}\n\nexport interface OperationError {\n code: string;\n message: string;\n}\n\nexport type SendResponse =\n | { accepted: true; submissionId: string; error: null }\n | { accepted: false; submissionId: null; error: OperationError };\n\nexport type PromptResult =\n | { status: 'done'; text: string; reason: null }\n | { status: 'unanswered'; text: null; reason: string };\n\nexport interface AgentControl {\n send(request: SendRequest, context: Context): Promise<SendResponse>;\n wait(submissionId: string, context: Context): Promise<PromptResult>;\n withdraw(\n submissionId: string,\n context: Context\n ): Promise<{ outcome: 'withdrawn' | 'already_placed' | 'not_found' }>;\n abort(context: Context): Promise<void>;\n compact(instructions: string | null, context: Context): Promise<SendResponse>;\n compactAgent(\n agentId: string,\n instructions: string | null,\n context: Context\n ): Promise<SendResponse>;\n reset(handoff: string | null, context: Context): Promise<void>;\n configure(change: AgentSettingsChange, context: Context): Promise<void>;\n rewind(messageId: string | null, context: Context): Promise<Rewound>;\n rewindAgent(agentId: string, messageId: string | null, context: Context): Promise<Rewound>;\n resolveLick(\n lickId: string,\n state: 'confirmed' | 'dismissed',\n context: Context\n ): Promise<LickResolved>;\n resolveAgentLick(\n agentId: string,\n lickId: string,\n state: 'confirmed' | 'dismissed',\n context: Context\n ): Promise<LickResolved>;\n webhook(\n name: string,\n delivery: WebhookRequest,\n context: Context\n ): Promise<{ delivered: boolean }>;\n stopAgent(agentId: string, context: Context): Promise<void>;\n selectCone(agentId: string, context: Context): Promise<void>;\n createCone(name: string, context: Context): Promise<Created>;\n createScoop(parentId: string, name: string, context: Context): Promise<Created>;\n drop(agentId: string, context: Context): Promise<Created>;\n unqueue(\n agentId: string | null,\n submissionId: string,\n context: Context\n ): Promise<{ outcome: 'withdrawn' | 'already_placed' | 'not_found' }>;\n sprinkleSend(\n sprinkleId: string,\n payload: { action: string; data: JsonValue | null; target: string | null },\n context: Context\n ): Promise<{ delivered: boolean }>;\n sprinkleCall(\n sprinkleId: string,\n method: string,\n args: JsonValue[],\n context: Context\n ): Promise<JsonValue>;\n memorySave(draft: MemoryDraft, context: Context): Promise<MemoryEntry>;\n memoryRemove(id: string, context: Context): Promise<{ removed: boolean }>;\n freeze(agentId: string, context: Context): Promise<Created>;\n newChat(agentId: string, context: Context): Promise<Created>;\n thaw(frozenId: string, context: Context): Promise<Created>;\n discard(frozenId: string, context: Context): Promise<Created>;\n importProfile(request: ImportRequest, context: Context): Promise<ImportResult>;\n importCancel(context: Context): Promise<void>;\n changesOpen(context: Context): Promise<void>;\n changeAccept(path: string, context: Context): Promise<Created>;\n changeRevert(path: string, context: Context): Promise<Created>;\n monitorOpen(lease: string | null, resync: boolean, context: Context): Promise<MonitorLease>;\n monitorClose(lease: string, context: Context): Promise<void>;\n image(ref: ImageRef, context: Context): Promise<StoredImage>;\n agentCommands(agentId: string, context: Context): Promise<Command[]>;\n toolLabel(agentId: string, callIds: string[], context: Context): Promise<string | null>;\n stepLabel(agentId: string, callId: string, context: Context): Promise<string | null>;\n entries(request: EntriesRequest, context: Context): Promise<EntriesPage>;\n guestOpen(draft: GuestDraft, context: Context): Promise<GuestOpened>;\n guestRevoke(id: string, context: Context): Promise<{ revoked: boolean }>;\n guestAlwaysForget(\n seat: string,\n approval: string,\n context: Context\n ): Promise<{ removed: boolean }>;\n approvalPolicySet(change: ApprovalPolicyChange, context: Context): Promise<ApprovalPolicySet>;\n decide(\n id: string,\n decision: ApprovalDecision,\n reason: string | null,\n context: Context\n ): Promise<ApprovalDecided>;\n approvalRun(id: string, context: Context): Promise<RunAnswer>;\n approvalRunStop(id: string, context: Context): Promise<RunAnswer>;\n approvalRunNotice(notice: RunNotice, context: Context): Promise<NoticeAnswer>;\n}\n\nexport interface ImportRequest {\n upload: string | null;\n data: string | null;\n inPlace?: string | null;\n again: boolean;\n preview: boolean;\n}\n\nexport interface ImageRef {\n entry: number;\n message: number;\n part: number;\n}\n\nexport type StoredImage = { data: string; mimeType: string } | { data: null; mimeType: null };\n\nexport interface MonitorLease {\n lease: string;\n ttlMs: number;\n}\n\nexport interface MonitorAgent {\n id: string;\n name: string;\n kind: 'cone' | 'scoop';\n parentId: string | null;\n model: string | null;\n running: boolean;\n queued: number;\n tool: string | null;\n retry: { attempt: number; since: number; error: string } | null;\n failed: string | null;\n context: number | null;\n cpu?: number | null;\n}\n\nexport interface MonitorTask {\n id: string;\n kind: string;\n detail: string | null;\n agentId: string | null;\n owner: string | null;\n status: 'pending' | 'running' | 'waiting' | 'sleeping' | 'completing';\n phase: string;\n background: boolean;\n aborting: number | null;\n since: number;\n waits: number;\n until: number | null;\n blocked: BlockedReason | null;\n}\n\nexport interface MonitorProcess {\n pid: number;\n ppid: number;\n pgid: number;\n user: string | null;\n agentId: string | null;\n command: string;\n state: 'S' | 'Z';\n started: number;\n zombie: number | null;\n tty: boolean;\n rss: number | null;\n utime?: number;\n stime?: number;\n cpu?: number | null;\n}\n\nexport interface MonitorProblem {\n id: string;\n at: number;\n agentId: string | null;\n kind: 'task' | 'retry' | 'turn' | 'report';\n message: string;\n report?: { type: string; source: string | null };\n taskId?: string;\n}\n\nexport interface MonitorFeed {\n open: boolean;\n at: number;\n usage: { tokens: number; cost: number; free: boolean } | null;\n agents: MonitorAgent[];\n tasks: MonitorTask[];\n processes: MonitorProcess[] | null;\n kernel: 'checking' | 'ok' | 'unreachable';\n problems: MonitorProblem[];\n paused: boolean;\n latency?: MonitorLatency | null;\n}\n\nexport interface MonitorLatency {\n requests: number;\n medianMs: number;\n firstChunkMedianMs: number | null;\n errors: number;\n series: number[];\n models: { model: string; requests: number; medianMs: number }[];\n}\n\nexport interface MemoryDraft {\n id: string | null;\n scope: string;\n section: string;\n title: string;\n body: string;\n tag: MemoryTag | null;\n}\n\nexport type Created = { id: string; error: null } | { id: null; error: string };\n\nexport interface AgentSummary {\n id: string;\n name: string;\n kind: 'cone' | 'scoop';\n parentId: string | null;\n role: string | null;\n}\n\nexport interface AgentsSummary {\n active: string;\n agents: AgentSummary[];\n}\n\nexport type LickResolved =\n | { done: true; text: string; error: null }\n | { done: false; text: null; error: string };\n\nexport interface WebhookRequest {\n id: string | null;\n headers: Record<string, string>;\n body: string;\n}\n\nexport type Rewound =\n | { done: true; text: string; reason: null; attachments?: ShownAttachment[] }\n | { done: false; text: null; reason: 'busy' | 'no-turn' };\n\nexport interface AgentSettingsChange {\n model: { provider: string; modelId: string } | null;\n thinkingLevel: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null;\n agentId?: string | null;\n}\n\nconst keys = <T>(record: Record<keyof T, true>) => Object.keys(record) as (keyof T & string)[];\n\nexport const CONTROL_METHODS = keys<AgentControl>({\n send: true,\n wait: true,\n withdraw: true,\n abort: true,\n compact: true,\n compactAgent: true,\n reset: true,\n configure: true,\n rewind: true,\n rewindAgent: true,\n resolveLick: true,\n resolveAgentLick: true,\n webhook: true,\n stopAgent: true,\n selectCone: true,\n createCone: true,\n createScoop: true,\n drop: true,\n unqueue: true,\n sprinkleSend: true,\n sprinkleCall: true,\n memorySave: true,\n memoryRemove: true,\n freeze: true,\n newChat: true,\n thaw: true,\n discard: true,\n importProfile: true,\n importCancel: true,\n changesOpen: true,\n changeAccept: true,\n changeRevert: true,\n monitorOpen: true,\n monitorClose: true,\n image: true,\n agentCommands: true,\n toolLabel: true,\n stepLabel: true,\n entries: true,\n guestOpen: true,\n guestRevoke: true,\n guestAlwaysForget: true,\n approvalPolicySet: true,\n decide: true,\n approvalRun: true,\n approvalRunStop: true,\n approvalRunNotice: true,\n});\n\nexport const OWNER_DEVICE_METHODS: readonly (keyof AgentControl & string)[] = [\n 'decide',\n 'approvalRun',\n 'approvalRunStop',\n 'approvalRunNotice',\n 'guestOpen',\n 'guestRevoke',\n 'guestAlwaysForget',\n 'approvalPolicySet',\n];\n\nexport const CONTROL_READS: readonly (keyof AgentControl & string)[] = [\n 'wait',\n 'changesOpen',\n 'monitorOpen',\n 'monitorClose',\n 'image',\n 'toolLabel',\n 'stepLabel',\n 'entries',\n];\n\nexport const AgentControl: RemoteContract = contract('slicc.agent.control', {\n control: { methods: CONTROL_METHODS },\n view: { methods: [...CONTROL_READS, ...OWNER_DEVICE_METHODS] },\n});\n\nexport type Delivered = 'run' | 'steer' | 'follow-up';\n\nexport interface AgentTranscript {\n readonly state: ReplicatedState<ConversationView>;\n readonly deliveries: ReplicatedState<Record<string, Delivered>>;\n readonly agents: ReplicatedState<AgentsSummary>;\n readonly views: ReplicatedState<Record<string, ConversationView>>;\n readonly commands: ReplicatedState<Command[]>;\n readonly privateRevision: ReplicatedState<PrivateRevision>;\n readonly sprinkles: ReplicatedState<Sprinkle[]>;\n readonly memories: ReplicatedState<MemoryEntry[]>;\n readonly memoryScopes: ReplicatedState<MemoryScope[]>;\n readonly frozen: ReplicatedState<FrozenCone[]>;\n readonly importing: ReplicatedState<ImportProgress>;\n readonly changes: ReplicatedState<ChangesView>;\n readonly monitor: ReplicatedState<MonitorFeed>;\n readonly vault: ReplicatedState<VaultState>;\n readonly labels: ReplicatedState<Record<string, string>>;\n readonly guests: ReplicatedState<GuestSeat[]>;\n readonly approvals: ReplicatedState<Approval[]>;\n readonly approvalPolicy: ReplicatedState<ApprovalPolicy>;\n readonly approvalRunnable: ReplicatedState<Record<string, Runnable>>;\n}\n\nexport interface PrivateRevision {\n revision: number;\n}\n\nexport interface Command {\n name: string;\n description: string;\n kind: 'prompt' | 'skill' | 'action';\n source?: SkillSource;\n package?: SkillPackage;\n}\n\nexport const TRANSCRIPT_STATES = keys<AgentTranscript>({\n state: true,\n deliveries: true,\n agents: true,\n views: true,\n commands: true,\n privateRevision: true,\n sprinkles: true,\n memories: true,\n memoryScopes: true,\n frozen: true,\n importing: true,\n changes: true,\n monitor: true,\n vault: true,\n labels: true,\n guests: true,\n approvals: true,\n approvalPolicy: true,\n approvalRunnable: true,\n});\n\nexport const AgentTranscript: RemoteContract = contract('slicc.agent.transcript', {\n transcript: { state: TRANSCRIPT_STATES },\n});\n\nexport const REMOTE_METHODS = keys<AgentRemote>({\n prompt: true,\n watch: true,\n history: true,\n next: true,\n close: true,\n abort: true,\n});\n\nexport const REMOTE_READS: readonly (keyof AgentRemote & string)[] = [\n 'watch',\n 'history',\n 'next',\n 'close',\n];\n\nexport interface GuestShown {\n id: string;\n label: string;\n agentId: string;\n name: string;\n expiresAt: number | null;\n gates: GuestGates;\n}\n\nexport interface GuestProposal {\n id: string;\n text: string;\n state: 'queued' | 'pending' | 'approved' | 'rejected' | 'unanswered' | 'withdrawn';\n reason: string | null;\n createdAt: number;\n decidedAt: number | null;\n}\n\nexport interface AgentGuest {\n readonly transcript: ReplicatedState<ConversationView>;\n readonly seat: ReplicatedState<GuestShown>;\n readonly proposals: ReplicatedState<GuestProposal[]>;\n propose(request: ProposeRequest, context: Context): Promise<Proposed>;\n guestOpen(draft: GuestDraft, context: Context): Promise<GuestOpened>;\n guestRevoke(id: string, context: Context): Promise<{ revoked: boolean }>;\n}\n\nexport const GUEST_STATES = ['transcript', 'seat', 'proposals'] as const;\n\nexport const GUEST_METHODS = ['propose', 'guestOpen', 'guestRevoke'] as const;\n\nexport const AgentGuestService: RemoteContract = contract('slicc.agent.guest', {\n guest: { state: GUEST_STATES, methods: GUEST_METHODS },\n none: {},\n});\n\nexport const AgentRemoteService: RemoteContract = contract('slicc.agent.remote', {\n remote: { methods: REMOTE_METHODS },\n watch: { methods: REMOTE_READS },\n});\n\nexport const PAGE_METHODS = keys<AgentPages>({\n open: true,\n report: true,\n next: true,\n answer: true,\n close: true,\n});\n\nexport const AgentPagesService: RemoteContract = contract('slicc.agent.pages', {\n pages: { methods: PAGE_METHODS },\n none: {},\n});\n\nexport const SUDO_METHODS = keys<Omit<AgentSudo, 'approvals'>>({\n request: true,\n withdraw: true,\n capture: true,\n});\n\nexport const AgentSudoService: RemoteContract = contract('slicc.agent.sudo', {\n sudo: { state: ['approvals'], methods: SUDO_METHODS },\n none: {},\n});\n\nexport interface ModelChoice {\n id: string;\n label: string;\n provider: string;\n kind: 'chat' | 'classifier';\n reasoning: boolean;\n images?: boolean;\n contextWindow: number;\n}\n\nexport interface AccountState {\n id: string;\n provider: string;\n identity: string;\n status: 'connected' | 'disconnected' | 'expired';\n auth: 'api-key' | 'oauth' | 'local';\n needs: 'cors-free-transport' | null;\n blocked?: 'cors-free-transport';\n group?: 'providers' | 'mcp';\n secret?: 'api-key' | 'token';\n store?: 'vault';\n fields?: AccountField[];\n description?: string;\n keyUrl?: string;\n vaultName?: string;\n state?: McpServerState;\n}\n\nexport type McpServerState =\n | 'connecting'\n | 'connected'\n | 'needs-secret'\n | 'needs-auth'\n | 'failed'\n | 'disabled'\n | 'refused';\n\nexport type McpRefusalCode =\n | 'bad-name'\n | 'duplicate'\n | 'not-found'\n | 'not-object'\n | 'bad-token'\n | 'token-conflict'\n | 'url-secret'\n | 'header-secret'\n | 'stdio'\n | 'sse'\n | 'bad-url'\n | 'insecure-url'\n | 'file-invalid'\n | 'file-unreadable'\n | 'file-unwritable'\n | 'not-owner'\n | 'invalid';\n\nexport interface McpRefusal {\n code: McpRefusalCode;\n reason: string;\n}\n\nexport type McpRefusals = Record<string, McpRefusal>;\n\nexport type McpEdit = { ok: true } | ({ ok: false } & McpRefusal);\n\nexport interface AccountField {\n name: string;\n label: string;\n required?: boolean;\n placeholder?: string;\n help?: string;\n customBase?: true;\n vaultSetting?: string;\n options?: readonly { value: string; label: string }[];\n value?: string;\n}\n\nexport interface ProviderOption {\n id: string;\n name: string;\n description?: string;\n auth: 'api-key' | 'oauth' | 'fields' | 'local';\n fields?: AccountField[];\n keyUrl?: string;\n needs?: 'cors-free-transport';\n blocked?: 'cors-free-transport';\n vaultName?: string;\n}\n\nexport interface BudgetState {\n provider: string;\n percent: number;\n window: 'weekly';\n resets: string;\n}\n\nexport interface SignIn {\n clientId: string;\n scopes: string;\n imsEnvironment: string;\n}\n\nexport interface McpSignIn {\n url: string;\n state: string;\n}\n\nexport interface SettingsState {\n models: ModelChoice[];\n accounts: AccountState[];\n providers?: ProviderOption[];\n budget?: BudgetState | null;\n budgets?: BudgetState[];\n moved?: { kind: 'model' | 'mcp'; label: string }[];\n labels?: Record<string, string>;\n toolIntents?: boolean;\n}\n\nexport interface AgentSettings {\n readonly state: ReplicatedState<SettingsState>;\n connect(\n providerId: string,\n secret: string | null,\n fields: Record<string, string> | null,\n context: Context\n ): Promise<void>;\n disconnect(providerId: string, context: Context): Promise<void>;\n remove(providerId: string, context: Context): Promise<void>;\n serverUrl(providerId: string, context: Context): Promise<string | null>;\n signIn(providerId: string, context: Context): Promise<SignIn | McpSignIn | DeviceSignIn | null>;\n dismissMoved(context: Context): Promise<void>;\n addServer(name: string, entry: unknown, context: Context): Promise<McpEdit>;\n removeServer(id: string, context: Context): Promise<McpEdit>;\n refusals(context: Context): Promise<McpRefusals>;\n}\n\nexport const SETTINGS_METHODS = keys<\n Omit<AgentSettings, 'state' | 'addServer' | 'removeServer' | 'refusals'>\n>({\n connect: true,\n disconnect: true,\n remove: true,\n serverUrl: true,\n signIn: true,\n dismissMoved: true,\n});\n\nexport const OWNER_SETTINGS_METHODS: readonly (keyof Omit<AgentSettings, 'state'> & string)[] = [\n ...SETTINGS_METHODS,\n 'addServer',\n 'removeServer',\n 'refusals',\n];\n\nexport const AgentSettings: RemoteContract = contract('slicc.agent.settings', {\n owner: { state: ['state'], methods: OWNER_SETTINGS_METHODS },\n settings: { state: ['state'], methods: SETTINGS_METHODS },\n view: { state: ['state'] },\n});\n\nexport type InventoryStatus = 'running' | 'queued' | 'waiting' | 'error' | 'idle';\n\nexport const INVENTORY_STATUSES: readonly InventoryStatus[] = [\n 'running',\n 'queued',\n 'waiting',\n 'error',\n 'idle',\n];\n\nexport interface InventoryAgent {\n id: string;\n kind: 'cone' | 'scoop';\n parent?: string;\n status: InventoryStatus;\n queued: number;\n provider?: string;\n model?: string;\n since: number;\n}\n\nexport interface InventoryRow extends InventoryAgent {\n cone: string;\n}\n\nexport interface InventoryState {\n seq: number;\n changedAt: number;\n active: string;\n agents: InventoryRow[];\n}\n\nexport interface InventorySnapshot {\n seq: number;\n changedAt: number;\n counts: Record<InventoryStatus, number>;\n agents: InventoryAgent[];\n}\n\nexport interface AgentInventory {\n readonly inventory: ReplicatedState<InventoryState>;\n}\n\nexport const AgentInventoryService: RemoteContract = contract('slicc.agent.inventory', {\n owner: { state: ['inventory'] },\n none: {},\n});\n"],
|
|
5
|
-
"mappings": "AAuBA,SAAS,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import type { Context, JsonValue, RemoteContract, ReplicatedState } from '@earendil-works/chord';\nimport type { BlockedReason, ConversationView } from '@earendil-works/pi-durable';\nimport type { Approval, ApprovalDecided, ApprovalDecision } from './approvals/index.ts';\nimport type {\n ApprovalPolicy,\n ApprovalPolicyChange,\n ApprovalPolicySet,\n} from './approvals/policy.ts';\nimport type { RunAnswer } from './approvals/run.ts';\nimport type { NoticeAnswer, RunNotice } from './approvals/run-notice.ts';\nimport type { Runnable } from './approvals/runnable.ts';\nimport type { AgentSudo } from './approvals/sudo.ts';\nimport type { SendAttachment, ShownAttachment } from './attachments.ts';\nimport type { ChangesView } from './changes/git.ts';\nimport type { FrozenCone } from './freezer/index.ts';\nimport type { ImportProgress, ImportResult } from './freezer/v6.ts';\nimport type { GuestOpened, Proposed, ProposeRequest } from './guests/index.ts';\nimport type { GuestDraft, GuestGates, GuestSeat, ShownAlwaysTool } from './guests/seats.ts';\nimport type { MemoryEntry, MemoryScope, MemoryTag } from './memory/format.ts';\nimport type { EntriesPage, EntriesRequest } from './remote/history.ts';\nimport type { AgentRemote } from './remote/host.ts';\nimport type { AgentPages } from './remote/pages.ts';\nimport type { VaultState } from './secrets/vault.ts';\nimport { contract } from './serving.ts';\nimport type { DeviceSignIn } from './sign-ins.ts';\nimport type { SkillPackage, SkillSource } from './skills/skills.ts';\nimport type { Sprinkle } from './sprinkles/kind.ts';\n\nexport type SendMode = 'steer' | 'followUp' | 'reject';\n\nexport interface SendRequest {\n text: string;\n whenBusy: SendMode;\n requestId: string | null;\n agentId?: string | null;\n attachments?: SendAttachment[];\n}\n\nexport interface OperationError {\n code: string;\n message: string;\n}\n\nexport type SendResponse =\n | { accepted: true; submissionId: string; error: null }\n | { accepted: false; submissionId: null; error: OperationError };\n\nexport type PromptResult =\n | { status: 'done'; text: string; reason: null }\n | { status: 'unanswered'; text: null; reason: string };\n\nexport interface AgentControl {\n send(request: SendRequest, context: Context): Promise<SendResponse>;\n wait(submissionId: string, context: Context): Promise<PromptResult>;\n withdraw(\n submissionId: string,\n context: Context\n ): Promise<{ outcome: 'withdrawn' | 'already_placed' | 'not_found' }>;\n abort(context: Context): Promise<void>;\n compact(instructions: string | null, context: Context): Promise<SendResponse>;\n compactAgent(\n agentId: string,\n instructions: string | null,\n context: Context\n ): Promise<SendResponse>;\n reset(handoff: string | null, context: Context): Promise<void>;\n configure(change: AgentSettingsChange, context: Context): Promise<void>;\n rewind(messageId: string | null, context: Context): Promise<Rewound>;\n rewindAgent(agentId: string, messageId: string | null, context: Context): Promise<Rewound>;\n resolveLick(\n lickId: string,\n state: 'confirmed' | 'dismissed',\n context: Context\n ): Promise<LickResolved>;\n resolveAgentLick(\n agentId: string,\n lickId: string,\n state: 'confirmed' | 'dismissed',\n context: Context\n ): Promise<LickResolved>;\n webhook(\n name: string,\n delivery: WebhookRequest,\n context: Context\n ): Promise<{ delivered: boolean }>;\n stopAgent(agentId: string, context: Context): Promise<void>;\n selectCone(agentId: string, context: Context): Promise<void>;\n createCone(name: string, context: Context): Promise<Created>;\n createScoop(parentId: string, name: string, context: Context): Promise<Created>;\n drop(agentId: string, context: Context): Promise<Created>;\n unqueue(\n agentId: string | null,\n submissionId: string,\n context: Context\n ): Promise<{ outcome: 'withdrawn' | 'already_placed' | 'not_found' }>;\n sprinkleSend(\n sprinkleId: string,\n payload: { action: string; data: JsonValue | null; target: string | null },\n context: Context\n ): Promise<{ delivered: boolean }>;\n sprinkleCall(\n sprinkleId: string,\n method: string,\n args: JsonValue[],\n context: Context\n ): Promise<JsonValue>;\n memorySave(draft: MemoryDraft, context: Context): Promise<MemoryEntry>;\n memoryRemove(id: string, context: Context): Promise<{ removed: boolean }>;\n freeze(agentId: string, context: Context): Promise<Created>;\n newChat(agentId: string, context: Context): Promise<Created>;\n thaw(frozenId: string, context: Context): Promise<Created>;\n discard(frozenId: string, context: Context): Promise<Created>;\n importProfile(request: ImportRequest, context: Context): Promise<ImportResult>;\n importCancel(context: Context): Promise<void>;\n changesOpen(context: Context): Promise<void>;\n changeAccept(path: string, context: Context): Promise<Created>;\n changeRevert(path: string, context: Context): Promise<Created>;\n monitorOpen(lease: string | null, resync: boolean, context: Context): Promise<MonitorLease>;\n monitorClose(lease: string, context: Context): Promise<void>;\n image(ref: ImageRef, context: Context): Promise<StoredImage>;\n agentCommands(agentId: string, context: Context): Promise<Command[]>;\n toolLabel(agentId: string, callIds: string[], context: Context): Promise<string | null>;\n stepLabel(agentId: string, callId: string, context: Context): Promise<string | null>;\n entries(request: EntriesRequest, context: Context): Promise<EntriesPage>;\n guestOpen(draft: GuestDraft, context: Context): Promise<GuestOpened>;\n guestRevoke(id: string, context: Context): Promise<{ revoked: boolean }>;\n guestAlwaysForget(\n seat: string,\n approval: string,\n context: Context\n ): Promise<{ removed: boolean }>;\n ownerAlways(context: Context): Promise<ShownAlwaysTool[]>;\n ownerAlwaysForget(approval: string, context: Context): Promise<{ removed: boolean }>;\n approvalPolicySet(change: ApprovalPolicyChange, context: Context): Promise<ApprovalPolicySet>;\n decide(\n id: string,\n decision: ApprovalDecision,\n reason: string | null,\n context: Context\n ): Promise<ApprovalDecided>;\n approvalRun(id: string, context: Context): Promise<RunAnswer>;\n approvalRunStop(id: string, context: Context): Promise<RunAnswer>;\n approvalRunNotice(notice: RunNotice, context: Context): Promise<NoticeAnswer>;\n}\n\nexport interface ImportRequest {\n upload: string | null;\n data: string | null;\n inPlace?: string | null;\n again: boolean;\n preview: boolean;\n}\n\nexport interface ImageRef {\n entry: number;\n message: number;\n part: number;\n}\n\nexport type StoredImage = { data: string; mimeType: string } | { data: null; mimeType: null };\n\nexport interface MonitorLease {\n lease: string;\n ttlMs: number;\n}\n\nexport interface MonitorAgent {\n id: string;\n name: string;\n kind: 'cone' | 'scoop';\n parentId: string | null;\n model: string | null;\n running: boolean;\n queued: number;\n tool: string | null;\n retry: { attempt: number; since: number; error: string } | null;\n failed: string | null;\n context: number | null;\n cpu?: number | null;\n}\n\nexport interface MonitorTask {\n id: string;\n kind: string;\n detail: string | null;\n agentId: string | null;\n owner: string | null;\n status: 'pending' | 'running' | 'waiting' | 'sleeping' | 'completing';\n phase: string;\n background: boolean;\n aborting: number | null;\n since: number;\n waits: number;\n until: number | null;\n blocked: BlockedReason | null;\n}\n\nexport interface MonitorProcess {\n pid: number;\n ppid: number;\n pgid: number;\n user: string | null;\n agentId: string | null;\n command: string;\n state: 'S' | 'Z';\n started: number;\n zombie: number | null;\n tty: boolean;\n rss: number | null;\n utime?: number;\n stime?: number;\n cpu?: number | null;\n}\n\nexport interface MonitorProblem {\n id: string;\n at: number;\n agentId: string | null;\n kind: 'task' | 'retry' | 'turn' | 'report';\n message: string;\n report?: { type: string; source: string | null };\n taskId?: string;\n}\n\nexport interface MonitorFeed {\n open: boolean;\n at: number;\n usage: { tokens: number; cost: number; free: boolean } | null;\n agents: MonitorAgent[];\n tasks: MonitorTask[];\n processes: MonitorProcess[] | null;\n kernel: 'checking' | 'ok' | 'unreachable';\n problems: MonitorProblem[];\n paused: boolean;\n latency?: MonitorLatency | null;\n}\n\nexport interface MonitorLatency {\n requests: number;\n medianMs: number;\n firstChunkMedianMs: number | null;\n errors: number;\n series: number[];\n models: { model: string; requests: number; medianMs: number }[];\n}\n\nexport interface MemoryDraft {\n id: string | null;\n scope: string;\n section: string;\n title: string;\n body: string;\n tag: MemoryTag | null;\n}\n\nexport type Created = { id: string; error: null } | { id: null; error: string };\n\nexport interface AgentSummary {\n id: string;\n name: string;\n kind: 'cone' | 'scoop';\n parentId: string | null;\n role: string | null;\n}\n\nexport interface AgentsSummary {\n active: string;\n agents: AgentSummary[];\n}\n\nexport type LickResolved =\n | { done: true; text: string; error: null }\n | { done: false; text: null; error: string };\n\nexport interface WebhookRequest {\n id: string | null;\n headers: Record<string, string>;\n body: string;\n}\n\nexport type Rewound =\n | { done: true; text: string; reason: null; attachments?: ShownAttachment[] }\n | { done: false; text: null; reason: 'busy' | 'no-turn' };\n\nexport interface AgentSettingsChange {\n model: { provider: string; modelId: string } | null;\n thinkingLevel: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null;\n agentId?: string | null;\n}\n\nconst keys = <T>(record: Record<keyof T, true>) => Object.keys(record) as (keyof T & string)[];\n\nexport const CONTROL_METHODS = keys<AgentControl>({\n send: true,\n wait: true,\n withdraw: true,\n abort: true,\n compact: true,\n compactAgent: true,\n reset: true,\n configure: true,\n rewind: true,\n rewindAgent: true,\n resolveLick: true,\n resolveAgentLick: true,\n webhook: true,\n stopAgent: true,\n selectCone: true,\n createCone: true,\n createScoop: true,\n drop: true,\n unqueue: true,\n sprinkleSend: true,\n sprinkleCall: true,\n memorySave: true,\n memoryRemove: true,\n freeze: true,\n newChat: true,\n thaw: true,\n discard: true,\n importProfile: true,\n importCancel: true,\n changesOpen: true,\n changeAccept: true,\n changeRevert: true,\n monitorOpen: true,\n monitorClose: true,\n image: true,\n agentCommands: true,\n toolLabel: true,\n stepLabel: true,\n entries: true,\n guestOpen: true,\n guestRevoke: true,\n guestAlwaysForget: true,\n ownerAlways: true,\n ownerAlwaysForget: true,\n approvalPolicySet: true,\n decide: true,\n approvalRun: true,\n approvalRunStop: true,\n approvalRunNotice: true,\n});\n\nexport const OWNER_DEVICE_METHODS: readonly (keyof AgentControl & string)[] = [\n 'decide',\n 'approvalRun',\n 'approvalRunStop',\n 'approvalRunNotice',\n 'guestOpen',\n 'guestRevoke',\n 'guestAlwaysForget',\n 'ownerAlways',\n 'ownerAlwaysForget',\n 'approvalPolicySet',\n];\n\nexport const CONTROL_READS: readonly (keyof AgentControl & string)[] = [\n 'wait',\n 'changesOpen',\n 'monitorOpen',\n 'monitorClose',\n 'image',\n 'toolLabel',\n 'stepLabel',\n 'entries',\n];\n\nexport const AgentControl: RemoteContract = contract('slicc.agent.control', {\n control: { methods: CONTROL_METHODS },\n view: { methods: [...CONTROL_READS, ...OWNER_DEVICE_METHODS] },\n});\n\nexport type Delivered = 'run' | 'steer' | 'follow-up';\n\nexport interface AgentTranscript {\n readonly state: ReplicatedState<ConversationView>;\n readonly deliveries: ReplicatedState<Record<string, Delivered>>;\n readonly agents: ReplicatedState<AgentsSummary>;\n readonly views: ReplicatedState<Record<string, ConversationView>>;\n readonly commands: ReplicatedState<Command[]>;\n readonly privateRevision: ReplicatedState<PrivateRevision>;\n readonly sprinkles: ReplicatedState<Sprinkle[]>;\n readonly memories: ReplicatedState<MemoryEntry[]>;\n readonly memoryScopes: ReplicatedState<MemoryScope[]>;\n readonly frozen: ReplicatedState<FrozenCone[]>;\n readonly importing: ReplicatedState<ImportProgress>;\n readonly changes: ReplicatedState<ChangesView>;\n readonly monitor: ReplicatedState<MonitorFeed>;\n readonly vault: ReplicatedState<VaultState>;\n readonly labels: ReplicatedState<Record<string, string>>;\n readonly guests: ReplicatedState<GuestSeat[]>;\n readonly approvals: ReplicatedState<Approval[]>;\n readonly approvalPolicy: ReplicatedState<ApprovalPolicy>;\n readonly approvalRunnable: ReplicatedState<Record<string, Runnable>>;\n}\n\nexport interface PrivateRevision {\n revision: number;\n}\n\nexport interface Command {\n name: string;\n description: string;\n kind: 'prompt' | 'skill' | 'action';\n source?: SkillSource;\n package?: SkillPackage;\n}\n\nexport const TRANSCRIPT_STATES = keys<AgentTranscript>({\n state: true,\n deliveries: true,\n agents: true,\n views: true,\n commands: true,\n privateRevision: true,\n sprinkles: true,\n memories: true,\n memoryScopes: true,\n frozen: true,\n importing: true,\n changes: true,\n monitor: true,\n vault: true,\n labels: true,\n guests: true,\n approvals: true,\n approvalPolicy: true,\n approvalRunnable: true,\n});\n\nexport const AgentTranscript: RemoteContract = contract('slicc.agent.transcript', {\n transcript: { state: TRANSCRIPT_STATES },\n});\n\nexport const REMOTE_METHODS = keys<AgentRemote>({\n prompt: true,\n watch: true,\n history: true,\n next: true,\n close: true,\n abort: true,\n});\n\nexport const REMOTE_READS: readonly (keyof AgentRemote & string)[] = [\n 'watch',\n 'history',\n 'next',\n 'close',\n];\n\nexport interface GuestShown {\n id: string;\n label: string;\n agentId: string;\n name: string;\n expiresAt: number | null;\n gates: GuestGates;\n}\n\nexport interface GuestProposal {\n id: string;\n text: string;\n state: 'queued' | 'pending' | 'approved' | 'rejected' | 'unanswered' | 'withdrawn';\n reason: string | null;\n createdAt: number;\n decidedAt: number | null;\n}\n\nexport interface AgentGuest {\n readonly transcript: ReplicatedState<ConversationView>;\n readonly seat: ReplicatedState<GuestShown>;\n readonly proposals: ReplicatedState<GuestProposal[]>;\n propose(request: ProposeRequest, context: Context): Promise<Proposed>;\n guestOpen(draft: GuestDraft, context: Context): Promise<GuestOpened>;\n guestRevoke(id: string, context: Context): Promise<{ revoked: boolean }>;\n}\n\nexport const GUEST_STATES = ['transcript', 'seat', 'proposals'] as const;\n\nexport const GUEST_METHODS = ['propose', 'guestOpen', 'guestRevoke'] as const;\n\nexport const AgentGuestService: RemoteContract = contract('slicc.agent.guest', {\n guest: { state: GUEST_STATES, methods: GUEST_METHODS },\n none: {},\n});\n\nexport const AgentRemoteService: RemoteContract = contract('slicc.agent.remote', {\n remote: { methods: REMOTE_METHODS },\n watch: { methods: REMOTE_READS },\n});\n\nexport const PAGE_METHODS = keys<AgentPages>({\n open: true,\n report: true,\n next: true,\n answer: true,\n close: true,\n});\n\nexport const AgentPagesService: RemoteContract = contract('slicc.agent.pages', {\n pages: { methods: PAGE_METHODS },\n none: {},\n});\n\nexport const SUDO_METHODS = keys<Omit<AgentSudo, 'approvals'>>({\n request: true,\n withdraw: true,\n capture: true,\n});\n\nexport const AgentSudoService: RemoteContract = contract('slicc.agent.sudo', {\n sudo: { state: ['approvals'], methods: SUDO_METHODS },\n none: {},\n});\n\nexport interface ModelChoice {\n id: string;\n label: string;\n provider: string;\n kind: 'chat' | 'classifier';\n reasoning: boolean;\n images?: boolean;\n contextWindow: number;\n}\n\nexport interface AccountState {\n id: string;\n provider: string;\n identity: string;\n status: 'connected' | 'disconnected' | 'expired';\n auth: 'api-key' | 'oauth' | 'local';\n needs: 'cors-free-transport' | null;\n blocked?: 'cors-free-transport';\n group?: 'providers' | 'mcp';\n secret?: 'api-key' | 'token';\n store?: 'vault';\n fields?: AccountField[];\n description?: string;\n keyUrl?: string;\n vaultName?: string;\n state?: McpServerState;\n}\n\nexport type McpServerState =\n | 'connecting'\n | 'connected'\n | 'needs-secret'\n | 'needs-auth'\n | 'failed'\n | 'disabled'\n | 'refused';\n\nexport type McpRefusalCode =\n | 'bad-name'\n | 'duplicate'\n | 'not-found'\n | 'not-object'\n | 'bad-token'\n | 'token-conflict'\n | 'url-secret'\n | 'header-secret'\n | 'stdio'\n | 'sse'\n | 'bad-url'\n | 'insecure-url'\n | 'file-invalid'\n | 'file-unreadable'\n | 'file-unwritable'\n | 'not-owner'\n | 'invalid';\n\nexport interface McpRefusal {\n code: McpRefusalCode;\n reason: string;\n}\n\nexport type McpRefusals = Record<string, McpRefusal>;\n\nexport type McpEdit = { ok: true } | ({ ok: false } & McpRefusal);\n\nexport interface AccountField {\n name: string;\n label: string;\n required?: boolean;\n placeholder?: string;\n help?: string;\n customBase?: true;\n vaultSetting?: string;\n options?: readonly { value: string; label: string }[];\n value?: string;\n}\n\nexport interface ProviderOption {\n id: string;\n name: string;\n description?: string;\n auth: 'api-key' | 'oauth' | 'fields' | 'local';\n fields?: AccountField[];\n keyUrl?: string;\n needs?: 'cors-free-transport';\n blocked?: 'cors-free-transport';\n vaultName?: string;\n}\n\nexport interface BudgetState {\n provider: string;\n percent: number;\n window: 'weekly';\n resets: string;\n}\n\nexport interface SignIn {\n clientId: string;\n scopes: string;\n imsEnvironment: string;\n}\n\nexport interface McpSignIn {\n url: string;\n state: string;\n}\n\nexport interface SettingsState {\n models: ModelChoice[];\n accounts: AccountState[];\n providers?: ProviderOption[];\n budget?: BudgetState | null;\n budgets?: BudgetState[];\n moved?: { kind: 'model' | 'mcp'; label: string }[];\n labels?: Record<string, string>;\n toolIntents?: boolean;\n}\n\nexport interface AgentSettings {\n readonly state: ReplicatedState<SettingsState>;\n connect(\n providerId: string,\n secret: string | null,\n fields: Record<string, string> | null,\n context: Context\n ): Promise<void>;\n disconnect(providerId: string, context: Context): Promise<void>;\n remove(providerId: string, context: Context): Promise<void>;\n serverUrl(providerId: string, context: Context): Promise<string | null>;\n signIn(providerId: string, context: Context): Promise<SignIn | McpSignIn | DeviceSignIn | null>;\n dismissMoved(context: Context): Promise<void>;\n addServer(name: string, entry: unknown, context: Context): Promise<McpEdit>;\n removeServer(id: string, context: Context): Promise<McpEdit>;\n refusals(context: Context): Promise<McpRefusals>;\n}\n\nexport const SETTINGS_METHODS = keys<\n Omit<AgentSettings, 'state' | 'addServer' | 'removeServer' | 'refusals'>\n>({\n connect: true,\n disconnect: true,\n remove: true,\n serverUrl: true,\n signIn: true,\n dismissMoved: true,\n});\n\nexport const OWNER_SETTINGS_METHODS: readonly (keyof Omit<AgentSettings, 'state'> & string)[] = [\n ...SETTINGS_METHODS,\n 'addServer',\n 'removeServer',\n 'refusals',\n];\n\nexport const AgentSettings: RemoteContract = contract('slicc.agent.settings', {\n owner: { state: ['state'], methods: OWNER_SETTINGS_METHODS },\n settings: { state: ['state'], methods: SETTINGS_METHODS },\n view: { state: ['state'] },\n});\n\nexport type InventoryStatus = 'running' | 'queued' | 'waiting' | 'error' | 'idle';\n\nexport const INVENTORY_STATUSES: readonly InventoryStatus[] = [\n 'running',\n 'queued',\n 'waiting',\n 'error',\n 'idle',\n];\n\nexport interface InventoryAgent {\n id: string;\n kind: 'cone' | 'scoop';\n parent?: string;\n status: InventoryStatus;\n queued: number;\n provider?: string;\n model?: string;\n since: number;\n}\n\nexport interface InventoryRow extends InventoryAgent {\n cone: string;\n}\n\nexport interface InventoryState {\n seq: number;\n changedAt: number;\n active: string;\n agents: InventoryRow[];\n}\n\nexport interface InventorySnapshot {\n seq: number;\n changedAt: number;\n counts: Record<InventoryStatus, number>;\n agents: InventoryAgent[];\n}\n\nexport interface AgentInventory {\n readonly inventory: ReplicatedState<InventoryState>;\n}\n\nexport const AgentInventoryService: RemoteContract = contract('slicc.agent.inventory', {\n owner: { state: ['inventory'] },\n none: {},\n});\n"],
|
|
5
|
+
"mappings": "AAuBA,SAAS,gBAAgB;AA2QzB,MAAM,OAAO,CAAI,WAAkC,OAAO,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SAAS,qBAAqB;AAAA,EAC7E,OAAO,EAAE,SAAS,aAAa;AAAA,EAC/B,MAAM,CAAC;AACT,CAAC;AAEM,MAAM,eAAe,KAAmC;AAAA,EAC7D,SAAS;AAAA,EACT,UAAU;AAAA,EACV,SAAS;AACX,CAAC;AAEM,MAAM,mBAAmC,SAAS,oBAAoB;AAAA,EAC3E,MAAM,EAAE,OAAO,CAAC,WAAW,GAAG,SAAS,aAAa;AAAA,EACpD,MAAM,CAAC;AACT,CAAC;AA0IM,MAAM,mBAAmB,KAE9B;AAAA,EACA,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,cAAc;AAChB,CAAC;AAEM,MAAM,yBAAmF;AAAA,EAC9F,GAAG;AAAA,EACH;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,gBAAgC,SAAS,wBAAwB;AAAA,EAC5E,OAAO,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,uBAAuB;AAAA,EAC3D,UAAU,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,iBAAiB;AAAA,EACxD,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE;AAC3B,CAAC;AAIM,MAAM,qBAAiD;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAmCO,MAAM,wBAAwC,SAAS,yBAAyB;AAAA,EACrF,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE;AAAA,EAC9B,MAAM,CAAC;AACT,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/settings.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { abortableBedrock } from "./bedrock.js";
|
|
14
14
|
import { codexProvider } from "./codex.js";
|
|
15
15
|
import { deviceFlows } from "./device.js";
|
|
16
|
+
import { KEY_OVER_HTTP, LOCAL, listLocal, localBase, SMALL_CONTEXT } from "./local.js";
|
|
16
17
|
import { MCP_ACCOUNT } from "./mcp/label.js";
|
|
17
18
|
import { BEDROCK, preferredModel } from "./preferred.js";
|
|
18
19
|
import {
|
|
@@ -127,7 +128,22 @@ function filled(fields, stored) {
|
|
|
127
128
|
return { ...field, ...options ? { options: [...options] } : {}, ...value ? { value } : {} };
|
|
128
129
|
});
|
|
129
130
|
}
|
|
130
|
-
function
|
|
131
|
+
function keylessOf(records, fields) {
|
|
132
|
+
return (providerId) => Boolean(LISTINGS.get(providerId)?.keyless) && !records.model(providerId) && fields.get(providerId) !== void 0 && fields.ready(providerId);
|
|
133
|
+
}
|
|
134
|
+
function small(models, providerId) {
|
|
135
|
+
return providerId === LOCAL && models.getModels(providerId).some((model) => model.contextWindow < SMALL_CONTEXT) ? ", context under 16k tokens" : "";
|
|
136
|
+
}
|
|
137
|
+
function connection(providerId, record, bare, models) {
|
|
138
|
+
if (!record)
|
|
139
|
+
return bare ? { identity: `No key${small(models, providerId)}`, status: "connected" } : { identity: "", status: "disconnected" };
|
|
140
|
+
return {
|
|
141
|
+
identity: `${identityOf(providerId, record)}${small(models, providerId)}`,
|
|
142
|
+
status: record.state === "expired" ? "expired" : "connected"
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function accounts(records, providers, given, blocked, models) {
|
|
146
|
+
const keyless = keylessOf(records, given);
|
|
131
147
|
return providers.map((provider) => {
|
|
132
148
|
const record = given.ready(provider.id) ? records.model(provider.id) : void 0;
|
|
133
149
|
const fields = ACCOUNT_FIELDS[provider.id];
|
|
@@ -135,8 +151,7 @@ function accounts(records, providers, given, blocked) {
|
|
|
135
151
|
return {
|
|
136
152
|
id: provider.id,
|
|
137
153
|
provider: provider.name ?? provider.id,
|
|
138
|
-
|
|
139
|
-
status: !record ? "disconnected" : record.state === "expired" ? "expired" : "connected",
|
|
154
|
+
...connection(provider.id, record, keyless(provider.id), models),
|
|
140
155
|
auth: oauth(provider.id) ? "oauth" : "api-key",
|
|
141
156
|
...DEVICE_SIGN_INS.has(provider.id) && listing?.keyUrl ? { secret: "api-key" } : {},
|
|
142
157
|
needs: listing?.corsFree ? "cors-free-transport" : null,
|
|
@@ -264,6 +279,17 @@ function grokBudgets(records, usage, { reach, every, now }) {
|
|
|
264
279
|
return found ? { provider: XAI, ...found } : null;
|
|
265
280
|
};
|
|
266
281
|
}
|
|
282
|
+
async function probeLocal({ records, fields }, given, reread) {
|
|
283
|
+
const base = localBase(given?.endpoint?.trim() || fields.get(LOCAL)?.endpoint || "");
|
|
284
|
+
if (typeof base !== "string") throw new Error(base.problem);
|
|
285
|
+
await reread();
|
|
286
|
+
const key = records.model(LOCAL)?.placeholder;
|
|
287
|
+
if (key && base.startsWith("http:")) throw new Error(KEY_OVER_HTTP);
|
|
288
|
+
await listLocal(base, {
|
|
289
|
+
...key ? { key } : {},
|
|
290
|
+
fetch: (input, init) => globalThis.fetch(input, init)
|
|
291
|
+
});
|
|
292
|
+
}
|
|
267
293
|
function blockedBy(reach) {
|
|
268
294
|
return (providerId) => Boolean(LISTINGS.get(providerId)?.corsFree) && reach?.free() === false;
|
|
269
295
|
}
|
|
@@ -296,9 +322,12 @@ async function createAgentSettings(models, sources, providers = sliccProviders()
|
|
|
296
322
|
const budgets = async () => (await Promise.all([adobeBudget(records, usage), polled ? grok() : null])).filter(
|
|
297
323
|
(found) => found !== null
|
|
298
324
|
);
|
|
325
|
+
const keyless = keylessOf(records, fields);
|
|
299
326
|
const snapshot = async () => {
|
|
300
327
|
const stored = new Set(
|
|
301
|
-
providers.filter(
|
|
328
|
+
providers.filter(
|
|
329
|
+
(provider) => records.model(provider.id) && fields.ready(provider.id) || keyless(provider.id)
|
|
330
|
+
).map((provider) => provider.id)
|
|
302
331
|
);
|
|
303
332
|
const show = listed(records, fields);
|
|
304
333
|
const shown = providers.filter((provider) => show(provider.id));
|
|
@@ -307,7 +336,10 @@ async function createAgentSettings(models, sources, providers = sliccProviders()
|
|
|
307
336
|
return {
|
|
308
337
|
models: choices(models, open(providers), stored),
|
|
309
338
|
labels: labels(models, open(shown), stored),
|
|
310
|
-
accounts: [
|
|
339
|
+
accounts: [
|
|
340
|
+
...accounts(records, shown, fields, blocked, models),
|
|
341
|
+
...await mcp?.accounts() ?? []
|
|
342
|
+
],
|
|
311
343
|
providers: offered(providers, blocked),
|
|
312
344
|
budget: held2[0] ?? null,
|
|
313
345
|
budgets: held2,
|
|
@@ -322,13 +354,13 @@ async function createAgentSettings(models, sources, providers = sliccProviders()
|
|
|
322
354
|
latest = next.catch(() => void 0);
|
|
323
355
|
return next;
|
|
324
356
|
};
|
|
325
|
-
const
|
|
357
|
+
const discovered = providers.filter((provider) => signIn.has(provider.id) || provider.id === LOCAL).map((provider) => provider.id);
|
|
326
358
|
const discover = (ids) => models.refresh({ providers: ids }).then(
|
|
327
359
|
() => void 0,
|
|
328
360
|
() => void 0
|
|
329
361
|
);
|
|
330
|
-
if (
|
|
331
|
-
const cycle = () => void (
|
|
362
|
+
if (discovered.length || polled) {
|
|
363
|
+
const cycle = () => void (discovered.length ? discover(discovered) : Promise.resolve()).then(() => refresh(BACKGROUND_CONTEXT)).catch(() => void 0);
|
|
332
364
|
cycle();
|
|
333
365
|
const timer = setInterval(cycle, every);
|
|
334
366
|
timer.unref?.();
|
|
@@ -336,14 +368,14 @@ async function createAgentSettings(models, sources, providers = sliccProviders()
|
|
|
336
368
|
mcp?.onChange(() => void refresh(BACKGROUND_CONTEXT).catch(() => void 0));
|
|
337
369
|
reach?.onChange(() => void refresh(BACKGROUND_CONTEXT).catch(() => void 0));
|
|
338
370
|
moved?.state.subscribe((_value, context) => void refresh(context).catch(() => void 0));
|
|
339
|
-
const held = () =>
|
|
371
|
+
const held = () => discovered.filter((id) => records.model(id)).join(" ");
|
|
340
372
|
let seen = held();
|
|
341
373
|
records.state.subscribe(() => {
|
|
342
374
|
const now = held();
|
|
343
375
|
const added = now !== seen;
|
|
344
376
|
seen = now;
|
|
345
|
-
const
|
|
346
|
-
void
|
|
377
|
+
const found = added ? discover(discovered) : Promise.resolve();
|
|
378
|
+
void found.then(() => refresh(BACKGROUND_CONTEXT)).catch(() => void 0);
|
|
347
379
|
});
|
|
348
380
|
const reread = (context) => records.refresh(context).catch(() => void 0);
|
|
349
381
|
return {
|
|
@@ -358,11 +390,12 @@ async function createAgentSettings(models, sources, providers = sliccProviders()
|
|
|
358
390
|
if (secret !== null)
|
|
359
391
|
throw new Error(signIn.has(providerId) ? SIGN_IN_NEEDS_VAULT : KEY_NEEDS_VAULT);
|
|
360
392
|
if (flows.has(providerId)) await flows.finish(providerId, context);
|
|
393
|
+
if (providerId === LOCAL) await probeLocal(sources, given, () => reread(context));
|
|
361
394
|
if (given !== null) await fields.set(providerId, given);
|
|
362
395
|
if (LISTINGS.has(providerId)) await fields.add(providerId);
|
|
363
396
|
records.reconnected(providerId);
|
|
364
397
|
await reread(context);
|
|
365
|
-
if (
|
|
398
|
+
if (discovered.includes(providerId)) await discover([providerId]);
|
|
366
399
|
await refresh(context);
|
|
367
400
|
},
|
|
368
401
|
async signIn(providerId, context) {
|
|
@@ -385,7 +418,10 @@ async function createAgentSettings(models, sources, providers = sliccProviders()
|
|
|
385
418
|
flows.stop(providerId);
|
|
386
419
|
const server = routed(providerId);
|
|
387
420
|
if (server) await server.disconnect(providerId);
|
|
388
|
-
else if (LISTINGS.
|
|
421
|
+
else if (LISTINGS.get(providerId)?.keyless) {
|
|
422
|
+
await fields.set(providerId, void 0);
|
|
423
|
+
await fields.add(providerId);
|
|
424
|
+
} else if (LISTINGS.has(providerId)) await fields.add(providerId);
|
|
389
425
|
else await fields.set(providerId, void 0);
|
|
390
426
|
await reread(context);
|
|
391
427
|
await refresh(context);
|
|
@@ -418,6 +454,7 @@ export {
|
|
|
418
454
|
createAgentSettings,
|
|
419
455
|
createSliccModels,
|
|
420
456
|
grokBudgets,
|
|
457
|
+
keylessOf,
|
|
421
458
|
preferredModel2 as preferredModel,
|
|
422
459
|
providerFields,
|
|
423
460
|
resolveDefaultModel,
|