odai-dsh-agent 0.2.5 → 0.2.7

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.
Files changed (166) hide show
  1. package/README.md +3 -3
  2. package/build/bin/odai-dsh-agent.d.mts +3 -0
  3. package/build/bin/odai-dsh-agent.d.mts.map +1 -0
  4. package/build/bin/odai-dsh-agent.mjs +114 -0
  5. package/build/bin/odai-dsh-agent.mjs.map +1 -0
  6. package/build/src/dsh-version.d.mts +16 -0
  7. package/build/src/dsh-version.d.mts.map +1 -0
  8. package/build/src/dsh-version.mjs +20 -0
  9. package/build/src/dsh-version.mjs.map +1 -0
  10. package/build/src/installer.d.mts +46 -0
  11. package/build/src/installer.d.mts.map +1 -0
  12. package/build/src/installer.mjs +398 -0
  13. package/build/src/installer.mjs.map +1 -0
  14. package/package.json +13 -12
  15. package/preset/odai/runtime/compaction-config.d.mts +66 -0
  16. package/preset/odai/runtime/compaction-config.d.mts.map +1 -0
  17. package/preset/odai/runtime/compaction-config.mjs +320 -342
  18. package/preset/odai/runtime/compaction-config.mjs.map +1 -0
  19. package/preset/odai/runtime/compaction-runtime.d.mts +68 -0
  20. package/preset/odai/runtime/compaction-runtime.d.mts.map +1 -0
  21. package/preset/odai/runtime/compaction-runtime.mjs +157 -0
  22. package/preset/odai/runtime/compaction-runtime.mjs.map +1 -0
  23. package/preset/odai/runtime/context-activation.d.mts +31 -0
  24. package/preset/odai/runtime/context-activation.d.mts.map +1 -0
  25. package/preset/odai/runtime/context-activation.mjs +55 -49
  26. package/preset/odai/runtime/context-activation.mjs.map +1 -0
  27. package/preset/odai/runtime/context-capability.d.mts +16 -0
  28. package/preset/odai/runtime/context-capability.d.mts.map +1 -0
  29. package/preset/odai/runtime/context-capability.mjs +79 -74
  30. package/preset/odai/runtime/context-capability.mjs.map +1 -0
  31. package/preset/odai/runtime/governance.d.mts +30 -0
  32. package/preset/odai/runtime/governance.d.mts.map +1 -0
  33. package/preset/odai/runtime/governance.mjs +126 -113
  34. package/preset/odai/runtime/governance.mjs.map +1 -0
  35. package/preset/odai/runtime/human-care.d.mts +13 -0
  36. package/preset/odai/runtime/human-care.d.mts.map +1 -0
  37. package/preset/odai/runtime/human-care.mjs +45 -42
  38. package/preset/odai/runtime/human-care.mjs.map +1 -0
  39. package/preset/odai/runtime/human-safety-continuity-store.d.mts +43 -0
  40. package/preset/odai/runtime/human-safety-continuity-store.d.mts.map +1 -0
  41. package/preset/odai/runtime/human-safety-continuity-store.mjs +193 -215
  42. package/preset/odai/runtime/human-safety-continuity-store.mjs.map +1 -0
  43. package/preset/odai/runtime/human-safety-continuity.d.mts +27 -0
  44. package/preset/odai/runtime/human-safety-continuity.d.mts.map +1 -0
  45. package/preset/odai/runtime/human-safety-continuity.mjs +205 -216
  46. package/preset/odai/runtime/human-safety-continuity.mjs.map +1 -0
  47. package/preset/odai/runtime/human-safety.d.mts +14 -0
  48. package/preset/odai/runtime/human-safety.d.mts.map +1 -0
  49. package/preset/odai/runtime/human-safety.mjs +50 -47
  50. package/preset/odai/runtime/human-safety.mjs.map +1 -0
  51. package/preset/odai/runtime/index.d.mts +8 -0
  52. package/preset/odai/runtime/index.d.mts.map +1 -0
  53. package/preset/odai/runtime/index.mjs +190 -2473
  54. package/preset/odai/runtime/index.mjs.map +1 -0
  55. package/preset/odai/runtime/lifecycle-runtime.d.mts +83 -0
  56. package/preset/odai/runtime/lifecycle-runtime.d.mts.map +1 -0
  57. package/preset/odai/runtime/lifecycle-runtime.mjs +1140 -0
  58. package/preset/odai/runtime/lifecycle-runtime.mjs.map +1 -0
  59. package/preset/odai/runtime/model-route.d.mts +22 -0
  60. package/preset/odai/runtime/model-route.d.mts.map +1 -0
  61. package/preset/odai/runtime/model-route.mjs +68 -60
  62. package/preset/odai/runtime/model-route.mjs.map +1 -0
  63. package/preset/odai/runtime/output-config.d.mts +54 -0
  64. package/preset/odai/runtime/output-config.d.mts.map +1 -0
  65. package/preset/odai/runtime/output-config.mjs +289 -315
  66. package/preset/odai/runtime/output-config.mjs.map +1 -0
  67. package/preset/odai/runtime/output-policy-state.d.mts +3 -0
  68. package/preset/odai/runtime/output-policy-state.d.mts.map +1 -0
  69. package/preset/odai/runtime/output-policy-state.mjs +41 -29
  70. package/preset/odai/runtime/output-policy-state.mjs.map +1 -0
  71. package/preset/odai/runtime/prompt-runtime.d.mts +55 -0
  72. package/preset/odai/runtime/prompt-runtime.d.mts.map +1 -0
  73. package/preset/odai/runtime/prompt-runtime.mjs +303 -0
  74. package/preset/odai/runtime/prompt-runtime.mjs.map +1 -0
  75. package/preset/odai/runtime/research-packet.d.mts +30 -0
  76. package/preset/odai/runtime/research-packet.d.mts.map +1 -0
  77. package/preset/odai/runtime/research-packet.mjs +116 -117
  78. package/preset/odai/runtime/research-packet.mjs.map +1 -0
  79. package/preset/odai/runtime/responsibility-gap.d.mts +26 -0
  80. package/preset/odai/runtime/responsibility-gap.d.mts.map +1 -0
  81. package/preset/odai/runtime/responsibility-gap.mjs +93 -85
  82. package/preset/odai/runtime/responsibility-gap.mjs.map +1 -0
  83. package/preset/odai/runtime/responsibility-scope.d.mts +69 -0
  84. package/preset/odai/runtime/responsibility-scope.d.mts.map +1 -0
  85. package/preset/odai/runtime/responsibility-scope.mjs +199 -171
  86. package/preset/odai/runtime/responsibility-scope.mjs.map +1 -0
  87. package/preset/odai/runtime/role-overlays.d.mts +5 -0
  88. package/preset/odai/runtime/role-overlays.d.mts.map +1 -0
  89. package/preset/odai/runtime/role-overlays.mjs +15 -14
  90. package/preset/odai/runtime/role-overlays.mjs.map +1 -0
  91. package/preset/odai/runtime/route-card.d.mts +42 -0
  92. package/preset/odai/runtime/route-card.d.mts.map +1 -0
  93. package/preset/odai/runtime/route-card.mjs +158 -146
  94. package/preset/odai/runtime/route-card.mjs.map +1 -0
  95. package/preset/odai/runtime/router.d.mts +80 -0
  96. package/preset/odai/runtime/router.d.mts.map +1 -0
  97. package/preset/odai/runtime/router.mjs +509 -559
  98. package/preset/odai/runtime/router.mjs.map +1 -0
  99. package/preset/odai/runtime/routing-config.d.mts +76 -0
  100. package/preset/odai/runtime/routing-config.d.mts.map +1 -0
  101. package/preset/odai/runtime/routing-config.mjs +373 -438
  102. package/preset/odai/runtime/routing-config.mjs.map +1 -0
  103. package/preset/odai/runtime/routing-context.d.mts +64 -0
  104. package/preset/odai/runtime/routing-context.d.mts.map +1 -0
  105. package/preset/odai/runtime/routing-context.mjs +398 -277
  106. package/preset/odai/runtime/routing-context.mjs.map +1 -0
  107. package/preset/odai/runtime/runtime-config.d.mts +24 -0
  108. package/preset/odai/runtime/runtime-config.d.mts.map +1 -0
  109. package/preset/odai/runtime/runtime-config.mjs +181 -0
  110. package/preset/odai/runtime/runtime-config.mjs.map +1 -0
  111. package/preset/odai/runtime/runtime-support.d.mts +91 -0
  112. package/preset/odai/runtime/runtime-support.d.mts.map +1 -0
  113. package/preset/odai/runtime/runtime-support.mjs +371 -0
  114. package/preset/odai/runtime/runtime-support.mjs.map +1 -0
  115. package/preset/odai/runtime/runtime-types.d.mts +237 -0
  116. package/preset/odai/runtime/runtime-types.d.mts.map +1 -0
  117. package/preset/odai/runtime/runtime-types.mjs +4 -0
  118. package/preset/odai/runtime/runtime-types.mjs.map +1 -0
  119. package/preset/odai/runtime/semantic-memory-store.d.mts +110 -0
  120. package/preset/odai/runtime/semantic-memory-store.d.mts.map +1 -0
  121. package/preset/odai/runtime/semantic-memory-store.mjs +271 -385
  122. package/preset/odai/runtime/semantic-memory-store.mjs.map +1 -0
  123. package/preset/odai/runtime/semantic-memory.d.mts +88 -0
  124. package/preset/odai/runtime/semantic-memory.d.mts.map +1 -0
  125. package/preset/odai/runtime/semantic-memory.mjs +790 -750
  126. package/preset/odai/runtime/semantic-memory.mjs.map +1 -0
  127. package/preset/odai/runtime/session-compat.d.mts +31 -0
  128. package/preset/odai/runtime/session-compat.d.mts.map +1 -0
  129. package/preset/odai/runtime/session-compat.mjs +301 -328
  130. package/preset/odai/runtime/session-compat.mjs.map +1 -0
  131. package/preset/odai/runtime/session-evidence.d.mts +25 -0
  132. package/preset/odai/runtime/session-evidence.d.mts.map +1 -0
  133. package/preset/odai/runtime/session-evidence.mjs +309 -287
  134. package/preset/odai/runtime/session-evidence.mjs.map +1 -0
  135. package/preset/odai/runtime/skill-bundle.d.mts +53 -0
  136. package/preset/odai/runtime/skill-bundle.d.mts.map +1 -0
  137. package/preset/odai/runtime/skill-bundle.mjs +286 -276
  138. package/preset/odai/runtime/skill-bundle.mjs.map +1 -0
  139. package/preset/odai/runtime/skill-evolution.d.mts +112 -0
  140. package/preset/odai/runtime/skill-evolution.d.mts.map +1 -0
  141. package/preset/odai/runtime/skill-evolution.mjs +1287 -1261
  142. package/preset/odai/runtime/skill-evolution.mjs.map +1 -0
  143. package/preset/odai/runtime/skill-selection-state.d.mts +5 -0
  144. package/preset/odai/runtime/skill-selection-state.d.mts.map +1 -0
  145. package/preset/odai/runtime/skill-selection-state.mjs +59 -43
  146. package/preset/odai/runtime/skill-selection-state.mjs.map +1 -0
  147. package/preset/odai/runtime/skill-selector.d.mts +28 -0
  148. package/preset/odai/runtime/skill-selector.d.mts.map +1 -0
  149. package/preset/odai/runtime/skill-selector.mjs +100 -109
  150. package/preset/odai/runtime/skill-selector.mjs.map +1 -0
  151. package/preset/odai/runtime/skill-source-config.d.mts +32 -0
  152. package/preset/odai/runtime/skill-source-config.d.mts.map +1 -0
  153. package/preset/odai/runtime/skill-source-config.mjs +200 -210
  154. package/preset/odai/runtime/skill-source-config.mjs.map +1 -0
  155. package/preset/odai/runtime/store-lock.d.mts +2 -0
  156. package/preset/odai/runtime/store-lock.d.mts.map +1 -0
  157. package/preset/odai/runtime/store-lock.mjs +92 -87
  158. package/preset/odai/runtime/store-lock.mjs.map +1 -0
  159. package/preset/odai/runtime/tool-runtime.d.mts +43 -0
  160. package/preset/odai/runtime/tool-runtime.d.mts.map +1 -0
  161. package/preset/odai/runtime/tool-runtime.mjs +221 -0
  162. package/preset/odai/runtime/tool-runtime.mjs.map +1 -0
  163. package/bin/odai-dsh-agent.mjs +0 -108
  164. package/scripts/verify-agent-load.mjs +0 -260
  165. package/src/dsh-version.mjs +0 -24
  166. package/src/installer.mjs +0 -385
