@osolmaz/pi-workflows 0.16.0 → 0.16.2
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 +18 -2
- package/dist/channels/adapter-entry.d.ts +3 -0
- package/dist/channels/adapter-entry.js +203 -0
- package/dist/channels/adapter-entry.js.map +1 -0
- package/dist/channels/config.d.ts +43 -0
- package/dist/channels/config.js +234 -0
- package/dist/channels/config.js.map +1 -0
- package/dist/channels/protocol.d.ts +94 -0
- package/dist/channels/protocol.js +219 -0
- package/dist/channels/protocol.js.map +1 -0
- package/dist/channels/telegram.d.ts +46 -0
- package/dist/channels/telegram.js +285 -0
- package/dist/channels/telegram.js.map +1 -0
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.js +5 -1
- package/dist/client/client.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/protocol.d.ts +1 -1
- package/dist/client/protocol.js +11 -5
- package/dist/client/protocol.js.map +1 -1
- package/dist/client/view.d.ts +48 -16
- package/dist/client/view.js +1 -0
- package/dist/client/view.js.map +1 -1
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/sqlite.d.ts +20 -165
- package/dist/controllers/sqlite.js +178 -436
- package/dist/controllers/sqlite.js.map +1 -1
- package/dist/extension/index.d.ts +23 -2
- package/dist/extension/index.js +637 -534
- package/dist/extension/index.js.map +1 -1
- package/dist/extension/recorder.d.ts +95 -0
- package/dist/extension/recorder.js +530 -0
- package/dist/extension/recorder.js.map +1 -0
- package/dist/extension/remote-recorder-store.d.ts +25 -0
- package/dist/extension/remote-recorder-store.js +81 -0
- package/dist/extension/remote-recorder-store.js.map +1 -0
- package/dist/extension/session-events.d.ts +134 -0
- package/dist/extension/session-events.js +60 -0
- package/dist/extension/session-events.js.map +1 -0
- package/dist/extension/session-view.d.ts +2 -0
- package/dist/extension/session-view.js +60 -2
- package/dist/extension/session-view.js.map +1 -1
- package/dist/extension/step-message.d.ts +6 -4
- package/dist/extension/step-message.js +12 -6
- package/dist/extension/step-message.js.map +1 -1
- package/dist/extension/widget.d.ts +2 -2
- package/dist/extension/widget.js +28 -18
- package/dist/extension/widget.js.map +1 -1
- package/dist/extension/workflow-message-coordinator.d.ts +28 -0
- package/dist/extension/workflow-message-coordinator.js +346 -0
- package/dist/extension/workflow-message-coordinator.js.map +1 -0
- package/dist/host/channel-effects.d.ts +72 -0
- package/dist/host/channel-effects.js +271 -0
- package/dist/host/channel-effects.js.map +1 -0
- package/dist/host/channel-supervisor.d.ts +21 -0
- package/dist/host/channel-supervisor.js +54 -0
- package/dist/host/channel-supervisor.js.map +1 -0
- package/dist/host/runner.d.ts +50 -8
- package/dist/host/runner.js +1632 -341
- package/dist/host/runner.js.map +1 -1
- package/dist/host/state.d.ts +19 -16
- package/dist/host/state.js +251 -63
- package/dist/host/state.js.map +1 -1
- package/dist/host/view.d.ts +19 -9
- package/dist/host/view.js +227 -119
- package/dist/host/view.js.map +1 -1
- package/dist/host/worker-entry.d.ts +4 -1
- package/dist/host/worker-entry.js +23 -24
- package/dist/host/worker-entry.js.map +1 -1
- package/dist/host/worker-protocol.d.ts +15 -0
- package/dist/host/worker-protocol.js.map +1 -1
- package/dist/state/prune.js +3 -25
- package/dist/state/prune.js.map +1 -1
- package/dist/state/schema.js +76 -97
- package/dist/state/schema.js.map +1 -1
- package/dist/state/workflow-messages.d.ts +98 -0
- package/dist/state/workflow-messages.js +366 -0
- package/dist/state/workflow-messages.js.map +1 -0
- package/dist/viewer/render.js +1 -1
- package/dist/viewer/render.js.map +1 -1
- package/dist/viewer/tui.d.ts +1 -1
- package/dist/viewer/tui.js +65 -8
- package/dist/viewer/tui.js.map +1 -1
- package/dist/workflows/composition.js +0 -4
- package/dist/workflows/composition.js.map +1 -1
- package/dist/workflows/definition.js +0 -8
- package/dist/workflows/definition.js.map +1 -1
- package/dist/workflows/engine.js +4 -5
- package/dist/workflows/engine.js.map +1 -1
- package/dist/workflows/human-decision.d.ts +2 -0
- package/dist/workflows/human-decision.js +8 -2
- package/dist/workflows/human-decision.js.map +1 -1
- package/dist/workflows/index.d.ts +1 -1
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/schema.js +0 -4
- package/dist/workflows/schema.js.map +1 -1
- package/dist/workflows/settings.d.ts +1 -8
- package/dist/workflows/settings.js.map +1 -1
- package/dist/workflows/store.d.ts +20 -19
- package/dist/workflows/store.js +163 -354
- package/dist/workflows/store.js.map +1 -1
- package/dist/workflows/tool-input.d.ts +21 -0
- package/dist/workflows/tool-input.js +23 -1
- package/dist/workflows/tool-input.js.map +1 -1
- package/dist/workflows/types.d.ts +6 -8
- package/dist/workflows/workflow-message-content.d.ts +38 -0
- package/dist/workflows/workflow-message-content.js +157 -0
- package/dist/workflows/workflow-message-content.js.map +1 -0
- package/docs/2026-08-18-herdr-piw-plan.md +2 -1
- package/docs/2026-08-20-durable-workflow-launch-plan.md +1 -1
- package/docs/2026-08-25-workflow-follow-ups.md +26 -50
- package/docs/2026-08-30-out-of-process-workflow-host-plan.md +3 -3
- package/docs/2026-09-01-restore-session-delivery-controls-plan.md +4 -0
- package/docs/2026-09-01-unified-workflow-client-plan.md +5 -1
- package/docs/2026-09-02-installed-live-e2e-plan.md +15 -1
- package/docs/2026-09-02-unify-workflow-messages-plan.md +562 -0
- package/docs/2026-09-04-workflow-run-state-plan.md +363 -0
- package/docs/DEFERRED_TURNS.md +66 -294
- package/docs/HUMAN_DECISIONS.md +29 -30
- package/docs/HUMAN_DECISION_PRESENTATIONS.md +4 -11
- package/docs/SQLITE_STATE.md +25 -17
- package/docs/WORKFLOW_HOST.md +105 -31
- package/docs/WORKFLOW_STEP_MESSAGES.md +166 -75
- package/docs/live-replay-protocol.md +8 -4
- package/docs/tui-viewer.md +3 -1
- package/docs/workflows.md +44 -28
- package/herdr-plugin.toml +1 -1
- package/package.json +1 -1
- package/plugins/herdr/viewer.mjs +14 -5
- package/src/channels/adapter-entry.ts +220 -0
- package/src/channels/config.ts +296 -0
- package/src/channels/protocol.ts +333 -0
- package/src/channels/telegram.ts +335 -0
- package/src/client/client.ts +6 -2
- package/src/client/index.ts +2 -1
- package/src/client/protocol.ts +11 -5
- package/src/client/view.ts +51 -18
- package/src/controllers/index.ts +0 -1
- package/src/controllers/sqlite.ts +247 -845
- package/src/extension/index.ts +712 -647
- package/src/extension/recorder.ts +687 -0
- package/src/extension/remote-recorder-store.ts +126 -0
- package/src/extension/session-events.ts +119 -0
- package/src/extension/session-view.ts +86 -3
- package/src/extension/step-message.ts +19 -9
- package/src/extension/widget.ts +37 -17
- package/src/extension/workflow-message-coordinator.ts +398 -0
- package/src/host/channel-effects.ts +465 -0
- package/src/host/channel-supervisor.ts +73 -0
- package/src/host/runner.ts +2163 -525
- package/src/host/state.ts +333 -94
- package/src/host/view.ts +254 -122
- package/src/host/worker-entry.ts +38 -30
- package/src/host/worker-protocol.ts +11 -0
- package/src/state/prune.ts +3 -31
- package/src/state/schema.ts +76 -97
- package/src/state/workflow-messages.ts +599 -0
- package/src/viewer/render.ts +1 -5
- package/src/viewer/tui.ts +71 -6
- package/src/workflows/composition.ts +0 -5
- package/src/workflows/definition.ts +0 -8
- package/src/workflows/engine.ts +4 -6
- package/src/workflows/human-decision.ts +18 -2
- package/src/workflows/index.ts +0 -1
- package/src/workflows/schema.ts +0 -6
- package/src/workflows/settings.ts +1 -20
- package/src/workflows/store.ts +237 -489
- package/src/workflows/tool-input.ts +36 -1
- package/src/workflows/types.ts +6 -8
- package/src/workflows/workflow-message-content.ts +197 -0
- package/dist/extension/decision-channels.d.ts +0 -134
- package/dist/extension/decision-channels.js +0 -1307
- package/dist/extension/decision-channels.js.map +0 -1
- package/src/extension/decision-channels.ts +0 -1826
|
@@ -9,6 +9,27 @@ export declare const WorkflowActionSchemas: {
|
|
|
9
9
|
workflow: Type.TString;
|
|
10
10
|
input: Type.TOptional<Type.TUnknown>;
|
|
11
11
|
}>;
|
|
12
|
+
readonly restart: TObject<{
|
|
13
|
+
action: Type.TLiteral<"restart">;
|
|
14
|
+
runId: Type.TString;
|
|
15
|
+
}>;
|
|
16
|
+
readonly "change-settings": TObject<{
|
|
17
|
+
action: Type.TLiteral<"change-settings">;
|
|
18
|
+
runId: Type.TOptional<Type.TString>;
|
|
19
|
+
scopeId: Type.TOptional<Type.TString>;
|
|
20
|
+
expectedChangeNumber: Type.TOptional<Type.TInteger>;
|
|
21
|
+
patch: Type.TUnknown;
|
|
22
|
+
}>;
|
|
23
|
+
readonly "queue-follow-up": TObject<{
|
|
24
|
+
action: Type.TLiteral<"queue-follow-up">;
|
|
25
|
+
runId: Type.TOptional<Type.TString>;
|
|
26
|
+
prompt: Type.TString;
|
|
27
|
+
}>;
|
|
28
|
+
readonly "remove-follow-up": TObject<{
|
|
29
|
+
action: Type.TLiteral<"remove-follow-up">;
|
|
30
|
+
runId: Type.TOptional<Type.TString>;
|
|
31
|
+
followUpId: Type.TString;
|
|
32
|
+
}>;
|
|
12
33
|
readonly status: TObject<{
|
|
13
34
|
action: Type.TLiteral<"status">;
|
|
14
35
|
runId: Type.TOptional<Type.TString>;
|
|
@@ -9,7 +9,7 @@ const inputSchema = Type.Unknown({
|
|
|
9
9
|
description: "Ordinary checkpoint answer for answer; protected human decisions require a human channel; optional structured workflow input for start",
|
|
10
10
|
});
|
|
11
11
|
const runIdSchema = Type.String({
|
|
12
|
-
description: "Run id; optional for status, cancel, and
|
|
12
|
+
description: "Run id; required for restart and optional for status, cancel, answer, settings, and follow-ups",
|
|
13
13
|
});
|
|
14
14
|
const stepSchema = Type.String({
|
|
15
15
|
description: "Workflow step id; required when action is update or submit",
|
|
@@ -32,6 +32,24 @@ export const WorkflowActionSchemas = {
|
|
|
32
32
|
workflow: workflowSchema,
|
|
33
33
|
input: Type.Optional(inputSchema),
|
|
34
34
|
}, noExtraProperties),
|
|
35
|
+
restart: Type.Object({ action: Type.Literal("restart"), runId: runIdSchema }, noExtraProperties),
|
|
36
|
+
"change-settings": Type.Object({
|
|
37
|
+
action: Type.Literal("change-settings"),
|
|
38
|
+
runId: Type.Optional(runIdSchema),
|
|
39
|
+
scopeId: Type.Optional(Type.String()),
|
|
40
|
+
expectedChangeNumber: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
41
|
+
patch: Type.Unknown(),
|
|
42
|
+
}, noExtraProperties),
|
|
43
|
+
"queue-follow-up": Type.Object({
|
|
44
|
+
action: Type.Literal("queue-follow-up"),
|
|
45
|
+
runId: Type.Optional(runIdSchema),
|
|
46
|
+
prompt: Type.String({ minLength: 1 }),
|
|
47
|
+
}, noExtraProperties),
|
|
48
|
+
"remove-follow-up": Type.Object({
|
|
49
|
+
action: Type.Literal("remove-follow-up"),
|
|
50
|
+
runId: Type.Optional(runIdSchema),
|
|
51
|
+
followUpId: Type.String(),
|
|
52
|
+
}, noExtraProperties),
|
|
35
53
|
status: Type.Object({ action: Type.Literal("status"), runId: Type.Optional(runIdSchema) }, noExtraProperties),
|
|
36
54
|
pause: Type.Object({ action: Type.Literal("pause") }, noExtraProperties),
|
|
37
55
|
resume: Type.Object({ action: Type.Literal("resume") }, noExtraProperties),
|
|
@@ -63,6 +81,10 @@ export const WorkflowSubmissionToolParameters = providerObjectSchema(Object.valu
|
|
|
63
81
|
const workflowInputParsers = {
|
|
64
82
|
list: (value) => parseToolInput(WorkflowActionSchemas.list, value, "workflow"),
|
|
65
83
|
start: (value) => parseToolInput(WorkflowActionSchemas.start, value, "workflow"),
|
|
84
|
+
restart: (value) => parseToolInput(WorkflowActionSchemas.restart, value, "workflow"),
|
|
85
|
+
"change-settings": (value) => parseToolInput(WorkflowActionSchemas["change-settings"], value, "workflow"),
|
|
86
|
+
"queue-follow-up": (value) => parseToolInput(WorkflowActionSchemas["queue-follow-up"], value, "workflow"),
|
|
87
|
+
"remove-follow-up": (value) => parseToolInput(WorkflowActionSchemas["remove-follow-up"], value, "workflow"),
|
|
66
88
|
status: (value) => parseToolInput(WorkflowActionSchemas.status, value, "workflow"),
|
|
67
89
|
pause: (value) => parseToolInput(WorkflowActionSchemas.pause, value, "workflow"),
|
|
68
90
|
resume: (value) => parseToolInput(WorkflowActionSchemas.resume, value, "workflow"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-input.js","sourceRoot":"","sources":["../../src/workflows/tool-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA6D,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,iBAAiB,GAAG,EAAE,oBAAoB,EAAE,KAAK,EAAW,CAAC;AAEnE,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC,CAAC;AACvF,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,WAAW,EAAE,+EAA+E;CAC7F,CAAC,CAAC;AACH,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC;IAC/B,WAAW,EACT,wIAAwI;CAC3I,CAAC,CAAC;AACH,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,WAAW,
|
|
1
|
+
{"version":3,"file":"tool-input.js","sourceRoot":"","sources":["../../src/workflows/tool-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA6D,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,iBAAiB,GAAG,EAAE,oBAAoB,EAAE,KAAK,EAAW,CAAC;AAEnE,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC,CAAC;AACvF,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACjC,WAAW,EAAE,+EAA+E;CAC7F,CAAC,CAAC;AACH,MAAM,WAAW,GAAG,IAA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C;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,cAAc,CACrB,MAAc,EACd,KAAc,EACd,KAAa;IAEb,IAAI,CAAC;QACH,OAAO,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC;YAAE,MAAM,KAAK,CAAC;QAChD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM;aAC/B,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;aACX,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE;YACjC,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACpE,MAAM,YAAY,GAAG,OAAO,KAAK,iBAAiB,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC;YACpF,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,CAAC;QACtD,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,WAAW,KAAK,gBAAgB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC"}
|
|
@@ -44,9 +44,7 @@ export type WorkflowEffectRecovery = "idempotent" | "manual";
|
|
|
44
44
|
export type WorkflowManagedEffect = {
|
|
45
45
|
/** Stable external effect category, for example `github.comment`. */
|
|
46
46
|
type: string;
|
|
47
|
-
/**
|
|
48
|
-
idempotencyKey: string | ((context: WorkflowNodeContext) => MaybePromise<string>);
|
|
49
|
-
/** Canonical request data used to reject key reuse with another operation. */
|
|
47
|
+
/** Canonical request data used to reject engine-owned key reuse with another operation. */
|
|
50
48
|
request: unknown | ((context: WorkflowNodeContext) => MaybePromise<unknown>);
|
|
51
49
|
/** `manual` never retries after an uncertain child exit. */
|
|
52
50
|
recovery: WorkflowEffectRecovery;
|
|
@@ -79,9 +77,9 @@ export type WorkflowProgressData = {
|
|
|
79
77
|
};
|
|
80
78
|
export type WorkflowNodeCommon = {
|
|
81
79
|
/**
|
|
82
|
-
* Per-node timeout or a callback that derives it from the run context.
|
|
83
|
-
*
|
|
84
|
-
* default (15 minutes).
|
|
80
|
+
* Per-node active-execution timeout or a callback that derives it from the run context.
|
|
81
|
+
* Waiting, paused, disconnected, and host-down origin-session time does not count.
|
|
82
|
+
* Null disables the deadline. Omission falls back to the engine default (15 minutes).
|
|
85
83
|
*/
|
|
86
84
|
timeoutMs?: number | null | ((context: WorkflowNodeContext) => MaybePromise<number | null>);
|
|
87
85
|
/** Short human-readable label shown in the viewer while the node runs. */
|
|
@@ -361,7 +359,7 @@ export type HumanDecisionSettlementRecord = {
|
|
|
361
359
|
decisionId: string;
|
|
362
360
|
requestDigest: string;
|
|
363
361
|
channel: string;
|
|
364
|
-
state: "confirmed" | "failed";
|
|
362
|
+
state: "confirmed" | "failed" | "unknown";
|
|
365
363
|
createdAt: string;
|
|
366
364
|
finishedAt: string;
|
|
367
365
|
errorCode?: string;
|
|
@@ -589,7 +587,7 @@ export type WorkflowRunState = {
|
|
|
589
587
|
currentNode?: string;
|
|
590
588
|
currentAttemptId?: string;
|
|
591
589
|
currentNodeStartedAt?: string;
|
|
592
|
-
/** Durable
|
|
590
|
+
/** Durable active-execution deadline for the current attempt. Null disables the deadline. */
|
|
593
591
|
currentNodeDeadlineAt?: string | null;
|
|
594
592
|
currentSettingsScopeId?: string;
|
|
595
593
|
currentSettingsChangeNumber?: number;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { JsonValue } from "../state/json.js";
|
|
2
|
+
import { type WorkflowMessageContent, type WorkflowStepReason } from "../state/workflow-messages.js";
|
|
3
|
+
export declare const WORKFLOW_STEP_MESSAGE_TYPE = "pi-workflows-step";
|
|
4
|
+
export declare const WORKFLOW_DECISION_MESSAGE_TYPE = "pi-workflows-interaction";
|
|
5
|
+
export declare const WORKFLOW_NOTIFICATION_MESSAGE_TYPE = "pi-workflows-notification";
|
|
6
|
+
export declare const WORKFLOW_TERMINAL_MESSAGE_TYPE = "pi-workflows-presentation";
|
|
7
|
+
export declare const WORKFLOW_FOLLOW_UP_MESSAGE_TYPE = "pi-workflows-follow-up";
|
|
8
|
+
export declare function stepWorkflowMessageContent(options: {
|
|
9
|
+
workflowMessageId: string;
|
|
10
|
+
requestId: string;
|
|
11
|
+
contract: JsonValue;
|
|
12
|
+
reason: WorkflowStepReason;
|
|
13
|
+
}): WorkflowMessageContent;
|
|
14
|
+
export declare function decisionWorkflowMessageContent(options: {
|
|
15
|
+
workflowMessageId: string;
|
|
16
|
+
requestId: string;
|
|
17
|
+
runId: string;
|
|
18
|
+
contract: JsonValue;
|
|
19
|
+
}): WorkflowMessageContent;
|
|
20
|
+
export declare function notificationWorkflowMessageContent(options: {
|
|
21
|
+
workflowMessageId: string;
|
|
22
|
+
notificationId: string;
|
|
23
|
+
runId: string;
|
|
24
|
+
kind: "progress" | "final";
|
|
25
|
+
content: string;
|
|
26
|
+
}): WorkflowMessageContent;
|
|
27
|
+
export declare function terminalWorkflowMessageContent(options: {
|
|
28
|
+
workflowMessageId: string;
|
|
29
|
+
runId: string;
|
|
30
|
+
content: string;
|
|
31
|
+
details: JsonValue;
|
|
32
|
+
}): WorkflowMessageContent;
|
|
33
|
+
export declare function followUpWorkflowMessageContent(options: {
|
|
34
|
+
workflowMessageId: string;
|
|
35
|
+
followUpId: string;
|
|
36
|
+
runId: string;
|
|
37
|
+
prompt: string;
|
|
38
|
+
}): WorkflowMessageContent;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { WORKFLOW_MESSAGE_CONTENT_SCHEMA, } from "../state/workflow-messages.js";
|
|
2
|
+
export const WORKFLOW_STEP_MESSAGE_TYPE = "pi-workflows-step";
|
|
3
|
+
export const WORKFLOW_DECISION_MESSAGE_TYPE = "pi-workflows-interaction";
|
|
4
|
+
export const WORKFLOW_NOTIFICATION_MESSAGE_TYPE = "pi-workflows-notification";
|
|
5
|
+
export const WORKFLOW_TERMINAL_MESSAGE_TYPE = "pi-workflows-presentation";
|
|
6
|
+
export const WORKFLOW_FOLLOW_UP_MESSAGE_TYPE = "pi-workflows-follow-up";
|
|
7
|
+
export function stepWorkflowMessageContent(options) {
|
|
8
|
+
const outer = requireRecord(options.contract, "Stored workflow step contract");
|
|
9
|
+
const agent = requireAgentContract(outer.contract);
|
|
10
|
+
const details = {
|
|
11
|
+
schema: "pi-workflows.agent-step-message.v1",
|
|
12
|
+
kind: "step",
|
|
13
|
+
contract: agent,
|
|
14
|
+
requestId: options.requestId,
|
|
15
|
+
workflowMessageId: options.workflowMessageId,
|
|
16
|
+
reason: options.reason,
|
|
17
|
+
};
|
|
18
|
+
if (isRecord(outer.presentation))
|
|
19
|
+
details.presentation = outer.presentation;
|
|
20
|
+
return {
|
|
21
|
+
schema: WORKFLOW_MESSAGE_CONTENT_SCHEMA,
|
|
22
|
+
customType: WORKFLOW_STEP_MESSAGE_TYPE,
|
|
23
|
+
content: typeof outer.prompt === "string" ? outer.prompt : "Continue the workflow step.",
|
|
24
|
+
display: true,
|
|
25
|
+
details,
|
|
26
|
+
triggerTurn: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function decisionWorkflowMessageContent(options) {
|
|
30
|
+
const contract = requireRecord(options.contract, "Stored workflow decision contract");
|
|
31
|
+
return {
|
|
32
|
+
schema: WORKFLOW_MESSAGE_CONTENT_SCHEMA,
|
|
33
|
+
customType: WORKFLOW_DECISION_MESSAGE_TYPE,
|
|
34
|
+
content: decisionPrompt(contract),
|
|
35
|
+
display: true,
|
|
36
|
+
details: {
|
|
37
|
+
workflowMessageId: options.workflowMessageId,
|
|
38
|
+
requestId: options.requestId,
|
|
39
|
+
runId: options.runId,
|
|
40
|
+
kind: "decision",
|
|
41
|
+
},
|
|
42
|
+
triggerTurn: false,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function notificationWorkflowMessageContent(options) {
|
|
46
|
+
return {
|
|
47
|
+
schema: WORKFLOW_MESSAGE_CONTENT_SCHEMA,
|
|
48
|
+
customType: WORKFLOW_NOTIFICATION_MESSAGE_TYPE,
|
|
49
|
+
content: options.content,
|
|
50
|
+
display: true,
|
|
51
|
+
details: {
|
|
52
|
+
workflowMessageId: options.workflowMessageId,
|
|
53
|
+
notificationId: options.notificationId,
|
|
54
|
+
runId: options.runId,
|
|
55
|
+
kind: options.kind,
|
|
56
|
+
},
|
|
57
|
+
triggerTurn: false,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function terminalWorkflowMessageContent(options) {
|
|
61
|
+
return {
|
|
62
|
+
schema: WORKFLOW_MESSAGE_CONTENT_SCHEMA,
|
|
63
|
+
customType: WORKFLOW_TERMINAL_MESSAGE_TYPE,
|
|
64
|
+
content: options.content,
|
|
65
|
+
display: false,
|
|
66
|
+
details: {
|
|
67
|
+
workflowMessageId: options.workflowMessageId,
|
|
68
|
+
runId: options.runId,
|
|
69
|
+
kind: "terminal",
|
|
70
|
+
terminal: options.details,
|
|
71
|
+
},
|
|
72
|
+
triggerTurn: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export function followUpWorkflowMessageContent(options) {
|
|
76
|
+
return {
|
|
77
|
+
schema: WORKFLOW_MESSAGE_CONTENT_SCHEMA,
|
|
78
|
+
customType: WORKFLOW_FOLLOW_UP_MESSAGE_TYPE,
|
|
79
|
+
content: options.prompt,
|
|
80
|
+
display: true,
|
|
81
|
+
details: {
|
|
82
|
+
workflowMessageId: options.workflowMessageId,
|
|
83
|
+
followUpId: options.followUpId,
|
|
84
|
+
runId: options.runId,
|
|
85
|
+
kind: "followUp",
|
|
86
|
+
},
|
|
87
|
+
triggerTurn: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function requireAgentContract(value) {
|
|
91
|
+
if (!isRecord(value) ||
|
|
92
|
+
typeof value.runId !== "string" ||
|
|
93
|
+
typeof value.workflowName !== "string" ||
|
|
94
|
+
typeof value.nodeId !== "string" ||
|
|
95
|
+
typeof value.attemptId !== "string" ||
|
|
96
|
+
(value.completion !== "submit" && value.completion !== "assistant")) {
|
|
97
|
+
throw new Error("Stored workflow agent contract is invalid");
|
|
98
|
+
}
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
function decisionPrompt(contract) {
|
|
102
|
+
const title = typeof contract.title === "string" ? contract.title : "Workflow decision";
|
|
103
|
+
const presentation = isRecord(contract.presentation) ? contract.presentation : {};
|
|
104
|
+
const blocks = Array.isArray(presentation.blocks)
|
|
105
|
+
? presentation.blocks.flatMap((block) => decisionBlockText(block))
|
|
106
|
+
: [];
|
|
107
|
+
const choices = isRecord(contract.choices)
|
|
108
|
+
? Object.entries(contract.choices).map(([key, value]) => {
|
|
109
|
+
const choice = isRecord(value) ? value : {};
|
|
110
|
+
const label = typeof choice.label === "string" ? choice.label : key;
|
|
111
|
+
const input = isRecord(choice.input) ? choice.input : undefined;
|
|
112
|
+
const prompt = input === undefined ? "" : `; input: ${String(input.prompt ?? "text")}`;
|
|
113
|
+
return `- ${key}: ${label}${prompt}`;
|
|
114
|
+
})
|
|
115
|
+
: [];
|
|
116
|
+
return [
|
|
117
|
+
title,
|
|
118
|
+
typeof presentation.summary === "string" ? presentation.summary : "",
|
|
119
|
+
...blocks,
|
|
120
|
+
choices.length === 0 ? "" : `Choices:\n${choices.join("\n")}`,
|
|
121
|
+
"A human must answer this protected decision with `/workflow answer`.",
|
|
122
|
+
]
|
|
123
|
+
.filter(Boolean)
|
|
124
|
+
.join("\n\n");
|
|
125
|
+
}
|
|
126
|
+
function decisionBlockText(value) {
|
|
127
|
+
if (!isRecord(value))
|
|
128
|
+
return [];
|
|
129
|
+
if (value.kind === "paragraph" && typeof value.text === "string")
|
|
130
|
+
return [value.text];
|
|
131
|
+
if (value.kind === "section" && typeof value.title === "string")
|
|
132
|
+
return [value.title];
|
|
133
|
+
if (value.kind === "preformatted" && typeof value.text === "string")
|
|
134
|
+
return [value.text];
|
|
135
|
+
if (value.kind === "bullets" && Array.isArray(value.items)) {
|
|
136
|
+
return [value.items.map((item) => `- ${String(item)}`).join("\n")];
|
|
137
|
+
}
|
|
138
|
+
if (value.kind === "fields" && Array.isArray(value.items)) {
|
|
139
|
+
return [
|
|
140
|
+
value.items
|
|
141
|
+
.flatMap((item) => isRecord(item) && typeof item.label === "string" && typeof item.value === "string"
|
|
142
|
+
? [`${item.label}: ${item.value}`]
|
|
143
|
+
: [])
|
|
144
|
+
.join("\n"),
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
function requireRecord(value, label) {
|
|
150
|
+
if (!isRecord(value))
|
|
151
|
+
throw new Error(`${label} is invalid`);
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
function isRecord(value) {
|
|
155
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=workflow-message-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-message-content.js","sourceRoot":"","sources":["../../src/workflows/workflow-message-content.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,GAGhC,MAAM,+BAA+B,CAAC;AAGvC,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAAmB,CAAC;AAC9D,MAAM,CAAC,MAAM,8BAA8B,GAAG,0BAA0B,CAAC;AACzE,MAAM,CAAC,MAAM,kCAAkC,GAAG,2BAA2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KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -26,7 +26,7 @@ When pi-workflows runs inside Herdr, show a shortcut that opens the current run
|
|
|
26
26
|
|
|
27
27
|
### One package with two host entry points
|
|
28
28
|
|
|
29
|
-
The package root will contain `herdr-plugin.toml`. Pi loads the existing extension entry point. Herdr loads a `piw` pane entry point from the same package root. A small checked-in JavaScript launcher validates
|
|
29
|
+
The package root will contain `herdr-plugin.toml`. Pi loads the existing extension entry point. Herdr loads a `piw` pane entry point from the same package root. A small checked-in JavaScript launcher validates the workflow run ID and starts `piw` with an argv array. It uses Herdr's configured executable path when that path works. If Herdr replaced its executable after the server started and the configured path no longer exists, the launcher retries the pane label command through `PATH`.
|
|
30
30
|
|
|
31
31
|
`pi-workflows herdr setup` explicitly links the current package root with `herdr plugin link`. It is idempotent and never changes plugin registration during normal Pi startup.
|
|
32
32
|
|
|
@@ -58,6 +58,7 @@ Herdr's public snapshot does not expose plugin metadata tokens. The launcher wil
|
|
|
58
58
|
- All six placements work and preserve the calling pane unless the user selects a focused viewer.
|
|
59
59
|
- Repeated opens and Pi reloads focus the existing run viewer.
|
|
60
60
|
- Failures produce bounded, useful messages and leave no empty tab or workspace.
|
|
61
|
+
- A viewer still opens when the Herdr server supplies a replaced executable path and the current `herdr` command is in `PATH`.
|
|
61
62
|
- The package tarball contains the Herdr manifest and launcher.
|
|
62
63
|
- `osolmaz/pi-workflows` is public, has a root `herdr-plugin.toml`, and has the `herdr-plugin` GitHub topic.
|
|
63
64
|
|
|
@@ -6,7 +6,7 @@ date: 2026-08-20
|
|
|
6
6
|
|
|
7
7
|
# Make deferred workflow launches durable
|
|
8
8
|
|
|
9
|
-
The launch queue and activation contract in this plan remain current. [
|
|
9
|
+
The launch queue and activation contract in this plan remain current. The send-specific parts are historical. [Terminal workflow messages](DEFERRED_TURNS.md) and the approved [workflow-message restoration plan](2026-09-02-unify-workflow-messages-plan.md) replace every deferred-turn intent and launch-failure sender in this plan with the shared `workflow_messages` path.
|
|
10
10
|
|
|
11
11
|
## Goal
|
|
12
12
|
|
|
@@ -6,9 +6,9 @@ date: 2026-08-25
|
|
|
6
6
|
|
|
7
7
|
# Continue normal work after a workflow finishes
|
|
8
8
|
|
|
9
|
-
A workflow can save several normal
|
|
9
|
+
A workflow can save several prompts for normal work while it runs. Pi Workflows sends them in order only after the workflow is officially terminal, its terminal message is sent, and its terminal model turn has ended. The completed workflow stays terminal and does not enter its start node again.
|
|
10
10
|
|
|
11
|
-
Follow-up prompts are separate from workflow settings. JSON Patch changes future workflow behavior. Follow-up actions create later normal
|
|
11
|
+
Follow-up prompts are separate from workflow settings. JSON Patch changes future workflow behavior. Follow-up actions create later normal conversation turns.
|
|
12
12
|
|
|
13
13
|
## Queue and remove prompts
|
|
14
14
|
|
|
@@ -61,74 +61,50 @@ The host creates the actor and stable request identity. Prompt data cannot claim
|
|
|
61
61
|
|
|
62
62
|
## Ordering and run states
|
|
63
63
|
|
|
64
|
-
Prompts keep database acceptance order. Several
|
|
64
|
+
Prompts keep database acceptance order. Several requests can add several prompts while one workflow response is in progress.
|
|
65
65
|
|
|
66
66
|
- Running, paused, parked, and waiting workflows accept new prompts.
|
|
67
67
|
- Pause and park keep prompts queued.
|
|
68
|
-
- A checkpoint continuation
|
|
69
|
-
- Successful completion records the terminal run and terminal
|
|
68
|
+
- A checkpoint continuation keeps queued prompt rows attached to the chain member that accepted them. The host walks the continuation chain to determine their final source outcome; it does not rewrite the rows.
|
|
69
|
+
- Successful completion records the terminal run and terminal workflow message before a follow-up can send.
|
|
70
70
|
- Failed, timed-out, and cancelled workflows cancel every unsent prompt.
|
|
71
71
|
- A terminal workflow rejects new prompts. Repeating an earlier request ID can still return its first result.
|
|
72
72
|
|
|
73
73
|
A repeated request ID with the same prompt returns the first result. Reusing that ID with different content fails.
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
Each accepted prompt creates its `workflow_follow_ups` source record and one `followUp` workflow message in one transaction. The message points to its source through `sourceId`; the source row stores no message pointer. The host derives eligibility from saved domain facts. A follow-up is eligible only after the source continuation chain completes successfully, its terminal message turn ends, every earlier accepted follow-up is settled or cancelled, and no nonterminal run, including one waiting for a checkpoint or protected decision, reserves the origin session.
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
## One message path
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
- `pending`: the terminal run has a final response that has not settled;
|
|
81
|
-
- `settled`: the active session branch contains the presentation message and its completed assistant response;
|
|
82
|
-
- `unavailable`: the extension recorded a definite timeout, failure, or restart gap.
|
|
79
|
+
The shared `WorkflowMessageCoordinator` handles follow-ups. There is no follow-up sender.
|
|
83
80
|
|
|
84
|
-
|
|
81
|
+
1. Wait for the terminal outcome, sent terminal workflow message, and matching model-turn end.
|
|
82
|
+
2. After every host connection, wait for the complete origin-session view and report the active branch.
|
|
83
|
+
3. Wait until the host view names this `followUp` as the next eligible pending message, Pi is idle, and no earlier workflow message is active.
|
|
84
|
+
4. Keep its ID in the coordinator's in-memory queued map and report a matching active-branch entry when one already exists.
|
|
85
|
+
5. Otherwise, recheck synchronously that Pi is idle, has no pending input, the message is absent, and the connection still owns the active coordinator epoch. Call documented `pi.sendMessage()` with the follow-up prompt and `triggerTurn: true` without an `await` between the check and call.
|
|
86
|
+
6. Report the active branch so the host saves the observed Pi entry ID and marks the message `sent`.
|
|
87
|
+
7. Wait for that turn and any workflow it starts to finish before the next follow-up becomes eligible.
|
|
85
88
|
|
|
86
|
-
The
|
|
87
|
-
|
|
88
|
-
## Delivery
|
|
89
|
-
|
|
90
|
-
The follow-up coordinator handles one prompt at a time:
|
|
91
|
-
|
|
92
|
-
1. Wait for terminal workflow state, a resolved terminal decision intent, and a completed final-response barrier.
|
|
93
|
-
2. Wait for the target session to be idle and have no active workflow.
|
|
94
|
-
3. Claim the first ready prompt with a lease.
|
|
95
|
-
4. Scan the active session branch for its stable follow-up ID.
|
|
96
|
-
5. If the message already exists, save its session entry ID without sending it again.
|
|
97
|
-
6. Otherwise, call documented `pi.sendUserMessage` with the prompt and a short nonsecret ID in a Markdown comment.
|
|
98
|
-
7. After Pi saves the normal user message, scan the branch and save its entry ID and send time.
|
|
99
|
-
8. Wait for that user turn and any workflow it starts to finish before taking the next prompt.
|
|
100
|
-
|
|
101
|
-
`pi.sendUserMessage` returns no message ID. Branch evidence is required after a new send and after restart.
|
|
102
|
-
|
|
103
|
-
The follow-up message is a normal user message. It can start normal work or a different workflow. It cannot resume or reactivate the completed workflow. A `restart` selected from the terminal decision is a separate immutable workflow run, not a follow-up prompt.
|
|
89
|
+
The follow-up custom message starts normal conversation work and can use a user-style renderer. Its internal workflow message ID stays in custom details and does not enter provider-facing content. It can ask the model to start another workflow, but it cannot resume or reactivate the completed workflow. Text that starts with `/` remains plain model input; a custom message cannot dispatch a Pi slash command or expand a prompt template. A `restart` chosen from the terminal turn creates a separate immutable workflow run.
|
|
104
90
|
|
|
105
91
|
Follow-up storage contains only prompts explicitly queued through this feature. Terminal restart does not find, copy, hash, or store an original user message. Conversation history remains owned by Pi.
|
|
106
92
|
|
|
107
93
|
## Failure handling
|
|
108
94
|
|
|
109
|
-
- A crash before
|
|
110
|
-
- A crash after
|
|
111
|
-
- A
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
- Branching follows the active Pi branch. A message on another branch does not count as delivered on the active branch.
|
|
95
|
+
- A crash before send leaves the workflow message `pending`.
|
|
96
|
+
- A crash after send but before the branch report also leaves it `pending`; reconnect reports the active branch before another send.
|
|
97
|
+
- A matching hidden workflow message ID changes a pending or cancelled message to `sent` because the Pi entry already exists.
|
|
98
|
+
- An unavailable session leaves the workflow message `pending`.
|
|
99
|
+
- An entry on another Pi branch does not confirm the send on the active branch.
|
|
100
|
+
- A stale coordinator epoch cannot send or report message state.
|
|
116
101
|
|
|
117
|
-
|
|
102
|
+
Documented Pi APIs do not prove cross-branch absence or exactly-once model execution. Pi Workflows guarantees only its saved order, message state, active-branch evidence, and local state. Sending also needs a later live Pi process, target session, and provider. This feature adds no external service.
|
|
118
103
|
|
|
119
104
|
## Saved states
|
|
120
105
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
- `queued`;
|
|
124
|
-
- `pending_presentation`;
|
|
125
|
-
- `ready`;
|
|
126
|
-
- `sent`;
|
|
127
|
-
- `removed`;
|
|
128
|
-
- `cancelled`.
|
|
129
|
-
|
|
130
|
-
A lease is temporary claim data, not another follow-up state.
|
|
106
|
+
`workflow_follow_ups` stores each prompt, source, queue order, and whether the source was removed or cancelled. It does not copy a workflow message ID, message state, or Pi entry ID. `workflow_messages` owns `pending`, `sent`, and `cancelled` state and points back to the source row.
|
|
131
107
|
|
|
132
|
-
|
|
108
|
+
Prompt text stays in the existing content-addressed value store. Normal status views show IDs, order, source type, and state without printing full prompts.
|
|
133
109
|
|
|
134
|
-
This is
|
|
110
|
+
This is an alpha hard change. It keeps schema version 1 and adds no Pi core change, private Pi API, external queue, compatibility reader, dual write, alias, fallback, or second schema.
|
|
@@ -6,7 +6,7 @@ date: 2026-08-30
|
|
|
6
6
|
|
|
7
7
|
# Run workflows outside Pi
|
|
8
8
|
|
|
9
|
-
Status: implemented
|
|
9
|
+
Status: implemented. The implementation keeps schema version 1, uses one global on-demand host, and has no embedded production fallback. The approved [workflow-message restoration plan](2026-09-02-unify-workflow-messages-plan.md) fixes the later model-turn status bug and restores session features that the hard cut removed.
|
|
10
10
|
|
|
11
11
|
A live workflow lost its lease while it was still working. The workflow engine kept the Node.js event loop busy, so its renewal timer did not run before the 30-second lease expired. The next state write used a generic error, the extension treated the error as a crash, and durable state was left with a running queue row, a running attempt, an expired lease, and a separate failed audit event.
|
|
12
12
|
|
|
@@ -209,7 +209,7 @@ Keep one active interactive request per Pi session. Other requests remain ordere
|
|
|
209
209
|
|
|
210
210
|
A protected human decision is displayed without starting a model turn. The model-facing workflow tool rejects it. A person answers it through the origin Pi session, while an ordinary checkpoint keeps its model-facing answer path.
|
|
211
211
|
|
|
212
|
-
Notify nodes
|
|
212
|
+
Notify nodes and terminal results create `workflow_messages` records in the same transaction as their source facts. The origin Pi session claims and adopts both message kinds through the one shared coordinator. There is no notification outbox or terminal-turn intent send path.
|
|
213
213
|
|
|
214
214
|
Detached workflows can use host-managed `pi --mode rpc` children. Their execution mode and origin are durable provenance.
|
|
215
215
|
|
|
@@ -236,7 +236,7 @@ The new state shape will add the minimum durable records needed for:
|
|
|
236
236
|
- child process epochs and exits;
|
|
237
237
|
- uncertain effects when existing effect rows cannot express the state.
|
|
238
238
|
|
|
239
|
-
Reuse
|
|
239
|
+
Reuse attempts, effects, and feature-specific source records when they already provide the required contract. `workflow_messages` is the only record for content that Pi must add to an origin session. Add no parallel send record for the same fact.
|
|
240
240
|
|
|
241
241
|
## Part 10: Hard cutover
|
|
242
242
|
|
|
@@ -6,6 +6,10 @@ date: 2026-09-01
|
|
|
6
6
|
|
|
7
7
|
# Restore workflow session delivery and controls
|
|
8
8
|
|
|
9
|
+
## Follow-up
|
|
10
|
+
|
|
11
|
+
This repair restored the widget, Escape pause, and the first shared sender. Version 0.16.0 still has a model-turn status bug and did not preserve all earlier session features. The approved [workflow-message restoration plan](2026-09-02-unify-workflow-messages-plan.md) replaces separate send records with one workflow-message contract and restores the remaining behavior.
|
|
12
|
+
|
|
9
13
|
The out-of-process workflow host removed the Pi workflow widget and Escape-to-pause behavior. A later delivery safety fix also caused normal polling to report `Interactive request presentation claim conflict`. This plan restores those features and fixes delivery without bringing back the embedded workflow runtime.
|
|
10
14
|
|
|
11
15
|
[Workflow host](WORKFLOW_HOST.md) remains the process and state specification. [Workflow step messages](WORKFLOW_STEP_MESSAGES.md) remains the session message specification. This plan records the cause, scope, implementation order, and acceptance checks for the repair.
|
|
@@ -7,6 +7,10 @@ status: implemented
|
|
|
7
7
|
|
|
8
8
|
# Unify live workflow clients
|
|
9
9
|
|
|
10
|
+
## Follow-up
|
|
11
|
+
|
|
12
|
+
The single host, client protocol, and run view remain the correct base. Version 0.16.0 still uses a short activity lease, clears terminal session display too soon, and did not preserve all session features during the cut. [Unify workflow messages and restore hosted behavior](2026-09-02-unify-workflow-messages-plan.md) is the approved follow-up. It replaces the activity lease with Pi turn events and gives all Pi-bound workflow content one shared message path.
|
|
13
|
+
|
|
10
14
|
## Goal
|
|
11
15
|
|
|
12
16
|
Give every live Pi Workflows interface one source of truth.
|
|
@@ -131,7 +135,7 @@ The host produces `pi-workflows.run-view.v1` from one consistent host-side read.
|
|
|
131
135
|
- live and interruption facts;
|
|
132
136
|
- a `display` object with effective status, activity kind, allowed controls, and either the complete inline reason or a small notice plus a digest-bound `reasonContent` reference.
|
|
133
137
|
|
|
134
|
-
The run-list row contains the same `display` object. The origin-session response contains the complete active run view or no active run plus an ordered byte-bounded window of
|
|
138
|
+
The run-list row contains the same `display` object. The origin-session response contains the complete active run view or no active run plus an ordered byte-bounded window of workflow messages and their complete count. The approved follow-up also retains the newest terminal run for its bounded display period. Message records include the source, content reference, order, send state, and Pi entry needed by the shared coordinator. The host returns this session response from one consistent read. A client does not resolve a reservation, load a run, or inspect message tables in separate reads.
|
|
135
139
|
|
|
136
140
|
Large history remains available through byte-bounded pages. The host counts histories and reads only the selected SQLite ranges. A page has an item limit and an encoded byte budget. It echoes the requested cursor and run-view revision, and a client rejects a response that no longer matches its request or current snapshot. Large workflow topology has bounded node, edge, graph-step, and transition projections plus durable references to the complete original definition and complete graph history. TypeScript clients assemble every run-history page for one revision and hydrate the complete definition. Values that do not fit inline use digest-bound opaque content references, and `view.content` returns the complete value in verified chunks before a TypeScript non-interactive viewer emits the complete run or the extension updates its widget. TypeScript and Rust load the complete graph steps and transitions through the same verified content interface. Rust also requests and verifies the complete referenced workflow definition, decodes only the complete value, and then builds the graph layout. Session-event pages include the replay checkpoint immediately before their first event. A large checkpoint uses the same content protocol. TypeScript hydrates it with the run view, and Rust requests and resolves it before replay. The complete logical result remains available. The client protocol does not add an arbitrary user-visible truncation.
|
|
137
141
|
|
|
@@ -78,6 +78,14 @@ An API-key run can use an ephemeral agent directory. Pi receives the caller's ex
|
|
|
78
78
|
|
|
79
79
|
Before a model call, the runner will execute Pi's documented `auth check` command for the exact provider and model. It will stop before the workflow starts when authentication or model resolution fails.
|
|
80
80
|
|
|
81
|
+
## Startup recovery
|
|
82
|
+
|
|
83
|
+
Before Pi starts, the runner creates an incompatible state fixture inside the guarded temporary home. It then starts Pi and waits for the extension's one bounded host-unavailable warning. The runner moves the fixture intact, as the alpha reset instruction requires, and starts the host through the installed client.
|
|
84
|
+
|
|
85
|
+
The same Pi process must establish its origin-session subscription without a restart. An observer subscription verifies that the host has a coordinator epoch for that session. More polling must not produce a second host-unavailable warning. The normal runtime workflow then proves that the recovered session receives live widget updates.
|
|
86
|
+
|
|
87
|
+
This check reproduces the case where Pi starts before the host can open durable state. It changes no operator database or Pi session.
|
|
88
|
+
|
|
81
89
|
## Runtime workflow
|
|
82
90
|
|
|
83
91
|
The first workflow does not call a model. It has one delayed compute step and a fixed final output.
|
|
@@ -179,8 +187,14 @@ Add tests for:
|
|
|
179
187
|
- timeout, missing-run, and host connection failures;
|
|
180
188
|
- packed npm installation with production dependencies;
|
|
181
189
|
- extension source isolation in base Pi;
|
|
190
|
+
- origin-session reconnection after initial host startup fails;
|
|
191
|
+
- one warning during the simulated outage;
|
|
182
192
|
- RPC widget and status transitions;
|
|
183
193
|
- pause with no active worker;
|
|
194
|
+
- abort of an active origin-session model turn;
|
|
195
|
+
- one new resumed step message and one fresh model turn after resume;
|
|
196
|
+
- protected decision revision stability across pause and resume;
|
|
197
|
+
- a complete session capture with no false host-interruption diagnostic;
|
|
184
198
|
- resume and completion;
|
|
185
199
|
- exact provider and model validation;
|
|
186
200
|
- model fallback rejection;
|
|
@@ -222,4 +236,4 @@ The implementation uses documented Pi package installation and CLI model selecti
|
|
|
222
236
|
|
|
223
237
|
## Completion criteria
|
|
224
238
|
|
|
225
|
-
The work is complete when a clean base Pi process loads only the packed Pi Workflows package. The deterministic runtime workflow must pass every widget and lifecycle check, while `piw --once` must agree with Pi and the host. An explicitly selected built-in model must complete the structured agent workflow. Cleanup must leave no process or large temporary directory, and all repository checks must pass.
|
|
239
|
+
The work is complete when a clean base Pi process loads only the packed Pi Workflows package. The same Pi process must recover after the temporary incompatible-state gate is removed. The deterministic runtime workflow must pass every widget and lifecycle check, while `piw --once` must agree with Pi and the host. The full Pi mock-provider test must abort an active origin-session workflow turn, resume it through a distinct resumed step message, complete through one fresh model turn, and leave a complete session capture. The installed real-model check must reject a false host-interruption diagnostic. An explicitly selected built-in model must complete the structured agent workflow. Cleanup must leave no process or large temporary directory, and all repository checks must pass.
|