@a5c-ai/agent-core 5.0.1-staging.3a341c33c → 5.0.1-staging.40a93c240e7b

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 (116) hide show
  1. package/README.md +13 -7
  2. package/dist/agenticTools/background/state.d.ts +6 -4
  3. package/dist/agenticTools/background/state.d.ts.map +1 -1
  4. package/dist/agenticTools/background/state.js +9 -23
  5. package/dist/agenticTools/browser/tool.js +2 -2
  6. package/dist/agenticTools/index.d.ts.map +1 -1
  7. package/dist/agenticTools/index.js +4 -0
  8. package/dist/agenticTools/shared/paths.d.ts.map +1 -1
  9. package/dist/agenticTools/shared/paths.js +2 -1
  10. package/dist/agenticTools/shared/process.d.ts.map +1 -1
  11. package/dist/agenticTools/shared/process.js +3 -1
  12. package/dist/agenticTools/shared/results.d.ts.map +1 -1
  13. package/dist/agenticTools/shared/results.js +1 -0
  14. package/dist/agenticTools/tools/code.d.ts.map +1 -1
  15. package/dist/agenticTools/tools/code.js +7 -6
  16. package/dist/agenticTools/tools/execution.d.ts.map +1 -1
  17. package/dist/agenticTools/tools/execution.js +5 -0
  18. package/dist/agenticTools/tools/fileSystem.d.ts.map +1 -1
  19. package/dist/agenticTools/tools/fileSystem.js +27 -4
  20. package/dist/agenticTools/tools/programmaticToolCalling.d.ts.map +1 -1
  21. package/dist/agenticTools/tools/programmaticToolCalling.js +2 -0
  22. package/dist/backgroundProcessRegistry.d.ts +4 -60
  23. package/dist/backgroundProcessRegistry.d.ts.map +1 -1
  24. package/dist/backgroundProcessRegistry.js +7 -197
  25. package/dist/context/index.d.ts +5 -0
  26. package/dist/context/index.d.ts.map +1 -0
  27. package/dist/context/index.js +12 -0
  28. package/dist/context/manager.d.ts +43 -0
  29. package/dist/context/manager.d.ts.map +1 -0
  30. package/dist/context/manager.js +113 -0
  31. package/dist/context/strategies/index.d.ts +4 -0
  32. package/dist/context/strategies/index.d.ts.map +1 -0
  33. package/dist/context/strategies/index.js +9 -0
  34. package/dist/context/strategies/priority.d.ts +29 -0
  35. package/dist/context/strategies/priority.d.ts.map +1 -0
  36. package/dist/context/strategies/priority.js +58 -0
  37. package/dist/context/strategies/sliding.d.ts +27 -0
  38. package/dist/context/strategies/sliding.d.ts.map +1 -0
  39. package/dist/context/strategies/sliding.js +62 -0
  40. package/dist/context/strategies/summary.d.ts +41 -0
  41. package/dist/context/strategies/summary.d.ts.map +1 -0
  42. package/dist/context/strategies/summary.js +75 -0
  43. package/dist/context/token-estimator.d.ts +25 -0
  44. package/dist/context/token-estimator.d.ts.map +1 -0
  45. package/dist/context/token-estimator.js +38 -0
  46. package/dist/context/types.d.ts +131 -0
  47. package/dist/context/types.d.ts.map +1 -0
  48. package/dist/context/types.js +9 -0
  49. package/dist/index.d.ts +9 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +23 -1
  52. package/dist/loop/agent-loop.d.ts +51 -0
  53. package/dist/loop/agent-loop.d.ts.map +1 -0
  54. package/dist/loop/agent-loop.js +255 -0
  55. package/dist/loop/index.d.ts +6 -0
  56. package/dist/loop/index.d.ts.map +1 -0
  57. package/dist/loop/index.js +11 -0
  58. package/dist/loop/strategies/concurrent.d.ts +33 -0
  59. package/dist/loop/strategies/concurrent.d.ts.map +1 -0
  60. package/dist/loop/strategies/concurrent.js +47 -0
  61. package/dist/loop/strategies/group-chat.d.ts +42 -0
  62. package/dist/loop/strategies/group-chat.d.ts.map +1 -0
  63. package/dist/loop/strategies/group-chat.js +91 -0
  64. package/dist/loop/strategies/handoff.d.ts +46 -0
  65. package/dist/loop/strategies/handoff.d.ts.map +1 -0
  66. package/dist/loop/strategies/handoff.js +86 -0
  67. package/dist/loop/strategies/index.d.ts +9 -0
  68. package/dist/loop/strategies/index.d.ts.map +1 -0
  69. package/dist/loop/strategies/index.js +11 -0
  70. package/dist/loop/strategies/sequential.d.ts +19 -0
  71. package/dist/loop/strategies/sequential.d.ts.map +1 -0
  72. package/dist/loop/strategies/sequential.js +29 -0
  73. package/dist/loop/types.d.ts +120 -0
  74. package/dist/loop/types.d.ts.map +1 -0
  75. package/dist/loop/types.js +9 -0
  76. package/dist/session.d.ts +9 -1
  77. package/dist/session.d.ts.map +1 -1
  78. package/dist/session.js +284 -32
  79. package/dist/session.test.js +207 -13
  80. package/dist/subagent/index.d.ts +6 -0
  81. package/dist/subagent/index.d.ts.map +1 -0
  82. package/dist/subagent/index.js +7 -0
  83. package/dist/subagent/invoker.d.ts +33 -0
  84. package/dist/subagent/invoker.d.ts.map +1 -0
  85. package/dist/subagent/invoker.js +113 -0
  86. package/dist/subagent/oversight.d.ts +43 -0
  87. package/dist/subagent/oversight.d.ts.map +1 -0
  88. package/dist/subagent/oversight.js +63 -0
  89. package/dist/subagent/types.d.ts +136 -0
  90. package/dist/subagent/types.d.ts.map +1 -0
  91. package/dist/subagent/types.js +9 -0
  92. package/dist/synthesis/index.d.ts +4 -0
  93. package/dist/synthesis/index.d.ts.map +1 -0
  94. package/dist/synthesis/index.js +9 -0
  95. package/dist/synthesis/strategies/index.d.ts +4 -0
  96. package/dist/synthesis/strategies/index.d.ts.map +1 -0
  97. package/dist/synthesis/strategies/index.js +9 -0
  98. package/dist/synthesis/strategies/merge.d.ts +18 -0
  99. package/dist/synthesis/strategies/merge.d.ts.map +1 -0
  100. package/dist/synthesis/strategies/merge.js +104 -0
  101. package/dist/synthesis/strategies/rank.d.ts +25 -0
  102. package/dist/synthesis/strategies/rank.d.ts.map +1 -0
  103. package/dist/synthesis/strategies/rank.js +51 -0
  104. package/dist/synthesis/strategies/vote.d.ts +17 -0
  105. package/dist/synthesis/strategies/vote.d.ts.map +1 -0
  106. package/dist/synthesis/strategies/vote.js +59 -0
  107. package/dist/synthesis/synthesizer.d.ts +25 -0
  108. package/dist/synthesis/synthesizer.d.ts.map +1 -0
  109. package/dist/synthesis/synthesizer.js +38 -0
  110. package/dist/synthesis/types.d.ts +96 -0
  111. package/dist/synthesis/types.d.ts.map +1 -0
  112. package/dist/synthesis/types.js +8 -0
  113. package/dist/tools.test.js +14 -6
  114. package/dist/types.d.ts +12 -4
  115. package/dist/types.d.ts.map +1 -1
  116. package/package.json +11 -4
