@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.
Files changed (101) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +35 -0
  3. package/bin/rl.mjs +75 -0
  4. package/dist/builder.d.ts +38 -0
  5. package/dist/builder.js +41 -0
  6. package/dist/bundler/index.d.ts +32 -0
  7. package/dist/bundler/index.js +143 -0
  8. package/dist/bundler/node.d.ts +10 -0
  9. package/dist/bundler/node.js +55 -0
  10. package/dist/cli/args.d.ts +9 -0
  11. package/dist/cli/args.js +71 -0
  12. package/dist/cli/config.d.ts +38 -0
  13. package/dist/cli/config.js +94 -0
  14. package/dist/cli/convex.d.ts +9 -0
  15. package/dist/cli/convex.js +25 -0
  16. package/dist/cli/format.d.ts +11 -0
  17. package/dist/cli/format.js +140 -0
  18. package/dist/cli/index.d.ts +1 -0
  19. package/dist/cli/index.js +721 -0
  20. package/dist/cli/keychain.d.ts +21 -0
  21. package/dist/cli/keychain.js +100 -0
  22. package/dist/cli/operations.d.ts +106 -0
  23. package/dist/cli/operations.js +623 -0
  24. package/dist/cli/sdk-package.d.ts +18 -0
  25. package/dist/cli/sdk-package.js +45 -0
  26. package/dist/cli/storage-upload.d.ts +9 -0
  27. package/dist/cli/storage-upload.js +21 -0
  28. package/dist/cli/watcher-compile.d.ts +1 -0
  29. package/dist/cli/watcher-compile.js +20 -0
  30. package/dist/cli/watcher-process.d.ts +1 -0
  31. package/dist/cli/watcher-process.js +312 -0
  32. package/dist/cli/workspace-files.d.ts +12 -0
  33. package/dist/cli/workspace-files.js +91 -0
  34. package/dist/cli/workspace-local.d.ts +27 -0
  35. package/dist/cli/workspace-local.js +310 -0
  36. package/dist/cli/workspace-session.d.ts +13 -0
  37. package/dist/cli/workspace-session.js +12 -0
  38. package/dist/compile.d.ts +27 -0
  39. package/dist/compile.js +834 -0
  40. package/dist/index.d.ts +10 -0
  41. package/dist/index.js +5 -0
  42. package/dist/schedule-validation.d.ts +1 -0
  43. package/dist/schedule-validation.js +16 -0
  44. package/dist/selector-schema.d.ts +26 -0
  45. package/dist/selector-schema.js +780 -0
  46. package/dist/selectors.d.ts +25 -0
  47. package/dist/selectors.js +99 -0
  48. package/dist/testkit.d.ts +32 -0
  49. package/dist/testkit.js +161 -0
  50. package/dist/types.d.ts +184 -0
  51. package/dist/types.js +110 -0
  52. package/node_modules/@reasonlayer/integrations/dist/catalog.d.ts +4937 -0
  53. package/node_modules/@reasonlayer/integrations/dist/catalog.js +20 -0
  54. package/node_modules/@reasonlayer/integrations/dist/generated/slack.d.ts +3014 -0
  55. package/node_modules/@reasonlayer/integrations/dist/generated/slack.js +3101 -0
  56. package/node_modules/@reasonlayer/integrations/dist/index.d.ts +2 -0
  57. package/node_modules/@reasonlayer/integrations/dist/index.js +1 -0
  58. package/node_modules/@reasonlayer/integrations/dist/internal/definitions.d.ts +44 -0
  59. package/node_modules/@reasonlayer/integrations/dist/internal/definitions.js +52 -0
  60. package/node_modules/@reasonlayer/integrations/dist/internal/transport.d.ts +7 -0
  61. package/node_modules/@reasonlayer/integrations/dist/internal/transport.js +48 -0
  62. package/node_modules/@reasonlayer/integrations/dist/testkit.d.ts +1 -0
  63. package/node_modules/@reasonlayer/integrations/dist/testkit.js +1 -0
  64. package/node_modules/@reasonlayer/integrations/package.json +26 -0
  65. package/node_modules/@reasonlayer/protocol/dist/environments.d.ts +7 -0
  66. package/node_modules/@reasonlayer/protocol/dist/environments.js +7 -0
  67. package/node_modules/@reasonlayer/protocol/dist/events.d.ts +313 -0
  68. package/node_modules/@reasonlayer/protocol/dist/events.js +20 -0
  69. package/node_modules/@reasonlayer/protocol/dist/index.d.ts +18 -0
  70. package/node_modules/@reasonlayer/protocol/dist/index.js +9 -0
  71. package/node_modules/@reasonlayer/protocol/dist/ir.d.ts +252 -0
  72. package/node_modules/@reasonlayer/protocol/dist/ir.js +116 -0
  73. package/node_modules/@reasonlayer/protocol/dist/permissions.d.ts +5 -0
  74. package/node_modules/@reasonlayer/protocol/dist/permissions.js +30 -0
  75. package/node_modules/@reasonlayer/protocol/dist/readmodels.d.ts +617 -0
  76. package/node_modules/@reasonlayer/protocol/dist/readmodels.js +36 -0
  77. package/node_modules/@reasonlayer/protocol/dist/runtime.d.ts +67 -0
  78. package/node_modules/@reasonlayer/protocol/dist/runtime.js +66 -0
  79. package/node_modules/@reasonlayer/protocol/dist/scheduling.d.ts +69 -0
  80. package/node_modules/@reasonlayer/protocol/dist/scheduling.js +126 -0
  81. package/node_modules/@reasonlayer/protocol/dist/selector.d.ts +23 -0
  82. package/node_modules/@reasonlayer/protocol/dist/selector.js +77 -0
  83. package/node_modules/@reasonlayer/protocol/dist/tasks.d.ts +69 -0
  84. package/node_modules/@reasonlayer/protocol/dist/tasks.js +6 -0
  85. package/node_modules/@reasonlayer/protocol/dist/validate.d.ts +6 -0
  86. package/node_modules/@reasonlayer/protocol/dist/validate.js +18 -0
  87. package/node_modules/@reasonlayer/protocol/package.json +21 -0
  88. package/node_modules/@reasonlayer/runner/dist/environment-materializer.d.ts +13 -0
  89. package/node_modules/@reasonlayer/runner/dist/environment-materializer.js +92 -0
  90. package/node_modules/@reasonlayer/runner/dist/flue-transcript.d.ts +17 -0
  91. package/node_modules/@reasonlayer/runner/dist/flue-transcript.js +182 -0
  92. package/node_modules/@reasonlayer/runner/dist/index.d.ts +184 -0
  93. package/node_modules/@reasonlayer/runner/dist/index.js +884 -0
  94. package/node_modules/@reasonlayer/runner/dist/mcp-supervisor.d.ts +15 -0
  95. package/node_modules/@reasonlayer/runner/dist/mcp-supervisor.js +142 -0
  96. package/node_modules/@reasonlayer/runner/dist/sandbox-env.d.ts +36 -0
  97. package/node_modules/@reasonlayer/runner/dist/sandbox-env.js +171 -0
  98. package/node_modules/@reasonlayer/runner/dist/task-child.d.ts +1 -0
  99. package/node_modules/@reasonlayer/runner/dist/task-child.js +72 -0
  100. package/node_modules/@reasonlayer/runner/package.json +21 -0
  101. package/package.json +65 -0
