@cogenta/agents 0.1.0

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 (293) hide show
  1. package/dist/agents/define.d.ts +9 -0
  2. package/dist/agents/define.d.ts.map +1 -0
  3. package/dist/agents/define.js +25 -0
  4. package/dist/agents/define.js.map +1 -0
  5. package/dist/agents/registry.d.ts +29 -0
  6. package/dist/agents/registry.d.ts.map +1 -0
  7. package/dist/agents/registry.js +50 -0
  8. package/dist/agents/registry.js.map +1 -0
  9. package/dist/agents/types.d.ts +36 -0
  10. package/dist/agents/types.d.ts.map +1 -0
  11. package/dist/agents/types.js +2 -0
  12. package/dist/agents/types.js.map +1 -0
  13. package/dist/audit/types.d.ts +23 -0
  14. package/dist/audit/types.d.ts.map +1 -0
  15. package/dist/audit/types.js +2 -0
  16. package/dist/audit/types.js.map +1 -0
  17. package/dist/audit/with-audit.d.ts +34 -0
  18. package/dist/audit/with-audit.d.ts.map +1 -0
  19. package/dist/audit/with-audit.js +65 -0
  20. package/dist/audit/with-audit.js.map +1 -0
  21. package/dist/autonomy/approval-queue.d.ts +13 -0
  22. package/dist/autonomy/approval-queue.d.ts.map +1 -0
  23. package/dist/autonomy/approval-queue.js +56 -0
  24. package/dist/autonomy/approval-queue.js.map +1 -0
  25. package/dist/autonomy/types.d.ts +36 -0
  26. package/dist/autonomy/types.d.ts.map +1 -0
  27. package/dist/autonomy/types.js +2 -0
  28. package/dist/autonomy/types.js.map +1 -0
  29. package/dist/autonomy/with-autonomy.d.ts +25 -0
  30. package/dist/autonomy/with-autonomy.d.ts.map +1 -0
  31. package/dist/autonomy/with-autonomy.js +77 -0
  32. package/dist/autonomy/with-autonomy.js.map +1 -0
  33. package/dist/budget/kill-switch.d.ts +14 -0
  34. package/dist/budget/kill-switch.d.ts.map +1 -0
  35. package/dist/budget/kill-switch.js +20 -0
  36. package/dist/budget/kill-switch.js.map +1 -0
  37. package/dist/budget/tracker.d.ts +15 -0
  38. package/dist/budget/tracker.d.ts.map +1 -0
  39. package/dist/budget/tracker.js +68 -0
  40. package/dist/budget/tracker.js.map +1 -0
  41. package/dist/budget/types.d.ts +35 -0
  42. package/dist/budget/types.d.ts.map +1 -0
  43. package/dist/budget/types.js +2 -0
  44. package/dist/budget/types.js.map +1 -0
  45. package/dist/eval/assert-threshold.d.ts +15 -0
  46. package/dist/eval/assert-threshold.d.ts.map +1 -0
  47. package/dist/eval/assert-threshold.js +27 -0
  48. package/dist/eval/assert-threshold.js.map +1 -0
  49. package/dist/eval/compare-prompt-versions.d.ts +17 -0
  50. package/dist/eval/compare-prompt-versions.d.ts.map +1 -0
  51. package/dist/eval/compare-prompt-versions.js +20 -0
  52. package/dist/eval/compare-prompt-versions.js.map +1 -0
  53. package/dist/eval/run-suite.d.ts +4 -0
  54. package/dist/eval/run-suite.d.ts.map +1 -0
  55. package/dist/eval/run-suite.js +18 -0
  56. package/dist/eval/run-suite.js.map +1 -0
  57. package/dist/eval/scorers.d.ts +13 -0
  58. package/dist/eval/scorers.d.ts.map +1 -0
  59. package/dist/eval/scorers.js +33 -0
  60. package/dist/eval/scorers.js.map +1 -0
  61. package/dist/eval/types.d.ts +27 -0
  62. package/dist/eval/types.d.ts.map +1 -0
  63. package/dist/eval/types.js +2 -0
  64. package/dist/eval/types.js.map +1 -0
  65. package/dist/identity/constitution.d.ts +17 -0
  66. package/dist/identity/constitution.d.ts.map +1 -0
  67. package/dist/identity/constitution.js +33 -0
  68. package/dist/identity/constitution.js.map +1 -0
  69. package/dist/identity/context.d.ts +49 -0
  70. package/dist/identity/context.d.ts.map +1 -0
  71. package/dist/identity/context.js +67 -0
  72. package/dist/identity/context.js.map +1 -0
  73. package/dist/index.d.ts +99 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +55 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/memory/file-store.d.ts +6 -0
  78. package/dist/memory/file-store.d.ts.map +1 -0
  79. package/dist/memory/file-store.js +94 -0
  80. package/dist/memory/file-store.js.map +1 -0
  81. package/dist/memory/from-approval.d.ts +20 -0
  82. package/dist/memory/from-approval.d.ts.map +1 -0
  83. package/dist/memory/from-approval.js +38 -0
  84. package/dist/memory/from-approval.js.map +1 -0
  85. package/dist/memory/memory-store.d.ts +4 -0
  86. package/dist/memory/memory-store.d.ts.map +1 -0
  87. package/dist/memory/memory-store.js +55 -0
  88. package/dist/memory/memory-store.js.map +1 -0
  89. package/dist/memory/types.d.ts +67 -0
  90. package/dist/memory/types.d.ts.map +1 -0
  91. package/dist/memory/types.js +2 -0
  92. package/dist/memory/types.js.map +1 -0
  93. package/dist/privacy/assert-provider-allowed.d.ts +10 -0
  94. package/dist/privacy/assert-provider-allowed.d.ts.map +1 -0
  95. package/dist/privacy/assert-provider-allowed.js +20 -0
  96. package/dist/privacy/assert-provider-allowed.js.map +1 -0
  97. package/dist/privacy/redact-fields.d.ts +11 -0
  98. package/dist/privacy/redact-fields.d.ts.map +1 -0
  99. package/dist/privacy/redact-fields.js +26 -0
  100. package/dist/privacy/redact-fields.js.map +1 -0
  101. package/dist/privacy/redact-text.d.ts +4 -0
  102. package/dist/privacy/redact-text.d.ts.map +1 -0
  103. package/dist/privacy/redact-text.js +26 -0
  104. package/dist/privacy/redact-text.js.map +1 -0
  105. package/dist/privacy/types.d.ts +23 -0
  106. package/dist/privacy/types.d.ts.map +1 -0
  107. package/dist/privacy/types.js +2 -0
  108. package/dist/privacy/types.js.map +1 -0
  109. package/dist/providers/anthropic.d.ts +57 -0
  110. package/dist/providers/anthropic.d.ts.map +1 -0
  111. package/dist/providers/anthropic.js +130 -0
  112. package/dist/providers/anthropic.js.map +1 -0
  113. package/dist/providers/google.d.ts +63 -0
  114. package/dist/providers/google.d.ts.map +1 -0
  115. package/dist/providers/google.js +144 -0
  116. package/dist/providers/google.js.map +1 -0
  117. package/dist/providers/openai.d.ts +56 -0
  118. package/dist/providers/openai.d.ts.map +1 -0
  119. package/dist/providers/openai.js +143 -0
  120. package/dist/providers/openai.js.map +1 -0
  121. package/dist/providers/registry.d.ts +31 -0
  122. package/dist/providers/registry.d.ts.map +1 -0
  123. package/dist/providers/registry.js +35 -0
  124. package/dist/providers/registry.js.map +1 -0
  125. package/dist/providers/types.d.ts +63 -0
  126. package/dist/providers/types.d.ts.map +1 -0
  127. package/dist/providers/types.js +10 -0
  128. package/dist/providers/types.js.map +1 -0
  129. package/dist/rag/chunking/chunk-document.d.ts +13 -0
  130. package/dist/rag/chunking/chunk-document.d.ts.map +1 -0
  131. package/dist/rag/chunking/chunk-document.js +51 -0
  132. package/dist/rag/chunking/chunk-document.js.map +1 -0
  133. package/dist/rag/chunking/incremental.d.ts +19 -0
  134. package/dist/rag/chunking/incremental.d.ts.map +1 -0
  135. package/dist/rag/chunking/incremental.js +24 -0
  136. package/dist/rag/chunking/incremental.js.map +1 -0
  137. package/dist/rag/chunking/types.d.ts +34 -0
  138. package/dist/rag/chunking/types.d.ts.map +1 -0
  139. package/dist/rag/chunking/types.js +2 -0
  140. package/dist/rag/chunking/types.js.map +1 -0
  141. package/dist/rag/embeddings/hashing-provider.d.ts +22 -0
  142. package/dist/rag/embeddings/hashing-provider.d.ts.map +1 -0
  143. package/dist/rag/embeddings/hashing-provider.js +53 -0
  144. package/dist/rag/embeddings/hashing-provider.js.map +1 -0
  145. package/dist/rag/embeddings/types.d.ts +16 -0
  146. package/dist/rag/embeddings/types.d.ts.map +1 -0
  147. package/dist/rag/embeddings/types.js +2 -0
  148. package/dist/rag/embeddings/types.js.map +1 -0
  149. package/dist/rag/index/bm25.d.ts +4 -0
  150. package/dist/rag/index/bm25.d.ts.map +1 -0
  151. package/dist/rag/index/bm25.js +38 -0
  152. package/dist/rag/index/bm25.js.map +1 -0
  153. package/dist/rag/index/memory-index.d.ts +12 -0
  154. package/dist/rag/index/memory-index.d.ts.map +1 -0
  155. package/dist/rag/index/memory-index.js +44 -0
  156. package/dist/rag/index/memory-index.js.map +1 -0
  157. package/dist/rag/index/rrf.d.ts +9 -0
  158. package/dist/rag/index/rrf.d.ts.map +1 -0
  159. package/dist/rag/index/rrf.js +20 -0
  160. package/dist/rag/index/rrf.js.map +1 -0
  161. package/dist/rag/index/types.d.ts +48 -0
  162. package/dist/rag/index/types.d.ts.map +1 -0
  163. package/dist/rag/index/types.js +2 -0
  164. package/dist/rag/index/types.js.map +1 -0
  165. package/dist/rag/index/vector-rank.d.ts +4 -0
  166. package/dist/rag/index/vector-rank.d.ts.map +1 -0
  167. package/dist/rag/index/vector-rank.js +27 -0
  168. package/dist/rag/index/vector-rank.js.map +1 -0
  169. package/dist/reversibility/diff.d.ts +17 -0
  170. package/dist/reversibility/diff.d.ts.map +1 -0
  171. package/dist/reversibility/diff.js +39 -0
  172. package/dist/reversibility/diff.js.map +1 -0
  173. package/dist/reversibility/receipt-store.d.ts +9 -0
  174. package/dist/reversibility/receipt-store.d.ts.map +1 -0
  175. package/dist/reversibility/receipt-store.js +34 -0
  176. package/dist/reversibility/receipt-store.js.map +1 -0
  177. package/dist/reversibility/revert.d.ts +18 -0
  178. package/dist/reversibility/revert.d.ts.map +1 -0
  179. package/dist/reversibility/revert.js +38 -0
  180. package/dist/reversibility/revert.js.map +1 -0
  181. package/dist/reversibility/types.d.ts +25 -0
  182. package/dist/reversibility/types.d.ts.map +1 -0
  183. package/dist/reversibility/types.js +2 -0
  184. package/dist/reversibility/types.js.map +1 -0
  185. package/dist/reversibility/with-receipts.d.ts +19 -0
  186. package/dist/reversibility/with-receipts.d.ts.map +1 -0
  187. package/dist/reversibility/with-receipts.js +35 -0
  188. package/dist/reversibility/with-receipts.js.map +1 -0
  189. package/dist/runtime/loop.d.ts +11 -0
  190. package/dist/runtime/loop.d.ts.map +1 -0
  191. package/dist/runtime/loop.js +116 -0
  192. package/dist/runtime/loop.js.map +1 -0
  193. package/dist/runtime/repetition.d.ts +16 -0
  194. package/dist/runtime/repetition.d.ts.map +1 -0
  195. package/dist/runtime/repetition.js +38 -0
  196. package/dist/runtime/repetition.js.map +1 -0
  197. package/dist/runtime/retry.d.ts +22 -0
  198. package/dist/runtime/retry.d.ts.map +1 -0
  199. package/dist/runtime/retry.js +69 -0
  200. package/dist/runtime/retry.js.map +1 -0
  201. package/dist/runtime/types.d.ts +78 -0
  202. package/dist/runtime/types.d.ts.map +1 -0
  203. package/dist/runtime/types.js +2 -0
  204. package/dist/runtime/types.js.map +1 -0
  205. package/dist/sandbox/types.d.ts +20 -0
  206. package/dist/sandbox/types.d.ts.map +1 -0
  207. package/dist/sandbox/types.js +2 -0
  208. package/dist/sandbox/types.js.map +1 -0
  209. package/dist/sandbox/with-sandbox.d.ts +26 -0
  210. package/dist/sandbox/with-sandbox.d.ts.map +1 -0
  211. package/dist/sandbox/with-sandbox.js +41 -0
  212. package/dist/sandbox/with-sandbox.js.map +1 -0
  213. package/dist/skills/file-store.d.ts +13 -0
  214. package/dist/skills/file-store.d.ts.map +1 -0
  215. package/dist/skills/file-store.js +73 -0
  216. package/dist/skills/file-store.js.map +1 -0
  217. package/dist/skills/frontmatter.d.ts +11 -0
  218. package/dist/skills/frontmatter.d.ts.map +1 -0
  219. package/dist/skills/frontmatter.js +46 -0
  220. package/dist/skills/frontmatter.js.map +1 -0
  221. package/dist/skills/types.d.ts +19 -0
  222. package/dist/skills/types.d.ts.map +1 -0
  223. package/dist/skills/types.js +2 -0
  224. package/dist/skills/types.js.map +1 -0
  225. package/dist/skin/generate.d.ts +22 -0
  226. package/dist/skin/generate.d.ts.map +1 -0
  227. package/dist/skin/generate.js +144 -0
  228. package/dist/skin/generate.js.map +1 -0
  229. package/dist/subagents/run-subagent.d.ts +10 -0
  230. package/dist/subagents/run-subagent.d.ts.map +1 -0
  231. package/dist/subagents/run-subagent.js +24 -0
  232. package/dist/subagents/run-subagent.js.map +1 -0
  233. package/dist/subagents/types.d.ts +13 -0
  234. package/dist/subagents/types.d.ts.map +1 -0
  235. package/dist/subagents/types.js +2 -0
  236. package/dist/subagents/types.js.map +1 -0
  237. package/dist/subagents/validate.d.ts +8 -0
  238. package/dist/subagents/validate.d.ts.map +1 -0
  239. package/dist/subagents/validate.js +32 -0
  240. package/dist/subagents/validate.js.map +1 -0
  241. package/dist/tools/core/agent-delegate.d.ts +34 -0
  242. package/dist/tools/core/agent-delegate.d.ts.map +1 -0
  243. package/dist/tools/core/agent-delegate.js +41 -0
  244. package/dist/tools/core/agent-delegate.js.map +1 -0
  245. package/dist/tools/core/content.d.ts +81 -0
  246. package/dist/tools/core/content.d.ts.map +1 -0
  247. package/dist/tools/core/content.js +121 -0
  248. package/dist/tools/core/content.js.map +1 -0
  249. package/dist/tools/core/http-fetch.d.ts +33 -0
  250. package/dist/tools/core/http-fetch.d.ts.map +1 -0
  251. package/dist/tools/core/http-fetch.js +63 -0
  252. package/dist/tools/core/http-fetch.js.map +1 -0
  253. package/dist/tools/core/media.d.ts +38 -0
  254. package/dist/tools/core/media.d.ts.map +1 -0
  255. package/dist/tools/core/media.js +93 -0
  256. package/dist/tools/core/media.js.map +1 -0
  257. package/dist/tools/core/site-config.d.ts +19 -0
  258. package/dist/tools/core/site-config.d.ts.map +1 -0
  259. package/dist/tools/core/site-config.js +37 -0
  260. package/dist/tools/core/site-config.js.map +1 -0
  261. package/dist/tools/define.d.ts +12 -0
  262. package/dist/tools/define.d.ts.map +1 -0
  263. package/dist/tools/define.js +28 -0
  264. package/dist/tools/define.js.map +1 -0
  265. package/dist/tools/manifest.d.ts +19 -0
  266. package/dist/tools/manifest.d.ts.map +1 -0
  267. package/dist/tools/manifest.js +70 -0
  268. package/dist/tools/manifest.js.map +1 -0
  269. package/dist/tools/registry.d.ts +8 -0
  270. package/dist/tools/registry.d.ts.map +1 -0
  271. package/dist/tools/registry.js +20 -0
  272. package/dist/tools/registry.js.map +1 -0
  273. package/dist/tools/types.d.ts +51 -0
  274. package/dist/tools/types.d.ts.map +1 -0
  275. package/dist/tools/types.js +2 -0
  276. package/dist/tools/types.js.map +1 -0
  277. package/dist/trace/capture.d.ts +19 -0
  278. package/dist/trace/capture.d.ts.map +1 -0
  279. package/dist/trace/capture.js +31 -0
  280. package/dist/trace/capture.js.map +1 -0
  281. package/dist/trace/file-store.d.ts +12 -0
  282. package/dist/trace/file-store.d.ts.map +1 -0
  283. package/dist/trace/file-store.js +78 -0
  284. package/dist/trace/file-store.js.map +1 -0
  285. package/dist/trace/memory-store.d.ts +9 -0
  286. package/dist/trace/memory-store.d.ts.map +1 -0
  287. package/dist/trace/memory-store.js +36 -0
  288. package/dist/trace/memory-store.js.map +1 -0
  289. package/dist/trace/types.d.ts +37 -0
  290. package/dist/trace/types.d.ts.map +1 -0
  291. package/dist/trace/types.js +2 -0
  292. package/dist/trace/types.js.map +1 -0
  293. package/package.json +44 -0
