@fungi.computer/workflows-wire 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +44 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/library-contracts.d.ts +501 -0
- package/dist/library-contracts.js +211 -0
- package/dist/outcomes.d.ts +292 -0
- package/dist/outcomes.js +183 -0
- package/dist/published-definition.d.ts +22 -0
- package/dist/published-definition.js +20 -0
- package/dist/run-contracts.d.ts +49 -0
- package/dist/run-contracts.js +31 -0
- package/dist/run-ids.d.ts +5 -0
- package/dist/run-ids.js +10 -0
- package/dist/trigger-contracts.d.ts +42 -0
- package/dist/trigger-contracts.js +27 -0
- package/dist/workflow-repository.d.ts +316 -0
- package/dist/workflow-repository.js +209 -0
- package/package.json +29 -3
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { runDeliverySchema } from "./trigger-contracts.js";
|
|
3
|
+
import { defineIdFamily } from "@fungi.computer/cairn/id";
|
|
4
|
+
import * as S from "effect/Schema";
|
|
5
|
+
import { sha256DigestSchema } from "@fungi.computer/puffball/effect";
|
|
6
|
+
import { gitAccessSchema, bindingsSelectionSchema, } from "@fungi.computer/braid/git-access";
|
|
7
|
+
import { gitSha1Schema } from "@fungi.computer/puffball/git-representation";
|
|
8
|
+
import { workflowIdSchema, workflowIssueSchema as issueSchema, } from "./outcomes.js";
|
|
9
|
+
export const provenanceSchema = z.union([
|
|
10
|
+
z.strictObject({
|
|
11
|
+
kind: z.literal("import"),
|
|
12
|
+
workflowId: workflowIdSchema,
|
|
13
|
+
version: z.number().int().positive(),
|
|
14
|
+
commit: gitSha1Schema,
|
|
15
|
+
sha256: z.string().refine(S.is(sha256DigestSchema)),
|
|
16
|
+
origin: z.string().max(256).optional(),
|
|
17
|
+
}),
|
|
18
|
+
z.strictObject({
|
|
19
|
+
kind: z.literal("fork"),
|
|
20
|
+
workflowId: workflowIdSchema,
|
|
21
|
+
commit: gitSha1Schema,
|
|
22
|
+
}),
|
|
23
|
+
]);
|
|
24
|
+
const identity = z.string().min(1).max(256);
|
|
25
|
+
export const runBase = z.strictObject({
|
|
26
|
+
requestId: identity,
|
|
27
|
+
workflowId: workflowIdSchema,
|
|
28
|
+
bindings: bindingsSelectionSchema,
|
|
29
|
+
input: z.record(z.string(), z.json()),
|
|
30
|
+
delivery: runDeliverySchema.optional(),
|
|
31
|
+
});
|
|
32
|
+
export const publishedRun = z.union([
|
|
33
|
+
runBase.extend({ version: z.number().int().positive() }),
|
|
34
|
+
runBase.extend({ commit: gitSha1Schema }),
|
|
35
|
+
]);
|
|
36
|
+
export const document = z.strictObject({
|
|
37
|
+
provenance: provenanceSchema.optional(),
|
|
38
|
+
definition: z.record(z.string(), z.json()),
|
|
39
|
+
layout: z.record(z.string(), z.strictObject({ x: z.number(), y: z.number() })),
|
|
40
|
+
commit: gitSha1Schema,
|
|
41
|
+
});
|
|
42
|
+
const invalid = z.strictObject({
|
|
43
|
+
kind: z.literal("invalid"),
|
|
44
|
+
issues: z.array(issueSchema),
|
|
45
|
+
});
|
|
46
|
+
export const revisionSchema = z.number().int().nonnegative();
|
|
47
|
+
export const draftDocument = document
|
|
48
|
+
.omit({ commit: true })
|
|
49
|
+
.extend({ revision: revisionSchema });
|
|
50
|
+
export const publishedDocument = document.extend({
|
|
51
|
+
workflowId: workflowIdSchema,
|
|
52
|
+
version: z.number().int().positive(),
|
|
53
|
+
digest: z.string().refine(S.is(sha256DigestSchema)),
|
|
54
|
+
});
|
|
55
|
+
export const saveReply = z.union([
|
|
56
|
+
z.strictObject({ kind: z.literal("saved"), revision: revisionSchema }),
|
|
57
|
+
z.strictObject({
|
|
58
|
+
kind: z.literal("conflict"),
|
|
59
|
+
current: draftDocument.nullable(),
|
|
60
|
+
}),
|
|
61
|
+
invalid,
|
|
62
|
+
]);
|
|
63
|
+
const reviewedNode = { graph: z.string(), node: z.string() };
|
|
64
|
+
export const shareReview = z.strictObject({
|
|
65
|
+
gitAccess: z.array(z.union([
|
|
66
|
+
gitAccessSchema.options[0].extend(reviewedNode),
|
|
67
|
+
gitAccessSchema.options[1].extend(reviewedNode),
|
|
68
|
+
])),
|
|
69
|
+
writeNodes: z.array(z.strictObject({
|
|
70
|
+
graph: z.string(),
|
|
71
|
+
node: z.string(),
|
|
72
|
+
appId: z.string(),
|
|
73
|
+
method: z.string(),
|
|
74
|
+
effect: z.enum(["write", "external"]),
|
|
75
|
+
})),
|
|
76
|
+
// Definition decoding owns trigger grammar; this reply transports configuration only.
|
|
77
|
+
triggers: z.array(z.json()),
|
|
78
|
+
});
|
|
79
|
+
export const shareCopyReply = z.union([
|
|
80
|
+
z.strictObject({
|
|
81
|
+
kind: z.literal("saved"),
|
|
82
|
+
revision: revisionSchema,
|
|
83
|
+
title: z.string(),
|
|
84
|
+
review: shareReview,
|
|
85
|
+
}),
|
|
86
|
+
saveReply.options[1],
|
|
87
|
+
invalid,
|
|
88
|
+
z.strictObject({
|
|
89
|
+
kind: z.literal("missing_apps"),
|
|
90
|
+
appIds: z.array(z.string()),
|
|
91
|
+
}),
|
|
92
|
+
z.strictObject({
|
|
93
|
+
kind: z.enum([
|
|
94
|
+
"too_large",
|
|
95
|
+
"digest_mismatch",
|
|
96
|
+
"invalid_bundle",
|
|
97
|
+
"not_found",
|
|
98
|
+
]),
|
|
99
|
+
}),
|
|
100
|
+
]);
|
|
101
|
+
export const shareExportReply = z.union([
|
|
102
|
+
z.strictObject({
|
|
103
|
+
bytes: z.string(),
|
|
104
|
+
sha256: z.string().refine(S.is(sha256DigestSchema)),
|
|
105
|
+
}),
|
|
106
|
+
z.strictObject({ kind: z.enum(["not_found", "too_large"]) }),
|
|
107
|
+
]);
|
|
108
|
+
export const publicationIds = defineIdFamily({
|
|
109
|
+
family: "workflow-publication",
|
|
110
|
+
version: 1,
|
|
111
|
+
kinds: { publication: { prefix: "publication" } },
|
|
112
|
+
});
|
|
113
|
+
export const publicationIdSchema = z
|
|
114
|
+
.string()
|
|
115
|
+
.min(1)
|
|
116
|
+
.max(256)
|
|
117
|
+
.refine((value) => publicationIds.publication.is(value));
|
|
118
|
+
export const publicationFailure = z.enum([
|
|
119
|
+
"git_conflict",
|
|
120
|
+
"publication_failed",
|
|
121
|
+
"too_large",
|
|
122
|
+
"access_changed",
|
|
123
|
+
]);
|
|
124
|
+
export const publicationComplete = z.strictObject({
|
|
125
|
+
kind: z.literal("published"),
|
|
126
|
+
commit: gitSha1Schema,
|
|
127
|
+
version: z.number().int().positive(),
|
|
128
|
+
});
|
|
129
|
+
export const publicationPending = z.strictObject({
|
|
130
|
+
kind: z.literal("publishing"),
|
|
131
|
+
publicationId: publicationIdSchema,
|
|
132
|
+
});
|
|
133
|
+
export const publicationFailed = z.strictObject({
|
|
134
|
+
kind: z.literal("failed"),
|
|
135
|
+
reason: publicationFailure,
|
|
136
|
+
});
|
|
137
|
+
export const publicationStatus = z.union([
|
|
138
|
+
publicationPending,
|
|
139
|
+
publicationComplete,
|
|
140
|
+
publicationFailed,
|
|
141
|
+
z.strictObject({ kind: z.literal("not_found") }),
|
|
142
|
+
]);
|
|
143
|
+
export const publicationElsewhere = z.strictObject({
|
|
144
|
+
kind: z.literal("publishing_elsewhere"),
|
|
145
|
+
});
|
|
146
|
+
export const publishReply = z.union([
|
|
147
|
+
publicationElsewhere,
|
|
148
|
+
publicationComplete,
|
|
149
|
+
publicationPending,
|
|
150
|
+
publicationFailed,
|
|
151
|
+
z.strictObject({
|
|
152
|
+
kind: z.literal("conflict"),
|
|
153
|
+
head: gitSha1Schema.nullable(),
|
|
154
|
+
}),
|
|
155
|
+
invalid,
|
|
156
|
+
]);
|
|
157
|
+
export const version = z.strictObject({
|
|
158
|
+
version: z.number().int().positive(),
|
|
159
|
+
commit: gitSha1Schema,
|
|
160
|
+
committedAt: z.number(),
|
|
161
|
+
message: z.string(),
|
|
162
|
+
});
|
|
163
|
+
export const workflow = z.strictObject({ workflowId: workflowIdSchema });
|
|
164
|
+
export const listings = z
|
|
165
|
+
.array(z.strictObject({
|
|
166
|
+
workflowId: workflowIdSchema,
|
|
167
|
+
title: z.string(),
|
|
168
|
+
draftRevision: revisionSchema.nullable(),
|
|
169
|
+
published: z
|
|
170
|
+
.strictObject({
|
|
171
|
+
commit: gitSha1Schema,
|
|
172
|
+
version: z.number().int().positive().nullable(),
|
|
173
|
+
})
|
|
174
|
+
.nullable(),
|
|
175
|
+
}))
|
|
176
|
+
.max(100);
|
|
177
|
+
export const history = z.array(version.omit({ version: true })).max(50);
|
|
178
|
+
/** A missing index is not an empty Git repository; only write paths reconstruct it. */
|
|
179
|
+
export const libraryPageInput = z.strictObject({
|
|
180
|
+
limit: z.number().int().min(1).max(100).default(100),
|
|
181
|
+
after: workflowIdSchema.optional(),
|
|
182
|
+
});
|
|
183
|
+
export const libraryPage = z.strictObject({
|
|
184
|
+
items: listings,
|
|
185
|
+
next: workflowIdSchema.optional(),
|
|
186
|
+
});
|
|
187
|
+
export const libraryListing = z.union([
|
|
188
|
+
libraryPage,
|
|
189
|
+
z.strictObject({ kind: z.literal("unindexed") }),
|
|
190
|
+
]);
|
|
191
|
+
/** A missing screen copy needs an explicit foreground rebuild, never a hidden Git read. */
|
|
192
|
+
export const rebuilding = z.strictObject({ kind: z.literal("rebuilding") });
|
|
193
|
+
export const documentRead = z.union([
|
|
194
|
+
draftDocument,
|
|
195
|
+
document,
|
|
196
|
+
z.null(),
|
|
197
|
+
rebuilding,
|
|
198
|
+
]);
|
|
199
|
+
export const versionsRead = z.union([z.array(version), rebuilding]);
|
|
200
|
+
export const rebuildCopiesInput = z.strictObject({
|
|
201
|
+
cursor: z.string().max(1024).nullable(),
|
|
202
|
+
target: workflow
|
|
203
|
+
.extend({
|
|
204
|
+
at: z.strictObject({ commit: gitSha1Schema }),
|
|
205
|
+
})
|
|
206
|
+
.optional(),
|
|
207
|
+
});
|
|
208
|
+
export const rebuildCopiesReply = z.strictObject({
|
|
209
|
+
done: z.boolean(),
|
|
210
|
+
cursor: z.string().max(1024).nullable(),
|
|
211
|
+
});
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const workflowIdSchema: z.ZodString;
|
|
3
|
+
export declare const catalogInputSchema: z.ZodObject<{
|
|
4
|
+
installationId: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, z.core.$strict>;
|
|
6
|
+
/** App method declarations admitted by the host for the current invocation. */
|
|
7
|
+
export declare const catalogReplySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
8
|
+
apps: z.ZodArray<z.ZodObject<{
|
|
9
|
+
methods: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
10
|
+
pending: z.ZodOptional<z.ZodLiteral<true>>;
|
|
11
|
+
description: z.ZodString;
|
|
12
|
+
effect: z.ZodEnum<{
|
|
13
|
+
read: "read";
|
|
14
|
+
write: "write";
|
|
15
|
+
external: "external";
|
|
16
|
+
}>;
|
|
17
|
+
approval: z.ZodEnum<{
|
|
18
|
+
none: "none";
|
|
19
|
+
queue: "queue";
|
|
20
|
+
simulate: "simulate";
|
|
21
|
+
}>;
|
|
22
|
+
requires: z.ZodArray<z.ZodString>;
|
|
23
|
+
digest: z.ZodString;
|
|
24
|
+
}, z.core.$strict>>;
|
|
25
|
+
events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
26
|
+
description: z.ZodString;
|
|
27
|
+
digest: z.ZodString;
|
|
28
|
+
}, z.core.$strict>>>;
|
|
29
|
+
installationId: z.ZodString;
|
|
30
|
+
appId: z.ZodString;
|
|
31
|
+
displayName: z.ZodString;
|
|
32
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
33
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
34
|
+
"agent.list": "agent.list";
|
|
35
|
+
"agent.manage": "agent.manage";
|
|
36
|
+
"agent.rename": "agent.rename";
|
|
37
|
+
"agent.toolPolicy": "agent.toolPolicy";
|
|
38
|
+
"agent.read": "agent.read";
|
|
39
|
+
"agent.send": "agent.send";
|
|
40
|
+
"computer.list": "computer.list";
|
|
41
|
+
"computer.readFile": "computer.readFile";
|
|
42
|
+
"computer.writeFile": "computer.writeFile";
|
|
43
|
+
"computer.execute": "computer.execute";
|
|
44
|
+
"llm.generation": "llm.generation";
|
|
45
|
+
"media.generation": "media.generation";
|
|
46
|
+
"games:servers": "games:servers";
|
|
47
|
+
"git.repository": "git.repository";
|
|
48
|
+
"apps.open": "apps.open";
|
|
49
|
+
"apps.call": "apps.call";
|
|
50
|
+
"app.storage": "app.storage";
|
|
51
|
+
"app.events.emit": "app.events.emit";
|
|
52
|
+
"team.workbenchHost": "team.workbenchHost";
|
|
53
|
+
"marketplace.browse": "marketplace.browse";
|
|
54
|
+
"marketplace.purchase": "marketplace.purchase";
|
|
55
|
+
"workflow.run": "workflow.run";
|
|
56
|
+
"workflow.publish": "workflow.publish";
|
|
57
|
+
"workflow.arm": "workflow.arm";
|
|
58
|
+
world: "world";
|
|
59
|
+
"channels.read": "channels.read";
|
|
60
|
+
"channels.personal.manage": "channels.personal.manage";
|
|
61
|
+
}>>>;
|
|
62
|
+
workflowPublishGranted: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
workflowRunGranted: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
66
|
+
app: z.ZodObject<{
|
|
67
|
+
methods: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
68
|
+
events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
69
|
+
installationId: z.ZodString;
|
|
70
|
+
appId: z.ZodString;
|
|
71
|
+
displayName: z.ZodString;
|
|
72
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
73
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
74
|
+
"agent.list": "agent.list";
|
|
75
|
+
"agent.manage": "agent.manage";
|
|
76
|
+
"agent.rename": "agent.rename";
|
|
77
|
+
"agent.toolPolicy": "agent.toolPolicy";
|
|
78
|
+
"agent.read": "agent.read";
|
|
79
|
+
"agent.send": "agent.send";
|
|
80
|
+
"computer.list": "computer.list";
|
|
81
|
+
"computer.readFile": "computer.readFile";
|
|
82
|
+
"computer.writeFile": "computer.writeFile";
|
|
83
|
+
"computer.execute": "computer.execute";
|
|
84
|
+
"llm.generation": "llm.generation";
|
|
85
|
+
"media.generation": "media.generation";
|
|
86
|
+
"games:servers": "games:servers";
|
|
87
|
+
"git.repository": "git.repository";
|
|
88
|
+
"apps.open": "apps.open";
|
|
89
|
+
"apps.call": "apps.call";
|
|
90
|
+
"app.storage": "app.storage";
|
|
91
|
+
"app.events.emit": "app.events.emit";
|
|
92
|
+
"team.workbenchHost": "team.workbenchHost";
|
|
93
|
+
"marketplace.browse": "marketplace.browse";
|
|
94
|
+
"marketplace.purchase": "marketplace.purchase";
|
|
95
|
+
"workflow.run": "workflow.run";
|
|
96
|
+
"workflow.publish": "workflow.publish";
|
|
97
|
+
"workflow.arm": "workflow.arm";
|
|
98
|
+
world: "world";
|
|
99
|
+
"channels.read": "channels.read";
|
|
100
|
+
"channels.personal.manage": "channels.personal.manage";
|
|
101
|
+
}>>>;
|
|
102
|
+
workflowPublishGranted: z.ZodOptional<z.ZodBoolean>;
|
|
103
|
+
workflowRunGranted: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
106
|
+
error: z.ZodString;
|
|
107
|
+
}, z.core.$strict>]>;
|
|
108
|
+
export declare const workflowIssueSchema: z.ZodObject<{
|
|
109
|
+
code: z.ZodString;
|
|
110
|
+
message: z.ZodString;
|
|
111
|
+
graph: z.ZodOptional<z.ZodString>;
|
|
112
|
+
node: z.ZodOptional<z.ZodString>;
|
|
113
|
+
trigger: z.ZodOptional<z.ZodString>;
|
|
114
|
+
port: z.ZodOptional<z.ZodString>;
|
|
115
|
+
edge: z.ZodOptional<z.ZodNumber>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export declare const runReply: z.ZodUnion<readonly [z.ZodObject<{
|
|
118
|
+
kind: z.ZodEnum<{
|
|
119
|
+
started: "started";
|
|
120
|
+
replay: "replay";
|
|
121
|
+
conflict: "conflict";
|
|
122
|
+
}>;
|
|
123
|
+
runId: z.ZodString;
|
|
124
|
+
planDigest: z.ZodString;
|
|
125
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
126
|
+
kind: z.ZodLiteral<"invalid">;
|
|
127
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
128
|
+
code: z.ZodString;
|
|
129
|
+
message: z.ZodString;
|
|
130
|
+
graph: z.ZodOptional<z.ZodString>;
|
|
131
|
+
node: z.ZodOptional<z.ZodString>;
|
|
132
|
+
trigger: z.ZodOptional<z.ZodString>;
|
|
133
|
+
port: z.ZodOptional<z.ZodString>;
|
|
134
|
+
edge: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
}, z.core.$strip>>;
|
|
136
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
137
|
+
error: z.ZodString;
|
|
138
|
+
}, z.core.$strict>]>;
|
|
139
|
+
export declare const cancelReplySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
140
|
+
kind: z.ZodEnum<{
|
|
141
|
+
cancelled: "cancelled";
|
|
142
|
+
terminal: "terminal";
|
|
143
|
+
}>;
|
|
144
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
145
|
+
kind: z.ZodLiteral<"refused">;
|
|
146
|
+
reason: z.ZodLiteral<"denied">;
|
|
147
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
148
|
+
error: z.ZodString;
|
|
149
|
+
}, z.core.$strict>]>;
|
|
150
|
+
export declare const runOutcomeSchema: z.ZodEnum<{
|
|
151
|
+
cancelled: "cancelled";
|
|
152
|
+
terminal: "terminal";
|
|
153
|
+
active: "active";
|
|
154
|
+
}>;
|
|
155
|
+
export declare const statusReply: z.ZodUnion<readonly [z.ZodObject<{
|
|
156
|
+
runId: z.ZodString;
|
|
157
|
+
planDigest: z.ZodString;
|
|
158
|
+
outcome: z.ZodEnum<{
|
|
159
|
+
cancelled: "cancelled";
|
|
160
|
+
terminal: "terminal";
|
|
161
|
+
active: "active";
|
|
162
|
+
}>;
|
|
163
|
+
title: z.ZodString;
|
|
164
|
+
events: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
165
|
+
reviews: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
166
|
+
status: z.ZodString;
|
|
167
|
+
output: z.ZodJSONSchema;
|
|
168
|
+
error: z.ZodJSONSchema;
|
|
169
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
170
|
+
error: z.ZodString;
|
|
171
|
+
}, z.core.$strict>]>;
|
|
172
|
+
export declare const answerReviewReply: z.ZodUnion<readonly [z.ZodObject<{
|
|
173
|
+
result: z.ZodEnum<{
|
|
174
|
+
invalid: "invalid";
|
|
175
|
+
denied: "denied";
|
|
176
|
+
accepted: "accepted";
|
|
177
|
+
not_waiting: "not_waiting";
|
|
178
|
+
}>;
|
|
179
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
180
|
+
error: z.ZodString;
|
|
181
|
+
}, z.core.$strict>]>;
|
|
182
|
+
export declare const scheduleArmReplySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
183
|
+
kind: z.ZodLiteral<"armed">;
|
|
184
|
+
scheduleId: z.ZodString;
|
|
185
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
186
|
+
kind: z.ZodLiteral<"refused">;
|
|
187
|
+
reason: z.ZodString;
|
|
188
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodJSONSchema>>;
|
|
189
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
190
|
+
error: z.ZodString;
|
|
191
|
+
}, z.core.$strict>]>;
|
|
192
|
+
export declare const triggerDisarmReplySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
193
|
+
kind: z.ZodEnum<{
|
|
194
|
+
disarmed: "disarmed";
|
|
195
|
+
not_found: "not_found";
|
|
196
|
+
}>;
|
|
197
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
198
|
+
error: z.ZodString;
|
|
199
|
+
}, z.core.$strict>]>;
|
|
200
|
+
export declare const schedulesReplySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
201
|
+
schedules: z.ZodArray<z.ZodObject<{
|
|
202
|
+
scheduleId: z.ZodString;
|
|
203
|
+
workflowId: z.ZodString;
|
|
204
|
+
triggerId: z.ZodString;
|
|
205
|
+
nextDueAt: z.ZodNumber;
|
|
206
|
+
state: z.ZodEnum<{
|
|
207
|
+
cancelled: "cancelled";
|
|
208
|
+
active: "active";
|
|
209
|
+
paused: "paused";
|
|
210
|
+
finished: "finished";
|
|
211
|
+
}>;
|
|
212
|
+
lastError: z.ZodNullable<z.ZodString>;
|
|
213
|
+
}, z.core.$strict>>;
|
|
214
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
215
|
+
error: z.ZodString;
|
|
216
|
+
}, z.core.$strict>]>;
|
|
217
|
+
export declare const workflowRunSourceSchema: z.ZodEnum<{
|
|
218
|
+
manual: "manual";
|
|
219
|
+
schedule: "schedule";
|
|
220
|
+
event: "event";
|
|
221
|
+
agent: "agent";
|
|
222
|
+
key: "key";
|
|
223
|
+
}>;
|
|
224
|
+
/** The Agent Session (`sessionId`) stays host-side; the wire names only the Agent/key and its grantor. */
|
|
225
|
+
export declare const workflowRunInitiatedBySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
226
|
+
kind: z.ZodLiteral<"member">;
|
|
227
|
+
memberId: z.ZodString;
|
|
228
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
229
|
+
kind: z.ZodLiteral<"agent">;
|
|
230
|
+
agentId: z.ZodString;
|
|
231
|
+
grantorMemberId: z.ZodString;
|
|
232
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
233
|
+
kind: z.ZodLiteral<"key">;
|
|
234
|
+
keyId: z.ZodString;
|
|
235
|
+
grantorMemberId: z.ZodString;
|
|
236
|
+
}, z.core.$strict>]>;
|
|
237
|
+
export declare const runsReplySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
238
|
+
runs: z.ZodArray<z.ZodObject<{
|
|
239
|
+
runId: z.ZodString;
|
|
240
|
+
workflowId: z.ZodString;
|
|
241
|
+
commit: z.ZodString;
|
|
242
|
+
source: z.ZodEnum<{
|
|
243
|
+
manual: "manual";
|
|
244
|
+
schedule: "schedule";
|
|
245
|
+
event: "event";
|
|
246
|
+
agent: "agent";
|
|
247
|
+
key: "key";
|
|
248
|
+
}>;
|
|
249
|
+
triggerId: z.ZodOptional<z.ZodString>;
|
|
250
|
+
initiatedBy: z.ZodUnion<readonly [z.ZodObject<{
|
|
251
|
+
kind: z.ZodLiteral<"member">;
|
|
252
|
+
memberId: z.ZodString;
|
|
253
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
254
|
+
kind: z.ZodLiteral<"agent">;
|
|
255
|
+
agentId: z.ZodString;
|
|
256
|
+
grantorMemberId: z.ZodString;
|
|
257
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
258
|
+
kind: z.ZodLiteral<"key">;
|
|
259
|
+
keyId: z.ZodString;
|
|
260
|
+
grantorMemberId: z.ZodString;
|
|
261
|
+
}, z.core.$strict>]>;
|
|
262
|
+
startedAt: z.ZodNumber;
|
|
263
|
+
}, z.core.$strict>>;
|
|
264
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
265
|
+
error: z.ZodString;
|
|
266
|
+
}, z.core.$strict>]>;
|
|
267
|
+
export declare const eventArmReplySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
268
|
+
kind: z.ZodLiteral<"armed">;
|
|
269
|
+
eventTriggerId: z.ZodString;
|
|
270
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
271
|
+
kind: z.ZodLiteral<"refused">;
|
|
272
|
+
reason: z.ZodString;
|
|
273
|
+
issues: z.ZodOptional<z.ZodArray<z.ZodJSONSchema>>;
|
|
274
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
275
|
+
error: z.ZodString;
|
|
276
|
+
}, z.core.$strict>]>;
|
|
277
|
+
export declare const eventTriggersReplySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
278
|
+
eventTriggers: z.ZodArray<z.ZodObject<{
|
|
279
|
+
eventTriggerId: z.ZodString;
|
|
280
|
+
workflowId: z.ZodString;
|
|
281
|
+
triggerId: z.ZodString;
|
|
282
|
+
emitterInstallationId: z.ZodString;
|
|
283
|
+
event: z.ZodString;
|
|
284
|
+
state: z.ZodEnum<{
|
|
285
|
+
active: "active";
|
|
286
|
+
paused: "paused";
|
|
287
|
+
}>;
|
|
288
|
+
lastError: z.ZodNullable<z.ZodString>;
|
|
289
|
+
}, z.core.$strict>>;
|
|
290
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
291
|
+
error: z.ZodString;
|
|
292
|
+
}, z.core.$strict>]>;
|
package/dist/outcomes.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { appCapabilityIds } from "@fungi.computer/puffball";
|
|
3
|
+
export const workflowIdSchema = z.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/);
|
|
4
|
+
const identity = z.string().min(1).max(256);
|
|
5
|
+
const refusal = z.strictObject({ error: identity });
|
|
6
|
+
/** What the palette shows before a method's ports are ever fetched. */
|
|
7
|
+
const methodSummarySchema = z.strictObject({
|
|
8
|
+
pending: z.literal(true).optional(),
|
|
9
|
+
description: z.string().max(1000),
|
|
10
|
+
effect: z.enum(["read", "write", "external"]),
|
|
11
|
+
approval: z.enum(["none", "queue", "simulate"]),
|
|
12
|
+
requires: z.array(z.string().max(80)).max(64),
|
|
13
|
+
digest: z.string().max(128),
|
|
14
|
+
});
|
|
15
|
+
const eventSummarySchema = z.strictObject({
|
|
16
|
+
description: z.string().max(1000),
|
|
17
|
+
digest: z.string().max(128),
|
|
18
|
+
});
|
|
19
|
+
const entryIdentity = {
|
|
20
|
+
installationId: identity,
|
|
21
|
+
appId: identity,
|
|
22
|
+
displayName: z.string().max(256),
|
|
23
|
+
icon: z.string().min(1).max(80).optional(),
|
|
24
|
+
capabilities: z.array(z.enum(appCapabilityIds)).optional(),
|
|
25
|
+
workflowPublishGranted: z.boolean().optional(),
|
|
26
|
+
workflowRunGranted: z.boolean().optional(),
|
|
27
|
+
};
|
|
28
|
+
/** `catalog({})`: a palette index over every installation, with no port schemas. */
|
|
29
|
+
const catalogIndexEntrySchema = z.strictObject({
|
|
30
|
+
...entryIdentity,
|
|
31
|
+
methods: z.record(z.string(), methodSummarySchema),
|
|
32
|
+
events: z.record(z.string(), eventSummarySchema).optional(),
|
|
33
|
+
});
|
|
34
|
+
/** `catalog({installationId})`: that one installation's full declared ports. */
|
|
35
|
+
const catalogFullEntrySchema = z.strictObject({
|
|
36
|
+
...entryIdentity,
|
|
37
|
+
methods: z.record(z.string(), z.json()),
|
|
38
|
+
events: z.record(z.string(), z.json()).optional(),
|
|
39
|
+
});
|
|
40
|
+
export const catalogInputSchema = z.strictObject({
|
|
41
|
+
installationId: identity.optional(),
|
|
42
|
+
});
|
|
43
|
+
/** App method declarations admitted by the host for the current invocation. */
|
|
44
|
+
export const catalogReplySchema = z.union([
|
|
45
|
+
z.strictObject({ apps: z.array(catalogIndexEntrySchema).max(200) }),
|
|
46
|
+
z.strictObject({ app: catalogFullEntrySchema }),
|
|
47
|
+
refusal,
|
|
48
|
+
]);
|
|
49
|
+
export const workflowIssueSchema = z.object({
|
|
50
|
+
code: z.string(),
|
|
51
|
+
message: z.string(),
|
|
52
|
+
graph: z.string().optional(),
|
|
53
|
+
node: z.string().optional(),
|
|
54
|
+
trigger: z.string().optional(),
|
|
55
|
+
port: z.string().optional(),
|
|
56
|
+
edge: z.number().optional(),
|
|
57
|
+
});
|
|
58
|
+
export const runReply = z.union([
|
|
59
|
+
z.strictObject({
|
|
60
|
+
kind: z.enum(["started", "replay", "conflict"]),
|
|
61
|
+
runId: identity,
|
|
62
|
+
planDigest: identity,
|
|
63
|
+
}),
|
|
64
|
+
z.strictObject({
|
|
65
|
+
kind: z.literal("invalid"),
|
|
66
|
+
issues: z.array(workflowIssueSchema),
|
|
67
|
+
}),
|
|
68
|
+
z.strictObject({ error: identity }),
|
|
69
|
+
]);
|
|
70
|
+
export const cancelReplySchema = z.union([
|
|
71
|
+
z.strictObject({ kind: z.enum(["cancelled", "terminal"]) }),
|
|
72
|
+
z.strictObject({ kind: z.literal("refused"), reason: z.literal("denied") }),
|
|
73
|
+
z.strictObject({ error: z.string() }),
|
|
74
|
+
]);
|
|
75
|
+
export const runOutcomeSchema = z.enum(["active", "terminal", "cancelled"]);
|
|
76
|
+
export const statusReply = z.union([
|
|
77
|
+
z.strictObject({
|
|
78
|
+
runId: identity,
|
|
79
|
+
planDigest: identity,
|
|
80
|
+
outcome: runOutcomeSchema,
|
|
81
|
+
title: z.string().max(120),
|
|
82
|
+
events: z.array(z.record(z.string(), z.json())).max(4096),
|
|
83
|
+
reviews: z.array(z.record(z.string(), z.json())).max(256),
|
|
84
|
+
status: identity,
|
|
85
|
+
output: z.json(),
|
|
86
|
+
error: z.json(),
|
|
87
|
+
}),
|
|
88
|
+
refusal,
|
|
89
|
+
]);
|
|
90
|
+
export const answerReviewReply = z.union([
|
|
91
|
+
z.strictObject({
|
|
92
|
+
result: z.enum(["accepted", "denied", "not_waiting", "invalid"]),
|
|
93
|
+
}),
|
|
94
|
+
refusal,
|
|
95
|
+
]);
|
|
96
|
+
const id = z.string().min(1).max(256);
|
|
97
|
+
const denied = z.strictObject({ error: id });
|
|
98
|
+
export const scheduleArmReplySchema = z.union([
|
|
99
|
+
z.strictObject({ kind: z.literal("armed"), scheduleId: id }),
|
|
100
|
+
z.strictObject({
|
|
101
|
+
kind: z.literal("refused"),
|
|
102
|
+
reason: z.string(),
|
|
103
|
+
issues: z.array(z.json()).optional(),
|
|
104
|
+
}),
|
|
105
|
+
denied,
|
|
106
|
+
]);
|
|
107
|
+
export const triggerDisarmReplySchema = z.union([
|
|
108
|
+
z.strictObject({ kind: z.enum(["disarmed", "not_found"]) }),
|
|
109
|
+
denied,
|
|
110
|
+
]);
|
|
111
|
+
export const schedulesReplySchema = z.union([
|
|
112
|
+
z.strictObject({
|
|
113
|
+
schedules: z.array(z.strictObject({
|
|
114
|
+
scheduleId: id,
|
|
115
|
+
workflowId: workflowIdSchema,
|
|
116
|
+
triggerId: id,
|
|
117
|
+
nextDueAt: z.number().int(),
|
|
118
|
+
state: z.enum(["active", "paused", "cancelled", "finished"]),
|
|
119
|
+
lastError: z.string().nullable(),
|
|
120
|
+
})),
|
|
121
|
+
}),
|
|
122
|
+
denied,
|
|
123
|
+
]);
|
|
124
|
+
export const workflowRunSourceSchema = z.enum([
|
|
125
|
+
"manual",
|
|
126
|
+
"schedule",
|
|
127
|
+
"event",
|
|
128
|
+
"agent",
|
|
129
|
+
"key",
|
|
130
|
+
]);
|
|
131
|
+
/** The Agent Session (`sessionId`) stays host-side; the wire names only the Agent/key and its grantor. */
|
|
132
|
+
export const workflowRunInitiatedBySchema = z.union([
|
|
133
|
+
z.strictObject({ kind: z.literal("member"), memberId: id }),
|
|
134
|
+
z.strictObject({
|
|
135
|
+
kind: z.literal("agent"),
|
|
136
|
+
agentId: id,
|
|
137
|
+
grantorMemberId: id,
|
|
138
|
+
}),
|
|
139
|
+
z.strictObject({
|
|
140
|
+
kind: z.literal("key"),
|
|
141
|
+
keyId: id,
|
|
142
|
+
grantorMemberId: id,
|
|
143
|
+
}),
|
|
144
|
+
]);
|
|
145
|
+
export const runsReplySchema = z.union([
|
|
146
|
+
z.strictObject({
|
|
147
|
+
runs: z
|
|
148
|
+
.array(z.strictObject({
|
|
149
|
+
runId: id,
|
|
150
|
+
workflowId: workflowIdSchema,
|
|
151
|
+
commit: z.string(),
|
|
152
|
+
source: workflowRunSourceSchema,
|
|
153
|
+
triggerId: id.optional(),
|
|
154
|
+
initiatedBy: workflowRunInitiatedBySchema,
|
|
155
|
+
startedAt: z.number(),
|
|
156
|
+
}))
|
|
157
|
+
.max(50),
|
|
158
|
+
}),
|
|
159
|
+
denied,
|
|
160
|
+
]);
|
|
161
|
+
export const eventArmReplySchema = z.union([
|
|
162
|
+
z.strictObject({ kind: z.literal("armed"), eventTriggerId: id }),
|
|
163
|
+
z.strictObject({
|
|
164
|
+
kind: z.literal("refused"),
|
|
165
|
+
reason: z.string(),
|
|
166
|
+
issues: z.array(z.json()).optional(),
|
|
167
|
+
}),
|
|
168
|
+
denied,
|
|
169
|
+
]);
|
|
170
|
+
export const eventTriggersReplySchema = z.union([
|
|
171
|
+
z.strictObject({
|
|
172
|
+
eventTriggers: z.array(z.strictObject({
|
|
173
|
+
eventTriggerId: id,
|
|
174
|
+
workflowId: workflowIdSchema,
|
|
175
|
+
triggerId: id,
|
|
176
|
+
emitterInstallationId: id,
|
|
177
|
+
event: id,
|
|
178
|
+
state: z.enum(["active", "paused"]),
|
|
179
|
+
lastError: z.string().nullable(),
|
|
180
|
+
})),
|
|
181
|
+
}),
|
|
182
|
+
denied,
|
|
183
|
+
]);
|