@osolmaz/pi-workflows 0.16.5 → 0.16.7
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 +5 -5
- package/dist/builtins/autoimplement.workflow.d.ts +5 -1
- package/dist/builtins/autoimplement.workflow.js +29 -10
- package/dist/builtins/autoimplement.workflow.js.map +1 -1
- package/dist/client/client.js +3 -1
- package/dist/client/client.js.map +1 -1
- package/dist/client/protocol.d.ts +1 -1
- package/dist/client/protocol.js +18 -1
- package/dist/client/protocol.js.map +1 -1
- package/dist/client/view.d.ts +7 -5
- package/dist/extension/index.d.ts +2 -1
- package/dist/extension/index.js +116 -166
- package/dist/extension/index.js.map +1 -1
- package/dist/extension/recorder.d.ts +1 -1
- package/dist/extension/recorder.js +2 -2
- package/dist/extension/recorder.js.map +1 -1
- package/dist/extension/step-message.d.ts +1 -1
- package/dist/extension/step-message.js +4 -4
- package/dist/extension/step-message.js.map +1 -1
- package/dist/extension/widget.js +1 -1
- package/dist/extension/widget.js.map +1 -1
- package/dist/extension/workflow-message-coordinator.d.ts +12 -3
- package/dist/extension/workflow-message-coordinator.js +108 -94
- package/dist/extension/workflow-message-coordinator.js.map +1 -1
- package/dist/render/graph-render.js +1 -1
- package/dist/resource-managers/index.d.ts +1 -2
- package/dist/resource-managers/index.js +1 -2
- package/dist/resource-managers/index.js.map +1 -1
- package/dist/resource-managers/sqlite.d.ts +2 -295
- package/dist/resource-managers/sqlite.js +71 -1528
- package/dist/resource-managers/sqlite.js.map +1 -1
- package/dist/resource-managers/types.d.ts +2 -7
- package/dist/server/resource-runner-entry.js +2 -6
- package/dist/server/resource-runner-entry.js.map +1 -1
- package/dist/server/rpc-bridge.js +1 -1
- package/dist/server/rpc-bridge.js.map +1 -1
- package/dist/server/rpc-executor.js +2 -4
- package/dist/server/rpc-executor.js.map +1 -1
- package/dist/server/server-entry.js +3 -0
- package/dist/server/server-entry.js.map +1 -1
- package/dist/server/server.d.ts +9 -8
- package/dist/server/server.js +364 -541
- package/dist/server/server.js.map +1 -1
- package/dist/server/state.d.ts +16 -29
- package/dist/server/state.js +105 -319
- package/dist/server/state.js.map +1 -1
- package/dist/server/view.d.ts +6 -5
- package/dist/server/view.js +68 -51
- package/dist/server/view.js.map +1 -1
- package/dist/server/workflow-runner-entry.d.ts +1 -1
- package/dist/server/workflow-runner-entry.js +1 -49
- package/dist/server/workflow-runner-entry.js.map +1 -1
- package/dist/server/workflow-runner-protocol.d.ts +2 -7
- package/dist/server/workflow-runner-protocol.js +5 -10
- package/dist/server/workflow-runner-protocol.js.map +1 -1
- package/dist/server/workflow-runner-store.d.ts +5 -6
- package/dist/server/workflow-runner-store.js +7 -14
- package/dist/server/workflow-runner-store.js.map +1 -1
- package/dist/state/attempt-time.d.ts +21 -0
- package/dist/state/attempt-time.js +95 -0
- package/dist/state/attempt-time.js.map +1 -0
- package/dist/state/json.d.ts +2 -1
- package/dist/state/json.js.map +1 -1
- package/dist/state/project-store.d.ts +39 -0
- package/dist/state/project-store.js +154 -0
- package/dist/state/project-store.js.map +1 -0
- package/dist/state/prune.js +0 -7
- package/dist/state/prune.js.map +1 -1
- package/dist/state/schema.js +23 -23
- package/dist/state/workflow-messages.d.ts +1 -1
- package/dist/state/workflow-messages.js +3 -1
- package/dist/state/workflow-messages.js.map +1 -1
- package/dist/viewer/backup.js +5 -0
- package/dist/viewer/backup.js.map +1 -1
- package/dist/workflows/diagnostics.d.ts +8 -0
- package/dist/workflows/diagnostics.js +61 -0
- package/dist/workflows/diagnostics.js.map +1 -0
- package/dist/workflows/engine.d.ts +2 -16
- package/dist/workflows/engine.js +128 -252
- package/dist/workflows/engine.js.map +1 -1
- package/dist/workflows/errors.d.ts +1 -1
- package/dist/workflows/errors.js +2 -2
- package/dist/workflows/errors.js.map +1 -1
- package/dist/workflows/human-decision.d.ts +3 -7
- package/dist/workflows/human-decision.js +2 -56
- package/dist/workflows/human-decision.js.map +1 -1
- package/dist/workflows/index.d.ts +2 -1
- package/dist/workflows/index.js +1 -0
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/queue.d.ts +267 -0
- package/dist/workflows/queue.js +1248 -0
- package/dist/workflows/queue.js.map +1 -0
- package/dist/workflows/requests.d.ts +47 -0
- package/dist/workflows/requests.js +158 -0
- package/dist/workflows/requests.js.map +1 -0
- package/dist/workflows/schema.js +2 -4
- package/dist/workflows/schema.js.map +1 -1
- package/dist/workflows/store.d.ts +11 -16
- package/dist/workflows/store.js +177 -174
- package/dist/workflows/store.js.map +1 -1
- package/dist/workflows/tool-input.d.ts +6 -9
- package/dist/workflows/tool-input.js +15 -12
- package/dist/workflows/tool-input.js.map +1 -1
- package/dist/workflows/transitions.d.ts +38 -0
- package/dist/workflows/transitions.js +276 -0
- package/dist/workflows/transitions.js.map +1 -0
- package/dist/workflows/types.d.ts +9 -42
- package/dist/workflows/workflow-message-content.d.ts +7 -1
- package/dist/workflows/workflow-message-content.js +22 -4
- package/dist/workflows/workflow-message-content.js.map +1 -1
- package/docs/2026-08-25-workflow-follow-ups.md +5 -5
- package/docs/2026-09-02-unify-workflow-messages-plan.md +2 -0
- package/docs/2026-09-04-workflow-run-state-plan.md +2 -0
- package/docs/2026-09-06-durable-execution-plan.md +176 -0
- package/docs/2026-09-07-workflow-handoff-plan.md +84 -0
- package/docs/DEFERRED_TURNS.md +84 -105
- package/docs/HUMAN_DECISIONS.md +17 -19
- package/docs/HUMAN_DECISION_PRESENTATIONS.md +1 -1
- package/docs/SQLITE_STATE.md +68 -29
- package/docs/WORKFLOW_SERVER.md +21 -10
- package/docs/WORKFLOW_STEP_MESSAGES.md +83 -54
- package/docs/plans/2026-08-04-controller-runtime-plan.md +2 -0
- package/docs/plans/2026-08-21-deferred-turn-intents-plan.md +2 -0
- package/docs/plans/2026-08-27-workflow-terminal-restart-plan.md +2 -0
- package/docs/workflows.md +111 -45
- package/examples/workflows/autoresearch.workflow.ts +0 -2
- package/examples/workflows/branch.workflow.ts +0 -4
- package/examples/workflows/echo.workflow.ts +0 -2
- package/examples/workflows/live-settings.workflow.ts +0 -2
- package/examples/workflows/two-turn.workflow.ts +0 -2
- package/herdr-plugin.toml +1 -1
- package/package.json +1 -1
- package/protocol/fixtures/client-v1.json +1 -1
- package/skills/pi-workflows/SKILL.md +8 -7
- package/src/builtins/autoimplement.workflow.ts +31 -10
- package/src/client/client.ts +3 -1
- package/src/client/protocol.ts +21 -1
- package/src/client/view.ts +9 -5
- package/src/extension/index.ts +118 -190
- package/src/extension/recorder.ts +2 -2
- package/src/extension/step-message.ts +4 -4
- package/src/extension/widget.ts +1 -1
- package/src/extension/workflow-message-coordinator.ts +133 -95
- package/src/render/graph-render.ts +1 -1
- package/src/resource-managers/index.ts +1 -9
- package/src/resource-managers/sqlite.ts +330 -2655
- package/src/resource-managers/types.ts +2 -3
- package/src/server/resource-runner-entry.ts +2 -7
- package/src/server/rpc-bridge.ts +1 -1
- package/src/server/rpc-executor.ts +4 -9
- package/src/server/server-entry.ts +3 -0
- package/src/server/server.ts +416 -641
- package/src/server/state.ts +122 -466
- package/src/server/view.ts +73 -58
- package/src/server/workflow-runner-entry.ts +2 -55
- package/src/server/workflow-runner-protocol.ts +5 -15
- package/src/server/workflow-runner-store.ts +12 -27
- package/src/state/attempt-time.ts +122 -0
- package/src/state/json.ts +2 -1
- package/src/state/project-store.ts +218 -0
- package/src/state/prune.ts +0 -13
- package/src/state/schema.ts +23 -23
- package/src/state/workflow-messages.ts +4 -2
- package/src/viewer/backup.ts +7 -0
- package/src/workflows/diagnostics.ts +78 -0
- package/src/workflows/engine.ts +136 -299
- package/src/workflows/errors.ts +4 -2
- package/src/workflows/human-decision.ts +3 -81
- package/src/workflows/index.ts +8 -2
- package/src/workflows/queue.ts +2091 -0
- package/src/workflows/requests.ts +283 -0
- package/src/workflows/schema.ts +2 -6
- package/src/workflows/store.ts +226 -236
- package/src/workflows/tool-input.ts +20 -12
- package/src/workflows/transitions.ts +330 -0
- package/src/workflows/types.ts +9 -46
- package/src/workflows/workflow-message-content.ts +28 -4
- package/dist/resource-managers/runtime.d.ts +0 -59
- package/dist/resource-managers/runtime.js +0 -423
- package/dist/resource-managers/runtime.js.map +0 -1
- package/src/resource-managers/runtime.ts +0 -576
package/src/workflows/errors.ts
CHANGED
|
@@ -54,12 +54,14 @@ export function isRunParkedError(error: unknown): error is RunParkedError {
|
|
|
54
54
|
return error instanceof RunParkedError;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
/**
|
|
57
|
+
/** A run can resume only with its original workflow source and definition. */
|
|
58
58
|
export class WorkflowSourceChangedError extends Error {
|
|
59
59
|
readonly runId: string;
|
|
60
60
|
|
|
61
61
|
constructor(runId: string) {
|
|
62
|
-
super(
|
|
62
|
+
super(
|
|
63
|
+
`Workflow source or definition changed since run ${runId} started; restore the original definition to resume, or explicitly start a new run`,
|
|
64
|
+
);
|
|
63
65
|
this.name = "WorkflowSourceChangedError";
|
|
64
66
|
this.runId = runId;
|
|
65
67
|
}
|
|
@@ -16,7 +16,6 @@ import type {
|
|
|
16
16
|
HumanDecisionCancellationRecord,
|
|
17
17
|
HumanDecisionChoiceMap,
|
|
18
18
|
HumanDecisionChannelRequest,
|
|
19
|
-
HumanDecisionContinuationRecord,
|
|
20
19
|
HumanDecisionDeliveryRecord,
|
|
21
20
|
HumanDecisionPrompt,
|
|
22
21
|
HumanDecisionRequest,
|
|
@@ -377,7 +376,7 @@ export class HumanDecisionStore {
|
|
|
377
376
|
if (this.ownsState) this.state.close();
|
|
378
377
|
}
|
|
379
378
|
|
|
380
|
-
|
|
379
|
+
createRequest(request: HumanDecisionRequest): "created" | "adopted" {
|
|
381
380
|
validateHumanDecisionRequestIntegrity(request);
|
|
382
381
|
return this.state.transaction(() => {
|
|
383
382
|
const existing = this.readRequestRow(request.decisionId);
|
|
@@ -674,42 +673,9 @@ export class HumanDecisionStore {
|
|
|
674
673
|
return resolution?.outcome === "accepted" ? resolution.decision : null;
|
|
675
674
|
}
|
|
676
675
|
|
|
677
|
-
async recordContinuation(
|
|
678
|
-
decisionId: string,
|
|
679
|
-
value: HumanDecisionContinuationRecord,
|
|
680
|
-
): Promise<"created" | "adopted"> {
|
|
681
|
-
return this.state.transaction(() => {
|
|
682
|
-
const existing = this.readContinuationRow(decisionId);
|
|
683
|
-
if (existing !== undefined) {
|
|
684
|
-
const stored = this.continuationRecord(decisionId, existing);
|
|
685
|
-
if (canonicalJson(stored) !== canonicalJson(value)) {
|
|
686
|
-
throw new Error("Immutable human decision continuation conflicts");
|
|
687
|
-
}
|
|
688
|
-
return "adopted";
|
|
689
|
-
}
|
|
690
|
-
const resolution = this.readResolution(decisionId);
|
|
691
|
-
if (resolution?.outcome !== "accepted") {
|
|
692
|
-
throw new Error("A continuation requires an accepted human decision");
|
|
693
|
-
}
|
|
694
|
-
this.state.connection
|
|
695
|
-
.prepare(
|
|
696
|
-
`INSERT INTO continuations(
|
|
697
|
-
decision_id, parent_run_id, continuation_run_id, created_at
|
|
698
|
-
) VALUES (?, ?, ?, ?)`,
|
|
699
|
-
)
|
|
700
|
-
.run(decisionId, value.parentRunId, value.runId, Date.parse(value.createdAt));
|
|
701
|
-
return "created";
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
async readContinuation(decisionId: string): Promise<HumanDecisionContinuationRecord | null> {
|
|
706
|
-
const row = this.readContinuationRow(decisionId);
|
|
707
|
-
return row === undefined ? null : this.continuationRecord(decisionId, row);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
676
|
markEffectApplied(
|
|
711
677
|
decisionId: string,
|
|
712
|
-
effectType: "decision.
|
|
678
|
+
effectType: "decision.cancel_parent" | "decision.settle_presentations",
|
|
713
679
|
): void {
|
|
714
680
|
const rows = this.state.connection
|
|
715
681
|
.prepare(
|
|
@@ -1005,7 +971,7 @@ export class HumanDecisionStore {
|
|
|
1005
971
|
): void {
|
|
1006
972
|
const types =
|
|
1007
973
|
outcome === "accepted"
|
|
1008
|
-
? ["decision.
|
|
974
|
+
? ["decision.settle_presentations"]
|
|
1009
975
|
: ["decision.cancel_parent", "decision.settle_presentations"];
|
|
1010
976
|
for (const effectType of types) {
|
|
1011
977
|
const idempotencyKey = request.decisionId;
|
|
@@ -1188,38 +1154,6 @@ export class HumanDecisionStore {
|
|
|
1188
1154
|
)
|
|
1189
1155
|
.run(outcome, resultHash, decisionId, attemptId);
|
|
1190
1156
|
}
|
|
1191
|
-
|
|
1192
|
-
private readContinuationRow(decisionId: string): ContinuationRow | undefined {
|
|
1193
|
-
const row = this.state.connection
|
|
1194
|
-
.prepare(
|
|
1195
|
-
`SELECT c.parent_run_id AS parentRunId, c.continuation_run_id AS continuationRunId,
|
|
1196
|
-
c.created_at AS createdAt, d.request_hash AS requestHash,
|
|
1197
|
-
r.response_hash AS resolutionHash
|
|
1198
|
-
FROM continuations c
|
|
1199
|
-
JOIN human_decisions d ON d.decision_id = c.decision_id
|
|
1200
|
-
JOIN human_decision_resolutions r ON r.decision_id = c.decision_id
|
|
1201
|
-
WHERE c.decision_id = ? AND r.outcome = 'accepted'`,
|
|
1202
|
-
)
|
|
1203
|
-
.get(decisionId);
|
|
1204
|
-
return isContinuationRow(row) ? row : undefined;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
private continuationRecord(
|
|
1208
|
-
decisionId: string,
|
|
1209
|
-
row: ContinuationRow,
|
|
1210
|
-
): HumanDecisionContinuationRecord {
|
|
1211
|
-
const request = this.state.readJson(row.requestHash) as HumanDecisionRequest;
|
|
1212
|
-
const decision = this.state.readJson(row.resolutionHash) as ResolvedHumanDecision;
|
|
1213
|
-
return {
|
|
1214
|
-
schema: "pi-workflows.human-decision-continuation.v1",
|
|
1215
|
-
decisionId,
|
|
1216
|
-
requestDigest: request.requestDigest,
|
|
1217
|
-
provenance: decision.provenance,
|
|
1218
|
-
parentRunId: row.parentRunId,
|
|
1219
|
-
runId: row.continuationRunId,
|
|
1220
|
-
createdAt: new Date(row.createdAt).toISOString(),
|
|
1221
|
-
};
|
|
1222
|
-
}
|
|
1223
1157
|
}
|
|
1224
1158
|
|
|
1225
1159
|
function recordDecisionViewerChange(
|
|
@@ -1302,18 +1236,6 @@ function isContentHashRow(value: unknown): value is { contentHash: Buffer } {
|
|
|
1302
1236
|
return isRecordValue(value);
|
|
1303
1237
|
}
|
|
1304
1238
|
|
|
1305
|
-
type ContinuationRow = {
|
|
1306
|
-
parentRunId: string;
|
|
1307
|
-
continuationRunId: string;
|
|
1308
|
-
createdAt: number;
|
|
1309
|
-
requestHash: Buffer;
|
|
1310
|
-
resolutionHash: Buffer;
|
|
1311
|
-
};
|
|
1312
|
-
|
|
1313
|
-
function isContinuationRow(value: unknown): value is ContinuationRow {
|
|
1314
|
-
return isRecordValue(value);
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
1239
|
function isDecisionResourceRow(value: unknown): value is { resourceId: string; revision: number } {
|
|
1318
1240
|
return isRecordValue(value);
|
|
1319
1241
|
}
|
package/src/workflows/index.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export {
|
|
2
|
+
WorkflowRunQueueStore,
|
|
3
|
+
type RunEventRecord,
|
|
4
|
+
type WorkflowRunPreparationResult,
|
|
5
|
+
type WorkflowRunQueueRecord,
|
|
6
|
+
type WorkflowRunQueueViewRecord,
|
|
7
|
+
type WorkflowRunReservationOptions,
|
|
8
|
+
} from "./queue.js";
|
|
1
9
|
export {
|
|
2
10
|
agent,
|
|
3
11
|
assistantMessage,
|
|
@@ -203,7 +211,6 @@ export type {
|
|
|
203
211
|
HumanDecisionChannelRequest,
|
|
204
212
|
HumanDecisionChoice,
|
|
205
213
|
HumanDecisionChoiceMap,
|
|
206
|
-
HumanDecisionContinuationRecord,
|
|
207
214
|
HumanDecisionDeliveryRecord,
|
|
208
215
|
HumanDecisionNodeContract,
|
|
209
216
|
HumanDecisionPrompt,
|
|
@@ -247,7 +254,6 @@ export type {
|
|
|
247
254
|
WorkflowNotificationReceipt,
|
|
248
255
|
WorkflowNotificationRequest,
|
|
249
256
|
WorkflowNotificationSink,
|
|
250
|
-
WorkflowPresentationContext,
|
|
251
257
|
WorkflowProgressData,
|
|
252
258
|
WorkflowProgressStatus,
|
|
253
259
|
WorkflowRunResult,
|