@agimon-ai/po-task 0.0.0-alpha.4 → 0.0.0-alpha.41

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.
Files changed (70) hide show
  1. package/LICENSE +149 -21
  2. package/README.md +12 -2
  3. package/dist/apiContracts.cjs +1 -0
  4. package/dist/apiContracts.cjs.map +1 -1
  5. package/dist/apiContracts.mjs +1 -0
  6. package/dist/apiContracts.mjs.map +1 -1
  7. package/dist/{delegation-Dsqf7fUM.mjs → delegation-CLcleXHi.mjs} +3 -2
  8. package/dist/{delegation-Dsqf7fUM.mjs.map → delegation-CLcleXHi.mjs.map} +1 -1
  9. package/dist/{delegation-frvEXhIz.cjs → delegation-DRp6iZid.cjs} +3 -2
  10. package/dist/{delegation-frvEXhIz.cjs.map → delegation-DRp6iZid.cjs.map} +1 -1
  11. package/dist/delegationManager.cjs +1 -1
  12. package/dist/delegationManager.d.mts +1 -1
  13. package/dist/delegationManager.mjs +1 -1
  14. package/dist/extensions/mcp.cjs +29 -27
  15. package/dist/extensions/mcp.cjs.map +1 -1
  16. package/dist/extensions/mcp.mjs +29 -27
  17. package/dist/extensions/mcp.mjs.map +1 -1
  18. package/dist/extensions/native.mjs +309 -207
  19. package/dist/extensions/native.mjs.map +1 -1
  20. package/dist/extensions/server.cjs +351 -122
  21. package/dist/extensions/server.cjs.map +1 -1
  22. package/dist/extensions/server.d.mts +2 -2
  23. package/dist/extensions/server.d.mts.map +1 -1
  24. package/dist/extensions/server.mjs +350 -121
  25. package/dist/extensions/server.mjs.map +1 -1
  26. package/dist/extensions/web.mjs +254 -206
  27. package/dist/extensions/web.mjs.map +1 -1
  28. package/dist/{index-DlmXKyhQ.d.mts → index-CdJx5tdI.d.mts} +2 -2
  29. package/dist/{index-DlmXKyhQ.d.mts.map → index-CdJx5tdI.d.mts.map} +1 -1
  30. package/dist/{index-B1JPJdpZ.d.mts → index-DrE00rrP.d.mts} +3 -3
  31. package/dist/{index-B1JPJdpZ.d.mts.map → index-DrE00rrP.d.mts.map} +1 -1
  32. package/dist/{index-B9QNwUBr.d.mts → index-Dyan0ai0.d.mts} +3 -3
  33. package/dist/{index-B9QNwUBr.d.mts.map → index-Dyan0ai0.d.mts.map} +1 -1
  34. package/dist/{index-qQGWsPum.d.mts → index-S77ZvGc-.d.mts} +2 -2
  35. package/dist/{index-qQGWsPum.d.mts.map → index-S77ZvGc-.d.mts.map} +1 -1
  36. package/dist/{index-CUWCvh-E.d.mts → index-nx0ueNkm.d.mts} +2 -2
  37. package/dist/{index-CUWCvh-E.d.mts.map → index-nx0ueNkm.d.mts.map} +1 -1
  38. package/dist/index.cjs +1 -1
  39. package/dist/index.d.mts +8 -8
  40. package/dist/index.mjs +1 -1
  41. package/dist/{logSinkTelemetry-BhbKdn-x.mjs → logSinkTelemetry-3GMazFYa.mjs} +2 -2
  42. package/dist/logSinkTelemetry-3GMazFYa.mjs.map +1 -0
  43. package/dist/{logSinkTelemetry-BGb8WQBz.cjs → logSinkTelemetry-DhzIQMsV.cjs} +3 -3
  44. package/dist/logSinkTelemetry-DhzIQMsV.cjs.map +1 -0
  45. package/dist/logSinkTelemetry.cjs +1 -1
  46. package/dist/logSinkTelemetry.d.mts +1 -1
  47. package/dist/logSinkTelemetry.mjs +1 -1
  48. package/dist/storeInvariants.d.mts +1 -1
  49. package/dist/storeReconcile.d.mts +1 -1
  50. package/dist/storeReducer.d.mts +1 -1
  51. package/dist/storeTaskGraph.d.mts +1 -1
  52. package/dist/storeTaskStore.d.mts +1 -1
  53. package/dist/storeTypes.d.mts +1 -1
  54. package/dist/{task-4HeGAS8o.d.mts → task--hlnpS7L.d.mts} +2 -2
  55. package/dist/{task-4HeGAS8o.d.mts.map → task--hlnpS7L.d.mts.map} +1 -1
  56. package/dist/task-CXF9VULl.cjs.map +1 -1
  57. package/dist/{task-DJpTteeJ.d.mts → task-DdTKZNtU.d.mts} +3 -1
  58. package/dist/task-DdTKZNtU.d.mts.map +1 -0
  59. package/dist/task-giCbpKzV.mjs.map +1 -1
  60. package/dist/{taskGraph-D0zFHF2p.d.mts → taskGraph-CB8ffMCz.d.mts} +2 -2
  61. package/dist/{taskGraph-D0zFHF2p.d.mts.map → taskGraph-CB8ffMCz.d.mts.map} +1 -1
  62. package/dist/toolResponseEnvelope.d.mts +1 -1
  63. package/dist/toolSchema.d.mts +1 -1
  64. package/llms.txt +11 -0
  65. package/package.json +17 -16
  66. package/src/prompts/codemode-how-to-task/SKILL.md +40 -0
  67. package/src/types/webTasks.ts +1 -0
  68. package/dist/logSinkTelemetry-BGb8WQBz.cjs.map +0 -1
  69. package/dist/logSinkTelemetry-BhbKdn-x.mjs.map +0 -1
  70. package/dist/task-DJpTteeJ.d.mts.map +0 -1