@@ -1,86 +1,91 @@
1
+ import { isUnknownRecord } from "./runtime-types.mjs";
1
2
  export const ODAI_CONTEXT_CAPABILITIES = Object.freeze([
2
- "routing-config",
3
- "human-care",
4
- "human-safety",
5
- "skill-source",
6
- "skill-evolution",
7
- "output-config",
8
- "compaction-config",
9
- "memory",
10
- "safety-continuity",
3
+ "routing-config",
4
+ "human-care",
5
+ "human-safety",
6
+ "skill-source",
7
+ "skill-evolution",
8
+ "output-config",
9
+ "compaction-config",
10
+ "memory",
11
+ "safety-continuity",
11
12
  ]);
12
-
13
13
  const CAPABILITY_FIELDS = Object.freeze({
14
- "routing-config": "routingConfig",
15
- "human-care": "care",
16
- "human-safety": "safety",
17
- "skill-source": "skillSource",
18
- "skill-evolution": "skillEvolution",
19
- "output-config": "outputConfig",
20
- "compaction-config": "compactionConfig",
21
- memory: "memory",
22
- "safety-continuity": "continuity",
14
+ "routing-config": "routingConfig",
15
+ "human-care": "care",
16
+ "human-safety": "safety",
17
+ "skill-source": "skillSource",
18
+ "skill-evolution": "skillEvolution",
19
+ "output-config": "outputConfig",
20
+ "compaction-config": "compactionConfig",
21
+ memory: "memory",
22
+ "safety-continuity": "continuity",
23
23
  });
