@agimon-ai/po-team 0.0.0-alpha.124 → 0.0.0-alpha.126
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/dist/coordinatorSessions.cjs +13 -3
- package/dist/coordinatorSessions.d.mts +2 -26
- package/dist/coordinatorSessions.mjs +1 -1
- package/dist/extensions/server.cjs +90 -99
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +30 -39
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/runtimeSubagentTool.cjs +1 -1
- package/dist/runtimeSubagentTool.d.mts +1 -1
- package/dist/runtimeSubagentTool.mjs +1 -1
- package/dist/{subagentTool-oRLu2Avh.mjs → subagentTool-CBADRWGC.mjs} +2 -2
- package/dist/{subagentTool-oRLu2Avh.mjs.map → subagentTool-CBADRWGC.mjs.map} +1 -1
- package/dist/{subagentTool-DP0qLQDh.cjs → subagentTool-CVP0n-wA.cjs} +2 -2
- package/dist/{subagentTool-DP0qLQDh.cjs.map → subagentTool-CVP0n-wA.cjs.map} +1 -1
- package/dist/{subagentTool-C4uQPolH.d.mts → subagentTool-DnFhEWuC.d.mts} +2 -2
- package/dist/{subagentTool-C4uQPolH.d.mts.map → subagentTool-DnFhEWuC.d.mts.map} +1 -1
- package/dist/subagentTool.cjs +1 -1
- package/dist/subagentTool.d.mts +1 -1
- package/dist/subagentTool.mjs +1 -1
- package/package.json +10 -10
- package/src/prompts/codemode-how-to-team/SKILL.md +3 -17
- package/dist/coordinatorSessions-DJr4jZJR.mjs +0 -94
- package/dist/coordinatorSessions-DJr4jZJR.mjs.map +0 -1
- package/dist/coordinatorSessions-wvx0tV3-.cjs +0 -123
- package/dist/coordinatorSessions-wvx0tV3-.cjs.map +0 -1
- package/dist/coordinatorSessions.d.mts.map +0 -1
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
2
|
+
let _agimon_ai_po_session = require("@agimon-ai/po-session");
|
|
3
|
+
Object.defineProperty(exports, "createStartSessionTool", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return _agimon_ai_po_session.createStartSessionTool;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
Object.defineProperty(exports, "startCoordinatedSession", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return _agimon_ai_po_session.startCoordinatedSession;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { PoSessionCoordination } from "@agimon-ai/po-core/packageApi";
|
|
4
|
-
//#region src/schemas/team/startSession.d.ts
|
|
5
|
-
/** The schema declared to the model for `start_session` and mirrored by `team.startSession`. */
|
|
6
|
-
declare const StartSessionParamsSchema: Type.TObject<{
|
|
7
|
-
name: Type.TString;
|
|
8
|
-
brief: Type.TString;
|
|
9
|
-
workspaceId: Type.TOptional<Type.TString>;
|
|
10
|
-
}>;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/services/coordinatorSessions/index.d.ts
|
|
13
|
-
interface CoordinatorSessionsOptions {
|
|
14
|
-
/** The calling session's provenance, read live. */
|
|
15
|
-
provenance(): string | undefined;
|
|
16
|
-
/** Host coordination; absent on hosts that cannot start sessions. */
|
|
17
|
-
coordination(): PoSessionCoordination | undefined;
|
|
18
|
-
}
|
|
19
|
-
/** The one implementation behind `team.startSession` and the `start_session` tool. Returns detached JSON. */
|
|
20
|
-
export declare function startCoordinatedSession(options: CoordinatorSessionsOptions, raw: unknown, signal?: AbortSignal): Promise<{
|
|
21
|
-
sessionId: string;
|
|
22
|
-
}>;
|
|
23
|
-
export declare function createStartSessionTool(options: CoordinatorSessionsOptions): PoHeadlessTool<typeof StartSessionParamsSchema>;
|
|
24
|
-
//#endregion
|
|
25
|
-
export type { CoordinatorSessionsOptions };
|
|
26
|
-
//# sourceMappingURL=coordinatorSessions.d.mts.map
|
|
1
|
+
import { CoordinatorSessionsOptions, createStartSessionTool, startCoordinatedSession } from "@agimon-ai/po-session";
|
|
2
|
+
export { type CoordinatorSessionsOptions, createStartSessionTool, startCoordinatedSession };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createStartSessionTool, startCoordinatedSession } from "@agimon-ai/po-session";
|
|
@@ -5,13 +5,11 @@ Object.defineProperties(exports, {
|
|
|
5
5
|
const require_agentDiscovery = require("../agentDiscovery-4MvlNlGi.cjs");
|
|
6
6
|
const require_environment = require("../environment-COaoVl5M.cjs");
|
|
7
7
|
const require_capabilityCeiling = require("../capabilityCeiling-x2WmB2TL.cjs");
|
|
8
|
-
const require_coordinatorSessions = require("../coordinatorSessions-wvx0tV3-.cjs");
|
|
9
8
|
const require_subagentPolicy = require("../subagentPolicy-DYj_SOTG.cjs");
|
|
10
|
-
const require_subagentTool = require("../subagentTool-
|
|
9
|
+
const require_subagentTool = require("../subagentTool-CVP0n-wA.cjs");
|
|
11
10
|
const require_teamSnapshot = require("../teamSnapshot-oKuGFdYc.cjs");
|
|
12
11
|
let _agimon_ai_po_core_childProcess = require("@agimon-ai/po-core/childProcess");
|
|
13
|
-
let
|
|
14
|
-
let typebox = require("typebox");
|
|
12
|
+
let _agimon_ai_po_session = require("@agimon-ai/po-session");
|
|
15
13
|
let _agimon_ai_po_core_delegation = require("@agimon-ai/po-core/delegation");
|
|
16
14
|
let node_path = require("node:path");
|
|
17
15
|
node_path = require_agentDiscovery.__toESM(node_path, 1);
|
|
@@ -20,6 +18,7 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
20
18
|
node_fs_promises = require_agentDiscovery.__toESM(node_fs_promises, 1);
|
|
21
19
|
let node_os = require("node:os");
|
|
22
20
|
node_os = require_agentDiscovery.__toESM(node_os, 1);
|
|
21
|
+
let typebox = require("typebox");
|
|
23
22
|
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
24
23
|
let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
|
|
25
24
|
let _agimon_ai_po_config = require("@agimon-ai/po-config");
|
|
@@ -27,9 +26,9 @@ let _agimon_ai_po_core_backgroundWork = require("@agimon-ai/po-core/backgroundWo
|
|
|
27
26
|
let _agimon_ai_po_core_childSession = require("@agimon-ai/po-core/childSession");
|
|
28
27
|
let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
|
|
29
28
|
let _agimon_ai_po_core_contextContributions = require("@agimon-ai/po-core/contextContributions");
|
|
29
|
+
let _agimon_ai_po_core_hubChannel = require("@agimon-ai/po-core/hubChannel");
|
|
30
30
|
let _agimon_ai_po_core_mcpToolResolver = require("@agimon-ai/po-core/mcpToolResolver");
|
|
31
31
|
let _agimon_ai_po_core_telemetry = require("@agimon-ai/po-core/telemetry");
|
|
32
|
-
let _agimon_ai_po_session = require("@agimon-ai/po-session");
|
|
33
32
|
let node_crypto = require("node:crypto");
|
|
34
33
|
let typebox_value = require("typebox/value");
|
|
35
34
|
let _agimon_ai_po_core_headless = require("@agimon-ai/po-core/headless");
|
|
@@ -1352,6 +1351,23 @@ function preflightSubagentDepth(depth, config) {
|
|
|
1352
1351
|
};
|
|
1353
1352
|
}
|
|
1354
1353
|
//#endregion
|
|
1354
|
+
//#region src/services/errors/index.ts
|
|
1355
|
+
var PoTeamExpectedError = class extends Error {
|
|
1356
|
+
code;
|
|
1357
|
+
retryable;
|
|
1358
|
+
recovery;
|
|
1359
|
+
constructor(code, message, retryable, recovery) {
|
|
1360
|
+
super(`[${code}] ${message}\nRecovery: ${recovery}`);
|
|
1361
|
+
this.code = code;
|
|
1362
|
+
this.retryable = retryable;
|
|
1363
|
+
this.recovery = recovery;
|
|
1364
|
+
this.name = "PoTeamExpectedError";
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
function invalidRequest(message, recovery) {
|
|
1368
|
+
return new PoTeamExpectedError("invalid_request", message, false, recovery);
|
|
1369
|
+
}
|
|
1370
|
+
//#endregion
|
|
1355
1371
|
//#region src/services/modelResolution/index.ts
|
|
1356
1372
|
/**
|
|
1357
1373
|
* Resolving a loosely-spelled model name to a canonical `provider/id`.
|
|
@@ -2038,7 +2054,7 @@ function appendPromptSection(prompt, section) {
|
|
|
2038
2054
|
}
|
|
2039
2055
|
function readWorkflowPreferences(payload) {
|
|
2040
2056
|
if (payload === void 0) return {};
|
|
2041
|
-
const invalid = (detail) => new
|
|
2057
|
+
const invalid = (detail) => new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `WORKFLOW_RUN_CONFIG ${detail}`, false, "Provide a JSON object with optional nonblank subagentModel and recognized subagentThinking.");
|
|
2042
2058
|
let value;
|
|
2043
2059
|
try {
|
|
2044
2060
|
value = JSON.parse(payload);
|
|
@@ -2106,7 +2122,7 @@ function resolvedModelSelection(taskInput, agentConfig, runtime, parentModel, av
|
|
|
2106
2122
|
const thinking = explicitThinking || preferredThinking || selectedSuffix || agentThinking || teamThinkingFor(model);
|
|
2107
2123
|
const workflowThinking = !explicitThinking && (preferredThinking || selectedCandidate === preferences.subagentModel && selectedSuffix);
|
|
2108
2124
|
const modelInfo = findModelInfo(model, availableModels);
|
|
2109
|
-
if (isPiRuntime(runtime) && workflowThinking && modelInfo && !getSupportedThinkingLevels(modelInfo).some((level) => level === thinking)) throw new
|
|
2125
|
+
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(", ")}.`);
|
|
2110
2126
|
if (model && selectedSuffix && !explicitThinking && preferredThinking) model = splitKnownThinkingSuffix(model).baseModel;
|
|
2111
2127
|
return {
|
|
2112
2128
|
primaryModel,
|
|
@@ -2153,9 +2169,9 @@ var SpawnPlanner = class {
|
|
|
2153
2169
|
try {
|
|
2154
2170
|
stat = await node_fs_promises.stat(cwd);
|
|
2155
2171
|
} catch {
|
|
2156
|
-
throw new
|
|
2172
|
+
throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `Working directory '${cwd}' does not exist.`, false, "Retry with an existing directory.");
|
|
2157
2173
|
}
|
|
2158
|
-
if (!stat.isDirectory()) throw new
|
|
2174
|
+
if (!stat.isDirectory()) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `Working directory '${cwd}' is not a directory.`, false, "Retry with an existing directory.");
|
|
2159
2175
|
}
|
|
2160
2176
|
async executableAvailable(command) {
|
|
2161
2177
|
if (node_path.isAbsolute(command) || command.includes(node_path.sep)) try {
|
|
@@ -2172,14 +2188,14 @@ var SpawnPlanner = class {
|
|
|
2172
2188
|
}
|
|
2173
2189
|
resolveTaskList(request) {
|
|
2174
2190
|
const hasSingle = request.single !== void 0;
|
|
2175
|
-
if (hasSingle === (request.tasks !== void 0)) throw new
|
|
2191
|
+
if (hasSingle === (request.tasks !== void 0)) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, "A run requires exactly one of internal single or tasks representations.", false, "Submit a non-empty requests array.");
|
|
2176
2192
|
if (hasSingle) return [request.single];
|
|
2177
|
-
if (!request.tasks || request.tasks.length === 0) throw new
|
|
2193
|
+
if (!request.tasks || request.tasks.length === 0) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, "A run requires at least one entry in its requests collection.", false, "Submit a non-empty requests array.");
|
|
2178
2194
|
return request.tasks;
|
|
2179
2195
|
}
|
|
2180
2196
|
async resolveAgentOrThrow(name, cwd, scope) {
|
|
2181
2197
|
const resolved = await this.agents.find(cwd, scope, name);
|
|
2182
|
-
if (!resolved) throw new
|
|
2198
|
+
if (!resolved) throw new PoTeamExpectedError(ERROR_CODE_AGENT_NOT_FOUND, `Unknown agent '${name}'.`, false, "Call subagent({\"action\":\"agents\"}) and retry with an exact name.");
|
|
2183
2199
|
return resolved;
|
|
2184
2200
|
}
|
|
2185
2201
|
async resolveExecutableAgent(taskInput, cwd, scope, inheritParent = false) {
|
|
@@ -2410,7 +2426,7 @@ var SpawnPlanner = class {
|
|
|
2410
2426
|
}
|
|
2411
2427
|
}
|
|
2412
2428
|
async spawn(request, config) {
|
|
2413
|
-
if (!this.agentConfig) throw new
|
|
2429
|
+
if (!this.agentConfig) throw new PoTeamExpectedError("runtime_unavailable", "Team agent configuration is not loaded yet.", true, "Retry after the session configuration is ready.");
|
|
2414
2430
|
const team = await this.agentConfig.current();
|
|
2415
2431
|
request.signal?.throwIfAborted();
|
|
2416
2432
|
const tasks = this.resolveTaskList(request);
|
|
@@ -2434,12 +2450,12 @@ var SpawnPlanner = class {
|
|
|
2434
2450
|
const teamPackageModels = team.models;
|
|
2435
2451
|
const capabilityCeiling = this.policies.resolve();
|
|
2436
2452
|
const depthCheck = preflightSubagentDepth(request.currentDepth ?? resolveCurrentSubagentDepth(), config);
|
|
2437
|
-
if (depthCheck.error) throw new
|
|
2453
|
+
if (depthCheck.error) throw new PoTeamExpectedError(ERROR_CODE_UNSUPPORTED_OPERATION, depthCheck.error, false, "Give each child a self-contained task within the Team package policy.");
|
|
2438
2454
|
const maxTasks = config.parallel?.maxTasks ?? DEFAULT_PARALLEL_MAX_TASKS;
|
|
2439
|
-
if (tasks.length > maxTasks) throw new
|
|
2455
|
+
if (tasks.length > maxTasks) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `Run requested ${tasks.length} tasks, but at most ${maxTasks} may be declared in one call. Concurrency throttles how fast they start, not how many run.`, false, "Send at most that many requests in this call and wait for them, or raise parallel.maxTasks in the subagent config. Splitting the same width across extra calls does not raise the live-child ceiling.");
|
|
2440
2456
|
for (const taskInput of tasks) {
|
|
2441
|
-
if (!taskInput.task?.trim()) throw new
|
|
2442
|
-
if (taskInput.inlineAgent && !taskInput.inlineAgent.systemPrompt.trim()) throw new
|
|
2457
|
+
if (!taskInput.task?.trim()) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `Run request for '${taskInput.agent}' requires a nonblank task.`, false, "Provide a self-contained nonblank task.");
|
|
2458
|
+
if (taskInput.inlineAgent && !taskInput.inlineAgent.systemPrompt.trim()) throw new PoTeamExpectedError(ERROR_CODE_INVALID_REQUEST, `Inline agent '${taskInput.agent}' requires a nonblank system prompt.`, false, "Provide a focused read-only exploration role.");
|
|
2443
2459
|
}
|
|
2444
2460
|
const resolvedAgentCache = /* @__PURE__ */ new Map();
|
|
2445
2461
|
const resolvedAgents = [];
|
|
@@ -2460,11 +2476,11 @@ var SpawnPlanner = class {
|
|
|
2460
2476
|
const effectiveContext = resolveEffectiveContext(taskInput, resolvedAgents[index]);
|
|
2461
2477
|
const runtime = taskInput.runtime ?? request.runtime ?? resolvedAgents[index].runtime ?? "pi";
|
|
2462
2478
|
if (effectiveContext === CONTEXT_FORK) {
|
|
2463
|
-
if (!isPiRuntime(runtime)) throw new
|
|
2464
|
-
if (!request.parentForkSource) throw new
|
|
2479
|
+
if (!isPiRuntime(runtime)) throw new PoTeamExpectedError(ERROR_CODE_UNSUPPORTED_CONTEXT, `Fork context requires ${PI_RUNTIME_REQUIREMENT} for '${taskInput.agent}'.`, false, "Use a Pi agent for fork context or explicitly request a fresh run.");
|
|
2480
|
+
if (!request.parentForkSource) throw new PoTeamExpectedError(ERROR_CODE_UNSUPPORTED_CONTEXT, `Fork context is unavailable for '${taskInput.agent}': ${describeForkFailure(request.parentForkFailure)}.`, false, "Use an active Pi session with a completed parent turn or explicitly request a fresh run.");
|
|
2465
2481
|
}
|
|
2466
2482
|
}
|
|
2467
|
-
if (request.preallocatedRunIds && request.preallocatedRunIds.length !== tasks.length) throw new
|
|
2483
|
+
if (request.preallocatedRunIds && request.preallocatedRunIds.length !== tasks.length) throw new PoTeamExpectedError(ERROR_CODE_OPERATION_CONFLICT, "The operation journal run-id count does not match the request count.", false, "Submit the run as a new tool call.");
|
|
2468
2484
|
const runIds = request.preallocatedRunIds ?? tasks.map(() => this.generateRunId());
|
|
2469
2485
|
const identities = [];
|
|
2470
2486
|
for (const [index, taskInput] of tasks.entries()) identities.push(await claimAgentIdentity(request.sessionScope, {
|
|
@@ -2478,8 +2494,8 @@ var SpawnPlanner = class {
|
|
|
2478
2494
|
await this.validateCwd(cwd);
|
|
2479
2495
|
const runtime = taskInput.runtime ?? request.runtime ?? agent.runtime ?? "pi";
|
|
2480
2496
|
const modelSelection = resolvedModelSelection(taskInput, agent, runtime, request.parentModel, request.availableModels, teamPackageModels, workflowPreferences, planningPreferences, team.thinking);
|
|
2481
|
-
if (modelSelection.primaryModel && request.availableModels !== void 0 && !modelSelection.model) throw new
|
|
2482
|
-
if (!isPiRuntime(runtime)) throw new
|
|
2497
|
+
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.");
|
|
2498
|
+
if (!isPiRuntime(runtime)) throw new PoTeamExpectedError(ERROR_CODE_RUNTIME_UNAVAILABLE, `External Team runtime '${runtime}' is retired.`, false, `Use ${PI_RUNTIME_REQUIREMENT}.`);
|
|
2483
2499
|
}
|
|
2484
2500
|
const concurrency = fanout ? request.concurrency ?? config.parallel?.concurrency ?? DEFAULT_PARALLEL_CONCURRENCY : 1;
|
|
2485
2501
|
const maxLiveRuns = Math.max(1, config.parallel?.maxLiveRuns ?? DEFAULT_MAX_LIVE_RUNS);
|
|
@@ -2985,11 +3001,11 @@ function validateTask(task) {
|
|
|
2985
3001
|
};
|
|
2986
3002
|
}
|
|
2987
3003
|
function parseTeamToolParams(raw) {
|
|
2988
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw
|
|
3004
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw invalidRequest("Intercom params must be an object.", "Use one documented intercom action shape.");
|
|
2989
3005
|
const params = raw;
|
|
2990
3006
|
const action = TEAM_ACTIONS.find((candidate) => candidate === params.action);
|
|
2991
|
-
if (!action) throw new
|
|
2992
|
-
if (!isOptionalString(params.to) || !isOptionalString(params.message) || !isOptionalString(params.requestId)) throw
|
|
3007
|
+
if (!action) throw new PoTeamExpectedError("unsupported_operation", `Unsupported intercom action: ${String(params.action)}.`, false, "Use members, send, ask, pending, or reply.");
|
|
3008
|
+
if (!isOptionalString(params.to) || !isOptionalString(params.message) || !isOptionalString(params.requestId)) throw invalidRequest("Intercom to, message and requestId values must be strings.", "Correct the action fields and retry.");
|
|
2993
3009
|
const allowed = new Set(action === "members" || action === "pending" ? ["action"] : action === "reply" ? [
|
|
2994
3010
|
"action",
|
|
2995
3011
|
"requestId",
|
|
@@ -3000,9 +3016,9 @@ function parseTeamToolParams(raw) {
|
|
|
3000
3016
|
"message"
|
|
3001
3017
|
]);
|
|
3002
3018
|
const unknown = Object.keys(params).filter((field) => !allowed.has(field));
|
|
3003
|
-
if (unknown.length) throw
|
|
3004
|
-
if ((action === "send" || action === "ask") && !params.to?.trim()) throw
|
|
3005
|
-
if (action === "reply" && !params.requestId?.trim()) throw
|
|
3019
|
+
if (unknown.length) throw invalidRequest(`Intercom action '${action}' does not accept: ${unknown.join(", ")}.`, "Remove unknown fields and retry.");
|
|
3020
|
+
if ((action === "send" || action === "ask") && !params.to?.trim()) throw invalidRequest(`Intercom action '${action}' requires to.`, "Pass the member id to address and retry.");
|
|
3021
|
+
if (action === "reply" && !params.requestId?.trim()) throw invalidRequest("Intercom action 'reply' requires requestId.", "Pass the requestId from the question and retry.");
|
|
3006
3022
|
return {
|
|
3007
3023
|
action,
|
|
3008
3024
|
...params.to !== void 0 ? { to: params.to } : {},
|
|
@@ -3012,8 +3028,8 @@ function parseTeamToolParams(raw) {
|
|
|
3012
3028
|
}
|
|
3013
3029
|
function validateMessage(message) {
|
|
3014
3030
|
const normalized = message?.trim();
|
|
3015
|
-
if (!normalized) throw
|
|
3016
|
-
if (!withinBytes(normalized, MAX_MESSAGE_BYTES)) throw
|
|
3031
|
+
if (!normalized) throw invalidRequest("message is required for intercom communication.", "Provide a nonblank message.");
|
|
3032
|
+
if (!withinBytes(normalized, MAX_MESSAGE_BYTES)) throw invalidRequest("Intercom message exceeds 64 KiB.", "Shorten the message and retry.");
|
|
3017
3033
|
return normalized;
|
|
3018
3034
|
}
|
|
3019
3035
|
function toChildSessionToolResult(result) {
|
|
@@ -3206,7 +3222,7 @@ var NativeTeamDirectChannel = class {
|
|
|
3206
3222
|
if (params.action === "reply") {
|
|
3207
3223
|
const request = this.asks.get(params.requestId ?? "");
|
|
3208
3224
|
const asker = request && this.members.get(request.fromMemberId);
|
|
3209
|
-
if (!request || request.toMemberId !== memberId || !asker) throw new
|
|
3225
|
+
if (!request || request.toMemberId !== memberId || !asker) throw new PoTeamExpectedError("recipient_not_found", `No open intercom ask matches requestId '${params.requestId}'. It may already be answered, or its asker has finished.`, false, "Call intercom({\"action\":\"pending\"}) and retry with an exact requestId, or continue without replying.");
|
|
3210
3226
|
await this.deliver(asker, formatDirectMessage(member.context, "reply", request.id, message));
|
|
3211
3227
|
this.closeAsk(request);
|
|
3212
3228
|
return {
|
|
@@ -3222,7 +3238,7 @@ var NativeTeamDirectChannel = class {
|
|
|
3222
3238
|
};
|
|
3223
3239
|
}
|
|
3224
3240
|
const target = this.findMember(params.to);
|
|
3225
|
-
if (!target) throw new
|
|
3241
|
+
if (!target) throw new PoTeamExpectedError("recipient_not_found", `Active intercom member '${params.to}' was not found.`, true, "Call intercom({\"action\":\"members\"}) and retry with an active member id.");
|
|
3226
3242
|
const messageId = operationMessageId(memberId, operationId);
|
|
3227
3243
|
const isAsk = params.action === "ask";
|
|
3228
3244
|
const result = () => ({
|
|
@@ -3293,15 +3309,15 @@ var NativeTeamDirectChannel = class {
|
|
|
3293
3309
|
}
|
|
3294
3310
|
async deliver(target, message) {
|
|
3295
3311
|
const id = target.context.memberId;
|
|
3296
|
-
if (this.members.get(id) !== target) throw new
|
|
3297
|
-
if (!target.deliver) throw new
|
|
3312
|
+
if (this.members.get(id) !== target) throw new PoTeamExpectedError("communication_unavailable", `Intercom member '${id}' has finished.`, false, "Call intercom({\"action\":\"members\"}) to see who is active.");
|
|
3313
|
+
if (!target.deliver) throw new PoTeamExpectedError("communication_unavailable", `Intercom member '${id}' is not ready.`, true, "Retry after the child session starts.");
|
|
3298
3314
|
target.inFlight += 1;
|
|
3299
3315
|
try {
|
|
3300
3316
|
await target.deliver(message);
|
|
3301
3317
|
target.delivered = true;
|
|
3302
3318
|
} catch (error) {
|
|
3303
|
-
if (error instanceof
|
|
3304
|
-
throw new
|
|
3319
|
+
if (error instanceof PoTeamExpectedError) throw error;
|
|
3320
|
+
throw new PoTeamExpectedError("communication_unavailable", `Intercom member '${id}' could not receive the message: ${error instanceof Error ? error.message : String(error)}`, true, "Retry shortly, or continue without it.");
|
|
3305
3321
|
} finally {
|
|
3306
3322
|
target.inFlight -= 1;
|
|
3307
3323
|
target.release?.(true);
|
|
@@ -3328,7 +3344,7 @@ var TeamChannelRuntime = class {
|
|
|
3328
3344
|
}
|
|
3329
3345
|
execute(operationId, rawParams) {
|
|
3330
3346
|
const context = this.context;
|
|
3331
|
-
if (!context || !this.directChannel) throw new
|
|
3347
|
+
if (!context || !this.directChannel) throw new PoTeamExpectedError("communication_unavailable", "Intercom is not active for this session.", true, "Wait for session startup or reload Po Team.");
|
|
3332
3348
|
return this.directChannel.execute(context.memberId, operationId, rawParams);
|
|
3333
3349
|
}
|
|
3334
3350
|
bindMainSession(rootSessionId) {
|
|
@@ -3395,7 +3411,7 @@ function resolvePeer(peers, to) {
|
|
|
3395
3411
|
if (byId !== void 0) return byId;
|
|
3396
3412
|
const wanted = to.toLowerCase();
|
|
3397
3413
|
const named = peers.filter((peer) => peer.name.trim().toLowerCase() === wanted);
|
|
3398
|
-
if (named.length > 1) throw
|
|
3414
|
+
if (named.length > 1) throw invalidRequest(`${String(named.length)} sessions are named "${to}".`, `Send to one session ID: ${named.map((peer) => peer.sessionId).join(", ")}.`);
|
|
3399
3415
|
return named[0];
|
|
3400
3416
|
}
|
|
3401
3417
|
function describePeerLine(peer) {
|
|
@@ -3424,12 +3440,12 @@ function createHeadlessIntercomTool(channel, sessions) {
|
|
|
3424
3440
|
const teamMember = to !== void 0 && channel.snapshot().members.some((member) => member.name === to) && !knownId && !peers.some((peer) => peer.sessionId === to);
|
|
3425
3441
|
const peer = sessions === void 0 || to === void 0 || teamMember ? void 0 : knownId ? peers.find((candidate) => candidate.sessionId === to) : resolvePeer(peers, to);
|
|
3426
3442
|
const recipientId = knownId ? to : peer?.sessionId;
|
|
3427
|
-
if (sessions !== void 0 && to?.startsWith("peer/") && recipientId === void 0) throw
|
|
3443
|
+
if (sessions !== void 0 && to?.startsWith("peer/") && recipientId === void 0) throw invalidRequest("Remote session is not in a linked shared group.", "Use members to find current peers.");
|
|
3428
3444
|
if (sessions !== void 0 && recipientId !== void 0) {
|
|
3429
3445
|
const remote = recipientId.startsWith("peer/");
|
|
3430
3446
|
const metadata = remote ? sessions.metadataFor?.(recipientId) : void 0;
|
|
3431
|
-
if (remote && (metadata === void 0 || !sessions.canCommunicate(recipientId))) throw
|
|
3432
|
-
if (params.action !== "send") throw
|
|
3447
|
+
if (remote && (metadata === void 0 || !sessions.canCommunicate(recipientId))) throw invalidRequest("Remote session is not in a linked shared group.", "Use members to find current peers.");
|
|
3448
|
+
if (params.action !== "send") throw invalidRequest("Session peers support send only.", "Use send with the session name or ID.");
|
|
3433
3449
|
const message = validateMessage(params.message);
|
|
3434
3450
|
const delivery = sessions.delivery();
|
|
3435
3451
|
if (delivery === void 0) throw new Error("Session delivery is unavailable.");
|
|
@@ -4353,7 +4369,7 @@ async function startOperation(scope, operationId, args, runIds) {
|
|
|
4353
4369
|
} catch (error) {
|
|
4354
4370
|
if (!(error instanceof Error && "code" in error && error.code === "EEXIST")) throw error;
|
|
4355
4371
|
const existing = await readRecord(file);
|
|
4356
|
-
if (existing.argumentHash !== argumentHash) throw new
|
|
4372
|
+
if (existing.argumentHash !== argumentHash) throw new PoTeamExpectedError("operation_conflict", `Operation '${operationId}' was already used with different arguments.`, false, "Submit the operation as a new tool call.");
|
|
4357
4373
|
return {
|
|
4358
4374
|
kind: "replay",
|
|
4359
4375
|
record: existing
|
|
@@ -4430,18 +4446,18 @@ function formatAgentDetail(agent) {
|
|
|
4430
4446
|
].join("\n");
|
|
4431
4447
|
}
|
|
4432
4448
|
function requireNonblank(record, field, action) {
|
|
4433
|
-
if (typeof record[field] !== "string" || !record[field].trim()) throw
|
|
4449
|
+
if (typeof record[field] !== "string" || !record[field].trim()) throw invalidRequest(`action='${action}' requires nonblank '${field}'.`, "Correct the request and retry.");
|
|
4434
4450
|
}
|
|
4435
4451
|
function validateParams(input) {
|
|
4436
4452
|
const raw = require_subagentTool.normalizeSubagentToolParams(input);
|
|
4437
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw
|
|
4453
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw invalidRequest("subagent parameters must be an object.", "Call subagent with one documented action shape.");
|
|
4438
4454
|
const record = raw;
|
|
4439
4455
|
const action = record.action;
|
|
4440
|
-
if (typeof action !== "string" || !IMPLEMENTED_SUBAGENT_ACTIONS.has(action)) throw
|
|
4456
|
+
if (typeof action !== "string" || !IMPLEMENTED_SUBAGENT_ACTIONS.has(action)) throw invalidRequest(`Unsupported or missing subagent action ${JSON.stringify(action)}.`, `Use one of: ${[...IMPLEMENTED_SUBAGENT_ACTIONS].join(", ")}.`);
|
|
4441
4457
|
const allowed = require_subagentTool.SUBAGENT_ACTION_FIELDS[action];
|
|
4442
4458
|
const unknown = Object.keys(record).filter((field) => !allowed.includes(field));
|
|
4443
|
-
if (unknown.length) throw
|
|
4444
|
-
if (action === require_subagentTool.SUBAGENT_ACTIONS.run && (!Array.isArray(record.requests) || record.requests.length === 0)) throw
|
|
4459
|
+
if (unknown.length) throw invalidRequest(`action='${action}' does not accept: ${unknown.join(", ")}.`, "Remove unknown fields and retry.");
|
|
4460
|
+
if (action === require_subagentTool.SUBAGENT_ACTIONS.run && (!Array.isArray(record.requests) || record.requests.length === 0)) throw invalidRequest("action='run' requires a nonempty 'requests' array.", "Add at least one agent and task.");
|
|
4445
4461
|
if (action === require_subagentTool.SUBAGENT_ACTIONS.steer) {
|
|
4446
4462
|
requireNonblank(record, "id", action);
|
|
4447
4463
|
requireNonblank(record, "message", action);
|
|
@@ -4477,7 +4493,7 @@ var SubagentToolService = class {
|
|
|
4477
4493
|
}
|
|
4478
4494
|
async buildSpawnRequest(operationId, params, ctx, preallocatedRunIds) {
|
|
4479
4495
|
const tasks = params.requests.map((request) => {
|
|
4480
|
-
if (!request.agent.trim() || !request.task.trim()) throw
|
|
4496
|
+
if (!request.agent.trim() || !request.task.trim()) throw invalidRequest("Every run request requires nonblank agent and task values.", "Correct the request and retry.");
|
|
4481
4497
|
return {
|
|
4482
4498
|
agent: request.agent.trim(),
|
|
4483
4499
|
...request.inlineAgent ? { inlineAgent: request.inlineAgent } : {},
|
|
@@ -4510,7 +4526,7 @@ var SubagentToolService = class {
|
|
|
4510
4526
|
const operation = await startOperation(scope, operationId, params, params.requests.map(() => (0, node_crypto.randomUUID)()));
|
|
4511
4527
|
if (operation.kind === "replay") {
|
|
4512
4528
|
if (operation.record.state === "completed" && operation.record.result) return operation.record.result;
|
|
4513
|
-
throw new
|
|
4529
|
+
throw new PoTeamExpectedError("delivery_unconfirmed", `Operation '${operationId}' is already pending for runs: ${operation.record.runIds.join(", ")}.`, true, "Call subagent({\"action\":\"status\"}) and do not submit the run again.");
|
|
4514
4530
|
}
|
|
4515
4531
|
const result = this.trackOutcomes(await this.planner.spawn(await this.buildSpawnRequest(operationId, params, ctx, operation.record.runIds), (await loadConfig()).config), ctx);
|
|
4516
4532
|
const started = result.outcomes.filter((outcome) => outcome.runId);
|
|
@@ -4518,7 +4534,7 @@ var SubagentToolService = class {
|
|
|
4518
4534
|
const outcomeLines = result.outcomes.map((outcome) => {
|
|
4519
4535
|
return `- ${formatAgentIdentity(outcome.identity, outcome.inline) ?? outcome.agent}: ${outcome.runId ? outcome.runId : `failed: ${outcome.error ?? "unknown error"}`}${outcome.warning ? `\n Warning: ${outcome.warning}` : ""}`;
|
|
4520
4536
|
});
|
|
4521
|
-
if (started.length === 0 && failed.length > 0) throw new
|
|
4537
|
+
if (started.length === 0 && failed.length > 0) throw new PoTeamExpectedError("runtime_unavailable", `No requested subagent started.\n${outcomeLines.join("\n")}`, true, "Correct the reported launch failures. If an agent name is uncertain, call subagent({\"action\":\"agents\"}) before retrying only corrected requests.");
|
|
4522
4538
|
const subagentLabel = result.outcomes.length === 1 ? "subagent" : "subagents";
|
|
4523
4539
|
const summary = failed.length === 0 ? `Started ${started.length} ${subagentLabel}:` : `Started ${started.length}/${result.outcomes.length} ${subagentLabel}; ${failed.length} failed:`;
|
|
4524
4540
|
const next = failed.length === 0 ? "Completion will arrive asynchronously. Continue only non-overlapping work, or end your turn." : "Completion will arrive asynchronously for started runs. Do not resubmit them; retry only corrected failed entries.";
|
|
@@ -4545,7 +4561,7 @@ var SubagentToolService = class {
|
|
|
4545
4561
|
const agent = await this.discovery.find(cwd, scope, params.name);
|
|
4546
4562
|
if (!agent) {
|
|
4547
4563
|
const candidates = (await this.discovery.discover(cwd, scope)).agents.map((candidate) => candidate.name).toSorted();
|
|
4548
|
-
throw new
|
|
4564
|
+
throw new PoTeamExpectedError("agent_not_found", `No executable agent matches '${params.name}'.${candidates.length ? ` Available: ${candidates.join(", ")}.` : ""}`, false, "Call subagent({\"action\":\"agents\"}) and retry with an exact name.");
|
|
4549
4565
|
}
|
|
4550
4566
|
return textResult(formatAgentDetail(agent), { agent: publicAgent(agent) });
|
|
4551
4567
|
}
|
|
@@ -4556,14 +4572,14 @@ var SubagentToolService = class {
|
|
|
4556
4572
|
switch (params.action) {
|
|
4557
4573
|
case require_subagentTool.SUBAGENT_ACTIONS.status: {
|
|
4558
4574
|
if (!("id" in params)) {
|
|
4559
|
-
if ("transcriptLines" in params && params.transcriptLines !== void 0) throw
|
|
4575
|
+
if ("transcriptLines" in params && params.transcriptLines !== void 0) throw invalidRequest("transcriptLines requires a run id.", "Add id or omit transcriptLines for fleet status.");
|
|
4560
4576
|
const runs = jobs.list();
|
|
4561
4577
|
return textResult(formatFleetView(runs, Date.now()), { fleet: runs });
|
|
4562
4578
|
}
|
|
4563
4579
|
const runId = params.id;
|
|
4564
|
-
if (!runId) throw
|
|
4580
|
+
if (!runId) throw invalidRequest("transcriptLines requires a run id.", "Add id or omit transcriptLines for fleet status.");
|
|
4565
4581
|
const result = this.management.status(runId);
|
|
4566
|
-
if (!result.status && !result.runDir && !result.resultPath) throw new
|
|
4582
|
+
if (!result.status && !result.runDir && !result.resultPath) throw new PoTeamExpectedError("run_not_found", `No run matches '${runId}'.`, false, "Call subagent({\"action\":\"status\"}) and retry with an exact id.");
|
|
4567
4583
|
if (params.transcriptLines !== void 0) return textResult(await formatRunTranscript(result.status, params.transcriptLines ?? 80), { transcript: { runId: result.runId } });
|
|
4568
4584
|
return textResult(result.status ? `Run '${result.runId}': ${result.status.state}` : `Run '${result.runId}' has no status yet.`, { status: result });
|
|
4569
4585
|
}
|
|
@@ -4575,7 +4591,7 @@ var SubagentToolService = class {
|
|
|
4575
4591
|
case require_subagentTool.SUBAGENT_ACTIONS.steer: {
|
|
4576
4592
|
const id = resolveTrackedRunId(jobs, params.id);
|
|
4577
4593
|
const runtime = jobs.get(id)?.runtime;
|
|
4578
|
-
if (runtime && !isPiRuntime(runtime)) throw new
|
|
4594
|
+
if (runtime && !isPiRuntime(runtime)) throw new PoTeamExpectedError("unsupported_operation", `Run '${id}' uses '${runtime}', which does not support steering.`, false, `Use subagent({"action":"stop","id":"${id}"}) to terminate it.`);
|
|
4579
4595
|
const result = await this.management.steer(id, {
|
|
4580
4596
|
text: params.message,
|
|
4581
4597
|
sender: MAIN_AGENT_SENDER
|
|
@@ -4596,7 +4612,7 @@ var SubagentToolService = class {
|
|
|
4596
4612
|
const operation = await startOperation(scope, id, params, []);
|
|
4597
4613
|
if (operation.kind === "replay") {
|
|
4598
4614
|
if (operation.record.state === "completed" && operation.record.result) return operation.record.result;
|
|
4599
|
-
throw new
|
|
4615
|
+
throw new PoTeamExpectedError("delivery_unconfirmed", `Operation '${id}' is already pending.`, true, "Inspect run status before retrying this control operation.");
|
|
4600
4616
|
}
|
|
4601
4617
|
const response = await this.executeManagement(params, ctx, signal);
|
|
4602
4618
|
await completeOperation(scope, id, operation.record, response);
|
|
@@ -4659,7 +4675,7 @@ function createHeadlessSubagentTool(runtime, initialExecution) {
|
|
|
4659
4675
|
const scope = scopeOf(params.scope);
|
|
4660
4676
|
const agents = (await runtime.discovery.discover(params.cwd ?? execution.cwd, scope)).agents;
|
|
4661
4677
|
const selected = params.name ? await runtime.discovery.find(params.cwd ?? execution.cwd, scope, params.name) : void 0;
|
|
4662
|
-
if (params.name && !selected) throw new
|
|
4678
|
+
if (params.name && !selected) throw new PoTeamExpectedError("agent_not_found", `No executable agent matches '${params.name}'.`, false, "Call subagent({\"action\":\"agents\"}) and retry with an exact agent name.");
|
|
4663
4679
|
if (selected) return result(formatAgentDetail(selected), { agents: [publicAgent(selected)] });
|
|
4664
4680
|
return result(formatAgentList(agents), { agents: agents.map((agent) => ({
|
|
4665
4681
|
name: agent.name,
|
|
@@ -5347,7 +5363,7 @@ var TeamAgentConfigService = class {
|
|
|
5347
5363
|
};
|
|
5348
5364
|
}
|
|
5349
5365
|
current() {
|
|
5350
|
-
if (!this.snapshot) return Promise.reject(new
|
|
5366
|
+
if (!this.snapshot) return Promise.reject(new PoTeamExpectedError("runtime_unavailable", "Team agent configuration is not loaded yet.", true, "Retry after the session configuration is ready."));
|
|
5351
5367
|
const snapshot = this.snapshot();
|
|
5352
5368
|
const cached = this.loads.get(snapshot);
|
|
5353
5369
|
if (cached) return cached;
|
|
@@ -5515,14 +5531,14 @@ declare const team: {
|
|
|
5515
5531
|
run(input: { systemPrompt: string; task: string; model?: string; timeoutMs?: number }): Promise<{
|
|
5516
5532
|
runId?: string; status: 'completed' | 'failed' | 'stopped'; output: string; error?: string;
|
|
5517
5533
|
}>;
|
|
5518
|
-
/**
|
|
5519
|
-
startSession(input: { name: string; brief: string; workspaceId?: string }): Promise<{ sessionId: string }>;
|
|
5534
|
+
/** Compatibility forwarder, main-agent coordinators only. Prefer sessions.start. */
|
|
5535
|
+
startSession(input: { name: string; brief: string; workspaceId?: string }): Promise<{ sessionId: string; promptError?: string }>;
|
|
5520
5536
|
};`;
|
|
5521
5537
|
/** Session-owned state and awaited inline runs. Direct tools retain discovery and management. */
|
|
5522
5538
|
function createTeamNamespace(options) {
|
|
5523
5539
|
return {
|
|
5524
5540
|
name: "team",
|
|
5525
|
-
summary: "Read team members and runs
|
|
5541
|
+
summary: "Read native team members and runs or await an inline agent with team.run(). Session coordination uses sessions.",
|
|
5526
5542
|
declarations: DECLARATIONS,
|
|
5527
5543
|
bind(run) {
|
|
5528
5544
|
if (run.sessionId !== options.sessionId) throw new Error("Team namespace belongs to another session.");
|
|
@@ -5590,6 +5606,7 @@ function createTeamNamespace(options) {
|
|
|
5590
5606
|
return pending;
|
|
5591
5607
|
};
|
|
5592
5608
|
members.startSession = async (input) => {
|
|
5609
|
+
if (run.caller !== "main") throw new Error("Starting sessions requires the main agent.");
|
|
5593
5610
|
check();
|
|
5594
5611
|
if (!options.startSession) throw new Error("Starting sessions is unavailable on this host.");
|
|
5595
5612
|
return JSON.parse(JSON.stringify(await options.startSession(input, signal)));
|
|
@@ -5757,11 +5774,11 @@ var ManagementActions = class {
|
|
|
5757
5774
|
if (exact) return exact;
|
|
5758
5775
|
const matches = runs.filter((run) => run.runId.startsWith(id));
|
|
5759
5776
|
if (matches.length === 1) return matches[0];
|
|
5760
|
-
if (matches.length > 1) throw new
|
|
5777
|
+
if (matches.length > 1) throw new PoTeamExpectedError("run_not_found", `Multiple current-session runs match '${id}'.`, false, "Retry with a longer run id.");
|
|
5761
5778
|
}
|
|
5762
5779
|
requireActiveJob(id) {
|
|
5763
5780
|
const job = this.resolveJob(id);
|
|
5764
|
-
if (!job) throw new
|
|
5781
|
+
if (!job) throw new PoTeamExpectedError("run_not_found", `No active run matches '${id}'.`, false, "Call subagent({\"action\":\"status\"}) and retry with an exact run id.");
|
|
5765
5782
|
return job;
|
|
5766
5783
|
}
|
|
5767
5784
|
status(id) {
|
|
@@ -5804,11 +5821,11 @@ var ManagementActions = class {
|
|
|
5804
5821
|
const job = this.requireActiveJob(id);
|
|
5805
5822
|
const requestId = (0, node_crypto.randomUUID)();
|
|
5806
5823
|
if (job.native) {
|
|
5807
|
-
if (!this.nativeRuns?.get(scope.rootSessionId, job.runId)) throw new
|
|
5824
|
+
if (!this.nativeRuns?.get(scope.rootSessionId, job.runId)) throw new PoTeamExpectedError("run_not_found", `Native run '${job.runId}' is no longer active.`, false, "List active runs and retry with a current run id.");
|
|
5808
5825
|
await this.nativeRuns.stop(scope.rootSessionId, job.runId, reason);
|
|
5809
5826
|
return { requestId };
|
|
5810
5827
|
}
|
|
5811
|
-
if (!this.externalProcesses?.has(scope, job.runId)) throw new
|
|
5828
|
+
if (!this.externalProcesses?.has(scope, job.runId)) throw new PoTeamExpectedError("run_not_found", `External run '${job.runId}' is no longer active.`, false, "List active runs and retry with a current run id.");
|
|
5812
5829
|
await this.externalProcesses.control(scope, job.runId, {
|
|
5813
5830
|
command,
|
|
5814
5831
|
requestId,
|
|
@@ -5822,7 +5839,7 @@ var ManagementActions = class {
|
|
|
5822
5839
|
const requestId = (0, node_crypto.randomUUID)();
|
|
5823
5840
|
const index = targetIndex ?? 0;
|
|
5824
5841
|
if (job.native) {
|
|
5825
|
-
if (!this.nativeRuns?.get(scope.rootSessionId, job.runId)) throw new
|
|
5842
|
+
if (!this.nativeRuns?.get(scope.rootSessionId, job.runId)) throw new PoTeamExpectedError("run_not_found", `Native run '${job.runId}' is no longer active.`, false, "List active runs and retry with a current run id.");
|
|
5826
5843
|
await this.nativeRuns.steer(scope.rootSessionId, job.runId, message, signal);
|
|
5827
5844
|
return {
|
|
5828
5845
|
requestId,
|
|
@@ -5831,7 +5848,7 @@ var ManagementActions = class {
|
|
|
5831
5848
|
message: "Native child accepted the steer request."
|
|
5832
5849
|
};
|
|
5833
5850
|
}
|
|
5834
|
-
if (!this.externalProcesses?.has(scope, job.runId)) throw new
|
|
5851
|
+
if (!this.externalProcesses?.has(scope, job.runId)) throw new PoTeamExpectedError("run_not_found", `External run '${job.runId}' is no longer active.`, false, "List active runs and retry with a current run id.");
|
|
5835
5852
|
const acknowledgement = await this.externalProcesses.control(scope, job.runId, {
|
|
5836
5853
|
command: "steer",
|
|
5837
5854
|
requestId,
|
|
@@ -6542,8 +6559,6 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context,
|
|
|
6542
6559
|
provenance: () => serverHost.context.sessionContext?.provenance,
|
|
6543
6560
|
coordination: () => serverHost.context.coordination
|
|
6544
6561
|
};
|
|
6545
|
-
const startSessionTool = require_coordinatorSessions.createStartSessionTool(coordinatorSessions);
|
|
6546
|
-
const startSessionRestriction = isCoordinator ? void 0 : { excludedTools: [require_coordinatorSessions.START_SESSION_TOOL_NAME] };
|
|
6547
6562
|
const roster = createTeamRosterDelivery(() => formatTeamRoster({
|
|
6548
6563
|
groups: serverHost.context.sessionCommunication?.groups ?? [],
|
|
6549
6564
|
members: require_teamSnapshot.readActiveTeamSnapshot(channel)?.members ?? [],
|
|
@@ -6608,16 +6623,12 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context,
|
|
|
6608
6623
|
channel,
|
|
6609
6624
|
jobs,
|
|
6610
6625
|
run: (input, signal) => awaitedInline.run(input, signal),
|
|
6611
|
-
startSession: (input, signal) =>
|
|
6626
|
+
startSession: (input, signal) => (0, _agimon_ai_po_session.startCoordinatedSession)(coordinatorSessions, input, signal),
|
|
6612
6627
|
assertAvailable: () => {
|
|
6613
6628
|
if (disposing) throw new Error("Team session is disposing.");
|
|
6614
6629
|
}
|
|
6615
6630
|
}));
|
|
6616
|
-
|
|
6617
|
-
return () => {
|
|
6618
|
-
restriction?.dispose();
|
|
6619
|
-
registration?.dispose();
|
|
6620
|
-
};
|
|
6631
|
+
return () => registration?.dispose();
|
|
6621
6632
|
});
|
|
6622
6633
|
providerContext.inject([_agimon_ai_po_config.PO_CONFIG_SERVICE], (configContext) => {
|
|
6623
6634
|
const config = configContext.get(_agimon_ai_po_config.PO_CONFIG_SERVICE);
|
|
@@ -6741,9 +6752,7 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context,
|
|
|
6741
6752
|
environment: serverHost.context.environment,
|
|
6742
6753
|
restoreRuns,
|
|
6743
6754
|
roster,
|
|
6744
|
-
publishSummary
|
|
6745
|
-
startSessionTool,
|
|
6746
|
-
startSessionRestriction
|
|
6755
|
+
publishSummary
|
|
6747
6756
|
},
|
|
6748
6757
|
services: [
|
|
6749
6758
|
(context) => {
|
|
@@ -6752,11 +6761,7 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(async ({ context,
|
|
|
6752
6761
|
serverService,
|
|
6753
6762
|
(context) => context.provide(PO_TEAM_AGENT_CONFIG_SERVICE, runtime.agentConfig),
|
|
6754
6763
|
(context) => context.provide(_agimon_ai_po_core_childSession.PO_CHILD_SESSION_LABELS_SERVICE, { labelFor: (runId) => nativeRuns.get(runId)?.identity }),
|
|
6755
|
-
mountMcpTools([
|
|
6756
|
-
intercom,
|
|
6757
|
-
createHeadlessSubagentTool(runtime, execution),
|
|
6758
|
-
...isCoordinator ? [startSessionTool] : []
|
|
6759
|
-
])
|
|
6764
|
+
mountMcpTools([intercom, createHeadlessSubagentTool(runtime, execution)])
|
|
6760
6765
|
],
|
|
6761
6766
|
activities: [activity],
|
|
6762
6767
|
async onStart() {
|
|
@@ -6969,7 +6974,7 @@ function isStopRequest(value) {
|
|
|
6969
6974
|
}
|
|
6970
6975
|
/** The typed error's text carries a recovery hint written for the model, so a missing run gets a sentence for people. */
|
|
6971
6976
|
function controlFailure(error) {
|
|
6972
|
-
if (error instanceof
|
|
6977
|
+
if (error instanceof PoTeamExpectedError && error.code === "run_not_found") return Response.json({ error: "This run is not active." }, { status: 404 });
|
|
6973
6978
|
return Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 409 });
|
|
6974
6979
|
}
|
|
6975
6980
|
/** Serves catalog discovery, run launch, and run steer and stop from the selected session process, never through a parent prompt. */
|
|
@@ -7141,16 +7146,9 @@ var codemode_how_to_team_server_default = (0, _agimon_ai_po_core_extensionFile.d
|
|
|
7141
7146
|
read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-team/SKILL.md")
|
|
7142
7147
|
});
|
|
7143
7148
|
//#endregion
|
|
7144
|
-
//#region src/extensions/workspaces/sessions/(backend)/tool-restriction/startSession.server.ts
|
|
7145
|
-
/** Withdraws start_session from every session that is not a coordinator. */
|
|
7146
|
-
var startSession_server_default$1 = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.startSessionRestriction, { cardinality: "optional" });
|
|
7147
|
-
//#endregion
|
|
7148
7149
|
//#region src/extensions/workspaces/sessions/(backend)/tool/intercom.server.ts
|
|
7149
7150
|
var intercom_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerTool)((context) => context.root.intercom);
|
|
7150
7151
|
//#endregion
|
|
7151
|
-
//#region src/extensions/workspaces/sessions/(backend)/tool/startSession.server.ts
|
|
7152
|
-
var startSession_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerTool)((context) => context.root.startSessionTool);
|
|
7153
|
-
//#endregion
|
|
7154
7152
|
//#region src/extensions/workspaces/sessions/(backend)/tool/subagent.server.ts
|
|
7155
7153
|
var subagent_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerTool)((context) => createHeadlessSubagentTool(context.root.runtime, context.root.execution));
|
|
7156
7154
|
//#endregion
|
|
@@ -7197,15 +7195,8 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
|
7197
7195
|
get resources() {
|
|
7198
7196
|
return [at(codemode_how_to_team_server_default, contextSession)];
|
|
7199
7197
|
},
|
|
7200
|
-
get toolRestrictions() {
|
|
7201
|
-
return defined([at(startSession_server_default$1, contextSession)]);
|
|
7202
|
-
},
|
|
7203
7198
|
get tools() {
|
|
7204
|
-
return [
|
|
7205
|
-
via({ name: "intercom" }, at(intercom_server_default, contextSession)),
|
|
7206
|
-
via({ name: "start_session" }, at(startSession_server_default, contextSession)),
|
|
7207
|
-
via({ name: "subagent" }, at(subagent_server_default, contextSession))
|
|
7208
|
-
];
|
|
7199
|
+
return [via({ name: "intercom" }, at(intercom_server_default, contextSession)), via({ name: "subagent" }, at(subagent_server_default, contextSession))];
|
|
7209
7200
|
},
|
|
7210
7201
|
services: [...scopeSession.services ?? []],
|
|
7211
7202
|
get activities() {
|