@@ -0,0 +1,9 @@
1
+ import type { AgentDeclaration } from './types.js';
2
+ /**
3
+ * Structural validation a type alone cannot enforce, mirroring `defineTool`
4
+ * (task 4): a name and an identity document are load-bearing strings, not
5
+ * decorative ones. Returns the declaration frozen, same reasoning as
6
+ * `defineTool` — nothing downstream mutates a shared declaration.
7
+ */
8
+ export declare function defineAgent(declaration: AgentDeclaration): AgentDeclaration;
9
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/agents/define.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,gBAAgB,GAAG,gBAAgB,CAiB3E"}
@@ -0,0 +1,25 @@
1
+ import { CogentaError } from '@cogenta/core';
2
+ /**
3
+ * Structural validation a type alone cannot enforce, mirroring `defineTool`
4
+ * (task 4): a name and an identity document are load-bearing strings, not
5
+ * decorative ones. Returns the declaration frozen, same reasoning as
6
+ * `defineTool` — nothing downstream mutates a shared declaration.
7
+ */
8
+ export function defineAgent(declaration) {
9
+ if (declaration.name.trim() === '') {
10
+ throw new CogentaError({
11
+ code: 'AGENT_DEFINITION_INVALID',
12
+ message: 'An agent declares an empty name.',
13
+ hint: 'Give the agent a stable, unique name.',
14
+ });
15
+ }
16
+ if (declaration.identity.trim() === '') {
17
+ throw new CogentaError({
18
+ code: 'AGENT_DEFINITION_INVALID',
19
+ message: `Agent "${declaration.name}" declares no identity document.`,
20
+ hint: 'Point `identity` at the file describing this agent’s role, objectives and style.',
21
+ });
22
+ }
23
+ return Object.freeze(declaration);
24
+ }
25
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/agents/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAG5C;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,WAA6B;IACvD,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,YAAY,CAAC;YACrB,IAAI,EAAE,0BAA0B;YAChC,OAAO,EAAE,kCAAkC;YAC3C,IAAI,EAAE,uCAAuC;SAC9C,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,YAAY,CAAC;YACrB,IAAI,EAAE,0BAA0B;YAChC,OAAO,EAAE,UAAU,WAAW,CAAC,IAAI,kCAAkC;YACrE,IAAI,EAAE,kFAAkF;SACzF,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;AACnC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { KillSwitch } from '../budget/types.js';
2
+ import type { AgentDeclaration } from './types.js';
3
+ export interface AgentRegistry {
4
+ list(): readonly AgentDeclaration[];
5
+ get(name: string): AgentDeclaration | undefined;
6
+ /** Re-enables a disabled agent — new runs may start; it does not affect what is already stopped. */
7
+ enable(name: string): void;
8
+ /**
9
+ * Disables an agent by flipping its shared kill switch — "désactiver un
10
+ * agent l'arrête immédiatement, y compris un run en cours". Every
11
+ * `runAgentLoop` call for this agent must be constructed with
12
+ * `killSwitchFor(name)` as its `killSwitch` for that guarantee to hold;
13
+ * this registry only owns the switch, not the runs themselves.
14
+ */
15
+ disable(name: string): void;
16
+ isEnabled(name: string): boolean;
17
+ /** The one `KillSwitch` instance shared by every run of this agent. */
18
+ killSwitchFor(name: string): KillSwitch;
19
+ }
20
+ /**
21
+ * "Format d'agent intégré, chargement, activation/désactivation" — loads a
22
+ * fixed set of `AgentDeclaration`s, checked once at construction (task 11's
23
+ * `validateSubagentTools`, since an `AgentDeclaration` is already a
24
+ * structural `AgentToolsDeclaration`), and gives each one a dedicated,
25
+ * shared kill switch for its enabled/disabled lifecycle. Every agent starts
26
+ * enabled.
27
+ */
28
+ export declare function createAgentRegistry(declarations: readonly AgentDeclaration[]): AgentRegistry;
29
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/agents/registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,WAAW,aAAa;IAC5B,IAAI,IAAI,SAAS,gBAAgB,EAAE,CAAA;IACnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAA;IAC/C,oGAAoG;IACpG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IAChC,uEAAuE;IACvE,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;CACxC;AAiBD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,SAAS,gBAAgB,EAAE,GAAG,aAAa,CA+B5F"}
@@ -0,0 +1,50 @@
1
+ import { CogentaError } from '@cogenta/core';
2
+ import { createKillSwitch } from '../budget/kill-switch.js';
3
+ import { validateSubagentTools } from '../subagents/validate.js';
4
+ function requireDeclaration(byName, name) {
5
+ const declaration = byName.get(name);
6
+ if (declaration === undefined) {
7
+ throw new CogentaError({
8
+ code: 'AGENT_UNKNOWN',
9
+ message: `No agent named "${name}" is registered.`,
10
+ hint: 'Check the name against `list()`, or register the agent before referring to it.',
11
+ });
12
+ }
13
+ return declaration;
14
+ }
15
+ /**
16
+ * "Format d'agent intégré, chargement, activation/désactivation" — loads a
17
+ * fixed set of `AgentDeclaration`s, checked once at construction (task 11's
18
+ * `validateSubagentTools`, since an `AgentDeclaration` is already a
19
+ * structural `AgentToolsDeclaration`), and gives each one a dedicated,
20
+ * shared kill switch for its enabled/disabled lifecycle. Every agent starts
21
+ * enabled.
22
+ */
23
+ export function createAgentRegistry(declarations) {
24
+ validateSubagentTools(declarations);
25
+ const byName = new Map(declarations.map((declaration) => [declaration.name, declaration]));
26
+ const killSwitches = new Map(declarations.map((declaration) => [declaration.name, createKillSwitch(false)]));
27
+ function requireKillSwitch(name) {
28
+ requireDeclaration(byName, name);
29
+ // Built from the same `declarations` this constructor validated above, so a
30
+ // name that passed `requireDeclaration` always has a matching switch.
31
+ return killSwitches.get(name);
32
+ }
33
+ return {
34
+ list: () => declarations,
35
+ get: (name) => byName.get(name),
36
+ enable(name) {
37
+ requireKillSwitch(name).deactivate();
38
+ },
39
+ disable(name) {
40
+ requireKillSwitch(name).activate();
41
+ },
42
+ isEnabled(name) {
43
+ return !requireKillSwitch(name).isActive();
44
+ },
45
+ killSwitchFor(name) {
46
+ return requireKillSwitch(name);
47
+ },
48
+ };
49
+ }
50
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/agents/registry.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AC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;QAC/B,MAAM,CAAC,IAAI;YACT,iBAAiB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAA;QACtC,CAAC;QACD,OAAO,CAAC,IAAI;YACV,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;QACpC,CAAC;QACD,SAAS,CAAC,IAAI;YACZ,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC5C,CAAC;QACD,aAAa,CAAC,IAAI;YAChB,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { AutonomyConfig } from '../autonomy/types.js';
2
+ import type { BudgetLimits } from '../budget/types.js';
3
+ export interface AgentModelPreference {
4
+ readonly preferred: string;
5
+ readonly fallback?: string;
6
+ }
7
+ export interface AgentTrigger {
8
+ readonly on: string;
9
+ /** Present only for `on: 'schedule'` triggers. */
10
+ readonly cron?: string;
11
+ }
12
+ export interface AgentMemoryConfig {
13
+ readonly episodic?: boolean;
14
+ readonly semantic?: boolean;
15
+ readonly procedural?: boolean;
16
+ readonly scope?: 'agent' | 'site';
17
+ }
18
+ /**
19
+ * Contract C's `defineAgent({...})` (`tools@1.0`, ADR-0020), reproduced as a
20
+ * type — `autonomy` and `budget` reuse the exact types tasks 8/9 already
21
+ * built rather than re-declaring their shape here.
22
+ */
23
+ export interface AgentDeclaration {
24
+ readonly name: string;
25
+ /** A path to the agent's identity document (role, objectives, style) — read by whoever assembles context (task 3), not by this module. */
26
+ readonly identity: string;
27
+ readonly model: AgentModelPreference;
28
+ readonly tools: readonly string[];
29
+ readonly skills?: readonly string[];
30
+ readonly subagents?: readonly string[];
31
+ readonly autonomy?: AutonomyConfig;
32
+ readonly budget?: BudgetLimits;
33
+ readonly memory?: AgentMemoryConfig;
34
+ readonly triggers?: readonly AgentTrigger[];
35
+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C,MAAM,CAAC,EAAE,iBAAiB,CAAA;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;CAC5C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/agents/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The narrow slice of `@cogenta/auth`'s `AuditLog` this module writes to —
3
+ * declared locally rather than imported so `@cogenta/agents` does not pull
4
+ * in `@simplewebauthn/server` just to describe one method. A real
5
+ * `AuditLog` (`createAuditLog`, `packages/auth/src/audit.ts`) already
6
+ * satisfies this structurally: it was built generic on purpose so L4 could
7
+ * become "a second writer" without redesigning it.
8
+ */
9
+ export interface AuditRecordInput {
10
+ readonly actorId: string | null;
11
+ readonly actorRoles: readonly string[];
12
+ readonly action: string;
13
+ readonly collection?: string;
14
+ readonly entryId?: string;
15
+ readonly diff?: Readonly<Record<string, unknown>>;
16
+ }
17
+ export interface AuditLogLike {
18
+ record(input: AuditRecordInput): Promise<{
19
+ readonly id: string;
20
+ readonly hash: string;
21
+ }>;
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/audit/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAClD;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACzF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/audit/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import type { ExecutableTool } from '../runtime/types.js';
2
+ import type { AuditLogLike } from './types.js';
3
+ export interface WithAuditOptions {
4
+ readonly auditLog: AuditLogLike;
5
+ readonly agentName: string;
6
+ readonly actor: {
7
+ readonly id: string | null;
8
+ readonly roles: readonly string[];
9
+ };
10
+ /** Injectable so tests never depend on real wall-clock duration. */
11
+ readonly now?: () => number;
12
+ /** Pulls `{collection, entryId}` out of a tool's input when it touches content, so the entry links to the right one — absent for tools that don't (site.config_read, http.fetch). */
13
+ readonly targetOf?: (input: Readonly<Record<string, unknown>>) => {
14
+ readonly collection?: string;
15
+ readonly entryId?: string;
16
+ };
17
+ /**
18
+ * Called when `auditLog.record` itself fails. Never rethrown: ADR-0018's
19
+ * own rule — "a write that fails must never fail the action it is
20
+ * auditing" — applies here exactly as it did for L2's first writer.
21
+ */
22
+ readonly onAuditFailure?: (error: unknown) => void;
23
+ }
24
+ /**
25
+ * L4 task 6: "Tout appel [d'outil] produit une entrée d'audit : acteur,
26
+ * agent, outil, entrée, sortie, diff, coût, durée." Wraps one
27
+ * `ExecutableTool` so every call — success or failure — is recorded once it
28
+ * resolves, never before: an entry that records only "attempted" and not
29
+ * "what happened" is not the accountability this rule asks for.
30
+ */
31
+ export declare function withAudit(tool: ExecutableTool, options: WithAuditOptions): ExecutableTool;
32
+ /** Applies `withAudit` to every tool in a manifest, so a caller does not have to remember to wrap each one individually. */
33
+ export declare function withAuditForManifest(tools: readonly ExecutableTool[], options: WithAuditOptions): readonly ExecutableTool[];
34
+ //# sourceMappingURL=with-audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-audit.d.ts","sourceRoot":"","sources":["../../src/audit/with-audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAA;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,YAAY,CAAA;AAEhE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAA;IACjF,oEAAoE;IACpE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAC3B,qLAAqL;IACrL,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK;QAChE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;QAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAC1B,CAAA;IACD;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CACnD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAqDzF;AAED,4HAA4H;AAC5H,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,EAAE,gBAAgB,GACxB,SAAS,cAAc,EAAE,CAE3B"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * L4 task 6: "Tout appel [d'outil] produit une entrée d'audit : acteur,
3
+ * agent, outil, entrée, sortie, diff, coût, durée." Wraps one
4
+ * `ExecutableTool` so every call — success or failure — is recorded once it
5
+ * resolves, never before: an entry that records only "attempted" and not
6
+ * "what happened" is not the accountability this rule asks for.
7
+ */
8
+ export function withAudit(tool, options) {
9
+ const now = options.now ?? Date.now;
10
+ async function record(input) {
11
+ try {
12
+ await options.auditLog.record(input);
13
+ }
14
+ catch (error) {
15
+ options.onAuditFailure?.(error);
16
+ }
17
+ }
18
+ return {
19
+ spec: tool.spec,
20
+ async execute(input, ctx) {
21
+ const startedAt = now();
22
+ const target = options.targetOf?.(input) ?? {};
23
+ try {
24
+ const output = await tool.execute(input, ctx);
25
+ await record({
26
+ actorId: options.actor.id,
27
+ actorRoles: options.actor.roles,
28
+ action: `agent.tool.${tool.spec.name}`,
29
+ ...target,
30
+ diff: {
31
+ agent: options.agentName,
32
+ tool: tool.spec.name,
33
+ input,
34
+ output,
35
+ durationMs: now() - startedAt,
36
+ ok: true,
37
+ },
38
+ });
39
+ return output;
40
+ }
41
+ catch (error) {
42
+ await record({
43
+ actorId: options.actor.id,
44
+ actorRoles: options.actor.roles,
45
+ action: `agent.tool.${tool.spec.name}`,
46
+ ...target,
47
+ diff: {
48
+ agent: options.agentName,
49
+ tool: tool.spec.name,
50
+ input,
51
+ durationMs: now() - startedAt,
52
+ ok: false,
53
+ error: error instanceof Error ? error.message : String(error),
54
+ },
55
+ });
56
+ throw error;
57
+ }
58
+ },
59
+ };
60
+ }
61
+ /** Applies `withAudit` to every tool in a manifest, so a caller does not have to remember to wrap each one individually. */
62
+ export function withAuditForManifest(tools, options) {
63
+ return tools.map((tool) => withAudit(tool, options));
64
+ }
65
+ //# sourceMappingURL=with-audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-audit.js","sourceRoot":"","sources":["../../src/aud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ACf,MAAM,MAAM,CAAC;oBACX,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE;oBACzB,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK;oBAC/B,MAAM,EAAE,cAAc,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;oBACtC,GAAG,MAAM;oBACT,IAAI,EAAE;wBACJ,KAAK,EAAE,OAAO,CAAC,SAAS;wBACxB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;wBACpB,KAAK;wBACL,UAAU,EAAE,GAAG,EAAE,GAAG,SAAS;wBAC7B,EAAE,EAAE,KAAK;wBACT,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;qBAC9D;iBACF,CAAC,CAAA;gBACF,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC;AAED,4HAA4H;AAC5H,MAAM,UAAU,oBAAoB,CAClC,KAAgC,EAChC,OAAyB;IAEzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;AACtD,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { ApprovalQueue } from './types.js';
2
+ export interface MemoryApprovalQueueOptions {
3
+ readonly now?: () => number;
4
+ readonly newId?: () => string;
5
+ }
6
+ /**
7
+ * In-process, one queue per running server — enough for `execute_with_approval`
8
+ * to block a run on a real human decision, and for the admin/channel surfaces
9
+ * (L2/L6) to list and decide requests. A durable, cross-process version is a
10
+ * later concern once those surfaces exist to need one.
11
+ */
12
+ export declare function createMemoryApprovalQueue(options?: MemoryApprovalQueueOptions): ApprovalQueue;
13
+ //# sourceMappingURL=approval-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-queue.d.ts","sourceRoot":"","sources":["../../src/autonomy/approval-queue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EAId,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAA;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,0BAA+B,GAAG,aAAa,CAuDjG"}
@@ -0,0 +1,56 @@
1
+ import { CogentaError, newId } from '@cogenta/core';
2
+ /**
3
+ * In-process, one queue per running server — enough for `execute_with_approval`
4
+ * to block a run on a real human decision, and for the admin/channel surfaces
5
+ * (L2/L6) to list and decide requests. A durable, cross-process version is a
6
+ * later concern once those surfaces exist to need one.
7
+ */
8
+ export function createMemoryApprovalQueue(options = {}) {
9
+ const now = options.now ?? Date.now;
10
+ const generateId = options.newId ?? newId;
11
+ const requests = new Map();
12
+ const resolvers = new Map();
13
+ return {
14
+ request(input) {
15
+ const id = generateId();
16
+ const record = {
17
+ id,
18
+ agentName: input.agentName,
19
+ toolName: input.toolName,
20
+ input: input.input,
21
+ requestedAt: new Date(now()).toISOString(),
22
+ status: 'pending',
23
+ };
24
+ requests.set(id, record);
25
+ return new Promise((resolve) => {
26
+ resolvers.set(id, resolve);
27
+ });
28
+ },
29
+ async list(status) {
30
+ const all = [...requests.values()];
31
+ return status === undefined ? all : all.filter((request) => request.status === status);
32
+ },
33
+ async decide(id, decision, decidedBy, reason) {
34
+ const existing = requests.get(id);
35
+ if (existing === undefined) {
36
+ throw new CogentaError({
37
+ code: 'APPROVAL_REQUEST_UNKNOWN',
38
+ message: `No approval request with id "${id}".`,
39
+ hint: 'Check the id, or list pending requests to find the right one.',
40
+ });
41
+ }
42
+ const decided = {
43
+ ...existing,
44
+ status: decision,
45
+ decidedAt: new Date(now()).toISOString(),
46
+ decidedBy,
47
+ ...(reason === undefined ? {} : { reason }),
48
+ };
49
+ requests.set(id, decided);
50
+ resolvers.get(id)?.(decided);
51
+ resolvers.delete(id);
52
+ return decided;
53
+ },
54
+ };
55
+ }
56
+ //# sourceMappingURL=approval-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-queue.js","sourceRoot":"","sources":["../../src/autonomy/approval-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAanD;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAO,GAA+B,EAAE;IAChF,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAA;IACnC,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAA;IACzC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAA;IACnD,MAAM,SAAS,GAAG,IAAI,GAAG,EAA8C,CAAA;IAEvE,OAAO;QACL,OAAO,CAAC,KAA2B;YACjC,MAAM,EAAE,GAAG,UAAU,EAAE,CAAA;YACvB,MAAM,MAAM,GAAoB;gBAC9B,EAAE;gBACF,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,WAAW,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE;gBAC1C,MAAM,EAAE,SAAS;aAClB,CAAA;YACD,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;YACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC7B,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;YAC5B,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,MAAuB;YAChC,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;YAClC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;QACxF,CAAC;QAED,KAAK,CAAC,MAAM,CACV,EAAU,EACV,QAAiC,EACjC,SAAiB,EACjB,MAAe;YAEf,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACjC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,MAAM,IAAI,YAAY,CAAC;oBACrB,IAAI,EAAE,0BAA0B;oBAChC,OAAO,EAAE,gCAAgC,EAAE,IAAI;oBAC/C,IAAI,EAAE,+DAA+D;iBACtE,CAAC,CAAA;YACJ,CAAC;YACD,MAAM,OAAO,GAAoB;gBAC/B,GAAG,QAAQ;gBACX,MAAM,EAAE,QAAQ;gBAChB,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE;gBACxC,SAAS;gBACT,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;aAC5C,CAAA;YACD,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;YACzB,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAA;YAC5B,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YACpB,OAAO,OAAO,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,36 @@
1
+ /** Contract C's four levels, settable per agent and per tool (`defineAgent`'s `autonomy: { default, 'tool.name': level }`). */
2
+ export type AutonomyLevel = 'observe' | 'propose' | 'execute_with_approval' | 'autonomous';
3
+ export interface AutonomyConfig {
4
+ readonly default: AutonomyLevel;
5
+ /** Per-tool overrides, keyed by tool name. */
6
+ readonly overrides?: Readonly<Record<string, AutonomyLevel>>;
7
+ }
8
+ export type ApprovalStatus = 'pending' | 'approved' | 'rejected';
9
+ export interface ApprovalRequest {
10
+ readonly id: string;
11
+ readonly agentName: string;
12
+ readonly toolName: string;
13
+ readonly input: Readonly<Record<string, unknown>>;
14
+ readonly requestedAt: string;
15
+ readonly status: ApprovalStatus;
16
+ readonly decidedAt?: string;
17
+ readonly decidedBy?: string;
18
+ readonly reason?: string;
19
+ }
20
+ export interface ApprovalRequestInput {
21
+ readonly agentName: string;
22
+ readonly toolName: string;
23
+ readonly input: Readonly<Record<string, unknown>>;
24
+ }
25
+ /**
26
+ * "La file d'approbation est consultable dans l'admin et actionnable depuis
27
+ * un canal (L6)" — this is the queue those surfaces will read and act on;
28
+ * building the admin/channel UI for it is later work, not this task's.
29
+ */
30
+ export interface ApprovalQueue {
31
+ /** Creates a pending request and resolves once a human decides it. */
32
+ request(input: ApprovalRequestInput): Promise<ApprovalRequest>;
33
+ list(status?: ApprovalStatus): Promise<readonly ApprovalRequest[]>;
34
+ decide(id: string, decision: 'approved' | 'rejected', decidedBy: string, reason?: string): Promise<ApprovalRequest>;
35
+ }
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/autonomy/types.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAC/H,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,uBAAuB,GAAG,YAAY,CAAA;AAE1F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAA;CAC7D;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAA;AAEhE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""}
@@ -0,0 +1,25 @@
1
+ import type { ExecutableTool } from '../runtime/types.js';
2
+ import type { ApprovalQueue, AutonomyConfig } from './types.js';
3
+ export interface WithAutonomyOptions {
4
+ readonly agentName: string;
5
+ readonly autonomy: AutonomyConfig;
6
+ readonly approvalQueue: ApprovalQueue;
7
+ }
8
+ /**
9
+ * L4 task 9. `sideEffects: true` with `reversible` not `true` — the same
10
+ * condition `defineTool` already requires either `revert` or forced human
11
+ * approval for (Contract C's own rule) — always routes through the
12
+ * approval queue, regardless of the configured level: `autonomous` cannot
13
+ * waive it, only a human decision can. A tool with no declared
14
+ * `sideEffects` is treated as side-effecting (the conservative default:
15
+ * an unlabelled tool gets the gate, not a free pass).
16
+ *
17
+ * "`autonomous` sur un outil destructif exige une confirmation explicite à
18
+ * l'activation, avec avertissement" is a config-time concern (validating a
19
+ * `defineAgent` before it is saved) — out of this runtime decorator's
20
+ * scope, which only ever sees an already-activated configuration.
21
+ */
22
+ export declare function withAutonomy(tool: ExecutableTool, options: WithAutonomyOptions): ExecutableTool;
23
+ /** Applies `withAutonomy` to every tool in a manifest. */
24
+ export declare function withAutonomyForManifest(tools: readonly ExecutableTool[], options: WithAutonomyOptions): readonly ExecutableTool[];
25
+ //# sourceMappingURL=with-autonomy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-autonomy.d.ts","sourceRoot":"","sources":["../../src/autonomy/with-autonomy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,qBAAqB,CAAA;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAA;AAE9E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAA;IACjC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAA;CACtC;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,mBAAmB,GAAG,cAAc,CA8D/F;AAED,0DAA0D;AAC1D,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,EAAE,mBAAmB,GAC3B,SAAS,cAAc,EAAE,CAE3B"}
@@ -0,0 +1,77 @@
1
+ import { CogentaError } from '@cogenta/core';
2
+ function levelFor(toolName, autonomy) {
3
+ return autonomy.overrides?.[toolName] ?? autonomy.default;
4
+ }
5
+ /**
6
+ * L4 task 9. `sideEffects: true` with `reversible` not `true` — the same
7
+ * condition `defineTool` already requires either `revert` or forced human
8
+ * approval for (Contract C's own rule) — always routes through the
9
+ * approval queue, regardless of the configured level: `autonomous` cannot
10
+ * waive it, only a human decision can. A tool with no declared
11
+ * `sideEffects` is treated as side-effecting (the conservative default:
12
+ * an unlabelled tool gets the gate, not a free pass).
13
+ *
14
+ * "`autonomous` sur un outil destructif exige une confirmation explicite à
15
+ * l'activation, avec avertissement" is a config-time concern (validating a
16
+ * `defineAgent` before it is saved) — out of this runtime decorator's
17
+ * scope, which only ever sees an already-activated configuration.
18
+ */
19
+ export function withAutonomy(tool, options) {
20
+ const isSideEffecting = tool.sideEffects !== false;
21
+ const forcedApproval = isSideEffecting && tool.reversible !== true;
22
+ async function awaitApproval(input, ctx) {
23
+ const decision = await options.approvalQueue.request({
24
+ agentName: options.agentName,
25
+ toolName: tool.spec.name,
26
+ input,
27
+ });
28
+ if (decision.status !== 'approved') {
29
+ throw new CogentaError({
30
+ code: 'TOOL_CALL_REJECTED',
31
+ message: `"${tool.spec.name}" was rejected by human review${decision.reason === undefined ? '.' : `: ${decision.reason}`}`,
32
+ hint: 'Try a different approach, or ask a human to approve the request.',
33
+ });
34
+ }
35
+ return tool.execute(input, ctx);
36
+ }
37
+ return {
38
+ spec: tool.spec,
39
+ ...(tool.sideEffects === undefined ? {} : { sideEffects: tool.sideEffects }),
40
+ ...(tool.reversible === undefined ? {} : { reversible: tool.reversible }),
41
+ async execute(input, ctx) {
42
+ if (!isSideEffecting)
43
+ return tool.execute(input, ctx);
44
+ const level = levelFor(tool.spec.name, options.autonomy);
45
+ if (!forcedApproval && level === 'observe') {
46
+ return {
47
+ observed: true,
48
+ note: `Observation mode: "${tool.spec.name}" was not called.`,
49
+ };
50
+ }
51
+ if (!forcedApproval && level === 'propose') {
52
+ // Deliberately not awaited: "propose" hands the decision to a human
53
+ // and moves on — the run does not block waiting for it, unlike
54
+ // execute_with_approval below.
55
+ void options.approvalQueue.request({
56
+ agentName: options.agentName,
57
+ toolName: tool.spec.name,
58
+ input,
59
+ });
60
+ return {
61
+ proposed: true,
62
+ note: `Proposed "${tool.spec.name}"; awaiting human review.`,
63
+ };
64
+ }
65
+ if (!forcedApproval && level === 'autonomous') {
66
+ return tool.execute(input, ctx);
67
+ }
68
+ // execute_with_approval, or any level overridden by forcedApproval.
69
+ return awaitApproval(input, ctx);
70
+ },
71
+ };
72
+ }
73
+ /** Applies `withAutonomy` to every tool in a manifest. */
74
+ export function withAutonomyForManifest(tools, options) {
75
+ return tools.map((tool) => withAutonomy(tool, options));
76
+ }
77
+ //# sourceMappingURL=with-autonomy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-autonomy.js","sourceRoot":"","sources":["../../src/autonomy/with-autonomy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAU5C,SAAS,QAAQ,CAAC,QAAgB,EAAE,QAAwB;IAC1D,OAAO,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAA;AAC3D,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAAC,IAAoB,EAAE,OAA4B;IAC7E,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,KAAK,KAAK,CAAA;IAClD,MAAM,cAAc,GAAG,eAAe,IAAI,IAAI,CAAC,UAAU,KAAK,IAA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CAAA;YAExD,IAAI,CAAC,cAAc,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC3C,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,sBAAsB,IAAI,CAAC,IAAI,CAAC,IAAI,mBAAmB;iBAC9D,CAAA;YACH,CAAC;YAED,IAAI,CAAC,cAAc,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC3C,oEAAoE;gBACpE,+DAA+D;gBAC/D,+BAA+B;gBAC/B,KAAK,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC;oBACjC,SAAS,EAAE,OAAO,CAAC,SAAS;oBAC5B,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;oBACxB,KAAK;iBACN,CAAC,CAAA;gBACF,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,aAAa,IAAI,CAAC,IAAI,CAAC,IAAI,2BAA2B;iBAC7D,CAAA;YACH,CAAC;YAED,IAAI,CAAC,cAAc,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;gBAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;YACjC,CAAC;YAED,oEAAoE;YACpE,OAAO,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAClC,CAAC;KACF,CAAA;AACH,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,uBAAuB,CACrC,KAAgC,EAChC,OAA4B;IAE5B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;AACzD,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { KillSwitch } from './types.js';
2
+ export interface MutableKillSwitch extends KillSwitch {
3
+ activate(): void;
4
+ deactivate(): void;
5
+ }
6
+ /**
7
+ * An explicit, human-flipped stop — independent of budgets, which trip on
8
+ * their own from measured usage. Shared across every run for the same
9
+ * agent (construct once, pass the same instance into every `runAgentLoop`
10
+ * call for that agent) so flipping it stops the next step of *every*
11
+ * in-flight run, not just new ones.
12
+ */
13
+ export declare function createKillSwitch(initial?: boolean): MutableKillSwitch;
14
+ //# sourceMappingURL=kill-switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kill-switch.d.ts","sourceRoot":"","sources":["../../src/budget/kill-switch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,QAAQ,IAAI,IAAI,CAAA;IAChB,UAAU,IAAI,IAAI,CAAA;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,UAAQ,GAAG,iBAAiB,CAWnE"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * An explicit, human-flipped stop — independent of budgets, which trip on
3
+ * their own from measured usage. Shared across every run for the same
4
+ * agent (construct once, pass the same instance into every `runAgentLoop`
5
+ * call for that agent) so flipping it stops the next step of *every*
6
+ * in-flight run, not just new ones.
7
+ */
8
+ export function createKillSwitch(initial = false) {
9
+ let active = initial;
10
+ return {
11
+ isActive: () => active,
12
+ activate: () => {
13
+ active = true;
14
+ },
15
+ deactivate: () => {
16
+ active = false;
17
+ },
18
+ };
19
+ }
20
+ //# sourceMappingURL=kill-switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kill-switch.js","sourceRoot":"","sources":["../../src/budget/kill-switch.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAO,GAAG,KAAK;IAC9C,IAAI,MAAM,GAAG,OAAO,CAAA;IACpB,OAAO;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM;QACtB,QAAQ,EAAE,GAAG,EAAE;YACb,MAAM,GAAG,IAAI,CAAA;QACf,CAAC;QACD,UAAU,EAAE,GAAG,EAAE;YACf,MAAM,GAAG,KAAK,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC"}