@astrosheep/keiyaku 4.5.7 → 4.5.8
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 +10 -0
- package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/opencode.js +3 -2
- package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +10 -9
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +22 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +35 -96
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +28 -49
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +21 -15
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +148 -89
- package/build/src/akuma/abort.d.ts +2 -1
- package/build/src/akuma/abort.js +6 -23
- package/build/src/akuma/akuma-handle.js +4 -2
- package/build/src/akuma/akuma-observe.d.ts +2 -0
- package/build/src/akuma/akuma-observe.js +1 -0
- package/build/src/akuma/akuma-product.js +9 -7
- package/build/src/akuma/akuma.d.ts +372 -9
- package/build/src/akuma/akuma.js +31 -1
- package/build/src/akuma/allowed.d.ts +1 -1
- package/build/src/akuma/allowed.js +1 -0
- package/build/src/akuma/body.d.ts +6 -4
- package/build/src/akuma/body.js +5 -3
- package/build/src/akuma/call-request.d.ts +80 -0
- package/build/src/akuma/call-request.js +211 -0
- package/build/src/akuma/heart/facts.d.ts +6 -78
- package/build/src/akuma/heart/index.d.ts +1 -1
- package/build/src/akuma/heart/request-authority.d.ts +5 -4
- package/build/src/akuma/heart/request-authority.js +20 -34
- package/build/src/akuma/heart/request-rows.js +12 -23
- package/build/src/akuma/heart/schema.d.ts +1 -1
- package/build/src/akuma/heart/schema.js +5 -13
- package/build/src/akuma/index.d.ts +1 -1
- package/build/src/akuma/index.js +1 -1
- package/build/src/akuma/projection-read.d.ts +1 -0
- package/build/src/akuma/projection-read.js +8 -1
- package/build/src/akuma/projection.d.ts +856 -137
- package/build/src/akuma/projection.js +190 -0
- package/build/src/akuma/provider.d.ts +30 -3
- package/build/src/akuma/provider.js +104 -0
- package/build/src/akuma/providers/acp/core.d.ts +2 -2
- package/build/src/akuma/providers/acp/core.js +13 -6
- package/build/src/akuma/providers/acp/index.js +5 -4
- package/build/src/akuma/providers/claude/index.d.ts +3 -3
- package/build/src/akuma/providers/claude/index.js +16 -5
- package/build/src/akuma/providers/codex-app-server/events.js +1 -1
- package/build/src/akuma/providers/codex-app-server/index.js +18 -6
- package/build/src/akuma/providers/grok-build/index.js +5 -4
- package/build/src/akuma/providers/opencode-sdk/index.js +66 -25
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +3 -2
- package/build/src/akuma/providers/opencode-sdk/session.js +28 -11
- package/build/src/akuma/providers/pi/index.js +42 -14
- package/build/src/akuma/request-lifecycle.d.ts +3 -9
- package/build/src/akuma/request-lifecycle.js +4 -4
- package/build/src/akuma/request-rendezvous.d.ts +26 -0
- package/build/src/akuma/request-rendezvous.js +100 -0
- package/build/src/akuma/request-serve.d.ts +5 -65
- package/build/src/akuma/request-serve.js +81 -208
- package/build/src/akuma/request-wire.d.ts +109 -115
- package/build/src/akuma/request-wire.js +63 -318
- package/build/src/akuma/requests.d.ts +19 -47
- package/build/src/akuma/requests.js +51 -107
- package/build/src/akuma/turn-drive.d.ts +5 -3
- package/build/src/akuma/turn-drive.js +32 -10
- package/build/src/akuma-body.d.ts +7 -2
- package/build/src/akuma-body.js +68 -46
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +2 -2
- package/build/src/cli/commands/akuma-invoke.d.ts +2 -0
- package/build/src/cli/commands/akuma-invoke.js +17 -9
- package/build/src/cli/commands/akuma.js +7 -7
- package/build/src/cli/commands/contract-invoke.d.ts +3 -2
- package/build/src/cli/commands/contract-invoke.js +26 -19
- package/build/src/cli/commands/contract.d.ts +13 -13
- package/build/src/cli/commands/contract.js +32 -17
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +1 -1
- package/build/src/cli/commands/task-invoke.d.ts +3 -0
- package/build/src/cli/commands/task-invoke.js +23 -140
- package/build/src/cli/commands/task.js +54 -20
- package/build/src/cli/invoke.js +39 -25
- package/build/src/cli/main.js +2 -1
- package/build/src/cli/parse.d.ts +2 -2
- package/build/src/cli/parse.js +37 -22
- package/build/src/cli/render/akuma-activity.d.ts +4 -1
- package/build/src/cli/render/akuma-activity.js +45 -30
- package/build/src/cli/render/akuma-tool.d.ts +5 -1
- package/build/src/cli/render/akuma.js +5 -9
- package/build/src/cli/render/audit.js +1 -1
- package/build/src/cli/render/catalog.js +80 -21
- package/build/src/cli/render/contract-observation.d.ts +2 -0
- package/build/src/cli/render/contract-observation.js +11 -0
- package/build/src/cli/render/contract.js +25 -65
- package/build/src/cli/render/kanshi-akuma.d.ts +8 -0
- package/build/src/cli/render/kanshi-akuma.js +111 -0
- package/build/src/cli/render/kanshi.js +108 -213
- package/build/src/cli/render/receipt.d.ts +1 -2
- package/build/src/cli/render/receipt.js +76 -26
- package/build/src/cli/render/refusal.js +2 -10
- package/build/src/cli/render/region.js +5 -2
- package/build/src/cli/render/settings.d.ts +1 -1
- package/build/src/cli/render/settings.js +27 -8
- package/build/src/cli/render/task.js +22 -5
- package/build/src/cli/render/terminal.d.ts +28 -0
- package/build/src/cli/render/terminal.js +65 -0
- package/build/src/cli/result.d.ts +3 -3
- package/build/src/cli/runtime.js +3 -1
- package/build/src/cli/selectors.d.ts +2 -1
- package/build/src/cli/selectors.js +4 -3
- package/build/src/cli/square-edge.js +120 -36
- package/build/src/cli/usage.js +2 -1
- package/build/src/contract-guidance.d.ts +5 -0
- package/build/src/contract-guidance.js +121 -0
- package/build/src/contract-worktree.d.ts +0 -1
- package/build/src/contract-worktree.js +32 -83
- package/build/src/coordination/sqlite-transaction-lock.d.ts +1 -0
- package/build/src/coordination/sqlite-transaction-lock.js +5 -0
- package/build/src/core/facts/codec.d.ts +2 -0
- package/build/src/core/facts/codec.js +4 -0
- package/build/src/core/verbs/placement.d.ts +6 -1
- package/build/src/core/verbs/placement.js +5 -3
- package/build/src/dispatch/index.d.ts +0 -2
- package/build/src/dispatch/index.js +54 -55
- package/build/src/git/admission.js +2 -2
- package/build/src/git/hooks.d.ts +9 -15
- package/build/src/git/hooks.js +23 -317
- package/build/src/git/nuke.d.ts +2 -1
- package/build/src/git/nuke.js +36 -18
- package/build/src/git/private-state-seat.d.ts +12 -0
- package/build/src/git/private-state-seat.js +39 -0
- package/build/src/git/process.d.ts +6 -0
- package/build/src/git/process.js +19 -7
- package/build/src/git/read-observation.js +29 -20
- package/build/src/git/reconcile.d.ts +11 -0
- package/build/src/git/reconcile.js +64 -11
- package/build/src/git/repository.d.ts +6 -2
- package/build/src/git/repository.js +8 -0
- package/build/src/git/target-placement.d.ts +1 -0
- package/build/src/git/target-placement.js +5 -0
- package/build/src/git/tender.d.ts +1 -0
- package/build/src/git/terminal-reconcile.d.ts +1 -1
- package/build/src/git/terminal-reconcile.js +22 -20
- package/build/src/git/workspace.d.ts +14 -0
- package/build/src/git/workspace.js +44 -0
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/read.js +16 -16
- package/build/src/kanshi/report.d.ts +2 -2
- package/build/src/library/address.d.ts +9 -3
- package/build/src/library/address.js +3 -2
- package/build/src/library/akuma-creation.d.ts +4 -3
- package/build/src/library/akuma-creation.js +19 -13
- package/build/src/library/audit.d.ts +1 -1
- package/build/src/library/audit.js +5 -3
- package/build/src/library/catalog.d.ts +3 -1
- package/build/src/library/catalog.js +20 -6
- package/build/src/library/composition.d.ts +371 -0
- package/build/src/library/composition.js +28 -0
- package/build/src/library/configuration.js +8 -2
- package/build/src/library/continuation.js +66 -30
- package/build/src/library/contract-bind.js +10 -2
- package/build/src/library/contract-forwarding-reconciliation-result.d.ts +96 -0
- package/build/src/library/contract-forwarding-reconciliation-result.js +83 -0
- package/build/src/library/contract-forwarding-result.d.ts +6723 -0
- package/build/src/library/contract-forwarding-result.js +521 -0
- package/build/src/library/contract-forwarding.d.ts +72 -0
- package/build/src/library/contract-forwarding.js +125 -0
- package/build/src/library/contract-handle.d.ts +36 -0
- package/build/src/library/contract-handle.js +313 -0
- package/build/src/library/contract-operations.d.ts +1044 -67
- package/build/src/library/contract-operations.js +190 -118
- package/build/src/library/contract.d.ts +11 -32
- package/build/src/library/contract.js +16 -289
- package/build/src/library/fleet-result.d.ts +1454 -0
- package/build/src/library/fleet-result.js +96 -0
- package/build/src/library/fleet.d.ts +112 -54
- package/build/src/library/fleet.js +211 -71
- package/build/src/library/input.d.ts +2 -0
- package/build/src/library/input.js +4 -0
- package/build/src/library/keiyaku.d.ts +371 -20
- package/build/src/library/keiyaku.js +8 -21
- package/build/src/library/mutation.d.ts +3 -3
- package/build/src/library/mutation.js +5 -9
- package/build/src/library/nuke.d.ts +1 -1
- package/build/src/library/nuke.js +4 -3
- package/build/src/library/reconcile.d.ts +4 -0
- package/build/src/library/reconcile.js +2 -0
- package/build/src/library/refusal.d.ts +0 -9
- package/build/src/library/refusal.js +0 -7
- package/build/src/protocol/amend.js +56 -50
- package/build/src/protocol/attempt.d.ts +2 -0
- package/build/src/protocol/attempt.js +8 -1
- package/build/src/protocol/completion.js +7 -0
- package/build/src/protocol/deliver.js +6 -2
- package/build/src/protocol/operations.d.ts +4 -1
- package/build/src/protocol/operations.js +5 -2
- package/build/src/protocol/placement.d.ts +1 -0
- package/build/src/protocol/placement.js +52 -38
- package/build/src/protocol/read/observation.d.ts +1 -4
- package/build/src/protocol/read/observation.js +2 -15
- package/build/src/protocol/reintegrate.js +62 -58
- package/build/src/protocol/review.js +5 -0
- package/build/src/protocol/run.js +17 -13
- package/build/src/runtime/proc/run.d.ts +8 -0
- package/build/src/runtime/proc/run.js +27 -0
- package/build/src/runtime/proc/termination.js +26 -22
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/holder.d.ts +2 -1
- package/build/src/settlement/holder.js +15 -4
- package/build/src/settlement/settle.js +99 -33
- package/build/src/task/board.d.ts +68 -27
- package/build/src/task/board.js +31 -1
- package/build/src/task/catalog.d.ts +4 -0
- package/build/src/task/catalog.js +23 -0
- package/build/src/task/compose-language.js +33 -7
- package/build/src/task/compose-parser.d.ts +1 -1
- package/build/src/task/compose-parser.js +1 -1
- package/build/src/task/compose.js +2 -0
- package/build/src/task/index.d.ts +12 -4
- package/build/src/task/index.js +97 -16
- package/build/src/task/mutation-result.d.ts +923 -0
- package/build/src/task/mutation-result.js +140 -0
- package/build/src/task/mutation.d.ts +552 -28
- package/build/src/task/mutation.js +304 -97
- package/build/src/task/operations.d.ts +1 -4
- package/build/src/task/operations.js +0 -6
- package/build/src/task/public.d.ts +2 -0
- package/build/src/task/public.js +1 -0
- package/build/src/workspace-place.d.ts +7 -2
- package/build/src/workspace-place.js +34 -24
- package/build/src/world.d.ts +1 -0
- package/build/src/world.js +11 -0
- package/package.json +8 -6
- package/build/src/akuma/request-execution.d.ts +0 -8
- package/build/src/akuma/request-execution.js +0 -98
|
@@ -70,8 +70,8 @@ function collectAliases(nodes, allocations, diagnostics) {
|
|
|
70
70
|
diagnostics.push(diagnostic(declaration.line, "only a new task may declare an alias", declaration.token));
|
|
71
71
|
continue;
|
|
72
72
|
}
|
|
73
|
-
if (declaration.operator !== "=" || !/^[
|
|
74
|
-
diagnostics.push(diagnostic(declaration.line, "alias must
|
|
73
|
+
if (declaration.operator !== "=" || !/^[^\s,]+$/u.test(declaration.value)) {
|
|
74
|
+
diagnostics.push(diagnostic(declaration.line, "alias must be a nonempty token without whitespace or comma", declaration.token));
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
77
77
|
if (aliases.has(declaration.value)) {
|
|
@@ -84,6 +84,33 @@ function collectAliases(nodes, allocations, diagnostics) {
|
|
|
84
84
|
}
|
|
85
85
|
return aliases;
|
|
86
86
|
}
|
|
87
|
+
function isTaskState(value) {
|
|
88
|
+
return value === "open" || value === "in_progress" || value === "on_hold" || value === "done" || value === "drop";
|
|
89
|
+
}
|
|
90
|
+
function applyStateAssignment(node, current, assignment, scalar, diagnostics) {
|
|
91
|
+
if (node.kind !== "new") {
|
|
92
|
+
diagnostics.push(diagnostic(assignment.line, "only a new task may declare an initial state", assignment.token));
|
|
93
|
+
return current;
|
|
94
|
+
}
|
|
95
|
+
if (scalar.has(assignment.field)) {
|
|
96
|
+
diagnostics.push(diagnostic(assignment.line, "state is assigned more than once", assignment.token));
|
|
97
|
+
return current;
|
|
98
|
+
}
|
|
99
|
+
scalar.add(assignment.field);
|
|
100
|
+
if (assignment.operator !== "=" || !isTaskState(assignment.value)) {
|
|
101
|
+
diagnostics.push(diagnostic(assignment.line, "state must use = with a valid persisted state", assignment.token));
|
|
102
|
+
return current;
|
|
103
|
+
}
|
|
104
|
+
return { ...current, state: assignment.value };
|
|
105
|
+
}
|
|
106
|
+
function markScalarAssignment(assignment, scalar, diagnostics) {
|
|
107
|
+
if (assignment.field !== "pri" && assignment.field !== "parent")
|
|
108
|
+
return;
|
|
109
|
+
if (scalar.has(assignment.field)) {
|
|
110
|
+
diagnostics.push(diagnostic(assignment.line, `${assignment.field} is assigned more than once`, assignment.token));
|
|
111
|
+
}
|
|
112
|
+
scalar.add(assignment.field);
|
|
113
|
+
}
|
|
87
114
|
function resolveReference(raw, line, board, aliases, diagnostics) {
|
|
88
115
|
if (raw.startsWith("^")) {
|
|
89
116
|
const alias = raw.slice(1);
|
|
@@ -142,12 +169,11 @@ function applyAssignments(node, base, board, aliases, diagnostics) {
|
|
|
142
169
|
for (const assignment of node.assignments) {
|
|
143
170
|
if (assignment.field === "as")
|
|
144
171
|
continue;
|
|
145
|
-
if (assignment.field === "
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
scalar.add(assignment.field);
|
|
172
|
+
if (assignment.field === "state") {
|
|
173
|
+
next = applyStateAssignment(node, next, assignment, scalar, diagnostics);
|
|
174
|
+
continue;
|
|
150
175
|
}
|
|
176
|
+
markScalarAssignment(assignment, scalar, diagnostics);
|
|
151
177
|
if (assignment.field === "pri") {
|
|
152
178
|
if (assignment.operator !== "=" || !/^[0-3]$/u.test(assignment.value)) {
|
|
153
179
|
diagnostics.push(diagnostic(assignment.line, "pri must use = with a value from 0 through 3", assignment.token));
|
|
@@ -2,7 +2,7 @@ import { type TaskId } from "./identity.js";
|
|
|
2
2
|
import type { TaskCompositionDiagnostic } from "./operations.js";
|
|
3
3
|
export type RelationField = "needs" | "supersedes" | "relates";
|
|
4
4
|
export type Assignment = Readonly<{
|
|
5
|
-
field: "as" | "parent" | "pri" | RelationField;
|
|
5
|
+
field: "as" | "state" | "parent" | "pri" | RelationField;
|
|
6
6
|
operator: "=" | "+=" | "-=";
|
|
7
7
|
value: string;
|
|
8
8
|
line: number;
|
|
@@ -39,7 +39,7 @@ function parseNamespace(value) {
|
|
|
39
39
|
return parseTaskId(`task/${value}/placeholder`).namespace;
|
|
40
40
|
}
|
|
41
41
|
function parseAssignment(text, line) {
|
|
42
|
-
const matched = /^(as|parent|pri|needs|supersedes|relates)\s*(=|\+=|-=)\s*(.*)$/u.exec(text);
|
|
42
|
+
const matched = /^(as|state|parent|pri|needs|supersedes|relates)\s*(=|\+=|-=)\s*(.*)$/u.exec(text);
|
|
43
43
|
if (matched === null)
|
|
44
44
|
return null;
|
|
45
45
|
return {
|
|
@@ -32,6 +32,8 @@ function taskDraft(task, remainingAliases) {
|
|
|
32
32
|
const lines = [task.kind === "new" ? `+ ${document.title}` : `@${document.id}`];
|
|
33
33
|
if (task.kind === "new" && task.alias !== undefined)
|
|
34
34
|
lines.push(`as = ${task.alias}`);
|
|
35
|
+
if (task.kind === "new")
|
|
36
|
+
lines.push(`state = ${document.state}`);
|
|
35
37
|
lines.push(`pri = ${document.priority}`, `needs = ${document.needs.map((id) => reference(id, remainingAliases)).join(", ")}`, `parent = ${document.parent === null ? "" : reference(document.parent, remainingAliases)}`, `supersedes = ${document.supersedes.map((id) => reference(id, remainingAliases)).join(", ")}`, `relates = ${document.relates.map((id) => reference(id, remainingAliases)).join(", ")}`);
|
|
36
38
|
if (document.body === "")
|
|
37
39
|
lines.push("body =");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WorldRoot } from "../world.js";
|
|
2
|
+
import { type ExecutionContext, type LibraryExecution } from "../akuma/requests.js";
|
|
2
3
|
export type { WorldRoot } from "../world.js";
|
|
3
4
|
import { type BlockedTaskRow, type TaskDetailFacts, type TaskDoctorIssue, type TaskRef, type TaskRow, type TaskTreeNode } from "./board.js";
|
|
4
5
|
import { type TaskCompositionAlias, type TaskCompositionBodyPreview, type TaskCompositionResult } from "./compose.js";
|
|
@@ -23,11 +24,13 @@ export type TaskDoctorReport = Readonly<{
|
|
|
23
24
|
}>;
|
|
24
25
|
export type TaskDecompositionTree = TaskOutcome<TaskTreeNode>;
|
|
25
26
|
export type { AddTaskDocumentInput, AddTaskInput, BlockedTaskRow, TaskBatchResult, TaskCompositionDiagnostic, TaskCompositionAlias, TaskCompositionBodyPreview, TaskCompositionResult, TaskDoctorIssue, TaskId, TaskMutationResult, TaskOutcome, TaskPriority, TaskRef, TaskRefusal, TaskRetry, TaskRow, TaskState, TaskTreeNode, TaskUpdateResult, TaskView, UpdateTaskInput, TaskPage, TaskQueryExpression, TaskQueryPredicate, TaskQueryRow, TaskQuerySort, TaskRelationPredicateField, };
|
|
27
|
+
export type { LibraryExecution } from "../akuma/requests.js";
|
|
26
28
|
export { TaskAuthorityCorruptionError, TASK_RELATION_PREDICATE_FIELDS };
|
|
27
29
|
declare class TaskHandle {
|
|
28
30
|
readonly id: TaskId;
|
|
29
31
|
private readonly world;
|
|
30
|
-
|
|
32
|
+
private readonly execution;
|
|
33
|
+
constructor(id: TaskId, world: WorldRoot, execution: ExecutionContext);
|
|
31
34
|
read(): Promise<TaskDetail | null>;
|
|
32
35
|
tree(): Promise<TaskDecompositionTree>;
|
|
33
36
|
update(input: UpdateTaskInput): Promise<TaskUpdateResult>;
|
|
@@ -56,8 +59,9 @@ declare class TaskHandle {
|
|
|
56
59
|
export type Task = TaskHandle;
|
|
57
60
|
declare class TasksHandle {
|
|
58
61
|
private readonly world;
|
|
62
|
+
private readonly execution;
|
|
59
63
|
readonly root: WorldRoot;
|
|
60
|
-
constructor(world: WorldRoot);
|
|
64
|
+
constructor(world: WorldRoot, execution: ExecutionContext);
|
|
61
65
|
task(input: Readonly<{
|
|
62
66
|
id: string;
|
|
63
67
|
}>): Task;
|
|
@@ -90,7 +94,7 @@ declare class TasksHandle {
|
|
|
90
94
|
}>): Promise<TaskQueryResult>;
|
|
91
95
|
doctor(): Promise<TaskDoctorReport>;
|
|
92
96
|
batch(input: Readonly<{
|
|
93
|
-
verb: "done" | "drop" | "hold";
|
|
97
|
+
verb: "start" | "done" | "drop" | "hold";
|
|
94
98
|
ids: readonly string[];
|
|
95
99
|
note?: string;
|
|
96
100
|
signal?: AbortSignal;
|
|
@@ -104,6 +108,10 @@ declare class TasksHandle {
|
|
|
104
108
|
}>): Promise<TaskCompositionResult>;
|
|
105
109
|
}
|
|
106
110
|
export type Tasks = TasksHandle;
|
|
111
|
+
export declare function tasksForExecution(world: WorldRoot, execution: ExecutionContext): Tasks;
|
|
112
|
+
type TasksOfInput = Readonly<{
|
|
113
|
+
execution?: LibraryExecution;
|
|
114
|
+
}>;
|
|
107
115
|
export declare const Tasks: Readonly<{
|
|
108
|
-
of(world: WorldRoot): Tasks;
|
|
116
|
+
of(world: WorldRoot, input?: TasksOfInput): Tasks;
|
|
109
117
|
}>;
|
package/build/src/task/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { executionChannel, libraryExecution, localExecutionContext, } from "../akuma/requests.js";
|
|
2
|
+
import { requestForwardedTask } from "./mutation.js";
|
|
1
3
|
import { buildTree, createTaskRelations, diagnoseBoard, projectDetailFacts, } from "./board.js";
|
|
2
4
|
import { composeTasks, } from "./compose.js";
|
|
3
5
|
import { TaskAuthorityCorruptionError } from "./document.js";
|
|
@@ -6,12 +8,22 @@ import { readBoard } from "./store.js";
|
|
|
6
8
|
import { actor, addInput, closed, limit, namespace, record, signal, sort, taskId as id, taskIds, text, updateInput, } from "./input.js";
|
|
7
9
|
import { normalizeTaskQuery, TASK_RELATION_PREDICATE_FIELDS, DEFAULT_TASK_LIMIT, } from "./query.js";
|
|
8
10
|
export { TaskAuthorityCorruptionError, TASK_RELATION_PREDICATE_FIELDS };
|
|
11
|
+
function forwardTask(directory, world, request, signal) {
|
|
12
|
+
return requestForwardedTask({
|
|
13
|
+
directory,
|
|
14
|
+
world,
|
|
15
|
+
request,
|
|
16
|
+
...(signal === undefined ? {} : { signal }),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
9
19
|
class TaskHandle {
|
|
10
20
|
id;
|
|
11
21
|
world;
|
|
12
|
-
|
|
22
|
+
execution;
|
|
23
|
+
constructor(id, world, execution) {
|
|
13
24
|
this.id = id;
|
|
14
25
|
this.world = world;
|
|
26
|
+
this.execution = execution;
|
|
15
27
|
}
|
|
16
28
|
async read() {
|
|
17
29
|
const board = (await readBoard(this.world)).board;
|
|
@@ -28,13 +40,37 @@ class TaskHandle {
|
|
|
28
40
|
: { kind: "accepted", value: node };
|
|
29
41
|
}
|
|
30
42
|
update(input) {
|
|
31
|
-
|
|
43
|
+
const values = updateInput(input);
|
|
44
|
+
const { signal: abort, ...request } = values;
|
|
45
|
+
const channel = executionChannel(this.execution);
|
|
46
|
+
if (channel.kind === "body-request") {
|
|
47
|
+
return forwardTask(channel.directory, this.world, { action: "task.update", id: this.id, input: request }, abort);
|
|
48
|
+
}
|
|
49
|
+
return updateTask(this.world, this.id, values);
|
|
32
50
|
}
|
|
33
51
|
lifecycle(verb, input) {
|
|
34
52
|
const value = record(input ?? {}, `${verb} input`);
|
|
35
53
|
closed(value, verb === "drop" || verb === "done" ? ["note", "signal"] : ["signal"], `${verb} input`);
|
|
36
54
|
const note = verb === "drop" || verb === "done" ? text(value.note, "note") : undefined;
|
|
37
|
-
|
|
55
|
+
const abort = signal(value.signal);
|
|
56
|
+
const channel = executionChannel(this.execution);
|
|
57
|
+
if (channel.kind === "body-request") {
|
|
58
|
+
switch (verb) {
|
|
59
|
+
case "start":
|
|
60
|
+
return forwardTask(channel.directory, this.world, { action: "task.start", id: this.id }, abort);
|
|
61
|
+
case "stop":
|
|
62
|
+
return forwardTask(channel.directory, this.world, { action: "task.stop", id: this.id }, abort);
|
|
63
|
+
case "hold":
|
|
64
|
+
return forwardTask(channel.directory, this.world, { action: "task.hold", id: this.id }, abort);
|
|
65
|
+
case "resume":
|
|
66
|
+
return forwardTask(channel.directory, this.world, { action: "task.resume", id: this.id }, abort);
|
|
67
|
+
case "done":
|
|
68
|
+
return forwardTask(channel.directory, this.world, { action: "task.done", id: this.id, ...(note === undefined ? {} : { note }) }, abort);
|
|
69
|
+
case "drop":
|
|
70
|
+
return forwardTask(channel.directory, this.world, { action: "task.drop", id: this.id, ...(note === undefined ? {} : { note }) }, abort);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return lifecycleTask(this.world, this.id, verb, abort, note);
|
|
38
74
|
}
|
|
39
75
|
start(input) {
|
|
40
76
|
return this.lifecycle("start", input);
|
|
@@ -57,18 +93,26 @@ class TaskHandle {
|
|
|
57
93
|
}
|
|
58
94
|
class TasksHandle {
|
|
59
95
|
world;
|
|
96
|
+
execution;
|
|
60
97
|
root;
|
|
61
|
-
constructor(world) {
|
|
98
|
+
constructor(world, execution) {
|
|
62
99
|
this.world = world;
|
|
100
|
+
this.execution = execution;
|
|
63
101
|
this.root = world;
|
|
64
102
|
}
|
|
65
103
|
task(input) {
|
|
66
104
|
const v = record(input, "task input");
|
|
67
105
|
closed(v, ["id"], "task input");
|
|
68
|
-
return new TaskHandle(id(v.id), this.world);
|
|
106
|
+
return new TaskHandle(id(v.id), this.world, this.execution);
|
|
69
107
|
}
|
|
70
108
|
add(input) {
|
|
71
|
-
|
|
109
|
+
const values = addInput(input);
|
|
110
|
+
const { actor: _actor, signal: abort, namespace: selected, ...request } = values;
|
|
111
|
+
const channel = executionChannel(this.execution);
|
|
112
|
+
if (channel.kind === "body-request") {
|
|
113
|
+
return forwardTask(channel.directory, this.world, { action: "task.add", input: { ...request, namespace: selected ?? [] } }, abort);
|
|
114
|
+
}
|
|
115
|
+
return addTask(this.world, values);
|
|
72
116
|
}
|
|
73
117
|
addDocument(input) {
|
|
74
118
|
const v = record(input, "addDocument input");
|
|
@@ -77,12 +121,17 @@ class TasksHandle {
|
|
|
77
121
|
if (markdown === undefined)
|
|
78
122
|
throw new TypeError("markdown is required");
|
|
79
123
|
const ns = namespace(v.namespace), createdBy = actor(v.actor), abort = signal(v.signal);
|
|
80
|
-
|
|
124
|
+
const local = {
|
|
81
125
|
markdown,
|
|
82
126
|
...(ns === undefined ? {} : { namespace: ns }),
|
|
83
127
|
...(createdBy === undefined ? {} : { actor: createdBy }),
|
|
84
128
|
...(abort === undefined ? {} : { signal: abort }),
|
|
85
|
-
}
|
|
129
|
+
};
|
|
130
|
+
const channel = executionChannel(this.execution);
|
|
131
|
+
if (channel.kind === "body-request") {
|
|
132
|
+
return forwardTask(channel.directory, this.world, { action: "task.addDocument", input: { markdown, namespace: ns ?? [] } }, abort);
|
|
133
|
+
}
|
|
134
|
+
return addTaskDocument(this.world, local);
|
|
86
135
|
}
|
|
87
136
|
async list(input = {}) {
|
|
88
137
|
const v = record(input, "list input");
|
|
@@ -140,12 +189,29 @@ class TasksHandle {
|
|
|
140
189
|
const v = record(input, "batch input");
|
|
141
190
|
closed(v, ["verb", "ids", "note", "signal"], "batch input");
|
|
142
191
|
const verb = v.verb;
|
|
143
|
-
if (verb !== "done" && verb !== "drop" && verb !== "hold")
|
|
192
|
+
if (verb !== "start" && verb !== "done" && verb !== "drop" && verb !== "hold")
|
|
144
193
|
throw new TypeError("batch verb is invalid");
|
|
194
|
+
const ids = taskIds(v.ids, "ids");
|
|
195
|
+
if (ids === undefined || ids.length === 0)
|
|
196
|
+
throw new TypeError("ids requires at least one TaskId");
|
|
145
197
|
const note = text(v.note, "note");
|
|
146
198
|
if (note !== undefined && verb !== "done" && verb !== "drop")
|
|
147
199
|
throw new TypeError("batch note is valid only for done or drop");
|
|
148
|
-
|
|
200
|
+
const abort = signal(v.signal);
|
|
201
|
+
const channel = executionChannel(this.execution);
|
|
202
|
+
if (channel.kind === "body-request") {
|
|
203
|
+
switch (verb) {
|
|
204
|
+
case "start":
|
|
205
|
+
return forwardTask(channel.directory, this.world, { action: "task.start", ids }, abort);
|
|
206
|
+
case "hold":
|
|
207
|
+
return forwardTask(channel.directory, this.world, { action: "task.hold", ids }, abort);
|
|
208
|
+
case "done":
|
|
209
|
+
return forwardTask(channel.directory, this.world, { action: "task.done", ids, ...(note === undefined ? {} : { note }) }, abort);
|
|
210
|
+
case "drop":
|
|
211
|
+
return forwardTask(channel.directory, this.world, { action: "task.drop", ids, ...(note === undefined ? {} : { note }) }, abort);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return batchTasks(this.world, verb, ids, abort, note);
|
|
149
215
|
}
|
|
150
216
|
compose(input) {
|
|
151
217
|
const v = record(input, "compose input");
|
|
@@ -158,20 +224,35 @@ class TasksHandle {
|
|
|
158
224
|
const selected = namespace(v.namespace);
|
|
159
225
|
const selectedSignal = signal(v.signal);
|
|
160
226
|
const selectedActor = actor(v.actor);
|
|
161
|
-
|
|
227
|
+
const local = {
|
|
162
228
|
world: this.world,
|
|
163
229
|
markdown,
|
|
164
230
|
...(selectedSignal === undefined ? {} : { signal: selectedSignal }),
|
|
165
231
|
...(selectedActor === undefined ? {} : { actor: selectedActor }),
|
|
166
232
|
...(selected === undefined ? {} : { defaultNamespace: selected }),
|
|
167
233
|
planOnly: v.plan === true,
|
|
168
|
-
}
|
|
234
|
+
};
|
|
235
|
+
const channel = executionChannel(this.execution);
|
|
236
|
+
if (channel.kind === "body-request" && v.plan !== true) {
|
|
237
|
+
return forwardTask(channel.directory, this.world, { action: "task.compose", markdown, namespace: selected ?? [] }, selectedSignal);
|
|
238
|
+
}
|
|
239
|
+
return composeTasks(local);
|
|
169
240
|
}
|
|
170
241
|
}
|
|
242
|
+
export function tasksForExecution(world, execution) {
|
|
243
|
+
if (typeof world !== "string")
|
|
244
|
+
throw new TypeError("Tasks.of world must be a WorldRoot");
|
|
245
|
+
return new TasksHandle(world, execution);
|
|
246
|
+
}
|
|
247
|
+
function tasksOfExecution(input) {
|
|
248
|
+
if (input === undefined)
|
|
249
|
+
return localExecutionContext();
|
|
250
|
+
const values = record(input, "Tasks.of input");
|
|
251
|
+
closed(values, ["execution"], "Tasks.of input");
|
|
252
|
+
return values.execution === undefined ? localExecutionContext() : libraryExecution(values.execution);
|
|
253
|
+
}
|
|
171
254
|
export const Tasks = Object.freeze({
|
|
172
|
-
of(world) {
|
|
173
|
-
|
|
174
|
-
throw new TypeError("Tasks.of world must be a WorldRoot");
|
|
175
|
-
return new TasksHandle(world);
|
|
255
|
+
of(world, input) {
|
|
256
|
+
return tasksForExecution(world, tasksOfExecution(input));
|
|
176
257
|
},
|
|
177
258
|
});
|