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,105 +1,110 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import {
3
- closeSync,
4
- fsyncSync,
5
- mkdirSync,
6
- openSync,
7
- readFileSync,
8
- rmSync,
9
- writeSync,
10
- } from "node:fs";
2
+ import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, rmSync, writeSync, } from "node:fs";
11
3
  import { dirname } from "node:path";
12
-
4
+ function errorCode(error) {
5
+ if (error === null || typeof error !== "object" || !("code" in error))
6
+ return undefined;
7
+ return typeof error.code === "string" ? error.code : undefined;
8
+ }
13
9
  function readLockOwner(lockPath) {
14
- try {
15
- const value = readFileSync(lockPath, "utf8").trim();
16
- const separator = value.indexOf(":");
17
- const pid = Number(separator < 0 ? "" : value.slice(0, separator));
18
- return Number.isSafeInteger(pid) && pid > 0 && separator < value.length - 1
19
- ? { value, pid }
20
- : undefined;
21
- } catch (error) {
22
- if (error?.code === "ENOENT") return undefined;
23
- throw error;
24
- }
10
+ try {
11
+ const value = readFileSync(lockPath, "utf8").trim();
12
+ const separator = value.indexOf(":");
13
+ const pid = Number(separator < 0 ? "" : value.slice(0, separator));
14
+ return Number.isSafeInteger(pid) && pid > 0 && separator < value.length - 1
15
+ ? { value, pid }
16
+ : undefined;
17
+ }
18
+ catch (error) {
19
+ if (errorCode(error) === "ENOENT")
20
+ return undefined;
21
+ throw error;
22
+ }
25
23
  }
26
-
27
24
  function processIsAlive(pid) {
28
- try {
29
- process.kill(pid, 0);
30
- return true;
31
- } catch (error) {
32
- return error?.code !== "ESRCH";
33
- }
25
+ try {
26
+ process.kill(pid, 0);
27
+ return true;
28
+ }
29
+ catch (error) {
30
+ return errorCode(error) !== "ESRCH";
31
+ }
34
32
  }
