@h-rig/contracts 0.0.6-alpha.131 → 0.0.6-alpha.133
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/dist/index.cjs +2206 -1386
- package/dist/index.mjs +2206 -1386
- package/dist/src/config.d.ts +156 -0
- package/dist/src/config.js +1566 -178
- package/dist/src/drift.d.ts +28 -0
- package/dist/src/drift.js +69 -0
- package/dist/src/engine.js +108 -0
- package/dist/src/graph.d.ts +284 -0
- package/dist/src/graph.js +121 -1
- package/dist/src/help-catalog.js +78 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +2206 -1386
- package/dist/src/kernel.d.ts +238 -0
- package/dist/src/kernel.js +284 -0
- package/dist/src/planning.d.ts +64 -0
- package/dist/src/planning.js +90 -0
- package/dist/src/plugin-hooks.js +318 -76
- package/dist/src/plugin.d.ts +92 -0
- package/dist/src/plugin.js +308 -64
- package/dist/src/rig.js +108 -0
- package/dist/src/rollups.d.ts +41 -0
- package/dist/src/rollups.js +70 -0
- package/dist/src/run-journal.d.ts +22 -21
- package/dist/src/run-journal.js +3 -1
- package/dist/src/run-session-journal.js +4 -2
- package/dist/src/stage.d.ts +245 -0
- package/dist/src/stage.js +169 -0
- package/dist/src/supervisor-journal.d.ts +205 -0
- package/dist/src/supervisor-journal.js +1246 -0
- package/dist/src/task-source.d.ts +9 -0
- package/dist/src/ws.js +108 -0
- package/package.json +45 -1
|
@@ -533,8 +533,8 @@ export declare const decodeRunJournalEvent: (input: unknown, options?: import("e
|
|
|
533
533
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
534
534
|
readonly v: 1;
|
|
535
535
|
readonly type: "status-changed";
|
|
536
|
-
readonly from: "running" | "
|
|
537
|
-
readonly to: "running" | "
|
|
536
|
+
readonly from: "running" | "stopped" | "completed" | "created" | "queued" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention" | "failed" | null;
|
|
537
|
+
readonly to: "running" | "stopped" | "completed" | "created" | "queued" | "preparing" | "waiting-approval" | "waiting-user-input" | "paused" | "validating" | "reviewing" | "closing-out" | "needs-attention" | "failed";
|
|
538
538
|
readonly seq: number;
|
|
539
539
|
readonly reason?: string | null | undefined;
|
|
540
540
|
readonly actor?: {
|
|
@@ -553,28 +553,28 @@ export declare const decodeRunJournalEvent: (input: unknown, options?: import("e
|
|
|
553
553
|
readonly createdAt?: string | undefined;
|
|
554
554
|
readonly title?: string | undefined;
|
|
555
555
|
readonly mode?: "local" | "remote" | undefined;
|
|
556
|
-
readonly model?: string | null | undefined;
|
|
557
|
-
readonly planning?: unknown;
|
|
558
|
-
readonly updatedAt?: string | undefined;
|
|
559
|
-
readonly completedAt?: string | null | undefined;
|
|
560
556
|
readonly startedAt?: string | null | undefined;
|
|
561
|
-
readonly
|
|
557
|
+
readonly updatedAt?: string | undefined;
|
|
562
558
|
readonly runtimeMode?: string | null | undefined;
|
|
563
559
|
readonly threadId?: string | null | undefined;
|
|
560
|
+
readonly completedAt?: string | null | undefined;
|
|
564
561
|
readonly interactionMode?: string | null | undefined;
|
|
565
562
|
readonly branch?: string | null | undefined;
|
|
566
563
|
readonly worktreePath?: string | null | undefined;
|
|
564
|
+
readonly model?: string | null | undefined;
|
|
567
565
|
readonly runtimeAdapter?: "pi" | undefined;
|
|
568
566
|
readonly initialPrompt?: string | null | undefined;
|
|
569
567
|
readonly latestMessageId?: string | null | undefined;
|
|
570
568
|
readonly errorText?: string | null | undefined;
|
|
569
|
+
readonly workspaceId?: string | undefined;
|
|
571
570
|
readonly sessionLogPath?: string | null | undefined;
|
|
572
571
|
readonly pid?: number | null | undefined;
|
|
572
|
+
readonly prUrl?: string | null | undefined;
|
|
573
|
+
readonly planning?: unknown;
|
|
573
574
|
readonly endpointId?: string | null | undefined;
|
|
574
575
|
readonly hostId?: string | null | undefined;
|
|
575
576
|
readonly leaseId?: string | null | undefined;
|
|
576
577
|
readonly runMode?: string | null | undefined;
|
|
577
|
-
readonly prUrl?: string | null | undefined;
|
|
578
578
|
readonly artifactRoot?: string | null | undefined;
|
|
579
579
|
readonly logRoot?: string | null | undefined;
|
|
580
580
|
readonly sessionPath?: string | null | undefined;
|
|
@@ -582,17 +582,17 @@ export declare const decodeRunJournalEvent: (input: unknown, options?: import("e
|
|
|
582
582
|
readonly piSessionPrivate?: unknown;
|
|
583
583
|
readonly projectRoot?: string | null | undefined;
|
|
584
584
|
readonly serverCloseout?: {
|
|
585
|
-
readonly status: "running" | "completed" | "
|
|
585
|
+
readonly status: "running" | "completed" | "pending" | "needs-attention" | "failed";
|
|
586
586
|
readonly updatedAt: string;
|
|
587
|
-
readonly phase: "push" | "
|
|
587
|
+
readonly phase: "push" | "completed" | "queued" | "merge" | "commit" | "pr-review-merge" | "pr-opened" | "close-source";
|
|
588
588
|
readonly taskId?: string | null | undefined;
|
|
589
|
-
readonly completedAt?: string | null | undefined;
|
|
590
|
-
readonly error?: string | null | undefined;
|
|
591
589
|
readonly reason?: string | null | undefined;
|
|
590
|
+
readonly error?: string | null | undefined;
|
|
591
|
+
readonly completedAt?: string | null | undefined;
|
|
592
592
|
readonly branch?: string | null | undefined;
|
|
593
|
+
readonly prUrl?: string | null | undefined;
|
|
593
594
|
readonly merged?: boolean | undefined;
|
|
594
595
|
readonly runtimeWorkspace?: string | null | undefined;
|
|
595
|
-
readonly prUrl?: string | null | undefined;
|
|
596
596
|
readonly artifactRoot?: string | null | undefined;
|
|
597
597
|
readonly iterations?: number | null | undefined;
|
|
598
598
|
readonly feedback?: readonly string[] | undefined;
|
|
@@ -611,22 +611,22 @@ export declare const decodeRunJournalEvent: (input: unknown, options?: import("e
|
|
|
611
611
|
readonly at: string;
|
|
612
612
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
613
613
|
readonly v: 1;
|
|
614
|
-
readonly payload: unknown;
|
|
615
614
|
readonly type: "timeline-entry";
|
|
615
|
+
readonly payload: unknown;
|
|
616
616
|
readonly seq: number;
|
|
617
617
|
} | {
|
|
618
618
|
readonly at: string;
|
|
619
619
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
620
620
|
readonly v: 1;
|
|
621
|
-
readonly payload: unknown;
|
|
622
621
|
readonly type: "log-entry";
|
|
622
|
+
readonly payload: unknown;
|
|
623
623
|
readonly seq: number;
|
|
624
624
|
} | {
|
|
625
625
|
readonly at: string;
|
|
626
626
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
627
627
|
readonly v: 1;
|
|
628
|
-
readonly payload: unknown;
|
|
629
628
|
readonly type: "approval-requested";
|
|
629
|
+
readonly payload: unknown;
|
|
630
630
|
readonly requestId: string;
|
|
631
631
|
readonly requestKind: string;
|
|
632
632
|
readonly seq: number;
|
|
@@ -635,9 +635,9 @@ export declare const decodeRunJournalEvent: (input: unknown, options?: import("e
|
|
|
635
635
|
readonly at: string;
|
|
636
636
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
637
637
|
readonly v: 1;
|
|
638
|
-
readonly decision: "approve" | "reject";
|
|
639
638
|
readonly type: "approval-resolved";
|
|
640
639
|
readonly requestId: string;
|
|
640
|
+
readonly decision: "approve" | "reject";
|
|
641
641
|
readonly actor: {
|
|
642
642
|
readonly kind: "server" | "system" | "agent" | "operator";
|
|
643
643
|
readonly id?: string | null | undefined;
|
|
@@ -648,8 +648,8 @@ export declare const decodeRunJournalEvent: (input: unknown, options?: import("e
|
|
|
648
648
|
readonly at: string;
|
|
649
649
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
650
650
|
readonly v: 1;
|
|
651
|
-
readonly payload: unknown;
|
|
652
651
|
readonly type: "input-requested";
|
|
652
|
+
readonly payload: unknown;
|
|
653
653
|
readonly requestId: string;
|
|
654
654
|
readonly seq: number;
|
|
655
655
|
} | {
|
|
@@ -670,8 +670,8 @@ export declare const decodeRunJournalEvent: (input: unknown, options?: import("e
|
|
|
670
670
|
readonly at: string;
|
|
671
671
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
672
672
|
readonly v: 1;
|
|
673
|
-
readonly text: string;
|
|
674
673
|
readonly type: "steering";
|
|
674
|
+
readonly text: string;
|
|
675
675
|
readonly actor: {
|
|
676
676
|
readonly kind: "server" | "system" | "agent" | "operator";
|
|
677
677
|
readonly id?: string | null | undefined;
|
|
@@ -697,7 +697,7 @@ export declare const decodeRunJournalEvent: (input: unknown, options?: import("e
|
|
|
697
697
|
readonly runId: string & import("effect/Brand").Brand<"RunId">;
|
|
698
698
|
readonly v: 1;
|
|
699
699
|
readonly type: "closeout-phase";
|
|
700
|
-
readonly phase: "push" | "
|
|
700
|
+
readonly phase: "push" | "completed" | "queued" | "merge" | "commit" | "pr-review-merge" | "pr-opened" | "close-source";
|
|
701
701
|
readonly seq: number;
|
|
702
702
|
readonly outcome: "completed" | "failed" | "started";
|
|
703
703
|
readonly detail?: string | null | undefined;
|
|
@@ -734,6 +734,7 @@ export type RunJournalResolvedInput = RunJournalPendingRequest & {
|
|
|
734
734
|
resolvedAt: string;
|
|
735
735
|
};
|
|
736
736
|
export type RunJournalProjection = {
|
|
737
|
+
runId: string | null;
|
|
737
738
|
record: Partial<RunJournalRecord>;
|
|
738
739
|
status: RunStatus | null;
|
|
739
740
|
statusHistory: ReadonlyArray<{
|
|
@@ -760,4 +761,4 @@ export type RunJournalProjection = {
|
|
|
760
761
|
lastEventAt: string | null;
|
|
761
762
|
anomalies: ReadonlyArray<RunJournalAnomaly>;
|
|
762
763
|
};
|
|
763
|
-
export declare function reduceRunJournal(events: ReadonlyArray<RunJournalEvent
|
|
764
|
+
export declare function reduceRunJournal(events: ReadonlyArray<RunJournalEvent>, runId?: string | null): RunJournalProjection;
|
package/dist/src/run-journal.js
CHANGED
|
@@ -1313,7 +1313,7 @@ function assertRunStatusTransition(from, to) {
|
|
|
1313
1313
|
throw new Error(`Illegal run status transition: ${from ?? "(none)"} -> ${to}. ` + `Allowed from ${from ?? "(none)"}: ${from ? RUN_STATUS_TRANSITIONS[from].join(", ") : "(any)"}.`);
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
|
-
function reduceRunJournal(events) {
|
|
1316
|
+
function reduceRunJournal(events, runId = null) {
|
|
1317
1317
|
let record = {};
|
|
1318
1318
|
let status = null;
|
|
1319
1319
|
const statusHistory = [];
|
|
@@ -1327,6 +1327,7 @@ function reduceRunJournal(events) {
|
|
|
1327
1327
|
let stallCount = 0;
|
|
1328
1328
|
let lastSeq = 0;
|
|
1329
1329
|
let lastEventAt = null;
|
|
1330
|
+
const projectedRunId = runId ?? events[0]?.runId ?? null;
|
|
1330
1331
|
for (const event of events) {
|
|
1331
1332
|
lastSeq = event.seq;
|
|
1332
1333
|
lastEventAt = event.at;
|
|
@@ -1460,6 +1461,7 @@ function reduceRunJournal(events) {
|
|
|
1460
1461
|
}
|
|
1461
1462
|
}
|
|
1462
1463
|
return {
|
|
1464
|
+
runId: projectedRunId,
|
|
1463
1465
|
record,
|
|
1464
1466
|
status,
|
|
1465
1467
|
statusHistory,
|
|
@@ -1305,7 +1305,7 @@ function canTransitionRunStatus(from, to) {
|
|
|
1305
1305
|
return true;
|
|
1306
1306
|
return RUN_STATUS_TRANSITIONS[from].includes(to);
|
|
1307
1307
|
}
|
|
1308
|
-
function reduceRunJournal(events) {
|
|
1308
|
+
function reduceRunJournal(events, runId = null) {
|
|
1309
1309
|
let record = {};
|
|
1310
1310
|
let status = null;
|
|
1311
1311
|
const statusHistory = [];
|
|
@@ -1319,6 +1319,7 @@ function reduceRunJournal(events) {
|
|
|
1319
1319
|
let stallCount = 0;
|
|
1320
1320
|
let lastSeq = 0;
|
|
1321
1321
|
let lastEventAt = null;
|
|
1322
|
+
const projectedRunId = runId ?? events[0]?.runId ?? null;
|
|
1322
1323
|
for (const event of events) {
|
|
1323
1324
|
lastSeq = event.seq;
|
|
1324
1325
|
lastEventAt = event.at;
|
|
@@ -1452,6 +1453,7 @@ function reduceRunJournal(events) {
|
|
|
1452
1453
|
}
|
|
1453
1454
|
}
|
|
1454
1455
|
return {
|
|
1456
|
+
runId: projectedRunId,
|
|
1455
1457
|
record,
|
|
1456
1458
|
status,
|
|
1457
1459
|
statusHistory,
|
|
@@ -1634,7 +1636,7 @@ function foldRunSessionEntries(entries, runId) {
|
|
|
1634
1636
|
events.push(decodeRunJournalEvent(stamped));
|
|
1635
1637
|
} catch {}
|
|
1636
1638
|
});
|
|
1637
|
-
return reduceRunJournal(events);
|
|
1639
|
+
return reduceRunJournal(events, runId);
|
|
1638
1640
|
}
|
|
1639
1641
|
export {
|
|
1640
1642
|
sessionIdFromSessionFile,
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const StageKind: Schema.Literals<readonly ["transform", "gate", "observe"]>;
|
|
3
|
+
export type StageKind = typeof StageKind.Type;
|
|
4
|
+
export declare const StageId: Schema.brand<Schema.Trim, "StageId">;
|
|
5
|
+
export type StageId = typeof StageId.Type;
|
|
6
|
+
export declare const StageContext: Schema.Struct<{
|
|
7
|
+
readonly runId: Schema.brand<Schema.Trim, "RunId">;
|
|
8
|
+
readonly taskId: Schema.optional<Schema.NullOr<Schema.brand<Schema.Trim, "TaskId">>>;
|
|
9
|
+
readonly state: Schema.Unknown;
|
|
10
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
11
|
+
}>;
|
|
12
|
+
export type StageContext = typeof StageContext.Type;
|
|
13
|
+
export declare const StageDescriptor: Schema.Struct<{
|
|
14
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
15
|
+
readonly kind: Schema.Literals<readonly ["transform", "gate", "observe"]>;
|
|
16
|
+
readonly before: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
17
|
+
readonly after: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
18
|
+
readonly priority: Schema.withDecodingDefault<Schema.Number>;
|
|
19
|
+
readonly protected: Schema.withDecodingDefault<Schema.Boolean>;
|
|
20
|
+
}>;
|
|
21
|
+
export type StageDescriptor = typeof StageDescriptor.Type;
|
|
22
|
+
export declare const Stage: Schema.Struct<{
|
|
23
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
24
|
+
readonly kind: Schema.Literals<readonly ["transform", "gate", "observe"]>;
|
|
25
|
+
readonly before: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
26
|
+
readonly after: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
27
|
+
readonly priority: Schema.withDecodingDefault<Schema.Number>;
|
|
28
|
+
readonly protected: Schema.withDecodingDefault<Schema.Boolean>;
|
|
29
|
+
}>;
|
|
30
|
+
export type Stage = typeof Stage.Type;
|
|
31
|
+
export declare const StageContinueResult: Schema.Struct<{
|
|
32
|
+
readonly kind: Schema.Literal<"continue">;
|
|
33
|
+
readonly ctx: Schema.Struct<{
|
|
34
|
+
readonly runId: Schema.brand<Schema.Trim, "RunId">;
|
|
35
|
+
readonly taskId: Schema.optional<Schema.NullOr<Schema.brand<Schema.Trim, "TaskId">>>;
|
|
36
|
+
readonly state: Schema.Unknown;
|
|
37
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
38
|
+
}>;
|
|
39
|
+
}>;
|
|
40
|
+
export type StageContinueResult = typeof StageContinueResult.Type;
|
|
41
|
+
export declare const StageAllowResult: Schema.Struct<{
|
|
42
|
+
readonly kind: Schema.Literal<"allow">;
|
|
43
|
+
}>;
|
|
44
|
+
export type StageAllowResult = typeof StageAllowResult.Type;
|
|
45
|
+
export declare const StageBlockResult: Schema.Struct<{
|
|
46
|
+
readonly kind: Schema.Literal<"block">;
|
|
47
|
+
readonly reason: Schema.Trim;
|
|
48
|
+
}>;
|
|
49
|
+
export type StageBlockResult = typeof StageBlockResult.Type;
|
|
50
|
+
export declare const StageResult: Schema.Union<readonly [Schema.Struct<{
|
|
51
|
+
readonly kind: Schema.Literal<"continue">;
|
|
52
|
+
readonly ctx: Schema.Struct<{
|
|
53
|
+
readonly runId: Schema.brand<Schema.Trim, "RunId">;
|
|
54
|
+
readonly taskId: Schema.optional<Schema.NullOr<Schema.brand<Schema.Trim, "TaskId">>>;
|
|
55
|
+
readonly state: Schema.Unknown;
|
|
56
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
57
|
+
}>;
|
|
58
|
+
}>, Schema.Struct<{
|
|
59
|
+
readonly kind: Schema.Literal<"allow">;
|
|
60
|
+
}>, Schema.Struct<{
|
|
61
|
+
readonly kind: Schema.Literal<"block">;
|
|
62
|
+
readonly reason: Schema.Trim;
|
|
63
|
+
}>]>;
|
|
64
|
+
export type StageResult = typeof StageResult.Type;
|
|
65
|
+
export type StageRun = (ctx: StageContext) => Promise<StageResult> | StageResult;
|
|
66
|
+
export declare const StageWrapperDescriptor: Schema.Struct<{
|
|
67
|
+
readonly id: Schema.Trim;
|
|
68
|
+
readonly priority: Schema.withDecodingDefault<Schema.Number>;
|
|
69
|
+
}>;
|
|
70
|
+
export type StageWrapperDescriptor = typeof StageWrapperDescriptor.Type;
|
|
71
|
+
export type StageWrapper = (next: StageRun, ctx: StageContext) => Promise<StageResult> | StageResult;
|
|
72
|
+
export declare const StageMutationOp: Schema.Literals<readonly ["insert", "remove", "replace", "wrap", "reorder"]>;
|
|
73
|
+
export type StageMutationOp = typeof StageMutationOp.Type;
|
|
74
|
+
export declare const InsertStageMutation: Schema.Struct<{
|
|
75
|
+
readonly op: Schema.Literal<"insert">;
|
|
76
|
+
readonly stage: Schema.Struct<{
|
|
77
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
78
|
+
readonly kind: Schema.Literals<readonly ["transform", "gate", "observe"]>;
|
|
79
|
+
readonly before: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
80
|
+
readonly after: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
81
|
+
readonly priority: Schema.withDecodingDefault<Schema.Number>;
|
|
82
|
+
readonly protected: Schema.withDecodingDefault<Schema.Boolean>;
|
|
83
|
+
}>;
|
|
84
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
85
|
+
}>;
|
|
86
|
+
export type InsertStageMutation = typeof InsertStageMutation.Type;
|
|
87
|
+
export declare const RemoveStageMutation: Schema.Struct<{
|
|
88
|
+
readonly op: Schema.Literal<"remove">;
|
|
89
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
90
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
91
|
+
}>;
|
|
92
|
+
export type RemoveStageMutation = typeof RemoveStageMutation.Type;
|
|
93
|
+
export declare const ReplaceStageMutation: Schema.Struct<{
|
|
94
|
+
readonly op: Schema.Literal<"replace">;
|
|
95
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
96
|
+
readonly stage: Schema.Struct<{
|
|
97
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
98
|
+
readonly kind: Schema.Literals<readonly ["transform", "gate", "observe"]>;
|
|
99
|
+
readonly before: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
100
|
+
readonly after: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
101
|
+
readonly priority: Schema.withDecodingDefault<Schema.Number>;
|
|
102
|
+
readonly protected: Schema.withDecodingDefault<Schema.Boolean>;
|
|
103
|
+
}>;
|
|
104
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
105
|
+
}>;
|
|
106
|
+
export type ReplaceStageMutation = typeof ReplaceStageMutation.Type;
|
|
107
|
+
export declare const WrapStageMutation: Schema.Struct<{
|
|
108
|
+
readonly op: Schema.Literal<"wrap">;
|
|
109
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
110
|
+
readonly around: Schema.Struct<{
|
|
111
|
+
readonly id: Schema.Trim;
|
|
112
|
+
readonly priority: Schema.withDecodingDefault<Schema.Number>;
|
|
113
|
+
}>;
|
|
114
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
115
|
+
}>;
|
|
116
|
+
export type WrapStageMutation = typeof WrapStageMutation.Type;
|
|
117
|
+
export declare const ReorderStageMutation: Schema.Struct<{
|
|
118
|
+
readonly op: Schema.Literal<"reorder">;
|
|
119
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
120
|
+
readonly before: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
121
|
+
readonly after: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
122
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
123
|
+
}>;
|
|
124
|
+
export type ReorderStageMutation = typeof ReorderStageMutation.Type;
|
|
125
|
+
export declare const StageMutation: Schema.Union<readonly [Schema.Struct<{
|
|
126
|
+
readonly op: Schema.Literal<"insert">;
|
|
127
|
+
readonly stage: Schema.Struct<{
|
|
128
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
129
|
+
readonly kind: Schema.Literals<readonly ["transform", "gate", "observe"]>;
|
|
130
|
+
readonly before: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
131
|
+
readonly after: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
132
|
+
readonly priority: Schema.withDecodingDefault<Schema.Number>;
|
|
133
|
+
readonly protected: Schema.withDecodingDefault<Schema.Boolean>;
|
|
134
|
+
}>;
|
|
135
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
136
|
+
}>, Schema.Struct<{
|
|
137
|
+
readonly op: Schema.Literal<"remove">;
|
|
138
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
139
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
140
|
+
}>, Schema.Struct<{
|
|
141
|
+
readonly op: Schema.Literal<"replace">;
|
|
142
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
143
|
+
readonly stage: Schema.Struct<{
|
|
144
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
145
|
+
readonly kind: Schema.Literals<readonly ["transform", "gate", "observe"]>;
|
|
146
|
+
readonly before: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
147
|
+
readonly after: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
148
|
+
readonly priority: Schema.withDecodingDefault<Schema.Number>;
|
|
149
|
+
readonly protected: Schema.withDecodingDefault<Schema.Boolean>;
|
|
150
|
+
}>;
|
|
151
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
152
|
+
}>, Schema.Struct<{
|
|
153
|
+
readonly op: Schema.Literal<"wrap">;
|
|
154
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
155
|
+
readonly around: Schema.Struct<{
|
|
156
|
+
readonly id: Schema.Trim;
|
|
157
|
+
readonly priority: Schema.withDecodingDefault<Schema.Number>;
|
|
158
|
+
}>;
|
|
159
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
160
|
+
}>, Schema.Struct<{
|
|
161
|
+
readonly op: Schema.Literal<"reorder">;
|
|
162
|
+
readonly id: Schema.brand<Schema.Trim, "StageId">;
|
|
163
|
+
readonly before: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
164
|
+
readonly after: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
165
|
+
readonly contributedBy: Schema.optional<Schema.Trim>;
|
|
166
|
+
}>]>;
|
|
167
|
+
export type StageMutation = typeof StageMutation.Type;
|
|
168
|
+
export declare const ResolutionGrantUse: Schema.Struct<{
|
|
169
|
+
readonly kind: Schema.Literals<readonly ["protected-stage", "kernel-replacement"]>;
|
|
170
|
+
readonly target: Schema.Trim;
|
|
171
|
+
readonly pluginId: Schema.Trim;
|
|
172
|
+
}>;
|
|
173
|
+
export type ResolutionGrantUse = typeof ResolutionGrantUse.Type;
|
|
174
|
+
export declare const ResolutionRecordEntry: Schema.Struct<{
|
|
175
|
+
readonly stageId: Schema.brand<Schema.Trim, "StageId">;
|
|
176
|
+
readonly contributedBy: Schema.Trim;
|
|
177
|
+
readonly removedBy: Schema.optional<Schema.Trim>;
|
|
178
|
+
readonly replacedBy: Schema.optional<Schema.Trim>;
|
|
179
|
+
readonly wrappedBy: Schema.optional<Schema.$Array<Schema.Trim>>;
|
|
180
|
+
readonly droppedAnchors: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
181
|
+
readonly isProtected: Schema.Boolean;
|
|
182
|
+
}>;
|
|
183
|
+
export type ResolutionRecordEntry = typeof ResolutionRecordEntry.Type;
|
|
184
|
+
export declare const ResolvedPipeline: Schema.Struct<{
|
|
185
|
+
readonly runId: Schema.optional<Schema.brand<Schema.Trim, "RunId">>;
|
|
186
|
+
readonly order: Schema.$Array<Schema.brand<Schema.Trim, "StageId">>;
|
|
187
|
+
readonly record: Schema.$Array<Schema.Struct<{
|
|
188
|
+
readonly stageId: Schema.brand<Schema.Trim, "StageId">;
|
|
189
|
+
readonly contributedBy: Schema.Trim;
|
|
190
|
+
readonly removedBy: Schema.optional<Schema.Trim>;
|
|
191
|
+
readonly replacedBy: Schema.optional<Schema.Trim>;
|
|
192
|
+
readonly wrappedBy: Schema.optional<Schema.$Array<Schema.Trim>>;
|
|
193
|
+
readonly droppedAnchors: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
194
|
+
readonly isProtected: Schema.Boolean;
|
|
195
|
+
}>>;
|
|
196
|
+
readonly cycles: Schema.$Array<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
197
|
+
readonly grantUses: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
198
|
+
readonly kind: Schema.Literals<readonly ["protected-stage", "kernel-replacement"]>;
|
|
199
|
+
readonly target: Schema.Trim;
|
|
200
|
+
readonly pluginId: Schema.Trim;
|
|
201
|
+
}>>>;
|
|
202
|
+
readonly resolvedAt: Schema.optional<Schema.String>;
|
|
203
|
+
}>;
|
|
204
|
+
export type ResolvedPipeline = typeof ResolvedPipeline.Type;
|
|
205
|
+
export declare const ResolutionRecord: Schema.Struct<{
|
|
206
|
+
readonly runId: Schema.optional<Schema.brand<Schema.Trim, "RunId">>;
|
|
207
|
+
readonly order: Schema.$Array<Schema.brand<Schema.Trim, "StageId">>;
|
|
208
|
+
readonly record: Schema.$Array<Schema.Struct<{
|
|
209
|
+
readonly stageId: Schema.brand<Schema.Trim, "StageId">;
|
|
210
|
+
readonly contributedBy: Schema.Trim;
|
|
211
|
+
readonly removedBy: Schema.optional<Schema.Trim>;
|
|
212
|
+
readonly replacedBy: Schema.optional<Schema.Trim>;
|
|
213
|
+
readonly wrappedBy: Schema.optional<Schema.$Array<Schema.Trim>>;
|
|
214
|
+
readonly droppedAnchors: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
215
|
+
readonly isProtected: Schema.Boolean;
|
|
216
|
+
}>>;
|
|
217
|
+
readonly cycles: Schema.$Array<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
218
|
+
readonly grantUses: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
219
|
+
readonly kind: Schema.Literals<readonly ["protected-stage", "kernel-replacement"]>;
|
|
220
|
+
readonly target: Schema.Trim;
|
|
221
|
+
readonly pluginId: Schema.Trim;
|
|
222
|
+
}>>>;
|
|
223
|
+
readonly resolvedAt: Schema.optional<Schema.String>;
|
|
224
|
+
}>;
|
|
225
|
+
export type ResolutionRecord = typeof ResolutionRecord.Type;
|
|
226
|
+
export declare const StageRunOutcome: Schema.Struct<{
|
|
227
|
+
readonly stageId: Schema.brand<Schema.Trim, "StageId">;
|
|
228
|
+
readonly result: Schema.Union<readonly [Schema.Struct<{
|
|
229
|
+
readonly kind: Schema.Literal<"continue">;
|
|
230
|
+
readonly ctx: Schema.Struct<{
|
|
231
|
+
readonly runId: Schema.brand<Schema.Trim, "RunId">;
|
|
232
|
+
readonly taskId: Schema.optional<Schema.NullOr<Schema.brand<Schema.Trim, "TaskId">>>;
|
|
233
|
+
readonly state: Schema.Unknown;
|
|
234
|
+
readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
235
|
+
}>;
|
|
236
|
+
}>, Schema.Struct<{
|
|
237
|
+
readonly kind: Schema.Literal<"allow">;
|
|
238
|
+
}>, Schema.Struct<{
|
|
239
|
+
readonly kind: Schema.Literal<"block">;
|
|
240
|
+
readonly reason: Schema.Trim;
|
|
241
|
+
}>]>;
|
|
242
|
+
readonly startedAt: Schema.String;
|
|
243
|
+
readonly finishedAt: Schema.String;
|
|
244
|
+
}>;
|
|
245
|
+
export type StageRunOutcome = typeof StageRunOutcome.Type;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/contracts/src/stage.ts
|
|
3
|
+
import { Schema as Schema2 } from "effect";
|
|
4
|
+
|
|
5
|
+
// packages/contracts/src/baseSchemas.ts
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
var TrimmedString = Schema.Trim;
|
|
8
|
+
var TrimmedNonEmptyString = TrimmedString.check(Schema.isNonEmpty());
|
|
9
|
+
var NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
10
|
+
var PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
|
|
11
|
+
var IsoDateTime = Schema.String;
|
|
12
|
+
var makeEntityId = (brand) => TrimmedNonEmptyString.pipe(Schema.brand(brand));
|
|
13
|
+
var ThreadId = makeEntityId("ThreadId");
|
|
14
|
+
var ProjectId = makeEntityId("ProjectId");
|
|
15
|
+
var WorkspaceId = makeEntityId("WorkspaceId");
|
|
16
|
+
var GraphId = makeEntityId("GraphId");
|
|
17
|
+
var TaskId = makeEntityId("TaskId");
|
|
18
|
+
var RunId = makeEntityId("RunId");
|
|
19
|
+
var SafePathSegment = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafePathSegment"));
|
|
20
|
+
var SafeRunId = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/)).pipe(Schema.brand("SafeRunId"));
|
|
21
|
+
var SafeGitRefComponent = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafeGitRefComponent"));
|
|
22
|
+
var EngineRuntimeId = makeEntityId("EngineRuntimeId");
|
|
23
|
+
var ConversationId = makeEntityId("ConversationId");
|
|
24
|
+
var ActionId = makeEntityId("ActionId");
|
|
25
|
+
var ArtifactId = makeEntityId("ArtifactId");
|
|
26
|
+
var WorktreeId = makeEntityId("WorktreeId");
|
|
27
|
+
var ValidationResultId = makeEntityId("ValidationResultId");
|
|
28
|
+
var ReviewResultId = makeEntityId("ReviewResultId");
|
|
29
|
+
var CommandId = makeEntityId("CommandId");
|
|
30
|
+
var EventId = makeEntityId("EventId");
|
|
31
|
+
var MessageId = makeEntityId("MessageId");
|
|
32
|
+
var TurnId = makeEntityId("TurnId");
|
|
33
|
+
var ProviderItemId = makeEntityId("ProviderItemId");
|
|
34
|
+
var RuntimeSessionId = makeEntityId("RuntimeSessionId");
|
|
35
|
+
var RuntimeItemId = makeEntityId("RuntimeItemId");
|
|
36
|
+
var RuntimeRequestId = makeEntityId("RuntimeRequestId");
|
|
37
|
+
var RuntimeTaskId = makeEntityId("RuntimeTaskId");
|
|
38
|
+
var ApprovalRequestId = makeEntityId("ApprovalRequestId");
|
|
39
|
+
var CheckpointRef = makeEntityId("CheckpointRef");
|
|
40
|
+
var RemoteEndpointId = makeEntityId("RemoteEndpointId");
|
|
41
|
+
|
|
42
|
+
// packages/contracts/src/stage.ts
|
|
43
|
+
var StageKind = Schema2.Literals(["transform", "gate", "observe"]);
|
|
44
|
+
var StageId = TrimmedNonEmptyString.pipe(Schema2.brand("StageId"));
|
|
45
|
+
var StageContext = Schema2.Struct({
|
|
46
|
+
runId: RunId,
|
|
47
|
+
taskId: Schema2.optional(Schema2.NullOr(TaskId)),
|
|
48
|
+
state: Schema2.Unknown,
|
|
49
|
+
metadata: Schema2.optional(Schema2.Record(Schema2.String, Schema2.Unknown))
|
|
50
|
+
});
|
|
51
|
+
var StageDescriptor = Schema2.Struct({
|
|
52
|
+
id: StageId,
|
|
53
|
+
kind: StageKind,
|
|
54
|
+
before: Schema2.optional(Schema2.Array(StageId)),
|
|
55
|
+
after: Schema2.optional(Schema2.Array(StageId)),
|
|
56
|
+
priority: Schema2.Number.pipe(Schema2.withDecodingDefault(() => 0)),
|
|
57
|
+
protected: Schema2.Boolean.pipe(Schema2.withDecodingDefault(() => false))
|
|
58
|
+
});
|
|
59
|
+
var Stage = StageDescriptor;
|
|
60
|
+
var StageContinueResult = Schema2.Struct({
|
|
61
|
+
kind: Schema2.Literal("continue"),
|
|
62
|
+
ctx: StageContext
|
|
63
|
+
});
|
|
64
|
+
var StageAllowResult = Schema2.Struct({
|
|
65
|
+
kind: Schema2.Literal("allow")
|
|
66
|
+
});
|
|
67
|
+
var StageBlockResult = Schema2.Struct({
|
|
68
|
+
kind: Schema2.Literal("block"),
|
|
69
|
+
reason: TrimmedNonEmptyString
|
|
70
|
+
});
|
|
71
|
+
var StageResult = Schema2.Union([
|
|
72
|
+
StageContinueResult,
|
|
73
|
+
StageAllowResult,
|
|
74
|
+
StageBlockResult
|
|
75
|
+
]);
|
|
76
|
+
var StageWrapperDescriptor = Schema2.Struct({
|
|
77
|
+
id: TrimmedNonEmptyString,
|
|
78
|
+
priority: Schema2.Number.pipe(Schema2.withDecodingDefault(() => 0))
|
|
79
|
+
});
|
|
80
|
+
var StageMutationOp = Schema2.Literals(["insert", "remove", "replace", "wrap", "reorder"]);
|
|
81
|
+
var InsertStageMutation = Schema2.Struct({
|
|
82
|
+
op: Schema2.Literal("insert"),
|
|
83
|
+
stage: StageDescriptor,
|
|
84
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
85
|
+
});
|
|
86
|
+
var RemoveStageMutation = Schema2.Struct({
|
|
87
|
+
op: Schema2.Literal("remove"),
|
|
88
|
+
id: StageId,
|
|
89
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
90
|
+
});
|
|
91
|
+
var ReplaceStageMutation = Schema2.Struct({
|
|
92
|
+
op: Schema2.Literal("replace"),
|
|
93
|
+
id: StageId,
|
|
94
|
+
stage: StageDescriptor,
|
|
95
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
96
|
+
});
|
|
97
|
+
var WrapStageMutation = Schema2.Struct({
|
|
98
|
+
op: Schema2.Literal("wrap"),
|
|
99
|
+
id: StageId,
|
|
100
|
+
around: StageWrapperDescriptor,
|
|
101
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
102
|
+
});
|
|
103
|
+
var ReorderStageMutation = Schema2.Struct({
|
|
104
|
+
op: Schema2.Literal("reorder"),
|
|
105
|
+
id: StageId,
|
|
106
|
+
before: Schema2.optional(Schema2.Array(StageId)),
|
|
107
|
+
after: Schema2.optional(Schema2.Array(StageId)),
|
|
108
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
109
|
+
});
|
|
110
|
+
var StageMutation = Schema2.Union([
|
|
111
|
+
InsertStageMutation,
|
|
112
|
+
RemoveStageMutation,
|
|
113
|
+
ReplaceStageMutation,
|
|
114
|
+
WrapStageMutation,
|
|
115
|
+
ReorderStageMutation
|
|
116
|
+
]);
|
|
117
|
+
var ResolutionGrantUse = Schema2.Struct({
|
|
118
|
+
kind: Schema2.Literals(["protected-stage", "kernel-replacement"]),
|
|
119
|
+
target: TrimmedNonEmptyString,
|
|
120
|
+
pluginId: TrimmedNonEmptyString
|
|
121
|
+
});
|
|
122
|
+
var ResolutionRecordEntry = Schema2.Struct({
|
|
123
|
+
stageId: StageId,
|
|
124
|
+
contributedBy: TrimmedNonEmptyString,
|
|
125
|
+
removedBy: Schema2.optional(TrimmedNonEmptyString),
|
|
126
|
+
replacedBy: Schema2.optional(TrimmedNonEmptyString),
|
|
127
|
+
wrappedBy: Schema2.optional(Schema2.Array(TrimmedNonEmptyString)),
|
|
128
|
+
droppedAnchors: Schema2.optional(Schema2.Array(StageId)),
|
|
129
|
+
isProtected: Schema2.Boolean
|
|
130
|
+
});
|
|
131
|
+
var ResolvedPipeline = Schema2.Struct({
|
|
132
|
+
runId: Schema2.optional(RunId),
|
|
133
|
+
order: Schema2.Array(StageId),
|
|
134
|
+
record: Schema2.Array(ResolutionRecordEntry),
|
|
135
|
+
cycles: Schema2.Array(Schema2.Array(StageId)),
|
|
136
|
+
grantUses: Schema2.optional(Schema2.Array(ResolutionGrantUse)),
|
|
137
|
+
resolvedAt: Schema2.optional(IsoDateTime)
|
|
138
|
+
});
|
|
139
|
+
var ResolutionRecord = ResolvedPipeline;
|
|
140
|
+
var StageRunOutcome = Schema2.Struct({
|
|
141
|
+
stageId: StageId,
|
|
142
|
+
result: StageResult,
|
|
143
|
+
startedAt: IsoDateTime,
|
|
144
|
+
finishedAt: IsoDateTime
|
|
145
|
+
});
|
|
146
|
+
export {
|
|
147
|
+
WrapStageMutation,
|
|
148
|
+
StageWrapperDescriptor,
|
|
149
|
+
StageRunOutcome,
|
|
150
|
+
StageResult,
|
|
151
|
+
StageMutationOp,
|
|
152
|
+
StageMutation,
|
|
153
|
+
StageKind,
|
|
154
|
+
StageId,
|
|
155
|
+
StageDescriptor,
|
|
156
|
+
StageContinueResult,
|
|
157
|
+
StageContext,
|
|
158
|
+
StageBlockResult,
|
|
159
|
+
StageAllowResult,
|
|
160
|
+
Stage,
|
|
161
|
+
ResolvedPipeline,
|
|
162
|
+
ResolutionRecordEntry,
|
|
163
|
+
ResolutionRecord,
|
|
164
|
+
ResolutionGrantUse,
|
|
165
|
+
ReplaceStageMutation,
|
|
166
|
+
ReorderStageMutation,
|
|
167
|
+
RemoveStageMutation,
|
|
168
|
+
InsertStageMutation
|
|
169
|
+
};
|