@xopcai/xopc 0.0.140 → 0.0.141
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DtONoxBN.js → agent-avatar-dicebear-BRTCpm3t.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Bd863Akz.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BRBxLECY.js → app-management-settings-panel-DaMMZBAT.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-ChvyuSEt.js → appearance-settings-BXHThPyM.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DgHWTnjs.js → apps-page-B4omjLxa.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CdIoagem.js → archive-plugin-izB-4N4L.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Ch411Kht.js → attachment-load-CJihXa5y.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-SVq27yw2.js → automation-suggestion-card-fgtj5Gek.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CFt5Ik4q.js → automations-page-Dz2mgjIR.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-D8cV-emn.js → binary-plugins-D3VUeG8s.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CXDkby6y.js → block-editor-KnA0sLI3.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-ColJPwer.js → browser-settings-page-DZZz5v_i.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-api-DLxI--Ge.js → capability-presets-api-D8rRNhc6.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DKyRbnlH.js → capability-presets-settings-panel-sCHojZr4.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-DllrPmp-.js → channel-recipient-api-BWgqwC5h.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-BDLHV3Jx.js → channels-settings-UyVSnf9s.js} +1 -1
- package/dist/gateway/static/root/assets/channels-status-swr-CB5FzcLf.js +1 -0
- package/dist/gateway/static/root/assets/{connectors-page-CA752gY8.js → connectors-page-BzhHiUO4.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Bz9ommjr.js → desktop-pet-CzdqX001.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BnLgxgoR.js → desktop-pet-settings-DqqUPC7G.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DLsCwFaf.js → directory-picker-path-field-PzlO5tSM.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-BzkF1-XT.js → dreaming-settings-BmL54kQq.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CdERvf3L.js → extension-debug-page-DcW8Ie3r.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D1fz474Z.js → extension-page-DT5cpace.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DoQMkNOK.js → extension-settings-page-CbMk4GhQ.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-BID89uCH.js → fetch-06q5eCMA.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Rygo8UAs.js → gateway-config-api-4VXUJtLz.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-kb8KIeQL.js → gateway-settings-CdghmKHJ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BkrLLlpE.js → gateway-startup-retry-2f7_vsv7.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-DVAHnifk.js → goal-create-dialog-CAlsM9MP.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-BuOEQZn_.js → goal-detail-page-CLPa4F2y.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-config-api-BuY6-l0a.js → goals-config-api-BpuQTufF.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-WV4cHvD-.js → goals-page-B2VpdzfH.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-settings-DoH5fZWo.js → goals-settings-CW1NwxvV.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-BqDs48B-.js → heartbeat-settings-C86k5tff.js} +1 -1
- package/dist/gateway/static/root/assets/{index-CrPRlGMg.js → index-ehajXmqL.js} +31 -31
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D51yogNZ.js → keyboard-shortcuts-settings-8xwKEhui.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-CL22jleU.js → logs-page-C_BMONOO.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-CSt32FWE.js → markdown-split-zS4KLNAf.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-ByItHxBj.js → media-plugins-_BgNJ9_7.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-DbNQuFdA.js → messages-B-8CqAeX.js} +2 -2
- package/dist/gateway/static/root/assets/{models-hub-panel-BkV9hDc-.js → models-hub-panel-Do_cwNjF.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-BK9yydrL.js → notes-page-5IdlPHaX.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-Dd0v-hK2.js → notes-workbench-0KsRZJIZ.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-DOfMaq_L.js → page-tabs-B7sGQkgU.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BArxASu7.js → preview-open-alternatives-D1ri4s_O.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-DSPhB3do.js → project-detail-page-Dk2zB1gy.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-C-fZk1f7.js → projects-page-CJQntm2G.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BGaVc3t7.js → remote-access-hub-CHeZZg7O.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-BRxlkhG8.js → save-bar-controls-BClrOinh.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-BzM1iyOc.js → schedule-field-CL7YTwLV.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-ChVcm0DX.js → schema-form-ww4PiIje.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-DbnzgQOP.js → sessions-page-9Hb_r0AG.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-PmzVFvAv.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BcD9xrvY.js → settings-collapsible-section-D9gEEVm2.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-Cu30CXVl.js → settings-form-section-DGeEoBkb.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-Cfd37IYb.js → settings-loading-skeleton-BXUeMR37.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-EINHyzLo.js → settings-page-C5G2klUB.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-C15zixct.js → settings-page-layout-CEepfbCa.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-Bu7SdpD4.js → setup-status-panel-oQ8OLnw3.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CjjAFV-v.js → share-preview-page-CXtDHMSi.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-06IYvwDt.js → shares-settings-BlNoairj.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BYV5x1KO.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-3W2-wDyO.js → skills-page-ClBcKQZP.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DlQMtzPf.js → system-settings-panel-W6MBJXrr.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-BS1BwExE.js → typed-models-lib-BkODXN7T.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-EA4hfbsP.js → use-channel-catalog-CTbwLZXc.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-B7RCdmSp.js → user-profile-settings-panel-CeC308-E.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-BrhEgVaa.js → utils-ZxrKHxyb.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BPn1ZEga.js → voice-api-key-field-BE57S-nS.js} +1 -1
- package/dist/gateway/static/root/assets/{work-item-detail-page-BQGTTsz1.js → work-item-detail-page-Di1ww5Aa.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-na-N4jZ6.js → workflow-run-setup-panel-CzK84i-B.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-start-dialog-BZCY7N42.js → workflow-start-dialog-CtLTtNUB.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-CjeVDs4h.js → workflows-page-CZFZdua9.js} +1 -1
- package/dist/gateway/static/root/index.html +4 -4
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +13 -21
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/background-review/run-background-review.js +1 -0
- package/dist/src/agent/background-review/run-background-review.js.map +1 -1
- package/dist/src/agent/memory/access-policy.d.ts +12 -0
- package/dist/src/agent/memory/access-policy.js +44 -0
- package/dist/src/agent/memory/access-policy.js.map +1 -0
- package/dist/src/agent/memory/builtin-provider.d.ts +4 -1
- package/dist/src/agent/memory/builtin-provider.js +51 -16
- package/dist/src/agent/memory/builtin-provider.js.map +1 -1
- package/dist/src/agent/memory/context/planner.d.ts +1 -0
- package/dist/src/agent/memory/context/planner.js +9 -5
- package/dist/src/agent/memory/context/planner.js.map +1 -1
- package/dist/src/agent/memory/create-memory-manager.d.ts +1 -1
- package/dist/src/agent/memory/create-memory-manager.js +8 -5
- package/dist/src/agent/memory/create-memory-manager.js.map +1 -1
- package/dist/src/agent/memory/dreaming/config.d.ts +2 -0
- package/dist/src/agent/memory/dreaming/config.js +13 -1
- package/dist/src/agent/memory/dreaming/config.js.map +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.d.ts +2 -0
- package/dist/src/agent/memory/dreaming/deep-promotion.js +24 -3
- package/dist/src/agent/memory/dreaming/deep-promotion.js.map +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.d.ts +1 -0
- package/dist/src/agent/memory/dreaming/light-sweep.js +184 -16
- package/dist/src/agent/memory/dreaming/light-sweep.js.map +1 -1
- package/dist/src/agent/memory/dreaming/promotion-lifecycle.d.ts +30 -0
- package/dist/src/agent/memory/dreaming/promotion-lifecycle.js +85 -0
- package/dist/src/agent/memory/dreaming/promotion-lifecycle.js.map +1 -0
- package/dist/src/agent/memory/dreaming/rem-patterns.d.ts +4 -0
- package/dist/src/agent/memory/dreaming/rem-patterns.js +76 -53
- package/dist/src/agent/memory/dreaming/rem-patterns.js.map +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.d.ts +10 -0
- package/dist/src/agent/memory/dreaming/short-term-store.js +157 -79
- package/dist/src/agent/memory/dreaming/short-term-store.js.map +1 -1
- package/dist/src/agent/memory/manager.d.ts +7 -0
- package/dist/src/agent/memory/manager.js +31 -6
- package/dist/src/agent/memory/manager.js.map +1 -1
- package/dist/src/agent/memory/memory-config.d.ts +1 -1
- package/dist/src/agent/memory/memory-config.js +3 -3
- package/dist/src/agent/memory/memory-config.js.map +1 -1
- package/dist/src/agent/memory/sensitivity.d.ts +3 -0
- package/dist/src/agent/memory/sensitivity.js +13 -0
- package/dist/src/agent/memory/sensitivity.js.map +1 -0
- package/dist/src/agent/memory/understanding/service.js +10 -14
- package/dist/src/agent/memory/understanding/service.js.map +1 -1
- package/dist/src/agent/memory/user-context-coordinator.d.ts +1 -0
- package/dist/src/agent/memory/user-context-coordinator.js +2 -0
- package/dist/src/agent/memory/user-context-coordinator.js.map +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js +8 -1
- package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
- package/dist/src/agent/tools/dreaming-tool.js +3 -12
- package/dist/src/agent/tools/dreaming-tool.js.map +1 -1
- package/dist/src/agent/tools/factory.js +14 -2
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/memory-tool.d.ts +3 -0
- package/dist/src/agent/tools/memory-tool.js +6 -3
- package/dist/src/agent/tools/memory-tool.js.map +1 -1
- package/dist/src/agent/workspace-runtime/registry.d.ts +6 -6
- package/dist/src/agent/workspace-runtime/registry.js +19 -12
- package/dist/src/agent/workspace-runtime/registry.js.map +1 -1
- package/dist/src/agent-manifest/schema.d.ts +4 -0
- package/dist/src/agent-manifest/schema.js +2 -1
- package/dist/src/agent-manifest/schema.js.map +1 -1
- package/dist/src/agent-runtime/index.js +1 -1
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/config/schema.d.ts +4 -0
- package/dist/src/gateway/hono/lib/config-payload.d.ts +2 -0
- package/dist/src/gateway/hono/routes/dreaming.js +28 -21
- package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
- package/dist/src/gateway/hono/routes/memory.js +16 -4
- package/dist/src/gateway/hono/routes/memory.js.map +1 -1
- package/dist/src/storage/sqlite/fts.d.ts +6 -0
- package/dist/src/storage/sqlite/fts.js +70 -1
- package/dist/src/storage/sqlite/fts.js.map +1 -1
- package/dist/src/storage/sqlite/memory-index-repository.js +16 -7
- package/dist/src/storage/sqlite/memory-index-repository.js.map +1 -1
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +18 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +55 -8
- package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-Dl9EWnUh.js +0 -2
- package/dist/gateway/static/root/assets/channels-status-swr-EUwWYx8l.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CuDBoz5k.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-0ODH0DXl.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-tool.js","names":[],"sources":["../../../../src/agent/tools/memory-tool.ts"],"sourcesContent":["// Memory search tools for xopc agent\nimport { Type } from '@sinclair/typebox';\nimport type { AgentTool, AgentToolResult } from '@earendil-works/pi-agent-core';\nimport { recordDreamingRecalls } from '../memory/dreaming/short-term-store.js';\nimport type { MemoryManager } from '../memory/manager.js';\n\n// =============================================================================\n// Memory Search Tool\n// =============================================================================\nconst MemorySearchSchema = Type.Object({\n query: Type.String(),\n maxResults: Type.Optional(Type.Number()),\n minScore: Type.Optional(Type.Number()),\n});\n\ntype MemorySearchParams = { query: string; maxResults?: number; minScore?: number };\n\nexport interface MemoryToolOptions {\n workspaceDir: string;\n dreamingRoot: string;\n getMemoryManager: () => MemoryManager;\n}\n\nexport function createMemorySearchTool(options: MemoryToolOptions): AgentTool {\n const { dreamingRoot, getMemoryManager } = options;\n return {\n name: 'memory_search',\n label: '🔍 Memory Search',\n description:\n 'Mandatory recall step: search indexed profile, curated, and session memory sources before answering questions about prior work, decisions, dates, people, preferences, or todos; returns top snippets with source path + lines.',\n parameters: MemorySearchSchema,\n\n async execute(\n _toolCallId: string,\n params: any,\n _signal?: AbortSignal,\n ): Promise<AgentToolResult<{}>> {\n const { query, maxResults, minScore } = params as MemorySearchParams;\n\n try {\n const results = await getMemoryManager().search({
|
|
1
|
+
{"version":3,"file":"memory-tool.js","names":[],"sources":["../../../../src/agent/tools/memory-tool.ts"],"sourcesContent":["// Memory search tools for xopc agent\nimport { Type } from '@sinclair/typebox';\nimport type { AgentTool, AgentToolResult } from '@earendil-works/pi-agent-core';\nimport { recordDreamingRecalls } from '../memory/dreaming/short-term-store.js';\nimport type { MemoryManager } from '../memory/manager.js';\nimport type { MemoryScope } from '../memory/types.js';\n\n// =============================================================================\n// Memory Search Tool\n// =============================================================================\nconst MemorySearchSchema = Type.Object({\n query: Type.String(),\n maxResults: Type.Optional(Type.Number()),\n minScore: Type.Optional(Type.Number()),\n});\n\ntype MemorySearchParams = { query: string; maxResults?: number; minScore?: number };\n\nexport interface MemoryToolOptions {\n workspaceDir: string;\n dreamingRoot: string;\n getMemoryManager: () => MemoryManager;\n getScope?: () => Partial<MemoryScope>;\n shouldRecordDreamingRecalls?: () => boolean;\n}\n\nexport function createMemorySearchTool(options: MemoryToolOptions): AgentTool {\n const { dreamingRoot, getMemoryManager } = options;\n return {\n name: 'memory_search',\n label: '🔍 Memory Search',\n description:\n 'Mandatory recall step: search indexed profile, curated, and session memory sources before answering questions about prior work, decisions, dates, people, preferences, or todos; returns top snippets with source path + lines.',\n parameters: MemorySearchSchema,\n\n async execute(\n _toolCallId: string,\n params: any,\n _signal?: AbortSignal,\n ): Promise<AgentToolResult<{}>> {\n const { query, maxResults, minScore } = params as MemorySearchParams;\n\n try {\n const results = await getMemoryManager().search({\n query,\n maxResults,\n minScore,\n scope: options.getScope?.(),\n });\n for (const result of results) {\n getMemoryManager().recordSignal({\n source: 'search_recall',\n recordId: result.record.id,\n score: result.score,\n content: result.snippet,\n metadata: {\n providerId: result.citation.providerId,\n path: result.citation.path,\n lineStart: result.citation.lineStart,\n lineEnd: result.citation.lineEnd,\n },\n });\n }\n // Dreaming: record short-term recall evidence from memory_search.\n if (options.shouldRecordDreamingRecalls?.() !== false) {\n void recordDreamingRecalls({\n dreamingRoot,\n query,\n matches: results.map((entry) => ({\n file: entry.citation.path ?? entry.record.source.path ?? entry.record.id,\n lines: entry.snippet,\n score: entry.score,\n lineNumbers:\n entry.citation.lineStart != null\n ? [entry.citation.lineStart, entry.citation.lineEnd ?? entry.citation.lineStart]\n : [],\n })),\n }).catch(() => {});\n }\n const withCitations = results.map((entry) => ({\n id: entry.record.id,\n ownerAgentId: entry.record.scope.agentId,\n kind: entry.record.kind,\n file: entry.citation.path ?? entry.record.source.path,\n lines: entry.snippet,\n score: entry.score,\n lineNumbers:\n entry.citation.lineStart != null\n ? [entry.citation.lineStart, entry.citation.lineEnd ?? entry.citation.lineStart]\n : [],\n citation: `${entry.citation.path ?? entry.record.id}${entry.citation.lineStart != null ? `#L${entry.citation.lineStart}${entry.citation.lineEnd && entry.citation.lineEnd !== entry.citation.lineStart ? `-L${entry.citation.lineEnd}` : ''}` : ''}`,\n snippet: `${entry.snippet.trim()}\\n\\nSource: ${entry.citation.path ?? entry.record.id}${entry.citation.lineStart != null ? `#L${entry.citation.lineStart}${entry.citation.lineEnd && entry.citation.lineEnd !== entry.citation.lineStart ? `-L${entry.citation.lineEnd}` : ''}` : ''}`,\n }));\n\n return {\n content: [{ type: 'text', text: JSON.stringify({ results: withCitations, provider: 'memory-manager' }, null, 2) }],\n details: { results: withCitations },\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return {\n content: [{ type: 'text', text: `Search error: ${message}` }],\n details: { error: message },\n };\n }\n },\n } as any;\n}\n\n// =============================================================================\n// Memory Get Tool\n// =============================================================================\nconst MemoryGetSchema = Type.Object({\n path: Type.String(),\n from: Type.Optional(Type.Number()),\n lines: Type.Optional(Type.Number()),\n});\n\ntype MemoryGetParams = { path: string; from?: number; lines?: number };\n\nexport function createMemoryGetTool(options: MemoryToolOptions): AgentTool {\n const { getMemoryManager } = options;\n return {\n name: 'memory_get',\n label: '📄 Memory Get',\n description: 'Safe snippet read from a source path returned by memory_search, with optional from/lines; pull only the needed lines and keep context small.',\n parameters: MemoryGetSchema,\n\n async execute(\n _toolCallId: string,\n params: any,\n _signal?: AbortSignal,\n ): Promise<AgentToolResult<{}>> {\n const { path, from, lines } = params as MemoryGetParams;\n\n try {\n const result = await getMemoryManager().read({\n path,\n from,\n lines,\n scope: options.getScope?.(),\n });\n if (!result) {\n return {\n content: [{ type: 'text', text: `File not found: ${path}` }],\n details: { path, text: '' },\n };\n }\n return {\n content: [{ type: 'text', text: result.record.content }],\n details: { path, text: result.record.content, lineNumbers: result.lineNumbers },\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return {\n content: [{ type: 'text', text: `Read error: ${message}` }],\n details: { error: message },\n };\n }\n },\n } as any;\n}\n"],"mappings":";;;AAUA,MAAM,qBAAqB,KAAK,OAAO;CACrC,OAAO,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kBAAkB,CAAC,KAAK;KAC3C;KACA;KACA;KACA,OAAO,QAAQ,YAAY;KAC5B,CAAC;AACF,QAAI,CAAC,OACH,QAAO;KACL,SAAS,CAAC;MAAE,MAAM;MAAQ,MAAM,mBAAmB;MAAQ,CAAC;KAC5D,SAAS;MAAE;MAAM,MAAM;MAAI;KAC5B;AAEH,WAAO;KACL,SAAS,CAAC;MAAE,MAAM;MAAQ,MAAM,OAAO,OAAO;MAAS,CAAC;KACxD,SAAS;MAAE;MAAM,MAAM,OAAO,OAAO;MAAS,aAAa,OAAO;MAAa;KAChF;YACM,KAAK;IACZ,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;AAChE,WAAO;KACL,SAAS,CAAC;MAAE,MAAM;MAAQ,MAAM,eAAe;MAAW,CAAC;KAC3D,SAAS,EAAE,OAAO,SAAS;KAC5B;;;EAGN"}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* Previously these four collaborators (`SkillManager`, `SystemPromptBuilder`,
|
|
5
5
|
* `BuiltinMemoryStore`, `MemoryManager`) were created inline inside
|
|
6
6
|
* `AgentManager.getWorkspaceRuntime` and cached in a private Map. They live
|
|
7
|
-
* outside `AgentInstance` because multiple session keys
|
|
8
|
-
*
|
|
7
|
+
* outside `AgentInstance` because multiple session keys for the same agent may
|
|
8
|
+
* share a workspace. Memory ownership is agent-scoped, so runtimes are keyed by
|
|
9
|
+
* both the effective agent id and resolved workspace path.
|
|
9
10
|
*
|
|
10
11
|
* Extracted so:
|
|
11
12
|
* - `AgentManager` no longer juggles four sibling caches.
|
|
@@ -37,16 +38,15 @@ export interface WorkspaceRuntimeRegistryOptions {
|
|
|
37
38
|
}
|
|
38
39
|
export declare class WorkspaceRuntimeRegistry {
|
|
39
40
|
private readonly runtimes;
|
|
41
|
+
private readonly notifiedWorkspacePaths;
|
|
40
42
|
private readonly getConfig;
|
|
41
43
|
private readonly bundledSkillsDir;
|
|
42
44
|
private readonly onRuntimeCreated?;
|
|
43
45
|
constructor(opts: WorkspaceRuntimeRegistryOptions);
|
|
44
|
-
/** Lazily construct
|
|
45
|
-
getOrCreate(resolvedPath: string): WorkspaceRuntime;
|
|
46
|
+
/** Lazily construct and cache an agent-scoped runtime for a workspace. */
|
|
47
|
+
getOrCreate(resolvedPath: string, requestedAgentId?: string): WorkspaceRuntime;
|
|
46
48
|
/** Iterate every live workspace runtime (used by skill / config hot-reload). */
|
|
47
49
|
values(): IterableIterator<WorkspaceRuntime>;
|
|
48
|
-
/** Iterate live workspace runtime entries keyed by resolved workspace path. */
|
|
49
|
-
entries(): IterableIterator<[string, WorkspaceRuntime]>;
|
|
50
50
|
/**
|
|
51
51
|
* Tear down every runtime (shutdown memory providers) and forget the cache.
|
|
52
52
|
* Used by `AgentManager.updateAgentDefaults` and `AgentManager.dispose`.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { init_agent_session_key, normalizeAgentId } from "../../routing/agent-session-key.js";
|
|
4
|
+
import { init_agent_scope, resolveAgentIdForWorkspacePath } from "../agent-scope.js";
|
|
3
5
|
import { resolveBuiltinMemoryStoreConfig } from "../memory/memory-config.js";
|
|
4
6
|
import { BuiltinMemoryStore } from "../memory/builtin-memory-store.js";
|
|
5
7
|
import { createMemoryManagerFromConfig } from "../memory/create-memory-manager.js";
|
|
@@ -8,10 +10,13 @@ import { SystemPromptBuilder } from "../prompt/service-prompt-builder.js";
|
|
|
8
10
|
import { CodeIntelligenceRuntime } from "../code-intelligence/runtime.js";
|
|
9
11
|
import "../code-intelligence/index.js";
|
|
10
12
|
//#region src/agent/workspace-runtime/registry.ts
|
|
13
|
+
init_agent_session_key();
|
|
14
|
+
init_agent_scope();
|
|
11
15
|
init_logger();
|
|
12
16
|
const log = createLogger("WorkspaceRuntimeRegistry");
|
|
13
17
|
var WorkspaceRuntimeRegistry = class {
|
|
14
18
|
runtimes = /* @__PURE__ */ new Map();
|
|
19
|
+
notifiedWorkspacePaths = /* @__PURE__ */ new Set();
|
|
15
20
|
getConfig;
|
|
16
21
|
bundledSkillsDir;
|
|
17
22
|
onRuntimeCreated;
|
|
@@ -20,13 +25,15 @@ var WorkspaceRuntimeRegistry = class {
|
|
|
20
25
|
this.bundledSkillsDir = opts.bundledSkillsDir;
|
|
21
26
|
this.onRuntimeCreated = opts.onRuntimeCreated;
|
|
22
27
|
}
|
|
23
|
-
/** Lazily construct
|
|
24
|
-
getOrCreate(resolvedPath) {
|
|
25
|
-
const existing = this.runtimes.get(resolvedPath);
|
|
26
|
-
if (existing) return existing;
|
|
28
|
+
/** Lazily construct and cache an agent-scoped runtime for a workspace. */
|
|
29
|
+
getOrCreate(resolvedPath, requestedAgentId) {
|
|
27
30
|
const cfg = this.getConfig();
|
|
28
|
-
const
|
|
29
|
-
const
|
|
31
|
+
const agentId = normalizeAgentId(requestedAgentId?.trim() || resolveAgentIdForWorkspacePath(cfg, resolvedPath));
|
|
32
|
+
const runtimeKey = `${agentId}\u0000${resolvedPath}`;
|
|
33
|
+
const existing = this.runtimes.get(runtimeKey);
|
|
34
|
+
if (existing) return existing;
|
|
35
|
+
const builtinMemoryStore = new BuiltinMemoryStore(resolveBuiltinMemoryStoreConfig(resolvedPath, cfg, agentId));
|
|
36
|
+
const memoryManager = createMemoryManagerFromConfig(resolvedPath, builtinMemoryStore, cfg, agentId);
|
|
30
37
|
const skillManager = new SkillManager(resolvedPath, this.bundledSkillsDir);
|
|
31
38
|
const rt = {
|
|
32
39
|
skillManager,
|
|
@@ -42,18 +49,17 @@ var WorkspaceRuntimeRegistry = class {
|
|
|
42
49
|
getConfig: this.getConfig
|
|
43
50
|
})
|
|
44
51
|
};
|
|
45
|
-
this.runtimes.set(
|
|
46
|
-
this.
|
|
52
|
+
this.runtimes.set(runtimeKey, rt);
|
|
53
|
+
if (!this.notifiedWorkspacePaths.has(resolvedPath)) {
|
|
54
|
+
this.notifiedWorkspacePaths.add(resolvedPath);
|
|
55
|
+
this.onRuntimeCreated?.(resolvedPath);
|
|
56
|
+
}
|
|
47
57
|
return rt;
|
|
48
58
|
}
|
|
49
59
|
/** Iterate every live workspace runtime (used by skill / config hot-reload). */
|
|
50
60
|
values() {
|
|
51
61
|
return this.runtimes.values();
|
|
52
62
|
}
|
|
53
|
-
/** Iterate live workspace runtime entries keyed by resolved workspace path. */
|
|
54
|
-
entries() {
|
|
55
|
-
return this.runtimes.entries();
|
|
56
|
-
}
|
|
57
63
|
/**
|
|
58
64
|
* Tear down every runtime (shutdown memory providers) and forget the cache.
|
|
59
65
|
* Used by `AgentManager.updateAgentDefaults` and `AgentManager.dispose`.
|
|
@@ -61,6 +67,7 @@ var WorkspaceRuntimeRegistry = class {
|
|
|
61
67
|
async clearAll() {
|
|
62
68
|
const toShutdown = [...this.runtimes.values()];
|
|
63
69
|
this.runtimes.clear();
|
|
70
|
+
this.notifiedWorkspacePaths.clear();
|
|
64
71
|
await Promise.allSettled(toShutdown.flatMap((rt) => [rt.memoryManager.shutdownAll().catch((err) => {
|
|
65
72
|
log.warn({ err }, "memoryManager.shutdownAll failed");
|
|
66
73
|
}), rt.codeIntelligence.dispose().catch((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","names":[],"sources":["../../../../src/agent/workspace-runtime/registry.ts"],"sourcesContent":["/**\n * WorkspaceRuntimeRegistry — lazy per-workspace cache of skill/memory/prompt-builder runtimes.\n *\n * Previously these four collaborators (`SkillManager`, `SystemPromptBuilder`,\n * `BuiltinMemoryStore`, `MemoryManager`) were created inline inside\n * `AgentManager.getWorkspaceRuntime` and cached in a private Map. They live\n * outside `AgentInstance` because multiple session keys may share a workspace\n *
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../../../src/agent/workspace-runtime/registry.ts"],"sourcesContent":["/**\n * WorkspaceRuntimeRegistry — lazy per-workspace cache of skill/memory/prompt-builder runtimes.\n *\n * Previously these four collaborators (`SkillManager`, `SystemPromptBuilder`,\n * `BuiltinMemoryStore`, `MemoryManager`) were created inline inside\n * `AgentManager.getWorkspaceRuntime` and cached in a private Map. They live\n * outside `AgentInstance` because multiple session keys for the same agent may\n * share a workspace. Memory ownership is agent-scoped, so runtimes are keyed by\n * both the effective agent id and resolved workspace path.\n *\n * Extracted so:\n * - `AgentManager` no longer juggles four sibling caches.\n * - Hot-reload teardown (`clearAll`) lives in one place — there are now no\n * callers that forget to shut down `memoryManager`.\n * - Future per-workspace runtimes (e.g. embedding store, vector cache) plug in\n * through `getOrCreate` without touching `AgentManager`.\n */\n\nimport type { Config } from '../../config/schema.js';\nimport { normalizeAgentId } from '../../routing/agent-session-key.js';\nimport { resolveAgentIdForWorkspacePath } from '../agent-scope.js';\nimport { BuiltinMemoryStore } from '../memory/builtin-memory-store.js';\nimport { createMemoryManagerFromConfig } from '../memory/create-memory-manager.js';\nimport { resolveBuiltinMemoryStoreConfig } from '../memory/memory-config.js';\nimport type { MemoryManager } from '../memory/manager.js';\nimport { SkillManager } from '../skills/skill-manager.js';\nimport { SystemPromptBuilder } from '../prompt/service-prompt-builder.js';\nimport { CodeIntelligenceRuntime } from '../code-intelligence/index.js';\nimport { createLogger } from '../../utils/logger.js';\n\nconst log = createLogger('WorkspaceRuntimeRegistry');\n\nexport interface WorkspaceRuntime {\n skillManager: SkillManager;\n systemPromptBuilder: SystemPromptBuilder;\n builtinMemoryStore: BuiltinMemoryStore;\n memoryManager: MemoryManager;\n codeIntelligence: CodeIntelligenceRuntime;\n}\n\nexport interface WorkspaceRuntimeRegistryOptions {\n /** Effective config snapshot accessor (must always return a value when called). */\n getConfig: () => Config;\n /** Absolute path to the bundled skills directory shared by every workspace. */\n bundledSkillsDir: string;\n /** Called after a runtime is first created for a workspace. */\n onRuntimeCreated?: (resolvedPath: string) => void;\n}\n\nexport class WorkspaceRuntimeRegistry {\n private readonly runtimes = new Map<string, WorkspaceRuntime>();\n private readonly notifiedWorkspacePaths = new Set<string>();\n private readonly getConfig: () => Config;\n private readonly bundledSkillsDir: string;\n private readonly onRuntimeCreated?: (resolvedPath: string) => void;\n\n constructor(opts: WorkspaceRuntimeRegistryOptions) {\n this.getConfig = opts.getConfig;\n this.bundledSkillsDir = opts.bundledSkillsDir;\n this.onRuntimeCreated = opts.onRuntimeCreated;\n }\n\n /** Lazily construct and cache an agent-scoped runtime for a workspace. */\n getOrCreate(resolvedPath: string, requestedAgentId?: string): WorkspaceRuntime {\n const cfg = this.getConfig();\n const agentId = normalizeAgentId(\n requestedAgentId?.trim() || resolveAgentIdForWorkspacePath(cfg, resolvedPath),\n );\n const runtimeKey = `${agentId}\\u0000${resolvedPath}`;\n const existing = this.runtimes.get(runtimeKey);\n if (existing) {\n return existing;\n }\n\n const builtinMemoryStore = new BuiltinMemoryStore(\n resolveBuiltinMemoryStoreConfig(resolvedPath, cfg, agentId),\n );\n const memoryManager = createMemoryManagerFromConfig(resolvedPath, builtinMemoryStore, cfg, agentId);\n const skillManager = new SkillManager(resolvedPath, this.bundledSkillsDir);\n const systemPromptBuilder = new SystemPromptBuilder({\n workspace: resolvedPath,\n config: cfg,\n skillManager,\n });\n const codeIntelligence = new CodeIntelligenceRuntime({\n workspace: resolvedPath,\n getConfig: this.getConfig,\n });\n\n const rt: WorkspaceRuntime = {\n skillManager,\n systemPromptBuilder,\n builtinMemoryStore,\n memoryManager,\n codeIntelligence,\n };\n this.runtimes.set(runtimeKey, rt);\n if (!this.notifiedWorkspacePaths.has(resolvedPath)) {\n this.notifiedWorkspacePaths.add(resolvedPath);\n this.onRuntimeCreated?.(resolvedPath);\n }\n return rt;\n }\n\n /** Iterate every live workspace runtime (used by skill / config hot-reload). */\n values(): IterableIterator<WorkspaceRuntime> {\n return this.runtimes.values();\n }\n\n /**\n * Tear down every runtime (shutdown memory providers) and forget the cache.\n * Used by `AgentManager.updateAgentDefaults` and `AgentManager.dispose`.\n */\n async clearAll(): Promise<void> {\n const toShutdown = [...this.runtimes.values()];\n this.runtimes.clear();\n this.notifiedWorkspacePaths.clear();\n await Promise.allSettled(\n toShutdown.flatMap((rt) => [\n rt.memoryManager.shutdownAll().catch((err) => {\n log.warn({ err }, 'memoryManager.shutdownAll failed');\n }),\n rt.codeIntelligence.dispose().catch((err) => {\n log.warn({ err }, 'codeIntelligence.dispose failed');\n }),\n ]),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;wBAmBsE;kBACH;aAQd;AAErD,MAAM,MAAM,aAAa,2BAA2B;AAmBpD,IAAa,2BAAb,MAAsC;CACpC,2BAA4B,IAAI,KAA+B;CAC/D,yCAA0C,IAAI,KAAa;CAC3D;CACA;CACA;CAEA,YAAY,MAAuC;AACjD,OAAK,YAAY,KAAK;AACtB,OAAK,mBAAmB,KAAK;AAC7B,OAAK,mBAAmB,KAAK;;;CAI/B,YAAY,cAAsB,kBAA6C;EAC7E,MAAM,MAAM,KAAK,WAAW;EAC5B,MAAM,UAAU,iBACd,kBAAkB,MAAM,IAAI,+BAA+B,KAAK,aAAa,CAC9E;EACD,MAAM,aAAa,GAAG,QAAQ,QAAQ;EACtC,MAAM,WAAW,KAAK,SAAS,IAAI,WAAW;AAC9C,MAAI,SACF,QAAO;EAGT,MAAM,qBAAqB,IAAI,mBAC7B,gCAAgC,cAAc,KAAK,QAAQ,CAC5D;EACD,MAAM,gBAAgB,8BAA8B,cAAc,oBAAoB,KAAK,QAAQ;EACnG,MAAM,eAAe,IAAI,aAAa,cAAc,KAAK,iBAAiB;EAW1E,MAAM,KAAuB;GAC3B;GACA,qBAAA,IAZ8B,oBAAoB;IAClD,WAAW;IACX,QAAQ;IACR;IACD,CAQoB;GACnB;GACA;GACA,kBAAA,IAV2B,wBAAwB;IACnD,WAAW;IACX,WAAW,KAAK;IACjB,CAOiB;GACjB;AACD,OAAK,SAAS,IAAI,YAAY,GAAG;AACjC,MAAI,CAAC,KAAK,uBAAuB,IAAI,aAAa,EAAE;AAClD,QAAK,uBAAuB,IAAI,aAAa;AAC7C,QAAK,mBAAmB,aAAa;;AAEvC,SAAO;;;CAIT,SAA6C;AAC3C,SAAO,KAAK,SAAS,QAAQ;;;;;;CAO/B,MAAM,WAA0B;EAC9B,MAAM,aAAa,CAAC,GAAG,KAAK,SAAS,QAAQ,CAAC;AAC9C,OAAK,SAAS,OAAO;AACrB,OAAK,uBAAuB,OAAO;AACnC,QAAM,QAAQ,WACZ,WAAW,SAAS,OAAO,CACzB,GAAG,cAAc,aAAa,CAAC,OAAO,QAAQ;AAC5C,OAAI,KAAK,EAAE,KAAK,EAAE,mCAAmC;IACrD,EACF,GAAG,iBAAiB,SAAS,CAAC,OAAO,QAAQ;AAC3C,OAAI,KAAK,EAAE,KAAK,EAAE,kCAAkC;IACpD,CACH,CAAC,CACH"}
|
|
@@ -262,6 +262,7 @@ export declare const MemoryPolicySchema: z.ZodDefault<z.ZodObject<{
|
|
|
262
262
|
compaction: z.ZodDefault<z.ZodBoolean>;
|
|
263
263
|
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
264
264
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
265
|
+
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
265
266
|
}, z.core.$strict>>;
|
|
266
267
|
privacy: z.ZodOptional<z.ZodObject<{
|
|
267
268
|
crossAgentSharing: z.ZodDefault<z.ZodEnum<{
|
|
@@ -541,6 +542,7 @@ export declare const AgentManifestSchema: z.ZodObject<{
|
|
|
541
542
|
compaction: z.ZodDefault<z.ZodBoolean>;
|
|
542
543
|
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
543
544
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
545
|
+
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
544
546
|
}, z.core.$strict>>;
|
|
545
547
|
privacy: z.ZodOptional<z.ZodObject<{
|
|
546
548
|
crossAgentSharing: z.ZodDefault<z.ZodEnum<{
|
|
@@ -777,6 +779,7 @@ export declare const AgentConfigEntrySchema: z.ZodObject<{
|
|
|
777
779
|
compaction: z.ZodDefault<z.ZodBoolean>;
|
|
778
780
|
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
779
781
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
782
|
+
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
780
783
|
}, z.core.$strict>>;
|
|
781
784
|
privacy: z.ZodOptional<z.ZodObject<{
|
|
782
785
|
crossAgentSharing: z.ZodDefault<z.ZodEnum<{
|
|
@@ -1055,6 +1058,7 @@ export declare const CapabilityPresetSchema: z.ZodObject<{
|
|
|
1055
1058
|
compaction: z.ZodDefault<z.ZodBoolean>;
|
|
1056
1059
|
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
1057
1060
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
1061
|
+
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
1058
1062
|
}, z.core.$strict>>;
|
|
1059
1063
|
privacy: z.ZodOptional<z.ZodObject<{
|
|
1060
1064
|
crossAgentSharing: z.ZodDefault<z.ZodEnum<{
|
|
@@ -190,7 +190,8 @@ var init_schema = __esmMin((() => {
|
|
|
190
190
|
retention: z.object({
|
|
191
191
|
compaction: z.boolean().default(true),
|
|
192
192
|
maxAgeDays: z.number().int().positive().optional(),
|
|
193
|
-
maxItems: z.number().int().positive().optional()
|
|
193
|
+
maxItems: z.number().int().positive().optional(),
|
|
194
|
+
maxChars: z.number().int().positive().optional()
|
|
194
195
|
}).strict().optional(),
|
|
195
196
|
privacy: z.object({
|
|
196
197
|
crossAgentSharing: z.enum([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../../../src/agent-manifest/schema.ts"],"sourcesContent":["import { z } from 'zod';\n\nconst IdSchema = z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/);\n\nexport const DEFAULT_CAPABILITY_PRESET_ID = 'default';\n\nexport const ManifestModelRoleSchema = z\n .object({\n model: z.string().min(1),\n fallbacks: z.array(z.string().min(1)).optional(),\n description: z.string().max(500).optional(),\n })\n .strict()\n .superRefine((entry, ctx) => {\n const validateRef = (ref: string) => {\n const trimmed = ref.trim();\n const idx = trimmed.indexOf('/');\n return idx > 0 && idx < trimmed.length - 1;\n };\n if (!validateRef(entry.model)) {\n ctx.addIssue({\n code: 'custom',\n message: `model must be provider/model format (got '${entry.model}')`,\n path: ['model'],\n });\n }\n for (const [index, fallback] of (entry.fallbacks ?? []).entries()) {\n if (!validateRef(fallback)) {\n ctx.addIssue({\n code: 'custom',\n message: `fallback must be provider/model format (got '${fallback}')`,\n path: ['fallbacks', index],\n });\n }\n }\n });\n\nexport const AgentToolModelSchema = z\n .object({\n primary: z.string().min(1),\n fallbacks: z.array(z.string().min(1)).optional(),\n timeoutMs: z.number().int().positive().optional(),\n autoProviderFallback: z.boolean().optional(),\n })\n .strict()\n .superRefine((entry, ctx) => {\n const validateRef = (ref: string) => {\n const trimmed = ref.trim();\n const idx = trimmed.indexOf('/');\n return idx > 0 && idx < trimmed.length - 1;\n };\n if (!validateRef(entry.primary)) {\n ctx.addIssue({\n code: 'custom',\n message: `primary must be provider/model format (got '${entry.primary}')`,\n path: ['primary'],\n });\n }\n for (const [index, fallback] of (entry.fallbacks ?? []).entries()) {\n if (!validateRef(fallback)) {\n ctx.addIssue({\n code: 'custom',\n message: `fallback must be provider/model format (got '${fallback}')`,\n path: ['fallbacks', index],\n });\n }\n }\n });\n\nexport const ModelPolicySchema = z\n .object({\n defaultRole: IdSchema,\n roles: z.record(IdSchema, ManifestModelRoleSchema).default({}),\n imageModel: AgentToolModelSchema.optional(),\n imageGenerationModel: AgentToolModelSchema.optional(),\n policy: z\n .object({\n allowFallbacks: z.boolean().optional(),\n maxCostTier: z.enum(['low', 'medium', 'high']).optional(),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport const ModelPolicyPatchSchema = z\n .object({\n defaultRole: IdSchema.optional(),\n roles: z.record(IdSchema, ManifestModelRoleSchema).optional(),\n imageModel: AgentToolModelSchema.optional(),\n imageGenerationModel: AgentToolModelSchema.optional(),\n policy: z\n .object({\n allowFallbacks: z.boolean().optional(),\n maxCostTier: z.enum(['low', 'medium', 'high']).optional(),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport const ToolModeSchema = z.enum(['allow', 'confirm', 'deny']);\nexport const ToolScopeSchema = z.enum(['readonly', 'workspace', 'unrestricted']);\n\nexport const ToolPolicySchema = z\n .object({\n mode: ToolModeSchema,\n scope: ToolScopeSchema.optional(),\n limits: z\n .object({\n maxCallsPerTurn: z.number().int().positive().optional(),\n timeoutMs: z.number().int().positive().optional(),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport const ToolPolicySetSchema = z\n .object({\n builtin: z.record(z.string().min(1), ToolPolicySchema).default({}),\n mcp: z\n .object({\n servers: z.record(z.string().min(1), ToolPolicySchema).optional(),\n tools: z.record(z.string().min(1), ToolPolicySchema).optional(),\n })\n .strict()\n .optional(),\n })\n .strict()\n .default({ builtin: {} });\n\nexport const SkillPolicySchema = z\n .object({\n mode: z.enum(['all', 'allowlist', 'denylist', 'off']).default('all'),\n allow: z.array(z.string().min(1)).optional(),\n deny: z.array(z.string().min(1)).optional(),\n })\n .strict()\n .default({ mode: 'all' });\n\nexport const DreamingPhasePolicySchema = z\n .object({\n enabled: z.boolean().optional(),\n cron: z.string().min(1).optional(),\n })\n .strict();\n\nexport const DreamingLightPolicySchema = DreamingPhasePolicySchema.extend({\n lookbackDays: z.number().int().positive().optional(),\n limit: z.number().int().nonnegative().optional(),\n dedupeSimilarity: z.number().min(0).max(1).optional(),\n}).strict();\n\nexport const DreamingDeepPolicySchema = DreamingPhasePolicySchema.extend({\n minScore: z.number().min(0).max(1).optional(),\n minRecallCount: z.number().int().positive().optional(),\n minUniqueQueries: z.number().int().positive().optional(),\n limit: z.number().int().nonnegative().optional(),\n recencyHalfLifeDays: z.number().positive().optional(),\n maxAgeDays: z.number().positive().optional(),\n}).strict();\n\nexport const DreamingRemPolicySchema = DreamingPhasePolicySchema.extend({\n lookbackDays: z.number().int().positive().optional(),\n limit: z.number().int().nonnegative().optional(),\n minPatternStrength: z.number().min(0).max(1).optional(),\n}).strict();\n\nexport const DreamingPolicySchema = z\n .object({\n enabled: z.boolean().default(false),\n frequency: z.string().min(1).optional(),\n timezone: z.string().optional(),\n phases: z\n .object({\n light: DreamingLightPolicySchema.optional(),\n deep: DreamingDeepPolicySchema.optional(),\n rem: DreamingRemPolicySchema.optional(),\n })\n .strict()\n .optional(),\n })\n .strict()\n .optional();\n\nexport const UserUnderstandingPolicySchema = z\n .object({\n enabled: z.boolean().optional(),\n adaptiveCadence: z.boolean().optional(),\n reviewIntervalTurns: z.number().int().min(1).max(1_000).optional(),\n maxHistoryMessages: z.number().int().min(1).max(200).optional(),\n maxDurationMs: z.number().int().min(1_000).max(600_000).optional(),\n })\n .strict();\n\nexport const MemoryPolicySchema = z\n .object({\n mode: z.enum(['off', 'readOnly', 'confirmWrite', 'auto']).default('off'),\n sources: z\n .array(z.enum(['session', 'userProfile', 'agentProfile', 'curated', 'workspace', 'connectedSources']))\n .default(['session']),\n writePolicy: z\n .object({\n userProfile: z.enum(['deny', 'confirm', 'allow']).optional(),\n agentProfile: z.enum(['deny', 'confirm', 'allow']).optional(),\n curated: z.enum(['deny', 'confirm', 'allow']).optional(),\n workspace: z.enum(['deny', 'confirm', 'allow']).optional(),\n })\n .strict()\n .optional(),\n retention: z\n .object({\n compaction: z.boolean().default(true),\n maxAgeDays: z.number().int().positive().optional(),\n maxItems: z.number().int().positive().optional(),\n })\n .strict()\n .optional(),\n privacy: z\n .object({\n crossAgentSharing: z.enum(['deny', 'readOnly', 'allow']).default('deny'),\n sensitiveWritePolicy: z.enum(['deny', 'confirm', 'allow']).default('confirm'),\n })\n .strict()\n .optional(),\n providerRouting: z\n .object({\n searchStrategy: z\n .enum(['local-first', 'external-first', 'fanout', 'local-only', 'external-only'])\n .default('fanout'),\n writeStrategy: z\n .enum(['local-first', 'external-first', 'write-through', 'local-only', 'external-only'])\n .default('local-first'),\n allowExternalWrites: z.boolean().default(false),\n allowedProviderIds: z.array(z.string().min(1)).optional(),\n autoWriteKinds: z\n .array(\n z.enum([\n 'user_profile',\n 'preference',\n 'boundary',\n 'relationship',\n 'project_context',\n 'commitment',\n 'routine',\n 'personal_logistics',\n 'open_question',\n 'milestone',\n 'current_state',\n 'agent_note',\n 'workspace_fact',\n 'daily_note',\n 'session_summary',\n 'derived_insight',\n 'task_lesson',\n 'tool_preference',\n 'long_term_goal',\n ]),\n )\n .optional(),\n })\n .strict()\n .optional(),\n dreaming: DreamingPolicySchema,\n understanding: UserUnderstandingPolicySchema.optional(),\n })\n .strict()\n .default({ mode: 'off', sources: ['session'] });\n\nexport const WorkflowPolicySchema = z\n .object({\n default: z.string().min(1).optional(),\n allowed: z.array(z.string().min(1)).optional(),\n suggested: z\n .array(\n z\n .object({\n intent: z.string().min(1),\n workflow: z.string().min(1),\n })\n .strict(),\n )\n .optional(),\n })\n .strict()\n .default({});\n\nexport const BoundaryPolicySchema = z\n .object({\n requiresConfirmation: z.array(z.string().min(1)).default([]),\n forbidden: z.array(z.string().min(1)).default([]),\n escalation: z.array(z.string().min(1)).default([]),\n })\n .strict()\n .default({ requiresConfirmation: [], forbidden: [], escalation: [] });\n\nexport const WorkspacePolicySchema = z\n .object({\n root: z.string().min(1),\n })\n .strict();\n\nexport const RuntimePolicySchema = z\n .object({\n maxTurns: z.number().int().positive().optional(),\n timeoutMs: z.number().int().positive().optional(),\n maxToolFailuresPerTurn: z.number().int().positive().optional(),\n })\n .strict()\n .optional();\n\nexport const PromptPolicySchema = z\n .object({\n customInstructions: z.string().optional(),\n })\n .strict()\n .optional();\n\nexport const AgentIdentitySchema = z\n .object({\n name: z.string().min(1),\n description: z.string().optional(),\n role: z.string().min(1),\n language: z.string().min(1).default('en'),\n tone: z.string().min(1).default('direct'),\n avatar: z.string().optional(),\n })\n .strict();\n\nexport const AgentResponsibilitiesSchema = z\n .object({\n primary: z.array(z.string().min(1)).min(1),\n secondary: z.array(z.string().min(1)).optional(),\n outOfScope: z.array(z.string().min(1)).optional(),\n })\n .strict();\n\nexport const AgentManifestSchema = z\n .object({\n id: IdSchema,\n enabled: z.boolean().default(true),\n extends: z.array(IdSchema).optional(),\n identity: AgentIdentitySchema,\n responsibilities: AgentResponsibilitiesSchema,\n workspace: WorkspacePolicySchema,\n models: ModelPolicySchema,\n tools: ToolPolicySetSchema,\n skills: SkillPolicySchema,\n memory: MemoryPolicySchema,\n workflows: WorkflowPolicySchema,\n boundaries: BoundaryPolicySchema,\n runtime: RuntimePolicySchema,\n prompt: PromptPolicySchema,\n })\n .strict();\n\nexport const AgentConfigEntrySchema = AgentManifestSchema.extend({\n models: ModelPolicySchema.optional(),\n}).strict();\n\nexport const CapabilityPresetSchema = z\n .object({\n id: IdSchema,\n name: z.string().min(1),\n description: z.string().optional(),\n version: z.number().int().positive().default(1),\n extends: z.array(IdSchema).optional(),\n models: ModelPolicyPatchSchema.optional(),\n tools: ToolPolicySetSchema.optional(),\n skills: SkillPolicySchema.optional(),\n memory: MemoryPolicySchema.optional(),\n workflows: WorkflowPolicySchema.optional(),\n boundaries: BoundaryPolicySchema.optional(),\n runtime: RuntimePolicySchema,\n locks: z.array(z.string().min(1)).optional(),\n })\n .strict();\n\nexport type AgentManifest = z.infer<typeof AgentManifestSchema>;\nexport type AgentConfigEntry = z.infer<typeof AgentConfigEntrySchema>;\nexport type CapabilityPreset = z.infer<typeof CapabilityPresetSchema>;\nexport type EffectiveAgentManifest = AgentManifest;\nexport type ToolPolicy = z.infer<typeof ToolPolicySchema>;\n"],"mappings":";;;;;AAEM,YAAW,EAAE,QAAQ,CAAC,MAAM,0BAA0B;AAE/C,gCAA+B;AAE/B,2BAA0B,EACpC,OAAO;EACN,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE;EACxB,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,UAAU;EAChD,aAAa,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU;EAC5C,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O,EAC/D,QAAQ,kBAAkB,UAAU,EACrC,CAAC,CAAC,QAAQ;AAEE,0BAAyB,EACnC,OAAO;EACN,IAAI;EACJ,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE;EACvB,aAAa,EAAE,QAAQ,CAAC,UAAU;EAClC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE;EAC/C,SAAS,EAAE,MAAM,SAAS,CAAC,UAAU;EACrC,QAAQ,uBAAuB,UAAU;EACzC,OAAO,oBAAoB,UAAU;EACrC,QAAQ,kBAAkB,UAAU;EACpC,QAAQ,mBAAmB,UAAU;EACrC,WAAW,qBAAqB,UAAU;EAC1C,YAAY,qBAAqB,UAAU;EAC3C,SAAS;EACT,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,UAAU;EAC7C,CAAC,CACD,QAAQ"}
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../../src/agent-manifest/schema.ts"],"sourcesContent":["import { z } from 'zod';\n\nconst IdSchema = z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/);\n\nexport const DEFAULT_CAPABILITY_PRESET_ID = 'default';\n\nexport const ManifestModelRoleSchema = z\n .object({\n model: z.string().min(1),\n fallbacks: z.array(z.string().min(1)).optional(),\n description: z.string().max(500).optional(),\n })\n .strict()\n .superRefine((entry, ctx) => {\n const validateRef = (ref: string) => {\n const trimmed = ref.trim();\n const idx = trimmed.indexOf('/');\n return idx > 0 && idx < trimmed.length - 1;\n };\n if (!validateRef(entry.model)) {\n ctx.addIssue({\n code: 'custom',\n message: `model must be provider/model format (got '${entry.model}')`,\n path: ['model'],\n });\n }\n for (const [index, fallback] of (entry.fallbacks ?? []).entries()) {\n if (!validateRef(fallback)) {\n ctx.addIssue({\n code: 'custom',\n message: `fallback must be provider/model format (got '${fallback}')`,\n path: ['fallbacks', index],\n });\n }\n }\n });\n\nexport const AgentToolModelSchema = z\n .object({\n primary: z.string().min(1),\n fallbacks: z.array(z.string().min(1)).optional(),\n timeoutMs: z.number().int().positive().optional(),\n autoProviderFallback: z.boolean().optional(),\n })\n .strict()\n .superRefine((entry, ctx) => {\n const validateRef = (ref: string) => {\n const trimmed = ref.trim();\n const idx = trimmed.indexOf('/');\n return idx > 0 && idx < trimmed.length - 1;\n };\n if (!validateRef(entry.primary)) {\n ctx.addIssue({\n code: 'custom',\n message: `primary must be provider/model format (got '${entry.primary}')`,\n path: ['primary'],\n });\n }\n for (const [index, fallback] of (entry.fallbacks ?? []).entries()) {\n if (!validateRef(fallback)) {\n ctx.addIssue({\n code: 'custom',\n message: `fallback must be provider/model format (got '${fallback}')`,\n path: ['fallbacks', index],\n });\n }\n }\n });\n\nexport const ModelPolicySchema = z\n .object({\n defaultRole: IdSchema,\n roles: z.record(IdSchema, ManifestModelRoleSchema).default({}),\n imageModel: AgentToolModelSchema.optional(),\n imageGenerationModel: AgentToolModelSchema.optional(),\n policy: z\n .object({\n allowFallbacks: z.boolean().optional(),\n maxCostTier: z.enum(['low', 'medium', 'high']).optional(),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport const ModelPolicyPatchSchema = z\n .object({\n defaultRole: IdSchema.optional(),\n roles: z.record(IdSchema, ManifestModelRoleSchema).optional(),\n imageModel: AgentToolModelSchema.optional(),\n imageGenerationModel: AgentToolModelSchema.optional(),\n policy: z\n .object({\n allowFallbacks: z.boolean().optional(),\n maxCostTier: z.enum(['low', 'medium', 'high']).optional(),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport const ToolModeSchema = z.enum(['allow', 'confirm', 'deny']);\nexport const ToolScopeSchema = z.enum(['readonly', 'workspace', 'unrestricted']);\n\nexport const ToolPolicySchema = z\n .object({\n mode: ToolModeSchema,\n scope: ToolScopeSchema.optional(),\n limits: z\n .object({\n maxCallsPerTurn: z.number().int().positive().optional(),\n timeoutMs: z.number().int().positive().optional(),\n })\n .strict()\n .optional(),\n })\n .strict();\n\nexport const ToolPolicySetSchema = z\n .object({\n builtin: z.record(z.string().min(1), ToolPolicySchema).default({}),\n mcp: z\n .object({\n servers: z.record(z.string().min(1), ToolPolicySchema).optional(),\n tools: z.record(z.string().min(1), ToolPolicySchema).optional(),\n })\n .strict()\n .optional(),\n })\n .strict()\n .default({ builtin: {} });\n\nexport const SkillPolicySchema = z\n .object({\n mode: z.enum(['all', 'allowlist', 'denylist', 'off']).default('all'),\n allow: z.array(z.string().min(1)).optional(),\n deny: z.array(z.string().min(1)).optional(),\n })\n .strict()\n .default({ mode: 'all' });\n\nexport const DreamingPhasePolicySchema = z\n .object({\n enabled: z.boolean().optional(),\n cron: z.string().min(1).optional(),\n })\n .strict();\n\nexport const DreamingLightPolicySchema = DreamingPhasePolicySchema.extend({\n lookbackDays: z.number().int().positive().optional(),\n limit: z.number().int().nonnegative().optional(),\n dedupeSimilarity: z.number().min(0).max(1).optional(),\n}).strict();\n\nexport const DreamingDeepPolicySchema = DreamingPhasePolicySchema.extend({\n minScore: z.number().min(0).max(1).optional(),\n minRecallCount: z.number().int().positive().optional(),\n minUniqueQueries: z.number().int().positive().optional(),\n limit: z.number().int().nonnegative().optional(),\n recencyHalfLifeDays: z.number().positive().optional(),\n maxAgeDays: z.number().positive().optional(),\n}).strict();\n\nexport const DreamingRemPolicySchema = DreamingPhasePolicySchema.extend({\n lookbackDays: z.number().int().positive().optional(),\n limit: z.number().int().nonnegative().optional(),\n minPatternStrength: z.number().min(0).max(1).optional(),\n}).strict();\n\nexport const DreamingPolicySchema = z\n .object({\n enabled: z.boolean().default(false),\n frequency: z.string().min(1).optional(),\n timezone: z.string().optional(),\n phases: z\n .object({\n light: DreamingLightPolicySchema.optional(),\n deep: DreamingDeepPolicySchema.optional(),\n rem: DreamingRemPolicySchema.optional(),\n })\n .strict()\n .optional(),\n })\n .strict()\n .optional();\n\nexport const UserUnderstandingPolicySchema = z\n .object({\n enabled: z.boolean().optional(),\n adaptiveCadence: z.boolean().optional(),\n reviewIntervalTurns: z.number().int().min(1).max(1_000).optional(),\n maxHistoryMessages: z.number().int().min(1).max(200).optional(),\n maxDurationMs: z.number().int().min(1_000).max(600_000).optional(),\n })\n .strict();\n\nexport const MemoryPolicySchema = z\n .object({\n mode: z.enum(['off', 'readOnly', 'confirmWrite', 'auto']).default('off'),\n sources: z\n .array(z.enum(['session', 'userProfile', 'agentProfile', 'curated', 'workspace', 'connectedSources']))\n .default(['session']),\n writePolicy: z\n .object({\n userProfile: z.enum(['deny', 'confirm', 'allow']).optional(),\n agentProfile: z.enum(['deny', 'confirm', 'allow']).optional(),\n curated: z.enum(['deny', 'confirm', 'allow']).optional(),\n workspace: z.enum(['deny', 'confirm', 'allow']).optional(),\n })\n .strict()\n .optional(),\n retention: z\n .object({\n compaction: z.boolean().default(true),\n maxAgeDays: z.number().int().positive().optional(),\n maxItems: z.number().int().positive().optional(),\n maxChars: z.number().int().positive().optional(),\n })\n .strict()\n .optional(),\n privacy: z\n .object({\n crossAgentSharing: z.enum(['deny', 'readOnly', 'allow']).default('deny'),\n sensitiveWritePolicy: z.enum(['deny', 'confirm', 'allow']).default('confirm'),\n })\n .strict()\n .optional(),\n providerRouting: z\n .object({\n searchStrategy: z\n .enum(['local-first', 'external-first', 'fanout', 'local-only', 'external-only'])\n .default('fanout'),\n writeStrategy: z\n .enum(['local-first', 'external-first', 'write-through', 'local-only', 'external-only'])\n .default('local-first'),\n allowExternalWrites: z.boolean().default(false),\n allowedProviderIds: z.array(z.string().min(1)).optional(),\n autoWriteKinds: z\n .array(\n z.enum([\n 'user_profile',\n 'preference',\n 'boundary',\n 'relationship',\n 'project_context',\n 'commitment',\n 'routine',\n 'personal_logistics',\n 'open_question',\n 'milestone',\n 'current_state',\n 'agent_note',\n 'workspace_fact',\n 'daily_note',\n 'session_summary',\n 'derived_insight',\n 'task_lesson',\n 'tool_preference',\n 'long_term_goal',\n ]),\n )\n .optional(),\n })\n .strict()\n .optional(),\n dreaming: DreamingPolicySchema,\n understanding: UserUnderstandingPolicySchema.optional(),\n })\n .strict()\n .default({ mode: 'off', sources: ['session'] });\n\nexport const WorkflowPolicySchema = z\n .object({\n default: z.string().min(1).optional(),\n allowed: z.array(z.string().min(1)).optional(),\n suggested: z\n .array(\n z\n .object({\n intent: z.string().min(1),\n workflow: z.string().min(1),\n })\n .strict(),\n )\n .optional(),\n })\n .strict()\n .default({});\n\nexport const BoundaryPolicySchema = z\n .object({\n requiresConfirmation: z.array(z.string().min(1)).default([]),\n forbidden: z.array(z.string().min(1)).default([]),\n escalation: z.array(z.string().min(1)).default([]),\n })\n .strict()\n .default({ requiresConfirmation: [], forbidden: [], escalation: [] });\n\nexport const WorkspacePolicySchema = z\n .object({\n root: z.string().min(1),\n })\n .strict();\n\nexport const RuntimePolicySchema = z\n .object({\n maxTurns: z.number().int().positive().optional(),\n timeoutMs: z.number().int().positive().optional(),\n maxToolFailuresPerTurn: z.number().int().positive().optional(),\n })\n .strict()\n .optional();\n\nexport const PromptPolicySchema = z\n .object({\n customInstructions: z.string().optional(),\n })\n .strict()\n .optional();\n\nexport const AgentIdentitySchema = z\n .object({\n name: z.string().min(1),\n description: z.string().optional(),\n role: z.string().min(1),\n language: z.string().min(1).default('en'),\n tone: z.string().min(1).default('direct'),\n avatar: z.string().optional(),\n })\n .strict();\n\nexport const AgentResponsibilitiesSchema = z\n .object({\n primary: z.array(z.string().min(1)).min(1),\n secondary: z.array(z.string().min(1)).optional(),\n outOfScope: z.array(z.string().min(1)).optional(),\n })\n .strict();\n\nexport const AgentManifestSchema = z\n .object({\n id: IdSchema,\n enabled: z.boolean().default(true),\n extends: z.array(IdSchema).optional(),\n identity: AgentIdentitySchema,\n responsibilities: AgentResponsibilitiesSchema,\n workspace: WorkspacePolicySchema,\n models: ModelPolicySchema,\n tools: ToolPolicySetSchema,\n skills: SkillPolicySchema,\n memory: MemoryPolicySchema,\n workflows: WorkflowPolicySchema,\n boundaries: BoundaryPolicySchema,\n runtime: RuntimePolicySchema,\n prompt: PromptPolicySchema,\n })\n .strict();\n\nexport const AgentConfigEntrySchema = AgentManifestSchema.extend({\n models: ModelPolicySchema.optional(),\n}).strict();\n\nexport const CapabilityPresetSchema = z\n .object({\n id: IdSchema,\n name: z.string().min(1),\n description: z.string().optional(),\n version: z.number().int().positive().default(1),\n extends: z.array(IdSchema).optional(),\n models: ModelPolicyPatchSchema.optional(),\n tools: ToolPolicySetSchema.optional(),\n skills: SkillPolicySchema.optional(),\n memory: MemoryPolicySchema.optional(),\n workflows: WorkflowPolicySchema.optional(),\n boundaries: BoundaryPolicySchema.optional(),\n runtime: RuntimePolicySchema,\n locks: z.array(z.string().min(1)).optional(),\n })\n .strict();\n\nexport type AgentManifest = z.infer<typeof AgentManifestSchema>;\nexport type AgentConfigEntry = z.infer<typeof AgentConfigEntrySchema>;\nexport type CapabilityPreset = z.infer<typeof CapabilityPresetSchema>;\nexport type EffectiveAgentManifest = AgentManifest;\nexport type ToolPolicy = z.infer<typeof ToolPolicySchema>;\n"],"mappings":";;;;;AAEM,YAAW,EAAE,QAAQ,CAAC,MAAM,0BAA0B;AAE/C,gCAA+B;AAE/B,2BAA0B,EACpC,OAAO;EACN,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE;EACxB,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,UAAU;EAChD,aAAa,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU;EAC5C,CAAC,CACD,QAAQ,CACR,aAAa,OAAO,QAAQ;EAC3B,MAAM,eAAe,QAAgB;GACnC,MAAM,UAAU,IAAI,MAAM;GAC1B,MAAM,MAAM,QAAQ,QAAQ,IAAI;AAChC,UAAO,MAAM,KAAK,MAAM,QAAQ,SAAS;;AAE3C,MAAI,CAAC,YAAY,MAAM,MAAM,CAC3B,KAAI,SAAS;GACX,MAAM;GACN,SAAS,6CAA6C,MAAM,MAAM;GAClE,MAAM,CAAC,QAAQ;GAChB,CAAC;AAEJ,OAAK,MAAM,CAAC,OAAO,cAAc,MAAM,aAAa,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,UAAU;EACzC,OAAO,oBAAoB,UAAU;EACrC,QAAQ,kBAAkB,UAAU;EACpC,QAAQ,mBAAmB,UAAU;EACrC,WAAW,qBAAqB,UAAU;EAC1C,YAAY,qBAAqB,UAAU;EAC3C,SAAS;EACT,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,UAAU;EAC7C,CAAC,CACD,QAAQ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
1
2
|
import { checkBoundary } from "./boundary-guard.js";
|
|
2
3
|
import { resolveModelRole } from "./model-router.js";
|
|
3
4
|
import { buildRuntimeToolRegistry } from "./tool-registry.js";
|
|
4
|
-
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
5
5
|
import { resolveWorkflow, validateWorkflowForRuntime } from "./workflow-runtime.js";
|
|
6
6
|
import { buildAgentRuntimeProfile } from "./runtime-profile.js";
|
|
7
7
|
import { appendAgentRunEvent, createAgentRunTrace, finishAgentRunTrace, hashEffectiveManifest } from "./run-trace.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildAgentManifestPromptSection } from "../agent-manifest/prompt.js";
|
|
2
2
|
import "../agent-manifest/index.js";
|
|
3
|
+
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
3
4
|
import { checkBoundary } from "./boundary-guard.js";
|
|
4
5
|
import { resolveModelRole } from "./model-router.js";
|
|
5
6
|
import { buildRuntimeToolRegistry } from "./tool-registry.js";
|
|
6
|
-
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
7
7
|
import { resolveWorkflow, validateWorkflowForRuntime } from "./workflow-runtime.js";
|
|
8
8
|
//#region src/agent-runtime/runtime-profile.ts
|
|
9
9
|
function buildAgentRuntimeProfile(params) {
|
|
@@ -188,6 +188,7 @@ export declare const AgentsConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
188
188
|
compaction: z.ZodDefault<z.ZodBoolean>;
|
|
189
189
|
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
190
190
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
191
|
+
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
191
192
|
}, z.core.$strict>>;
|
|
192
193
|
privacy: z.ZodOptional<z.ZodObject<{
|
|
193
194
|
crossAgentSharing: z.ZodDefault<z.ZodEnum<{
|
|
@@ -422,6 +423,7 @@ export declare const AgentsConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
422
423
|
compaction: z.ZodDefault<z.ZodBoolean>;
|
|
423
424
|
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
424
425
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
426
|
+
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
425
427
|
}, z.core.$strict>>;
|
|
426
428
|
privacy: z.ZodOptional<z.ZodObject<{
|
|
427
429
|
crossAgentSharing: z.ZodDefault<z.ZodEnum<{
|
|
@@ -1876,6 +1878,7 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
1876
1878
|
compaction: z.ZodDefault<z.ZodBoolean>;
|
|
1877
1879
|
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
1878
1880
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
1881
|
+
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
1879
1882
|
}, z.core.$strict>>;
|
|
1880
1883
|
privacy: z.ZodOptional<z.ZodObject<{
|
|
1881
1884
|
crossAgentSharing: z.ZodDefault<z.ZodEnum<{
|
|
@@ -2110,6 +2113,7 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
2110
2113
|
compaction: z.ZodDefault<z.ZodBoolean>;
|
|
2111
2114
|
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
2112
2115
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
2116
|
+
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
2113
2117
|
}, z.core.$strict>>;
|
|
2114
2118
|
privacy: z.ZodOptional<z.ZodObject<{
|
|
2115
2119
|
crossAgentSharing: z.ZodDefault<z.ZodEnum<{
|
|
@@ -110,6 +110,7 @@ export declare function buildSafeWebConfigPayload(service: GatewayService, optio
|
|
|
110
110
|
compaction: boolean;
|
|
111
111
|
maxAgeDays?: number;
|
|
112
112
|
maxItems?: number;
|
|
113
|
+
maxChars?: number;
|
|
113
114
|
};
|
|
114
115
|
privacy?: {
|
|
115
116
|
crossAgentSharing: "allow" | "deny" | "readOnly";
|
|
@@ -251,6 +252,7 @@ export declare function buildSafeWebConfigPayload(service: GatewayService, optio
|
|
|
251
252
|
compaction: boolean;
|
|
252
253
|
maxAgeDays?: number;
|
|
253
254
|
maxItems?: number;
|
|
255
|
+
maxChars?: number;
|
|
254
256
|
};
|
|
255
257
|
privacy?: {
|
|
256
258
|
crossAgentSharing: "allow" | "deny" | "readOnly";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { init_agent_scope, normalizeAgentId, resolveDefaultAgentId } from "../../../agent/agent-scope.js";
|
|
2
2
|
import { DREAMING_DIR_RELATIVE, DREAMING_LAST_RUN_RELATIVE, SHORT_TERM_PROMOTION_LOCK_RELATIVE, SHORT_TERM_RECALL_STORE_RELATIVE } from "../../../agent/memory/dreaming/constants.js";
|
|
3
|
-
import { loadDreamingStore,
|
|
3
|
+
import { clearStaleDreamingLock, loadDreamingStore, resetDreamingStore } from "../../../agent/memory/dreaming/short-term-store.js";
|
|
4
4
|
import { resolveDreamingAgentScope } from "../../../agent/memory/dreaming/scope.js";
|
|
5
5
|
import { parseDreamingLastRunFile } from "../../../agent/memory/dreaming/last-run.js";
|
|
6
6
|
import { runDreamingDeepPromotion } from "../../../agent/memory/dreaming/deep-promotion.js";
|
|
@@ -207,15 +207,22 @@ function registerDreamingRoutes(authenticated, deps) {
|
|
|
207
207
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
208
208
|
});
|
|
209
209
|
const result = requestedPhase === "light" ? await runLightSweep({
|
|
210
|
+
workspaceDir: scope.workspaceDir,
|
|
210
211
|
dreamingRoot: scope.memoriesDir,
|
|
211
212
|
config: dreaming.phases.light
|
|
212
213
|
}) : requestedPhase === "rem" ? await runRemPatterns({
|
|
214
|
+
agentId: scope.agentId,
|
|
215
|
+
workspaceDir: scope.workspaceDir,
|
|
213
216
|
dreamingRoot: scope.memoriesDir,
|
|
214
|
-
config: dreaming.phases.rem
|
|
217
|
+
config: dreaming.phases.rem,
|
|
218
|
+
sensitiveWritePolicy: scope.memory.privacy?.sensitiveWritePolicy,
|
|
219
|
+
promotionWritePolicy: dreaming.promotionWritePolicy.decision
|
|
215
220
|
}) : await runDreamingDeepPromotion({
|
|
221
|
+
agentId: scope.agentId,
|
|
216
222
|
workspaceDir: scope.workspaceDir,
|
|
217
223
|
dreamingRoot: scope.memoriesDir,
|
|
218
|
-
config: dreaming.phases.deep
|
|
224
|
+
config: dreaming.phases.deep,
|
|
225
|
+
sensitiveWritePolicy: scope.memory.privacy?.sensitiveWritePolicy
|
|
219
226
|
});
|
|
220
227
|
service.emit("dreaming.phase.end", {
|
|
221
228
|
agentId: scope.agentId,
|
|
@@ -270,15 +277,7 @@ function registerDreamingRoutes(authenticated, deps) {
|
|
|
270
277
|
error: { message: "Invalid action" }
|
|
271
278
|
}, 400);
|
|
272
279
|
if (action === "reset_store") {
|
|
273
|
-
|
|
274
|
-
version: 1,
|
|
275
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
276
|
-
entries: {}
|
|
277
|
-
};
|
|
278
|
-
await saveDreamingStore({
|
|
279
|
-
dreamingRoot: scope.memoriesDir,
|
|
280
|
-
store: next
|
|
281
|
-
});
|
|
280
|
+
await resetDreamingStore({ dreamingRoot: scope.memoriesDir });
|
|
282
281
|
return c.json({
|
|
283
282
|
ok: true,
|
|
284
283
|
payload: {
|
|
@@ -289,15 +288,23 @@ function registerDreamingRoutes(authenticated, deps) {
|
|
|
289
288
|
});
|
|
290
289
|
}
|
|
291
290
|
const lockPath = path.join(scope.memoriesDir, SHORT_TERM_PROMOTION_LOCK_RELATIVE);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
291
|
+
try {
|
|
292
|
+
const cleared = await clearStaleDreamingLock(scope.memoriesDir);
|
|
293
|
+
return c.json({
|
|
294
|
+
ok: true,
|
|
295
|
+
payload: {
|
|
296
|
+
agentId: scope.agentId,
|
|
297
|
+
cleared,
|
|
298
|
+
lockPath
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
} catch (err) {
|
|
302
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
303
|
+
return c.json({
|
|
304
|
+
ok: false,
|
|
305
|
+
error: { message }
|
|
306
|
+
}, 409);
|
|
307
|
+
}
|
|
301
308
|
});
|
|
302
309
|
authenticated.get("/api/dreaming/events", async (c) => {
|
|
303
310
|
const cfg = service.currentConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dreaming.js","names":[],"sources":["../../../../../src/gateway/hono/routes/dreaming.ts"],"sourcesContent":["import type { Hono } from 'hono';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { type Config } from '../../../config/schema.js';\nimport { normalizeAgentId, resolveDefaultAgentId } from '../../../agent/agent-scope.js';\nimport {\n DREAMING_DIR_RELATIVE,\n DREAMING_LAST_RUN_RELATIVE,\n SHORT_TERM_PROMOTION_LOCK_RELATIVE,\n SHORT_TERM_RECALL_STORE_RELATIVE,\n type DreamingPhaseId,\n} from '../../../agent/memory/dreaming/constants.js';\nimport { readDreamingEvents } from '../../../agent/memory/dreaming/events.js';\nimport { previewDreamingDeepPromotion } from '../../../agent/memory/dreaming/preview.js';\nimport { runLightSweep } from '../../../agent/memory/dreaming/light-sweep.js';\nimport { runDreamingDeepPromotion } from '../../../agent/memory/dreaming/deep-promotion.js';\nimport { runRemPatterns } from '../../../agent/memory/dreaming/rem-patterns.js';\nimport { parseDreamingLastRunFile, type DreamingDeepLastRun } from '../../../agent/memory/dreaming/last-run.js';\nimport { resolveDreamingAgentScope, type DreamingAgentScope } from '../../../agent/memory/dreaming/scope.js';\nimport {\n loadDreamingStore,\n saveDreamingStore,\n type DreamingStore,\n} from '../../../agent/memory/dreaming/short-term-store.js';\nimport type { AuthenticatedRouteDeps } from './deps.js';\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return v !== null && typeof v === 'object' && !Array.isArray(v);\n}\n\nfunction requestedAgentIdFrom(c: { req: { query(name: string): string | undefined } }, body?: unknown): string | undefined {\n const fromBody = isRecord(body) && typeof body.agentId === 'string' ? body.agentId : undefined;\n return fromBody ?? c.req.query('agentId');\n}\n\nfunction hasEnabledAgent(cfg: Config, agentId: string): boolean {\n const normalized = normalizeAgentId(agentId);\n return cfg.agents.list.some((agent) => agent.enabled !== false && normalizeAgentId(agent.id) === normalized);\n}\n\nfunction resolveRouteScope(cfg: Config, requestedAgentId?: string): DreamingAgentScope {\n const agentId = normalizeAgentId(requestedAgentId || resolveDefaultAgentId(cfg));\n if (!hasEnabledAgent(cfg, agentId)) {\n throw new Error(`Agent not found: ${agentId}`);\n }\n return resolveDreamingAgentScope(cfg, agentId);\n}\n\nasync function readLockInfo(dreamingRoot: string): Promise<\n | { locked: false }\n | { locked: true; path: string; content: string; mtimeMs?: number }\n> {\n const lockPath = path.join(dreamingRoot, SHORT_TERM_PROMOTION_LOCK_RELATIVE);\n try {\n const [content, st] = await Promise.all([fs.readFile(lockPath, 'utf-8'), fs.stat(lockPath)]);\n return {\n locked: true,\n path: SHORT_TERM_PROMOTION_LOCK_RELATIVE,\n content: content.trim(),\n mtimeMs: st.mtimeMs,\n };\n } catch (err) {\n const code = (err as NodeJS.ErrnoException | undefined)?.code;\n if (code === 'ENOENT') return { locked: false };\n return { locked: true, path: SHORT_TERM_PROMOTION_LOCK_RELATIVE, content: 'unknown', mtimeMs: undefined };\n }\n}\n\nasync function readLastRun(\n dreamingRoot: string,\n): Promise<\n | { exists: false }\n | {\n exists: true;\n path: string;\n raw: unknown;\n record: DreamingDeepLastRun | null;\n parseError: string | null;\n }\n> {\n const fullPath = path.join(dreamingRoot, DREAMING_LAST_RUN_RELATIVE);\n try {\n const text = await fs.readFile(fullPath, 'utf-8');\n let raw: unknown;\n try {\n raw = JSON.parse(text) as unknown;\n } catch (parseErr) {\n return {\n exists: true,\n path: DREAMING_LAST_RUN_RELATIVE,\n raw: null,\n record: null,\n parseError: parseErr instanceof Error ? parseErr.message : String(parseErr),\n };\n }\n const record = parseDreamingLastRunFile(raw);\n return {\n exists: true,\n path: DREAMING_LAST_RUN_RELATIVE,\n raw,\n record,\n parseError: record ? null : 'Invalid or unsupported last-run.json (expected v2 deep record).',\n };\n } catch (err) {\n const code = (err as NodeJS.ErrnoException | undefined)?.code;\n if (code === 'ENOENT') return { exists: false };\n return {\n exists: true,\n path: DREAMING_LAST_RUN_RELATIVE,\n raw: null,\n record: null,\n parseError: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nasync function readPhaseLastRun(\n dreamingRoot: string,\n filename: string,\n): Promise<{ exists: false } | { exists: true; path: string; raw: unknown }> {\n const relPath = path.join(DREAMING_DIR_RELATIVE, filename);\n const fullPath = path.join(dreamingRoot, relPath);\n try {\n const text = await fs.readFile(fullPath, 'utf-8');\n const raw = JSON.parse(text) as unknown;\n return { exists: true, path: relPath, raw };\n } catch (err) {\n const code = (err as NodeJS.ErrnoException | undefined)?.code;\n if (code === 'ENOENT') return { exists: false };\n return { exists: false };\n }\n}\n\nfunction storeStats(store: DreamingStore): {\n version: number;\n updatedAt: string;\n entryCount: number;\n promotedCount: number;\n lastPromotedAt: string | null;\n} {\n const entries = Object.values(store.entries ?? {});\n const promoted = entries.filter((e) => typeof e.promotedAt === 'string' && e.promotedAt.trim());\n const lastPromotedAt = promoted\n .map((e) => e.promotedAt!)\n .sort((a, b) => (a < b ? 1 : a > b ? -1 : 0))[0];\n return {\n version: store.version,\n updatedAt: store.updatedAt,\n entryCount: entries.length,\n promotedCount: promoted.length,\n lastPromotedAt: lastPromotedAt ?? null,\n };\n}\n\nexport function registerDreamingRoutes(authenticated: Hono, deps: AuthenticatedRouteDeps): void {\n const { service } = deps;\n\n authenticated.get('/api/dreaming', async (c) => {\n const cfg = service.currentConfig as Config;\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, c.req.query('agentId'));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n const { store } = await loadDreamingStore({ dreamingRoot: scope.memoriesDir });\n const lock = await readLockInfo(scope.memoriesDir);\n\n // Read all three phase last-run files in parallel.\n const [lastRun, lightLastRun, remLastRun] = await Promise.all([\n readLastRun(scope.memoriesDir),\n readPhaseLastRun(scope.memoriesDir, 'last-run-light.json'),\n readPhaseLastRun(scope.memoriesDir, 'last-run-rem.json'),\n ]);\n\n return c.json({\n ok: true,\n payload: {\n agentId: scope.agentId,\n memory: scope.memory,\n workspaceDir: scope.workspaceDir,\n memoriesDir: scope.memoriesDir,\n config: scope.config,\n storePath: path.join(scope.memoriesDir, SHORT_TERM_RECALL_STORE_RELATIVE),\n store: storeStats(store),\n lock,\n lastRun,\n lightLastRun,\n remLastRun,\n },\n });\n });\n\n authenticated.get('/api/dreaming/preview', async (c) => {\n const cfg = service.currentConfig as Config;\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, c.req.query('agentId'));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n\n const rawLimit = c.req.query('limit');\n const limit = rawLimit ? Number(rawLimit) : 20;\n\n const preview = await previewDreamingDeepPromotion({\n workspaceDir: scope.workspaceDir,\n dreamingRoot: scope.memoriesDir,\n config: scope.config.deep,\n limit: Number.isFinite(limit) ? limit : 20,\n });\n\n return c.json({ ok: true, payload: preview });\n });\n\n authenticated.post('/api/dreaming/run', async (c) => {\n let body: unknown;\n try { body = await c.req.json(); } catch { body = {}; }\n const requestedPhase: DreamingPhaseId =\n isRecord(body) && typeof body.phase === 'string' && ['light', 'deep', 'rem'].includes(body.phase)\n ? (body.phase as DreamingPhaseId)\n : 'deep';\n\n const cfg = service.currentConfig as Config;\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, requestedAgentIdFrom(c, body));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n const dreaming = scope.config;\n if (!dreaming.enabled || !dreaming.phases[requestedPhase].enabled) {\n return c.json({\n ok: false,\n error: { message: `Dreaming ${requestedPhase} phase is disabled in config. Enable it first.` },\n }, 400);\n }\n\n try {\n service.emit('dreaming.phase.start', {\n agentId: scope.agentId,\n phase: requestedPhase,\n timestamp: new Date().toISOString(),\n });\n\n const result =\n requestedPhase === 'light'\n ? await runLightSweep({ dreamingRoot: scope.memoriesDir, config: dreaming.phases.light })\n : requestedPhase === 'rem'\n ? await runRemPatterns({ dreamingRoot: scope.memoriesDir, config: dreaming.phases.rem })\n : await runDreamingDeepPromotion({\n workspaceDir: scope.workspaceDir,\n dreamingRoot: scope.memoriesDir,\n config: dreaming.phases.deep,\n });\n\n service.emit('dreaming.phase.end', {\n agentId: scope.agentId,\n phase: requestedPhase,\n ok: true,\n timestamp: new Date().toISOString(),\n });\n\n return c.json({ ok: true, payload: { agentId: scope.agentId, phase: requestedPhase, result } });\n } catch (err) {\n const em = err instanceof Error ? err.message : String(err);\n service.emit('dreaming.phase.end', {\n agentId: scope.agentId,\n phase: requestedPhase,\n ok: false,\n error: em,\n timestamp: new Date().toISOString(),\n });\n return c.json({ ok: false, error: { message: em || 'Failed to trigger job' } }, 400);\n }\n });\n\n authenticated.post('/api/dreaming/action', async (c) => {\n const cfg = service.currentConfig as Config;\n\n let body: unknown;\n try {\n body = await c.req.json();\n } catch {\n body = {};\n }\n const action = isRecord(body) && typeof body.action === 'string' ? body.action.trim() : '';\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, requestedAgentIdFrom(c, body));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n\n if (action !== 'reset_store' && action !== 'clear_lock') {\n return c.json({ ok: false, error: { message: 'Invalid action' } }, 400);\n }\n\n if (action === 'reset_store') {\n const nowIso = new Date().toISOString();\n const next: DreamingStore = { version: 1, updatedAt: nowIso, entries: {} };\n await saveDreamingStore({ dreamingRoot: scope.memoriesDir, store: next });\n return c.json({\n ok: true,\n payload: { agentId: scope.agentId, reset: true, storePath: path.join(scope.memoriesDir, SHORT_TERM_RECALL_STORE_RELATIVE) },\n });\n }\n\n const lockPath = path.join(scope.memoriesDir, SHORT_TERM_PROMOTION_LOCK_RELATIVE);\n await fs.unlink(lockPath).catch(() => undefined);\n return c.json({\n ok: true,\n payload: { agentId: scope.agentId, cleared: true, lockPath },\n });\n });\n\n authenticated.get('/api/dreaming/events', async (c) => {\n const cfg = service.currentConfig as Config;\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, c.req.query('agentId'));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n\n const rawLimit = c.req.query('limit');\n const limit = rawLimit ? Math.min(Math.max(Number(rawLimit) || 50, 1), 200) : 50;\n\n const events = await readDreamingEvents(scope.memoriesDir, limit);\n return c.json({ ok: true, payload: { agentId: scope.agentId, events } });\n });\n}\n"],"mappings":";;;;;;;;;;;;;kBAKwF;AAsBxF,SAAS,SAAS,GAA0C;AAC1D,QAAO,MAAM,QAAQ,OAAO,MAAM,YAAY,CAAC,MAAM,QAAQ,EAAE;;AAGjE,SAAS,qBAAqB,GAAyD,MAAoC;AAEzH,SADiB,SAAS,KAAK,IAAI,OAAO,KAAK,YAAY,WAAW,KAAK,UAAU,KAAA,MAClE,EAAE,IAAI,MAAM,UAAU;;AAG3C,SAAS,gB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MAAM,aAAa,mCAAmC;AACjF,QAAM,GAAG,OAAO,SAAS,CAAC,YAAY,KAAA,EAAU;AAChD,SAAO,EAAE,KAAK;GACZ,IAAI;GACJ,SAAS;IAAE,SAAS,MAAM;IAAS,SAAS;IAAM;IAAU;GAC7D,CAAC;GACF;AAEF,eAAc,IAAI,wBAAwB,OAAO,MAAM;EACrD,MAAM,MAAM,QAAQ;EACpB,IAAI;AACJ,MAAI;AACF,WAAQ,kBAAkB,KAAK,EAAE,IAAI,MAAM,UAAU,CAAC;WAC/C,KAAK;GACZ,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;AAChE,UAAO,EAAE,KAAK;IAAE,IAAI;IAAO,OAAO,EAAE,SAAS;IAAE,EAAE,IAAI;;EAGvD,MAAM,WAAW,EAAE,IAAI,MAAM,QAAQ;EACrC,MAAM,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,OAAO,SAAS,IAAI,IAAI,EAAE,EAAE,IAAI,GAAG;EAE9E,MAAM,SAAS,MAAM,mBAAmB,MAAM,aAAa,MAAM;AACjE,SAAO,EAAE,KAAK;GAAE,IAAI;GAAM,SAAS;IAAE,SAAS,MAAM;IAAS;IAAQ;GAAE,CAAC;GACxE"}
|
|
1
|
+
{"version":3,"file":"dreaming.js","names":[],"sources":["../../../../../src/gateway/hono/routes/dreaming.ts"],"sourcesContent":["import type { Hono } from 'hono';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { type Config } from '../../../config/schema.js';\nimport { normalizeAgentId, resolveDefaultAgentId } from '../../../agent/agent-scope.js';\nimport {\n DREAMING_DIR_RELATIVE,\n DREAMING_LAST_RUN_RELATIVE,\n SHORT_TERM_PROMOTION_LOCK_RELATIVE,\n SHORT_TERM_RECALL_STORE_RELATIVE,\n type DreamingPhaseId,\n} from '../../../agent/memory/dreaming/constants.js';\nimport { readDreamingEvents } from '../../../agent/memory/dreaming/events.js';\nimport { previewDreamingDeepPromotion } from '../../../agent/memory/dreaming/preview.js';\nimport { runLightSweep } from '../../../agent/memory/dreaming/light-sweep.js';\nimport { runDreamingDeepPromotion } from '../../../agent/memory/dreaming/deep-promotion.js';\nimport { runRemPatterns } from '../../../agent/memory/dreaming/rem-patterns.js';\nimport { parseDreamingLastRunFile, type DreamingDeepLastRun } from '../../../agent/memory/dreaming/last-run.js';\nimport { resolveDreamingAgentScope, type DreamingAgentScope } from '../../../agent/memory/dreaming/scope.js';\nimport {\n clearStaleDreamingLock,\n loadDreamingStore,\n resetDreamingStore,\n type DreamingStore,\n} from '../../../agent/memory/dreaming/short-term-store.js';\nimport type { AuthenticatedRouteDeps } from './deps.js';\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return v !== null && typeof v === 'object' && !Array.isArray(v);\n}\n\nfunction requestedAgentIdFrom(c: { req: { query(name: string): string | undefined } }, body?: unknown): string | undefined {\n const fromBody = isRecord(body) && typeof body.agentId === 'string' ? body.agentId : undefined;\n return fromBody ?? c.req.query('agentId');\n}\n\nfunction hasEnabledAgent(cfg: Config, agentId: string): boolean {\n const normalized = normalizeAgentId(agentId);\n return cfg.agents.list.some((agent) => agent.enabled !== false && normalizeAgentId(agent.id) === normalized);\n}\n\nfunction resolveRouteScope(cfg: Config, requestedAgentId?: string): DreamingAgentScope {\n const agentId = normalizeAgentId(requestedAgentId || resolveDefaultAgentId(cfg));\n if (!hasEnabledAgent(cfg, agentId)) {\n throw new Error(`Agent not found: ${agentId}`);\n }\n return resolveDreamingAgentScope(cfg, agentId);\n}\n\nasync function readLockInfo(dreamingRoot: string): Promise<\n | { locked: false }\n | { locked: true; path: string; content: string; mtimeMs?: number }\n> {\n const lockPath = path.join(dreamingRoot, SHORT_TERM_PROMOTION_LOCK_RELATIVE);\n try {\n const [content, st] = await Promise.all([fs.readFile(lockPath, 'utf-8'), fs.stat(lockPath)]);\n return {\n locked: true,\n path: SHORT_TERM_PROMOTION_LOCK_RELATIVE,\n content: content.trim(),\n mtimeMs: st.mtimeMs,\n };\n } catch (err) {\n const code = (err as NodeJS.ErrnoException | undefined)?.code;\n if (code === 'ENOENT') return { locked: false };\n return { locked: true, path: SHORT_TERM_PROMOTION_LOCK_RELATIVE, content: 'unknown', mtimeMs: undefined };\n }\n}\n\nasync function readLastRun(\n dreamingRoot: string,\n): Promise<\n | { exists: false }\n | {\n exists: true;\n path: string;\n raw: unknown;\n record: DreamingDeepLastRun | null;\n parseError: string | null;\n }\n> {\n const fullPath = path.join(dreamingRoot, DREAMING_LAST_RUN_RELATIVE);\n try {\n const text = await fs.readFile(fullPath, 'utf-8');\n let raw: unknown;\n try {\n raw = JSON.parse(text) as unknown;\n } catch (parseErr) {\n return {\n exists: true,\n path: DREAMING_LAST_RUN_RELATIVE,\n raw: null,\n record: null,\n parseError: parseErr instanceof Error ? parseErr.message : String(parseErr),\n };\n }\n const record = parseDreamingLastRunFile(raw);\n return {\n exists: true,\n path: DREAMING_LAST_RUN_RELATIVE,\n raw,\n record,\n parseError: record ? null : 'Invalid or unsupported last-run.json (expected v2 deep record).',\n };\n } catch (err) {\n const code = (err as NodeJS.ErrnoException | undefined)?.code;\n if (code === 'ENOENT') return { exists: false };\n return {\n exists: true,\n path: DREAMING_LAST_RUN_RELATIVE,\n raw: null,\n record: null,\n parseError: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nasync function readPhaseLastRun(\n dreamingRoot: string,\n filename: string,\n): Promise<{ exists: false } | { exists: true; path: string; raw: unknown }> {\n const relPath = path.join(DREAMING_DIR_RELATIVE, filename);\n const fullPath = path.join(dreamingRoot, relPath);\n try {\n const text = await fs.readFile(fullPath, 'utf-8');\n const raw = JSON.parse(text) as unknown;\n return { exists: true, path: relPath, raw };\n } catch (err) {\n const code = (err as NodeJS.ErrnoException | undefined)?.code;\n if (code === 'ENOENT') return { exists: false };\n return { exists: false };\n }\n}\n\nfunction storeStats(store: DreamingStore): {\n version: number;\n updatedAt: string;\n entryCount: number;\n promotedCount: number;\n lastPromotedAt: string | null;\n} {\n const entries = Object.values(store.entries ?? {});\n const promoted = entries.filter((e) => typeof e.promotedAt === 'string' && e.promotedAt.trim());\n const lastPromotedAt = promoted\n .map((e) => e.promotedAt!)\n .sort((a, b) => (a < b ? 1 : a > b ? -1 : 0))[0];\n return {\n version: store.version,\n updatedAt: store.updatedAt,\n entryCount: entries.length,\n promotedCount: promoted.length,\n lastPromotedAt: lastPromotedAt ?? null,\n };\n}\n\nexport function registerDreamingRoutes(authenticated: Hono, deps: AuthenticatedRouteDeps): void {\n const { service } = deps;\n\n authenticated.get('/api/dreaming', async (c) => {\n const cfg = service.currentConfig as Config;\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, c.req.query('agentId'));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n const { store } = await loadDreamingStore({ dreamingRoot: scope.memoriesDir });\n const lock = await readLockInfo(scope.memoriesDir);\n\n // Read all three phase last-run files in parallel.\n const [lastRun, lightLastRun, remLastRun] = await Promise.all([\n readLastRun(scope.memoriesDir),\n readPhaseLastRun(scope.memoriesDir, 'last-run-light.json'),\n readPhaseLastRun(scope.memoriesDir, 'last-run-rem.json'),\n ]);\n\n return c.json({\n ok: true,\n payload: {\n agentId: scope.agentId,\n memory: scope.memory,\n workspaceDir: scope.workspaceDir,\n memoriesDir: scope.memoriesDir,\n config: scope.config,\n storePath: path.join(scope.memoriesDir, SHORT_TERM_RECALL_STORE_RELATIVE),\n store: storeStats(store),\n lock,\n lastRun,\n lightLastRun,\n remLastRun,\n },\n });\n });\n\n authenticated.get('/api/dreaming/preview', async (c) => {\n const cfg = service.currentConfig as Config;\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, c.req.query('agentId'));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n\n const rawLimit = c.req.query('limit');\n const limit = rawLimit ? Number(rawLimit) : 20;\n\n const preview = await previewDreamingDeepPromotion({\n workspaceDir: scope.workspaceDir,\n dreamingRoot: scope.memoriesDir,\n config: scope.config.deep,\n limit: Number.isFinite(limit) ? limit : 20,\n });\n\n return c.json({ ok: true, payload: preview });\n });\n\n authenticated.post('/api/dreaming/run', async (c) => {\n let body: unknown;\n try { body = await c.req.json(); } catch { body = {}; }\n const requestedPhase: DreamingPhaseId =\n isRecord(body) && typeof body.phase === 'string' && ['light', 'deep', 'rem'].includes(body.phase)\n ? (body.phase as DreamingPhaseId)\n : 'deep';\n\n const cfg = service.currentConfig as Config;\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, requestedAgentIdFrom(c, body));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n const dreaming = scope.config;\n if (!dreaming.enabled || !dreaming.phases[requestedPhase].enabled) {\n return c.json({\n ok: false,\n error: { message: `Dreaming ${requestedPhase} phase is disabled in config. Enable it first.` },\n }, 400);\n }\n\n try {\n service.emit('dreaming.phase.start', {\n agentId: scope.agentId,\n phase: requestedPhase,\n timestamp: new Date().toISOString(),\n });\n\n const result =\n requestedPhase === 'light'\n ? await runLightSweep({\n workspaceDir: scope.workspaceDir,\n dreamingRoot: scope.memoriesDir,\n config: dreaming.phases.light,\n })\n : requestedPhase === 'rem'\n ? await runRemPatterns({\n agentId: scope.agentId,\n workspaceDir: scope.workspaceDir,\n dreamingRoot: scope.memoriesDir,\n config: dreaming.phases.rem,\n sensitiveWritePolicy: scope.memory.privacy?.sensitiveWritePolicy,\n promotionWritePolicy: dreaming.promotionWritePolicy.decision,\n })\n : await runDreamingDeepPromotion({\n agentId: scope.agentId,\n workspaceDir: scope.workspaceDir,\n dreamingRoot: scope.memoriesDir,\n config: dreaming.phases.deep,\n sensitiveWritePolicy: scope.memory.privacy?.sensitiveWritePolicy,\n });\n\n service.emit('dreaming.phase.end', {\n agentId: scope.agentId,\n phase: requestedPhase,\n ok: true,\n timestamp: new Date().toISOString(),\n });\n\n return c.json({ ok: true, payload: { agentId: scope.agentId, phase: requestedPhase, result } });\n } catch (err) {\n const em = err instanceof Error ? err.message : String(err);\n service.emit('dreaming.phase.end', {\n agentId: scope.agentId,\n phase: requestedPhase,\n ok: false,\n error: em,\n timestamp: new Date().toISOString(),\n });\n return c.json({ ok: false, error: { message: em || 'Failed to trigger job' } }, 400);\n }\n });\n\n authenticated.post('/api/dreaming/action', async (c) => {\n const cfg = service.currentConfig as Config;\n\n let body: unknown;\n try {\n body = await c.req.json();\n } catch {\n body = {};\n }\n const action = isRecord(body) && typeof body.action === 'string' ? body.action.trim() : '';\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, requestedAgentIdFrom(c, body));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n\n if (action !== 'reset_store' && action !== 'clear_lock') {\n return c.json({ ok: false, error: { message: 'Invalid action' } }, 400);\n }\n\n if (action === 'reset_store') {\n await resetDreamingStore({ dreamingRoot: scope.memoriesDir });\n return c.json({\n ok: true,\n payload: { agentId: scope.agentId, reset: true, storePath: path.join(scope.memoriesDir, SHORT_TERM_RECALL_STORE_RELATIVE) },\n });\n }\n\n const lockPath = path.join(scope.memoriesDir, SHORT_TERM_PROMOTION_LOCK_RELATIVE);\n try {\n const cleared = await clearStaleDreamingLock(scope.memoriesDir);\n return c.json({\n ok: true,\n payload: { agentId: scope.agentId, cleared, lockPath },\n });\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 409);\n }\n });\n\n authenticated.get('/api/dreaming/events', async (c) => {\n const cfg = service.currentConfig as Config;\n let scope: DreamingAgentScope;\n try {\n scope = resolveRouteScope(cfg, c.req.query('agentId'));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return c.json({ ok: false, error: { message } }, 404);\n }\n\n const rawLimit = c.req.query('limit');\n const limit = rawLimit ? Math.min(Math.max(Number(rawLimit) || 50, 1), 200) : 50;\n\n const events = await readDream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