@agimon-ai/po-team 0.0.0-alpha.16 → 0.0.0-alpha.17
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.
|
@@ -19,6 +19,7 @@ let node_fs = require("node:fs");
|
|
|
19
19
|
node_fs = require_atomicJson.__toESM(node_fs, 1);
|
|
20
20
|
let node_path = require("node:path");
|
|
21
21
|
node_path = require_atomicJson.__toESM(node_path, 1);
|
|
22
|
+
let _agimon_ai_po_config = require("@agimon-ai/po-config");
|
|
22
23
|
let node_os = require("node:os");
|
|
23
24
|
node_os = require_atomicJson.__toESM(node_os, 1);
|
|
24
25
|
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
@@ -1916,24 +1917,26 @@ function readWorkflowPreferences(payload) {
|
|
|
1916
1917
|
if (preferences.subagentThinking && !THINKING_LEVELS.some((level) => level === preferences.subagentThinking)) throw invalid(`subagentThinking must be one of: ${THINKING_LEVELS.join(", ")}.`);
|
|
1917
1918
|
return preferences;
|
|
1918
1919
|
}
|
|
1919
|
-
function resolvedModelSelection(taskInput, agentConfig, runtime, parentModel, availableModels, teamPackageModels, preferences) {
|
|
1920
|
+
function resolvedModelSelection(taskInput, agentConfig, runtime, parentModel, availableModels, teamPackageModels, preferences, planning = {}) {
|
|
1920
1921
|
const parentModelId = isPiRuntime(runtime) && parentModel ? `${parentModel.provider}/${parentModel.id}` : void 0;
|
|
1921
1922
|
const agentModels = [...agentConfig.modelSource?.scope === "package" ? [] : [agentConfig.model], ...agentConfig.fallbackModels ?? []];
|
|
1922
1923
|
const candidates = (isPiRuntime(runtime) ? [
|
|
1923
1924
|
taskInput.model,
|
|
1924
1925
|
preferences.subagentModel,
|
|
1926
|
+
planning.subagentModel,
|
|
1925
1927
|
...agentModels,
|
|
1926
1928
|
...teamPackageModels ?? [],
|
|
1927
1929
|
parentModelId
|
|
1928
1930
|
] : [
|
|
1929
1931
|
taskInput.model,
|
|
1930
1932
|
preferences.subagentModel,
|
|
1933
|
+
planning.subagentModel,
|
|
1931
1934
|
...agentModels,
|
|
1932
1935
|
...teamPackageModels ?? []
|
|
1933
1936
|
]).filter((candidate) => Boolean(candidate?.trim()));
|
|
1934
1937
|
const [primaryModel, ...fallbackModels] = candidates;
|
|
1935
1938
|
const agentThinking = typeof agentConfig.thinking === "string" ? agentConfig.thinking : void 0;
|
|
1936
|
-
if (!preferences.subagentModel && !preferences.subagentThinking) return {
|
|
1939
|
+
if (!preferences.subagentModel && !preferences.subagentThinking && !planning.subagentModel && !planning.subagentThinking) return {
|
|
1937
1940
|
primaryModel,
|
|
1938
1941
|
fallbackModels,
|
|
1939
1942
|
model: selectAvailableModel(primaryModel, fallbackModels, availableModels),
|
|
@@ -1950,11 +1953,13 @@ function resolvedModelSelection(taskInput, agentConfig, runtime, parentModel, av
|
|
|
1950
1953
|
}
|
|
1951
1954
|
const selectedSuffix = model ? splitKnownThinkingSuffix(model).thinkingSuffix.slice(1) : void 0;
|
|
1952
1955
|
const explicitThinking = selectedCandidate === taskInput.model ? selectedSuffix : void 0;
|
|
1953
|
-
const
|
|
1954
|
-
const
|
|
1956
|
+
const planningThinking = !planning.subagentModel || selectedCandidate === planning.subagentModel ? planning.subagentThinking : void 0;
|
|
1957
|
+
const preferredThinking = (!preferences.subagentModel || selectedCandidate === preferences.subagentModel || selectedCandidate === taskInput.model ? preferences.subagentThinking : void 0) || planningThinking;
|
|
1958
|
+
const thinking = explicitThinking || preferredThinking || selectedSuffix || agentThinking;
|
|
1959
|
+
const workflowThinking = !explicitThinking && (preferredThinking || selectedCandidate === preferences.subagentModel && selectedSuffix);
|
|
1955
1960
|
const modelInfo = findModelInfo(model, availableModels);
|
|
1956
|
-
if (isPiRuntime(runtime) && workflowThinking && modelInfo && !getSupportedThinkingLevels(modelInfo).some((level) => level === thinking)) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `
|
|
1957
|
-
if (model && selectedSuffix && !explicitThinking &&
|
|
1961
|
+
if (isPiRuntime(runtime) && workflowThinking && modelInfo && !getSupportedThinkingLevels(modelInfo).some((level) => level === thinking)) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `Subagent thinking '${thinking}' is unsupported by model '${modelInfo.fullId}'.`, false, `Choose a supported thinking level: ${getSupportedThinkingLevels(modelInfo).join(", ")}.`);
|
|
1962
|
+
if (model && selectedSuffix && !explicitThinking && preferredThinking) model = splitKnownThinkingSuffix(model).baseModel;
|
|
1958
1963
|
return {
|
|
1959
1964
|
primaryModel,
|
|
1960
1965
|
fallbackModels,
|
|
@@ -2132,12 +2137,12 @@ var SpawnPlanner = class {
|
|
|
2132
2137
|
* the module header.
|
|
2133
2138
|
*/
|
|
2134
2139
|
async spawnOneChild(input) {
|
|
2135
|
-
const { runId, operationId, agentConfig, identity, capabilityCeiling, excludeTools, teamPackageModels, workflowPreferences, taskInput, childIndex, fanout, fallbackCwd, parentSessionId, parentForkSource, sessionScope, environment, parentSessionFile, maxLiveRuns, admissionTimeoutMs, handshakeTimeoutMs, artifacts, artifactDir, availableModels, parentModel, runtime, runtimes, skillProjectionCache, sender } = input;
|
|
2140
|
+
const { runId, operationId, agentConfig, identity, capabilityCeiling, excludeTools, teamPackageModels, workflowPreferences, planningPreferences, taskInput, childIndex, fanout, fallbackCwd, parentSessionId, parentForkSource, sessionScope, environment, parentSessionFile, maxLiveRuns, admissionTimeoutMs, handshakeTimeoutMs, artifacts, artifactDir, availableModels, parentModel, runtime, runtimes, skillProjectionCache, sender } = input;
|
|
2136
2141
|
const cwd = taskInput.cwd ?? fallbackCwd;
|
|
2137
2142
|
const task = taskInput.task ?? "";
|
|
2138
2143
|
const effectiveContext = resolveEffectiveContext(taskInput, agentConfig);
|
|
2139
2144
|
const effectiveRuntime = taskInput.runtime ?? runtime ?? agentConfig.runtime ?? "pi";
|
|
2140
|
-
const modelSelection = resolvedModelSelection(taskInput, agentConfig, effectiveRuntime, parentModel, availableModels, teamPackageModels, workflowPreferences);
|
|
2145
|
+
const modelSelection = resolvedModelSelection(taskInput, agentConfig, effectiveRuntime, parentModel, availableModels, teamPackageModels, workflowPreferences, planningPreferences);
|
|
2141
2146
|
if (modelSelection.primaryModel && availableModels !== void 0 && !modelSelection.model) return {
|
|
2142
2147
|
agent: agentConfig.name,
|
|
2143
2148
|
identity: identity.identity,
|
|
@@ -2159,7 +2164,11 @@ var SpawnPlanner = class {
|
|
|
2159
2164
|
error: error instanceof Error ? error.message : String(error)
|
|
2160
2165
|
};
|
|
2161
2166
|
}
|
|
2162
|
-
const warnings = [
|
|
2167
|
+
const warnings = [
|
|
2168
|
+
...modelSelection.primaryModel && modelSelection.model && !selectAvailableModel(modelSelection.primaryModel, [], availableModels) ? [`[fallback] ${modelSelection.primaryModel} is unavailable. Using ${modelSelection.model}.`] : [],
|
|
2169
|
+
...skillProjection.warnings,
|
|
2170
|
+
...bestEffortRuntimeWarnings(effectiveRuntime, agentConfig, excludeTools)
|
|
2171
|
+
];
|
|
2163
2172
|
const warning = warnings.length > 0 ? warnings.join(" ") : void 0;
|
|
2164
2173
|
const spawnInput = {
|
|
2165
2174
|
runId,
|
|
@@ -2231,6 +2240,7 @@ var SpawnPlanner = class {
|
|
|
2231
2240
|
source,
|
|
2232
2241
|
agent: agentConfig.name,
|
|
2233
2242
|
task,
|
|
2243
|
+
...warning ? { meta: { warning } } : {},
|
|
2234
2244
|
sender: sender ?? MAIN_AGENT_SENDER,
|
|
2235
2245
|
cwd,
|
|
2236
2246
|
...modelSelection.model ? { model: modelSelection.model } : {},
|
|
@@ -2294,6 +2304,11 @@ var SpawnPlanner = class {
|
|
|
2294
2304
|
async spawn(request, config) {
|
|
2295
2305
|
const tasks = this.resolveTaskList(request);
|
|
2296
2306
|
const workflowPreferences = readWorkflowPreferences(request.environment?.WORKFLOW_RUN_CONFIG ?? this.environment.WORKFLOW_RUN_CONFIG);
|
|
2307
|
+
const planningConfig = request.repoRoot && request.parentSelection?.state?.["minor-mode"]?.includes("plan") ? (0, _agimon_ai_po_config.loadPoConfig)(request.repoRoot, request.environment?.HOME ?? this.environment.HOME).modes?.planning?.subagents : void 0;
|
|
2308
|
+
const planningPreferences = {
|
|
2309
|
+
subagentModel: planningConfig?.model,
|
|
2310
|
+
subagentThinking: planningConfig?.thinking
|
|
2311
|
+
};
|
|
2297
2312
|
const fanout = tasks.length > 1;
|
|
2298
2313
|
const teamPackageExcludeTools = this.resolveTeamPackageExcludeTools();
|
|
2299
2314
|
const teamPackageModels = this.resolveTeamPackageModels();
|
|
@@ -2341,7 +2356,7 @@ var SpawnPlanner = class {
|
|
|
2341
2356
|
const cwd = taskInput.cwd ?? request.cwd;
|
|
2342
2357
|
this.validateCwd(cwd);
|
|
2343
2358
|
const runtime = taskInput.runtime ?? request.runtime ?? agent.runtime ?? "pi";
|
|
2344
|
-
const modelSelection = resolvedModelSelection(taskInput, agent, runtime, request.parentModel, request.availableModels, teamPackageModels, workflowPreferences);
|
|
2359
|
+
const modelSelection = resolvedModelSelection(taskInput, agent, runtime, request.parentModel, request.availableModels, teamPackageModels, workflowPreferences, planningPreferences);
|
|
2345
2360
|
if (modelSelection.primaryModel && request.availableModels !== void 0 && !modelSelection.model) throw new PoTeamExpectedError(ERROR_CODE_MODEL_UNAVAILABLE, `No authenticated model is available for '${agent.name}'.`, false, "Authenticate the requested model or choose an available model.");
|
|
2346
2361
|
if (taskInput.inlineAgent && !isPiRuntime(runtime)) throw new PoTeamExpectedError(ERROR_CODE_UNSUPPORTED_OPERATION, `Inline agent '${taskInput.agent}' requires ${PI_RUNTIME_REQUIREMENT} to enforce its read-only tools.`, false, "Remove the runtime override or use a discovered external-runtime agent without inlineAgent.");
|
|
2347
2362
|
if (capabilityCeiling && !isPiRuntime(runtime)) throw new PoTeamExpectedError(ERROR_CODE_UNSUPPORTED_OPERATION, `Runtime '${runtime}' cannot enforce the active capability ceiling.`, false, `Use ${PI_RUNTIME_REQUIREMENT} while plan mode or another capability ceiling is active.`);
|
|
@@ -2370,6 +2385,7 @@ var SpawnPlanner = class {
|
|
|
2370
2385
|
excludeTools: teamPackageExcludeTools,
|
|
2371
2386
|
teamPackageModels,
|
|
2372
2387
|
workflowPreferences,
|
|
2388
|
+
planningPreferences,
|
|
2373
2389
|
capabilityCeiling,
|
|
2374
2390
|
taskInput,
|
|
2375
2391
|
childIndex,
|
|
@@ -2596,6 +2612,9 @@ function createDelegationBridge(deps) {
|
|
|
2596
2612
|
agentScope: "both",
|
|
2597
2613
|
sessionScope: session.sessionScope,
|
|
2598
2614
|
parentSessionId: session.sessionId,
|
|
2615
|
+
parentSelection: session.parentSelection,
|
|
2616
|
+
repoRoot: session.repoRoot,
|
|
2617
|
+
environment: session.environment,
|
|
2599
2618
|
...forkRequestFields(forkSource),
|
|
2600
2619
|
availableModels: await session.availableModels(),
|
|
2601
2620
|
...session.parentModel ? { parentModel: session.parentModel } : {}
|
|
@@ -2624,6 +2643,11 @@ function createDelegationBridge(deps) {
|
|
|
2624
2643
|
requestId: request.requestId,
|
|
2625
2644
|
runId: outcome.runId
|
|
2626
2645
|
});
|
|
2646
|
+
if (outcome.warning) try {
|
|
2647
|
+
await session.reportWarning?.(outcome.warning);
|
|
2648
|
+
} catch (error) {
|
|
2649
|
+
process.emitWarning(`Delegation warning could not be delivered: ${error instanceof Error ? error.message : String(error)}`);
|
|
2650
|
+
}
|
|
2627
2651
|
await monitor(entry, request, ctx, jobs, session.sessionId, session.sessionScope);
|
|
2628
2652
|
} catch (error) {
|
|
2629
2653
|
finish(entry, {
|
|
@@ -4892,6 +4916,8 @@ function createHeadlessSubagentTool(runtime, initialExecution) {
|
|
|
4892
4916
|
sessionScope: require_externalProcessIpc.createSessionScope(execution.sessionId),
|
|
4893
4917
|
environment: execution.environment,
|
|
4894
4918
|
parentSessionId: execution.sessionId,
|
|
4919
|
+
parentSelection: execution.selection,
|
|
4920
|
+
repoRoot: execution.repoRoot,
|
|
4895
4921
|
...params.concurrency === void 0 ? {} : { concurrency: params.concurrency },
|
|
4896
4922
|
...params.artifacts === void 0 ? {} : { artifacts: params.artifacts },
|
|
4897
4923
|
availableModels: await availableModelInfos(execution),
|
|
@@ -4992,7 +5018,7 @@ function subscribeNativeRunProjection(sessionId, listener) {
|
|
|
4992
5018
|
if (closed) return;
|
|
4993
5019
|
closed = true;
|
|
4994
5020
|
projection.listeners.delete(listener);
|
|
4995
|
-
if (projection.listeners.size === 0 && projection.runs.size === 0) sessions.delete(sessionId);
|
|
5021
|
+
if (projection.listeners.size === 0 && projection.runs.size === 0 && sessions.get(sessionId) === projection) sessions.delete(sessionId);
|
|
4996
5022
|
};
|
|
4997
5023
|
}
|
|
4998
5024
|
//#endregion
|
|
@@ -6386,9 +6412,17 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ context, host:
|
|
|
6386
6412
|
cwd: execution.cwd,
|
|
6387
6413
|
environment: serverHost.context.environment,
|
|
6388
6414
|
availableModels: () => availableModelInfos(execution),
|
|
6415
|
+
repoRoot: execution.repoRoot,
|
|
6416
|
+
get parentSelection() {
|
|
6417
|
+
return execution.selection;
|
|
6418
|
+
},
|
|
6389
6419
|
get parentModel() {
|
|
6390
6420
|
return execution.model;
|
|
6391
6421
|
},
|
|
6422
|
+
reportWarning: (body) => execution.client.notify({
|
|
6423
|
+
body,
|
|
6424
|
+
level: "warning"
|
|
6425
|
+
}),
|
|
6392
6426
|
captureForkSource: () => execution.session.forkSource?.()
|
|
6393
6427
|
},
|
|
6394
6428
|
directRunTracker: runtime.asyncJobTracker,
|
|
@@ -6521,39 +6555,43 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ context, host:
|
|
|
6521
6555
|
async onDispose() {
|
|
6522
6556
|
disposing = true;
|
|
6523
6557
|
activityAttached = false;
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6558
|
+
let stoppedRuns;
|
|
6559
|
+
await (0, _agimon_ai_po_core_extensionFile.runCleanups)([
|
|
6560
|
+
() => stopPeerDiscovery?.(),
|
|
6561
|
+
() => sessionPeers.clear(),
|
|
6562
|
+
() => execution.client.setStatus(TEAM_COST_STATUS, void 0),
|
|
6563
|
+
() => channel.dispose(),
|
|
6564
|
+
() => runtime.completionNotifier.dispose(),
|
|
6565
|
+
async () => {
|
|
6566
|
+
stoppedRuns = await stopScopeRuns({
|
|
6567
|
+
reason: "headless session ended",
|
|
6568
|
+
jobs: jobs.list(),
|
|
6569
|
+
stop: (runId, reason) => runtime.management.stop(runId, reason)
|
|
6570
|
+
});
|
|
6571
|
+
},
|
|
6572
|
+
() => (0, _agimon_ai_po_core_extensionFile.runCleanups)([() => runtime.nativeRuns.close(), () => nativeRunProjection.dispose(execution.sessionId)], "Native Team runs cleanup failed."),
|
|
6573
|
+
unsubscribeCostTracker,
|
|
6574
|
+
unsubscribeCostNative,
|
|
6575
|
+
() => nativeRuns.clear(),
|
|
6576
|
+
() => childCosts.clear(),
|
|
6577
|
+
() => {
|
|
6578
|
+
costText = void 0;
|
|
6579
|
+
},
|
|
6580
|
+
() => bridge.abandonAll(),
|
|
6581
|
+
() => fablePlan.abandonAll(),
|
|
6582
|
+
() => runtime.capabilityPolicies.clear(),
|
|
6583
|
+
() => runtime.management.releaseSessionScope(scope),
|
|
6584
|
+
() => runtime.dispose(),
|
|
6585
|
+
() => runtime.asyncJobTracker.stop(),
|
|
6586
|
+
() => runtime.pollScheduler.stop(),
|
|
6587
|
+
() => telemetry.recordEvent("po_team.session_finished", {
|
|
6588
|
+
reason: "headless session ended",
|
|
6589
|
+
"team.stopped_count": stoppedRuns?.stopped.length ?? 0,
|
|
6590
|
+
"team.unstoppable_count": stoppedRuns?.unstoppable.length ?? 0,
|
|
6591
|
+
outcome: stoppedRuns && !stoppedRuns.unstoppable.length ? "stopped" : "degraded"
|
|
6592
|
+
}),
|
|
6593
|
+
() => telemetry.shutdown()
|
|
6594
|
+
], "Team cleanup failed.");
|
|
6557
6595
|
}
|
|
6558
6596
|
};
|
|
6559
6597
|
});
|