@a5c-ai/agent-core 5.0.1-staging.ac4f12d9

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 (83) hide show
  1. package/README.md +217 -0
  2. package/dist/agenticTools/background/state.d.ts +5 -0
  3. package/dist/agenticTools/background/state.d.ts.map +1 -0
  4. package/dist/agenticTools/background/state.js +25 -0
  5. package/dist/agenticTools/background/tools.d.ts +3 -0
  6. package/dist/agenticTools/background/tools.d.ts.map +1 -0
  7. package/dist/agenticTools/background/tools.js +37 -0
  8. package/dist/agenticTools/browser/tool.d.ts +3 -0
  9. package/dist/agenticTools/browser/tool.d.ts.map +1 -0
  10. package/dist/agenticTools/browser/tool.js +64 -0
  11. package/dist/agenticTools/config/state.d.ts +10 -0
  12. package/dist/agenticTools/config/state.d.ts.map +1 -0
  13. package/dist/agenticTools/config/state.js +127 -0
  14. package/dist/agenticTools/config/tool.d.ts +3 -0
  15. package/dist/agenticTools/config/tool.d.ts.map +1 -0
  16. package/dist/agenticTools/config/tool.js +87 -0
  17. package/dist/agenticTools/discovery/tools.d.ts +3 -0
  18. package/dist/agenticTools/discovery/tools.d.ts.map +1 -0
  19. package/dist/agenticTools/discovery/tools.js +71 -0
  20. package/dist/agenticTools/index.d.ts +5 -0
  21. package/dist/agenticTools/index.d.ts.map +1 -0
  22. package/dist/agenticTools/index.js +41 -0
  23. package/dist/agenticTools/shared/paths.d.ts +5 -0
  24. package/dist/agenticTools/shared/paths.d.ts.map +1 -0
  25. package/dist/agenticTools/shared/paths.js +116 -0
  26. package/dist/agenticTools/shared/process.d.ts +15 -0
  27. package/dist/agenticTools/shared/process.d.ts.map +1 -0
  28. package/dist/agenticTools/shared/process.js +122 -0
  29. package/dist/agenticTools/shared/results.d.ts +9 -0
  30. package/dist/agenticTools/shared/results.d.ts.map +1 -0
  31. package/dist/agenticTools/shared/results.js +50 -0
  32. package/dist/agenticTools/tools/code.d.ts +3 -0
  33. package/dist/agenticTools/tools/code.d.ts.map +1 -0
  34. package/dist/agenticTools/tools/code.js +305 -0
  35. package/dist/agenticTools/tools/delegation.d.ts +3 -0
  36. package/dist/agenticTools/tools/delegation.d.ts.map +1 -0
  37. package/dist/agenticTools/tools/delegation.js +131 -0
  38. package/dist/agenticTools/tools/execution.d.ts +3 -0
  39. package/dist/agenticTools/tools/execution.d.ts.map +1 -0
  40. package/dist/agenticTools/tools/execution.js +132 -0
  41. package/dist/agenticTools/tools/fileSystem.d.ts +3 -0
  42. package/dist/agenticTools/tools/fileSystem.d.ts.map +1 -0
  43. package/dist/agenticTools/tools/fileSystem.js +210 -0
  44. package/dist/agenticTools/types.d.ts +3 -0
  45. package/dist/agenticTools/types.d.ts.map +1 -0
  46. package/dist/agenticTools/types.js +5 -0
  47. package/dist/agenticTools/web/content.d.ts +3 -0
  48. package/dist/agenticTools/web/content.d.ts.map +1 -0
  49. package/dist/agenticTools/web/content.js +54 -0
  50. package/dist/agenticTools/web/searchHelpers.d.ts +8 -0
  51. package/dist/agenticTools/web/searchHelpers.d.ts.map +1 -0
  52. package/dist/agenticTools/web/searchHelpers.js +50 -0
  53. package/dist/agenticTools/web/tools.d.ts +3 -0
  54. package/dist/agenticTools/web/tools.d.ts.map +1 -0
  55. package/dist/agenticTools/web/tools.js +119 -0
  56. package/dist/backgroundProcessRegistry.d.ts +63 -0
  57. package/dist/backgroundProcessRegistry.d.ts.map +1 -0
  58. package/dist/backgroundProcessRegistry.js +200 -0
  59. package/dist/deferredToolRegistry.d.ts +76 -0
  60. package/dist/deferredToolRegistry.d.ts.map +1 -0
  61. package/dist/deferredToolRegistry.js +150 -0
  62. package/dist/deferredToolRegistry.test.d.ts +2 -0
  63. package/dist/deferredToolRegistry.test.d.ts.map +1 -0
  64. package/dist/deferredToolRegistry.test.js +64 -0
  65. package/dist/index.d.ts +7 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +20 -0
  68. package/dist/session.d.ts +31 -0
  69. package/dist/session.d.ts.map +1 -0
  70. package/dist/session.js +272 -0
  71. package/dist/session.test.d.ts +2 -0
  72. package/dist/session.test.d.ts.map +1 -0
  73. package/dist/session.test.js +258 -0
  74. package/dist/tools.d.ts +9 -0
  75. package/dist/tools.d.ts.map +1 -0
  76. package/dist/tools.js +18 -0
  77. package/dist/tools.test.d.ts +2 -0
  78. package/dist/tools.test.d.ts.map +1 -0
  79. package/dist/tools.test.js +514 -0
  80. package/dist/types.d.ts +110 -0
  81. package/dist/types.d.ts.map +1 -0
  82. package/dist/types.js +30 -0
  83. package/package.json +49 -0
