@osolmaz/pi-workflows 0.12.0 → 0.12.1
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 +4 -3
- package/dist/builtins/autoimplement.workflow.d.ts +485 -126
- package/dist/builtins/autoimplement.workflow.js +17 -105
- package/dist/builtins/autoimplement.workflow.js.map +1 -1
- package/dist/builtins/catalog.js +4 -4
- package/dist/builtins/index.d.ts +2 -1
- package/dist/builtins/index.js +2 -1
- package/dist/builtins/index.js.map +1 -1
- package/dist/builtins/monitor.workflow.d.ts +2 -4
- package/dist/builtins/monitor.workflow.js +26 -128
- 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/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 +301 -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 +5 -3
- package/dist/builtins/sanity-check.workflow.js +105 -21
- package/dist/builtins/sanity-check.workflow.js.map +1 -1
- package/dist/extension/decision-channels.d.ts +2 -2
- package/dist/extension/decision-channels.js +22 -28
- package/dist/extension/decision-channels.js.map +1 -1
- package/dist/extension/index.js +62 -33
- package/dist/extension/index.js.map +1 -1
- package/dist/extension/session-events.d.ts +2 -2
- package/dist/extension/widget.js +23 -3
- package/dist/extension/widget.js.map +1 -1
- package/dist/render/graph-render.js +1 -2
- package/dist/render/graph-render.js.map +1 -1
- package/dist/viewer/render.js +7 -6
- package/dist/viewer/render.js.map +1 -1
- package/dist/workflows/catalog.js +7 -2
- package/dist/workflows/catalog.js.map +1 -1
- package/dist/workflows/composition.js +8 -0
- 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/engine.d.ts +2 -2
- package/dist/workflows/engine.js +14 -13
- package/dist/workflows/engine.js.map +1 -1
- package/dist/workflows/errors.d.ts +13 -0
- package/dist/workflows/errors.js +15 -0
- package/dist/workflows/errors.js.map +1 -1
- package/dist/workflows/human-decision.d.ts +16 -4
- package/dist/workflows/human-decision.js +175 -72
- package/dist/workflows/human-decision.js.map +1 -1
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +1 -1
- 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 +10 -0
- package/dist/workflows/schema.js.map +1 -1
- package/dist/workflows/store.js +5 -0
- package/dist/workflows/store.js.map +1 -1
- package/dist/workflows/types.d.ts +33 -45
- package/docs/HUMAN_DECISIONS.md +25 -35
- package/docs/HUMAN_DECISION_PRESENTATIONS.md +14 -24
- package/docs/MONITOR.md +5 -11
- package/docs/WORKFLOW_COMPOSITION.md +8 -7
- package/docs/plans/2026-08-21-plan-change-approval-policy-plan.md +322 -0
- package/docs/plans/2026-08-21-sanity-check-plan.md +202 -94
- package/docs/run-bundles.md +6 -6
- package/docs/workflows.md +26 -6
- package/examples/workflows/approved-plan.workflow.ts +19 -46
- package/herdr-plugin.toml +1 -1
- package/package.json +7 -7
- 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/monitor/SKILL.md +31 -3
- package/skills/pi-workflows/SKILL.md +2 -1
- package/skills/sanity-check/SKILL.md +44 -0
- package/src/builtins/autoimplement.workflow.ts +19 -118
- package/src/builtins/catalog.ts +4 -4
- package/src/builtins/index.ts +11 -0
- package/src/builtins/monitor.workflow.ts +27 -150
- package/src/builtins/pi-agent-group.ts +1407 -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 +186 -41
- package/src/extension/decision-channels.ts +29 -59
- package/src/extension/index.ts +79 -41
- package/src/extension/session-events.ts +2 -2
- package/src/extension/widget.ts +24 -5
- package/src/render/graph-render.ts +1 -2
- package/src/viewer/render.ts +7 -6
- package/src/workflows/catalog.ts +7 -2
- package/src/workflows/composition.ts +9 -0
- package/src/workflows/decision-presentation.ts +56 -43
- package/src/workflows/engine.ts +17 -15
- package/src/workflows/errors.ts +24 -0
- package/src/workflows/human-decision.ts +218 -101
- package/src/workflows/index.ts +5 -11
- package/src/workflows/progress.ts +18 -3
- package/src/workflows/schema.ts +17 -0
- package/src/workflows/store.ts +5 -0
- package/src/workflows/types.ts +39 -56
- 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/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/schema.ts
CHANGED
|
@@ -151,6 +151,23 @@ export function assertValidCheckpointNode(
|
|
|
151
151
|
if (typeof node.humanDecision.request !== "function") {
|
|
152
152
|
fail(`node ${nodeId} humanDecision request must be a function`);
|
|
153
153
|
}
|
|
154
|
+
if (
|
|
155
|
+
node.humanDecision.onTimeout !== undefined &&
|
|
156
|
+
typeof node.humanDecision.onTimeout !== "function"
|
|
157
|
+
) {
|
|
158
|
+
assertRecord(node.humanDecision.onTimeout, `node ${nodeId} humanDecision onTimeout`);
|
|
159
|
+
if (
|
|
160
|
+
typeof node.humanDecision.onTimeout.afterMs !== "number" ||
|
|
161
|
+
!Number.isFinite(node.humanDecision.onTimeout.afterMs) ||
|
|
162
|
+
node.humanDecision.onTimeout.afterMs <= 0
|
|
163
|
+
) {
|
|
164
|
+
fail(`node ${nodeId} humanDecision onTimeout afterMs must be a finite positive number`);
|
|
165
|
+
}
|
|
166
|
+
assertRecord(
|
|
167
|
+
node.humanDecision.onTimeout.response,
|
|
168
|
+
`node ${nodeId} humanDecision onTimeout response`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
154
171
|
}
|
|
155
172
|
assertCommonNodeFields(node, nodeId);
|
|
156
173
|
}
|
package/src/workflows/store.ts
CHANGED
|
@@ -1437,6 +1437,11 @@ function snapshotNode(
|
|
|
1437
1437
|
typeof node.humanDecision.audience === "string" ? node.humanDecision.audience : "<dynamic>",
|
|
1438
1438
|
...(typeof node.humanDecision.audience === "function" ? { dynamicAudience: true } : {}),
|
|
1439
1439
|
choices: structuredClone(node.humanDecision.choices),
|
|
1440
|
+
...(node.humanDecision.onTimeout !== undefined &&
|
|
1441
|
+
typeof node.humanDecision.onTimeout !== "function"
|
|
1442
|
+
? { onTimeout: structuredClone(node.humanDecision.onTimeout) }
|
|
1443
|
+
: {}),
|
|
1444
|
+
...(typeof node.humanDecision.onTimeout === "function" ? { dynamicTimeout: true } : {}),
|
|
1440
1445
|
};
|
|
1441
1446
|
}
|
|
1442
1447
|
if (node.nodeType === "action") {
|
package/src/workflows/types.ts
CHANGED
|
@@ -231,37 +231,34 @@ export type DecisionPresentation = {
|
|
|
231
231
|
blocks: DecisionPresentationBlock[];
|
|
232
232
|
};
|
|
233
233
|
|
|
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> = {
|
|
234
|
+
export type HumanDecisionPrompt<TSubject = unknown> = {
|
|
245
235
|
title: string;
|
|
246
236
|
subject: TSubject;
|
|
247
237
|
presentation: DecisionPresentation;
|
|
248
|
-
body?: never;
|
|
249
238
|
/** Positive revision of the decision subject and presentation. Defaults to 1. */
|
|
250
239
|
revision?: number;
|
|
251
240
|
/** Optional absolute expiry. An expired request cannot accept an answer. */
|
|
252
241
|
expiresAt?: string;
|
|
253
242
|
};
|
|
254
243
|
|
|
255
|
-
export type HumanDecisionPrompt = LegacyHumanDecisionPrompt | PresentedHumanDecisionPrompt;
|
|
256
|
-
|
|
257
244
|
export type HumanDecisionAudience =
|
|
258
245
|
| string
|
|
259
246
|
| ((context: WorkflowNodeContext) => MaybePromise<string>);
|
|
260
247
|
|
|
248
|
+
export type HumanDecisionTimeout = {
|
|
249
|
+
afterMs: number;
|
|
250
|
+
response: HumanDecisionResponse;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export type HumanDecisionTimeoutPolicy =
|
|
254
|
+
| HumanDecisionTimeout
|
|
255
|
+
| ((context: WorkflowNodeContext) => MaybePromise<HumanDecisionTimeout | undefined>);
|
|
256
|
+
|
|
261
257
|
export type HumanDecisionNodeContract = {
|
|
262
258
|
audience: HumanDecisionAudience;
|
|
263
259
|
choices: HumanDecisionChoiceMap;
|
|
264
260
|
request: (context: WorkflowNodeContext) => MaybePromise<HumanDecisionPrompt>;
|
|
261
|
+
onTimeout?: HumanDecisionTimeoutPolicy;
|
|
265
262
|
};
|
|
266
263
|
|
|
267
264
|
type HumanDecisionRequestCommon = {
|
|
@@ -276,15 +273,11 @@ type HumanDecisionRequestCommon = {
|
|
|
276
273
|
choices: HumanDecisionChoiceMap;
|
|
277
274
|
createdAt: string;
|
|
278
275
|
expiresAt?: string;
|
|
276
|
+
defaultResponse?: HumanDecisionResponse;
|
|
279
277
|
};
|
|
280
278
|
|
|
281
|
-
export type
|
|
279
|
+
export type HumanDecisionRequest = HumanDecisionRequestCommon & {
|
|
282
280
|
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
281
|
subject: unknown;
|
|
289
282
|
presentation: DecisionPresentation;
|
|
290
283
|
revision: number;
|
|
@@ -292,11 +285,9 @@ export type HumanDecisionRequestV2 = HumanDecisionRequestCommon & {
|
|
|
292
285
|
presentationDigest: string;
|
|
293
286
|
};
|
|
294
287
|
|
|
295
|
-
export type HumanDecisionRequest = HumanDecisionRequestV1 | HumanDecisionRequestV2;
|
|
296
|
-
|
|
297
288
|
/**
|
|
298
289
|
* Complete operator-facing request passed to a decision channel. It excludes
|
|
299
|
-
* the canonical subject
|
|
290
|
+
* the canonical subject by design.
|
|
300
291
|
*/
|
|
301
292
|
export type HumanDecisionChannelRequest = HumanDecisionRequestCommon & {
|
|
302
293
|
schema: "pi-workflows.human-decision-channel-request.v1";
|
|
@@ -324,69 +315,62 @@ export type HumanDecisionSubmission = HumanDecisionResponse & {
|
|
|
324
315
|
idempotencyKey: string;
|
|
325
316
|
};
|
|
326
317
|
|
|
327
|
-
type
|
|
318
|
+
type ResolvedHumanDecisionCommon = {
|
|
328
319
|
decisionId: string;
|
|
329
320
|
requestDigest: string;
|
|
330
321
|
response: HumanDecisionResponse;
|
|
331
|
-
|
|
332
|
-
idempotencyKey: string;
|
|
322
|
+
provenance: "human" | "timeout";
|
|
333
323
|
acceptedAt: string;
|
|
334
324
|
answerDigest: string;
|
|
335
325
|
};
|
|
336
326
|
|
|
337
|
-
|
|
338
|
-
|
|
327
|
+
type AcceptedHumanDecisionCommon = ResolvedHumanDecisionCommon & {
|
|
328
|
+
provenance: "human";
|
|
329
|
+
source: HumanDecisionAnswerSource;
|
|
330
|
+
idempotencyKey: string;
|
|
339
331
|
};
|
|
340
332
|
|
|
341
|
-
|
|
342
|
-
|
|
333
|
+
type DefaultedHumanDecisionCommon = ResolvedHumanDecisionCommon & {
|
|
334
|
+
provenance: "timeout";
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export type AcceptedHumanDecision = AcceptedHumanDecisionCommon & {
|
|
338
|
+
schema: "pi-workflows.human-decision-accepted.v1";
|
|
343
339
|
subjectDigest: string;
|
|
344
340
|
presentationDigest: string;
|
|
345
341
|
revision: number;
|
|
346
342
|
};
|
|
347
343
|
|
|
348
|
-
export type
|
|
344
|
+
export type DefaultedHumanDecision = DefaultedHumanDecisionCommon & {
|
|
345
|
+
schema: "pi-workflows.human-decision-accepted.v1";
|
|
346
|
+
subjectDigest: string;
|
|
347
|
+
presentationDigest: string;
|
|
348
|
+
revision: number;
|
|
349
|
+
};
|
|
350
|
+
export type ResolvedHumanDecision = AcceptedHumanDecision | DefaultedHumanDecision;
|
|
349
351
|
|
|
350
352
|
type HumanDecisionReceiptCommon = {
|
|
351
353
|
decisionId: string;
|
|
352
354
|
requestDigest: string;
|
|
353
355
|
nodeId: string;
|
|
354
356
|
response: HumanDecisionResponse;
|
|
357
|
+
provenance: "human" | "timeout";
|
|
355
358
|
acceptedAt: string;
|
|
356
359
|
answerDigest: string;
|
|
357
360
|
};
|
|
358
361
|
|
|
359
|
-
export type
|
|
362
|
+
export type HumanDecisionReceipt = HumanDecisionReceiptCommon & {
|
|
360
363
|
schema: "pi-workflows.human-decision-receipt.v1";
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
export type HumanDecisionReceiptV2 = HumanDecisionReceiptCommon & {
|
|
364
|
-
schema: "pi-workflows.human-decision-receipt.v2";
|
|
365
364
|
subjectDigest: string;
|
|
366
365
|
presentationDigest: string;
|
|
367
366
|
revision: number;
|
|
368
367
|
};
|
|
369
368
|
|
|
370
|
-
export type
|
|
371
|
-
|
|
372
|
-
export type HumanDecisionDeliveryRecordV1 = {
|
|
369
|
+
export type HumanDecisionDeliveryRecord = {
|
|
373
370
|
schema: "pi-workflows.human-decision-delivery.v1";
|
|
374
371
|
attemptId: string;
|
|
375
372
|
decisionId: string;
|
|
376
373
|
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
374
|
presentationDigest: string;
|
|
391
375
|
channel: string;
|
|
392
376
|
phase: "intent" | "part" | "complete";
|
|
@@ -401,10 +385,6 @@ export type HumanDecisionDeliveryRecordV2 = {
|
|
|
401
385
|
errorCode?: string;
|
|
402
386
|
};
|
|
403
387
|
|
|
404
|
-
export type HumanDecisionDeliveryRecord =
|
|
405
|
-
| HumanDecisionDeliveryRecordV1
|
|
406
|
-
| HumanDecisionDeliveryRecordV2;
|
|
407
|
-
|
|
408
388
|
export type HumanDecisionSettlementRecord = {
|
|
409
389
|
schema: "pi-workflows.human-decision-settlement.v1";
|
|
410
390
|
attemptId: string;
|
|
@@ -429,6 +409,7 @@ export type HumanDecisionContinuationRecord = {
|
|
|
429
409
|
schema: "pi-workflows.human-decision-continuation.v1";
|
|
430
410
|
decisionId: string;
|
|
431
411
|
requestDigest: string;
|
|
412
|
+
provenance: "human" | "timeout";
|
|
432
413
|
parentRunId: string;
|
|
433
414
|
runId: string;
|
|
434
415
|
createdAt: string;
|
|
@@ -728,6 +709,8 @@ export type WorkflowNodeSnapshot = {
|
|
|
728
709
|
audience: string;
|
|
729
710
|
dynamicAudience?: boolean;
|
|
730
711
|
choices: HumanDecisionChoiceMap;
|
|
712
|
+
onTimeout?: HumanDecisionTimeout;
|
|
713
|
+
dynamicTimeout?: boolean;
|
|
731
714
|
};
|
|
732
715
|
};
|
|
733
716
|
|
|
@@ -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,E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,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACZ,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,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,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://github.com/osolmaz/pi-workflows/schemas/human-decision-accepted-v2.schema.json",
|
|
4
|
-
"title": "pi-workflows accepted human decision v2",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"additionalProperties": false,
|
|
7
|
-
"required": [
|
|
8
|
-
"schema",
|
|
9
|
-
"decisionId",
|
|
10
|
-
"requestDigest",
|
|
11
|
-
"subjectDigest",
|
|
12
|
-
"presentationDigest",
|
|
13
|
-
"revision",
|
|
14
|
-
"response",
|
|
15
|
-
"source",
|
|
16
|
-
"idempotencyKey",
|
|
17
|
-
"acceptedAt",
|
|
18
|
-
"answerDigest"
|
|
19
|
-
],
|
|
20
|
-
"properties": {
|
|
21
|
-
"schema": { "const": "pi-workflows.human-decision-accepted.v2" },
|
|
22
|
-
"decisionId": { "type": "string" },
|
|
23
|
-
"requestDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
24
|
-
"subjectDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
25
|
-
"presentationDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
26
|
-
"revision": { "type": "integer", "minimum": 1 },
|
|
27
|
-
"response": {
|
|
28
|
-
"type": "object",
|
|
29
|
-
"additionalProperties": false,
|
|
30
|
-
"required": ["choice"],
|
|
31
|
-
"properties": {
|
|
32
|
-
"choice": { "type": "string" },
|
|
33
|
-
"input": { "type": "object", "additionalProperties": { "type": "string" } }
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"source": {
|
|
37
|
-
"type": "object",
|
|
38
|
-
"additionalProperties": false,
|
|
39
|
-
"required": ["channel", "actorId", "eventId"],
|
|
40
|
-
"properties": {
|
|
41
|
-
"channel": { "type": "string" },
|
|
42
|
-
"actorId": { "type": "string" },
|
|
43
|
-
"eventId": { "type": "string" }
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
"idempotencyKey": { "type": "string" },
|
|
47
|
-
"acceptedAt": { "type": "string", "format": "date-time" },
|
|
48
|
-
"answerDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://github.com/osolmaz/pi-workflows/schemas/human-decision-delivery-v2.schema.json",
|
|
4
|
-
"title": "pi-workflows human decision delivery v2",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"additionalProperties": false,
|
|
7
|
-
"required": [
|
|
8
|
-
"schema",
|
|
9
|
-
"attemptId",
|
|
10
|
-
"decisionId",
|
|
11
|
-
"requestDigest",
|
|
12
|
-
"presentationDigest",
|
|
13
|
-
"channel",
|
|
14
|
-
"phase",
|
|
15
|
-
"state",
|
|
16
|
-
"createdAt"
|
|
17
|
-
],
|
|
18
|
-
"properties": {
|
|
19
|
-
"schema": { "const": "pi-workflows.human-decision-delivery.v2" },
|
|
20
|
-
"attemptId": { "type": "string" },
|
|
21
|
-
"decisionId": { "type": "string" },
|
|
22
|
-
"requestDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
23
|
-
"presentationDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
24
|
-
"channel": { "type": "string" },
|
|
25
|
-
"phase": { "enum": ["intent", "part", "complete"] },
|
|
26
|
-
"state": { "enum": ["intent", "confirmed", "failed", "unknown"] },
|
|
27
|
-
"createdAt": { "type": "string", "format": "date-time" },
|
|
28
|
-
"finishedAt": { "type": "string", "format": "date-time" },
|
|
29
|
-
"recipientIndex": { "type": "integer", "minimum": 1 },
|
|
30
|
-
"partIndex": { "type": "integer", "minimum": 1 },
|
|
31
|
-
"partCount": { "type": "integer", "minimum": 1, "maximum": 20 },
|
|
32
|
-
"contentDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
33
|
-
"messageCount": { "type": "integer", "minimum": 0 },
|
|
34
|
-
"errorCode": { "type": "string" }
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://github.com/osolmaz/pi-workflows/schemas/human-decision-receipt-v2.schema.json",
|
|
4
|
-
"title": "pi-workflows redacted human decision receipt v2",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"additionalProperties": false,
|
|
7
|
-
"required": [
|
|
8
|
-
"schema",
|
|
9
|
-
"decisionId",
|
|
10
|
-
"requestDigest",
|
|
11
|
-
"subjectDigest",
|
|
12
|
-
"presentationDigest",
|
|
13
|
-
"revision",
|
|
14
|
-
"nodeId",
|
|
15
|
-
"response",
|
|
16
|
-
"acceptedAt",
|
|
17
|
-
"answerDigest"
|
|
18
|
-
],
|
|
19
|
-
"properties": {
|
|
20
|
-
"schema": { "const": "pi-workflows.human-decision-receipt.v2" },
|
|
21
|
-
"decisionId": { "type": "string" },
|
|
22
|
-
"requestDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
23
|
-
"subjectDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
24
|
-
"presentationDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
25
|
-
"revision": { "type": "integer", "minimum": 1 },
|
|
26
|
-
"nodeId": { "type": "string" },
|
|
27
|
-
"response": {
|
|
28
|
-
"type": "object",
|
|
29
|
-
"additionalProperties": false,
|
|
30
|
-
"required": ["choice"],
|
|
31
|
-
"properties": {
|
|
32
|
-
"choice": { "type": "string" },
|
|
33
|
-
"input": { "type": "object", "additionalProperties": { "type": "string" } }
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"acceptedAt": { "type": "string", "format": "date-time" },
|
|
37
|
-
"answerDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://github.com/osolmaz/pi-workflows/schemas/human-decision-request-v2.schema.json",
|
|
4
|
-
"title": "pi-workflows human decision request v2",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"additionalProperties": false,
|
|
7
|
-
"required": [
|
|
8
|
-
"schema",
|
|
9
|
-
"decisionId",
|
|
10
|
-
"requestDigest",
|
|
11
|
-
"subjectDigest",
|
|
12
|
-
"presentationDigest",
|
|
13
|
-
"runId",
|
|
14
|
-
"workflowName",
|
|
15
|
-
"nodeId",
|
|
16
|
-
"attemptId",
|
|
17
|
-
"audience",
|
|
18
|
-
"title",
|
|
19
|
-
"subject",
|
|
20
|
-
"presentation",
|
|
21
|
-
"revision",
|
|
22
|
-
"choices",
|
|
23
|
-
"createdAt"
|
|
24
|
-
],
|
|
25
|
-
"properties": {
|
|
26
|
-
"schema": { "const": "pi-workflows.human-decision-request.v2" },
|
|
27
|
-
"decisionId": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$" },
|
|
28
|
-
"requestDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
29
|
-
"subjectDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
30
|
-
"presentationDigest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
31
|
-
"runId": { "type": "string" },
|
|
32
|
-
"workflowName": { "type": "string" },
|
|
33
|
-
"nodeId": { "type": "string" },
|
|
34
|
-
"attemptId": { "type": "string" },
|
|
35
|
-
"audience": { "type": "string" },
|
|
36
|
-
"title": { "type": "string", "minLength": 1 },
|
|
37
|
-
"subject": true,
|
|
38
|
-
"presentation": {
|
|
39
|
-
"$ref": "decision-presentation-v1.schema.json"
|
|
40
|
-
},
|
|
41
|
-
"revision": { "type": "integer", "minimum": 1 },
|
|
42
|
-
"choices": {
|
|
43
|
-
"type": "object",
|
|
44
|
-
"minProperties": 1,
|
|
45
|
-
"additionalProperties": {
|
|
46
|
-
"type": "object",
|
|
47
|
-
"additionalProperties": false,
|
|
48
|
-
"required": ["label"],
|
|
49
|
-
"properties": {
|
|
50
|
-
"label": { "type": "string", "minLength": 1 },
|
|
51
|
-
"input": {
|
|
52
|
-
"type": "object",
|
|
53
|
-
"additionalProperties": false,
|
|
54
|
-
"required": ["kind", "name", "prompt", "minLength", "maxLength"],
|
|
55
|
-
"properties": {
|
|
56
|
-
"kind": { "const": "text" },
|
|
57
|
-
"name": { "type": "string" },
|
|
58
|
-
"prompt": { "type": "string", "minLength": 1 },
|
|
59
|
-
"minLength": { "type": "integer", "minimum": 0 },
|
|
60
|
-
"maxLength": { "type": "integer", "minimum": 1 }
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"createdAt": { "type": "string", "format": "date-time" },
|
|
67
|
-
"expiresAt": { "type": "string", "format": "date-time" }
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://github.com/osolmaz/pi-workflows/schemas/human-decision-resolution-v2.schema.json",
|
|
4
|
-
"title": "pi-workflows human decision resolution v2",
|
|
5
|
-
"oneOf": [
|
|
6
|
-
{
|
|
7
|
-
"type": "object",
|
|
8
|
-
"additionalProperties": false,
|
|
9
|
-
"required": ["schema", "outcome", "decision"],
|
|
10
|
-
"properties": {
|
|
11
|
-
"schema": { "const": "pi-workflows.human-decision-resolution.v2" },
|
|
12
|
-
"outcome": { "const": "accepted" },
|
|
13
|
-
"decision": { "$ref": "human-decision-accepted-v2.schema.json" }
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"type": "object",
|
|
18
|
-
"additionalProperties": false,
|
|
19
|
-
"required": ["schema", "outcome", "cancellation"],
|
|
20
|
-
"properties": {
|
|
21
|
-
"schema": { "const": "pi-workflows.human-decision-resolution.v2" },
|
|
22
|
-
"outcome": { "const": "cancelled" },
|
|
23
|
-
"cancellation": { "$ref": "human-decision-cancellation-v1.schema.json" }
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
}
|