35
-
36
33
  function createLock(lockPath, owner) {
37
- const handle = openSync(lockPath, "wx", 0o600);
38
- try {
39
- const content = Buffer.from(`${owner}\n`, "utf8");
40
- if (writeSync(handle, content, 0, content.length) !== content.length) {
41
- throw new Error(`short write while acquiring Odai configuration lock: ${lockPath}`);
34
+ const handle = openSync(lockPath, "wx", 0o600);
35
+ try {
36
+ const content = Buffer.from(`${owner}\n`, "utf8");
37
+ if (writeSync(handle, content, 0, content.length) !== content.length) {
38
+ throw new Error(`short write while acquiring Odai configuration lock: ${lockPath}`);
39
+ }
40
+ fsyncSync(handle);
41
+ return handle;
42
+ }
43
+ catch (error) {
44
+ closeSync(handle);
45
+ rmSync(lockPath, { force: true });
46
+ throw error;
42
47
  }
43
- fsyncSync(handle);
44
- return handle;
45
- } catch (error) {
46
- closeSync(handle);
47
- rmSync(lockPath, { force: true });
48
- throw error;
49
- }
50
48
  }
51
-
52
49
  function releaseLock(handle, lockPath, owner) {
53
- closeSync(handle);
54
- const current = readLockOwner(lockPath);
55
- if (current === undefined) throw new Error(`Odai configuration lock disappeared before release: ${lockPath}`);
56
- if (current.value !== owner) throw new Error(`Odai configuration lock ownership changed before release: ${lockPath}`);
57
- rmSync(lockPath);
50
+ closeSync(handle);
51
+ const current = readLockOwner(lockPath);
52
+ if (current === undefined)
53
+ throw new Error(`Odai configuration lock disappeared before release: ${lockPath}`);
54
+ if (current.value !== owner)
55
+ throw new Error(`Odai configuration lock ownership changed before release: ${lockPath}`);
56
+ rmSync(lockPath);
58
57
  }
59
-
60
58
  export function acquireOwnedStoreLock(path, label) {
61
- mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
62
- const lockPath = `${path}.lock`;
63
- const claimPath = `${lockPath}.claim`;
64
- const owner = `${process.pid}:${randomUUID()}`;
65
- const claimOwner = `${process.pid}:${randomUUID()}`;
66
- let claimHandle;
67
- try {
68
- claimHandle = createLock(claimPath, claimOwner);
69
- } catch (error) {
70
- if (error?.code === "EEXIST") {
71
- throw new Error(`${label} lock acquisition is already in progress; retry the tool call`);
72
- }
73
- throw error;
74
- }
75
-
76
- let handle;
77
- try {
59
+ mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
60
+ const lockPath = `${path}.lock`;
61
+ const claimPath = `${lockPath}.claim`;
62
+ const owner = `${process.pid}:${randomUUID()}`;
63
+ const claimOwner = `${process.pid}:${randomUUID()}`;
64
+ let claimHandle;
78
65
  try {
79
- handle = createLock(lockPath, owner);
80
- } catch (error) {
81
- if (error?.code !== "EEXIST") throw error;
82
- const current = readLockOwner(lockPath);
83
- if (current === undefined || processIsAlive(current.pid)) {
84
- throw new Error(`${label} is being updated; retry the tool call`);
85
- }
86
- rmSync(lockPath);
87
- handle = createLock(lockPath, owner);
66
+ claimHandle = createLock(claimPath, claimOwner);
88
67
  }
89
- } finally {
68
+ catch (error) {
69
+ if (errorCode(error) === "EEXIST") {
70
+ throw new Error(`${label} lock acquisition is already in progress; retry the tool call`);
71
+ }
72
+ throw error;
73
+ }
74
+ let handle;
90
75
  try {
91
- releaseLock(claimHandle, claimPath, claimOwner);
92
- } catch (error) {
93
- if (handle !== undefined) {
94
76
  try {
95
- releaseLock(handle, lockPath, owner);
96
- } catch {}
97
- handle = undefined;
98
- }
99
- throw error;
77
+ handle = createLock(lockPath, owner);
78
+ }
79
+ catch (error) {
80
+ if (errorCode(error) !== "EEXIST")
81
+ throw error;
82
+ const current = readLockOwner(lockPath);
83
+ if (current === undefined || processIsAlive(current.pid)) {
84
+ throw new Error(`${label} is being updated; retry the tool call`);
85
+ }
86
+ rmSync(lockPath);
87
+ handle = createLock(lockPath, owner);
88
+ }
89
+ }
90
+ finally {
91
+ try {
92
+ releaseLock(claimHandle, claimPath, claimOwner);
93
+ }
94
+ catch (error) {
95
+ if (handle !== undefined) {
96
+ try {
97
+ releaseLock(handle, lockPath, owner);
98
+ }
99
+ catch { }
100
+ handle = undefined;
101
+ }
102
+ throw error;
103
+ }
100
104
  }
101
- }
102
-
103
- if (handle === undefined) throw new Error(`could not lock ${label}`);
104
- return () => releaseLock(handle, lockPath, owner);
105
+ if (handle === undefined)
106
+ throw new Error(`could not lock ${label}`);
107
+ const ownedHandle = handle;
108
+ return () => releaseLock(ownedHandle, lockPath, owner);
105
109
  }