package/README.md ADDED
@@ -0,0 +1,217 @@
1
+ # @a5c-ai/agent-core
2
+
3
+ Built-in programmatic session wrapper and agentic tool surface for Babysitter runtime consumers.
4
+
5
+ <!-- docs-status:start -->
6
+ > Status: Public advanced/runtime package.
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`.
9
+ <!-- docs-status:end -->
10
+
11
+ ## Package role
12
+
13
+ `@a5c-ai/agent-core` sits between `@a5c-ai/babysitter-agent`, `@a5c-ai/agent-mux`, and `@a5c-ai/babysitter-sdk`:
14
+
15
+ - `createAgentCoreSession()` wraps an `@a5c-ai/agent-mux` client for in-process prompt execution.
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.
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
+
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.
21
+
22
+ ## Root exports
23
+
24
+ The package root exports the runtime surface assembled from `src/index.ts` and `src/tools.ts`:
25
+
26
+ ```ts
27
+ import {
28
+ AGENT_CORE_TOOL_NAMES,
29
+ AgentCoreSessionHandle,
30
+ DeferredToolRegistry,
31
+ createAgentCoreSession,
32
+ createAgentCoreToolDefinitions,
33
+ disposeAgentCoreToolDefinitions,
34
+ extractTextFromHtml,
35
+ filterByRelevance,
36
+ parseSearchResults,
37
+ resetRunScopedConfig,
38
+ stripHtmlTags,
39
+ type AgentCoreEventListener,
40
+ type AgentCorePromptResult,
41
+ type AgentCoreSessionEvent,
42
+ type AgentCoreSessionOptions,
43
+ type AgentCoreToolOptions,
44
+ type CustomToolDefinition,
45
+ type ToolResult,
46
+ } from "@a5c-ai/agent-core";
47
+ ```
48
+
49
+ Key exports:
50
+
51
+ - `createAgentCoreSession(options)` / `AgentCoreSessionHandle`: programmatic session API backed by `@a5c-ai/agent-mux`.
52
+ - `createAgentCoreToolDefinitions(options)` / `disposeAgentCoreToolDefinitions(definitions)`: built-in tool-definition assembly and teardown.
53
+ - `DeferredToolRegistry`: lazy registry for searchable/fetchable external tool schemas.
54
+ - `AGENT_CORE_TOOL_NAMES`: canonical bundled tool name list.
55
+ - `AgenticToolOptions` and `AGENTIC_TOOL_NAMES`: compatibility aliases for older host integrations.
56
+ - `resetRunScopedConfig()`: clears run-scoped state used by the `config` tool.
57
+ - `parseSearchResults()`, `stripHtmlTags()`, `extractTextFromHtml()`, `filterByRelevance()`: helper exports used by web/search integrations.
58
+
59
+ ## Session API
60
+
61
+ `createAgentCoreSession()` returns an `AgentCoreSessionHandle` that wraps a shared `@a5c-ai/agent-mux` client with built-in adapters registered once per process.
62
+
63
+ Core handle methods:
64
+
65
+ - `initialize()`: currently a no-op placeholder for compatibility.
66
+ - `prompt(text, timeout?)`: starts a run, streams events to subscribers, and returns `{ output, duration, success, exitCode }`.
67
+ - `steer(text)`: sends immediate steering text while a prompt is active, or queues it for the next prompt.
68
+ - `followUp(text)`: queues a post-response follow-up when streaming, or appends it to the next prompt when idle.
69
+ - `subscribe(listener)`: receives normalized `AgentCoreSessionEvent` payloads, including `session_start`.
70
+ - `abort()`: aborts the active run if one is in progress.
71
+ - `dispose()`: aborts the active run, clears listeners, and drops queued follow-ups.
72
+ - `executeCommand()` / `executeBash()`: local shell helpers scoped to `options.workspace`.
73
+ - `sessionId` / `isStreaming`: getters for the active continued session id and current streaming state.
74
+
75
+ Session behavior that matters to host integrations:
76
+
77
+ - Agent-core reuses the `sessionId` learned from prior runs, so later prompts continue the same agent-mux session when the backend supports it.
78
+ - Concurrent `prompt()` calls on the same handle are rejected.
79
+ - Event payloads are normalized before subscribers see them. Non-object payloads become `{ type: "unknown", value }`.
80
+ - Approval mode is `prompt` only when `uiContext` is present; otherwise agent-core uses `yolo`.
81
+
82
+ ### Supported runtime options
83
+
84
+ | Option | Runtime effect |
85
+ | --- | --- |
86
+ | `workspace` | Forwarded to agent-mux as `cwd`. |
87
+ | `model` | Forwarded to agent-mux as `model`. |
88
+ | `timeout` | Forwarded to agent-mux as `timeout`. |
89
+ | `thinkingLevel` | Translated to agent-mux `thinkingEffort` (`minimal`/`low` -> `low`, `medium` -> `medium`, `high` -> `high`, `xhigh` -> `max`). |
90
+ | `systemPrompt` | Used as the base `systemPrompt`. |
91
+ | `appendSystemPrompt` | Appended to the final `systemPrompt` before dispatch. |
92
+ | `uiContext` | Switches run approval mode to `prompt`; when omitted, agent-core uses `yolo`. |
93
+ | `backend` | Selects the agent-mux adapter/backend forwarded as `agent`. |
94
+
95
+ ### Deprecated compatibility fields
96
+
97
+ These fields remain on `AgentCoreSessionOptions` for compatibility, but the current runtime ignores them:
98
+
99
+ | Option | Status | Migration note |
100
+ | --- | --- | --- |
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. |
102
+ | `customTools` | Deprecated, ignored by agent-core | Register host-side tools with `createAgentCoreToolDefinitions()` or use the PI wrapper for runtime custom-tool injection. |
103
+ | `isolated` | Deprecated, ignored by agent-core | Use the PI wrapper if you still need extension/skills isolation controls. |
104
+ | `ephemeral` | Deprecated, ignored by agent-core | Session persistence is determined by the selected agent-mux backend. |
105
+ | `bashSandbox` | Deprecated, ignored by agent-core | Sandbox behavior belongs to the selected backend. |
106
+ | `enableCompaction` | Deprecated, ignored by agent-core | Compaction behavior belongs to the selected backend/runtime. |
107
+ | `agentDir` | Deprecated, ignored by agent-core | Configure agent directories through the target backend instead. |
108
+
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`.
110
+
111
+ ## Tool-definition API
112
+
113
+ `createAgentCoreToolDefinitions(options)` returns a wrapped `CustomToolDefinition[]` assembled from:
114
+
115
+ - file-system tools: `read`, `write`, `edit`, `grep`, `find`
116
+ - execution tools: `bash`, `python`, `ssh`, `fetch`
117
+ - browser/config tools: `browser`, `config`
118
+ - delegation tools: `AskUserQuestion`, `task`, `skill`
119
+ - code tools: `calc`, `ast_grep`, `ast_edit`, `render_mermaid`, `notebook`
120
+ - background/discovery/web tools: `background_status`, `background_list`, `tool_search`, `tool_fetch`, `web_search`, `fetch_process`
121
+
122
+ `AgentCoreToolOptions` controls how those definitions are wired into a host runtime:
123
+
124
+ - `workspace`: base directory for filesystem and execution tools.
125
+ - `interactive`: gates interactive tool behavior.
126
+ - `askUserQuestionHandler`, `taskHandler`, `skillHandler`: host-owned handlers for delegated tool calls.
127
+ - `onToolUse`: observer callback fired after tool wrapping.
128
+ - `onBackgroundComplete`, `maxBackgroundProcesses`, `backgroundRegistry`: background-process lifecycle hooks and limits.
129
+ - `deferredToolRegistry`: enables `tool_search` and `tool_fetch`.
130
+
131
+ ### Interactive and cancellation contract
132
+
133
+ - `interactive: false` disables `AskUserQuestion` even if `askUserQuestionHandler` is supplied. Both simple and structured calls return `Error: AskUserQuestion is unavailable when interactive=false.` and the handler is never invoked.
134
+ - `CustomToolDefinition.execute()` does not receive a shared `AbortSignal`. Long-running tools must own their own timeout/cancellation behavior.
135
+ - Synchronous throws and rejected promises are normalized into `Error: ...` tool results.
136
+ - Timeout-driven aborts are normalized to `Error: Tool execution was cancelled.`
137
+
138
+ ### Background-task lifecycle caveats
139
+
140
+ Background tasks are scoped to the returned tool-definition array, not to a module-global singleton.
141
+
142
+ - `background_list` and `background_status` only expose tasks started by that same definition set.
143
+ - `maxBackgroundProcesses` is enforced per scoped registry.
144
+ - `disposeAgentCoreToolDefinitions(definitions)` kills still-running background tasks and clears retained stdout/stderr/task records for that definition set.
145
+ - If you inject a custom `backgroundRegistry`, ownership moves to the caller and you must dispose it yourself.
146
+
147
+ ### Config tool state
148
+
149
+ The `config` tool reads Babysitter defaults from `@a5c-ai/babysitter-sdk` and also supports run-scoped in-memory overrides plus selected global env-var writes.
150
+
151
+ Call `resetRunScopedConfig()` between independent runs if your host process reuses the same agent-core module instance and you do not want config overrides to leak across runs.
152
+
153
+ ## DeferredToolRegistry API
154
+
155
+ `DeferredToolRegistry` is the package's lazy schema registry for non-bundled tools.
156
+
157
+ Typical flow:
158
+
159
+ 1. Register tier-1 entries with `registerTools()`.
160
+ 2. Register per-source loaders with `registerLoader()`.
161
+ 3. Use `tool_search` or `searchTools()` for lightweight discovery by name/description.
162
+ 4. Use `tool_fetch` or `fetchSchema()` to lazily load and cache a full schema.
163
+
164
+ Useful methods:
165
+
166
+ - `registerTools(entries)`
167
+ - `registerLoader(source, loader)`
168
+ - `getAllEntries()`
169
+ - `getEntriesBySource(source, sourceQualifier?)`
170
+ - `searchTools(query, maxResults?)`
171
+ - `fetchSchema(toolName, source?, sourceQualifier?)`
172
+ - `removeToolsBySource(source, sourceQualifier?)`
173
+ - `clear()`
174
+ - `size` / `loadedSchemaCount`
175
+
176
+ Source disambiguation uses `(source, sourceQualifier, name)`, so duplicate tool names from different MCP servers or plugins can coexist safely.
177
+
178
+ ## Integration points
179
+
180
+ Current downstream integration boundaries in this repo:
181
+
182
+ - `@a5c-ai/babysitter-agent`
183
+ - re-exports the session/tool APIs from `src/harness/index.ts`
184
+ - uses `createAgentCoreSession()` for the direct `agent-core` harness path in `src/harness/invoker.ts`
185
+ - injects `createAgentCoreToolDefinitions()` into plan-process and delegated-task flows in `src/harness/internal/createRun/planProcess/*`
186
+ - uses both session and tool-definition APIs in `src/cli/commands/harness/resumeRun.ts` to inspect and resume existing runs
187
+ - `@a5c-ai/agent-mux`
188
+ - provides the actual client, built-in adapters, session continuation, approval mode, and backend selection that agent-core forwards into
189
+ - `@a5c-ai/babysitter-sdk`
190
+ - provides config defaults/env wiring used by the `config` tool and remains the owner of orchestration/run-state semantics outside this package
191
+
192
+ 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.
193
+
194
+ ## Build, test, and CI
195
+
196
+ From the repo root:
197
+
198
+ ```bash
199
+ npm run build --workspace=@a5c-ai/agent-core
200
+ npm run test --workspace=@a5c-ai/agent-core
201
+ ```
202
+
203
+ The package `build` script invokes the root `build:runtime:agent-core-deps` entrypoint before `tsc --build`, so fresh-checkout builds do not depend on prebuilt upstream `dist/` output.
204
+
205
+ Package-local `test` runs `vitest` against:
206
+
207
+ - `src/session.test.ts` for session option/event/continuation behavior
208
+ - `src/tools.test.ts` for tool-surface behavior, background-task scoping, AskUserQuestion gating, and helper exports
209
+ - `src/deferredToolRegistry.test.ts` for registry search, fetch, cache, and removal behavior
210
+
211
+ For the shared runtime chain used by release-oriented workflows, run:
212
+
213
+ ```bash
214
+ npm run build:runtime
215
+ ```
216
+
217
+ Per [Workspace Validation Map](../../docs/workspace-validation.md), `packages/agent-core` is a public advanced/runtime package validated by `.github/workflows/ci.yml` job `test` and by the release/staging workflows. Keep README claims aligned with those validation paths rather than inventing package-specific CI jobs that do not exist.
@@ -0,0 +1,5 @@
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;
5
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,25 @@
1
+ "use strict";
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
+ }
@@ -0,0 +1,3 @@
1
+ import type { AgenticToolOptions, CustomToolDefinition } from "../types";
2
+ export declare function createBackgroundTools(options: AgenticToolOptions): CustomToolDefinition[];
3
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/background/tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAIzE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CA+BzF"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBackgroundTools = createBackgroundTools;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ const results_1 = require("../shared/results");
6
+ const state_1 = require("./state");
7
+ function createBackgroundTools(options) {
8
+ return [
9
+ {
10
+ name: "background_status",
11
+ label: "Background Task Status",
12
+ description: "Query the status of a background task by its backgroundTaskId. Returns the task record including status, stdout, stderr, and exit code.",
13
+ parameters: typebox_1.Type.Object({
14
+ backgroundTaskId: typebox_1.Type.String({
15
+ description: "The backgroundTaskId returned when launching a background task",
16
+ }),
17
+ }),
18
+ execute: (_toolCallId, params) => {
19
+ const backgroundTaskId = String(params.backgroundTaskId);
20
+ const record = (0, state_1.getBackgroundRegistry)(options).get(backgroundTaskId);
21
+ if (!record) {
22
+ return (0, results_1.errorResult)(`Background task not found: ${backgroundTaskId}`);
23
+ }
24
+ return (0, results_1.jsonResult)(record);
25
+ },
26
+ },
27
+ {
28
+ name: "background_list",
29
+ label: "List Background Tasks",
30
+ description: "List all tracked background tasks with their current status.",
31
+ parameters: typebox_1.Type.Object({}),
32
+ execute: () => (0, results_1.jsonResult)({
33
+ tasks: (0, state_1.getBackgroundRegistry)(options).list(),
34
+ }),
35
+ },
36
+ ];
37
+ }
@@ -0,0 +1,3 @@
1
+ import type { CustomToolDefinition } from "../types";
2
+ export declare function createBrowserTool(): CustomToolDefinition;
3
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/browser/tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAoBrD,wBAAgB,iBAAiB,IAAI,oBAAoB,CA+DxD"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBrowserTool = createBrowserTool;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ const results_1 = require("../shared/results");
6
+ let browserInstance = null;
7
+ function createBrowserTool() {
8
+ return {
9
+ name: "browser",
10
+ label: "Headless Browser",
11
+ description: "Interact with a headless browser. Actions: navigate, click, type, evaluate, screenshot, close.",
12
+ parameters: typebox_1.Type.Object({
13
+ action: typebox_1.Type.String({
14
+ description: "Action: navigate | click | type | evaluate | screenshot | close",
15
+ }),
16
+ url: typebox_1.Type.Optional(typebox_1.Type.String({ description: "URL to navigate to" })),
17
+ selector: typebox_1.Type.Optional(typebox_1.Type.String({ description: "CSS selector for click/type" })),
18
+ text: typebox_1.Type.Optional(typebox_1.Type.String({ description: "Text to type" })),
19
+ script: typebox_1.Type.Optional(typebox_1.Type.String({ description: "JavaScript to evaluate in page" })),
20
+ options: typebox_1.Type.Optional(typebox_1.Type.Object({}, { additionalProperties: true })),
21
+ }),
22
+ execute: async (_toolCallId, params) => {
23
+ let puppeteer;
24
+ try {
25
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-assignment
26
+ puppeteer = await new Function("id", "return import(id)")("puppeteer");
27
+ }
28
+ catch {
29
+ return (0, results_1.errorResult)("puppeteer is not installed. Install it with: npm install puppeteer");
30
+ }
31
+ if (!browserInstance) {
32
+ browserInstance = await puppeteer.launch({
33
+ headless: true,
34
+ args: ["--no-sandbox", "--disable-setuid-sandbox"],
35
+ });
36
+ }
37
+ const browser = browserInstance;
38
+ const page = (await browser.pages())[0] ?? await browser.newPage();
39
+ switch (String(params.action)) {
40
+ case "navigate":
41
+ await page.goto(String(params.url), { waitUntil: "domcontentloaded" });
42
+ return (0, results_1.ok)(`Navigated to ${String(params.url)} — title: ${await page.title()}`);
43
+ case "click":
44
+ await page.click(String(params.selector));
45
+ return (0, results_1.ok)(`Clicked ${String(params.selector)}`);
46
+ case "type":
47
+ await page.type(String(params.selector), String(params.text));
48
+ return (0, results_1.ok)(`Typed into ${String(params.selector)}`);
49
+ case "evaluate":
50
+ return (0, results_1.jsonResult)(await page.evaluate(String(params.script)));
51
+ case "screenshot": {
52
+ const buffer = await page.screenshot({ encoding: "base64" });
53
+ return (0, results_1.ok)(`Screenshot captured (${buffer.length} base64 chars).`);
54
+ }
55
+ case "close":
56
+ await browser.close();
57
+ browserInstance = null;
58
+ return (0, results_1.ok)("Browser closed.");
59
+ default:
60
+ return (0, results_1.errorResult)(`Unknown browser action: ${String(params.action)}`);
61
+ }
62
+ },
63
+ };
64
+ }
@@ -0,0 +1,10 @@
1
+ export declare function resetRunScopedConfig(): void;
2
+ export declare function isValidConfigKey(key: string): boolean;
3
+ export declare function validateConfigValue(key: string, value: unknown): string | null;
4
+ export declare function getConfigValue(key: string): unknown;
5
+ export declare function getConfigDefault(key: string): unknown;
6
+ export declare function listConfigKeys(): string[];
7
+ export declare function getRunScopedConfigEntries(): IterableIterator<[string, unknown]>;
8
+ export declare function setConfigValue(key: string, value: unknown, scope: string): void;
9
+ export declare function resetConfigValue(key?: string): void;
10
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/config/state.ts"],"names":[],"mappings":"AAwDA,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAKrD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAY9E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CASnD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAKrD;AAED,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAMzC;AAED,wBAAgB,yBAAyB,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAE/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAU/E;AAED,wBAAgB,gBAAgB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAMnD"}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resetRunScopedConfig = resetRunScopedConfig;
4
+ exports.isValidConfigKey = isValidConfigKey;
5
+ exports.validateConfigValue = validateConfigValue;
6
+ exports.getConfigValue = getConfigValue;
7
+ exports.getConfigDefault = getConfigDefault;
8
+ exports.listConfigKeys = listConfigKeys;
9
+ exports.getRunScopedConfigEntries = getRunScopedConfigEntries;
10
+ exports.setConfigValue = setConfigValue;
11
+ exports.resetConfigValue = resetConfigValue;
12
+ const babysitter_sdk_1 = require("@a5c-ai/babysitter-sdk");
13
+ const EXTENDED_CONFIG_KEYS = new Set([
14
+ "model",
15
+ "provider",
16
+ "breakpoint.autoApproveAfterN",
17
+ "breakpoint.presentAlwaysApprove",
18
+ ]);
19
+ const BABYSITTER_CONFIG_KEYS = new Set([
20
+ "runsDir",
21
+ "maxIterations",
22
+ "qualityThreshold",
23
+ "timeout",
24
+ "logLevel",
25
+ "allowSecretLogs",
26
+ "hookTimeout",
27
+ "nodeTaskTimeout",
28
+ "clockStepMs",
29
+ "clockStartMs",
30
+ "layoutVersion",
31
+ "largeResultPreviewLimit",
32
+ ]);
33
+ const CONFIG_KEY_TYPES = {
34
+ runsDir: "string",
35
+ maxIterations: "number",
36
+ qualityThreshold: "number",
37
+ timeout: "number",
38
+ logLevel: "string",
39
+ allowSecretLogs: "boolean",
40
+ hookTimeout: "number",
41
+ nodeTaskTimeout: "number",
42
+ clockStepMs: "number",
43
+ clockStartMs: "number",
44
+ layoutVersion: "string",
45
+ largeResultPreviewLimit: "number",
46
+ model: "string",
47
+ provider: "string",
48
+ };
49
+ const VALID_LOG_LEVELS = new Set(["debug", "info", "warn", "error", "silent"]);
50
+ const CONFIG_KEY_TO_ENV = {
51
+ runsDir: babysitter_sdk_1.CONFIG_ENV_VARS.RUNS_DIR,
52
+ maxIterations: babysitter_sdk_1.CONFIG_ENV_VARS.MAX_ITERATIONS,
53
+ qualityThreshold: babysitter_sdk_1.CONFIG_ENV_VARS.QUALITY_THRESHOLD,
54
+ timeout: babysitter_sdk_1.CONFIG_ENV_VARS.TIMEOUT,
55
+ logLevel: babysitter_sdk_1.CONFIG_ENV_VARS.LOG_LEVEL,
56
+ allowSecretLogs: babysitter_sdk_1.CONFIG_ENV_VARS.ALLOW_SECRET_LOGS,
57
+ hookTimeout: babysitter_sdk_1.CONFIG_ENV_VARS.HOOK_TIMEOUT,
58
+ nodeTaskTimeout: babysitter_sdk_1.CONFIG_ENV_VARS.NODE_TASK_TIMEOUT,
59
+ };
60
+ const runScopedConfig = new Map();
61
+ function resetRunScopedConfig() {
62
+ runScopedConfig.clear();
63
+ }
64
+ function isValidConfigKey(key) {
65
+ return BABYSITTER_CONFIG_KEYS.has(key)
66
+ || EXTENDED_CONFIG_KEYS.has(key)
67
+ || key.startsWith("compression.")
68
+ || key.startsWith("breakpoint.");
69
+ }
70
+ function validateConfigValue(key, value) {
71
+ const expectedType = CONFIG_KEY_TYPES[key];
72
+ if (expectedType && typeof value !== expectedType) {
73
+ return `Expected '${key}' to be ${expectedType}, got ${typeof value}.`;
74
+ }
75
+ if (key === "logLevel" && typeof value === "string" && !VALID_LOG_LEVELS.has(value)) {
76
+ return `Invalid logLevel '${value}'. Must be one of: ${[...VALID_LOG_LEVELS].join(", ")}.`;
77
+ }
78
+ if (expectedType === "number" && typeof value === "number" && key !== "clockStartMs" && value <= 0) {
79
+ return `'${key}' must be a positive number.`;
80
+ }
81
+ return null;
82
+ }
83
+ function getConfigValue(key) {
84
+ if (runScopedConfig.has(key)) {
85
+ return runScopedConfig.get(key);
86
+ }
87
+ if (BABYSITTER_CONFIG_KEYS.has(key)) {
88
+ const config = (0, babysitter_sdk_1.getConfig)();
89
+ return config[key];
90
+ }
91
+ return undefined;
92
+ }
93
+ function getConfigDefault(key) {
94
+ if (BABYSITTER_CONFIG_KEYS.has(key)) {
95
+ return babysitter_sdk_1.DEFAULTS[key];
96
+ }
97
+ return undefined;
98
+ }
99
+ function listConfigKeys() {
100
+ return [...new Set([
101
+ ...BABYSITTER_CONFIG_KEYS,
102
+ ...EXTENDED_CONFIG_KEYS,
103
+ ...runScopedConfig.keys(),
104
+ ])];
105
+ }
106
+ function getRunScopedConfigEntries() {
107
+ return runScopedConfig.entries();
108
+ }
109
+ function setConfigValue(key, value, scope) {
110
+ if (scope === "global") {
111
+ const envKey = CONFIG_KEY_TO_ENV[key];
112
+ if (envKey) {
113
+ process.env[envKey] = String(value);
114
+ }
115
+ else {
116
+ process.env[`BABYSITTER_${key.replace(/\./g, "_").toUpperCase()}`] = String(value);
117
+ }
118
+ }
119
+ runScopedConfig.set(key, value);
120
+ }
121
+ function resetConfigValue(key) {
122
+ if (key) {
123
+ runScopedConfig.delete(key);
124
+ return;
125
+ }
126
+ runScopedConfig.clear();
127
+ }
@@ -0,0 +1,3 @@
1
+ import type { CustomToolDefinition } from "../types";
2
+ export declare function createConfigTool(): CustomToolDefinition;
3
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/config/tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAarD,wBAAgB,gBAAgB,IAAI,oBAAoB,CAuFvD"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createConfigTool = createConfigTool;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ const results_1 = require("../shared/results");
6
+ const state_1 = require("./state");
7
+ function createConfigTool() {
8
+ return {
9
+ name: "config",
10
+ label: "Runtime Config",
11
+ description: "Read and modify babysitter configuration at runtime. Supports get/set/list/reset actions for standard config keys, model/provider selection, and compression settings.",
12
+ parameters: typebox_1.Type.Object({
13
+ action: typebox_1.Type.Union([
14
+ typebox_1.Type.Literal("get"),
15
+ typebox_1.Type.Literal("set"),
16
+ typebox_1.Type.Literal("list"),
17
+ typebox_1.Type.Literal("reset"),
18
+ ], { description: "Action to perform: get, set, list, or reset" }),
19
+ key: typebox_1.Type.Optional(typebox_1.Type.String({ description: "Config key path (dot notation for nested, e.g. 'compression.enabled')" })),
20
+ value: typebox_1.Type.Optional(typebox_1.Type.Unknown({ description: "New value for set action" })),
21
+ scope: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Literal("run"), typebox_1.Type.Literal("global")], {
22
+ description: "Scope: 'run' (default, in-memory) or 'global' (env vars)",
23
+ })),
24
+ }),
25
+ execute: (_toolCallId, params) => {
26
+ const action = params.action;
27
+ if (!action) {
28
+ return (0, results_1.errorResult)("'action' parameter is required (get, set, list, reset).");
29
+ }
30
+ const key = params.key;
31
+ const value = params.value;
32
+ const scope = params.scope ?? "run";
33
+ switch (action) {
34
+ case "get":
35
+ if (!key) {
36
+ const merged = {};
37
+ for (const configKey of (0, state_1.listConfigKeys)()) {
38
+ merged[configKey] = (0, state_1.getConfigValue)(configKey);
39
+ }
40
+ return (0, results_1.jsonResult)(merged);
41
+ }
42
+ if (!(0, state_1.isValidConfigKey)(key)) {
43
+ return (0, results_1.errorResult)(`Error: Unknown config key '${key}'.`);
44
+ }
45
+ return (0, results_1.jsonResult)({ key, value: (0, state_1.getConfigValue)(key) });
46
+ case "set":
47
+ if (!key) {
48
+ return (0, results_1.errorResult)("Error: 'key' parameter is required for set action.");
49
+ }
50
+ if (value === undefined) {
51
+ return (0, results_1.errorResult)("Error: 'value' parameter is required for set action.");
52
+ }
53
+ if (!(0, state_1.isValidConfigKey)(key)) {
54
+ return (0, results_1.errorResult)(`Error: Unknown config key '${key}'.`);
55
+ }
56
+ {
57
+ const validationError = (0, state_1.validateConfigValue)(key, value);
58
+ if (validationError) {
59
+ return (0, results_1.errorResult)(`Error: ${validationError}`);
60
+ }
61
+ }
62
+ (0, state_1.setConfigValue)(key, value, scope);
63
+ return (0, results_1.ok)(`Set '${key}' to ${JSON.stringify(value)} (scope: ${scope}).`);
64
+ case "list": {
65
+ const entries = {};
66
+ for (const configKey of (0, state_1.listConfigKeys)()) {
67
+ entries[configKey] = {
68
+ current: (0, state_1.getConfigValue)(configKey),
69
+ default: (0, state_1.getConfigDefault)(configKey),
70
+ };
71
+ }
72
+ for (const [configKey, configValue] of (0, state_1.getRunScopedConfigEntries)()) {
73
+ if (!entries[configKey]) {
74
+ entries[configKey] = { current: configValue, default: undefined };
75
+ }
76
+ }
77
+ return (0, results_1.jsonResult)(entries);
78
+ }
79
+ case "reset":
80
+ (0, state_1.resetConfigValue)(key);
81
+ return (0, results_1.ok)(key ? `Reset '${key}' to default.` : "Reset all config to defaults.");
82
+ default:
83
+ return (0, results_1.errorResult)(`Error: Unknown action '${action}'. Use get, set, list, or reset.`);
84
+ }
85
+ },
86
+ };
87
+ }
@@ -0,0 +1,3 @@
1
+ import type { AgenticToolOptions, CustomToolDefinition } from "../types";
2
+ export declare function createDiscoveryTools(options: AgenticToolOptions): CustomToolDefinition[];
3
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/agenticTools/discovery/tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGzE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,oBAAoB,EAAE,CA0ExF"}