@oh-my-pi/pi-coding-agent 17.0.2 → 17.0.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +70 -20
  2. package/dist/cli.js +4087 -4108
  3. package/dist/types/config/settings-schema.d.ts +7 -3
  4. package/dist/types/eval/agent-bridge.d.ts +7 -19
  5. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +15 -1
  6. package/dist/types/lsp/client.d.ts +2 -0
  7. package/dist/types/lsp/types.d.ts +3 -0
  8. package/dist/types/mcp/transports/stdio.d.ts +29 -0
  9. package/dist/types/modes/components/agent-hub.d.ts +15 -0
  10. package/dist/types/registry/persisted-agents.d.ts +3 -0
  11. package/dist/types/sdk.d.ts +14 -3
  12. package/dist/types/session/session-entries.d.ts +6 -1
  13. package/dist/types/session/session-manager.d.ts +5 -0
  14. package/dist/types/task/executor.d.ts +26 -1
  15. package/dist/types/task/index.d.ts +1 -1
  16. package/dist/types/task/parallel.d.ts +14 -0
  17. package/dist/types/task/structured-subagent.d.ts +111 -0
  18. package/dist/types/task/types.d.ts +51 -0
  19. package/dist/types/tools/fetch.d.ts +4 -5
  20. package/dist/types/tools/hub/messaging.d.ts +5 -1
  21. package/dist/types/tools/index.d.ts +16 -1
  22. package/dist/types/tools/todo.d.ts +31 -0
  23. package/dist/types/tui/tree-list.d.ts +7 -0
  24. package/dist/types/utils/markit.d.ts +11 -0
  25. package/package.json +12 -12
  26. package/src/cli/file-processor.ts +1 -2
  27. package/src/config/settings-schema.ts +4 -3
  28. package/src/eval/__tests__/agent-bridge.test.ts +133 -47
  29. package/src/eval/__tests__/prelude-agent.test.ts +29 -0
  30. package/src/eval/agent-bridge.ts +104 -477
  31. package/src/eval/jl/prelude.jl +7 -6
  32. package/src/eval/js/shared/prelude.txt +5 -4
  33. package/src/eval/py/prelude.py +11 -39
  34. package/src/eval/rb/prelude.rb +5 -6
  35. package/src/extensibility/legacy-pi-coding-agent-shim.ts +53 -7
  36. package/src/lsp/client.ts +57 -0
  37. package/src/lsp/index.ts +62 -6
  38. package/src/lsp/types.ts +3 -0
  39. package/src/mcp/oauth-flow.ts +20 -0
  40. package/src/mcp/transports/stdio.test.ts +269 -1
  41. package/src/mcp/transports/stdio.ts +152 -1
  42. package/src/modes/components/agent-hub.ts +1 -72
  43. package/src/modes/components/bash-execution.ts +7 -3
  44. package/src/modes/components/eval-execution.ts +3 -1
  45. package/src/modes/interactive-mode.ts +30 -8
  46. package/src/prompts/system/system-prompt.md +1 -1
  47. package/src/prompts/tools/eval.md +5 -2
  48. package/src/prompts/tools/read.md +1 -1
  49. package/src/prompts/tools/task.md +12 -8
  50. package/src/prompts/tools/write.md +1 -1
  51. package/src/registry/persisted-agents.ts +74 -0
  52. package/src/sdk.ts +129 -87
  53. package/src/session/agent-session.ts +75 -21
  54. package/src/session/session-entries.ts +6 -1
  55. package/src/session/session-manager.ts +9 -0
  56. package/src/session/streaming-output.ts +41 -1
  57. package/src/system-prompt.ts +7 -2
  58. package/src/task/executor.ts +99 -21
  59. package/src/task/index.ts +258 -429
  60. package/src/task/parallel.ts +43 -0
  61. package/src/task/persisted-revive.ts +19 -7
  62. package/src/task/structured-subagent.ts +642 -0
  63. package/src/task/types.ts +58 -0
  64. package/src/tools/__tests__/eval-description.test.ts +1 -1
  65. package/src/tools/fetch.ts +28 -105
  66. package/src/tools/hub/messaging.ts +16 -3
  67. package/src/tools/index.ts +47 -14
  68. package/src/tools/path-utils.ts +1 -0
  69. package/src/tools/read.ts +14 -26
  70. package/src/tools/todo.ts +126 -13
  71. package/src/tui/tree-list.ts +39 -0
  72. package/src/utils/markit.ts +12 -0
  73. package/src/utils/zip.ts +16 -1
@@ -83,6 +83,49 @@ export async function mapWithConcurrencyLimit<T, R>(
83
83
  return { results, aborted: signal?.aborted ?? false };
84
84
  }
85
85
 
