odai-dsh-agent 0.2.1 → 0.2.2

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 (51) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +138 -138
  3. package/bin/odai-dsh-agent.mjs +108 -108
  4. package/package.json +69 -69
  5. package/preset/odai/agent.cordis.yml +260 -260
  6. package/preset/odai/preset.yml +3 -3
  7. package/preset/odai/runtime/compaction-config.mjs +388 -388
  8. package/preset/odai/runtime/governance.mjs +128 -128
  9. package/preset/odai/runtime/index.mjs +2461 -2263
  10. package/preset/odai/runtime/output-config.mjs +360 -304
  11. package/preset/odai/runtime/research-packet.mjs +150 -150
  12. package/preset/odai/runtime/responsibility-scope.mjs +35 -2
  13. package/preset/odai/runtime/role-overlays.mjs +27 -27
  14. package/preset/odai/runtime/route-card.mjs +168 -152
  15. package/preset/odai/runtime/router.mjs +683 -651
  16. package/preset/odai/runtime/routing-config.mjs +480 -436
  17. package/preset/odai/runtime/routing-context.mjs +321 -321
  18. package/preset/odai/runtime/semantic-memory-store.mjs +452 -452
  19. package/preset/odai/runtime/semantic-memory.mjs +842 -842
  20. package/preset/odai/runtime/session-compat.mjs +389 -389
  21. package/preset/odai/runtime/skill-bundle.mjs +318 -318
  22. package/preset/odai/runtime/skill-evolution.mjs +1413 -1413
  23. package/preset/odai/skills/odai/agents/openai.yaml +4 -4
  24. package/preset/odai/skills/odai/assets/claude-agents/agent.md +11 -11
  25. package/preset/odai/skills/odai/assets/codex-agents/config.toml +11 -11
  26. package/preset/odai/skills/odai/assets/codex-agents/role.toml +5 -5
  27. package/preset/odai/skills/odai/assets/copilot-agents/agent.md +13 -13
  28. package/preset/odai/skills/odai/assets/hooks-policy.example.json +24 -24
  29. package/preset/odai/skills/odai/assets/routing-roles/controller.md +15 -15
  30. package/preset/odai/skills/odai/assets/routing-roles/executor.md +11 -11
  31. package/preset/odai/skills/odai/assets/routing-roles/frontend.md +7 -7
  32. package/preset/odai/skills/odai/assets/routing-roles/planner.md +29 -29
  33. package/preset/odai/skills/odai/assets/routing-roles/researcher.md +6 -6
  34. package/preset/odai/skills/odai/assets/routing-roles/reviewer.md +11 -11
  35. package/preset/odai/skills/odai/assets/task-state.md +14 -14
  36. package/preset/odai/skills/odai/manifest.json +37 -37
  37. package/preset/odai/skills/odai/references/craft.md +54 -54
  38. package/preset/odai/skills/odai/references/dao.md +30 -30
  39. package/preset/odai/skills/odai/references/leverage.md +53 -53
  40. package/preset/odai/skills/odai/references/planning.md +82 -82
  41. package/preset/odai/skills/odai/references/support.md +36 -36
  42. package/preset/odai/skills/odai/references/verification.md +23 -23
  43. package/preset/odai/skills/odai/scripts/build-hooks.mjs +273 -273
  44. package/preset/odai/skills/odai/scripts/build-routing.mjs +274 -274
  45. package/preset/odai/skills/odai/scripts/install-routing.mjs +397 -397
  46. package/preset/odai/skills/odai/scripts/odai-hook.mjs +457 -457
  47. package/preset/odai/skills/odai/scripts/run-role.mjs +336 -336
  48. package/preset/odai/skills/odai/scripts/run-routing.mjs +1154 -1154
  49. package/preset/odai/skills/odai/scripts/verify-routing.mjs +103 -103
  50. package/scripts/verify-agent-load.mjs +257 -257
  51. package/src/installer.mjs +382 -382
@@ -1,128 +1,128 @@
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",
20
- ]);
21
-
22
- 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",
36
- ]);
37
-
38
- export function isSubagent(agent) {
39
- const header = agent?.session?.header;
40
- return header?.origin === "subagent"
41
- || (Number.isSafeInteger(header?.delegationDepth) && header.delegationDepth > 0);
42
- }
43
-
44
- 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
- };
59
- }
60
-
61
- 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;
82
- }
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;
89
- }
90
-
91
- 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
- };
112
- }
113
-
114
- 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;
128
- }
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",
20
+ ]);
21
+
22
+ 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",
36
+ ]);
37
+
38
+ export function isSubagent(agent) {
39
+ const header = agent?.session?.header;
40
+ return header?.origin === "subagent"
41
+ || (Number.isSafeInteger(header?.delegationDepth) && header.delegationDepth > 0);
42
+ }
43
+
44
+ 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
+ };
59
+ }
60
+
61
+ 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;
82
+ }
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;
89
+ }
90
+
91
+ 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
+ };
112
+ }
113
+
114
+ 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;
128
+ }