@fungi.computer/braid 0.0.1 → 0.2.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/dist/cloudflare/graph-program.js +29 -7
- package/dist/code-execution.js +2 -0
- package/dist/compile.d.ts +2 -0
- package/dist/compile.js +9 -1
- package/dist/execution.d.ts +81 -0
- package/dist/execution.js +22 -0
- package/dist/git-access.d.ts +15 -15
- package/dist/git-access.js +8 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/review-text.d.ts +15 -0
- package/dist/review-text.js +40 -0
- package/dist/runtime/arming-authority.d.ts +5 -5
- package/dist/runtime/arming-authority.js +5 -5
- package/dist/runtime/git-pass-contract.d.ts +30 -9
- package/dist/runtime/git-pass-contract.js +26 -2
- package/dist/runtime/git-pass-store.d.ts +16 -13
- package/dist/runtime/git-pass-store.js +126 -50
- package/dist/runtime/git-pass.d.ts +3 -4
- package/dist/runtime/git-pass.js +3 -17
- package/dist/runtime/graph-contract.d.ts +5 -1
- package/dist/runtime/graph-run-store.d.ts +6 -0
- package/dist/runtime/ports.d.ts +11 -1
- package/dist/runtime/run-ceiling.d.ts +1 -1
- package/dist/runtime/run-owner.d.ts +89 -4
- package/dist/runtime/run-owner.js +27 -12
- package/dist/runtime/schedules.d.ts +1 -0
- package/dist/runtime/schedules.js +1 -0
- package/dist/runtime/trigger-owner.d.ts +10 -6
- package/dist/runtime/trigger-owner.js +2 -2
- package/dist/runtime/trigger-plans.d.ts +8 -0
- package/dist/runtime/trigger-run-reservations.d.ts +67 -3
- package/dist/runtime/trigger-run-reservations.js +126 -7
- package/dist/schema.d.ts +80 -8
- package/dist/schema.js +14 -2
- package/dist/validate.js +7 -0
- package/dist/workflow-id.d.ts +1 -1
- package/dist/workflow-id.js +1 -1
- package/package.json +8 -7
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as S from "effect/Schema";
|
|
2
2
|
import { type NodeEvent, type NodeAdmissionResult } from "../execution.js";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import type { WatchdogSqliteOwner } from "@fungi.computer/watchdog";
|
|
4
5
|
import { type WorkflowRunAuthority } from "./run-authority.js";
|
|
5
6
|
import type { ArmedWorkflowTrigger } from "./trigger-owner.js";
|
|
6
7
|
import { type WorkflowRunContext, type GraphRun, type WorkflowRunDelivery } from "./graph-contract.js";
|
|
7
8
|
import { type StoredWorkflowNode } from "./graph-dispatch.js";
|
|
8
|
-
import type { WorkflowAppCall, WorkflowAppCallResult, WorkflowCatalogEntry } from "./ports.js";
|
|
9
|
+
import type { WorkflowAppCall, WorkflowAppCallResult, WorkflowCatalogEntry, WorkflowTriggerAdmission } from "./ports.js";
|
|
9
10
|
import { type GraphStartRequest } from "./graph-start.js";
|
|
10
11
|
/** The member can supply a plan, never stored authority or a captured ceiling. */
|
|
11
12
|
export declare const memberCompiledGraphStartSchema: S.Struct<{
|
|
@@ -66,6 +67,7 @@ export declare const memberCompiledGraphStartSchema: S.Struct<{
|
|
|
66
67
|
readonly id: S.String;
|
|
67
68
|
readonly kind: S.Literal<"review">;
|
|
68
69
|
readonly title: S.String;
|
|
70
|
+
readonly detail: S.optionalKey<S.String>;
|
|
69
71
|
readonly show: S.$Array<S.Struct<{
|
|
70
72
|
readonly node: S.Union<readonly [S.String, S.Literals<readonly ["$input", "$item"]>]>;
|
|
71
73
|
readonly port: S.String;
|
|
@@ -75,6 +77,7 @@ export declare const memberCompiledGraphStartSchema: S.Struct<{
|
|
|
75
77
|
readonly choices: S.optionalKey<S.$Array<S.Struct<{
|
|
76
78
|
readonly id: S.String;
|
|
77
79
|
readonly label: S.String;
|
|
80
|
+
readonly description: S.optionalKey<S.String>;
|
|
78
81
|
}>>>;
|
|
79
82
|
}>, S.Struct<{
|
|
80
83
|
readonly id: S.String;
|
|
@@ -185,6 +188,7 @@ export declare const memberCompiledGraphStartSchema: S.Struct<{
|
|
|
185
188
|
readonly id: S.String;
|
|
186
189
|
readonly kind: S.Literal<"review">;
|
|
187
190
|
readonly title: S.String;
|
|
191
|
+
readonly detail: S.optionalKey<S.String>;
|
|
188
192
|
readonly show: S.$Array<S.Struct<{
|
|
189
193
|
readonly node: S.Union<readonly [S.String, S.Literals<readonly ["$input", "$item"]>]>;
|
|
190
194
|
readonly port: S.String;
|
|
@@ -194,6 +198,7 @@ export declare const memberCompiledGraphStartSchema: S.Struct<{
|
|
|
194
198
|
readonly choices: S.optionalKey<S.$Array<S.Struct<{
|
|
195
199
|
readonly id: S.String;
|
|
196
200
|
readonly label: S.String;
|
|
201
|
+
readonly description: S.optionalKey<S.String>;
|
|
197
202
|
}>>>;
|
|
198
203
|
}>, S.Struct<{
|
|
199
204
|
readonly id: S.String;
|
|
@@ -297,6 +302,8 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
297
302
|
sql: WatchdogSqliteOwner["sql"];
|
|
298
303
|
transactionSync: <T>(body: () => T) => T;
|
|
299
304
|
teamId: () => string;
|
|
305
|
+
/** Host-owned wall clock; deterministic native journeys may supply their clock. */
|
|
306
|
+
now?: () => number;
|
|
300
307
|
admission: () => "active" | "suspended";
|
|
301
308
|
errors: Readonly<{
|
|
302
309
|
app(code: "denied" | "invalid" | "unavailable"): Error;
|
|
@@ -336,6 +343,7 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
336
343
|
readonly source: "key" | "manual" | "event" | "schedule" | "agent";
|
|
337
344
|
readonly runId: string;
|
|
338
345
|
readonly computerId: string | null;
|
|
346
|
+
readonly teamId: string;
|
|
339
347
|
readonly plan: {
|
|
340
348
|
readonly planDigest: string;
|
|
341
349
|
readonly definition: {
|
|
@@ -394,9 +402,11 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
394
402
|
readonly timeout: number;
|
|
395
403
|
readonly kind: "review";
|
|
396
404
|
readonly reviewers: "runner" | "owners";
|
|
405
|
+
readonly detail?: string;
|
|
397
406
|
readonly choices?: readonly {
|
|
398
407
|
readonly id: string;
|
|
399
408
|
readonly label: string;
|
|
409
|
+
readonly description?: string;
|
|
400
410
|
}[];
|
|
401
411
|
} | {
|
|
402
412
|
readonly id: string;
|
|
@@ -495,9 +505,11 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
495
505
|
readonly timeout: number;
|
|
496
506
|
readonly kind: "review";
|
|
497
507
|
readonly reviewers: "runner" | "owners";
|
|
508
|
+
readonly detail?: string;
|
|
498
509
|
readonly choices?: readonly {
|
|
499
510
|
readonly id: string;
|
|
500
511
|
readonly label: string;
|
|
512
|
+
readonly description?: string;
|
|
501
513
|
}[];
|
|
502
514
|
} | {
|
|
503
515
|
readonly id: string;
|
|
@@ -636,7 +648,6 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
636
648
|
readonly pending?: true;
|
|
637
649
|
}[];
|
|
638
650
|
};
|
|
639
|
-
readonly teamId: string;
|
|
640
651
|
readonly requestId: string;
|
|
641
652
|
readonly actorId: string;
|
|
642
653
|
readonly ceiling: {
|
|
@@ -647,7 +658,7 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
647
658
|
readonly operations: readonly string[];
|
|
648
659
|
}[];
|
|
649
660
|
readonly nodeId: string;
|
|
650
|
-
readonly capabilities: readonly ("agent.list" | "agent.manage" | "agent.rename" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage")[];
|
|
661
|
+
readonly capabilities: readonly ("approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.toolPolicy" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage")[];
|
|
651
662
|
readonly graphId?: string;
|
|
652
663
|
}[];
|
|
653
664
|
readonly nodeGitAccess: readonly {
|
|
@@ -896,9 +907,11 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
896
907
|
readonly timeout: number;
|
|
897
908
|
readonly kind: "review";
|
|
898
909
|
readonly reviewers: "runner" | "owners";
|
|
910
|
+
readonly detail?: string;
|
|
899
911
|
readonly choices?: readonly {
|
|
900
912
|
readonly id: string;
|
|
901
913
|
readonly label: string;
|
|
914
|
+
readonly description?: string;
|
|
902
915
|
}[];
|
|
903
916
|
} | {
|
|
904
917
|
readonly id: string;
|
|
@@ -997,9 +1010,11 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
997
1010
|
readonly timeout: number;
|
|
998
1011
|
readonly kind: "review";
|
|
999
1012
|
readonly reviewers: "runner" | "owners";
|
|
1013
|
+
readonly detail?: string;
|
|
1000
1014
|
readonly choices?: readonly {
|
|
1001
1015
|
readonly id: string;
|
|
1002
1016
|
readonly label: string;
|
|
1017
|
+
readonly description?: string;
|
|
1003
1018
|
}[];
|
|
1004
1019
|
} | {
|
|
1005
1020
|
readonly id: string;
|
|
@@ -1274,9 +1289,11 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
1274
1289
|
readonly timeout: number;
|
|
1275
1290
|
readonly kind: "review";
|
|
1276
1291
|
readonly reviewers: "runner" | "owners";
|
|
1292
|
+
readonly detail?: string;
|
|
1277
1293
|
readonly choices?: readonly {
|
|
1278
1294
|
readonly id: string;
|
|
1279
1295
|
readonly label: string;
|
|
1296
|
+
readonly description?: string;
|
|
1280
1297
|
}[];
|
|
1281
1298
|
} | {
|
|
1282
1299
|
readonly id: string;
|
|
@@ -1375,9 +1392,11 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
1375
1392
|
readonly timeout: number;
|
|
1376
1393
|
readonly kind: "review";
|
|
1377
1394
|
readonly reviewers: "runner" | "owners";
|
|
1395
|
+
readonly detail?: string;
|
|
1378
1396
|
readonly choices?: readonly {
|
|
1379
1397
|
readonly id: string;
|
|
1380
1398
|
readonly label: string;
|
|
1399
|
+
readonly description?: string;
|
|
1381
1400
|
}[];
|
|
1382
1401
|
} | {
|
|
1383
1402
|
readonly id: string;
|
|
@@ -1539,7 +1558,7 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
1539
1558
|
}>;
|
|
1540
1559
|
startCachedGraph(binding: ArmedWorkflowTrigger, started: Pick<GraphStartRequest, "requestId" | "input"> & {
|
|
1541
1560
|
triggerRepository?: string;
|
|
1542
|
-
}): Promise<{
|
|
1561
|
+
}, admission?: WorkflowTriggerAdmission): Promise<{
|
|
1543
1562
|
kind: "conflict" | "started" | "replay";
|
|
1544
1563
|
runId: string;
|
|
1545
1564
|
planDigest: string;
|
|
@@ -1565,6 +1584,66 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
1565
1584
|
revokeReleaseInMutation(appIds: readonly string[]): void;
|
|
1566
1585
|
/** The kernel's lifecycle caller owns the transaction. Suspension ends every run. */
|
|
1567
1586
|
onLifecycle(status: "active" | "suspended"): void;
|
|
1587
|
+
reserveWebhookDelivery(raw: z.input<z.ZodObject<{
|
|
1588
|
+
scope: z.ZodLazy<z.ZodObject<{
|
|
1589
|
+
installationId: z.ZodString;
|
|
1590
|
+
workflowId: z.ZodString;
|
|
1591
|
+
commit: z.ZodString;
|
|
1592
|
+
triggerId: z.ZodString;
|
|
1593
|
+
}, z.core.$strict>>;
|
|
1594
|
+
delivery: z.ZodObject<{
|
|
1595
|
+
host: z.ZodString;
|
|
1596
|
+
tenant: z.ZodString;
|
|
1597
|
+
bindingId: z.ZodString;
|
|
1598
|
+
eventId: z.ZodString;
|
|
1599
|
+
}, z.core.$strict>;
|
|
1600
|
+
cargo: z.ZodJSONSchema;
|
|
1601
|
+
limits: z.ZodObject<{
|
|
1602
|
+
hostConcurrency: z.ZodNumber;
|
|
1603
|
+
bindingConcurrency: z.ZodNumber;
|
|
1604
|
+
}, z.core.$strict>;
|
|
1605
|
+
}, z.core.$strict>>): {
|
|
1606
|
+
kind: "reserved" | "replay";
|
|
1607
|
+
reservationId: string;
|
|
1608
|
+
runId: string | null;
|
|
1609
|
+
} | {
|
|
1610
|
+
kind: "refused";
|
|
1611
|
+
reason: "limit";
|
|
1612
|
+
};
|
|
1613
|
+
pendingWebhookDeliveries(rawOwner: z.input<z.ZodObject<{
|
|
1614
|
+
host: z.ZodString;
|
|
1615
|
+
tenant: z.ZodString;
|
|
1616
|
+
}, z.core.$strict>>): ({
|
|
1617
|
+
kind: "launch";
|
|
1618
|
+
reservationId: string;
|
|
1619
|
+
runId: string;
|
|
1620
|
+
} | {
|
|
1621
|
+
scope: {
|
|
1622
|
+
installationId: string;
|
|
1623
|
+
workflowId: string;
|
|
1624
|
+
commit: string;
|
|
1625
|
+
triggerId: string;
|
|
1626
|
+
};
|
|
1627
|
+
delivery: {
|
|
1628
|
+
host: string;
|
|
1629
|
+
tenant: string;
|
|
1630
|
+
bindingId: string;
|
|
1631
|
+
eventId: string;
|
|
1632
|
+
};
|
|
1633
|
+
cargo: z.core.util.JSONType;
|
|
1634
|
+
limits: {
|
|
1635
|
+
hostConcurrency: number;
|
|
1636
|
+
bindingConcurrency: number;
|
|
1637
|
+
};
|
|
1638
|
+
kind: "start";
|
|
1639
|
+
reservationId: string;
|
|
1640
|
+
runId?: never;
|
|
1641
|
+
})[];
|
|
1642
|
+
nextWebhookWake(rawOwner: z.input<z.ZodObject<{
|
|
1643
|
+
host: z.ZodString;
|
|
1644
|
+
tenant: z.ZodString;
|
|
1645
|
+
}, z.core.$strict>>): number | null;
|
|
1646
|
+
completeWebhookDelivery(rawReservationId: string): void;
|
|
1568
1647
|
reserveTriggerRun(raw: {
|
|
1569
1648
|
scope: import("./trigger-run-reservations.js").TriggerRunScope;
|
|
1570
1649
|
requestId: string;
|
|
@@ -1606,6 +1685,12 @@ export declare function createTeamWorkflowRuns(options: {
|
|
|
1606
1685
|
readonly iteration: string;
|
|
1607
1686
|
readonly instanceId: string;
|
|
1608
1687
|
readonly eventType: string;
|
|
1688
|
+
readonly position?: readonly {
|
|
1689
|
+
readonly node: string;
|
|
1690
|
+
readonly loop: "repeat" | "map";
|
|
1691
|
+
readonly index: number;
|
|
1692
|
+
readonly count: number;
|
|
1693
|
+
}[];
|
|
1609
1694
|
readonly choices?: readonly string[];
|
|
1610
1695
|
};
|
|
1611
1696
|
status: "closed" | "pending" | "answered" | "delivered" | "timed_out";
|
|
@@ -25,10 +25,10 @@ export const memberCompiledGraphStartSchema = graphRunSchema.mapFields(Struct.om
|
|
|
25
25
|
const publisherGranted = (entries, installationId) => entries.some((entry) => entry.installationId === installationId &&
|
|
26
26
|
entry.workflowPublishGranted === true &&
|
|
27
27
|
entry.capabilities?.includes("workflow.publish") === true);
|
|
28
|
-
const workflowNodeTargetSchema = z.strictObject({
|
|
28
|
+
const workflowNodeTargetSchema = z.lazy(() => z.strictObject({
|
|
29
29
|
installationId: z.string().min(1).max(256),
|
|
30
30
|
method: z.string().min(1).max(256),
|
|
31
|
-
});
|
|
31
|
+
}));
|
|
32
32
|
/**
|
|
33
33
|
* The one Workflow run owner: graph runs, their captured authority, trigger
|
|
34
34
|
* reservations and revocation. Every run, Storyboard included, is a graph run.
|
|
@@ -384,7 +384,7 @@ export function createTeamWorkflowRuns(options) {
|
|
|
384
384
|
throw options.errors.app("denied");
|
|
385
385
|
return startCompiled(preparation, request, identity, ceiling, undefined, publication, libraryInstallationId);
|
|
386
386
|
},
|
|
387
|
-
async startCachedGraph(binding, started) {
|
|
387
|
+
async startCachedGraph(binding, started, admission) {
|
|
388
388
|
const { triggerRepository, ...request } = started;
|
|
389
389
|
await admitGraphMember(binding.armedBy, binding.computerId);
|
|
390
390
|
const stored = triggerPlans.read(binding);
|
|
@@ -467,15 +467,30 @@ export function createTeamWorkflowRuns(options) {
|
|
|
467
467
|
trigger = { ...trigger, nodeGitAccess: binding.nodeGitAccess };
|
|
468
468
|
if (triggerRepository !== undefined)
|
|
469
469
|
trigger = { ...trigger, repository: triggerRepository };
|
|
470
|
-
return
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
470
|
+
return options.transactionSync(() => {
|
|
471
|
+
// Different external bindings may share the compiled publication.
|
|
472
|
+
// Check the binding's owning store after all capture I/O, in the same
|
|
473
|
+
// transaction as the durable start, rather than invalidating its peers.
|
|
474
|
+
if (admission !== undefined && !admission.admitBinding())
|
|
475
|
+
return {
|
|
476
|
+
kind: "refused",
|
|
477
|
+
reason: "Trigger binding is no longer armed",
|
|
478
|
+
};
|
|
479
|
+
const result = startCompiled(preparation, binding.delivery === undefined
|
|
480
|
+
? request
|
|
481
|
+
: { ...request, delivery: binding.delivery }, identity, ceiling, trigger, {
|
|
482
|
+
installationId: binding.installationId,
|
|
483
|
+
workflowId: binding.workflowId,
|
|
484
|
+
commit: binding.commit,
|
|
485
|
+
digest: binding.digest,
|
|
486
|
+
armedBy: { kind: "member", memberId: binding.armedBy },
|
|
487
|
+
}, binding.installationId);
|
|
488
|
+
if (admission?.reservationId !== undefined &&
|
|
489
|
+
(result.kind === "started" || result.kind === "replay") &&
|
|
490
|
+
triggerReservations.bindTriggerRun(admission.reservationId, result.runId) === "conflict")
|
|
491
|
+
throw new Error("Trigger reservation binding conflict");
|
|
492
|
+
return result;
|
|
493
|
+
});
|
|
479
494
|
},
|
|
480
495
|
callWorkflowApp: options.callWorkflowApp,
|
|
481
496
|
admitDelivery: options.admitDelivery,
|
|
@@ -24,6 +24,7 @@ export declare function createWorkflowSchedules(options: {
|
|
|
24
24
|
}>;
|
|
25
25
|
list(principal: WorkflowTriggerPrincipal, installationId: string): Promise<{
|
|
26
26
|
scheduleId: string;
|
|
27
|
+
installationId: string;
|
|
27
28
|
workflowId: string;
|
|
28
29
|
triggerId: string;
|
|
29
30
|
nextDueAt: number;
|
|
@@ -95,6 +95,7 @@ export function createWorkflowSchedules(options) {
|
|
|
95
95
|
.filter((record) => record.installationId === installationId)
|
|
96
96
|
.map((record) => ({
|
|
97
97
|
scheduleId: record.id,
|
|
98
|
+
installationId: record.installationId,
|
|
98
99
|
workflowId: record.workflowId,
|
|
99
100
|
triggerId: record.triggerId,
|
|
100
101
|
nextDueAt: record.nextDueAt,
|
|
@@ -3,7 +3,7 @@ import * as S from "effect/Schema";
|
|
|
3
3
|
import { type GitBinding, type RepositoryRef } from "@fungi.computer/agar/git";
|
|
4
4
|
import { type TriggerEvent } from "../index.js";
|
|
5
5
|
import { type WorkflowArmingAuthorityPorts, type WorkflowArmingReceipt } from "./arming-authority.js";
|
|
6
|
-
import type { PublishedDefinitionPort, WorkflowPublicationContext, WorkflowTriggerRunPorts, WorkflowErrorPort } from "./ports.js";
|
|
6
|
+
import type { PublishedDefinitionPort, WorkflowPublicationContext, WorkflowTriggerRunPorts, WorkflowErrorPort, WorkflowTriggerAdmission } from "./ports.js";
|
|
7
7
|
export declare const workflowTriggerTargetSchema: z.ZodObject<{
|
|
8
8
|
installationId: z.ZodString;
|
|
9
9
|
workflowId: z.ZodString;
|
|
@@ -14,9 +14,9 @@ export declare const workflowTriggerTargetSchema: z.ZodObject<{
|
|
|
14
14
|
readonly appReleaseKind: "Sha256Digest";
|
|
15
15
|
}, string>>;
|
|
16
16
|
triggerId: z.ZodString;
|
|
17
|
-
bindings: z.ZodRecord<z.ZodString
|
|
17
|
+
bindings: z.ZodRecord<z.ZodLazy<z.ZodString>, z.ZodUnion<readonly [z.ZodString, z.ZodLazy<z.ZodObject<{
|
|
18
18
|
kind: z.ZodLiteral<"team-source">;
|
|
19
|
-
}, z.core.$strict
|
|
19
|
+
}, z.core.$strict>>]>>;
|
|
20
20
|
delivery: z.ZodOptional<z.ZodCustom<{
|
|
21
21
|
readonly agentId: string;
|
|
22
22
|
readonly sessionId: string;
|
|
@@ -65,9 +65,9 @@ export declare const armedWorkflowTriggerSchema: z.ZodObject<{
|
|
|
65
65
|
readonly appReleaseKind: "Sha256Digest";
|
|
66
66
|
}, string>>;
|
|
67
67
|
triggerId: z.ZodString;
|
|
68
|
-
bindings: z.ZodRecord<z.ZodString
|
|
68
|
+
bindings: z.ZodRecord<z.ZodLazy<z.ZodString>, z.ZodUnion<readonly [z.ZodString, z.ZodLazy<z.ZodObject<{
|
|
69
69
|
kind: z.ZodLiteral<"team-source">;
|
|
70
|
-
}, z.core.$strict
|
|
70
|
+
}, z.core.$strict>>]>>;
|
|
71
71
|
delivery: z.ZodOptional<z.ZodCustom<{
|
|
72
72
|
readonly agentId: string;
|
|
73
73
|
readonly sessionId: string;
|
|
@@ -382,9 +382,11 @@ export declare function createTeamWorkflowTriggers(options: {
|
|
|
382
382
|
readonly timeout: number;
|
|
383
383
|
readonly kind: "review";
|
|
384
384
|
readonly reviewers: "runner" | "owners";
|
|
385
|
+
readonly detail?: string;
|
|
385
386
|
readonly choices?: readonly {
|
|
386
387
|
readonly id: string;
|
|
387
388
|
readonly label: string;
|
|
389
|
+
readonly description?: string;
|
|
388
390
|
}[];
|
|
389
391
|
} | {
|
|
390
392
|
readonly id: string;
|
|
@@ -483,9 +485,11 @@ export declare function createTeamWorkflowTriggers(options: {
|
|
|
483
485
|
readonly timeout: number;
|
|
484
486
|
readonly kind: "review";
|
|
485
487
|
readonly reviewers: "runner" | "owners";
|
|
488
|
+
readonly detail?: string;
|
|
486
489
|
readonly choices?: readonly {
|
|
487
490
|
readonly id: string;
|
|
488
491
|
readonly label: string;
|
|
492
|
+
readonly description?: string;
|
|
489
493
|
}[];
|
|
490
494
|
} | {
|
|
491
495
|
readonly id: string;
|
|
@@ -577,7 +581,7 @@ export declare function createTeamWorkflowTriggers(options: {
|
|
|
577
581
|
invalidateInstallation: (installationId: string) => void;
|
|
578
582
|
/** The single native push owner supplies host-issued Git, never a fire caller. */
|
|
579
583
|
revalidatePublished(installationId: string, git: GitBinding): Promise<void>;
|
|
580
|
-
fire(raw: ArmedWorkflowTrigger, scope: string, event: TriggerEvent): Promise<Readonly<{
|
|
584
|
+
fire(raw: ArmedWorkflowTrigger, scope: string, event: TriggerEvent, admission?: WorkflowTriggerAdmission): Promise<Readonly<{
|
|
581
585
|
kind: "ignored";
|
|
582
586
|
}> | Readonly<{
|
|
583
587
|
kind: "started" | "replay" | "conflict";
|
|
@@ -213,7 +213,7 @@ export function createTeamWorkflowTriggers(options) {
|
|
|
213
213
|
options.runs.triggerPlans.refuse(binding, "commit no longer published");
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
|
-
async fire(raw, scope, event) {
|
|
216
|
+
async fire(raw, scope, event, admission) {
|
|
217
217
|
const binding = armedWorkflowTriggerSchema.parse(raw);
|
|
218
218
|
try {
|
|
219
219
|
const current = await options.admit(binding.armedBy, binding.installationId, binding.computerId);
|
|
@@ -256,7 +256,7 @@ export function createTeamWorkflowTriggers(options) {
|
|
|
256
256
|
};
|
|
257
257
|
const result = await options.runs.startCachedGraph(binding, mapped.repository === undefined
|
|
258
258
|
? request
|
|
259
|
-
: { ...request, triggerRepository: mapped.repository });
|
|
259
|
+
: { ...request, triggerRepository: mapped.repository }, admission);
|
|
260
260
|
if (result.kind === "refused")
|
|
261
261
|
return result;
|
|
262
262
|
if (result.kind === "conflict")
|
|
@@ -138,9 +138,11 @@ export declare function createTriggerPlans(sql: WatchdogSqliteOwner["sql"]): {
|
|
|
138
138
|
readonly timeout: number;
|
|
139
139
|
readonly kind: "review";
|
|
140
140
|
readonly reviewers: "runner" | "owners";
|
|
141
|
+
readonly detail?: string;
|
|
141
142
|
readonly choices?: readonly {
|
|
142
143
|
readonly id: string;
|
|
143
144
|
readonly label: string;
|
|
145
|
+
readonly description?: string;
|
|
144
146
|
}[];
|
|
145
147
|
} | {
|
|
146
148
|
readonly id: string;
|
|
@@ -239,9 +241,11 @@ export declare function createTriggerPlans(sql: WatchdogSqliteOwner["sql"]): {
|
|
|
239
241
|
readonly timeout: number;
|
|
240
242
|
readonly kind: "review";
|
|
241
243
|
readonly reviewers: "runner" | "owners";
|
|
244
|
+
readonly detail?: string;
|
|
242
245
|
readonly choices?: readonly {
|
|
243
246
|
readonly id: string;
|
|
244
247
|
readonly label: string;
|
|
248
|
+
readonly description?: string;
|
|
245
249
|
}[];
|
|
246
250
|
} | {
|
|
247
251
|
readonly id: string;
|
|
@@ -516,9 +520,11 @@ export declare function createTriggerPlans(sql: WatchdogSqliteOwner["sql"]): {
|
|
|
516
520
|
readonly timeout: number;
|
|
517
521
|
readonly kind: "review";
|
|
518
522
|
readonly reviewers: "runner" | "owners";
|
|
523
|
+
readonly detail?: string;
|
|
519
524
|
readonly choices?: readonly {
|
|
520
525
|
readonly id: string;
|
|
521
526
|
readonly label: string;
|
|
527
|
+
readonly description?: string;
|
|
522
528
|
}[];
|
|
523
529
|
} | {
|
|
524
530
|
readonly id: string;
|
|
@@ -617,9 +623,11 @@ export declare function createTriggerPlans(sql: WatchdogSqliteOwner["sql"]): {
|
|
|
617
623
|
readonly timeout: number;
|
|
618
624
|
readonly kind: "review";
|
|
619
625
|
readonly reviewers: "runner" | "owners";
|
|
626
|
+
readonly detail?: string;
|
|
620
627
|
readonly choices?: readonly {
|
|
621
628
|
readonly id: string;
|
|
622
629
|
readonly label: string;
|
|
630
|
+
readonly description?: string;
|
|
623
631
|
}[];
|
|
624
632
|
} | {
|
|
625
633
|
readonly id: string;
|
|
@@ -1,14 +1,78 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { WatchdogSqliteOwner } from "@fungi.computer/watchdog";
|
|
3
|
-
declare const triggerRunScopeSchema: z.ZodObject<{
|
|
3
|
+
declare const triggerRunScopeSchema: z.ZodLazy<z.ZodObject<{
|
|
4
4
|
installationId: z.ZodString;
|
|
5
5
|
workflowId: z.ZodString;
|
|
6
6
|
commit: z.ZodString;
|
|
7
7
|
triggerId: z.ZodString;
|
|
8
|
-
}, z.core.$strict
|
|
8
|
+
}, z.core.$strict>>;
|
|
9
9
|
export type TriggerRunScope = z.output<typeof triggerRunScopeSchema>;
|
|
10
|
+
declare const deliveryInputSchema: z.ZodObject<{
|
|
11
|
+
scope: z.ZodLazy<z.ZodObject<{
|
|
12
|
+
installationId: z.ZodString;
|
|
13
|
+
workflowId: z.ZodString;
|
|
14
|
+
commit: z.ZodString;
|
|
15
|
+
triggerId: z.ZodString;
|
|
16
|
+
}, z.core.$strict>>;
|
|
17
|
+
delivery: z.ZodObject<{
|
|
18
|
+
host: z.ZodString;
|
|
19
|
+
tenant: z.ZodString;
|
|
20
|
+
bindingId: z.ZodString;
|
|
21
|
+
eventId: z.ZodString;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
cargo: z.ZodJSONSchema;
|
|
24
|
+
limits: z.ZodObject<{
|
|
25
|
+
hostConcurrency: z.ZodNumber;
|
|
26
|
+
bindingConcurrency: z.ZodNumber;
|
|
27
|
+
}, z.core.$strict>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
declare const deliveryOwnerSchema: z.ZodObject<{
|
|
30
|
+
host: z.ZodString;
|
|
31
|
+
tenant: z.ZodString;
|
|
32
|
+
}, z.core.$strict>;
|
|
10
33
|
/** The enclosing Team owner supplies SQLite; callers never select the Team. */
|
|
11
|
-
export declare function createTriggerRunReservations(options: Pick<WatchdogSqliteOwner, "sql" | "transactionSync">
|
|
34
|
+
export declare function createTriggerRunReservations(options: Pick<WatchdogSqliteOwner, "sql" | "transactionSync"> & {
|
|
35
|
+
now?: () => number;
|
|
36
|
+
}): {
|
|
37
|
+
/** Opaque verified cargo and delivery identity live with the run reservation. */
|
|
38
|
+
reserveWebhookDelivery(raw: z.input<typeof deliveryInputSchema>): {
|
|
39
|
+
kind: "reserved" | "replay";
|
|
40
|
+
reservationId: string;
|
|
41
|
+
runId: string | null;
|
|
42
|
+
} | {
|
|
43
|
+
kind: "refused";
|
|
44
|
+
reason: "limit";
|
|
45
|
+
};
|
|
46
|
+
/** Bounded restart/lost-launch-reply recovery over the SAME reservations. */
|
|
47
|
+
pendingWebhookDeliveries(rawOwner: z.input<typeof deliveryOwnerSchema>): ({
|
|
48
|
+
kind: "launch";
|
|
49
|
+
reservationId: string;
|
|
50
|
+
runId: string;
|
|
51
|
+
} | {
|
|
52
|
+
scope: {
|
|
53
|
+
installationId: string;
|
|
54
|
+
workflowId: string;
|
|
55
|
+
commit: string;
|
|
56
|
+
triggerId: string;
|
|
57
|
+
};
|
|
58
|
+
delivery: {
|
|
59
|
+
host: string;
|
|
60
|
+
tenant: string;
|
|
61
|
+
bindingId: string;
|
|
62
|
+
eventId: string;
|
|
63
|
+
};
|
|
64
|
+
cargo: z.core.util.JSONType;
|
|
65
|
+
limits: {
|
|
66
|
+
hostConcurrency: number;
|
|
67
|
+
bindingConcurrency: number;
|
|
68
|
+
};
|
|
69
|
+
kind: "start";
|
|
70
|
+
reservationId: string;
|
|
71
|
+
runId?: never;
|
|
72
|
+
})[];
|
|
73
|
+
/** Native alarms share this deadline with schedules, including idle TTL cleanup. */
|
|
74
|
+
nextWebhookWake(rawOwner: z.input<typeof deliveryOwnerSchema>): number | null;
|
|
75
|
+
completeWebhookDelivery(rawReservationId: string): void;
|
|
12
76
|
reserveTriggerRun(raw: {
|
|
13
77
|
scope: TriggerRunScope;
|
|
14
78
|
requestId: string;
|