@agimon-ai/po-team 0.0.0-alpha.122 → 0.0.0-alpha.124
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-DJr4jZJR.mjs +94 -0
- package/dist/coordinatorSessions-DJr4jZJR.mjs.map +1 -0
- package/dist/coordinatorSessions-wvx0tV3-.cjs +123 -0
- package/dist/coordinatorSessions-wvx0tV3-.cjs.map +1 -0
- package/dist/coordinatorSessions.cjs +4 -0
- package/dist/coordinatorSessions.d.mts +26 -0
- package/dist/coordinatorSessions.d.mts.map +1 -0
- package/dist/coordinatorSessions.mjs +1 -0
- package/dist/extensions/native.mjs +227 -134
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +70 -151
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +6 -87
- 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-DnFhEWuC.d.mts → subagentTool-C4uQPolH.d.mts} +2 -2
- package/dist/{subagentTool-DnFhEWuC.d.mts.map → subagentTool-C4uQPolH.d.mts.map} +1 -1
- package/dist/{subagentTool-CVP0n-wA.cjs → subagentTool-DP0qLQDh.cjs} +2 -2
- package/dist/{subagentTool-CVP0n-wA.cjs.map → subagentTool-DP0qLQDh.cjs.map} +1 -1
- package/dist/{subagentTool-CBADRWGC.mjs → subagentTool-oRLu2Avh.mjs} +2 -2
- package/dist/{subagentTool-CBADRWGC.mjs.map → subagentTool-oRLu2Avh.mjs.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 +15 -10
- package/src/prompts/codemode-how-to-team/SKILL.md +3 -2
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { COORDINATOR_SESSION_PROVENANCE } from "@agimon-ai/po-core/hubChannel";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
const START_SESSION_BRIEF_MAX = 8e3;
|
|
4
|
+
/** The schema declared to the model for `start_session` and mirrored by `team.startSession`. */
|
|
5
|
+
const StartSessionParamsSchema = Type.Object({
|
|
6
|
+
name: Type.String({
|
|
7
|
+
minLength: 1,
|
|
8
|
+
maxLength: 80,
|
|
9
|
+
description: "Short session name the person will see in the rail."
|
|
10
|
+
}),
|
|
11
|
+
brief: Type.String({
|
|
12
|
+
minLength: 1,
|
|
13
|
+
maxLength: START_SESSION_BRIEF_MAX,
|
|
14
|
+
description: "The first prompt the new session receives: goal, context, and what done looks like."
|
|
15
|
+
}),
|
|
16
|
+
workspaceId: Type.Optional(Type.String({
|
|
17
|
+
minLength: 1,
|
|
18
|
+
maxLength: 512,
|
|
19
|
+
description: "Home coordinators only: target an admitted workspace without its own coordinator. Omit for your own scope."
|
|
20
|
+
}))
|
|
21
|
+
}, { additionalProperties: false });
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/services/errors/index.ts
|
|
24
|
+
var PoTeamExpectedError = class extends Error {
|
|
25
|
+
code;
|
|
26
|
+
retryable;
|
|
27
|
+
recovery;
|
|
28
|
+
constructor(code, message, retryable, recovery) {
|
|
29
|
+
super(`[${code}] ${message}\nRecovery: ${recovery}`);
|
|
30
|
+
this.code = code;
|
|
31
|
+
this.retryable = retryable;
|
|
32
|
+
this.recovery = recovery;
|
|
33
|
+
this.name = "PoTeamExpectedError";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function invalidRequest(message, recovery) {
|
|
37
|
+
return new PoTeamExpectedError("invalid_request", message, false, recovery);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/services/coordinatorSessions/index.ts
|
|
41
|
+
const START_SESSION_TOOL_NAME = "start_session";
|
|
42
|
+
function field(params, key, max) {
|
|
43
|
+
const value = params[key];
|
|
44
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
45
|
+
if (text === "" || text.length > max) throw invalidRequest(`${key} must be text of 1 to ${String(max)} characters.`, `Pass a non-empty ${key}.`);
|
|
46
|
+
return text;
|
|
47
|
+
}
|
|
48
|
+
/** Validates input at the boundary and refuses every unknown key. The host authorizes any target workspace. */
|
|
49
|
+
function parseStartSessionInput(raw) {
|
|
50
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw invalidRequest("startSession input must be an object.", "Pass { name, brief }.");
|
|
51
|
+
const params = raw;
|
|
52
|
+
const extra = Object.keys(params).filter((key) => key !== "name" && key !== "brief" && key !== "workspaceId");
|
|
53
|
+
if (extra.length) throw invalidRequest(`Unknown field: ${extra.join(", ")}.`, "Pass only { name, brief, workspaceId? }.");
|
|
54
|
+
return {
|
|
55
|
+
name: field(params, "name", 80),
|
|
56
|
+
brief: field(params, "brief", START_SESSION_BRIEF_MAX),
|
|
57
|
+
...params.workspaceId === void 0 ? {} : { workspaceId: field(params, "workspaceId", 512) }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** The one implementation behind `team.startSession` and the `start_session` tool. Returns detached JSON. */
|
|
61
|
+
async function startCoordinatedSession(options, raw, signal) {
|
|
62
|
+
signal?.throwIfAborted();
|
|
63
|
+
if (options.provenance() !== COORDINATOR_SESSION_PROVENANCE) throw new PoTeamExpectedError("unsupported_context", "Only a coordinator session can start sessions.", false, "Delegate to a subagent, or send an intercom message to a session that already exists.");
|
|
64
|
+
const coordination = options.coordination();
|
|
65
|
+
if (coordination === void 0) throw new PoTeamExpectedError("unsupported_operation", "This host cannot start sessions.", false, "Delegate to a subagent instead.");
|
|
66
|
+
const request = parseStartSessionInput(raw);
|
|
67
|
+
const { sessionId } = await coordination.startSession(request);
|
|
68
|
+
return { sessionId: String(sessionId) };
|
|
69
|
+
}
|
|
70
|
+
function createStartSessionTool(options) {
|
|
71
|
+
return {
|
|
72
|
+
name: START_SESSION_TOOL_NAME,
|
|
73
|
+
label: "Start session",
|
|
74
|
+
mainAgentOnly: true,
|
|
75
|
+
description: "Coordinators only: start a briefed session in your own scope. Home coordinators may target an uncoordinated workspace with workspaceId. Limited to 5 an hour.",
|
|
76
|
+
parameters: StartSessionParamsSchema,
|
|
77
|
+
promptGuidelines: ["Start a session only for independent, long-running work the person will want to follow on its own. Use a subagent for work you will wait on, and intercom to reach a session that already exists."],
|
|
78
|
+
executionMode: "serial",
|
|
79
|
+
async execute(_toolCallId, parameters, signal) {
|
|
80
|
+
const result = await startCoordinatedSession(options, parameters, signal);
|
|
81
|
+
return {
|
|
82
|
+
content: [{
|
|
83
|
+
type: "text",
|
|
84
|
+
text: `Started session ${result.sessionId}. Reach it with intercom send.`
|
|
85
|
+
}],
|
|
86
|
+
details: result
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { invalidRequest as a, PoTeamExpectedError as i, createStartSessionTool as n, startCoordinatedSession as r, START_SESSION_TOOL_NAME as t };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=coordinatorSessions-DJr4jZJR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinatorSessions-DJr4jZJR.mjs","names":[],"sources":["../src/schemas/team/startSession.ts","../src/services/errors/index.ts","../src/services/coordinatorSessions/index.ts"],"sourcesContent":["import { Type } from 'typebox';\n\nexport const START_SESSION_NAME_MAX = 80;\nexport const START_SESSION_BRIEF_MAX = 8000;\nexport const START_SESSION_WORKSPACE_ID_MAX = 512;\n\n/** The schema declared to the model for `start_session` and mirrored by `team.startSession`. */\nexport const StartSessionParamsSchema = Type.Object(\n {\n name: Type.String({\n minLength: 1,\n maxLength: START_SESSION_NAME_MAX,\n description: 'Short session name the person will see in the rail.',\n }),\n brief: Type.String({\n minLength: 1,\n maxLength: START_SESSION_BRIEF_MAX,\n description: 'The first prompt the new session receives: goal, context, and what done looks like.',\n }),\n workspaceId: Type.Optional(\n Type.String({\n minLength: 1,\n maxLength: START_SESSION_WORKSPACE_ID_MAX,\n description:\n 'Home coordinators only: target an admitted workspace without its own coordinator. Omit for your own scope.',\n }),\n ),\n },\n { additionalProperties: false },\n);\n","export type PoTeamErrorCode =\n | 'invalid_request'\n | 'unsupported_operation'\n | 'unsupported_context'\n | 'agent_not_found'\n | 'runtime_unavailable'\n | 'model_unavailable'\n | 'run_not_found'\n | 'ambiguous_run_id'\n | 'run_terminal'\n | 'not_resumable'\n | 'communication_unavailable'\n | 'recipient_not_found'\n | 'recipient_ambiguous'\n | 'delivery_unconfirmed'\n | 'status_corrupt'\n | 'operation_conflict'\n | 'tool_conflict';\n\nexport class PoTeamExpectedError extends Error {\n constructor(\n readonly code: PoTeamErrorCode,\n message: string,\n readonly retryable: boolean,\n readonly recovery: string,\n ) {\n super(`[${code}] ${message}\\nRecovery: ${recovery}`);\n this.name = 'PoTeamExpectedError';\n }\n}\n\nexport function invalidRequest(message: string, recovery: string): PoTeamExpectedError {\n return new PoTeamExpectedError('invalid_request', message, false, recovery);\n}\n","import type { PoHeadlessTool } from '@agimon-ai/po-core/headless';\nimport { COORDINATOR_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\nimport type { PoSessionCoordination } from '@agimon-ai/po-core/packageApi';\n\nimport {\n START_SESSION_BRIEF_MAX,\n START_SESSION_NAME_MAX,\n START_SESSION_WORKSPACE_ID_MAX,\n StartSessionParamsSchema,\n} from '../../schemas/team/startSession';\nimport { invalidRequest, PoTeamExpectedError } from '../errors';\n\nexport const START_SESSION_TOOL_NAME = 'start_session';\n\nexport interface CoordinatorSessionsOptions {\n /** The calling session's provenance, read live. */\n provenance(): string | undefined;\n /** Host coordination; absent on hosts that cannot start sessions. */\n coordination(): PoSessionCoordination | undefined;\n}\n\nfunction field(params: Record<string, unknown>, key: string, max: number): string {\n const value = params[key];\n const text = typeof value === 'string' ? value.trim() : '';\n if (text === '' || text.length > max)\n throw invalidRequest(`${key} must be text of 1 to ${String(max)} characters.`, `Pass a non-empty ${key}.`);\n return text;\n}\n\n/** Validates input at the boundary and refuses every unknown key. The host authorizes any target workspace. */\nexport function parseStartSessionInput(raw: unknown): { name: string; brief: string; workspaceId?: string } {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw))\n throw invalidRequest('startSession input must be an object.', 'Pass { name, brief }.');\n const params = raw as Record<string, unknown>;\n const extra = Object.keys(params).filter((key) => key !== 'name' && key !== 'brief' && key !== 'workspaceId');\n if (extra.length)\n throw invalidRequest(`Unknown field: ${extra.join(', ')}.`, 'Pass only { name, brief, workspaceId? }.');\n return {\n name: field(params, 'name', START_SESSION_NAME_MAX),\n brief: field(params, 'brief', START_SESSION_BRIEF_MAX),\n ...(params.workspaceId === undefined\n ? {}\n : { workspaceId: field(params, 'workspaceId', START_SESSION_WORKSPACE_ID_MAX) }),\n };\n}\n\n/** The one implementation behind `team.startSession` and the `start_session` tool. Returns detached JSON. */\nexport async function startCoordinatedSession(\n options: CoordinatorSessionsOptions,\n raw: unknown,\n signal?: AbortSignal,\n): Promise<{ sessionId: string }> {\n signal?.throwIfAborted();\n if (options.provenance() !== COORDINATOR_SESSION_PROVENANCE)\n throw new PoTeamExpectedError(\n 'unsupported_context',\n 'Only a coordinator session can start sessions.',\n false,\n 'Delegate to a subagent, or send an intercom message to a session that already exists.',\n );\n const coordination = options.coordination();\n if (coordination === undefined)\n throw new PoTeamExpectedError(\n 'unsupported_operation',\n 'This host cannot start sessions.',\n false,\n 'Delegate to a subagent instead.',\n );\n const request = parseStartSessionInput(raw);\n // The host may already have started the session, so a late abort does not hide its id.\n const { sessionId } = await coordination.startSession(request);\n return { sessionId: String(sessionId) };\n}\n\nexport function createStartSessionTool(\n options: CoordinatorSessionsOptions,\n): PoHeadlessTool<typeof StartSessionParamsSchema> {\n return {\n name: START_SESSION_TOOL_NAME,\n label: 'Start session',\n mainAgentOnly: true,\n description:\n 'Coordinators only: start a briefed session in your own scope. Home coordinators may target an uncoordinated workspace with workspaceId. Limited to 5 an hour.',\n parameters: StartSessionParamsSchema,\n promptGuidelines: [\n 'Start a session only for independent, long-running work the person will want to follow on its own. Use a subagent for work you will wait on, and intercom to reach a session that already exists.',\n ],\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n const result = await startCoordinatedSession(options, parameters, signal);\n return {\n content: [{ type: 'text', text: `Started session ${result.sessionId}. Reach it with intercom send.` }],\n details: result,\n };\n },\n };\n}\n"],"mappings":";;AAGA,MAAa,0BAA0B;;AAIvC,MAAa,2BAA2B,KAAK,OAC3C;CACE,MAAM,KAAK,OAAO;EAChB,WAAW;EACX,WAAA;EACA,aAAa;CACf,CAAC;CACD,OAAO,KAAK,OAAO;EACjB,WAAW;EACX,WAAW;EACX,aAAa;CACf,CAAC;CACD,aAAa,KAAK,SAChB,KAAK,OAAO;EACV,WAAW;EACX,WAAA;EACA,aACE;CACJ,CAAC,CACH;AACF,GACA,EAAE,sBAAsB,MAAM,CAChC;;;ACVA,IAAa,sBAAb,cAAyC,MAAM;CAElC;CAEA;CACA;CAJX,YACE,MACA,SACA,WACA,UACA;EACA,MAAM,IAAI,KAAK,IAAI,QAAQ,cAAc,UAAU;EAL1C,KAAA,OAAA;EAEA,KAAA,YAAA;EACA,KAAA,WAAA;EAGT,KAAK,OAAO;CACd;AACF;AAEA,SAAgB,eAAe,SAAiB,UAAuC;CACrF,OAAO,IAAI,oBAAoB,mBAAmB,SAAS,OAAO,QAAQ;AAC5E;;;ACrBA,MAAa,0BAA0B;AASvC,SAAS,MAAM,QAAiC,KAAa,KAAqB;CAChF,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI;CACxD,IAAI,SAAS,MAAM,KAAK,SAAS,KAC/B,MAAM,eAAe,GAAG,IAAI,wBAAwB,OAAO,GAAG,EAAE,eAAe,oBAAoB,IAAI,EAAE;CAC3G,OAAO;AACT;;AAGA,SAAgB,uBAAuB,KAAqE;CAC1G,IAAI,CAAC,OAAO,OAA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ubChannel = require("@agimon-ai/po-core/hubChannel");
|
|
2
|
+
let typebox = require("typebox");
|
|
3
|
+
const START_SESSION_BRIEF_MAX = 8e3;
|
|
4
|
+
/** The schema declared to the model for `start_session` and mirrored by `team.startSession`. */
|
|
5
|
+
const StartSessionParamsSchema = typebox.Type.Object({
|
|
6
|
+
name: typebox.Type.String({
|
|
7
|
+
minLength: 1,
|
|
8
|
+
maxLength: 80,
|
|
9
|
+
description: "Short session name the person will see in the rail."
|
|
10
|
+
}),
|
|
11
|
+
brief: typebox.Type.String({
|
|
12
|
+
minLength: 1,
|
|
13
|
+
maxLength: START_SESSION_BRIEF_MAX,
|
|
14
|
+
description: "The first prompt the new session receives: goal, context, and what done looks like."
|
|
15
|
+
}),
|
|
16
|
+
workspaceId: typebox.Type.Optional(typebox.Type.String({
|
|
17
|
+
minLength: 1,
|
|
18
|
+
maxLength: 512,
|
|
19
|
+
description: "Home coordinators only: target an admitted workspace without its own coordinator. Omit for your own scope."
|
|
20
|
+
}))
|
|
21
|
+
}, { additionalProperties: false });
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/services/errors/index.ts
|
|
24
|
+
var PoTeamExpectedError = class extends Error {
|
|
25
|
+
code;
|
|
26
|
+
retryable;
|
|
27
|
+
recovery;
|
|
28
|
+
constructor(code, message, retryable, recovery) {
|
|
29
|
+
super(`[${code}] ${message}\nRecovery: ${recovery}`);
|
|
30
|
+
this.code = code;
|
|
31
|
+
this.retryable = retryable;
|
|
32
|
+
this.recovery = recovery;
|
|
33
|
+
this.name = "PoTeamExpectedError";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function invalidRequest(message, recovery) {
|
|
37
|
+
return new PoTeamExpectedError("invalid_request", message, false, recovery);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/services/coordinatorSessions/index.ts
|
|
41
|
+
const START_SESSION_TOOL_NAME = "start_session";
|
|
42
|
+
function field(params, key, max) {
|
|
43
|
+
const value = params[key];
|
|
44
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
45
|
+
if (text === "" || text.length > max) throw invalidRequest(`${key} must be text of 1 to ${String(max)} characters.`, `Pass a non-empty ${key}.`);
|
|
46
|
+
return text;
|
|
47
|
+
}
|
|
48
|
+
/** Validates input at the boundary and refuses every unknown key. The host authorizes any target workspace. */
|
|
49
|
+
function parseStartSessionInput(raw) {
|
|
50
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw invalidRequest("startSession input must be an object.", "Pass { name, brief }.");
|
|
51
|
+
const params = raw;
|
|
52
|
+
const extra = Object.keys(params).filter((key) => key !== "name" && key !== "brief" && key !== "workspaceId");
|
|
53
|
+
if (extra.length) throw invalidRequest(`Unknown field: ${extra.join(", ")}.`, "Pass only { name, brief, workspaceId? }.");
|
|
54
|
+
return {
|
|
55
|
+
name: field(params, "name", 80),
|
|
56
|
+
brief: field(params, "brief", START_SESSION_BRIEF_MAX),
|
|
57
|
+
...params.workspaceId === void 0 ? {} : { workspaceId: field(params, "workspaceId", 512) }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** The one implementation behind `team.startSession` and the `start_session` tool. Returns detached JSON. */
|
|
61
|
+
async function startCoordinatedSession(options, raw, signal) {
|
|
62
|
+
signal?.throwIfAborted();
|
|
63
|
+
if (options.provenance() !== _agimon_ai_po_core_hubChannel.COORDINATOR_SESSION_PROVENANCE) throw new PoTeamExpectedError("unsupported_context", "Only a coordinator session can start sessions.", false, "Delegate to a subagent, or send an intercom message to a session that already exists.");
|
|
64
|
+
const coordination = options.coordination();
|
|
65
|
+
if (coordination === void 0) throw new PoTeamExpectedError("unsupported_operation", "This host cannot start sessions.", false, "Delegate to a subagent instead.");
|
|
66
|
+
const request = parseStartSessionInput(raw);
|
|
67
|
+
const { sessionId } = await coordination.startSession(request);
|
|
68
|
+
return { sessionId: String(sessionId) };
|
|
69
|
+
}
|
|
70
|
+
function createStartSessionTool(options) {
|
|
71
|
+
return {
|
|
72
|
+
name: START_SESSION_TOOL_NAME,
|
|
73
|
+
label: "Start session",
|
|
74
|
+
mainAgentOnly: true,
|
|
75
|
+
description: "Coordinators only: start a briefed session in your own scope. Home coordinators may target an uncoordinated workspace with workspaceId. Limited to 5 an hour.",
|
|
76
|
+
parameters: StartSessionParamsSchema,
|
|
77
|
+
promptGuidelines: ["Start a session only for independent, long-running work the person will want to follow on its own. Use a subagent for work you will wait on, and intercom to reach a session that already exists."],
|
|
78
|
+
executionMode: "serial",
|
|
79
|
+
async execute(_toolCallId, parameters, signal) {
|
|
80
|
+
const result = await startCoordinatedSession(options, parameters, signal);
|
|
81
|
+
return {
|
|
82
|
+
content: [{
|
|
83
|
+
type: "text",
|
|
84
|
+
text: `Started session ${result.sessionId}. Reach it with intercom send.`
|
|
85
|
+
}],
|
|
86
|
+
details: result
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
Object.defineProperty(exports, "PoTeamExpectedError", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function() {
|
|
95
|
+
return PoTeamExpectedError;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(exports, "START_SESSION_TOOL_NAME", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function() {
|
|
101
|
+
return START_SESSION_TOOL_NAME;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, "createStartSessionTool", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function() {
|
|
107
|
+
return createStartSessionTool;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(exports, "invalidRequest", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
get: function() {
|
|
113
|
+
return invalidRequest;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(exports, "startCoordinatedSession", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function() {
|
|
119
|
+
return startCoordinatedSession;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=coordinatorSessions-wvx0tV3-.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinatorSessions-wvx0tV3-.cjs","names":["Type","COORDINATOR_SESSION_PROVENANCE"],"sources":["../src/schemas/team/startSession.ts","../src/services/errors/index.ts","../src/services/coordinatorSessions/index.ts"],"sourcesContent":["import { Type } from 'typebox';\n\nexport const START_SESSION_NAME_MAX = 80;\nexport const START_SESSION_BRIEF_MAX = 8000;\nexport const START_SESSION_WORKSPACE_ID_MAX = 512;\n\n/** The schema declared to the model for `start_session` and mirrored by `team.startSession`. */\nexport const StartSessionParamsSchema = Type.Object(\n {\n name: Type.String({\n minLength: 1,\n maxLength: START_SESSION_NAME_MAX,\n description: 'Short session name the person will see in the rail.',\n }),\n brief: Type.String({\n minLength: 1,\n maxLength: START_SESSION_BRIEF_MAX,\n description: 'The first prompt the new session receives: goal, context, and what done looks like.',\n }),\n workspaceId: Type.Optional(\n Type.String({\n minLength: 1,\n maxLength: START_SESSION_WORKSPACE_ID_MAX,\n description:\n 'Home coordinators only: target an admitted workspace without its own coordinator. Omit for your own scope.',\n }),\n ),\n },\n { additionalProperties: false },\n);\n","export type PoTeamErrorCode =\n | 'invalid_request'\n | 'unsupported_operation'\n | 'unsupported_context'\n | 'agent_not_found'\n | 'runtime_unavailable'\n | 'model_unavailable'\n | 'run_not_found'\n | 'ambiguous_run_id'\n | 'run_terminal'\n | 'not_resumable'\n | 'communication_unavailable'\n | 'recipient_not_found'\n | 'recipient_ambiguous'\n | 'delivery_unconfirmed'\n | 'status_corrupt'\n | 'operation_conflict'\n | 'tool_conflict';\n\nexport class PoTeamExpectedError extends Error {\n constructor(\n readonly code: PoTeamErrorCode,\n message: string,\n readonly retryable: boolean,\n readonly recovery: string,\n ) {\n super(`[${code}] ${message}\\nRecovery: ${recovery}`);\n this.name = 'PoTeamExpectedError';\n }\n}\n\nexport function invalidRequest(message: string, recovery: string): PoTeamExpectedError {\n return new PoTeamExpectedError('invalid_request', message, false, recovery);\n}\n","import type { PoHeadlessTool } from '@agimon-ai/po-core/headless';\nimport { COORDINATOR_SESSION_PROVENANCE } from '@agimon-ai/po-core/hubChannel';\nimport type { PoSessionCoordination } from '@agimon-ai/po-core/packageApi';\n\nimport {\n START_SESSION_BRIEF_MAX,\n START_SESSION_NAME_MAX,\n START_SESSION_WORKSPACE_ID_MAX,\n StartSessionParamsSchema,\n} from '../../schemas/team/startSession';\nimport { invalidRequest, PoTeamExpectedError } from '../errors';\n\nexport const START_SESSION_TOOL_NAME = 'start_session';\n\nexport interface CoordinatorSessionsOptions {\n /** The calling session's provenance, read live. */\n provenance(): string | undefined;\n /** Host coordination; absent on hosts that cannot start sessions. */\n coordination(): PoSessionCoordination | undefined;\n}\n\nfunction field(params: Record<string, unknown>, key: string, max: number): string {\n const value = params[key];\n const text = typeof value === 'string' ? value.trim() : '';\n if (text === '' || text.length > max)\n throw invalidRequest(`${key} must be text of 1 to ${String(max)} characters.`, `Pass a non-empty ${key}.`);\n return text;\n}\n\n/** Validates input at the boundary and refuses every unknown key. The host authorizes any target workspace. */\nexport function parseStartSessionInput(raw: unknown): { name: string; brief: string; workspaceId?: string } {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw))\n throw invalidRequest('startSession input must be an object.', 'Pass { name, brief }.');\n const params = raw as Record<string, unknown>;\n const extra = Object.keys(params).filter((key) => key !== 'name' && key !== 'brief' && key !== 'workspaceId');\n if (extra.length)\n throw invalidRequest(`Unknown field: ${extra.join(', ')}.`, 'Pass only { name, brief, workspaceId? }.');\n return {\n name: field(params, 'name', START_SESSION_NAME_MAX),\n brief: field(params, 'brief', START_SESSION_BRIEF_MAX),\n ...(params.workspaceId === undefined\n ? {}\n : { workspaceId: field(params, 'workspaceId', START_SESSION_WORKSPACE_ID_MAX) }),\n };\n}\n\n/** The one implementation behind `team.startSession` and the `start_session` tool. Returns detached JSON. */\nexport async function startCoordinatedSession(\n options: CoordinatorSessionsOptions,\n raw: unknown,\n signal?: AbortSignal,\n): Promise<{ sessionId: string }> {\n signal?.throwIfAborted();\n if (options.provenance() !== COORDINATOR_SESSION_PROVENANCE)\n throw new PoTeamExpectedError(\n 'unsupported_context',\n 'Only a coordinator session can start sessions.',\n false,\n 'Delegate to a subagent, or send an intercom message to a session that already exists.',\n );\n const coordination = options.coordination();\n if (coordination === undefined)\n throw new PoTeamExpectedError(\n 'unsupported_operation',\n 'This host cannot start sessions.',\n false,\n 'Delegate to a subagent instead.',\n );\n const request = parseStartSessionInput(raw);\n // The host may already have started the session, so a late abort does not hide its id.\n const { sessionId } = await coordination.startSession(request);\n return { sessionId: String(sessionId) };\n}\n\nexport function createStartSessionTool(\n options: CoordinatorSessionsOptions,\n): PoHeadlessTool<typeof StartSessionParamsSchema> {\n return {\n name: START_SESSION_TOOL_NAME,\n label: 'Start session',\n mainAgentOnly: true,\n description:\n 'Coordinators only: start a briefed session in your own scope. Home coordinators may target an uncoordinated workspace with workspaceId. Limited to 5 an hour.',\n parameters: StartSessionParamsSchema,\n promptGuidelines: [\n 'Start a session only for independent, long-running work the person will want to follow on its own. Use a subagent for work you will wait on, and intercom to reach a session that already exists.',\n ],\n executionMode: 'serial',\n async execute(_toolCallId, parameters, signal) {\n const result = await startCoordinatedSession(options, parameters, signal);\n return {\n content: [{ type: 'text', text: `Started session ${result.sessionId}. Reach it with intercom send.` }],\n details: result,\n };\n },\n };\n}\n"],"mappings":";;AAGA,MAAa,0BAA0B;;AAIvC,MAAa,2BAA2BA,QAAAA,KAAK,OAC3C;CACE,MAAMA,QAAAA,KAAK,OAAO;EAChB,WAAW;EACX,WAAA;EACA,aAAa;CACf,CAAC;CACD,OAAOA,QAAAA,KAAK,OAAO;EACjB,WAAW;EACX,WAAW;EACX,aAAa;CACf,CAAC;CACD,aAAaA,QAAAA,KAAK,SAChBA,QAAAA,KAAK,OAAO;EACV,WAAW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AAQ,eAAe;CACvB,IAAI,QAAQ,WAAW,MAAMC,8BAAAA,gCAC3B,MAAM,IAAI,oBACR,uBACA,kDACA,OACA,uFACF;CACF,MAAM,eAAe,QAAQ,aAAa;CAC1C,IAAI,iBAAiB,KAAA,GACnB,MAAM,IAAI,oBACR,yBACA,oCACA,OACA,iCACF;CACF,MAAM,UAAU,uBAAuB,GAAG;CAE1C,MAAM,EAAE,cAAc,MAAM,aAAa,aAAa,OAAO;CAC7D,OAAO,EAAE,WAAW,OAAO,SAAS,EAAE;AACxC;AAEA,SAAgB,uBACd,SACiD;CACjD,OAAO;EACL,MAAM;EACN,OAAO;EACP,eAAe;EACf,aACE;EACF,YAAY;EACZ,kBAAkB,CAChB,mMACF;EACA,eAAe;EACf,MAAM,QAAQ,aAAa,YAAY,QAAQ;GAC7C,MAAM,SAAS,MAAM,wBAAwB,SAAS,YAAY,MAAM;GACxE,OAAO;IACL,SAAS,CAAC;KAAE,MAAM;KAAQ,MAAM,mBAAmB,OAAO,UAAU;IAAgC,CAAC;IACrG,SAAS;GACX;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_coordinatorSessions = require("./coordinatorSessions-wvx0tV3-.cjs");
|
|
3
|
+
exports.createStartSessionTool = require_coordinatorSessions.createStartSessionTool;
|
|
4
|
+
exports.startCoordinatedSession = require_coordinatorSessions.startCoordinatedSession;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { PoHeadlessTool } from "@agimon-ai/po-core/headless";
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinatorSessions.d.mts","names":[],"sources":["../src/schemas/team/startSession.ts","../src/services/coordinatorSessions/index.ts"],"mappings":";;;;;cAOa,0BAAwB,KAAA;;;;;;;UCOpB;;EAEf;;EAEA,gBAAgB;;;wBA6BI,wBACpB,SAAS,4BACT,cACA,SAAS,cACR;EAAU;;wBAuBG,uBACd,SAAS,6BACR,sBAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as createStartSessionTool, r as startCoordinatedSession } from "./coordinatorSessions-DJr4jZJR.mjs";
|