@oh-my-pi/pi-coding-agent 17.0.2 → 17.0.4
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 +80 -20
- package/dist/cli.js +4087 -4108
- package/dist/types/config/settings-schema.d.ts +7 -3
- package/dist/types/eval/agent-bridge.d.ts +7 -19
- package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +15 -1
- package/dist/types/lsp/client.d.ts +2 -0
- package/dist/types/lsp/types.d.ts +3 -0
- package/dist/types/mcp/transports/stdio.d.ts +29 -0
- package/dist/types/mnemopi/state.d.ts +32 -9
- package/dist/types/modes/components/agent-hub.d.ts +15 -0
- package/dist/types/registry/persisted-agents.d.ts +3 -0
- package/dist/types/sdk.d.ts +14 -3
- package/dist/types/session/session-entries.d.ts +6 -1
- package/dist/types/session/session-manager.d.ts +5 -0
- package/dist/types/task/executor.d.ts +26 -1
- package/dist/types/task/index.d.ts +1 -1
- package/dist/types/task/parallel.d.ts +14 -0
- package/dist/types/task/structured-subagent.d.ts +111 -0
- package/dist/types/task/types.d.ts +51 -0
- package/dist/types/tools/fetch.d.ts +4 -5
- package/dist/types/tools/hub/messaging.d.ts +5 -1
- package/dist/types/tools/index.d.ts +16 -1
- package/dist/types/tools/todo.d.ts +31 -0
- package/dist/types/tui/tree-list.d.ts +7 -0
- package/dist/types/utils/markit.d.ts +11 -0
- package/package.json +12 -12
- package/src/cli/file-processor.ts +1 -2
- package/src/config/settings-schema.ts +4 -3
- package/src/eval/__tests__/agent-bridge.test.ts +133 -47
- package/src/eval/__tests__/prelude-agent.test.ts +29 -0
- package/src/eval/agent-bridge.ts +104 -477
- package/src/eval/jl/prelude.jl +7 -6
- package/src/eval/js/shared/prelude.txt +5 -4
- package/src/eval/py/prelude.py +11 -39
- package/src/eval/rb/prelude.rb +5 -6
- package/src/extensibility/legacy-pi-coding-agent-shim.ts +53 -7
- package/src/lsp/client.ts +57 -0
- package/src/lsp/index.ts +62 -6
- package/src/lsp/types.ts +3 -0
- package/src/mcp/oauth-flow.ts +20 -0
- package/src/mcp/transports/stdio.test.ts +269 -1
- package/src/mcp/transports/stdio.ts +152 -1
- package/src/mnemopi/backend.ts +1 -1
- package/src/mnemopi/embed-worker.ts +8 -7
- package/src/mnemopi/state.ts +45 -18
- package/src/modes/components/agent-hub.ts +1 -72
- package/src/modes/components/bash-execution.ts +7 -3
- package/src/modes/components/eval-execution.ts +3 -1
- package/src/modes/components/transcript-container.ts +13 -7
- package/src/modes/interactive-mode.ts +30 -8
- package/src/prompts/system/system-prompt.md +1 -1
- package/src/prompts/tools/eval.md +5 -2
- package/src/prompts/tools/read.md +1 -1
- package/src/prompts/tools/task.md +12 -8
- package/src/prompts/tools/write.md +1 -1
- package/src/registry/persisted-agents.ts +74 -0
- package/src/sdk.ts +129 -87
- package/src/session/agent-session.ts +75 -21
- package/src/session/session-entries.ts +6 -1
- package/src/session/session-loader.ts +31 -3
- package/src/session/session-manager.ts +9 -0
- package/src/session/streaming-output.ts +41 -1
- package/src/stt/recorder.ts +68 -55
- package/src/system-prompt.ts +7 -2
- package/src/task/executor.ts +99 -21
- package/src/task/index.ts +258 -429
- package/src/task/parallel.ts +43 -0
- package/src/task/persisted-revive.ts +19 -7
- package/src/task/structured-subagent.ts +642 -0
- package/src/task/types.ts +61 -0
- package/src/tools/__tests__/eval-description.test.ts +1 -1
- package/src/tools/fetch.ts +28 -105
- package/src/tools/hub/messaging.ts +16 -3
- package/src/tools/index.ts +47 -14
- package/src/tools/path-utils.ts +1 -0
- package/src/tools/read.ts +14 -26
- package/src/tools/todo.ts +126 -13
- package/src/tui/tree-list.ts +39 -0
- package/src/utils/markit.ts +12 -0
- package/src/utils/zip.ts +16 -1
package/src/task/parallel.ts
CHANGED
|
@@ -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
|
-
//
|
|
83
|
-
//
|
|
84
|
-
const
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|