@fleetagent/pi-coding-agent 0.0.9 → 0.0.11
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 +44 -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 +13 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +42 -8
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts +5 -3
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +4 -2
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +86 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +27 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +56 -3
- 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 +3 -0
- package/dist/core/pi-agent.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +5 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +115 -0
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader.d.ts +15 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +332 -40
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/rules.d.ts +6 -0
- package/dist/core/rules.d.ts.map +1 -1
- package/dist/core/rules.js +216 -0
- package/dist/core/rules.js.map +1 -1
- package/dist/core/skills.d.ts +6 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +216 -0
- package/dist/core/skills.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/source-info.d.ts +2 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +6 -0
- package/dist/core/source-info.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 +27 -101
- 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 +12 -18
- 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 +13 -25
- 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 +95 -43
- 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 +11 -22
- 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 +9 -15
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +9 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +14 -0
- package/dist/core/tools/render-utils.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 +9 -12
- 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 +40 -5
- package/dist/main.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 +73 -9
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +9 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +14 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +9 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +22 -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 +83 -5
- package/docs/usage.md +2 -0
- 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,25 @@ export class AgentSession {
|
|
|
178
180
|
get modelRegistry() {
|
|
179
181
|
return this._modelRegistry;
|
|
180
182
|
}
|
|
183
|
+
getToolOperations() {
|
|
184
|
+
const shellPath = this.settingsManager.getShellPath();
|
|
185
|
+
return this._toolOperations ?? createLocalBashOperations({ cwd: this.session.getCwd(), shellPath });
|
|
186
|
+
}
|
|
187
|
+
getToolBackendInfo() {
|
|
188
|
+
return this.getToolOperations().getBackendInfo?.() ?? { type: "local", cwd: this._cwd };
|
|
189
|
+
}
|
|
190
|
+
async configureSshSandbox(options) {
|
|
191
|
+
if (!(this._toolOperations instanceof DeferredSshToolOperations)) {
|
|
192
|
+
throw new Error("SSH sandbox can only be configured when Pi is started with --ssh-deferred");
|
|
193
|
+
}
|
|
194
|
+
return this._toolOperations.configure(options);
|
|
195
|
+
}
|
|
196
|
+
clearSshSandbox() {
|
|
197
|
+
if (!(this._toolOperations instanceof DeferredSshToolOperations)) {
|
|
198
|
+
throw new Error("SSH sandbox can only be cleared when Pi is started with --ssh-deferred");
|
|
199
|
+
}
|
|
200
|
+
this._toolOperations.clear();
|
|
201
|
+
}
|
|
181
202
|
async _getRequiredRequestAuth(model) {
|
|
182
203
|
const result = await this._modelRegistry.getApiKeyAndHeaders(model);
|
|
183
204
|
if (!result.ok) {
|
|
@@ -709,7 +730,7 @@ export class AgentSession {
|
|
|
709
730
|
const loadedRules = this._resourceLoader.getRules().rules;
|
|
710
731
|
const loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;
|
|
711
732
|
this._baseSystemPromptOptions = {
|
|
712
|
-
cwd: this._cwd,
|
|
733
|
+
cwd: this._toolOperations?.cwd ?? this._cwd,
|
|
713
734
|
skills: loadedSkills,
|
|
714
735
|
rules: loadedRules,
|
|
715
736
|
contextFiles: loadedContextFiles,
|
|
@@ -1120,7 +1141,7 @@ export class AgentSession {
|
|
|
1120
1141
|
if (!skill)
|
|
1121
1142
|
return text; // Unknown skill, pass through
|
|
1122
1143
|
try {
|
|
1123
|
-
const content = readFileSync(skill.filePath, "utf-8");
|
|
1144
|
+
const content = skill.content ?? readFileSync(skill.filePath, "utf-8");
|
|
1124
1145
|
const body = stripFrontmatter(content).trim();
|
|
1125
1146
|
const skillBlock = `<skill name="${skill.name}" location="${skill.filePath}">\nReferences are relative to ${skill.baseDir}.\n\n${body}\n</skill>`;
|
|
1126
1147
|
return args ? `${skillBlock}\n\n${args}` : skillBlock;
|
|
@@ -1145,7 +1166,7 @@ export class AgentSession {
|
|
|
1145
1166
|
if (!rule)
|
|
1146
1167
|
return text; // Unknown rule, pass through
|
|
1147
1168
|
try {
|
|
1148
|
-
const content = readFileSync(rule.filePath, "utf-8");
|
|
1169
|
+
const content = rule.content ?? readFileSync(rule.filePath, "utf-8");
|
|
1149
1170
|
const body = stripFrontmatter(content).trim();
|
|
1150
1171
|
const ruleBlock = `<rule name="${rule.name}" location="${rule.filePath}">\nReferences are relative to ${rule.baseDir}.\n\n${body}\n</rule>`;
|
|
1151
1172
|
return args ? `${ruleBlock}\n\n${args}` : ruleBlock;
|
|
@@ -2046,6 +2067,7 @@ export class AgentSession {
|
|
|
2046
2067
|
this.agent.state.model = refreshedModel;
|
|
2047
2068
|
}
|
|
2048
2069
|
_bindExtensionCore(runner) {
|
|
2070
|
+
const getToolOperations = () => this.getToolOperations();
|
|
2049
2071
|
const getCommands = () => {
|
|
2050
2072
|
const extensionCommands = runner.getRegisteredCommands().map((command) => ({
|
|
2051
2073
|
name: command.invocationName,
|
|
@@ -2137,6 +2159,14 @@ export class AgentSession {
|
|
|
2137
2159
|
this._requestExtensionCompaction(options);
|
|
2138
2160
|
},
|
|
2139
2161
|
getSystemPrompt: () => this.systemPrompt,
|
|
2162
|
+
getToolOperations,
|
|
2163
|
+
getToolBackendInfo: () => this.getToolBackendInfo(),
|
|
2164
|
+
execToolBackend: (command, options) => {
|
|
2165
|
+
const operations = getToolOperations();
|
|
2166
|
+
const prefix = this.settingsManager.getShellCommandPrefix();
|
|
2167
|
+
const resolvedCommand = prefix ? `${prefix}\n${command}` : command;
|
|
2168
|
+
return executeBashWithOperations(resolvedCommand, options?.cwd ?? operations.cwd, operations, options);
|
|
2169
|
+
},
|
|
2140
2170
|
}, {
|
|
2141
2171
|
registerProvider: (name, config) => {
|
|
2142
2172
|
this._modelRegistry.registerProvider(name, config);
|
|
@@ -2228,14 +2258,15 @@ export class AgentSession {
|
|
|
2228
2258
|
const autoResizeImages = this.settingsManager.getImageAutoResize();
|
|
2229
2259
|
const shellCommandPrefix = this.settingsManager.getShellCommandPrefix();
|
|
2230
2260
|
const shellPath = this.settingsManager.getShellPath();
|
|
2261
|
+
const operations = this._toolOperations ?? new LocalToolOperations(this._cwd, { shellPath });
|
|
2231
2262
|
const baseToolDefinitions = this._baseToolsOverride
|
|
2232
2263
|
? Object.fromEntries(Object.entries(this._baseToolsOverride).map(([name, tool]) => [
|
|
2233
2264
|
name,
|
|
2234
2265
|
createToolDefinitionFromAgentTool(tool),
|
|
2235
2266
|
]))
|
|
2236
|
-
: createAllToolDefinitions(
|
|
2267
|
+
: createAllToolDefinitions(operations, {
|
|
2237
2268
|
read: { autoResizeImages },
|
|
2238
|
-
bash: { commandPrefix: shellCommandPrefix
|
|
2269
|
+
bash: { commandPrefix: shellCommandPrefix },
|
|
2239
2270
|
});
|
|
2240
2271
|
this._baseToolDefinitions = new Map(Object.entries(baseToolDefinitions).map(([name, tool]) => [name, tool]));
|
|
2241
2272
|
const extensionsResult = this._resourceLoader.getExtensions();
|
|
@@ -2381,7 +2412,7 @@ export class AgentSession {
|
|
|
2381
2412
|
* @param command The bash command to execute
|
|
2382
2413
|
* @param onChunk Optional streaming callback for output
|
|
2383
2414
|
* @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix)
|
|
2384
|
-
* @param options.operations Custom
|
|
2415
|
+
* @param options.operations Custom ToolOperations for remote execution
|
|
2385
2416
|
*/
|
|
2386
2417
|
async executeBash(command, onChunk, options) {
|
|
2387
2418
|
this._bashAbortController = new AbortController();
|
|
@@ -2390,7 +2421,10 @@ export class AgentSession {
|
|
|
2390
2421
|
const shellPath = this.settingsManager.getShellPath();
|
|
2391
2422
|
const resolvedCommand = prefix ? `${prefix}\n${command}` : command;
|
|
2392
2423
|
try {
|
|
2393
|
-
const
|
|
2424
|
+
const operations = options?.operations ??
|
|
2425
|
+
this._toolOperations ??
|
|
2426
|
+
createLocalBashOperations({ cwd: this.session.getCwd(), shellPath });
|
|
2427
|
+
const result = await executeBashWithOperations(resolvedCommand, operations.cwd, operations, {
|
|
2394
2428
|
onChunk,
|
|
2395
2429
|
signal: this._bashAbortController.signal,
|
|
2396
2430
|
});
|