86
+ /** Result of a concurrency-limited operation that waits for every launched item. */
87
+ export interface ParallelSettledResult<R> {
88
+ /** Settled results in original input order; absent entries were never launched after cancellation. */
89
+ results: (PromiseSettledResult<R> | undefined)[];
90
+ /** Whether cancellation prevented scheduling all items. */
91
+ aborted: boolean;
92
+ }
93
+
94
+ /**
95
+ * Execute items with a concurrency limit without failing fast. Rejections are
96
+ * captured at their input position and already launched siblings always settle
97
+ * before this function returns. Cancellation stops new launches but preserves
98
+ * the settled state of every item that began.
99
+ */
100
+ export async function mapWithConcurrencyLimitAllSettled<T, R>(
101
+ items: T[],
102
+ concurrency: number,
103
+ fn: (item: T, index: number, signal: AbortSignal) => Promise<R>,
104
+ signal?: AbortSignal,
105
+ ): Promise<ParallelSettledResult<R>> {
106
+ const normalizedConcurrency = Number.isFinite(concurrency) ? Math.floor(concurrency) : items.length;
107
+ const effectiveConcurrency = normalizedConcurrency > 0 ? normalizedConcurrency : items.length;
108
+ const limit = Math.max(1, Math.min(effectiveConcurrency, items.length));
109
+ const results: (PromiseSettledResult<R> | undefined)[] = new Array(items.length);
110
+ const workerSignal = signal ?? new AbortController().signal;
111
+ let nextIndex = 0;
112
+
113
+ const worker = async (): Promise<void> => {
114
+ while (!workerSignal.aborted) {
115
+ const index = nextIndex++;
116
+ if (index >= items.length) return;
117
+ try {
118
+ results[index] = { status: "fulfilled", value: await fn(items[index], index, workerSignal) };
119
+ } catch (reason) {
120
+ results[index] = { status: "rejected", reason };
121
+ }
122
+ }
123
+ };
124
+
125
+ await Promise.all(Array.from({ length: limit }, () => worker()));
126
+ return { results, aborted: workerSignal.aborted };
127
+ }
128
+
86
129
  /**
87
130
  * Simple counting semaphore for limiting concurrency across independently-scheduled async work.
88
131
  *
@@ -79,9 +79,10 @@ export function createPersistedSubagentReviverFactory(
79
79
  });
80
80
  const artifactManager = ctx.session.sessionManager.getArtifactManager();
81
81
  if (artifactManager) reopened.adoptArtifactManager(artifactManager);
82
- // Reuse the parent's live MCP connections via proxy tools (no
83
- // re-discovery), exactly as the executor does for live subagents.
84
- const mcpManager = MCPManager.instance();
82
+ // A restricted persisted contract must not consult process-global MCP
83
+ // state: same-name MCP tools are untrusted capability sources.
84
+ const restrictToolNames = init.restrictToolNames === true;
85
+ const mcpManager = restrictToolNames ? undefined : MCPManager.instance();
85
86
  const mcpProxyTools = mcpManager ? createMCPProxyTools(mcpManager) : [];
86
87
  const { session } = await createAgentSession({
87
88
  cwd: ctx.session.sessionManager.getCwd(),
@@ -99,16 +100,27 @@ export function createPersistedSubagentReviverFactory(
99
100
  taskDepth,
100
101
  toolNames: init.tools,
101
102
  outputSchema: init.outputSchema,
103
+ outputSchemaMode: init.outputSchemaMode,
104
+ restrictToolNames: restrictToolNames || undefined,
102
105
  requireYieldTool: true,
103
106
  systemPrompt: () => [init.systemPrompt],
104
107
  // Old files predate persisted spawns: deny re-spawning rather than let
105
108
  // createAgentSession default to wildcard ("*").
106
109
  spawns: init.spawns ?? "",
107
110
  hasUI: false,
108
- enableLsp: ctx.enableLsp,
109
- enableMCP: !mcpManager,
110
- mcpManager,
111
- customTools: mcpProxyTools.length > 0 ? mcpProxyTools : undefined,
111
+ enableLsp: restrictToolNames ? false : ctx.enableLsp,
112
+ ...(restrictToolNames
113
+ ? {
114
+ enableIrc: false,
115
+ enableMCP: false,
116
+ preloadedExtensionPaths: [],
117
+ preloadedCustomToolPaths: [],
118
+ }
119
+ : {
120
+ enableMCP: !mcpManager,
121
+ mcpManager,
122
+ customTools: mcpProxyTools.length > 0 ? mcpProxyTools : undefined,
123
+ }),
112
124
  });
113
125
  // Clamp the active set to the persisted list: createAgentSession's
114
126
  // `alwaysInclude` can re-add non-defaultInactive extension/custom tools