@reasonlayer/sdk 0.0.1-rc.3
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 +201 -0
- package/README.md +35 -0
- package/bin/rl.mjs +75 -0
- package/dist/builder.d.ts +38 -0
- package/dist/builder.js +41 -0
- package/dist/bundler/index.d.ts +32 -0
- package/dist/bundler/index.js +143 -0
- package/dist/bundler/node.d.ts +10 -0
- package/dist/bundler/node.js +55 -0
- package/dist/cli/args.d.ts +9 -0
- package/dist/cli/args.js +71 -0
- package/dist/cli/config.d.ts +38 -0
- package/dist/cli/config.js +94 -0
- package/dist/cli/convex.d.ts +9 -0
- package/dist/cli/convex.js +25 -0
- package/dist/cli/format.d.ts +11 -0
- package/dist/cli/format.js +140 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +721 -0
- package/dist/cli/keychain.d.ts +21 -0
- package/dist/cli/keychain.js +100 -0
- package/dist/cli/operations.d.ts +106 -0
- package/dist/cli/operations.js +623 -0
- package/dist/cli/sdk-package.d.ts +18 -0
- package/dist/cli/sdk-package.js +45 -0
- package/dist/cli/storage-upload.d.ts +9 -0
- package/dist/cli/storage-upload.js +21 -0
- package/dist/cli/watcher-compile.d.ts +1 -0
- package/dist/cli/watcher-compile.js +20 -0
- package/dist/cli/watcher-process.d.ts +1 -0
- package/dist/cli/watcher-process.js +312 -0
- package/dist/cli/workspace-files.d.ts +12 -0
- package/dist/cli/workspace-files.js +91 -0
- package/dist/cli/workspace-local.d.ts +27 -0
- package/dist/cli/workspace-local.js +310 -0
- package/dist/cli/workspace-session.d.ts +13 -0
- package/dist/cli/workspace-session.js +12 -0
- package/dist/compile.d.ts +27 -0
- package/dist/compile.js +834 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/schedule-validation.d.ts +1 -0
- package/dist/schedule-validation.js +16 -0
- package/dist/selector-schema.d.ts +26 -0
- package/dist/selector-schema.js +780 -0
- package/dist/selectors.d.ts +25 -0
- package/dist/selectors.js +99 -0
- package/dist/testkit.d.ts +32 -0
- package/dist/testkit.js +161 -0
- package/dist/types.d.ts +184 -0
- package/dist/types.js +110 -0
- package/node_modules/@reasonlayer/integrations/dist/catalog.d.ts +4937 -0
- package/node_modules/@reasonlayer/integrations/dist/catalog.js +20 -0
- package/node_modules/@reasonlayer/integrations/dist/generated/slack.d.ts +3014 -0
- package/node_modules/@reasonlayer/integrations/dist/generated/slack.js +3101 -0
- package/node_modules/@reasonlayer/integrations/dist/index.d.ts +2 -0
- package/node_modules/@reasonlayer/integrations/dist/index.js +1 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/definitions.d.ts +44 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/definitions.js +52 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/transport.d.ts +7 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/transport.js +48 -0
- package/node_modules/@reasonlayer/integrations/dist/testkit.d.ts +1 -0
- package/node_modules/@reasonlayer/integrations/dist/testkit.js +1 -0
- package/node_modules/@reasonlayer/integrations/package.json +26 -0
- package/node_modules/@reasonlayer/protocol/dist/environments.d.ts +7 -0
- package/node_modules/@reasonlayer/protocol/dist/environments.js +7 -0
- package/node_modules/@reasonlayer/protocol/dist/events.d.ts +313 -0
- package/node_modules/@reasonlayer/protocol/dist/events.js +20 -0
- package/node_modules/@reasonlayer/protocol/dist/index.d.ts +18 -0
- package/node_modules/@reasonlayer/protocol/dist/index.js +9 -0
- package/node_modules/@reasonlayer/protocol/dist/ir.d.ts +252 -0
- package/node_modules/@reasonlayer/protocol/dist/ir.js +116 -0
- package/node_modules/@reasonlayer/protocol/dist/permissions.d.ts +5 -0
- package/node_modules/@reasonlayer/protocol/dist/permissions.js +30 -0
- package/node_modules/@reasonlayer/protocol/dist/readmodels.d.ts +617 -0
- package/node_modules/@reasonlayer/protocol/dist/readmodels.js +36 -0
- package/node_modules/@reasonlayer/protocol/dist/runtime.d.ts +67 -0
- package/node_modules/@reasonlayer/protocol/dist/runtime.js +66 -0
- package/node_modules/@reasonlayer/protocol/dist/scheduling.d.ts +69 -0
- package/node_modules/@reasonlayer/protocol/dist/scheduling.js +126 -0
- package/node_modules/@reasonlayer/protocol/dist/selector.d.ts +23 -0
- package/node_modules/@reasonlayer/protocol/dist/selector.js +77 -0
- package/node_modules/@reasonlayer/protocol/dist/tasks.d.ts +69 -0
- package/node_modules/@reasonlayer/protocol/dist/tasks.js +6 -0
- package/node_modules/@reasonlayer/protocol/dist/validate.d.ts +6 -0
- package/node_modules/@reasonlayer/protocol/dist/validate.js +18 -0
- package/node_modules/@reasonlayer/protocol/package.json +21 -0
- package/node_modules/@reasonlayer/runner/dist/environment-materializer.d.ts +13 -0
- package/node_modules/@reasonlayer/runner/dist/environment-materializer.js +92 -0
- package/node_modules/@reasonlayer/runner/dist/flue-transcript.d.ts +17 -0
- package/node_modules/@reasonlayer/runner/dist/flue-transcript.js +182 -0
- package/node_modules/@reasonlayer/runner/dist/index.d.ts +184 -0
- package/node_modules/@reasonlayer/runner/dist/index.js +884 -0
- package/node_modules/@reasonlayer/runner/dist/mcp-supervisor.d.ts +15 -0
- package/node_modules/@reasonlayer/runner/dist/mcp-supervisor.js +142 -0
- package/node_modules/@reasonlayer/runner/dist/sandbox-env.d.ts +36 -0
- package/node_modules/@reasonlayer/runner/dist/sandbox-env.js +171 -0
- package/node_modules/@reasonlayer/runner/dist/task-child.d.ts +1 -0
- package/node_modules/@reasonlayer/runner/dist/task-child.js +72 -0
- package/node_modules/@reasonlayer/runner/package.json +21 -0
- package/package.json +65 -0
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes the `FN` functions return.
|
|
3
|
+
*
|
|
4
|
+
* `FN` names the Convex functions every consumer calls; this module names what
|
|
5
|
+
* those calls resolve to. Backend handlers declare these as their return type,
|
|
6
|
+
* so a handler that stops producing a field fails to compile at the source
|
|
7
|
+
* instead of silently at the console, the CLI, or the runner.
|
|
8
|
+
*
|
|
9
|
+
* Named ceiling: TypeScript is erased at runtime, so this catches drift only at
|
|
10
|
+
* build time and only for consumers that compile in CI. Upgrade path is Convex
|
|
11
|
+
* `v.*` return validators on the handlers, with the types derived from those.
|
|
12
|
+
*/
|
|
13
|
+
import type { EnvironmentStatus, ReviewViewIR, VariableIR } from "./ir.js";
|
|
14
|
+
import type { AgentEventLevel, LifecycleEvent, LifecycleEventType, RunStatus } from "./events.js";
|
|
15
|
+
import type { StepRunStatus } from "./scheduling.js";
|
|
16
|
+
import type { Scope } from "./permissions.js";
|
|
17
|
+
export type RunMode = "deployment" | "test";
|
|
18
|
+
export type RunTrigger = "schedule" | "manual";
|
|
19
|
+
/** `FN.runsGet` */
|
|
20
|
+
export interface RunReadModel {
|
|
21
|
+
runId: string;
|
|
22
|
+
workflowId: string;
|
|
23
|
+
mode: RunMode;
|
|
24
|
+
status: RunStatus;
|
|
25
|
+
trigger: RunTrigger;
|
|
26
|
+
input: unknown;
|
|
27
|
+
variables?: Record<string, unknown> | undefined;
|
|
28
|
+
output?: unknown;
|
|
29
|
+
error?: string | undefined;
|
|
30
|
+
createdAt: number;
|
|
31
|
+
finishedAt?: number | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** One row of `FN.runsList` (and of the `runs:listPage` page). */
|
|
34
|
+
export interface RunListRow {
|
|
35
|
+
runId: string;
|
|
36
|
+
workflowId: string;
|
|
37
|
+
mode: RunMode;
|
|
38
|
+
status: RunStatus;
|
|
39
|
+
trigger: RunTrigger;
|
|
40
|
+
createdAt: number;
|
|
41
|
+
finishedAt?: number | undefined;
|
|
42
|
+
error?: string | undefined;
|
|
43
|
+
costUsd: number;
|
|
44
|
+
totalTokens: number;
|
|
45
|
+
hasStepFailures: boolean;
|
|
46
|
+
isQueued: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface RunStepUsageRow {
|
|
49
|
+
stepId: string;
|
|
50
|
+
invocationKey: string;
|
|
51
|
+
attempt: number;
|
|
52
|
+
model?: string | undefined;
|
|
53
|
+
inputTokens: number;
|
|
54
|
+
outputTokens: number;
|
|
55
|
+
costUsd: number;
|
|
56
|
+
turns: number;
|
|
57
|
+
updatedAt: number;
|
|
58
|
+
}
|
|
59
|
+
/** `transcripts:usageForRun`, and the `usage` block of `FN.runsInspect`. */
|
|
60
|
+
export interface RunUsageReadModel {
|
|
61
|
+
totals: {
|
|
62
|
+
inputTokens: number;
|
|
63
|
+
outputTokens: number;
|
|
64
|
+
costUsd: number;
|
|
65
|
+
};
|
|
66
|
+
steps: RunStepUsageRow[];
|
|
67
|
+
}
|
|
68
|
+
export interface RunInspectionStep {
|
|
69
|
+
stepId: string;
|
|
70
|
+
invocationKey: string;
|
|
71
|
+
attempt: number;
|
|
72
|
+
status: StepRunStatus;
|
|
73
|
+
output?: unknown;
|
|
74
|
+
error?: string | undefined;
|
|
75
|
+
childrenSucceeded?: number | undefined;
|
|
76
|
+
childrenTotal?: number | undefined;
|
|
77
|
+
startedAt: number;
|
|
78
|
+
finishedAt?: number | undefined;
|
|
79
|
+
}
|
|
80
|
+
export interface RunInspectionApproval {
|
|
81
|
+
approvalId: string;
|
|
82
|
+
stepId: string;
|
|
83
|
+
invocationKey: string;
|
|
84
|
+
status: ApprovalStatus;
|
|
85
|
+
view: ReviewViewIR;
|
|
86
|
+
content: unknown;
|
|
87
|
+
decision?: unknown;
|
|
88
|
+
edited?: boolean | undefined;
|
|
89
|
+
originalContentHash?: string | undefined;
|
|
90
|
+
reason?: string | undefined;
|
|
91
|
+
deadlineAt?: number | undefined;
|
|
92
|
+
createdAt: number;
|
|
93
|
+
resolvedAt?: number | undefined;
|
|
94
|
+
}
|
|
95
|
+
export interface RunLifecycleEventRow {
|
|
96
|
+
eventId: string;
|
|
97
|
+
seq: number;
|
|
98
|
+
at: number;
|
|
99
|
+
type: LifecycleEventType;
|
|
100
|
+
stepId?: string | undefined;
|
|
101
|
+
invocationKey?: string | undefined;
|
|
102
|
+
attempt?: number | undefined;
|
|
103
|
+
taskId?: string | undefined;
|
|
104
|
+
payload: LifecycleEvent["payload"];
|
|
105
|
+
}
|
|
106
|
+
/** `FN.runsInspect` — run, steps, usage, approvals, and the lifecycle log in one read. */
|
|
107
|
+
export interface RunInspection {
|
|
108
|
+
run: {
|
|
109
|
+
runId: string;
|
|
110
|
+
workflowId: string;
|
|
111
|
+
mode: RunMode;
|
|
112
|
+
status: RunStatus;
|
|
113
|
+
trigger: RunTrigger;
|
|
114
|
+
input: unknown;
|
|
115
|
+
variables?: Record<string, unknown> | undefined;
|
|
116
|
+
output?: unknown;
|
|
117
|
+
error?: string | undefined;
|
|
118
|
+
interpreterVersion: number;
|
|
119
|
+
createdAt: number;
|
|
120
|
+
finishedAt?: number | undefined;
|
|
121
|
+
hasStepFailures: boolean;
|
|
122
|
+
isQueued: boolean;
|
|
123
|
+
};
|
|
124
|
+
irJson?: string | undefined;
|
|
125
|
+
steps: RunInspectionStep[];
|
|
126
|
+
usage: RunUsageReadModel;
|
|
127
|
+
approvals: RunInspectionApproval[];
|
|
128
|
+
events: RunLifecycleEventRow[];
|
|
129
|
+
}
|
|
130
|
+
export type TranscriptEventType = "agent.turn" | "agent.tool" | "agent.task" | "agent.log" | "agent.error";
|
|
131
|
+
/** One stored `AgentEvent`, widened with the step locator it was recorded against. */
|
|
132
|
+
export interface TranscriptEvent {
|
|
133
|
+
seq: number;
|
|
134
|
+
turnSeq?: number | undefined;
|
|
135
|
+
level: AgentEventLevel;
|
|
136
|
+
ts: number;
|
|
137
|
+
type: TranscriptEventType;
|
|
138
|
+
data: unknown;
|
|
139
|
+
stepId: string;
|
|
140
|
+
invocationKey: string;
|
|
141
|
+
attempt: number;
|
|
142
|
+
}
|
|
143
|
+
/** `FN.transcriptsList` */
|
|
144
|
+
export interface TranscriptPage {
|
|
145
|
+
events: TranscriptEvent[];
|
|
146
|
+
nextCursor: string;
|
|
147
|
+
isDone: boolean;
|
|
148
|
+
}
|
|
149
|
+
export declare const APPROVAL_STATUSES: readonly ["pending", "approved", "rejected", "expired", "canceled"];
|
|
150
|
+
export type ApprovalStatus = (typeof APPROVAL_STATUSES)[number];
|
|
151
|
+
/** Display identity for whoever resolved a review or published a version. */
|
|
152
|
+
export interface ActorIdentity {
|
|
153
|
+
memberId?: string | undefined;
|
|
154
|
+
email?: string | undefined;
|
|
155
|
+
tokenLabel?: string | undefined;
|
|
156
|
+
}
|
|
157
|
+
/** `FN.approvalsList`, `approvals:listPage` rows, and `approvals:get`. */
|
|
158
|
+
export interface ApprovalReadModel {
|
|
159
|
+
approvalId: string;
|
|
160
|
+
runId: string;
|
|
161
|
+
workflowId: string;
|
|
162
|
+
workflowName: string;
|
|
163
|
+
runStatus: RunStatus;
|
|
164
|
+
stepId: string;
|
|
165
|
+
invocationKey: string;
|
|
166
|
+
content: unknown;
|
|
167
|
+
view: ReviewViewIR;
|
|
168
|
+
outputSchemaJsonText: string;
|
|
169
|
+
status: ApprovalStatus;
|
|
170
|
+
decision?: unknown;
|
|
171
|
+
edited?: boolean | undefined;
|
|
172
|
+
originalContentHash?: string | undefined;
|
|
173
|
+
reason?: string | undefined;
|
|
174
|
+
resolvedBy?: ActorIdentity | undefined;
|
|
175
|
+
deadlineAt?: number | undefined;
|
|
176
|
+
createdAt: number;
|
|
177
|
+
resolvedAt?: number | undefined;
|
|
178
|
+
}
|
|
179
|
+
export type WorkflowPublishState = "drafting" | "published" | "unpublished_changes";
|
|
180
|
+
export interface WorkflowCompileStatus {
|
|
181
|
+
ok: boolean;
|
|
182
|
+
errors?: Array<{
|
|
183
|
+
stepId?: string | undefined;
|
|
184
|
+
message: string;
|
|
185
|
+
}> | undefined;
|
|
186
|
+
lastGreenArtifactId?: string | undefined;
|
|
187
|
+
updatedAt: number;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The operational summary shared by `FN.deploymentsListWorkflows` and
|
|
191
|
+
* `dashboard:workflowHealth` rows.
|
|
192
|
+
*/
|
|
193
|
+
export interface WorkflowHealthRow {
|
|
194
|
+
workflowId: string;
|
|
195
|
+
publishedDeploymentId?: string | undefined;
|
|
196
|
+
publishedVersionId?: string | undefined;
|
|
197
|
+
publishedVersionNumber?: number | undefined;
|
|
198
|
+
description?: string | undefined;
|
|
199
|
+
group: {
|
|
200
|
+
groupId: string;
|
|
201
|
+
name: string;
|
|
202
|
+
color?: string | undefined;
|
|
203
|
+
} | null;
|
|
204
|
+
latestDeployment: {
|
|
205
|
+
deploymentId: string;
|
|
206
|
+
createdAt: number;
|
|
207
|
+
deployedBy?: ActorIdentity | undefined;
|
|
208
|
+
} | null;
|
|
209
|
+
lastRun: {
|
|
210
|
+
runId: string;
|
|
211
|
+
status: RunStatus;
|
|
212
|
+
hasStepFailures: boolean;
|
|
213
|
+
isQueued: boolean;
|
|
214
|
+
createdAt: number;
|
|
215
|
+
finishedAt?: number | undefined;
|
|
216
|
+
} | null;
|
|
217
|
+
successRate: number | null;
|
|
218
|
+
successWindow: number;
|
|
219
|
+
pendingReviews: number;
|
|
220
|
+
schedules: Array<{
|
|
221
|
+
name: string;
|
|
222
|
+
cron: string;
|
|
223
|
+
timezone: string;
|
|
224
|
+
status: "enabled" | "disabled";
|
|
225
|
+
nextRunAt?: number | undefined;
|
|
226
|
+
}>;
|
|
227
|
+
scheduleCount: number;
|
|
228
|
+
nextScheduledRunAt?: number | undefined;
|
|
229
|
+
}
|
|
230
|
+
/** One row of `FN.deploymentsListWorkflows` — health plus draft/publish state. */
|
|
231
|
+
export interface WorkflowListRow extends WorkflowHealthRow {
|
|
232
|
+
publishState: WorkflowPublishState;
|
|
233
|
+
compile?: WorkflowCompileStatus | undefined;
|
|
234
|
+
draftUpdatedAt?: number | undefined;
|
|
235
|
+
requiredSecrets: string[];
|
|
236
|
+
}
|
|
237
|
+
/** `workflowGroups:list`; the group mutations return one row. */
|
|
238
|
+
export interface WorkflowGroupRow {
|
|
239
|
+
groupId: string;
|
|
240
|
+
name: string;
|
|
241
|
+
description?: string | undefined;
|
|
242
|
+
color?: string | undefined;
|
|
243
|
+
workflowIds: string[];
|
|
244
|
+
createdAt: number;
|
|
245
|
+
updatedAt: number;
|
|
246
|
+
}
|
|
247
|
+
/** An active authoring session as the console detail reports it. */
|
|
248
|
+
export interface AuthoringSessionRow {
|
|
249
|
+
sessionId: string;
|
|
250
|
+
machineLabel: string;
|
|
251
|
+
startedAt: number;
|
|
252
|
+
lastHeartbeatAt: number;
|
|
253
|
+
error?: string | undefined;
|
|
254
|
+
}
|
|
255
|
+
/** `FN.workspacesStatus` */
|
|
256
|
+
export interface WorkspaceStatus {
|
|
257
|
+
workflowId: string;
|
|
258
|
+
state: WorkflowPublishState;
|
|
259
|
+
compile?: WorkflowCompileStatus | undefined;
|
|
260
|
+
publishedVersionId?: string | undefined;
|
|
261
|
+
versionNumber?: number | undefined;
|
|
262
|
+
draftUpdatedAt?: number | undefined;
|
|
263
|
+
session?: (AuthoringSessionRow & {
|
|
264
|
+
endedAt?: number | undefined;
|
|
265
|
+
endReason?: "done" | "expired" | undefined;
|
|
266
|
+
}) | undefined;
|
|
267
|
+
}
|
|
268
|
+
/** `workspaces:consoleDetail` — null when the workflow doesn't exist. */
|
|
269
|
+
export interface WorkflowConsoleDetail {
|
|
270
|
+
workflowId: string;
|
|
271
|
+
state: WorkflowPublishState;
|
|
272
|
+
compile?: WorkflowCompileStatus | undefined;
|
|
273
|
+
publishedVersionId?: string | undefined;
|
|
274
|
+
versionNumber?: number | undefined;
|
|
275
|
+
draftUpdatedAt?: number | undefined;
|
|
276
|
+
irJson?: string | undefined;
|
|
277
|
+
sessions: AuthoringSessionRow[];
|
|
278
|
+
}
|
|
279
|
+
/** One row of `FN.workspacesListVersions`. */
|
|
280
|
+
export interface WorkflowVersionRow {
|
|
281
|
+
versionId: string;
|
|
282
|
+
versionNumber: number;
|
|
283
|
+
deploymentId: string;
|
|
284
|
+
irJson?: string | undefined;
|
|
285
|
+
createdAt: number;
|
|
286
|
+
createdBy: string;
|
|
287
|
+
fromSessionId?: string | undefined;
|
|
288
|
+
}
|
|
289
|
+
/** One row of `FN.workspacesAvailableBundles`. */
|
|
290
|
+
export interface WorkspaceBundleRow {
|
|
291
|
+
sha256: string;
|
|
292
|
+
storageId: string;
|
|
293
|
+
size: number;
|
|
294
|
+
}
|
|
295
|
+
/** `FN.deploymentsGet` */
|
|
296
|
+
export interface DeploymentReadModel {
|
|
297
|
+
deploymentId: string;
|
|
298
|
+
workflowId: string;
|
|
299
|
+
description?: string | undefined;
|
|
300
|
+
deployedBy?: ActorIdentity | undefined;
|
|
301
|
+
codeStepIds: string[];
|
|
302
|
+
stepsBundleSha256?: string | undefined;
|
|
303
|
+
agentBundleSha256?: string | undefined;
|
|
304
|
+
stepsBundleSize?: number | undefined;
|
|
305
|
+
agentBundleSize?: number | undefined;
|
|
306
|
+
inputSchemaJsonText: string;
|
|
307
|
+
environments: EnvironmentStatus[];
|
|
308
|
+
createdAt: number;
|
|
309
|
+
}
|
|
310
|
+
/** `FN.deploymentsLatestFor` — null when the workflow has no published deployment. */
|
|
311
|
+
export interface LatestDeploymentRef {
|
|
312
|
+
deploymentId: string;
|
|
313
|
+
inputSchemaJsonText: string;
|
|
314
|
+
}
|
|
315
|
+
/** One row of `FN.triggersList`; the trigger mutations return one row. */
|
|
316
|
+
export interface TriggerScheduleReadModel {
|
|
317
|
+
triggerId: string;
|
|
318
|
+
workflowId: string;
|
|
319
|
+
name: string;
|
|
320
|
+
kind: "schedule";
|
|
321
|
+
cron: string;
|
|
322
|
+
timezone: string;
|
|
323
|
+
enabled: boolean;
|
|
324
|
+
status: "enabled" | "disabled";
|
|
325
|
+
nextFireAt?: number | undefined;
|
|
326
|
+
lastFiredAt?: number | undefined;
|
|
327
|
+
lastRunId?: string | undefined;
|
|
328
|
+
lastError?: string | undefined;
|
|
329
|
+
versionId: string;
|
|
330
|
+
createdAt: number;
|
|
331
|
+
updatedAt: number;
|
|
332
|
+
}
|
|
333
|
+
/** One row of `FN.variablesList` — a declared variable merged with its org override. */
|
|
334
|
+
export interface WorkflowVariableRow {
|
|
335
|
+
name: string;
|
|
336
|
+
description?: string | undefined;
|
|
337
|
+
schemaJson: VariableIR["schemaJson"];
|
|
338
|
+
defaultJson: unknown;
|
|
339
|
+
value?: unknown;
|
|
340
|
+
updatedAt?: number | undefined;
|
|
341
|
+
}
|
|
342
|
+
export type MemberRole = "admin" | "operator" | "reviewer" | "viewer";
|
|
343
|
+
export type ActorKind = "bootstrap" | "platform_token" | "access_token" | "authoring_session" | "user";
|
|
344
|
+
/** The authenticated caller as `FN.orgsWhoami` reports it. */
|
|
345
|
+
export interface OrgActor {
|
|
346
|
+
kind: ActorKind;
|
|
347
|
+
role?: MemberRole | undefined;
|
|
348
|
+
memberId?: string | undefined;
|
|
349
|
+
userId?: string | undefined;
|
|
350
|
+
tokenId?: string | undefined;
|
|
351
|
+
label?: string | undefined;
|
|
352
|
+
scopes?: Scope[] | undefined;
|
|
353
|
+
workflowIds?: string[] | undefined;
|
|
354
|
+
sessionId?: string | undefined;
|
|
355
|
+
}
|
|
356
|
+
/** `FN.orgsWhoami` */
|
|
357
|
+
export interface OrgReadModel {
|
|
358
|
+
orgId: string;
|
|
359
|
+
name: string;
|
|
360
|
+
actor: OrgActor;
|
|
361
|
+
}
|
|
362
|
+
/** `members:list`, `members:updateRole`. */
|
|
363
|
+
export interface MemberReadModel {
|
|
364
|
+
memberId: string;
|
|
365
|
+
userId: string;
|
|
366
|
+
email: string;
|
|
367
|
+
name?: string | undefined;
|
|
368
|
+
role: MemberRole;
|
|
369
|
+
workflowIds?: string[] | undefined;
|
|
370
|
+
createdAt: number;
|
|
371
|
+
updatedAt: number;
|
|
372
|
+
}
|
|
373
|
+
/** One row of `members:myOrgs`. */
|
|
374
|
+
export interface OrgMembershipRow {
|
|
375
|
+
orgId: string;
|
|
376
|
+
orgName: string;
|
|
377
|
+
role: MemberRole;
|
|
378
|
+
}
|
|
379
|
+
/** `members:currentSession` — null when a native human still needs provisioning. */
|
|
380
|
+
export interface SessionReadModel {
|
|
381
|
+
orgId: string;
|
|
382
|
+
orgName: string;
|
|
383
|
+
member: MemberReadModel;
|
|
384
|
+
orgs: Array<OrgMembershipRow & {
|
|
385
|
+
workosOrgId: string;
|
|
386
|
+
}>;
|
|
387
|
+
user: {
|
|
388
|
+
email: string;
|
|
389
|
+
name?: string | undefined;
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
/** `FN.devicesList` */
|
|
393
|
+
export interface DeviceReadModel {
|
|
394
|
+
deviceId: string;
|
|
395
|
+
name: string;
|
|
396
|
+
handles: string[];
|
|
397
|
+
enabled: boolean;
|
|
398
|
+
settings: Record<string, unknown>;
|
|
399
|
+
createdAt: number;
|
|
400
|
+
updatedAt: number;
|
|
401
|
+
lastSeenAt?: number | undefined;
|
|
402
|
+
}
|
|
403
|
+
export type DeviceProfileLoginState = "not_started" | "pending" | "ready" | "failed";
|
|
404
|
+
/** `FN.devicesListProfiles` rows; the profile mutations return one row. */
|
|
405
|
+
export interface DeviceProfileReadModel {
|
|
406
|
+
profileId: string;
|
|
407
|
+
deviceId: string;
|
|
408
|
+
profileKey: string;
|
|
409
|
+
label?: string | undefined;
|
|
410
|
+
enabled: boolean;
|
|
411
|
+
loginState: DeviceProfileLoginState;
|
|
412
|
+
loginMessage?: string | undefined;
|
|
413
|
+
loginRequestedAt?: number | undefined;
|
|
414
|
+
loginCompletedAt?: number | undefined;
|
|
415
|
+
leasedByTaskId?: string | undefined;
|
|
416
|
+
leaseExpiresAt?: number | undefined;
|
|
417
|
+
createdAt: number;
|
|
418
|
+
updatedAt: number;
|
|
419
|
+
}
|
|
420
|
+
/** `invitations:list` and the single-invitation mutations, as WorkOS reports them. */
|
|
421
|
+
export interface InvitationReadModel {
|
|
422
|
+
id: string;
|
|
423
|
+
email: string;
|
|
424
|
+
workosOrgId: string;
|
|
425
|
+
state: string;
|
|
426
|
+
createdAt?: number | undefined;
|
|
427
|
+
expiresAt?: number | undefined;
|
|
428
|
+
}
|
|
429
|
+
/** One row of `FN.secretsList` — names and timestamps only, never values. */
|
|
430
|
+
export interface SecretReadModel {
|
|
431
|
+
name: string;
|
|
432
|
+
createdAt: number;
|
|
433
|
+
updatedAt: number;
|
|
434
|
+
}
|
|
435
|
+
/** One row of `FN.tokensList`; `tokens:create` returns one plus the raw token. */
|
|
436
|
+
export interface PlatformTokenReadModel {
|
|
437
|
+
tokenId: string;
|
|
438
|
+
label: string;
|
|
439
|
+
tokenPrefix?: string | undefined;
|
|
440
|
+
kind: "bootstrap" | "platform";
|
|
441
|
+
scopes?: string[] | undefined;
|
|
442
|
+
workflowIds?: string[] | undefined;
|
|
443
|
+
createdByMemberId?: string | undefined;
|
|
444
|
+
createdAt?: number | undefined;
|
|
445
|
+
expiresAt?: number | undefined;
|
|
446
|
+
revokedAt?: number | undefined;
|
|
447
|
+
lastUsedAt?: number | undefined;
|
|
448
|
+
}
|
|
449
|
+
export type IntegrationConnectionState = "not_connected" | "connecting" | "connected" | "unhealthy" | "failed";
|
|
450
|
+
export interface IntegrationCatalogAction {
|
|
451
|
+
id: string;
|
|
452
|
+
label: string;
|
|
453
|
+
description: string;
|
|
454
|
+
inputSchemaJsonText: string;
|
|
455
|
+
outputSchemaJsonText: string;
|
|
456
|
+
}
|
|
457
|
+
/** One entry of `FN.integrationsListCatalog`. */
|
|
458
|
+
export interface IntegrationCatalogApp {
|
|
459
|
+
id: string;
|
|
460
|
+
label: string;
|
|
461
|
+
description: string;
|
|
462
|
+
actions: IntegrationCatalogAction[];
|
|
463
|
+
}
|
|
464
|
+
/** `FN.integrationsGetConnection` */
|
|
465
|
+
export interface IntegrationConnectionReadModel {
|
|
466
|
+
appId: string;
|
|
467
|
+
state: IntegrationConnectionState;
|
|
468
|
+
connectStartedAt?: number | undefined;
|
|
469
|
+
connectedAt?: number | undefined;
|
|
470
|
+
lastCheckedAt?: number | undefined;
|
|
471
|
+
lastHealthyAt?: number | undefined;
|
|
472
|
+
lastRefreshedAt?: number | undefined;
|
|
473
|
+
lastUsedAt?: number | undefined;
|
|
474
|
+
lastError?: string | undefined;
|
|
475
|
+
}
|
|
476
|
+
export declare const ALERT_KINDS: readonly ["run_failed", "run_canceled", "run_retried", "run_succeeded_with_failures", "review_created", "review_expired", "task_failed", "task_timeout", "stuck_run"];
|
|
477
|
+
export type AlertKind = (typeof ALERT_KINDS)[number];
|
|
478
|
+
export type AlertLifecycle = "open" | "resolved" | "exhausted";
|
|
479
|
+
export type AlertPolicyScope = {
|
|
480
|
+
kind: "org";
|
|
481
|
+
} | {
|
|
482
|
+
kind: "group";
|
|
483
|
+
groupId: string;
|
|
484
|
+
groupName?: string | undefined;
|
|
485
|
+
} | {
|
|
486
|
+
kind: "workflow";
|
|
487
|
+
workflowId: string;
|
|
488
|
+
};
|
|
489
|
+
export interface AlertMemberIdentity {
|
|
490
|
+
memberId: string;
|
|
491
|
+
email: string;
|
|
492
|
+
name?: string | undefined;
|
|
493
|
+
}
|
|
494
|
+
export interface AlertChainRung {
|
|
495
|
+
members: AlertMemberIdentity[];
|
|
496
|
+
}
|
|
497
|
+
/** One row of `alerts:listNotifications`. */
|
|
498
|
+
export interface AlertNotificationRow {
|
|
499
|
+
notificationId: string;
|
|
500
|
+
alertId: string;
|
|
501
|
+
rung: number;
|
|
502
|
+
channel: "slack";
|
|
503
|
+
memberIds: string[];
|
|
504
|
+
ccMemberIds: string[];
|
|
505
|
+
status: "queued" | "delivered" | "failed";
|
|
506
|
+
deliveryError?: string | undefined;
|
|
507
|
+
createdAt: number;
|
|
508
|
+
deliveredAt?: number | undefined;
|
|
509
|
+
}
|
|
510
|
+
/** A notification inside `FN.alertsList`, with member identities resolved. */
|
|
511
|
+
export interface AlertNotification extends AlertNotificationRow {
|
|
512
|
+
members: AlertMemberIdentity[];
|
|
513
|
+
ccMembers: AlertMemberIdentity[];
|
|
514
|
+
}
|
|
515
|
+
/** One row of `FN.alertsList`. */
|
|
516
|
+
export interface AlertReadModel {
|
|
517
|
+
alertId: string;
|
|
518
|
+
policyId?: string | undefined;
|
|
519
|
+
event: AlertKind;
|
|
520
|
+
title: string;
|
|
521
|
+
message: string;
|
|
522
|
+
workflowId?: string | undefined;
|
|
523
|
+
runId?: string | undefined;
|
|
524
|
+
stepId?: string | undefined;
|
|
525
|
+
sourceApprovalId?: string | undefined;
|
|
526
|
+
status: AlertLifecycle;
|
|
527
|
+
currentRung: number;
|
|
528
|
+
notifiedMemberIds: string[];
|
|
529
|
+
closedReason?: string | undefined;
|
|
530
|
+
resolvedAt?: number | undefined;
|
|
531
|
+
createdAt: number;
|
|
532
|
+
escalateAfterMs?: number | undefined;
|
|
533
|
+
chain: AlertChainRung[];
|
|
534
|
+
policy?: {
|
|
535
|
+
name: string;
|
|
536
|
+
scope: AlertPolicyScope;
|
|
537
|
+
} | undefined;
|
|
538
|
+
integration?: {
|
|
539
|
+
name: string;
|
|
540
|
+
} | undefined;
|
|
541
|
+
notifications: AlertNotification[];
|
|
542
|
+
}
|
|
543
|
+
/** One row of `FN.alertsListPolicies`, with scope and chain identities resolved. */
|
|
544
|
+
export interface AlertPolicyReadModel {
|
|
545
|
+
policyId: string;
|
|
546
|
+
name: string;
|
|
547
|
+
events: AlertKind[];
|
|
548
|
+
scope: AlertPolicyScope;
|
|
549
|
+
chain: AlertChainRung[];
|
|
550
|
+
escalateAfterMs?: number | undefined;
|
|
551
|
+
slackIntegrationId?: string | undefined;
|
|
552
|
+
enabled: boolean;
|
|
553
|
+
createdAt: number;
|
|
554
|
+
updatedAt: number;
|
|
555
|
+
integration?: {
|
|
556
|
+
name: string;
|
|
557
|
+
enabled: boolean;
|
|
558
|
+
} | undefined;
|
|
559
|
+
}
|
|
560
|
+
/** One row of `alerts:listSlackIntegrations`. */
|
|
561
|
+
export interface SlackIntegrationReadModel {
|
|
562
|
+
integrationId: string;
|
|
563
|
+
name: string;
|
|
564
|
+
enabled: boolean;
|
|
565
|
+
}
|
|
566
|
+
/** `dashboard:shellCounts` — null for sections the caller can't read. */
|
|
567
|
+
export interface ShellCounts {
|
|
568
|
+
pendingReviews: number | null;
|
|
569
|
+
unresolvedAlerts: number | null;
|
|
570
|
+
}
|
|
571
|
+
/** The compact alert row in the home overview feed. */
|
|
572
|
+
export interface AlertSummaryRow {
|
|
573
|
+
alertId: string;
|
|
574
|
+
title: string;
|
|
575
|
+
status: AlertLifecycle;
|
|
576
|
+
currentRung: number;
|
|
577
|
+
createdAt: number;
|
|
578
|
+
workflowId?: string | undefined;
|
|
579
|
+
}
|
|
580
|
+
/** `dashboard:overview` — each section gated by the caller's permissions. */
|
|
581
|
+
export interface HomeOverview {
|
|
582
|
+
workflows: {
|
|
583
|
+
available: false;
|
|
584
|
+
} | {
|
|
585
|
+
available: true;
|
|
586
|
+
count: number;
|
|
587
|
+
};
|
|
588
|
+
approvals: {
|
|
589
|
+
available: false;
|
|
590
|
+
} | {
|
|
591
|
+
available: true;
|
|
592
|
+
data: ApprovalReadModel[];
|
|
593
|
+
recent: ApprovalReadModel[];
|
|
594
|
+
};
|
|
595
|
+
runs: {
|
|
596
|
+
available: false;
|
|
597
|
+
} | {
|
|
598
|
+
available: true;
|
|
599
|
+
data: RunListRow[];
|
|
600
|
+
recent: RunListRow[];
|
|
601
|
+
};
|
|
602
|
+
alerts: {
|
|
603
|
+
available: false;
|
|
604
|
+
} | {
|
|
605
|
+
available: true;
|
|
606
|
+
data: AlertSummaryRow[];
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
/** `dashboard:workflowHealth` — attention-ranked, paged. */
|
|
610
|
+
export type WorkflowHealthPage = {
|
|
611
|
+
available: false;
|
|
612
|
+
} | {
|
|
613
|
+
available: true;
|
|
614
|
+
rows: WorkflowHealthRow[];
|
|
615
|
+
totalItems: number;
|
|
616
|
+
pageIndex: number;
|
|
617
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes the `FN` functions return.
|
|
3
|
+
*
|
|
4
|
+
* `FN` names the Convex functions every consumer calls; this module names what
|
|
5
|
+
* those calls resolve to. Backend handlers declare these as their return type,
|
|
6
|
+
* so a handler that stops producing a field fails to compile at the source
|
|
7
|
+
* instead of silently at the console, the CLI, or the runner.
|
|
8
|
+
*
|
|
9
|
+
* Named ceiling: TypeScript is erased at runtime, so this catches drift only at
|
|
10
|
+
* build time and only for consumers that compile in CI. Upgrade path is Convex
|
|
11
|
+
* `v.*` return validators on the handlers, with the types derived from those.
|
|
12
|
+
*/
|
|
13
|
+
/* -------------------------------------------------------------------------- */
|
|
14
|
+
/* reviews */
|
|
15
|
+
/* -------------------------------------------------------------------------- */
|
|
16
|
+
export const APPROVAL_STATUSES = [
|
|
17
|
+
"pending",
|
|
18
|
+
"approved",
|
|
19
|
+
"rejected",
|
|
20
|
+
"expired",
|
|
21
|
+
"canceled",
|
|
22
|
+
];
|
|
23
|
+
/* -------------------------------------------------------------------------- */
|
|
24
|
+
/* alerts */
|
|
25
|
+
/* -------------------------------------------------------------------------- */
|
|
26
|
+
export const ALERT_KINDS = [
|
|
27
|
+
"run_failed",
|
|
28
|
+
"run_canceled",
|
|
29
|
+
"run_retried",
|
|
30
|
+
"run_succeeded_with_failures",
|
|
31
|
+
"review_created",
|
|
32
|
+
"review_expired",
|
|
33
|
+
"task_failed",
|
|
34
|
+
"task_timeout",
|
|
35
|
+
"stuck_run",
|
|
36
|
+
];
|