@backendkit-labs/agent-core 0.37.2 → 0.39.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 (102) hide show
  1. package/README.md +132 -43
  2. package/dist/delegation/DelegationBus.d.ts +8 -1
  3. package/dist/delegation/DelegationBus.d.ts.map +1 -1
  4. package/dist/delegation/DelegationBus.js +2 -1
  5. package/dist/delegation/DelegationBus.js.map +1 -1
  6. package/dist/engine/AgentEngine.d.ts +109 -25
  7. package/dist/engine/AgentEngine.d.ts.map +1 -1
  8. package/dist/engine/AgentEngine.js +467 -139
  9. package/dist/engine/AgentEngine.js.map +1 -1
  10. package/dist/engine/ApprovalGate.d.ts +4 -3
  11. package/dist/engine/ApprovalGate.d.ts.map +1 -1
  12. package/dist/engine/ApprovalGate.js +9 -13
  13. package/dist/engine/ApprovalGate.js.map +1 -1
  14. package/dist/engine/MCPRegistrar.js +1 -1
  15. package/dist/engine/MCPRegistrar.js.map +1 -1
  16. package/dist/engine/coding-pipeline-hooks.d.ts +28 -0
  17. package/dist/engine/coding-pipeline-hooks.d.ts.map +1 -0
  18. package/dist/engine/coding-pipeline-hooks.js +91 -0
  19. package/dist/engine/coding-pipeline-hooks.js.map +1 -0
  20. package/dist/engine/createBaseEngine.d.ts +32 -25
  21. package/dist/engine/createBaseEngine.d.ts.map +1 -1
  22. package/dist/engine/createBaseEngine.js +8 -6
  23. package/dist/engine/createBaseEngine.js.map +1 -1
  24. package/dist/engine/package-install.d.ts +7 -0
  25. package/dist/engine/package-install.d.ts.map +1 -1
  26. package/dist/engine/package-install.js +17 -0
  27. package/dist/engine/package-install.js.map +1 -1
  28. package/dist/engine/qa-orchestrator.d.ts +11 -12
  29. package/dist/engine/qa-orchestrator.d.ts.map +1 -1
  30. package/dist/engine/qa-orchestrator.js +13 -16
  31. package/dist/engine/qa-orchestrator.js.map +1 -1
  32. package/dist/governance/approval-store.d.ts +32 -0
  33. package/dist/governance/approval-store.d.ts.map +1 -0
  34. package/dist/governance/approval-store.js +129 -0
  35. package/dist/governance/approval-store.js.map +1 -0
  36. package/dist/governance/approval.d.ts +35 -0
  37. package/dist/governance/approval.d.ts.map +1 -0
  38. package/dist/governance/approval.js +65 -0
  39. package/dist/governance/approval.js.map +1 -0
  40. package/dist/governance/approvers.d.ts +24 -0
  41. package/dist/governance/approvers.d.ts.map +1 -0
  42. package/dist/governance/approvers.js +69 -0
  43. package/dist/governance/approvers.js.map +1 -0
  44. package/dist/governance/audit.d.ts +101 -0
  45. package/dist/governance/audit.d.ts.map +1 -0
  46. package/dist/governance/audit.js +178 -0
  47. package/dist/governance/audit.js.map +1 -0
  48. package/dist/governance/hooks.d.ts +62 -0
  49. package/dist/governance/hooks.d.ts.map +1 -0
  50. package/dist/governance/hooks.js +26 -0
  51. package/dist/governance/hooks.js.map +1 -0
  52. package/dist/governance/policy.d.ts +33 -0
  53. package/dist/governance/policy.d.ts.map +1 -0
  54. package/dist/governance/policy.js +115 -0
  55. package/dist/governance/policy.js.map +1 -0
  56. package/dist/governance/types.d.ts +162 -0
  57. package/dist/governance/types.d.ts.map +1 -0
  58. package/dist/governance/types.js +3 -0
  59. package/dist/governance/types.js.map +1 -0
  60. package/dist/index.d.ts +18 -12
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +53 -16
  63. package/dist/index.js.map +1 -1
  64. package/dist/mcp/tool-server-http.d.ts +2 -6
  65. package/dist/mcp/tool-server-http.d.ts.map +1 -1
  66. package/dist/mcp/tool-server-http.js +4 -20
  67. package/dist/mcp/tool-server-http.js.map +1 -1
  68. package/dist/mcp/tool-server.d.ts +18 -4
  69. package/dist/mcp/tool-server.d.ts.map +1 -1
  70. package/dist/mcp/tool-server.js +110 -22
  71. package/dist/mcp/tool-server.js.map +1 -1
  72. package/dist/reflection/index.d.ts +0 -7
  73. package/dist/reflection/index.d.ts.map +1 -1
  74. package/dist/reflection/index.js +1 -16
  75. package/dist/reflection/index.js.map +1 -1
  76. package/dist/sandbox/types.d.ts +2 -2
  77. package/dist/sandbox/types.d.ts.map +1 -1
  78. package/dist/shared/llm/chat-client.d.ts +16 -0
  79. package/dist/shared/llm/chat-client.d.ts.map +1 -0
  80. package/dist/shared/llm/chat-client.js +27 -0
  81. package/dist/shared/llm/chat-client.js.map +1 -0
  82. package/dist/shared/llm/resilient-client.d.ts +1 -1
  83. package/dist/shared/llm/resilient-client.d.ts.map +1 -1
  84. package/dist/shared/utils/canonical-json.d.ts +12 -0
  85. package/dist/shared/utils/canonical-json.d.ts.map +1 -0
  86. package/dist/shared/utils/canonical-json.js +29 -0
  87. package/dist/shared/utils/canonical-json.js.map +1 -0
  88. package/dist/shared/utils/loopback.d.ts +10 -0
  89. package/dist/shared/utils/loopback.d.ts.map +1 -0
  90. package/dist/shared/utils/loopback.js +25 -0
  91. package/dist/shared/utils/loopback.js.map +1 -0
  92. package/dist/tools/defineTool.d.ts +2 -0
  93. package/dist/tools/defineTool.d.ts.map +1 -1
  94. package/dist/tools/defineTool.js +1 -0
  95. package/dist/tools/defineTool.js.map +1 -1
  96. package/dist/tools/services.d.ts +7 -0
  97. package/dist/tools/services.d.ts.map +1 -0
  98. package/dist/tools/services.js +11 -0
  99. package/dist/tools/services.js.map +1 -0
  100. package/dist/types/index.d.ts +24 -38
  101. package/dist/types/index.d.ts.map +1 -1
  102. package/package.json +89 -93