110
+ //# sourceMappingURL=store-lock.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-lock.mjs","sourceRoot":"","sources":["../src/store-lock.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACxF,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACrC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QACpD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QACnE,OAAO,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC;YACzE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;YAChB,CA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AM,KAAK,CAAC;YAC/C,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;YACxC,IAAI,OAAO,KAAK,SAAS,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzD,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,wCAAwC,CAAC,CAAC;YACpE,CAAC;YACD,MAAM,CAAC,QAAQ,CAAC,CAAC;YACjB,MAAM,GAAG,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,WAAW,CAAC,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,IAAI,CAAC;oBACH,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACvC,CAAC;gBAAC,MAAM,CAAC,CAAA,CAAC;gBACV,MAAM,GAAG,SAAS,CAAC;YACrB,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,EAAE,CAAC,CAAC;IACrE,MAAM,WAAW,GAAG,MAAM,CAAC;IAC3B,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { OutputPolicy } from "./output-config.mjs";
2
+ import type { ContextActivation } from "./context-activation.mjs";
3
+ import type { ResponsibilityGapProposal } from "./responsibility-gap.mjs";
4
+ import type { SkillBundle } from "./skill-bundle.mjs";
5
+ import type { SkillSelection } from "./runtime-support.mjs";
6
+ import type { DshAgent, DshEvent, DshRuntimeContext, RuntimeConfig, RuntimeEventData, RuntimeLogger, UnknownRecord } from "./runtime-types.mjs";
7
+ interface RouteProtection extends UnknownRecord {
8
+ scopeId?: string;
9
+ }
10
+ interface PromptInstaller {
11
+ install(deps: {
12
+ pendingResponsibilityGap: ToolRuntimeDependencies["pendingResponsibilityGap"];
13
+ syncToolExposure: (agent: DshAgent, activation: ContextActivation, options: {
14
+ turn?: number;
15
+ step: number;
16
+ routeCard: boolean;
17
+ }) => readonly string[];
18
+ }): void;
19
+ }
20
+ interface ToolRuntimeDependencies {
21
+ appendEvent(agent: DshAgent, type: string, data: object): void;
22
+ baseSelection: SkillSelection;
23
+ bundled: SkillBundle;
24
+ config: RuntimeConfig;
25
+ ctx: DshRuntimeContext;
26
+ evidence: {
27
+ events(agent: DshAgent): DshEvent[];
28
+ };
29
+ evolutionDisabled: boolean;
30
+ explicitSkillPath: boolean;
31
+ hasSessionEvent(agent: DshAgent, type: string, predicate: (data: RuntimeEventData) => boolean): boolean;
32
+ humanSafetyContinuityStorePath: string;
33
+ logger: RuntimeLogger;
34
+ pendingResponsibilityGap(agent: DshAgent, turn: number | undefined, step: number): ResponsibilityGapProposal | undefined;
35
+ promptRuntime: PromptInstaller;
36
+ routeProtections: WeakMap<DshAgent, RouteProtection>;
37
+ selectOutputForAgent(): {
38
+ policy: OutputPolicy;
39
+ };
40
+ }
41
+ export declare function installToolRuntime(deps: ToolRuntimeDependencies): void;
42
+ export {};
43
+ //# sourceMappingURL=tool-runtime.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-runtime.d.mts","sourceRoot":"","sources":["../src/tool-runtime.mts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAOlE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAK1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,KAA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AAwB,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,yBAAyB,GAAG,SAAS,CAAC;IACzH,aAAa,EAAE,eAAe,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACrD,oBAAoB,IAAI;QAAE,MAAM,EAAE,YAAY,CAAA;KAAE,CAAC;CAClD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,CA+MtE"}
@@ -0,0 +1,221 @@
1
+ import { classifyImplementationAuthorization, extractLatestUserText } from "./router.mjs";
2
+ import { activeRouteProtection, createChildToolGuard, createRouteProtectionGuard, isSubagent, summarizeToolResult } from "./governance.mjs";
3
+ import { createRoutingConfigTool, effectiveRoutingSnapshot } from "./routing-config.mjs";
4
+ import { createOutputConfigTool } from "./output-config.mjs";
5
+ import { createCompactionConfigTool } from "./compaction-config.mjs";
6
+ import { ODAI_CORE_TOOL_NAMES, activeOdaiToolNames, inactiveOdaiToolNames } from "./context-activation.mjs";
7
+ import { createContextCapabilityTool } from "./context-capability.mjs";
8
+ import { HUMAN_CARE_REFERENCE_PATH, createHumanCareTool } from "./human-care.mjs";
9
+ import { HUMAN_SAFETY_REFERENCE_PATH, createHumanSafetyTool } from "./human-safety.mjs";
10
+ import { createHumanSafetyContinuityTool } from "./human-safety-continuity.mjs";
11
+ import { activeRouteCard, createRouteCardTool, unsettledRouteCard } from "./route-card.mjs";
12
+ import { createResponsibilityGapTool } from "./responsibility-gap.mjs";
13
+ import { createSkillSourceConfigTool } from "./skill-source-config.mjs";
14
+ import { createSkillEvolutionTool, applySkillEvolutionSelection } from "./skill-evolution.mjs";
15
+ import { createSemanticMemoryTool, latestDirectUserMessage } from "./semantic-memory.mjs";
16
+ import { readSkillBundleFile } from "./skill-bundle.mjs";
17
+ import { currentAgentTurn, sharedSkillSelection } from "./skill-selection-state.mjs";
18
+ import { currentAgentStep, isSubagentSession, latestRouteReceipt } from "./runtime-support.mjs";
19
+ export function installToolRuntime(deps) {
20
+ const { appendEvent, baseSelection, bundled, config, ctx, evidence, evolutionDisabled, explicitSkillPath, hasSessionEvent, humanSafetyContinuityStorePath, logger, pendingResponsibilityGap, promptRuntime, routeProtections, selectOutputForAgent } = deps;
21
+ const onDenied = (execution, reason) => {
22
+ appendEvent(execution.agent, "odai/governance-denied", {
23
+ callId: String(execution.callId),
24
+ tool: execution.name,
25
+ reason,
26
+ });
27
+ };
28
+ const childGuard = createChildToolGuard({
29
+ additionalDeniedTools: config.governance.additionalDeniedTools,
30
+ onDenied,
31
+ });
32
+ const routeProtectionGuard = createRouteProtectionGuard({
33
+ additionalDeniedTools: config.governance.additionalDeniedTools,
34
+ onDenied,
35
+ protectionFor(agent) {
36
+ if (config.routing.mode === "off")
37
+ return undefined;
38
+ return routeProtections.get(agent) ?? activeRouteProtection(agent, evidence.events(agent));
39
+ },
40
+ });
41
+ ctx.tools.register(createContextCapabilityTool({
42
+ isChild: isSubagent,
43
+ onRequested(agent, capability) {
44
+ const turn = currentAgentTurn(agent);
45
+ const step = currentAgentStep(agent);
46
+ appendEvent(agent, "odai/context-capability-requested", {
47
+ ...(turn === undefined ? {} : { turn }),
48
+ ...(step === undefined ? {} : { step }),
49
+ capability,
50
+ });
51
+ },
52
+ }));
53
+ ctx.tools.register(createRoutingConfigTool(config.routing.configPath, {
54
+ configuredRoles: config.routing.roles,
55
+ resolveCallConfig(route, signal) {
56
+ return ctx.llm.resolveCallConfig(route, signal);
57
+ },
58
+ latestRouteFor(agent) {
59
+ return latestRouteReceipt(evidence.events(agent));
60
+ },
61
+ outputPolicyFor() {
62
+ return selectOutputForAgent().policy;
63
+ },
64
+ onConfigured(agent, data) {
65
+ appendEvent(agent, "odai/routing-configured", data);
66
+ },
67
+ }));
68
+ ctx.tools.register(createHumanCareTool({
69
+ isChild: isSubagent,
70
+ contractFor(agent) {
71
+ const bundle = sharedSkillSelection(agent)?.bundle ?? bundled;
72
+ return readSkillBundleFile(bundle, HUMAN_CARE_REFERENCE_PATH).toString("utf8");
73
+ },
74
+ }));
75
+ ctx.tools.register(createHumanSafetyTool({
76
+ isChild: isSubagent,
77
+ contractFor(agent) {
78
+ const bundle = sharedSkillSelection(agent)?.bundle ?? bundled;
79
+ return readSkillBundleFile(bundle, HUMAN_SAFETY_REFERENCE_PATH).toString("utf8");
80
+ },
81
+ }));
82
+ ctx.tools.register(createResponsibilityGapTool({
83
+ isChild: isSubagent,
84
+ onProposed(agent, proposal) {
85
+ const turn = currentAgentTurn(agent);
86
+ const step = currentAgentStep(agent);
87
+ appendEvent(agent, "odai/responsibility-gap", {
88
+ ...(turn === undefined ? {} : { turn }),
89
+ ...(step === undefined ? {} : { step }),
90
+ ...proposal,
91
+ });
92
+ },
93
+ }));
94
+ ctx.tools.register(createRouteCardTool({
95
+ activeFor(agent) {
96
+ return activeRouteCard(evidence.events(agent));
97
+ },
98
+ unsettledFor(agent) {
99
+ return unsettledRouteCard(evidence.events(agent));
100
+ },
101
+ authorizationFor(agent) {
102
+ const message = latestDirectUserMessage(agent);
103
+ if (!message)
104
+ return Object.freeze({ status: "unknown" });
105
+ return Object.freeze({
106
+ ...classifyImplementationAuthorization(extractLatestUserText([message])),
107
+ userMessageId: message.id,
108
+ });
109
+ },
110
+ onFrozen(agent, card) {
111
+ appendEvent(agent, "odai/route-card-frozen", { card });
112
+ },
113
+ onCleared(agent, cardId) {
114
+ appendEvent(agent, "odai/route-card-cleared", { cardId });
115
+ },
116
+ }));
117
+ ctx.tools.register(createSkillSourceConfigTool(config.governance.skillConfigPath, config.governance.skillSource, {
118
+ explicitPath: explicitSkillPath,
119
+ onConfigured(agent, data) {
120
+ appendEvent(agent, "odai/skill-source-configured", data);
121
+ },
122
+ }));
123
+ ctx.tools.register(createSkillEvolutionTool(config.governance.evolutionRoot, {
124
+ disabled: evolutionDisabled,
125
+ currentSelectionFor(agent) {
126
+ return sharedSkillSelection(agent)
127
+ ?? applySkillEvolutionSelection(baseSelection, config.governance.evolutionRoot, { disabled: evolutionDisabled });
128
+ },
129
+ onChanged(agent, data) {
130
+ appendEvent(agent, `odai/evolution-${data.action}`, data);
131
+ },
132
+ }));
133
+ ctx.tools.register(createOutputConfigTool(config.output.configPath, {
134
+ isChild: isSubagent,
135
+ responsibilityRoutesFor() {
136
+ try {
137
+ return effectiveRoutingSnapshot(config.routing.configPath, config.routing.roles).roles;
138
+ }
139
+ catch {
140
+ return undefined;
141
+ }
142
+ },
143
+ onConfigured(agent, data) {
144
+ appendEvent(agent, "odai/output-configured", data);
145
+ },
146
+ }));
147
+ ctx.tools.register(createCompactionConfigTool(config.compaction.configPath, {
148
+ isChild: isSubagent,
149
+ resolveCallConfig(route, signal) {
150
+ return ctx.llm.resolveCallConfig(route, signal);
151
+ },
152
+ onConfigured(agent, data) {
153
+ appendEvent(agent, "odai/compaction-configured", data);
154
+ },
155
+ }));
156
+ ctx.tools.register(createSemanticMemoryTool(config.memory.storePath, {
157
+ configuredMode: config.memory.mode,
158
+ onChanged(agent, data) {
159
+ appendEvent(agent, "odai/memory-changed", data);
160
+ },
161
+ }));
162
+ ctx.tools.register(createHumanSafetyContinuityTool({
163
+ storePath: humanSafetyContinuityStorePath,
164
+ directUserTextFor(agent) {
165
+ const message = latestDirectUserMessage(agent);
166
+ return message ? extractLatestUserText([message]) : "";
167
+ },
168
+ onChanged(agent, data) {
169
+ appendEvent(agent, "odai/human-safety-continuity-changed", data);
170
+ },
171
+ }));
172
+ ctx.tools.guard?.((execution) => childGuard(execution) ?? routeProtectionGuard(execution));
173
+ const toolExposureStates = new WeakMap();
174
+ const syncToolExposure = (agent, activation, options = {}) => {
175
+ const child = isSubagentSession(agent);
176
+ const activeNames = activeOdaiToolNames(activation, { child, routeCard: options.routeCard === true });
177
+ const deniedNames = [
178
+ ...inactiveOdaiToolNames(activeNames),
179
+ ...(child ? ODAI_CORE_TOOL_NAMES : []),
180
+ ];
181
+ const key = deniedNames.join("\u0000");
182
+ const previous = toolExposureStates.get(agent);
183
+ if (previous?.key === key || previous?.key === "unsupported" || previous?.key === "fallback")
184
+ return activeNames;
185
+ previous?.dispose?.();
186
+ const agentTools = agent.ctx?.tools;
187
+ const restrict = agentTools?.restrict;
188
+ if (typeof restrict !== "function") {
189
+ toolExposureStates.set(agent, Object.freeze({ key: "unsupported", dispose: undefined }));
190
+ return activeNames;
191
+ }
192
+ try {
193
+ const restriction = deniedNames.length > 0
194
+ ? restrict.call(agentTools, { deny: deniedNames })
195
+ : undefined;
196
+ const dispose = typeof restriction === "function" ? restriction : undefined;
197
+ toolExposureStates.set(agent, Object.freeze({ key, dispose }));
198
+ appendEvent(agent, "odai/tool-exposure-selected", {
199
+ ...(options.turn === undefined ? {} : { turn: options.turn }),
200
+ ...(options.step === undefined ? {} : { step: options.step }),
201
+ mode: "adaptive",
202
+ activeTools: activeNames,
203
+ });
204
+ }
205
+ catch (error) {
206
+ logger.warn(`Odai adaptive execution restriction is unavailable; prompt schemas remain limited while the executable catalog stays complete: ${error instanceof Error ? error.message : String(error)}`);
207
+ toolExposureStates.set(agent, Object.freeze({ key: "fallback", dispose: undefined }));
208
+ }
209
+ return activeNames;
210
+ };
211
+ promptRuntime.install({ pendingResponsibilityGap, syncToolExposure });
212
+ ctx.on("tools/result", (execution, result) => {
213
+ if (!execution.agent)
214
+ return;
215
+ const summary = summarizeToolResult(execution, result);
216
+ if (hasSessionEvent(execution.agent, "odai/tool-observed", (data) => data?.callId === summary.callId))
217
+ return;
218
+ appendEvent(execution.agent, "odai/tool-observed", summary);
219
+ });
220
+ }
221
+ //# sourceMappingURL=tool-runtime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-runtime.mjs","sourceRoot":"","sources":["../src/tool-runtime.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE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AY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACxM,kBAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QACxF,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;IAEF,aAAa,CAAC,OAAO,CAAC,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAEtE,GAAG,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,SAAwB,EAAE,MAAkB,EAAE,EAAE;QACtE,IAAI,CAAC,SAAS,CAAC,KAAK;YAAE,OAAO;QAC7B,MAAM,OAAO,GAAG,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACvD,IAAI,eAAe,CAAC,SAAS,CAAC,KAAK,EAAE,oBAAoB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO;QAC9G,WAAW,CAAC,SAAS,CAAC,KAAK,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AAGL,CAAC"}
@@ -1,108 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { readDshVersion } from "../src/dsh-version.mjs";
4
- import {
5
- inspectAgentInstallation,
6
- installAgentPreset,
7
- SUPPORTED_DSH_VERSIONS,
8
- uninstallAgentPreset,
9
- } from "../src/installer.mjs";
10
-
11
- const HELP = `Usage: odai-dsh-agent <command> [options]
12
-
13
- Commands:
14
- install Install or update the managed Odai preset
15
- status Inspect the managed Odai preset
16
- uninstall Remove the preset when its managed files are unchanged
17
-
18
- Options:
19
- --dsh-home <path> Override DSH_HOME
20
- --json Print JSON
21
- --yes Confirm DSH is stopped; active-process verification still applies
22
- -h, --help Show this help
23
- `;
24
-
25
- try {
26
- const args = parseArgs(process.argv.slice(2));
27
- if (args.help) {
28
- process.stdout.write(HELP);
29
- } else if (args.command === "install") {
30
- const dshVersion = assertDshVersion();
31
- print(await installAgentPreset({
32
- dshHome: args.dshHome,
33
- dshVersion,
34
- confirmDshStopped: args.yes,
35
- }), args.json);
36
- } else if (args.command === "status") {
37
- const result = await inspectAgentInstallation({ dshHome: args.dshHome });
38
- print(result, args.json);
39
- if (result.status === "drifted") process.exitCode = 2;
40
- } else if (args.command === "uninstall") {
41
- print(await uninstallAgentPreset({
42
- dshHome: args.dshHome,
43
- confirmDshStopped: args.yes,
44
- }), args.json);
45
- } else {
46
- throw new Error("a command is required\n\n" + HELP);
47
- }
48
- } catch (error) {
49
- process.stderr.write(`odai-dsh-agent: ${error instanceof Error ? error.message : String(error)}\n`);
50
- process.exitCode = 1;
51
- }
52
-
53
- function assertDshVersion() {
54
- const dsh = process.env.DSH_BIN ?? "dsh";
55
- let actual;
56
- try {
57
- actual = readDshVersion({ dsh });
58
- } catch (error) {
59
- throw new Error(`cannot run ${dsh} -V; install one of ${SUPPORTED_DSH_VERSIONS.join(", ")} before installing the preset`);
60
- }
61
- if (!SUPPORTED_DSH_VERSIONS.includes(actual)) {
62
- throw new Error(`unsupported DSH version ${actual || "<empty>"}; expected one of ${SUPPORTED_DSH_VERSIONS.join(", ")}`);
63
- }
64
- return actual;
65
- }
66
-
67
- function parseArgs(argv) {
68
- const parsed = { command: undefined, dshHome: undefined, json: false, yes: false, help: false };
69
- for (let index = 0; index < argv.length; index += 1) {
70
- const arg = argv[index];
71
- if (arg === "-h" || arg === "--help") parsed.help = true;
72
- else if (arg === "--json") parsed.json = true;
73
- else if (arg === "--yes") parsed.yes = true;
74
- else if (arg === "--dsh-home") parsed.dshHome = argv[++index];
75
- else if (!parsed.command && ["install", "status", "uninstall"].includes(arg)) parsed.command = arg;
76
- else throw new Error(`unknown argument: ${arg}`);
77
- }
78
- if (parsed.dshHome !== undefined && (typeof parsed.dshHome !== "string" || parsed.dshHome.trim() === "")) {
79
- throw new Error("--dsh-home requires a non-empty path");
80
- }
81
- return parsed;
82
- }
83
-
84
- function print(result, json) {
85
- if (json) {
86
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
87
- return;
88
- }
89
- if (result.status) {
90
- process.stdout.write(`${result.status}: ${result.target}\n`);
91
- for (const issue of result.issues ?? []) process.stdout.write(`- ${issue}\n`);
92
- return;
93
- }
94
- process.stdout.write(`${result.operation}: ${result.target}\n`);
95
- if (result.sessionCompatibility?.repairedEvents > 0) {
96
- process.stdout.write(`session compatibility: made ${result.sessionCompatibility.repairedEvents} legacy Odai event(s) ignorable in ${result.sessionCompatibility.repairedArtifacts} session artifact(s)\n`);
97
- }
98
- if (result.sessionCompatibility?.backupPaths?.length > 0) {
99
- process.stdout.write(`session compatibility: retained ${result.sessionCompatibility.backupPaths.length} verified backup artifact(s)\n`);
100
- }
101
- for (const path of result.sessionCompatibility?.tornArtifacts ?? []) {
102
- process.stdout.write(`session compatibility warning: preserved DSH-recoverable torn tail: ${path}\n`);
103
- }
104
- for (const failure of result.sessionCompatibility?.failures ?? []) {
105
- process.stdout.write(`session compatibility warning: ${failure.path}: ${failure.error}\n`);
106
- }
107
- if (result.security) process.stdout.write(`security: ${result.security}\n`);
108
- }