@@ -6,23 +6,24 @@ const require_paths = require("../paths-P-XvOUuH.cjs");
6
6
  const require_config = require("../config-BC-bztyx.cjs");
7
7
  const require_taskGraph = require("../taskGraph-BskRslrr.cjs");
8
8
  const require_telemetry = require("../telemetry-x3JxCA5K.cjs");
9
- const require_delegation = require("../delegation-frvEXhIz.cjs");
9
+ const require_delegation = require("../delegation-DRp6iZid.cjs");
10
10
  const require_taskResult = require("../taskResult-D2G7b4w-.cjs");
11
11
  const require_task = require("../task-UvW877Ez.cjs");
12
12
  const require_reducer = require("../reducer-BV0YIZ2o.cjs");
13
13
  const require_taskStore = require("../taskStore-C4vcUOzA.cjs");
14
- const require_logSinkTelemetry = require("../logSinkTelemetry-BGb8WQBz.cjs");
14
+ const require_logSinkTelemetry = require("../logSinkTelemetry-DhzIQMsV.cjs");
15
15
  let _agimon_ai_po_core_delegation = require("@agimon-ai/po-core/delegation");
16
16
  let node_path = require("node:path");
17
17
  node_path = require_paths.__toESM(node_path, 1);
18
- let _agimon_ai_po_core_serverFacet = require("@agimon-ai/po-core/serverFacet");
18
+ let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
19
19
  let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
20
20
  let _agimon_ai_po_core_backgroundWork = require("@agimon-ai/po-core/backgroundWork");
21
+ let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
21
22
  let _agimon_ai_po_core_contextContributions = require("@agimon-ai/po-core/contextContributions");
22
23
  let _agimon_ai_po_core_readiness = require("@agimon-ai/po-core/readiness");
23
24
  let node_crypto = require("node:crypto");
24
- let _agimon_ai_po_core_hubChannel = require("@agimon-ai/po-core/hubChannel");
25
25
  let typebox_value = require("typebox/value");
26
+ let _agimon_ai_po_core_hubChannel = require("@agimon-ai/po-core/hubChannel");
26
27
  //#region src/services/contextContribution/index.ts
27
28
  const TASK_CONTEXT_CONTRIBUTION_SOURCE = "@agimon-ai/po-task";
28
29
  const TASK_CONTEXT_CONTRIBUTION_ID = "active-tasks";
@@ -82,6 +83,298 @@ function createNodeDelegationPlatform(environment = process.env) {
82
83
  };
