@geminilight/mindos 1.1.8 → 1.1.10
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/agent/agent-run-context.d.ts +8 -0
- package/dist/agent/agent-run-context.d.ts.map +1 -0
- package/dist/agent/agent-run-context.js +9 -0
- package/dist/agent/agent-run-context.js.map +1 -0
- package/dist/agent/capability-registry.d.ts +60 -0
- package/dist/agent/capability-registry.d.ts.map +1 -0
- package/dist/agent/capability-registry.js +323 -0
- package/dist/agent/capability-registry.js.map +1 -0
- package/dist/agent/file-write-lock.d.ts +22 -0
- package/dist/agent/file-write-lock.d.ts.map +1 -0
- package/dist/agent/file-write-lock.js +86 -0
- package/dist/agent/file-write-lock.js.map +1 -0
- package/dist/agent/global-state.d.ts +109 -0
- package/dist/agent/global-state.d.ts.map +1 -0
- package/dist/agent/global-state.js +118 -0
- package/dist/agent/global-state.js.map +1 -0
- package/dist/agent/index.d.ts +17 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +17 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/kb-extension.d.ts +38 -0
- package/dist/agent/kb-extension.d.ts.map +1 -0
- package/dist/agent/kb-extension.js +140 -0
- package/dist/agent/kb-extension.js.map +1 -0
- package/dist/agent/kb-tools.d.ts +158 -0
- package/dist/agent/kb-tools.d.ts.map +1 -0
- package/dist/agent/kb-tools.js +707 -0
- package/dist/agent/kb-tools.js.map +1 -0
- package/dist/agent/line-diff.d.ts +13 -0
- package/dist/agent/line-diff.d.ts.map +1 -0
- package/dist/agent/line-diff.js +66 -0
- package/dist/agent/line-diff.js.map +1 -0
- package/dist/agent/paragraph-extract.d.ts +25 -0
- package/dist/agent/paragraph-extract.d.ts.map +1 -0
- package/dist/agent/paragraph-extract.js +106 -0
- package/dist/agent/paragraph-extract.js.map +1 -0
- package/dist/agent/permission-policy.d.ts +37 -0
- package/dist/agent/permission-policy.d.ts.map +1 -0
- package/dist/agent/permission-policy.js +153 -0
- package/dist/agent/permission-policy.js.map +1 -0
- package/dist/agent/redaction.d.ts +3 -0
- package/dist/agent/redaction.d.ts.map +1 -0
- package/dist/agent/redaction.js +52 -0
- package/dist/agent/redaction.js.map +1 -0
- package/dist/agent/result-reducer.d.ts +36 -0
- package/dist/agent/result-reducer.d.ts.map +1 -0
- package/dist/agent/result-reducer.js +101 -0
- package/dist/agent/result-reducer.js.map +1 -0
- package/dist/agent/run-cancellation.d.ts +13 -0
- package/dist/agent/run-cancellation.d.ts.map +1 -0
- package/dist/agent/run-cancellation.js +97 -0
- package/dist/agent/run-cancellation.js.map +1 -0
- package/dist/agent/run-ledger-types.d.ts +197 -0
- package/dist/agent/run-ledger-types.d.ts.map +1 -0
- package/dist/agent/run-ledger-types.js +9 -0
- package/dist/agent/run-ledger-types.js.map +1 -0
- package/dist/agent/run-ledger.d.ts +44 -0
- package/dist/agent/run-ledger.d.ts.map +1 -0
- package/dist/agent/run-ledger.js +814 -0
- package/dist/agent/run-ledger.js.map +1 -0
- package/dist/agent/run-timeline-events.d.ts +3 -0
- package/dist/agent/run-timeline-events.d.ts.map +1 -0
- package/dist/agent/run-timeline-events.js +239 -0
- package/dist/agent/run-timeline-events.js.map +1 -0
- package/dist/agent/runtime-permission-bridge.d.ts +34 -0
- package/dist/agent/runtime-permission-bridge.d.ts.map +1 -0
- package/dist/agent/runtime-permission-bridge.js +284 -0
- package/dist/agent/runtime-permission-bridge.js.map +1 -0
- package/dist/agent/stream-consumer.d.ts +65 -0
- package/dist/agent/stream-consumer.d.ts.map +1 -0
- package/dist/agent/stream-consumer.js +664 -0
- package/dist/agent/stream-consumer.js.map +1 -0
- package/dist/agent/stream-message-types.d.ts +138 -0
- package/dist/agent/stream-message-types.d.ts.map +1 -0
- package/dist/agent/stream-message-types.js +14 -0
- package/dist/agent/stream-message-types.js.map +1 -0
- package/dist/agent/subagent-ledger-extension.d.ts +22 -0
- package/dist/agent/subagent-ledger-extension.d.ts.map +1 -0
- package/dist/agent/subagent-ledger-extension.js +533 -0
- package/dist/agent/subagent-ledger-extension.js.map +1 -0
- package/dist/agent/subagent-orchestrator.d.ts +62 -0
- package/dist/agent/subagent-orchestrator.d.ts.map +1 -0
- package/dist/agent/subagent-orchestrator.js +350 -0
- package/dist/agent/subagent-orchestrator.js.map +1 -0
- package/dist/agent/user-question-bridge.d.ts +90 -0
- package/dist/agent/user-question-bridge.d.ts.map +1 -0
- package/dist/agent/user-question-bridge.js +260 -0
- package/dist/agent/user-question-bridge.js.map +1 -0
- package/dist/agent-runtime/capabilities.d.ts +10 -0
- package/dist/agent-runtime/capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/capabilities.js +100 -0
- package/dist/agent-runtime/capabilities.js.map +1 -0
- package/dist/agent-runtime/child-process.d.ts +21 -0
- package/dist/agent-runtime/child-process.d.ts.map +1 -0
- package/dist/agent-runtime/child-process.js +29 -0
- package/dist/agent-runtime/child-process.js.map +1 -0
- package/dist/agent-runtime/claude-code-cli.d.ts.map +1 -1
- package/dist/agent-runtime/claude-code-cli.js +31 -4
- package/dist/agent-runtime/claude-code-cli.js.map +1 -1
- package/dist/agent-runtime/claude-code-sdk.d.ts.map +1 -1
- package/dist/agent-runtime/claude-code-sdk.js +22 -5
- package/dist/agent-runtime/claude-code-sdk.js.map +1 -1
- package/dist/agent-runtime/codex-app-server.d.ts.map +1 -1
- package/dist/agent-runtime/codex-app-server.js +27 -3
- package/dist/agent-runtime/codex-app-server.js.map +1 -1
- package/dist/agent-runtime/codex-env.d.ts +2 -1
- package/dist/agent-runtime/codex-env.d.ts.map +1 -1
- package/dist/agent-runtime/codex-env.js +14 -2
- package/dist/agent-runtime/codex-env.js.map +1 -1
- package/dist/agent-runtime/descriptors.d.ts +19 -0
- package/dist/agent-runtime/descriptors.d.ts.map +1 -0
- package/dist/agent-runtime/descriptors.js +143 -0
- package/dist/agent-runtime/descriptors.js.map +1 -0
- package/dist/agent-runtime/detection.d.ts +15 -0
- package/dist/agent-runtime/detection.d.ts.map +1 -0
- package/dist/agent-runtime/detection.js +124 -0
- package/dist/agent-runtime/detection.js.map +1 -0
- package/dist/agent-runtime/index.d.ts +2 -0
- package/dist/agent-runtime/index.d.ts.map +1 -1
- package/dist/agent-runtime/index.js +2 -0
- package/dist/agent-runtime/index.js.map +1 -1
- package/dist/agent-runtime/registry.d.ts +152 -0
- package/dist/agent-runtime/registry.d.ts.map +1 -0
- package/dist/agent-runtime/registry.js +84 -0
- package/dist/agent-runtime/registry.js.map +1 -0
- package/dist/agent-runtime/run.d.ts +12 -0
- package/dist/agent-runtime/run.d.ts.map +1 -1
- package/dist/agent-runtime/run.js +16 -1
- package/dist/agent-runtime/run.js.map +1 -1
- package/dist/foundation/config/schema.d.ts +1 -1
- package/dist/foundation/mind-root/index.d.ts +5 -0
- package/dist/foundation/mind-root/index.d.ts.map +1 -0
- package/dist/foundation/mind-root/index.js +67 -0
- package/dist/foundation/mind-root/index.js.map +1 -0
- package/dist/foundation/native-import.d.ts +22 -0
- package/dist/foundation/native-import.d.ts.map +1 -0
- package/dist/foundation/native-import.js +22 -0
- package/dist/foundation/native-import.js.map +1 -0
- package/dist/foundation.d.ts +1 -0
- package/dist/foundation.d.ts.map +1 -1
- package/dist/foundation.js +1 -0
- package/dist/foundation.js.map +1 -1
- package/dist/protocols/mcp-server/index.cjs +24 -23
- package/dist/protocols/mcp-server/index.js +45 -0
- package/dist/protocols/mcp-server/index.js.map +1 -1
- package/dist/server/contract.d.ts.map +1 -1
- package/dist/server/contract.js +1 -0
- package/dist/server/contract.js.map +1 -1
- package/dist/server/handlers/agent-runtimes.d.ts +3 -125
- package/dist/server/handlers/agent-runtimes.d.ts.map +1 -1
- package/dist/server/handlers/agent-runtimes.js +6 -414
- package/dist/server/handlers/agent-runtimes.js.map +1 -1
- package/dist/server/handlers/assistants.d.ts.map +1 -1
- package/dist/server/handlers/assistants.js +1 -0
- package/dist/server/handlers/assistants.js.map +1 -1
- package/dist/server/handlers/mcp-agents.d.ts +8 -0
- package/dist/server/handlers/mcp-agents.d.ts.map +1 -1
- package/dist/server/handlers/mcp-agents.js +39 -0
- package/dist/server/handlers/mcp-agents.js.map +1 -1
- package/dist/server/handlers/mcp-install.d.ts +0 -6
- package/dist/server/handlers/mcp-install.d.ts.map +1 -1
- package/dist/server/handlers/mcp-install.js +1 -31
- package/dist/server/handlers/mcp-install.js.map +1 -1
- package/dist/server/handlers/skill-links.d.ts +130 -0
- package/dist/server/handlers/skill-links.d.ts.map +1 -0
- package/dist/server/handlers/skill-links.js +534 -0
- package/dist/server/handlers/skill-links.js.map +1 -0
- package/dist/server/handlers/skills.d.ts +12 -1
- package/dist/server/handlers/skills.d.ts.map +1 -1
- package/dist/server/handlers/skills.js +48 -5
- package/dist/server/handlers/skills.js.map +1 -1
- package/dist/server/http.d.ts.map +1 -1
- package/dist/server/http.js +16 -3
- package/dist/server/http.js.map +1 -1
- package/dist/server/index.d.ts +3 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/route-ownership.d.ts.map +1 -1
- package/dist/server/route-ownership.js +3 -0
- package/dist/server/route-ownership.js.map +1 -1
- package/dist/server/runtime.d.ts.map +1 -1
- package/dist/server/runtime.js +8 -4
- package/dist/server/runtime.js.map +1 -1
- package/dist/session/index.d.ts +43 -2
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +42 -5
- package/dist/session/index.js.map +1 -1
- package/dist/session/pi-coding-agent-runtime.d.ts +4 -2
- package/dist/session/pi-coding-agent-runtime.d.ts.map +1 -1
- package/dist/session/pi-coding-agent-runtime.js +18 -11
- package/dist/session/pi-coding-agent-runtime.js.map +1 -1
- package/package.json +15 -9
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-global state registry for the agent core.
|
|
3
|
+
*
|
|
4
|
+
* One Node process can load more than one copy of these modules: the Next.js
|
|
5
|
+
* server bundle inlines a copy while API helpers resolve the node_modules
|
|
6
|
+
* copy, web shims re-export the core subpath, and a duplicated install can
|
|
7
|
+
* physically ship two files. Module-level state would silently fork per copy
|
|
8
|
+
* — a lock taken through one copy would be invisible to the other. Keying
|
|
9
|
+
* the state through `Symbol.for` (the realm-wide symbol registry) makes
|
|
10
|
+
* every copy share a single instance.
|
|
11
|
+
*
|
|
12
|
+
* All agent-domain `Symbol.for('mindos.*')` keys live in this file
|
|
13
|
+
* (spec-agent-core-consolidation 关键设计决策). Every key documents why
|
|
14
|
+
* cross-copy sharing is required; adding a key requires review.
|
|
15
|
+
*/
|
|
16
|
+
/** Resolve (or lazily create) the shared value for a registered key. */
|
|
17
|
+
export declare function getProcessGlobal<T>(key: symbol, create: () => T): T;
|
|
18
|
+
/** Drop the shared value so the next access re-creates it (test reloads). */
|
|
19
|
+
export declare function deleteProcessGlobal(key: symbol): void;
|
|
20
|
+
/**
|
|
21
|
+
* File write lock map (file-write-lock.ts). Two agent runs writing the same
|
|
22
|
+
* note must conflict even when their call paths import different module
|
|
23
|
+
* copies; a forked lock map would let both writers proceed.
|
|
24
|
+
*/
|
|
25
|
+
export declare const AGENT_FILE_WRITE_LOCKS_KEY: unique symbol;
|
|
26
|
+
/**
|
|
27
|
+
* In-memory run ledger store (run-ledger.ts). The ledger is hydrated from
|
|
28
|
+
* disk once per process; a forked store would double-hydrate and the two
|
|
29
|
+
* copies would diverge as runs progress (UI reads one, runtime writes the
|
|
30
|
+
* other).
|
|
31
|
+
*/
|
|
32
|
+
export declare const AGENT_RUN_LEDGER_STORE_KEY: unique symbol;
|
|
33
|
+
/**
|
|
34
|
+
* Realtime ledger event subscribers (run-ledger.ts). SSE routes subscribe
|
|
35
|
+
* through the web shim while runtimes emit through the core path — both must
|
|
36
|
+
* land in one subscriber set or live updates silently stop.
|
|
37
|
+
*/
|
|
38
|
+
export declare const AGENT_RUN_LEDGER_SUBSCRIBERS_KEY: unique symbol;
|
|
39
|
+
/**
|
|
40
|
+
* Per-process ledger shard identity (run-ledger.ts). Every module copy must
|
|
41
|
+
* agree on the one `agent-run-ledger.<pid>-<startTs>.jsonl` file this
|
|
42
|
+
* process owns; two copies computing their own start timestamp would write
|
|
43
|
+
* two shards for one process and break the single-writer-per-shard
|
|
44
|
+
* invariant.
|
|
45
|
+
*/
|
|
46
|
+
export declare const AGENT_RUN_LEDGER_SHARD_KEY: unique symbol;
|
|
47
|
+
/**
|
|
48
|
+
* Run cancellation handler map (run-cancellation.ts). The cancel API route
|
|
49
|
+
* resolves handlers registered by the streaming route; a forked map means
|
|
50
|
+
* cancellation requests find no handler and runs become unkillable.
|
|
51
|
+
*/
|
|
52
|
+
export declare const AGENT_RUN_CANCEL_HANDLERS_KEY: unique symbol;
|
|
53
|
+
/**
|
|
54
|
+
* Native runtime permission bridge state (runtime-permission-bridge.ts).
|
|
55
|
+
* Pending permission requests are created inside the runtime stream and
|
|
56
|
+
* resolved by a separate HTTP route; both sides must see one pending map.
|
|
57
|
+
*/
|
|
58
|
+
export declare const RUNTIME_PERMISSION_BRIDGE_KEY: unique symbol;
|
|
59
|
+
/**
|
|
60
|
+
* AskUserQuestion bridge state (user-question-bridge.ts). Same shape as the
|
|
61
|
+
* permission bridge: questions are raised mid-stream and answered via a
|
|
62
|
+
* separate route.
|
|
63
|
+
*/
|
|
64
|
+
export declare const ASK_USER_QUESTION_BRIDGE_KEY: unique symbol;
|
|
65
|
+
/**
|
|
66
|
+
* Request-scoped KB permission policy storage (kb-extension.ts). The pi
|
|
67
|
+
* DefaultResourceLoader imports the host's kb-extension entry file in its own
|
|
68
|
+
* module graph, so the AsyncLocalStorage written by the /api/ask route and
|
|
69
|
+
* the one read during extension reload() only meet through this key. The key
|
|
70
|
+
* string predates the consolidation — keep it stable.
|
|
71
|
+
*/
|
|
72
|
+
export declare const KB_PERMISSION_POLICY_STORAGE_KEY: unique symbol;
|
|
73
|
+
/**
|
|
74
|
+
* Module-level fallback KB policy (kb-extension.ts) used outside a scoped
|
|
75
|
+
* runWithKbPermissionPolicy() call (setKbMode/setKbPermissionPolicy). Same
|
|
76
|
+
* dual-module-graph problem as the storage above: a fallback set through the
|
|
77
|
+
* web module copy must be visible to the loader-imported copy.
|
|
78
|
+
*/
|
|
79
|
+
export declare const KB_PERMISSION_POLICY_FALLBACK_KEY: unique symbol;
|
|
80
|
+
/**
|
|
81
|
+
* Host toolkit for the KB extension (kb-extension.ts). The pi loader imports
|
|
82
|
+
* the host's kb-extension entry file with jiti, which resolves no host path
|
|
83
|
+
* aliases (`@/...`), so the entry cannot import the host's tool registry or
|
|
84
|
+
* audit log directly — any webpack-land import in its module graph makes the
|
|
85
|
+
* whole entry fail to load and silently drops every KB tool. The host
|
|
86
|
+
* registers its toolkit here (webpack module graph) and the entry reads it
|
|
87
|
+
* back (jiti module graph).
|
|
88
|
+
*/
|
|
89
|
+
export declare const KB_EXTENSION_HOST_KEY: unique symbol;
|
|
90
|
+
/**
|
|
91
|
+
* Buffered early subagent async completions (subagent-ledger-extension.ts).
|
|
92
|
+
* A fast async subagent can emit its completion event before the tool
|
|
93
|
+
* wrapper stores the asyncId on the ledger record; the payload is buffered
|
|
94
|
+
* here until the wrapper registers the run. The event handler lives in the
|
|
95
|
+
* pi loader's module graph while the wrapper may run through the host's copy
|
|
96
|
+
* — both must share one buffer or early completions are lost. The key string
|
|
97
|
+
* predates the consolidation — keep it stable.
|
|
98
|
+
*/
|
|
99
|
+
export declare const SUBAGENT_EARLY_ASYNC_COMPLETIONS_KEY: unique symbol;
|
|
100
|
+
/**
|
|
101
|
+
* Unsubscribe handle for the subagent async-complete event listener
|
|
102
|
+
* (subagent-ledger-extension.ts). Extension reload() re-executes the entry
|
|
103
|
+
* module — possibly a different copy than the one that subscribed — so the
|
|
104
|
+
* previous listener can only be cleaned up through a shared slot. Replaces
|
|
105
|
+
* the pre-consolidation `__mindosSubagentLedgerEventUnsubscribe` string key
|
|
106
|
+
* on globalThis.
|
|
107
|
+
*/
|
|
108
|
+
export declare const SUBAGENT_LEDGER_EVENT_UNSUBSCRIBE_KEY: unique symbol;
|
|
109
|
+
//# sourceMappingURL=global-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-state.d.ts","sourceRoot":"","sources":["../../src/agent/global-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAMnE;AAED,6EAA6E;AAC7E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGrD;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,eAA2C,CAAC;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,eAAsC,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,eAAkD,CAAC;AAEhG;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,eAA4C,CAAC;AAEpF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,eAAqD,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,eAA+C,CAAC;AAE1F;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,eAA6C,CAAC;AAEvF;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,eAAiD,CAAC;AAE/F;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,eAAkD,CAAC;AAEjG;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,eAAuC,CAAC;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,eAAqD,CAAC;AAEvG;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,eAAsD,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-global state registry for the agent core.
|
|
3
|
+
*
|
|
4
|
+
* One Node process can load more than one copy of these modules: the Next.js
|
|
5
|
+
* server bundle inlines a copy while API helpers resolve the node_modules
|
|
6
|
+
* copy, web shims re-export the core subpath, and a duplicated install can
|
|
7
|
+
* physically ship two files. Module-level state would silently fork per copy
|
|
8
|
+
* — a lock taken through one copy would be invisible to the other. Keying
|
|
9
|
+
* the state through `Symbol.for` (the realm-wide symbol registry) makes
|
|
10
|
+
* every copy share a single instance.
|
|
11
|
+
*
|
|
12
|
+
* All agent-domain `Symbol.for('mindos.*')` keys live in this file
|
|
13
|
+
* (spec-agent-core-consolidation 关键设计决策). Every key documents why
|
|
14
|
+
* cross-copy sharing is required; adding a key requires review.
|
|
15
|
+
*/
|
|
16
|
+
/** Resolve (or lazily create) the shared value for a registered key. */
|
|
17
|
+
export function getProcessGlobal(key, create) {
|
|
18
|
+
const root = globalThis;
|
|
19
|
+
if (root[key] === undefined) {
|
|
20
|
+
root[key] = create();
|
|
21
|
+
}
|
|
22
|
+
return root[key];
|
|
23
|
+
}
|
|
24
|
+
/** Drop the shared value so the next access re-creates it (test reloads). */
|
|
25
|
+
export function deleteProcessGlobal(key) {
|
|
26
|
+
const root = globalThis;
|
|
27
|
+
delete root[key];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* File write lock map (file-write-lock.ts). Two agent runs writing the same
|
|
31
|
+
* note must conflict even when their call paths import different module
|
|
32
|
+
* copies; a forked lock map would let both writers proceed.
|
|
33
|
+
*/
|
|
34
|
+
export const AGENT_FILE_WRITE_LOCKS_KEY = Symbol.for('mindos.agentFileWriteLocks');
|
|
35
|
+
/**
|
|
36
|
+
* In-memory run ledger store (run-ledger.ts). The ledger is hydrated from
|
|
37
|
+
* disk once per process; a forked store would double-hydrate and the two
|
|
38
|
+
* copies would diverge as runs progress (UI reads one, runtime writes the
|
|
39
|
+
* other).
|
|
40
|
+
*/
|
|
41
|
+
export const AGENT_RUN_LEDGER_STORE_KEY = Symbol.for('mindos.agentRunLedger');
|
|
42
|
+
/**
|
|
43
|
+
* Realtime ledger event subscribers (run-ledger.ts). SSE routes subscribe
|
|
44
|
+
* through the web shim while runtimes emit through the core path — both must
|
|
45
|
+
* land in one subscriber set or live updates silently stop.
|
|
46
|
+
*/
|
|
47
|
+
export const AGENT_RUN_LEDGER_SUBSCRIBERS_KEY = Symbol.for('mindos.agentRunLedger.subscribers');
|
|
48
|
+
/**
|
|
49
|
+
* Per-process ledger shard identity (run-ledger.ts). Every module copy must
|
|
50
|
+
* agree on the one `agent-run-ledger.<pid>-<startTs>.jsonl` file this
|
|
51
|
+
* process owns; two copies computing their own start timestamp would write
|
|
52
|
+
* two shards for one process and break the single-writer-per-shard
|
|
53
|
+
* invariant.
|
|
54
|
+
*/
|
|
55
|
+
export const AGENT_RUN_LEDGER_SHARD_KEY = Symbol.for('mindos.agentRunLedger.shard');
|
|
56
|
+
/**
|
|
57
|
+
* Run cancellation handler map (run-cancellation.ts). The cancel API route
|
|
58
|
+
* resolves handlers registered by the streaming route; a forked map means
|
|
59
|
+
* cancellation requests find no handler and runs become unkillable.
|
|
60
|
+
*/
|
|
61
|
+
export const AGENT_RUN_CANCEL_HANDLERS_KEY = Symbol.for('mindos.agentRunCancellation.handlers');
|
|
62
|
+
/**
|
|
63
|
+
* Native runtime permission bridge state (runtime-permission-bridge.ts).
|
|
64
|
+
* Pending permission requests are created inside the runtime stream and
|
|
65
|
+
* resolved by a separate HTTP route; both sides must see one pending map.
|
|
66
|
+
*/
|
|
67
|
+
export const RUNTIME_PERMISSION_BRIDGE_KEY = Symbol.for('mindos.runtimePermissionBridge');
|
|
68
|
+
/**
|
|
69
|
+
* AskUserQuestion bridge state (user-question-bridge.ts). Same shape as the
|
|
70
|
+
* permission bridge: questions are raised mid-stream and answered via a
|
|
71
|
+
* separate route.
|
|
72
|
+
*/
|
|
73
|
+
export const ASK_USER_QUESTION_BRIDGE_KEY = Symbol.for('mindos.askUserQuestionBridge');
|
|
74
|
+
/**
|
|
75
|
+
* Request-scoped KB permission policy storage (kb-extension.ts). The pi
|
|
76
|
+
* DefaultResourceLoader imports the host's kb-extension entry file in its own
|
|
77
|
+
* module graph, so the AsyncLocalStorage written by the /api/ask route and
|
|
78
|
+
* the one read during extension reload() only meet through this key. The key
|
|
79
|
+
* string predates the consolidation — keep it stable.
|
|
80
|
+
*/
|
|
81
|
+
export const KB_PERMISSION_POLICY_STORAGE_KEY = Symbol.for('mindos.kbPermissionPolicyStorage');
|
|
82
|
+
/**
|
|
83
|
+
* Module-level fallback KB policy (kb-extension.ts) used outside a scoped
|
|
84
|
+
* runWithKbPermissionPolicy() call (setKbMode/setKbPermissionPolicy). Same
|
|
85
|
+
* dual-module-graph problem as the storage above: a fallback set through the
|
|
86
|
+
* web module copy must be visible to the loader-imported copy.
|
|
87
|
+
*/
|
|
88
|
+
export const KB_PERMISSION_POLICY_FALLBACK_KEY = Symbol.for('mindos.kbPermissionPolicyFallback');
|
|
89
|
+
/**
|
|
90
|
+
* Host toolkit for the KB extension (kb-extension.ts). The pi loader imports
|
|
91
|
+
* the host's kb-extension entry file with jiti, which resolves no host path
|
|
92
|
+
* aliases (`@/...`), so the entry cannot import the host's tool registry or
|
|
93
|
+
* audit log directly — any webpack-land import in its module graph makes the
|
|
94
|
+
* whole entry fail to load and silently drops every KB tool. The host
|
|
95
|
+
* registers its toolkit here (webpack module graph) and the entry reads it
|
|
96
|
+
* back (jiti module graph).
|
|
97
|
+
*/
|
|
98
|
+
export const KB_EXTENSION_HOST_KEY = Symbol.for('mindos.kbExtensionHost');
|
|
99
|
+
/**
|
|
100
|
+
* Buffered early subagent async completions (subagent-ledger-extension.ts).
|
|
101
|
+
* A fast async subagent can emit its completion event before the tool
|
|
102
|
+
* wrapper stores the asyncId on the ledger record; the payload is buffered
|
|
103
|
+
* here until the wrapper registers the run. The event handler lives in the
|
|
104
|
+
* pi loader's module graph while the wrapper may run through the host's copy
|
|
105
|
+
* — both must share one buffer or early completions are lost. The key string
|
|
106
|
+
* predates the consolidation — keep it stable.
|
|
107
|
+
*/
|
|
108
|
+
export const SUBAGENT_EARLY_ASYNC_COMPLETIONS_KEY = Symbol.for('mindos.subagentEarlyAsyncCompletions');
|
|
109
|
+
/**
|
|
110
|
+
* Unsubscribe handle for the subagent async-complete event listener
|
|
111
|
+
* (subagent-ledger-extension.ts). Extension reload() re-executes the entry
|
|
112
|
+
* module — possibly a different copy than the one that subscribed — so the
|
|
113
|
+
* previous listener can only be cleaned up through a shared slot. Replaces
|
|
114
|
+
* the pre-consolidation `__mindosSubagentLedgerEventUnsubscribe` string key
|
|
115
|
+
* on globalThis.
|
|
116
|
+
*/
|
|
117
|
+
export const SUBAGENT_LEDGER_EVENT_UNSUBSCRIBE_KEY = Symbol.for('mindos.subagentLedgerEventUnsubscribe');
|
|
118
|
+
//# sourceMappingURL=global-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-state.js","sourceRoot":"","sources":["../../src/agent/global-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,wEAAwE;AACxE,MAAM,UAAU,gBAAgB,CAAI,GAAW,EAAE,MAAe;IAC9D,MAAM,IAAI,GAAG,UAAyD,CAAC;IACvE,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAM,CAAC;AACxB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,IAAI,GAAG,UAAyD,CAAC;IACvE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAEhG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAEpF;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AAEhG;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAE1F;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAEvF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAEjG;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AAE1E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AAEvG;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,MAAM,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC"}
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -7,4 +7,21 @@ export type MindosAgentDescriptor = {
|
|
|
7
7
|
export declare function defineMindosAgent(descriptor: MindosAgentDescriptor): MindosAgentDescriptor;
|
|
8
8
|
export { AGENT_SYSTEM_PROMPT, CHAT_SYSTEM_PROMPT, ORGANIZE_SYSTEM_PROMPT, } from './prompts.js';
|
|
9
9
|
export { buildMindosAskSystemPrompt, compactMindosPromptForTokenBudget, formatMindosAskTimeContext, type BuildMindosAskSystemPromptInput, type BuildMindosAskSystemPromptServices, type CompactMindosPromptOptions, type MindosAskActiveRecallConfig, type MindosAskInitializationContext, type MindosAskPromptMessage, type MindosKnowledgeFile, } from './prompt-builder.js';
|
|
10
|
+
export * from './run-ledger-types.js';
|
|
11
|
+
export * from './agent-run-context.js';
|
|
12
|
+
export * from './file-write-lock.js';
|
|
13
|
+
export * from './result-reducer.js';
|
|
14
|
+
export * from './permission-policy.js';
|
|
15
|
+
export * from './global-state.js';
|
|
16
|
+
export * from './redaction.js';
|
|
17
|
+
export * from './run-ledger.js';
|
|
18
|
+
export * from './run-timeline-events.js';
|
|
19
|
+
export * from './run-cancellation.js';
|
|
20
|
+
export * from './runtime-permission-bridge.js';
|
|
21
|
+
export * from './user-question-bridge.js';
|
|
22
|
+
export * from './line-diff.js';
|
|
23
|
+
export * from './paragraph-extract.js';
|
|
24
|
+
export * from './kb-tools.js';
|
|
25
|
+
export * from './kb-extension.js';
|
|
26
|
+
export * from './capability-registry.js';
|
|
10
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC;CACrD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,qBAAqB,GAAG,qBAAqB,CAK1F;AAED,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,0BAA0B,EAC1B,iCAAiC,EACjC,0BAA0B,EAC1B,KAAK,+BAA+B,EAC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C9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC"}
|
package/dist/agent/index.js
CHANGED
|
@@ -9,4 +9,21 @@ export function defineMindosAgent(descriptor) {
|
|
|
9
9
|
}
|
|
10
10
|
export { AGENT_SYSTEM_PROMPT, CHAT_SYSTEM_PROMPT, ORGANIZE_SYSTEM_PROMPT, } from './prompts.js';
|
|
11
11
|
export { buildMindosAskSystemPrompt, compactMindosPromptForTokenBudget, formatMindosAskTimeContext, } from './prompt-builder.js';
|
|
12
|
+
export * from './run-ledger-types.js';
|
|
13
|
+
export * from './agent-run-context.js';
|
|
14
|
+
export * from './file-write-lock.js';
|
|
15
|
+
export * from './result-reducer.js';
|
|
16
|
+
export * from './permission-policy.js';
|
|
17
|
+
export * from './global-state.js';
|
|
18
|
+
export * from './redaction.js';
|
|
19
|
+
export * from './run-ledger.js';
|
|
20
|
+
export * from './run-timeline-events.js';
|
|
21
|
+
export * from './run-cancellation.js';
|
|
22
|
+
export * from './runtime-permission-bridge.js';
|
|
23
|
+
export * from './user-question-bridge.js';
|
|
24
|
+
export * from './line-diff.js';
|
|
25
|
+
export * from './paragraph-extract.js';
|
|
26
|
+
export * from './kb-tools.js';
|
|
27
|
+
export * from './kb-extension.js';
|
|
28
|
+
export * from './capability-registry.js';
|
|
12
29
|
//# sourceMappingURL=index.js.map
|
package/dist/agent/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,iBAAiB,CAAC,UAAiC;IACjE,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACpE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC;IAC3F,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,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import { type MindosAgentPermissionPolicy } from './permission-policy.js';
|
|
3
|
+
import { type MindosAgentTool } from './kb-tools.js';
|
|
4
|
+
export type KbMode = 'agent' | 'chat' | 'organize';
|
|
5
|
+
/** Run fn with a request-scoped policy; the kb extension reads it during reload(). */
|
|
6
|
+
export declare function runWithKbPermissionPolicy<T>(policy: MindosAgentPermissionPolicy, fn: () => T): T;
|
|
7
|
+
/** Set the mode before resourceLoader.reload(). Determines which tools get registered. */
|
|
8
|
+
export declare function setKbMode(mode: KbMode): void;
|
|
9
|
+
export declare function setKbPermissionPolicy(policy: MindosAgentPermissionPolicy): void;
|
|
10
|
+
/** The policy the extension will register tools for: request-scoped, else fallback. */
|
|
11
|
+
export declare function getEffectiveKbPermissionPolicy(): MindosAgentPermissionPolicy;
|
|
12
|
+
export interface MindosKbAuditEntry {
|
|
13
|
+
ts: string;
|
|
14
|
+
tool: string;
|
|
15
|
+
params: Record<string, unknown>;
|
|
16
|
+
result: 'ok' | 'error';
|
|
17
|
+
message?: string;
|
|
18
|
+
durationMs?: number;
|
|
19
|
+
agentName?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface MindosKbExtensionHost {
|
|
22
|
+
/** Toolkit lookup for the effective policy — typically MindosKbToolkit.getToolsForPolicy. */
|
|
23
|
+
getToolsForPolicy(policy: MindosAgentPermissionPolicy): MindosAgentTool[];
|
|
24
|
+
/** Audit sink for executed tool calls. Write path is a host concern; must never throw. */
|
|
25
|
+
logAgentOp?(entry: MindosKbAuditEntry): void;
|
|
26
|
+
}
|
|
27
|
+
export declare function createMindosKbExtension(host: MindosKbExtensionHost): (pi: ExtensionAPI) => void;
|
|
28
|
+
/** Register the host toolkit. Must run before resourceLoader.reload(). Idempotent. */
|
|
29
|
+
export declare function registerMindosKbExtensionHost(host: MindosKbExtensionHost): void;
|
|
30
|
+
/** The toolkit registered by the host runtime, if any. */
|
|
31
|
+
export declare function getMindosKbExtensionHost(): MindosKbExtensionHost | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Extension factory for host entry files: resolves the host toolkit from the
|
|
34
|
+
* registered slot at execution time, so the entry file's own import graph
|
|
35
|
+
* stays free of host modules (jiti-loadable).
|
|
36
|
+
*/
|
|
37
|
+
export declare function createMindosKbExtensionFromRegisteredHost(): (pi: ExtensionAPI) => void;
|
|
38
|
+
//# sourceMappingURL=kb-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kb-extension.d.ts","sourceRoot":"","sources":["../../src/agent/kb-extension.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,iCAAiC,CAAC;AAIpF,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAIlE,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;AAgBnD,sFAAsF;AACtF,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,MAAM,EAAE,2BAA2B,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEhG;AAED,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,GAAG,IAAI,CAE/E;AAED,uFAAuF;AACvF,wBAAgB,8BAA8B,IAAI,2BAA2B,CAE5E;AAID,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAqBD,MAAM,WAAW,qBAAqB;IACpC,6FAA6F;IAC7F,iBAAiB,CAAC,MAAM,EAAE,2BAA2B,GAAG,eAAe,EAAE,CAAC;IAC1E,0FAA0F;IAC1F,UAAU,CAAC,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC9C;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,qBAAqB,GAAG,CAAC,EAAE,EAAE,YAAY,KAAK,IAAI,CAwD/F;AAiBD,sFAAsF;AACtF,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAE/E;AAED,0DAA0D;AAC1D,wBAAgB,wBAAwB,IAAI,qBAAqB,GAAG,SAAS,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,yCAAyC,IAAI,CAAC,EAAE,EAAE,YAAY,KAAK,IAAI,CAYtF"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Sunk from packages/web/lib/agent/kb-extension.ts (Wave 3, spec-agent-core-consolidation).
|
|
2
|
+
//
|
|
3
|
+
// Knowledge Base Extension — registers the MindOS KB tools via the Pi
|
|
4
|
+
// Extension API, wrapping them with write-protection and audit logging.
|
|
5
|
+
// Hosts keep a real extension entry file (the pi DefaultResourceLoader loads
|
|
6
|
+
// it by file path) that wires their toolkit into createMindosKbExtension().
|
|
7
|
+
//
|
|
8
|
+
// Mode-based filtering (chat/organize/agent) is controlled by
|
|
9
|
+
// runWithKbPermissionPolicy() (request-scoped) or setKbMode()/
|
|
10
|
+
// setKbPermissionPolicy() (process fallback), evaluated at reload() time.
|
|
11
|
+
//
|
|
12
|
+
// All policy state lives behind Symbol.for keys (global-state.ts): the pi
|
|
13
|
+
// loader imports the host's extension entry in its own module graph, so
|
|
14
|
+
// module-level state here would fork between the route's copy and the
|
|
15
|
+
// loader's copy.
|
|
16
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
17
|
+
import { assertNotProtected } from '../foundation/security/index.js';
|
|
18
|
+
import { createMindosAgentPermissionPolicy, } from './permission-policy.js';
|
|
19
|
+
import { getProcessGlobal, KB_EXTENSION_HOST_KEY, KB_PERMISSION_POLICY_FALLBACK_KEY, KB_PERMISSION_POLICY_STORAGE_KEY, } from './global-state.js';
|
|
20
|
+
import { WRITE_TOOLS } from './kb-tools.js';
|
|
21
|
+
function getPolicyStorage() {
|
|
22
|
+
return getProcessGlobal(KB_PERMISSION_POLICY_STORAGE_KEY, () => new AsyncLocalStorage());
|
|
23
|
+
}
|
|
24
|
+
function getPolicyFallback() {
|
|
25
|
+
return getProcessGlobal(KB_PERMISSION_POLICY_FALLBACK_KEY, () => ({ policy: createMindosAgentPermissionPolicy('agent') }));
|
|
26
|
+
}
|
|
27
|
+
/** Run fn with a request-scoped policy; the kb extension reads it during reload(). */
|
|
28
|
+
export function runWithKbPermissionPolicy(policy, fn) {
|
|
29
|
+
return getPolicyStorage().run(policy, fn);
|
|
30
|
+
}
|
|
31
|
+
/** Set the mode before resourceLoader.reload(). Determines which tools get registered. */
|
|
32
|
+
export function setKbMode(mode) {
|
|
33
|
+
getPolicyFallback().policy = createMindosAgentPermissionPolicy(mode);
|
|
34
|
+
}
|
|
35
|
+
export function setKbPermissionPolicy(policy) {
|
|
36
|
+
getPolicyFallback().policy = policy;
|
|
37
|
+
}
|
|
38
|
+
/** The policy the extension will register tools for: request-scoped, else fallback. */
|
|
39
|
+
export function getEffectiveKbPermissionPolicy() {
|
|
40
|
+
return getPolicyStorage().getStore() ?? getPolicyFallback().policy;
|
|
41
|
+
}
|
|
42
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
43
|
+
function textResult(text) {
|
|
44
|
+
return { content: [{ type: 'text', text }], details: undefined };
|
|
45
|
+
}
|
|
46
|
+
function getProtectedPaths(toolName, args) {
|
|
47
|
+
const paths = [];
|
|
48
|
+
if (toolName === 'batch_create_files' && Array.isArray(args.files)) {
|
|
49
|
+
args.files.forEach((f) => { if (f.path)
|
|
50
|
+
paths.push(f.path); });
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const p = (args.path ?? args.from_path);
|
|
54
|
+
if (typeof p === 'string')
|
|
55
|
+
paths.push(p);
|
|
56
|
+
}
|
|
57
|
+
return paths;
|
|
58
|
+
}
|
|
59
|
+
export function createMindosKbExtension(host) {
|
|
60
|
+
return function kbExtension(pi) {
|
|
61
|
+
const policy = getEffectiveKbPermissionPolicy();
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
const tools = host.getToolsForPolicy(policy);
|
|
64
|
+
for (const tool of tools) {
|
|
65
|
+
pi.registerTool({
|
|
66
|
+
name: tool.name,
|
|
67
|
+
label: tool.label,
|
|
68
|
+
description: tool.description,
|
|
69
|
+
parameters: tool.parameters,
|
|
70
|
+
execute: async (toolCallId, params, signal, onUpdate) => {
|
|
71
|
+
const args = (params ?? {});
|
|
72
|
+
// Write-protection guard
|
|
73
|
+
if (WRITE_TOOLS.has(tool.name)) {
|
|
74
|
+
for (const filePath of getProtectedPaths(tool.name, args)) {
|
|
75
|
+
try {
|
|
76
|
+
assertNotProtected(filePath, 'modified by AI agent');
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
80
|
+
return textResult(`Write-protection error: ${msg}. You CANNOT modify ${filePath} because it is system-protected. Please tell the user you don't have permission to do this.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Execute the actual tool
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
const result = await tool.execute(toolCallId, params, signal, onUpdate);
|
|
87
|
+
// Log the operation
|
|
88
|
+
try {
|
|
89
|
+
const outputText = result?.content
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
?.filter((p) => p.type === 'text')
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
+
.map((p) => p.text)
|
|
94
|
+
.join('') ?? '';
|
|
95
|
+
host.logAgentOp?.({
|
|
96
|
+
ts: new Date().toISOString(),
|
|
97
|
+
tool: tool.name,
|
|
98
|
+
params: args,
|
|
99
|
+
result: outputText.startsWith('Error:') ? 'error' : 'ok',
|
|
100
|
+
message: outputText.slice(0, 200),
|
|
101
|
+
agentName: 'MindOS',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// logging must never kill the stream
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function getHostSlot() {
|
|
114
|
+
return getProcessGlobal(KB_EXTENSION_HOST_KEY, () => ({ host: undefined }));
|
|
115
|
+
}
|
|
116
|
+
/** Register the host toolkit. Must run before resourceLoader.reload(). Idempotent. */
|
|
117
|
+
export function registerMindosKbExtensionHost(host) {
|
|
118
|
+
getHostSlot().host = host;
|
|
119
|
+
}
|
|
120
|
+
/** The toolkit registered by the host runtime, if any. */
|
|
121
|
+
export function getMindosKbExtensionHost() {
|
|
122
|
+
return getHostSlot().host;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Extension factory for host entry files: resolves the host toolkit from the
|
|
126
|
+
* registered slot at execution time, so the entry file's own import graph
|
|
127
|
+
* stays free of host modules (jiti-loadable).
|
|
128
|
+
*/
|
|
129
|
+
export function createMindosKbExtensionFromRegisteredHost() {
|
|
130
|
+
return function kbExtensionFromRegisteredHost(pi) {
|
|
131
|
+
const host = getMindosKbExtensionHost();
|
|
132
|
+
if (!host) {
|
|
133
|
+
throw new Error('MindOS KB extension host not registered. Call registerMindosKbExtensionHost() '
|
|
134
|
+
+ 'from the host runtime before resourceLoader.reload() — the kb-extension entry '
|
|
135
|
+
+ 'is loaded in the pi loader module graph and cannot import host modules.');
|
|
136
|
+
}
|
|
137
|
+
return createMindosKbExtension(host)(pi);
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=kb-extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kb-extension.js","sourceRoot":"","sources":["../../src/agent/kb-extension.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,EAAE;AACF,sEAAsE;AACtE,wEAAwE;AACxE,6EAA6E;AAC7E,4EAA4E;AAC5E,EAAE;AACF,8DAA8D;AAC9D,+DAA+D;AAC/D,0EAA0E;AAC1E,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,sEAAsE;AACtE,iBAAiB;AAEjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EACL,iCAAiC,GAElC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,iCAAiC,EACjC,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAwB,MAAM,eAAe,CAAC;AAMlE,SAAS,gBAAgB;IACvB,OAAO,gBAAgB,CACrB,gCAAgC,EAChC,GAAG,EAAE,CAAC,IAAI,iBAAiB,EAA+B,CAC3D,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO,gBAAgB,CACrB,iCAAiC,EACjC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,iCAAiC,CAAC,OAAO,CAAC,EAAE,CAAC,CAC/D,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IAAI,CAAC;AAC5B,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,wBAAwB;IACtC,OAAO,WAAW,EAAE,CAAC,IAAI,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yCAAyC;IACvD,OAAO,SAAS,6BAA6B,CAAC,EAAgB;QAC5D,MAAM,IAAI,GAAG,wBAAwB,EAAE,CAAC;QACxC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACb,gFAAgF;kBAC9E,gFAAgF;kBAChF,yEAAyE,CAC5E,CAAC;QACJ,CAAC;QACD,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { AgentToolResult } from '@earendil-works/pi-agent-core';
|
|
2
|
+
import { type MindosAgentPermissionPolicy } from './permission-policy.js';
|
|
3
|
+
import { type DiffLine } from './line-diff.js';
|
|
4
|
+
export type MindosAgentTool = {
|
|
5
|
+
name: string;
|
|
6
|
+
label: string;
|
|
7
|
+
description: string;
|
|
8
|
+
parameters: unknown;
|
|
9
|
+
execute: (...args: any[]) => Promise<AgentToolResult<any>>;
|
|
10
|
+
};
|
|
11
|
+
/** Loose file-tree node shape — hosts cast their concrete tree type to this. */
|
|
12
|
+
export interface MindosKbFileTreeNode {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
children?: MindosKbFileTreeNode[];
|
|
16
|
+
}
|
|
17
|
+
export interface MindosKbSearchResult {
|
|
18
|
+
path: string;
|
|
19
|
+
score: number;
|
|
20
|
+
snippet: string;
|
|
21
|
+
}
|
|
22
|
+
export interface MindosKbLintReport {
|
|
23
|
+
healthScore: number;
|
|
24
|
+
scope: string;
|
|
25
|
+
stats: {
|
|
26
|
+
totalFiles: number;
|
|
27
|
+
};
|
|
28
|
+
orphans: Array<{
|
|
29
|
+
path: string;
|
|
30
|
+
}>;
|
|
31
|
+
brokenLinks: Array<{
|
|
32
|
+
source: string;
|
|
33
|
+
line: number;
|
|
34
|
+
target: string;
|
|
35
|
+
}>;
|
|
36
|
+
stale: Array<{
|
|
37
|
+
path: string;
|
|
38
|
+
daysSinceUpdate: number;
|
|
39
|
+
}>;
|
|
40
|
+
empty: string[];
|
|
41
|
+
}
|
|
42
|
+
export type MindosKbCompileResult = {
|
|
43
|
+
ok: true;
|
|
44
|
+
stats: {
|
|
45
|
+
spaceName: string;
|
|
46
|
+
fileCount: number;
|
|
47
|
+
};
|
|
48
|
+
} | {
|
|
49
|
+
ok: false;
|
|
50
|
+
message: string;
|
|
51
|
+
};
|
|
52
|
+
export interface MindosKbDreamingRunSummary {
|
|
53
|
+
id: string;
|
|
54
|
+
scope: string;
|
|
55
|
+
lint: {
|
|
56
|
+
healthScore: number;
|
|
57
|
+
stats: {
|
|
58
|
+
totalFiles: number;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
proposals: Array<{
|
|
62
|
+
type: string;
|
|
63
|
+
title: string;
|
|
64
|
+
}>;
|
|
65
|
+
artifacts?: {
|
|
66
|
+
reportMarkdown: string;
|
|
67
|
+
pendingJson: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface MindosKbDreamingOptions {
|
|
71
|
+
space?: string;
|
|
72
|
+
writeArtifacts: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface MindosKbDreamingResult {
|
|
75
|
+
run: MindosKbDreamingRunSummary;
|
|
76
|
+
report: string;
|
|
77
|
+
}
|
|
78
|
+
/** Synchronous knowledge-base file operations the host must provide. */
|
|
79
|
+
export interface MindosKbFileHost {
|
|
80
|
+
getMindRoot(): string;
|
|
81
|
+
getFileTree(): MindosKbFileTreeNode[];
|
|
82
|
+
getFileContent(filePath: string): string;
|
|
83
|
+
getRecentlyModified(limit: number): Array<{
|
|
84
|
+
path: string;
|
|
85
|
+
mtime: number | string | Date;
|
|
86
|
+
}>;
|
|
87
|
+
saveFileContent(filePath: string, content: string): void;
|
|
88
|
+
createFile(filePath: string, content: string): void;
|
|
89
|
+
appendToFile(filePath: string, content: string): void;
|
|
90
|
+
insertAfterHeading(filePath: string, heading: string, content: string): void;
|
|
91
|
+
updateSection(filePath: string, heading: string, content: string): void;
|
|
92
|
+
updateLines(mindRoot: string, filePath: string, startIndex: number, endIndex: number, lines: string[]): void | Promise<void>;
|
|
93
|
+
moveToTrashFile(filePath: string): {
|
|
94
|
+
id: string;
|
|
95
|
+
};
|
|
96
|
+
renameFile(filePath: string, newName: string): string;
|
|
97
|
+
moveFile(fromPath: string, toPath: string): {
|
|
98
|
+
newPath: string;
|
|
99
|
+
affectedFiles: string[];
|
|
100
|
+
};
|
|
101
|
+
findBacklinks(filePath: string): Array<{
|
|
102
|
+
source: string;
|
|
103
|
+
line: number;
|
|
104
|
+
context: string;
|
|
105
|
+
}>;
|
|
106
|
+
gitLog(filePath: string, limit: number): Array<{
|
|
107
|
+
hash: string;
|
|
108
|
+
date: string;
|
|
109
|
+
message: string;
|
|
110
|
+
author: string;
|
|
111
|
+
}>;
|
|
112
|
+
gitShowFile(filePath: string, commit: string): string;
|
|
113
|
+
appendCsvRow(filePath: string, row: string[]): {
|
|
114
|
+
newRowCount: number;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export interface MindosKbToolsHost {
|
|
118
|
+
files: MindosKbFileHost;
|
|
119
|
+
hybridSearch(mindRoot: string, query: string): Promise<MindosKbSearchResult[]>;
|
|
120
|
+
readSkillContent(name: string): string | null | Promise<string | null>;
|
|
121
|
+
/** Optional: KB health check backend. The lint tool reports unavailability without it. */
|
|
122
|
+
runLint?(mindRoot: string, space?: string): MindosKbLintReport | Promise<MindosKbLintReport>;
|
|
123
|
+
/** Optional: conservative background maintenance pass. */
|
|
124
|
+
runDreaming?(mindRoot: string, options: MindosKbDreamingOptions): MindosKbDreamingResult | Promise<MindosKbDreamingResult>;
|
|
125
|
+
/** Optional: AI Space-overview backend. The compile tool reports unavailability without it. */
|
|
126
|
+
compileSpaceOverview?(space: string): MindosKbCompileResult | Promise<MindosKbCompileResult>;
|
|
127
|
+
/** Optional: off-thread diff for large files. Resolve null on timeout/unavailable. */
|
|
128
|
+
computeDiffAsync?(before: string, after: string): Promise<DiffLine[] | null>;
|
|
129
|
+
/** Optional: delegation tool sets appended per policy.toolScope. */
|
|
130
|
+
delegationTools?: {
|
|
131
|
+
a2a?: MindosAgentTool[];
|
|
132
|
+
acp?: MindosAgentTool[];
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export declare function truncate(content: string, query?: string): string;
|
|
136
|
+
export declare const WRITE_TOOLS: Set<string>;
|
|
137
|
+
/** Tool names sufficient for the "organize uploaded files" task. */
|
|
138
|
+
export declare const ORGANIZE_TOOL_NAMES: Set<string>;
|
|
139
|
+
/**
|
|
140
|
+
* Read-only tool set for Chat mode.
|
|
141
|
+
*
|
|
142
|
+
* Allows searching and reading the knowledge base + web access,
|
|
143
|
+
* but blocks all write operations. Extensible: add tool names here
|
|
144
|
+
* to grant more read-only capabilities to Chat mode.
|
|
145
|
+
*/
|
|
146
|
+
export declare const CHAT_TOOL_NAMES: Set<string>;
|
|
147
|
+
export interface MindosKbToolkit {
|
|
148
|
+
/** The full knowledge-base tool array (no policy filtering, no delegation tools). */
|
|
149
|
+
knowledgeBaseTools: MindosAgentTool[];
|
|
150
|
+
getToolsForPolicy(policy: MindosAgentPermissionPolicy): MindosAgentTool[];
|
|
151
|
+
/** Lean tool set for organize mode — skips MCP discovery, history, backlinks, etc. */
|
|
152
|
+
getOrganizeTools(): MindosAgentTool[];
|
|
153
|
+
getChatTools(): MindosAgentTool[];
|
|
154
|
+
getRequestScopedTools(): MindosAgentTool[];
|
|
155
|
+
}
|
|
156
|
+
export declare function createMindosKbToolkit(host: MindosKbToolsHost): MindosKbToolkit;
|
|
157
|
+
export declare function buildMindosKnowledgeBaseTools(host: MindosKbToolsHost): MindosAgentTool[];
|
|
158
|
+
//# sourceMappingURL=kb-tools.d.ts.map
|