@gaunt-sloth/agent 2.0.0-alpha.9 → 2.0.0-beta.0
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/cli-acp.js +21 -24
- package/dist/builtInToolsConfig.d.ts +17 -3
- package/dist/builtInToolsConfig.js +43 -41
- package/dist/builtInToolsConfig.js.map +1 -1
- package/dist/core/debugCapture.d.ts +7 -49
- package/dist/core/debugCapture.js +1 -1
- package/dist/core/debugCapture.js.map +1 -1
- package/dist/core/resolveAgentFactory.d.ts +10 -9
- package/dist/core/resolveAgentFactory.js +11 -12
- package/dist/core/resolveAgentFactory.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -5
- 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 +107 -0
- package/dist/middleware/frontendImageInjectionMiddleware.js +167 -0
- package/dist/middleware/frontendImageInjectionMiddleware.js.map +1 -0
- package/dist/middleware/registry.js +49 -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/acp/acpAgentApp.d.ts +57 -0
- package/dist/modules/acp/acpAgentApp.js +378 -0
- package/dist/modules/acp/acpAgentApp.js.map +1 -0
- package/dist/modules/acp/acpAgentAppV1.d.ts +52 -0
- package/dist/modules/acp/acpAgentAppV1.js +307 -0
- package/dist/modules/acp/acpAgentAppV1.js.map +1 -0
- package/dist/modules/acp/acpCommon.d.ts +167 -0
- package/dist/modules/acp/acpCommon.js +282 -0
- package/dist/modules/acp/acpCommon.js.map +1 -0
- package/dist/modules/acp/acpPermissions.d.ts +65 -0
- package/dist/modules/acp/acpPermissions.js +162 -0
- package/dist/modules/acp/acpPermissions.js.map +1 -0
- package/dist/modules/acp/acpPermissionsV1.d.ts +45 -0
- package/dist/modules/acp/acpPermissionsV1.js +110 -0
- package/dist/modules/acp/acpPermissionsV1.js.map +1 -0
- package/dist/modules/acp/acpRouter.d.ts +41 -0
- package/dist/modules/acp/acpRouter.js +48 -0
- package/dist/modules/acp/acpRouter.js.map +1 -0
- package/dist/modules/acp/acpStdio.d.ts +47 -0
- package/dist/modules/acp/acpStdio.js +71 -0
- package/dist/modules/acp/acpStdio.js.map +1 -0
- package/dist/modules/acp/acpToolCalls.d.ts +93 -0
- package/dist/modules/acp/acpToolCalls.js +193 -0
- package/dist/modules/acp/acpToolCalls.js.map +1 -0
- package/dist/modules/acp/acpUpdates.d.ts +48 -0
- package/dist/modules/acp/acpUpdates.js +142 -0
- package/dist/modules/acp/acpUpdates.js.map +1 -0
- package/dist/modules/acp/acpUpdatesV1.d.ts +61 -0
- package/dist/modules/acp/acpUpdatesV1.js +162 -0
- package/dist/modules/acp/acpUpdatesV1.js.map +1 -0
- package/dist/modules/apiAgUiModule.d.ts +87 -0
- package/dist/modules/apiAgUiModule.js +193 -28
- package/dist/modules/apiAgUiModule.js.map +1 -1
- package/dist/modules/interactiveSessionModule.js +497 -51
- package/dist/modules/interactiveSessionModule.js.map +1 -1
- package/dist/modules/slashCommands.d.ts +582 -0
- package/dist/modules/slashCommands.js +1001 -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 +8 -5
- package/dist/tools/GthDevToolkit.js +89 -43
- 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 +80 -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 +1 -10
- package/dist/tools/shell/workDir.js +10 -36
- package/dist/tools/shell/workDir.js.map +1 -1
- package/dist/utils/mcpAuthError.d.ts +36 -0
- package/dist/utils/mcpAuthError.js +89 -0
- package/dist/utils/mcpAuthError.js.map +1 -0
- package/package.json +13 -13
- package/dist/core/GthDeepAgent.d.ts +0 -181
- package/dist/core/GthDeepAgent.js +0 -682
- package/dist/core/GthDeepAgent.js.map +0 -1
- package/dist/core/deepAgentPermissions.d.ts +0 -115
- package/dist/core/deepAgentPermissions.js +0 -282
- package/dist/core/deepAgentPermissions.js.map +0 -1
- package/dist/core/gthAcpServer.d.ts +0 -27
- package/dist/core/gthAcpServer.js +0 -82
- package/dist/core/gthAcpServer.js.map +0 -1
- package/dist/core/gthDeepAgentFactory.d.ts +0 -8
- package/dist/core/gthDeepAgentFactory.js +0 -9
- package/dist/core/gthDeepAgentFactory.js.map +0 -1
- package/dist/modules/acpModule.d.ts +0 -40
- package/dist/modules/acpModule.js +0 -78
- package/dist/modules/acpModule.js.map +0 -1
- 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
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
* ACP (Agent Client Protocol) server entry for the Gaunt Sloth deep agent.
|
|
4
|
-
*
|
|
5
|
-
* This is a parallel front-door to the AG-UI server ({@link startAgUiServer}); both expose
|
|
6
|
-
* the SAME {@link GthDeepAgent}. AG-UI stays the robot-controller path; ACP is an additional
|
|
7
|
-
* way to drive Galvanized Pukeko from an ACP host (Zed, JetBrains, a future Pukeko client).
|
|
8
|
-
*
|
|
9
|
-
* It reuses {@link GthDeepAgent.buildDeepAgentParams} so tool resolution (with the filesystem
|
|
10
|
-
* disabled so deepagents owns fs access), the `.aiignore`/filesystem→permission mapping and the
|
|
11
|
-
* fs-denial-softening middleware are identical to the local runner path. `deepagents-acp`
|
|
12
|
-
* supplies the rest of the coding-agent surface itself: a per-session `ACPFilesystemBackend`
|
|
13
|
-
* (proxying reads/writes through the ACP client so unsaved editor buffers are visible), the
|
|
14
|
-
* checkpointer, interactive `session/request_permission` gating, and tool-call/plan reporting.
|
|
15
|
-
*/
|
|
16
|
-
import { getProcessCwd, stderr } from '@gaunt-sloth/core/utils/systemUtils.js';
|
|
17
|
-
import { debugLog } from '@gaunt-sloth/core/utils/debugUtils.js';
|
|
18
|
-
import { GthDeepAgent } from '#src/core/GthDeepAgent.js';
|
|
19
|
-
import { startGthAcpServer } from '#src/core/gthAcpServer.js';
|
|
20
|
-
import { createResolvers } from '#src/resolvers.js';
|
|
21
|
-
/**
|
|
22
|
-
* ACP-side status routing: the ACP protocol owns stdout (JSON-RPC framing), so agent
|
|
23
|
-
* status/info must never touch it. Route everything to stderr.
|
|
24
|
-
*/
|
|
25
|
-
const acpStatusUpdate = (_level, message) => {
|
|
26
|
-
stderr.write(`${message}\n`);
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Start the Gaunt Sloth deep agent as an ACP server over stdio.
|
|
30
|
-
*
|
|
31
|
-
* Resolves once the stdio transport is listening; the process then stays alive serving the
|
|
32
|
-
* ACP host until it is terminated. The returned promise rejecting means startup failed.
|
|
33
|
-
*
|
|
34
|
-
* NOTE: deepagents-acp 0.1.12 does NOT forward `permissions` to `createDeepAgent` — on the ACP
|
|
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
|
-
* 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.
|
|
41
|
-
*/
|
|
42
|
-
export async function startAcpServer(config, options = {}) {
|
|
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
|
-
}
|
|
52
|
-
const agent = new GthDeepAgent(acpStatusUpdate, createResolvers());
|
|
53
|
-
const params = await agent.buildDeepAgentParams(command, config);
|
|
54
|
-
// gsloth's composed system prompt (backstory + guidelines + per-command mode prompt + system
|
|
55
|
-
// prompt) comes back on `params.systemPrompt` — the SAME prompt the local runner passes to
|
|
56
|
-
// createDeepAgent. ACP has no per-turn hook, so it sets the agent's `systemPrompt` here.
|
|
57
|
-
const systemPrompt = params.systemPrompt;
|
|
58
|
-
// workspaceRoot is only the startup default: startGthAcpServer re-roots the filesystem backend
|
|
59
|
-
// to each ACP session's `cwd` (the IDE's project root). Use the raw process cwd, not
|
|
60
|
-
// getCurrentWorkDir() — its INIT_CWD preference leaks stale paths into this long-lived subprocess.
|
|
61
|
-
const workspaceRoot = getProcessCwd();
|
|
62
|
-
debugLog(`Starting ACP server (command: ${command}, startup workspace: ${workspaceRoot})`);
|
|
63
|
-
await startGthAcpServer({
|
|
64
|
-
agents: {
|
|
65
|
-
name: options.name ?? 'gaunt-sloth',
|
|
66
|
-
description: options.description ?? 'Gaunt Sloth deep coding agent',
|
|
67
|
-
model: params.model,
|
|
68
|
-
tools: params.tools,
|
|
69
|
-
systemPrompt,
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
-
middleware: params.middleware,
|
|
72
|
-
// Forward-compat: ignored by deepagents-acp 0.1.12 (the host gates fs interactively).
|
|
73
|
-
permissions: params.permissions,
|
|
74
|
-
},
|
|
75
|
-
workspaceRoot,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=acpModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,UAAiC,EAAE;IAEnC,MAAM,OAAO,GAAe,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC;IAEtD,0FAA0F;IAC1F,yFAAyF;IACzF,yFAAyF;IACzF,gFAAgF;IAChF,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,oFAAoF;YAClF,8FAA8F,CACjG,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,eAAe,EAAE,eAAe,EAAE,CAAC,CAAC;IACnE,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAEjE,6FAA6F;IAC7F,2FAA2F;IAC3F,yFAAyF;IACzF,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;IAEzC,+FAA+F;IAC/F,qFAAqF;IACrF,mGAAmG;IACnG,MAAM,aAAa,GAAG,aAAa,EAAE,CAAC;IACtC,QAAQ,CAAC,iCAAiC,OAAO,wBAAwB,aAAa,GAAG,CAAC,CAAC;IAE3F,MAAM,iBAAiB,CAAC;QACtB,MAAM,EAAE;YACN,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,aAAa;YACnC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,+BAA+B;YACnE,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,YAAY;YACZ,8DAA8D;YAC9D,UAAU,EAAE,MAAM,CAAC,UAAiB;YACpC,sFAAsF;YACtF,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC;QACD,aAAa;KACd,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module tools/shell/allowlist
|
|
3
|
-
*
|
|
4
|
-
* Re-export of the EXT-9 Tier-2 allow-list engine. The implementation lives in
|
|
5
|
-
* `@gaunt-sloth/core` (`core/shell/allowlist`) because the core {@link GthAgentRunner}
|
|
6
|
-
* owns the per-instance session store and the loaded persisted store and consults
|
|
7
|
-
* `matchesApproval` before prompting (core cannot import from `@gaunt-sloth/agent`).
|
|
8
|
-
*
|
|
9
|
-
* See the core module for the exact safe-bin / anti-widening matching rule.
|
|
10
|
-
*/
|
|
11
|
-
export { matchesApproval, hasWideningFlag, AllowlistStore, PersistedAllowlist, type ApprovalScope, type ApprovalStores, } from '@gaunt-sloth/core/core/shell/allowlist.js';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module tools/shell/allowlist
|
|
3
|
-
*
|
|
4
|
-
* Re-export of the EXT-9 Tier-2 allow-list engine. The implementation lives in
|
|
5
|
-
* `@gaunt-sloth/core` (`core/shell/allowlist`) because the core {@link GthAgentRunner}
|
|
6
|
-
* owns the per-instance session store and the loaded persisted store and consults
|
|
7
|
-
* `matchesApproval` before prompting (core cannot import from `@gaunt-sloth/agent`).
|
|
8
|
-
*
|
|
9
|
-
* See the core module for the exact safe-bin / anti-widening matching rule.
|
|
10
|
-
*/
|
|
11
|
-
export { matchesApproval, hasWideningFlag, AllowlistStore, PersistedAllowlist, } from '@gaunt-sloth/core/core/shell/allowlist.js';
|
|
12
|
-
//# sourceMappingURL=allowlist.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"allowlist.js","sourceRoot":"","sources":["../../../src/tools/shell/allowlist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,EACd,kBAAkB,GAGnB,MAAM,2CAA2C,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module tools/shell/arity
|
|
3
|
-
*
|
|
4
|
-
* Re-export of the EXT-9 Tier-2 command classifier. The implementation lives in
|
|
5
|
-
* `@gaunt-sloth/core` (`core/shell/arity`) because the core {@link GthAgentRunner}
|
|
6
|
-
* must consult it BEFORE prompting (and core cannot import from `@gaunt-sloth/agent`).
|
|
7
|
-
* This stable agent-side path is kept for tests and any agent-layer consumers.
|
|
8
|
-
*
|
|
9
|
-
* See the core module for the arity table scope and the anti-injection fail-closed rule.
|
|
10
|
-
*/
|
|
11
|
-
export { classifyCommand, tokenize, meaningfulPrefixTokens, type CommandClassification, } from '@gaunt-sloth/core/core/shell/arity.js';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module tools/shell/arity
|
|
3
|
-
*
|
|
4
|
-
* Re-export of the EXT-9 Tier-2 command classifier. The implementation lives in
|
|
5
|
-
* `@gaunt-sloth/core` (`core/shell/arity`) because the core {@link GthAgentRunner}
|
|
6
|
-
* must consult it BEFORE prompting (and core cannot import from `@gaunt-sloth/agent`).
|
|
7
|
-
* This stable agent-side path is kept for tests and any agent-layer consumers.
|
|
8
|
-
*
|
|
9
|
-
* See the core module for the arity table scope and the anti-injection fail-closed rule.
|
|
10
|
-
*/
|
|
11
|
-
export { classifyCommand, tokenize, meaningfulPrefixTokens, } from '@gaunt-sloth/core/core/shell/arity.js';
|
|
12
|
-
//# sourceMappingURL=arity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arity.js","sourceRoot":"","sources":["../../../src/tools/shell/arity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,eAAe,EACf,QAAQ,EACR,sBAAsB,GAEvB,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hardline patterns: [regex, human description]. Matched case-insensitively
|
|
3
|
-
* against the normalized command.
|
|
4
|
-
*/
|
|
5
|
-
export declare const HARDLINE_PATTERNS: ReadonlyArray<readonly [RegExp, string]>;
|
|
6
|
-
export interface HardlineMatch {
|
|
7
|
-
/** Human-readable reason the command was refused. */
|
|
8
|
-
description: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Check a raw command against the hardline blocklist. Normalizes first so
|
|
12
|
-
* obfuscated variants are caught. Returns the match (with a description) when the
|
|
13
|
-
* command is catastrophic, or `null` when it is allowed to proceed.
|
|
14
|
-
*/
|
|
15
|
-
export declare function checkHardline(command: string): HardlineMatch | null;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module tools/shell/hardline
|
|
3
|
-
*
|
|
4
|
-
* Unbypassable hardline blocklist for the shell tool. These are catastrophic,
|
|
5
|
-
* non-recoverable commands (wipe the root filesystem, format a disk, overwrite a
|
|
6
|
-
* raw block device, fork-bomb, take the host down). They are refused inside
|
|
7
|
-
* `executeCommand` itself — BEFORE spawn — so the refusal fires regardless of
|
|
8
|
-
* yolo (`shellYolo`), any allow-list, or the confirmation path. yolo deliberately
|
|
9
|
-
* bypasses the *confirmation*; it does NOT bypass this floor.
|
|
10
|
-
*
|
|
11
|
-
* Recoverable-but-costly operations (e.g. `git reset --hard`, `rm -rf ./build`,
|
|
12
|
-
* `chmod -R 777 ./dir`, `curl | sh`) are intentionally NOT here — those are what
|
|
13
|
-
* the confirmation dialog / yolo are for.
|
|
14
|
-
*
|
|
15
|
-
* Patterns match the NORMALIZED command ({@link ./normalize.js}) so obfuscation
|
|
16
|
-
* (ANSI/fullwidth/backslash splits/whitespace padding) cannot bypass them.
|
|
17
|
-
*
|
|
18
|
-
* Patterned after hermes-agent `tools/approval.py` HARDLINE_PATTERNS.
|
|
19
|
-
*/
|
|
20
|
-
import { normalizeCommand } from '#src/tools/shell/normalize.js';
|
|
21
|
-
// Matches a position where the shell would begin parsing a NEW command: start of
|
|
22
|
-
// string, after a separator (; & | newline), after `$(` or backtick, optionally
|
|
23
|
-
// consuming leading wrappers (sudo/env VAR=VAL/exec/nohup/setsid/time). Used by
|
|
24
|
-
// the shutdown-family patterns so they don't false-positive on `echo reboot`.
|
|
25
|
-
const CMD_POS = '(?:^|[;&|\\n`]|\\$\\()' +
|
|
26
|
-
'\\s*' +
|
|
27
|
-
'(?:sudo\\s+(?:-[^\\s]+\\s+)*)?' +
|
|
28
|
-
'(?:env\\s+(?:\\w+=\\S*\\s+)*)?' +
|
|
29
|
-
'(?:(?:exec|nohup|setsid|time)\\s+)*' +
|
|
30
|
-
'\\s*';
|
|
31
|
-
/**
|
|
32
|
-
* Hardline patterns: [regex, human description]. Matched case-insensitively
|
|
33
|
-
* against the normalized command.
|
|
34
|
-
*/
|
|
35
|
-
export const HARDLINE_PATTERNS = [
|
|
36
|
-
// rm -rf targeting the root filesystem (`/`, `/*`).
|
|
37
|
-
[/\brm\s+(?:-[^\s]*\s+)*\/\s*\*?\s*(?:$|[;&|])/, 'recursive delete of root filesystem'],
|
|
38
|
-
// rm -rf targeting protected system directories (with optional /* suffix).
|
|
39
|
-
[
|
|
40
|
-
/\brm\s+(?:-[^\s]*\s+)*(?:\/(?:home|root|etc|usr|var|bin|sbin|boot|lib|lib64|opt|sys|proc))(?:\/\*)?\s*(?:$|[;&|])/,
|
|
41
|
-
'recursive delete of system directory',
|
|
42
|
-
],
|
|
43
|
-
// rm -rf targeting the home directory (~ or $HOME).
|
|
44
|
-
// Note: patterns match the LOWERCASED normalized command, so $HOME → $home.
|
|
45
|
-
[
|
|
46
|
-
/\brm\s+(?:-[^\s]*\s+)*(?:~|\$home)(?:\/\*)?\s*(?:$|[;&|])/,
|
|
47
|
-
'recursive delete of home directory',
|
|
48
|
-
],
|
|
49
|
-
// Filesystem format.
|
|
50
|
-
[/\bmkfs(?:\.[a-z0-9]+)?\b/, 'format filesystem (mkfs)'],
|
|
51
|
-
// dd writing to a raw block device.
|
|
52
|
-
[/\bdd\b[^\n]*\bof=\/dev\/(?:sd|nvme|hd|mmcblk|vd|xvd)[a-z0-9]*/, 'dd to raw block device'],
|
|
53
|
-
// Shell redirection to a raw block device (`> /dev/sda`).
|
|
54
|
-
[/>\s*\/dev\/(?:sd|nvme|hd|mmcblk|vd|xvd)[a-z0-9]*\b/, 'redirect to raw block device'],
|
|
55
|
-
// Classic fork bomb `:(){ :|:& };:`.
|
|
56
|
-
[/:\s*\(\s*\)\s*\{\s*:\s*\|\s*:\s*&\s*\}\s*;\s*:/, 'fork bomb'],
|
|
57
|
-
// chmod -R 777 / (recursive world-writable on root).
|
|
58
|
-
[
|
|
59
|
-
/\bchmod\s+(?:-[^\s]*\s+)*(?:-r|--recursive)\s+(?:-[^\s]*\s+)*777\s+\//,
|
|
60
|
-
'recursive chmod 777 of root',
|
|
61
|
-
],
|
|
62
|
-
// Kill every process on the system (`kill -1`, `kill -9 -1`).
|
|
63
|
-
[/\bkill\s+(?:-[^\s]+\s+)*-1\b/, 'kill all processes'],
|
|
64
|
-
// System shutdown / reboot — anchored to a command position so `echo reboot`
|
|
65
|
-
// and `grep shutdown log` don't trip it.
|
|
66
|
-
[new RegExp(CMD_POS + '(?:shutdown|reboot|halt|poweroff)\\b'), 'system shutdown/reboot'],
|
|
67
|
-
[new RegExp(CMD_POS + 'init\\s+[06]\\b'), 'init 0/6 (shutdown/reboot)'],
|
|
68
|
-
[
|
|
69
|
-
new RegExp(CMD_POS + 'systemctl\\s+(?:poweroff|reboot|halt|kexec)\\b'),
|
|
70
|
-
'systemctl poweroff/reboot',
|
|
71
|
-
],
|
|
72
|
-
[new RegExp(CMD_POS + 'telinit\\s+[06]\\b'), 'telinit 0/6 (shutdown/reboot)'],
|
|
73
|
-
];
|
|
74
|
-
/**
|
|
75
|
-
* Check a raw command against the hardline blocklist. Normalizes first so
|
|
76
|
-
* obfuscated variants are caught. Returns the match (with a description) when the
|
|
77
|
-
* command is catastrophic, or `null` when it is allowed to proceed.
|
|
78
|
-
*/
|
|
79
|
-
export function checkHardline(command) {
|
|
80
|
-
const normalized = normalizeCommand(command).toLowerCase();
|
|
81
|
-
for (const [pattern, description] of HARDLINE_PATTERNS) {
|
|
82
|
-
if (pattern.test(normalized)) {
|
|
83
|
-
return { description };
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=hardline.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hardline.js","sourceRoot":"","sources":["../../../src/tools/shell/hardline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,iFAAiF;AACjF,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,MAAM,OAAO,GACX,wBAAwB;IACxB,MAAM;IACN,gCAAgC;IAChC,gCAAgC;IAChC,qCAAqC;IACrC,MAAM,CAAC;AAET;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA6C;IACzE,oDAAoD;IACpD,CAAC,8CAA8C,EAAE,qCAAqC,CAAC;IACvF,2EAA2E;IAC3E;QACE,mHAAmH;QACnH,sCAAsC;KACvC;IACD,oDAAoD;IACpD,4EAA4E;IAC5E;QACE,2DAA2D;QAC3D,oCAAoC;KACrC;IACD,qBAAqB;IACrB,CAAC,0BAA0B,EAAE,0BAA0B,CAAC;IACxD,oCAAoC;IACpC,CAAC,+DAA+D,EAAE,wBAAwB,CAAC;IAC3F,0DAA0D;IAC1D,CAAC,oDAAoD,EAAE,8BAA8B,CAAC;IACtF,qCAAqC;IACrC,CAAC,gDAAgD,EAAE,WAAW,CAAC;IAC/D,qDAAqD;IACrD;QACE,uEAAuE;QACvE,6BAA6B;KAC9B;IACD,8DAA8D;IAC9D,CAAC,8BAA8B,EAAE,oBAAoB,CAAC;IACtD,6EAA6E;IAC7E,yCAAyC;IACzC,CAAC,IAAI,MAAM,CAAC,OAAO,GAAG,sCAAsC,CAAC,EAAE,wBAAwB,CAAC;IACxF,CAAC,IAAI,MAAM,CAAC,OAAO,GAAG,iBAAiB,CAAC,EAAE,4BAA4B,CAAC;IACvE;QACE,IAAI,MAAM,CAAC,OAAO,GAAG,gDAAgD,CAAC;QACtE,2BAA2B;KAC5B;IACD,CAAC,IAAI,MAAM,CAAC,OAAO,GAAG,oBAAoB,CAAC,EAAE,+BAA+B,CAAC;CAC9E,CAAC;AAOF;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3D,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,iBAAiB,EAAE,CAAC;QACvD,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7B,OAAO,EAAE,WAAW,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module tools/shell/normalize
|
|
3
|
-
*
|
|
4
|
-
* Re-export of the canonical command normalizer, which now lives in
|
|
5
|
-
* `@gaunt-sloth/core` (`core/shell/normalize`) so the core runner's EXT-9 Tier-2
|
|
6
|
-
* allow-list classifier and the agent's Tier-1 hardline blocklist share ONE
|
|
7
|
-
* implementation. Kept as a stable import path for existing agent-side consumers
|
|
8
|
-
* (`tools/shell/hardline`, specs).
|
|
9
|
-
*/
|
|
10
|
-
export { normalizeCommand } from '@gaunt-sloth/core/core/shell/normalize.js';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module tools/shell/normalize
|
|
3
|
-
*
|
|
4
|
-
* Re-export of the canonical command normalizer, which now lives in
|
|
5
|
-
* `@gaunt-sloth/core` (`core/shell/normalize`) so the core runner's EXT-9 Tier-2
|
|
6
|
-
* allow-list classifier and the agent's Tier-1 hardline blocklist share ONE
|
|
7
|
-
* implementation. Kept as a stable import path for existing agent-side consumers
|
|
8
|
-
* (`tools/shell/hardline`, specs).
|
|
9
|
-
*/
|
|
10
|
-
export { normalizeCommand } from '@gaunt-sloth/core/core/shell/normalize.js';
|
|
11
|
-
//# sourceMappingURL=normalize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../../src/tools/shell/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC"}
|