@code-yeongyu/senpi 2026.11.15-2 → 2026.11.15-3
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/CHANGELOG.md +19 -0
- package/dist/bundle/chunks/{chunk-Q4RJ4WLE.js → chunk-225TDKTA.js} +4 -4
- package/dist/bundle/chunks/{chunk-QSU2456D.js → chunk-3KR3CDGM.js} +1 -1
- package/dist/bundle/chunks/{chunk-AOTHPTMU.js → chunk-5GCZFK4X.js} +2 -2
- package/dist/bundle/chunks/{chunk-BMADOJHZ.js → chunk-5QIFH624.js} +1 -1
- package/dist/bundle/chunks/{chunk-THYIV26N.js → chunk-GQEXLLWJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-3RILB2OD.js → chunk-OJOPOUAY.js} +9 -9
- package/dist/bundle/chunks/{chunk-64FJ4QQJ.js → chunk-PPCAJQDJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-74HCKLRH.js → chunk-TEXE4HT6.js} +1 -1
- package/dist/bundle/chunks/{chunk-RRFDLGX6.js → chunk-TNYFCGI7.js} +156 -156
- package/dist/bundle/chunks/{cli-main-GNQY2LTU.js → cli-main-CV3ODX4A.js} +1 -1
- package/dist/bundle/chunks/{hand-entry-D3DNH6XL.js → hand-entry-2NN7ZTY6.js} +1 -1
- package/dist/bundle/chunks/{interactive-mode-ATBPY4M5.js → interactive-mode-TGHZWM2T.js} +1 -1
- package/dist/bundle/chunks/{main-OMFVSMUR.js → main-B7WEY4JW.js} +1 -1
- package/dist/bundle/chunks/{multi-session-host-ACQ5N4UB.js → multi-session-host-53YLL2OD.js} +1 -1
- package/dist/bundle/chunks/{package-manager-cli-2VMRV4HL.js → package-manager-cli-2U54AVKW.js} +1 -1
- package/dist/bundle/chunks/{role-BTH5PVME.js → role-4IXZZAL4.js} +1 -1
- package/dist/bundle/chunks/{rpc-mode-XUK5SYKH.js → rpc-mode-RRYXENML.js} +1 -1
- package/dist/bundle/chunks/{runtime-session-VO3X4OE3.js → runtime-session-KKHEYZOH.js} +1 -1
- package/dist/bundle/chunks/{session-control-endpoint-Y5EIFFPY.js → session-control-endpoint-HVULSIUR.js} +1 -1
- package/dist/bundle/chunks/session-worker.js +331 -331
- package/dist/bundle/cli.js +2 -2
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/bundle/runtime-manifest.json +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.js +34 -3
- package/dist/core/extensions/builtin/anthropic-subscription/auth-lane.d.ts +2 -0
- package/dist/core/extensions/builtin/anthropic-subscription/auth-lane.js +1 -0
- package/dist/core/extensions/builtin/anthropic-subscription/failover.d.ts +2 -0
- package/dist/core/extensions/builtin/anthropic-subscription/failover.js +22 -4
- package/dist/core/extensions/builtin/anthropic-subscription/index.js +7 -2
- package/dist/core/extensions/builtin/anthropic-subscription/limit-recheck.d.ts +15 -0
- package/dist/core/extensions/builtin/anthropic-subscription/limit-recheck.js +55 -0
- package/dist/core/extensions/builtin/anthropic-subscription/session-stream.d.ts +1 -0
- package/dist/core/extensions/builtin/anthropic-subscription/session-stream.js +1 -0
- package/dist/core/extensions/builtin/anthropic-subscription/stream-guidance.js +8 -5
- package/dist/core/extensions/builtin/anthropic-subscription/stream.d.ts +1 -1
- package/dist/core/extensions/builtin/anthropic-subscription/stream.js +3 -1
- package/dist/core/extensions/builtin/terminal/extension-state.js +15 -0
- package/dist/core/extensions/builtin/terminal/notify.d.ts +2 -1
- package/dist/core/extensions/builtin/terminal/notify.js +15 -6
- package/dist/core/extensions/builtin/terminal/session-bundle.d.ts +5 -1
- package/dist/core/extensions/builtin/terminal/session-bundle.js +41 -1
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts +4 -0
- package/dist/core/extensions/loader.js +5 -0
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.js +5 -0
- package/dist/core/extensions/types.d.ts +7 -0
- package/dist/core/run-background-jobs.d.ts +33 -0
- package/dist/core/run-background-jobs.js +47 -0
- package/dist/core/tools/bash-core.d.ts +50 -0
- package/dist/core/tools/bash-core.js +169 -0
- package/dist/core/tools/bash-schema.d.ts +48 -0
- package/dist/core/tools/bash-schema.js +34 -0
- package/dist/core/tools/bash.d.ts +4 -70
- package/dist/core/tools/bash.js +32 -409
- package/dist/core/tools/coding-tools-core.d.ts +24 -0
- package/dist/core/tools/coding-tools-core.js +14 -0
- package/dist/core/tools/edit-core.d.ts +56 -0
- package/dist/core/tools/edit-core.js +175 -0
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.js +0 -32
- package/dist/core/tools/edit-preview.d.ts +7 -0
- package/dist/core/tools/edit-preview.js +34 -0
- package/dist/core/tools/edit.d.ts +5 -43
- package/dist/core/tools/edit.js +10 -158
- package/dist/core/tools/encoding.d.ts +10 -0
- package/dist/core/tools/encoding.js +58 -0
- package/dist/core/tools/file-tool-host.d.ts +25 -0
- package/dist/core/tools/file-tool-host.js +109 -0
- package/dist/core/tools/fs-error-code.d.ts +2 -0
- package/dist/core/tools/fs-error-code.js +15 -0
- package/dist/core/tools/machine-output-spill.d.ts +11 -0
- package/dist/core/tools/machine-output-spill.js +65 -0
- package/dist/core/tools/machine.d.ts +4 -24
- package/dist/core/tools/machine.js +4 -44
- package/dist/core/tools/output-accumulator-core.d.ts +84 -0
- package/dist/core/tools/output-accumulator-core.js +200 -0
- package/dist/core/tools/output-accumulator.d.ts +9 -61
- package/dist/core/tools/output-accumulator.js +90 -265
- package/dist/core/tools/path-utils.js +3 -48
- package/dist/core/tools/posix-signals.d.ts +3 -0
- package/dist/core/tools/posix-signals.js +113 -0
- package/dist/core/tools/read-core.d.ts +64 -0
- package/dist/core/tools/read-core.js +180 -0
- package/dist/core/tools/read-text.d.ts +23 -0
- package/dist/core/tools/read-text.js +90 -0
- package/dist/core/tools/read.d.ts +6 -47
- package/dist/core/tools/read.js +13 -218
- package/dist/core/tools/renderers/bash.d.ts +0 -1
- package/dist/core/tools/renderers/bash.js +0 -1
- package/dist/core/tools/renderers/edit.d.ts +1 -1
- package/dist/core/tools/renderers/edit.js +1 -1
- package/dist/core/tools/secret-output-redactor.js +2 -1
- package/dist/core/tools/shell-operations.d.ts +53 -0
- package/dist/core/tools/shell-operations.js +115 -0
- package/dist/core/tools/shell-output.d.ts +20 -0
- package/dist/core/tools/shell-output.js +152 -0
- package/dist/core/tools/tail-window.js +5 -7
- package/dist/core/tools/tool-machine.d.ts +30 -0
- package/dist/core/tools/tool-machine.js +47 -0
- package/dist/core/tools/truncate.js +15 -14
- package/dist/core/tools/write-core.d.ts +47 -0
- package/dist/core/tools/write-core.js +108 -0
- package/dist/core/tools/write-result.d.ts +0 -1
- package/dist/core/tools/write-result.js +0 -13
- package/dist/core/tools/write.d.ts +6 -31
- package/dist/core/tools/write.js +25 -77
- package/dist/core/turn-origin.d.ts +4 -2
- package/dist/core/turn-origin.js +15 -8
- package/dist/modes/interactive/session-control-session-commands.js +1 -1
- package/dist/modes/rpc/connection-handler.js +2 -2
- package/dist/modes/rpc/effect-commands.d.ts +1 -4
- package/dist/modes/rpc/method-classes-schema-session.d.ts +1 -0
- package/dist/modes/rpc/method-classes-schema-session.js +5 -1
- package/dist/modes/rpc/method-classes-schema.d.ts +1 -0
- package/dist/modes/rpc/pause-command-validation.js +2 -0
- package/dist/modes/rpc/rpc-mutation-response-types.d.ts +2 -4
- package/dist/modes/rpc/rpc-session-command-types.d.ts +1 -0
- package/dist/modes/rpc/session-control-actions-data.d.ts +7 -3
- package/dist/modes/rpc/session-control-actions-data.js +12 -6
- package/dist/tools-core.d.ts +14 -0
- package/dist/tools-core.js +9 -0
- package/dist/utils/image-mime.d.ts +4 -0
- package/dist/utils/image-mime.js +99 -0
- package/dist/utils/mime.d.ts +1 -1
- package/dist/utils/mime.js +2 -97
- package/docs/extensions.md +7 -1
- package/docs/rpc.md +14 -0
- package/package.json +11 -7
- package/vendor/senpi-machine-ops/files/local-files.js +34 -5
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { bashOutputSchema, bashSchema, bashToolConfig, } from "./bash-schema.js";
|
|
2
|
+
import { createMachineOutputSpill } from "./machine-output-spill.js";
|
|
3
|
+
import { OutputAccumulator } from "./output-accumulator-core.js";
|
|
4
|
+
import { createShellOutput } from "./shell-output.js";
|
|
5
|
+
import { createShellOperations, machineShellExecHost } from "./shell-operations.js";
|
|
6
|
+
import { wrapToolDefinition } from "./tool-definition-wrapper.js";
|
|
7
|
+
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES } from "./truncate.js";
|
|
8
|
+
/** Output limit of `structuredContent.output`, which programmatic callers such as codemode scripts receive. */
|
|
9
|
+
const STRUCTURED_OUTPUT_MAX_BYTES = 1024 * 1024;
|
|
10
|
+
function resolveSpawnContext(command, cwd, baseEnv, spawnHook, exposeSessionEnvironment, ctx) {
|
|
11
|
+
const env = { ...baseEnv };
|
|
12
|
+
delete env.PI_SESSION_ID;
|
|
13
|
+
delete env.PI_SESSION_FILE;
|
|
14
|
+
delete env.PI_SESSION_CWD;
|
|
15
|
+
delete env.PI_GOAL_STORE_FILE;
|
|
16
|
+
delete env.PI_PROVIDER;
|
|
17
|
+
delete env.PI_MODEL;
|
|
18
|
+
delete env.PI_REASONING_LEVEL;
|
|
19
|
+
delete env.OMO_BROWSER_ENGINE;
|
|
20
|
+
if (exposeSessionEnvironment && ctx) {
|
|
21
|
+
const model = ctx.model;
|
|
22
|
+
env.PI_SESSION_ID = ctx.sessionManager.getSessionId();
|
|
23
|
+
env.PI_SESSION_CWD = ctx.cwd;
|
|
24
|
+
if (ctx.goalStoreFile)
|
|
25
|
+
env.PI_GOAL_STORE_FILE = ctx.goalStoreFile;
|
|
26
|
+
const sessionFile = ctx.sessionManager.getSessionFile();
|
|
27
|
+
if (sessionFile)
|
|
28
|
+
env.PI_SESSION_FILE = sessionFile;
|
|
29
|
+
if (model) {
|
|
30
|
+
env.PI_PROVIDER = model.provider;
|
|
31
|
+
env.PI_MODEL = model.id;
|
|
32
|
+
}
|
|
33
|
+
if (ctx.thinkingLevel)
|
|
34
|
+
env.PI_REASONING_LEVEL = ctx.thinkingLevel;
|
|
35
|
+
if (ctx.browserEngine)
|
|
36
|
+
env.OMO_BROWSER_ENGINE = ctx.browserEngine;
|
|
37
|
+
Object.assign(env, ctx.sessionEnv);
|
|
38
|
+
}
|
|
39
|
+
const baseContext = { command, cwd, env };
|
|
40
|
+
return spawnHook ? spawnHook(baseContext) : baseContext;
|
|
41
|
+
}
|
|
42
|
+
const appendStatus = (text, status) => `${text ? `${text}\n\n` : ""}${status}`;
|
|
43
|
+
/** A shell tool's model-facing definition and execution, without renderers: the shared core of bash and powershell. */
|
|
44
|
+
export function createShellToolCore(cwd, config, options) {
|
|
45
|
+
const { machine, operations: ops, commandPrefix, spawnHook, annotateTrust } = options;
|
|
46
|
+
const exposeSessionEnvironment = options.exposeSessionEnvironment ?? true;
|
|
47
|
+
const redactSecretsInOutput = options.redactSecretsInOutput === true;
|
|
48
|
+
return {
|
|
49
|
+
name: config.name,
|
|
50
|
+
label: config.label,
|
|
51
|
+
description: `Execute a ${config.shellName} command in the current working directory. Returns stdout and stderr. Output is truncated to last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). If truncated, full output is saved to a temp file. Optionally provide a timeout in seconds.`,
|
|
52
|
+
promptSnippet: config.promptSnippet,
|
|
53
|
+
promptGuidelines: exposeSessionEnvironment && config.promptGuidelines ? [...config.promptGuidelines] : undefined,
|
|
54
|
+
fullPromptGuidelines: exposeSessionEnvironment && config.fullPromptGuidelines ? [...config.fullPromptGuidelines] : undefined,
|
|
55
|
+
parameters: bashSchema,
|
|
56
|
+
outputSchema: bashOutputSchema,
|
|
57
|
+
constrainedSampling: { type: "json_schema", strict: "prefer" },
|
|
58
|
+
async execute(_toolCallId, { command, timeout }, signal, onUpdate, ctx) {
|
|
59
|
+
const admitted = machine.begin("process.exec", { command, timeout }, signal);
|
|
60
|
+
if (admitted !== undefined)
|
|
61
|
+
await admitted;
|
|
62
|
+
const resolvedCommand = commandPrefix ? `${commandPrefix}\n${command}` : command;
|
|
63
|
+
const spawnContext = resolveSpawnContext(resolvedCommand, ctx?.cwd || cwd, options.shellEnv?.() ?? {}, spawnHook, exposeSessionEnvironment, ctx);
|
|
64
|
+
const output = new OutputAccumulator({ tempFilePrefix: config.tempFilePrefix, spill: options.outputSpill });
|
|
65
|
+
const shellOutput = createShellOutput(output, onUpdate, redactSecretsInOutput);
|
|
66
|
+
if (onUpdate) {
|
|
67
|
+
onUpdate({ content: [], details: undefined });
|
|
68
|
+
}
|
|
69
|
+
const startedAt = performance.now();
|
|
70
|
+
try {
|
|
71
|
+
let exitCode;
|
|
72
|
+
try {
|
|
73
|
+
const result = await ops.exec(spawnContext.command, spawnContext.cwd, {
|
|
74
|
+
onData: shellOutput.handleData,
|
|
75
|
+
redactSecretsInOutput,
|
|
76
|
+
signal,
|
|
77
|
+
timeout,
|
|
78
|
+
env: spawnContext.env,
|
|
79
|
+
});
|
|
80
|
+
exitCode = result.exitCode;
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
let snapshot;
|
|
84
|
+
try {
|
|
85
|
+
snapshot = await shellOutput.finishOutput();
|
|
86
|
+
}
|
|
87
|
+
catch (cleanupError) {
|
|
88
|
+
throw new AggregateError([err, cleanupError], "Bash command and output cleanup failed");
|
|
89
|
+
}
|
|
90
|
+
const { text } = shellOutput.formatOutput(snapshot, "");
|
|
91
|
+
if (err instanceof Error && err.message === "aborted") {
|
|
92
|
+
throw new Error(appendStatus(text, "Command aborted"));
|
|
93
|
+
}
|
|
94
|
+
if (err instanceof Error && err.message.startsWith("timeout:")) {
|
|
95
|
+
const timeoutSecs = err.message.split(":")[1];
|
|
96
|
+
throw new Error(appendStatus(text, `Command timed out after ${timeoutSecs} seconds`));
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
await output.removeTempFile();
|
|
100
|
+
}
|
|
101
|
+
catch (unlinkError) {
|
|
102
|
+
throw new AggregateError([err, unlinkError], "Bash command and output cleanup failed");
|
|
103
|
+
}
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
106
|
+
const snapshot = await shellOutput.finishOutput();
|
|
107
|
+
const { text: outputText, content, details } = shellOutput.formatOutput(snapshot);
|
|
108
|
+
if (exitCode === null) {
|
|
109
|
+
throw new Error(appendStatus(outputText, "Command terminated without an exit code"));
|
|
110
|
+
}
|
|
111
|
+
const wallTimeSeconds = Math.round((performance.now() - startedAt) / 100) / 10;
|
|
112
|
+
const fullOutput = await output.readFullOutput(STRUCTURED_OUTPUT_MAX_BYTES);
|
|
113
|
+
const structuredContent = {
|
|
114
|
+
output: fullOutput.content,
|
|
115
|
+
truncated: fullOutput.truncated,
|
|
116
|
+
...(fullOutput.truncated && snapshot.fullOutputPath
|
|
117
|
+
? { full_output_path: snapshot.fullOutputPath }
|
|
118
|
+
: {}),
|
|
119
|
+
exit_code: exitCode,
|
|
120
|
+
wall_time_seconds: wallTimeSeconds,
|
|
121
|
+
};
|
|
122
|
+
if (exitCode !== 0) {
|
|
123
|
+
const text = appendStatus(outputText, `Command exited with code ${exitCode}`);
|
|
124
|
+
// The engine trust annotation (omo#10762) rides only on error results, so the success
|
|
125
|
+
// `outputSchema` (and the prompt bytes it costs) stays unchanged.
|
|
126
|
+
const annotation = annotateTrust?.({ exitCode, output: fullOutput.content });
|
|
127
|
+
if (annotation === undefined) {
|
|
128
|
+
return { content: [{ type: "text", text }], details, structuredContent, isError: true };
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
content: [
|
|
132
|
+
{ type: "text", text: annotation.text === undefined ? text : `${text}\n\n${annotation.text}` },
|
|
133
|
+
],
|
|
134
|
+
details: { ...details, trust: annotation.trust },
|
|
135
|
+
structuredContent: { ...structuredContent, trust: annotation.trust },
|
|
136
|
+
isError: true,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
// Success keeps the fork's model-only truncation notice; the error text above carries it inline.
|
|
140
|
+
return { content, details, structuredContent };
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
shellOutput.clearUpdateTimer();
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/** The bash tool for a host whose only effect channel is `machine`. */
|
|
149
|
+
export function createCoreBashToolDefinition(cwd, options) {
|
|
150
|
+
const { machine } = options;
|
|
151
|
+
return {
|
|
152
|
+
...createShellToolCore(cwd, bashToolConfig, {
|
|
153
|
+
...options,
|
|
154
|
+
operations: options.operations ?? createShellOperations("bash", machine, machineShellExecHost(machine, options.shell)),
|
|
155
|
+
outputSpill: options.outputSpill ?? createMachineOutputSpill(machine),
|
|
156
|
+
}),
|
|
157
|
+
exposure: "eval",
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
export function createCoreBashTool(cwd, options) {
|
|
161
|
+
const definition = createCoreBashToolDefinition(cwd, options);
|
|
162
|
+
const tool = wrapToolDefinition(definition);
|
|
163
|
+
Object.assign(tool, {
|
|
164
|
+
promptSnippet: definition.promptSnippet,
|
|
165
|
+
promptGuidelines: definition.promptGuidelines,
|
|
166
|
+
});
|
|
167
|
+
return tool;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=bash-core.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
import type { ShellTrust } from "../../engine-trust/shell-trust.ts";
|
|
3
|
+
import type { TruncationResult } from "./truncate.ts";
|
|
4
|
+
export declare const bashSchema: Type.TObject<{
|
|
5
|
+
command: Type.TString;
|
|
6
|
+
timeout: Type.TOptional<Type.TNumber>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const bashToolSystemPromptContribution: {
|
|
9
|
+
readonly snippet: "Execute bash commands (ls, rg, find, etc.)";
|
|
10
|
+
readonly guidelines: readonly ["PI_* env vars = current model + session details."];
|
|
11
|
+
readonly fullGuidelines: readonly ["You can inspect PI_* environment variables for current model and session details."];
|
|
12
|
+
};
|
|
13
|
+
export type BashToolInput = Static<typeof bashSchema>;
|
|
14
|
+
/**
|
|
15
|
+
* Result for programmatic callers such as codemode scripts. A non-zero exit code is an error result for the model, but scripts still resolve to this value.
|
|
16
|
+
* `output` is not limited like the model-facing output: callers decide how much of it reaches the model.
|
|
17
|
+
*/
|
|
18
|
+
export declare const bashOutputSchema: Type.TObject<{
|
|
19
|
+
output: Type.TString;
|
|
20
|
+
truncated: Type.TBoolean;
|
|
21
|
+
full_output_path: Type.TOptional<Type.TString>;
|
|
22
|
+
exit_code: Type.TNumber;
|
|
23
|
+
wall_time_seconds: Type.TNumber;
|
|
24
|
+
}>;
|
|
25
|
+
export type BashToolOutput = Static<typeof bashOutputSchema>;
|
|
26
|
+
export interface BashToolDetails {
|
|
27
|
+
truncation?: TruncationResult;
|
|
28
|
+
fullOutputPath?: string;
|
|
29
|
+
trust?: ShellTrust;
|
|
30
|
+
}
|
|
31
|
+
export interface BashSpawnContext {
|
|
32
|
+
command: string;
|
|
33
|
+
cwd: string;
|
|
34
|
+
env: NodeJS.ProcessEnv;
|
|
35
|
+
}
|
|
36
|
+
export type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;
|
|
37
|
+
export interface ShellToolConfig {
|
|
38
|
+
name: string;
|
|
39
|
+
label: string;
|
|
40
|
+
shellName: string;
|
|
41
|
+
prompt: string;
|
|
42
|
+
promptSnippet: string;
|
|
43
|
+
promptGuidelines?: readonly string[];
|
|
44
|
+
fullPromptGuidelines?: readonly string[];
|
|
45
|
+
tempFilePrefix: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const bashToolConfig: ShellToolConfig;
|
|
48
|
+
//# sourceMappingURL=bash-schema.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
export const bashSchema = Type.Object({
|
|
3
|
+
command: Type.String({ description: "Shell command to execute" }),
|
|
4
|
+
timeout: Type.Optional(Type.Number({ description: "Timeout in seconds (optional, no default timeout)" })),
|
|
5
|
+
});
|
|
6
|
+
export const bashToolSystemPromptContribution = {
|
|
7
|
+
snippet: "Execute bash commands (ls, rg, find, etc.)",
|
|
8
|
+
guidelines: ["PI_* env vars = current model + session details."],
|
|
9
|
+
fullGuidelines: ["You can inspect PI_* environment variables for current model and session details."],
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Result for programmatic callers such as codemode scripts. A non-zero exit code is an error result for the model, but scripts still resolve to this value.
|
|
13
|
+
* `output` is not limited like the model-facing output: callers decide how much of it reaches the model.
|
|
14
|
+
*/
|
|
15
|
+
export const bashOutputSchema = Type.Object({
|
|
16
|
+
output: Type.String({
|
|
17
|
+
description: "Combined stdout and stderr, up to 1 MiB. Longer output keeps its first and last 512 KiB around an omission marker.",
|
|
18
|
+
}),
|
|
19
|
+
truncated: Type.Boolean({ description: "Whether `output` omits part of the command output" }),
|
|
20
|
+
full_output_path: Type.Optional(Type.String({ description: "Temp file with the full output, when truncated" })),
|
|
21
|
+
exit_code: Type.Number(),
|
|
22
|
+
wall_time_seconds: Type.Number(),
|
|
23
|
+
});
|
|
24
|
+
export const bashToolConfig = {
|
|
25
|
+
name: "bash",
|
|
26
|
+
label: "bash",
|
|
27
|
+
shellName: "bash",
|
|
28
|
+
prompt: "$",
|
|
29
|
+
promptSnippet: bashToolSystemPromptContribution.snippet,
|
|
30
|
+
promptGuidelines: bashToolSystemPromptContribution.guidelines,
|
|
31
|
+
fullPromptGuidelines: bashToolSystemPromptContribution.fullGuidelines,
|
|
32
|
+
tempFilePrefix: "pi-bash",
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=bash-schema.js.map
|
|
@@ -1,60 +1,11 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { type Static, Type } from "typebox";
|
|
3
|
-
import { type ShellTrust } from "../../engine-trust/shell-trust.ts";
|
|
4
2
|
import { type ShellConfig } from "../../utils/shell.ts";
|
|
5
3
|
import type { ToolDefinition } from "../extensions/types.ts";
|
|
4
|
+
import { type BashSpawnHook, type BashToolDetails, type bashSchema, type ShellToolConfig } from "./bash-schema.ts";
|
|
6
5
|
import { type ToolMachine } from "./machine.ts";
|
|
7
|
-
import { type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
timeout: Type.TOptional<Type.TNumber>;
|
|
11
|
-
}>;
|
|
12
|
-
export declare const bashToolSystemPromptContribution: {
|
|
13
|
-
readonly snippet: "Execute bash commands (ls, rg, find, etc.)";
|
|
14
|
-
readonly guidelines: readonly ["PI_* env vars = current model + session details."];
|
|
15
|
-
readonly fullGuidelines: readonly ["You can inspect PI_* environment variables for current model and session details."];
|
|
16
|
-
};
|
|
17
|
-
export type BashToolInput = Static<typeof bashSchema>;
|
|
18
|
-
/**
|
|
19
|
-
* Result for programmatic callers such as codemode scripts. A non-zero exit code is an error result for the model, but scripts still resolve to this value.
|
|
20
|
-
* `output` is not limited like the model-facing output: callers decide how much of it reaches the model.
|
|
21
|
-
*/
|
|
22
|
-
declare const bashOutputSchema: Type.TObject<{
|
|
23
|
-
output: Type.TString;
|
|
24
|
-
truncated: Type.TBoolean;
|
|
25
|
-
full_output_path: Type.TOptional<Type.TString>;
|
|
26
|
-
exit_code: Type.TNumber;
|
|
27
|
-
wall_time_seconds: Type.TNumber;
|
|
28
|
-
}>;
|
|
29
|
-
export type BashToolOutput = Static<typeof bashOutputSchema>;
|
|
30
|
-
export interface BashToolDetails {
|
|
31
|
-
truncation?: TruncationResult;
|
|
32
|
-
fullOutputPath?: string;
|
|
33
|
-
trust?: ShellTrust;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Pluggable operations for the bash tool.
|
|
37
|
-
* Override these to delegate command execution to remote systems (for example SSH).
|
|
38
|
-
*/
|
|
39
|
-
export interface BashOperations {
|
|
40
|
-
/**
|
|
41
|
-
* Execute a command and stream output.
|
|
42
|
-
* @param command The command to execute
|
|
43
|
-
* @param cwd Working directory
|
|
44
|
-
* @param options Execution options
|
|
45
|
-
* @returns Promise resolving to the exit code. Report signal terminations as 128 + signal number;
|
|
46
|
-
* a null exit code is treated as a failed command.
|
|
47
|
-
*/
|
|
48
|
-
exec: (command: string, cwd: string, options: {
|
|
49
|
-
onData: (data: Buffer, stream?: "stdout" | "stderr") => void;
|
|
50
|
-
signal?: AbortSignal;
|
|
51
|
-
timeout?: number;
|
|
52
|
-
env?: NodeJS.ProcessEnv;
|
|
53
|
-
redactSecretsInOutput?: boolean;
|
|
54
|
-
}) => Promise<{
|
|
55
|
-
exitCode: number | null;
|
|
56
|
-
}>;
|
|
57
|
-
}
|
|
6
|
+
import { type BashOperations } from "./shell-operations.ts";
|
|
7
|
+
export { type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOutput, bashToolSystemPromptContribution, type ShellToolConfig, } from "./bash-schema.ts";
|
|
8
|
+
export type { BashOperations } from "./shell-operations.ts";
|
|
58
9
|
/**
|
|
59
10
|
* Shared process execution used by the built-in shell tools: one `process.exec` of the operation layer (own
|
|
60
11
|
* process group, scope token, abort/timeout kill the group). The tool keeps its own output handling.
|
|
@@ -76,12 +27,6 @@ export declare class DeviceUnavailableError extends Error {
|
|
|
76
27
|
readonly tool: string;
|
|
77
28
|
constructor(tool: string);
|
|
78
29
|
}
|
|
79
|
-
export interface BashSpawnContext {
|
|
80
|
-
command: string;
|
|
81
|
-
cwd: string;
|
|
82
|
-
env: NodeJS.ProcessEnv;
|
|
83
|
-
}
|
|
84
|
-
export type BashSpawnHook = (context: BashSpawnContext) => BashSpawnContext;
|
|
85
30
|
export interface BashToolOptions {
|
|
86
31
|
/** Redact credential-shaped output before streaming or spilling. Default: false. */
|
|
87
32
|
redactSecretsInOutput?: boolean;
|
|
@@ -109,18 +54,7 @@ export type BashRenderState = {
|
|
|
109
54
|
endedAt: number | undefined;
|
|
110
55
|
interval: NodeJS.Timeout | undefined;
|
|
111
56
|
};
|
|
112
|
-
export interface ShellToolConfig {
|
|
113
|
-
name: string;
|
|
114
|
-
label: string;
|
|
115
|
-
shellName: string;
|
|
116
|
-
prompt: string;
|
|
117
|
-
promptSnippet: string;
|
|
118
|
-
promptGuidelines?: readonly string[];
|
|
119
|
-
fullPromptGuidelines?: readonly string[];
|
|
120
|
-
tempFilePrefix: string;
|
|
121
|
-
}
|
|
122
57
|
export declare function createShellToolDefinition(cwd: string, config: ShellToolConfig, options?: BashToolOptions): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState>;
|
|
123
58
|
export declare function createBashToolDefinition(cwd: string, options?: BashToolOptions): ToolDefinition<typeof bashSchema, BashToolDetails | undefined, BashRenderState>;
|
|
124
59
|
export declare function createBashTool(cwd: string, options?: BashToolOptions): AgentTool<typeof bashSchema>;
|
|
125
|
-
export {};
|
|
126
60
|
//# sourceMappingURL=bash.d.ts.map
|