@agimon-ai/po-task 0.0.0-alpha.27 → 0.0.0-alpha.29

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 CHANGED
@@ -63,6 +63,16 @@ The reducer enforces lifecycle transitions and rejects dependency cycles. A grap
63
63
  non-deleted tasks by default; updates still apply when full, but new tasks are rejected until space
64
64
  is freed.
65
65
 
66
+ ## Tasks in code mode
67
+
68
+ When code mode is loaded, the `tasks` namespace covers every task action and the direct `task` tool is
69
+ withdrawn from the model for that session. `await tasks.snapshot()` returns a detached `TaskDocument`,
70
+ including deleted tasks, and never locks, writes, increments `rev`, or replaces the store cache. A
71
+ missing file returns an empty document; other read failures reject. `upsert`, `delete`, `clear`,
72
+ `assign` and `cancel` write through the same store and reducer as the tool and resolve to
73
+ `{ message, document }`; a refused change rejects. Without code mode, and on remote MCP, the `task`
74
+ tool stays available. The `po-use-task` skill carries the usage rules.
75
+
66
76
  ## Presentation
67
77
 
68
78
  The browser owns the task view and renderer. Terminal task shortcuts and overlays are retired; the native `task` tool remains available.
@@ -1059,6 +1059,34 @@ async function assignmentBatch(manager, assignments, signal) {
1059
1059
  }
1060
1060
  return result;
1061
1061
  }
1062
+ /** One task action against the session store, shared by the `task` tool and the `tasks` code-mode namespace. */
1063
+ async function runTaskAction(store, manager, maxTasks, rawParams, signal, onUpdate) {
1064
+ if (!(0, typebox_value.Check)(TaskParamsSchema, rawParams)) return failure("Invalid task parameters.");
1065
+ const params = rawParams;
1066
+ try {
1067
+ if ((params.action === "assign" || params.action === "cancel") && !manager) throw new Error("Delegation is not available on this connection.");
1068
+ if (params.action === "assign") {
1069
+ if (!params.assignments?.length) throw new Error("assign requires a non-empty assignments[] array");
1070
+ onUpdate?.(output(`Delegating ${params.assignments.length} task${params.assignments.length === 1 ? "" : "s"}...`));
1071
+ const items = await assignmentBatch(manager, params.assignments, signal);
1072
+ const assigned = items.filter((item) => item.ok).map((item) => item.id);
1073
+ const text = formatAssignmentResults(items);
1074
+ if (assigned.length === 0) throw new Error(text);
1075
+ return buildAssignmentResult(params, store.snapshot, text, {
1076
+ assigned,
1077
+ failed: items.length - assigned.length
1078
+ });
1079
+ }
1080
+ if (params.action === "cancel") {
1081
+ const outcome = await manager.cancel(params.id ?? NaN);
1082
+ if (!outcome.ok) throw new Error(outcome.message);
1083
+ return buildTextResult("cancel", params, store.snapshot, outcome.message);
1084
+ }
1085
+ return reducerAction(store, params.action, params, maxTasks);
1086
+ } catch (error) {
1087
+ return failure(error);
1088
+ }
1089
+ }
1062
1090
  function createHeadlessTaskTool(store, manager, maxTasks) {
1063
1091
  return {
1064
1092
  name: "task",
@@ -1067,33 +1095,7 @@ function createHeadlessTaskTool(store, manager, maxTasks) {
1067
1095
  parameters: TaskParamsSchema,
1068
1096
  promptSnippet: "Track complex work persistently and delegate ready tasks",
1069
1097
  executionMode: "serial",
1070
- async execute(_toolCallId, rawParams, signal, onUpdate) {
1071
- if (!(0, typebox_value.Check)(TaskParamsSchema, rawParams)) return failure("Invalid task parameters.");
1072
- const params = rawParams;
1073
- try {
1074
- if ((params.action === "assign" || params.action === "cancel") && !manager) throw new Error("Delegation is not available on this connection.");
1075
- if (params.action === "assign") {
1076
- if (!params.assignments?.length) throw new Error("assign requires a non-empty assignments[] array");
1077
- onUpdate?.(output(`Delegating ${params.assignments.length} task${params.assignments.length === 1 ? "" : "s"}...`));
1078
- const items = await assignmentBatch(manager, params.assignments, signal);
1079
- const assigned = items.filter((item) => item.ok).map((item) => item.id);
1080
- const text = formatAssignmentResults(items);
1081
- if (assigned.length === 0) throw new Error(text);
1082
- return buildAssignmentResult(params, store.snapshot, text, {
1083
- assigned,
1084
- failed: items.length - assigned.length
1085
- });
1086
- }
1087
- if (params.action === "cancel") {
1088
- const outcome = await manager.cancel(params.id ?? NaN);
1089
- if (!outcome.ok) throw new Error(outcome.message);
1090
- return buildTextResult("cancel", params, store.snapshot, outcome.message);
1091
- }
1092
- return reducerAction(store, params.action, params, maxTasks);
1093
- } catch (error) {
1094
- return failure(error);
1095
- }
1096
- }
1098
+ execute: (_toolCallId, rawParams, signal, onUpdate) => runTaskAction(store, manager, maxTasks, rawParams, signal, onUpdate)
1097
1099
  };
1098
1100
  }
1099
1101
  //#endregion