83
84
  }
84
85
  //#endregion
86
+ //#region src/services/taskTool/index.ts
87
+ function output(value) {
88
+ if (typeof value === "object" && value !== null && "content" in value) return value;
89
+ return {
90
+ content: [{
91
+ type: "text",
92
+ text: typeof value === "string" ? value : JSON.stringify(value, null, 2)
93
+ }],
94
+ details: value
95
+ };
96
+ }
97
+ function failure(error) {
98
+ return {
99
+ content: [{
100
+ type: "text",
101
+ text: error instanceof Error ? error.message : String(error)
102
+ }],
103
+ isError: true
104
+ };
105
+ }
106
+ async function reducerAction(store, action, params, maxTasks) {
107
+ const { document, value } = await store.mutate((current) => {
108
+ const result = require_reducer.applyTaskMutation(current, action, params, void 0, maxTasks);
109
+ return {
110
+ ...require_reducer.isCommittingOp(result.op) ? { document: result.document } : {},
111
+ value: result
112
+ };
113
+ });
114
+ if (value.op.kind === "error") throw new Error(value.op.message);
115
+ return require_taskResult.buildToolResult(action, params, document, value.op);
116
+ }
117
+ async function assignmentBatch(manager, assignments, signal) {
118
+ const result = [];
119
+ for (const [index, assignment] of assignments.entries()) try {
120
+ const outcome = await manager.assign(assignment.id, {
121
+ agent: assignment.agent,
122
+ inlineAgent: assignment.inlineAgent,
123
+ instructions: assignment.instructions,
124
+ relevantFiles: assignment.relevantFiles,
125
+ priorFindings: assignment.priorFindings,
126
+ model: assignment.model,
127
+ ...assignment.context === "fork" || assignment.context === "fresh" ? { context: assignment.context } : {},
128
+ signal
129
+ });
130
+ result.push({
131
+ index,
132
+ id: assignment.id,
133
+ agent: assignment.agent,
134
+ ...outcome
135
+ });
136
+ } catch (error) {
137
+ result.push({
138
+ index,
139
+ id: assignment.id,
140
+ agent: assignment.agent,
141
+ ok: false,
142
+ message: String(error)
143
+ });
144
+ }
145
+ return result;
146
+ }
147
+ /** One task action against the session store, shared by the `task` tool and the `tasks` code-mode namespace. */
148
+ async function runTaskAction(store, manager, maxTasks, rawParams, signal, onUpdate) {
149
+ if (!(0, typebox_value.Check)(require_task.TaskParamsSchema, rawParams)) return failure("Invalid task parameters.");
150
+ const params = rawParams;
151
+ try {
152
+ if ((params.action === "assign" || params.action === "cancel") && !manager) throw new Error("Delegation is not available on this connection.");
153
+ if (params.action === "assign") {
154
+ if (!params.assignments?.length) throw new Error("assign requires a non-empty assignments[] array");
155
+ onUpdate?.(output(`Delegating ${params.assignments.length} task${params.assignments.length === 1 ? "" : "s"}...`));
156
+ const items = await assignmentBatch(manager, params.assignments, signal);
157
+ const assigned = items.filter((item) => item.ok).map((item) => item.id);
158
+ const text = require_taskResult.formatAssignmentResults(items);
159
+ if (assigned.length === 0) throw new Error(text);
160
+ return require_taskResult.buildAssignmentResult(params, store.snapshot, text, {
161
+ assigned,
162
+ failed: items.length - assigned.length
163
+ });
164
+ }
165
+ if (params.action === "cancel") {
166
+ const outcome = await manager.cancel(params.id ?? NaN);
167
+ if (!outcome.ok) throw new Error(outcome.message);
168
+ return require_taskResult.buildTextResult("cancel", params, store.snapshot, outcome.message);
169
+ }
170
+ return reducerAction(store, params.action, params, maxTasks);
171
+ } catch (error) {
172
+ return failure(error);
173
+ }
174
+ }
175
+ function createHeadlessTaskTool(store, manager, maxTasks) {
176
+ return {
177
+ name: "task",
178
+ label: "Task",
179
+ description: "Maintain a persistent task graph and delegate ready tasks to background agents.",
180
+ parameters: require_task.TaskParamsSchema,
181
+ promptSnippet: "Track complex work persistently and delegate ready tasks",
182
+ executionMode: "serial",
183
+ execute: (_toolCallId, rawParams, signal, onUpdate) => runTaskAction(store, manager, maxTasks, rawParams, signal, onUpdate)
184
+ };
185
+ }
186
+ //#endregion
187
+ //#region src/services/taskNamespace/index.ts
188
+ const DECLARATIONS = `type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'deleted';
189
+
190
+ type DelegationState = 'requested' | 'running' | 'completed' | 'failed' | 'cancelled';
191
+
192
+ interface DelegationResult {
193
+ status: string;
194
+ output?: string;
195
+ outputPath?: string;
196
+ sessionFile?: string;
197
+ error?: string;
198
+ durationMs?: number;
199
+ toolCount?: number;
200
+ }
201
+
202
+ interface TaskDelegation {
203
+ requestId: string;
204
+ agent: string;
205
+ identity?: string;
206
+ state: DelegationState;
207
+ sessionId?: string;
208
+ pid?: number;
209
+ runId?: string;
210
+ model?: string;
211
+ startedAt?: string;
212
+ endedAt?: string;
213
+ result?: DelegationResult;
214
+ }
215
+
216
+ interface Task {
217
+ id: number;
218
+ subject: string;
219
+ description?: string;
220
+ activeForm?: string;
221
+ status: TaskStatus;
222
+ blockedBy?: number[];
223
+ owner?: string;
224
+ metadata?: Record<string, unknown>;
225
+ createdAt?: string;
226
+ updatedAt?: string;
227
+ delegation?: TaskDelegation;
228
+ }
229
+
230
+ interface TaskDocument {
231
+ version: number;
232
+ rev: number;
233
+ nextId: number;
234
+ tasks: Task[];
235
+ }
236
+ interface TaskItem {
237
+ /** Existing task id to change. Omit to create; an unknown id fails only that entry. */
238
+ id?: number;
239
+ /** Temporary name so a LATER entry in the same call can list it in blockedBy. Never stored. */
240
+ ref?: string;
241
+ /** Short and imperative. Required when creating. */
242
+ subject?: string;
243
+ /** The durable brief handed to a subagent on assign. */
244
+ description?: string;
245
+ /** Present-continuous label shown while in_progress, such as 'writing tests'. */
246
+ activeForm?: string;
247
+ status?: TaskStatus;
248
+ /** For a NEW entry: task ids or earlier refs. */
249
+ blockedBy?: (number | string)[];
250
+ /** For an entry with an id: dependencies to add or remove. */
251
+ addBlockedBy?: (number | string)[];
252
+ removeBlockedBy?: (number | string)[];
253
+ owner?: string;
254
+ /** Merged into the task; a null value deletes that key. */
255
+ metadata?: Record<string, unknown>;
256
+ }
257
+
258
+ interface TaskAssignment {
259
+ /** A pending, unblocked task. */
260
+ id: number;
261
+ /** Exact name from subagent({ action: 'agents' }). */
262
+ agent: string;
263
+ instructions?: string;
264
+ /** Only files you actually read or located. */
265
+ relevantFiles?: string[];
266
+ /** Only verified facts, not directives. */
267
+ priorFindings?: string;
268
+ model?: string;
269
+ context?: 'fresh' | 'fork';
270
+ }
271
+
272
+ /** What a write returns: the text the task tool would print, and the graph after the write. */
273
+ interface TaskWrite {
274
+ message: string;
275
+ document: TaskDocument;
276
+ /** upsert only: ids that landed and how many entries failed. Nothing landing throws; a partial failure does not. */
277
+ applied?: number[];
278
+ failed?: number;
279
+ }
280
+ declare const tasks: {
281
+ /** The whole task graph, tombstones included. Filter it in the script. */
282
+ snapshot(): Promise<TaskDocument>;
283
+ /**
284
+ * Create or change tasks, applied in array order. Never mark a task completed while tests fail or the
285
+ * work is partial: use failed, or keep it in_progress and add a task for the blocker in the same call.
286
+ * Status flow is pending, in_progress, completed. failed is recoverable and deleted is a tombstone.
287
+ */
288
+ upsert(tasks: TaskItem[]): Promise<TaskWrite>;
289
+ /** Tombstone one task. Refused while it has a running delegation. */
290
+ delete(id: number): Promise<TaskWrite>;
291
+ /** Remove every task. Refused while a delegation is running. */
292
+ clear(): Promise<TaskWrite>;
293
+ /** Hand ready tasks to background subagents. Batch independent tasks in one call. */
294
+ assign(assignments: TaskAssignment[]): Promise<TaskWrite>;
295
+ /** Cancel a task's running delegation. */
296
+ cancel(id: number): Promise<TaskWrite>;
297
+ };`;
298
+ /** The owning session's task graph: `snapshot` reads without locking, the rest write through the same store as the `task` tool. */
299
+ function createTaskNamespace(options) {
300
+ return {
301
+ name: "tasks",
302
+ summary: "The session task graph: tasks.snapshot() reads it, tasks.upsert/delete/clear change it, tasks.assign/cancel hand tasks to background subagents. Use it to track multi-step work.",
303
+ declarations: DECLARATIONS,
304
+ bind(run) {
305
+ if (run.sessionId !== options.sessionId) throw new Error("Tasks namespace belongs to another session.");
306
+ let disposed = false;
307
+ run.onDispose(() => {
308
+ disposed = true;
309
+ });
310
+ const assertAvailable = () => {
311
+ run.signal.throwIfAborted();
312
+ if (disposed) throw new Error("Tasks namespace run is disposed.");
313
+ options.assertAvailable();
314
+ };
315
+ const members = Object.create(null);
316
+ members.snapshot = async () => {
317
+ assertAvailable();
318
+ const storePath = options.store.storePath;
319
+ const errors = [];
320
+ const document = await options.store.readAsync(() => false, (error) => errors.push(error));
321
+ assertAvailable();
322
+ if (options.store.storePath !== storePath) throw new Error("Task store path changed during snapshot.");
323
+ if (errors.length > 0) throw new Error("Task snapshot read failed.", { cause: errors[0] });
324
+ return JSON.parse(JSON.stringify(document));
325
+ };
326
+ const write = async (params) => {
327
+ assertAvailable();
328
+ const started = Date.now();
329
+ const result = await runTaskAction(options.store, options.manager, options.maxTasks, params, run.signal);
330
+ assertAvailable();
331
+ const message = result.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n");
332
+ const upsert = result.details?.upsert;
333
+ const failure = result.isError || upsert && upsert.applied.length === 0 && upsert.failed > 0 ? message : void 0;
334
+ run.record?.({
335
+ name: `tasks.${String(params.action)}`,
336
+ tool: "task",
337
+ args: params,
338
+ ok: failure === void 0,
339
+ ms: Date.now() - started,
340
+ ...failure === void 0 ? {} : { error: failure },
341
+ result: {
342
+ content: result.content,
343
+ details: result.details
344
+ }
345
+ });
346
+ if (failure !== void 0) throw new Error(failure);
347
+ return {
348
+ message,
349
+ document: JSON.parse(JSON.stringify(options.store.snapshot)),
350
+ ...upsert ? {
351
+ applied: upsert.applied,
352
+ failed: upsert.failed
353
+ } : {}
354
+ };
355
+ };
356
+ members.upsert = (tasks) => write({
357
+ action: "upsert",
358
+ tasks
359
+ });
360
+ members.delete = (id) => write({
361
+ action: "delete",
362
+ id
363
+ });
364
+ members.clear = () => write({ action: "clear" });
365
+ members.assign = (assignments) => write({
366
+ action: "assign",
367
+ assignments
368
+ });
369
+ members.cancel = (id) => write({
370
+ action: "cancel",
371
+ id
372
+ });
373
+ return members;
374
+ }
375
+ };
376
+ }
377
+ //#endregion
85
378
  //#region src/types/webTasks.ts