package/README.md CHANGED
@@ -4,8 +4,6 @@ The foundation engine for the BackendKit Labs agent framework. Provides everythi
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@backendkit-labs/agent-core)](https://www.npmjs.com/package/@backendkit-labs/agent-core)
6
6
 
7
- > **Status: `core`** — Required by the enterprise use case. Breaking changes go through full review before merging.
8
-
9
7
  ## Table of contents
10
8
 
11
9
  - [Installation](#installation)
@@ -286,7 +284,7 @@ new AgentEngine({
286
284
 
287
285
  // Observability
288
286
  observability: obsManager,
289
- auditLog: '/path/to/audit.ndjson',
287
+ audit: new NdjsonAuditSink('/path/to/audit.ndjson'), // one AuditEvent per tool call (see Observability → Audit)
290
288
 
291
289
  // Context injected into the system prompt
292
290
  projectContext: 'You are working in project X...',
@@ -323,7 +321,7 @@ await engine.run('Analyze the database schema', {
323
321
  | `'step-by-step'` | Calls `onStep` after every iteration; return `false` to stop |
324
322
  | `'interactive'` | Calls `onIterationLimit` when cap is reached; return `true` to continue. Without that callback the run stops at the cap |
325
323
 
326
- Tool approval is independent of the mode: whenever `onToolApproval` is set, the engine asks before `write_file`, `edit_file`, `run_command` and package installs.
324
+ Tool approval is independent of the mode: whenever `onToolApproval` is set, the engine asks before `write_file`, `edit_file`, `run_command` and package installs. That is the legacy gate, and it is what coding agents should keep using for now. For approval decided by what tools declare (`readOnly`, `destructive`), by a policy, or by another agent or a service, see [Policy and approval](#policy-and-approval-per-call).
327
325
 
328
326
  ```typescript
329
327
  // Approval — user approves destructive tool calls
@@ -475,7 +473,7 @@ stored history is corrected and a `guardrail` event carries the `replacement` fo
475
473
  until the answer is checked: nothing unchecked is ever shown, but there is no streaming.
476
474
 
477
475
  Every redaction, block and error emits a `{ type: 'guardrail', name, phase, action, reason, ... }` event, is written to the
478
- `auditLog` as `guardrail:<phase>:<name>`, and is counted in `MetricsSnapshot.guardrails`.
476
+ legacy `auditLog` as `guardrail:<phase>:<name>`, and is counted in `MetricsSnapshot.guardrails`.
479
477
 
480
478
  ---
481
479
 
@@ -610,43 +608,29 @@ await engine.run("What's my name?"); // → "Your name is Alice."
610
608
 
611
609
  ## MCP client
612
610
 
613
- `MCPClientManager` connects to external MCP (Model Context Protocol) servers, discovers their tools, and makes them available to the engine. Supports stdio, Streamable HTTP, and SSE transports.
611
+ `MCPClientManager` connects to external MCP (Model Context Protocol) servers, discovers their tools, and makes them available to the engine. One `MCPServerConfig` per server decides the transport:
612
+
613
+ - `command` (+ `args`, `env`) — a local subprocess over stdio.
614
+ - `url` (+ `headers`) — a remote server over Streamable HTTP, falling back to SSE when the server answers 4xx; force one with `remoteTransport: 'streamable-http' | 'sse'`.
615
+ - When both are set, `url` wins.
614
616
 
615
- ### Stdio (most common)
617
+ ### Standalone
616
618
 
617
619
  ```typescript
618
620
  import { MCPClientManager } from '@backendkit-labs/agent-core';
619
621
 
620
- const mcp = new MCPClientManager();
621
-
622
- await mcp.connectStdio({
623
- name: 'filesystem',
624
- command: 'npx',
625
- args: ['-y', '@modelcontextprotocol/server-filesystem', '/workspace'],
626
- env: {},
627
- });
628
-
629
- const tools = mcp.getTools(); // ToolDefinition[] — discovered from the server
630
- ```
631
-
632
- ### HTTP transport
622
+ const mcp = new MCPClientManager([
623
+ { name: 'filesystem', command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '/workspace'] },
624
+ { name: 'remote', url: 'https://mcp.example.com/v1', headers: { Authorization: `Bearer ${process.env.MCP_TOKEN}` } },
625
+ ]);
633
626
 
634
- ```typescript
635
- await mcp.connectStreamableHTTP({
636
- name: 'remote-server',
637
- baseUrl: 'https://mcp.example.com',
638
- apiKey: process.env.MCP_API_KEY,
639
- });
627
+ await mcp.initialize(); // connects every configured server
628
+ const tools = mcp.getTools(); // ToolDefinition[], named mcp__{server}__{tool}
629
+ mcp.isConnected('remote'); // per-server status
630
+ await mcp.disconnect();
640
631
  ```
641
632
 
642
- ### SSE transport (legacy servers)
643
-
644
- ```typescript
645
- await mcp.connectSSE({
646
- name: 'legacy-server',
647
- url: 'http://localhost:8080/sse',
648
- });
649
- ```
633
+ Other useful fields: `timeoutMs` (per tool call, default 30 s), `connectTimeoutMs`, `trustAnnotations` (believe the server's `readOnlyHint` and `_meta`; off by default), `mode: 'tools' | 'agent'` and `assignTo` (which agents get the tools).
650
634
 
651
635
  ### Multiple servers via engine options
652
636
 
@@ -672,8 +656,8 @@ The client detects server crashes via `client.onclose` and marks them `'failed'`
672
656
  // For manual use:
673
657
  mcp.setDisconnectHandler((serverName) => {
674
658
  console.warn(`MCP server "${serverName}" disconnected`);
675
- // Re-attempt connection on next engine.run() call
676
659
  });
660
+ await mcp.reconnectFailed(); // retry the servers marked 'failed'
677
661
  ```
678
662
 
679
663
  ---
@@ -820,7 +804,7 @@ const memory = createMemorySystem({
820
804
  path: '~/.bk-agent/projects/my-project/memory/patterns.json',
821
805
  },
822
806
  retention: {
823
- maxEpisodes: 500, // prunes by relevance score when exceeded (v0.22.3+)
807
+ maxEpisodes: 500, // prunes by relevance score when exceeded
824
808
  summarizeAfter: 50,
825
809
  // Optional: compress old episodes with an LLM summary
826
810
  summarizeFn: async (episodes) => {
@@ -871,7 +855,7 @@ await procedural.add({
871
855
  const deploySteps = await procedural.get('deploy-to-staging');
872
856
  ```
873
857
 
874
- ### Forgetting curve (v0.22.3+)
858
+ ### Forgetting curve
875
859
 
876
860
  When `maxEpisodes` is set and the limit is exceeded, `EpisodicMemory` prunes by **relevance score** rather than raw age:
877
861
 
@@ -917,7 +901,7 @@ interface MemoryStoreBackend {
917
901
  upsert(id: string, record: StoredRecord): void;
918
902
  getAll(): StoredRecord[];
919
903
  deleteOldest(keepNewest: number): void;
920
- deleteByIds(ids: string[]): void; // v0.22.3+: used by relevance-based pruning
904
+ deleteByIds(ids: string[]): void; // used by relevance-based pruning
921
905
  count(): number;
922
906
  }
923
907
  ```
@@ -1011,18 +995,123 @@ const tracer = new Tracer({
1011
995
  });
1012
996
  ```
1013
997
 
1014
- ### Audit log (NDJSON)
998
+ ### Audit (one event per tool call)
1015
999
 
1016
- Every tool call can be logged to a newline-delimited JSON file:
1000
+ Give the engine one or more `AuditSink`s and it records **exactly one `AuditEvent` per tool call**, whether it ran or was refused (not found, not in `allowedTools`, blocked by a guardrail or the sandbox, rejected by the approver), plus one per `ask_agent` delegation. Arguments are recorded only as a SHA-256 of their canonical JSON, never in clear.
1017
1001
 
1018
1002
  ```typescript
1019
- const engine = new AgentEngine({
1003
+ import { createBaseEngine, HashChainAuditSink, NdjsonAuditSink, verifyAuditChain } from '@backendkit-labs/agent-core';
1004
+
1005
+ const engine = createBaseEngine({
1006
+ ...opts,
1007
+ identity: { tenantId: 'acme', userId: 'u-42', roles: ['treasury'] }, // part of every event's principal
1008
+ audit: [
1009
+ new NdjsonAuditSink('/var/log/agent/events.ndjson'), // plain, one JSON line per event
1010
+ new HashChainAuditSink('/var/log/agent/chain.log', { secret: process.env.AUDIT_KEY }), // tamper-evident
1011
+ ],
1012
+ });
1013
+
1014
+ // Later, or on another host:
1015
+ verifyAuditChain('/var/log/agent/chain.log', { secret: process.env.AUDIT_KEY });
1016
+ // → { ok: true, entries, head } or { ok: false, brokenAt, reason }
1017
+ ```
1018
+
1019
+ An event carries `at`, `principal` (agent, session, delegation chain, tenant, user), `tool`, `argsHash`, `decision` (`allow`, `deny`, `ask`, `not_found`, `not_allowed`, `sandbox_denied`, `guardrail_blocked`), `outcome` when it ran (`ok`, `error`, `timeout`, `aborted`), `durationMs`, the sandbox decisions taken during the call and the tool's `meta`. Sinks receive events one at a time in call order; a failing sink is reported on the transport (`system` warning) and never changes the result. `HashChainAuditSink` links every entry to the previous one, so editing, removing or reordering entries is detected; with a `secret` a log rewritten by someone without it does not verify either. It refuses to extend a log that is already broken.
1020
+
1021
+ `auditLog: '/path.ndjson'` (the older option) still works unchanged but is deprecated: it writes up to 200 characters of the arguments in clear. It will be removed in 0.40.
1022
+
1023
+ ### Policy and approval (per call)
1024
+
1025
+ A `ToolPolicy` decides every tool call and every `ask_agent` delegation: `allow`, `deny` or `ask`. It sees the principal (agent, delegation chain, tenant, user, roles) and the call (the tool with its declared facts, the arguments after guardrails). An `ask` goes to the `approver` (a person, another agent, a service), or is stored as pending in `approvals` when nobody answers now.
1026
+
1027
+ ```typescript
1028
+ import { createBaseEngine, type ToolPolicy, type Approver } from '@backendkit-labs/agent-core';
1029
+
1030
+ const treasuryRules: ToolPolicy = {
1031
+ decide(principal, call) {
1032
+ if (call.tool.name === 'pay_invoice' && (call.args.amount as number) > 10_000) {
1033
+ return { effect: 'ask', reason: 'payment above 10k', accepts: ['human'] };
1034
+ }
1035
+ if (!principal.roles?.includes('treasury') && !call.tool.readOnly) {
1036
+ return { effect: 'deny', reason: 'only treasury writes' };
1037
+ }
1038
+ return { effect: 'allow' };
1039
+ },
1040
+ };
1041
+
1042
+ const engine = createBaseEngine({
1020
1043
  ...opts,
1021
- auditLog: '/var/log/agent-audit.ndjson',
1022
- // Each line: { ts, agentId, toolName, args, result, durationMs }
1044
+ identity: { tenantId: 'acme', userId: 'u-42', roles: ['treasury'] },
1045
+ policy: treasuryRules, // several combine: deny > ask > allow; a throwing policy denies
1046
+ approver: myApprover, // { ref, request(req) → { decision, by: { kind, id }, at } }
1047
+ audit: new HashChainAuditSink('audit.log'),
1023
1048
  });
1024
1049
  ```
1025
1050
 
1051
+ - **Without `policy`**, but with someone to ask, `defaultToolPolicy` applies. Tools declared `readOnly` run. Tools declared `destructive` always ask a person. Anything else asks.
1052
+ - **Approvals are validated before they count:**
1053
+ - the approver's kind must be accepted;
1054
+ - nobody approves their own request or one from their delegation chain;
1055
+ - an agent approves only what it could do itself.
1056
+
1057
+ Every approval is audited with who gave it.
1058
+ - **`allow` can carry a mode.** `mode: 'dry_run'` runs the tool with `ctx.dryRun = true`. `mode: 'sandboxed'` requires a configured sandbox.
1059
+ - **Opt-in.** Setting `policy`, `approver` or `approvals` switches to this path. Without them, `onToolApproval` behaves exactly as before. With them, `onToolApproval` is adapted as the approver: "approve all" never covers destructive tools or package installs.
1060
+
1061
+ ### Durable approvals
1062
+
1063
+ If nobody can answer an `ask` right now, give the engine an `approvals` store. The call is stored as pending, the model is told it did not run, and whoever decides later runs it with `runApproved`.
1064
+
1065
+ ```typescript
1066
+ import { createBaseEngine, FileApprovalStore, agentApprover, consoleApprover } from '@backendkit-labs/agent-core';
1067
+
1068
+ const approvals = new FileApprovalStore('/var/lib/agent/approvals');
1069
+ const engine = createBaseEngine({ ...opts, approvals });
1070
+
1071
+ await engine.run('pay the October invoices'); // asks become pending requests
1072
+
1073
+ // Later, maybe in another process (a UI, Hermes, a CLI):
1074
+ const [req] = await approvals.list({ status: 'pending' });
1075
+ await approvals.resolve(req.id, { decision: 'approve', by: { kind: 'human', id: 'ana' }, at: new Date().toISOString() });
1076
+ const result = await engine.runApproved(req.id); // runs once; a second call throws
1077
+
1078
+ // Approvers that answer right away:
1079
+ createBaseEngine({ ...opts, approver: consoleApprover() }); // a person at the terminal
1080
+ createBaseEngine({ ...opts, approver: agentApprover((id, q) => engine.consultAgent(id, q), 'supervisor') }); // another agent
1081
+ ```
1082
+
1083
+ - **One decision and one execution per request.** `FileApprovalStore` allows exactly one decision and one execution per request, even across processes that share the directory.
1084
+ - **Everything is checked again.** `runApproved` repeats every check. A stored approval only satisfies an `ask` whose `accepts` admits the approver: an approval from an agent never covers a destructive tool.
1085
+ - **An invalid approval is spent.** If the approval turns out not to be valid, it is consumed and audited as `deny`.
1086
+
1087
+ ### Lifecycle hooks
1088
+
1089
+ Hooks let a vertical plug into a turn without new engine options. Every hook of one turn shares a `RunContext`: the principal, the input, a `state` map and an abort `signal`.
1090
+
1091
+ ```typescript
1092
+ import { createBaseEngine, type EngineHooks } from '@backendkit-labs/agent-core';
1093
+
1094
+ const review: EngineHooks = {
1095
+ name: 'review',
1096
+ beforeRun: (ctx) => ctx.state.set('task', classify(ctx.input)),
1097
+ systemPrompt: (ctx, profile) => profile.id === 'general' ? `## Task\n${describe(ctx.state.get('task'))}` : undefined,
1098
+ afterTurn: (ctx, turn) => !ctx.state.get('reviewed') && turn.profile.id === 'general'
1099
+ ? { action: 'continue', agentId: 'reviewer', message: 'Review the answer above.' } // another pass, as another agent
1100
+ : undefined,
1101
+ beforeTool: (ctx, call) => metrics.start(call.tool.name),
1102
+ afterTool: (ctx, call, result) => metrics.end(call.tool.name, result.success),
1103
+ afterRun: (ctx, result) => store.save(ctx.state.get('task'), result.text),
1104
+ };
1105
+
1106
+ const engine = createBaseEngine({ ...opts, hooks: [review], maxHookContinues: 3 });
1107
+ ```
1108
+
1109
+ - **Order.** Hooks run in registration order.
1110
+ - **`systemPrompt`** adds sections to the active agent and to delegates.
1111
+ - **`afterTurn`** runs when the model answers without asking for tools. The first hook that asks to `continue` wins. The number of extra passes is capped by `maxHookContinues` (default 5) and by `maxIterations`.
1112
+ - **`beforeTool` / `afterTool`** wrap only the calls the policy allowed.
1113
+ - **Errors.** A hook that throws fails the turn, and the error names the hook and the point.
1114
+
1026
1115
  ---
1027
1116
 
1028
1117
  ## Skills and slash commands
@@ -14,6 +14,11 @@ export interface DelegationRequest {
14
14
  * slots are occupied by agents that are themselves waiting for nested delegations.
15
15
  */
16
16
  depth?: number;
17
+ /**
18
+ * Delegation chain of the agent that asks, oldest first (SPEC-0014 principal). The delegate's chain is this
19
+ * plus its own id. When absent, `[fromAgentId]` is assumed.
20
+ */
21
+ chain?: string[];
17
22
  }
18
23
  export interface DelegationResult {
19
24
  agentId: string;
@@ -31,7 +36,9 @@ export interface DelegationBusOptions {
31
36
  maxDepth?: number;
32
37
  agents: AgentRegistry;
33
38
  transport: Transport;
34
- runAgent(agentId: string, question: string, context?: string, depth?: number, outputBuffer?: AgentEvent[]): Promise<DelegationResult>;
39
+ runAgent(agentId: string, question: string, context?: string, depth?: number, outputBuffer?: AgentEvent[],
40
+ /** Chain of the delegate itself: the caller's chain plus the delegate's id. */
41
+ chain?: string[]): Promise<DelegationResult>;
35
42
  }
36
43
  export declare class DelegationBus {
37
44
  private readonly opts;
@@ -1 +1 @@
1
- {"version":3,"file":"DelegationBus.d.ts","sourceRoot":"","sources":["../../src/delegation/DelegationBus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACz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V,OAAO,CAAC,QAAQ,CAAC,IAAI;IARjC;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;gBAE5B,IAAI,EAAE,oBAAoB;IAIvD,OAAO,CAAC,WAAW;IAenB;;;;;;;OAOG;IACG,WAAW,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAgBvE,SAAS,CAAC,OAAO,EAAE,iBAAiB,EAAE,YAAY,CAAC,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0DnG,kBAAkB;CAGrB"}
@@ -86,7 +86,8 @@ class DelegationBus {
86
86
  to_name: profile.name,
87
87
  to_icon: profile.icon,
88
88
  });
89
- return this.opts.runAgent(request.agentId, request.question, request.context, depth, outputBuffer);
89
+ const callerChain = request.chain ?? (request.fromAgentId ? [request.fromAgentId] : []);
90
+ return this.opts.runAgent(request.agentId, request.question, request.context, depth, outputBuffer, [...callerChain, request.agentId]);
90
91
  };
91
92
  try {
92
93
  return await this.bulkheadFor(depth).execute(execute);
@@ -1 +1 @@
1
- {"version":3,"file":"DelegationBus.js","sourceRoot":"","sources":["../../src/delegation/DelegationBus.ts"],"names":[],"mappings":";;;AAAA,wDAAkG;AA6BlG,2FAA2F;AAC9E,QAAA,4BAA4B,GAAG,CAAC,CAAC;AAiB9C,MAAa,aAAa;IASO;IAR7B;;;;;OAKG;IACc,SAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAEzD,YAA6B,IAA0B;QAA1B,SAAI,GAAJ,IAAI,CAAsB;QACnD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;IAEO,WAAW,CAAC,KAAa;QAC7B,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,QAAQ,GAAG,IAAI,mBAAQ,CAAC;gBACpB,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,WAAW,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,OAAO,GACT,GAAG,YAAY,gCAAqB,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC;gBAC7E,GAAG,YAAY,+BAAoB,CAAE,CAAC,CAAC,+BAA+B,CAAC,CAAC;oBACxE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACrD,OAAO;gBACH,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,OAAO,EAAE,UAAU,OAAO,EAAE;gBAC5B,WAAW,EAAE,CAAC;gBACd,YAAY,EAAE,CAAC;gBACf,SAAS,EAAE,CAAC;gBACZ,KAAK,EAAE,OAAO;aACjB,CAAC;QACN,CAAC;IACL,CAAC;IAED,kBAAkB;QACd,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IAC5C,CAAC;CACJ;AAjHD,sCAiHC"}
@@ -1,3 +1,5 @@
1
+ import { type EngineHooks } from '../governance/hooks';
2
+ import type { ApprovalStore, Approver, AuditSink, Identity, ToolPolicy } from '../governance/types';
1
3
  import type { EngineOptions, SessionMemoryData } from '../types';
2
4
  import type { Transport } from '../transport/Transport';
3
5
  import type { AgentRegistry } from './AgentRegistry';
@@ -9,8 +11,6 @@ import type { MemorySystem } from '../agent-memory/MemorySystem';
9
11
  import type { CommandContext } from '../commands/SlashCommandRegistry';
10
12
  import type { WorkflowDef, WorkflowResult, WorkflowRunOptions } from '../workflow/types';
11
13
  import type { WorkflowBuilder } from '../workflow/WorkflowBuilder';
12
- import type { Orchestrator } from '../orchestration/orchestrator';
13
- import type { QAService } from '../qa/qa-service';
14
14
  import { type IterationMode, type IterationStats } from './IterationManager';
15
15
  export interface AgentEngineOptions extends EngineOptions {
16
16
  agents: AgentRegistry;
@@ -30,23 +30,10 @@ export interface AgentEngineOptions extends EngineOptions {
30
30
  * Set true to keep that behavior while the profiles are fixed.
31
31
  */
32
32
  allowUnlistedTools?: boolean;
33
- /** Orchestrator para clasificacion de tareas, risk scoring y FSM */
34
- orchestrator?: Orchestrator;
35
- /**
36
- * What run() does when the orchestrator throws. 'closed' (default) rethrows: the gates it would have
37
- * applied cannot be silently skipped. 'open' warns on the transport and runs without orchestration.
38
- */
39
- orchestratorFailureMode?: 'closed' | 'open';
40
- /** QA service para revisar respuestas y registrar gates */
41
- qaService?: QAService;
42
- /** Si true, deshabilita las revisiones de QA automaticas */
43
- noQA?: boolean;
44
- /** Callback invocado cuando el QA genera una revision */
45
- onQAReview?: (review: string) => void;
46
33
  /** MCP client manager — connects to external MCP servers and registers their tools */
47
34
  mcpManager?: MCPClientManager;
48
35
  /**
49
- * Called before executing write/execute tools (write_file, edit_file, run_command) when
36
+ * Called before executing write/execute tools (tools that declare `readOnly: false`) when
50
37
  * iteration mode is 'manual'. Return 'approve' to run, 'approve_all' to run and disable
51
38
  * further prompts this session, 'reject' to skip the tool call.
52
39
  */
@@ -91,8 +78,44 @@ export interface AgentEngineOptions extends EngineOptions {
91
78
  * Path to an append-only NDJSON file for tool call audit records.
92
79
  * Each executed tool call is appended as one JSON line with: ts, session, agent, tool, inputPreview, success, durationMs.
93
80
  * Directory is created automatically. Optional — no audit file written when absent.
81
+ * @deprecated Writes up to 200 characters of the arguments in clear. Use `audit` (an `AuditSink`, e.g.
82
+ * `new NdjsonAuditSink(path)` or `new HashChainAuditSink(path)`), whose events carry only a hash of the
83
+ * arguments. Kept unchanged, same file format, until 0.40.
94
84
  */
95
85
  auditLog?: string;
86
+ /**
87
+ * Where every tool call (and every `ask_agent` delegation) is recorded, accepted or refused: exactly one
88
+ * `AuditEvent` per call, arguments as a SHA-256 only. Several sinks receive the same events in the same order.
89
+ */
90
+ audit?: AuditSink | AuditSink[];
91
+ /** Who this engine acts for (tenant, user, roles...). Becomes part of the `Principal` of every call. */
92
+ identity?: Identity;
93
+ /**
94
+ * Decides every tool call and delegation (allow, deny, ask) after allowedTools, the sandbox and the argument
95
+ * guardrails. Several policies combine: deny wins, then ask, then allow. When absent but there is someone to
96
+ * ask (`approver`, `approvals` or `onToolApproval`), `defaultToolPolicy` applies: readOnly runs, everything else
97
+ * asks, destructive asks a person. Setting any of `policy`, `approver` or `approvals` switches the engine to this
98
+ * path; with none of them the legacy `onToolApproval` gate keeps working exactly as before.
99
+ */
100
+ policy?: ToolPolicy | ToolPolicy[];
101
+ /**
102
+ * Who answers an `ask` right away: a person through a UI, a supervising agent, a service such as Hermes. Its
103
+ * answers are checked (accepted kind, no self-approval, an agent approves only what it can do) and audited.
104
+ * Without it, `onToolApproval` is adapted as the approver.
105
+ */
106
+ approver?: Approver;
107
+ /**
108
+ * Durable approvals: when nobody answers right away, an `ask` is stored here as pending and the model is told
109
+ * the call did not run (resubmission, SPEC-0014 §6).
110
+ */
111
+ approvals?: ApprovalStore;
112
+ /**
113
+ * Lifecycle hooks (SPEC-0014 §3): before/after a turn, system prompt sections, after the model's final answer
114
+ * (may force another pass), before/after each tool call. Run in registration order; a throwing hook fails the turn.
115
+ */
116
+ hooks?: EngineHooks[];
117
+ /** Most extra passes `afterTurn` hooks may force in one turn. Default 5. */
118
+ maxHookContinues?: number;
96
119
  /**
97
120
  * Called by updateWorkingDir after the workingDir changes (e.g. /workspace switch).
98
121
  * Should return the new projectContext string built from the new cwd
@@ -114,6 +137,19 @@ export declare class AgentEngine {
114
137
  /** Uncalibrated token estimate of the last request sent by runLoop, to calibrate against real usage. */
115
138
  private lastRequestEstimate;
116
139
  private readonly auditLogger;
140
+ private readonly audit;
141
+ /** Policy path (SPEC-0014 F2) instead of the legacy ApprovalGate: on when policy, approver or approvals is set. */
142
+ private readonly governed;
143
+ private readonly policies;
144
+ private readonly approver?;
145
+ /** Set when the approver is the adapted onToolApproval callback, so disable/enableToolApproval reach it. */
146
+ private readonly callbackApprover?;
147
+ private readonly hooks;
148
+ /** Context shared by the hooks of the turn in progress; undefined between turns. */
149
+ private runCtx?;
150
+ private runController?;
151
+ /** Last final answer of the model in the current turn (for afterRun). */
152
+ private lastAnswer;
117
153
  private currentAgentId;
118
154
  private aborted;
119
155
  private abortController;
@@ -191,7 +227,30 @@ export declare class AgentEngine {
191
227
  private getProviderForProfile;
192
228
  run(input: string): Promise<void>;
193
229
  private _run;
230
+ /** Sections the `systemPrompt` hooks add for `profile`. */
231
+ private hookPromptSections;
232
+ /** The first `afterTurn` hook that asks to continue wins; the rest still run (they may only observe). */
233
+ private afterTurnHooks;
234
+ /** Arguments the model produced, as an object (anything else becomes `{}`). */
235
+ private parseArgs;
236
+ /** Context for a tool hook: the turn's context with the principal of the agent that makes the call. */
237
+ private toolHookContext;
194
238
  runWorkflow(defOrBuilder: WorkflowDef | WorkflowBuilder, opts?: WorkflowRunOptions): Promise<WorkflowResult>;
239
+ /**
240
+ * Runs a tool call that was stored as pending and has since been approved (SPEC-0014 §6, resubmission).
241
+ *
242
+ * - At most once: the store marks it executed atomically before it runs; a second call throws.
243
+ * - Everything is checked again (allowedTools, sandbox, guardrails, policies); the stored approval only
244
+ * satisfies an `ask`, and only if its approver is one that ask accepts. An approval that turns out not to be
245
+ * valid is consumed and audited as `deny`.
246
+ * - The result is returned to the caller (e.g. Hermes or a UI); it is not added to the conversation.
247
+ */
248
+ runApproved(approvalId: string): Promise<string>;
249
+ /**
250
+ * Puts one question to an agent outside the conversation and returns its answer (its tool calls are governed
251
+ * like any other). Used by `agentApprover` to let a supervising agent approve or reject requests.
252
+ */
253
+ consultAgent(agentId: string, question: string): Promise<string>;
195
254
  abort(): void;
196
255
  /** Change the iteration mode at runtime — takes effect on the next run(). */
197
256
  setIterationMode(mode: IterationMode): void;
@@ -226,12 +285,6 @@ export declare class AgentEngine {
226
285
  private getCurrentProfile;
227
286
  private buildAgentRoster;
228
287
  private buildSystemPrompt;
229
- /**
230
- * Converts an OrchestrationResult into a system-prompt section that tells the
231
- * default agent which specialists to use, in what order, and what gates apply.
232
- * This closes the gap between the deterministic policy layer and the LLM layer.
233
- */
234
- private buildOrchestrationBrief;
235
288
  private resolvesDelegateTo;
236
289
  private getToolsForAgent;
237
290
  /**
@@ -252,16 +305,36 @@ export declare class AgentEngine {
252
305
  private sandboxFor;
253
306
  /** The message for the model when the sandbox policy refuses `tool` for `agentId`; undefined when allowed. */
254
307
  private sandboxRefusal;
308
+ /**
309
+ * Reports a sandbox decision on the transport and the legacy audit log, and, when `collect` is given, adds it to
310
+ * the decisions the single `AuditEvent` of the current tool call will carry.
311
+ */
255
312
  private reportSandboxDecision;
256
313
  /**
257
314
  * Unified tool execution used by both runLoop (primary agent) and
258
315
  * runAgentInternal (sub-agents via ask_agent).
259
- * Handles: allowedTools authorization → onToolApproval gate → execute → audit → transport.
316
+ * Handles: allowedTools → sandbox refusal → argument guardrails → policy/approval (or the legacy gate)
317
+ * → execute → result guardrails → audit → transport.
260
318
  */
261
319
  private executeToolCall;
262
320
  /** Approval checks never overlap and run in call order, even inside a parallel wave. */
263
321
  private gateQueue;
264
- private checkGateSerial;
322
+ private serialize;
323
+ /** The legacy gate (onToolApproval + the built-in list of tools that ask), unchanged, as a verdict. */
324
+ private decideLegacy;
325
+ private noApproverForSandbox;
326
+ /**
327
+ * The policy path (SPEC-0014 §2, F2): the policies decide on the arguments that would really run (after the
328
+ * guardrails), a sandbox that wants approval adds an `ask`, and an `ask` goes to the approver in call order or,
329
+ * when nobody answers now, to the durable store.
330
+ */
331
+ private decideGoverned;
332
+ private resolveAsk;
333
+ /**
334
+ * Rule 3 of SPEC-0014 §6.2: an agent approves only what it could do itself. It must be registered, have the
335
+ * tool in its allowedTools, and the policies must allow the same call with that agent as principal.
336
+ */
337
+ private agentCanPerform;
265
338
  private runToolDef;
266
339
  /**
267
340
  * Disconnects an MCP server at runtime — reverts all tool assignments and
@@ -273,10 +346,21 @@ export declare class AgentEngine {
273
346
  * For mode='tools' servers, agents fall back to shell commands automatically.
274
347
  */
275
348
  unregisterMCPServer(serverName: string): void;
276
- /** Disable approval gate for the rest of this session (approve_all). */
349
+ /**
350
+ * Disable approval for the rest of this session (approve_all). In the policy path it affects only the adapted
351
+ * onToolApproval callback, and never covers what only a person may approve (destructive tools, package installs).
352
+ */
277
353
  disableToolApproval(): void;
278
354
  /** Re-enable approval gate (e.g. after /iteration manual). */
279
355
  enableToolApproval(): void;
356
+ /** The principal of a call: this engine's identity, the executing agent and its delegation chain. */
357
+ private principalFor;
358
+ /**
359
+ * Writes the single `AuditEvent` of a tool call (or delegation). Arguments only as a hash: the raw JSON string
360
+ * the model produced is parsed when it can be (so equal arguments hash equal whatever their key order) and
361
+ * hashed as text when it cannot.
362
+ */
363
+ private recordAudit;
280
364
  private buildContext;
281
365
  }
282
366
  //# sourceMappingURL=AgentEngine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentEngine.d.ts","sourceRoot":"","sources":["../../src/engine/AgentEngine.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAER,aAAa,EAIb,iBAAiB,EAGpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,KAA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