@deliverd/sdk 0.11.0 → 0.12.0
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 +39 -0
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +398 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +13 -0
- package/dist/released.d.ts +1 -1
- package/dist/released.d.ts.map +1 -1
- package/dist/released.js +1262 -0
- package/dist/tasks.d.ts +95 -0
- package/dist/tasks.d.ts.map +1 -0
- package/dist/tasks.js +254 -0
- package/dist/types.d.ts +341 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dev.ts +407 -1
- package/src/index.ts +4 -0
- package/src/messages.ts +13 -0
- package/src/released.ts +1262 -0
- package/src/tasks.ts +312 -0
- package/src/types.ts +398 -1
package/README.md
CHANGED
|
@@ -253,6 +253,45 @@ await deliverd.flows.get(id);
|
|
|
253
253
|
`allSettled` is a fact about this moment, not a verdict. You may be about to
|
|
254
254
|
add the next step, so nothing closes a flow but you.
|
|
255
255
|
|
|
256
|
+
## Tasks
|
|
257
|
+
|
|
258
|
+
An agent deep in a debugging session forgets what it set out to do, because
|
|
259
|
+
the objective is a paragraph thousands of tokens back. A task keeps it
|
|
260
|
+
somewhere the agent can ask for, and a side task keeps a detour from taking
|
|
261
|
+
over the thread.
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
const task = await deliverd.tasks.create({
|
|
265
|
+
title: "Ship SSO",
|
|
266
|
+
objective: "Customers can sign in with their own identity provider.",
|
|
267
|
+
externalId: "sso_rollout", // a restart resumes this one
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const side = await task.createSideTask({
|
|
271
|
+
title: "Token audience",
|
|
272
|
+
goal: "Find why the API refuses the access token.",
|
|
273
|
+
kind: "debug",
|
|
274
|
+
});
|
|
275
|
+
await side.addFinding({ kind: "evidence", title: "aud is the SPA client id" });
|
|
276
|
+
await side.complete({
|
|
277
|
+
summary: "The token is issued for the wrong audience.",
|
|
278
|
+
suggestedNextAction: "Request the token for the API audience.",
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
const { context } = await side.apply(); // the result, carried into the parent
|
|
282
|
+
context.rootObjective // said first, always
|
|
283
|
+
context.reanchor // one paragraph to say back to yourself
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
`task.context()` is what to read instead of the history: the objective, where
|
|
287
|
+
this task stands, what is settled, what is still open. `task.graph()` is the
|
|
288
|
+
whole tree. `deliverd.tasks.list({ status: "active" })` lists objectives; side
|
|
289
|
+
tasks are reached through the one they belong to.
|
|
290
|
+
|
|
291
|
+
A finding of kind `decision` is a suggestion until a person confirms it.
|
|
292
|
+
`task.requestDecisionApproval(findingId)` puts it to somebody. Only a person
|
|
293
|
+
changes what a task is for; an agent proposes that as a finding too.
|
|
294
|
+
|
|
256
295
|
## Evidence
|
|
257
296
|
|
|
258
297
|
Show your working. One call assembles the whole record of a piece of work —
|
package/dist/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAWb,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE7F,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,kBAAkB,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,kBAAkB,CAAC,CAAC;IAC/E,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAcD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,UAAU,CAAC,KAAK,CAykB1F"}
|
package/dist/dev.js
CHANGED
|
@@ -13,6 +13,7 @@ export function developmentFetch(options = {}) {
|
|
|
13
13
|
const gateStore = new Map();
|
|
14
14
|
const collectionStore = new Map();
|
|
15
15
|
const flowStore = new Map();
|
|
16
|
+
const tasks = developmentTasks(options);
|
|
16
17
|
return (async (input, init) => {
|
|
17
18
|
const url = new URL(String(input));
|
|
18
19
|
const path = url.pathname.replace(/^\/api\/v1/, "");
|
|
@@ -520,10 +521,31 @@ export function developmentFetch(options = {}) {
|
|
|
520
521
|
const all = [...flowStore.values()];
|
|
521
522
|
return json({ flows: externalId ? all.filter((f) => f.externalId === externalId) : all });
|
|
522
523
|
}
|
|
524
|
+
/*
|
|
525
|
+
* Task Graph in development: real objects with no simulation attached,
|
|
526
|
+
* the same reasoning as flows. Nothing here is decided by anybody, so
|
|
527
|
+
* there is nobody to imagine — what is worth running offline is the loop
|
|
528
|
+
* itself: start an objective, branch a side task, complete it, apply it,
|
|
529
|
+
* and read the context the parent comes back with. Putting a decision to
|
|
530
|
+
* an approval is the one call left to the real API, because the approval
|
|
531
|
+
* it raises lives in a store this simulation does not join to.
|
|
532
|
+
*/
|
|
533
|
+
if (method === "POST" && path === "/tasks") {
|
|
534
|
+
const { task, resumed } = tasks.create(body);
|
|
535
|
+
return json({ ...task, resumed }, resumed ? 200 : 201);
|
|
536
|
+
}
|
|
537
|
+
if (method === "GET" && path === "/tasks") {
|
|
538
|
+
return json({ tasks: tasks.list(url.searchParams), nextCursor: null });
|
|
539
|
+
}
|
|
540
|
+
const taskMatch = /^\/tasks\/([^/]+)(?:\/(context|graph|side-tasks|findings|complete|apply|reopen|cancel|links))?$/.exec(path);
|
|
541
|
+
if (taskMatch) {
|
|
542
|
+
const [status, payload] = tasks.act(method, taskMatch[1], taskMatch[2] ?? null, body);
|
|
543
|
+
return json(payload, status);
|
|
544
|
+
}
|
|
523
545
|
return json({
|
|
524
546
|
error: {
|
|
525
547
|
code: "not_in_development_mode",
|
|
526
|
-
message: `Development mode simulates approvals, reviews and
|
|
548
|
+
message: `Development mode simulates approvals, reviews, collections, flows and tasks only, and something called ${method} ${path}. Use a real API key for the rest of the API.`,
|
|
527
549
|
},
|
|
528
550
|
}, 501);
|
|
529
551
|
});
|
|
@@ -714,3 +736,378 @@ function announceCollection(data, outcome) {
|
|
|
714
736
|
];
|
|
715
737
|
console.log(lines.join("\n"));
|
|
716
738
|
}
|
|
739
|
+
const notFound = (what) => [
|
|
740
|
+
404,
|
|
741
|
+
{ error: { code: "not_found", message: `No such ${what} in this development session.` } },
|
|
742
|
+
];
|
|
743
|
+
const refused = (code, message, status = 409) => [
|
|
744
|
+
status,
|
|
745
|
+
{ error: { code, message } },
|
|
746
|
+
];
|
|
747
|
+
function strings(value) {
|
|
748
|
+
return Array.isArray(value) ? value.filter((v) => typeof v === "string" && v.trim() !== "") : [];
|
|
749
|
+
}
|
|
750
|
+
function mergeState(current, patch) {
|
|
751
|
+
if (!patch)
|
|
752
|
+
return current;
|
|
753
|
+
const next = { ...current };
|
|
754
|
+
if ("currentState" in patch)
|
|
755
|
+
next.currentState = patch.currentState ?? null;
|
|
756
|
+
if ("nextAction" in patch)
|
|
757
|
+
next.nextAction = patch.nextAction ?? null;
|
|
758
|
+
if (patch.openQuestions)
|
|
759
|
+
next.openQuestions = strings(patch.openQuestions);
|
|
760
|
+
if (patch.constraints)
|
|
761
|
+
next.constraints = strings(patch.constraints);
|
|
762
|
+
if (patch.blockedBy)
|
|
763
|
+
next.blockedBy = strings(patch.blockedBy);
|
|
764
|
+
for (const q of strings(patch.addOpenQuestions)) {
|
|
765
|
+
if (!next.openQuestions.includes(q))
|
|
766
|
+
next.openQuestions = [...next.openQuestions, q];
|
|
767
|
+
}
|
|
768
|
+
const gone = new Set(strings(patch.resolveOpenQuestions).map((q) => q.toLowerCase()));
|
|
769
|
+
if (gone.size)
|
|
770
|
+
next.openQuestions = next.openQuestions.filter((q) => !gone.has(q.toLowerCase()));
|
|
771
|
+
return next;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* The Task Graph, in memory: enough of the server's rules that the loop an
|
|
775
|
+
* agent actually runs — objective, side task, result, apply, context — does
|
|
776
|
+
* offline what it does live. Not the whole service: no workspaces, no
|
|
777
|
+
* permissions, no audit, and a context assembled from what this store holds.
|
|
778
|
+
*/
|
|
779
|
+
function developmentTasks(options) {
|
|
780
|
+
const store = new Map();
|
|
781
|
+
const findings = new Map();
|
|
782
|
+
const links = [];
|
|
783
|
+
const active = (t) => t.status !== "completed" && t.status !== "cancelled";
|
|
784
|
+
const childrenOf = (id) => [...store.values()].filter((t) => t.parentTaskId === id);
|
|
785
|
+
const node = (t) => ({
|
|
786
|
+
id: t.id,
|
|
787
|
+
parentTaskId: t.parentTaskId,
|
|
788
|
+
kind: t.kind,
|
|
789
|
+
depth: t.depth,
|
|
790
|
+
status: t.status,
|
|
791
|
+
title: t.title,
|
|
792
|
+
outcome: t.outcome,
|
|
793
|
+
resultSummary: t.result?.summary ?? null,
|
|
794
|
+
url: t.url,
|
|
795
|
+
});
|
|
796
|
+
const pathTo = (t) => {
|
|
797
|
+
const path = [];
|
|
798
|
+
for (let at = t; at; at = at.parentTaskId ? store.get(at.parentTaskId) : undefined) {
|
|
799
|
+
path.unshift({ id: at.id, title: at.title, kind: at.kind });
|
|
800
|
+
}
|
|
801
|
+
return path;
|
|
802
|
+
};
|
|
803
|
+
const bump = (t) => {
|
|
804
|
+
t.version += 1;
|
|
805
|
+
t.updatedAt = new Date().toISOString();
|
|
806
|
+
};
|
|
807
|
+
const listed = (t) => {
|
|
808
|
+
const { sideTasks: _counts, path: _path, children: _children, findings: _findings, links: _links, resumed: _resumed, ...rest } = t;
|
|
809
|
+
return rest;
|
|
810
|
+
};
|
|
811
|
+
function make(body, parent) {
|
|
812
|
+
const id = `tsk_dev_${++counter}`;
|
|
813
|
+
const now = new Date().toISOString();
|
|
814
|
+
const parentDecisions = parent
|
|
815
|
+
? (findings.get(parent.id) ?? []).filter((f) => f.kind === "decision" && f.decisionStatus !== "rejected")
|
|
816
|
+
: [];
|
|
817
|
+
return {
|
|
818
|
+
id,
|
|
819
|
+
kind: parent ? (body.kind ?? "side_task") : "objective",
|
|
820
|
+
status: "open",
|
|
821
|
+
url: `https://deliverd.dev/tasks/${id}`,
|
|
822
|
+
title: String(body.title ?? "Untitled"),
|
|
823
|
+
objective: String((parent ? body.goal : body.objective) ?? ""),
|
|
824
|
+
rootTaskId: parent ? parent.rootTaskId : id,
|
|
825
|
+
parentTaskId: parent ? parent.id : null,
|
|
826
|
+
depth: parent ? parent.depth + 1 : 0,
|
|
827
|
+
workspaceId: parent ? parent.workspaceId : (body.workspaceId ?? null),
|
|
828
|
+
flowId: parent ? parent.flowId : (body.flowId ?? null),
|
|
829
|
+
state: mergeState({ currentState: null, openQuestions: [], constraints: [], blockedBy: [], nextAction: null }, body.state),
|
|
830
|
+
snapshot: parent
|
|
831
|
+
? {
|
|
832
|
+
rootObjective: store.get(parent.rootTaskId)?.objective ?? parent.objective,
|
|
833
|
+
parentObjective: parent.objective,
|
|
834
|
+
sideTaskGoal: String(body.goal ?? ""),
|
|
835
|
+
relevantContext: body.relevantContext
|
|
836
|
+
? strings(body.relevantContext)
|
|
837
|
+
: parent.state.currentState
|
|
838
|
+
? [parent.state.currentState]
|
|
839
|
+
: [],
|
|
840
|
+
knownConstraints: body.knownConstraints ? strings(body.knownConstraints) : parent.state.constraints,
|
|
841
|
+
relatedDecisions: parentDecisions.map((d) => d.decisionStatus === "confirmed" ? d.title : `${d.title} (suggested)`),
|
|
842
|
+
resolvesQuestion: body.resolvesQuestion ?? null,
|
|
843
|
+
}
|
|
844
|
+
: null,
|
|
845
|
+
result: null,
|
|
846
|
+
previousResults: [],
|
|
847
|
+
outcome: null,
|
|
848
|
+
origin: body.origin ?? "manual",
|
|
849
|
+
externalId: parent ? null : (body.externalId ?? null),
|
|
850
|
+
sessionUrl: body.sessionUrl ?? null,
|
|
851
|
+
version: 1,
|
|
852
|
+
startedBy: "You (development mode)",
|
|
853
|
+
createdAt: now,
|
|
854
|
+
updatedAt: now,
|
|
855
|
+
completedAt: null,
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
function context(t) {
|
|
859
|
+
const root = store.get(t.rootTaskId) ?? t;
|
|
860
|
+
const isSideTask = t.kind !== "objective";
|
|
861
|
+
const own = findings.get(t.id) ?? [];
|
|
862
|
+
const decisions = [...(t.id === root.id ? [] : (findings.get(root.id) ?? [])), ...own].filter((f) => f.kind === "decision");
|
|
863
|
+
const children = childrenOf(t.id);
|
|
864
|
+
const finished = children.filter((c) => c.status === "completed");
|
|
865
|
+
const awaiting = finished.filter((c) => c.outcome === null);
|
|
866
|
+
const next = t.state.nextAction ?? (isSideTask ? null : root.state.nextAction);
|
|
867
|
+
return {
|
|
868
|
+
rootObjective: root.objective,
|
|
869
|
+
task: { id: t.id, kind: t.kind, title: t.title, objective: t.objective, status: t.status, isSideTask },
|
|
870
|
+
path: pathTo(t),
|
|
871
|
+
currentState: t.state.currentState,
|
|
872
|
+
nextAction: next,
|
|
873
|
+
openQuestions: t.state.openQuestions,
|
|
874
|
+
constraints: t.state.constraints.length ? t.state.constraints : (t.snapshot?.knownConstraints ?? []),
|
|
875
|
+
blockedBy: t.state.blockedBy,
|
|
876
|
+
decisions: {
|
|
877
|
+
confirmed: decisions.filter((d) => d.decisionStatus === "confirmed").map((d) => d.title),
|
|
878
|
+
suggested: decisions.filter((d) => d.decisionStatus === "suggested").map((d) => d.title),
|
|
879
|
+
},
|
|
880
|
+
snapshot: t.snapshot,
|
|
881
|
+
relevantFindings: own
|
|
882
|
+
.filter((f) => f.kind !== "decision")
|
|
883
|
+
.slice(0, 12)
|
|
884
|
+
.map((f) => ({ kind: f.kind, title: f.title, body: f.body })),
|
|
885
|
+
sideTasks: {
|
|
886
|
+
active: children.filter(active).map((c) => ({ id: c.id, title: c.title, kind: c.kind, status: c.status })),
|
|
887
|
+
awaitingOutcome: awaiting.map((c) => ({ id: c.id, title: c.title, summary: c.result?.summary ?? null })),
|
|
888
|
+
completed: finished
|
|
889
|
+
.filter((c) => c.outcome !== null)
|
|
890
|
+
.map((c) => ({ id: c.id, title: c.title, summary: c.result?.summary ?? null, outcome: c.outcome })),
|
|
891
|
+
},
|
|
892
|
+
reanchor: [
|
|
893
|
+
`Objective: ${root.objective}`,
|
|
894
|
+
isSideTask ? `You are in a side task: ${t.title}. Its goal: ${t.objective}` : null,
|
|
895
|
+
t.state.currentState ? `Where it stands: ${t.state.currentState}` : null,
|
|
896
|
+
next ? `Next: ${next}` : null,
|
|
897
|
+
]
|
|
898
|
+
.filter(Boolean)
|
|
899
|
+
.join("\n"),
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
function addFinding(t, body, sourceTaskId = null) {
|
|
903
|
+
const kind = body.kind ?? "finding";
|
|
904
|
+
const finding = {
|
|
905
|
+
id: `fnd_dev_${++counter}`,
|
|
906
|
+
taskId: t.id,
|
|
907
|
+
kind,
|
|
908
|
+
title: String(body.title ?? "Untitled"),
|
|
909
|
+
body: String(body.body ?? ""),
|
|
910
|
+
evidence: strings(body.evidence),
|
|
911
|
+
decisionStatus: kind === "decision" ? "suggested" : null,
|
|
912
|
+
decidedBy: null,
|
|
913
|
+
decidedAt: null,
|
|
914
|
+
approvalId: null,
|
|
915
|
+
approvalStatus: null,
|
|
916
|
+
sourceTaskId,
|
|
917
|
+
createdBy: "You (development mode)",
|
|
918
|
+
createdAt: new Date().toISOString(),
|
|
919
|
+
};
|
|
920
|
+
findings.set(t.id, [finding, ...(findings.get(t.id) ?? [])]);
|
|
921
|
+
return finding;
|
|
922
|
+
}
|
|
923
|
+
return {
|
|
924
|
+
create(body) {
|
|
925
|
+
const externalId = body.externalId;
|
|
926
|
+
if (externalId) {
|
|
927
|
+
const existing = [...store.values()].find((t) => t.kind === "objective" && t.externalId === externalId && active(t));
|
|
928
|
+
if (existing)
|
|
929
|
+
return { task: listed(existing), resumed: true };
|
|
930
|
+
}
|
|
931
|
+
const task = make(body, null);
|
|
932
|
+
store.set(task.id, task);
|
|
933
|
+
if (options.log !== false)
|
|
934
|
+
console.log(`\n ▸ Objective: ${task.title}\n ${task.url}\n`);
|
|
935
|
+
return { task: listed(task), resumed: false };
|
|
936
|
+
},
|
|
937
|
+
list(query) {
|
|
938
|
+
const status = query.get("status");
|
|
939
|
+
const externalId = query.get("externalId");
|
|
940
|
+
const q = query.get("q")?.toLowerCase();
|
|
941
|
+
return [...store.values()]
|
|
942
|
+
.filter((t) => t.kind === "objective")
|
|
943
|
+
.filter((t) => !status || (status === "active" ? active(t) : t.status === status))
|
|
944
|
+
.filter((t) => !externalId || t.externalId === externalId)
|
|
945
|
+
.filter((t) => !q || `${t.title} ${t.objective}`.toLowerCase().includes(q))
|
|
946
|
+
.map((t) => {
|
|
947
|
+
const below = [...store.values()].filter((s) => s.rootTaskId === t.id && s.id !== t.id);
|
|
948
|
+
return {
|
|
949
|
+
...listed(t),
|
|
950
|
+
sideTasks: {
|
|
951
|
+
open: below.filter(active).length,
|
|
952
|
+
done: below.filter((s) => s.status === "completed" && s.outcome !== null).length,
|
|
953
|
+
awaiting: below.filter((s) => s.status === "completed" && s.outcome === null).length,
|
|
954
|
+
},
|
|
955
|
+
};
|
|
956
|
+
});
|
|
957
|
+
},
|
|
958
|
+
act(method, id, action, body) {
|
|
959
|
+
const t = store.get(id);
|
|
960
|
+
if (!t)
|
|
961
|
+
return notFound("task");
|
|
962
|
+
if (method === "GET" && action === null) {
|
|
963
|
+
return [
|
|
964
|
+
200,
|
|
965
|
+
{
|
|
966
|
+
...listed(t),
|
|
967
|
+
path: pathTo(t),
|
|
968
|
+
children: childrenOf(t.id).map(node),
|
|
969
|
+
findings: findings.get(t.id) ?? [],
|
|
970
|
+
links: links.filter((l) => l.sourceTaskId === t.id || l.targetTaskId === t.id),
|
|
971
|
+
},
|
|
972
|
+
];
|
|
973
|
+
}
|
|
974
|
+
if (method === "GET" && action === "context")
|
|
975
|
+
return [200, context(t)];
|
|
976
|
+
if (method === "GET" && action === "graph") {
|
|
977
|
+
const root = store.get(t.rootTaskId) ?? t;
|
|
978
|
+
const tree = [...store.values()].filter((n) => n.rootTaskId === root.id);
|
|
979
|
+
const ids = new Set(tree.map((n) => n.id));
|
|
980
|
+
return [
|
|
981
|
+
200,
|
|
982
|
+
{
|
|
983
|
+
root: listed(root),
|
|
984
|
+
nodes: tree.map(node),
|
|
985
|
+
links: links.filter((l) => ids.has(l.sourceTaskId) || ids.has(l.targetTaskId)),
|
|
986
|
+
},
|
|
987
|
+
];
|
|
988
|
+
}
|
|
989
|
+
if (method === "PATCH" && action === null) {
|
|
990
|
+
if (typeof body.expectedVersion === "number" && body.expectedVersion !== t.version) {
|
|
991
|
+
return refused("version_conflict", "The task changed since you read it. Read it again and retry.");
|
|
992
|
+
}
|
|
993
|
+
if (typeof body.title === "string")
|
|
994
|
+
t.title = body.title;
|
|
995
|
+
if (typeof body.objective === "string")
|
|
996
|
+
t.objective = body.objective;
|
|
997
|
+
if (typeof body.status === "string")
|
|
998
|
+
t.status = body.status;
|
|
999
|
+
if ("sessionUrl" in body)
|
|
1000
|
+
t.sessionUrl = body.sessionUrl ?? null;
|
|
1001
|
+
t.state = mergeState(t.state, body.state);
|
|
1002
|
+
bump(t);
|
|
1003
|
+
return [200, listed(t)];
|
|
1004
|
+
}
|
|
1005
|
+
if (method !== "POST")
|
|
1006
|
+
return refused("not_in_development_mode", `${method} ${action ?? ""} is not simulated.`, 501);
|
|
1007
|
+
switch (action) {
|
|
1008
|
+
case "side-tasks": {
|
|
1009
|
+
if (!active(t))
|
|
1010
|
+
return refused("not_open", "The task this belongs to is finished. Reopen it first.");
|
|
1011
|
+
if (t.depth >= 3) {
|
|
1012
|
+
return refused("invalid", "Side tasks nest at most three deep. Branch from a task higher up instead.", 400);
|
|
1013
|
+
}
|
|
1014
|
+
const side = make(body, t);
|
|
1015
|
+
store.set(side.id, side);
|
|
1016
|
+
if (options.log !== false)
|
|
1017
|
+
console.log(`\n ↳ Side task: ${side.title}\n ${side.url}\n`);
|
|
1018
|
+
return [201, listed(side)];
|
|
1019
|
+
}
|
|
1020
|
+
case "findings":
|
|
1021
|
+
return [201, addFinding(t, body)];
|
|
1022
|
+
case "complete": {
|
|
1023
|
+
if (!active(t))
|
|
1024
|
+
return refused("not_open", "This task is already complete or cancelled.");
|
|
1025
|
+
t.result = {
|
|
1026
|
+
summary: String(body.summary ?? ""),
|
|
1027
|
+
findings: body.findings ?? [],
|
|
1028
|
+
decisions: body.decisions ?? [],
|
|
1029
|
+
recommendations: strings(body.recommendations),
|
|
1030
|
+
unresolvedQuestions: strings(body.unresolvedQuestions),
|
|
1031
|
+
parentImpact: body.parentImpact ?? null,
|
|
1032
|
+
suggestedNextAction: body.suggestedNextAction ?? null,
|
|
1033
|
+
};
|
|
1034
|
+
for (const f of t.result.findings)
|
|
1035
|
+
addFinding(t, { kind: "finding", title: f.title, body: f.description, evidence: f.evidence });
|
|
1036
|
+
for (const d of t.result.decisions)
|
|
1037
|
+
addFinding(t, { kind: "decision", title: d.title, body: d.rationale });
|
|
1038
|
+
t.status = "completed";
|
|
1039
|
+
t.completedAt = new Date().toISOString();
|
|
1040
|
+
bump(t);
|
|
1041
|
+
return [200, listed(t)];
|
|
1042
|
+
}
|
|
1043
|
+
case "apply": {
|
|
1044
|
+
const parent = t.parentTaskId ? store.get(t.parentTaskId) : undefined;
|
|
1045
|
+
if (!parent)
|
|
1046
|
+
return refused("invalid", "An objective has no parent to apply to.", 400);
|
|
1047
|
+
if (t.status !== "completed" || !t.result) {
|
|
1048
|
+
return refused("not_completed", "This side task has not been completed yet, so there is no result to use.");
|
|
1049
|
+
}
|
|
1050
|
+
if (t.outcome !== null) {
|
|
1051
|
+
return refused("already_applied", "This result has already been applied to the main task. Reopen the side task to change it.");
|
|
1052
|
+
}
|
|
1053
|
+
const outcome = body.outcome ?? "applied";
|
|
1054
|
+
t.outcome = outcome;
|
|
1055
|
+
bump(t);
|
|
1056
|
+
if (outcome === "applied") {
|
|
1057
|
+
for (const f of findings.get(t.id) ?? []) {
|
|
1058
|
+
addFinding(parent, { kind: f.kind, title: f.title, body: f.body, evidence: f.evidence }, t.id);
|
|
1059
|
+
}
|
|
1060
|
+
const resolves = t.snapshot?.resolvesQuestion;
|
|
1061
|
+
parent.state = mergeState(parent.state, {
|
|
1062
|
+
addOpenQuestions: t.result.unresolvedQuestions,
|
|
1063
|
+
...(resolves ? { resolveOpenQuestions: [resolves] } : {}),
|
|
1064
|
+
...(t.result.suggestedNextAction ? { nextAction: t.result.suggestedNextAction } : {}),
|
|
1065
|
+
});
|
|
1066
|
+
bump(parent);
|
|
1067
|
+
}
|
|
1068
|
+
const message = outcome === "applied"
|
|
1069
|
+
? `The result of "${t.title}" is now part of "${parent.title}".`
|
|
1070
|
+
: outcome === "kept"
|
|
1071
|
+
? `"${t.title}" is kept for reference; nothing in "${parent.title}" changed.`
|
|
1072
|
+
: `"${t.title}" was discarded; nothing in "${parent.title}" changed.`;
|
|
1073
|
+
return [200, { sideTask: listed(t), parent: listed(parent), message, context: context(parent) }];
|
|
1074
|
+
}
|
|
1075
|
+
case "reopen": {
|
|
1076
|
+
if (t.status !== "completed" && t.status !== "cancelled") {
|
|
1077
|
+
return refused("not_open", "Only a completed or cancelled task can be reopened.");
|
|
1078
|
+
}
|
|
1079
|
+
if (t.result)
|
|
1080
|
+
t.previousResults = [t.result, ...t.previousResults];
|
|
1081
|
+
t.result = null;
|
|
1082
|
+
t.outcome = null;
|
|
1083
|
+
t.status = "open";
|
|
1084
|
+
t.completedAt = null;
|
|
1085
|
+
bump(t);
|
|
1086
|
+
return [200, listed(t)];
|
|
1087
|
+
}
|
|
1088
|
+
case "cancel": {
|
|
1089
|
+
if (!active(t))
|
|
1090
|
+
return refused("not_open", "This task is already complete or cancelled.");
|
|
1091
|
+
t.status = "cancelled";
|
|
1092
|
+
t.completedAt = new Date().toISOString();
|
|
1093
|
+
bump(t);
|
|
1094
|
+
return [200, listed(t)];
|
|
1095
|
+
}
|
|
1096
|
+
case "links": {
|
|
1097
|
+
const targetTaskId = String(body.targetTaskId ?? "");
|
|
1098
|
+
if (targetTaskId === t.id)
|
|
1099
|
+
return refused("invalid", "A task cannot be linked to itself.", 400);
|
|
1100
|
+
if (!store.has(targetTaskId))
|
|
1101
|
+
return notFound("task");
|
|
1102
|
+
const kind = body.kind;
|
|
1103
|
+
const exists = links.some((l) => l.sourceTaskId === t.id && l.targetTaskId === targetTaskId && l.kind === kind);
|
|
1104
|
+
if (!exists)
|
|
1105
|
+
links.push({ sourceTaskId: t.id, targetTaskId, kind });
|
|
1106
|
+
return [201, { linked: true, sourceTaskId: t.id, targetTaskId, kind, created: !exists }];
|
|
1107
|
+
}
|
|
1108
|
+
default:
|
|
1109
|
+
return refused("not_in_development_mode", `POST /tasks/${id}/${action ?? ""} is not simulated.`, 501);
|
|
1110
|
+
}
|
|
1111
|
+
},
|
|
1112
|
+
};
|
|
1113
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Comments, Reports, Schedules } from "./reports.js";
|
|
|
5
5
|
import { Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
6
6
|
import { Collections, type CollectWaitOptions } from "./collections.js";
|
|
7
7
|
import { Flows } from "./flows.js";
|
|
8
|
+
import { Tasks } from "./tasks.js";
|
|
8
9
|
import { Webhooks } from "./webhooks.js";
|
|
9
10
|
import { type DevelopmentOptions } from "./dev.js";
|
|
10
11
|
import { type Duration } from "./duration.js";
|
|
@@ -15,6 +16,7 @@ export { Comments, Reports, Schedules } from "./reports.js";
|
|
|
15
16
|
export { Review, Reviews, type ReviewWaitOptions } from "./reviews.js";
|
|
16
17
|
export { Collection, Collections, type CollectWaitOptions } from "./collections.js";
|
|
17
18
|
export { Flow, Flows, type FlowPrimitives } from "./flows.js";
|
|
19
|
+
export { Task, Tasks } from "./tasks.js";
|
|
18
20
|
export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
|
|
19
21
|
export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
20
22
|
export { DEFAULT_BASE_URL, type ClientOptions } from "./http.js";
|
|
@@ -114,6 +116,7 @@ export declare class Deliverd {
|
|
|
114
116
|
readonly reviews: Reviews;
|
|
115
117
|
readonly collections: Collections;
|
|
116
118
|
readonly flows: Flows;
|
|
119
|
+
readonly tasks: Tasks;
|
|
117
120
|
readonly reports: Reports;
|
|
118
121
|
readonly comments: Comments;
|
|
119
122
|
readonly schedules: Schedules;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAsB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WA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C;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;gBAElB,OAAO,GAAE,eAAoB;IA6BzC;;;;;;;;;;OAUG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IA0CzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAsBvD;;;;;;OAMG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAoC5D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkCjE,gFAAgF;IAChF,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAGjF;AAoBD,eAAO,MAAM,QAAQ,EAAE,QAMrB,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { Comments, Reports, Schedules } from "./reports.js";
|
|
|
5
5
|
import { Reviews } from "./reviews.js";
|
|
6
6
|
import { Collections } from "./collections.js";
|
|
7
7
|
import { Flows } from "./flows.js";
|
|
8
|
+
import { Tasks } from "./tasks.js";
|
|
8
9
|
import { Webhooks } from "./webhooks.js";
|
|
9
10
|
import { developmentFetch } from "./dev.js";
|
|
10
11
|
import { durationMs } from "./duration.js";
|
|
@@ -14,6 +15,7 @@ export { Comments, Reports, Schedules } from "./reports.js";
|
|
|
14
15
|
export { Review, Reviews } from "./reviews.js";
|
|
15
16
|
export { Collection, Collections } from "./collections.js";
|
|
16
17
|
export { Flow, Flows } from "./flows.js";
|
|
18
|
+
export { Task, Tasks } from "./tasks.js";
|
|
17
19
|
export { constructCallback, constructEvent, DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, TOLERANCE_SECONDS, verifySignature, Webhooks, } from "./webhooks.js";
|
|
18
20
|
export { DeliverdError, DeliverdTimeoutError } from "./errors.js";
|
|
19
21
|
export { DEFAULT_BASE_URL } from "./http.js";
|
|
@@ -45,6 +47,7 @@ export class Deliverd {
|
|
|
45
47
|
reviews;
|
|
46
48
|
collections;
|
|
47
49
|
flows;
|
|
50
|
+
tasks;
|
|
48
51
|
reports;
|
|
49
52
|
comments;
|
|
50
53
|
schedules;
|
|
@@ -72,6 +75,7 @@ export class Deliverd {
|
|
|
72
75
|
* implementation that can drift from it.
|
|
73
76
|
*/
|
|
74
77
|
this.flows = new Flows(this.http, this);
|
|
78
|
+
this.tasks = new Tasks(this.http);
|
|
75
79
|
this.reports = new Reports(this.http);
|
|
76
80
|
this.comments = new Comments(this.http);
|
|
77
81
|
this.schedules = new Schedules(this.http);
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAmMpD,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAI5F"}
|
package/dist/messages.js
CHANGED
|
@@ -191,6 +191,19 @@ export const EXPLANATIONS = {
|
|
|
191
191
|
invalid_signature: {
|
|
192
192
|
hint: "Check the endpoint's signing secret, and that you passed the raw request body rather than a re-encoded object.",
|
|
193
193
|
},
|
|
194
|
+
/*
|
|
195
|
+
* The Task Graph's refusals. The server's sentences already say what
|
|
196
|
+
* happened; these say what to do, which for each is one specific call.
|
|
197
|
+
*/
|
|
198
|
+
version_conflict: {
|
|
199
|
+
hint: "Somebody wrote to the task between your read and your write. Read it again (`task.refresh()`), reapply your change to what is there now, and pass the new `expectedVersion`.",
|
|
200
|
+
},
|
|
201
|
+
not_completed: {
|
|
202
|
+
hint: "Only a completed side task has a result to apply. Finish it with `complete()` first; a cancelled one has to be reopened and completed.",
|
|
203
|
+
},
|
|
204
|
+
already_applied: {
|
|
205
|
+
hint: "Applying happens once, so the parent is never given the same decisions twice. To change what was carried up, `reopen()` the side task, complete it again and apply the new result.",
|
|
206
|
+
},
|
|
194
207
|
};
|
|
195
208
|
/** The message as a developer should read it: what happened, then what to do. */
|
|
196
209
|
export function explain(code, apiMessage) {
|
package/dist/released.d.ts
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
* **Add the version here when you publish it, not before.** An entry is a
|
|
44
44
|
* claim that `npm install @deliverd/sdk@x` works today.
|
|
45
45
|
*/
|
|
46
|
-
export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0"];
|
|
46
|
+
export declare const PUBLISHED_TO_NPM: readonly ["0.1.0", "0.2.0", "0.3.0", "0.4.0", "0.5.0", "0.6.0", "0.6.1", "0.6.2", "0.7.0", "0.7.1", "0.8.0", "0.8.1", "0.8.2", "0.9.0", "0.10.0", "0.11.0", "0.11.1"];
|
|
47
47
|
/**
|
|
48
48
|
* A fingerprint of what each *published* version recorded.
|
|
49
49
|
*
|
package/dist/released.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"released.d.ts","sourceRoot":"","sources":["../src/released.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,uKAkBnB,CAAC;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8CzC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAsiJtD,CAAC"}
|