@agimon-ai/po-task 0.0.0-alpha.2 → 0.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/apiContracts.cjs +1 -1
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +18 -18
- package/dist/apiContracts.mjs +1 -1
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/{config-CdX-Bv8q.cjs → config-BC-bztyx.cjs} +8 -8
- package/dist/config-BC-bztyx.cjs.map +1 -0
- package/dist/{config-CFSs3iku.mjs → config-BTadoGeF.mjs} +8 -8
- package/dist/config-BTadoGeF.mjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -2
- package/dist/{delegation-CdMqOZB4.mjs → delegation-Dsqf7fUM.mjs} +11 -11
- package/dist/delegation-Dsqf7fUM.mjs.map +1 -0
- package/dist/{delegation-DsnKjMbJ.cjs → delegation-frvEXhIz.cjs} +10 -10
- package/dist/delegation-frvEXhIz.cjs.map +1 -0
- package/dist/delegationManager.cjs +1 -1
- package/dist/delegationManager.d.mts +1 -1
- package/dist/delegationManager.mjs +1 -1
- package/dist/extensions/mcp-ui.mjs.map +1 -1
- package/dist/extensions/mcp.cjs +23 -23
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.d.mts +1 -1
- package/dist/extensions/mcp.mjs +23 -23
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/native.mjs +14 -0
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +70 -15
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +1 -1
- package/dist/extensions/server.mjs +75 -20
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +28 -28
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/{index-teIf67qQ.d.mts → index-B9QNwUBr.d.mts} +8 -8
- package/dist/{index-teIf67qQ.d.mts.map → index-B9QNwUBr.d.mts.map} +1 -1
- package/dist/{index-B-3sCF2S.d.mts → index-BsZ8DxpJ.d.mts} +7 -7
- package/dist/{index-B-3sCF2S.d.mts.map → index-BsZ8DxpJ.d.mts.map} +1 -1
- package/dist/{index-XY9VPmfm.d.mts → index-CA4Opp4r.d.mts} +2 -2
- package/dist/{index-XY9VPmfm.d.mts.map → index-CA4Opp4r.d.mts.map} +1 -1
- package/dist/{index-Dvb8X_qB.d.mts → index-qQGWsPum.d.mts} +2 -2
- package/dist/index-qQGWsPum.d.mts.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +4 -4
- package/dist/{logSinkTelemetry-B23qGiP-.cjs → logSinkTelemetry-BGb8WQBz.cjs} +4 -4
- package/dist/logSinkTelemetry-BGb8WQBz.cjs.map +1 -0
- package/dist/{logSinkTelemetry-BMBsC54p.mjs → logSinkTelemetry-BhbKdn-x.mjs} +5 -5
- package/dist/logSinkTelemetry-BhbKdn-x.mjs.map +1 -0
- package/dist/logSinkTelemetry.cjs +2 -2
- package/dist/logSinkTelemetry.d.mts +3 -3
- package/dist/logSinkTelemetry.mjs +2 -2
- package/dist/{paths-Cah1vFGv.mjs → paths-DajceJig.mjs} +4 -4
- package/dist/paths-DajceJig.mjs.map +1 -0
- package/dist/{paths-CSya2l9_.cjs → paths-P-XvOUuH.cjs} +4 -4
- package/dist/paths-P-XvOUuH.cjs.map +1 -0
- package/dist/storeInvariants.mjs +1 -2
- package/dist/storePaths.cjs +1 -1
- package/dist/storePaths.d.mts +1 -1
- package/dist/storePaths.mjs +1 -2
- package/dist/storeProcessLiveness.mjs +1 -2
- package/dist/storeReconcile.mjs +1 -2
- package/dist/storeReducer.mjs +1 -2
- package/dist/storeTaskGraph.mjs +1 -2
- package/dist/storeTaskStore.cjs +1 -1
- package/dist/storeTaskStore.d.mts +1 -1
- package/dist/storeTaskStore.mjs +1 -2
- package/dist/storeTypes.mjs +1 -2
- package/dist/{task-Dhta7JyA.d.mts → task-4HeGAS8o.d.mts} +6 -6
- package/dist/{task-Dhta7JyA.d.mts.map → task-4HeGAS8o.d.mts.map} +1 -1
- package/dist/{taskStore-pAJ971Ml.mjs → taskStore-BAi54FKL.mjs} +4 -4
- package/dist/{taskStore-pAJ971Ml.mjs.map → taskStore-BAi54FKL.mjs.map} +1 -1
- package/dist/{taskStore-DjU60rMm.cjs → taskStore-C4vcUOzA.cjs} +4 -4
- package/dist/{taskStore-DjU60rMm.cjs.map → taskStore-C4vcUOzA.cjs.map} +1 -1
- package/dist/telemetry-DYfgUFF8.d.mts +35 -0
- package/dist/telemetry-DYfgUFF8.d.mts.map +1 -0
- package/dist/telemetry-gEGWTaMI.mjs +25 -0
- package/dist/telemetry-gEGWTaMI.mjs.map +1 -0
- package/dist/telemetry-x3JxCA5K.cjs +30 -0
- package/dist/telemetry-x3JxCA5K.cjs.map +1 -0
- package/dist/toolPromptGuidelines.cjs +1 -1
- package/dist/toolPromptGuidelines.cjs.map +1 -1
- package/dist/toolPromptGuidelines.mjs +1 -1
- package/dist/toolPromptGuidelines.mjs.map +1 -1
- package/dist/toolResponseEnvelope.mjs +1 -2
- package/dist/toolSchema.d.mts +1 -1
- package/dist/toolSchema.mjs +1 -2
- package/package.json +16 -15
- package/dist/config-CFSs3iku.mjs.map +0 -1
- package/dist/config-CdX-Bv8q.cjs.map +0 -1
- package/dist/delegation-CdMqOZB4.mjs.map +0 -1
- package/dist/delegation-DsnKjMbJ.cjs.map +0 -1
- package/dist/index-Dvb8X_qB.d.mts.map +0 -1
- package/dist/logSinkTelemetry-B23qGiP-.cjs.map +0 -1
- package/dist/logSinkTelemetry-BMBsC54p.mjs.map +0 -1
- package/dist/paths-CSya2l9_.cjs.map +0 -1
- package/dist/paths-Cah1vFGv.mjs.map +0 -1
- package/dist/telemetry-Ca0I3Tqo.cjs +0 -30
- package/dist/telemetry-Ca0I3Tqo.cjs.map +0 -1
- package/dist/telemetry-DyS44zAD.mjs +0 -25
- package/dist/telemetry-DyS44zAD.mjs.map +0 -1
- package/dist/telemetry-FMGRovb4.d.mts +0 -35
- package/dist/telemetry-FMGRovb4.d.mts.map +0 -1
|
@@ -19,7 +19,7 @@ const DEFAULT_PROMPT_GUIDELINES = [
|
|
|
19
19
|
"Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.",
|
|
20
20
|
"Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.",
|
|
21
21
|
"Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.",
|
|
22
|
-
"When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending.
|
|
22
|
+
"When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Po Task records delegated lifecycle and results on the task itself."
|
|
23
23
|
];
|
|
24
24
|
//#endregion
|
|
25
25
|
exports.DEFAULT_PROMPT_GUIDELINES = DEFAULT_PROMPT_GUIDELINES;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolPromptGuidelines.cjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending.
|
|
1
|
+
{"version":3,"file":"toolPromptGuidelines.cjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Po Task records delegated lifecycle and results on the task itself.',\n];\n"],"mappings":";;;;;;;;;;;AASA,MAAa,4BAAsC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -18,7 +18,7 @@ const DEFAULT_PROMPT_GUIDELINES = [
|
|
|
18
18
|
"Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.",
|
|
19
19
|
"Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.",
|
|
20
20
|
"Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.",
|
|
21
|
-
"When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending.
|
|
21
|
+
"When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Po Task records delegated lifecycle and results on the task itself."
|
|
22
22
|
];
|
|
23
23
|
//#endregion
|
|
24
24
|
export { DEFAULT_PROMPT_GUIDELINES };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolPromptGuidelines.mjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending.
|
|
1
|
+
{"version":3,"file":"toolPromptGuidelines.mjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Po Task records delegated lifecycle and results on the task itself.',\n];\n"],"mappings":";;;;;;;;;;AASA,MAAa,4BAAsC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, buildAssignmentResult, buildTextResult, buildToolResult, formatAssignmentResults, formatContent, formatUpsertFailureText };
|
|
1
|
+
export { t as MSG_ALL_COMPLETE_CLEAR, n as MSG_ASSIGN_PARTIAL, r as MSG_UPSERT_NONE_APPLIED, i as MSG_UPSERT_PARTIAL, a as buildAssignmentResult, o as buildTextResult, s as buildToolResult, c as formatAssignmentResults, l as formatContent, u as formatUpsertFailureText } from "./taskResult-edBAAKSH.mjs";
|
package/dist/toolSchema.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as TaskParamsSchema, a as RemoteTaskParamsSchema, c as TASK_CONTEXTS, d as TOOL_NAME, f as TaskAssignmentParams, g as TaskParams, h as TaskItemSchema, i as REMOTE_TASK_ACTIONS, l as TASK_STATUSES, m as TaskItemParams, n as MSG_NO_TASKS, o as TASK_ACTIONS, p as TaskAssignmentSchema, r as MSG_UPSERT_FIELD_MISPLACED, s as TASK_ACTION_FIELDS, t as ERR_REQUIRES_INTERACTIVE, u as TOOL_LABEL, v as taskActionAcceptsField, y as COMMAND_NAME } from "./task-
|
|
1
|
+
import { _ as TaskParamsSchema, a as RemoteTaskParamsSchema, c as TASK_CONTEXTS, d as TOOL_NAME, f as TaskAssignmentParams, g as TaskParams, h as TaskItemSchema, i as REMOTE_TASK_ACTIONS, l as TASK_STATUSES, m as TaskItemParams, n as MSG_NO_TASKS, o as TASK_ACTIONS, p as TaskAssignmentSchema, r as MSG_UPSERT_FIELD_MISPLACED, s as TASK_ACTION_FIELDS, t as ERR_REQUIRES_INTERACTIVE, u as TOOL_LABEL, v as taskActionAcceptsField, y as COMMAND_NAME } from "./task-4HeGAS8o.mjs";
|
|
2
2
|
export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, REMOTE_TASK_ACTIONS, RemoteTaskParamsSchema, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentParams, TaskAssignmentSchema, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField };
|
package/dist/toolSchema.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, REMOTE_TASK_ACTIONS, RemoteTaskParamsSchema, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentSchema, TaskItemSchema, TaskParamsSchema, taskActionAcceptsField };
|
|
1
|
+
export { g as COMMAND_NAME, t as ERR_REQUIRES_INTERACTIVE, n as MSG_NO_TASKS, r as MSG_UPSERT_FIELD_MISPLACED, i as REMOTE_TASK_ACTIONS, a as RemoteTaskParamsSchema, o as TASK_ACTIONS, s as TASK_ACTION_FIELDS, c as TASK_CONTEXTS, l as TASK_STATUSES, u as TOOL_LABEL, d as TOOL_NAME, f as TaskAssignmentSchema, p as TaskItemSchema, m as TaskParamsSchema, h as taskActionAcceptsField } from "./task-DO0TwZ0z.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-task",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.4",
|
|
4
4
|
"description": "Persistent, dependency-aware task graphs and subagent delegation for Pi coding sessions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -129,30 +129,30 @@
|
|
|
129
129
|
"registry": "https://registry.npmjs.org/"
|
|
130
130
|
},
|
|
131
131
|
"dependencies": {
|
|
132
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
133
|
-
"@agimon-ai/po-telemetry": "0.0.0-alpha.
|
|
134
|
-
"@agimon-ai/po-ui": "0.0.0-alpha.
|
|
135
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
132
|
+
"@agimon-ai/po-core": "0.0.0-alpha.4",
|
|
133
|
+
"@agimon-ai/po-telemetry": "0.0.0-alpha.4",
|
|
134
|
+
"@agimon-ai/po-ui": "0.0.0-alpha.4",
|
|
135
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.4",
|
|
136
136
|
"@deepseek-ai/cordis": "4.0.4",
|
|
137
|
-
"typebox": "1.3.
|
|
137
|
+
"typebox": "1.3.37"
|
|
138
138
|
},
|
|
139
139
|
"devDependencies": {
|
|
140
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
141
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
140
|
+
"@agimon-ai/po-build": "0.0.0-alpha.4",
|
|
141
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.4",
|
|
142
142
|
"@babel/core": "7.29.7",
|
|
143
143
|
"@earendil-works/pi-coding-agent": "1.2.0",
|
|
144
144
|
"@tanstack/react-store": "0.11.2",
|
|
145
145
|
"@tanstack/store": "0.11.2",
|
|
146
|
-
"@types/node": "26.6.
|
|
147
|
-
"@types/react": "19.
|
|
148
|
-
"@vitest/coverage-v8": "5.0.
|
|
146
|
+
"@types/node": "26.6.5",
|
|
147
|
+
"@types/react": "~19.2.4",
|
|
148
|
+
"@vitest/coverage-v8": "5.0.4",
|
|
149
149
|
"react": "19.3.0",
|
|
150
150
|
"react-dom": "19.3.0",
|
|
151
151
|
"react-native": "0.86.3",
|
|
152
|
-
"react-native-unistyles": "3.5.
|
|
153
|
-
"tsdown": "0.23.
|
|
154
|
-
"typescript": "
|
|
155
|
-
"vitest": "5.0.
|
|
152
|
+
"react-native-unistyles": "3.5.3",
|
|
153
|
+
"tsdown": "0.23.1",
|
|
154
|
+
"typescript": "~6.0.3",
|
|
155
|
+
"vitest": "5.0.4"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"@earendil-works/pi-coding-agent": "1.2.0"
|
|
@@ -186,6 +186,7 @@
|
|
|
186
186
|
],
|
|
187
187
|
"client": "./dist/extensions/native.mjs",
|
|
188
188
|
"scopes": [
|
|
189
|
+
"workspace",
|
|
189
190
|
"session"
|
|
190
191
|
]
|
|
191
192
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-CFSs3iku.mjs","names":[],"sources":["../src/services/config/index.ts"],"sourcesContent":["/**\n * Extension configuration, read from the environment.\n *\n * Env rather than a config file: po already carries per-launch state to Pi\n * through env vars, so this keeps doom-task consistent with how the harness\n * configures the rest of the extension set.\n */\n\nexport const MAX_WIDGET_LINES_ENV = 'DOOM_TASK_MAX_WIDGET_LINES';\nexport const MAX_TASKS_ENV = 'DOOM_TASK_MAX_TASKS';\nexport const COLLAPSE_KEY_ENV = 'DOOM_TASK_COLLAPSE_KEY';\nexport const STORE_TTL_MS_ENV = 'DOOM_TASK_STORE_TTL_MS';\nexport const DELEGATION_TIMEOUT_MS_ENV = 'DOOM_TASK_DELEGATION_TIMEOUT_MS';\n\nexport const DEFAULT_MAX_WIDGET_LINES = 12;\nexport const DEFAULT_MAX_TASKS = 15;\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+shift+t';\nexport const DEFAULT_STORE_TTL_MS = 30 * 24 * 60 * 60 * 1000;\n/** Deliberately under the subagents auto-drain ceiling (30 min) so a headless\n * session still gets the failure and a model turn before draining gives up. */\nexport const DEFAULT_DELEGATION_TIMEOUT_MS = 20 * 60 * 1000;\nexport const COLLAPSE_KEY_OFF = 'off';\n\nconst MIN_WIDGET_LINES = 3;\nconst MAX_WIDGET_LINES = 60;\n\nexport interface PiTaskConfig {\n maxWidgetLines: number;\n maxTasks: number;\n storeTtlMs: number;\n collapseKey: string;\n delegationTimeoutMs: number;\n}\n\nfunction configRecord(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};\n}\n\n/** Parse configuration only after the Pi host has applied its project-trust policy. */\nexport function parsePiTaskConfig(value: unknown): PiTaskConfig {\n const config = configRecord(value);\n const maxWidgetLines =\n typeof config.maxWidgetLines === 'number' && Number.isFinite(config.maxWidgetLines)\n ? Math.min(Math.max(config.maxWidgetLines, MIN_WIDGET_LINES), MAX_WIDGET_LINES)\n : DEFAULT_MAX_WIDGET_LINES;\n const maxTasks =\n typeof config.maxTasks === 'number' && Number.isSafeInteger(config.maxTasks) && config.maxTasks > 0\n ? config.maxTasks\n : DEFAULT_MAX_TASKS;\n const storeTtlMs =\n typeof config.storeTtlMs === 'number' && Number.isFinite(config.storeTtlMs) && config.storeTtlMs > 0\n ? config.storeTtlMs\n : DEFAULT_STORE_TTL_MS;\n const delegationTimeoutMs =\n typeof config.delegationTimeoutMs === 'number' &&\n Number.isFinite(config.delegationTimeoutMs) &&\n config.delegationTimeoutMs > 0\n ? config.delegationTimeoutMs\n : DEFAULT_DELEGATION_TIMEOUT_MS;\n const collapseKey =\n typeof config.collapseKey === 'string' && config.collapseKey.trim()\n ? config.collapseKey.trim().toLowerCase() === COLLAPSE_KEY_OFF\n ? COLLAPSE_KEY_OFF\n : config.collapseKey.trim()\n : DEFAULT_COLLAPSE_KEY;\n\n return { maxWidgetLines, maxTasks, storeTtlMs, collapseKey, delegationTimeoutMs };\n}\n\n/** Rows the overlay may use for content, clamped to a sane range. */\nexport function getMaxWidgetLines(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number.parseInt(env[MAX_WIDGET_LINES_ENV] ?? '', 10);\n if (!Number.isFinite(raw)) return DEFAULT_MAX_WIDGET_LINES;\n return Math.min(Math.max(raw, MIN_WIDGET_LINES), MAX_WIDGET_LINES);\n}\n\n/** Maximum number of non-deleted tasks retained on one board. */\nexport function getMaxTasks(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[MAX_TASKS_ENV]);\n return Number.isSafeInteger(raw) && raw > 0 ? raw : DEFAULT_MAX_TASKS;\n}\n\n/** Retention window for inactive session-tree stores. */\nexport function getStoreTtlMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[STORE_TTL_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_STORE_TTL_MS;\n}\n\n/** How long a delegated run may go without reporting a result. */\nexport function getDelegationTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[DELEGATION_TIMEOUT_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_DELEGATION_TIMEOUT_MS;\n}\n\n/** Collapse shortcut, or the `off` sentinel when the user disabled it. */\nexport function resolveCollapseKey(env: NodeJS.ProcessEnv = process.env): string {\n const configured = env[COLLAPSE_KEY_ENV]?.trim();\n if (!configured) return DEFAULT_COLLAPSE_KEY;\n return configured.toLowerCase() === COLLAPSE_KEY_OFF ? COLLAPSE_KEY_OFF : configured;\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,uBAAuB;AACpC,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,4BAA4B;AAEzC,MAAa,2BAA2B;AACxC,MAAa,oBAAoB;AACjC,MAAa,uBAAuB;AACpC,MAAa,uBAAuB;;;AAGpC,MAAa,gCAAgC;AAC7C,MAAa,mBAAmB;AAEhC,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AAUzB,SAAS,aAAa,OAAyC;CAC7D,OAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAoC,CAAC;AACtH;;AAGA,SAAgB,kBAAkB,OAA8B;CAC9D,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,iBACJ,OAAO,OAAO,mBAAmB,YAAY,OAAO,SAAS,OAAO,cAAc,IAC9E,KAAK,IAAI,KAAK,IAAI,OAAO,gBAAgB,gBAAgB,GAAG,gBAAgB,IAAA;CAElF,MAAM,WACJ,OAAO,OAAO,aAAa,YAAY,OAAO,cAAc,OAAO,QAAQ,KAAK,OAAO,WAAW,IAC9F,OAAO,WAAA;CAEb,MAAM,aACJ,OAAO,OAAO,eAAe,YAAY,OAAO,SAAS,OAAO,UAAU,KAAK,OAAO,aAAa,IAC/F,OAAO,aACP;CACN,MAAM,sBACJ,OAAO,OAAO,wBAAwB,YACtC,OAAO,SAAS,OAAO,mBAAmB,KAC1C,OAAO,sBAAsB,IACzB,OAAO,sBACP;CAQN,OAAO;EAAE;EAAgB;EAAU;EAAY,aAN7C,OAAO,OAAO,gBAAgB,YAAY,OAAO,YAAY,KAAK,IAC9D,OAAO,YAAY,KAAK,CAAC,CAAC,YAAY,MAAA,QAAA,QAEpC,OAAO,YAAY,KAAK,IAC1B;EAEsD;CAAoB;AAClF;;AAGA,SAAgB,kBAAkB,MAAyB,QAAQ,KAAa;CAC9E,MAAM,MAAM,OAAO,SAAS,IAAA,iCAA6B,IAAI,EAAE;CAC/D,IAAI,CAAC,OAAO,SAAS,GAAG,GAAG,OAAA;CAC3B,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,gBAAgB,GAAG,gBAAgB;AACnE;;AAGA,SAAgB,YAAY,MAAyB,QAAQ,KAAa;CACxE,MAAM,MAAM,OAAO,IAAI,cAAc;CACrC,OAAO,OAAO,cAAc,GAAG,KAAK,MAAM,IAAI,MAAA;AAChD;;AAGA,SAAgB,cAAc,MAAyB,QAAQ,KAAa;CAC1E,MAAM,MAAM,OAAO,IAAI,iBAAiB;CACxC,OAAO,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;AACjD;;AAGA,SAAgB,uBAAuB,MAAyB,QAAQ,KAAa;CACnF,MAAM,MAAM,OAAO,IAAI,0BAA0B;CACjD,OAAO,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;AACjD;;AAGA,SAAgB,mBAAmB,MAAyB,QAAQ,KAAa;CAC/E,MAAM,aAAa,IAAI,iBAAiB,EAAE,KAAK;CAC/C,IAAI,CAAC,YAAY,OAAO;CACxB,OAAO,WAAW,YAAY,MAAA,QAAA,QAA4C;AAC5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-CdX-Bv8q.cjs","names":[],"sources":["../src/services/config/index.ts"],"sourcesContent":["/**\n * Extension configuration, read from the environment.\n *\n * Env rather than a config file: po already carries per-launch state to Pi\n * through env vars, so this keeps doom-task consistent with how the harness\n * configures the rest of the extension set.\n */\n\nexport const MAX_WIDGET_LINES_ENV = 'DOOM_TASK_MAX_WIDGET_LINES';\nexport const MAX_TASKS_ENV = 'DOOM_TASK_MAX_TASKS';\nexport const COLLAPSE_KEY_ENV = 'DOOM_TASK_COLLAPSE_KEY';\nexport const STORE_TTL_MS_ENV = 'DOOM_TASK_STORE_TTL_MS';\nexport const DELEGATION_TIMEOUT_MS_ENV = 'DOOM_TASK_DELEGATION_TIMEOUT_MS';\n\nexport const DEFAULT_MAX_WIDGET_LINES = 12;\nexport const DEFAULT_MAX_TASKS = 15;\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+shift+t';\nexport const DEFAULT_STORE_TTL_MS = 30 * 24 * 60 * 60 * 1000;\n/** Deliberately under the subagents auto-drain ceiling (30 min) so a headless\n * session still gets the failure and a model turn before draining gives up. */\nexport const DEFAULT_DELEGATION_TIMEOUT_MS = 20 * 60 * 1000;\nexport const COLLAPSE_KEY_OFF = 'off';\n\nconst MIN_WIDGET_LINES = 3;\nconst MAX_WIDGET_LINES = 60;\n\nexport interface PiTaskConfig {\n maxWidgetLines: number;\n maxTasks: number;\n storeTtlMs: number;\n collapseKey: string;\n delegationTimeoutMs: number;\n}\n\nfunction configRecord(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};\n}\n\n/** Parse configuration only after the Pi host has applied its project-trust policy. */\nexport function parsePiTaskConfig(value: unknown): PiTaskConfig {\n const config = configRecord(value);\n const maxWidgetLines =\n typeof config.maxWidgetLines === 'number' && Number.isFinite(config.maxWidgetLines)\n ? Math.min(Math.max(config.maxWidgetLines, MIN_WIDGET_LINES), MAX_WIDGET_LINES)\n : DEFAULT_MAX_WIDGET_LINES;\n const maxTasks =\n typeof config.maxTasks === 'number' && Number.isSafeInteger(config.maxTasks) && config.maxTasks > 0\n ? config.maxTasks\n : DEFAULT_MAX_TASKS;\n const storeTtlMs =\n typeof config.storeTtlMs === 'number' && Number.isFinite(config.storeTtlMs) && config.storeTtlMs > 0\n ? config.storeTtlMs\n : DEFAULT_STORE_TTL_MS;\n const delegationTimeoutMs =\n typeof config.delegationTimeoutMs === 'number' &&\n Number.isFinite(config.delegationTimeoutMs) &&\n config.delegationTimeoutMs > 0\n ? config.delegationTimeoutMs\n : DEFAULT_DELEGATION_TIMEOUT_MS;\n const collapseKey =\n typeof config.collapseKey === 'string' && config.collapseKey.trim()\n ? config.collapseKey.trim().toLowerCase() === COLLAPSE_KEY_OFF\n ? COLLAPSE_KEY_OFF\n : config.collapseKey.trim()\n : DEFAULT_COLLAPSE_KEY;\n\n return { maxWidgetLines, maxTasks, storeTtlMs, collapseKey, delegationTimeoutMs };\n}\n\n/** Rows the overlay may use for content, clamped to a sane range. */\nexport function getMaxWidgetLines(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number.parseInt(env[MAX_WIDGET_LINES_ENV] ?? '', 10);\n if (!Number.isFinite(raw)) return DEFAULT_MAX_WIDGET_LINES;\n return Math.min(Math.max(raw, MIN_WIDGET_LINES), MAX_WIDGET_LINES);\n}\n\n/** Maximum number of non-deleted tasks retained on one board. */\nexport function getMaxTasks(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[MAX_TASKS_ENV]);\n return Number.isSafeInteger(raw) && raw > 0 ? raw : DEFAULT_MAX_TASKS;\n}\n\n/** Retention window for inactive session-tree stores. */\nexport function getStoreTtlMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[STORE_TTL_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_STORE_TTL_MS;\n}\n\n/** How long a delegated run may go without reporting a result. */\nexport function getDelegationTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[DELEGATION_TIMEOUT_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_DELEGATION_TIMEOUT_MS;\n}\n\n/** Collapse shortcut, or the `off` sentinel when the user disabled it. */\nexport function resolveCollapseKey(env: NodeJS.ProcessEnv = process.env): string {\n const configured = env[COLLAPSE_KEY_ENV]?.trim();\n if (!configured) return DEFAULT_COLLAPSE_K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B,QAAQ,KAAa;CAC9E,MAAM,MAAM,OAAO,SAAS,IAAA,iCAA6B,IAAI,EAAE;CAC/D,IAAI,CAAC,OAAO,SAAS,GAAG,GAAG,OAAA;CAC3B,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,gBAAgB,GAAG,gBAAgB;AACnE;;AAGA,SAAgB,YAAY,MAAyB,QAAQ,KAAa;CACxE,MAAM,MAAM,OAAO,IAAI,cAAc;CACrC,OAAO,OAAO,cAAc,GAAG,KAAK,MAAM,IAAI,MAAA;AAChD;;AAGA,SAAgB,cAAc,MAAyB,QAAQ,KAAa;CAC1E,MAAM,MAAM,OAAO,IAAI,iBAAiB;CACxC,OAAO,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;AACjD;;AAGA,SAAgB,uBAAuB,MAAyB,QAAQ,KAAa;CACnF,MAAM,MAAM,OAAO,IAAI,0BAA0B;CACjD,OAAO,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;AACjD;;AAGA,SAAgB,mBAAmB,MAAyB,QAAQ,KAAa;CAC/E,MAAM,aAAa,IAAI,iBAAiB,EAAE,KAAK;CAC/C,IAAI,CAAC,YAAY,OAAO;CACxB,OAAO,WAAW,YAAY,MAAA,QAAA,QAA4C;AAC5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delegation-CdMqOZB4.mjs","names":[],"sources":["../src/services/delegation/index.ts"],"sourcesContent":["import {\n type DelegationAccepted as DelegationAcceptedPayload,\n DOOM_DELEGATION_ACCEPTED_EVENT,\n DOOM_DELEGATION_FINISHED_EVENT,\n DOOM_DELEGATION_STARTED_EVENT,\n DOOM_DELEGATION_UPDATED_EVENT,\n type DoomDelegationService,\n type DelegationResult,\n type DelegationStarted as DelegationStartedPayload,\n type DelegationUpdate,\n type InlineAgent,\n} from '@agimon-ai/po-core/delegation';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { isBlocked, isTaskListComplete } from '../../models/taskGraph';\nimport { MAX_BRIEF_FILES } from '../../types/delegation';\nimport { TASK_EVENT, type TaskEventName, type TaskFailureReporter } from '../../types/telemetry';\nimport { reconcileOrphanedDelegations } from '../reconcile';\nimport type { TaskStore } from '../taskStore';\n\nexport { MAX_BRIEF_FILES };\nimport { isDelegationActive, type Task, type TaskDelegation, type TaskDocument } from '../../models/task';\n\nexport const NOTIFY_CUSTOM_TYPE = 'doom-task-notify';\nexport const BACKGROUND_WORK_PROVIDER = 'doom-task';\n\nconst DEFAULT_STARTED_TIMEOUT_MS = 5000;\nconst DEFAULT_RUN_TIMEOUT_MS = 20 * 60 * 1000;\nconst DEFAULT_CANCEL_TIMEOUT_MS = 10_000;\nconst MAX_RUN_TIMEOUT_GRACE_MS = 60_000;\nconst MAX_STORED_OUTPUT = 4000;\n/**\n * Cap on files rendered into a brief. Exported so the tool schema can state the\n * same number to the model rather than restating it and drifting.\n */\nconst MAX_BRIEF_NOTES = 1500;\nconst COMPLETED_STATE = 'completed';\nconst FAILED_STATE = 'failed';\nconst CANCELLED_STATE = 'cancelled';\nconst TIMED_OUT_STATUS = 'timed_out';\nconst DELETED_STATUS: Task['status'] = 'deleted';\n\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REQUEST_ID_ATTRIBUTE = 'delegation.request_id';\n// `_name` suffix is load-bearing: the telemetry redactor drops string values\n// whose key has no safe meaning, and a bare `delegation.agent` is dropped.\nconst AGENT_ATTRIBUTE = 'delegation.agent_name';\nconst PID_ATTRIBUTE = 'delegation.pid';\nconst CONTEXT_PRESENT_ATTRIBUTE = 'delegation.context_present';\nconst CONTEXT_FILE_COUNT_ATTRIBUTE = 'delegation.context_file_count';\nconst CONTEXT_NOTES_LENGTH_ATTRIBUTE = 'delegation.context_notes_length';\nconst BRIEF_LENGTH_ATTRIBUTE = 'delegation.brief_length';\nconst TOOL_COUNT_ATTRIBUTE = 'delegation.tool_count';\nconst DURATION_MS_ATTRIBUTE = 'delegation.duration_ms';\nconst OUTCOME_ATTRIBUTE = 'delegation.outcome';\n\ntype SettlementState = typeof COMPLETED_STATE | typeof FAILED_STATE | typeof CANCELLED_STATE;\n\nexport const ERR_NO_RUNTIME =\n 'No subagent runtime responded. Delegation needs the subagents extension — relaunch po with agents enabled.';\nexport const ERR_CHILD_SESSION =\n 'assign is only available in the main session. Update this task directly instead of re-delegating it.';\nexport const ERR_CANCEL_UNACKNOWLEDGED = 'Subagent did not acknowledge the cancel request';\n\n/** Live progress from a running subagent. Kept in memory: persisting per-tool\n * ticks would rewrite the store file every second for no durable benefit. */\nexport interface DelegationProgress {\n agent: string;\n currentTool?: string;\n toolCount?: number;\n tokens?: number;\n /** Latest child-runtime duration baseline, excluding assignment wait. */\n durationMs?: number;\n /** Wall-clock time at which durationMs was observed or rebased. */\n durationObservedAt?: number;\n /** Assign-time context-pack shape, carried so the completion event can be\n * grouped by it without joining back to the assignment event. */\n contextFileCount?: number;\n contextNotesLength?: number;\n}\n\nexport type DelegationNotifier = (\n message: { customType: string; content: string; display: boolean },\n options?: { triggerTurn?: boolean; deliverAs?: 'steer' | 'followUp' | 'nextTurn' },\n) => void;\n\nexport interface DelegationPlatform {\n readonly environment: Readonly<Record<string, string | undefined>>;\n readonly processId: number;\n readonly createRequestId: () => string;\n readonly formatBriefPath: (entry: string, cwd: string) => string;\n}\n\nexport interface DelegationManagerOptions {\n store: TaskStore;\n cwd: string;\n platform: DelegationPlatform;\n notify?: DelegationNotifier;\n getSessionId?: () => string | undefined;\n onChange?: () => void;\n startedTimeoutMs?: number;\n /** How long a started run may go without reporting a result. */\n runTimeoutMs?: number;\n /** How long to wait for a cancelled run to report back before forcing it. */\n cancelTimeoutMs?: number;\n now?: () => string;\n nowMs?: () => number;\n /** Called when a completion notification could not be delivered. */\n onNotifyError: (error: unknown, taskId: number) => void;\n /** Where other swallowed delegation failures go. */\n report?: TaskFailureReporter;\n}\n\nexport interface AssignOptions {\n agent?: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n /** Paths the parent already located, rendered into the brief so the child\n * skips rediscovering them. */\n relevantFiles?: string[];\n /** Facts the parent already established, rendered into the brief so the child\n * does not re-derive them. */\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n signal?: AbortSignal;\n}\n\nexport interface DelegationOutcome {\n ok: boolean;\n message: string;\n}\n\n/** Result of the guarded store mutation that claims a task for delegation. */\ninterface AssignAttempt extends DelegationOutcome {\n task?: Task;\n}\n\ninterface PendingTask {\n readonly taskId: number;\n readonly sessionId?: string;\n}\n\nfunction truncate(value: string | undefined, limit = MAX_STORED_OUTPUT): string | undefined {\n if (!value) return undefined;\n return value.length <= limit ? value : `${value.slice(0, limit)}\\n… (truncated)`;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** The assign-time context pack, normalized once for the brief and the telemetry. */\ninterface BriefContext {\n files: string[];\n notes?: string;\n}\n\n/** Normalize the parent context with host-owned path semantics. */\nfunction briefContext(options: AssignOptions, cwd: string, platform: DelegationPlatform): BriefContext {\n const files = new Set<string>();\n for (const entry of options.relevantFiles ?? []) {\n if (files.size >= MAX_BRIEF_FILES) break;\n const normalized = platform.formatBriefPath(entry.trim(), cwd);\n if (normalized && normalized !== '.') files.add(normalized);\n }\n return { files: [...files], notes: truncate(options.priorFindings?.trim(), MAX_BRIEF_NOTES) };\n}\n\n/**\n * Build the brief handed to the subagent.\n *\n * Doom Team owns the child tool surface and the parent owns the task record.\n * Keeping those responsibilities explicit prevents a child from attempting to\n * call a task tool that is not loaded in its runtime, while still giving it a\n * reliable path to ask the parent for a decision.\n *\n * The context pack is the parent's verified discovery handed over. The whole\n * block is omitted when nothing was supplied: this brief is the child's whole\n * starting context, so an empty section header is pure token cost.\n */\nfunction buildBrief(task: Task, instructions: string | undefined, context: BriefContext): string {\n const sections = [`Task #${task.id}: ${task.subject}`];\n if (task.description) sections.push(task.description);\n if (instructions) sections.push(instructions);\n if (context.files.length > 0 || context.notes) {\n const contextLines = ['Parent context — consume before repository discovery:'];\n if (context.files.length > 0) {\n contextLines.push(`- Parent-verified files (read these first with direct reads): ${context.files.join(', ')}`);\n }\n if (context.notes) {\n contextLines.push(\n `- Established facts (do not re-derive unless direct evidence contradicts them): ${context.notes}`,\n );\n }\n contextLines.push(\n 'This pack satisfies initial repository/context exploration. Do not begin with repository-wide listing, find, or grep. Expand only after consuming the pack and naming a concrete missing dependency or invalid path; search narrowly for that item and state why.',\n );\n sections.push(contextLines.join('\\n'));\n }\n sections.push(\n 'Coordination: work directly without changing the task record; ask main through intercom only for blockers or decisions; report changed files and verification when done.',\n );\n return sections.join('\\n\\n');\n}\n\n/**\n * Owns the lifecycle of tasks delegated to subagents.\n *\n * Delegation rides Team's injected Cordis service rather than spawning\n * processes directly, so doom-task stays decoupled from the subagent runtime\n * and degrades to a clear error when that service is not loaded.\n *\n * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so\n * a delegation always has a deadline no matter which phase it is in. Losing\n * that pairing is what previously left tasks running forever.\n */\nexport class DelegationManager {\n private readonly options: DelegationManagerOptions;\n private readonly progress = new Map<string, DelegationProgress>();\n private readonly pendingTasks = new Map<string, PendingTask>();\n private readonly settlingRequests = new Set<string>();\n private readonly timers = new Map<string, ReturnType<typeof setTimeout>>();\n private readonly subscriptions: Array<() => void> = [];\n private service: DoomDelegationService | undefined;\n\n constructor(options: DelegationManagerOptions) {\n this.options = options;\n }\n\n setCwd(cwd: string): void {\n this.options.cwd = cwd;\n }\n\n private now(): string {\n return this.options.now?.() ?? new Date().toISOString();\n }\n\n private nowMs(): number {\n return this.options.nowMs?.() ?? Date.now();\n }\n\n private get runTimeoutMs(): number {\n return this.options.runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;\n }\n\n private report(event: TaskEventName, error: unknown, attributes?: Record<string, string | number | boolean>): void {\n this.options.report?.error(event, error, attributes);\n }\n\n /** True in a session that is itself a subagent child. */\n get isChildSession(): boolean {\n return Boolean(this.options.platform.environment.PI_SUBAGENT_CHILD);\n }\n\n /** Live progress for a task, for the overlay to render. */\n progressFor(task: Task): DelegationProgress | undefined {\n const requestId = task.delegation?.requestId;\n return requestId ? this.progress.get(requestId) : undefined;\n }\n\n /** Displayed runtime duration, rebased from the latest child observation. */\n static elapsedMs(progress: DelegationProgress, nowMs = Date.now()): number {\n const baseline = progress.durationMs ?? 0;\n const observedAt = progress.durationObservedAt ?? nowMs;\n return baseline + Math.max(0, nowMs - observedAt);\n }\n\n /** Rebind to the active Team service without stacking lifecycle listeners. */\n bind(ctx: Context, service: DoomDelegationService): () => void {\n this.unbind();\n this.service = service;\n this.subscriptions.push(\n ctx.on(DOOM_DELEGATION_ACCEPTED_EVENT, (event) => {\n this.handleAccepted(event);\n }),\n ctx.on(DOOM_DELEGATION_STARTED_EVENT, (event) => {\n this.handleStarted(event);\n }),\n ctx.on(DOOM_DELEGATION_UPDATED_EVENT, (event) => {\n this.handleUpdate(event);\n }),\n ctx.on(DOOM_DELEGATION_FINISHED_EVENT, (event) => {\n void this.handleResponse(event).catch((error: unknown) => {\n this.report(TASK_EVENT.delegationResponseFailed, error, { [REQUEST_ID_ATTRIBUTE]: event.requestId });\n });\n }),\n );\n return () => {\n if (this.service === service) this.unbind();\n };\n }\n\n /** Remove only the cross-package binding; task state and watchdogs remain live. */\n unbind(): void {\n for (const unsubscribe of this.subscriptions.splice(0)) unsubscribe();\n this.service = undefined;\n }\n\n /** Items still in flight, surfaced so auto-stop will not kill the harness. */\n listActiveWork(): Array<{ id: string; sessionId: string }> {\n return [...this.pendingTasks.entries()].flatMap(([requestId, pending]) =>\n pending.sessionId ? [{ id: `task-${pending.taskId}:${requestId}`, sessionId: pending.sessionId }] : [],\n );\n }\n\n /**\n * Return tasks nothing can finish to `pending`.\n *\n * The live request set is read inside the mutation so a delegation assigned\n * while the lock was contended is not mistaken for a leftover.\n */\n async reconcile(isCurrent: () => boolean = () => true): Promise<Task[]> {\n const { value } = await this.options.store.mutate((document) => {\n if (!isCurrent()) return { value: [] as Task[] };\n const result = reconcileOrphanedDelegations(document, this.now(), undefined, {\n pid: this.options.platform.processId,\n liveRequestIds: new Set(this.pendingTasks.keys()),\n });\n if (result.orphaned.length === 0) return { value: [] as Task[] };\n return { document: result.document, value: result.orphaned };\n });\n\n if (!isCurrent()) return [];\n for (const task of value) {\n this.options.report?.warn(TASK_EVENT.delegationOrphaned, new Error(task.delegation?.result?.error ?? ''), {\n [TASK_ID_ATTRIBUTE]: task.id,\n ...(task.delegation?.agent ? { [AGENT_ATTRIBUTE]: task.delegation.agent } : {}),\n ...(task.delegation?.pid === undefined ? {} : { [PID_ATTRIBUTE]: task.delegation.pid }),\n });\n }\n\n if (value.length > 0) this.options.onChange?.();\n return value;\n }\n\n async assign(taskId: number, options: AssignOptions): Promise<DelegationOutcome> {\n const agent = options.agent?.trim();\n if (!agent) return { ok: false, message: 'agent required for assign' };\n if (this.isChildSession) return { ok: false, message: ERR_CHILD_SESSION };\n if (options.signal?.aborted) return { ok: false, message: 'delegation cancelled before it started' };\n\n const requestId = this.options.platform.createRequestId();\n const startedAt = this.now();\n const sessionId = this.options.getSessionId?.();\n const context = briefContext(options, this.options.cwd, this.options.platform);\n\n const { value: outcome } = await this.options.store.mutate<AssignAttempt>((current) => {\n const index = current.tasks.findIndex((task) => task.id === taskId);\n if (index === -1) return { value: { ok: false, message: `#${taskId} not found` } };\n\n const task = current.tasks[index];\n if (task.status === DELETED_STATUS) return { value: { ok: false, message: `#${taskId} is deleted` } };\n if (task.status === COMPLETED_STATE) {\n return { value: { ok: false, message: `#${taskId} is already completed` } };\n }\n if (isDelegationActive(task)) {\n return { value: { ok: false, message: `#${taskId} is already delegated to ${task.delegation?.agent}` } };\n }\n if (isBlocked(current.tasks, task)) {\n const blockers = (task.blockedBy ?? []).map((id) => `#${id}`).join(', ');\n return { value: { ok: false, message: `#${taskId} is blocked by ${blockers}` } };\n }\n\n const delegation: TaskDelegation = {\n requestId,\n agent,\n state: 'requested',\n pid: this.options.platform.processId,\n startedAt,\n ...(sessionId ? { sessionId } : {}),\n ...(options.model ? { model: options.model } : {}),\n };\n\n const tasks = [...current.tasks];\n tasks[index] = { ...task, owner: agent, updatedAt: startedAt, delegation };\n return {\n document: { ...current, tasks },\n value: { ok: true, message: '', task: tasks[index] },\n };\n });\n\n if (!outcome.ok || !outcome.task) return { ok: false, message: outcome.message };\n\n const contextNotesLength = context.notes?.length ?? 0;\n this.pendingTasks.set(requestId, { taskId, sessionId });\n this.progress.set(requestId, { agent, contextFileCount: context.files.length, contextNotesLength });\n this.armStartedTimeout(requestId);\n this.options.onChange?.();\n const request = {\n requestId,\n taskId,\n agent,\n ...(options.inlineAgent ? { inlineAgent: options.inlineAgent } : {}),\n prompt: buildBrief(outcome.task, options.instructions, context),\n ...(options.context ? { context: options.context } : {}),\n cwd: this.options.cwd,\n artifacts: true,\n timeoutMs: this.runTimeoutMs,\n runMode: 'detached' as const,\n teamTask: { id: String(outcome.task.id), subject: outcome.task.subject },\n ...(options.model ? { model: options.model } : {}),\n };\n\n try {\n const service = this.service;\n if (!service) throw new Error(ERR_NO_RUNTIME);\n void service.request(request).catch((error: unknown) => {\n this.report(TASK_EVENT.delegationRequestFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n });\n this.settleDetached(requestId, FAILED_STATE, {\n status: FAILED_STATE,\n error: `Delegation request failed: ${messageOf(error)}`,\n });\n });\n } catch (error) {\n this.report(TASK_EVENT.delegationRequestFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n });\n const detail = messageOf(error);\n await this.settle(requestId, FAILED_STATE, {\n status: FAILED_STATE,\n error: `Delegation request failed: ${detail}`,\n });\n return { ok: false, message: `Could not dispatch #${taskId} to ${agent}: ${detail}` };\n }\n\n // Recorded only after the service accepted the request call, so it means a\n // brief actually entered Team's state machine rather than merely being assembled.\n this.options.report?.event(TASK_EVENT.delegationAssigned, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [CONTEXT_PRESENT_ATTRIBUTE]: context.files.length > 0 || contextNotesLength > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: context.files.length,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: contextNotesLength,\n [BRIEF_LENGTH_ATTRIBUTE]: request.prompt.length,\n });\n\n return {\n ok: true,\n message: `Delegated #${taskId} to ${agent} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end your turn.`,\n };\n }\n\n async cancel(taskId: number): Promise<DelegationOutcome> {\n const document = this.options.store.read();\n const task = document.tasks.find((candidate) => candidate.id === taskId);\n if (!task) return { ok: false, message: `#${taskId} not found` };\n if (!task.delegation || !isDelegationActive(task)) {\n return { ok: false, message: `#${taskId} has no running delegation` };\n }\n\n const { requestId } = task.delegation;\n this.service?.cancel({ requestId });\n // Only this session can force the outcome; a delegation owned elsewhere\n // gets the request and nothing more.\n this.armCancelTimeout(requestId);\n return { ok: true, message: `Cancelling delegation for #${taskId} (${task.delegation.agent})` };\n }\n\n /** Settle without awaiting, reporting rather than dropping a failure. */\n private settleDetached(\n requestId: string,\n state: SettlementState,\n result: TaskDelegation['result'],\n event: TaskEventName = TASK_EVENT.delegationSettleFailed,\n ): void {\n void this.settle(requestId, state, result).catch((error: unknown) => {\n this.report(event, error, { [REQUEST_ID_ATTRIBUTE]: requestId });\n });\n }\n\n /**\n * Fail a delegation that nobody acknowledged.\n *\n * Provider loss or a stalled Team runtime can still leave a dispatched\n * request silent. Without this acknowledgement deadline the task would sit\n * in `requested` forever.\n */\n private armStartedTimeout(requestId: string): void {\n this.armTimer(requestId, this.options.startedTimeoutMs ?? DEFAULT_STARTED_TIMEOUT_MS, () => {\n this.settleDetached(requestId, FAILED_STATE, { status: FAILED_STATE, error: ERR_NO_RUNTIME });\n });\n }\n\n /**\n * Bound a run that already started.\n *\n * The request carries the same budget, so in the normal case the runtime ends\n * the run itself and reports a richer result. The grace period biases toward\n * that answer; this timer only covers a runtime that goes silent, which is\n * precisely the case where no response event will ever arrive.\n */\n private armRunTimeout(requestId: string): void {\n const grace = Math.min(MAX_RUN_TIMEOUT_GRACE_MS, this.runTimeoutMs);\n this.armTimer(requestId, this.runTimeoutMs + grace, () => {\n const taskId = this.pendingTasks.get(requestId)?.taskId;\n const agent = this.progress.get(requestId)?.agent;\n const error = new Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);\n this.options.report?.warn(TASK_EVENT.delegationTimedOut, error, {\n ...(taskId === undefined ? {} : { [TASK_ID_ATTRIBUTE]: taskId }),\n [REQUEST_ID_ATTRIBUTE]: requestId,\n ...(agent ? { [AGENT_ATTRIBUTE]: agent } : {}),\n });\n this.service?.cancel({ requestId, reason: error.message });\n this.settleDetached(requestId, FAILED_STATE, { status: TIMED_OUT_STATUS, error: error.message });\n });\n }\n\n /**\n * Guarantee a cancel reaches a terminal state.\n *\n * Calling the service is a request, not an outcome: a runtime that has\n * already forgotten the request answers nothing at all. The window still\n * favours a real response, which carries the run's partial output.\n */\n private armCancelTimeout(requestId: string): void {\n if (!this.pendingTasks.has(requestId)) return;\n this.armTimer(requestId, this.options.cancelTimeoutMs ?? DEFAULT_CANCEL_TIMEOUT_MS, () => {\n this.settleDetached(requestId, CANCELLED_STATE, {\n status: CANCELLED_STATE,\n error: ERR_CANCEL_UNACKNOWLEDGED,\n });\n });\n }\n\n private armTimer(requestId: string, delayMs: number, onFire: () => void): void {\n this.clearTimer(requestId);\n const timer = setTimeout(onFire, delayMs);\n timer.unref?.();\n this.timers.set(requestId, timer);\n }\n\n private clearTimer(requestId: string): void {\n const timer = this.timers.get(requestId);\n if (timer) clearTimeout(timer);\n this.timers.delete(requestId);\n }\n\n /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */\n private handleAccepted(event: DelegationAcceptedPayload): void {\n if (!this.pendingTasks.has(event.requestId)) return;\n this.armRunTimeout(event.requestId);\n }\n\n private handleStarted(event: DelegationStartedPayload): void {\n const { runId } = event;\n const taskId = this.pendingTasks.get(event.requestId)?.taskId;\n if (taskId === undefined) return;\n this.armRunTimeout(event.requestId);\n const existing = this.progress.get(event.requestId);\n if (existing) {\n this.progress.set(event.requestId, {\n ...existing,\n durationMs: existing.durationMs ?? 0,\n durationObservedAt: existing.durationObservedAt ?? this.nowMs(),\n });\n }\n\n void this.options.store\n .mutate((document) =>\n this.patchDelegation(document, event.requestId, (task, delegation) => ({\n ...task,\n status: task.status === COMPLETED_STATE ? task.status : 'in_progress',\n delegation: {\n ...delegation,\n state: 'running',\n startedAt: delegation.startedAt ?? this.now(),\n ...(runId ? { runId } : {}),\n },\n })),\n )\n .then(() => this.options.onChange?.())\n .catch((error: unknown) => {\n this.report(TASK_EVENT.delegationStartFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: event.requestId,\n });\n });\n }\n\n private handleUpdate(event: DelegationUpdate): void {\n const existing = this.progress.get(event.requestId);\n if (!existing) return;\n\n const observedAt = this.nowMs();\n const currentElapsed = DelegationManager.elapsedMs(existing, observedAt);\n const hasDuration = event.durationMs !== undefined;\n this.progress.set(event.requestId, {\n // Spread, not field-by-field: anything carried on progress that this\n // event does not report (the assign-time context shape) must survive the\n // first update, or the completion event reports it as absent.\n ...existing,\n currentTool: event.currentTool ?? existing.currentTool,\n toolCount:\n event.toolCount === undefined ? existing.toolCount : Math.max(existing.toolCount ?? 0, event.toolCount),\n tokens: event.tokens === undefined ? existing.tokens : Math.max(existing.tokens ?? 0, event.tokens),\n durationMs: hasDuration ? Math.max(currentElapsed, event.durationMs!) : existing.durationMs,\n durationObservedAt: hasDuration ? observedAt : existing.durationObservedAt,\n });\n this.options.onChange?.();\n }\n\n private async handleResponse(event: DelegationResult): Promise<void> {\n if (!this.pendingTasks.has(event.requestId)) return;\n\n const succeeded = event.status === COMPLETED_STATE && !event.error;\n const state = succeeded ? COMPLETED_STATE : event.status === CANCELLED_STATE ? CANCELLED_STATE : FAILED_STATE;\n await this.settle(event.requestId, state, {\n status: event.status,\n error: event.error,\n output: truncate(event.output),\n outputPath: event.outputPath,\n sessionFile: event.sessionFile,\n durationMs: event.durationMs,\n toolCount: event.toolCount,\n });\n }\n\n /**\n * Apply the terminal state of a delegation and tell the model about it.\n *\n * A cancelled run returns the task to `pending` (the work is still wanted,\n * just not by that agent); a failure marks it `failed` so it stays visible\n * rather than silently rejoining the backlog.\n *\n * The request is claimed in `settlingRequests` while it remains published as\n * active work. It is removed only after the terminal state and model notification\n * have been handed off, so an auto-stop observer cannot end the session between\n * receiving the result and delivering it to the model.\n */\n private async settle(requestId: string, state: SettlementState, result: TaskDelegation['result']): Promise<void> {\n const pending = this.pendingTasks.get(requestId);\n if (!pending || this.settlingRequests.has(requestId)) return;\n this.settlingRequests.add(requestId);\n this.clearTimer(requestId);\n const { taskId } = pending;\n const progress = this.progress.get(requestId);\n\n try {\n const endedAt = this.now();\n let task: Task | undefined;\n try {\n const { value } = await this.options.store.mutate((document) =>\n this.patchDelegation(document, requestId, (current, delegation) => ({\n ...current,\n status: state === COMPLETED_STATE ? COMPLETED_STATE : state === CANCELLED_STATE ? 'pending' : FAILED_STATE,\n updatedAt: endedAt,\n delegation: { ...delegation, state, endedAt, ...(result ? { result } : {}) },\n })),\n );\n task = value;\n } catch (error) {\n this.report(TASK_EVENT.delegationSettleFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n });\n }\n\n const agent = task?.delegation?.agent ?? progress?.agent ?? 'subagent';\n const subject = task?.subject ?? `#${taskId}`;\n\n // Repeats the assign-time context shape so the cost question (\"did packs\n // reduce child tool calls?\") is one grouping rather than a self-join.\n // A run that never started reports neither metric, keeping the medians clean.\n this.options.report?.event(TASK_EVENT.delegationCompleted, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [OUTCOME_ATTRIBUTE]: state,\n [CONTEXT_PRESENT_ATTRIBUTE]: (progress?.contextFileCount ?? 0) > 0 || (progress?.contextNotesLength ?? 0) > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: progress?.contextFileCount ?? 0,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: progress?.contextNotesLength ?? 0,\n ...(result?.toolCount === undefined ? {} : { [TOOL_COUNT_ATTRIBUTE]: result.toolCount }),\n ...(result?.durationMs === undefined ? {} : { [DURATION_MS_ATTRIBUTE]: result.durationMs }),\n });\n const listComplete =\n state === COMPLETED_STATE && task !== undefined && isTaskListComplete(this.options.store.snapshot.tasks);\n this.notifyModel(state, taskId, subject, agent, result, listComplete);\n } finally {\n this.pendingTasks.delete(requestId);\n this.progress.delete(requestId);\n this.settlingRequests.delete(requestId);\n this.options.onChange?.();\n }\n }\n\n private notifyModel(\n state: SettlementState,\n taskId: number,\n subject: string,\n agent: string,\n result: TaskDelegation['result'],\n listComplete: boolean,\n ): void {\n const notify = this.options.notify;\n if (!notify) return;\n\n const headline =\n state === COMPLETED_STATE\n ? `Subagent ${agent} completed task #${taskId}: ${subject}`\n : state === CANCELLED_STATE\n ? `Subagent ${agent} was cancelled on task #${taskId}: ${subject} (returned to pending)`\n : `Subagent ${agent} failed task #${taskId}: ${subject}`;\n\n const lines = [headline];\n if (listComplete) {\n lines.push(\n '',\n 'All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.',\n );\n }\n if (result?.error) lines.push(`Error: ${result.error}`);\n if (result?.output) lines.push('', result.output);\n if (result?.outputPath) lines.push('', `Full output: ${result.outputPath}`);\n\n try {\n notify(\n { customType: NOTIFY_CUSTOM_TYPE, content: lines.join('\\n'), display: true },\n { triggerTurn: true, deliverAs: 'steer' },\n );\n } catch (error) {\n // The delegation state is already committed to the store, so a failed\n // notification costs the model its wake-up, not the result. Report it\n // rather than rethrowing, which would strand the settled run.\n this.options.onNotifyError(error, taskId);\n }\n }\n\n /**\n * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.\n *\n * Terminal delegations are left alone. The document here is the freshest one,\n * read under the store lock, which is the only place the check is meaningful:\n * a `started` event can land after a cancel already settled the run, and\n * without this guard its write would resurrect a delegation that nothing is\n * tracking any more.\n */\n private patchDelegation(\n document: TaskDocument,\n requestId: string,\n patch: (task: Task, delegation: TaskDelegation) => Task,\n ): { document?: TaskDocument; value: Task | undefined } {\n const index = document.tasks.findIndex((task) => task.delegation?.requestId === requestId);\n if (index === -1) return { value: undefined };\n\n const task = document.tasks[index];\n if (!isDelegationActive(task)) return { value: task };\n\n const updated = patch(task, task.delegation!);\n if (updated === task) return { value: task };\n const tasks = [...document.tasks];\n tasks[index] = updated;\n return { document: { ...document, tasks }, value: updated };\n }\n\n dispose(): void {\n this.unbind();\n this.reset();\n }\n\n /** Clear one Pi session's transient delegation state without losing service injection. */\n reset(): void {\n const changed = this.pendingTasks.size > 0 || this.progress.size > 0;\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n this.pendingTasks.clear();\n this.settlingRequests.clear();\n this.progress.clear();\n if (changed) this.options.onChange?.();\n }\n}\n"],"mappings":";;;;;;;AAuBA,MAAa,qBAAqB;AAClC,MAAa,2BAA2B;AAExC,MAAM,6BAA6B;AACnC,MAAM,yBAAyB;AAC/B,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AACjC,MAAM,oBAAoB;;;;;AAK1B,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,MAAM,iBAAiC;AAEvC,MAAM,oBAAoB;AAC1B,MAAM,uBAAuB;AAG7B,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,4BAA4B;AAClC,MAAM,+BAA+B;AACrC,MAAM,iCAAiC;AACvC,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;AAC7B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5B,IAAI,CAAC,mBAAmB,IAAI,GAAG,OAAO,EAAE,OAAO,KAAK;EAEpD,MAAM,UAAU,MAAM,MAAM,KAAK,UAAW;EAC5C,IAAI,YAAY,MAAM,OAAO,EAAE,OAAO,KAAK;EAC3C,MAAM,QAAQ,CAAC,GAAG,SAAS,KAAK;EAChC,MAAM,SAAS;EACf,OAAO;GAAE,UAAU;IAAE,GAAG;IAAU;GAAM;GAAG,OAAO;EAAQ;CAC5D;CAEA,UAAgB;EACd,KAAK,OAAO;EACZ,KAAK,MAAM;CACb;;CAGA,QAAc;EACZ,MAAM,UAAU,KAAK,aAAa,OAAO,KAAK,KAAK,SAAS,OAAO;EACnE,KAAK,MAAM,SAAS,KAAK,OAAO,OAAO,GAAG,aAAa,KAAK;EAC5D,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM;EACxB,KAAK,iBAAiB,MAAM;EAC5B,KAAK,SAAS,MAAM;EACpB,IAAI,SAAS,KAAK,QAAQ,WAAW;CACvC;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delegation-DsnKjMbJ.cjs","names":["DOOM_DELEGATION_ACCEPTED_EVENT","DOOM_DELEGATION_STARTED_EVENT","DOOM_DELEGATION_UPDATED_EVENT","DOOM_DELEGATION_FINISHED_EVENT","TASK_EVENT","reconcileOrphanedDelegations","isDelegationActive","isBlocked","isTaskListComplete"],"sources":["../src/services/delegation/index.ts"],"sourcesContent":["import {\n type DelegationAccepted as DelegationAcceptedPayload,\n DOOM_DELEGATION_ACCEPTED_EVENT,\n DOOM_DELEGATION_FINISHED_EVENT,\n DOOM_DELEGATION_STARTED_EVENT,\n DOOM_DELEGATION_UPDATED_EVENT,\n type DoomDelegationService,\n type DelegationResult,\n type DelegationStarted as DelegationStartedPayload,\n type DelegationUpdate,\n type InlineAgent,\n} from '@agimon-ai/po-core/delegation';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { isBlocked, isTaskListComplete } from '../../models/taskGraph';\nimport { MAX_BRIEF_FILES } from '../../types/delegation';\nimport { TASK_EVENT, type TaskEventName, type TaskFailureReporter } from '../../types/telemetry';\nimport { reconcileOrphanedDelegations } from '../reconcile';\nimport type { TaskStore } from '../taskStore';\n\nexport { MAX_BRIEF_FILES };\nimport { isDelegationActive, type Task, type TaskDelegation, type TaskDocument } from '../../models/task';\n\nexport const NOTIFY_CUSTOM_TYPE = 'doom-task-notify';\nexport const BACKGROUND_WORK_PROVIDER = 'doom-task';\n\nconst DEFAULT_STARTED_TIMEOUT_MS = 5000;\nconst DEFAULT_RUN_TIMEOUT_MS = 20 * 60 * 1000;\nconst DEFAULT_CANCEL_TIMEOUT_MS = 10_000;\nconst MAX_RUN_TIMEOUT_GRACE_MS = 60_000;\nconst MAX_STORED_OUTPUT = 4000;\n/**\n * Cap on files rendered into a brief. Exported so the tool schema can state the\n * same number to the model rather than restating it and drifting.\n */\nconst MAX_BRIEF_NOTES = 1500;\nconst COMPLETED_STATE = 'completed';\nconst FAILED_STATE = 'failed';\nconst CANCELLED_STATE = 'cancelled';\nconst TIMED_OUT_STATUS = 'timed_out';\nconst DELETED_STATUS: Task['status'] = 'deleted';\n\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REQUEST_ID_ATTRIBUTE = 'delegation.request_id';\n// `_name` suffix is load-bearing: the telemetry redactor drops string values\n// whose key has no safe meaning, and a bare `delegation.agent` is dropped.\nconst AGENT_ATTRIBUTE = 'delegation.agent_name';\nconst PID_ATTRIBUTE = 'delegation.pid';\nconst CONTEXT_PRESENT_ATTRIBUTE = 'delegation.context_present';\nconst CONTEXT_FILE_COUNT_ATTRIBUTE = 'delegation.context_file_count';\nconst CONTEXT_NOTES_LENGTH_ATTRIBUTE = 'delegation.context_notes_length';\nconst BRIEF_LENGTH_ATTRIBUTE = 'delegation.brief_length';\nconst TOOL_COUNT_ATTRIBUTE = 'delegation.tool_count';\nconst DURATION_MS_ATTRIBUTE = 'delegation.duration_ms';\nconst OUTCOME_ATTRIBUTE = 'delegation.outcome';\n\ntype SettlementState = typeof COMPLETED_STATE | typeof FAILED_STATE | typeof CANCELLED_STATE;\n\nexport const ERR_NO_RUNTIME =\n 'No subagent runtime responded. Delegation needs the subagents extension — relaunch po with agents enabled.';\nexport const ERR_CHILD_SESSION =\n 'assign is only available in the main session. Update this task directly instead of re-delegating it.';\nexport const ERR_CANCEL_UNACKNOWLEDGED = 'Subagent did not acknowledge the cancel request';\n\n/** Live progress from a running subagent. Kept in memory: persisting per-tool\n * ticks would rewrite the store file every second for no durable benefit. */\nexport interface DelegationProgress {\n agent: string;\n currentTool?: string;\n toolCount?: number;\n tokens?: number;\n /** Latest child-runtime duration baseline, excluding assignment wait. */\n durationMs?: number;\n /** Wall-clock time at which durationMs was observed or rebased. */\n durationObservedAt?: number;\n /** Assign-time context-pack shape, carried so the completion event can be\n * grouped by it without joining back to the assignment event. */\n contextFileCount?: number;\n contextNotesLength?: number;\n}\n\nexport type DelegationNotifier = (\n message: { customType: string; content: string; display: boolean },\n options?: { triggerTurn?: boolean; deliverAs?: 'steer' | 'followUp' | 'nextTurn' },\n) => void;\n\nexport interface DelegationPlatform {\n readonly environment: Readonly<Record<string, string | undefined>>;\n readonly processId: number;\n readonly createRequestId: () => string;\n readonly formatBriefPath: (entry: string, cwd: string) => string;\n}\n\nexport interface DelegationManagerOptions {\n store: TaskStore;\n cwd: string;\n platform: DelegationPlatform;\n notify?: DelegationNotifier;\n getSessionId?: () => string | undefined;\n onChange?: () => void;\n startedTimeoutMs?: number;\n /** How long a started run may go without reporting a result. */\n runTimeoutMs?: number;\n /** How long to wait for a cancelled run to report back before forcing it. */\n cancelTimeoutMs?: number;\n now?: () => string;\n nowMs?: () => number;\n /** Called when a completion notification could not be delivered. */\n onNotifyError: (error: unknown, taskId: number) => void;\n /** Where other swallowed delegation failures go. */\n report?: TaskFailureReporter;\n}\n\nexport interface AssignOptions {\n agent?: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n /** Paths the parent already located, rendered into the brief so the child\n * skips rediscovering them. */\n relevantFiles?: string[];\n /** Facts the parent already established, rendered into the brief so the child\n * does not re-derive them. */\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n signal?: AbortSignal;\n}\n\nexport interface DelegationOutcome {\n ok: boolean;\n message: string;\n}\n\n/** Result of the guarded store mutation that claims a task for delegation. */\ninterface AssignAttempt extends DelegationOutcome {\n task?: Task;\n}\n\ninterface PendingTask {\n readonly taskId: number;\n readonly sessionId?: string;\n}\n\nfunction truncate(value: string | undefined, limit = MAX_STORED_OUTPUT): string | undefined {\n if (!value) return undefined;\n return value.length <= limit ? value : `${value.slice(0, limit)}\\n… (truncated)`;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** The assign-time context pack, normalized once for the brief and the telemetry. */\ninterface BriefContext {\n files: string[];\n notes?: string;\n}\n\n/** Normalize the parent context with host-owned path semantics. */\nfunction briefContext(options: AssignOptions, cwd: string, platform: DelegationPlatform): BriefContext {\n const files = new Set<string>();\n for (const entry of options.relevantFiles ?? []) {\n if (files.size >= MAX_BRIEF_FILES) break;\n const normalized = platform.formatBriefPath(entry.trim(), cwd);\n if (normalized && normalized !== '.') files.add(normalized);\n }\n return { files: [...files], notes: truncate(options.priorFindings?.trim(), MAX_BRIEF_NOTES) };\n}\n\n/**\n * Build the brief handed to the subagent.\n *\n * Doom Team owns the child tool surface and the parent owns the task record.\n * Keeping those responsibilities explicit prevents a child from attempting to\n * call a task tool that is not loaded in its runtime, while still giving it a\n * reliable path to ask the parent for a decision.\n *\n * The context pack is the parent's verified discovery handed over. The whole\n * block is omitted when nothing was supplied: this brief is the child's whole\n * starting context, so an empty section header is pure token cost.\n */\nfunction buildBrief(task: Task, instructions: string | undefined, context: BriefContext): string {\n const sections = [`Task #${task.id}: ${task.subject}`];\n if (task.description) sections.push(task.description);\n if (instructions) sections.push(instructions);\n if (context.files.length > 0 || context.notes) {\n const contextLines = ['Parent context — consume before repository discovery:'];\n if (context.files.length > 0) {\n contextLines.push(`- Parent-verified files (read these first with direct reads): ${context.files.join(', ')}`);\n }\n if (context.notes) {\n contextLines.push(\n `- Established facts (do not re-derive unless direct evidence contradicts them): ${context.notes}`,\n );\n }\n contextLines.push(\n 'This pack satisfies initial repository/context exploration. Do not begin with repository-wide listing, find, or grep. Expand only after consuming the pack and naming a concrete missing dependency or invalid path; search narrowly for that item and state why.',\n );\n sections.push(contextLines.join('\\n'));\n }\n sections.push(\n 'Coordination: work directly without changing the task record; ask main through intercom only for blockers or decisions; report changed files and verification when done.',\n );\n return sections.join('\\n\\n');\n}\n\n/**\n * Owns the lifecycle of tasks delegated to subagents.\n *\n * Delegation rides Team's injected Cordis service rather than spawning\n * processes directly, so doom-task stays decoupled from the subagent runtime\n * and degrades to a clear error when that service is not loaded.\n *\n * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so\n * a delegation always has a deadline no matter which phase it is in. Losing\n * that pairing is what previously left tasks running forever.\n */\nexport class DelegationManager {\n private readonly options: DelegationManagerOptions;\n private readonly progress = new Map<string, DelegationProgress>();\n private readonly pendingTasks = new Map<string, PendingTask>();\n private readonly settlingRequests = new Set<string>();\n private readonly timers = new Map<string, ReturnType<typeof setTimeout>>();\n private readonly subscriptions: Array<() => void> = [];\n private service: DoomDelegationService | undefined;\n\n constructor(options: DelegationManagerOptions) {\n this.options = options;\n }\n\n setCwd(cwd: string): void {\n this.options.cwd = cwd;\n }\n\n private now(): string {\n return this.options.now?.() ?? new Date().toISOString();\n }\n\n private nowMs(): number {\n return this.options.nowMs?.() ?? Date.now();\n }\n\n private get runTimeoutMs(): number {\n return this.options.runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;\n }\n\n private report(event: TaskEventName, error: unknown, attributes?: Record<string, string | number | boolean>): void {\n this.options.report?.error(event, error, attributes);\n }\n\n /** True in a session that is itself a subagent child. */\n get isChildSession(): boolean {\n return Boolean(this.options.platform.environment.PI_SUBAGENT_CHILD);\n }\n\n /** Live progress for a task, for the overlay to render. */\n progressFor(task: Task): DelegationProgress | undefined {\n const requestId = task.delegation?.requestId;\n return requestId ? this.progress.get(requestId) : undefined;\n }\n\n /** Displayed runtime duration, rebased from the latest child observation. */\n static elapsedMs(progress: DelegationProgress, nowMs = Date.now()): number {\n const baseline = progress.durationMs ?? 0;\n const observedAt = progress.durationObservedAt ?? nowMs;\n return baseline + Math.max(0, nowMs - observedAt);\n }\n\n /** Rebind to the active Team service without stacking lifecycle listeners. */\n bind(ctx: Context, service: DoomDelegationService): () => void {\n this.unbind();\n this.service = service;\n this.subscriptions.push(\n ctx.on(DOOM_DELEGATION_ACCEPTED_EVENT, (event) => {\n this.handleAccepted(event);\n }),\n ctx.on(DOOM_DELEGATION_STARTED_EVENT, (event) => {\n this.handleStarted(event);\n }),\n ctx.on(DOOM_DELEGATION_UPDATED_EVENT, (event) => {\n this.handleUpdate(event);\n }),\n ctx.on(DOOM_DELEGATION_FINISHED_EVENT, (event) => {\n void this.handleResponse(event).catch((error: unknown) => {\n this.report(TASK_EVENT.delegationResponseFailed, error, { [REQUEST_ID_ATTRIBUTE]: event.requestId });\n });\n }),\n );\n return () => {\n if (this.service === service) this.unbind();\n };\n }\n\n /** Remove only the cross-package binding; task state and watchdogs remain live. */\n unbind(): void {\n for (const unsubscribe of this.subscriptions.splice(0)) unsubscribe();\n this.service = undefined;\n }\n\n /** Items still in flight, surfaced so auto-stop will not kill the harness. */\n listActiveWork(): Array<{ id: string; sessionId: string }> {\n return [...this.pendingTasks.entries()].flatMap(([requestId, pending]) =>\n pending.sessionId ? [{ id: `task-${pending.taskId}:${requestId}`, sessionId: pending.sessionId }] : [],\n );\n }\n\n /**\n * Return tasks nothing can finish to `pending`.\n *\n * The live request set is read inside the mutation so a delegation assigned\n * while the lock was contended is not mistaken for a leftover.\n */\n async reconcile(isCurrent: () => boolean = () => true): Promise<Task[]> {\n const { value } = await this.options.store.mutate((document) => {\n if (!isCurrent()) return { value: [] as Task[] };\n const result = reconcileOrphanedDelegations(document, this.now(), undefined, {\n pid: this.options.platform.processId,\n liveRequestIds: new Set(this.pendingTasks.keys()),\n });\n if (result.orphaned.length === 0) return { value: [] as Task[] };\n return { document: result.document, value: result.orphaned };\n });\n\n if (!isCurrent()) return [];\n for (const task of value) {\n this.options.report?.warn(TASK_EVENT.delegationOrphaned, new Error(task.delegation?.result?.error ?? ''), {\n [TASK_ID_ATTRIBUTE]: task.id,\n ...(task.delegation?.agent ? { [AGENT_ATTRIBUTE]: task.delegation.agent } : {}),\n ...(task.delegation?.pid === undefined ? {} : { [PID_ATTRIBUTE]: task.delegation.pid }),\n });\n }\n\n if (value.length > 0) this.options.onChange?.();\n return value;\n }\n\n async assign(taskId: number, options: AssignOptions): Promise<DelegationOutcome> {\n const agent = options.agent?.trim();\n if (!agent) return { ok: false, message: 'agent required for assign' };\n if (this.isChildSession) return { ok: false, message: ERR_CHILD_SESSION };\n if (options.signal?.aborted) return { ok: false, message: 'delegation cancelled before it started' };\n\n const requestId = this.options.platform.createRequestId();\n const startedAt = this.now();\n const sessionId = this.options.getSessionId?.();\n const context = briefContext(options, this.options.cwd, this.options.platform);\n\n const { value: outcome } = await this.options.store.mutate<AssignAttempt>((current) => {\n const index = current.tasks.findIndex((task) => task.id === taskId);\n if (index === -1) return { value: { ok: false, message: `#${taskId} not found` } };\n\n const task = current.tasks[index];\n if (task.status === DELETED_STATUS) return { value: { ok: false, message: `#${taskId} is deleted` } };\n if (task.status === COMPLETED_STATE) {\n return { value: { ok: false, message: `#${taskId} is already completed` } };\n }\n if (isDelegationActive(task)) {\n return { value: { ok: false, message: `#${taskId} is already delegated to ${task.delegation?.agent}` } };\n }\n if (isBlocked(current.tasks, task)) {\n const blockers = (task.blockedBy ?? []).map((id) => `#${id}`).join(', ');\n return { value: { ok: false, message: `#${taskId} is blocked by ${blockers}` } };\n }\n\n const delegation: TaskDelegation = {\n requestId,\n agent,\n state: 'requested',\n pid: this.options.platform.processId,\n startedAt,\n ...(sessionId ? { sessionId } : {}),\n ...(options.model ? { model: options.model } : {}),\n };\n\n const tasks = [...current.tasks];\n tasks[index] = { ...task, owner: agent, updatedAt: startedAt, delegation };\n return {\n document: { ...current, tasks },\n value: { ok: true, message: '', task: tasks[index] },\n };\n });\n\n if (!outcome.ok || !outcome.task) return { ok: false, message: outcome.message };\n\n const contextNotesLength = context.notes?.length ?? 0;\n this.pendingTasks.set(requestId, { taskId, sessionId });\n this.progress.set(requestId, { agent, contextFileCount: context.files.length, contextNotesLength });\n this.armStartedTimeout(requestId);\n this.options.onChange?.();\n const request = {\n requestId,\n taskId,\n agent,\n ...(options.inlineAgent ? { inlineAgent: options.inlineAgent } : {}),\n prompt: buildBrief(outcome.task, options.instructions, context),\n ...(options.context ? { context: options.context } : {}),\n cwd: this.options.cwd,\n artifacts: true,\n timeoutMs: this.runTimeoutMs,\n runMode: 'detached' as const,\n teamTask: { id: String(outcome.task.id), subject: outcome.task.subject },\n ...(options.model ? { model: options.model } : {}),\n };\n\n try {\n const service = this.service;\n if (!service) throw new Error(ERR_NO_RUNTIME);\n void service.request(request).catch((error: unknown) => {\n this.report(TASK_EVENT.delegationRequestFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n });\n this.settleDetached(requestId, FAILED_STATE, {\n status: FAILED_STATE,\n error: `Delegation request failed: ${messageOf(error)}`,\n });\n });\n } catch (error) {\n this.report(TASK_EVENT.delegationRequestFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n });\n const detail = messageOf(error);\n await this.settle(requestId, FAILED_STATE, {\n status: FAILED_STATE,\n error: `Delegation request failed: ${detail}`,\n });\n return { ok: false, message: `Could not dispatch #${taskId} to ${agent}: ${detail}` };\n }\n\n // Recorded only after the service accepted the request call, so it means a\n // brief actually entered Team's state machine rather than merely being assembled.\n this.options.report?.event(TASK_EVENT.delegationAssigned, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [CONTEXT_PRESENT_ATTRIBUTE]: context.files.length > 0 || contextNotesLength > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: context.files.length,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: contextNotesLength,\n [BRIEF_LENGTH_ATTRIBUTE]: request.prompt.length,\n });\n\n return {\n ok: true,\n message: `Delegated #${taskId} to ${agent} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end your turn.`,\n };\n }\n\n async cancel(taskId: number): Promise<DelegationOutcome> {\n const document = this.options.store.read();\n const task = document.tasks.find((candidate) => candidate.id === taskId);\n if (!task) return { ok: false, message: `#${taskId} not found` };\n if (!task.delegation || !isDelegationActive(task)) {\n return { ok: false, message: `#${taskId} has no running delegation` };\n }\n\n const { requestId } = task.delegation;\n this.service?.cancel({ requestId });\n // Only this session can force the outcome; a delegation owned elsewhere\n // gets the request and nothing more.\n this.armCancelTimeout(requestId);\n return { ok: true, message: `Cancelling delegation for #${taskId} (${task.delegation.agent})` };\n }\n\n /** Settle without awaiting, reporting rather than dropping a failure. */\n private settleDetached(\n requestId: string,\n state: SettlementState,\n result: TaskDelegation['result'],\n event: TaskEventName = TASK_EVENT.delegationSettleFailed,\n ): void {\n void this.settle(requestId, state, result).catch((error: unknown) => {\n this.report(event, error, { [REQUEST_ID_ATTRIBUTE]: requestId });\n });\n }\n\n /**\n * Fail a delegation that nobody acknowledged.\n *\n * Provider loss or a stalled Team runtime can still leave a dispatched\n * request silent. Without this acknowledgement deadline the task would sit\n * in `requested` forever.\n */\n private armStartedTimeout(requestId: string): void {\n this.armTimer(requestId, this.options.startedTimeoutMs ?? DEFAULT_STARTED_TIMEOUT_MS, () => {\n this.settleDetached(requestId, FAILED_STATE, { status: FAILED_STATE, error: ERR_NO_RUNTIME });\n });\n }\n\n /**\n * Bound a run that already started.\n *\n * The request carries the same budget, so in the normal case the runtime ends\n * the run itself and reports a richer result. The grace period biases toward\n * that answer; this timer only covers a runtime that goes silent, which is\n * precisely the case where no response event will ever arrive.\n */\n private armRunTimeout(requestId: string): void {\n const grace = Math.min(MAX_RUN_TIMEOUT_GRACE_MS, this.runTimeoutMs);\n this.armTimer(requestId, this.runTimeoutMs + grace, () => {\n const taskId = this.pendingTasks.get(requestId)?.taskId;\n const agent = this.progress.get(requestId)?.agent;\n const error = new Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);\n this.options.report?.warn(TASK_EVENT.delegationTimedOut, error, {\n ...(taskId === undefined ? {} : { [TASK_ID_ATTRIBUTE]: taskId }),\n [REQUEST_ID_ATTRIBUTE]: requestId,\n ...(agent ? { [AGENT_ATTRIBUTE]: agent } : {}),\n });\n this.service?.cancel({ requestId, reason: error.message });\n this.settleDetached(requestId, FAILED_STATE, { status: TIMED_OUT_STATUS, error: error.message });\n });\n }\n\n /**\n * Guarantee a cancel reaches a terminal state.\n *\n * Calling the service is a request, not an outcome: a runtime that has\n * already forgotten the request answers nothing at all. The window still\n * favours a real response, which carries the run's partial output.\n */\n private armCancelTimeout(requestId: string): void {\n if (!this.pendingTasks.has(requestId)) return;\n this.armTimer(requestId, this.options.cancelTimeoutMs ?? DEFAULT_CANCEL_TIMEOUT_MS, () => {\n this.settleDetached(requestId, CANCELLED_STATE, {\n status: CANCELLED_STATE,\n error: ERR_CANCEL_UNACKNOWLEDGED,\n });\n });\n }\n\n private armTimer(requestId: string, delayMs: number, onFire: () => void): void {\n this.clearTimer(requestId);\n const timer = setTimeout(onFire, delayMs);\n timer.unref?.();\n this.timers.set(requestId, timer);\n }\n\n private clearTimer(requestId: string): void {\n const timer = this.timers.get(requestId);\n if (timer) clearTimeout(timer);\n this.timers.delete(requestId);\n }\n\n /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */\n private handleAccepted(event: DelegationAcceptedPayload): void {\n if (!this.pendingTasks.has(event.requestId)) return;\n this.armRunTimeout(event.requestId);\n }\n\n private handleStarted(event: DelegationStartedPayload): void {\n const { runId } = event;\n const taskId = this.pendingTasks.get(event.requestId)?.taskId;\n if (taskId === undefined) return;\n this.armRunTimeout(event.requestId);\n const existing = this.progress.get(event.requestId);\n if (existing) {\n this.progress.set(event.requestId, {\n ...existing,\n durationMs: existing.durationMs ?? 0,\n durationObservedAt: existing.durationObservedAt ?? this.nowMs(),\n });\n }\n\n void this.options.store\n .mutate((document) =>\n this.patchDelegation(document, event.requestId, (task, delegation) => ({\n ...task,\n status: task.status === COMPLETED_STATE ? task.status : 'in_progress',\n delegation: {\n ...delegation,\n state: 'running',\n startedAt: delegation.startedAt ?? this.now(),\n ...(runId ? { runId } : {}),\n },\n })),\n )\n .then(() => this.options.onChange?.())\n .catch((error: unknown) => {\n this.report(TASK_EVENT.delegationStartFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: event.requestId,\n });\n });\n }\n\n private handleUpdate(event: DelegationUpdate): void {\n const existing = this.progress.get(event.requestId);\n if (!existing) return;\n\n const observedAt = this.nowMs();\n const currentElapsed = DelegationManager.elapsedMs(existing, observedAt);\n const hasDuration = event.durationMs !== undefined;\n this.progress.set(event.requestId, {\n // Spread, not field-by-field: anything carried on progress that this\n // event does not report (the assign-time context shape) must survive the\n // first update, or the completion event reports it as absent.\n ...existing,\n currentTool: event.currentTool ?? existing.currentTool,\n toolCount:\n event.toolCount === undefined ? existing.toolCount : Math.max(existing.toolCount ?? 0, event.toolCount),\n tokens: event.tokens === undefined ? existing.tokens : Math.max(existing.tokens ?? 0, event.tokens),\n durationMs: hasDuration ? Math.max(currentElapsed, event.durationMs!) : existing.durationMs,\n durationObservedAt: hasDuration ? observedAt : existing.durationObservedAt,\n });\n this.options.onChange?.();\n }\n\n private async handleResponse(event: DelegationResult): Promise<void> {\n if (!this.pendingTasks.has(event.requestId)) return;\n\n const succeeded = event.status === COMPLETED_STATE && !event.error;\n const state = succeeded ? COMPLETED_STATE : event.status === CANCELLED_STATE ? CANCELLED_STATE : FAILED_STATE;\n await this.settle(event.requestId, state, {\n status: event.status,\n error: event.error,\n output: truncate(event.output),\n outputPath: event.outputPath,\n sessionFile: event.sessionFile,\n durationMs: event.durationMs,\n toolCount: event.toolCount,\n });\n }\n\n /**\n * Apply the terminal state of a delegation and tell the model about it.\n *\n * A cancelled run returns the task to `pending` (the work is still wanted,\n * just not by that agent); a failure marks it `failed` so it stays visible\n * rather than silently rejoining the backlog.\n *\n * The request is claimed in `settlingRequests` while it remains published as\n * active work. It is removed only after the terminal state and model notification\n * have been handed off, so an auto-stop observer cannot end the session between\n * receiving the result and delivering it to the model.\n */\n private async settle(requestId: string, state: SettlementState, result: TaskDelegation['result']): Promise<void> {\n const pending = this.pendingTasks.get(requestId);\n if (!pending || this.settlingRequests.has(requestId)) return;\n this.settlingRequests.add(requestId);\n this.clearTimer(requestId);\n const { taskId } = pending;\n const progress = this.progress.get(requestId);\n\n try {\n const endedAt = this.now();\n let task: Task | undefined;\n try {\n const { value } = await this.options.store.mutate((document) =>\n this.patchDelegation(document, requestId, (current, delegation) => ({\n ...current,\n status: state === COMPLETED_STATE ? COMPLETED_STATE : state === CANCELLED_STATE ? 'pending' : FAILED_STATE,\n updatedAt: endedAt,\n delegation: { ...delegation, state, endedAt, ...(result ? { result } : {}) },\n })),\n );\n task = value;\n } catch (error) {\n this.report(TASK_EVENT.delegationSettleFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n });\n }\n\n const agent = task?.delegation?.agent ?? progress?.agent ?? 'subagent';\n const subject = task?.subject ?? `#${taskId}`;\n\n // Repeats the assign-time context shape so the cost question (\"did packs\n // reduce child tool calls?\") is one grouping rather than a self-join.\n // A run that never started reports neither metric, keeping the medians clean.\n this.options.report?.event(TASK_EVENT.delegationCompleted, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [OUTCOME_ATTRIBUTE]: state,\n [CONTEXT_PRESENT_ATTRIBUTE]: (progress?.contextFileCount ?? 0) > 0 || (progress?.contextNotesLength ?? 0) > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: progress?.contextFileCount ?? 0,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: progress?.contextNotesLength ?? 0,\n ...(result?.toolCount === undefined ? {} : { [TOOL_COUNT_ATTRIBUTE]: result.toolCount }),\n ...(result?.durationMs === undefined ? {} : { [DURATION_MS_ATTRIBUTE]: result.durationMs }),\n });\n const listComplete =\n state === COMPLETED_STATE && task !== undefined && isTaskListComplete(this.options.store.snapshot.tasks);\n this.notifyModel(state, taskId, subject, agent, result, listComplete);\n } finally {\n this.pendingTasks.delete(requestId);\n this.progress.delete(requestId);\n this.settlingRequests.delete(requestId);\n this.options.onChange?.();\n }\n }\n\n private notifyModel(\n state: SettlementState,\n taskId: number,\n subject: string,\n agent: string,\n result: TaskDelegation['result'],\n listComplete: boolean,\n ): void {\n const notify = this.options.notify;\n if (!notify) return;\n\n const headline =\n state === COMPLETED_STATE\n ? `Subagent ${agent} completed task #${taskId}: ${subject}`\n : state === CANCELLED_STATE\n ? `Subagent ${agent} was cancelled on task #${taskId}: ${subject} (returned to pending)`\n : `Subagent ${agent} failed task #${taskId}: ${subject}`;\n\n const lines = [headline];\n if (listComplete) {\n lines.push(\n '',\n 'All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.',\n );\n }\n if (result?.error) lines.push(`Error: ${result.error}`);\n if (result?.output) lines.push('', result.output);\n if (result?.outputPath) lines.push('', `Full output: ${result.outputPath}`);\n\n try {\n notify(\n { customType: NOTIFY_CUSTOM_TYPE, content: lines.join('\\n'), display: true },\n { triggerTurn: true, deliverAs: 'steer' },\n );\n } catch (error) {\n // The delegation state is already committed to the store, so a failed\n // notification costs the model its wake-up, not the result. Report it\n // rather than rethrowing, which would strand the settled run.\n this.options.onNotifyError(error, taskId);\n }\n }\n\n /**\n * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.\n *\n * Terminal delegations are left alone. The document here is the freshest one,\n * read under the store lock, which is the only place the check is meaningful:\n * a `started` event can land after a cancel already settled the run, and\n * without this guard its write would resurrect a delegation that nothing is\n * tracking any more.\n */\n private patchDelegation(\n document: TaskDocument,\n requestId: string,\n patch: (task: Task, delegation: TaskDelegation) => Task,\n ): { document?: TaskDocument; value: Task | undefined } {\n const index = document.tasks.findIndex((task) => task.delegation?.requestId === requestId);\n if (index === -1) return { value: undefined };\n\n const task = document.tasks[index];\n if (!isDelegationActive(task)) return { value: task };\n\n const updated = patch(task, task.delegation!);\n if (updated === task) return { value: task };\n const tasks = [...document.tasks];\n tasks[index] = updated;\n return { document: { ...document, tasks }, value: updated };\n }\n\n dispose(): void {\n this.unbind();\n this.reset();\n }\n\n /** Clear one Pi session's transient delegation state without losing service injection. */\n reset(): void {\n const changed = this.pendingTasks.size > 0 || this.progress.size > 0;\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n this.pendingTasks.clear();\n this.settlingRequests.clear();\n this.progress.clear();\n if (changed) this.options.onChange?.();\n }\n}\n"],"mappings":";;;;;;;AAuBA,MAAa,qBAAqB;AAClC,MAAa,2BAA2B;AAExC,MAAM,6BAA6B;AACnC,MAAM,yBAAyB;AAC/B,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AACjC,MAAM,oBAAoB;;;;;AAK1B,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,MAAM,iBAAiC;AAEvC,MAAM,oBAAoB;AAC1B,MAAM,uBAAuB;AAG7B,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,4BAA4B;AAClC,MAAM,+BAA+B;AACrC,MAAM,iCAAiC;AACvC,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB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IAAc,OAAO;;UAwBpC;UAUA;UAUM;;UAoCN;;;;;;;EAwBR,iBAAiB,WAAW,UAAU;EAKtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logSinkTelemetry-B23qGiP-.cjs","names":["createDoomTelemetry","TASK_EVENT"],"sources":["../src/services/logSinkTelemetry/index.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/po-telemetry';\n\nimport { TASK_EVENT, type TaskErrorAttributes, type TaskFailureReporter } from '../../types/telemetry';\n\nexport {\n TASK_EVENT,\n type TaskErrorAttributes,\n type TaskErrorSink,\n type TaskEventName,\n type TaskEventSink,\n type TaskFailureReporter,\n} from '../../types/telemetry';\n\nconst SERVICE_NAME = 'doom-task';\nconst PACKAGE_NAME = '@agimon-ai/po-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":";;;AAaA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAmB/B,SAAgB,wBAAwB,UAAoC,CAAC,GAAsB;CACjG,MAAM,aAAA,GAA2BA,wBAAAA,oBAAAA,CAAoB;EACnD,aAAa;EACb,aAAa;EACb,KAAK,QAAQ;EACb,eAAe,QAAQ;EACvB,KAAK,QAAQ;EACb,kBAAkB,QAAQ;EAC1B,MAAM,QAAQ;EACd,YAAY;EACZ,cAAc;CAChB,CAAC;CACD,OAAO;EACL,cAAc,OAAO,OAAO,eAAe,UAAU,YAAY,OAAO,OAAO,UAAU;EACzF,gBAAgB,OAAO,OAAO,eAAe,UAAU,cAAc,OAAO,OAAO,UAAU;EAC7F,cAAc,OAAO,eAAe,UAAU,YAAY,OAAO,UAAU;EAC3E,0BAA0B,OAAO,WAC/B,UAAU,YAAYC,kBAAAA,WAAW,oBAAoB,OAAO;GAC1D,WAAW;GACX,kBAAkB;EACpB,CAAC;EACH,aAAa,UAAU,MAAM;EAC7B,gBAAgB,UAAU,SAAS;CACrC;AACF;AAEA,SAAgB,kBAAkB,UAAkD;CAClF,OAAO;EACL,QAAQ,OAAO,OAAO,eAAe,KAAK,SAAS,YAAY,OAAO,OAAO,UAAU;EACvF,OAAO,OAAO,OAAO,eAAe,KAAK,SAAS,cAAc,OAAO,OAAO,UAAU;EACxF,QAAQ,OAAO,eAAe,KAAK,SAAS,YAAY,OAAO,UAAU;CAC3E;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logSinkTelemetry-BMBsC54p.mjs","names":[],"sources":["../src/services/logSinkTelemetry/index.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/po-telemetry';\n\nimport { TASK_EVENT, type TaskErrorAttributes, type TaskFailureReporter } from '../../types/telemetry';\n\nexport {\n TASK_EVENT,\n type TaskErrorAttributes,\n type TaskErrorSink,\n type TaskEventName,\n type TaskEventSink,\n type TaskFailureReporter,\n} from '../../types/telemetry';\n\nconst SERVICE_NAME = 'doom-task';\nconst PACKAGE_NAME = '@agimon-ai/po-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":";;;AAaA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAmB/B,SAAgB,wBAAwB,UAAoC,CAAC,GAAsB;CACjG,MAAM,YAA2B,oBAAoB;EACnD,aAAa;EACb,aAAa;EACb,KAAK,QAAQ;EACb,eAAe,QAAQ;EACvB,KAAK,QAAQ;EACb,kBAAkB,QAAQ;EAC1B,MAAM,QAAQ;EACd,YAAY;EACZ,cAAc;CAChB,CAAC;CACD,OAAO;EACL,cAAc,OAAO,OAAO,eAAe,UAAU,YAAY,OAAO,OAAO,UAAU;EACzF,gBAAgB,OAAO,OAAO,eAAe,UAAU,cAAc,OAAO,OAAO,UAAU;EAC7F,cAAc,OAAO,eAAe,UAAU,YAAY,OAAO,UAAU;EAC3E,0BAA0B,OAAO,WAC/B,UAAU,YAAY,WAAW,oBAAoB,OAAO;GAC1D,WAAW;GACX,kBAAkB;EACpB,CAAC;EACH,aAAa,UAAU,MAAM;EAC7B,gBAAgB,UAAU,SAAS;CACrC;AACF;AAEA,SAAgB,kBAAkB,UAAkD;CAClF,OAAO;EACL,QAAQ,OAAO,OAAO,eAAe,KAAK,SAAS,YAAY,OAAO,OAAO,UAAU;EACvF,OAAO,OAAO,OAAO,eAAe,KAAK,SAAS,cAAc,OAAO,OAAO,UAAU;EACxF,QAAQ,OAAO,eAAe,KAAK,SAAS,YAAY,OAAO,UAAU;CAC3E;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths-CSya2l9_.cjs","names":["execFileSync","path","SUBAGENT_CHILD_ENV","SUBAGENT_PARENT_SESSION_ENV","piAgentDirectory","fs"],"sources":["../src/services/paths/index.ts"],"sourcesContent":["import { execFile, execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { SUBAGENT_CHILD_ENV, SUBAGENT_PARENT_SESSION_ENV } from '@agimon-ai/po-core/childProcess';\nimport { piAgentDirectory } from '@agimon-ai/po-core/piSettings';\n\nexport const STORE_PATH_ENV = 'DOOM_TASK_STORE';\n\nconst STORE_DIR_NAME = 'doom-task';\nconst STORE_FILE_NAME = 'tasks.json';\nconst FILE_ENCODING = 'utf8';\nconst NOT_FOUND_ERROR_CODE = 'ENOENT';\n\nfunction git(args: string[], cwd: string): string | undefined {\n try {\n const output = execFileSync('git', args, {\n cwd,\n encoding: FILE_ENCODING,\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n const trimmed = output.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function gitAsync(args: string[], cwd: string): Promise<string | undefined> {\n return new Promise((resolve) => {\n execFile('git', args, { cwd, encoding: FILE_ENCODING }, (error, stdout) => {\n if (error) {\n resolve(undefined);\n return;\n }\n const trimmed = stdout.trim();\n resolve(trimmed.length > 0 ? trimmed : undefined);\n });\n });\n}\n\nfunction isWithin(root: string, candidate: string): boolean {\n const relative = path.relative(path.resolve(root), path.resolve(candidate));\n return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));\n}\n\n/** Resolve the tree root without relying on extension startup order. */\nexport function resolveSessionKey(\n rootSessionId: string,\n env: Readonly<Record<string, string | undefined>> = process.env,\n): string {\n if (!env[SUBAGENT_CHILD_ENV]) return rootSessionId;\n const parentSessionId = env[SUBAGENT_PARENT_SESSION_ENV]?.trim();\n if (!parentSessionId) throw new Error(`${SUBAGENT_PARENT_SESSION_ENV} is required in a subagent child`);\n return parentSessionId;\n}\n\n/** Resolve one root session tree to a task document under the Pi agent directory. */\nexport function resolveStorePath(\n _cwd: string = process.cwd(),\n env: Readonly<Record<string, string | undefined>> = process.env,\n sessionKey: string = 'standalone',\n): string {\n const override = env[STORE_PATH_ENV]?.trim();\n if (override) return path.resolve(override);\n\n const trimmedSessionKey = sessionKey.trim();\n if (!trimmedSessionKey) throw new Error('doom-task session id cannot be blank');\n return path.join(piAgentDirectory(env), STORE_DIR_NAME, trimmedSessionKey, STORE_FILE_NAME);\n}\n\n/** Whether a deliberate unscoped task-store override is active. */\nexport function hasStorePathOverride(env: Readonly<Record<string, string | undefined>> = process.env): boolean {\n return Boolean(env[STORE_PATH_ENV]?.trim());\n}\n\n/** Exact legacy Git-directory store, if the current working tree has one. */\nexport function resolveLegacyStoreDirectory(cwd: string = process.cwd()): string | undefined {\n const commonDirectory = git(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport async function resolveLegacyStoreDirectoryAsync(cwd: string = process.cwd()): Promise<string | undefined> {\n const commonDirectory = await gitAsync(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport interface StoreSweepResult {\n removed: string[];\n errors: string[];\n}\n\n/** Remove only the validated legacy Git store unless it contains the active override. */\nexport function removeLegacyStoreDirectory(currentStorePath: string, cwd: string = process.cwd()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = resolveLegacyStoreDirectory(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n if (!fs.existsSync(target)) return result;\n fs.rmSync(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n return result;\n}\n\nexport async function removeLegacyStoreDirectoryAsync(\n currentStorePath: string,\n cwd: string = process.cwd(),\n): Promise<StoreSweepResult> {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = await resolveLegacyStoreDirectoryAsync(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n await fs.promises.access(target);\n await fs.promises.rm(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== NOT_FOUND_ERROR_CODE) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n }\n return result;\n}\n\n/** Delete expired sibling session stores while preserving active or unreadable stores. */\nexport function sweepStoreFiles(currentStorePath: string, ttlMs: number, now: number = Date.now()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const currentSessionDirectory = path.dirname(currentStorePath);\n const storeDirectory = path.dirname(currentSessionDirectory);\n let entries: string[];\n try {\n entries = fs.readdirSync(storeDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) return result;\n result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);\n return result;\n }\n\n for (const entry of entries) {\n const sessionDirectory = path.join(storeDirectory, entry);\n const candidate = path.join(sessionDirectory, STORE_FILE_NAME);\n if (sessionDirectory === currentSessionDirectory || !fs.existsSync(candidate)) continue;\n try {\n if (fs.existsSync(lockPathFor(candidate))) continue;\n JSON.parse(fs.readFileSync(candidate, FILE_ENCODING));\n if (now - fs.statSync(candidate).mtimeMs <= ttlMs) continue;\n fs.rmSync(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport async function sweepStoreFilesAsync(\n currentStorePath: string,\n ttlMs: number,\n now: number = Date.now(),\n): Promise<StoreSweepResult> {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const currentSessionDirectory = path.dirname(currentStorePath);\n const storeDirectory = path.dirname(currentSessionDirectory);\n let entries: string[];\n try {\n entries = await fs.promises.readdir(storeDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) return result;\n result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);\n return result;\n }\n\n for (const entry of entries) {\n const sessionDirectory = path.join(storeDirectory, entry);\n const candidate = path.join(sessionDirectory, STORE_FILE_NAME);\n if (sessionDirectory === currentSessionDirectory) continue;\n try {\n await fs.promises.access(candidate);\n try {\n await fs.promises.access(lockPathFor(candidate));\n continue;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== NOT_FOUND_ERROR_CODE) throw error;\n }\n JSON.parse(await fs.promises.readFile(candidate, FILE_ENCODING));\n if (now - (await fs.promises.stat(candidate)).mtimeMs <= ttlMs) continue;\n await fs.promises.rm(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) continue;\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport function lockPathFor(storePath: string): string {\n return `${storePath}.lock`;\n}\n\nexport function tempPathFor(storePath: string, pid: number = process.pid): string {\n return `${storePath}.tmp.${pid}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,iBAAiB;AAE9B,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,uBAAuB;AAE7B,SAAS,IAAI,MAAgB,KAAiC;CAC5D,IAAI;EAMF,MAAM,WAAA,GALSA,mBAAAA,aAAAA,CAAa,OAAO,MAAM;GACvC;GACA,UAAU;GACV,OAAO;IAAC;IAAU;IAAQ;GAAQ;EACpC,CACqB,CAAC,CAAC,KAAK;EAC5B,OAAO,QAAQ,SAAS,IAAI,UAAU,KAAA;CACxC,QAAQ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BAA8B,UAAU,IAAI,OAAO,KAAK,GAAG;EAChF;CACF;CACA,OAAO;AACT;AAEA,SAAgB,YAAY,WAA2B;CACrD,OAAO,GAAG,UAAU;AACtB;AAEA,SAAgB,YAAY,WAAmB,MAAc,QAAQ,KAAa;CAChF,OAAO,GAAG,UAAU,OAAO;AAC7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paths-Cah1vFGv.mjs","names":[],"sources":["../src/services/paths/index.ts"],"sourcesContent":["import { execFile, execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { SUBAGENT_CHILD_ENV, SUBAGENT_PARENT_SESSION_ENV } from '@agimon-ai/po-core/childProcess';\nimport { piAgentDirectory } from '@agimon-ai/po-core/piSettings';\n\nexport const STORE_PATH_ENV = 'DOOM_TASK_STORE';\n\nconst STORE_DIR_NAME = 'doom-task';\nconst STORE_FILE_NAME = 'tasks.json';\nconst FILE_ENCODING = 'utf8';\nconst NOT_FOUND_ERROR_CODE = 'ENOENT';\n\nfunction git(args: string[], cwd: string): string | undefined {\n try {\n const output = execFileSync('git', args, {\n cwd,\n encoding: FILE_ENCODING,\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n const trimmed = output.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function gitAsync(args: string[], cwd: string): Promise<string | undefined> {\n return new Promise((resolve) => {\n execFile('git', args, { cwd, encoding: FILE_ENCODING }, (error, stdout) => {\n if (error) {\n resolve(undefined);\n return;\n }\n const trimmed = stdout.trim();\n resolve(trimmed.length > 0 ? trimmed : undefined);\n });\n });\n}\n\nfunction isWithin(root: string, candidate: string): boolean {\n const relative = path.relative(path.resolve(root), path.resolve(candidate));\n return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));\n}\n\n/** Resolve the tree root without relying on extension startup order. */\nexport function resolveSessionKey(\n rootSessionId: string,\n env: Readonly<Record<string, string | undefined>> = process.env,\n): string {\n if (!env[SUBAGENT_CHILD_ENV]) return rootSessionId;\n const parentSessionId = env[SUBAGENT_PARENT_SESSION_ENV]?.trim();\n if (!parentSessionId) throw new Error(`${SUBAGENT_PARENT_SESSION_ENV} is required in a subagent child`);\n return parentSessionId;\n}\n\n/** Resolve one root session tree to a task document under the Pi agent directory. */\nexport function resolveStorePath(\n _cwd: string = process.cwd(),\n env: Readonly<Record<string, string | undefined>> = process.env,\n sessionKey: string = 'standalone',\n): string {\n const override = env[STORE_PATH_ENV]?.trim();\n if (override) return path.resolve(override);\n\n const trimmedSessionKey = sessionKey.trim();\n if (!trimmedSessionKey) throw new Error('doom-task session id cannot be blank');\n return path.join(piAgentDirectory(env), STORE_DIR_NAME, trimmedSessionKey, STORE_FILE_NAME);\n}\n\n/** Whether a deliberate unscoped task-store override is active. */\nexport function hasStorePathOverride(env: Readonly<Record<string, string | undefined>> = process.env): boolean {\n return Boolean(env[STORE_PATH_ENV]?.trim());\n}\n\n/** Exact legacy Git-directory store, if the current working tree has one. */\nexport function resolveLegacyStoreDirectory(cwd: string = process.cwd()): string | undefined {\n const commonDirectory = git(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport async function resolveLegacyStoreDirectoryAsync(cwd: string = process.cwd()): Promise<string | undefined> {\n const commonDirectory = await gitAsync(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport interface StoreSweepResult {\n removed: string[];\n errors: string[];\n}\n\n/** Remove only the validated legacy Git store unless it contains the active override. */\nexport function removeLegacyStoreDirectory(currentStorePath: string, cwd: string = process.cwd()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = resolveLegacyStoreDirectory(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n if (!fs.existsSync(target)) return result;\n fs.rmSync(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n return result;\n}\n\nexport async function removeLegacyStoreDirectoryAsync(\n currentStorePath: string,\n cwd: string = process.cwd(),\n): Promise<StoreSweepResult> {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = await resolveLegacyStoreDirectoryAsync(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n await fs.promises.access(target);\n await fs.promises.rm(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== NOT_FOUND_ERROR_CODE) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n }\n return result;\n}\n\n/** Delete expired sibling session stores while preserving active or unreadable stores. */\nexport function sweepStoreFiles(currentStorePath: string, ttlMs: number, now: number = Date.now()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const currentSessionDirectory = path.dirname(currentStorePath);\n const storeDirectory = path.dirname(currentSessionDirectory);\n let entries: string[];\n try {\n entries = fs.readdirSync(storeDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) return result;\n result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);\n return result;\n }\n\n for (const entry of entries) {\n const sessionDirectory = path.join(storeDirectory, entry);\n const candidate = path.join(sessionDirectory, STORE_FILE_NAME);\n if (sessionDirectory === currentSessionDirectory || !fs.existsSync(candidate)) continue;\n try {\n if (fs.existsSync(lockPathFor(candidate))) continue;\n JSON.parse(fs.readFileSync(candidate, FILE_ENCODING));\n if (now - fs.statSync(candidate).mtimeMs <= ttlMs) continue;\n fs.rmSync(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport async function sweepStoreFilesAsync(\n currentStorePath: string,\n ttlMs: number,\n now: number = Date.now(),\n): Promise<StoreSweepResult> {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const currentSessionDirectory = path.dirname(currentStorePath);\n const storeDirectory = path.dirname(currentSessionDirectory);\n let entries: string[];\n try {\n entries = await fs.promises.readdir(storeDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) return result;\n result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);\n return result;\n }\n\n for (const entry of entries) {\n const sessionDirectory = path.join(storeDirectory, entry);\n const candidate = path.join(sessionDirectory, STORE_FILE_NAME);\n if (sessionDirectory === currentSessionDirectory) continue;\n try {\n await fs.promises.access(candidate);\n try {\n await fs.promises.access(lockPathFor(candidate));\n continue;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== NOT_FOUND_ERROR_CODE) throw error;\n }\n JSON.parse(await fs.promises.readFile(candidate, FILE_ENCODING));\n if (now - (await fs.promises.stat(candidate)).mtimeMs <= ttlMs) continue;\n await fs.promises.rm(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) continue;\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport function lockPathFor(storePath: string): string {\n return `${storePath}.lock`;\n}\n\nexport function tempPathFor(storePath: string, pid: number = process.pid): string {\n return `${storePath}.tmp.${pid}`;\n}\n"],"mappings":";;;;;;AAOA,MAAa,iBAAiB;AAE9B,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,uBAAuB;AAE7B,SAAS,IAAI,MAAgB,KAAiC;CAC5D,IAAI;EAMF,MAAM,UALS,aAAa,OAAO,MAAM;GACvC;GACA,UAAU;GACV,OAAO;IAAC;IAAU;IAAQ;GAAQ;EACpC,CACqB,CAAC,CAAC,K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
notificationFailed: "doom_task.notification_failed",
|
|
4
|
-
storeReadFailed: "doom_task.store_read_failed",
|
|
5
|
-
storeLockTimeout: "doom_task.store_lock_timeout",
|
|
6
|
-
storeLockBreakFailed: "doom_task.store_lock_break_failed",
|
|
7
|
-
storeWatchFailed: "doom_task.store_watch_failed",
|
|
8
|
-
storeListenerFailed: "doom_task.store_listener_failed",
|
|
9
|
-
storeSweepFailed: "doom_task.store_sweep_failed",
|
|
10
|
-
sessionStartFailed: "doom_task.session_start_failed",
|
|
11
|
-
sessionStartDegraded: "doom_task.session_start_degraded",
|
|
12
|
-
toolFailed: "doom_task.tool_failed",
|
|
13
|
-
delegationRequestFailed: "doom_task.delegation_request_failed",
|
|
14
|
-
delegationStartFailed: "doom_task.delegation_start_failed",
|
|
15
|
-
delegationResponseFailed: "doom_task.delegation_response_failed",
|
|
16
|
-
delegationSettleFailed: "doom_task.delegation_settle_failed",
|
|
17
|
-
delegationTimedOut: "doom_task.delegation_timed_out",
|
|
18
|
-
delegationOrphaned: "doom_task.delegation_orphaned",
|
|
19
|
-
delegationAssigned: "doom_task.delegation_assigned",
|
|
20
|
-
delegationCompleted: "doom_task.delegation_completed"
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
23
|
-
Object.defineProperty(exports, "TASK_EVENT", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function() {
|
|
26
|
-
return TASK_EVENT;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=telemetry-Ca0I3Tqo.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-Ca0I3Tqo.cjs","names":[],"sources":["../src/types/telemetry.ts"],"sourcesContent":["export const TASK_EVENT = {\n notificationFailed: 'doom_task.notification_failed',\n storeReadFailed: 'doom_task.store_read_failed',\n storeLockTimeout: 'doom_task.store_lock_timeout',\n storeLockBreakFailed: 'doom_task.store_lock_break_failed',\n storeWatchFailed: 'doom_task.store_watch_failed',\n storeListenerFailed: 'doom_task.store_listener_failed',\n storeSweepFailed: 'doom_task.store_sweep_failed',\n sessionStartFailed: 'doom_task.session_start_failed',\n sessionStartDegraded: 'doom_task.session_start_degraded',\n toolFailed: 'doom_task.tool_failed',\n delegationRequestFailed: 'doom_task.delegation_request_failed',\n delegationStartFailed: 'doom_task.delegation_start_failed',\n delegationResponseFailed: 'doom_task.delegation_response_failed',\n delegationSettleFailed: 'doom_task.delegation_settle_failed',\n delegationTimedOut: 'doom_task.delegation_timed_out',\n delegationOrphaned: 'doom_task.delegation_orphaned',\n // Info-level lifecycle events. These are the measurement pair: the shape of\n // the brief that went out, and the cost of the run it produced.\n delegationAssigned: 'doom_task.delegation_assigned',\n delegationCompleted: 'doom_task.delegation_completed',\n} as const;\n\nexport type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];\nexport type TaskErrorAttributes = Record<string, string | number | boolean>;\nexport type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;\nexport type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;\n\n/** Host-neutral telemetry port consumed by Task services and store adapters. */\nexport interface TaskFailureReporter {\n error: TaskErrorSink;\n warn: TaskErrorSink;\n /** Info-level event sink. Required so an unwired reporter fails to compile. */\n event: TaskEventSink;\n}\n"],"mappings":";AAAA,MAAa,aAAa;CACxB,oBAAoB;CACpB,iBAAiB;CACjB,kBAAkB;CAClB,sBAAsB;CACtB,kBAAkB;CAClB,qBAAqB;CACrB,kBAAkB;CAClB,oBAAoB;CACpB,sBAAsB;CACtB,YAAY;CACZ,yBAAyB;CACzB,uBAAuB;CACvB,0BAA0B;CAC1B,wBAAwB;CACxB,oBAAoB;CACpB,oBAAoB;CAGpB,oBAAoB;CACpB,qBAAqB;AACvB"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region src/types/telemetry.ts
|
|
2
|
-
const TASK_EVENT = {
|
|
3
|
-
notificationFailed: "doom_task.notification_failed",
|
|
4
|
-
storeReadFailed: "doom_task.store_read_failed",
|
|
5
|
-
storeLockTimeout: "doom_task.store_lock_timeout",
|
|
6
|
-
storeLockBreakFailed: "doom_task.store_lock_break_failed",
|
|
7
|
-
storeWatchFailed: "doom_task.store_watch_failed",
|
|
8
|
-
storeListenerFailed: "doom_task.store_listener_failed",
|
|
9
|
-
storeSweepFailed: "doom_task.store_sweep_failed",
|
|
10
|
-
sessionStartFailed: "doom_task.session_start_failed",
|
|
11
|
-
sessionStartDegraded: "doom_task.session_start_degraded",
|
|
12
|
-
toolFailed: "doom_task.tool_failed",
|
|
13
|
-
delegationRequestFailed: "doom_task.delegation_request_failed",
|
|
14
|
-
delegationStartFailed: "doom_task.delegation_start_failed",
|
|
15
|
-
delegationResponseFailed: "doom_task.delegation_response_failed",
|
|
16
|
-
delegationSettleFailed: "doom_task.delegation_settle_failed",
|
|
17
|
-
delegationTimedOut: "doom_task.delegation_timed_out",
|
|
18
|
-
delegationOrphaned: "doom_task.delegation_orphaned",
|
|
19
|
-
delegationAssigned: "doom_task.delegation_assigned",
|
|
20
|
-
delegationCompleted: "doom_task.delegation_completed"
|
|
21
|
-
};
|
|
22
|
-
//#endregion
|
|
23
|
-
export { TASK_EVENT as t };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=telemetry-DyS44zAD.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-DyS44zAD.mjs","names":[],"sources":["../src/types/telemetry.ts"],"sourcesContent":["export const TASK_EVENT = {\n notificationFailed: 'doom_task.notification_failed',\n storeReadFailed: 'doom_task.store_read_failed',\n storeLockTimeout: 'doom_task.store_lock_timeout',\n storeLockBreakFailed: 'doom_task.store_lock_break_failed',\n storeWatchFailed: 'doom_task.store_watch_failed',\n storeListenerFailed: 'doom_task.store_listener_failed',\n storeSweepFailed: 'doom_task.store_sweep_failed',\n sessionStartFailed: 'doom_task.session_start_failed',\n sessionStartDegraded: 'doom_task.session_start_degraded',\n toolFailed: 'doom_task.tool_failed',\n delegationRequestFailed: 'doom_task.delegation_request_failed',\n delegationStartFailed: 'doom_task.delegation_start_failed',\n delegationResponseFailed: 'doom_task.delegation_response_failed',\n delegationSettleFailed: 'doom_task.delegation_settle_failed',\n delegationTimedOut: 'doom_task.delegation_timed_out',\n delegationOrphaned: 'doom_task.delegation_orphaned',\n // Info-level lifecycle events. These are the measurement pair: the shape of\n // the brief that went out, and the cost of the run it produced.\n delegationAssigned: 'doom_task.delegation_assigned',\n delegationCompleted: 'doom_task.delegation_completed',\n} as const;\n\nexport type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];\nexport type TaskErrorAttributes = Record<string, string | number | boolean>;\nexport type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;\nexport type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;\n\n/** Host-neutral telemetry port consumed by Task services and store adapters. */\nexport interface TaskFailureReporter {\n error: TaskErrorSink;\n warn: TaskErrorSink;\n /** Info-level event sink. Required so an unwired reporter fails to compile. */\n event: TaskEventSink;\n}\n"],"mappings":";AAAA,MAAa,aAAa;CACxB,oBAAoB;CACpB,iBAAiB;CACjB,kBAAkB;CAClB,sBAAsB;CACtB,kBAAkB;CAClB,qBAAqB;CACrB,kBAAkB;CAClB,oBAAoB;CACpB,sBAAsB;CACtB,YAAY;CACZ,yBAAyB;CACzB,uBAAuB;CACvB,0BAA0B;CAC1B,wBAAwB;CACxB,oBAAoB;CACpB,oBAAoB;CAGpB,oBAAoB;CACpB,qBAAqB;AACvB"}
|