86
379
  /** Browser-safe task view published by the cockpit hub channel. */
87
380
  const TASKS_CHANNEL_TYPE = "task_graph";
@@ -95,7 +388,7 @@ function headlineOf(content) {
95
388
  const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ host: serverHost, agent: host, signal: pluginSignal }) => {
96
389
  if (!host) throw new Error("Task session requires the headless host.");
97
390
  const execution = host.context;
98
- if (serverHost.context.directEvents === void 0) throw new Error("Task headless facet requires the session direct event bus.");
391
+ if (serverHost.context.directEvents === void 0) throw new Error("Task server plugin requires the session direct event bus.");
99
392
  const directEvents = serverHost.context.directEvents;
100
393
  const reporter = require_logSinkTelemetry.createTaskErrorReporter({
101
394
  cwd: execution.cwd,
@@ -180,6 +473,25 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ host: serverHos
180
473
  },
181
474
  services: [(serviceContextOwner) => {
182
475
  serviceContext = serviceContextOwner;
476
+ const namespace = createTaskNamespace({
477
+ store,
478
+ manager,
479
+ maxTasks,
480
+ sessionId: execution.sessionId,
481
+ assertAvailable: () => {
482
+ if (!active || disposed || pluginSignal?.aborted) throw new Error("Task session is unavailable.");
483
+ }
484
+ });
485
+ serviceContextOwner.inject([_agimon_ai_po_core_codemode.PO_CODEMODE_SERVICE], (context) => {
486
+ const codemode = (0, _agimon_ai_po_core_codemode.readPoCodemode)(context);
487
+ if (!codemode) return void 0;
488
+ const registration = codemode.register(SOURCE, namespace);
489
+ const restriction = host.registerToolRestriction({ excludedTools: ["task"] });
490
+ return () => {
491
+ restriction.dispose();
492
+ registration.dispose();
493
+ };
494
+ });
183
495
  serviceContextOwner.inject([_agimon_ai_po_core_contextContributions.PO_CONTEXT_CONTRIBUTIONS_SERVICE], (context) => {
184
496
  const registration = (0, _agimon_ai_po_core_contextContributions.requirePoContextContributions)(context).register(createTaskContextContribution(() => active && !disposed ? store.snapshot.tasks : []));
185
497
  return () => registration.dispose();
@@ -282,12 +594,14 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ host: serverHos
282
594
  generation += 1;
283
595
  startupAbort.abort();
284
596
  await Promise.allSettled([startup]);
285
- unwatch?.();
286
- background?.dispose();
287
- manager.dispose();
288
- store.dispose();
289
- await ownedReadiness.dispose();
290
- await reporter.shutdown();
597
+ await (0, _agimon_ai_po_core_extensionFile.runCleanups)([
598
+ () => unwatch?.(),
599
+ () => background?.dispose(),
600
+ () => manager.dispose(),
601
+ () => store.dispose(),
602
+ () => ownedReadiness.dispose(),
603
+ () => reporter.shutdown()
604
+ ], "Task cleanup failed.");
291
605
  }
292
606
  };
293
607
  });
@@ -315,6 +629,7 @@ function present(document) {
315
629
  if (task.updatedAt) view.updatedAt = task.updatedAt;
316
630
  if (task.delegation) view.delegation = {
317
631
  ...task.delegation.agent === void 0 ? {} : { agent: task.delegation.agent },
632
+ ...task.delegation.identity === void 0 ? {} : { identity: task.delegation.identity },
318
633
  ...task.delegation.state === void 0 ? {} : { state: task.delegation.state }
319
634
  };
320
635
  return [view];
@@ -434,105 +749,6 @@ function createTasksChannel(options = {}) {
434
749
  //#region src/extensions/(backend)/channel/task-graph.server.ts
435
750
  var task_graph_server_default = (0, _agimon_ai_po_core_extensionFile.defineChannel)(createTasksChannel);
436
751
  //#endregion
437
- //#region src/services/taskTool/index.ts
438
- function output(value) {
439
- if (typeof value === "object" && value !== null && "content" in value) return value;
440
- return {
441
- content: [{
442
- type: "text",
443
- text: typeof value === "string" ? value : JSON.stringify(value, null, 2)
444
- }],
445
- details: value
446
- };
447
- }
448
- function failure(error) {
449
- return {
450
- content: [{
451
- type: "text",
452
- text: error instanceof Error ? error.message : String(error)
453
- }],
454
- isError: true
455
- };
456
- }
457
- async function reducerAction(store, action, params, maxTasks) {
458
- const { document, value } = await store.mutate((current) => {
459
- const result = require_reducer.applyTaskMutation(current, action, params, void 0, maxTasks);
460
- return {
461
- ...require_reducer.isCommittingOp(result.op) ? { document: result.document } : {},
462
- value: result
463
- };
464
- });
465
- if (value.op.kind === "error") throw new Error(value.op.message);
466
- return require_taskResult.buildToolResult(action, params, document, value.op);
467
- }
468
- async function assignmentBatch(manager, assignments, signal) {
469
- const result = [];
470
- for (const [index, assignment] of assignments.entries()) try {
471
- const outcome = await manager.assign(assignment.id, {
472
- agent: assignment.agent,
473
- inlineAgent: assignment.inlineAgent,
474
- instructions: assignment.instructions,
475
- relevantFiles: assignment.relevantFiles,
476
- priorFindings: assignment.priorFindings,
477
- model: assignment.model,
478
- ...assignment.context === "fork" || assignment.context === "fresh" ? { context: assignment.context } : {},
479
- signal
480
- });
481
- result.push({
482
- index,
483
- id: assignment.id,
484
- agent: assignment.agent,
485
- ...outcome
486
- });
487
- } catch (error) {
488
- result.push({
489
- index,
490
- id: assignment.id,
491
- agent: assignment.agent,
492
- ok: false,
493
- message: String(error)
494
- });
495
- }
496
- return result;
497
- }
498
- function createHeadlessTaskTool(store, manager, maxTasks) {
499
- return {
500
- name: "task",
501
- label: "Task",
502
- description: "Maintain a persistent task graph and delegate ready tasks to background agents.",
503
- parameters: require_task.TaskParamsSchema,
504
- promptSnippet: "Track complex work persistently and delegate ready tasks",
505
- executionMode: "serial",
506
- async execute(_toolCallId, rawParams, signal, onUpdate) {
507
- if (!(0, typebox_value.Check)(require_task.TaskParamsSchema, rawParams)) return failure("Invalid task parameters.");
508
- const params = rawParams;
509
- try {
510
- if ((params.action === "assign" || params.action === "cancel") && !manager) throw new Error("Delegation is not available on this connection.");
511
- if (params.action === "assign") {
512
- if (!params.assignments?.length) throw new Error("assign requires a non-empty assignments[] array");
513
- onUpdate?.(output(`Delegating ${params.assignments.length} task${params.assignments.length === 1 ? "" : "s"}...`));
514
- const items = await assignmentBatch(manager, params.assignments, signal);
515
- const assigned = items.filter((item) => item.ok).map((item) => item.id);
516
- const text = require_taskResult.formatAssignmentResults(items);
517
- if (assigned.length === 0) throw new Error(text);
518
- return require_taskResult.buildAssignmentResult(params, store.snapshot, text, {
519
- assigned,
520
- failed: items.length - assigned.length
521
- });
522
- }
523
- if (params.action === "cancel") {
524
- const outcome = await manager.cancel(params.id ?? NaN);
525
- if (!outcome.ok) throw new Error(outcome.message);
526
- return require_taskResult.buildTextResult("cancel", params, store.snapshot, outcome.message);
527
- }
528
- return reducerAction(store, params.action, params, maxTasks);
529
- } catch (error) {
530
- return failure(error);
531
- }
532
- }
533
- };
534
- }
535
- //#endregion
536
752
  //#region src/extensions/workspaces/sessions/(backend)/command/_lib/tasks.server.ts
537
753
  var tasks_server_default$1 = (context) => ({
538
754
  name: require_task.COMMAND_NAME,
@@ -550,12 +766,22 @@ var tasks_server_default$1 = (context) => ({
550
766
  //#region src/extensions/workspaces/sessions/(backend)/command/tasks.server.ts
551
767
  var tasks_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerCommand)(tasks_server_default$1);
552
768
  //#endregion
769
+ //#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-task.server.ts
770
+ var codemode_how_to_task_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
771
+ name: "codemode-how-to-task",
772
+ description: "Keep a plan that survives compaction and delegate parts of it to background subagents. Use for any multi-step plan, todo list, or delegation.",
773
+ kind: "skill",
774
+ pinned: true,
775
+ path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-task/SKILL.md"),
776
+ read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-task/SKILL.md")
777
+ });
778
+ //#endregion
553
779
  //#region src/extensions/workspaces/sessions/(backend)/resource/_lib/task-board.server.ts
554
780
  var task_board_server_default$1 = (context) => ({
555
781
  name: "po/task-board",
556
782
  kind: "context",
557
783
  /**
558
- * The same bounded projection the Pi facet renders: open work only, one line each.
784
+ * The same bounded projection the Pi extension renders: open work only, one line each.
559
785
  * Dumping the whole TaskDocument put every completed task plus the store's own
560
786
  * version/rev/nextId bookkeeping in the prompt, and an idle board still cost a
561
787
  * paragraph. '' is dropped by the prompt composer.
@@ -577,21 +803,24 @@ var task_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerTool)
577
803
  //#endregion
578
804
  //#region generated/server.ts
579
805
  const at = (value, context) => typeof value === "function" ? value(context) : value;
806
+ /* v8 ignore next -- generated normalization branch */
807
+ const defined = (values) => values.filter((value) => value !== void 0);
580
808
  const via = (identity, value) => value === void 0 ? void 0 : {
581
809
  ...identity,
582
810
  ...value
583
811
  };
584
- const facet = (0, _agimon_ai_po_core_serverFacet.defineServerPlugin)({
812
+ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
585
813
  name: "@agimon-ai/po-task",
586
- providerOverrides: (0, _agimon_ai_po_core_serverFacet.composeServerProviderOverrides)(root_server_default),
587
- global: () => ({ get channels() {
588
- return [() => via({ frameType: "task_graph" }, task_graph_server_default())];
814
+ providerOverrides: (0, _agimon_ai_po_core_serverPlugin.composeServerProviderOverrides)(root_server_default),
815
+ injects: (0, _agimon_ai_po_core_extensionFile.composeRootInjects)({ session: [root_server_default] }),
816
+ global: (context) => ({ get channels() {
817
+ return [() => via({ frameType: "task_graph" }, at(task_graph_server_default, context))];
589
818
  } }),
590
- workspace: () => ({ get channels() {
591
- return [() => via({ frameType: "task_graph" }, task_graph_server_default())];
819
+ workspace: (context) => ({ get channels() {
820
+ return defined([context.hosted("global") ? void 0 : () => via({ frameType: "task_graph" }, at(task_graph_server_default, context))]);
592
821
  } }),
593
822
  session: async (context) => {
594
- const scopeSession = await root_server_default(context);
823
+ const scopeSession = await context.scopeRoot("session", root_server_default, context);
595
824
  const contextSession = {
596
825
  ...context,
597
826
  root: scopeSession.value
@@ -599,13 +828,13 @@ const facet = (0, _agimon_ai_po_core_serverFacet.defineServerPlugin)({
599
828
  return {
600
829
  ...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeSession),
601
830
  get channels() {
602
- return [() => via({ frameType: "task_graph" }, task_graph_server_default())];
831
+ return defined([context.hosted("global") ? void 0 : () => via({ frameType: "task_graph" }, at(task_graph_server_default, context))]);
603
832
  },
604
833
  get commands() {
605
834
  return [via({ name: "tasks" }, at(tasks_server_default, contextSession))];
606
835
  },
607
836
  get resources() {
608
- return [at(task_board_server_default, contextSession)];
837
+ return [at(codemode_how_to_task_server_default, contextSession), at(task_board_server_default, contextSession)];
609
838
  },
610
839
  get tools() {
611
840
  return [via({ name: "task" }, at(task_server_default, contextSession))];
@@ -618,7 +847,7 @@ const facet = (0, _agimon_ai_po_core_serverFacet.defineServerPlugin)({
618
847
  }
619
848
  });
620
849
  //#endregion
621
- exports.default = facet;
622
- exports.facet = facet;
850
+ exports.default = serverPlugin;
851
+ exports.serverPlugin = serverPlugin;
623
852
 
624
853
  //# sourceMappingURL=server.cjs.map