@osolmaz/pi-workflows 0.12.0 → 0.13.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 +56 -31
- package/dist/builtins/autodoc.workflow.d.ts +4 -4
- package/dist/builtins/autoimplement.workflow.d.ts +797 -142
- package/dist/builtins/autoimplement.workflow.js +17 -105
- package/dist/builtins/autoimplement.workflow.js.map +1 -1
- package/dist/builtins/autoplan.workflow.d.ts +126 -13
- package/dist/builtins/autoplan.workflow.js +200 -29
- package/dist/builtins/autoplan.workflow.js.map +1 -1
- package/dist/builtins/catalog.js +7 -5
- package/dist/builtins/catalog.js.map +1 -1
- package/dist/builtins/index.d.ts +4 -2
- package/dist/builtins/index.js +3 -1
- package/dist/builtins/index.js.map +1 -1
- package/dist/builtins/monitor.workflow.d.ts +56 -23
- package/dist/builtins/monitor.workflow.js +508 -329
- package/dist/builtins/monitor.workflow.js.map +1 -1
- package/dist/builtins/pi-agent-group.d.ts +72 -0
- package/dist/builtins/pi-agent-group.js +1087 -0
- package/dist/builtins/pi-agent-group.js.map +1 -0
- package/dist/builtins/plain-summary.workflow.d.ts +32 -0
- package/dist/builtins/plain-summary.workflow.js +134 -0
- package/dist/builtins/plain-summary.workflow.js.map +1 -0
- package/dist/builtins/plan-approval.workflow.d.ts +39 -5
- package/dist/builtins/plan-approval.workflow.js +92 -14
- package/dist/builtins/plan-approval.workflow.js.map +1 -1
- package/dist/builtins/plan-change.workflow.d.ts +449 -0
- package/dist/builtins/plan-change.workflow.js +256 -0
- package/dist/builtins/plan-change.workflow.js.map +1 -0
- package/dist/builtins/plan-presentation.js +2 -2
- package/dist/builtins/plan-presentation.js.map +1 -1
- package/dist/builtins/sanity-check.workflow.d.ts +50 -6
- package/dist/builtins/sanity-check.workflow.js +150 -28
- package/dist/builtins/sanity-check.workflow.js.map +1 -1
- package/dist/controllers/effects.d.ts +3 -2
- package/dist/controllers/effects.js +8 -1
- package/dist/controllers/effects.js.map +1 -1
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/index.js +1 -1
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/manager.d.ts +1 -0
- package/dist/controllers/manager.js +41 -17
- package/dist/controllers/manager.js.map +1 -1
- package/dist/controllers/sqlite.d.ts +107 -85
- package/dist/controllers/sqlite.js +1611 -1486
- package/dist/controllers/sqlite.js.map +1 -1
- package/dist/controllers/store.d.ts +9 -8
- package/dist/controllers/store.js +1 -31
- package/dist/controllers/store.js.map +1 -1
- package/dist/controllers/types.d.ts +3 -0
- package/dist/controllers/workflow-engine-scheduler.d.ts +1 -1
- package/dist/controllers/workflow-engine-scheduler.js +3 -5
- package/dist/controllers/workflow-engine-scheduler.js.map +1 -1
- package/dist/controllers/workflows.d.ts +2 -2
- package/dist/controllers/workflows.js +11 -10
- package/dist/controllers/workflows.js.map +1 -1
- package/dist/extension/controller-host.js +2 -2
- package/dist/extension/controller-host.js.map +1 -1
- package/dist/extension/decision-channels.d.ts +4 -2
- package/dist/extension/decision-channels.js +333 -146
- package/dist/extension/decision-channels.js.map +1 -1
- package/dist/extension/executor.d.ts +9 -2
- package/dist/extension/executor.js +89 -2
- package/dist/extension/executor.js.map +1 -1
- package/dist/extension/herdr-viewer.d.ts +0 -1
- package/dist/extension/herdr-viewer.js +0 -4
- package/dist/extension/herdr-viewer.js.map +1 -1
- package/dist/extension/index.js +209 -127
- package/dist/extension/index.js.map +1 -1
- package/dist/extension/recorder.d.ts +3 -10
- package/dist/extension/recorder.js +13 -22
- package/dist/extension/recorder.js.map +1 -1
- package/dist/extension/session-events.d.ts +2 -2
- package/dist/extension/step-message.d.ts +7 -2
- package/dist/extension/step-message.js +94 -2
- package/dist/extension/step-message.js.map +1 -1
- package/dist/extension/widget.js +29 -3
- package/dist/extension/widget.js.map +1 -1
- package/dist/host/rpc-executor.d.ts +3 -0
- package/dist/host/rpc-executor.js +2 -0
- package/dist/host/rpc-executor.js.map +1 -1
- package/dist/host/runner.d.ts +3 -6
- package/dist/host/runner.js +83 -32
- package/dist/host/runner.js.map +1 -1
- package/dist/render/graph-render.js +15 -10
- package/dist/render/graph-render.js.map +1 -1
- package/dist/state/database.d.ts +35 -0
- package/dist/state/database.js +287 -0
- package/dist/state/database.js.map +1 -0
- package/dist/state/index.d.ts +4 -0
- package/dist/state/index.js +5 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/json.d.ts +6 -0
- package/dist/state/json.js +38 -0
- package/dist/state/json.js.map +1 -0
- package/dist/state/mutation.d.ts +57 -0
- package/dist/state/mutation.js +255 -0
- package/dist/state/mutation.js.map +1 -0
- package/dist/state/schema.d.ts +6 -0
- package/dist/state/schema.js +473 -0
- package/dist/state/schema.js.map +1 -0
- package/dist/viewer/cli.d.ts +2 -2
- package/dist/viewer/cli.js +142 -122
- package/dist/viewer/cli.js.map +1 -1
- package/dist/viewer/render.d.ts +4 -4
- package/dist/viewer/render.js +9 -23
- package/dist/viewer/render.js.map +1 -1
- package/dist/viewer/session-reducer.d.ts +1 -1
- package/dist/viewer/session-reducer.js +1 -1
- package/dist/viewer/tui.d.ts +3 -3
- package/dist/viewer/tui.js +15 -13
- package/dist/viewer/tui.js.map +1 -1
- package/dist/viewer/watch.d.ts +2 -5
- package/dist/viewer/watch.js +13 -13
- package/dist/viewer/watch.js.map +1 -1
- package/dist/workflows/catalog.js +7 -2
- package/dist/workflows/catalog.js.map +1 -1
- package/dist/workflows/composition.js +20 -2
- package/dist/workflows/composition.js.map +1 -1
- package/dist/workflows/decision-presentation.d.ts +1 -1
- package/dist/workflows/decision-presentation.js +51 -38
- package/dist/workflows/decision-presentation.js.map +1 -1
- package/dist/workflows/definition.d.ts +6 -2
- package/dist/workflows/definition.js +17 -0
- package/dist/workflows/definition.js.map +1 -1
- package/dist/workflows/engine.d.ts +7 -7
- package/dist/workflows/engine.js +196 -115
- package/dist/workflows/engine.js.map +1 -1
- package/dist/workflows/errors.d.ts +16 -3
- package/dist/workflows/errors.js +18 -3
- package/dist/workflows/errors.js.map +1 -1
- package/dist/workflows/human-decision.d.ts +45 -8
- package/dist/workflows/human-decision.js +641 -274
- package/dist/workflows/human-decision.js.map +1 -1
- package/dist/workflows/index.d.ts +5 -6
- package/dist/workflows/index.js +4 -5
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/progress.d.ts +1 -0
- package/dist/workflows/progress.js +15 -3
- package/dist/workflows/progress.js.map +1 -1
- package/dist/workflows/schema.js +27 -1
- package/dist/workflows/schema.js.map +1 -1
- package/dist/workflows/store.d.ts +83 -103
- package/dist/workflows/store.js +907 -951
- package/dist/workflows/store.js.map +1 -1
- package/dist/workflows/types.d.ts +88 -126
- package/docs/CONTROLLERS.md +10 -8
- package/docs/DEFERRED_TURNS.md +2 -2
- package/docs/DESIGN_PHILOSOPHY.md +4 -2
- package/docs/HUMAN_DECISIONS.md +36 -47
- package/docs/HUMAN_DECISION_PRESENTATIONS.md +14 -24
- package/docs/MONITOR.md +179 -237
- package/docs/SQLITE_STATE.md +219 -0
- package/docs/WORKFLOW_COMPOSITION.md +27 -26
- package/docs/WORKFLOW_STEP_MESSAGES.md +20 -18
- package/docs/WORKFLOW_UPDATES.md +10 -9
- package/docs/development.md +9 -9
- package/docs/live-replay-protocol.md +28 -37
- package/docs/plans/2026-08-16-workflow-updates-plan.md +1 -1
- package/docs/plans/2026-08-19-human-decision-gates-plan.md +1 -1
- package/docs/plans/2026-08-21-autoimplement-timeout-fallback-plan.md +1 -1
- package/docs/plans/2026-08-21-plan-change-approval-policy-plan.md +322 -0
- package/docs/plans/2026-08-21-sanity-check-plan.md +217 -95
- package/docs/plans/2026-08-22-goal-finishing-monitor-plan.md +200 -0
- package/docs/plans/2026-08-23-assistant-agent-completion-plan.md +701 -0
- package/docs/plans/2026-08-23-sqlite-state-plan.md +970 -0
- package/docs/plans/replayable-run-bundles-implementation-plan.md +2 -2
- package/docs/plans/session-event-replay-implementation-plan.md +1 -1
- package/docs/plans/tui-viewer-implementation-plan.md +1 -1
- package/docs/session-event-journal.md +63 -434
- package/docs/tui-viewer.md +13 -15
- package/docs/workflows.md +127 -53
- package/examples/workflows/approved-plan.workflow.ts +19 -46
- package/examples/workflows/plain-summary.workflow.ts +1 -0
- package/herdr-plugin.toml +1 -1
- package/package.json +7 -7
- package/plugins/herdr/viewer.mjs +1 -11
- package/schemas/human-decision-accepted-v1.schema.json +15 -3
- package/schemas/human-decision-continuation-v1.schema.json +10 -1
- package/schemas/human-decision-delivery-v1.schema.json +8 -0
- package/schemas/human-decision-receipt-v1.schema.json +8 -0
- package/schemas/human-decision-request-v1.schema.json +24 -4
- package/skills/autoimplement/SKILL.md +27 -0
- package/skills/autoplan/SKILL.md +5 -4
- package/skills/monitor/SKILL.md +91 -135
- package/skills/pi-workflows/SKILL.md +9 -8
- package/skills/sanity-check/SKILL.md +44 -0
- package/src/builtins/autoimplement.workflow.ts +19 -118
- package/src/builtins/autoplan.workflow.ts +290 -40
- package/src/builtins/catalog.ts +7 -5
- package/src/builtins/index.ts +18 -1
- package/src/builtins/monitor.workflow.ts +673 -382
- package/src/builtins/pi-agent-group.ts +1407 -0
- package/src/builtins/plain-summary.workflow.ts +185 -0
- package/src/builtins/plan-approval.workflow.ts +157 -24
- package/src/builtins/plan-change.workflow.ts +321 -0
- package/src/builtins/plan-presentation.ts +2 -2
- package/src/builtins/sanity-check.workflow.ts +248 -48
- package/src/controllers/effects.ts +7 -0
- package/src/controllers/index.ts +0 -6
- package/src/controllers/manager.ts +72 -32
- package/src/controllers/sqlite.ts +2420 -1948
- package/src/controllers/store.ts +17 -38
- package/src/controllers/types.ts +3 -0
- package/src/controllers/workflow-engine-scheduler.ts +4 -8
- package/src/controllers/workflows.ts +45 -21
- package/src/extension/controller-host.ts +1 -2
- package/src/extension/decision-channels.ts +456 -203
- package/src/extension/executor.ts +105 -2
- package/src/extension/herdr-viewer.ts +0 -5
- package/src/extension/index.ts +251 -151
- package/src/extension/recorder.ts +13 -22
- package/src/extension/session-events.ts +2 -2
- package/src/extension/step-message.ts +106 -4
- package/src/extension/widget.ts +32 -5
- package/src/host/rpc-executor.ts +4 -0
- package/src/host/runner.ts +93 -41
- package/src/render/graph-render.ts +12 -6
- package/src/state/database.ts +375 -0
- package/src/state/index.ts +29 -0
- package/src/state/json.ts +42 -0
- package/src/state/mutation.ts +435 -0
- package/src/state/schema.ts +475 -0
- package/src/viewer/cli.ts +151 -144
- package/src/viewer/render.ts +19 -30
- package/src/viewer/session-reducer.ts +1 -1
- package/src/viewer/tui.ts +18 -17
- package/src/viewer/watch.ts +13 -17
- package/src/workflows/catalog.ts +7 -2
- package/src/workflows/composition.ts +21 -3
- package/src/workflows/decision-presentation.ts +56 -43
- package/src/workflows/definition.ts +36 -3
- package/src/workflows/engine.ts +228 -130
- package/src/workflows/errors.ts +27 -3
- package/src/workflows/human-decision.ts +921 -349
- package/src/workflows/index.ts +20 -30
- package/src/workflows/progress.ts +18 -3
- package/src/workflows/schema.ts +36 -1
- package/src/workflows/store.ts +1300 -1163
- package/src/workflows/types.ts +100 -137
- package/dist/builtins/sanity-check-session.d.ts +0 -17
- package/dist/builtins/sanity-check-session.js +0 -168
- package/dist/builtins/sanity-check-session.js.map +0 -1
- package/dist/workflows/artifacts.d.ts +0 -40
- package/dist/workflows/artifacts.js +0 -155
- package/dist/workflows/artifacts.js.map +0 -1
- package/dist/workflows/migrate-sources.d.ts +0 -42
- package/dist/workflows/migrate-sources.js +0 -133
- package/dist/workflows/migrate-sources.js.map +0 -1
- package/docs/run-bundles.md +0 -481
- package/schemas/human-decision-accepted-v2.schema.json +0 -50
- package/schemas/human-decision-delivery-v2.schema.json +0 -36
- package/schemas/human-decision-receipt-v2.schema.json +0 -39
- package/schemas/human-decision-request-v2.schema.json +0 -69
- package/schemas/human-decision-resolution-v2.schema.json +0 -27
- package/src/builtins/sanity-check-session.ts +0 -205
- package/src/workflows/artifacts.ts +0 -188
- package/src/workflows/migrate-sources.ts +0 -178
package/src/workflows/types.ts
CHANGED
|
@@ -97,21 +97,35 @@ export type WorkflowEdge =
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
/** A visible assistant response used as the accepted agent-node output. */
|
|
101
|
+
export type AssistantMessageOutput = {
|
|
102
|
+
kind: "assistant-message";
|
|
103
|
+
/** Optional author-supplied character limit. Omission adds no workflow limit. */
|
|
104
|
+
maxChars?: number;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type AgentExpectedOutput = string | AssistantMessageOutput;
|
|
108
|
+
|
|
109
|
+
type AgentNodeBase = WorkflowNodeCommon & {
|
|
109
110
|
nodeType: "agent";
|
|
110
111
|
prompt: (context: WorkflowNodeContext) => MaybePromise<string>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** The existing workflow-tool submission form. */
|
|
115
|
+
export type SubmittedAgentNodeDefinition = AgentNodeBase & {
|
|
111
116
|
expectedOutput?: string;
|
|
112
117
|
validate?: (output: unknown, context: WorkflowNodeContext) => MaybePromise<unknown>;
|
|
113
118
|
};
|
|
114
119
|
|
|
120
|
+
/** A model turn whose normal visible assistant text becomes the node output. */
|
|
121
|
+
export type AssistantAgentNodeDefinition = AgentNodeBase & {
|
|
122
|
+
expectedOutput: AssistantMessageOutput;
|
|
123
|
+
validate?: never;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/** A model-shaped step with either submitted or visible assistant output. */
|
|
127
|
+
export type AgentNodeDefinition = SubmittedAgentNodeDefinition | AssistantAgentNodeDefinition;
|
|
128
|
+
|
|
115
129
|
/** A pure local function: shape inputs, route, format, derive values. */
|
|
116
130
|
export type ComputeNodeDefinition = WorkflowNodeCommon & {
|
|
117
131
|
nodeType: "compute";
|
|
@@ -231,37 +245,34 @@ export type DecisionPresentation = {
|
|
|
231
245
|
blocks: DecisionPresentationBlock[];
|
|
232
246
|
};
|
|
233
247
|
|
|
234
|
-
export type
|
|
235
|
-
title: string;
|
|
236
|
-
body: unknown;
|
|
237
|
-
subject?: never;
|
|
238
|
-
presentation?: never;
|
|
239
|
-
revision?: never;
|
|
240
|
-
/** Optional absolute expiry. An expired request cannot accept an answer. */
|
|
241
|
-
expiresAt?: string;
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
export type PresentedHumanDecisionPrompt<TSubject = unknown> = {
|
|
248
|
+
export type HumanDecisionPrompt<TSubject = unknown> = {
|
|
245
249
|
title: string;
|
|
246
250
|
subject: TSubject;
|
|
247
251
|
presentation: DecisionPresentation;
|
|
248
|
-
body?: never;
|
|
249
252
|
/** Positive revision of the decision subject and presentation. Defaults to 1. */
|
|
250
253
|
revision?: number;
|
|
251
254
|
/** Optional absolute expiry. An expired request cannot accept an answer. */
|
|
252
255
|
expiresAt?: string;
|
|
253
256
|
};
|
|
254
257
|
|
|
255
|
-
export type HumanDecisionPrompt = LegacyHumanDecisionPrompt | PresentedHumanDecisionPrompt;
|
|
256
|
-
|
|
257
258
|
export type HumanDecisionAudience =
|
|
258
259
|
| string
|
|
259
260
|
| ((context: WorkflowNodeContext) => MaybePromise<string>);
|
|
260
261
|
|
|
262
|
+
export type HumanDecisionTimeout = {
|
|
263
|
+
afterMs: number;
|
|
264
|
+
response: HumanDecisionResponse;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export type HumanDecisionTimeoutPolicy =
|
|
268
|
+
| HumanDecisionTimeout
|
|
269
|
+
| ((context: WorkflowNodeContext) => MaybePromise<HumanDecisionTimeout | undefined>);
|
|
270
|
+
|
|
261
271
|
export type HumanDecisionNodeContract = {
|
|
262
272
|
audience: HumanDecisionAudience;
|
|
263
273
|
choices: HumanDecisionChoiceMap;
|
|
264
274
|
request: (context: WorkflowNodeContext) => MaybePromise<HumanDecisionPrompt>;
|
|
275
|
+
onTimeout?: HumanDecisionTimeoutPolicy;
|
|
265
276
|
};
|
|
266
277
|
|
|
267
278
|
type HumanDecisionRequestCommon = {
|
|
@@ -276,15 +287,11 @@ type HumanDecisionRequestCommon = {
|
|
|
276
287
|
choices: HumanDecisionChoiceMap;
|
|
277
288
|
createdAt: string;
|
|
278
289
|
expiresAt?: string;
|
|
290
|
+
defaultResponse?: HumanDecisionResponse;
|
|
279
291
|
};
|
|
280
292
|
|
|
281
|
-
export type
|
|
293
|
+
export type HumanDecisionRequest = HumanDecisionRequestCommon & {
|
|
282
294
|
schema: "pi-workflows.human-decision-request.v1";
|
|
283
|
-
body: unknown;
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
export type HumanDecisionRequestV2 = HumanDecisionRequestCommon & {
|
|
287
|
-
schema: "pi-workflows.human-decision-request.v2";
|
|
288
295
|
subject: unknown;
|
|
289
296
|
presentation: DecisionPresentation;
|
|
290
297
|
revision: number;
|
|
@@ -292,11 +299,9 @@ export type HumanDecisionRequestV2 = HumanDecisionRequestCommon & {
|
|
|
292
299
|
presentationDigest: string;
|
|
293
300
|
};
|
|
294
301
|
|
|
295
|
-
export type HumanDecisionRequest = HumanDecisionRequestV1 | HumanDecisionRequestV2;
|
|
296
|
-
|
|
297
302
|
/**
|
|
298
303
|
* Complete operator-facing request passed to a decision channel. It excludes
|
|
299
|
-
* the canonical subject
|
|
304
|
+
* the canonical subject by design.
|
|
300
305
|
*/
|
|
301
306
|
export type HumanDecisionChannelRequest = HumanDecisionRequestCommon & {
|
|
302
307
|
schema: "pi-workflows.human-decision-channel-request.v1";
|
|
@@ -324,69 +329,62 @@ export type HumanDecisionSubmission = HumanDecisionResponse & {
|
|
|
324
329
|
idempotencyKey: string;
|
|
325
330
|
};
|
|
326
331
|
|
|
327
|
-
type
|
|
332
|
+
type ResolvedHumanDecisionCommon = {
|
|
328
333
|
decisionId: string;
|
|
329
334
|
requestDigest: string;
|
|
330
335
|
response: HumanDecisionResponse;
|
|
331
|
-
|
|
332
|
-
idempotencyKey: string;
|
|
336
|
+
provenance: "human" | "timeout";
|
|
333
337
|
acceptedAt: string;
|
|
334
338
|
answerDigest: string;
|
|
335
339
|
};
|
|
336
340
|
|
|
337
|
-
|
|
338
|
-
|
|
341
|
+
type AcceptedHumanDecisionCommon = ResolvedHumanDecisionCommon & {
|
|
342
|
+
provenance: "human";
|
|
343
|
+
source: HumanDecisionAnswerSource;
|
|
344
|
+
idempotencyKey: string;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
type DefaultedHumanDecisionCommon = ResolvedHumanDecisionCommon & {
|
|
348
|
+
provenance: "timeout";
|
|
339
349
|
};
|
|
340
350
|
|
|
341
|
-
export type
|
|
342
|
-
schema: "pi-workflows.human-decision-accepted.
|
|
351
|
+
export type AcceptedHumanDecision = AcceptedHumanDecisionCommon & {
|
|
352
|
+
schema: "pi-workflows.human-decision-accepted.v1";
|
|
343
353
|
subjectDigest: string;
|
|
344
354
|
presentationDigest: string;
|
|
345
355
|
revision: number;
|
|
346
356
|
};
|
|
347
357
|
|
|
348
|
-
export type
|
|
358
|
+
export type DefaultedHumanDecision = DefaultedHumanDecisionCommon & {
|
|
359
|
+
schema: "pi-workflows.human-decision-accepted.v1";
|
|
360
|
+
subjectDigest: string;
|
|
361
|
+
presentationDigest: string;
|
|
362
|
+
revision: number;
|
|
363
|
+
};
|
|
364
|
+
export type ResolvedHumanDecision = AcceptedHumanDecision | DefaultedHumanDecision;
|
|
349
365
|
|
|
350
366
|
type HumanDecisionReceiptCommon = {
|
|
351
367
|
decisionId: string;
|
|
352
368
|
requestDigest: string;
|
|
353
369
|
nodeId: string;
|
|
354
370
|
response: HumanDecisionResponse;
|
|
371
|
+
provenance: "human" | "timeout";
|
|
355
372
|
acceptedAt: string;
|
|
356
373
|
answerDigest: string;
|
|
357
374
|
};
|
|
358
375
|
|
|
359
|
-
export type
|
|
376
|
+
export type HumanDecisionReceipt = HumanDecisionReceiptCommon & {
|
|
360
377
|
schema: "pi-workflows.human-decision-receipt.v1";
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
export type HumanDecisionReceiptV2 = HumanDecisionReceiptCommon & {
|
|
364
|
-
schema: "pi-workflows.human-decision-receipt.v2";
|
|
365
378
|
subjectDigest: string;
|
|
366
379
|
presentationDigest: string;
|
|
367
380
|
revision: number;
|
|
368
381
|
};
|
|
369
382
|
|
|
370
|
-
export type
|
|
371
|
-
|
|
372
|
-
export type HumanDecisionDeliveryRecordV1 = {
|
|
383
|
+
export type HumanDecisionDeliveryRecord = {
|
|
373
384
|
schema: "pi-workflows.human-decision-delivery.v1";
|
|
374
385
|
attemptId: string;
|
|
375
386
|
decisionId: string;
|
|
376
387
|
requestDigest: string;
|
|
377
|
-
channel: string;
|
|
378
|
-
state: "intent" | "confirmed" | "failed" | "unknown";
|
|
379
|
-
createdAt: string;
|
|
380
|
-
finishedAt?: string;
|
|
381
|
-
messageCount?: number;
|
|
382
|
-
errorCode?: string;
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
export type HumanDecisionDeliveryRecordV2 = {
|
|
386
|
-
schema: "pi-workflows.human-decision-delivery.v2";
|
|
387
|
-
attemptId: string;
|
|
388
|
-
decisionId: string;
|
|
389
|
-
requestDigest: string;
|
|
390
388
|
presentationDigest: string;
|
|
391
389
|
channel: string;
|
|
392
390
|
phase: "intent" | "part" | "complete";
|
|
@@ -401,10 +399,6 @@ export type HumanDecisionDeliveryRecordV2 = {
|
|
|
401
399
|
errorCode?: string;
|
|
402
400
|
};
|
|
403
401
|
|
|
404
|
-
export type HumanDecisionDeliveryRecord =
|
|
405
|
-
| HumanDecisionDeliveryRecordV1
|
|
406
|
-
| HumanDecisionDeliveryRecordV2;
|
|
407
|
-
|
|
408
402
|
export type HumanDecisionSettlementRecord = {
|
|
409
403
|
schema: "pi-workflows.human-decision-settlement.v1";
|
|
410
404
|
attemptId: string;
|
|
@@ -429,6 +423,7 @@ export type HumanDecisionContinuationRecord = {
|
|
|
429
423
|
schema: "pi-workflows.human-decision-continuation.v1";
|
|
430
424
|
decisionId: string;
|
|
431
425
|
requestDigest: string;
|
|
426
|
+
provenance: "human" | "timeout";
|
|
432
427
|
parentRunId: string;
|
|
433
428
|
runId: string;
|
|
434
429
|
createdAt: string;
|
|
@@ -548,7 +543,7 @@ export type WorkflowDefinition<
|
|
|
548
543
|
/**
|
|
549
544
|
* Optional instructions for a normal assistant response after the run ends.
|
|
550
545
|
* The Pi extension resolves this only after the final state is persisted;
|
|
551
|
-
* the engine and
|
|
546
|
+
* the engine and durable store remain presentation-agnostic.
|
|
552
547
|
*/
|
|
553
548
|
presentationPrompt?:
|
|
554
549
|
| string
|
|
@@ -564,27 +559,7 @@ export type WorkflowDefinition<
|
|
|
564
559
|
|
|
565
560
|
export type WorkflowNodeOutcome = "ok" | "timed_out" | "failed" | "cancelled";
|
|
566
561
|
|
|
567
|
-
/**
|
|
568
|
-
* Reference to a content-addressed file under the bundle's `artifacts/`
|
|
569
|
-
* directory. Large string leaves inside persisted values are replaced by
|
|
570
|
-
* `{ "$artifact": ArtifactRef }` at write time (see `docs/run-bundles.md`).
|
|
571
|
-
*/
|
|
572
|
-
export type ArtifactRef = {
|
|
573
|
-
/** Bundle-relative path, `artifacts/sha256-<64 hex>.txt`. */
|
|
574
|
-
path: string;
|
|
575
|
-
mediaType: string;
|
|
576
|
-
bytes: number;
|
|
577
|
-
/** Hex digest of the artifact bytes. */
|
|
578
|
-
sha256: string;
|
|
579
|
-
};
|
|
580
|
-
|
|
581
|
-
/** The sentinel wrapper that replaces an externalized value. */
|
|
582
|
-
export type ArtifactValue = { $artifact: ArtifactRef };
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* Explicit linkage from a workflow attempt to the Pi conversation slice it
|
|
586
|
-
* produced. Ids address entries in `session/entries.ndjson` by Pi entry id.
|
|
587
|
-
*/
|
|
562
|
+
/** Explicit linkage from a workflow attempt to the Pi conversation slice it produced. */
|
|
588
563
|
export type ConversationRange = {
|
|
589
564
|
/** First Pi session entry id of the attempt. */
|
|
590
565
|
firstEntryId: string;
|
|
@@ -621,14 +596,13 @@ export type WorkflowStepRecord = {
|
|
|
621
596
|
outcome: WorkflowNodeOutcome;
|
|
622
597
|
startedAt: string;
|
|
623
598
|
finishedAt: string;
|
|
624
|
-
/**
|
|
625
|
-
|
|
626
|
-
* persisted bundle a large prompt may be an `ArtifactValue`.
|
|
627
|
-
*/
|
|
628
|
-
prompt: string | ArtifactValue | null;
|
|
599
|
+
/** Full prompt text for agent steps, `null` for other node types. */
|
|
600
|
+
prompt: string | null;
|
|
629
601
|
output: unknown;
|
|
630
602
|
error?: string;
|
|
631
603
|
action?: WorkflowActionReceipt;
|
|
604
|
+
/** Receipt for a visible assistant-message completion. */
|
|
605
|
+
assistantMessage?: AssistantMessageReceipt;
|
|
632
606
|
/** For agent steps recorded inside a Pi conversation. */
|
|
633
607
|
conversation?: ConversationRange;
|
|
634
608
|
};
|
|
@@ -665,11 +639,7 @@ export type WorkflowCompositionSnapshot = {
|
|
|
665
639
|
|
|
666
640
|
export type WorkflowRunState = {
|
|
667
641
|
schema: "pi-workflows.run-state.v1";
|
|
668
|
-
/**
|
|
669
|
-
* `seq` of the trace event this projection reflects. `trace.ndjson` is the
|
|
670
|
-
* source of truth; a state whose `traceSeq` is older than the trace tail is
|
|
671
|
-
* a stale projection.
|
|
672
|
-
*/
|
|
642
|
+
/** Resource revision of the event reflected by this projection. */
|
|
673
643
|
traceSeq: number;
|
|
674
644
|
runId: string;
|
|
675
645
|
workflowName: string;
|
|
@@ -719,7 +689,7 @@ export type WorkflowNodeSnapshot = {
|
|
|
719
689
|
timeoutMs?: number | null;
|
|
720
690
|
statusDetail?: string;
|
|
721
691
|
summary?: string;
|
|
722
|
-
expectedOutput?:
|
|
692
|
+
expectedOutput?: AgentExpectedOutput;
|
|
723
693
|
actionExecution?: "function" | "shell";
|
|
724
694
|
mountPath?: string[];
|
|
725
695
|
localNodeId?: string;
|
|
@@ -728,6 +698,8 @@ export type WorkflowNodeSnapshot = {
|
|
|
728
698
|
audience: string;
|
|
729
699
|
dynamicAudience?: boolean;
|
|
730
700
|
choices: HumanDecisionChoiceMap;
|
|
701
|
+
onTimeout?: HumanDecisionTimeout;
|
|
702
|
+
dynamicTimeout?: boolean;
|
|
731
703
|
};
|
|
732
704
|
};
|
|
733
705
|
|
|
@@ -775,7 +747,7 @@ export type WorkflowSessionBinding = {
|
|
|
775
747
|
export type WorkflowSessionEntryRecord = {
|
|
776
748
|
/** Starts at 1, increases by exactly 1 within the file. */
|
|
777
749
|
seq: number;
|
|
778
|
-
/** When the entry was recorded
|
|
750
|
+
/** When the entry was recorded in workflow state. */
|
|
779
751
|
at: string;
|
|
780
752
|
/** Verbatim Pi session entry (has its own id/parentId/timestamp). */
|
|
781
753
|
entry: Record<string, unknown>;
|
|
@@ -825,32 +797,21 @@ export type WorkflowSessionCapture = {
|
|
|
825
797
|
|
|
826
798
|
export type WorkflowTraceEventDraft = Omit<WorkflowTraceEvent, "seq" | "at" | "runId">;
|
|
827
799
|
|
|
828
|
-
export type
|
|
829
|
-
schema: "pi-workflows.run-bundle.v1";
|
|
800
|
+
export type WorkflowRunResult = {
|
|
830
801
|
runId: string;
|
|
831
|
-
|
|
832
|
-
runTitle?: string;
|
|
833
|
-
workflowSource?: WorkflowSource;
|
|
834
|
-
workflowSources?: WorkflowMountedSource[];
|
|
835
|
-
definitionDigest?: string;
|
|
836
|
-
startedAt: string;
|
|
837
|
-
finishedAt?: string;
|
|
838
|
-
status: WorkflowRunStatus;
|
|
839
|
-
traceSchema: "pi-workflows.trace-event.v1";
|
|
840
|
-
paths: {
|
|
841
|
-
workflow: string;
|
|
842
|
-
state: string;
|
|
843
|
-
trace: string;
|
|
844
|
-
/** Bundle-relative session directory, present once a session is bound. */
|
|
845
|
-
session?: string;
|
|
846
|
-
/** Bundle-relative artifacts directory, present once a value was externalized. */
|
|
847
|
-
artifacts?: string;
|
|
848
|
-
};
|
|
802
|
+
state: WorkflowRunState;
|
|
849
803
|
};
|
|
850
804
|
|
|
851
|
-
export type
|
|
852
|
-
|
|
853
|
-
|
|
805
|
+
export type AgentStepCompletion = "submit" | "assistant";
|
|
806
|
+
|
|
807
|
+
export type AssistantMessageReceipt = {
|
|
808
|
+
sha256: string;
|
|
809
|
+
/** Pi session entry containing the visible response, when available. */
|
|
810
|
+
entryId?: string;
|
|
811
|
+
/** Present only when the workflow author supplied a limit. */
|
|
812
|
+
maxChars?: number;
|
|
813
|
+
/** True when recovery adopted an already visible response. */
|
|
814
|
+
recovered?: boolean;
|
|
854
815
|
};
|
|
855
816
|
|
|
856
817
|
/** The step contract handed to the executor alongside the prompt. */
|
|
@@ -859,7 +820,9 @@ export type AgentStepContract = {
|
|
|
859
820
|
workflowName: string;
|
|
860
821
|
nodeId: string;
|
|
861
822
|
attemptId: string;
|
|
823
|
+
completion: AgentStepCompletion;
|
|
862
824
|
expectedOutput?: string;
|
|
825
|
+
maxOutputChars?: number;
|
|
863
826
|
};
|
|
864
827
|
|
|
865
828
|
/** Optional human-facing labels for an agent step. They never affect execution. */
|
|
@@ -886,6 +849,8 @@ export type AgentStepRequest = {
|
|
|
886
849
|
|
|
887
850
|
export type AgentStepSubmission = {
|
|
888
851
|
output: unknown;
|
|
852
|
+
/** Receipt for a visible assistant response. */
|
|
853
|
+
assistantMessage?: AssistantMessageReceipt;
|
|
889
854
|
/**
|
|
890
855
|
* The Pi conversation slice this step produced, when the executor records
|
|
891
856
|
* one. Persisted verbatim into the step record and terminal node event.
|
|
@@ -895,10 +860,15 @@ export type AgentStepSubmission = {
|
|
|
895
860
|
|
|
896
861
|
/**
|
|
897
862
|
* Runs one agent step to completion. Implementations deliver the prompt to
|
|
898
|
-
* the model and resolve once
|
|
863
|
+
* the model and resolve once the configured output has been accepted.
|
|
899
864
|
* Must reject with an `AbortError`-like error when `signal` aborts.
|
|
900
865
|
*/
|
|
901
866
|
export interface AgentStepExecutor {
|
|
867
|
+
/**
|
|
868
|
+
* `visible` supports assistant-message output. `park` asks the engine to
|
|
869
|
+
* leave the run claimable for an origin session. Omission is unsupported.
|
|
870
|
+
*/
|
|
871
|
+
readonly assistantMessageMode?: "visible" | "park" | "unsupported";
|
|
902
872
|
runAgentStep(request: AgentStepRequest, signal: AbortSignal): Promise<AgentStepSubmission>;
|
|
903
873
|
}
|
|
904
874
|
|
|
@@ -926,26 +896,19 @@ export type WorkflowEngineOptions = {
|
|
|
926
896
|
executor: AgentStepExecutor;
|
|
927
897
|
/** Durable destination for notify nodes. Required when a workflow uses one. */
|
|
928
898
|
notificationSink?: WorkflowNotificationSink;
|
|
929
|
-
/**
|
|
930
|
-
|
|
931
|
-
/**
|
|
932
|
-
* Shared run store. Pass the same instance used by a session recorder so
|
|
933
|
-
* trace sequence numbers stay single-writer. Defaults to a new store on
|
|
934
|
-
* `outputRoot`.
|
|
935
|
-
*/
|
|
899
|
+
/** Canonical SQLite database. Defaults to `~/.pi/agent/workflows/state.sqlite`. */
|
|
900
|
+
databasePath?: string;
|
|
901
|
+
/** Shared SQLite run store. */
|
|
936
902
|
store?: import("./store.js").WorkflowRunStore;
|
|
937
903
|
/**
|
|
938
|
-
* Awaited after `run_started` is persisted, before any node executes.
|
|
939
|
-
* is where a session recorder binds, so `session_bound` lands at the start
|
|
940
|
-
* of the trace and can never trail the terminal event.
|
|
904
|
+
* Awaited after `run_started` is persisted, before any node executes.
|
|
941
905
|
*/
|
|
942
|
-
onRunStarted?: (
|
|
906
|
+
onRunStarted?: (runId: string, state: WorkflowRunState) => MaybePromise<void>;
|
|
943
907
|
/**
|
|
944
908
|
* Awaited before the terminal snapshot is persisted. This is where a
|
|
945
|
-
* session recorder stops and drains
|
|
946
|
-
* the terminal event exists. Errors are swallowed: finishing the run wins.
|
|
909
|
+
* session recorder stops and drains. Errors are swallowed: finishing the run wins.
|
|
947
910
|
*/
|
|
948
|
-
onRunFinishing?: (
|
|
911
|
+
onRunFinishing?: (runId: string, state: WorkflowRunState) => MaybePromise<void>;
|
|
949
912
|
/** Default per-node timeout. Defaults to 15 minutes. */
|
|
950
913
|
defaultNodeTimeoutMs?: number;
|
|
951
914
|
/** Guard against unbounded graph loops. Defaults to 100 executed steps. */
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type IsolatedReviewRequest = {
|
|
2
|
-
id: string;
|
|
3
|
-
prompt: string;
|
|
4
|
-
};
|
|
5
|
-
export type PiInvocation = {
|
|
6
|
-
command: string;
|
|
7
|
-
prefixArgs: string[];
|
|
8
|
-
};
|
|
9
|
-
export type IsolatedReviewOptions = {
|
|
10
|
-
invocation?: PiInvocation;
|
|
11
|
-
timeoutMs?: number;
|
|
12
|
-
maxOutputChars?: number;
|
|
13
|
-
maxConcurrency?: number;
|
|
14
|
-
};
|
|
15
|
-
export declare function runIsolatedReviewSessions(requests: IsolatedReviewRequest[], cwd: string, signal: AbortSignal, options?: IsolatedReviewOptions): Promise<Record<string, unknown>>;
|
|
16
|
-
export declare function resolvePiInvocation(): PiInvocation;
|
|
17
|
-
export declare function parsePiJsonOutput(stdout: string): unknown;
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { runCommandBatch } from "../workflows/command-batch.js";
|
|
5
|
-
import { extractJsonValue } from "../workflows/json.js";
|
|
6
|
-
const SESSION_TIMEOUT_MS = 15 * 60_000;
|
|
7
|
-
const SESSION_OUTPUT_CHARS = 1_000_000;
|
|
8
|
-
const MAX_PROMPT_CHARS = 96_000;
|
|
9
|
-
const MAX_ERROR_CHARS = 2_000;
|
|
10
|
-
export async function runIsolatedReviewSessions(requests, cwd, signal, options = {}) {
|
|
11
|
-
if (requests.length === 0)
|
|
12
|
-
return {};
|
|
13
|
-
const ids = new Set();
|
|
14
|
-
for (const request of requests) {
|
|
15
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/.test(request.id)) {
|
|
16
|
-
throw new Error(`Invalid isolated review id: ${request.id}`);
|
|
17
|
-
}
|
|
18
|
-
if (ids.has(request.id))
|
|
19
|
-
throw new Error(`Duplicate isolated review id: ${request.id}`);
|
|
20
|
-
ids.add(request.id);
|
|
21
|
-
if (request.prompt.length > MAX_PROMPT_CHARS) {
|
|
22
|
-
throw new Error(`Isolated review prompt ${request.id} exceeds ${MAX_PROMPT_CHARS} characters`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const promptDir = await fs.mkdtemp(path.join(os.tmpdir(), "pi-sanity-check-"));
|
|
26
|
-
try {
|
|
27
|
-
const invocation = options.invocation ?? resolvePiInvocation();
|
|
28
|
-
const items = await Promise.all(requests.map(async (request) => {
|
|
29
|
-
const promptPath = path.join(promptDir, `${request.id}.md`);
|
|
30
|
-
await fs.writeFile(promptPath, request.prompt, { encoding: "utf8", mode: 0o600 });
|
|
31
|
-
return {
|
|
32
|
-
id: request.id,
|
|
33
|
-
command: invocation.command,
|
|
34
|
-
args: [
|
|
35
|
-
...invocation.prefixArgs,
|
|
36
|
-
"--mode",
|
|
37
|
-
"json",
|
|
38
|
-
"--print",
|
|
39
|
-
"--no-session",
|
|
40
|
-
"--no-extensions",
|
|
41
|
-
"--no-skills",
|
|
42
|
-
"--no-context-files",
|
|
43
|
-
"--tools",
|
|
44
|
-
"read,grep,find,ls",
|
|
45
|
-
`@${promptPath}`,
|
|
46
|
-
"Follow the attached review instructions and return only the requested JSON.",
|
|
47
|
-
],
|
|
48
|
-
cwd,
|
|
49
|
-
timeoutMs: options.timeoutMs ?? SESSION_TIMEOUT_MS,
|
|
50
|
-
maxOutputChars: options.maxOutputChars ?? SESSION_OUTPUT_CHARS,
|
|
51
|
-
};
|
|
52
|
-
}));
|
|
53
|
-
const batch = await runCommandBatch({
|
|
54
|
-
items,
|
|
55
|
-
maxConcurrency: options.maxConcurrency ?? requests.length,
|
|
56
|
-
}, { signal });
|
|
57
|
-
const outputs = {};
|
|
58
|
-
for (const item of batch.items) {
|
|
59
|
-
outputs[item.id] = parseSessionResult(item);
|
|
60
|
-
}
|
|
61
|
-
return outputs;
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
await fs.rm(promptDir, { recursive: true, force: true });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
export function resolvePiInvocation() {
|
|
68
|
-
const currentScript = process.argv[1];
|
|
69
|
-
const isBunVirtualScript = currentScript?.startsWith("/$bunfs/root/");
|
|
70
|
-
const scriptName = currentScript === undefined ? "" : path.basename(currentScript).toLowerCase();
|
|
71
|
-
const isPiPackageCli = scriptName === "cli.js" &&
|
|
72
|
-
currentScript?.split(path.sep).some((segment) => segment === "pi-coding-agent");
|
|
73
|
-
const isPiScript = /^(pi|pi\.[cm]?js)$/.test(scriptName) || isPiPackageCli;
|
|
74
|
-
if (currentScript && !isBunVirtualScript && isPiScript) {
|
|
75
|
-
return {
|
|
76
|
-
command: process.execPath,
|
|
77
|
-
prefixArgs: [currentScript, ...inheritedPiArgs(process.argv.slice(2))],
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const execName = path.basename(process.execPath).toLowerCase();
|
|
81
|
-
if (/^pi(\.exe)?$/.test(execName)) {
|
|
82
|
-
return { command: process.execPath, prefixArgs: inheritedPiArgs(process.argv.slice(1)) };
|
|
83
|
-
}
|
|
84
|
-
return { command: "pi", prefixArgs: [] };
|
|
85
|
-
}
|
|
86
|
-
export function parsePiJsonOutput(stdout) {
|
|
87
|
-
let finalText = "";
|
|
88
|
-
for (const line of stdout.split("\n")) {
|
|
89
|
-
if (!line.trim())
|
|
90
|
-
continue;
|
|
91
|
-
let event;
|
|
92
|
-
try {
|
|
93
|
-
event = JSON.parse(line);
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (event.type !== "message_end" || !isRecord(event.message))
|
|
99
|
-
continue;
|
|
100
|
-
const message = event.message;
|
|
101
|
-
if (message.role !== "assistant")
|
|
102
|
-
continue;
|
|
103
|
-
if (message.stopReason === "error" || message.stopReason === "aborted") {
|
|
104
|
-
throw new Error(boundedError(typeof message.errorMessage === "string"
|
|
105
|
-
? message.errorMessage
|
|
106
|
-
: `Pi session stopped with ${String(message.stopReason)}`));
|
|
107
|
-
}
|
|
108
|
-
const text = messageText(message.content);
|
|
109
|
-
if (text.trim())
|
|
110
|
-
finalText = text;
|
|
111
|
-
}
|
|
112
|
-
if (!finalText)
|
|
113
|
-
throw new Error("Isolated Pi session returned no assistant JSON output");
|
|
114
|
-
return extractJsonValue(finalText);
|
|
115
|
-
}
|
|
116
|
-
function parseSessionResult(result) {
|
|
117
|
-
if (result.outcome !== "succeeded") {
|
|
118
|
-
throw new Error(`Isolated Pi session ${result.id} ${result.outcome}: ${boundedError(result.error ?? result.stderr)}`);
|
|
119
|
-
}
|
|
120
|
-
if (result.stdoutTruncated) {
|
|
121
|
-
throw new Error(`Isolated Pi session ${result.id} exceeded its output limit`);
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
return parsePiJsonOutput(result.stdout);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
throw new Error(`Isolated Pi session ${result.id} returned invalid output: ${boundedError(errorMessage(error))}`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function inheritedPiArgs(args) {
|
|
131
|
-
const inherited = [];
|
|
132
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
133
|
-
const arg = args[index];
|
|
134
|
-
if (arg === "--offline") {
|
|
135
|
-
inherited.push(arg);
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
if (arg !== "--provider" && arg !== "--model" && arg !== "--thinking")
|
|
139
|
-
continue;
|
|
140
|
-
const value = args[index + 1];
|
|
141
|
-
if (value !== undefined) {
|
|
142
|
-
inherited.push(arg, value);
|
|
143
|
-
index += 1;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return inherited;
|
|
147
|
-
}
|
|
148
|
-
function messageText(content) {
|
|
149
|
-
if (typeof content === "string")
|
|
150
|
-
return content;
|
|
151
|
-
if (!Array.isArray(content))
|
|
152
|
-
return "";
|
|
153
|
-
return content
|
|
154
|
-
.map((part) => isRecord(part) && part.type === "text" && typeof part.text === "string" ? part.text : "")
|
|
155
|
-
.filter(Boolean)
|
|
156
|
-
.join("\n");
|
|
157
|
-
}
|
|
158
|
-
function isRecord(value) {
|
|
159
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
160
|
-
}
|
|
161
|
-
function errorMessage(error) {
|
|
162
|
-
return error instanceof Error ? error.message : String(error);
|
|
163
|
-
}
|
|
164
|
-
function boundedError(message) {
|
|
165
|
-
const value = message.trim() || "unknown failure";
|
|
166
|
-
return value.length <= MAX_ERROR_CHARS ? value : `${value.slice(0, MAX_ERROR_CHARS)}…`;
|
|
167
|
-
}
|
|
168
|
-
//# sourceMappingURL=sanity-check-session.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanity-check-session.js","sourceRoot":"","sources":["../../src/builtins/sanity-check-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAA+B,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,kBAAkB,GAAG,EAAE,GAAG,MAAM,CAAC;AACvC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,eAAe,GAAG,KAAK,CAAC;AAmB9B,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,QAAiC,EACjC,GAAW,EACX,MAAmB,EACnB,OAAO,GAA0B,EAAE;IAEnC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC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AQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CACzF;SACA,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,iBAAiB,CAAC;IAClD,OAAO,KAAK,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC;AACzF,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { ArtifactRef, ArtifactValue } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Value externalization for run bundles (see docs/run-bundles.md): string
|
|
4
|
-
* leaves larger than the threshold are written once, content-addressed, under
|
|
5
|
-
* `artifacts/` and replaced by `{ "$artifact": ref }`. Because artifacts are
|
|
6
|
-
* immutable and deduplicated by hash, the same output appearing in `outputs`,
|
|
7
|
-
* `results`, `steps`, and the trace costs one file plus small references.
|
|
8
|
-
*/
|
|
9
|
-
export declare const ARTIFACT_THRESHOLD_BYTES = 4096;
|
|
10
|
-
export declare const ARTIFACTS_DIR = "artifacts";
|
|
11
|
-
export declare function isArtifactValue(value: unknown): value is ArtifactValue;
|
|
12
|
-
/**
|
|
13
|
-
* Writes externalized string leaves for one run bundle. Instances serialize
|
|
14
|
-
* their writes and deduplicate by content hash, so encoding the same large
|
|
15
|
-
* string in several value positions touches the filesystem once.
|
|
16
|
-
*/
|
|
17
|
-
export declare class ArtifactWriter {
|
|
18
|
-
private readonly runDir;
|
|
19
|
-
private readonly written;
|
|
20
|
-
private chain;
|
|
21
|
-
private dirCreated;
|
|
22
|
-
constructor(runDir: string);
|
|
23
|
-
/** True once any artifact exists for this run. */
|
|
24
|
-
get hasArtifacts(): boolean;
|
|
25
|
-
externalize(text: string): Promise<ArtifactValue>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Encode a persisted value: externalize large string leaves and escape
|
|
29
|
-
* single-key `$artifact`/`$escaped` objects so the sentinel stays
|
|
30
|
-
* unambiguous. Returns the original value when nothing changed.
|
|
31
|
-
*/
|
|
32
|
-
export declare function encodeValue(value: unknown, writer: ArtifactWriter, thresholdBytes?: number): Promise<unknown>;
|
|
33
|
-
/**
|
|
34
|
-
* Walk a persisted value, replacing every `$artifact` sentinel via `resolve`
|
|
35
|
-
* and unwrapping `$escaped` objects. `resolve` may return the artifact
|
|
36
|
-
* contents or a placeholder; it receives the reference untouched.
|
|
37
|
-
*/
|
|
38
|
-
export declare function decodeValueWith(value: unknown, resolve: (ref: ArtifactRef) => unknown): unknown;
|
|
39
|
-
/** Resolve every artifact reference in `value` by reading the bundle files. */
|
|
40
|
-
export declare function resolveArtifacts(value: unknown, runDir: string): Promise<unknown>;
|