@gaunt-sloth/agent 2.0.0-alpha.35 → 2.0.0-alpha.37

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 (63) hide show
  1. package/README.md +9 -10
  2. package/cli-acp.js +20 -24
  3. package/dist/builtInToolsConfig.d.ts +2 -2
  4. package/dist/builtInToolsConfig.js +2 -2
  5. package/dist/core/debugCapture.d.ts +4 -5
  6. package/dist/core/debugCapture.js.map +1 -1
  7. package/dist/core/resolveAgentFactory.d.ts +10 -9
  8. package/dist/core/resolveAgentFactory.js +11 -12
  9. package/dist/core/resolveAgentFactory.js.map +1 -1
  10. package/dist/index.d.ts +2 -4
  11. package/dist/index.js +4 -5
  12. package/dist/index.js.map +1 -1
  13. package/dist/middleware/frontendImageInjectionMiddleware.d.ts +3 -2
  14. package/dist/middleware/frontendImageInjectionMiddleware.js +3 -2
  15. package/dist/middleware/frontendImageInjectionMiddleware.js.map +1 -1
  16. package/dist/middleware/registry.js +16 -3
  17. package/dist/middleware/registry.js.map +1 -1
  18. package/dist/modules/acp/acpAgentApp.d.ts +93 -0
  19. package/dist/modules/acp/acpAgentApp.js +593 -0
  20. package/dist/modules/acp/acpAgentApp.js.map +1 -0
  21. package/dist/modules/acp/acpPermissions.d.ts +60 -0
  22. package/dist/modules/acp/acpPermissions.js +158 -0
  23. package/dist/modules/acp/acpPermissions.js.map +1 -0
  24. package/dist/modules/acp/acpStdio.d.ts +41 -0
  25. package/dist/modules/acp/acpStdio.js +65 -0
  26. package/dist/modules/acp/acpStdio.js.map +1 -0
  27. package/dist/modules/acp/acpUpdates.d.ts +101 -0
  28. package/dist/modules/acp/acpUpdates.js +287 -0
  29. package/dist/modules/acp/acpUpdates.js.map +1 -0
  30. package/dist/modules/apiAgUiModule.js +8 -16
  31. package/dist/modules/apiAgUiModule.js.map +1 -1
  32. package/dist/modules/interactiveSessionModule.js +39 -6
  33. package/dist/modules/interactiveSessionModule.js.map +1 -1
  34. package/dist/tools/GthCustomToolkit.js +1 -1
  35. package/dist/tools/GthCustomToolkit.js.map +1 -1
  36. package/dist/tools/GthDevToolkit.d.ts +2 -2
  37. package/dist/tools/GthDevToolkit.js +8 -13
  38. package/dist/tools/GthDevToolkit.js.map +1 -1
  39. package/dist/tools/gthChecklistTool.js +4 -5
  40. package/dist/tools/gthChecklistTool.js.map +1 -1
  41. package/dist/tools/gthGrepTool.js +6 -6
  42. package/dist/tools/shell/workDir.d.ts +1 -10
  43. package/dist/tools/shell/workDir.js +10 -36
  44. package/dist/tools/shell/workDir.js.map +1 -1
  45. package/package.json +8 -9
  46. package/dist/core/GthDeepAgent.d.ts +0 -128
  47. package/dist/core/GthDeepAgent.js +0 -712
  48. package/dist/core/GthDeepAgent.js.map +0 -1
  49. package/dist/core/deepAgentPermissions.d.ts +0 -138
  50. package/dist/core/deepAgentPermissions.js +0 -309
  51. package/dist/core/deepAgentPermissions.js.map +0 -1
  52. package/dist/core/gthAcpServer.d.ts +0 -27
  53. package/dist/core/gthAcpServer.js +0 -82
  54. package/dist/core/gthAcpServer.js.map +0 -1
  55. package/dist/core/gthDeepAgentFactory.d.ts +0 -11
  56. package/dist/core/gthDeepAgentFactory.js +0 -17
  57. package/dist/core/gthDeepAgentFactory.js.map +0 -1
  58. package/dist/core/subagentProfiles.d.ts +0 -50
  59. package/dist/core/subagentProfiles.js +0 -76
  60. package/dist/core/subagentProfiles.js.map +0 -1
  61. package/dist/modules/acpModule.d.ts +0 -40
  62. package/dist/modules/acpModule.js +0 -86
  63. package/dist/modules/acpModule.js.map +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The agent runtime for Gaunt Sloth: built-in tools and toolkits (filesystem, dev/shell, web
4
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
5
+ AG-UI server (`startAgUiServer`), the interactive session
6
6
  module, and the `createResolvers` tool/middleware resolver wiring. It builds on
7
7
  [`@gaunt-sloth/core`](https://www.npmjs.com/package/@gaunt-sloth/core) (config, provider
8
8
  factory, lean agent runtime).
@@ -45,19 +45,18 @@ not expose it to public networks. Port and CORS come from `commands.api.*` in th
45
45
 
46
46
  - **`gaunt-sloth-api`** — starts the AG-UI server standalone (the code above as a command):
47
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.
48
+ - **`gaunt-sloth-acp`** — serves the [Agent Client Protocol](https://agentclientprotocol.com/) over
49
+ stdio, for an editor that spawns the agent as a subprocess. **ACP v2 only**; a v1-only host
50
+ cannot connect. Takes no arguments, and roots the session at the working directory the host
51
+ supplies. Gated tools are escalated to the host as `session/request_permission`. The same server
52
+ is reachable programmatically as `startAcpServer()`, and as `createAcpAgentApp()` when you want
53
+ to serve it over a transport of your own.
55
54
 
56
55
  ## Exports
57
56
 
58
- - `@gaunt-sloth/agent` (the root export) is the public API: the AG-UI/ACP/interactive-session
57
+ - `@gaunt-sloth/agent` (the root export) is the public API: the AG-UI and interactive-session
59
58
  modules, A2A client and tool, MCP utilities and OAuth provider, built-in tools config, the
60
- middleware registry, the deep-agent factory, and `createResolvers`.
59
+ middleware registry, the agent-backend seam (`resolveAgentFactory`), and `createResolvers`.
61
60
  - `@gaunt-sloth/agent/<path>.js` deep paths mirror the internal `dist/` layout 1:1 and are
62
61
  deliberately kept open for reach-in (the fat CLI imports e.g.
63
62
  `@gaunt-sloth/agent/resolvers.js`). They are supported at your own risk: internal files can
package/cli-acp.js CHANGED
@@ -1,35 +1,31 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * ACP (Agent Client Protocol) server entry for the Gaunt Sloth deep agent.
4
+ * ACP (Agent Client Protocol) server entry.
5
5
  * Usage: gaunt-sloth-acp
6
6
  *
7
- * Speaks ACP JSON-RPC over stdio, so an ACP host (Zed, JetBrains, a future Pukeko client)
8
- * can spawn this binary as a coding agent subprocess.
7
+ * Serves ACP v2 over stdio, for an editor that spawns the agent as a subprocess (Zed, and any
8
+ * other v2 client). The whole startup including redirecting ordinary console output away from
9
+ * stdout, which the protocol owns — lives in `startAcpServer`, shared with
10
+ * `gaunt-sloth --acp-agent` so the two doors cannot drift.
9
11
  *
10
- * stdout is the ACP protocol channel and must stay clean: any stray byte corrupts framing.
11
- * gsloth's console output (initConfig info, agent status) routes through console.log/info,
12
- * which write to stdout — so before doing anything we redirect those to stderr. The ACP SDK
13
- * writes the protocol via process.stdout.write directly and is unaffected; console.warn/error
14
- * already go to stderr.
12
+ * A failure before the transport is up is written to stderr, never stdout: to a host, stdout is
13
+ * the JSON-RPC framing channel, so prose there is a protocol error rather than a message anyone
14
+ * reads.
15
15
  */
16
16
 
17
- for (const method of ['log', 'info']) {
18
- console[method] = (...args) => process.stderr.write(args.join(' ') + '\n');
19
- }
17
+ import { setEntryPoint } from '@gaunt-sloth/core/utils/systemUtils.js';
18
+ import { startAcpServer } from '#src/modules/acp/acpStdio.js';
20
19
 
21
- import { initConfig } from '@gaunt-sloth/core/config.js';
22
- import { displayError } from '@gaunt-sloth/core/utils/consoleUtils.js';
23
- import { startAcpServer } from '#src/modules/acpModule.js';
20
+ // The install dir is what `getSlothVersion()` reads, and the initialize handshake reports the
21
+ // version. Set from THIS file so it resolves the agent package's own manifest.
22
+ setEntryPoint(import.meta.url);
24
23
 
25
- async function main() {
26
- try {
27
- const config = await initConfig({});
28
- await startAcpServer(config);
29
- } catch (err) {
30
- displayError(`ACP server failed: ${err instanceof Error ? err.message : String(err)}`);
31
- process.exit(1);
32
- }
24
+ try {
25
+ await startAcpServer();
26
+ } catch (err) {
27
+ process.stderr.write(
28
+ `Gaunt Sloth ACP agent failed to start: ${err instanceof Error ? (err.stack ?? err.message) : String(err)}\n`
29
+ );
30
+ process.exit(1);
33
31
  }
34
-
35
- main();
@@ -27,8 +27,8 @@ export declare const AVAILABLE_BUILT_IN_TOOLS: {
27
27
  /**
28
28
  * Content-search (grep) tool: ripgrep-backed regex search over file CONTENTS, with an
29
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
30
+ * available in every mode. Named `gth_grep` rather than `grep` so it cannot collide with a
31
+ * built-in a graph builder registers under that name. Enabled by default (see {@link DEFAULT_CONFIG.builtInTools}, GS2-51); disable
32
32
  * with `{ "builtInTools": { "gth_grep": { "enabled": false } } }`. Its searched corpus is
33
33
  * selectable via the `fileSet` tool-config key (`gitignore` default / `all`).
34
34
  */
@@ -34,8 +34,8 @@ export const AVAILABLE_BUILT_IN_TOOLS = {
34
34
  /**
35
35
  * Content-search (grep) tool: ripgrep-backed regex search over file CONTENTS, with an
36
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
37
+ * available in every mode. Named `gth_grep` rather than `grep` so it cannot collide with a
38
+ * built-in a graph builder registers under that name. Enabled by default (see {@link DEFAULT_CONFIG.builtInTools}, GS2-51); disable
39
39
  * with `{ "builtInTools": { "gth_grep": { "enabled": false } } }`. Its searched corpus is
40
40
  * selectable via the `fileSet` tool-config key (`gitignore` default / `all`).
41
41
  */
@@ -1,10 +1,9 @@
1
1
  /**
2
2
  * @packageDocumentation
3
- * The debug-capture contract now lives in `@gaunt-sloth/core` so BOTH the lean
4
- * ({@link import('@gaunt-sloth/core/core/GthLangChainAgent.js').GthLangChainAgent}) and deep
5
- * ({@link import('#src/core/GthDeepAgent.js').GthDeepAgent}) backends can install the same
6
- * `wrapModelCall` capture middleware. This module re-exports it so existing
7
- * `@gaunt-sloth/agent/core/debugCapture.js` importers (the TUI debug panel) are unaffected.
3
+ * The debug-capture contract lives in `@gaunt-sloth/core`, beside the agent
4
+ * ({@link import('@gaunt-sloth/core/core/GthLangChainAgent.js').GthLangChainAgent}) that installs
5
+ * the `wrapModelCall` capture middleware. This module re-exports it so
6
+ * `@gaunt-sloth/agent/core/debugCapture.js` importers (the TUI debug panel) resolve it here too.
8
7
  */
9
8
  export type { DebugRequestExtras, DebugToolDef, DebugCapture, LastModelRequest, } from '@gaunt-sloth/core/core/debugCapture.js';
10
9
  export { extractDebugRequestExtras } from '@gaunt-sloth/core/core/debugCapture.js';
@@ -1 +1 @@
1
- {"version":3,"file":"debugCapture.js","sourceRoot":"","sources":["../../src/core/debugCapture.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC"}
1
+ {"version":3,"file":"debugCapture.js","sourceRoot":"","sources":["../../src/core/debugCapture.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC"}
@@ -1,14 +1,15 @@
1
1
  import type { GthAgentFactory } from '@gaunt-sloth/core/core/types.js';
2
2
  import type { GthConfig } from '@gaunt-sloth/core/config.js';
3
3
  /**
4
- * Resolve the agent backend factory from config (B5). An explicit `agent.backend` wins;
5
- * otherwise `defaultBackend` is used — the per-command default. Every command now defaults to
6
- * `'lean'`; `'deep'` is the experimental, opt-in backend (selecting it emits a warning).
4
+ * Resolve the agent backend factory from config (B5).
7
5
  *
8
- * Returns {@link gthDeepAgentFactory} for `'deep'` and {@link gthLeanAgentFactory} for `'lean'`.
9
- * Both factories receive the SAME `createResolvers()` toolset, so lean is not capability-stripped:
10
- * it keeps gaunt-sloth's own filesystem + (in code mode) dev/shell tools plus the `gth_checklist`
11
- * planning tool; it only drops the deepagents-specific extras (subagent `task`, `write_todos`,
12
- * summarization, `/large_tool_results`).
6
+ * There is one backend the lean {@link gthLeanAgentFactory} so every call resolves to it, and
7
+ * `agent.backend` can only name it. The seam is kept rather than inlined at the ten call sites
8
+ * because it is the single place a backend choice is made: reinstating a choice (EXT-46's ACP
9
+ * rebuild, or any later runtime) is an edit here, not an edit spread across every command.
10
+ *
11
+ * The parameters are accepted and ignored for the same reason. `defaultBackend` is each caller's
12
+ * per-command default, and every caller passes `'lean'`; typing it as the literal keeps a caller
13
+ * that means something else from compiling silently.
13
14
  */
14
- export declare function resolveAgentFactory(config: GthConfig, defaultBackend: 'deep' | 'lean'): GthAgentFactory;
15
+ export declare function resolveAgentFactory(_config: GthConfig, _defaultBackend?: 'lean'): GthAgentFactory;
@@ -1,18 +1,17 @@
1
1
  import { gthLeanAgentFactory } from '@gaunt-sloth/core/core/gthLeanAgentFactory.js';
2
- import { gthDeepAgentFactory } from '#src/core/gthDeepAgentFactory.js';
3
2
  /**
4
- * Resolve the agent backend factory from config (B5). An explicit `agent.backend` wins;
5
- * otherwise `defaultBackend` is used — the per-command default. Every command now defaults to
6
- * `'lean'`; `'deep'` is the experimental, opt-in backend (selecting it emits a warning).
3
+ * Resolve the agent backend factory from config (B5).
7
4
  *
8
- * Returns {@link gthDeepAgentFactory} for `'deep'` and {@link gthLeanAgentFactory} for `'lean'`.
9
- * Both factories receive the SAME `createResolvers()` toolset, so lean is not capability-stripped:
10
- * it keeps gaunt-sloth's own filesystem + (in code mode) dev/shell tools plus the `gth_checklist`
11
- * planning tool; it only drops the deepagents-specific extras (subagent `task`, `write_todos`,
12
- * summarization, `/large_tool_results`).
5
+ * There is one backend the lean {@link gthLeanAgentFactory} so every call resolves to it, and
6
+ * `agent.backend` can only name it. The seam is kept rather than inlined at the ten call sites
7
+ * because it is the single place a backend choice is made: reinstating a choice (EXT-46's ACP
8
+ * rebuild, or any later runtime) is an edit here, not an edit spread across every command.
9
+ *
10
+ * The parameters are accepted and ignored for the same reason. `defaultBackend` is each caller's
11
+ * per-command default, and every caller passes `'lean'`; typing it as the literal keeps a caller
12
+ * that means something else from compiling silently.
13
13
  */
14
- export function resolveAgentFactory(config, defaultBackend) {
15
- const backend = config.agent?.backend ?? defaultBackend;
16
- return backend === 'deep' ? gthDeepAgentFactory : gthLeanAgentFactory;
14
+ export function resolveAgentFactory(_config, _defaultBackend = 'lean') {
15
+ return gthLeanAgentFactory;
17
16
  }
18
17
  //# sourceMappingURL=resolveAgentFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveAgentFactory.js","sourceRoot":"","sources":["../../src/core/resolveAgentFactory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAiB,EACjB,cAA+B;IAE/B,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,cAAc,CAAC;IACxD,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC;AACxE,CAAC"}
1
+ {"version":3,"file":"resolveAgentFactory.js","sourceRoot":"","sources":["../../src/core/resolveAgentFactory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AAEpF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAkB,EAClB,eAAe,GAAW,MAAM;IAEhC,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from '#src/modules/apiAgUiModule.js';
2
- export * from '#src/modules/acpModule.js';
3
2
  export * from '#src/modules/interactiveSessionModule.js';
4
3
  export * from '#src/modules/a2a/A2AClientWrapper.js';
5
4
  export * from '#src/tools/A2AAgentTool.js';
@@ -8,7 +7,6 @@ export * from '#src/utils/mcpUtils.js';
8
7
  export { createResolvers } from '#src/resolvers.js';
9
8
  export * from '#src/builtInToolsConfig.js';
10
9
  export { resolveMiddleware } from '#src/middleware/registry.js';
11
- export { GthDeepAgent, type GthDeepAgentParams } from '#src/core/GthDeepAgent.js';
12
- export * from '#src/core/deepAgentPermissions.js';
13
- export { gthDeepAgentFactory } from '#src/core/gthDeepAgentFactory.js';
14
10
  export { resolveAgentFactory } from '#src/core/resolveAgentFactory.js';
11
+ export { startAcpServer } from '#src/modules/acp/acpStdio.js';
12
+ export { createAcpAgentApp } from '#src/modules/acp/acpAgentApp.js';
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from '#src/modules/apiAgUiModule.js';
2
- export * from '#src/modules/acpModule.js';
3
2
  export * from '#src/modules/interactiveSessionModule.js';
4
3
  export * from '#src/modules/a2a/A2AClientWrapper.js';
5
4
  export * from '#src/tools/A2AAgentTool.js';
@@ -9,9 +8,9 @@ export { createResolvers } from '#src/resolvers.js';
9
8
  // Tools + middleware (formerly @gaunt-sloth/tools)
10
9
  export * from '#src/builtInToolsConfig.js';
11
10
  export { resolveMiddleware } from '#src/middleware/registry.js';
12
- // Deep agent (createDeepAgent / deepagents) + the GthConfig→permission mapping
13
- export { GthDeepAgent } from '#src/core/GthDeepAgent.js';
14
- export * from '#src/core/deepAgentPermissions.js';
15
- export { gthDeepAgentFactory } from '#src/core/gthDeepAgentFactory.js';
11
+ // The agent-backend seam every command resolves its factory through.
16
12
  export { resolveAgentFactory } from '#src/core/resolveAgentFactory.js';
13
+ // The ACP (Agent Client Protocol) v2 agent, and the stdio starter both ACP bins run.
14
+ export { startAcpServer } from '#src/modules/acp/acpStdio.js';
15
+ export { createAcpAgentApp } from '#src/modules/acp/acpAgentApp.js';
17
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,mDAAmD;AACnD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,+EAA+E;AAC/E,OAAO,EAAE,YAAY,EAA2B,MAAM,2BAA2B,CAAC;AAClF,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,mDAAmD;AACnD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,qEAAqE;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,qFAAqF;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -38,8 +38,9 @@ export interface FrontendImageInjectionOptions {
38
38
  * - **ollama** → `{ type:'image_url', image_url:'<data-URL string>' }`. ChatOllama's
39
39
  * `convertToOllamaMessages` only handles `image_url` blocks (extractBase64FromDataUrl); the
40
40
  * LangChain standard `source_type` block throws "Unsupported content type: image".
41
- * - **OpenAI-compatible** (`openai`, `openrouter`, `deepseek`, `xai`, `groq` — all extend
42
- * `ChatOpenAI` / report `_llmType()==='openai'`) `{ type:'image_url', image_url:{ url:'<data-URL>' } }`.
41
+ * - **OpenAI-compatible** (`openai`, `openrouter`, `deepseek`, `xai`, `groq` — served by an
42
+ * OpenAI-compatible Chat Completions API, whichever LangChain class fronts it)
43
+ * `{ type:'image_url', image_url:{ url:'<data-URL>' } }`.
43
44
  * This native OpenAI shape is correct on BOTH the Completions API AND the Responses API (GS2-74
44
45
  * flips reasoning-capable openai models to Responses). A raw `source_type` standard block
45
46
  * serialises to an *invalid* image part on the Responses path, so we emit the provider-native
@@ -24,8 +24,9 @@ export const DEFAULT_CAPTURE_TOOL_NAME = 'capture_image';
24
24
  * - **ollama** → `{ type:'image_url', image_url:'<data-URL string>' }`. ChatOllama's
25
25
  * `convertToOllamaMessages` only handles `image_url` blocks (extractBase64FromDataUrl); the
26
26
  * LangChain standard `source_type` block throws "Unsupported content type: image".
27
- * - **OpenAI-compatible** (`openai`, `openrouter`, `deepseek`, `xai`, `groq` — all extend
28
- * `ChatOpenAI` / report `_llmType()==='openai'`) `{ type:'image_url', image_url:{ url:'<data-URL>' } }`.
27
+ * - **OpenAI-compatible** (`openai`, `openrouter`, `deepseek`, `xai`, `groq` — served by an
28
+ * OpenAI-compatible Chat Completions API, whichever LangChain class fronts it)
29
+ * `{ type:'image_url', image_url:{ url:'<data-URL>' } }`.
29
30
  * This native OpenAI shape is correct on BOTH the Completions API AND the Responses API (GS2-74
30
31
  * flips reasoning-capable openai models to Responses). A raw `source_type` standard block
31
32
  * serialises to an *invalid* image part on the Responses path, so we emit the provider-native
@@ -1 +1 @@
1
- {"version":3,"file":"frontendImageInjectionMiddleware.js","sourceRoot":"","sources":["../../src/middleware/frontendImageInjectionMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,gBAAgB,EAAwB,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAavE,6FAA6F;AAC7F,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAkBzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,QAAgB,EAAE,IAAY;IAC5E,MAAM,OAAO,GAAG,QAAQ,QAAQ,WAAW,IAAI,EAAE,CAAC;IAClD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,EAAE,IAAI,EAAE,WAAoB,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;QAC5D,KAAK,QAAQ,CAAC;QACd,KAAK,YAAY,CAAC;QAClB,KAAK,UAAU,CAAC;QAChB,KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,EAAE,IAAI,EAAE,WAAoB,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QACrE,KAAK,WAAW;YACd,OAAO;gBACL,IAAI,EAAE,OAAgB;gBACtB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;aAChE,CAAC;QACJ,KAAK,cAAc,CAAC;QACpB,KAAK,UAAU,CAAC;QAChB;YACE,OAAO;gBACL,IAAI,EAAE,OAAgB;gBACtB,WAAW,EAAE,QAAiB;gBAC9B,SAAS,EAAE,QAAQ;gBACnB,IAAI;aACL,CAAC;IACN,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sCAAsC,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E,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,EAAE,EAAE,KAAK,CAAmB;qBACrF,CAAC,CACH,CAAC;gBACJ,CAAC;gBACD,yFAAyF;YAC3F,CAAC;YAED,6FAA6F;YAC7F,2FAA2F;YAC3F,OAAO,WAAW,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACtF,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"frontendImageInjectionMiddleware.js","sourceRoot":"","sources":["../../src/middleware/frontendImageInjectionMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,gBAAgB,EAAwB,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAavE,6FAA6F;AAC7F,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAkBzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,QAAgB,EAAE,IAAY;IAC5E,MAAM,OAAO,GAAG,QAAQ,QAAQ,WAAW,IAAI,EAAE,CAAC;IAClD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,EAAE,IAAI,EAAE,WAAoB,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;QAC5D,KAAK,QAAQ,CAAC;QACd,KAAK,YAAY,CAAC;QAClB,KAAK,UAAU,CAAC;QAChB,KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,EAAE,IAAI,EAAE,WAAoB,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QACrE,KAAK,WAAW;YACd,OAAO;gBACL,IAAI,EAAE,OAAgB;gBACtB,MAAM,EA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AAC,IAAI,EAAE,CAAC;oBACrC,0FAA0F;oBAC1F,uFAAuF;oBACvF,mFAAmF;oBACnF,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;oBACpB,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC3E,WAAW,CAAC,IAAI,CACd,IAAI,YAAY,CAAC;wBACf,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wBAAwB,EAAE,EAAE,KAAK,CAAmB;qBACrF,CAAC,CACH,CAAC;gBACJ,CAAC;gBACD,yFAAyF;YAC3F,CAAC;YAED,6FAA6F;YAC7F,2FAA2F;YAC3F,OAAO,WAAW,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACtF,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -14,9 +14,22 @@ import { createFrontendImageInjectionMiddleware } from '#src/middleware/frontend
14
14
  * Derive the provider string the vision middleware maps to a per-provider block shape. Prefers the
15
15
  * loader-stashed raw `llm.type` ({@link GthConfig.modelProviderType}) — the exact gth provider
16
16
  * namespace (`anthropic`/`openrouter`/`deepseek`/`xai`/`groq`/`ollama`/`google-genai`/`vertexai`/…)
17
- * — and falls back to the live model's `_llmType()` only when it is absent (module configs). The
18
- * OpenAI-compatible shims (openrouter/deepseek/xai/groq) all report `_llmType() === 'openai'`, which
19
- * maps to the same `image_url:{url}` block, so the fallback stays shape-correct.
17
+ * — and falls back to the live model's `_llmType()` only when it is absent (module configs).
18
+ * `_llmType()` is the model class's own label rather than the gth provider namespace, so the two
19
+ * only mostly agree. Where they do: `openrouter`/`deepseek`/`xai`/`groq`/`ollama`/`anthropic` each
20
+ * report their own name, which `imageBlockFor` matches directly, and both Gemini providers report
21
+ * `google`, which lands on the default branch — the same standard block its `google-genai`/
22
+ * `vertexai` cases return.
23
+ *
24
+ * Two labels do NOT agree, and this fallback is the only path either can arrive on:
25
+ * - `huggingface` reports `openai`, so the fallback emits `image_url:{url}` where the configured
26
+ * `type` would take the default standard block. Which of the two the HF router actually accepts
27
+ * is unmeasured — see [[CFG-45]]. Do not add a branch by analogy.
28
+ * - `ChatXAIResponses` reports `xai-responses`, which matches no case and so takes the default
29
+ * standard block — while `imageBlockFor`'s own docstring records that a standard block
30
+ * serialises to an INVALID image part on the Responses path. gth itself only ever constructs
31
+ * `ChatXAI`, so this is reachable only from a module config that builds the Responses class
32
+ * itself.
20
33
  */
21
34
  function resolveVisionProvider(gthConfig) {
22
35
  if (gthConfig.modelProviderType)
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/middleware/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EACL,gCAAgC,EAChC,uBAAuB,GAExB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,sCAAsC,GAEvC,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,sCAAsC,EAAE,MAAM,qDAAqD,CAAC;AAO7G;;;;;;;GAOG;AACH,SAAS,qBAAqB,CAAC,SAAoB;IACjD,IAAI,SAAS,CAAC,iBAAiB;QAAE,OAAO,SAAS,CAAC,iBAAiB,CAAC;IACpE,MAAM,GAAG,GAAG,SAAS,CAAC,GAA8C,CAAC;IACrE,IAAI,CAAC;QACH,IAAI,OAAO,GAAG,EAAE,QAAQ,KAAK,UAAU;YAAE,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,+DAA+D;IACjE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,6BAA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ACrC,UAAU,CAAC,IAAI,CAAC,MAAyB,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,cAAc,CACZ,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACzF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,0BAA0B,CACvC,IAAY,EACZ,QAAiC,EACjC,SAAoB;IAEpB,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,OAAO,GAAG,6BAA6B,CAAC,IAAI,CAAC,CAAC;IACpD,OAAO,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Gaunt Sloth's ACP (Agent Client Protocol) **v2** agent, built on the official SDK's
4
+ * `experimental/v2` surface.
5
+ *
6
+ * ## v2 only, on purpose
7
+ *
8
+ * The SDK still ships v1 as its stable entry point and the migration guide advises serving both.
9
+ * This agent serves **v2 alone**. Zed — the editor this surface exists for — speaks v2, and the
10
+ * suite here drives a client we write ourselves, so nothing about proving this code works depends
11
+ * on a third party. A v1-only client failing to connect is a known consequence, not a defect: the
12
+ * cost of the compatibility layer is a second protocol to keep correct forever, and it would be
13
+ * carried on speculation about clients nobody here has.
14
+ *
15
+ * ## Shape
16
+ *
17
+ * v2's agent side is a fluent app builder: `acp.agent()` returns an {@link AgentApp} on which
18
+ * typed handlers are registered by ACP method name, and `connect()` serves a client — either over
19
+ * a transport stream or, for tests, directly against a `ClientApp`. Nothing about it resembles the
20
+ * v1 code this replaces, which subclassed a third party's server and monkey-patched an instance
21
+ * method before start; that is why this targets v2 directly rather than porting the old shape.
22
+ *
23
+ * ## The prompt lifecycle is the part that looks wrong until you read the spec
24
+ *
25
+ * `session/prompt` returns `{}` **as soon as the prompt is accepted** — not when the turn finishes.
26
+ * Progress, tool calls and the final stop reason all arrive as `session/update` notifications, and
27
+ * the turn is over when an idle `state_update` carrying a stop reason lands. That is what makes
28
+ * cancellation expressible at all: a cancelled turn reports `cancelled` on a `state_update`, while
29
+ * the prompt request it belongs to was answered long before. A client that waited on the prompt
30
+ * response for the result would hang through every tool call.
31
+ *
32
+ * ## Why a runner and not an agent
33
+ *
34
+ * Each session drives a {@link GthAgentRunner}, not a bare agent. The runner is where the
35
+ * tool-approval gate lives, so this is also the surface where `session/request_permission` is
36
+ * wired — see `acpPermissions.ts` for why that is not optional.
37
+ *
38
+ * ## One workspace per process
39
+ *
40
+ * Config discovery, the filesystem tools' allowed root, grep and the shell tool ALL resolve
41
+ * through `getCurrentWorkDir()`, a process-global. So the workspace is bound by the first
42
+ * `session/new` and a later `session/new` naming a different `cwd` is refused rather than served
43
+ * from the wrong root. An editor spawns one agent process per project, which is exactly the shape
44
+ * this serves; the alternative — letting the second session silently re-root the first session's
45
+ * tools — is the kind of quiet wrongness that is worse than an error a host can report.
46
+ */
47
+ import * as acp from '@agentclientprotocol/sdk/experimental/v2';
48
+ import type { GthConfig } from '@gaunt-sloth/core/config.js';
49
+ import type { AgentResolvers } from '@gaunt-sloth/core/core/types.js';
50
+ import type { GthAgentFactory } from '@gaunt-sloth/core/core/types.js';
51
+ /** How this agent identifies itself in the `initialize` response. */
52
+ export declare const ACP_AGENT_NAME = "gaunt-sloth";
53
+ /** Human-facing name for the same, used where a client shows a title rather than an id. */
54
+ export declare const ACP_AGENT_TITLE = "Gaunt Sloth";
55
+ /**
56
+ * Whether two already-resolved absolute paths name the same workspace.
57
+ *
58
+ * **Case-insensitive on win32 and nowhere else**, because that is where the answer differs: NTFS is
59
+ * case-insensitive and case-preserving, so `C:\Foo` and `c:\foo` are one directory and an exact
60
+ * string compare calls them two — a client that re-sends its own `cwd` with different casing would
61
+ * be told to start a second agent process for the project it is already in. On POSIX the two really
62
+ * are different directories and must keep comparing unequal, so the platform is the whole
63
+ * distinction rather than a workaround for one.
64
+ *
65
+ * `platform` is a parameter with the live value as its default so both arms are testable on any
66
+ * host. Every other bug of this shape in this repo (OPS-27, EXT-38, GS2-42, EXT-16) was a POSIX-only
67
+ * assertion that passed everywhere except the Windows cell, and a test that can only run on win32
68
+ * would have the same blind spot pointed the other way.
69
+ */
70
+ export declare function isSameWorkspace(a: string, b: string, platform?: NodeJS.Platform): boolean;
71
+ /** Seams the tests replace; production leaves every one of them at its default. */
72
+ export interface AcpAgentAppOptions {
73
+ /**
74
+ * Loads the effective gth config for a session rooted at `cwd`. Defaults to pointing config
75
+ * discovery at the session workspace and running the normal loader.
76
+ */
77
+ loadConfig?: (cwd: string) => Promise<GthConfig>;
78
+ /**
79
+ * The agent backend for a session. Defaults to {@link resolveAgentFactory}, i.e. the lean agent
80
+ * — the same backend every other command resolves, reached through the same seam rather than
81
+ * named here, so a future backend choice stays a single edit.
82
+ */
83
+ agentFactory?: (config: GthConfig) => GthAgentFactory;
84
+ /** Tool/content resolvers handed to the runner. Defaults to {@link createResolvers}. */
85
+ resolvers?: AgentResolvers;
86
+ }
87
+ /**
88
+ * Builds the ACP v2 agent app. Register-and-return only: nothing is connected and no config is
89
+ * read until a client connects and creates a session.
90
+ */
91
+ export declare function createAcpAgentApp(options?: AcpAgentAppOptions): acp.AgentApp;
92
+ /** Kept for the entry points, which announce themselves on stderr before serving. */
93
+ export declare function announceAcpStart(): void;