package/README.md CHANGED
@@ -5,16 +5,16 @@ Built-in programmatic session wrapper and agentic tool surface for Babysitter ru
5
5
  <!-- docs-status:start -->
6
6
  > Status: Public advanced/runtime package.
7
7
  > Canonical docs home: [Package and Plugin Docs Map](../../docs/package-and-plugin-map.md).
8
- > This README defines the package contract for runtime consumers and published dependents such as `@a5c-ai/babysitter-agent`.
8
+ > This README defines the package contract for runtime consumers and published dependents such as `@a5c-ai/agent-platform`.
9
9
  <!-- docs-status:end -->
10
10
 
11
11
  ## Package role
12
12
 
13
- `@a5c-ai/agent-core` sits between `@a5c-ai/babysitter-agent`, `@a5c-ai/agent-mux`, and `@a5c-ai/babysitter-sdk`:
13
+ `@a5c-ai/agent-core` sits between `@a5c-ai/agent-platform`, `@a5c-ai/agent-mux`, and `@a5c-ai/babysitter-sdk`:
14
14
 
15
15
  - `createAgentCoreSession()` wraps an `@a5c-ai/agent-mux` client for in-process prompt execution.
16
16
  - `createAgentCoreToolDefinitions()` assembles the built-in Babysitter-flavored tool surface that host runtimes can inject into planning, resume, or delegated-task flows.
