@fleetagent/pi-coding-agent 0.0.8 → 0.0.10
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 +40 -0
- package/README.md +9 -0
- package/dist/cli/args.d.ts +3 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +18 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session.d.ts +12 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +27 -6
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts +3 -3
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +3 -2
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/pi-agent.d.ts +2 -0
- package/dist/core/pi-agent.d.ts.map +1 -1
- package/dist/core/pi-agent.js +2 -0
- package/dist/core/pi-agent.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts +6 -29
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +23 -97
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +3 -2
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +6 -8
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -16
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +7 -13
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +3 -17
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +11 -23
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +3 -14
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +93 -41
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +17 -15
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +53 -52
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +3 -20
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +9 -20
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/operations.d.ts +145 -0
- package/dist/core/tools/operations.d.ts.map +1 -0
- package/dist/core/tools/operations.js +418 -0
- package/dist/core/tools/operations.js.map +1 -0
- package/dist/core/tools/read.d.ts +3 -16
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +6 -13
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts +3 -14
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +6 -10
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +33 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +2 -2
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +52 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +14 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +32 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +47 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +48 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/extensions.md +1 -2
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/bash-spawn-hook.ts +2 -2
- package/examples/extensions/built-in-tool-renderer.ts +12 -5
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/minimal-mode.ts +9 -7
- package/examples/extensions/sandbox/index.ts +55 -56
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
- package/examples/extensions/ssh.ts +0 -220
|
@@ -33,7 +33,7 @@ import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-man
|
|
|
33
33
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
34
34
|
import { buildSystemPrompt } from "./system-prompt.js";
|
|
35
35
|
import { createLocalBashOperations } from "./tools/bash.js";
|
|
36
|
-
import { createAllToolDefinitions } from "./tools/index.js";
|
|
36
|
+
import { createAllToolDefinitions, DeferredSshToolOperations, LocalToolOperations, } from "./tools/index.js";
|
|
37
37
|
import { createToolDefinitionFromAgentTool } from "./tools/tool-definition-wrapper.js";
|
|
38
38
|
/**
|
|
39
39
|
* Parse a skill block from message text.
|
|
@@ -133,6 +133,7 @@ export class AgentSession {
|
|
|
133
133
|
_initialActiveToolNames;
|
|
134
134
|
_allowedToolNames;
|
|
135
135
|
_baseToolsOverride;
|
|
136
|
+
_toolOperations;
|
|
136
137
|
_sessionStartEvent;
|
|
137
138
|
_extensionUIContext;
|
|
138
139
|
_extensionCommandContextActions;
|
|
@@ -163,6 +164,7 @@ export class AgentSession {
|
|
|
163
164
|
this._initialActiveToolNames = config.initialActiveToolNames;
|
|
164
165
|
this._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : undefined;
|
|
165
166
|
this._baseToolsOverride = config.baseToolsOverride;
|
|
167
|
+
this._toolOperations = config.toolOperations;
|
|
166
168
|
this._sessionStartEvent = config.sessionStartEvent ?? { type: "session_start", reason: "startup" };
|
|
167
169
|
// Always subscribe to agent events for internal handling
|
|
168
170
|
// (session persistence, extensions, auto-compaction, retry logic)
|
|
@@ -178,6 +180,21 @@ export class AgentSession {
|
|
|
178
180
|
get modelRegistry() {
|
|
179
181
|
return this._modelRegistry;
|
|
180
182
|
}
|
|
183
|
+
getToolBackendInfo() {
|
|
184
|
+
return this._toolOperations?.getBackendInfo?.() ?? { type: "local", cwd: this._cwd };
|
|
185
|
+
}
|
|
186
|
+
async configureSshSandbox(options) {
|
|
187
|
+
if (!(this._toolOperations instanceof DeferredSshToolOperations)) {
|
|
188
|
+
throw new Error("SSH sandbox can only be configured when Pi is started with --ssh-deferred");
|
|
189
|
+
}
|
|
190
|
+
return this._toolOperations.configure(options);
|
|
191
|
+
}
|
|
192
|
+
clearSshSandbox() {
|
|
193
|
+
if (!(this._toolOperations instanceof DeferredSshToolOperations)) {
|
|
194
|
+
throw new Error("SSH sandbox can only be cleared when Pi is started with --ssh-deferred");
|
|
195
|
+
}
|
|
196
|
+
this._toolOperations.clear();
|
|
197
|
+
}
|
|
181
198
|
async _getRequiredRequestAuth(model) {
|
|
182
199
|
const result = await this._modelRegistry.getApiKeyAndHeaders(model);
|
|
183
200
|
if (!result.ok) {
|
|
@@ -709,7 +726,7 @@ export class AgentSession {
|
|
|
709
726
|
const loadedRules = this._resourceLoader.getRules().rules;
|
|
710
727
|
const loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;
|
|
711
728
|
this._baseSystemPromptOptions = {
|
|
712
|
-
cwd: this._cwd,
|
|
729
|
+
cwd: this._toolOperations?.cwd ?? this._cwd,
|
|
713
730
|
skills: loadedSkills,
|
|
714
731
|
rules: loadedRules,
|
|
715
732
|
contextFiles: loadedContextFiles,
|
|
@@ -2228,14 +2245,15 @@ export class AgentSession {
|
|
|
2228
2245
|
const autoResizeImages = this.settingsManager.getImageAutoResize();
|
|
2229
2246
|
const shellCommandPrefix = this.settingsManager.getShellCommandPrefix();
|
|
2230
2247
|
const shellPath = this.settingsManager.getShellPath();
|
|
2248
|
+
const operations = this._toolOperations ?? new LocalToolOperations(this._cwd, { shellPath });
|
|
2231
2249
|
const baseToolDefinitions = this._baseToolsOverride
|
|
2232
2250
|
? Object.fromEntries(Object.entries(this._baseToolsOverride).map(([name, tool]) => [
|
|
2233
2251
|
name,
|
|
2234
2252
|
createToolDefinitionFromAgentTool(tool),
|
|
2235
2253
|
]))
|
|
2236
|
-
: createAllToolDefinitions(
|
|
2254
|
+
: createAllToolDefinitions(operations, {
|
|
2237
2255
|
read: { autoResizeImages },
|
|
2238
|
-
bash: { commandPrefix: shellCommandPrefix
|
|
2256
|
+
bash: { commandPrefix: shellCommandPrefix },
|
|
2239
2257
|
});
|
|
2240
2258
|
this._baseToolDefinitions = new Map(Object.entries(baseToolDefinitions).map(([name, tool]) => [name, tool]));
|
|
2241
2259
|
const extensionsResult = this._resourceLoader.getExtensions();
|
|
@@ -2381,7 +2399,7 @@ export class AgentSession {
|
|
|
2381
2399
|
* @param command The bash command to execute
|
|
2382
2400
|
* @param onChunk Optional streaming callback for output
|
|
2383
2401
|
* @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix)
|
|
2384
|
-
* @param options.operations Custom
|
|
2402
|
+
* @param options.operations Custom ToolOperations for remote execution
|
|
2385
2403
|
*/
|
|
2386
2404
|
async executeBash(command, onChunk, options) {
|
|
2387
2405
|
this._bashAbortController = new AbortController();
|
|
@@ -2390,7 +2408,10 @@ export class AgentSession {
|
|
|
2390
2408
|
const shellPath = this.settingsManager.getShellPath();
|
|
2391
2409
|
const resolvedCommand = prefix ? `${prefix}\n${command}` : command;
|
|
2392
2410
|
try {
|
|
2393
|
-
const
|
|
2411
|
+
const operations = options?.operations ??
|
|
2412
|
+
this._toolOperations ??
|
|
2413
|
+
createLocalBashOperations({ cwd: this.session.getCwd(), shellPath });
|
|
2414
|
+
const result = await executeBashWithOperations(resolvedCommand, operations.cwd, operations, {
|
|
2394
2415
|
onChunk,
|
|
2395
2416
|
signal: this._bashAbortController.signal,
|
|
2396
2417
|
});
|