24
-
24
+ function isContextCapability(value) {
25
+ return typeof value === "string" && ODAI_CONTEXT_CAPABILITIES.includes(value);
26
+ }
25
27
  export function requestedContextCapabilities(events, turn) {
26
- if (!Number.isSafeInteger(turn)) return Object.freeze([]);
27
- const capabilities = new Set();
28
- for (const event of Array.isArray(events) ? events : []) {
29
- if (event?.type === "odai/context-capability-requested"
30
- && event.data?.turn === turn
31
- && ODAI_CONTEXT_CAPABILITIES.includes(event.data.capability)) {
32
- capabilities.add(event.data.capability);
28
+ if (!Number.isSafeInteger(turn))
29
+ return Object.freeze([]);
30
+ const capabilities = new Set();
31
+ for (const event of Array.isArray(events) ? events : []) {
32
+ const capability = event.data?.capability;
33
+ if (event.type === "odai/context-capability-requested"
34
+ && event.data?.turn === turn
35
+ && isContextCapability(capability)) {
36
+ capabilities.add(capability);
37
+ }
33
38
  }
34
- }
35
- return Object.freeze([...capabilities]);
39
+ return Object.freeze([...capabilities]);
36
40
  }
37
-
38
41
  export function activateRequestedCapabilities(activation, capabilities) {
39
- const merged = { ...activation };
40
- for (const capability of capabilities) {
41
- const field = CAPABILITY_FIELDS[capability];
42
- if (field) merged[field] = true;
43
- }
44
- if (merged.safety) merged.care = false;
45
- return Object.freeze(merged);
42
+ const merged = { ...activation };
43
+ for (const capability of capabilities) {
44
+ merged[CAPABILITY_FIELDS[capability]] = true;
45
+ }
46
+ if (merged.safety)
47
+ merged.care = false;
48
+ return Object.freeze(merged);
46
49
  }
47
-
48
50
  export function createContextCapabilityTool(options = {}) {
49
- const isChild = typeof options.isChild === "function" ? options.isChild : () => false;
50
- const onRequested = typeof options.onRequested === "function" ? options.onRequested : () => {};
51
- return {
52
- name: "odai_context_capability",
53
- description: "Request one Odai capability when its specialized tool is not currently visible. Use this only as a discovery fallback for routing configuration, non-crisis care, crisis safety, skill source/evolution, output, compaction, memory, or safety continuity. The real tool and its complete constraints appear on the next step; this request performs no configuration, persistence, diagnosis, or model switch.",
54
- parameters: {
55
- type: "object",
56
- additionalProperties: false,
57
- required: ["capability"],
58
- properties: {
59
- capability: { type: "string", enum: ODAI_CONTEXT_CAPABILITIES },
60
- },
61
- },
62
- output: {
63
- schema: {
64
- type: "object",
65
- additionalProperties: false,
66
- required: ["capability", "status"],
67
- properties: {
68
- capability: { type: "string", enum: ODAI_CONTEXT_CAPABILITIES },
69
- status: { type: "string", enum: ["available-next-step"] },
51
+ const isChild = typeof options.isChild === "function" ? options.isChild : () => false;
52
+ const onRequested = typeof options.onRequested === "function" ? options.onRequested : () => { };
53
+ return {
54
+ name: "odai_context_capability",
55
+ description: "Request one Odai capability when its specialized tool is not currently visible. Use this only as a discovery fallback for routing configuration, non-crisis care, crisis safety, skill source/evolution, output, compaction, memory, or safety continuity. The real tool and its complete constraints appear on the next step; this request performs no configuration, persistence, diagnosis, or model switch.",
56
+ parameters: {
57
+ type: "object",
58
+ additionalProperties: false,
59
+ required: ["capability"],
60
+ properties: {
61
+ capability: { type: "string", enum: ODAI_CONTEXT_CAPABILITIES },
62
+ },
63
+ },
64
+ output: {
65
+ schema: {
66
+ type: "object",
67
+ additionalProperties: false,
68
+ required: ["capability", "status"],
69
+ properties: {
70
+ capability: { type: "string", enum: ODAI_CONTEXT_CAPABILITIES },
71
+ status: { type: "string", enum: ["available-next-step"] },
72
+ },
73
+ },
74
+ render(_arguments, value) {
75
+ return [{ type: "text", text: `Odai ${value.capability} capability is available on the next step.` }];
76
+ },
77
+ },
78
+ execute(arguments_, execution) {
79
+ if (!execution.agent)
80
+ throw new Error("odai_context_capability requires an owning agent session");
81
+ if (isChild(execution.agent))
82
+ throw new Error("child agents may not request Odai controller capabilities");
83
+ if (!isUnknownRecord(arguments_) || !isContextCapability(arguments_.capability)) {
84
+ throw new TypeError(`capability must be ${ODAI_CONTEXT_CAPABILITIES.join(", ")}`);
85
+ }
86
+ onRequested(execution.agent, arguments_.capability, execution);
87
+ return Promise.resolve({ capability: arguments_.capability, status: "available-next-step" });
70
88
  },
71
- },
72
- render(_args, value) {
73
- return [{ type: "text", text: `Odai ${value.capability} capability is available on the next step.` }];
74
- },
75
- },
76
- execute(args, execution) {
77
- if (!execution.agent) throw new Error("odai_context_capability requires an owning agent session");
78
- if (isChild(execution.agent)) throw new Error("child agents may not request Odai controller capabilities");
79
- if (!args || typeof args !== "object" || Array.isArray(args) || !ODAI_CONTEXT_CAPABILITIES.includes(args.capability)) {
80
- throw new TypeError(`capability must be ${ODAI_CONTEXT_CAPABILITIES.join(", ")}`);
81
- }
82
- onRequested(execution.agent, args.capability, execution);
83
- return Promise.resolve({ capability: args.capability, status: "available-next-step" });
84
- },
85
- };
89
+ };
86
90
  }
91
+ //# sourceMappingURL=context-capability.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-capability.mjs","sourceRoot":"","sources":["../src/context-capability.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrD,gBAAgB;IAChB,YAAY;IACZ,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,eAAe;IACf,mBAAmB;IACnB,QAAQ;IACR,mBAAmB;CACX,CAAC,CAAC;AAMZ,MAAM,iBAAiB,GAAgE,MAAM,CAAC,MAAM,CAAC;IACnG,gBAAgB,EAAE,eAAe;IACjC,YAAY,EAAE,MAAM;IACpB,cAAc,EAAE,QAAQ;IACxB,cAAc,EAAE,aAAa;IAC7B,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,cAAc;IAC/B,mBAAmB,EAAE,kBAAkB;IACvC,MAAM,EAAE,QAAQ;IAChB,mBAAmB,EAAE,YAAY;CAClC,CAAC,CAAC;AAEH,SAAS,mBAAmB,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,yBAA+C,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvG,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,MAAuC,EAAE,IAAwB;IAC5G,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1D,MAAM,YAAY,GAAG,IAAI,GAAG,EAAqB,CAAC;IAClD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACxD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC;QAC1C,IAAI,KAAK,CAAC,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30 @@
1
+ import type { DshAgent, DshEvent, ToolExecution, ToolResult } from "./runtime-types.mjs";
2
+ export declare const DEFAULT_CHILD_DENIED_TOOLS: readonly ["write", "edit", "str_replace_editor", "bash", "pwsh", "ask_user_question", "subagent", "subagent_fork", "subagent_codex", "subagent_claude_code", "send_message", "interrupt_agent", "list_agents", "workflow", "ralph", "job_output", "job_list", "job_kill"];
3
+ export declare const DEFAULT_PROTECTED_CONTROLLER_ALLOWED_TOOLS: readonly ["read", "read_image", "glob", "grep", "web_search", "web_fetch", "ask_user_question", "get_goal", "list_agents", "job_output", "job_list", "skill", "odai_route_card"];
4
+ export interface ToolGuardOptions {
5
+ additionalDeniedTools?: readonly string[];
6
+ onDenied?(execution: ToolExecution, reason: string): void;
7
+ }
8
+ export interface RouteProtection {
9
+ readonly turn?: number;
10
+ readonly mode?: "read-only";
11
+ readonly scopeId?: string;
12
+ readonly reasonCode?: string;
13
+ }
14
+ export interface RouteProtectionGuardOptions extends ToolGuardOptions {
15
+ protectionFor?(agent: DshAgent | undefined): RouteProtection | undefined;
16
+ }
17
+ export interface ToolResultSummary {
18
+ callId: string;
19
+ rootCallId: string;
20
+ tool: string;
21
+ child: boolean;
22
+ isError: boolean;
23
+ errorCode?: string;
24
+ }
25
+ export declare function isSubagent(agent: DshAgent | null | undefined): boolean;
26
+ export declare function createChildToolGuard(options?: ToolGuardOptions): (execution: ToolExecution) => string | undefined;
27
+ export declare function activeRouteProtection(agent: DshAgent | null | undefined, recordedEvents?: readonly DshEvent[] | undefined): RouteProtection | undefined;
28
+ export declare function createRouteProtectionGuard(options?: RouteProtectionGuardOptions): (execution: ToolExecution) => string | undefined;
29
+ export declare function summarizeToolResult(execution: ToolExecution, result: ToolResult): ToolResultSummary;
30
+ //# sourceMappingURL=governance.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance.d.mts","sourceRoot":"","sources":["../src/governance.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAA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,CA6B7B;AAED,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,2BAAgC,GACxC,CAAC,SAAS,EAAE,aAAa,KAAK,MAAM,GAAG,SAAS,CAqBlD;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,GAAG,iBAAiB,CAcnG"}
@@ -1,128 +1,141 @@
1
1
  export const DEFAULT_CHILD_DENIED_TOOLS = Object.freeze([
2
- "write",
3
- "edit",
4
- "str_replace_editor",
5
- "bash",
6
- "pwsh",
7
- "ask_user_question",
8
- "subagent",
9
- "subagent_fork",
10
- "subagent_codex",
11
- "subagent_claude_code",
12
- "send_message",
13
- "interrupt_agent",
14
- "list_agents",
15
- "workflow",
16
- "ralph",
17
- "job_output",
18
- "job_list",
19
- "job_kill",
2
+ "write",
3
+ "edit",
4
+ "str_replace_editor",
5
+ "bash",
6
+ "pwsh",
7
+ "ask_user_question",
8
+ "subagent",
9
+ "subagent_fork",
10
+ "subagent_codex",
11
+ "subagent_claude_code",
12
+ "send_message",
13
+ "interrupt_agent",
14
+ "list_agents",
15
+ "workflow",
16
+ "ralph",
17
+ "job_output",
18
+ "job_list",
19
+ "job_kill",
20
20
  ]);
21
-
22
21
  export const DEFAULT_PROTECTED_CONTROLLER_ALLOWED_TOOLS = Object.freeze([
23
- "read",
24
- "read_image",
25
- "glob",
26
- "grep",
27
- "web_search",
28
- "web_fetch",
29
- "ask_user_question",
30
- "get_goal",
31
- "list_agents",
32
- "job_output",
33
- "job_list",
34
- "skill",
35
- "odai_route_card",
22
+ "read",
23
+ "read_image",
24
+ "glob",
25
+ "grep",
26
+ "web_search",
27
+ "web_fetch",
28
+ "ask_user_question",
29
+ "get_goal",
30
+ "list_agents",
31
+ "job_output",
32
+ "job_list",
33
+ "skill",
34
+ "odai_route_card",
36
35
  ]);
37
-
38
36
  export function isSubagent(agent) {
39
- const header = agent?.session?.header;
40
- return header?.origin === "subagent"
41
- || (Number.isSafeInteger(header?.delegationDepth) && header.delegationDepth > 0);
37
+ const header = agent?.session?.header;
38
+ return header?.origin === "subagent"
39
+ || (Number.isSafeInteger(header?.delegationDepth) && (header?.delegationDepth ?? 0) > 0);
42
40
  }
43
-
44
41
  export function createChildToolGuard(options = {}) {
45
- const denied = new Set([
46
- ...DEFAULT_CHILD_DENIED_TOOLS,
47
- ...(Array.isArray(options.additionalDeniedTools) ? options.additionalDeniedTools : []),
48
- ]);
49
- const onDenied = typeof options.onDenied === "function" ? options.onDenied : () => {};
50
-
51
- return (execution) => {
52
- if (!isSubagent(execution?.agent)) return undefined;
53
- if (!denied.has(execution?.name)) return undefined;
54
-
55
- const reason = `ODAI_SUBAGENT_BOUNDARY: child agents may not execute ${execution.name}; return evidence to the controller instead.`;
56
- onDenied(execution, reason);
57
- return reason;
58
- };
42
+ const denied = new Set([
43
+ ...DEFAULT_CHILD_DENIED_TOOLS,
44
+ ...(Array.isArray(options.additionalDeniedTools) ? options.additionalDeniedTools : []),
45
+ ]);
46
+ const onDenied = typeof options.onDenied === "function" ? options.onDenied : () => { };
47
+ return (execution) => {
48
+ if (!isSubagent(execution?.agent))
49
+ return undefined;
50
+ if (!denied.has(execution?.name))
51
+ return undefined;
52
+ const reason = `ODAI_SUBAGENT_BOUNDARY: child agents may not execute ${execution.name}; return evidence to the controller instead.`;
53
+ onDenied(execution, reason);
54
+ return reason;
55
+ };
56
+ }
57
+ function asRouteProtection(event, turn) {
58
+ const { data } = event;
59
+ if (data.turn !== turn || data.mode !== "read-only")
60
+ return undefined;
61
+ return {
62
+ turn,
63
+ mode: "read-only",
64
+ ...(typeof data.scopeId === "string" ? { scopeId: data.scopeId } : {}),
65
+ ...(typeof data.reasonCode === "string" ? { reasonCode: data.reasonCode } : {}),
66
+ };
59
67
  }
60
-
61
68
  export function activeRouteProtection(agent, recordedEvents = agent?.session?.events) {
62
- if (isSubagent(agent)) return undefined;
63
- const events = recordedEvents;
64
- if (!Array.isArray(events)) return undefined;
65
-
66
- let currentTurn;
67
- for (let index = events.length - 1; index >= 0; index -= 1) {
68
- const event = events[index];
69
- if (event?.type !== "odai/route-decided") continue;
70
- if (!Number.isSafeInteger(event.data?.turn)) return undefined;
71
- currentTurn = event.data.turn;
72
- break;
73
- }
74
- if (currentTurn === undefined) return undefined;
75
-
76
- const releasedScopes = new Set();
77
- for (let index = events.length - 1; index >= 0; index -= 1) {
78
- const event = events[index];
79
- if (event?.type === "odai/route-protection-released" && event.data?.turn === currentTurn) {
80
- if (typeof event.data?.scopeId === "string") releasedScopes.add(event.data.scopeId);
81
- continue;
69
+ if (isSubagent(agent))
70
+ return undefined;
71
+ const events = recordedEvents;
72
+ if (!Array.isArray(events))
73
+ return undefined;
74
+ let currentTurn;
75
+ for (let index = events.length - 1; index >= 0; index -= 1) {
76
+ const event = events[index];
77
+ if (event?.type !== "odai/route-decided")
78
+ continue;
79
+ if (!Number.isSafeInteger(event.data?.turn))
80
+ return undefined;
81
+ currentTurn = event.data.turn;
82
+ break;
83
+ }
84
+ if (currentTurn === undefined)
85
+ return undefined;
86
+ const releasedScopes = new Set();
87
+ for (let index = events.length - 1; index >= 0; index -= 1) {
88
+ const event = events[index];
89
+ if (event?.type === "odai/route-protection-released" && event.data?.turn === currentTurn) {
90
+ if (typeof event.data?.scopeId === "string")
91
+ releasedScopes.add(event.data.scopeId);
92
+ continue;
93
+ }
94
+ if (event?.type !== "odai/route-protection")
95
+ continue;
96
+ const protection = asRouteProtection(event, currentTurn);
97
+ if (!protection)
98
+ continue;
99
+ if (protection.scopeId && releasedScopes.has(protection.scopeId))
100
+ continue;
101
+ return protection;
82
102
  }
83
- if (event?.type !== "odai/route-protection") continue;
84
- if (event.data?.turn !== currentTurn || event.data?.mode !== "read-only") continue;
85
- if (event.data?.scopeId && releasedScopes.has(event.data.scopeId)) continue;
86
- return event.data;
87
- }
88
- return undefined;
103
+ return undefined;
89
104
  }
90
-
91
105
  export function createRouteProtectionGuard(options = {}) {
92
- const allowed = new Set(DEFAULT_PROTECTED_CONTROLLER_ALLOWED_TOOLS);
93
- for (const name of Array.isArray(options.additionalDeniedTools) ? options.additionalDeniedTools : []) {
94
- allowed.delete(name);
95
- }
96
- const onDenied = typeof options.onDenied === "function" ? options.onDenied : () => {};
97
- const protectionFor = typeof options.protectionFor === "function"
98
- ? options.protectionFor
99
- : activeRouteProtection;
100
-
101
- return (execution) => {
102
- if (isSubagent(execution?.agent)) return undefined;
103
- if (allowed.has(execution?.name)) return undefined;
104
- const protection = protectionFor(execution?.agent);
105
- if (!protection) return undefined;
106
-
107
- const reasonCode = protection.reasonCode ?? "unresolved-high-impact-route";
108
- const reason = `ODAI_HIGH_IMPACT_ROUTE_BLOCKED: controller may not execute ${execution.name} while ${reasonCode} remains unresolved; use read-only evidence and provide an actionable decision path.`;
109
- onDenied(execution, reason);
110
- return reason;
111
- };
106
+ const allowed = new Set(DEFAULT_PROTECTED_CONTROLLER_ALLOWED_TOOLS);
107
+ for (const name of Array.isArray(options.additionalDeniedTools) ? options.additionalDeniedTools : []) {
108
+ allowed.delete(name);
109
+ }
110
+ const onDenied = typeof options.onDenied === "function" ? options.onDenied : () => { };
111
+ const protectionFor = typeof options.protectionFor === "function"
112
+ ? options.protectionFor
113
+ : activeRouteProtection;
114
+ return (execution) => {
115
+ if (isSubagent(execution?.agent))
116
+ return undefined;
117
+ if (allowed.has(execution?.name))
118
+ return undefined;
119
+ const protection = protectionFor(execution?.agent);
120
+ if (!protection)
121
+ return undefined;
122
+ const reasonCode = protection.reasonCode ?? "unresolved-high-impact-route";
123
+ const reason = `ODAI_HIGH_IMPACT_ROUTE_BLOCKED: controller may not execute ${execution.name} while ${reasonCode} remains unresolved; use read-only evidence and provide an actionable decision path.`;
124
+ onDenied(execution, reason);
125
+ return reason;
126
+ };
112
127
  }
113
-
114
128
  export function summarizeToolResult(execution, result) {
115
- const summary = {
116
- callId: String(execution.callId),
117
- rootCallId: String(execution.rootCallId),
118
- tool: execution.name,
119
- child: isSubagent(execution.agent),
120
- isError: result.isError === true,
121
- };
122
-
123
- if (result.isError === true && result.error?.code) {
124
- summary.errorCode = String(result.error.code);
125
- }
126
-
127
- return summary;
129
+ const summary = {
130
+ callId: String(execution.callId),
131
+ rootCallId: String(execution.rootCallId),
132
+ tool: execution.name,
133
+ child: isSubagent(execution.agent),
134
+ isError: result.isError === true,
135
+ };
136
+ if (result.isError === true && result.error?.code) {
137
+ summary.errorCode = String(result.error.code);
138
+ }
139
+ return summary;
128
140
  }
141
+ //# sourceMappingURL=governance.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance.mjs","sourceRoot":"","sources":["../src/governance.mts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC;IACtD,OAAO;IACP,MAAM;IACN,oBAAoB;IACpB,MAAM;IACN,MAAM;IACN,mBAAmB;IACnB,UAAU;IACV,eAAe;IACf,gBAAgB;IAChB,sBAAsB;IACtB,cAAc;IACd,iBAAiB;IACjB,aAAa;IACb,UAAU;IACV,OAAO;IACP,YAAY;IACZ,UAAU;IACV,UAAU;CACF,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,0CAA0C,GAAG,MAAM,CAAC,MAAM,CAAC;IACtE,MAAM;IACN,YAAY;IACZ,MAAM;IACN,MAAM;IACN,YAAY;IACZ,WAAW;IACX,mBAAmB;IACnB,UAAU;IACV,aAAa;IACb,YAAY;IACZ,UAAU;IACV,OAAO;IACP,iBAAiB;CACT,CAAC,CAAC;AA2BZ,MAAM,UAAU,UAAU,CAAC,KAAkC;IAC3D,MAAM,MAAM,GAAG,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC;IACtC,OAAO,MAAM,EAAE,MAAM,KAAK,UAAU;WAC/B,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,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QACnD,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACnD,IAAI,CAAC,UAAU;YAAE,OAAO,SAAS,CAAC;QAElC,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,8BAA8B,CAAC;QAC3E,MAAM,MAAM,GAAG,8DAA8D,SAAS,CAAC,IAAI,UAAU,UAAU,sFAAsF,CAAC;QACtM,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,SAAwB,EAAE,MAAkB;IAC9E,MAAM,OAAO,GAAsB;QACjC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;QAChC,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC;QACxC,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC;QAClC,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI;KACjC,CAAC;IAEF,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;QAClD,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { DshAgent, RuntimeTool } from "./runtime-types.mjs";
2
+ export declare const HUMAN_CARE_REFERENCE_PATH = "references/care.md";
3
+ export interface HumanCareToolOptions {
4
+ contractFor(agent: DshAgent): string;
5
+ isChild?(agent: DshAgent): boolean;
6
+ }
7
+ export interface HumanCareResult {
8
+ scope: "non-crisis-care";
9
+ userChannelOwner: "current-controller" | "controller";
10
+ contract: string;
11
+ }
12
+ export declare function createHumanCareTool(options: HumanCareToolOptions): RuntimeTool<unknown, HumanCareResult>;
13
+ //# sourceMappingURL=human-care.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"human-care.d.mts","sourceRoot":"","sources":["../src/human-care.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEjE,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAC;IACrC,OAAO,CAAC,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,iBAAiB,CAAC;IACzB,gBAAgB,EAAE,oBAAoB,GAAG,YAAY,CAAC;IACtD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,WAAW,CAAC,OAAO,EAAE,eAAe,CAAC,CA0CxG"}
@@ -1,45 +1,48 @@
1
1
  export const HUMAN_CARE_REFERENCE_PATH = "references/care.md";
2
-
3
- export function createHumanCareTool(options = {}) {
4
- if (typeof options.contractFor !== "function") throw new TypeError("createHumanCareTool requires contractFor");
5
- return {
6
- name: "odai_human_care",
7
- description: "Load Odai's non-crisis care and user-controlled interaction-style contract when the current message shows fatigue, anxiety, self-doubt, rumination, shame, fear of mistakes, negativity, or reduced agency. This does not diagnose, score, persist state, or change model routing.",
8
- parameters: {
9
- type: "object",
10
- additionalProperties: false,
11
- properties: {},
12
- },
13
- output: {
14
- schema: {
15
- type: "object",
16
- additionalProperties: false,
17
- required: ["scope", "userChannelOwner", "contract"],
18
- properties: {
19
- scope: { type: "string", enum: ["non-crisis-care"] },
20
- userChannelOwner: { type: "string", enum: ["current-controller", "controller"] },
21
- contract: { type: "string" },
2
+ export function createHumanCareTool(options) {
3
+ if (typeof options.contractFor !== "function")
4
+ throw new TypeError("createHumanCareTool requires contractFor");
5
+ return {
6
+ name: "odai_human_care",
7
+ description: "Load Odai's non-crisis care and user-controlled interaction-style contract when the current message shows fatigue, anxiety, self-doubt, rumination, shame, fear of mistakes, negativity, or reduced agency. This does not diagnose, score, persist state, or change model routing.",
8
+ parameters: {
9
+ type: "object",
10
+ additionalProperties: false,
11
+ properties: {},
22
12
  },
23
- },
24
- render(_args, value) {
25
- return [{
26
- type: "text",
27
- text: `Non-crisis care contract loaded; the ${value.userChannelOwner} owns the response.\n\n${value.contract}`,
28
- }];
29
- },
30
- },
31
- execute(args, execution) {
32
- if (args === null || typeof args !== "object" || Array.isArray(args) || Object.keys(args).length > 0) {
33
- throw new TypeError("odai_human_care accepts no arguments");
34
- }
35
- if (!execution.agent) throw new Error("odai_human_care requires an owning agent session");
36
- const contract = options.contractFor(execution.agent);
37
- if (typeof contract !== "string" || contract.trim() === "") throw new Error("Odai human-care contract is unavailable");
38
- return Promise.resolve({
39
- scope: "non-crisis-care",
40
- userChannelOwner: options.isChild?.(execution.agent) ? "controller" : "current-controller",
41
- contract: contract.trim(),
42
- });
43
- },
44
- };
13
+ output: {
14
+ schema: {
15
+ type: "object",
16
+ additionalProperties: false,
17
+ required: ["scope", "userChannelOwner", "contract"],
18
+ properties: {
19
+ scope: { type: "string", enum: ["non-crisis-care"] },
20
+ userChannelOwner: { type: "string", enum: ["current-controller", "controller"] },
21
+ contract: { type: "string" },
22
+ },
23
+ },
24
+ render(_arguments, value) {
25
+ return [{
26
+ type: "text",
27
+ text: `Non-crisis care contract loaded; the ${value.userChannelOwner} owns the response.\n\n${value.contract}`,
28
+ }];
29
+ },
30
+ },
31
+ execute(arguments_, execution) {
32
+ if (arguments_ === null || typeof arguments_ !== "object" || Array.isArray(arguments_) || Object.keys(arguments_).length > 0) {
33
+ throw new TypeError("odai_human_care accepts no arguments");
34
+ }
35
+ if (!execution.agent)
36
+ throw new Error("odai_human_care requires an owning agent session");
37
+ const contract = options.contractFor(execution.agent);
38
+ if (typeof contract !== "string" || contract.trim() === "")
39
+ throw new Error("Odai human-care contract is unavailable");
40
+ return Promise.resolve({
41
+ scope: "non-crisis-care",
42
+ userChannelOwner: options.isChild?.(execution.agent) ? "controller" : "current-controller",
43
+ contract: contract.trim(),
44
+ });
45
+ },
46
+ };
45
47
  }
48
+ //# sourceMappingURL=human-care.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"human-care.mjs","sourceRoot":"","sources":["../src/human-care.mts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAa9D,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAC/D,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU;QAAE,MAAM,IAAI,SAAS,CAAC,0CAA0C,CAAC,CAAC;IAC/G,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,oRAAoR;QACjS,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE,EAAE;SACf;QACD,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,QAAQ,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,UAAU,CAAC;gBACnD,UAAU,EAAE;oBACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,iBAAiB,CAAC,EAAE;oBACpD,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,oBAAoB,EAAE,YAAY,CAAC,EAAE;oBAChF,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC7B;aACF;YACD,MAAM,CAAC,UAAU,EAAE,KAAK;gBACtB,OAAO,CAAC;wBACN,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,wCAAwC,KAAK,CAAC,gBAAgB,0BAA0B,KAAK,CAAC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