@fleetagent/pi-coding-agent 0.0.11 → 0.1.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cli/args.d.ts +3 -2
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +20 -8
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/core/agent-session.d.ts +9 -2
  7. package/dist/core/agent-session.d.ts.map +1 -1
  8. package/dist/core/agent-session.js +59 -11
  9. package/dist/core/agent-session.js.map +1 -1
  10. package/dist/core/resource-loader.d.ts.map +1 -1
  11. package/dist/core/resource-loader.js +30 -7
  12. package/dist/core/resource-loader.js.map +1 -1
  13. package/dist/core/rules.d.ts.map +1 -1
  14. package/dist/core/rules.js +20 -15
  15. package/dist/core/rules.js.map +1 -1
  16. package/dist/core/skills.d.ts.map +1 -1
  17. package/dist/core/skills.js +20 -15
  18. package/dist/core/skills.js.map +1 -1
  19. package/dist/core/slash-commands.d.ts.map +1 -1
  20. package/dist/core/slash-commands.js +1 -1
  21. package/dist/core/slash-commands.js.map +1 -1
  22. package/dist/core/source-info.d.ts.map +1 -1
  23. package/dist/core/source-info.js +1 -1
  24. package/dist/core/source-info.js.map +1 -1
  25. package/dist/core/tools/bash.d.ts.map +1 -1
  26. package/dist/core/tools/bash.js +6 -3
  27. package/dist/core/tools/bash.js.map +1 -1
  28. package/dist/core/tools/index.d.ts +1 -1
  29. package/dist/core/tools/index.d.ts.map +1 -1
  30. package/dist/core/tools/index.js +1 -1
  31. package/dist/core/tools/index.js.map +1 -1
  32. package/dist/core/tools/operations.d.ts +49 -4
  33. package/dist/core/tools/operations.d.ts.map +1 -1
  34. package/dist/core/tools/operations.js +340 -4
  35. package/dist/core/tools/operations.js.map +1 -1
  36. package/dist/core/tools/read.d.ts +2 -0
  37. package/dist/core/tools/read.d.ts.map +1 -1
  38. package/dist/core/tools/read.js +12 -5
  39. package/dist/core/tools/read.js.map +1 -1
  40. package/dist/core/tools/render-utils.d.ts.map +1 -1
  41. package/dist/core/tools/render-utils.js +2 -0
  42. package/dist/core/tools/render-utils.js.map +1 -1
  43. package/dist/index.d.ts +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/main.d.ts.map +1 -1
  48. package/dist/main.js +30 -15
  49. package/dist/main.js.map +1 -1
  50. package/dist/modes/interactive/interactive-mode.d.ts +3 -1
  51. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  52. package/dist/modes/interactive/interactive-mode.js +41 -20
  53. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  54. package/dist/modes/rpc/rpc-client.d.ts +11 -4
  55. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  56. package/dist/modes/rpc/rpc-client.js +6 -6
  57. package/dist/modes/rpc/rpc-client.js.map +1 -1
  58. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  59. package/dist/modes/rpc/rpc-mode.js +11 -7
  60. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  61. package/dist/modes/rpc/rpc-types.d.ts +10 -4
  62. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  63. package/dist/modes/rpc/rpc-types.js.map +1 -1
  64. package/docs/extensions.md +2 -2
  65. package/docs/rpc.md +31 -0
  66. package/docs/usage.md +4 -1
  67. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  68. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  69. package/examples/extensions/sandbox/package.json +1 -1
  70. package/examples/extensions/with-deps/package.json +1 -1
  71. package/npm-shrinkwrap.json +12 -12
  72. package/package.json +4 -4
@@ -13,7 +13,7 @@
13
13
  * Modes use this class and add their own I/O layer on top.
14
14
  */
15
15
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
16
- import { basename, dirname } from "node:path";
16
+ import { basename, dirname, sep } from "node:path";
17
17
  import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, modelsAreEqual, resetApiProviders, streamSimple, validateToolArguments, } from "@fleetagent/pi-ai";
18
18
  import { theme } from "../modes/interactive/theme/theme.js";
19
19
  import { stripFrontmatter } from "../utils/frontmatter.js";
@@ -30,10 +30,10 @@ import { emitSessionShutdownEvent } from "./extensions/runner.js";
30
30
  import { STRUCTURED_RESPONSE_INTERNAL_CUSTOM_TYPE } from "./messages.js";
31
31
  import { expandPromptTemplate } from "./prompt-templates.js";
32
32
  import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
33
- import { createSyntheticSourceInfo } from "./source-info.js";
33
+ import { createSyntheticSourceInfo, getSourceBackend } from "./source-info.js";
34
34
  import { buildSystemPrompt } from "./system-prompt.js";