17
- - `@a5c-ai/babysitter-agent` re-exports these APIs from `src/harness/index.ts`, uses `createAgentCoreSession()` for direct `agent-core` harness invocation in `src/harness/invoker.ts`, and injects tool definitions into plan-process and resume-run flows.
17
+ - `@a5c-ai/agent-platform` re-exports these APIs from `src/harness/index.ts`, uses `createAgentCoreSession()` for direct `agent-core` harness invocation in `src/harness/invoker.ts`, and injects tool definitions into plan-process and resume-run flows.
18
18
  - `@a5c-ai/babysitter-sdk` still owns run directories, journals, task/effect lifecycle, and config defaults. `agent-core` does not replace the SDK orchestration layer.
19
19
 
20
20
  This package is published as a runtime dependency surface for higher-level Babysitter runtimes. It is still an advanced/operator-facing building block rather than the primary entrypoint for new users.
@@ -66,6 +66,8 @@ Core handle methods:
66
66
  - `prompt(text, timeout?)`: starts a run, streams events to subscribers, and returns `{ output, duration, success, exitCode }`.
67
67
  - `steer(text)`: sends immediate steering text while a prompt is active, or queues it for the next prompt.
68
68
  - `followUp(text)`: queues a post-response follow-up when streaming, or appends it to the next prompt when idle.
69
+ - `getHistory()`: returns a defensive copy of persisted user/assistant turns for the session handle.
70
+ - `clearHistory()`: clears persisted user/assistant turns without changing listeners, options, or the current session id.
69
71
  - `subscribe(listener)`: receives normalized `AgentCoreSessionEvent` payloads, including `session_start`.
70
72
  - `abort()`: aborts the active run if one is in progress.
71
73
  - `dispose()`: aborts the active run, clears listeners, and drops queued follow-ups.
@@ -75,6 +77,8 @@ Core handle methods:
75
77
  Session behavior that matters to host integrations:
76
78
 
77
79
  - Agent-core reuses the `sessionId` learned from prior runs, so later prompts continue the same agent-mux session when the backend supports it.
80
+ - Agent-core also keeps successful user/assistant turns on the session handle and includes bounded prior history in later direct provider prompts. System prompts are rebuilt from options for each request and are not stored in mutable history.
81
+ - Failed prompts, timed-out requests, aborted requests, and malformed streams do not append partial assistant output to history.
78
82
  - Concurrent `prompt()` calls on the same handle are rejected.
79
83
  - Event payloads are normalized before subscribers see them. Non-object payloads become `{ type: "unknown", value }`.
80
84
  - Approval mode is `prompt` only when `uiContext` is present; otherwise agent-core uses `yolo`.
@@ -86,6 +90,8 @@ Session behavior that matters to host integrations:
86
90
  | `workspace` | Forwarded to agent-mux as `cwd`. |
87
91
  | `model` | Forwarded to agent-mux as `model`. |
88
92
  | `timeout` | Forwarded to agent-mux as `timeout`. |
93
+ | `maxHistoryTurns` | Maximum persisted user/assistant history entries retained on the session handle. Defaults to 20. |
94
+ | `maxHistoryTokens` | Maximum estimated tokens from prior history sent with a prompt. Uses the package's rough token estimator and drops oldest entries first. |
89
95
  | `thinkingLevel` | Translated to agent-mux `thinkingEffort` (`minimal`/`low` -> `low`, `medium` -> `medium`, `high` -> `high`, `xhigh` -> `max`). |
90
96
  | `systemPrompt` | Used as the base `systemPrompt`. |
91
97
  | `appendSystemPrompt` | Appended to the final `systemPrompt` before dispatch. |
@@ -98,7 +104,7 @@ These fields remain on `AgentCoreSessionOptions` for compatibility, but the curr
98
104
 
99
105
  | Option | Status | Migration note |
100
106
  | --- | --- | --- |
101
- | `toolsMode` | Deprecated, ignored by agent-core | Use backend-native configuration, or the PI wrapper in `@a5c-ai/babysitter-agent`, if you still need tool-surface control. |
107
+ | `toolsMode` | Deprecated, ignored by agent-core | Use backend-native configuration, or the PI wrapper in `@a5c-ai/agent-platform`, if you still need tool-surface control. |
102
108
  | `customTools` | Deprecated, ignored by agent-core | Register host-side tools with `createAgentCoreToolDefinitions()` or use the PI wrapper for runtime custom-tool injection. |
103
109
  | `isolated` | Deprecated, ignored by agent-core | Use the PI wrapper if you still need extension/skills isolation controls. |
104
110
  | `ephemeral` | Deprecated, ignored by agent-core | Session persistence is determined by the selected agent-mux backend. |
