@gaunt-sloth/agent 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +10 -0
- package/dist/builtInToolsConfig.d.ts +17 -3
- package/dist/builtInToolsConfig.js +41 -14
- package/dist/builtInToolsConfig.js.map +1 -1
- package/dist/core/GthDeepAgent.d.ts +63 -13
- package/dist/core/GthDeepAgent.js +360 -130
- 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 +73 -13
- package/dist/core/deepAgentPermissions.js +191 -29
- 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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/OAuthClientProviderImpl.js +2 -2
- 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/registry.d.ts +1 -1
- package/dist/middleware/registry.js +1 -1
- package/dist/middleware/types.d.ts +1 -1
- package/dist/middleware/types.js +1 -1
- package/dist/modules/a2a/A2AClientWrapper.d.ts +46 -0
- package/dist/modules/a2a/A2AClientWrapper.js +71 -0
- package/dist/modules/a2a/A2AClientWrapper.js.map +1 -1
- package/dist/modules/acpModule.d.ts +5 -2
- package/dist/modules/acpModule.js +13 -2
- package/dist/modules/acpModule.js.map +1 -1
- package/dist/modules/apiAgUiModule.js +48 -16
- package/dist/modules/apiAgUiModule.js.map +1 -1
- package/dist/modules/interactiveSessionModule.js +140 -7
- package/dist/modules/interactiveSessionModule.js.map +1 -1
- package/dist/resolvers.js +104 -9
- package/dist/resolvers.js.map +1 -1
- package/dist/tools/GthCustomToolkit.js +24 -9
- package/dist/tools/GthCustomToolkit.js.map +1 -1
- package/dist/tools/GthDevToolkit.d.ts +45 -1
- package/dist/tools/GthDevToolkit.js +229 -31
- package/dist/tools/GthDevToolkit.js.map +1 -1
- package/dist/tools/GthFileSystemToolkit.d.ts +47 -0
- package/dist/tools/GthFileSystemToolkit.js +305 -18
- package/dist/tools/GthFileSystemToolkit.js.map +1 -1
- 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/allowlist.d.ts +11 -0
- package/dist/tools/shell/allowlist.js +12 -0
- package/dist/tools/shell/allowlist.js.map +1 -0
- package/dist/tools/shell/arity.d.ts +11 -0
- package/dist/tools/shell/arity.js +12 -0
- package/dist/tools/shell/arity.js.map +1 -0
- package/dist/tools/shell/env.d.ts +22 -0
- package/dist/tools/shell/env.js +110 -0
- package/dist/tools/shell/env.js.map +1 -0
- package/dist/tools/shell/hardline.d.ts +15 -0
- package/dist/tools/shell/hardline.js +88 -0
- package/dist/tools/shell/hardline.js.map +1 -0
- package/dist/tools/shell/normalize.d.ts +10 -0
- package/dist/tools/shell/normalize.js +11 -0
- package/dist/tools/shell/normalize.js.map +1 -0
- package/dist/tools/shell/outputBuffer.d.ts +53 -0
- package/dist/tools/shell/outputBuffer.js +157 -0
- package/dist/tools/shell/outputBuffer.js.map +1 -0
- 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 +14 -13
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GthAgentFactory } from '@gaunt-sloth/core/core/types.js';
|
|
2
|
+
import type { GthConfig } from '@gaunt-sloth/core/config.js';
|
|
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).
|
|
7
|
+
*
|
|
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`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveAgentFactory(config: GthConfig, defaultBackend: 'deep' | 'lean'): GthAgentFactory;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { gthLeanAgentFactory } from '@gaunt-sloth/core/core/gthLeanAgentFactory.js';
|
|
2
|
+
import { gthDeepAgentFactory } from '#src/core/gthDeepAgentFactory.js';
|
|
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).
|
|
7
|
+
*
|
|
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`).
|
|
13
|
+
*/
|
|
14
|
+
export function resolveAgentFactory(config, defaultBackend) {
|
|
15
|
+
const backend = config.agent?.backend ?? defaultBackend;
|
|
16
|
+
return backend === 'deep' ? gthDeepAgentFactory : gthLeanAgentFactory;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=resolveAgentFactory.js.map
|
|
@@ -0,0 +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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export { resolveMiddleware } from '#src/middleware/registry.js';
|
|
|
11
11
|
export { GthDeepAgent, type GthDeepAgentParams } from '#src/core/GthDeepAgent.js';
|
|
12
12
|
export * from '#src/core/deepAgentPermissions.js';
|
|
13
13
|
export { gthDeepAgentFactory } from '#src/core/gthDeepAgentFactory.js';
|
|
14
|
+
export { resolveAgentFactory } from '#src/core/resolveAgentFactory.js';
|
package/dist/index.js
CHANGED
|
@@ -13,4 +13,5 @@ export { resolveMiddleware } from '#src/middleware/registry.js';
|
|
|
13
13
|
export { GthDeepAgent } from '#src/core/GthDeepAgent.js';
|
|
14
14
|
export * from '#src/core/deepAgentPermissions.js';
|
|
15
15
|
export { gthDeepAgentFactory } from '#src/core/gthDeepAgentFactory.js';
|
|
16
|
+
export { resolveAgentFactory } from '#src/core/resolveAgentFactory.js';
|
|
16
17
|
//# 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"}
|
|
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"}
|
|
@@ -82,8 +82,8 @@ export class OAuthClientProviderImpl {
|
|
|
82
82
|
get clientMetadata() {
|
|
83
83
|
return {
|
|
84
84
|
redirect_uris: [this.config.redirectUrl],
|
|
85
|
-
client_name: 'Gaunt Sloth
|
|
86
|
-
client_uri: 'https://
|
|
85
|
+
client_name: 'Gaunt Sloth',
|
|
86
|
+
client_uri: 'https://gauntsloth.app/',
|
|
87
87
|
software_id: '1dd38b83-946b-4631-8855-66ee467bfd68',
|
|
88
88
|
scope: 'mcp:read mcp:write',
|
|
89
89
|
token_endpoint_auth_method: 'none',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthClientProviderImpl.js","sourceRoot":"","sources":["../../src/mcp/OAuthClientProviderImpl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAMhE,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAcnF;;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EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,0DAA0D;YAC1D,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Process-global TLS trust for outbound HTTPS, driven by the `tls` config block.
|
|
4
|
+
*
|
|
5
|
+
* Motivation: an `http`-transport MCP server behind a private/corporate CA (e.g. a dev monolith
|
|
6
|
+
* with a self-signed cert) makes Node's global `fetch` reject the connection with
|
|
7
|
+
* `TypeError: fetch failed` (`SELF_SIGNED_CERT_IN_CHAIN`). The only pre-existing workaround was to
|
|
8
|
+
* prepend `NODE_EXTRA_CA_CERTS=<ca.crt>` on every invocation — that env var is read ONCE at Node
|
|
9
|
+
* startup, so it can't be set from config after launch.
|
|
10
|
+
*
|
|
11
|
+
* Node's `fetch` runs on undici and ignores `https.globalAgent`, so the CA must be installed via an
|
|
12
|
+
* undici dispatcher. `@langchain/mcp-adapters` forwards only `serverName`/`headers`/`authProvider`
|
|
13
|
+
* to the SDK transport (it drops the SDK's `requestInit`/`fetch` hooks), so a per-server CA is not
|
|
14
|
+
* reachable through the adapter. The trust is therefore installed **process-globally** via
|
|
15
|
+
* `setGlobalDispatcher`. That is acceptable for adding a CA (additive trust weakens nothing) — but
|
|
16
|
+
* note the insecure latch below is global too, and so affects LLM provider calls, not only MCP.
|
|
17
|
+
*/
|
|
18
|
+
import type { GthConfig } from '@gaunt-sloth/core/config.js';
|
|
19
|
+
type TlsConfig = GthConfig['tls'];
|
|
20
|
+
/** A cert path that could not be read, with the reason (surfaced by the installer). */
|
|
21
|
+
export interface TlsCertFailure {
|
|
22
|
+
path: string;
|
|
23
|
+
message: string;
|
|
24
|
+
}
|
|
25
|
+
/** The undici `connect` options computed from a `tls` config, plus what happened while reading. */
|
|
26
|
+
export interface BuiltDispatcher {
|
|
27
|
+
/** Node's default roots FIRST, then successfully-read user certs. `connect.ca` REPLACES the */
|
|
28
|
+
/** default store, so the roots must be included or every public-CA fetch breaks. */
|
|
29
|
+
ca: string[];
|
|
30
|
+
/** `false` disables verification entirely (process-global). Defaults to `true`. */
|
|
31
|
+
rejectUnauthorized: boolean;
|
|
32
|
+
/** How many configured certs were read successfully. */
|
|
33
|
+
loadedCount: number;
|
|
34
|
+
/** Configured certs that could not be read (fail-soft: skipped, not fatal). */
|
|
35
|
+
failures: TlsCertFailure[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Compute the undici dispatcher options from a `tls` config. Pure aside from the injected
|
|
39
|
+
* `readCert` (so unit tests stub file reads): resolves nothing about the environment itself.
|
|
40
|
+
*
|
|
41
|
+
* Returns `null` only when NOTHING is configured — no `tls` block, or an empty `tls` with no cert
|
|
42
|
+
* entries and verification left at its secure default. When certs ARE configured it always returns
|
|
43
|
+
* the object (even if every read failed), so the caller can surface those `failures` rather than
|
|
44
|
+
* silently swallowing a bad cert path. Whether to actually install is the caller's call:
|
|
45
|
+
* `loadedCount > 0 || !rejectUnauthorized`.
|
|
46
|
+
*
|
|
47
|
+
* `readCert` receives each configured path verbatim and must return the PEM contents or throw.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildDispatcherOptions(tls: TlsConfig, readCert: (path: string) => string, baseRoots?: readonly string[]): BuiltDispatcher | null;
|
|
50
|
+
/**
|
|
51
|
+
* Install the process-global undici dispatcher from `config.tls`, if any. Idempotent (installs at
|
|
52
|
+
* most once per process). Fail-soft: an unreadable cert is warned about and skipped, never fatal.
|
|
53
|
+
* Emits a loud security warning when verification is disabled.
|
|
54
|
+
*
|
|
55
|
+
* Wired into `getMcpClient` before the MCP client is created; because it is global it also covers
|
|
56
|
+
* LLM/tool fetches — which is desired for the CA case and is the danger to flag for the latch.
|
|
57
|
+
*/
|
|
58
|
+
export declare function installMcpTlsTrust(config: GthConfig): void;
|
|
59
|
+
/** Test-only: reset the install-once guard between cases. */
|
|
60
|
+
export declare function resetMcpTlsTrustForTests(): void;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Process-global TLS trust for outbound HTTPS, driven by the `tls` config block.
|
|
4
|
+
*
|
|
5
|
+
* Motivation: an `http`-transport MCP server behind a private/corporate CA (e.g. a dev monolith
|
|
6
|
+
* with a self-signed cert) makes Node's global `fetch` reject the connection with
|
|
7
|
+
* `TypeError: fetch failed` (`SELF_SIGNED_CERT_IN_CHAIN`). The only pre-existing workaround was to
|
|
8
|
+
* prepend `NODE_EXTRA_CA_CERTS=<ca.crt>` on every invocation — that env var is read ONCE at Node
|
|
9
|
+
* startup, so it can't be set from config after launch.
|
|
10
|
+
*
|
|
11
|
+
* Node's `fetch` runs on undici and ignores `https.globalAgent`, so the CA must be installed via an
|
|
12
|
+
* undici dispatcher. `@langchain/mcp-adapters` forwards only `serverName`/`headers`/`authProvider`
|
|
13
|
+
* to the SDK transport (it drops the SDK's `requestInit`/`fetch` hooks), so a per-server CA is not
|
|
14
|
+
* reachable through the adapter. The trust is therefore installed **process-globally** via
|
|
15
|
+
* `setGlobalDispatcher`. That is acceptable for adding a CA (additive trust weakens nothing) — but
|
|
16
|
+
* note the insecure latch below is global too, and so affects LLM provider calls, not only MCP.
|
|
17
|
+
*/
|
|
18
|
+
import { rootCertificates } from 'node:tls';
|
|
19
|
+
import { readFileSync } from 'node:fs';
|
|
20
|
+
import { homedir } from 'node:os';
|
|
21
|
+
import { resolve } from 'node:path';
|
|
22
|
+
import { Agent, setGlobalDispatcher } from 'undici';
|
|
23
|
+
import { getProjectDir } from '@gaunt-sloth/core/utils/systemUtils.js';
|
|
24
|
+
import { displayWarning } from '@gaunt-sloth/core/utils/consoleUtils.js';
|
|
25
|
+
import { debugLog } from '@gaunt-sloth/core/utils/debugUtils.js';
|
|
26
|
+
/**
|
|
27
|
+
* Compute the undici dispatcher options from a `tls` config. Pure aside from the injected
|
|
28
|
+
* `readCert` (so unit tests stub file reads): resolves nothing about the environment itself.
|
|
29
|
+
*
|
|
30
|
+
* Returns `null` only when NOTHING is configured — no `tls` block, or an empty `tls` with no cert
|
|
31
|
+
* entries and verification left at its secure default. When certs ARE configured it always returns
|
|
32
|
+
* the object (even if every read failed), so the caller can surface those `failures` rather than
|
|
33
|
+
* silently swallowing a bad cert path. Whether to actually install is the caller's call:
|
|
34
|
+
* `loadedCount > 0 || !rejectUnauthorized`.
|
|
35
|
+
*
|
|
36
|
+
* `readCert` receives each configured path verbatim and must return the PEM contents or throw.
|
|
37
|
+
*/
|
|
38
|
+
export function buildDispatcherOptions(tls, readCert, baseRoots = rootCertificates) {
|
|
39
|
+
const rejectUnauthorized = tls?.rejectUnauthorized ?? true;
|
|
40
|
+
const certPaths = tls?.extraCaCerts ?? [];
|
|
41
|
+
// Nothing configured at all: no cert entries and verification not being disabled.
|
|
42
|
+
if (certPaths.length === 0 && rejectUnauthorized)
|
|
43
|
+
return null;
|
|
44
|
+
const userCerts = [];
|
|
45
|
+
const failures = [];
|
|
46
|
+
for (const path of certPaths) {
|
|
47
|
+
try {
|
|
48
|
+
userCerts.push(readCert(path));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
failures.push({ path, message: error instanceof Error ? error.message : String(error) });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
// ca REPLACES the trust store — keep the default roots or public-CA fetches (incl. the LLM
|
|
56
|
+
// provider) silently break.
|
|
57
|
+
ca: [...baseRoots, ...userCerts],
|
|
58
|
+
rejectUnauthorized,
|
|
59
|
+
loadedCount: userCerts.length,
|
|
60
|
+
failures,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Install-once guard: the trust is process-global and set-once, so re-running resolveTools (re-init)
|
|
64
|
+
// must not re-replace the dispatcher nor re-emit the security warning every time.
|
|
65
|
+
let installed = false;
|
|
66
|
+
/**
|
|
67
|
+
* Install the process-global undici dispatcher from `config.tls`, if any. Idempotent (installs at
|
|
68
|
+
* most once per process). Fail-soft: an unreadable cert is warned about and skipped, never fatal.
|
|
69
|
+
* Emits a loud security warning when verification is disabled.
|
|
70
|
+
*
|
|
71
|
+
* Wired into `getMcpClient` before the MCP client is created; because it is global it also covers
|
|
72
|
+
* LLM/tool fetches — which is desired for the CA case and is the danger to flag for the latch.
|
|
73
|
+
*/
|
|
74
|
+
export function installMcpTlsTrust(config) {
|
|
75
|
+
if (installed) {
|
|
76
|
+
debugLog('MCP TLS trust already installed this process; skipping.');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const built = buildDispatcherOptions(config.tls, resolveAndReadCert);
|
|
80
|
+
if (!built)
|
|
81
|
+
return;
|
|
82
|
+
// Surface unreadable certs even if we end up installing nothing — a bad cert path must never be
|
|
83
|
+
// swallowed silently. Warn BEFORE the "nothing actionable" bail below.
|
|
84
|
+
for (const failure of built.failures) {
|
|
85
|
+
displayWarning(`TLS: could not read CA certificate '${failure.path}' (${failure.message}); skipping it.`);
|
|
86
|
+
}
|
|
87
|
+
// Nothing left to install: every configured cert failed to read and verification is still on.
|
|
88
|
+
// (Failures were already surfaced above.) Leave Node's default dispatcher untouched.
|
|
89
|
+
if (built.loadedCount === 0 && built.rejectUnauthorized)
|
|
90
|
+
return;
|
|
91
|
+
installed = true;
|
|
92
|
+
if (!built.rejectUnauthorized) {
|
|
93
|
+
displayWarning('TLS: certificate verification is DISABLED (tls.rejectUnauthorized: false). This is INSECURE ' +
|
|
94
|
+
'and applies to ALL outbound HTTPS this process makes — MCP servers AND LLM provider calls. ' +
|
|
95
|
+
'Use only against trusted dev endpoints; prefer tls.extraCaCerts to trust a specific CA instead.');
|
|
96
|
+
}
|
|
97
|
+
setGlobalDispatcher(new Agent({ connect: { ca: built.ca, rejectUnauthorized: built.rejectUnauthorized } }));
|
|
98
|
+
debugLog(`MCP TLS trust installed: ${built.loadedCount} extra CA cert(s), rejectUnauthorized=${built.rejectUnauthorized}.`);
|
|
99
|
+
}
|
|
100
|
+
/** Resolve a configured cert path (`~` / relative-to-project / absolute) and read it as UTF-8. */
|
|
101
|
+
function resolveAndReadCert(path) {
|
|
102
|
+
const expanded = path === '~' || path.startsWith('~/') ? homedir() + path.slice(1) : path;
|
|
103
|
+
return readFileSync(resolve(getProjectDir(), expanded), 'utf8');
|
|
104
|
+
}
|
|
105
|
+
/** Test-only: reset the install-once guard between cases. */
|
|
106
|
+
export function resetMcpTlsTrustForTests() {
|
|
107
|
+
installed = false;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=tlsTrust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tlsTrust.js","sourceRoot":"","sources":["../../src/mcp/tlsTrust.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAuBjE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CACpC,GAAc,EACd,QAAkC,EAClC,SAAS,GAAsB,gBAAgB;IAE/C,MAAM,kBAAkB,GAAG,GAAG,EAAE,kBAAkB,IAAI,IAAI,CAAC;IAC3D,MAAM,SAAS,GAAG,GAAG,EAAE,YAAY,IAAI,EAAE,CAAC;IAE1C,kFAAkF;IAClF,IAAI,SAAS,CAAC,MAAM,KA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9F,qFAAqF;IACrF,IAAI,KAAK,CAAC,WAAW,KAAK,CAAC,IAAI,KAAK,CAAC,kBAAkB;QAAE,OAAO;IAEhE,SAAS,GAAG,IAAI,CAAC;IAEjB,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAC9B,cAAc,CACZ,8FAA8F;YAC5F,6FAA6F;YAC7F,iGAAiG,CACpG,CAAC;IACJ,CAAC;IAED,mBAAmB,CACjB,IAAI,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE,EAAE,CAAC,CACvF,CAAC;IACF,QAAQ,CACN,4BAA4B,KAAK,CAAC,WAAW,yCAAyC,KAAK,CAAC,kBAAkB,GAAG,CAClH,CAAC;AACJ,CAAC;AAED,kGAAkG;AAClG,SAAS,kBAAkB,CAAC,IAAY;IACtC,MAAM,QAAQ,GAAG,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1F,OAAO,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;AAClE,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,wBAAwB;IACtC,SAAS,GAAG,KAAK,CAAC;AACpB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
|
-
* Middleware registry for Gaunt Sloth
|
|
3
|
+
* Middleware registry for Gaunt Sloth.
|
|
4
4
|
*
|
|
5
5
|
* This module provides factory functions for creating predefined middleware instances
|
|
6
6
|
* and a resolver to convert middleware configurations into middleware objects.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
|
-
* Middleware registry for Gaunt Sloth
|
|
3
|
+
* Middleware registry for Gaunt Sloth.
|
|
4
4
|
*
|
|
5
5
|
* This module provides factory functions for creating predefined middleware instances
|
|
6
6
|
* and a resolver to convert middleware configurations into middleware objects.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
|
-
* Type definitions for middleware configuration in Gaunt Sloth
|
|
3
|
+
* Type definitions for middleware configuration in Gaunt Sloth.
|
|
4
4
|
*
|
|
5
5
|
* Middleware provides hooks to intercept and control agent execution at critical points.
|
|
6
6
|
* This module defines the configuration interfaces for both predefined and custom middleware.
|
package/dist/middleware/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
|
-
* Type definitions for middleware configuration in Gaunt Sloth
|
|
3
|
+
* Type definitions for middleware configuration in Gaunt Sloth.
|
|
4
4
|
*
|
|
5
5
|
* Middleware provides hooks to intercept and control agent execution at critical points.
|
|
6
6
|
* This module defines the configuration interfaces for both predefined and custom middleware.
|
|
@@ -5,6 +5,27 @@ export interface A2AClientConfig {
|
|
|
5
5
|
/** URL endpoint for the A2A agent */
|
|
6
6
|
agentUrl: string;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* A single A2A turn's result with its conversation-continuity handles (BATCH-14). Unlike the
|
|
10
|
+
* text-only {@link A2AClientWrapper.sendMessage}, this carries the `contextId`/`taskId` the server
|
|
11
|
+
* returned so a caller can thread them into follow-up turns (an ADK agent keeps conversational
|
|
12
|
+
* context by `contextId`). Both are optional because a response may be a bare `Message` (which
|
|
13
|
+
* carries them only optionally) or a `Task` (which always carries `contextId`, and `id` as the
|
|
14
|
+
* taskId).
|
|
15
|
+
*/
|
|
16
|
+
export interface A2AMessageResult {
|
|
17
|
+
/** The agent's answer text, extracted from the response's text parts. */
|
|
18
|
+
text: string;
|
|
19
|
+
/** The A2A context id to thread into subsequent turns for conversational continuity. */
|
|
20
|
+
contextId?: string;
|
|
21
|
+
/** The A2A task id, when the response was a Task (`Task.id`) or a task-scoped Message. */
|
|
22
|
+
taskId?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Optional conversation-continuity handles to attach to an outgoing A2A message (BATCH-14). */
|
|
25
|
+
export interface A2ASendContext {
|
|
26
|
+
contextId?: string;
|
|
27
|
+
taskId?: string;
|
|
28
|
+
}
|
|
8
29
|
/**
|
|
9
30
|
* Wrapper around the A2A SDK client for communicating with external agents.
|
|
10
31
|
* @experimental
|
|
@@ -19,4 +40,29 @@ export declare class A2AClientWrapper {
|
|
|
19
40
|
* @returns The agent's response as a string
|
|
20
41
|
*/
|
|
21
42
|
sendMessage(messageText: string): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* BATCH-14 — send one message and return its text ALONG WITH the A2A `contextId`/`taskId` needed to
|
|
45
|
+
* thread a multi-turn conversation. Reads the real `@a2a-js/sdk` result shapes rather than the
|
|
46
|
+
* loose envelope {@link sendMessage} uses:
|
|
47
|
+
*
|
|
48
|
+
* - A **Message** result (`kind: 'message'`) carries its text in `parts` and `contextId`/`taskId`
|
|
49
|
+
* directly (both optional).
|
|
50
|
+
* - A **Task** result (`kind: 'task'`) — what Google ADK agents commonly return — carries text in
|
|
51
|
+
* `status.message.parts` (falling back to the last artifact's parts), `contextId` (required), and
|
|
52
|
+
* the taskId as `Task.id`.
|
|
53
|
+
*
|
|
54
|
+
* `context.contextId`/`taskId` are attached to the OUTGOING message only when defined, so a
|
|
55
|
+
* first-turn send stays byte-identical to a contextless one.
|
|
56
|
+
*
|
|
57
|
+
* @param messageText - The message to send to the agent.
|
|
58
|
+
* @param context - Optional context/task ids to continue an existing conversation.
|
|
59
|
+
* @returns The agent's text answer plus the context/task ids from its response.
|
|
60
|
+
*/
|
|
61
|
+
sendMessageWithContext(messageText: string, context?: A2ASendContext): Promise<A2AMessageResult>;
|
|
62
|
+
/** Normalize a `Message | Task` A2A result into text + continuity handles (BATCH-14). Static +
|
|
63
|
+
* tolerant of missing optional fields so it can be reused and unit-tested directly. */
|
|
64
|
+
private static extractResult;
|
|
65
|
+
/** Concatenate the text of every {@link https://github.com/a2aproject/A2A TextPart} in `parts`
|
|
66
|
+
* (ignoring file/data parts), or `''` when there is no text part. */
|
|
67
|
+
private static extractText;
|
|
22
68
|
}
|
|
@@ -59,5 +59,76 @@ export class A2AClientWrapper {
|
|
|
59
59
|
throw error;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* BATCH-14 — send one message and return its text ALONG WITH the A2A `contextId`/`taskId` needed to
|
|
64
|
+
* thread a multi-turn conversation. Reads the real `@a2a-js/sdk` result shapes rather than the
|
|
65
|
+
* loose envelope {@link sendMessage} uses:
|
|
66
|
+
*
|
|
67
|
+
* - A **Message** result (`kind: 'message'`) carries its text in `parts` and `contextId`/`taskId`
|
|
68
|
+
* directly (both optional).
|
|
69
|
+
* - A **Task** result (`kind: 'task'`) — what Google ADK agents commonly return — carries text in
|
|
70
|
+
* `status.message.parts` (falling back to the last artifact's parts), `contextId` (required), and
|
|
71
|
+
* the taskId as `Task.id`.
|
|
72
|
+
*
|
|
73
|
+
* `context.contextId`/`taskId` are attached to the OUTGOING message only when defined, so a
|
|
74
|
+
* first-turn send stays byte-identical to a contextless one.
|
|
75
|
+
*
|
|
76
|
+
* @param messageText - The message to send to the agent.
|
|
77
|
+
* @param context - Optional context/task ids to continue an existing conversation.
|
|
78
|
+
* @returns The agent's text answer plus the context/task ids from its response.
|
|
79
|
+
*/
|
|
80
|
+
async sendMessageWithContext(messageText, context) {
|
|
81
|
+
debugLog(`Sending message (with context) to A2A agent ${this.config.agentId} at ` +
|
|
82
|
+
`${this.config.agentUrl}: ${messageText}` +
|
|
83
|
+
(context?.contextId ? ` [contextId=${context.contextId}]` : ''));
|
|
84
|
+
try {
|
|
85
|
+
const response = await this.client.sendMessage({
|
|
86
|
+
message: {
|
|
87
|
+
kind: 'message',
|
|
88
|
+
messageId: uuidv4(),
|
|
89
|
+
role: 'user',
|
|
90
|
+
parts: [{ kind: 'text', text: messageText }],
|
|
91
|
+
// Attach continuity handles only when present, so a first-turn send is unchanged.
|
|
92
|
+
...(context?.contextId ? { contextId: context.contextId } : {}),
|
|
93
|
+
...(context?.taskId ? { taskId: context.taskId } : {}),
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
debugLog(`Received response from A2A agent: ${JSON.stringify(response)}`);
|
|
97
|
+
if ('error' in response) {
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
throw new Error(`A2A Error: ${JSON.stringify(response.error)}`);
|
|
100
|
+
}
|
|
101
|
+
const result = response.result;
|
|
102
|
+
return A2AClientWrapper.extractResult(result);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
debugLogError('Error sending message (with context) to A2A agent', error);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Normalize a `Message | Task` A2A result into text + continuity handles (BATCH-14). Static +
|
|
110
|
+
* tolerant of missing optional fields so it can be reused and unit-tested directly. */
|
|
111
|
+
static extractResult(result) {
|
|
112
|
+
if (result && result.kind === 'task') {
|
|
113
|
+
const task = result;
|
|
114
|
+
const statusParts = task.status?.message?.parts;
|
|
115
|
+
const artifactParts = task.artifacts?.[task.artifacts.length - 1]?.parts;
|
|
116
|
+
const text = A2AClientWrapper.extractText(statusParts ?? artifactParts) || JSON.stringify(task);
|
|
117
|
+
return { text, contextId: task.contextId, taskId: task.id };
|
|
118
|
+
}
|
|
119
|
+
const message = result;
|
|
120
|
+
const text = A2AClientWrapper.extractText(message?.parts) || JSON.stringify(result);
|
|
121
|
+
return { text, contextId: message?.contextId, taskId: message?.taskId };
|
|
122
|
+
}
|
|
123
|
+
/** Concatenate the text of every {@link https://github.com/a2aproject/A2A TextPart} in `parts`
|
|
124
|
+
* (ignoring file/data parts), or `''` when there is no text part. */
|
|
125
|
+
static extractText(parts) {
|
|
126
|
+
if (!parts || parts.length === 0)
|
|
127
|
+
return '';
|
|
128
|
+
return parts
|
|
129
|
+
.filter((part) => part?.kind === 'text')
|
|
130
|
+
.map((part) => part.text)
|
|
131
|
+
.join('\n');
|
|
132
|
+
}
|
|
62
133
|
}
|
|
63
134
|
//# sourceMappingURL=A2AClientWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A2AClientWrapper.js","sourceRoot":"","sources":["../../../src/modules/a2a/A2AClientWrapper.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"A2AClientWrapper.js","sourceRoot":"","sources":["../../../src/modules/a2a/A2AClientWrapper.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAiCpC;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAY;IAClB,MAAM,CAAkB;IAEhC,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,gEAAgE;QAChE,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,WAAmB;QACnC,QAAQ,CACN,gCAAgC,IAAI,CAAC,MAAM,CAAC,OAAO,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,WAAW,EAAE,CACjG,CAAC;QACF,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;YAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,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E,IAAI,KAAK,MAAM,CAAC;aAChF,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;aACxB,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -31,7 +31,10 @@ export interface StartAcpServerOptions {
|
|
|
31
31
|
*
|
|
32
32
|
* NOTE: deepagents-acp 0.1.12 does NOT forward `permissions` to `createDeepAgent` — on the ACP
|
|
33
33
|
* path fs gating is delegated to the host's interactive permission prompts, not gsloth's
|
|
34
|
-
* `.aiignore`→permissions mapping. `permissions` is still passed here for forward-compatibility
|
|
35
|
-
*
|
|
34
|
+
* `.aiignore`→permissions mapping. `permissions` is still passed here for forward-compatibility.
|
|
35
|
+
* EXT-13 caveat: the ACP backend keeps `virtualMode` ON (`/` = workspace, see gthAcpServer), while
|
|
36
|
+
* EXT-13 re-anchored gsloth's default permissions at the REAL absolute cwd for the local runner. So
|
|
37
|
+
* if a future deepagents-acp DOES forward these rules they would not match the virtual `/`-rooted
|
|
38
|
+
* paths the ACP backend hands them — revisit the mapping (or the ACP backend's mode) at that point.
|
|
36
39
|
*/
|
|
37
40
|
export declare function startAcpServer(config: GthConfig, options?: StartAcpServerOptions): Promise<void>;
|
|
@@ -33,11 +33,22 @@ const acpStatusUpdate = (_level, message) => {
|
|
|
33
33
|
*
|
|
34
34
|
* NOTE: deepagents-acp 0.1.12 does NOT forward `permissions` to `createDeepAgent` — on the ACP
|
|
35
35
|
* path fs gating is delegated to the host's interactive permission prompts, not gsloth's
|
|
36
|
-
* `.aiignore`→permissions mapping. `permissions` is still passed here for forward-compatibility
|
|
37
|
-
*
|
|
36
|
+
* `.aiignore`→permissions mapping. `permissions` is still passed here for forward-compatibility.
|
|
37
|
+
* EXT-13 caveat: the ACP backend keeps `virtualMode` ON (`/` = workspace, see gthAcpServer), while
|
|
38
|
+
* EXT-13 re-anchored gsloth's default permissions at the REAL absolute cwd for the local runner. So
|
|
39
|
+
* if a future deepagents-acp DOES forward these rules they would not match the virtual `/`-rooted
|
|
40
|
+
* paths the ACP backend hands them — revisit the mapping (or the ACP backend's mode) at that point.
|
|
38
41
|
*/
|
|
39
42
|
export async function startAcpServer(config, options = {}) {
|
|
40
43
|
const command = options.command ?? 'code';
|
|
44
|
+
// ACP is structurally deep-only: it calls GthDeepAgent.buildDeepAgentParams and hands the
|
|
45
|
+
// extracted params to the deepagents-acp server. There is no lean analog, so an explicit
|
|
46
|
+
// `agent.backend: 'lean'` cannot be honored here — reject it loudly rather than silently
|
|
47
|
+
// running deep despite the request (B5 selector, kept honest at the ACP entry).
|
|
48
|
+
if (config.agent?.backend === 'lean') {
|
|
49
|
+
throw new Error("agent.backend: 'lean' is not supported by the ACP server — ACP relies on the deep " +
|
|
50
|
+
'(deepagents) backend. Remove the lean setting, or use the AG-UI/api server for a lean agent.');
|
|
51
|
+
}
|
|
41
52
|
const agent = new GthDeepAgent(acpStatusUpdate, createResolvers());
|
|
42
53
|
const params = await agent.buildDeepAgentParams(command, config);
|
|
43
54
|
// gsloth's composed system prompt (backstory + guidelines + per-command mode prompt + system
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acpModule.js","sourceRoot":"","sources":["../../src/modules/acpModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAWpD;;;GAGG;AACH,MAAM,eAAe,GAAyB,CAAC,MAAmB,EAAE,OAAe,EAAQ,EAAE;IAC3F,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;AAC/B,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