35
35
  import { createLocalBashOperations } from "./tools/bash.js";
36
- import { createAllToolDefinitions, DeferredSshToolOperations, LocalToolOperations, } from "./tools/index.js";
36
+ import { createAllToolDefinitions, DeferredRemoteToolOperations, 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.
@@ -134,6 +134,7 @@ export class AgentSession {
134
134
  _allowedToolNames;
135
135
  _baseToolsOverride;
136
136
  _toolOperations;
137
+ _localResourceToolOperations;
137
138
  _sessionStartEvent;
138
139
  _extensionUIContext;
139
140
  _extensionCommandContextActions;
@@ -187,15 +188,57 @@ export class AgentSession {
187
188
  getToolBackendInfo() {
188
189
  return this.getToolOperations().getBackendInfo?.() ?? { type: "local", cwd: this._cwd };
189
190
  }
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");
191
+ _getLocalResourceToolOperations(shellPath) {
192
+ this._localResourceToolOperations ??= new LocalToolOperations(this._cwd, { shellPath });
193
+ return this._localResourceToolOperations;
194
+ }
195
+ _getReadOperationsForPath(absolutePath, shellPath) {
196
+ const isSameOrChild = (target, root) => {
197
+ const normalizedRoot = resolvePath(root);
198
+ if (target === normalizedRoot)
199
+ return true;
200
+ const prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;
201
+ return target.startsWith(prefix);
202
+ };
203
+ const resources = [
204
+ ...this._resourceLoader.getSkills().skills.map((skill) => ({
205
+ path: skill.filePath,
206
+ baseDir: skill.baseDir,
207
+ sourceInfo: skill.sourceInfo,
208
+ })),
209
+ ...this._resourceLoader.getRules().rules.map((rule) => ({
210
+ path: rule.filePath,
211
+ baseDir: rule.baseDir,
212
+ sourceInfo: rule.sourceInfo,
213
+ })),
214
+ ...this._resourceLoader.getPrompts().prompts.map((prompt) => ({
215
+ path: prompt.filePath,
216
+ baseDir: dirname(prompt.filePath),
217
+ sourceInfo: prompt.sourceInfo,
218
+ })),
219
+ ];
220
+ for (const resource of resources) {
221
+ if (getSourceBackend(resource.sourceInfo) !== "local")
222
+ continue;
223
+ const resourcePath = resolvePath(resource.path);
224
+ const baseDir = resolvePath(resource.baseDir);
225
+ if (absolutePath === resourcePath || isSameOrChild(absolutePath, baseDir)) {
226
+ return this._getLocalResourceToolOperations(shellPath);
227
+ }
193
228
  }
194
- return this._toolOperations.configure(options);
229
+ return undefined;
195
230
  }
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");
231
+ async configureRemoteSandbox(options) {
232
+ if (!(this._toolOperations instanceof DeferredRemoteToolOperations)) {
233
+ throw new Error("Remote backend can only be configured when Pi is started with --remote-deferred");
234
+ }
235
+ return options.type === "ssh"
236
+ ? this._toolOperations.configure({ remote: options.remote, cwd: options.cwd })
237
+ : this._toolOperations.configureRemote(options.url);
238
+ }
239
+ clearRemoteSandbox() {
240
+ if (!(this._toolOperations instanceof DeferredRemoteToolOperations)) {
241
+ throw new Error("Remote backend can only be cleared when Pi is started with --remote-deferred");
199
242
  }
200
243
  this._toolOperations.clear();
201
244
  }
@@ -558,6 +601,8 @@ export class AgentSession {
558
601
  this.abortBranchSummary();
559
602
  this.abortBash();
560
603
  this.agent.abort();
604
+ void this._localResourceToolOperations?.dispose?.();
605
+ this._localResourceToolOperations = undefined;
561
606
  }
562
607
  catch {
563
608
  // Dispose must succeed even if an abort hook throws.
@@ -2265,7 +2310,10 @@ export class AgentSession {
2265
2310
  createToolDefinitionFromAgentTool(tool),
2266
2311
  ]))
2267
2312
  : createAllToolDefinitions(operations, {
2268
- read: { autoResizeImages },
2313
+ read: {
2314
+ autoResizeImages,
2315
+ operationsForPath: (path) => this._getReadOperationsForPath(path, shellPath),
2316
+ },
2269
2317
  bash: { commandPrefix: shellCommandPrefix },
2270
2318
  });
2271
2319
  this._baseToolDefinitions = new Map(Object.entries(baseToolDefinitions).map(([name, tool]) => [name, tool]));