@@ -0,0 +1,2 @@
1
+ export { catalog, catalogActionById, resolveCatalogActionDescriptor, slack, } from "./catalog.js";
2
+ export type { CatalogActionDescriptor, CatalogActionId, CatalogActionInput, CatalogActionOutput, CatalogAppId, CatalogJsonSchema, } from "./catalog.js";
@@ -0,0 +1 @@
1
+ export { catalog, catalogActionById, resolveCatalogActionDescriptor, slack, } from "./catalog.js";
@@ -0,0 +1,44 @@
1
+ import * as v from "valibot";
2
+ export type CatalogJsonSchema = Record<string, unknown>;
3
+ declare const catalogActionType: unique symbol;
4
+ export interface CatalogActionDescriptor<InputSchema extends v.GenericSchema = any, OutputSchema extends v.GenericSchema = any, AppId extends string = string, ActionId extends string = string> {
5
+ (input: v.InferOutput<InputSchema>): Promise<v.InferOutput<OutputSchema>>;
6
+ readonly [catalogActionType]: true;
7
+ readonly id: ActionId;
8
+ readonly appId: AppId;
9
+ readonly label: string;
10
+ readonly description: string;
11
+ readonly version: string;
12
+ readonly input: InputSchema;
13
+ readonly output: OutputSchema;
14
+ readonly inputSchemaJson: CatalogJsonSchema;
15
+ readonly outputSchemaJson: CatalogJsonSchema;
16
+ }
17
+ export type CatalogActionInput<Action extends CatalogActionDescriptor> = v.InferOutput<Action["input"]>;
18
+ export type CatalogActionOutput<Action extends CatalogActionDescriptor> = v.InferOutput<Action["output"]>;
19
+ export type CatalogActionDefinition = {
20
+ readonly id: string;
21
+ readonly label: string;
22
+ readonly description: string;
23
+ readonly version: string;
24
+ readonly input: v.GenericSchema;
25
+ readonly output: v.GenericSchema;
26
+ };
27
+ type DefinedAction<AppId extends string, Definition extends CatalogActionDefinition> = CatalogActionDescriptor<Definition["input"], Definition["output"], AppId, Definition["id"]>;
28
+ type DefinedActions<AppId extends string, Definitions extends Record<string, CatalogActionDefinition>> = {
29
+ readonly [Name in keyof Definitions]: DefinedAction<AppId, Definitions[Name]>;
30
+ };
31
+ export type DefinedApp<AppId extends string, Definitions extends Record<string, CatalogActionDefinition>> = {
32
+ readonly id: AppId;
33
+ readonly label: string;
34
+ readonly description: string;
35
+ readonly actions: DefinedActions<AppId, Definitions>;
36
+ };
37
+ export declare function defineApp<const AppId extends string, const Definitions extends Record<string, CatalogActionDefinition>>(definition: {
38
+ readonly id: AppId;
39
+ readonly label: string;
40
+ readonly description: string;
41
+ readonly actions: Definitions;
42
+ }): DefinedApp<AppId, Definitions>;
43
+ export declare function isRegisteredCatalogAction(value: unknown): value is CatalogActionDescriptor;
44
+ export {};
@@ -0,0 +1,52 @@
1
+ import { toJsonSchema } from "@valibot/to-json-schema";
2
+ import * as v from "valibot";
3
+ import { callIntegrationTransport } from "./transport.js";
4
+ const catalogActionRegistryKey = Symbol.for("@reasonlayer/integrations/catalog-actions/v1");
5
+ const catalogGlobal = globalThis;
6
+ const existingCatalogActionRegistry = catalogGlobal[catalogActionRegistryKey];
7
+ const catalogActionRegistry = existingCatalogActionRegistry instanceof WeakSet
8
+ ? existingCatalogActionRegistry
9
+ : new WeakSet();
10
+ if (existingCatalogActionRegistry === undefined) {
11
+ Object.defineProperty(catalogGlobal, catalogActionRegistryKey, {
12
+ value: catalogActionRegistry,
13
+ });
14
+ }
15
+ function deepFreeze(value) {
16
+ if (!value || typeof value !== "object" || Object.isFrozen(value))
17
+ return;
18
+ for (const child of Object.values(value))
19
+ deepFreeze(child);
20
+ Object.freeze(value);
21
+ }
22
+ function defineAction(definition) {
23
+ const inputSchemaJson = toJsonSchema(definition.input);
24
+ const outputSchemaJson = toJsonSchema(definition.output);
25
+ deepFreeze(inputSchemaJson);
26
+ deepFreeze(outputSchemaJson);
27
+ const action = async (input) => {
28
+ const output = await callIntegrationTransport({
29
+ actionId: definition.id,
30
+ input,
31
+ });
32
+ return v.parse(definition.output, output);
33
+ };
34
+ const descriptor = Object.freeze(Object.assign(action, definition, { inputSchemaJson, outputSchemaJson }));
35
+ catalogActionRegistry.add(descriptor);
36
+ return descriptor;
37
+ }
38
+ export function defineApp(definition) {
39
+ const actions = Object.fromEntries(Object.entries(definition.actions).map(([name, action]) => [
40
+ name,
41
+ defineAction({ ...action, appId: definition.id }),
42
+ ]));
43
+ return Object.freeze({
44
+ id: definition.id,
45
+ label: definition.label,
46
+ description: definition.description,
47
+ actions: Object.freeze(actions),
48
+ });
49
+ }
50
+ export function isRegisteredCatalogAction(value) {
51
+ return ((typeof value === "object" && value !== null) || typeof value === "function") && catalogActionRegistry.has(value);
52
+ }
@@ -0,0 +1,7 @@
1
+ export interface IntegrationTransportRequest {
2
+ readonly actionId: string;
3
+ readonly input: unknown;
4
+ }
5
+ export type IntegrationTransport = (request: IntegrationTransportRequest) => Promise<unknown>;
6
+ export declare function callIntegrationTransport(request: IntegrationTransportRequest): Promise<unknown>;
7
+ export declare function setIntegrationTransportForTests(transport: IntegrationTransport): () => void;
@@ -0,0 +1,48 @@
1
+ import { ConvexHttpClient } from "convex/browser";
2
+ import { makeFunctionReference } from "convex/server";
3
+ const integrationTransportStateKey = Symbol.for("@reasonlayer/integrations/transport-state/v1");
4
+ const integrationGlobal = globalThis;
5
+ const existingIntegrationTransportState = integrationGlobal[integrationTransportStateKey];
6
+ const integrationTransportState = existingIntegrationTransportState &&
7
+ typeof existingIntegrationTransportState === "object"
8
+ ? existingIntegrationTransportState
9
+ : {};
10
+ if (existingIntegrationTransportState === undefined) {
11
+ Object.defineProperty(integrationGlobal, integrationTransportStateKey, {
12
+ value: integrationTransportState,
13
+ });
14
+ }
15
+ const invokeIntegration = makeFunctionReference("integrations:invokeIntegration");
16
+ async function defaultIntegrationTransport(request) {
17
+ const convexUrl = process.env["RL_CONVEX_URL"];
18
+ const taskId = process.env["RL_TASK_ID"];
19
+ const taskToken = process.env["RL_TASK_TOKEN"];
20
+ if (!convexUrl || !taskId || !taskToken) {
21
+ throw new Error("integration calls only work inside a running Reasonlayer step");
22
+ }
23
+ const client = new ConvexHttpClient(convexUrl, {
24
+ logger: false,
25
+ skipConvexDeploymentUrlCheck: true,
26
+ });
27
+ return await client.action(invokeIntegration, {
28
+ taskId,
29
+ taskToken,
30
+ actionId: request.actionId,
31
+ input: request.input,
32
+ });
33
+ }
34
+ export async function callIntegrationTransport(request) {
35
+ return await (integrationTransportState.override ?? defaultIntegrationTransport)(request);
36
+ }
37
+ export function setIntegrationTransportForTests(transport) {
38
+ const previous = integrationTransportState.override;
39
+ integrationTransportState.override = transport;
40
+ return () => {
41
+ if (integrationTransportState.override !== transport)
42
+ return;
43
+ if (previous === undefined)
44
+ delete integrationTransportState.override;
45
+ else
46
+ integrationTransportState.override = previous;
47
+ };
48
+ }
@@ -0,0 +1 @@
1
+ export { setIntegrationTransportForTests as setIntegrationTransport, type IntegrationTransport, type IntegrationTransportRequest, } from "./internal/transport.js";
@@ -0,0 +1 @@
1
+ export { setIntegrationTransportForTests as setIntegrationTransport, } from "./internal/transport.js";
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@reasonlayer/integrations",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "./testkit": {
16
+ "types": "./dist/testkit.d.ts",
17
+ "import": "./dist/testkit.js"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json",
22
+ "codegen": "node scripts/generate-catalog.mjs",
23
+ "test": "vitest run",
24
+ "typecheck": "tsc -p tsconfig.json --noEmit"
25
+ }
26
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The production Convex deployment. Compiled into every consumer (CLI,
3
+ * backend) deliberately: repointing production is a reviewed code change and
4
+ * a release, never a runtime input. Dev/E2E deployments are injected via
5
+ * RL_CONVEX_URL by generated tooling and are not listed here.
6
+ */
7
+ export declare const PRODUCTION_CONVEX_URL = "https://patient-meerkat-744.convex.cloud";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The production Convex deployment. Compiled into every consumer (CLI,
3
+ * backend) deliberately: repointing production is a reviewed code change and
4
+ * a release, never a runtime input. Dev/E2E deployments are injected via
5
+ * RL_CONVEX_URL by generated tooling and are not listed here.
6
+ */
7
+ export const PRODUCTION_CONVEX_URL = "https://patient-meerkat-744.convex.cloud";
@@ -0,0 +1,313 @@
1
+ import type { HostIR, ReviewViewIR } from "./ir.js";
2
+ export type RunFinishedStatus = "succeeded" | "succeeded_with_failures" | "failed" | "canceled";
3
+ export type RunStatus = "running" | "waiting_for_review" | RunFinishedStatus;
4
+ export declare function isTerminalRunStatus(status: string): status is RunFinishedStatus;
5
+ export type RunCause = {
6
+ kind: "trigger";
7
+ trigger: string;
8
+ versionId: string;
9
+ } | {
10
+ kind: "manual";
11
+ actor: string;
12
+ versionId: string;
13
+ } | {
14
+ kind: "retry";
15
+ ofRunId: string;
16
+ actor: string;
17
+ };
18
+ export type TaskClaimant = {
19
+ kind: "sandbox" | "device" | "executor";
20
+ id: string;
21
+ };
22
+ /**
23
+ * The V2 launch vocabulary. Payloads are deliberately complete for readers;
24
+ * emitters do not reach into Review, Alerting, or Billing directly.
25
+ */
26
+ export type LifecycleEvent = {
27
+ type: "run.created";
28
+ payload: {
29
+ cause: RunCause;
30
+ input: unknown;
31
+ runKey?: string;
32
+ };
33
+ } | {
34
+ type: "run.finished";
35
+ payload: {
36
+ status: RunFinishedStatus;
37
+ error?: string;
38
+ };
39
+ } | {
40
+ type: "run.retried";
41
+ payload: {
42
+ actor: string;
43
+ };
44
+ } | {
45
+ type: "step.started";
46
+ payload: {
47
+ stepId: string;
48
+ invocationKey: string;
49
+ attempt: number;
50
+ };
51
+ } | {
52
+ type: "step.expanded";
53
+ payload: {
54
+ stepId: string;
55
+ childrenTotal: number;
56
+ };
57
+ } | {
58
+ type: "step.succeeded";
59
+ payload: {
60
+ stepId: string;
61
+ invocationKey: string;
62
+ attempt: number;
63
+ };
64
+ } | {
65
+ type: "step.failed";
66
+ payload: {
67
+ stepId: string;
68
+ invocationKey: string;
69
+ attempt: number;
70
+ error: string;
71
+ };
72
+ } | {
73
+ type: "step.skipped";
74
+ payload: {
75
+ stepId: string;
76
+ reason: string;
77
+ };
78
+ } | {
79
+ type: "step.canceled";
80
+ payload: {
81
+ stepId: string;
82
+ invocationKey: string;
83
+ scope: "run" | "step";
84
+ };
85
+ } | {
86
+ type: "task.created";
87
+ payload: {
88
+ taskId: string;
89
+ stepId: string;
90
+ invocationKey: string;
91
+ attempt: number;
92
+ host: HostIR;
93
+ };
94
+ } | {
95
+ type: "task.dispatched";
96
+ payload: {
97
+ taskId: string;
98
+ host: HostIR;
99
+ };
100
+ } | {
101
+ type: "task.spawned";
102
+ payload: {
103
+ taskId: string;
104
+ sandboxId: string;
105
+ };
106
+ } | {
107
+ type: "task.claimed";
108
+ payload: {
109
+ taskId: string;
110
+ claimant: TaskClaimant;
111
+ };
112
+ } | {
113
+ type: "task.completed";
114
+ payload: {
115
+ taskId: string;
116
+ result: "ok" | "error";
117
+ error?: string;
118
+ };
119
+ } | {
120
+ type: "task.timeout";
121
+ payload: {
122
+ taskId: string;
123
+ attempt: number;
124
+ };
125
+ } | {
126
+ type: "task.canceled";
127
+ payload: {
128
+ taskId: string;
129
+ scope: "run" | "step";
130
+ };
131
+ } | {
132
+ type: "task.redispatched";
133
+ payload: {
134
+ taskId: string;
135
+ };
136
+ } | {
137
+ type: "review.requested";
138
+ payload: {
139
+ reviewId: string;
140
+ runId: string;
141
+ stepId: string;
142
+ invocationKey: string;
143
+ attempt: number;
144
+ contentRef: {
145
+ kind: "reviewContent";
146
+ contentId: string;
147
+ } | {
148
+ kind: "approval";
149
+ approvalId: string;
150
+ };
151
+ view: ReviewViewIR;
152
+ outputSchemaJson: string;
153
+ originalContentHash: string;
154
+ deadlineAt: number;
155
+ };
156
+ } | {
157
+ type: "review.decided";
158
+ payload: {
159
+ reviewId: string;
160
+ decision: "approved" | "rejected";
161
+ actor: string;
162
+ edited: boolean;
163
+ };
164
+ } | {
165
+ type: "review.expired";
166
+ payload: {
167
+ reviewId: string;
168
+ };
169
+ } | {
170
+ type: "review.canceled";
171
+ payload: {
172
+ reviewId: string;
173
+ reason: string;
174
+ };
175
+ } | {
176
+ type: "usage.recorded";
177
+ payload: {
178
+ runId: string;
179
+ stepId: string;
180
+ invocationKey: string;
181
+ attempt: number;
182
+ model?: string;
183
+ inputTokens: number;
184
+ outputTokens: number;
185
+ costUsd: number;
186
+ };
187
+ } | {
188
+ type: "workspace.session_started";
189
+ payload: {
190
+ workflowId: string;
191
+ sessionId: string;
192
+ actor: string;
193
+ machineLabel: string;
194
+ };
195
+ } | {
196
+ type: "workspace.session_ended";
197
+ payload: {
198
+ workflowId: string;
199
+ sessionId: string;
200
+ reason: "done" | "expired";
201
+ };
202
+ } | {
203
+ type: "trigger.fired";
204
+ payload: {
205
+ workflowId: string;
206
+ trigger: string;
207
+ versionId: string;
208
+ scheduledFor: number;
209
+ runId: string;
210
+ };
211
+ } | {
212
+ type: "trigger.reconciled";
213
+ payload: {
214
+ workflowId: string;
215
+ versionId: string;
216
+ created: string[];
217
+ kept: string[];
218
+ retired: string[];
219
+ };
220
+ } | {
221
+ type: "variables.set";
222
+ payload: {
223
+ name: string;
224
+ value: unknown;
225
+ actor: string;
226
+ };
227
+ } | {
228
+ type: "variables.removed";
229
+ payload: {
230
+ name: string;
231
+ actor: string;
232
+ };
233
+ } | {
234
+ type: "version.published";
235
+ payload: {
236
+ workflowId: string;
237
+ versionId: string;
238
+ versionNumber: number;
239
+ actor: string;
240
+ cause: "publish" | "rollback";
241
+ };
242
+ };
243
+ export type LifecycleEventType = LifecycleEvent["type"];
244
+ export type LifecycleEventOf<T extends LifecycleEventType> = Extract<LifecycleEvent, {
245
+ type: T;
246
+ }>;
247
+ export declare const LIFECYCLE_EVENT_TYPES: readonly ["run.created", "run.finished", "run.retried", "step.started", "step.expanded", "step.succeeded", "step.failed", "step.skipped", "step.canceled", "task.created", "task.dispatched", "task.spawned", "task.claimed", "task.completed", "task.timeout", "task.canceled", "task.redispatched", "review.requested", "review.decided", "review.expired", "review.canceled", "usage.recorded", "workspace.session_started", "workspace.session_ended", "trigger.fired", "trigger.reconciled", "variables.set", "variables.removed", "version.published"];
248
+ /**
249
+ * The typed agent transcript model. These high-volume observations are not
250
+ * lifecycle events and remain in `agentEvents`.
251
+ */
252
+ export interface AgentStepUsage {
253
+ model?: string;
254
+ inputTokens: number;
255
+ outputTokens: number;
256
+ costUsd: number;
257
+ }
258
+ export type AgentEventLevel = "debug" | "info" | "warn" | "error";
259
+ interface AgentEventBase {
260
+ seq: number;
261
+ turnSeq?: number;
262
+ level: AgentEventLevel;
263
+ ts: number;
264
+ }
265
+ export interface AgentTurnEvent extends AgentEventBase {
266
+ type: "agent.turn";
267
+ data: {
268
+ model?: string;
269
+ text?: string;
270
+ finishReason?: string;
271
+ purpose?: "agent" | "compaction";
272
+ usage: AgentStepUsage;
273
+ };
274
+ }
275
+ export interface AgentToolEvent extends AgentEventBase {
276
+ type: "agent.tool";
277
+ data: {
278
+ toolName: string;
279
+ args?: unknown;
280
+ result?: unknown;
281
+ ok: boolean;
282
+ durationMs: number;
283
+ };
284
+ }
285
+ /** A collapsed subagent delegation (flat siblings, not a tree — named ceiling, spec §8.2). */
286
+ export interface AgentTaskEvent extends AgentEventBase {
287
+ type: "agent.task";
288
+ data: {
289
+ agent?: string;
290
+ prompt?: string;
291
+ result?: unknown;
292
+ ok: boolean;
293
+ durationMs: number;
294
+ usage: AgentStepUsage;
295
+ };
296
+ }
297
+ export interface AgentLogEvent extends AgentEventBase {
298
+ type: "agent.log";
299
+ data: {
300
+ message: string;
301
+ fields?: Record<string, unknown>;
302
+ };
303
+ }
304
+ /** Exactly one per terminally-failed step — in addition to, never instead of, the task result. */
305
+ export interface AgentErrorEvent extends AgentEventBase {
306
+ type: "agent.error";
307
+ data: {
308
+ message: string;
309
+ kind?: string;
310
+ };
311
+ }
312
+ export type AgentEvent = AgentTurnEvent | AgentToolEvent | AgentTaskEvent | AgentLogEvent | AgentErrorEvent;
313
+ export {};
@@ -0,0 +1,20 @@
1
+ const TERMINAL_RUN_STATUSES = new Set([
2
+ "succeeded",
3
+ "succeeded_with_failures",
4
+ "failed",
5
+ "canceled",
6
+ ]);
7
+ export function isTerminalRunStatus(status) {
8
+ return TERMINAL_RUN_STATUSES.has(status);
9
+ }
10
+ export const LIFECYCLE_EVENT_TYPES = [
11
+ "run.created", "run.finished", "run.retried",
12
+ "step.started", "step.expanded", "step.succeeded", "step.failed", "step.skipped", "step.canceled",
13
+ "task.created", "task.dispatched", "task.spawned", "task.claimed", "task.completed", "task.timeout", "task.canceled", "task.redispatched",
14
+ "review.requested", "review.decided", "review.expired", "review.canceled",
15
+ "usage.recorded",
16
+ "workspace.session_started", "workspace.session_ended",
17
+ "trigger.fired", "trigger.reconciled",
18
+ "variables.set", "variables.removed",
19
+ "version.published",
20
+ ];
@@ -0,0 +1,18 @@
1
+ export type { JsonSchema, SelectorIR, RetryPolicyIR, SecretRefIR, VariableIR, DeviceRefIR, LocalMcpServerIR, RemoteMcpServerIR, McpServerIR, EnvironmentFileIR, EnvironmentIR, EnvironmentStatusKind, EnvironmentMcpToolInventory, EnvironmentProvenance, EnvironmentStatus, EnvironmentDeclaration, HostIR, ReviewViewIR, CodeStepIR, AgentStepIR, ReviewStepIR, ActionStepIR, MapChildStepIR, MapStepIR, StepIR, TriggerIR, WorkflowIR, } from "./ir.js";
2
+ export { STEP_ID_PATTERN, VARIABLE_NAME_PATTERN, mapChildId, isCloudHostedStep, executableStepEnvironment, collectWorkflowEnvironments, stableJson, environmentDeclaration, canonicalEnvironmentDeclarationJson, mcpUrlEnvName, shellQuote, parseExactNpmPackage, parseExactPipPackage, executableNameFromPackageName, executableNameFromNpmSpec, executableNameFromPipSpec, firstCommandToken, declaredEnvironmentExecutables, } from "./ir.js";
3
+ export type { ParsedNpmPackage, ParsedPipPackage } from "./ir.js";
4
+ export type { TaskKind, TaskStatus, StepLocator, CodeTaskSpec, AgentTaskSpec, ActionTaskSpec, TaskSpec, TaskResult, TaskEvent, } from "./tasks.js";
5
+ export type { LifecycleEvent, LifecycleEventType, LifecycleEventOf, RunStatus, RunFinishedStatus, RunCause, TaskClaimant, AgentStepUsage, AgentEventLevel, AgentEvent, AgentTurnEvent, AgentToolEvent, AgentTaskEvent, AgentLogEvent, AgentErrorEvent, } from "./events.js";
6
+ export { LIFECYCLE_EVENT_TYPES, isTerminalRunStatus } from "./events.js";
7
+ export { evaluateSelector, getPath, referencedStepIds, usesMapItem, SelectorEvalError, } from "./selector.js";
8
+ export type { SelectorContext } from "./selector.js";
9
+ export { validateAgainstSchema } from "./validate.js";
10
+ export { collapseMapChildren, dependencyBlockers, doomedSteps, stepDependencies, isTerminalStepRunStatus, readySteps, workflowOutputBlockers, workflowOutputReady, workflowStepsComplete, expandMapStep, evaluateStepInput, evaluateWorkflowOutput, } from "./scheduling.js";
11
+ export type { DependencyBlocker, InputStep, MapChildResult, MapCollapseResult, MapExpansionItem, BlockingStepRunStatus, StepRunState, StepRunStatus, } from "./scheduling.js";
12
+ export { FN, LEASE_DEFAULT_MS, LEASE_FLOOR_MS } from "./runtime.js";
13
+ export type { FnName } from "./runtime.js";
14
+ export { ALERT_KINDS, APPROVAL_STATUSES } from "./readmodels.js";
15
+ export type { RunMode, RunTrigger, RunReadModel, RunListRow, RunStepUsageRow, RunUsageReadModel, RunInspectionStep, RunInspectionApproval, RunLifecycleEventRow, RunInspection, TranscriptEventType, TranscriptEvent, TranscriptPage, ApprovalStatus, ActorIdentity, ApprovalReadModel, WorkflowPublishState, WorkflowCompileStatus, WorkflowHealthRow, WorkflowListRow, WorkflowGroupRow, AuthoringSessionRow, WorkspaceStatus, WorkflowConsoleDetail, WorkflowVersionRow, WorkspaceBundleRow, DeploymentReadModel, LatestDeploymentRef, TriggerScheduleReadModel, WorkflowVariableRow, SecretReadModel, PlatformTokenReadModel, IntegrationConnectionState, IntegrationCatalogAction, IntegrationCatalogApp, IntegrationConnectionReadModel, AlertKind, AlertLifecycle, AlertPolicyScope, AlertMemberIdentity, AlertChainRung, AlertNotificationRow, AlertNotification, AlertReadModel, AlertPolicyReadModel, SlackIntegrationReadModel, ShellCounts, AlertSummaryRow, HomeOverview, WorkflowHealthPage, MemberRole, ActorKind, OrgActor, OrgReadModel, MemberReadModel, OrgMembershipRow, SessionReadModel, DeviceReadModel, DeviceProfileLoginState, DeviceProfileReadModel, InvitationReadModel, } from "./readmodels.js";
16
+ export { PERMISSIONS } from "./permissions.js";
17
+ export type { Permission, Scope } from "./permissions.js";
18
+ export { PRODUCTION_CONVEX_URL } from "./environments.js";
@@ -0,0 +1,9 @@
1
+ export { STEP_ID_PATTERN, VARIABLE_NAME_PATTERN, mapChildId, isCloudHostedStep, executableStepEnvironment, collectWorkflowEnvironments, stableJson, environmentDeclaration, canonicalEnvironmentDeclarationJson, mcpUrlEnvName, shellQuote, parseExactNpmPackage, parseExactPipPackage, executableNameFromPackageName, executableNameFromNpmSpec, executableNameFromPipSpec, firstCommandToken, declaredEnvironmentExecutables, } from "./ir.js";
2
+ export { LIFECYCLE_EVENT_TYPES, isTerminalRunStatus } from "./events.js";
3
+ export { evaluateSelector, getPath, referencedStepIds, usesMapItem, SelectorEvalError, } from "./selector.js";
4
+ export { validateAgainstSchema } from "./validate.js";
5
+ export { collapseMapChildren, dependencyBlockers, doomedSteps, stepDependencies, isTerminalStepRunStatus, readySteps, workflowOutputBlockers, workflowOutputReady, workflowStepsComplete, expandMapStep, evaluateStepInput, evaluateWorkflowOutput, } from "./scheduling.js";
6
+ export { FN, LEASE_DEFAULT_MS, LEASE_FLOOR_MS } from "./runtime.js";
7
+ export { ALERT_KINDS, APPROVAL_STATUSES } from "./readmodels.js";
8
+ export { PERMISSIONS } from "./permissions.js";
9
+ export { PRODUCTION_CONVEX_URL } from "./environments.js";