@@ -106,7 +112,7 @@ These fields remain on `AgentCoreSessionOptions` for compatibility, but the curr
106
112
  | `enableCompaction` | Deprecated, ignored by agent-core | Compaction behavior belongs to the selected backend/runtime. |
107
113
  | `agentDir` | Deprecated, ignored by agent-core | Configure agent directories through the target backend instead. |
108
114
 
109
- If you still need the PI-era controls above, use the PI wrapper exposed from `@a5c-ai/babysitter-agent` rather than `@a5c-ai/agent-core`.
115
+ If you still need the PI-era controls above, use the PI wrapper exposed from `@a5c-ai/agent-platform` rather than `@a5c-ai/agent-core`.
110
116
 
111
117
  ## Tool-definition API
112
118
 
@@ -192,7 +198,7 @@ Source disambiguation uses `(source, sourceQualifier, name)`, so duplicate tool
192
198
 
193
199
  Current downstream integration boundaries in this repo:
194
200
 
195
- - `@a5c-ai/babysitter-agent`
201
+ - `@a5c-ai/agent-platform`
196
202
  - re-exports the session/tool APIs from `src/harness/index.ts`
197
203
  - uses `createAgentCoreSession()` for the direct `agent-core` harness path in `src/harness/invoker.ts`
198
204
  - injects `createAgentCoreToolDefinitions()` into plan-process and delegated-task flows in `src/harness/internal/createRun/planProcess/*`
@@ -202,7 +208,7 @@ Current downstream integration boundaries in this repo:
202
208
  - `@a5c-ai/babysitter-sdk`
203
209
  - provides config defaults/env wiring used by the `config` tool and remains the owner of orchestration/run-state semantics outside this package
204
210
 
205
- In practice, use `agent-core` when you need an in-process runtime wrapper or bundled tool surface. Use `babysitter-agent` when you need the higher-level harness CLI/runtime entrypoints.
211
+ In practice, use `agent-core` when you need an in-process runtime wrapper or bundled tool surface. Use `agent-platform` when you need the higher-level harness CLI/runtime entrypoints.
206
212
 
207
213
  ## Build, test, and CI
208
214
 
@@ -1,5 +1,7 @@
1
- import { BackgroundProcessRegistry } from "../../backgroundProcessRegistry";
2
- import type { AgenticToolOptions } from "../types";
3
- export declare function getBackgroundRegistry(options: AgenticToolOptions): BackgroundProcessRegistry;
4
- export declare function disposeBackgroundRegistry(options: AgenticToolOptions): void;
1
+ /**
2
+ * Backwards-compatibility shim -- the canonical implementation now lives in
3
+ * `@a5c-ai/agent-runtime`. This re-export keeps internal agent-core consumers
4
+ * working without changes.
5
+ */
6
+ export { getBackgroundRegistry, disposeBackgroundRegistry, } from "@a5c-ai/agent-runtime";
5
7
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/background/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAInD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,yBAAyB,CAW5F;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAO3E"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/background/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC"}
@@ -1,25 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBackgroundRegistry = getBackgroundRegistry;
4
- exports.disposeBackgroundRegistry = disposeBackgroundRegistry;
5
- const backgroundProcessRegistry_1 = require("../../backgroundProcessRegistry");
6
- const scopedRegistries = new WeakMap();
7
- function getBackgroundRegistry(options) {
8
- if (options.backgroundRegistry) {
9
- return options.backgroundRegistry;
10
- }
11
- let registry = scopedRegistries.get(options);
12
- if (!registry) {
13
- registry = new backgroundProcessRegistry_1.BackgroundProcessRegistry({ maxConcurrent: options.maxBackgroundProcesses });
14
- scopedRegistries.set(options, registry);
15
- }
16
- return registry;
17
- }
18
- function disposeBackgroundRegistry(options) {
19
- const registry = scopedRegistries.get(options);
20
- if (!registry) {
21
- return;
22
- }
23
- registry.dispose();
24
- scopedRegistries.delete(options);
25
- }
3
+ exports.disposeBackgroundRegistry = exports.getBackgroundRegistry = void 0;
4
+ /**
5
+ * Backwards-compatibility shim -- the canonical implementation now lives in
6
+ * `@a5c-ai/agent-runtime`. This re-export keeps internal agent-core consumers
7
+ * working without changes.
8
+ */
9
+ var agent_runtime_1 = require("@a5c-ai/agent-runtime");
10
+ Object.defineProperty(exports, "getBackgroundRegistry", { enumerable: true, get: function () { return agent_runtime_1.getBackgroundRegistry; } });
11
+ Object.defineProperty(exports, "disposeBackgroundRegistry", { enumerable: true, get: function () { return agent_runtime_1.disposeBackgroundRegistry; } });
@@ -25,8 +25,8 @@ function createBrowserTool() {
25
25
  // eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-assignment
26
26
  puppeteer = await new Function("id", "return import(id)")("puppeteer");
27
27
  }
