@gaunt-sloth/agent 2.0.0-alpha.3 → 2.0.0-alpha.30
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.
- package/README.md +73 -23
- package/dist/builtInToolsConfig.d.ts +17 -3
- package/dist/builtInToolsConfig.js +40 -41
- package/dist/builtInToolsConfig.js.map +1 -1
- package/dist/core/GthDeepAgent.d.ts +52 -32
- package/dist/core/GthDeepAgent.js +438 -198
- package/dist/core/GthDeepAgent.js.map +1 -1
- package/dist/core/debugCapture.d.ts +8 -49
- package/dist/core/debugCapture.js +1 -1
- package/dist/core/debugCapture.js.map +1 -1
- package/dist/core/deepAgentPermissions.d.ts +67 -2
- package/dist/core/deepAgentPermissions.js +151 -3
- package/dist/core/deepAgentPermissions.js.map +1 -1
- package/dist/core/gthAcpServer.js +11 -0
- package/dist/core/gthAcpServer.js.map +1 -1
- package/dist/core/gthDeepAgentFactory.d.ts +3 -0
- package/dist/core/gthDeepAgentFactory.js +9 -1
- package/dist/core/gthDeepAgentFactory.js.map +1 -1
- package/dist/core/resolveAgentFactory.d.ts +14 -0
- package/dist/core/resolveAgentFactory.js +18 -0
- package/dist/core/resolveAgentFactory.js.map +1 -0
- package/dist/core/subagentProfiles.d.ts +50 -0
- package/dist/core/subagentProfiles.js +76 -0
- package/dist/core/subagentProfiles.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/OAuthClientProviderImpl.js.map +1 -1
- package/dist/mcp/tlsTrust.d.ts +61 -0
- package/dist/mcp/tlsTrust.js +109 -0
- package/dist/mcp/tlsTrust.js.map +1 -0
- package/dist/middleware/binaryContentInjectionMiddleware.d.ts +8 -1
- package/dist/middleware/binaryContentInjectionMiddleware.js +11 -2
- package/dist/middleware/binaryContentInjectionMiddleware.js.map +1 -1
- package/dist/middleware/frontendImageInjectionMiddleware.d.ts +106 -0
- package/dist/middleware/frontendImageInjectionMiddleware.js +166 -0
- package/dist/middleware/frontendImageInjectionMiddleware.js.map +1 -0
- package/dist/middleware/registry.js +36 -1
- package/dist/middleware/registry.js.map +1 -1
- package/dist/middleware/types.d.ts +16 -2
- package/dist/modules/a2a/A2AClientWrapper.d.ts +56 -1
- package/dist/modules/a2a/A2AClientWrapper.js +131 -31
- package/dist/modules/a2a/A2AClientWrapper.js.map +1 -1
- package/dist/modules/acpModule.js +17 -1
- package/dist/modules/acpModule.js.map +1 -1
- package/dist/modules/apiAgUiModule.d.ts +87 -0
- package/dist/modules/apiAgUiModule.js +229 -28
- package/dist/modules/apiAgUiModule.js.map +1 -1
- package/dist/modules/interactiveSessionModule.js +501 -41
- package/dist/modules/interactiveSessionModule.js.map +1 -1
- package/dist/modules/slashCommands.d.ts +576 -0
- package/dist/modules/slashCommands.js +995 -0
- package/dist/modules/slashCommands.js.map +1 -0
- package/dist/resolvers.js +119 -9
- package/dist/resolvers.js.map +1 -1
- package/dist/tools/GthCustomToolkit.js +95 -11
- package/dist/tools/GthCustomToolkit.js.map +1 -1
- package/dist/tools/GthDevToolkit.d.ts +11 -3
- package/dist/tools/GthDevToolkit.js +120 -34
- package/dist/tools/GthDevToolkit.js.map +1 -1
- package/dist/tools/GthFileSystemToolkit.d.ts +63 -0
- package/dist/tools/GthFileSystemToolkit.js +506 -105
- package/dist/tools/GthFileSystemToolkit.js.map +1 -1
- package/dist/tools/McpResourceTool.d.ts +31 -0
- package/dist/tools/McpResourceTool.js +106 -0
- package/dist/tools/McpResourceTool.js.map +1 -0
- package/dist/tools/gthChecklistTool.d.ts +30 -0
- package/dist/tools/gthChecklistTool.js +81 -0
- package/dist/tools/gthChecklistTool.js.map +1 -0
- package/dist/tools/gthGrepTool.d.ts +54 -0
- package/dist/tools/gthGrepTool.js +482 -0
- package/dist/tools/gthGrepTool.js.map +1 -0
- package/dist/tools/shell/env.js +1 -1
- package/dist/tools/shell/env.js.map +1 -1
- package/dist/tools/shell/outputBuffer.js.map +1 -1
- package/dist/tools/shell/workDir.d.ts +11 -0
- package/dist/tools/shell/workDir.js +45 -0
- package/dist/tools/shell/workDir.js.map +1 -0
- package/dist/utils/mcpAuthError.d.ts +36 -0
- package/dist/utils/mcpAuthError.js +89 -0
- package/dist/utils/mcpAuthError.js.map +1 -0
- package/dist/utils/mcpUtils.js +16 -0
- package/dist/utils/mcpUtils.js.map +1 -1
- package/package.json +12 -11
- package/dist/tools/shell/allowlist.d.ts +0 -11
- package/dist/tools/shell/allowlist.js +0 -12
- package/dist/tools/shell/allowlist.js.map +0 -1
- package/dist/tools/shell/arity.d.ts +0 -11
- package/dist/tools/shell/arity.js +0 -12
- package/dist/tools/shell/arity.js.map +0 -1
- package/dist/tools/shell/hardline.d.ts +0 -15
- package/dist/tools/shell/hardline.js +0 -88
- package/dist/tools/shell/hardline.js.map +0 -1
- package/dist/tools/shell/normalize.d.ts +0 -10
- package/dist/tools/shell/normalize.js +0 -11
- package/dist/tools/shell/normalize.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,25 +1,75 @@
|
|
|
1
1
|
# @gaunt-sloth/agent
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
3
|
+
The agent runtime for Gaunt Sloth: built-in tools and toolkits (filesystem, dev/shell, web
|
|
4
|
+
fetch, custom), the middleware registry, MCP client + OAuth provider, A2A client and tools, the
|
|
5
|
+
AG-UI server (`startAgUiServer`), the ACP server (`startAcpServer`), the interactive session
|
|
6
|
+
module, and the `createResolvers` tool/middleware resolver wiring. It builds on
|
|
7
|
+
[`@gaunt-sloth/core`](https://www.npmjs.com/package/@gaunt-sloth/core) (config, provider
|
|
8
|
+
factory, lean agent runtime).
|
|
9
|
+
|
|
10
|
+
**When to depend on this package** — you are embedding the running agent: serving it to a web
|
|
11
|
+
client over AG-UI, wiring its tools/middleware into your own host, or talking to MCP/A2A
|
|
12
|
+
services. The fat [`gaunt-sloth`](https://www.npmjs.com/package/gaunt-sloth) CLI wires this same
|
|
13
|
+
runtime into `gth chat` / `gth code` / `gth api`; install that instead if you want the terminal
|
|
14
|
+
experience rather than a library.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @gaunt-sloth/agent @langchain/anthropic
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
AI providers are optional peer dependencies of `@gaunt-sloth/core` — install the one(s) your
|
|
23
|
+
config uses (see the core README's provider list).
|
|
24
|
+
|
|
25
|
+
## Embedding: serve the agent over AG-UI
|
|
26
|
+
|
|
27
|
+
I want a local web client to talk to the configured Gaunt Sloth agent over the
|
|
28
|
+
[AG-UI protocol](https://github.com/ag-ui-protocol/ag-ui). With a `.gsloth.config.*` in the
|
|
29
|
+
working directory:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import { initConfig } from '@gaunt-sloth/core';
|
|
33
|
+
import { startAgUiServer } from '@gaunt-sloth/agent';
|
|
34
|
+
|
|
35
|
+
const config = await initConfig({});
|
|
36
|
+
await startAgUiServer(config, config.commands?.api?.port ?? 3000);
|
|
37
|
+
// POST /agents/:agentId/run now streams typed AG-UI SSE events
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The server is intended for **local clients only** (a local web UI talking to a local agent); do
|
|
41
|
+
not expose it to public networks. Port and CORS come from `commands.api.*` in the config — see
|
|
42
|
+
[the configuration guide](https://github.com/pukeko-robotics/gaunt-sloth/blob/main/docs/configuration/index.md).
|
|
43
|
+
|
|
44
|
+
## Binaries
|
|
45
|
+
|
|
46
|
+
- **`gaunt-sloth-api`** — starts the AG-UI server standalone (the code above as a command):
|
|
47
|
+
`gaunt-sloth-api` (defaults to the `ag-ui` server on `commands.api.port`, 3000 by default).
|
|
48
|
+
- **`gaunt-sloth-acp`** — runs the [Agent Client Protocol](https://agentclientprotocol.com/)
|
|
49
|
+
server over stdio, for ACP hosts (Zed, JetBrains). Prefer `gaunt-sloth --acp-agent` from the
|
|
50
|
+
[`gaunt-sloth`](https://www.npmjs.com/package/gaunt-sloth) app instead: the LLM providers are
|
|
51
|
+
`peerDependencies` of `@gaunt-sloth/core` that only the app declares, so a bare
|
|
52
|
+
`@gaunt-sloth/agent` install has no providers to construct a model from. See the
|
|
53
|
+
[app README → ACP server](https://github.com/pukeko-robotics/gaunt-sloth/blob/main/packages/app/README.md#acp-server-editor-integration)
|
|
54
|
+
for setup and a Zed `settings.json` example.
|
|
55
|
+
|
|
56
|
+
## Exports
|
|
57
|
+
|
|
58
|
+
- `@gaunt-sloth/agent` (the root export) is the public API: the AG-UI/ACP/interactive-session
|
|
59
|
+
modules, A2A client and tool, MCP utilities and OAuth provider, built-in tools config, the
|
|
60
|
+
middleware registry, the deep-agent factory, and `createResolvers`.
|
|
61
|
+
- `@gaunt-sloth/agent/<path>.js` deep paths mirror the internal `dist/` layout 1:1 and are
|
|
62
|
+
deliberately kept open for reach-in (the fat CLI imports e.g.
|
|
63
|
+
`@gaunt-sloth/agent/resolvers.js`). They are supported at your own risk: internal files can
|
|
64
|
+
move between alpha/minor versions without a deprecation cycle. Prefer the root export where it
|
|
65
|
+
suffices.
|
|
66
|
+
|
|
67
|
+
> `@gaunt-sloth/tools` and `@gaunt-sloth/api` are deprecated and now re-export from this
|
|
68
|
+
> package.
|
|
69
|
+
|
|
70
|
+
## Related packages
|
|
71
|
+
|
|
72
|
+
- [`@gaunt-sloth/core`](https://www.npmjs.com/package/@gaunt-sloth/core) — Core utilities, config, and agent infrastructure ([source](https://github.com/pukeko-robotics/gaunt-sloth/tree/main/packages/core))
|
|
73
|
+
- [`@gaunt-sloth/review`](https://www.npmjs.com/package/@gaunt-sloth/review) — Review engine with content/requirement sources (GitHub, Jira, file, text) and standalone CLI ([source](https://github.com/pukeko-robotics/gaunt-sloth/tree/main/packages/review))
|
|
74
|
+
- [`@gaunt-sloth/batch`](https://www.npmjs.com/package/@gaunt-sloth/batch) — Batch / eval / workflow runtime ([source](https://github.com/pukeko-robotics/gaunt-sloth/tree/main/packages/batch))
|
|
75
|
+
- [`gaunt-sloth`](https://www.npmjs.com/package/gaunt-sloth) — Main CLI application ([source](https://github.com/pukeko-robotics/gaunt-sloth/tree/main/packages/app))
|
|
@@ -10,15 +10,29 @@ export declare const AVAILABLE_BUILT_IN_TOOLS: {
|
|
|
10
10
|
/**
|
|
11
11
|
* Reference tool. Simply prints provided argument to the screen.
|
|
12
12
|
*/
|
|
13
|
-
readonly gth_status_update:
|
|
13
|
+
readonly gth_status_update: '#src/tools/gthStatusUpdateTool.js';
|
|
14
14
|
/**
|
|
15
15
|
* Web fetch tool.
|
|
16
16
|
*/
|
|
17
|
-
readonly gth_web_fetch:
|
|
17
|
+
readonly gth_web_fetch: '#src/tools/gthWebFetchTool.js';
|
|
18
18
|
/**
|
|
19
19
|
* AG-UI A2UI surface tool: lets the agent render an A2UI surface in the web client.
|
|
20
20
|
*/
|
|
21
|
-
readonly show_a2ui_surface:
|
|
21
|
+
readonly show_a2ui_surface: '#src/tools/showA2UISurfaceTool.js';
|
|
22
|
+
/**
|
|
23
|
+
* Checklist / todo planning tool for the lean agent (the `write_todos` equivalent). Enabled
|
|
24
|
+
* by default (see {@link DEFAULT_CONFIG}); disable by setting your own `builtInTools`.
|
|
25
|
+
*/
|
|
26
|
+
readonly gth_checklist: '#src/tools/gthChecklistTool.js';
|
|
27
|
+
/**
|
|
28
|
+
* Content-search (grep) tool: ripgrep-backed regex search over file CONTENTS, with an
|
|
29
|
+
* in-process JS fallback when `rg` is absent. Permission-light (no shell approval) and
|
|
30
|
+
* available in every mode. Named `gth_grep` to avoid colliding with the deep backend's
|
|
31
|
+
* built-in `grep`. Enabled by default (see {@link DEFAULT_CONFIG.builtInTools}, GS2-51); disable
|
|
32
|
+
* with `{ "builtInTools": { "gth_grep": { "enabled": false } } }`. Its searched corpus is
|
|
33
|
+
* selectable via the `fileSet` tool-config key (`gitignore` default / `all`).
|
|
34
|
+
*/
|
|
35
|
+
readonly gth_grep: '#src/tools/gthGrepTool.js';
|
|
22
36
|
};
|
|
23
37
|
/**
|
|
24
38
|
* Get default tools based on filesystem and built-in tools configuration
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Built-in tools config. {@link AVAILABLE_BUILT_IN_TOOLS} has a list of available tools.
|
|
4
4
|
*/
|
|
5
5
|
import GthFileSystemToolkit from '#src/tools/GthFileSystemToolkit.js';
|
|
6
|
+
import { getEffectiveDevToolsConfig, normalizeBuiltInTools, isBuiltInToolEntryEnabled, isFilesystemToolRegistered, DEV_TOOL_NAMES, } from '@gaunt-sloth/core/config.js';
|
|
6
7
|
import { displayWarning } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
7
8
|
import { getCurrentWorkDir } from '@gaunt-sloth/core/utils/systemUtils.js';
|
|
8
9
|
import GthDevToolkit from '#src/tools/GthDevToolkit.js';
|
|
@@ -25,6 +26,20 @@ export const AVAILABLE_BUILT_IN_TOOLS = {
|
|
|
25
26
|
* AG-UI A2UI surface tool: lets the agent render an A2UI surface in the web client.
|
|
26
27
|
*/
|
|
27
28
|
show_a2ui_surface: '#src/tools/showA2UISurfaceTool.js',
|
|
29
|
+
/**
|
|
30
|
+
* Checklist / todo planning tool for the lean agent (the `write_todos` equivalent). Enabled
|
|
31
|
+
* by default (see {@link DEFAULT_CONFIG}); disable by setting your own `builtInTools`.
|
|
32
|
+
*/
|
|
33
|
+
gth_checklist: '#src/tools/gthChecklistTool.js',
|
|
34
|
+
/**
|
|
35
|
+
* Content-search (grep) tool: ripgrep-backed regex search over file CONTENTS, with an
|
|
36
|
+
* in-process JS fallback when `rg` is absent. Permission-light (no shell approval) and
|
|
37
|
+
* available in every mode. Named `gth_grep` to avoid colliding with the deep backend's
|
|
38
|
+
* built-in `grep`. Enabled by default (see {@link DEFAULT_CONFIG.builtInTools}, GS2-51); disable
|
|
39
|
+
* with `{ "builtInTools": { "gth_grep": { "enabled": false } } }`. Its searched corpus is
|
|
40
|
+
* selectable via the `fileSet` tool-config key (`gitignore` default / `all`).
|
|
41
|
+
*/
|
|
42
|
+
gth_grep: '#src/tools/gthGrepTool.js',
|
|
28
43
|
};
|
|
29
44
|
/**
|
|
30
45
|
* Get default tools based on filesystem and built-in tools configuration
|
|
@@ -33,15 +48,11 @@ export async function getDefaultTools(config, command) {
|
|
|
33
48
|
const filesystemTools = filterFilesystemTools(config.filesystem, config.aiignore, config.binaryFormats);
|
|
34
49
|
const builtInTools = await getBuiltInTools(config);
|
|
35
50
|
// Dev tools (run commands etc.) are available to the interactive `code` command and to the
|
|
36
|
-
// scripted `exec` command — both are "do-the-job" runs
|
|
37
|
-
// `ask
|
|
38
|
-
//
|
|
51
|
+
// scripted `exec` command — both are "do-the-job" runs. `ask --write` (config.askWriteMode) opts
|
|
52
|
+
// `ask` into the same do-the-job tools. CFG-18: the dev/shell config is resolved from the unified
|
|
53
|
+
// `builtInTools` registry by the shared core resolver (was per-command `devTools`).
|
|
39
54
|
const askWrite = command === 'ask' && config.askWriteMode === true;
|
|
40
|
-
const devToolConfig = command
|
|
41
|
-
? config.commands?.exec?.devTools
|
|
42
|
-
: askWrite
|
|
43
|
-
? config.commands?.ask?.devTools
|
|
44
|
-
: config.commands?.code?.devTools;
|
|
55
|
+
const devToolConfig = getEffectiveDevToolsConfig(config, command);
|
|
45
56
|
const devTools = await filterDevTools(askWrite ? 'code' : command, devToolConfig);
|
|
46
57
|
const customTools = getCustomTools(config, command);
|
|
47
58
|
return [...filesystemTools, ...devTools, ...customTools, ...builtInTools];
|
|
@@ -93,7 +104,13 @@ function getCustomTools(config, command) {
|
|
|
93
104
|
return toolkit.getTools();
|
|
94
105
|
}
|
|
95
106
|
/**
|
|
96
|
-
* Filter filesystem tools based on configuration
|
|
107
|
+
* Filter filesystem tools based on configuration.
|
|
108
|
+
*
|
|
109
|
+
* The decision itself lives in core ({@link isFilesystemToolRegistered}) rather than here, because
|
|
110
|
+
* the system-prompt notes need the same answer: a note that names a tool this filter did not
|
|
111
|
+
* register tells the model to call something that does not exist. Each tool is judged by the
|
|
112
|
+
* read/write class the toolkit stamped on it (`gthFileSystemType`), so the class is read from the
|
|
113
|
+
* tool rather than from a second table of names.
|
|
97
114
|
*/
|
|
98
115
|
function filterFilesystemTools(filesystemConfig, aiignoreConfig, binaryFormats) {
|
|
99
116
|
const toolkit = new GthFileSystemToolkit({
|
|
@@ -101,44 +118,26 @@ function filterFilesystemTools(filesystemConfig, aiignoreConfig, binaryFormats)
|
|
|
101
118
|
aiignoreConfig,
|
|
102
119
|
binaryFormats,
|
|
103
120
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (filesystemConfig === 'none') {
|
|
108
|
-
return [];
|
|
109
|
-
}
|
|
110
|
-
if (filesystemConfig === 'read') {
|
|
111
|
-
// Read-only: only allow read operations
|
|
112
|
-
return toolkit.getFilteredTools(['read']);
|
|
113
|
-
}
|
|
114
|
-
if (!Array.isArray(filesystemConfig)) {
|
|
115
|
-
return toolkit.getTools();
|
|
116
|
-
}
|
|
117
|
-
if (filesystemConfig.includes('all')) {
|
|
118
|
-
return toolkit.getTools();
|
|
119
|
-
}
|
|
120
|
-
// Handle an array of specific tool names or 'read'/'all'
|
|
121
|
-
const allowedTools = filesystemConfig.includes('read')
|
|
122
|
-
? toolkit.getFilteredTools(['read'])
|
|
123
|
-
: [];
|
|
124
|
-
// Also allow specific tool names
|
|
125
|
-
const allowedToolNames = new Set(filesystemConfig.filter((name) => name !== 'read' && name !== 'all'));
|
|
126
|
-
const specificNamedTools = toolkit.getTools().filter((tool) => {
|
|
127
|
-
return tool.name && allowedToolNames.has(tool.name);
|
|
128
|
-
});
|
|
129
|
-
// Combine and deduplicate
|
|
130
|
-
const allAllowedTools = [...allowedTools, ...specificNamedTools];
|
|
131
|
-
return allAllowedTools.filter((tool, index, arr) => arr.findIndex((t) => t.name === tool.name) === index);
|
|
121
|
+
return toolkit.getTools().filter((tool) => isFilesystemToolRegistered(filesystemConfig, tool.name,
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
123
|
+
tool.gthFileSystemType));
|
|
132
124
|
}
|
|
133
125
|
/**
|
|
134
126
|
* Get built-in tools based on configuration
|
|
135
127
|
*/
|
|
136
128
|
async function getBuiltInTools(config) {
|
|
137
129
|
const tools = [];
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
130
|
+
// CFG-18: `builtInTools` may be a string[] or the widened registry — normalize to a name→value
|
|
131
|
+
// lookup. Dev/shell tools (run_*, run_shell_command) are emitted by GthDevToolkit via the dev
|
|
132
|
+
// bucket, so skip them here (a registry entry for them is legitimate, not an unknown built-in).
|
|
133
|
+
const registry = normalizeBuiltInTools(config.builtInTools);
|
|
134
|
+
for (const [toolName, value] of Object.entries(registry)) {
|
|
135
|
+
if (DEV_TOOL_NAMES.includes(toolName)) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (!isBuiltInToolEntryEnabled(value)) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
142
141
|
if (toolName in AVAILABLE_BUILT_IN_TOOLS) {
|
|
143
142
|
try {
|
|
144
143
|
const tool = await import(AVAILABLE_BUILT_IN_TOOLS[toolName]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtInToolsConfig.js","sourceRoot":"","sources":["../src/builtInToolsConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,oBAAoB,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"builtInToolsConfig.js","sourceRoot":"","sources":["../src/builtInToolsConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,oBAAoB,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AAC,QAAiD,CAAC,CAC5E,CAAC;gBACF,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,cAAc,CAAC,iCAAiC,QAAQ,MAAM,KAAK,EAAE,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { GthConfig } from '@gaunt-sloth/core/config.js';
|
|
2
2
|
import { GthAbstractAgent } from '@gaunt-sloth/core/core/GthAbstractAgent.js';
|
|
3
3
|
import { type GthCommand } from '@gaunt-sloth/core/core/types.js';
|
|
4
|
+
export { appendOsShellNote, appendCwdNote, appendCommitCoAuthorNote, appendModelContextNote, resolveModelIdentity, OS_SHELL_GUIDANCE, } from '@gaunt-sloth/core/utils/systemPromptNotes.js';
|
|
4
5
|
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
5
6
|
import type { BaseCheckpointSaver } from '@langchain/langgraph';
|
|
6
7
|
import { type InterruptOnConfig } from 'langchain';
|
|
7
8
|
import { type FilesystemPermission } from '#src/core/deepAgentPermissions.js';
|
|
8
|
-
|
|
9
|
+
export { extractDebugRequestExtras } from '#src/core/debugCapture.js';
|
|
9
10
|
/**
|
|
10
11
|
* The subset of `createDeepAgent` params that are independent of the transport
|
|
11
12
|
* (the local runner vs. the ACP server). Both {@link GthDeepAgent.init} (which adds the
|
|
@@ -39,9 +40,14 @@ export interface GthDeepAgentParams {
|
|
|
39
40
|
* `__interrupt__` (a `HITLRequest`) so a consumer can approve/reject before the tool runs;
|
|
40
41
|
* resume with `new Command({ resume: { decisions: [...] } })` on the same `thread_id`.
|
|
41
42
|
*
|
|
42
|
-
* gsloth
|
|
43
|
-
*
|
|
44
|
-
*
|
|
43
|
+
* gsloth sets this for the opt-in `run_shell_command` tool whenever the shell tool is
|
|
44
|
+
* enabled — including under `approvals.mode: "bypass"` in interactive `code` mode, where the tool
|
|
45
|
+
* stays gated so the session's own approvals mode governs it (the runner seeds that mode from
|
|
46
|
+
* config and, at `bypass`, approves a gated shell call without prompting or rating; the deny
|
|
47
|
+
* list still runs first, and `/approvals <mode>` can switch a session back to a rated mode
|
|
48
|
+
* mid-run, which only works while the tool is still gated). It is left `undefined` only for a non-interactive
|
|
49
|
+
* bypass run (exec / ask --write), whose single-shot path does not drain interrupts, so the tool
|
|
50
|
+
* there runs inline without suspending. See `getAgentBuildParams`.
|
|
45
51
|
*/
|
|
46
52
|
interruptOn?: Record<string, boolean | InterruptOnConfig>;
|
|
47
53
|
}
|
|
@@ -56,7 +62,10 @@ export interface GthDeepAgentParams {
|
|
|
56
62
|
* {@link FilesystemBackend}. gsloth's `.aiignore` + `filesystem` config are mapped
|
|
57
63
|
* onto deepagents `permissions` (see {@link buildPermissions}). Any resolved tool
|
|
58
64
|
* that reuses a deepagents filesystem-tool name is therefore superseded and dropped
|
|
59
|
-
* (`createDeepAgent` would otherwise throw on the collision).
|
|
65
|
+
* (`createDeepAgent` would otherwise throw on the collision). EXT-14: the
|
|
66
|
+
* `FilesystemBackend` itself is wrapped with {@link guardFilesystemBackend} before it
|
|
67
|
+
* reaches `createDeepAgent`, adding a realpath (symlink-resolved) containment check the
|
|
68
|
+
* permission globs alone can't provide.
|
|
60
69
|
* - todos / subagents / summarization come from deepagents' standard middleware.
|
|
61
70
|
*
|
|
62
71
|
* The transport-agnostic param assembly lives in {@link buildDeepAgentParams} so the ACP
|
|
@@ -64,13 +73,6 @@ export interface GthDeepAgentParams {
|
|
|
64
73
|
* middleware hardening without re-running `createDeepAgent` locally.
|
|
65
74
|
*/
|
|
66
75
|
export declare class GthDeepAgent extends GthAbstractAgent {
|
|
67
|
-
/**
|
|
68
|
-
* Opt-in debug sink for the TUI `/debug` panel. Set AFTER {@link init} via
|
|
69
|
-
* `runner.getAgent()`; read lazily inside the `wrapModelCall` middleware so that when it
|
|
70
|
-
* is `undefined` (the normal path) the middleware is a transparent pass-through. Never
|
|
71
|
-
* touched by the lean agent or the AG-UI server, so those contracts are unchanged.
|
|
72
|
-
*/
|
|
73
|
-
debugCapture: DebugCapture | undefined;
|
|
74
76
|
init(command: GthCommand | undefined, configIn: GthConfig, checkpointer?: BaseCheckpointSaver | undefined): Promise<void>;
|
|
75
77
|
/**
|
|
76
78
|
* Assemble the transport-agnostic {@link GthDeepAgentParams}: resolve tools (with the
|
|
@@ -80,29 +82,47 @@ export declare class GthDeepAgent extends GthAbstractAgent {
|
|
|
80
82
|
* runner ({@link init}) and the `deepagents-acp` ACP entry.
|
|
81
83
|
*/
|
|
82
84
|
buildDeepAgentParams(command: GthCommand | undefined, configIn: GthConfig): Promise<GthDeepAgentParams>;
|
|
83
|
-
/**
|
|
84
|
-
* Resolve the {@link GthDevToolsConfig} that applies to the active command, mirroring the
|
|
85
|
-
* per-command selection in `builtInToolsConfig.getDefaultTools` (which is what actually emits
|
|
86
|
-
* the dev tools): `exec` → `commands.exec.devTools`, `ask --write` → `commands.ask.devTools`,
|
|
87
|
-
* otherwise (`code`) → `commands.code.devTools`. Returns `undefined` for any other command,
|
|
88
|
-
* matching the toolkit being inert there. Kept private and side-effect-free so the interrupt
|
|
89
|
-
* wiring above and the tool emission stay in lockstep.
|
|
90
|
-
*/
|
|
91
|
-
private getEffectiveDevToolsConfig;
|
|
92
85
|
}
|
|
93
86
|
/**
|
|
94
|
-
* EXT-
|
|
87
|
+
* EXT-22: shared virtualMode path-namespace guidance — ONE source of truth used by BOTH the S2
|
|
88
|
+
* early-framing note ({@link appendVirtualCwdNote}, injected into gsloth's composed systemPrompt =
|
|
89
|
+
* block 0) and the S1 last-word correction middleware
|
|
90
|
+
* ({@link createPathNamespaceCorrectionMiddleware}, appended after deepagents' `/`-rooted line).
|
|
91
|
+
*
|
|
92
|
+
* In a virtualMode `code` session (EXT-16, e.g. Windows) the deepagents filesystem tools use a
|
|
93
|
+
* VIRTUAL `/` root (= the working dir) while `run_shell_command` uses REAL native OS paths; the
|
|
94
|
+
* model conflates the two forms. This text draws the distinction and steers toward cwd-relative
|
|
95
|
+
* paths (the one form both tool families read alike).
|
|
95
96
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* dynamically (never baked into the .md). Returns the note alone when there is no base prompt.
|
|
97
|
+
* It deliberately does NOT equate the virtual root with a specific real path (no "`/` = D:\\work"):
|
|
98
|
+
* virtualMode withholds the real cwd on purpose (see the systemPrompt gate in {@link
|
|
99
|
+
* GthDeepAgent.init}), so the guidance is about the DISTINCTION between the two namespaces and the
|
|
100
|
+
* safety of relative paths, not a mapping between them.
|
|
101
101
|
*/
|
|
102
|
-
export declare
|
|
102
|
+
export declare const PATH_NAMESPACE_GUIDANCE: string;
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
104
|
+
* EXT-22 (S2): virtualMode variant of {@link appendCwdNote}. On the `code` path when the fs
|
|
105
|
+
* backend runs in virtualMode (EXT-16), inject the shared path-namespace guidance EARLY in
|
|
106
|
+
* gsloth's composed systemPrompt (block 0) so the model is framed before deepagents' own prompt.
|
|
107
|
+
*
|
|
108
|
+
* This is early framing only: deepagents' hardcoded `/`-rooted line lands in a LATER block and can
|
|
109
|
+
* partially override block 0, so the authoritative last word is delivered by the S1 middleware
|
|
110
|
+
* ({@link createPathNamespaceCorrectionMiddleware}); see handoff/spike-systemmessage-ordering.md.
|
|
111
|
+
* Returns the note alone when there is no base prompt.
|
|
112
|
+
*/
|
|
113
|
+
export declare function appendVirtualCwdNote(systemPrompt: string | undefined): string;
|
|
114
|
+
/**
|
|
115
|
+
* EXT-22 (S1): the load-bearing path-namespace correction. A gsloth `wrapModelCall` middleware
|
|
116
|
+
* runs INNERMOST (inside deepagents' filesystem middleware), so appending a trailing block to
|
|
117
|
+
* `request.systemMessage` lands AFTER deepagents' hardcoded "All file paths must start with a /."
|
|
118
|
+
* line — giving gsloth the last word on path semantics (empirically verified; see
|
|
119
|
+
* handoff/spike-systemmessage-ordering.md). It APPENDS via `request.systemMessage.concat(...)`
|
|
120
|
+
* (mirroring how deepagents appends its own fs prompt), never string-splices, and returns a NEW
|
|
121
|
+
* request so it never mutates persisted state (no compounding across turns).
|
|
122
|
+
*
|
|
123
|
+
* `appendCorrection` gates it to `code` + virtualMode: only there do the fs virtual `/` root and
|
|
124
|
+
* the shell's real-OS paths diverge. On POSIX real-path mode deepagents' "start with /" is
|
|
125
|
+
* literally true, so the middleware is a transparent pass-through (like the debug-capture
|
|
126
|
+
* middleware when no sink is attached).
|
|
107
127
|
*/
|
|
108
|
-
export declare function
|
|
128
|
+
export declare function createPathNamespaceCorrectionMiddleware(appendCorrection: boolean): import("langchain").AgentMiddleware<undefined, undefined, unknown, readonly (import("@langchain/core/tools").ServerTool | import("@langchain/core/tools").ClientTool)[], readonly []>;
|