@ai-ecoverse/slicc-agent 3.13.1 → 3.14.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 +19 -2
- package/bin/agent +1 -1
- package/dist/agents.js.map +2 -2
- package/dist/client.js +5 -1
- package/dist/client.js.map +2 -2
- package/dist/control.js +14 -1
- package/dist/control.js.map +2 -2
- package/dist/host.js +6 -2
- package/dist/host.js.map +2 -2
- package/dist/main.js +19 -2
- package/dist/main.js.map +2 -2
- package/dist/memory/context.js +91 -0
- package/dist/memory/context.js.map +7 -0
- package/dist/memory/format.js +251 -0
- package/dist/memory/format.js.map +7 -0
- package/dist/memory/index.js +32 -0
- package/dist/memory/index.js.map +7 -0
- package/dist/memory/prompt.js +175 -0
- package/dist/memory/prompt.js.map +7 -0
- package/dist/memory/runtime.js +194 -0
- package/dist/memory/runtime.js.map +7 -0
- package/dist/memory/store.js +153 -0
- package/dist/memory/store.js.map +7 -0
- package/dist/roles/frontmatter.js +9 -4
- package/dist/roles/frontmatter.js.map +2 -2
- package/dist/roles/roles.js +55 -11
- package/dist/roles/roles.js.map +2 -2
- package/dist/scoops/cli.js +3 -0
- package/dist/scoops/cli.js.map +2 -2
- package/dist/scoops/index.js +3 -2
- package/dist/scoops/index.js.map +2 -2
- package/dist/scoops/requests.js +1 -1
- package/dist/scoops/requests.js.map +2 -2
- package/dist/scoops/service.js +3 -0
- package/dist/scoops/service.js.map +2 -2
- package/dist/scoops/sync.js +1 -0
- package/dist/scoops/sync.js.map +2 -2
- package/dist/services.js.map +2 -2
- package/dist/skills/index.js +8 -1
- package/dist/skills/index.js.map +2 -2
- package/dist/spectrum/index.js +5 -1
- package/dist/spectrum/index.js.map +3 -3
- package/dist/spectrum/memory-port.js +64 -0
- package/dist/spectrum/memory-port.js.map +7 -0
- package/dist/types/agents.d.ts +7 -0
- package/dist/types/client.d.ts +3 -0
- package/dist/types/control.d.ts +2 -1
- package/dist/types/host.d.ts +2 -0
- package/dist/types/memory/context.d.ts +27 -0
- package/dist/types/memory/format.d.ts +67 -0
- package/dist/types/memory/index.d.ts +12 -0
- package/dist/types/memory/prompt.d.ts +48 -0
- package/dist/types/memory/runtime.d.ts +45 -0
- package/dist/types/memory/store.d.ts +41 -0
- package/dist/types/roles/frontmatter.d.ts +1 -1
- package/dist/types/roles/roles.d.ts +8 -0
- package/dist/types/scoops/cli.d.ts +1 -0
- package/dist/types/scoops/index.d.ts +1 -0
- package/dist/types/scoops/requests.d.ts +1 -1
- package/dist/types/scoops/service.d.ts +1 -0
- package/dist/types/services.d.ts +15 -0
- package/dist/types/spectrum/index.d.ts +3 -0
- package/dist/types/spectrum/memory-port.d.ts +12 -0
- package/package.json +2 -2
- package/packages/vfs-root/skills/memory/SKILL.md +48 -0
package/dist/scoops/sync.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/scoops/sync.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { ConversationId, EntryRecord, TaskId } from '@earendil-works/pi-durable';\nimport { answerText } from '../agent.ts';\nimport type { ScoopRecord } from '../agents.ts';\nimport { resolve } from '../kernel/paths.ts';\nimport {\n type Caller,\n choices,\n type Deps,\n fail,\n flags,\n isAnswer,\n last,\n MAX_DEPTH,\n prompts,\n readText,\n role,\n unsupported,\n} from './cli.ts';\nimport type { ReportResult } from './extension.ts';\nimport type { Request } from './requests.ts';\nimport { type Answer, SCOOPS_ROOT } from './service.ts';\n\nexport const SESSIONS = { tmp: '/tmp/agent-sessions', durable: '/home/sessions' };\n\ntype Ending = 'cancel' | 'detach';\n\ninterface Pending {\n end: (ending: Ending) => void;\n}\n\nexport interface SyncState {\n pending: Map<string, Pending>;\n}\n\nconst SYNC_VALUES = [\n '--name',\n '--agent',\n '--provider',\n '--model',\n '--thinking',\n '--effort',\n '--tools',\n '--prompt',\n '--file',\n '--read-only',\n '--system-prompt',\n '--system-prompt-file',\n '--background-after',\n];\nconst SYNC_SWITCHES = new Set([\n '--persist-session',\n '--no-persist-session',\n '--no-extensions',\n '--no-skills',\n '--no-context-files',\n]);\n\ntype Persist = 'tmp' | 'durable' | 'none';\n\nfunction persistOf(switches: Set<string>): Persist {\n if (switches.has('--no-persist-session')) return 'none';\n return switches.has('--persist-session') ? 'durable' : 'tmp';\n}\n\nfunction block(text: unknown): string {\n return typeof text === 'string' ? text : JSON.stringify(text, null, 2);\n}\n\nfunction entryMarkdown(entry: EntryRecord): string | undefined {\n const message = entry.model?.[0] as { content?: unknown; toolCallId?: string } | undefined;\n if (entry.kind === 'pi.user') return `## Request\\n\\n${answerText(message?.content)}`;\n if (entry.kind === 'pi.tool-result')\n return `### Result\\n\\n\\`\\`\\`\\n${answerText(message?.content)}\\n\\`\\`\\``;\n if (entry.kind !== 'pi.assistant') return undefined;\n const parts = Array.isArray(message?.content)\n ? (message.content as { type: string; name?: string; arguments?: unknown }[])\n : [];\n const calls = parts\n .filter((part) => part.type === 'toolCall')\n .map((part) => `\\`${part.name}\\` ${block(part.arguments)}`);\n return [`## Answer\\n\\n${answerText(message?.content)}`, ...calls].join('\\n\\n');\n}\n\nexport function transcript(record: ScoopRecord, entries: readonly EntryRecord[]): string {\n const body = entries.map(entryMarkdown).filter(Boolean);\n return `# ${record.name}${record.role ? ` (${record.role})` : ''}\\n\\n${body.join('\\n\\n')}\\n`;\n}\n\nasync function archive(\n deps: Deps,\n record: ScoopRecord,\n persist: Persist,\n context: Context\n): Promise<string | null> {\n if (persist === 'none') return null;\n const conversation = await deps.harness.conversation(\n record.conversation as ConversationId,\n context\n );\n if (!conversation) return null;\n const { entries } = await conversation.context(context);\n const path = `${SESSIONS[persist]}/${record.folder}.md`;\n await deps.env.writeFile(path, transcript(record, entries), context);\n return path;\n}\n\nasync function finish(deps: Deps, id: string, persist: Persist, context: Context): Promise<void> {\n const record = deps.agents.state().scoops[id];\n if (!record) return;\n await archive(deps, record, persist, context).catch(() => null);\n await deps.scoops.stop(id, false, context);\n await deps.env.remove(\n `${SCOOPS_ROOT}/${record.folder}`,\n { recursive: true, force: true },\n context\n );\n}\n\nasync function callerRunning(deps: Deps, who: Caller, context: Context): Promise<boolean> {\n if (!who.fromAgent) return false;\n const state = deps.agents.state();\n const conversation = who.scoop\n ? state.scoops[who.scoop]?.conversation\n : state.cones[who.cone]?.conversation;\n return conversation !== undefined && deps.scoops.busy(conversation, context);\n}\n\nasync function keep(\n deps: Deps,\n id: string,\n tasks: readonly number[],\n target: string | null,\n context: Context\n) {\n if (target) await deps.scoops.detach(tasks, target, context);\n await deps.agents.update((_tx, state) => {\n const record = state.scoops[id];\n if (record) record.kind = 'async';\n }, context);\n}\n\nfunction watchPid(deps: Deps, pid: number | null, end: (ending: Ending) => void): () => void {\n const alive = deps.alive;\n if (pid === null || !alive) return () => undefined;\n const timer = setInterval(() => {\n void alive(pid).then(\n (yes) => yes || end('cancel'),\n () => undefined\n );\n }, 1000);\n return () => clearInterval(timer);\n}\n\ninterface Plan {\n given: string[];\n workdir?: string;\n instructions: string;\n readOnly: string[];\n persist: Persist;\n}\n\nasync function plan(\n deps: Deps,\n request: Request,\n parsed: ReturnType<typeof flags>,\n context: Context\n) {\n const given = await prompts(deps, request.argv, request, context);\n let workdir: string | undefined;\n const notes: string[] = [];\n if (!given.length && parsed.rest.length === 3) {\n const [cwd, allowed, prompt] = parsed.rest as [string, string, string];\n workdir = resolve(request.cwd, cwd);\n if (allowed && allowed !== '*')\n notes.push(\n `Use only these commands in bash: ${allowed}. This is not enforced; keep to it anyway.`\n );\n given.push(prompt);\n } else if (parsed.rest.length) return fail(`unexpected argument ${parsed.rest[0]}`, 2);\n if (!given.length)\n return fail('agent needs --prompt, --file, - or <cwd> <allowed-commands> <prompt>', 2);\n const systemFile = last(parsed, '--system-prompt-file');\n const system =\n last(parsed, '--system-prompt') ??\n (systemFile ? await readText(deps, systemFile, request, context) : undefined);\n if (system) notes.push(system);\n if (workdir) notes.push(`Your working folder is ${workdir}; you may change files there.`);\n const readOnly = (last(parsed, '--read-only') ?? '')\n .split(',')\n .map((path) => path.trim())\n .filter(Boolean)\n .map((path) => resolve(request.cwd, path));\n const result: Plan = {\n given,\n instructions: notes.join('\\n\\n'),\n readOnly,\n persist: persistOf(parsed.switches),\n };\n if (workdir) result.workdir = workdir;\n return result;\n}\n\nasync function outcome(\n deps: Deps,\n tasks: readonly number[],\n context: Context\n): Promise<ReportResult> {\n let result: ReportResult = { text: '', failed: 'no request', path: null };\n for (const task of tasks) {\n const settled = await deps.harness.waitForTask(task as TaskId<ReportResult>, context);\n const outcome = settled.state.outcome;\n result =\n outcome.status === 'completed'\n ? outcome.result\n : { text: '', failed: outcome.status, path: null };\n }\n return result;\n}\n\nfunction answerOf(result: ReportResult): Answer {\n if (result.failed) return fail(`the scoop's request ended without an answer: ${result.failed}`);\n return { code: 0, out: result.text.endsWith('\\n') ? result.text : `${result.text}\\n` };\n}\n\nasync function settle(\n deps: Deps,\n who: Caller,\n id: string,\n tasks: readonly number[],\n ending: Ending,\n context: Context\n): Promise<Answer> {\n const handle = id.slice('scoop:'.length);\n if (ending === 'detach') {\n await keep(deps, id, tasks, who.id, context);\n const how = who.id ? 'its answer arrives as a lick' : `follow it with agent wait ${handle}`;\n return { code: 0, out: `${handle} continues in the background; ${how}\\n` };\n }\n if (await callerRunning(deps, who, context)) {\n await keep(deps, id, tasks, who.id, context);\n return {\n code: 143,\n out: `agent: the call was interrupted; ${handle} continues and its answer arrives as a lick\\n`,\n };\n }\n return { code: 130, out: 'agent: stopped\\n' };\n}\n\nexport async function runSync(\n deps: Deps,\n request: Request,\n who: Caller,\n context: Context\n): Promise<Answer> {\n const refused = unsupported(request.argv);\n if (refused) return refused;\n if (who.depth >= MAX_DEPTH) return fail(`agents nest at most ${MAX_DEPTH} deep`);\n const parsed = flags(request.argv, SYNC_VALUES);\n const unknown = [...parsed.switches].find((flag) => !SYNC_SWITCHES.has(flag));\n if (unknown) return fail(`unknown option ${unknown}`, 2);\n const planned = await plan(deps, request, parsed, context);\n if (isAnswer(planned)) return planned;\n const chosen = choices(parsed);\n if (isAnswer(chosen)) return chosen;\n const found = await role(deps, parsed);\n if (found.error) return found.error;\n const spawned = await deps.scoops.spawn(\n {\n cone: who.cone,\n kind: 'sync',\n parent: who.scoop ?? who.cone,\n depth: who.depth + 1,\n roots: { write: planned.workdir ? [planned.workdir] : [], read: planned.readOnly },\n ...(planned.workdir ? { cwd: planned.workdir } : {}),\n ...(planned.instructions ? { instructions: planned.instructions } : {}),\n target: null,\n asker: who.id,\n name: last(parsed, '--name') ?? found.role?.name ?? 'agent',\n ...(found.role ? { role: found.role } : {}),\n ...(chosen.model ? { model: chosen.model } : {}),\n ...(chosen.thinking ? { thinking: chosen.thinking as never } : {}),\n ...(chosen.tools ? { tools: chosen.tools } : {}),\n prompts: planned.given,\n fromAgent: who.fromAgent,\n request: request.id,\n limits: found.roles.limits,\n },\n context\n );\n if (spawned.code !== 0) return spawned;\n const id = `scoop:${spawned.out.trim()}`;\n const tasks = spawned.tasks ?? [];\n let end: (ending: Ending) => void = () => undefined;\n const ended = new Promise<Ending>((done) => {\n end = done;\n });\n deps.sync.pending.set(request.id, { end });\n const unwatch = watchPid(deps, request.pid, end);\n try {\n const raced = await Promise.race([outcome(deps, tasks, context), ended]);\n if (typeof raced === 'string') {\n const answer = await settle(deps, who, id, tasks, raced, context);\n if (answer.code === 130) await finish(deps, id, planned.persist, context);\n return answer;\n }\n await finish(deps, id, planned.persist, context);\n return answerOf(raced);\n } finally {\n unwatch();\n deps.sync.pending.delete(request.id);\n }\n}\n\nexport async function cancelSync(\n deps: Deps,\n requestId: string,\n _context: Context\n): Promise<Answer> {\n deps.sync.pending.get(requestId)?.end('cancel');\n return { code: 0, out: '' };\n}\n\nexport async function detachSync(\n deps: Deps,\n requestId: string,\n _context: Context\n): Promise<Answer> {\n deps.sync.pending.get(requestId)?.end('detach');\n return { code: 0, out: '' };\n}\n"],
|
|
5
|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AAO,SAAS,IAAK,OAAM,OAAO,MAAM,IAAI,QAAQ,SAAS,OAAO;AACxE,aAAO;AAAA,IACT;AACA,UAAM,OAAO,MAAM,IAAI,QAAQ,SAAS,OAAO;AAC/C,WAAO,SAAS,KAAK;AAAA,EACvB,UAAE;AACA,YAAQ;AACR,SAAK,KAAK,QAAQ,OAAO,QAAQ,EAAE;AAAA,EACrC;AACF;AAEA,eAAsB,WACpB,MACA,WACA,UACiB;AACjB,OAAK,KAAK,QAAQ,IAAI,SAAS,GAAG,IAAI,QAAQ;AAC9C,SAAO,EAAE,MAAM,GAAG,KAAK,GAAG;AAC5B;AAEA,eAAsB,WACpB,MACA,WACA,UACiB;AACjB,OAAK,KAAK,QAAQ,IAAI,SAAS,GAAG,IAAI,QAAQ;AAC9C,SAAO,EAAE,MAAM,GAAG,KAAK,GAAG;AAC5B;",
|
|
4
|
+
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { ConversationId, EntryRecord, TaskId } from '@earendil-works/pi-durable';\nimport { answerText } from '../agent.ts';\nimport type { ScoopRecord } from '../agents.ts';\nimport { resolve } from '../kernel/paths.ts';\nimport {\n type Caller,\n choices,\n type Deps,\n fail,\n flags,\n isAnswer,\n last,\n MAX_DEPTH,\n prompts,\n readText,\n role,\n unsupported,\n} from './cli.ts';\nimport type { ReportResult } from './extension.ts';\nimport type { Request } from './requests.ts';\nimport { type Answer, SCOOPS_ROOT } from './service.ts';\n\nexport const SESSIONS = { tmp: '/tmp/agent-sessions', durable: '/home/sessions' };\n\ntype Ending = 'cancel' | 'detach';\n\ninterface Pending {\n end: (ending: Ending) => void;\n}\n\nexport interface SyncState {\n pending: Map<string, Pending>;\n}\n\nconst SYNC_VALUES = [\n '--name',\n '--agent',\n '--provider',\n '--model',\n '--thinking',\n '--effort',\n '--tools',\n '--prompt',\n '--file',\n '--read-only',\n '--system-prompt',\n '--system-prompt-file',\n '--background-after',\n];\nconst SYNC_SWITCHES = new Set([\n '--persist-session',\n '--no-persist-session',\n '--no-extensions',\n '--no-skills',\n '--no-context-files',\n]);\n\ntype Persist = 'tmp' | 'durable' | 'none';\n\nfunction persistOf(switches: Set<string>): Persist {\n if (switches.has('--no-persist-session')) return 'none';\n return switches.has('--persist-session') ? 'durable' : 'tmp';\n}\n\nfunction block(text: unknown): string {\n return typeof text === 'string' ? text : JSON.stringify(text, null, 2);\n}\n\nfunction entryMarkdown(entry: EntryRecord): string | undefined {\n const message = entry.model?.[0] as { content?: unknown; toolCallId?: string } | undefined;\n if (entry.kind === 'pi.user') return `## Request\\n\\n${answerText(message?.content)}`;\n if (entry.kind === 'pi.tool-result')\n return `### Result\\n\\n\\`\\`\\`\\n${answerText(message?.content)}\\n\\`\\`\\``;\n if (entry.kind !== 'pi.assistant') return undefined;\n const parts = Array.isArray(message?.content)\n ? (message.content as { type: string; name?: string; arguments?: unknown }[])\n : [];\n const calls = parts\n .filter((part) => part.type === 'toolCall')\n .map((part) => `\\`${part.name}\\` ${block(part.arguments)}`);\n return [`## Answer\\n\\n${answerText(message?.content)}`, ...calls].join('\\n\\n');\n}\n\nexport function transcript(record: ScoopRecord, entries: readonly EntryRecord[]): string {\n const body = entries.map(entryMarkdown).filter(Boolean);\n return `# ${record.name}${record.role ? ` (${record.role})` : ''}\\n\\n${body.join('\\n\\n')}\\n`;\n}\n\nasync function archive(\n deps: Deps,\n record: ScoopRecord,\n persist: Persist,\n context: Context\n): Promise<string | null> {\n if (persist === 'none') return null;\n const conversation = await deps.harness.conversation(\n record.conversation as ConversationId,\n context\n );\n if (!conversation) return null;\n const { entries } = await conversation.context(context);\n const path = `${SESSIONS[persist]}/${record.folder}.md`;\n await deps.env.writeFile(path, transcript(record, entries), context);\n return path;\n}\n\nasync function finish(deps: Deps, id: string, persist: Persist, context: Context): Promise<void> {\n const record = deps.agents.state().scoops[id];\n if (!record) return;\n await archive(deps, record, persist, context).catch(() => null);\n await deps.scoops.stop(id, false, context);\n await deps.env.remove(\n `${SCOOPS_ROOT}/${record.folder}`,\n { recursive: true, force: true },\n context\n );\n}\n\nasync function callerRunning(deps: Deps, who: Caller, context: Context): Promise<boolean> {\n if (!who.fromAgent) return false;\n const state = deps.agents.state();\n const conversation = who.scoop\n ? state.scoops[who.scoop]?.conversation\n : state.cones[who.cone]?.conversation;\n return conversation !== undefined && deps.scoops.busy(conversation, context);\n}\n\nasync function keep(\n deps: Deps,\n id: string,\n tasks: readonly number[],\n target: string | null,\n context: Context\n) {\n if (target) await deps.scoops.detach(tasks, target, context);\n await deps.agents.update((_tx, state) => {\n const record = state.scoops[id];\n if (record) record.kind = 'async';\n }, context);\n}\n\nfunction watchPid(deps: Deps, pid: number | null, end: (ending: Ending) => void): () => void {\n const alive = deps.alive;\n if (pid === null || !alive) return () => undefined;\n const timer = setInterval(() => {\n void alive(pid).then(\n (yes) => yes || end('cancel'),\n () => undefined\n );\n }, 1000);\n return () => clearInterval(timer);\n}\n\ninterface Plan {\n given: string[];\n workdir?: string;\n instructions: string;\n readOnly: string[];\n persist: Persist;\n}\n\nasync function plan(\n deps: Deps,\n request: Request,\n parsed: ReturnType<typeof flags>,\n context: Context\n) {\n const given = await prompts(deps, request.argv, request, context);\n let workdir: string | undefined;\n const notes: string[] = [];\n if (!given.length && parsed.rest.length === 3) {\n const [cwd, allowed, prompt] = parsed.rest as [string, string, string];\n workdir = resolve(request.cwd, cwd);\n if (allowed && allowed !== '*')\n notes.push(\n `Use only these commands in bash: ${allowed}. This is not enforced; keep to it anyway.`\n );\n given.push(prompt);\n } else if (parsed.rest.length) return fail(`unexpected argument ${parsed.rest[0]}`, 2);\n if (!given.length)\n return fail('agent needs --prompt, --file, - or <cwd> <allowed-commands> <prompt>', 2);\n const systemFile = last(parsed, '--system-prompt-file');\n const system =\n last(parsed, '--system-prompt') ??\n (systemFile ? await readText(deps, systemFile, request, context) : undefined);\n if (system) notes.push(system);\n if (workdir) notes.push(`Your working folder is ${workdir}; you may change files there.`);\n const readOnly = (last(parsed, '--read-only') ?? '')\n .split(',')\n .map((path) => path.trim())\n .filter(Boolean)\n .map((path) => resolve(request.cwd, path));\n const result: Plan = {\n given,\n instructions: notes.join('\\n\\n'),\n readOnly,\n persist: persistOf(parsed.switches),\n };\n if (workdir) result.workdir = workdir;\n return result;\n}\n\nasync function outcome(\n deps: Deps,\n tasks: readonly number[],\n context: Context\n): Promise<ReportResult> {\n let result: ReportResult = { text: '', failed: 'no request', path: null };\n for (const task of tasks) {\n const settled = await deps.harness.waitForTask(task as TaskId<ReportResult>, context);\n const outcome = settled.state.outcome;\n result =\n outcome.status === 'completed'\n ? outcome.result\n : { text: '', failed: outcome.status, path: null };\n }\n return result;\n}\n\nfunction answerOf(result: ReportResult): Answer {\n if (result.failed) return fail(`the scoop's request ended without an answer: ${result.failed}`);\n return { code: 0, out: result.text.endsWith('\\n') ? result.text : `${result.text}\\n` };\n}\n\nasync function settle(\n deps: Deps,\n who: Caller,\n id: string,\n tasks: readonly number[],\n ending: Ending,\n context: Context\n): Promise<Answer> {\n const handle = id.slice('scoop:'.length);\n if (ending === 'detach') {\n await keep(deps, id, tasks, who.id, context);\n const how = who.id ? 'its answer arrives as a lick' : `follow it with agent wait ${handle}`;\n return { code: 0, out: `${handle} continues in the background; ${how}\\n` };\n }\n if (await callerRunning(deps, who, context)) {\n await keep(deps, id, tasks, who.id, context);\n return {\n code: 143,\n out: `agent: the call was interrupted; ${handle} continues and its answer arrives as a lick\\n`,\n };\n }\n return { code: 130, out: 'agent: stopped\\n' };\n}\n\nexport async function runSync(\n deps: Deps,\n request: Request,\n who: Caller,\n context: Context\n): Promise<Answer> {\n const refused = unsupported(request.argv);\n if (refused) return refused;\n if (who.depth >= MAX_DEPTH) return fail(`agents nest at most ${MAX_DEPTH} deep`);\n const parsed = flags(request.argv, SYNC_VALUES);\n const unknown = [...parsed.switches].find((flag) => !SYNC_SWITCHES.has(flag));\n if (unknown) return fail(`unknown option ${unknown}`, 2);\n const planned = await plan(deps, request, parsed, context);\n if (isAnswer(planned)) return planned;\n const chosen = choices(parsed);\n if (isAnswer(chosen)) return chosen;\n const found = await role(deps, parsed);\n if (found.error) return found.error;\n const spawned = await deps.scoops.spawn(\n {\n cone: who.cone,\n kind: 'sync',\n parent: who.scoop ?? who.cone,\n depth: who.depth + 1,\n roots: { write: planned.workdir ? [planned.workdir] : [], read: planned.readOnly },\n ...(planned.workdir ? { cwd: planned.workdir } : {}),\n ...(planned.instructions ? { instructions: planned.instructions } : {}),\n target: null,\n asker: who.id,\n name: last(parsed, '--name') ?? found.role?.name ?? 'agent',\n ...(found.role ? { role: found.role } : {}),\n ...(chosen.model ? { model: chosen.model } : {}),\n ...(chosen.thinking ? { thinking: chosen.thinking as never } : {}),\n ...(chosen.tools ? { tools: chosen.tools } : {}),\n prompts: planned.given,\n origin: request.cwd,\n fromAgent: who.fromAgent,\n request: request.id,\n limits: found.roles.limits,\n },\n context\n );\n if (spawned.code !== 0) return spawned;\n const id = `scoop:${spawned.out.trim()}`;\n const tasks = spawned.tasks ?? [];\n let end: (ending: Ending) => void = () => undefined;\n const ended = new Promise<Ending>((done) => {\n end = done;\n });\n deps.sync.pending.set(request.id, { end });\n const unwatch = watchPid(deps, request.pid, end);\n try {\n const raced = await Promise.race([outcome(deps, tasks, context), ended]);\n if (typeof raced === 'string') {\n const answer = await settle(deps, who, id, tasks, raced, context);\n if (answer.code === 130) await finish(deps, id, planned.persist, context);\n return answer;\n }\n await finish(deps, id, planned.persist, context);\n return answerOf(raced);\n } finally {\n unwatch();\n deps.sync.pending.delete(request.id);\n }\n}\n\nexport async function cancelSync(\n deps: Deps,\n requestId: string,\n _context: Context\n): Promise<Answer> {\n deps.sync.pending.get(requestId)?.end('cancel');\n return { code: 0, out: '' };\n}\n\nexport async function detachSync(\n deps: Deps,\n requestId: string,\n _context: Context\n): Promise<Answer> {\n deps.sync.pending.get(requestId)?.end('detach');\n return { code: 0, out: '' };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,kBAAkB;AAE3B,SAAS,eAAe;AACxB;AAAA,EAEE;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AAQ,SAAS,OAAO;AACxE,aAAO;AAAA,IACT;AACA,UAAM,OAAO,MAAM,IAAI,QAAQ,SAAS,OAAO;AAC/C,WAAO,SAAS,KAAK;AAAA,EACvB,UAAE;AACA,YAAQ;AACR,SAAK,KAAK,QAAQ,OAAO,QAAQ,EAAE;AAAA,EACrC;AACF;AAEA,eAAsB,WACpB,MACA,WACA,UACiB;AACjB,OAAK,KAAK,QAAQ,IAAI,SAAS,GAAG,IAAI,QAAQ;AAC9C,SAAO,EAAE,MAAM,GAAG,KAAK,GAAG;AAC5B;AAEA,eAAsB,WACpB,MACA,WACA,UACiB;AACjB,OAAK,KAAK,QAAQ,IAAI,SAAS,GAAG,IAAI,QAAQ;AAC9C,SAAO,EAAE,MAAM,GAAG,KAAK,GAAG;AAC5B;",
|
|
6
6
|
"names": ["outcome"]
|
|
7
7
|
}
|
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 {\n type Context,\n defineService,\n type JsonValue,\n type ReplicatedState,\n} from '@earendil-works/chord';\nimport type { ConversationView } from '@earendil-works/pi-durable';\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}\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 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 resolveLick(\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}\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 }\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\nexport const AgentControl = defineService<AgentControl>('slicc.agent.control');\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 sprinkles: ReplicatedState<Sprinkle[]>;\n}\n\nexport interface Command {\n name: string;\n description: string;\n kind: 'prompt' | 'skill';\n}\n\nexport const AgentTranscript = defineService<AgentTranscript>('slicc.agent.transcript');\n\nexport interface AgentSessions {\n attach(sessionId: string, context: Context): Promise<void>;\n detach(context: Context): Promise<void>;\n}\n\nexport const AgentSessions = defineService<AgentSessions>('slicc.agent.sessions');\n\nexport const AGENT_SESSION = 'agent';\n\nexport interface ModelChoice {\n id: string;\n label: string;\n provider: string;\n kind: 'chat' | 'classifier';\n reasoning: boolean;\n contextWindow: number;\n}\n\nexport interface AccountState {\n id: string;\n provider: string;\n identity: string;\n status: 'connected' | 'disconnected';\n auth: 'api-key' | 'oauth';\n needs: 'cors-free-transport' | null;\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 SettingsState {\n models: ModelChoice[];\n accounts: AccountState[];\n budget?: BudgetState | null;\n}\n\nexport interface AgentSettings {\n readonly state: ReplicatedState<SettingsState>;\n connect(\n providerId: string,\n secret: string,\n region: string | null,\n context: Context\n ): Promise<void>;\n disconnect(providerId: string, context: Context): Promise<void>;\n signIn(providerId: string, context: Context): Promise<SignIn | null>;\n}\n\nexport const AgentSettings = defineService<AgentSettings>('slicc.agent.settings');\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EAEE;AAAA,OAGK;
|
|
4
|
+
"sourcesContent": ["import {\n type Context,\n defineService,\n type JsonValue,\n type ReplicatedState,\n} from '@earendil-works/chord';\nimport type { ConversationView } from '@earendil-works/pi-durable';\nimport type { MemoryEntry, MemoryScope, MemoryTag } from './memory/format.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}\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 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 resolveLick(\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}\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 }\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\nexport const AgentControl = defineService<AgentControl>('slicc.agent.control');\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 sprinkles: ReplicatedState<Sprinkle[]>;\n readonly memories: ReplicatedState<MemoryEntry[]>;\n readonly memoryScopes: ReplicatedState<MemoryScope[]>;\n}\n\nexport interface Command {\n name: string;\n description: string;\n kind: 'prompt' | 'skill';\n}\n\nexport const AgentTranscript = defineService<AgentTranscript>('slicc.agent.transcript');\n\nexport interface AgentSessions {\n attach(sessionId: string, context: Context): Promise<void>;\n detach(context: Context): Promise<void>;\n}\n\nexport const AgentSessions = defineService<AgentSessions>('slicc.agent.sessions');\n\nexport const AGENT_SESSION = 'agent';\n\nexport interface ModelChoice {\n id: string;\n label: string;\n provider: string;\n kind: 'chat' | 'classifier';\n reasoning: boolean;\n contextWindow: number;\n}\n\nexport interface AccountState {\n id: string;\n provider: string;\n identity: string;\n status: 'connected' | 'disconnected';\n auth: 'api-key' | 'oauth';\n needs: 'cors-free-transport' | null;\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 SettingsState {\n models: ModelChoice[];\n accounts: AccountState[];\n budget?: BudgetState | null;\n}\n\nexport interface AgentSettings {\n readonly state: ReplicatedState<SettingsState>;\n connect(\n providerId: string,\n secret: string,\n region: string | null,\n context: Context\n ): Promise<void>;\n disconnect(providerId: string, context: Context): Promise<void>;\n signIn(providerId: string, context: Context): Promise<SignIn | null>;\n}\n\nexport const AgentSettings = defineService<AgentSettings>('slicc.agent.settings');\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EAEE;AAAA,OAGK;AAsHA,MAAM,eAAe,cAA4B,qBAAqB;AAqBtE,MAAM,kBAAkB,cAA+B,wBAAwB;AAO/E,MAAM,gBAAgB,cAA6B,sBAAsB;AAEzE,MAAM,gBAAgB;AAmDtB,MAAM,gBAAgB,cAA6B,sBAAsB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/skills/index.js
CHANGED
|
@@ -10,7 +10,14 @@ import {
|
|
|
10
10
|
loadSkills
|
|
11
11
|
} from "./skills.js";
|
|
12
12
|
import { expandPromptTemplate, loadTemplates } from "./templates.js";
|
|
13
|
-
const BUILTIN_SKILLS = [
|
|
13
|
+
const BUILTIN_SKILLS = [
|
|
14
|
+
"agent",
|
|
15
|
+
"licks",
|
|
16
|
+
"memory",
|
|
17
|
+
"skill-authoring",
|
|
18
|
+
"sprinkles",
|
|
19
|
+
"welcome"
|
|
20
|
+
];
|
|
14
21
|
const BUILTIN_PROMPTS = ["parallel-review", "review-loop"];
|
|
15
22
|
const SKILLS_DIR = "/var/lib/slicc/agent/skills";
|
|
16
23
|
const PROMPTS_DIR = "/var/lib/slicc/agent/prompts";
|
package/dist/skills/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/skills/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Context, type ReplicatedState, replicatedState } from '@earendil-works/chord';\nimport {\n defineExtension,\n type Extension,\n type Registry,\n section,\n} from '@earendil-works/pi-durable';\nimport type { ExecutionEnv, FileWatcher } from '@earendil-works/pi-durable/env';\nimport type { Licks } from '../licks/licks.ts';\nimport { manifestDirs } from '../roles/roles.ts';\nimport type { Command } from '../services.ts';\nimport {\n type Diagnostic,\n expandSkillCommand,\n formatSkillsForPrompt,\n loadSkills,\n type Skill,\n type SkillRoot,\n} from './skills.ts';\nimport { expandPromptTemplate, loadTemplates, type PromptTemplate } from './templates.ts';\n\nexport const BUILTIN_SKILLS = ['agent'
|
|
5
|
-
"mappings": "AAAA,SAA6C,uBAAuB;AACpE;AAAA,EACE;AAAA,EAGA;AAAA,OACK;AAGP,SAAS,oBAAoB;AAE7B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,sBAAsB,qBAA0C;AAElE,MAAM,iBAAiB,
|
|
4
|
+
"sourcesContent": ["import { type Context, type ReplicatedState, replicatedState } from '@earendil-works/chord';\nimport {\n defineExtension,\n type Extension,\n type Registry,\n section,\n} from '@earendil-works/pi-durable';\nimport type { ExecutionEnv, FileWatcher } from '@earendil-works/pi-durable/env';\nimport type { Licks } from '../licks/licks.ts';\nimport { manifestDirs } from '../roles/roles.ts';\nimport type { Command } from '../services.ts';\nimport {\n type Diagnostic,\n expandSkillCommand,\n formatSkillsForPrompt,\n loadSkills,\n type Skill,\n type SkillRoot,\n} from './skills.ts';\nimport { expandPromptTemplate, loadTemplates, type PromptTemplate } from './templates.ts';\n\nexport const BUILTIN_SKILLS = [\n 'agent',\n 'licks',\n 'memory',\n 'skill-authoring',\n 'sprinkles',\n 'welcome',\n];\nexport const BUILTIN_PROMPTS = ['parallel-review', 'review-loop'];\nexport const SKILLS_DIR = '/var/lib/slicc/agent/skills';\nexport const PROMPTS_DIR = '/var/lib/slicc/agent/prompts';\nexport const COMPAT_DIR = '/workspace/skills';\nexport const RELOAD_MS = 300;\n\nexport interface SkillsRuntime {\n readonly commands: ReplicatedState<Command[]>;\n skills(): readonly Skill[];\n dirs(): string[];\n templates(): readonly PromptTemplate[];\n expand(text: string, context: Context): Promise<string>;\n reload(context: Context): Promise<void>;\n close(context: Context): Promise<void>;\n}\n\nexport interface SkillsAttach {\n env: ExecutionEnv;\n home: string;\n assets?: (path: string) => Promise<string>;\n reloadMs: number;\n}\n\nexport interface SkillsSetup {\n extension: Extension;\n attach(options: SkillsAttach, context: Context): Promise<SkillsRuntime>;\n}\n\ntype Manifest = { pi?: { skills?: unknown; prompts?: unknown } };\n\nexport function piResources(dir: string, text: string, kind: 'skills' | 'prompts'): string[] {\n let manifest: Manifest;\n try {\n manifest = JSON.parse(text) as Manifest;\n } catch {\n return [];\n }\n const listed = manifest.pi?.[kind];\n const paths = Array.isArray(listed) ? listed : typeof listed === 'string' ? [listed] : [];\n return paths\n .filter((path): path is string => typeof path === 'string')\n .map((path) => `${dir}/${path.replace(/^\\.\\//, '').replace(/\\/$/, '')}`);\n}\n\nasync function packaged(env: ExecutionEnv, kind: 'skills' | 'prompts', context: Context) {\n const out: string[] = [];\n for (const dir of await manifestDirs(env, '/node_modules', context)) {\n const read = await env.readTextFile(`${dir}/package.json`, context);\n if (read.ok) out.push(...piResources(dir, read.value, kind));\n }\n return out;\n}\n\nasync function installBuiltins(\n env: ExecutionEnv,\n assets: (path: string) => Promise<string>,\n context: Context\n): Promise<void> {\n await env.remove(SKILLS_DIR, { recursive: true, force: true }, context);\n await env.remove(PROMPTS_DIR, { recursive: true, force: true }, context);\n for (const name of BUILTIN_SKILLS) {\n const text = await assets(`packages/vfs-root/skills/${name}/SKILL.md`).catch(() => undefined);\n if (text === undefined) continue;\n await env.createDir(`${SKILLS_DIR}/${name}`, { recursive: true }, context);\n await env.writeFile(`${SKILLS_DIR}/${name}/SKILL.md`, text, context);\n }\n await env.createDir(PROMPTS_DIR, { recursive: true }, context);\n for (const name of BUILTIN_PROMPTS) {\n const text = await assets(`packages/vfs-root/prompts/${name}.md`).catch(() => undefined);\n if (text !== undefined) await env.writeFile(`${PROMPTS_DIR}/${name}.md`, text, context);\n }\n}\n\nexport function problemLick(problem: Diagnostic, home: string) {\n const path = problem.path.startsWith(`${home}/`)\n ? `~${problem.path.slice(home.length)}`\n : problem.path;\n return {\n channel: 'fswatch' as const,\n source: `skills:${path}`,\n title: `Skill or prompt template problem: ${path}`,\n text: problem.message,\n body: 'The file is used with this problem, or skipped if it has no description.\\nThe rules are in the slicc-agent README.',\n target: 'cone' as const,\n severity: 'warn' as const,\n eventId: `${path}\\n${problem.message}`,\n };\n}\n\nexport function commandsOf(\n skills: readonly Skill[],\n templates: readonly PromptTemplate[]\n): Command[] {\n return [\n ...templates.map((template) => ({\n name: template.name,\n description: template.description,\n kind: 'prompt' as const,\n })),\n ...skills.map((skill) => ({\n name: `skill:${skill.name}`,\n description: skill.description,\n kind: 'skill' as const,\n })),\n ];\n}\n\nexport function setupSkills(registry: Registry, licks: Licks): SkillsSetup {\n let current: Skill[] = [];\n const extension = defineExtension({\n name: 'slicc-skills',\n sections: [section('skills', async () => formatSkillsForPrompt(current) || undefined)],\n });\n registry.install(extension);\n return {\n extension,\n async attach(options, context) {\n const { env, home } = options;\n if (options.assets)\n await installBuiltins(env, options.assets, context).catch(() => undefined);\n let templates: PromptTemplate[] = [];\n const commands = replicatedState<Command[]>([]);\n const reported = new Set<string>();\n const reload = async (using: Context) => {\n const roots: SkillRoot[] = [\n { dir: `${home}/.pi/agent/skills`, source: 'user' },\n { dir: `${home}/.agents/skills`, source: 'user' },\n { dir: COMPAT_DIR, source: 'compat' },\n ...(await packaged(env, 'skills', using)).map((dir) => ({\n dir,\n source: 'package' as const,\n })),\n { dir: SKILLS_DIR, source: 'builtin' },\n ];\n const loaded = await loadSkills(env, roots, using);\n const prompts = await loadTemplates(\n env,\n [`${home}/.pi/agent/prompts`, ...(await packaged(env, 'prompts', using)), PROMPTS_DIR],\n using\n );\n current = loaded.skills;\n templates = prompts.templates;\n commands.replace(using, commandsOf(current, templates));\n for (const problem of [...loaded.diagnostics, ...prompts.diagnostics]) {\n const key = `${problem.path}\\n${problem.message}`;\n if (reported.has(key)) continue;\n reported.add(key);\n await licks.deliver(problemLick(problem, home), using).catch(() => undefined);\n }\n };\n await reload(context);\n let timer: ReturnType<typeof setTimeout> | undefined;\n const schedule = () => {\n clearTimeout(timer);\n timer = setTimeout(() => void reload(context).catch(() => undefined), options.reloadMs);\n };\n const watched = await env.watch(\n [\n { path: `${home}/.pi/agent/skills`, recursive: true },\n { path: `${home}/.pi/agent/prompts` },\n { path: `${home}/.agents/skills`, recursive: true },\n { path: COMPAT_DIR, recursive: true },\n ],\n schedule,\n context\n );\n const watcher: FileWatcher | undefined = watched.ok ? watched.value : undefined;\n return {\n commands,\n skills: () => current,\n dirs: () => current.map((skill) => skill.baseDir),\n templates: () => templates,\n async expand(text, using) {\n const expanded = await expandSkillCommand(text, current, env, using);\n return expanded === text ? expandPromptTemplate(text, templates) : expanded;\n },\n reload,\n async close(using) {\n clearTimeout(timer);\n await watcher?.close(using);\n },\n };\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAA6C,uBAAuB;AACpE;AAAA,EACE;AAAA,EAGA;AAAA,OACK;AAGP,SAAS,oBAAoB;AAE7B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,sBAAsB,qBAA0C;AAElE,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACO,MAAM,kBAAkB,CAAC,mBAAmB,aAAa;AACzD,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MA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AACrB,qBAAa,KAAK;AAClB,gBAAQ,WAAW,MAAM,KAAK,OAAO,OAAO,EAAE,MAAM,MAAM,MAAS,GAAG,QAAQ,QAAQ;AAAA,MACxF;AACA,YAAM,UAAU,MAAM,IAAI;AAAA,QACxB;AAAA,UACE,EAAE,MAAM,GAAG,IAAI,qBAAqB,WAAW,KAAK;AAAA,UACpD,EAAE,MAAM,GAAG,IAAI,qBAAqB;AAAA,UACpC,EAAE,MAAM,GAAG,IAAI,mBAAmB,WAAW,KAAK;AAAA,UAClD,EAAE,MAAM,YAAY,WAAW,KAAK;AAAA,QACtC;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,YAAM,UAAmC,QAAQ,KAAK,QAAQ,QAAQ;AACtE,aAAO;AAAA,QACL;AAAA,QACA,QAAQ,MAAM;AAAA,QACd,MAAM,MAAM,QAAQ,IAAI,CAAC,UAAU,MAAM,OAAO;AAAA,QAChD,WAAW,MAAM;AAAA,QACjB,MAAM,OAAO,MAAM,OAAO;AACxB,gBAAM,WAAW,MAAM,mBAAmB,MAAM,SAAS,KAAK,KAAK;AACnE,iBAAO,aAAa,OAAO,qBAAqB,MAAM,SAAS,IAAI;AAAA,QACrE;AAAA,QACA;AAAA,QACA,MAAM,MAAM,OAAO;AACjB,uBAAa,KAAK;AAClB,gBAAM,SAAS,MAAM,KAAK;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/spectrum/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AgentAdapter } from "./agent-port.js";
|
|
2
|
+
import { MemoryAdapter } from "./memory-port.js";
|
|
2
3
|
import { SettingsAdapter } from "./settings-port.js";
|
|
3
4
|
import { SprinkleAdapter } from "./sprinkle-port.js";
|
|
4
5
|
import { TrayAdapter } from "./tray-port.js";
|
|
5
6
|
import { AgentAdapter as AgentAdapter2, CONE } from "./agent-port.js";
|
|
7
|
+
import { MemoryAdapter as MemoryAdapter2 } from "./memory-port.js";
|
|
6
8
|
import {
|
|
7
9
|
assistant,
|
|
8
10
|
errorAction,
|
|
@@ -26,12 +28,14 @@ function createAgentModel(connection, options = {}) {
|
|
|
26
28
|
options.login ?? null
|
|
27
29
|
),
|
|
28
30
|
tray: new TrayAdapter(connection.settings),
|
|
29
|
-
sprinkles: new SprinkleAdapter(connection)
|
|
31
|
+
sprinkles: new SprinkleAdapter(connection),
|
|
32
|
+
memory: new MemoryAdapter(connection)
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
35
|
export {
|
|
33
36
|
AgentAdapter2 as AgentAdapter,
|
|
34
37
|
CONE,
|
|
38
|
+
MemoryAdapter2 as MemoryAdapter,
|
|
35
39
|
SETTINGS_KEY,
|
|
36
40
|
SettingsAdapter2 as SettingsAdapter,
|
|
37
41
|
SprinkleAdapter2 as SprinkleAdapter,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/spectrum/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type { AgentConnection } from '../client.ts';\nimport { AgentAdapter } from './agent-port.ts';\nimport { type Login, SettingsAdapter } from './settings-port.ts';\nimport { SprinkleAdapter } from './sprinkle-port.ts';\nimport { TrayAdapter } from './tray-port.ts';\n\nexport { AgentAdapter, CONE } from './agent-port.ts';\nexport {\n assistant,\n errorAction,\n errorPart,\n isBusy,\n queued,\n textOf,\n toMessages,\n} from './messages.ts';\nexport { type Login, SETTINGS_KEY, SettingsAdapter } from './settings-port.ts';\nexport { SprinkleAdapter } from './sprinkle-port.ts';\nexport { TrayAdapter } from './tray-port.ts';\n\nexport function createAgentModel(\n connection: AgentConnection,\n options: { storage?: Pick<Storage, 'getItem' | 'setItem'> | null; login?: Login } = {}\n): {\n agent: AgentAdapter;\n settings: SettingsAdapter;\n tray: TrayAdapter;\n sprinkles: SprinkleAdapter;\n} {\n const agent = new AgentAdapter(connection);\n return {\n agent,\n settings: new SettingsAdapter(\n connection.settings,\n agent,\n options.storage ?? null,\n options.login ?? null\n ),\n tray: new TrayAdapter(connection.settings),\n sprinkles: new SprinkleAdapter(connection),\n };\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAqB,uBAAuB;AAC5C,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAE5B,SAAS,gBAAAA,eAAc,YAAY;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAqB,cAAc,mBAAAC,wBAAuB;AAC1D,SAAS,mBAAAC,wBAAuB;AAChC,SAAS,eAAAC,oBAAmB;AAErB,SAAS,iBACd,YACA,UAAoF,CAAC,
|
|
6
|
-
"names": ["AgentAdapter", "SettingsAdapter", "SprinkleAdapter", "TrayAdapter"]
|
|
4
|
+
"sourcesContent": ["import type { AgentConnection } from '../client.ts';\nimport { AgentAdapter } from './agent-port.ts';\nimport { MemoryAdapter } from './memory-port.ts';\nimport { type Login, SettingsAdapter } from './settings-port.ts';\nimport { SprinkleAdapter } from './sprinkle-port.ts';\nimport { TrayAdapter } from './tray-port.ts';\n\nexport { AgentAdapter, CONE } from './agent-port.ts';\nexport { MemoryAdapter } from './memory-port.ts';\nexport {\n assistant,\n errorAction,\n errorPart,\n isBusy,\n queued,\n textOf,\n toMessages,\n} from './messages.ts';\nexport { type Login, SETTINGS_KEY, SettingsAdapter } from './settings-port.ts';\nexport { SprinkleAdapter } from './sprinkle-port.ts';\nexport { TrayAdapter } from './tray-port.ts';\n\nexport function createAgentModel(\n connection: AgentConnection,\n options: { storage?: Pick<Storage, 'getItem' | 'setItem'> | null; login?: Login } = {}\n): {\n agent: AgentAdapter;\n settings: SettingsAdapter;\n tray: TrayAdapter;\n sprinkles: SprinkleAdapter;\n memory: MemoryAdapter;\n} {\n const agent = new AgentAdapter(connection);\n return {\n agent,\n settings: new SettingsAdapter(\n connection.settings,\n agent,\n options.storage ?? null,\n options.login ?? null\n ),\n tray: new TrayAdapter(connection.settings),\n sprinkles: new SprinkleAdapter(connection),\n memory: new MemoryAdapter(connection),\n };\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAqB,uBAAuB;AAC5C,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAE5B,SAAS,gBAAAA,eAAc,YAAY;AACnC,SAAS,iBAAAC,sBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAqB,cAAc,mBAAAC,wBAAuB;AAC1D,SAAS,mBAAAC,wBAAuB;AAChC,SAAS,eAAAC,oBAAmB;AAErB,SAAS,iBACd,YACA,UAAoF,CAAC,GAOrF;AACA,QAAM,QAAQ,IAAI,aAAa,UAAU;AACzC,SAAO;AAAA,IACL;AAAA,IACA,UAAU,IAAI;AAAA,MACZ,WAAW;AAAA,MACX;AAAA,MACA,QAAQ,WAAW;AAAA,MACnB,QAAQ,SAAS;AAAA,IACnB;AAAA,IACA,MAAM,IAAI,YAAY,WAAW,QAAQ;AAAA,IACzC,WAAW,IAAI,gBAAgB,UAAU;AAAA,IACzC,QAAQ,IAAI,cAAc,UAAU;AAAA,EACtC;AACF;",
|
|
6
|
+
"names": ["AgentAdapter", "MemoryAdapter", "SettingsAdapter", "SprinkleAdapter", "TrayAdapter"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
2
|
+
import { slugOf as slug } from "../memory/format.js";
|
|
3
|
+
import { Emitter } from "./emitter.js";
|
|
4
|
+
class MemoryAdapter extends Emitter {
|
|
5
|
+
#connection;
|
|
6
|
+
#pending = /* @__PURE__ */ new Map();
|
|
7
|
+
constructor(connection) {
|
|
8
|
+
super();
|
|
9
|
+
this.#connection = connection;
|
|
10
|
+
connection.memories?.subscribe(() => {
|
|
11
|
+
this.#pending.clear();
|
|
12
|
+
this.emit("memories", this.list());
|
|
13
|
+
});
|
|
14
|
+
connection.memoryScopes?.subscribe(() => this.emit("memories", this.list()));
|
|
15
|
+
}
|
|
16
|
+
list() {
|
|
17
|
+
const stored = this.#connection.memories?.value ?? [];
|
|
18
|
+
if (!this.#pending.size) return stored;
|
|
19
|
+
const out = stored.filter((item) => !this.#pending.has(item.id));
|
|
20
|
+
for (const item of this.#pending.values()) if (item) out.push(item);
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
scopes() {
|
|
24
|
+
return this.#connection.memoryScopes?.value ?? [];
|
|
25
|
+
}
|
|
26
|
+
save(draft) {
|
|
27
|
+
const memory = {
|
|
28
|
+
...draft,
|
|
29
|
+
id: `${draft.scope}/${slug(draft.section)}/${slug(draft.title)}`,
|
|
30
|
+
updatedAt: Date.now(),
|
|
31
|
+
source: "entry"
|
|
32
|
+
};
|
|
33
|
+
if (draft.id && draft.id !== memory.id) this.#pending.set(draft.id, null);
|
|
34
|
+
this.#pending.set(memory.id, memory);
|
|
35
|
+
this.emit("memories", this.list());
|
|
36
|
+
void this.#connection.control.memorySave(
|
|
37
|
+
{
|
|
38
|
+
id: draft.id ?? null,
|
|
39
|
+
scope: draft.scope,
|
|
40
|
+
section: draft.section,
|
|
41
|
+
title: draft.title,
|
|
42
|
+
body: draft.body,
|
|
43
|
+
tag: draft.tag
|
|
44
|
+
},
|
|
45
|
+
BACKGROUND_CONTEXT
|
|
46
|
+
).catch(() => {
|
|
47
|
+
this.#pending.clear();
|
|
48
|
+
this.emit("memories", this.list());
|
|
49
|
+
});
|
|
50
|
+
return memory;
|
|
51
|
+
}
|
|
52
|
+
remove(id) {
|
|
53
|
+
this.#pending.set(id, null);
|
|
54
|
+
this.emit("memories", this.list());
|
|
55
|
+
void this.#connection.control.memoryRemove(id, BACKGROUND_CONTEXT).catch(() => {
|
|
56
|
+
this.#pending.delete(id);
|
|
57
|
+
this.emit("memories", this.list());
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
MemoryAdapter
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=memory-port.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/spectrum/memory-port.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Memory, MemoryDraft, MemoryEvents, MemoryPort } from '@ai-ecoverse/slicc-spectrum/ui';\nimport { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';\nimport type { AgentConnection } from '../client.ts';\nimport { type MemoryScope, slugOf as slug } from '../memory/format.ts';\nimport { Emitter } from './emitter.ts';\n\ntype Local = Memory & { source?: 'entry' | 'notes' };\n\nexport class MemoryAdapter extends Emitter<MemoryEvents> implements MemoryPort {\n readonly #connection: AgentConnection;\n #pending = new Map<string, Local | null>();\n\n constructor(connection: AgentConnection) {\n super();\n this.#connection = connection;\n connection.memories?.subscribe(() => {\n this.#pending.clear();\n this.emit('memories', this.list());\n });\n connection.memoryScopes?.subscribe(() => this.emit('memories', this.list()));\n }\n\n list(): readonly Memory[] {\n const stored = (this.#connection.memories?.value ?? []) as Local[];\n if (!this.#pending.size) return stored;\n const out = stored.filter((item) => !this.#pending.has(item.id));\n for (const item of this.#pending.values()) if (item) out.push(item);\n return out;\n }\n\n scopes(): readonly MemoryScope[] {\n return this.#connection.memoryScopes?.value ?? [];\n }\n\n save(draft: MemoryDraft): Memory {\n const memory: Local = {\n ...draft,\n id: `${draft.scope}/${slug(draft.section)}/${slug(draft.title)}`,\n updatedAt: Date.now(),\n source: 'entry',\n };\n if (draft.id && draft.id !== memory.id) this.#pending.set(draft.id, null);\n this.#pending.set(memory.id, memory);\n this.emit('memories', this.list());\n void this.#connection.control\n .memorySave(\n {\n id: draft.id ?? null,\n scope: draft.scope,\n section: draft.section,\n title: draft.title,\n body: draft.body,\n tag: draft.tag,\n },\n BACKGROUND_CONTEXT\n )\n .catch(() => {\n this.#pending.clear();\n this.emit('memories', this.list());\n });\n return memory;\n }\n\n remove(id: string): void {\n this.#pending.set(id, null);\n this.emit('memories', this.list());\n void this.#connection.control.memoryRemove(id, BACKGROUND_CONTEXT).catch(() => {\n this.#pending.delete(id);\n this.emit('memories', this.list());\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,0BAA0B;AAEnC,SAA2B,UAAU,YAAY;AACjD,SAAS,eAAe;AAIjB,MAAM,sBAAsB,QAA4C;AAAA,EACpE;AAAA,EACT,WAAW,oBAAI,IAA0B;AAAA,EAEzC,YAAY,YAA6B;AACvC,UAAM;AACN,SAAK,cAAc;AACnB,eAAW,UAAU,UAAU,MAAM;AACnC,WAAK,SAAS,MAAM;AACpB,WAAK,KAAK,YAAY,KAAK,KAAK,CAAC;AAAA,IACnC,CAAC;AACD,eAAW,cAAc,UAAU,MAAM,KAAK,KAAK,YAAY,KAAK,KAAK,CAAC,CAAC;AAAA,EAC7E;AAAA,EAEA,OAA0B;AACxB,UAAM,SAAU,KAAK,YAAY,UAAU,SAAS,CAAC;AACrD,QAAI,CAAC,KAAK,SAAS,KAAM,QAAO;AAChC,UAAM,MAAM,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,SAAS,IAAI,KAAK,EAAE,CAAC;AAC/D,eAAW,QAAQ,KAAK,SAAS,OAAO,EAAG,KAAI,KAAM,KAAI,KAAK,IAAI;AAClE,WAAO;AAAA,EACT;AAAA,EAEA,SAAiC;AAC/B,WAAO,KAAK,YAAY,cAAc,SAAS,CAAC;AAAA,EAClD;AAAA,EAEA,KAAK,OAA4B;AAC/B,UAAM,SAAgB;AAAA,MACpB,GAAG;AAAA,MACH,IAAI,GAAG,MAAM,KAAK,IAAI,KAAK,MAAM,OAAO,CAAC,IAAI,KAAK,MAAM,KAAK,CAAC;AAAA,MAC9D,WAAW,KAAK,IAAI;AAAA,MACpB,QAAQ;AAAA,IACV;AACA,QAAI,MAAM,MAAM,MAAM,OAAO,OAAO,GAAI,MAAK,SAAS,IAAI,MAAM,IAAI,IAAI;AACxE,SAAK,SAAS,IAAI,OAAO,IAAI,MAAM;AACnC,SAAK,KAAK,YAAY,KAAK,KAAK,CAAC;AACjC,SAAK,KAAK,YAAY,QACnB;AAAA,MACC;AAAA,QACE,IAAI,MAAM,MAAM;AAAA,QAChB,OAAO,MAAM;AAAA,QACb,SAAS,MAAM;AAAA,QACf,OAAO,MAAM;AAAA,QACb,MAAM,MAAM;AAAA,QACZ,KAAK,MAAM;AAAA,MACb;AAAA,MACA;AAAA,IACF,EACC,MAAM,MAAM;AACX,WAAK,SAAS,MAAM;AACpB,WAAK,KAAK,YAAY,KAAK,KAAK,CAAC;AAAA,IACnC,CAAC;AACH,WAAO;AAAA,EACT;AAAA,EAEA,OAAO,IAAkB;AACvB,SAAK,SAAS,IAAI,IAAI,IAAI;AAC1B,SAAK,KAAK,YAAY,KAAK,KAAK,CAAC;AACjC,SAAK,KAAK,YAAY,QAAQ,aAAa,IAAI,kBAAkB,EAAE,MAAM,MAAM;AAC7E,WAAK,SAAS,OAAO,EAAE;AACvB,WAAK,KAAK,YAAY,KAAK,KAAK,CAAC;AAAA,IACnC,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/types/agents.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from '@earendil-works/chord';
|
|
2
2
|
import { type Conversation, type Harness, type Tx } from '@earendil-works/pi-durable';
|
|
3
|
+
import type { RoleMemory } from './memory/store.ts';
|
|
3
4
|
export declare const FIRST_CONE = "cone";
|
|
4
5
|
export type ConeRecord = {
|
|
5
6
|
name: string;
|
|
@@ -16,6 +17,12 @@ export type ScoopRecord = {
|
|
|
16
17
|
conversation: number;
|
|
17
18
|
anchor: number;
|
|
18
19
|
role: string | null;
|
|
20
|
+
memory?: RoleMemory;
|
|
21
|
+
origin?: string;
|
|
22
|
+
context?: {
|
|
23
|
+
project: boolean;
|
|
24
|
+
global: boolean;
|
|
25
|
+
};
|
|
19
26
|
kind: 'async' | 'sync';
|
|
20
27
|
parent: string;
|
|
21
28
|
depth: number;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Context, type ReplicatedState } from '@earendil-works/chord';
|
|
2
2
|
import type { ConversationView } from '@earendil-works/pi-durable';
|
|
3
|
+
import type { MemoryEntry, MemoryScope } from './memory/format.ts';
|
|
3
4
|
import { AgentControl, AgentSettings, type AgentsSummary, type Command, type Delivered, type SendMode } from './services.ts';
|
|
4
5
|
import type { Sprinkle } from './sprinkles/kind.ts';
|
|
5
6
|
import { type PortEndpoint } from './wire.ts';
|
|
@@ -12,6 +13,8 @@ export interface AgentConnection {
|
|
|
12
13
|
readonly views?: ReplicatedState<Record<string, ConversationView>>;
|
|
13
14
|
readonly commands?: ReplicatedState<Command[]>;
|
|
14
15
|
readonly sprinkles?: ReplicatedState<Sprinkle[]>;
|
|
16
|
+
readonly memories?: ReplicatedState<MemoryEntry[]>;
|
|
17
|
+
readonly memoryScopes?: ReplicatedState<MemoryScope[]>;
|
|
15
18
|
readonly settings: AgentSettings;
|
|
16
19
|
prompt(text: string, whenBusy?: SendMode): Promise<string>;
|
|
17
20
|
close(): Promise<void>;
|
package/dist/types/control.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type Conversation, type Harness, type SubmissionId } from '@earendil-wo
|
|
|
2
2
|
import type { Cones } from './cone.ts';
|
|
3
3
|
import type { Deliveries } from './deliveries.ts';
|
|
4
4
|
import type { LickSources, Licks } from './licks/index.ts';
|
|
5
|
+
import type { MemoryRuntime } from './memory/index.ts';
|
|
5
6
|
import type { Scoops, ScoopsRuntime } from './scoops/index.ts';
|
|
6
7
|
import type { AgentControl } from './services.ts';
|
|
7
8
|
import type { SkillsRuntime } from './skills/index.ts';
|
|
@@ -16,4 +17,4 @@ export interface HostScoops {
|
|
|
16
17
|
}
|
|
17
18
|
export declare function readable(out: string): string;
|
|
18
19
|
export declare function submissionId(value: string): SubmissionId | undefined;
|
|
19
|
-
export declare function createAgentControl(harness: Harness, target: Conversation | Cones, deliveries?: Deliveries, licks?: HostLicks, scoops?: HostScoops, skills?: Pick<SkillsRuntime, 'expand'>, sprinkles?: Pick<SprinklesRuntime, 'send' | 'call'>): AgentControl;
|
|
20
|
+
export declare function createAgentControl(harness: Harness, target: Conversation | Cones, deliveries?: Deliveries, licks?: HostLicks, scoops?: HostScoops, skills?: Pick<SkillsRuntime, 'expand'>, sprinkles?: Pick<SprinklesRuntime, 'send' | 'call'>, memory?: Pick<MemoryRuntime, 'save' | 'remove'>): AgentControl;
|
package/dist/types/host.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Context } from '@earendil-works/chord';
|
|
2
2
|
import type { Agent } from './agent.ts';
|
|
3
3
|
import { type HostLicks, type HostScoops } from './control.ts';
|
|
4
|
+
import type { MemoryRuntime } from './memory/index.ts';
|
|
4
5
|
import { AgentSettings } from './services.ts';
|
|
5
6
|
import type { SkillsRuntime } from './skills/index.ts';
|
|
6
7
|
import type { SprinklesRuntime } from './sprinkles/index.ts';
|
|
@@ -19,4 +20,5 @@ export declare function hostAgent(agent: Agent, options?: {
|
|
|
19
20
|
scoops?: HostScoops;
|
|
20
21
|
skills?: SkillsRuntime;
|
|
21
22
|
sprinkles?: SprinklesRuntime;
|
|
23
|
+
memory?: MemoryRuntime;
|
|
22
24
|
}): Promise<AgentHost>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Context } from '@earendil-works/chord';
|
|
2
|
+
import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
|
|
3
|
+
export declare const CANDIDATES: string[];
|
|
4
|
+
export declare const TRUSTED_ROOTS: string[];
|
|
5
|
+
export declare const UNTRUSTED = "outside /home: mounted folders and other roots load once SLICC can trust a folder";
|
|
6
|
+
export type ContextFile = {
|
|
7
|
+
path: string;
|
|
8
|
+
content: string;
|
|
9
|
+
};
|
|
10
|
+
export type Skipped = {
|
|
11
|
+
path: string;
|
|
12
|
+
reason: string;
|
|
13
|
+
};
|
|
14
|
+
export type ContextFiles = {
|
|
15
|
+
files: ContextFile[];
|
|
16
|
+
skipped: Skipped[];
|
|
17
|
+
};
|
|
18
|
+
type Files = Pick<ExecutionEnv, 'readTextFile' | 'canonicalPath'>;
|
|
19
|
+
export declare function trusted(path: string): boolean;
|
|
20
|
+
export declare function loadContextFiles(env: Files, options: {
|
|
21
|
+
cwd: string;
|
|
22
|
+
agentDir: string;
|
|
23
|
+
global?: boolean;
|
|
24
|
+
project?: boolean;
|
|
25
|
+
}, context: Context): Promise<ContextFiles>;
|
|
26
|
+
export declare function renderContextFiles({ files, skipped }: ContextFiles): string | undefined;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type MemoryTag = 'user' | 'feedback' | 'project';
|
|
2
|
+
export interface MemoryEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
scope: string;
|
|
5
|
+
section: string;
|
|
6
|
+
title: string;
|
|
7
|
+
body: string;
|
|
8
|
+
tag: MemoryTag | null;
|
|
9
|
+
updatedAt: number;
|
|
10
|
+
source: 'entry' | 'notes';
|
|
11
|
+
}
|
|
12
|
+
export interface MemoryScope {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
group?: 'cones' | 'roles';
|
|
16
|
+
}
|
|
17
|
+
export type Entry = {
|
|
18
|
+
title: string;
|
|
19
|
+
tag: MemoryTag | null;
|
|
20
|
+
body: string;
|
|
21
|
+
};
|
|
22
|
+
export type Section = {
|
|
23
|
+
name: string;
|
|
24
|
+
intro: string;
|
|
25
|
+
entries: Entry[];
|
|
26
|
+
};
|
|
27
|
+
export type MemoryDoc = {
|
|
28
|
+
head: string;
|
|
29
|
+
sections: Section[];
|
|
30
|
+
};
|
|
31
|
+
export declare const MEMORY_FILE = "MEMORY.md";
|
|
32
|
+
export declare const NOTES = "Notes";
|
|
33
|
+
export declare const MAX_LINES = 200;
|
|
34
|
+
export declare const MAX_BYTES: number;
|
|
35
|
+
export declare function slugOf(text: string): string;
|
|
36
|
+
export declare function parseMemory(text: string): MemoryDoc;
|
|
37
|
+
export declare function serializeMemory(doc: MemoryDoc): string;
|
|
38
|
+
export declare function memoryEntries(doc: MemoryDoc, scope: string, updatedAt: number): MemoryEntry[];
|
|
39
|
+
export type Change = {
|
|
40
|
+
kind: 'save';
|
|
41
|
+
id?: string;
|
|
42
|
+
section: string;
|
|
43
|
+
title: string;
|
|
44
|
+
body: string;
|
|
45
|
+
tag: MemoryTag | null;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'remove';
|
|
48
|
+
id?: string;
|
|
49
|
+
section?: string;
|
|
50
|
+
title?: string;
|
|
51
|
+
};
|
|
52
|
+
export declare function oneLine(text: string): string;
|
|
53
|
+
export declare function demote(body: string): string;
|
|
54
|
+
export declare function applyChange(doc: MemoryDoc, scope: string, change: Change): {
|
|
55
|
+
doc: MemoryDoc;
|
|
56
|
+
found: boolean;
|
|
57
|
+
};
|
|
58
|
+
export declare function excerpt(text: string): {
|
|
59
|
+
text: string;
|
|
60
|
+
capped: boolean;
|
|
61
|
+
};
|
|
62
|
+
export declare function byteLength(text: string): number;
|
|
63
|
+
export declare const REDACTED = "[redacted]";
|
|
64
|
+
export declare function redactSecrets(text: string): {
|
|
65
|
+
text: string;
|
|
66
|
+
count: number;
|
|
67
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Context } from '@earendil-works/chord';
|
|
2
|
+
import { type Extension, type Registry, type ToolRegistration } from '@earendil-works/pi-durable';
|
|
3
|
+
import { type MemoryAttach, type MemoryRuntime } from './runtime.ts';
|
|
4
|
+
export { MEMORY_WRITE, whoIs } from './prompt.ts';
|
|
5
|
+
export type { MemoryAttach, MemoryDraft, MemoryRuntime } from './runtime.ts';
|
|
6
|
+
export { USAGE } from './runtime.ts';
|
|
7
|
+
export interface MemorySetup {
|
|
8
|
+
extension: Extension;
|
|
9
|
+
tools: readonly ToolRegistration[];
|
|
10
|
+
attach(options: MemoryAttach, context: Context): Promise<MemoryRuntime>;
|
|
11
|
+
}
|
|
12
|
+
export declare function setupMemory(registry: Registry): MemorySetup;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Context } from '@earendil-works/chord';
|
|
2
|
+
import { Type } from '@earendil-works/pi-ai';
|
|
3
|
+
import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
|
|
4
|
+
import type { Agents, AgentsState, ScoopRecord } from '../agents.ts';
|
|
5
|
+
import { type MemoryFiles, type Place, type Written } from './store.ts';
|
|
6
|
+
export declare const MEMORY_WRITE = "memory_write";
|
|
7
|
+
export type Host = {
|
|
8
|
+
agents: Agents;
|
|
9
|
+
env: ExecutionEnv;
|
|
10
|
+
home: string;
|
|
11
|
+
files: MemoryFiles;
|
|
12
|
+
changed: (context: Context) => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export type Who = {
|
|
15
|
+
kind: 'cone';
|
|
16
|
+
id: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'scoop';
|
|
19
|
+
id: string;
|
|
20
|
+
record: ScoopRecord;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'other';
|
|
23
|
+
};
|
|
24
|
+
type Problem = {
|
|
25
|
+
problem: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function whoIs(state: Readonly<AgentsState>, conversation: number): Who;
|
|
28
|
+
export declare function ownPlace(host: Host, who: Who, cwd: string, context: Context): Promise<Place | Problem>;
|
|
29
|
+
export declare function contextSection(ready: Promise<Host>): import("@earendil-works/pi-durable").PromptSection<import("@earendil-works/pi-durable").ToolRegistration>;
|
|
30
|
+
export declare function memorySection(ready: Promise<Host>): import("@earendil-works/pi-durable").PromptSection<import("@earendil-works/pi-durable").ToolRegistration>;
|
|
31
|
+
type Args = {
|
|
32
|
+
section: string;
|
|
33
|
+
title: string;
|
|
34
|
+
body?: string;
|
|
35
|
+
tag?: 'user' | 'feedback' | 'project';
|
|
36
|
+
remove?: boolean;
|
|
37
|
+
scope?: 'own' | 'global';
|
|
38
|
+
};
|
|
39
|
+
export declare function writeAnswer(args: Args, place: Place, written: Written): string;
|
|
40
|
+
export declare function memoryWriteTool(ready: Promise<Host>): import("@earendil-works/pi-durable").ToolRegistration<Type.TObject<{
|
|
41
|
+
section: Type.TString;
|
|
42
|
+
title: Type.TString;
|
|
43
|
+
body: Type.TOptional<Type.TString>;
|
|
44
|
+
tag: Type.TOptional<Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"feedback">, Type.TLiteral<"project">]>>;
|
|
45
|
+
remove: Type.TOptional<Type.TBoolean>;
|
|
46
|
+
scope: Type.TOptional<Type.TUnion<[Type.TLiteral<"own">, Type.TLiteral<"global">]>>;
|
|
47
|
+
}>, import("@earendil-works/chord").JsonValue>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Context, type ReplicatedState } from '@earendil-works/chord';
|
|
2
|
+
import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
|
|
3
|
+
import type { Agents } from '../agents.ts';
|
|
4
|
+
import type { Role } from '../roles/roles.ts';
|
|
5
|
+
import { type MemoryEntry, type MemoryScope, type MemoryTag } from './format.ts';
|
|
6
|
+
import type { Host } from './prompt.ts';
|
|
7
|
+
import { type Place } from './store.ts';
|
|
8
|
+
export type Answer = {
|
|
9
|
+
code: number;
|
|
10
|
+
out: string;
|
|
11
|
+
};
|
|
12
|
+
export interface MemoryDraft {
|
|
13
|
+
id?: string;
|
|
14
|
+
scope: string;
|
|
15
|
+
section: string;
|
|
16
|
+
title: string;
|
|
17
|
+
body: string;
|
|
18
|
+
tag: MemoryTag | null;
|
|
19
|
+
}
|
|
20
|
+
export interface MemoryRuntime {
|
|
21
|
+
readonly memories: ReplicatedState<MemoryEntry[]>;
|
|
22
|
+
readonly scopes: ReplicatedState<MemoryScope[]>;
|
|
23
|
+
save(draft: MemoryDraft, context: Context): Promise<MemoryEntry>;
|
|
24
|
+
remove(id: string, context: Context): Promise<boolean>;
|
|
25
|
+
command(argv: readonly string[], caller: string | null, context: Context): Promise<Answer>;
|
|
26
|
+
reload(context: Context): Promise<void>;
|
|
27
|
+
close(context: Context): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export interface MemoryAttach {
|
|
30
|
+
agents: Agents;
|
|
31
|
+
env: ExecutionEnv;
|
|
32
|
+
home: string;
|
|
33
|
+
reloadMs: number;
|
|
34
|
+
roles?: (context: Context) => Promise<{
|
|
35
|
+
roles: readonly Role[];
|
|
36
|
+
} | undefined>;
|
|
37
|
+
}
|
|
38
|
+
export declare const USAGE = "usage:\n memory show [<scope>] print a memory file (yours by default)\n memory scopes every memory scope, its entries and its file\n\nScopes: global (everyone), a cone's id, or role:<path> for a role's memory.\nAgents write memory with the memory_write tool; the files are plain markdown you can edit.\n";
|
|
39
|
+
type Listed = Place & {
|
|
40
|
+
group?: 'cones' | 'roles';
|
|
41
|
+
name: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function listPlaces(options: MemoryAttach, context: Context): Promise<Listed[]>;
|
|
44
|
+
export declare function attachMemory(options: MemoryAttach, connect: (host: Host) => void, context: Context): Promise<MemoryRuntime>;
|
|
45
|
+
export {};
|