28
- catch {
29
- return (0, results_1.errorResult)("puppeteer is not installed. Install it with: npm install puppeteer");
28
+ catch (error) {
29
+ return (0, results_1.errorResult)(`puppeteer import failed: ${error instanceof Error ? error.message : String(error)}. Install with: npm install puppeteer`);
30
30
  }
31
31
  if (!browserInstance) {
32
32
  browserInstance = await puppeteer.launch({
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agenticTools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAmBxE,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CAsBlG;AAED,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAOzF;AAED,eAAO,MAAM,4BAA4B,uCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agenticTools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAuBxE,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CAsBlG;AAED,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAOzF;AAED,eAAO,MAAM,4BAA4B,uCAAiC,CAAC"}
@@ -15,6 +15,10 @@ const delegation_1 = require("./tools/delegation");
15
15
  const execution_1 = require("./tools/execution");
16
16
  const fileSystem_1 = require("./tools/fileSystem");
17
17
  const programmaticToolCalling_1 = require("./tools/programmaticToolCalling");
18
+ // HERE BE DRAGONS: WeakMap keyed by exact array reference. Dispose MUST be called
19
+ // with the same array object returned by createAgentCoreToolDefinitions().
20
+ // Passing a copy, spread, or recreated array will silently fail to clean up
21
+ // background processes, causing resource leaks.
18
22
  const toolDefinitionScopes = new WeakMap();
19
23
  function createAgentCoreToolDefinitions(options) {
20
24
  const baseTools = [
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/shared/paths.ts"],"names":[],"mappings":"AAGA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAU7E;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIvE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA2BnD;AAED,wBAAgB,OAAO,CACrB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,OAAO,EACtB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,GAChB,IAAI,CA2BN"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/shared/paths.ts"],"names":[],"mappings":"AAGA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAU7E;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIvE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA2BnD;AAED,wBAAgB,OAAO,CACrB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,OAAO,EACtB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,GAChB,IAAI,CA4BN"}
@@ -93,7 +93,8 @@ function walkDir(directory, includeHidden, limit, results) {
93
93
  try {
94
94
  entries = fs.readdirSync(directory, { withFileTypes: true });
95
95
  }
96
- catch {
96
+ catch (e) {
97
+ process.stderr.write(`[agent-core] walkDir: cannot read ${directory}: ${e instanceof Error ? e.message : String(e)}\n`);
97
98
  return;
98
99
  }
99
100
  for (const entry of entries) {
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/shared/process.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,SAAU,CAAC;AAC5C,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAC7C,eAAO,MAAM,cAAc,QAAS,CAAC;AAKrC,wBAAgB,SAAS,IAAI,MAAM,CAgBlC;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgE/D"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/shared/process.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,SAAU,CAAC;AAC5C,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAC7C,eAAO,MAAM,cAAc,QAAS,CAAC;AAKrC,wBAAgB,SAAS,IAAI,MAAM,CAgBlC;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAkE/D"}
@@ -83,6 +83,7 @@ function spawnAsync(command, args, options) {
83
83
  stdoutBytes += chunk.length;
84
84
  if (stdoutBytes > MAX_SPAWN_OUTPUT_BYTES) {
85
85
  stdoutTruncated = true;
86
+ stdoutChunks.push(Buffer.from(`\n[babysitter] WARNING: stdout truncated at ${MAX_SPAWN_OUTPUT_BYTES} bytes. Subsequent output discarded.\n`));
86
87
  return;
87
88
  }
88
89
  stdoutChunks.push(chunk);
@@ -94,6 +95,7 @@ function spawnAsync(command, args, options) {
94
95
  stderrBytes += chunk.length;
95
96
  if (stderrBytes > MAX_SPAWN_OUTPUT_BYTES) {
96
97
  stderrTruncated = true;
98
+ stderrChunks.push(Buffer.from(`\n[babysitter] WARNING: stderr truncated at ${MAX_SPAWN_OUTPUT_BYTES} bytes. Subsequent output discarded.\n`));
97
99
  return;
98
100
  }
99
101
  stderrChunks.push(chunk);
@@ -114,7 +116,7 @@ function spawnAsync(command, args, options) {
114
116
  processHandle.on("error", (error) => {
115
117
  resolve({
116
118
  stdout: concatSafe(stdoutChunks, stdoutTruncated, stdoutBytes),
117
- stderr: error.message,
119
+ stderr: `${error.message}${error.code ? ` (${error.code})` : ''}`,
118
120
  exitCode: 1,
119
121
  });
120
122
  });
@@ -1 +1 @@
1
- {"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/shared/results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEjE,eAAO,MAAM,sBAAsB,kCAAkC,CAAC;AAEtE,wBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAE3C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAEpD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAEvD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUhE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAM1E;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,oBAAoB,EAChC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GACtD,oBAAoB,CAkBtB"}
1
+ {"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/shared/results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEjE,eAAO,MAAM,sBAAsB,kCAAkC,CAAC;AAEtE,wBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAE3C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAEpD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAEvD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUhE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAM1E;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,oBAAoB,EAChC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GACtD,oBAAoB,CAmBtB"}
@@ -43,6 +43,7 @@ function wrapToolDefinition(definition, onToolUse) {
43
43
  return await Promise.resolve(originalExecute(toolCallId, params, onUpdate, toolContext));
44
44
  }
45
45
  catch (error) {
46
+ process.stderr.write(`[agent-core] tool ${definition.name} error: ${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
46
47
  return errorResultFor(error);
47
48
  }
48
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/tools/code.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAc,MAAM,UAAU,CAAC;AAwErF,wBAAgB,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CAuOnF"}
1
+ {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/tools/code.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAc,MAAM,UAAU,CAAC;AAwErF,wBAAgB,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CAwOnF"}
@@ -122,6 +122,7 @@ function createCodeTools(options) {
122
122
  continue;
123
123
  }
124
124
  if (astResult.exitCode !== 0) {
125
+ process.stderr.write(`[agent-core] ast-grep failed (exit ${astResult.exitCode}), falling back to ripgrep\n`);
125
126
  const grepArgs = ["--no-heading", "--line-number", "--color", "never"];
126
127
  if (params.glob) {
127
128
  grepArgs.push("--glob", String(params.glob));
@@ -218,21 +219,21 @@ function createCodeTools(options) {
218
219
  return (0, results_1.ok)(fs.readFileSync(outputPath, "utf8"));
219
220
  }
220
221
  }
221
- catch {
222
- // fall through to source return
222
+ catch (error) {
223
+ process.stderr.write(`[agent-core] mmdc rendering failed: ${error instanceof Error ? error.message : String(error)}, returning source\n`);
223
224
  }
224
225
  finally {
225
226
  try {
226
227
  fs.unlinkSync(inputPath);
227
228
  }
228
- catch {
229
- // ignore
229
+ catch (unlinkErr) {
230
+ process.stderr.write(`[agent-core] failed to clean up ${inputPath}: ${unlinkErr instanceof Error ? unlinkErr.message : String(unlinkErr)}\n`);
230
231
  }
231
232
  try {
232
233
  fs.unlinkSync(outputPath);
233
234
  }
234
- catch {
235
- // ignore
235
+ catch (unlinkErr) {
236
+ process.stderr.write(`[agent-core] failed to clean up ${outputPath}: ${unlinkErr instanceof Error ? unlinkErr.message : String(unlinkErr)}\n`);
236
237
  }
237
238
  }
238
239
  return (0, results_1.ok)(`(mmdc not available — returning source)\n\n\`\`\`mermaid\n${source}\n\`\`\``);
@@ -1 +1 @@
1
- {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/tools/execution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAMzE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CA4IxF"}
1
+ {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/tools/execution.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAMzE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CAiJxF"}
@@ -47,6 +47,11 @@ function createExecutionTools(options) {
47
47
  description: record.description,
48
48
  });
49
49
  }
50
+ // HERE BE DRAGONS: Shell invocation is duplicated in 5 files. All must use the same flags.
51
+ // See also: agent-core/session.ts, agent-platform/tools/execution.ts,
52
+ // agent-platform/backgroundProcessRegistry.ts, agent-runtime/backgroundProcessRegistry.ts
53
+ // HERE BE DRAGONS: Assumes /bin/bash exists on non-Windows. macOS Catalina+
54
+ // defaults to zsh, and some containers may not have bash at this path.
50
55
  const shell = process.platform === "win32" ? "cmd.exe" : "/bin/bash";
51
56
  const shellArgs = process.platform === "win32"
52
57
  ? ["/c", String(params.command)]
@@ -1 +1 @@
1
- {"version":3,"file":"fileSystem.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/tools/fileSystem.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAc,MAAM,UAAU,CAAC;AAKrF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CA+KzF"}
1
+ {"version":3,"file":"fileSystem.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/tools/fileSystem.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAc,MAAM,UAAU,CAAC;AAsBrF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CAuLzF"}
@@ -40,6 +40,21 @@ const typebox_1 = require("@sinclair/typebox");
40
40
  const process_1 = require("../shared/process");
41
41
  const results_1 = require("../shared/results");
42
42
  const paths_1 = require("../shared/paths");
43
+ function escapePatchPath(value) {
44
+ return value.replace(/\\/g, "/");
45
+ }
46
+ function buildUnifiedPatch(filePath, before, after) {
47
+ const label = escapePatchPath(filePath);
48
+ const beforeLines = before.split("\n");
49
+ const afterLines = after.split("\n");
50
+ return [
51
+ `--- a/${label}`,
52
+ `+++ b/${label}`,
53
+ `@@ -1,${beforeLines.length} +1,${afterLines.length} @@`,
54
+ ...beforeLines.map((line) => `-${line}`),
55
+ ...afterLines.map((line) => `+${line}`),
56
+ ].join("\n");
57
+ }
43
58
  function createFileSystemTools(options) {
44
59
  const { workspace } = options;
45
60
  return [
@@ -56,8 +71,13 @@ function createFileSystemTools(options) {
56
71
  const filePath = (0, paths_1.resolveSafe)(workspace, String(params.path));
57
72
  const lines = fs.readFileSync(filePath, "utf8").split("\n");
58
73
  const start = Math.max(0, (params.offset ?? 1) - 1);
59
- const count = Math.min(params.limit ?? process_1.MAX_READ_LINES, process_1.MAX_READ_LINES);
60
- return (0, results_1.ok)(lines.slice(start, start + count).map((line, index) => `${start + index + 1}\t${line}`).join("\n"));
74
+ const requestedLimit = params.limit ?? process_1.MAX_READ_LINES;
75
+ const count = Math.min(requestedLimit, process_1.MAX_READ_LINES);
76
+ const content = lines.slice(start, start + count).map((line, index) => `${start + index + 1}\t${line}`).join("\n");
77
+ if (requestedLimit > process_1.MAX_READ_LINES) {
78
+ return (0, results_1.ok)(`${content}\n(capped at ${process_1.MAX_READ_LINES} lines — requested ${requestedLimit})`);
79
+ }
80
+ return (0, results_1.ok)(content);
61
81
  },
62
82
  },
63
83
  {
@@ -97,7 +117,8 @@ function createFileSystemTools(options) {
97
117
  ? content.split(oldString).join(newString)
98
118
  : content.replace(oldString, newString);
99
119
  fs.writeFileSync(filePath, updated, "utf8");
100
- return (0, results_1.ok)(`File edited: ${filePath}`);
120
+ const relativePath = path.relative(workspace, filePath) || String(params.path);
121
+ return (0, results_1.ok)(`File edited: ${filePath}\nUnified patch:\n${buildUnifiedPatch(relativePath, content, updated)}`);
101
122
  },
102
123
  },
103
124
  {
@@ -189,7 +210,9 @@ function createFileSystemTools(options) {
189
210
  limit: typebox_1.Type.Optional(typebox_1.Type.Number({ description: "Max results (default: 500)" })),
190
211
  }),
191
212
  execute: (_toolCallId, params) => {
192
- const maxResults = Math.min(params.limit ?? 500, 5000);
213
+ const DEFAULT_GLOB_LIMIT = 500;
214
+ const MAX_GLOB_LIMIT = 5000;
215
+ const maxResults = Math.min(params.limit ?? DEFAULT_GLOB_LIMIT, MAX_GLOB_LIMIT);
193
216
  const allFiles = [];
194
217
  (0, paths_1.walkDir)(workspace, Boolean(params.hidden), maxResults * 5, allFiles);
195
218
  const regex = (0, paths_1.globToRegex)(String(params.pattern));
@@ -1 +1 @@
1
- {"version":3,"file":"programmaticToolCalling.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/tools/programmaticToolCalling.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAc,MAAM,UAAU,CAAC;AAgBrF,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAExF;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,kBAAkB,EAC3B,cAAc,EAAE,oBAAoB,EAAE,GACrC,oBAAoB,CAwEtB"}
1
+ {"version":3,"file":"programmaticToolCalling.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/tools/programmaticToolCalling.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAc,MAAM,UAAU,CAAC;AAkBrF,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAExF;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,kBAAkB,EAC3B,cAAc,EAAE,oBAAoB,EAAE,GACrC,oBAAoB,CAwEtB"}
@@ -9,6 +9,8 @@ const node_vm_1 = __importDefault(require("node:vm"));
9
9
  const typebox_1 = require("@sinclair/typebox");
10
10
  const results_1 = require("../shared/results");
11
11
  const DEFAULT_TIMEOUT_MS = 120_000;
12
+ // Prevents infinite tool-calling loops. 25 is high enough for complex multi-step work
13
+ // but low enough to catch runaway recursion.
12
14
  const DEFAULT_MAX_TOOL_CALLS = 25;
13
15
  function shouldEnableProgrammaticToolCalling(options) {
14
16
  return Boolean(options.programmaticToolCalling);
@@ -1,63 +1,7 @@
1
1
  /**
2
- * Background process lifecycle management for the bash agentic tool (GAP-TOOLS-036).
3
- *
4
- * Tracks child processes spawned with `run_in_background: true`, collects
5
- * stdout/stderr, fires completion callbacks, and enforces a concurrency limit.
2
+ * Backwards-compatibility shim -- the canonical implementation now lives in
3
+ * `@a5c-ai/agent-runtime`. This re-export keeps internal agent-core consumers
4
+ * (and any external code that deep-imported this path) working without changes.
6
5
  */
7
- /** Snapshot of a tracked background process. */
8
- export interface BackgroundTaskRecord {
9
- backgroundTaskId: string;
10
- pid: number;
11
- command: string;
12
- description?: string;
13
- startedAt: string;
14
- status: "running" | "completed" | "exited" | "cancelled" | "killed";
15
- exitCode: number | null;
16
- stdout: string;
17
- stderr: string;
18
- durationMs: number | null;
19
- }
20
- /** Payload delivered to `onComplete` callbacks. */
21
- export interface BackgroundCompletionEvent {
22
- backgroundTaskId: string;
23
- pid: number;
24
- command: string;
25
- description?: string;
26
- status: "completed" | "exited";
27
- exitCode: number;
28
- stdout: string;
29
- stderr: string;
30
- durationMs: number;
31
- }
32
- /** Options for spawning a background process. */
33
- export interface SpawnOptions {
34
- command: string;
35
- cwd: string;
36
- env?: Record<string, string>;
37
- description?: string;
38
- onComplete?: (event: BackgroundCompletionEvent) => void;
39
- }
40
- export declare class BackgroundProcessRegistry {
41
- private readonly processes;
42
- private readonly maxConcurrent;
43
- constructor(options?: {
44
- maxConcurrent?: number;
45
- });
46
- /**
47
- * Spawn a command in the background and begin tracking it.
48
- * Returns a snapshot of the initial record.
49
- */
50
- spawn(opts: SpawnOptions): BackgroundTaskRecord;
51
- /** Get a snapshot of a tracked process by ID, or undefined. */
52
- get(backgroundTaskId: string): BackgroundTaskRecord | undefined;
53
- /** List snapshots of all tracked processes. */
54
- list(): BackgroundTaskRecord[];
55
- /** Cancel (SIGTERM) a running process. Returns true if found and killed. */
56
- cancel(backgroundTaskId: string): boolean;
57
- /** Kill all running processes. */
58
- killAll(): void;
59
- /** Kill all processes and clear tracking state. */
60
- dispose(): void;
61
- private snapshot;
62
- }
6
+ export { BackgroundProcessRegistry, type BackgroundTaskRecord, type BackgroundCompletionEvent, type SpawnOptions, } from "@a5c-ai/agent-runtime";
63
7
  //# sourceMappingURL=backgroundProcessRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"backgroundProcessRegistry.d.ts","sourceRoot":"","sources":["../src/backgroundProcessRegistry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,gDAAgD;AAChD,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;IACpE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,mDAAmD;AACnD,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAC;CACzD;AA4BD,qBAAa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqC;IAC/D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;gBAE3B,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IAIhD;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,oBAAoB;IAuF/C,+DAA+D;IAC/D,GAAG,CAAC,gBAAgB,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS;IAM/D,+CAA+C;IAC/C,IAAI,IAAI,oBAAoB,EAAE;IAI9B,4EAA4E;IAC5E,MAAM,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO;IAczC,kCAAkC;IAClC,OAAO,IAAI,IAAI;IAcf,mDAAmD;IACnD,OAAO,IAAI,IAAI;IASf,OAAO,CAAC,QAAQ;CAcjB"}
1
+ {"version":3,"file":"backgroundProcessRegistry.d.ts","sourceRoot":"","sources":["../src/backgroundProcessRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,yBAAyB,EACzB,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,YAAY,GAClB,MAAM,uBAAuB,CAAC"}