@fleetagent/pi-coding-agent 0.0.9 → 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.
Files changed (101) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +9 -0
  3. package/dist/cli/args.d.ts +3 -0
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +18 -0
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/core/agent-session.d.ts +12 -3
  8. package/dist/core/agent-session.d.ts.map +1 -1
  9. package/dist/core/agent-session.js +27 -6
  10. package/dist/core/agent-session.js.map +1 -1
  11. package/dist/core/bash-executor.d.ts +3 -3
  12. package/dist/core/bash-executor.d.ts.map +1 -1
  13. package/dist/core/bash-executor.js +3 -2
  14. package/dist/core/bash-executor.js.map +1 -1
  15. package/dist/core/extensions/types.d.ts +2 -2
  16. package/dist/core/extensions/types.d.ts.map +1 -1
  17. package/dist/core/extensions/types.js.map +1 -1
  18. package/dist/core/pi-agent.d.ts +2 -0
  19. package/dist/core/pi-agent.d.ts.map +1 -1
  20. package/dist/core/pi-agent.js +2 -0
  21. package/dist/core/pi-agent.js.map +1 -1
  22. package/dist/core/slash-commands.d.ts.map +1 -1
  23. package/dist/core/slash-commands.js +1 -0
  24. package/dist/core/slash-commands.js.map +1 -1
  25. package/dist/core/tools/bash.d.ts +6 -29
  26. package/dist/core/tools/bash.d.ts.map +1 -1
  27. package/dist/core/tools/bash.js +23 -97
  28. package/dist/core/tools/bash.js.map +1 -1
  29. package/dist/core/tools/edit-diff.d.ts +3 -2
  30. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  31. package/dist/core/tools/edit-diff.js +6 -8
  32. package/dist/core/tools/edit-diff.js.map +1 -1
  33. package/dist/core/tools/edit.d.ts +3 -16
  34. package/dist/core/tools/edit.d.ts.map +1 -1
  35. package/dist/core/tools/edit.js +7 -13
  36. package/dist/core/tools/edit.js.map +1 -1
  37. package/dist/core/tools/find.d.ts +3 -17
  38. package/dist/core/tools/find.d.ts.map +1 -1
  39. package/dist/core/tools/find.js +11 -23
  40. package/dist/core/tools/find.js.map +1 -1
  41. package/dist/core/tools/grep.d.ts +3 -14
  42. package/dist/core/tools/grep.d.ts.map +1 -1
  43. package/dist/core/tools/grep.js +93 -41
  44. package/dist/core/tools/grep.js.map +1 -1
  45. package/dist/core/tools/index.d.ts +17 -15
  46. package/dist/core/tools/index.d.ts.map +1 -1
  47. package/dist/core/tools/index.js +53 -52
  48. package/dist/core/tools/index.js.map +1 -1
  49. package/dist/core/tools/ls.d.ts +3 -20
  50. package/dist/core/tools/ls.d.ts.map +1 -1
  51. package/dist/core/tools/ls.js +9 -20
  52. package/dist/core/tools/ls.js.map +1 -1
  53. package/dist/core/tools/operations.d.ts +145 -0
  54. package/dist/core/tools/operations.d.ts.map +1 -0
  55. package/dist/core/tools/operations.js +418 -0
  56. package/dist/core/tools/operations.js.map +1 -0
  57. package/dist/core/tools/read.d.ts +3 -16
  58. package/dist/core/tools/read.d.ts.map +1 -1
  59. package/dist/core/tools/read.js +6 -13
  60. package/dist/core/tools/read.js.map +1 -1
  61. package/dist/core/tools/write.d.ts +3 -14
  62. package/dist/core/tools/write.d.ts.map +1 -1
  63. package/dist/core/tools/write.js +6 -10
  64. package/dist/core/tools/write.js.map +1 -1
  65. package/dist/index.d.ts +1 -1
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +1 -1
  68. package/dist/index.js.map +1 -1
  69. package/dist/main.d.ts.map +1 -1
  70. package/dist/main.js +33 -0
  71. package/dist/main.js.map +1 -1
  72. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  73. package/dist/modes/interactive/components/tool-execution.js +2 -2
  74. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  75. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  76. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  77. package/dist/modes/interactive/interactive-mode.js +52 -0
  78. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  79. package/dist/modes/rpc/rpc-client.d.ts +9 -0
  80. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  81. package/dist/modes/rpc/rpc-client.js +14 -0
  82. package/dist/modes/rpc/rpc-client.js.map +1 -1
  83. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  84. package/dist/modes/rpc/rpc-mode.js +9 -0
  85. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  86. package/dist/modes/rpc/rpc-types.d.ts +22 -0
  87. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  88. package/dist/modes/rpc/rpc-types.js.map +1 -1
  89. package/docs/extensions.md +1 -2
  90. package/examples/extensions/README.md +0 -1
  91. package/examples/extensions/bash-spawn-hook.ts +2 -2
  92. package/examples/extensions/built-in-tool-renderer.ts +12 -5
  93. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  94. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  95. package/examples/extensions/minimal-mode.ts +9 -7
  96. package/examples/extensions/sandbox/index.ts +55 -56
  97. package/examples/extensions/sandbox/package.json +1 -1
  98. package/examples/extensions/with-deps/package.json +1 -1
  99. package/npm-shrinkwrap.json +12 -12
  100. package/package.json +4 -4
  101. 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(this._cwd, {
2254
+ : createAllToolDefinitions(operations, {
2237
2255
  read: { autoResizeImages },
2238
- bash: { commandPrefix: shellCommandPrefix, shellPath },
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 BashOperations for remote execution
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 result = await executeBashWithOperations(resolvedCommand, this.session.getCwd(), options?.operations ?? createLocalBashOperations({ shellPath }), {
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
  });