@relayfx/sdk 0.3.1 → 0.3.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 (64) hide show
  1. package/dist/ai.js +67 -37
  2. package/dist/http-server.js +22 -0
  3. package/dist/index-25gwk9tj.js +3423 -0
  4. package/dist/{index-3sv8mmz5.js → index-49fm2rdv.js} +23 -30
  5. package/dist/{index-c2skef55.js → index-8pa5e2yn.js} +16521 -18783
  6. package/dist/index-cphmds30.js +2852 -0
  7. package/dist/index-nb39b5ae.js +17 -0
  8. package/dist/index.js +315 -844
  9. package/dist/mysql.js +18 -18
  10. package/dist/postgres.js +724 -24
  11. package/dist/sqlite.js +57 -168
  12. package/dist/types/ai/index.d.ts +2 -1
  13. package/dist/types/ai/language-model/language-model-registration.d.ts +9 -6
  14. package/dist/types/relay/adapter-outbox.d.ts +1 -1
  15. package/dist/types/relay/ai.d.ts +34 -2
  16. package/dist/types/relay/child-fan-out-admission.d.ts +5 -0
  17. package/dist/types/relay/child-fan-out-host.d.ts +73 -0
  18. package/dist/types/relay/client-public.d.ts +481 -0
  19. package/dist/types/relay/client.d.ts +1 -478
  20. package/dist/types/relay/database-identity.d.ts +4 -0
  21. package/dist/types/relay/http-server.d.ts +95 -0
  22. package/dist/types/relay/index.d.ts +37 -14
  23. package/dist/types/relay/internal-client.d.ts +22 -0
  24. package/dist/types/relay/language-model-registration.d.ts +13 -0
  25. package/dist/types/relay/mysql.d.ts +6 -7
  26. package/dist/types/relay/operation.d.ts +4 -4
  27. package/dist/types/relay/postgres.d.ts +10 -7
  28. package/dist/types/relay/runtime-acquisition-error.d.ts +61 -0
  29. package/dist/types/relay/runtime-database-adapter.d.ts +8 -5
  30. package/dist/types/relay/runtime-database-owner.d.ts +13 -0
  31. package/dist/types/relay/runtime-database-public.d.ts +10 -0
  32. package/dist/types/relay/runtime.d.ts +77 -72
  33. package/dist/types/relay/sqlite-runtime.d.ts +5 -18
  34. package/dist/types/relay/sqlite.d.ts +4 -31
  35. package/dist/types/relay/state-version-conflict.d.ts +12 -0
  36. package/dist/types/relay/tool-runtime.d.ts +44 -0
  37. package/dist/types/relay/tool-worker.d.ts +2 -2
  38. package/dist/types/relay/workflow-definition-host.d.ts +32 -0
  39. package/dist/types/runtime/agent/agent-loop-error.d.ts +21 -0
  40. package/dist/types/runtime/agent/agent-loop-service.d.ts +6 -16
  41. package/dist/types/runtime/agent/prompt-assembler-service.d.ts +3 -3
  42. package/dist/types/runtime/cluster/execution-entity.d.ts +3 -3
  43. package/dist/types/runtime/execution/execution-service.d.ts +3 -0
  44. package/dist/types/runtime/index.d.ts +1 -0
  45. package/dist/types/runtime/model/language-model-service.d.ts +5 -12
  46. package/dist/types/runtime/model/model-hub.d.ts +27 -0
  47. package/dist/types/runtime/presence/presence-contract.d.ts +24 -0
  48. package/dist/types/runtime/presence/presence-service.d.ts +6 -24
  49. package/dist/types/runtime/runner/runner-runtime-service.d.ts +29 -13
  50. package/dist/types/runtime/session/session-store-service.d.ts +4 -1
  51. package/dist/types/runtime/tool/tool-runtime-contract.d.ts +121 -0
  52. package/dist/types/runtime/tool/tool-runtime-service.d.ts +6 -120
  53. package/dist/types/runtime/workflow/execution-workflow.d.ts +22 -24
  54. package/dist/types/schema/agent-schema.d.ts +4 -1
  55. package/dist/types/schema/execution-schema.d.ts +13 -2
  56. package/dist/types/schema/index.d.ts +1 -0
  57. package/dist/types/schema/pagination-schema.d.ts +17 -0
  58. package/dist/types/schema/shared-schema.d.ts +4 -0
  59. package/dist/types/store-sql/schema/relay-schema.d.ts +12 -12
  60. package/dist/types/store-sql/session/session-repository.d.ts +54 -11
  61. package/package.json +17 -14
  62. package/dist/index-9k4k3wq1.js +0 -2860
  63. package/dist/index-d3dme13d.js +0 -141
  64. package/dist/types/relay/database.d.ts +0 -16
@@ -0,0 +1,2852 @@
1
+ // @bun
2
+ import {
3
+ __export
4
+ } from "./index-nb39b5ae.js";
5
+
6
+ // ../schema/dist/index.js
7
+ import { Schema as Schema3 } from "effect";
8
+ import { Schema } from "effect";
9
+ import { Equal, Schema as Schema2 } from "effect";
10
+ import { dual } from "effect/Function";
11
+ import { Schema as Schema5 } from "effect";
12
+ import { JsonSchema, Schema as Schema4, SchemaRepresentation } from "effect";
13
+ import { Schema as Schema8 } from "effect";
14
+ import { Schema as Schema7 } from "effect";
15
+ import { Schema as Schema6 } from "effect";
16
+ import { Schema as Schema9 } from "effect";
17
+ import { Schema as Schema11 } from "effect";
18
+ import { Schema as Schema10 } from "effect";
19
+ import { Schema as Schema12 } from "effect";
20
+ import { Schema as Schema13 } from "effect";
21
+ import { Schema as Schema14 } from "effect";
22
+ import { Schema as Schema15 } from "effect";
23
+ import { Schema as Schema16 } from "effect";
24
+ import { Schema as Schema17 } from "effect";
25
+ import { Encoding, Schema as Schema18 } from "effect";
26
+ import { Schema as Schema19 } from "effect";
27
+ var __defProp = Object.defineProperty;
28
+ var __returnValue = (v) => v;
29
+ function __exportSetter(name, newValue) {
30
+ this[name] = __returnValue.bind(null, newValue);
31
+ }
32
+ var __export2 = (target, all) => {
33
+ for (var name in all)
34
+ __defProp(target, name, {
35
+ get: all[name],
36
+ enumerable: true,
37
+ configurable: true,
38
+ set: __exportSetter.bind(all, name)
39
+ });
40
+ };
41
+ var exports_address_schema = {};
42
+ __export2(exports_address_schema, {
43
+ RouteRegistered: () => RouteRegistered,
44
+ RouteRecord: () => RouteRecord,
45
+ RouteList: () => RouteList,
46
+ RouteKind: () => RouteKind,
47
+ Route: () => Route,
48
+ RegisterRoutePayload: () => RegisterRoutePayload
49
+ });
50
+ var exports_ids_schema = {};
51
+ __export2(exports_ids_schema, {
52
+ WorkspaceSnapshotId: () => WorkspaceSnapshotId,
53
+ WorkspaceRef: () => WorkspaceRef,
54
+ WorkspaceLeaseId: () => WorkspaceLeaseId,
55
+ WorkflowOperationId: () => WorkflowOperationId,
56
+ WorkflowDefinitionId: () => WorkflowDefinitionId,
57
+ WaitId: () => WaitId,
58
+ ToolCallId: () => ToolCallId,
59
+ ToolAttemptId: () => ToolAttemptId,
60
+ TenantId: () => TenantId,
61
+ SystemTenantId: () => SystemTenantId,
62
+ SnapshotRef: () => SnapshotRef,
63
+ SkillDefinitionId: () => SkillDefinitionId,
64
+ SessionId: () => SessionId,
65
+ SessionEntryId: () => SessionEntryId,
66
+ ScheduleId: () => ScheduleId,
67
+ MemorySubjectId: () => MemorySubjectId,
68
+ ExecutionId: () => ExecutionId,
69
+ EventId: () => EventId,
70
+ EnvelopeReadyId: () => EnvelopeReadyId,
71
+ EnvelopeId: () => EnvelopeId,
72
+ EntityKindName: () => EntityKindName,
73
+ EntityKey: () => EntityKey,
74
+ ChildFanOutId: () => ChildFanOutId,
75
+ ChildExecutionId: () => ChildExecutionId,
76
+ AgentId: () => AgentId,
77
+ AddressId: () => AddressId,
78
+ AddressBookEntryId: () => AddressBookEntryId
79
+ });
80
+ var id = (name) => {
81
+ const schema = Schema.String.check(Schema.isMinLength(1)).pipe(Schema.brand(name)).annotate({ identifier: name });
82
+ return Object.assign(schema, {
83
+ make: Schema.decodeUnknownSync(schema)
84
+ });
85
+ };
86
+ var AddressId = id("Relay.AddressId");
87
+ var TenantId = id("Relay.TenantId");
88
+ var SystemTenantId = TenantId.make("system");
89
+ var AddressBookEntryId = id("Relay.AddressBookEntryId");
90
+ var AgentId = id("Relay.AgentId");
91
+ var WorkflowDefinitionId = id("Relay.WorkflowDefinitionId");
92
+ var WorkflowOperationId = id("Relay.WorkflowOperationId");
93
+ var EntityKindName = id("Relay.EntityKindName");
94
+ var EntityKey = id("Relay.EntityKey");
95
+ var SkillDefinitionId = id("Relay.SkillDefinitionId");
96
+ var EnvelopeId = id("Relay.EnvelopeId");
97
+ var EnvelopeReadyId = id("Relay.EnvelopeReadyId");
98
+ var ExecutionId = id("Relay.ExecutionId");
99
+ var ChildExecutionId = id("Relay.ChildExecutionId");
100
+ var ChildFanOutId = id("Relay.ChildFanOutId");
101
+ var MemorySubjectId = id("Relay.MemorySubjectId");
102
+ var SessionId = id("Relay.SessionId");
103
+ var SessionEntryId = id("Relay.SessionEntryId");
104
+ var WorkspaceLeaseId = id("Relay.WorkspaceLeaseId");
105
+ var WorkspaceSnapshotId = id("Relay.WorkspaceSnapshotId");
106
+ var WorkspaceRef = id("Relay.WorkspaceRef");
107
+ var SnapshotRef = id("Relay.SnapshotRef");
108
+ var ToolCallId = id("Relay.ToolCallId");
109
+ var ToolAttemptId = id("Relay.ToolAttemptId");
110
+ var WaitId = id("Relay.WaitId");
111
+ var ScheduleId = id("Relay.ScheduleId");
112
+ var EventId = id("Relay.EventId");
113
+ var exports_shared_schema = {};
114
+ __export2(exports_shared_schema, {
115
+ canonicalValue: () => canonicalValue,
116
+ canonicalString: () => canonicalString,
117
+ canonicalEquals: () => canonicalEquals,
118
+ TimestampMillis: () => TimestampMillis,
119
+ ProtocolVersion: () => ProtocolVersion,
120
+ NonEmptyString: () => NonEmptyString,
121
+ Metadata: () => Metadata,
122
+ JsonValue: () => JsonValue
123
+ });
124
+ var ProtocolVersion = Schema2.Literal(1).annotate({ identifier: "Relay.ProtocolVersion" });
125
+ var JsonValue = Schema2.Json.annotate({ identifier: "Relay.JsonValue" });
126
+ var Metadata = Schema2.Record(Schema2.String, JsonValue).annotate({ identifier: "Relay.Metadata" });
127
+ var TimestampMillis = Schema2.Int.annotate({ identifier: "Relay.TimestampMillis" });
128
+ var NonEmptyString = Schema2.String.check(Schema2.isMinLength(1)).annotate({
129
+ identifier: "Relay.NonEmptyString"
130
+ });
131
+ var canonicalValue = (value) => {
132
+ if (Array.isArray(value))
133
+ return value.map(canonicalValue);
134
+ if (value !== null && typeof value === "object") {
135
+ return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, item]) => [key, canonicalValue(item)]));
136
+ }
137
+ return value;
138
+ };
139
+ var canonicalString = (value) => JSON.stringify(canonicalValue(value));
140
+ var canonicalEquals = dual(2, (left, right) => Equal.equals(canonicalValue(left), canonicalValue(right)));
141
+ var RouteKind = Schema3.Literals([
142
+ "local-agent",
143
+ "local-execution",
144
+ "remote-relay",
145
+ "local-adapter",
146
+ "unavailable",
147
+ "deferred-retry"
148
+ ]).annotate({ identifier: "Relay.Address.RouteKind" });
149
+ var Route = Schema3.Struct({
150
+ kind: RouteKind,
151
+ route_key: NonEmptyString,
152
+ metadata: Schema3.optionalKey(Metadata)
153
+ }).annotate({ identifier: "Relay.Address.Route" });
154
+ var RouteRecord = Schema3.Struct({
155
+ id: AddressBookEntryId,
156
+ address_id: AddressId,
157
+ route: Route,
158
+ created_at: TimestampMillis,
159
+ updated_at: TimestampMillis
160
+ }).annotate({ identifier: "Relay.Address.RouteRecord" });
161
+ var RegisterRoutePayload = Schema3.Struct({
162
+ address_id: AddressId,
163
+ route: Route
164
+ }).annotate({ identifier: "Relay.Address.RegisterRoutePayload" });
165
+ var RouteRegistered = Schema3.Struct({
166
+ record: RouteRecord
167
+ }).annotate({ identifier: "Relay.Address.RouteRegistered" });
168
+ var RouteList = Schema3.Struct({
169
+ records: Schema3.Array(RouteRecord)
170
+ }).annotate({ identifier: "Relay.Address.RouteList" });
171
+ var exports_agent_schema = {};
172
+ __export2(exports_agent_schema, {
173
+ maxTurnPolicySnapshotNodes: () => maxTurnPolicySnapshotNodes,
174
+ maxTurnPolicySnapshotDepth: () => maxTurnPolicySnapshotDepth,
175
+ define: () => define,
176
+ defaultMaxWaitTurns: () => defaultMaxWaitTurns,
177
+ defaultMaxToolTurns: () => defaultMaxToolTurns,
178
+ TurnPolicySnapshot: () => TurnPolicySnapshot,
179
+ ToolInputSchemaDigests: () => ToolInputSchemaDigests,
180
+ RegisterDefinitionPayload: () => RegisterDefinitionPayload,
181
+ PermissionRuleset: () => PermissionRuleset,
182
+ PermissionRule: () => PermissionRule,
183
+ PermissionLevel: () => PermissionLevel,
184
+ ModelSelection: () => ModelSelection,
185
+ HandoffTarget: () => HandoffTarget,
186
+ DefinitionRevisionRecord: () => DefinitionRevisionRecord,
187
+ DefinitionRevisionList: () => DefinitionRevisionList,
188
+ DefinitionRevision: () => DefinitionRevision,
189
+ DefinitionRegistered: () => DefinitionRegistered,
190
+ DefinitionRecord: () => DefinitionRecord,
191
+ DefinitionList: () => DefinitionList,
192
+ Definition: () => Definition2,
193
+ CompactionPolicy: () => CompactionPolicy,
194
+ ChildRunWorkspacePolicy: () => ChildRunWorkspacePolicy,
195
+ ChildRunPreset: () => ChildRunPreset
196
+ });
197
+ var exports_tool_schema = {};
198
+ __export2(exports_tool_schema, {
199
+ resultSchema: () => resultSchema,
200
+ parametersSchema: () => parametersSchema,
201
+ WorkerId: () => WorkerId,
202
+ RuntimeRequirement: () => RuntimeRequirement,
203
+ Result: () => Result,
204
+ PlacementKey: () => PlacementKey,
205
+ Placement: () => Placement,
206
+ Permission: () => Permission,
207
+ ExternalOutcome: () => ExternalOutcome,
208
+ Definition: () => Definition,
209
+ CallState: () => CallState,
210
+ Call: () => Call,
211
+ AttemptState: () => AttemptState
212
+ });
213
+ var Permission = Schema4.Struct({
214
+ name: NonEmptyString,
215
+ value: JsonValue,
216
+ metadata: Schema4.optionalKey(Metadata)
217
+ }).annotate({ identifier: "Relay.Tool.Permission" });
218
+ var RuntimeRequirement = Schema4.Union([
219
+ Schema4.Struct({
220
+ type: Schema4.Literal("workspace"),
221
+ mode: Schema4.Literals(["read", "write", "exec"])
222
+ })
223
+ ]).annotate({ identifier: "Relay.Tool.RuntimeRequirement" });
224
+ var PlacementKey = NonEmptyString.check(Schema4.isMaxLength(191)).annotate({
225
+ identifier: "Relay.Tool.PlacementKey"
226
+ });
227
+ var WorkerId = NonEmptyString.check(Schema4.isMaxLength(191)).annotate({
228
+ identifier: "Relay.Tool.WorkerId"
229
+ });
230
+ var Placement = Schema4.Union([
231
+ Schema4.Struct({ kind: Schema4.Literal("local") }),
232
+ Schema4.Struct({ kind: Schema4.Literal("client") }),
233
+ Schema4.Struct({ kind: Schema4.Literal("remote"), queue: PlacementKey }),
234
+ Schema4.Struct({ kind: Schema4.Literal("mcp"), server_id: PlacementKey })
235
+ ]).annotate({ identifier: "Relay.Tool.Placement" });
236
+ var ExternalOutcome = Schema4.Union([
237
+ Schema4.Struct({ kind: Schema4.Literal("success"), output: JsonValue }),
238
+ Schema4.Struct({ kind: Schema4.Literal("failure"), message: Schema4.String })
239
+ ]).annotate({ identifier: "Relay.Tool.ExternalOutcome" });
240
+ var CallState = Schema4.Literals([
241
+ "requested",
242
+ "waiting",
243
+ "running",
244
+ "submitted",
245
+ "completed",
246
+ "failed"
247
+ ]).annotate({ identifier: "Relay.Tool.CallState" });
248
+ var AttemptState = Schema4.Literals([
249
+ "running",
250
+ "completed",
251
+ "failed",
252
+ "released",
253
+ "expired",
254
+ "abandoned"
255
+ ]).annotate({ identifier: "Relay.Tool.AttemptState" });
256
+ var Definition = Schema4.Struct({
257
+ name: NonEmptyString,
258
+ description: Schema4.String,
259
+ input_schema: JsonValue,
260
+ output_schema: JsonValue,
261
+ permissions: Schema4.Array(Permission),
262
+ requirements: Schema4.optionalKey(Schema4.Array(RuntimeRequirement)),
263
+ needs_approval: Schema4.optionalKey(Schema4.Boolean),
264
+ metadata: Schema4.optionalKey(Metadata)
265
+ }).annotate({ identifier: "Relay.Tool.Definition" });
266
+ var Call = Schema4.Struct({
267
+ id: ToolCallId,
268
+ name: NonEmptyString,
269
+ input: JsonValue,
270
+ metadata: Schema4.optionalKey(Metadata)
271
+ }).annotate({ identifier: "Relay.Tool.Call" });
272
+ var Result = Schema4.Struct({
273
+ call_id: ToolCallId,
274
+ output: JsonValue,
275
+ error: Schema4.optionalKey(Schema4.String),
276
+ metadata: Schema4.optionalKey(Metadata)
277
+ }).annotate({ identifier: "Relay.Tool.Result" });
278
+ var objectInferenceKeys = [
279
+ "properties",
280
+ "required",
281
+ "additionalProperties",
282
+ "patternProperties",
283
+ "propertyNames",
284
+ "minProperties",
285
+ "maxProperties"
286
+ ];
287
+ var jsonSchemaTypes = new Set(["null", "string", "number", "integer", "boolean", "object", "array"]);
288
+ var emptyObjectSchema = { type: "object", properties: {} };
289
+ var isJsonObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
290
+ var hasObjectInferenceKey = (js) => objectInferenceKeys.some((key) => js[key] !== undefined);
291
+ var hasLiteralJsonSchemaType = (type) => typeof type === "string" && jsonSchemaTypes.has(type);
292
+ var isObjectNode = (js) => {
293
+ const type = js.type;
294
+ if (type === "object")
295
+ return true;
296
+ if (hasLiteralJsonSchemaType(type))
297
+ return false;
298
+ return hasObjectInferenceKey(js);
299
+ };
300
+ var closeObjectNodes = (js) => {
301
+ if (!isJsonObject(js))
302
+ return js;
303
+ const node = Object.keys(js).length === 0 ? emptyObjectSchema : js;
304
+ return isObjectNode(node) && node.additionalProperties === undefined ? { ...node, additionalProperties: false } : node;
305
+ };
306
+ var parametersSchema = (inputSchema) => {
307
+ try {
308
+ const schema = SchemaRepresentation.toSchema(SchemaRepresentation.fromJsonSchemaDocument(JsonSchema.fromSchemaDraft2020_12(closeObjectNodes(inputSchema)), {
309
+ onEnter: closeObjectNodes
310
+ }));
311
+ return schema.ast._tag === "Unknown" ? Schema4.Struct({}) : schema;
312
+ } catch {
313
+ return Schema4.Unknown;
314
+ }
315
+ };
316
+ var resultSchema = (outputSchema) => {
317
+ if (outputSchema === true || isJsonObject(outputSchema) && Object.keys(outputSchema).length === 0) {
318
+ return Schema4.Unknown;
319
+ }
320
+ if (outputSchema === false)
321
+ return Schema4.Never;
322
+ try {
323
+ const schema = SchemaRepresentation.toSchema(SchemaRepresentation.fromJsonSchemaDocument(JsonSchema.fromSchemaDraft2020_12(outputSchema)));
324
+ return schema.ast._tag === "Unknown" ? Schema4.Never : schema;
325
+ } catch {
326
+ return Schema4.Never;
327
+ }
328
+ };
329
+ var DefinitionRevision = Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(1)).annotate({
330
+ identifier: "Relay.Agent.DefinitionRevision"
331
+ });
332
+ var ModelSelection = Schema5.Struct({
333
+ provider: NonEmptyString,
334
+ model: NonEmptyString,
335
+ registration_key: Schema5.optionalKey(NonEmptyString),
336
+ request_options: Schema5.optionalKey(Metadata),
337
+ metadata: Schema5.optionalKey(Metadata)
338
+ }).annotate({ identifier: "Relay.Agent.ModelSelection" });
339
+ var PositiveSafeInteger = Schema5.Finite.check(Schema5.makeFilter((value) => Number.isSafeInteger(value) && value > 0 ? undefined : "must be a positive safe integer"));
340
+ var CompactionPolicy = Schema5.Struct({
341
+ context_window: PositiveSafeInteger,
342
+ reserve_tokens: PositiveSafeInteger,
343
+ keep_recent_tokens: PositiveSafeInteger,
344
+ summary_model: Schema5.optionalKey(ModelSelection)
345
+ }).check(Schema5.makeFilter((policy) => policy.reserve_tokens + policy.keep_recent_tokens < policy.context_window ? undefined : "reserve_tokens + keep_recent_tokens must be less than context_window")).annotate({ identifier: "Relay.Agent.CompactionPolicy" });
346
+ var ChildRunWorkspacePolicy = Schema5.Struct({
347
+ mode: Schema5.Literals(["share", "fork"]),
348
+ fallback: Schema5.optionalKey(Schema5.Literals(["fail", "fresh"]))
349
+ }).annotate({ identifier: "Relay.Agent.ChildRunWorkspacePolicy" });
350
+ var ChildRunPreset = Schema5.Struct({
351
+ instructions: Schema5.optionalKey(Schema5.String),
352
+ model: Schema5.optionalKey(ModelSelection),
353
+ compaction_policy: Schema5.optionalKey(CompactionPolicy),
354
+ tool_names: Schema5.optionalKey(Schema5.Array(Schema5.String)),
355
+ permissions: Schema5.optionalKey(Schema5.Array(Schema5.String)),
356
+ workspace_policy: Schema5.optionalKey(ChildRunWorkspacePolicy),
357
+ output_schema_ref: Schema5.optionalKey(Schema5.String),
358
+ metadata: Schema5.optionalKey(Metadata)
359
+ }).annotate({ identifier: "Relay.Agent.ChildRunPreset" });
360
+ var HandoffTarget = Schema5.Struct({
361
+ name: NonEmptyString,
362
+ preset_name: NonEmptyString
363
+ }).annotate({ identifier: "Relay.Agent.HandoffTarget" });
364
+ var PermissionLevel = Schema5.Literals(["allow", "deny", "ask"]).annotate({
365
+ identifier: "Relay.Agent.PermissionLevel"
366
+ });
367
+ var PermissionRule = Schema5.Struct({
368
+ pattern: NonEmptyString,
369
+ level: PermissionLevel,
370
+ reason: Schema5.optionalKey(Schema5.String)
371
+ }).annotate({ identifier: "Relay.Agent.PermissionRule" });
372
+ var PermissionRuleset = Schema5.Struct({
373
+ rules: Schema5.Array(PermissionRule),
374
+ fallback: Schema5.optionalKey(PermissionLevel)
375
+ }).annotate({ identifier: "Relay.Agent.PermissionRuleset" });
376
+ var ToolInputSchemaDigests = Schema5.Record(Schema5.String, Schema5.String).annotate({
377
+ identifier: "Relay.Agent.ToolInputSchemaDigests"
378
+ });
379
+ var ForeverTurnPolicySnapshot = Schema5.Struct({
380
+ kind: Schema5.Literals(["forever"])
381
+ });
382
+ var RecursTurnPolicySnapshot = Schema5.Struct({
383
+ kind: Schema5.Literals(["recurs"]),
384
+ count: Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(0))
385
+ });
386
+ var UntilToolCallTurnPolicySnapshot = Schema5.Struct({
387
+ kind: Schema5.Literals(["until-tool-call"]),
388
+ name: NonEmptyString
389
+ });
390
+ var maxTurnPolicySnapshotDepth = 16;
391
+ var maxTurnPolicySnapshotNodes = 64;
392
+ var turnPolicySnapshotNodeCount = Schema5.makeFilter((input) => {
393
+ let nodes = 0;
394
+ const pending = [input];
395
+ while (pending.length > 0) {
396
+ const snapshot = pending.pop();
397
+ if (snapshot === undefined)
398
+ continue;
399
+ nodes += 1;
400
+ if (nodes > maxTurnPolicySnapshotNodes) {
401
+ return `turn policy snapshot node count exceeds ${maxTurnPolicySnapshotNodes}`;
402
+ }
403
+ if (snapshot.kind === "both")
404
+ pending.push(snapshot.second, snapshot.first);
405
+ }
406
+ return;
407
+ });
408
+ var turnPolicySnapshotLeaf = Schema5.Union([
409
+ ForeverTurnPolicySnapshot,
410
+ RecursTurnPolicySnapshot,
411
+ UntilToolCallTurnPolicySnapshot
412
+ ]);
413
+ var makeTurnPolicySnapshotTree = () => {
414
+ let tree = turnPolicySnapshotLeaf;
415
+ for (let depth = 2;depth <= maxTurnPolicySnapshotDepth; depth += 1) {
416
+ const child = tree;
417
+ tree = Schema5.Union([
418
+ ForeverTurnPolicySnapshot,
419
+ RecursTurnPolicySnapshot,
420
+ UntilToolCallTurnPolicySnapshot,
421
+ Schema5.Struct({
422
+ kind: Schema5.Literals(["both"]),
423
+ first: child,
424
+ second: child
425
+ })
426
+ ]);
427
+ if (depth < maxTurnPolicySnapshotDepth) {
428
+ tree = tree.annotate({ identifier: `Relay.Agent.TurnPolicySnapshot.Depth${depth}` });
429
+ }
430
+ }
431
+ return tree;
432
+ };
433
+ var TurnPolicySnapshot = makeTurnPolicySnapshotTree().check(turnPolicySnapshotNodeCount).annotate({ identifier: "Relay.Agent.TurnPolicySnapshot" });
434
+ var defaultMaxToolTurns = Number.POSITIVE_INFINITY;
435
+ var defaultMaxWaitTurns = Number.POSITIVE_INFINITY;
436
+ var DefinitionSchema = Schema5.Struct({
437
+ name: NonEmptyString,
438
+ instructions: Schema5.optionalKey(Schema5.String),
439
+ model: ModelSelection,
440
+ tool_names: Schema5.Array(Schema5.String),
441
+ permissions: Schema5.Array(Permission),
442
+ skill_definition_ids: Schema5.optionalKey(Schema5.Array(SkillDefinitionId)),
443
+ permission_rules: Schema5.optionalKey(PermissionRuleset),
444
+ turn_policy: Schema5.optionalKey(TurnPolicySnapshot),
445
+ compaction_policy: Schema5.optionalKey(CompactionPolicy),
446
+ max_tool_turns: Schema5.optionalKey(Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(1))),
447
+ max_wait_turns: Schema5.optionalKey(Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(0))),
448
+ token_budget: Schema5.optionalKey(Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(1))),
449
+ child_run_presets: Schema5.optionalKey(Schema5.Record(Schema5.String, ChildRunPreset)),
450
+ handoff_targets: Schema5.optionalKey(Schema5.Array(HandoffTarget)),
451
+ output_schema_ref: Schema5.optionalKey(Schema5.String),
452
+ metadata: Schema5.optionalKey(Metadata)
453
+ }).annotate({ identifier: "Relay.Agent.Definition" });
454
+ var Definition2 = DefinitionSchema;
455
+ var define = (input) => ({
456
+ id: input.id,
457
+ definition: {
458
+ name: input.name,
459
+ ...input.instructions === undefined ? {} : { instructions: input.instructions },
460
+ model: input.model,
461
+ tool_names: input.tools?.map((tool) => tool.name) ?? [],
462
+ permissions: input.permissions,
463
+ ...input.skill_definition_ids === undefined ? {} : { skill_definition_ids: input.skill_definition_ids },
464
+ ...input.permission_rules === undefined ? {} : { permission_rules: input.permission_rules },
465
+ ...input.turn_policy === undefined ? {} : { turn_policy: input.turn_policy },
466
+ ...input.compaction_policy === undefined ? {} : { compaction_policy: input.compaction_policy },
467
+ ...input.max_tool_turns === undefined ? {} : { max_tool_turns: input.max_tool_turns },
468
+ ...input.max_wait_turns === undefined ? {} : { max_wait_turns: input.max_wait_turns },
469
+ ...input.token_budget === undefined ? {} : { token_budget: input.token_budget },
470
+ ...input.child_run_presets === undefined ? {} : { child_run_presets: input.child_run_presets },
471
+ ...input.handoff_targets === undefined ? {} : { handoff_targets: input.handoff_targets },
472
+ ...input.output_schema_ref === undefined ? {} : { output_schema_ref: input.output_schema_ref },
473
+ ...input.metadata === undefined ? {} : { metadata: input.metadata }
474
+ }
475
+ });
476
+ var DefinitionRecord = Schema5.Struct({
477
+ id: AgentId,
478
+ current_revision: DefinitionRevision,
479
+ definition: Definition2,
480
+ tool_input_schema_digests: Schema5.optionalKey(ToolInputSchemaDigests),
481
+ created_at: TimestampMillis,
482
+ updated_at: TimestampMillis
483
+ }).annotate({ identifier: "Relay.Agent.DefinitionRecord" });
484
+ var DefinitionRevisionRecord = Schema5.Struct({
485
+ id: AgentId,
486
+ revision: DefinitionRevision,
487
+ definition: Definition2,
488
+ tool_input_schema_digests: Schema5.optionalKey(ToolInputSchemaDigests),
489
+ created_at: TimestampMillis
490
+ }).annotate({ identifier: "Relay.Agent.DefinitionRevisionRecord" });
491
+ var RegisterDefinitionPayload = Schema5.Struct({
492
+ id: AgentId,
493
+ definition: Definition2
494
+ }).annotate({ identifier: "Relay.Agent.RegisterDefinitionPayload" });
495
+ var DefinitionRegistered = Schema5.Struct({
496
+ record: DefinitionRecord
497
+ }).annotate({ identifier: "Relay.Agent.DefinitionRegistered" });
498
+ var DefinitionList = Schema5.Struct({
499
+ records: Schema5.Array(DefinitionRecord)
500
+ }).annotate({ identifier: "Relay.Agent.DefinitionList" });
501
+ var DefinitionRevisionList = Schema5.Struct({
502
+ records: Schema5.Array(DefinitionRevisionRecord)
503
+ }).annotate({ identifier: "Relay.Agent.DefinitionRevisionList" });
504
+ var exports_child_orchestration_schema = {};
505
+ __export2(exports_child_orchestration_schema, {
506
+ MemberState: () => MemberState,
507
+ JoinPolicy: () => JoinPolicy,
508
+ FanOutState: () => FanOutState,
509
+ FanOutMember: () => FanOutMember,
510
+ FanOutDefinition: () => FanOutDefinition,
511
+ FanOutChild: () => FanOutChild,
512
+ AggregateState: () => AggregateState
513
+ });
514
+ var exports_execution_schema = {};
515
+ __export2(exports_execution_schema, {
516
+ childSessionId: () => childSessionId,
517
+ SpawnChildRunInput: () => SpawnChildRunInput,
518
+ ExecutionStatus: () => ExecutionStatus,
519
+ ExecutionEventType: () => ExecutionEventType,
520
+ ExecutionEventSequence: () => ExecutionEventSequence,
521
+ ExecutionEvent: () => ExecutionEvent,
522
+ Execution: () => Execution,
523
+ CompactionCommittedEventData: () => CompactionCommittedEventData,
524
+ ChildRunPreset: () => ChildRunPreset2,
525
+ ChildRunOverride: () => ChildRunOverride,
526
+ ChildRunContext: () => ChildRunContext,
527
+ ChildRunAccepted: () => ChildRunAccepted
528
+ });
529
+ var exports_content_schema = {};
530
+ __export2(exports_content_schema, {
531
+ text: () => text,
532
+ ToolResultPart: () => ToolResultPart,
533
+ ToolCallPart: () => ToolCallPart,
534
+ TextPart: () => TextPart,
535
+ StructuredPart: () => StructuredPart,
536
+ Part: () => Part,
537
+ BlobReferencePart: () => BlobReferencePart,
538
+ ArtifactReferencePart: () => ArtifactReferencePart
539
+ });
540
+ var TextPart = Schema6.Struct({
541
+ type: Schema6.Literal("text"),
542
+ text: Schema6.String,
543
+ provider_options: Schema6.optionalKey(Metadata),
544
+ metadata: Schema6.optionalKey(Metadata)
545
+ }).annotate({ identifier: "Relay.Content.TextPart" });
546
+ var StructuredPart = Schema6.Struct({
547
+ type: Schema6.Literal("structured"),
548
+ value: JsonValue,
549
+ schema_ref: Schema6.optionalKey(Schema6.String),
550
+ provider_options: Schema6.optionalKey(Metadata),
551
+ metadata: Schema6.optionalKey(Metadata)
552
+ }).annotate({ identifier: "Relay.Content.StructuredPart" });
553
+ var BlobReferencePart = Schema6.Struct({
554
+ type: Schema6.Literal("blob-reference"),
555
+ uri: Schema6.String,
556
+ media_type: Schema6.String,
557
+ filename: Schema6.optionalKey(Schema6.String),
558
+ provider_options: Schema6.optionalKey(Metadata),
559
+ metadata: Schema6.optionalKey(Metadata)
560
+ }).annotate({ identifier: "Relay.Content.BlobReferencePart" });
561
+ var ArtifactReferencePart = Schema6.Struct({
562
+ type: Schema6.Literal("artifact-reference"),
563
+ artifact_id: Schema6.String,
564
+ media_type: Schema6.optionalKey(Schema6.String),
565
+ provider_options: Schema6.optionalKey(Metadata),
566
+ metadata: Schema6.optionalKey(Metadata)
567
+ }).annotate({ identifier: "Relay.Content.ArtifactReferencePart" });
568
+ var ToolCallPart = Schema6.Struct({
569
+ type: Schema6.Literal("tool-call"),
570
+ call: Call,
571
+ provider_options: Schema6.optionalKey(Metadata),
572
+ metadata: Schema6.optionalKey(Metadata)
573
+ }).annotate({ identifier: "Relay.Content.ToolCallPart" });
574
+ var ToolResultPart = Schema6.Struct({
575
+ type: Schema6.Literal("tool-result"),
576
+ result: Result,
577
+ provider_options: Schema6.optionalKey(Metadata),
578
+ metadata: Schema6.optionalKey(Metadata)
579
+ }).annotate({ identifier: "Relay.Content.ToolResultPart" });
580
+ var Part = Schema6.Union([
581
+ TextPart,
582
+ StructuredPart,
583
+ BlobReferencePart,
584
+ ArtifactReferencePart,
585
+ ToolCallPart,
586
+ ToolResultPart
587
+ ]).pipe(Schema6.toTaggedUnion("type")).annotate({ identifier: "Relay.Content.Part" });
588
+ var text = (value) => ({ type: "text", text: value });
589
+ var ExecutionStatus = Schema7.Literals([
590
+ "queued",
591
+ "running",
592
+ "waiting",
593
+ "completed",
594
+ "failed",
595
+ "cancelled"
596
+ ]).annotate({ identifier: "Relay.ExecutionStatus" });
597
+ var Execution = Schema7.Struct({
598
+ id: ExecutionId,
599
+ root_address_id: AddressId,
600
+ session_id: Schema7.optionalKey(SessionId),
601
+ status: ExecutionStatus,
602
+ agent_id: Schema7.optionalKey(AgentId),
603
+ agent_revision: Schema7.optionalKey(DefinitionRevision),
604
+ agent_snapshot: Schema7.optionalKey(Definition2),
605
+ agent_tool_input_schema_digests: Schema7.optionalKey(ToolInputSchemaDigests),
606
+ metadata: Schema7.optionalKey(Metadata),
607
+ created_at: TimestampMillis,
608
+ updated_at: TimestampMillis
609
+ }).annotate({ identifier: "Relay.Execution" });
610
+ var ExecutionEventSequence = Schema7.Int.check(Schema7.isGreaterThanOrEqualTo(0)).annotate({
611
+ identifier: "Relay.ExecutionEventSequence"
612
+ });
613
+ var ChildRunContext = Schema7.Struct({
614
+ instructions: Schema7.optionalKey(Schema7.String),
615
+ model: Schema7.optionalKey(ModelSelection),
616
+ compaction_policy: Schema7.optionalKey(CompactionPolicy),
617
+ tool_names: Schema7.Array(Schema7.String),
618
+ permissions: Schema7.Array(Schema7.String),
619
+ output_schema_ref: Schema7.optionalKey(Schema7.String),
620
+ metadata: Schema7.optionalKey(Metadata)
621
+ }).annotate({ identifier: "Relay.ChildRunContext" });
622
+ var ChildRunOverride = Schema7.Struct({
623
+ instructions: Schema7.optionalKey(Schema7.String),
624
+ model: Schema7.optionalKey(ModelSelection),
625
+ compaction_policy: Schema7.optionalKey(CompactionPolicy),
626
+ tool_names: Schema7.optionalKey(Schema7.Array(Schema7.String)),
627
+ permissions: Schema7.optionalKey(Schema7.Array(Schema7.String)),
628
+ workspace_policy: Schema7.optionalKey(ChildRunWorkspacePolicy),
629
+ output_schema_ref: Schema7.optionalKey(Schema7.String),
630
+ metadata: Schema7.optionalKey(Metadata)
631
+ }).annotate({ identifier: "Relay.ChildRunOverride" });
632
+ var ChildRunPreset2 = ChildRunOverride.annotate({ identifier: "Relay.ChildRunPreset" });
633
+ var SpawnChildRunInput = Schema7.Struct({
634
+ execution_id: ExecutionId,
635
+ child_execution_id: Schema7.optionalKey(ChildExecutionId),
636
+ address_id: AddressId,
637
+ parent_context: ChildRunContext,
638
+ presets: Schema7.optionalKey(Schema7.Record(Schema7.String, ChildRunPreset2)),
639
+ preset_name: Schema7.optionalKey(NonEmptyString),
640
+ instructions: Schema7.optionalKey(Schema7.String),
641
+ model: Schema7.optionalKey(ModelSelection),
642
+ compaction_policy: Schema7.optionalKey(CompactionPolicy),
643
+ tool_names: Schema7.optionalKey(Schema7.Array(Schema7.String)),
644
+ permissions: Schema7.optionalKey(Schema7.Array(Schema7.String)),
645
+ workspace_policy: Schema7.optionalKey(ChildRunWorkspacePolicy),
646
+ output_schema_ref: Schema7.optionalKey(Schema7.String),
647
+ metadata: Schema7.optionalKey(Metadata),
648
+ input: Schema7.optionalKey(Schema7.Array(Part)),
649
+ wait: Schema7.optionalKey(Schema7.Boolean),
650
+ event_sequence: Schema7.optionalKey(ExecutionEventSequence),
651
+ created_at: Schema7.optionalKey(TimestampMillis)
652
+ }).annotate({ identifier: "Relay.SpawnChildRunInput" });
653
+ var ChildRunAccepted = Schema7.Struct({
654
+ child_execution_id: ChildExecutionId,
655
+ execution_id: ExecutionId
656
+ }).annotate({ identifier: "Relay.ChildRunAccepted" });
657
+ var childSessionId = (childExecutionId) => SessionId.make(`session:child:${childExecutionId}`);
658
+ var ExecutionEventType = Schema7.Literals([
659
+ "execution.accepted",
660
+ "execution.started",
661
+ "execution.completed",
662
+ "execution.failed",
663
+ "execution.cancelled",
664
+ "model.input.prepared",
665
+ "model.output.delta",
666
+ "model.reasoning.delta",
667
+ "model.toolcall.delta",
668
+ "model.output.completed",
669
+ "model.usage.reported",
670
+ "agent.compaction.committed",
671
+ "budget.exceeded",
672
+ "tool.call.requested",
673
+ "tool.result.received",
674
+ "tool.approval.requested",
675
+ "tool.approval.resolved",
676
+ "permission.ask.requested",
677
+ "permission.ask.resolved",
678
+ "steering.received",
679
+ "state.updated",
680
+ "state.deleted",
681
+ "inbox.enqueued",
682
+ "inbox.drained",
683
+ "entity.created",
684
+ "entity.destroyed",
685
+ "envelope.accepted",
686
+ "envelope.routed",
687
+ "envelope.ready",
688
+ "delivery.attempt",
689
+ "wait.created",
690
+ "wait.woken",
691
+ "wait.timed_out",
692
+ "wait.cancelled",
693
+ "child_run.spawned",
694
+ "child_run.event",
695
+ "child_fan_out.created",
696
+ "child_fan_out.member.admitted",
697
+ "child_fan_out.member.terminal",
698
+ "child_fan_out.terminal",
699
+ "workspace.lease.planned",
700
+ "workspace.lease.acquired",
701
+ "workspace.suspended",
702
+ "workspace.resumed",
703
+ "workspace.snapshot.created",
704
+ "workspace.lease.released",
705
+ "workspace.lease.failed"
706
+ ]).annotate({ identifier: "Relay.ExecutionEventType" });
707
+ var CompactionCommittedEventData = Schema7.Struct({
708
+ checkpoint_id: SessionEntryId,
709
+ session_id: SessionId,
710
+ summary_present: Schema7.Boolean
711
+ }).annotate({ identifier: "Relay.CompactionCommittedEventData" });
712
+ var ExecutionEvent = Schema7.Struct({
713
+ id: EventId,
714
+ execution_id: ExecutionId,
715
+ child_execution_id: Schema7.optionalKey(ChildExecutionId),
716
+ type: ExecutionEventType,
717
+ sequence: ExecutionEventSequence,
718
+ cursor: NonEmptyString,
719
+ content: Schema7.optionalKey(Schema7.Array(Part)),
720
+ data: Schema7.optionalKey(Metadata),
721
+ created_at: TimestampMillis
722
+ }).annotate({ identifier: "Relay.ExecutionEvent" });
723
+ var JoinPolicy = Schema8.Union([
724
+ Schema8.TaggedStruct("all", {}),
725
+ Schema8.TaggedStruct("first-success", {}),
726
+ Schema8.TaggedStruct("quorum", { count: Schema8.Int.check(Schema8.isGreaterThan(0)) }),
727
+ Schema8.TaggedStruct("best-effort", {})
728
+ ]).annotate({ identifier: "Relay.ChildOrchestration.JoinPolicy" });
729
+ var FanOutChild = Schema8.Struct({
730
+ child_execution_id: ChildExecutionId,
731
+ address_id: AddressId,
732
+ override: Schema8.optionalKey(ChildRunOverride),
733
+ input: Schema8.optionalKey(Schema8.Array(Part)),
734
+ metadata: Schema8.optionalKey(Metadata)
735
+ }).annotate({ identifier: "Relay.ChildOrchestration.FanOutChild" });
736
+ var FanOutDefinition = Schema8.Struct({
737
+ fan_out_id: ChildFanOutId,
738
+ parent_execution_id: ExecutionId,
739
+ children: Schema8.Array(FanOutChild).check(Schema8.isMinLength(1)),
740
+ max_concurrency: Schema8.Int.check(Schema8.isGreaterThan(0)),
741
+ join: JoinPolicy,
742
+ created_at: TimestampMillis,
743
+ metadata: Schema8.optionalKey(Metadata)
744
+ }).annotate({ identifier: "Relay.ChildOrchestration.FanOutDefinition" });
745
+ var MemberState = Schema8.Literals(["queued", "running", "completed", "failed", "cancelled"]).annotate({
746
+ identifier: "Relay.ChildOrchestration.MemberState"
747
+ });
748
+ var AggregateState = Schema8.Literals(["joining", "satisfied", "failed", "cancelled"]).annotate({
749
+ identifier: "Relay.ChildOrchestration.AggregateState"
750
+ });
751
+ var FanOutMember = Schema8.Struct({
752
+ child_execution_id: ChildExecutionId,
753
+ ordinal: Schema8.Int.check(Schema8.isGreaterThanOrEqualTo(0)),
754
+ state: MemberState,
755
+ output: Schema8.optionalKey(Schema8.Array(Part)),
756
+ error: Schema8.optionalKey(Schema8.String),
757
+ completed_at: Schema8.optionalKey(TimestampMillis)
758
+ }).annotate({ identifier: "Relay.ChildOrchestration.FanOutMember" });
759
+ var FanOutState = Schema8.Struct({
760
+ ...FanOutDefinition.fields,
761
+ state: AggregateState,
762
+ members: Schema8.Array(FanOutMember),
763
+ satisfied_at: Schema8.optionalKey(TimestampMillis),
764
+ failed_at: Schema8.optionalKey(TimestampMillis),
765
+ cancelled_at: Schema8.optionalKey(TimestampMillis)
766
+ }).annotate({ identifier: "Relay.ChildOrchestration.FanOutState" });
767
+ var exports_envelope_schema = {};
768
+ __export2(exports_envelope_schema, {
769
+ WaitMode: () => WaitMode,
770
+ Wait: () => Wait,
771
+ SendInput: () => SendInput,
772
+ EnvelopeReady: () => EnvelopeReady,
773
+ EnvelopeAccepted: () => EnvelopeAccepted,
774
+ Envelope: () => Envelope
775
+ });
776
+ var WaitMode = Schema9.Literals(["reply", "event", "until", "child"]).annotate({ identifier: "Relay.WaitMode" });
777
+ var Wait = Schema9.Struct({
778
+ mode: WaitMode,
779
+ timeout: Schema9.optionalKey(Schema9.String),
780
+ correlation_key: Schema9.optionalKey(Schema9.String),
781
+ metadata: Schema9.optionalKey(Metadata)
782
+ }).annotate({ identifier: "Relay.Wait" });
783
+ var Envelope = Schema9.Struct({
784
+ id: EnvelopeId,
785
+ execution_id: ExecutionId,
786
+ from: AddressId,
787
+ to: AddressId,
788
+ content: Schema9.Array(Part),
789
+ wait: Schema9.optionalKey(Wait),
790
+ correlation_key: Schema9.optionalKey(Schema9.String),
791
+ metadata: Schema9.optionalKey(Metadata),
792
+ created_at: TimestampMillis
793
+ }).annotate({ identifier: "Relay.Envelope" });
794
+ var SendInput = Schema9.Struct({
795
+ from: AddressId,
796
+ to: AddressId,
797
+ content: Schema9.Array(Part),
798
+ idempotency_key: Schema9.optionalKey(Schema9.String),
799
+ wait: Schema9.optionalKey(Wait),
800
+ correlation_key: Schema9.optionalKey(Schema9.String),
801
+ metadata: Schema9.optionalKey(Metadata)
802
+ }).annotate({ identifier: "Relay.SendInput" });
803
+ var EnvelopeAccepted = Schema9.Struct({
804
+ envelope_id: EnvelopeId,
805
+ execution_id: ExecutionId,
806
+ wait_id: Schema9.optionalKey(WaitId)
807
+ }).annotate({ identifier: "Relay.EnvelopeAccepted" });
808
+ var EnvelopeReady = Schema9.Struct({
809
+ id: EnvelopeReadyId,
810
+ envelope_id: EnvelopeId,
811
+ route_key: Schema9.String,
812
+ available_at: TimestampMillis,
813
+ attempt: Schema9.Int,
814
+ metadata: Schema9.optionalKey(Metadata)
815
+ }).annotate({ identifier: "Relay.EnvelopeReady" });
816
+ var exports_entity_schema = {};
817
+ __export2(exports_entity_schema, {
818
+ KindDefinition: () => KindDefinition,
819
+ InstanceStatus: () => InstanceStatus,
820
+ Instance: () => Instance
821
+ });
822
+ var exports_inbox_schema = {};
823
+ __export2(exports_inbox_schema, {
824
+ MessageSequence: () => MessageSequence,
825
+ Message: () => Message,
826
+ InboxPolicy: () => InboxPolicy
827
+ });
828
+ var MessageSequence = Schema10.Int.check(Schema10.isGreaterThanOrEqualTo(0)).annotate({
829
+ identifier: "Relay.Inbox.MessageSequence"
830
+ });
831
+ var Message = Schema10.Struct({
832
+ execution_id: ExecutionId,
833
+ sequence: MessageSequence,
834
+ from: AddressId,
835
+ envelope_id: Schema10.optionalKey(EnvelopeId),
836
+ content: Schema10.Array(Part),
837
+ reply_wait_id: Schema10.optionalKey(WaitId),
838
+ correlation_key: Schema10.optionalKey(Schema10.String),
839
+ idempotency_key: Schema10.optionalKey(Schema10.String),
840
+ drain_id: Schema10.optionalKey(Schema10.String),
841
+ consumed_at: Schema10.optionalKey(TimestampMillis),
842
+ metadata: Schema10.optionalKey(Metadata),
843
+ created_at: TimestampMillis
844
+ }).annotate({ identifier: "Relay.Inbox.Message" });
845
+ var InboxPolicy = Schema10.Struct({
846
+ drain: Schema10.Literals(["all", "one"]),
847
+ max_batch: Schema10.optionalKey(Schema10.Int.check(Schema10.isGreaterThan(0)))
848
+ }).annotate({ identifier: "Relay.Inbox.InboxPolicy" });
849
+ var KindDefinition = Schema11.Struct({
850
+ kind: EntityKindName,
851
+ agent_id: AgentId,
852
+ inbox: Schema11.optionalKey(InboxPolicy),
853
+ state_enabled: Schema11.optionalKey(Schema11.Boolean),
854
+ continue_as_new_after_turns: Schema11.optionalKey(Schema11.Int.check(Schema11.isGreaterThan(0))),
855
+ metadata: Schema11.optionalKey(Metadata)
856
+ }).annotate({ identifier: "Relay.Entity.KindDefinition" });
857
+ var InstanceStatus = Schema11.Literals(["active", "destroyed"]).annotate({
858
+ identifier: "Relay.Entity.InstanceStatus"
859
+ });
860
+ var Instance = Schema11.Struct({
861
+ kind: EntityKindName,
862
+ key: EntityKey,
863
+ address_id: AddressId,
864
+ execution_id: ExecutionId,
865
+ generation: Schema11.Int.check(Schema11.isGreaterThanOrEqualTo(0)),
866
+ status: InstanceStatus,
867
+ created_at: TimestampMillis,
868
+ destroyed_at: Schema11.optionalKey(TimestampMillis)
869
+ }).annotate({ identifier: "Relay.Entity.Instance" });
870
+ var exports_pagination_schema = {};
871
+ __export2(exports_pagination_schema, {
872
+ SessionCursorCodec: () => SessionCursorCodec,
873
+ SessionCursor: () => SessionCursor,
874
+ ExecutionCursorCodec: () => ExecutionCursorCodec,
875
+ ExecutionCursor: () => ExecutionCursor
876
+ });
877
+ var codec = (id2, identifier) => Schema12.StringFromBase64Url.pipe(Schema12.decodeTo(Schema12.fromJsonString(Schema12.Struct({
878
+ id: id2,
879
+ at: TimestampMillis
880
+ })))).annotate({ identifier });
881
+ var opaque = (schema, identifier) => Schema12.String.check(Schema12.makeFilter((value) => Schema12.decodeUnknownOption(schema)(value)._tag === "Some" ? undefined : "invalid pagination cursor")).annotate({ identifier });
882
+ var ExecutionCursorCodec = codec(ExecutionId, "Relay.Pagination.ExecutionCursorCodec");
883
+ var ExecutionCursor = opaque(ExecutionCursorCodec, "Relay.Pagination.ExecutionCursor");
884
+ var SessionCursorCodec = codec(SessionId, "Relay.Pagination.SessionCursorCodec");
885
+ var SessionCursor = opaque(SessionCursorCodec, "Relay.Pagination.SessionCursor");
886
+ var exports_presence_schema = {};
887
+ __export2(exports_presence_schema, {
888
+ View: () => View,
889
+ Scope: () => Scope,
890
+ Entry: () => Entry
891
+ });
892
+ var Scope = Schema13.Struct({
893
+ kind: Schema13.Literals(["execution", "session"]),
894
+ id: NonEmptyString
895
+ }).annotate({ identifier: "Relay.Presence.Scope" });
896
+ var Entry = Schema13.Struct({
897
+ id: NonEmptyString,
898
+ metadata: Metadata,
899
+ connected_at: TimestampMillis
900
+ }).annotate({ identifier: "Relay.Presence.Entry" });
901
+ var View = Schema13.Struct({
902
+ scope: Scope,
903
+ entries: Schema13.Array(Entry),
904
+ observed_at: TimestampMillis
905
+ }).annotate({ identifier: "Relay.Presence.View" });
906
+ var exports_schedule_schema = {};
907
+ __export2(exports_schedule_schema, {
908
+ ScheduleTargetKind: () => ScheduleTargetKind,
909
+ ScheduleState: () => ScheduleState,
910
+ ScheduleRecord: () => ScheduleRecord,
911
+ ScheduleKind: () => ScheduleKind
912
+ });
913
+ var ScheduleKind = Schema14.Literals(["once", "cron"]).annotate({ identifier: "Relay.ScheduleKind" });
914
+ var ScheduleTargetKind = Schema14.Literals(["start-execution", "wake-wait", "timeout-wait"]).annotate({
915
+ identifier: "Relay.ScheduleTargetKind"
916
+ });
917
+ var ScheduleState = Schema14.Literals(["active", "claimed", "completed", "cancelled", "failed"]).annotate({
918
+ identifier: "Relay.ScheduleState"
919
+ });
920
+ var ScheduleRecord = Schema14.Struct({
921
+ id: ScheduleId,
922
+ kind: ScheduleKind,
923
+ target_kind: ScheduleTargetKind,
924
+ address_id: Schema14.optionalKey(AddressId),
925
+ wait_id: Schema14.optionalKey(WaitId),
926
+ cron_expr: Schema14.optionalKey(NonEmptyString),
927
+ input: Schema14.optionalKey(Schema14.Array(Part)),
928
+ state: ScheduleState,
929
+ next_run_at: TimestampMillis,
930
+ attempt: Schema14.Int,
931
+ last_error: Schema14.optionalKey(Schema14.String),
932
+ metadata: Schema14.optionalKey(Metadata),
933
+ created_at: TimestampMillis,
934
+ updated_at: TimestampMillis
935
+ }).annotate({ identifier: "Relay.ScheduleRecord" });
936
+ var exports_skill_schema = {};
937
+ __export2(exports_skill_schema, {
938
+ RegisterDefinitionPayload: () => RegisterDefinitionPayload2,
939
+ Frontmatter: () => Frontmatter,
940
+ ExecutionPinRecord: () => ExecutionPinRecord,
941
+ ExecutionPinList: () => ExecutionPinList,
942
+ DefinitionRevisionRecord: () => DefinitionRevisionRecord2,
943
+ DefinitionRevisionList: () => DefinitionRevisionList2,
944
+ DefinitionRevision: () => DefinitionRevision2,
945
+ DefinitionRegistered: () => DefinitionRegistered2,
946
+ DefinitionRecord: () => DefinitionRecord2,
947
+ DefinitionList: () => DefinitionList2,
948
+ Definition: () => Definition3
949
+ });
950
+ var DefinitionRevision2 = Schema15.Int.check(Schema15.isGreaterThanOrEqualTo(1)).annotate({
951
+ identifier: "Relay.Skill.DefinitionRevision"
952
+ });
953
+ var Frontmatter = Schema15.Struct({
954
+ name: NonEmptyString,
955
+ description: Schema15.String,
956
+ when_to_use: Schema15.optionalKey(Schema15.String),
957
+ allowed_tools: Schema15.optionalKey(Schema15.Array(Schema15.String)),
958
+ disable_model_invocation: Schema15.optionalKey(Schema15.Boolean),
959
+ user_invocable: Schema15.optionalKey(Schema15.Boolean),
960
+ context_fork: Schema15.optionalKey(Schema15.Boolean),
961
+ agent: Schema15.optionalKey(Schema15.String),
962
+ model: Schema15.optionalKey(Schema15.String),
963
+ paths: Schema15.optionalKey(Schema15.Array(Schema15.String)),
964
+ metadata: Schema15.optionalKey(Metadata)
965
+ }).annotate({ identifier: "Relay.Skill.Frontmatter" });
966
+ var Definition3 = Schema15.Struct({
967
+ frontmatter: Frontmatter,
968
+ body: Schema15.String,
969
+ metadata: Schema15.optionalKey(Metadata)
970
+ }).annotate({ identifier: "Relay.Skill.Definition" });
971
+ var DefinitionRecord2 = Schema15.Struct({
972
+ id: SkillDefinitionId,
973
+ current_revision: DefinitionRevision2,
974
+ definition: Definition3,
975
+ created_at: TimestampMillis,
976
+ updated_at: TimestampMillis
977
+ }).annotate({ identifier: "Relay.Skill.DefinitionRecord" });
978
+ var DefinitionRevisionRecord2 = Schema15.Struct({
979
+ id: SkillDefinitionId,
980
+ revision: DefinitionRevision2,
981
+ definition: Definition3,
982
+ created_at: TimestampMillis
983
+ }).annotate({ identifier: "Relay.Skill.DefinitionRevisionRecord" });
984
+ var ExecutionPinRecord = Schema15.Struct({
985
+ execution_id: ExecutionId,
986
+ skill_definition_id: SkillDefinitionId,
987
+ skill_definition_revision: DefinitionRevision2,
988
+ skill_definition_snapshot: Definition3,
989
+ created_at: TimestampMillis
990
+ }).annotate({ identifier: "Relay.Skill.ExecutionPinRecord" });
991
+ var RegisterDefinitionPayload2 = Schema15.Struct({
992
+ id: SkillDefinitionId,
993
+ definition: Definition3
994
+ }).annotate({ identifier: "Relay.Skill.RegisterDefinitionPayload" });
995
+ var DefinitionRegistered2 = Schema15.Struct({
996
+ record: DefinitionRecord2
997
+ }).annotate({ identifier: "Relay.Skill.DefinitionRegistered" });
998
+ var DefinitionList2 = Schema15.Struct({
999
+ records: Schema15.Array(DefinitionRecord2)
1000
+ }).annotate({ identifier: "Relay.Skill.DefinitionList" });
1001
+ var DefinitionRevisionList2 = Schema15.Struct({
1002
+ records: Schema15.Array(DefinitionRevisionRecord2)
1003
+ }).annotate({ identifier: "Relay.Skill.DefinitionRevisionList" });
1004
+ var ExecutionPinList = Schema15.Struct({
1005
+ records: Schema15.Array(ExecutionPinRecord)
1006
+ }).annotate({ identifier: "Relay.Skill.ExecutionPinList" });
1007
+ var exports_state_schema = {};
1008
+ __export2(exports_state_schema, {
1009
+ StateVersion: () => StateVersion,
1010
+ StateUpdatedEventData: () => StateUpdatedEventData,
1011
+ StateRecordView: () => StateRecordView,
1012
+ StateKey: () => StateKey,
1013
+ StateIdempotencyKey: () => StateIdempotencyKey,
1014
+ StateDeletedEventData: () => StateDeletedEventData
1015
+ });
1016
+ var StateKey = NonEmptyString.check(Schema16.isMaxLength(191)).annotate({
1017
+ identifier: "Relay.State.StateKey"
1018
+ });
1019
+ var StateIdempotencyKey = NonEmptyString.check(Schema16.isMaxLength(191)).annotate({
1020
+ identifier: "Relay.State.StateIdempotencyKey"
1021
+ });
1022
+ var StateVersion = Schema16.Int.check(Schema16.isGreaterThanOrEqualTo(1)).annotate({
1023
+ identifier: "Relay.State.StateVersion"
1024
+ });
1025
+ var StateRecordView = Schema16.Struct({
1026
+ execution_id: ExecutionId,
1027
+ key: StateKey,
1028
+ value: JsonValue,
1029
+ version: StateVersion,
1030
+ created_at: TimestampMillis,
1031
+ updated_at: TimestampMillis
1032
+ }).annotate({ identifier: "Relay.State.StateRecordView" });
1033
+ var StateUpdatedEventData = Schema16.Union([
1034
+ Schema16.Struct({ key: StateKey, version: StateVersion, value: JsonValue }),
1035
+ Schema16.Struct({ key: StateKey, version: StateVersion, blob_ref: NonEmptyString })
1036
+ ]).annotate({ identifier: "Relay.State.StateUpdatedEventData" });
1037
+ var StateDeletedEventData = Schema16.Struct({
1038
+ key: StateKey,
1039
+ version: StateVersion
1040
+ }).annotate({ identifier: "Relay.State.StateDeletedEventData" });
1041
+ var exports_wait_schema = {};
1042
+ __export2(exports_wait_schema, {
1043
+ resolverFor: () => resolverFor,
1044
+ externallyResolvable: () => externallyResolvable,
1045
+ classify: () => classify,
1046
+ WaitKind: () => WaitKind,
1047
+ ToolPlacementWait: () => ToolPlacementWait,
1048
+ ToolApprovalWait: () => ToolApprovalWait,
1049
+ TimerWait: () => TimerWait,
1050
+ Resolver: () => Resolver,
1051
+ ReplyWait: () => ReplyWait,
1052
+ PermissionWait: () => PermissionWait,
1053
+ InboxWait: () => InboxWait,
1054
+ ExternalWait: () => ExternalWait,
1055
+ Classification: () => Classification,
1056
+ ChildJoinWait: () => ChildJoinWait
1057
+ });
1058
+ var WaitKind = Schema17.Literals([
1059
+ "permission",
1060
+ "tool_approval",
1061
+ "tool_placement",
1062
+ "child_join",
1063
+ "inbox",
1064
+ "reply",
1065
+ "timer",
1066
+ "external"
1067
+ ]).annotate({ identifier: "Relay.WaitKind" });
1068
+ var PermissionWait = Schema17.Struct({
1069
+ kind: Schema17.Literal("permission"),
1070
+ wait_id: WaitId,
1071
+ tool_call_id: ToolCallId
1072
+ }).annotate({ identifier: "Relay.PermissionWait" });
1073
+ var ToolApprovalWait = Schema17.Struct({
1074
+ kind: Schema17.Literal("tool_approval"),
1075
+ wait_id: WaitId,
1076
+ tool_call_id: ToolCallId
1077
+ }).annotate({ identifier: "Relay.ToolApprovalWait" });
1078
+ var ToolPlacementWait = Schema17.Struct({
1079
+ kind: Schema17.Literal("tool_placement"),
1080
+ wait_id: WaitId,
1081
+ tool_call_id: ToolCallId
1082
+ }).annotate({ identifier: "Relay.ToolPlacementWait" });
1083
+ var ChildJoinWait = Schema17.Struct({
1084
+ kind: Schema17.Literal("child_join"),
1085
+ wait_id: WaitId,
1086
+ child_execution_id: ChildExecutionId
1087
+ }).annotate({ identifier: "Relay.ChildJoinWait" });
1088
+ var InboxWait = Schema17.Struct({
1089
+ kind: Schema17.Literal("inbox"),
1090
+ wait_id: WaitId,
1091
+ tool_call_id: ToolCallId
1092
+ }).annotate({ identifier: "Relay.InboxWait" });
1093
+ var ReplyWait = Schema17.Struct({
1094
+ kind: Schema17.Literal("reply"),
1095
+ wait_id: WaitId,
1096
+ envelope_id: Schema17.optionalKey(EnvelopeId)
1097
+ }).annotate({ identifier: "Relay.ReplyWait" });
1098
+ var TimerWait = Schema17.Struct({
1099
+ kind: Schema17.Literal("timer"),
1100
+ wait_id: WaitId
1101
+ }).annotate({ identifier: "Relay.TimerWait" });
1102
+ var ExternalWait = Schema17.Struct({
1103
+ kind: Schema17.Literal("external"),
1104
+ wait_id: WaitId,
1105
+ mode: WaitMode
1106
+ }).annotate({ identifier: "Relay.ExternalWait" });
1107
+ var Classification = Schema17.Union([
1108
+ PermissionWait,
1109
+ ToolApprovalWait,
1110
+ ToolPlacementWait,
1111
+ ChildJoinWait,
1112
+ InboxWait,
1113
+ ReplyWait,
1114
+ TimerWait,
1115
+ ExternalWait
1116
+ ]).annotate({ identifier: "Relay.WaitClassification" });
1117
+ var suffixAfter = (waitId, namespace) => waitId.slice(namespace.length);
1118
+ var classify = (input) => {
1119
+ const waitId = input.wait_id;
1120
+ if (waitId.startsWith("wait:permission:")) {
1121
+ return {
1122
+ kind: "permission",
1123
+ wait_id: waitId,
1124
+ tool_call_id: ToolCallId.make(suffixAfter(waitId, "wait:permission:"))
1125
+ };
1126
+ }
1127
+ if (waitId.startsWith("wait:approval:")) {
1128
+ return {
1129
+ kind: "tool_approval",
1130
+ wait_id: waitId,
1131
+ tool_call_id: ToolCallId.make(suffixAfter(waitId, "wait:approval:"))
1132
+ };
1133
+ }
1134
+ if (waitId.startsWith("wait:child:")) {
1135
+ return {
1136
+ kind: "child_join",
1137
+ wait_id: waitId,
1138
+ child_execution_id: ChildExecutionId.make(suffixAfter(waitId, "wait:child:"))
1139
+ };
1140
+ }
1141
+ if (waitId.startsWith("wait:inbox:")) {
1142
+ return {
1143
+ kind: "inbox",
1144
+ wait_id: waitId,
1145
+ tool_call_id: ToolCallId.make(suffixAfter(waitId, "wait:inbox:"))
1146
+ };
1147
+ }
1148
+ if (waitId.startsWith("wait:tool:")) {
1149
+ return {
1150
+ kind: "tool_placement",
1151
+ wait_id: waitId,
1152
+ tool_call_id: ToolCallId.make(suffixAfter(waitId, "wait:tool:"))
1153
+ };
1154
+ }
1155
+ if (waitId.startsWith("wait:reply:") || input.envelope_id !== undefined && input.mode === "reply") {
1156
+ return {
1157
+ kind: "reply",
1158
+ wait_id: waitId,
1159
+ ...input.envelope_id === undefined ? {} : { envelope_id: input.envelope_id }
1160
+ };
1161
+ }
1162
+ if (input.mode === "until")
1163
+ return { kind: "timer", wait_id: waitId };
1164
+ return { kind: "external", wait_id: waitId, mode: input.mode };
1165
+ };
1166
+ var Resolver = Schema17.Literals(["resolve_permission", "resolve_tool_approval", "wake"]).annotate({
1167
+ identifier: "Relay.WaitResolver"
1168
+ });
1169
+ var resolverFor = (classification) => {
1170
+ switch (classification.kind) {
1171
+ case "permission":
1172
+ return "resolve_permission";
1173
+ case "tool_approval":
1174
+ return "resolve_tool_approval";
1175
+ case "reply":
1176
+ case "timer":
1177
+ case "external":
1178
+ return "wake";
1179
+ case "tool_placement":
1180
+ case "child_join":
1181
+ case "inbox":
1182
+ return;
1183
+ }
1184
+ };
1185
+ var externallyResolvable = (classification) => resolverFor(classification) !== undefined;
1186
+ var exports_workflow_schema = {};
1187
+ __export2(exports_workflow_schema, {
1188
+ digestDefinition: () => digestDefinition,
1189
+ canonicalDefinition: () => canonicalDefinition,
1190
+ ToolOperation: () => ToolOperation,
1191
+ TimerOperation: () => TimerOperation,
1192
+ StructuredCompletionOperation: () => StructuredCompletionOperation,
1193
+ StartRunPayload: () => StartRunPayload,
1194
+ SequenceOperation: () => SequenceOperation,
1195
+ RunStatus: () => RunStatus,
1196
+ RunRecord: () => RunRecord,
1197
+ RunPin: () => RunPin,
1198
+ RetryOperation: () => RetryOperation,
1199
+ RegisterDefinitionPayload: () => RegisterDefinitionPayload3,
1200
+ ParallelOperationV2: () => ParallelOperationV2,
1201
+ ParallelOperation: () => ParallelOperation,
1202
+ OperationV2: () => OperationV2,
1203
+ OperationStatus: () => OperationStatus,
1204
+ OperationState: () => OperationState,
1205
+ Operation: () => Operation,
1206
+ LifecycleEventType: () => LifecycleEventType,
1207
+ LifecycleEvent: () => LifecycleEvent,
1208
+ JoinOperationV2: () => JoinOperationV2,
1209
+ JoinOperation: () => JoinOperation,
1210
+ DispatchableChildOperation: () => DispatchableChildOperation,
1211
+ DefinitionV2: () => DefinitionV2,
1212
+ DefinitionV1: () => DefinitionV1,
1213
+ DefinitionRevisionRecord: () => DefinitionRevisionRecord3,
1214
+ DefinitionRevisionList: () => DefinitionRevisionList3,
1215
+ DefinitionRevision: () => DefinitionRevision3,
1216
+ DefinitionRegistered: () => DefinitionRegistered3,
1217
+ DefinitionDigest: () => DefinitionDigest,
1218
+ Definition: () => Definition4,
1219
+ CompensationOperation: () => CompensationOperation,
1220
+ ChildOperation: () => ChildOperation,
1221
+ CancellationOperation: () => CancellationOperation,
1222
+ BudgetOperation: () => BudgetOperation,
1223
+ BranchOperation: () => BranchOperation,
1224
+ ApprovalOperation: () => ApprovalOperation
1225
+ });
1226
+ var DefinitionRevision3 = Schema18.Int.check(Schema18.isGreaterThanOrEqualTo(1)).annotate({
1227
+ identifier: "Relay.WorkflowDefinitionRevision"
1228
+ });
1229
+ var DefinitionDigest = Schema18.String.check(Schema18.isPattern(/^sha256:[0-9a-f]{64}$/)).annotate({
1230
+ identifier: "Relay.WorkflowDefinitionDigest"
1231
+ });
1232
+ var OperationRef = WorkflowOperationId;
1233
+ var base = { id: WorkflowOperationId };
1234
+ var SequenceOperation = Schema18.Struct({
1235
+ ...base,
1236
+ kind: Schema18.Literal("sequence"),
1237
+ operations: Schema18.Array(OperationRef)
1238
+ });
1239
+ var ChildOperation = Schema18.Struct({
1240
+ ...base,
1241
+ kind: Schema18.Literal("child"),
1242
+ workflow_id: WorkflowDefinitionId,
1243
+ input: Schema18.optionalKey(JsonValue)
1244
+ });
1245
+ var DispatchableChildOperation = Schema18.Struct({
1246
+ ...base,
1247
+ kind: Schema18.Literal("child"),
1248
+ address_id: AddressId,
1249
+ preset_name: Schema18.optionalKey(NonEmptyString),
1250
+ input: Schema18.optionalKey(JsonValue)
1251
+ });
1252
+ var ToolOperation = Schema18.Struct({
1253
+ ...base,
1254
+ kind: Schema18.Literal("tool"),
1255
+ tool_name: NonEmptyString,
1256
+ input: Schema18.optionalKey(JsonValue)
1257
+ });
1258
+ var ApprovalOperation = Schema18.Struct({ ...base, kind: Schema18.Literal("approval"), prompt: NonEmptyString });
1259
+ var TimerOperation = Schema18.Struct({
1260
+ ...base,
1261
+ kind: Schema18.Literal("timer"),
1262
+ duration_ms: Schema18.Int.check(Schema18.isGreaterThanOrEqualTo(0))
1263
+ });
1264
+ var BranchOperation = Schema18.Struct({
1265
+ ...base,
1266
+ kind: Schema18.Literal("branch"),
1267
+ condition: NonEmptyString,
1268
+ when_true: OperationRef,
1269
+ when_false: OperationRef
1270
+ });
1271
+ var ParallelOperation = Schema18.Struct({
1272
+ ...base,
1273
+ kind: Schema18.Literal("parallel"),
1274
+ operations: Schema18.Array(OperationRef)
1275
+ });
1276
+ var JoinOperation = Schema18.Struct({
1277
+ ...base,
1278
+ kind: Schema18.Literal("join"),
1279
+ operations: Schema18.Array(OperationRef)
1280
+ });
1281
+ var ParallelOperationV2 = Schema18.Struct({
1282
+ ...base,
1283
+ kind: Schema18.Literal("parallel"),
1284
+ fan_out_key: NonEmptyString,
1285
+ operations: Schema18.Array(OperationRef).check(Schema18.isMinLength(1)),
1286
+ max_concurrency: Schema18.Int.check(Schema18.isGreaterThan(0))
1287
+ });
1288
+ var JoinOperationV2 = Schema18.Struct({
1289
+ ...base,
1290
+ kind: Schema18.Literal("join"),
1291
+ parallel_operation: OperationRef,
1292
+ members: Schema18.Array(OperationRef).check(Schema18.isMinLength(1)),
1293
+ policy: Schema18.Union([
1294
+ Schema18.TaggedStruct("all", {}),
1295
+ Schema18.TaggedStruct("first-success", {}),
1296
+ Schema18.TaggedStruct("quorum", { count: Schema18.Int.check(Schema18.isGreaterThan(0)) }),
1297
+ Schema18.TaggedStruct("best-effort", {})
1298
+ ])
1299
+ });
1300
+ var RetryOperation = Schema18.Struct({
1301
+ ...base,
1302
+ kind: Schema18.Literal("retry"),
1303
+ operation: OperationRef,
1304
+ max_attempts: Schema18.Int.check(Schema18.isGreaterThanOrEqualTo(1))
1305
+ });
1306
+ var BudgetOperation = Schema18.Struct({
1307
+ ...base,
1308
+ kind: Schema18.Literal("budget"),
1309
+ operation: OperationRef,
1310
+ limit: Schema18.Int.check(Schema18.isGreaterThanOrEqualTo(1)),
1311
+ unit: Schema18.Literals(["tokens", "milliseconds", "operations"])
1312
+ });
1313
+ var CancellationOperation = Schema18.Struct({
1314
+ ...base,
1315
+ kind: Schema18.Literal("cancellation"),
1316
+ operation: OperationRef,
1317
+ on_cancel: Schema18.optionalKey(OperationRef)
1318
+ });
1319
+ var CompensationOperation = Schema18.Struct({
1320
+ ...base,
1321
+ kind: Schema18.Literal("compensation"),
1322
+ operation: OperationRef,
1323
+ compensate_with: OperationRef
1324
+ });
1325
+ var StructuredCompletionOperation = Schema18.Struct({
1326
+ ...base,
1327
+ kind: Schema18.Literal("structured-completion"),
1328
+ schema_ref: NonEmptyString,
1329
+ value_from: OperationRef
1330
+ });
1331
+ var Operation = Schema18.Union([
1332
+ SequenceOperation,
1333
+ ChildOperation,
1334
+ ToolOperation,
1335
+ ApprovalOperation,
1336
+ TimerOperation,
1337
+ BranchOperation,
1338
+ ParallelOperation,
1339
+ JoinOperation,
1340
+ RetryOperation,
1341
+ BudgetOperation,
1342
+ CancellationOperation,
1343
+ CompensationOperation,
1344
+ StructuredCompletionOperation
1345
+ ]).annotate({ identifier: "Relay.WorkflowOperation" });
1346
+ var OperationV2 = Schema18.Union([
1347
+ SequenceOperation,
1348
+ DispatchableChildOperation,
1349
+ ToolOperation,
1350
+ ApprovalOperation,
1351
+ TimerOperation,
1352
+ BranchOperation,
1353
+ ParallelOperationV2,
1354
+ JoinOperationV2,
1355
+ RetryOperation,
1356
+ BudgetOperation,
1357
+ CancellationOperation,
1358
+ CompensationOperation,
1359
+ StructuredCompletionOperation
1360
+ ]).annotate({ identifier: "Relay.WorkflowOperationV2" });
1361
+ var references = (operation) => {
1362
+ switch (operation.kind) {
1363
+ case "sequence":
1364
+ case "parallel":
1365
+ case "join":
1366
+ return operation.operations;
1367
+ case "branch":
1368
+ return [operation.when_true, operation.when_false];
1369
+ case "retry":
1370
+ case "budget":
1371
+ return [operation.operation];
1372
+ case "cancellation":
1373
+ return operation.on_cancel === undefined ? [operation.operation] : [operation.operation, operation.on_cancel];
1374
+ case "compensation":
1375
+ return [operation.operation, operation.compensate_with];
1376
+ case "structured-completion":
1377
+ return [operation.value_from];
1378
+ case "child":
1379
+ case "tool":
1380
+ case "approval":
1381
+ case "timer":
1382
+ return [];
1383
+ }
1384
+ };
1385
+ var validGraph = Schema18.makeFilter((definition) => {
1386
+ const ids = new Set(definition.operations.map((operation) => operation.id));
1387
+ if (ids.size !== definition.operations.length)
1388
+ return "workflow operation ids must be unique";
1389
+ if (!ids.has(definition.entry_operation_id))
1390
+ return "entry_operation_id must reference an operation";
1391
+ for (const operation of definition.operations) {
1392
+ if (references(operation).some((reference) => !ids.has(reference)))
1393
+ return `operation ${operation.id} contains an unknown reference`;
1394
+ }
1395
+ return;
1396
+ });
1397
+ var referencesV2 = (operation) => {
1398
+ if (operation.kind === "join")
1399
+ return [operation.parallel_operation, ...operation.members];
1400
+ return references(operation);
1401
+ };
1402
+ var validGraphV2 = Schema18.makeFilter((definition) => {
1403
+ const operations = new Map(definition.operations.map((operation) => [operation.id, operation]));
1404
+ if (operations.size !== definition.operations.length)
1405
+ return "workflow operation ids must be unique";
1406
+ if (!operations.has(definition.entry_operation_id))
1407
+ return "entry_operation_id must reference an operation";
1408
+ const fanOutKeys = new Set;
1409
+ for (const operation of definition.operations) {
1410
+ if (referencesV2(operation).some((reference) => !operations.has(reference)))
1411
+ return `operation ${operation.id} contains an unknown reference`;
1412
+ if (operation.kind === "parallel") {
1413
+ if (fanOutKeys.has(operation.fan_out_key))
1414
+ return "parallel fan_out_key values must be unique";
1415
+ fanOutKeys.add(operation.fan_out_key);
1416
+ if (operation.operations.some((reference) => operations.get(reference)?.kind !== "child"))
1417
+ return `parallel operation ${operation.id} may reference only child operations`;
1418
+ }
1419
+ if (operation.kind === "join") {
1420
+ const parallel = operations.get(operation.parallel_operation);
1421
+ if (parallel?.kind !== "parallel")
1422
+ return `join operation ${operation.id} must reference a parallel operation`;
1423
+ if (operation.members.length !== new Set(operation.members).size || operation.members.some((member) => !parallel.operations.includes(member)))
1424
+ return `join operation ${operation.id} contains invalid member references`;
1425
+ if (operation.policy._tag === "quorum" && operation.policy.count > operation.members.length)
1426
+ return `join operation ${operation.id} quorum exceeds its member count`;
1427
+ }
1428
+ }
1429
+ return;
1430
+ });
1431
+ var DefinitionV1 = Schema18.Struct({
1432
+ version: Schema18.Literal(1),
1433
+ name: NonEmptyString,
1434
+ entry_operation_id: WorkflowOperationId,
1435
+ operations: Schema18.Array(Operation).check(Schema18.isMinLength(1)),
1436
+ metadata: Schema18.optionalKey(Metadata)
1437
+ }).check(validGraph).annotate({ identifier: "Relay.WorkflowDefinitionV1" });
1438
+ var DefinitionV2 = Schema18.Struct({
1439
+ version: Schema18.Literal(2),
1440
+ name: NonEmptyString,
1441
+ entry_operation_id: WorkflowOperationId,
1442
+ operations: Schema18.Array(OperationV2).check(Schema18.isMinLength(1)),
1443
+ metadata: Schema18.optionalKey(Metadata)
1444
+ }).check(validGraphV2).annotate({ identifier: "Relay.WorkflowDefinitionV2" });
1445
+ var Definition4 = Schema18.Union([DefinitionV1, DefinitionV2]).annotate({
1446
+ identifier: "Relay.WorkflowDefinition"
1447
+ });
1448
+ var canonicalDefinition = (definition) => canonicalString(definition);
1449
+ var sha256Constants = [
1450
+ 1116352408,
1451
+ 1899447441,
1452
+ 3049323471,
1453
+ 3921009573,
1454
+ 961987163,
1455
+ 1508970993,
1456
+ 2453635748,
1457
+ 2870763221,
1458
+ 3624381080,
1459
+ 310598401,
1460
+ 607225278,
1461
+ 1426881987,
1462
+ 1925078388,
1463
+ 2162078206,
1464
+ 2614888103,
1465
+ 3248222580,
1466
+ 3835390401,
1467
+ 4022224774,
1468
+ 264347078,
1469
+ 604807628,
1470
+ 770255983,
1471
+ 1249150122,
1472
+ 1555081692,
1473
+ 1996064986,
1474
+ 2554220882,
1475
+ 2821834349,
1476
+ 2952996808,
1477
+ 3210313671,
1478
+ 3336571891,
1479
+ 3584528711,
1480
+ 113926993,
1481
+ 338241895,
1482
+ 666307205,
1483
+ 773529912,
1484
+ 1294757372,
1485
+ 1396182291,
1486
+ 1695183700,
1487
+ 1986661051,
1488
+ 2177026350,
1489
+ 2456956037,
1490
+ 2730485921,
1491
+ 2820302411,
1492
+ 3259730800,
1493
+ 3345764771,
1494
+ 3516065817,
1495
+ 3600352804,
1496
+ 4094571909,
1497
+ 275423344,
1498
+ 430227734,
1499
+ 506948616,
1500
+ 659060556,
1501
+ 883997877,
1502
+ 958139571,
1503
+ 1322822218,
1504
+ 1537002063,
1505
+ 1747873779,
1506
+ 1955562222,
1507
+ 2024104815,
1508
+ 2227730452,
1509
+ 2361852424,
1510
+ 2428436474,
1511
+ 2756734187,
1512
+ 3204031479,
1513
+ 3329325298
1514
+ ];
1515
+ var rotateRight = (value, count) => value >>> count | value << 32 - count;
1516
+ var sha256 = (value) => {
1517
+ const encoded = Encoding.encodeHex(value);
1518
+ const bytes = Array.from({ length: encoded.length / 2 }, (_, index) => Number.parseInt(encoded.slice(index * 2, index * 2 + 2), 16));
1519
+ const bitLength = bytes.length * 8;
1520
+ bytes.push(128);
1521
+ while (bytes.length % 64 !== 56)
1522
+ bytes.push(0);
1523
+ for (let shift = 56;shift >= 0; shift -= 8)
1524
+ bytes.push(Math.floor(bitLength / 2 ** shift) & 255);
1525
+ const hash = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225];
1526
+ const words = Array.from({ length: 64 }).fill(0);
1527
+ for (let offset = 0;offset < bytes.length; offset += 64) {
1528
+ for (let index = 0;index < 16; index++) {
1529
+ const position = offset + index * 4;
1530
+ words[index] = (bytes[position] ?? 0) << 24 | (bytes[position + 1] ?? 0) << 16 | (bytes[position + 2] ?? 0) << 8 | (bytes[position + 3] ?? 0);
1531
+ }
1532
+ for (let index = 16;index < 64; index++) {
1533
+ const previous15 = words[index - 15] ?? 0;
1534
+ const previous2 = words[index - 2] ?? 0;
1535
+ const sigma0 = rotateRight(previous15, 7) ^ rotateRight(previous15, 18) ^ previous15 >>> 3;
1536
+ const sigma1 = rotateRight(previous2, 17) ^ rotateRight(previous2, 19) ^ previous2 >>> 10;
1537
+ words[index] = (words[index - 16] ?? 0) + sigma0 + (words[index - 7] ?? 0) + sigma1 | 0;
1538
+ }
1539
+ let [a, b, c, d, e, f, g, h] = hash;
1540
+ for (let index = 0;index < 64; index++) {
1541
+ const sum1 = rotateRight(e ?? 0, 6) ^ rotateRight(e ?? 0, 11) ^ rotateRight(e ?? 0, 25);
1542
+ const choice = (e ?? 0) & (f ?? 0) ^ ~(e ?? 0) & (g ?? 0);
1543
+ const temporary1 = (h ?? 0) + sum1 + choice + sha256Constants[index] + (words[index] ?? 0) | 0;
1544
+ const sum0 = rotateRight(a ?? 0, 2) ^ rotateRight(a ?? 0, 13) ^ rotateRight(a ?? 0, 22);
1545
+ const majority = (a ?? 0) & (b ?? 0) ^ (a ?? 0) & (c ?? 0) ^ (b ?? 0) & (c ?? 0);
1546
+ const temporary2 = sum0 + majority | 0;
1547
+ [a, b, c, d, e, f, g, h] = [temporary1 + temporary2, a, b, c, (d ?? 0) + temporary1, e, f, g];
1548
+ }
1549
+ [a, b, c, d, e, f, g, h].forEach((part, index) => {
1550
+ hash[index] = (hash[index] ?? 0) + (part ?? 0) | 0;
1551
+ });
1552
+ }
1553
+ return hash.map((part) => (part >>> 0).toString(16).padStart(8, "0")).join("");
1554
+ };
1555
+ var digestDefinition = (definition) => Schema18.decodeUnknownSync(DefinitionDigest)(`sha256:${sha256(canonicalDefinition(definition))}`);
1556
+ var DefinitionRevisionRecord3 = Schema18.Struct({
1557
+ id: WorkflowDefinitionId,
1558
+ revision: DefinitionRevision3,
1559
+ digest: DefinitionDigest,
1560
+ definition: Definition4,
1561
+ created_at: TimestampMillis
1562
+ }).annotate({ identifier: "Relay.WorkflowDefinitionRevisionRecord" });
1563
+ var RunPin = Schema18.Struct({
1564
+ workflow_definition_id: WorkflowDefinitionId,
1565
+ workflow_definition_revision: DefinitionRevision3,
1566
+ workflow_definition_digest: DefinitionDigest
1567
+ }).annotate({ identifier: "Relay.WorkflowRunPin" });
1568
+ var RegisterDefinitionPayload3 = Schema18.Struct({ id: WorkflowDefinitionId, definition: Definition4 });
1569
+ var DefinitionRegistered3 = Schema18.Struct({ record: DefinitionRevisionRecord3 });
1570
+ var DefinitionRevisionList3 = Schema18.Struct({ records: Schema18.Array(DefinitionRevisionRecord3) });
1571
+ var RunStatus = Schema18.Literals(["running", "completed", "failed", "cancelled"]);
1572
+ var RunRecord = Schema18.Struct({
1573
+ execution_id: ExecutionId,
1574
+ pin: RunPin,
1575
+ status: RunStatus,
1576
+ created_at: TimestampMillis,
1577
+ updated_at: TimestampMillis
1578
+ });
1579
+ var StartRunPayload = Schema18.Struct({
1580
+ execution_id: ExecutionId,
1581
+ workflow_definition_id: WorkflowDefinitionId,
1582
+ revision: Schema18.optionalKey(DefinitionRevision3)
1583
+ });
1584
+ var OperationStatus = Schema18.Literals([
1585
+ "pending",
1586
+ "started",
1587
+ "waiting",
1588
+ "completed",
1589
+ "failed",
1590
+ "compensating",
1591
+ "compensated"
1592
+ ]);
1593
+ var OperationState = Schema18.Struct({
1594
+ execution_id: ExecutionId,
1595
+ operation_id: WorkflowOperationId,
1596
+ status: OperationStatus,
1597
+ fan_out_id: Schema18.optionalKey(ChildFanOutId),
1598
+ decision: Schema18.optionalKey(Schema18.Boolean),
1599
+ output: Schema18.optionalKey(JsonValue),
1600
+ attempt: Schema18.optionalKey(Schema18.Int.check(Schema18.isGreaterThanOrEqualTo(0))),
1601
+ backoff_until: Schema18.optionalKey(TimestampMillis),
1602
+ compensation_operation_id: Schema18.optionalKey(WorkflowOperationId),
1603
+ started_at: Schema18.optionalKey(TimestampMillis),
1604
+ completed_at: Schema18.optionalKey(TimestampMillis),
1605
+ updated_at: TimestampMillis
1606
+ });
1607
+ var LifecycleEventType = Schema18.Literals([
1608
+ "workflow.started",
1609
+ "operation.started",
1610
+ "operation.waiting",
1611
+ "operation.completed",
1612
+ "operation.failed",
1613
+ "operation.retry_scheduled",
1614
+ "operation.budget_exhausted",
1615
+ "operation.cancelled",
1616
+ "compensation.recorded",
1617
+ "compensation.started",
1618
+ "compensation.completed",
1619
+ "workflow.cancelled",
1620
+ "workflow.completed",
1621
+ "workflow.failed"
1622
+ ]);
1623
+ var LifecycleEvent = Schema18.Struct({
1624
+ execution_id: ExecutionId,
1625
+ sequence: Schema18.Int.check(Schema18.isGreaterThanOrEqualTo(1)),
1626
+ type: LifecycleEventType,
1627
+ operation_id: Schema18.optionalKey(WorkflowOperationId),
1628
+ data: Schema18.optionalKey(JsonValue),
1629
+ created_at: TimestampMillis
1630
+ });
1631
+ var exports_workspace_schema = {};
1632
+ __export2(exports_workspace_schema, {
1633
+ WorkspaceSnapshotRecord: () => WorkspaceSnapshotRecord,
1634
+ WorkspaceSnapshotReason: () => WorkspaceSnapshotReason,
1635
+ WorkspaceResumeStrategy: () => WorkspaceResumeStrategy,
1636
+ WorkspaceRequest: () => WorkspaceRequest,
1637
+ WorkspaceProviderKey: () => WorkspaceProviderKey,
1638
+ WorkspaceLeaseStatus: () => WorkspaceLeaseStatus,
1639
+ WorkspaceLeaseRecord: () => WorkspaceLeaseRecord,
1640
+ WorkspaceCapabilities: () => WorkspaceCapabilities
1641
+ });
1642
+ var WorkspaceProviderKey = NonEmptyString.annotate({ identifier: "Relay.WorkspaceProviderKey" });
1643
+ var WorkspaceLeaseStatus = Schema19.Literals([
1644
+ "planned",
1645
+ "running",
1646
+ "suspended",
1647
+ "snapshotted",
1648
+ "archived",
1649
+ "released",
1650
+ "failed"
1651
+ ]).annotate({ identifier: "Relay.WorkspaceLeaseStatus" });
1652
+ var WorkspaceResumeStrategy = Schema19.Literals(["reattach", "restore_snapshot"]).annotate({
1653
+ identifier: "Relay.WorkspaceResumeStrategy"
1654
+ });
1655
+ var WorkspaceCapabilities = Schema19.Struct({
1656
+ can_suspend: Schema19.Boolean,
1657
+ can_snapshot: Schema19.Boolean,
1658
+ can_fork: Schema19.Boolean,
1659
+ persistent_by_default: Schema19.Boolean,
1660
+ suspend_granularity: Schema19.Literals(["memory", "filesystem", "none"]),
1661
+ max_suspend_duration_ms: Schema19.optionalKey(Schema19.Finite),
1662
+ reattach_by_ref: Schema19.Boolean
1663
+ }).annotate({ identifier: "Relay.WorkspaceCapabilities" });
1664
+ var WorkspaceRequest = Schema19.Struct({
1665
+ provider_key: Schema19.optionalKey(WorkspaceProviderKey),
1666
+ resume_snapshot_ref: Schema19.optionalKey(SnapshotRef),
1667
+ metadata: Schema19.optionalKey(Metadata)
1668
+ }).annotate({ identifier: "Relay.WorkspaceRequest" });
1669
+ var WorkspaceLeaseRecord = Schema19.Struct({
1670
+ id: WorkspaceLeaseId,
1671
+ execution_id: ExecutionId,
1672
+ provider_key: WorkspaceProviderKey,
1673
+ sandbox_ref: Schema19.optionalKey(WorkspaceRef),
1674
+ latest_snapshot_ref: Schema19.optionalKey(SnapshotRef),
1675
+ status: WorkspaceLeaseStatus,
1676
+ resume_strategy: WorkspaceResumeStrategy,
1677
+ region: Schema19.optionalKey(NonEmptyString),
1678
+ request: Schema19.optionalKey(WorkspaceRequest),
1679
+ metadata: Schema19.optionalKey(Metadata),
1680
+ created_at: TimestampMillis,
1681
+ updated_at: TimestampMillis
1682
+ }).annotate({ identifier: "Relay.WorkspaceLeaseRecord" });
1683
+ var WorkspaceSnapshotReason = Schema19.Literals([
1684
+ "before_wait",
1685
+ "before_child_fork",
1686
+ "on_complete",
1687
+ "on_failure",
1688
+ "manual"
1689
+ ]).annotate({ identifier: "Relay.WorkspaceSnapshotReason" });
1690
+ var WorkspaceSnapshotRecord = Schema19.Struct({
1691
+ id: WorkspaceSnapshotId,
1692
+ lease_id: WorkspaceLeaseId,
1693
+ execution_id: ExecutionId,
1694
+ reason: WorkspaceSnapshotReason,
1695
+ snapshot_ref: SnapshotRef,
1696
+ metadata: Schema19.optionalKey(Metadata),
1697
+ created_at: TimestampMillis
1698
+ }).annotate({ identifier: "Relay.WorkspaceSnapshotRecord" });
1699
+
1700
+ // src/state-version-conflict.ts
1701
+ import { Schema as Schema20 } from "effect";
1702
+ var NonNegativeStateVersion = Schema20.Int.check(Schema20.isGreaterThanOrEqualTo(0));
1703
+
1704
+ class StateVersionConflict extends Schema20.TaggedErrorClass()("StateVersionConflict", {
1705
+ execution_id: exports_ids_schema.ExecutionId,
1706
+ key: exports_state_schema.StateKey,
1707
+ expected_version: NonNegativeStateVersion,
1708
+ actual_version: NonNegativeStateVersion
1709
+ }) {
1710
+ }
1711
+
1712
+ // src/operation.ts
1713
+ var exports_operation = {};
1714
+ __export(exports_operation, {
1715
+ WatchExecutionsInput: () => WatchExecutionsInput,
1716
+ WakeInput: () => WakeInput,
1717
+ WakeAccepted: () => WakeAccepted,
1718
+ WaitView: () => WaitView,
1719
+ WaitTerminalState: () => WaitTerminalState,
1720
+ WaitState: () => WaitState,
1721
+ WaitOutcome: () => WaitOutcome,
1722
+ UnsubscribeTopicInput: () => UnsubscribeTopicInput,
1723
+ TopicSubscription: () => TopicSubscription,
1724
+ TopicPublishAccepted: () => TopicPublishAccepted,
1725
+ ToolWorkReleased: () => ToolWorkReleased,
1726
+ ToolWorkLease: () => ToolWorkLease,
1727
+ ToolOutcomeAccepted: () => ToolOutcomeAccepted,
1728
+ ToolCallSummary: () => ToolCallSummary,
1729
+ ToolAttemptList: () => ToolAttemptList,
1730
+ ToolAttempt: () => ToolAttempt,
1731
+ SubscribeTopicInput: () => SubscribeTopicInput,
1732
+ SubmitInboundEnvelopeInput: () => SubmitInboundEnvelopeInput,
1733
+ SubmitInboundEnvelopeAccepted: () => SubmitInboundEnvelopeAccepted,
1734
+ StreamSessionInput: () => StreamSessionInput,
1735
+ StreamExecutionInput: () => StreamExecutionInput,
1736
+ SteeringKind: () => SteeringKind,
1737
+ SteerInput: () => SteerInput,
1738
+ SteerAccepted: () => SteerAccepted,
1739
+ StartExecutionResult: () => StartExecutionResult,
1740
+ StartExecutionInput: () => StartExecutionInput,
1741
+ SpawnChildRunInput: () => SpawnChildRunInput2,
1742
+ SessionSummary: () => SessionSummary,
1743
+ SessionStreamItem: () => SessionStreamItem,
1744
+ RunnerSummary: () => RunnerSummary,
1745
+ RouteExecutionResult: () => RouteExecutionResult,
1746
+ ResolveToolApprovalInput: () => ResolveToolApprovalInput,
1747
+ ResolvePermissionInput: () => ResolvePermissionInput,
1748
+ ReplayExecutionResult: () => ReplayExecutionResult,
1749
+ ReplayExecutionInput: () => ReplayExecutionInput,
1750
+ ReleaseToolWorkInput: () => ReleaseToolWorkInput,
1751
+ ReleaseEnvelopeReadyInput: () => ReleaseEnvelopeReadyInput,
1752
+ PutEntityStateInput: () => PutEntityStateInput,
1753
+ PublishTopicInput: () => PublishTopicInput,
1754
+ PermissionAnswer: () => PermissionAnswer,
1755
+ PendingToolCallList: () => PendingToolCallList,
1756
+ PendingToolCall: () => PendingToolCall,
1757
+ PendingToolApprovalList: () => PendingToolApprovalList,
1758
+ PendingToolApproval: () => PendingToolApproval,
1759
+ PageExecutionEventsResult: () => PageExecutionEventsResult,
1760
+ PageExecutionEventsInput: () => PageExecutionEventsInput,
1761
+ ListWaitsInput: () => ListWaitsInput,
1762
+ ListTopicSubscriptionsInput: () => ListTopicSubscriptionsInput,
1763
+ ListToolAttemptsInput: () => ListToolAttemptsInput,
1764
+ ListSessionsResult: () => ListSessionsResult,
1765
+ ListSessionsInput: () => ListSessionsInput,
1766
+ ListSchedulesResult: () => ListSchedulesResult,
1767
+ ListSchedulesInput: () => ListSchedulesInput,
1768
+ ListRunnersResult: () => ListRunnersResult,
1769
+ ListPendingToolCallsInput: () => ListPendingToolCallsInput,
1770
+ ListPendingApprovalsInput: () => ListPendingApprovalsInput,
1771
+ ListInboxMessagesInput: () => ListInboxMessagesInput,
1772
+ ListExecutionsResult: () => ListExecutionsResult,
1773
+ ListExecutionsInput: () => ListExecutionsInput,
1774
+ ListEntityStateInput: () => ListEntityStateInput,
1775
+ ListEntitiesInput: () => ListEntitiesInput,
1776
+ InspectChildFanOutResult: () => InspectChildFanOutResult,
1777
+ InspectChildFanOutInput: () => InspectChildFanOutInput,
1778
+ GetSessionResult: () => GetSessionResult,
1779
+ GetSessionInput: () => GetSessionInput,
1780
+ GetOrCreateEntityInput: () => GetOrCreateEntityInput,
1781
+ GetEntityStateInput: () => GetEntityStateInput,
1782
+ GetEntityInput: () => GetEntityInput,
1783
+ FulfillToolCallInput: () => FulfillToolCallInput,
1784
+ FollowStopReason: () => FollowStopReason,
1785
+ FollowExecutionItem: () => FollowExecutionItem,
1786
+ FollowExecutionInput: () => FollowExecutionInput,
1787
+ ExecutionListChange: () => ExecutionListChange,
1788
+ ExecutionInspection: () => ExecutionInspection,
1789
+ ExecutionEventPageDirection: () => ExecutionEventPageDirection,
1790
+ ExecutionCursor: () => ExecutionCursor2,
1791
+ EventLogCursorNotFound: () => EventLogCursorNotFound,
1792
+ EnvelopeReadyReleased: () => EnvelopeReadyReleased,
1793
+ EnvelopeReadyLease: () => EnvelopeReadyLease,
1794
+ EnvelopeReadyAcked: () => EnvelopeReadyAcked,
1795
+ EntityInstance: () => EntityInstance,
1796
+ DestroyEntityInput: () => DestroyEntityInput,
1797
+ DeleteEntityStateInput: () => DeleteEntityStateInput,
1798
+ CreateScheduleResult: () => CreateScheduleResult,
1799
+ CreateScheduleInput: () => CreateScheduleInput,
1800
+ CreateChildFanOutInput: () => CreateChildFanOutInput,
1801
+ ConversationSummary: () => ConversationSummary,
1802
+ ConversationKind: () => ConversationKind,
1803
+ CompleteToolWorkInput: () => CompleteToolWorkInput,
1804
+ ClaimToolWorkInput: () => ClaimToolWorkInput,
1805
+ ClaimEnvelopeReadyInput: () => ClaimEnvelopeReadyInput,
1806
+ ChildRunSummary: () => ChildRunSummary,
1807
+ CancelScheduleResult: () => CancelScheduleResult,
1808
+ CancelScheduleInput: () => CancelScheduleInput,
1809
+ CancelExecutionInput: () => CancelExecutionInput,
1810
+ CancelExecutionAccepted: () => CancelExecutionAccepted,
1811
+ CancelChildFanOutResult: () => CancelChildFanOutResult,
1812
+ CancelChildFanOutInput: () => CancelChildFanOutInput,
1813
+ AwaitWaitInput: () => AwaitWaitInput,
1814
+ AckEnvelopeReadyInput: () => AckEnvelopeReadyInput
1815
+ });
1816
+ import { Schema as Schema22 } from "effect";
1817
+ var StartExecutionInput = Schema22.Struct({
1818
+ execution_id: exports_ids_schema.ExecutionId,
1819
+ root_address_id: exports_ids_schema.AddressId,
1820
+ session_id: Schema22.optionalKey(exports_ids_schema.SessionId),
1821
+ input: Schema22.optionalKey(Schema22.Array(exports_content_schema.Part)),
1822
+ event_sequence: exports_execution_schema.ExecutionEventSequence,
1823
+ started_at: exports_shared_schema.TimestampMillis,
1824
+ completed_at: exports_shared_schema.TimestampMillis,
1825
+ agent_id: Schema22.optionalKey(exports_ids_schema.AgentId),
1826
+ agent_revision: Schema22.optionalKey(exports_agent_schema.DefinitionRevision),
1827
+ agent_snapshot: Schema22.optionalKey(exports_agent_schema.Definition),
1828
+ agent_tool_input_schema_digests: Schema22.optionalKey(exports_agent_schema.ToolInputSchemaDigests),
1829
+ wait_id: Schema22.optionalKey(exports_ids_schema.WaitId),
1830
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata)
1831
+ }).annotate({ identifier: "Relay.Operation.StartExecutionInput" });
1832
+ var StartExecutionResult = Schema22.Struct({
1833
+ execution_id: exports_ids_schema.ExecutionId,
1834
+ status: exports_execution_schema.ExecutionStatus,
1835
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata)
1836
+ }).annotate({ identifier: "Relay.Operation.StartExecutionResult" });
1837
+ var GetOrCreateEntityInput = Schema22.Struct({
1838
+ kind: exports_ids_schema.EntityKindName,
1839
+ key: exports_ids_schema.EntityKey,
1840
+ input: Schema22.optionalKey(Schema22.Array(exports_content_schema.Part)),
1841
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata),
1842
+ created_at: exports_shared_schema.TimestampMillis
1843
+ }).annotate({ identifier: "Relay.Operation.GetOrCreateEntityInput" });
1844
+ var GetEntityInput = Schema22.Struct({ kind: exports_ids_schema.EntityKindName, key: exports_ids_schema.EntityKey }).annotate({
1845
+ identifier: "Relay.Operation.GetEntityInput"
1846
+ });
1847
+ var DestroyEntityInput = Schema22.Struct({
1848
+ kind: exports_ids_schema.EntityKindName,
1849
+ key: exports_ids_schema.EntityKey,
1850
+ reason: Schema22.optionalKey(Schema22.String),
1851
+ destroyed_at: exports_shared_schema.TimestampMillis
1852
+ }).annotate({ identifier: "Relay.Operation.DestroyEntityInput" });
1853
+ var ListEntitiesInput = Schema22.Struct({
1854
+ kind: Schema22.optionalKey(exports_ids_schema.EntityKindName),
1855
+ after_kind: Schema22.optionalKey(exports_ids_schema.EntityKindName),
1856
+ after_key: Schema22.optionalKey(Schema22.String),
1857
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0)))
1858
+ }).annotate({ identifier: "Relay.Operation.ListEntitiesInput" });
1859
+ var EntityInstance = exports_entity_schema.Instance;
1860
+ var StreamExecutionInput = Schema22.Struct({
1861
+ execution_id: exports_execution_schema.Execution.fields.id,
1862
+ after_cursor: Schema22.optionalKey(exports_shared_schema.NonEmptyString),
1863
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0)))
1864
+ }).annotate({ identifier: "Relay.Operation.StreamExecutionInput" });
1865
+ var GetEntityStateInput = Schema22.Struct({ execution_id: exports_ids_schema.ExecutionId, key: exports_state_schema.StateKey }).annotate({
1866
+ identifier: "Relay.Operation.GetEntityStateInput"
1867
+ });
1868
+ var PutEntityStateInput = Schema22.Struct({
1869
+ execution_id: exports_ids_schema.ExecutionId,
1870
+ key: exports_state_schema.StateKey,
1871
+ value: exports_shared_schema.JsonValue,
1872
+ expected_version: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThanOrEqualTo(0))),
1873
+ idempotency_key: Schema22.optionalKey(exports_state_schema.StateIdempotencyKey.check(Schema22.makeFilter((value) => !value.startsWith("relay:internal:")))),
1874
+ updated_at: exports_shared_schema.TimestampMillis
1875
+ }).annotate({ identifier: "Relay.Operation.PutEntityStateInput" });
1876
+ var DeleteEntityStateInput = Schema22.Struct({
1877
+ execution_id: exports_ids_schema.ExecutionId,
1878
+ key: exports_state_schema.StateKey,
1879
+ expected_version: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThanOrEqualTo(0))),
1880
+ idempotency_key: Schema22.optionalKey(exports_state_schema.StateIdempotencyKey.check(Schema22.makeFilter((value) => !value.startsWith("relay:internal:")))),
1881
+ removed_at: exports_shared_schema.TimestampMillis
1882
+ }).annotate({ identifier: "Relay.Operation.DeleteEntityStateInput" });
1883
+ var ListEntityStateInput = Schema22.Struct({
1884
+ execution_id: exports_ids_schema.ExecutionId,
1885
+ prefix: Schema22.optionalKey(Schema22.String),
1886
+ after_key: Schema22.optionalKey(Schema22.String),
1887
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0)))
1888
+ }).annotate({ identifier: "Relay.Operation.ListEntityStateInput" });
1889
+ var WaitTerminalState = Schema22.Literals(["resolved", "timed_out", "cancelled"]).annotate({
1890
+ identifier: "Relay.Operation.WaitTerminalState"
1891
+ });
1892
+ var AwaitWaitInput = Schema22.Struct({
1893
+ wait_id: exports_ids_schema.WaitId,
1894
+ execution_id: exports_ids_schema.ExecutionId
1895
+ }).annotate({ identifier: "Relay.Operation.AwaitWaitInput" });
1896
+ var WaitOutcome = Schema22.Struct({
1897
+ wait_id: exports_ids_schema.WaitId,
1898
+ state: WaitTerminalState,
1899
+ content: Schema22.optionalKey(Schema22.Array(exports_content_schema.Part)),
1900
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata)
1901
+ }).annotate({ identifier: "Relay.Operation.WaitOutcome" });
1902
+ var CancelExecutionInput = Schema22.Struct({
1903
+ execution_id: exports_ids_schema.ExecutionId,
1904
+ cancelled_at: exports_shared_schema.TimestampMillis,
1905
+ reason: Schema22.optionalKey(Schema22.String)
1906
+ }).annotate({ identifier: "Relay.Operation.CancelExecutionInput" });
1907
+ var CancelExecutionAccepted = Schema22.Struct({
1908
+ execution_id: exports_ids_schema.ExecutionId,
1909
+ status: exports_execution_schema.ExecutionStatus
1910
+ }).annotate({ identifier: "Relay.Operation.CancelExecutionAccepted" });
1911
+ var SteeringKind = Schema22.Literals(["steering", "follow_up"]).annotate({
1912
+ identifier: "Relay.Operation.SteeringKind"
1913
+ });
1914
+ var SteerInput = Schema22.Struct({
1915
+ execution_id: exports_ids_schema.ExecutionId,
1916
+ kind: SteeringKind,
1917
+ content: Schema22.Array(exports_content_schema.Part),
1918
+ created_at: exports_shared_schema.TimestampMillis
1919
+ }).annotate({ identifier: "Relay.Operation.SteerInput" });
1920
+ var SteerAccepted = Schema22.Struct({
1921
+ execution_id: exports_ids_schema.ExecutionId,
1922
+ kind: SteeringKind,
1923
+ sequence: Schema22.Int.check(Schema22.isGreaterThanOrEqualTo(0))
1924
+ }).annotate({ identifier: "Relay.Operation.SteerAccepted" });
1925
+ var WakeInput = Schema22.Struct({
1926
+ wait_id: exports_ids_schema.WaitId,
1927
+ state: WaitTerminalState,
1928
+ signaled_at: exports_shared_schema.TimestampMillis,
1929
+ from: Schema22.optionalKey(exports_ids_schema.AddressId),
1930
+ content: Schema22.optionalKey(Schema22.Array(exports_content_schema.Part)),
1931
+ correlation_key: Schema22.optionalKey(Schema22.String),
1932
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata)
1933
+ }).annotate({ identifier: "Relay.Operation.WakeInput" });
1934
+ var WakeAccepted = Schema22.Struct({
1935
+ wait_id: exports_ids_schema.WaitId,
1936
+ state: WaitTerminalState,
1937
+ signaled_at: exports_shared_schema.TimestampMillis
1938
+ }).annotate({ identifier: "Relay.Operation.WakeAccepted" });
1939
+ var WaitState = Schema22.Literals(["open", "resolved", "timed_out", "cancelled"]).annotate({
1940
+ identifier: "Relay.Operation.WaitState"
1941
+ });
1942
+ var ListWaitsInput = Schema22.Struct({
1943
+ state: Schema22.optionalKey(WaitState),
1944
+ execution_id: Schema22.optionalKey(exports_ids_schema.ExecutionId),
1945
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0)))
1946
+ }).annotate({ identifier: "Relay.Operation.ListWaitsInput" });
1947
+ var WaitView = Schema22.Struct({
1948
+ wait_id: exports_ids_schema.WaitId,
1949
+ execution_id: exports_ids_schema.ExecutionId,
1950
+ envelope_id: Schema22.optionalKey(exports_ids_schema.EnvelopeId),
1951
+ kind: Schema22.optionalKey(exports_wait_schema.WaitKind),
1952
+ mode: exports_envelope_schema.WaitMode,
1953
+ correlation_key: Schema22.optionalKey(Schema22.String),
1954
+ state: WaitState,
1955
+ metadata: exports_shared_schema.Metadata,
1956
+ created_at: exports_shared_schema.TimestampMillis,
1957
+ resolved_at: Schema22.optionalKey(exports_shared_schema.TimestampMillis)
1958
+ }).annotate({ identifier: "Relay.Operation.WaitView" });
1959
+ var FollowStopReason = Schema22.Union([
1960
+ Schema22.Struct({ _tag: Schema22.tag("terminal"), status: exports_execution_schema.ExecutionStatus }),
1961
+ Schema22.Struct({ _tag: Schema22.tag("actionable_wait"), wait: WaitView })
1962
+ ]).annotate({ identifier: "Relay.Operation.FollowStopReason" });
1963
+ var FollowExecutionItem = Schema22.Union([
1964
+ Schema22.Struct({ _tag: Schema22.tag("event"), event: exports_execution_schema.ExecutionEvent }),
1965
+ Schema22.Struct({ _tag: Schema22.tag("reconnecting"), message: Schema22.String, attempt: Schema22.Int }),
1966
+ Schema22.Struct({
1967
+ _tag: Schema22.tag("stopped"),
1968
+ reason: FollowStopReason,
1969
+ cursor: Schema22.NullOr(exports_shared_schema.NonEmptyString)
1970
+ })
1971
+ ]).annotate({ identifier: "Relay.Operation.FollowExecutionItem" });
1972
+ var FollowExecutionInput = Schema22.Struct({
1973
+ execution_id: exports_ids_schema.ExecutionId,
1974
+ after_cursor: Schema22.optionalKey(exports_shared_schema.NonEmptyString),
1975
+ stop_on_wait_modes: Schema22.optionalKey(Schema22.Array(exports_envelope_schema.WaitMode)),
1976
+ max_reconnects: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThanOrEqualTo(0)))
1977
+ }).annotate({ identifier: "Relay.Operation.FollowExecutionInput" });
1978
+ var PendingToolApproval = Schema22.Struct({
1979
+ wait_id: exports_ids_schema.WaitId,
1980
+ execution_id: exports_ids_schema.ExecutionId,
1981
+ tool_call_id: exports_ids_schema.ToolCallId,
1982
+ tool_name: exports_shared_schema.NonEmptyString,
1983
+ input: exports_shared_schema.JsonValue,
1984
+ requested_at: exports_shared_schema.TimestampMillis
1985
+ }).annotate({ identifier: "Relay.Operation.PendingToolApproval" });
1986
+ var ListPendingApprovalsInput = Schema22.Struct({
1987
+ execution_id: exports_ids_schema.ExecutionId
1988
+ }).annotate({ identifier: "Relay.Operation.ListPendingApprovalsInput" });
1989
+ var PendingToolApprovalList = Schema22.Struct({
1990
+ approvals: Schema22.Array(PendingToolApproval)
1991
+ }).annotate({ identifier: "Relay.Operation.PendingToolApprovalList" });
1992
+ var PendingToolCall = Schema22.Struct({
1993
+ execution_id: exports_ids_schema.ExecutionId,
1994
+ call: exports_tool_schema.Call,
1995
+ definition: exports_tool_schema.Definition,
1996
+ placement: exports_tool_schema.Placement,
1997
+ state: exports_tool_schema.CallState,
1998
+ wait_id: exports_ids_schema.WaitId,
1999
+ idempotency_key: Schema22.String,
2000
+ requested_at: exports_shared_schema.TimestampMillis
2001
+ }).annotate({ identifier: "Relay.Operation.PendingToolCall" });
2002
+ var ListPendingToolCallsInput = Schema22.Struct({
2003
+ execution_id: Schema22.optionalKey(exports_ids_schema.ExecutionId),
2004
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0)))
2005
+ }).annotate({ identifier: "Relay.Operation.ListPendingToolCallsInput" });
2006
+ var PendingToolCallList = Schema22.Struct({
2007
+ tool_calls: Schema22.Array(PendingToolCall)
2008
+ }).annotate({ identifier: "Relay.Operation.PendingToolCallList" });
2009
+ var FulfillToolCallInput = Schema22.Struct({
2010
+ execution_id: exports_ids_schema.ExecutionId,
2011
+ tool_call_id: exports_ids_schema.ToolCallId,
2012
+ outcome: exports_tool_schema.ExternalOutcome,
2013
+ fulfilled_at: exports_shared_schema.TimestampMillis
2014
+ }).annotate({ identifier: "Relay.Operation.FulfillToolCallInput" });
2015
+ var ClaimToolWorkInput = Schema22.Struct({
2016
+ queue: exports_tool_schema.PlacementKey,
2017
+ worker_id: exports_tool_schema.WorkerId,
2018
+ now: exports_shared_schema.TimestampMillis,
2019
+ claim_expires_at: exports_shared_schema.TimestampMillis
2020
+ }).annotate({ identifier: "Relay.Operation.ClaimToolWorkInput" });
2021
+ var CompleteToolWorkInput = Schema22.Struct({
2022
+ tool_call_id: exports_ids_schema.ToolCallId,
2023
+ attempt_id: exports_ids_schema.ToolAttemptId,
2024
+ worker_id: exports_tool_schema.WorkerId,
2025
+ outcome: exports_tool_schema.ExternalOutcome,
2026
+ completed_at: exports_shared_schema.TimestampMillis
2027
+ }).annotate({ identifier: "Relay.Operation.CompleteToolWorkInput" });
2028
+ var ReleaseToolWorkInput = Schema22.Struct({
2029
+ tool_call_id: exports_ids_schema.ToolCallId,
2030
+ attempt_id: exports_ids_schema.ToolAttemptId,
2031
+ worker_id: exports_tool_schema.WorkerId,
2032
+ released_at: exports_shared_schema.TimestampMillis,
2033
+ next_available_at: exports_shared_schema.TimestampMillis,
2034
+ error: Schema22.optionalKey(Schema22.String)
2035
+ }).annotate({ identifier: "Relay.Operation.ReleaseToolWorkInput" });
2036
+ var ListToolAttemptsInput = Schema22.Struct({
2037
+ tool_call_id: exports_ids_schema.ToolCallId
2038
+ }).annotate({ identifier: "Relay.Operation.ListToolAttemptsInput" });
2039
+ var ToolAttempt = Schema22.Struct({
2040
+ attempt_id: exports_ids_schema.ToolAttemptId,
2041
+ tool_call_id: exports_ids_schema.ToolCallId,
2042
+ attempt_number: Schema22.Int.check(Schema22.isGreaterThan(0)),
2043
+ state: exports_tool_schema.AttemptState,
2044
+ worker_id: Schema22.optionalKey(Schema22.String),
2045
+ claim_expires_at: Schema22.optionalKey(exports_shared_schema.TimestampMillis),
2046
+ error: Schema22.optionalKey(Schema22.String),
2047
+ created_at: exports_shared_schema.TimestampMillis,
2048
+ completed_at: Schema22.optionalKey(exports_shared_schema.TimestampMillis)
2049
+ }).annotate({ identifier: "Relay.Operation.ToolAttempt" });
2050
+ var ToolAttemptList = Schema22.Struct({
2051
+ attempts: Schema22.Array(ToolAttempt)
2052
+ }).annotate({ identifier: "Relay.Operation.ToolAttemptList" });
2053
+ var ToolOutcomeAccepted = Schema22.Struct({
2054
+ tool_call_id: exports_ids_schema.ToolCallId,
2055
+ attempt: ToolAttempt,
2056
+ duplicate: Schema22.Boolean
2057
+ }).annotate({ identifier: "Relay.Operation.ToolOutcomeAccepted" });
2058
+ var ToolWorkLease = Schema22.Struct({
2059
+ execution_id: exports_ids_schema.ExecutionId,
2060
+ call: exports_tool_schema.Call,
2061
+ definition: exports_tool_schema.Definition,
2062
+ placement: exports_tool_schema.Placement,
2063
+ attempt: ToolAttempt,
2064
+ queue: exports_tool_schema.PlacementKey,
2065
+ worker_id: exports_tool_schema.WorkerId,
2066
+ claim_expires_at: exports_shared_schema.TimestampMillis,
2067
+ idempotency_key: Schema22.String
2068
+ }).annotate({ identifier: "Relay.Operation.ToolWorkLease" });
2069
+ var ToolWorkReleased = Schema22.Struct({
2070
+ tool_call_id: exports_ids_schema.ToolCallId,
2071
+ state: Schema22.Literal("waiting"),
2072
+ next_available_at: exports_shared_schema.TimestampMillis
2073
+ }).annotate({ identifier: "Relay.Operation.ToolWorkReleased" });
2074
+ var SpawnChildRunInput2 = Schema22.Struct({
2075
+ execution_id: exports_ids_schema.ExecutionId,
2076
+ child_execution_id: Schema22.optionalKey(exports_ids_schema.ChildExecutionId),
2077
+ address_id: exports_ids_schema.AddressId,
2078
+ preset_name: Schema22.optionalKey(exports_shared_schema.NonEmptyString),
2079
+ instructions: Schema22.optionalKey(Schema22.String),
2080
+ model: Schema22.optionalKey(exports_agent_schema.ModelSelection),
2081
+ compaction_policy: Schema22.optionalKey(exports_agent_schema.CompactionPolicy),
2082
+ tool_names: Schema22.optionalKey(Schema22.Array(Schema22.String)),
2083
+ permissions: Schema22.optionalKey(Schema22.Array(Schema22.String)),
2084
+ workspace_policy: Schema22.optionalKey(exports_agent_schema.ChildRunWorkspacePolicy),
2085
+ output_schema_ref: Schema22.optionalKey(Schema22.String),
2086
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata),
2087
+ input: Schema22.optionalKey(Schema22.Array(exports_content_schema.Part)),
2088
+ wait: Schema22.optionalKey(Schema22.Boolean)
2089
+ }).annotate({ identifier: "Relay.Operation.SpawnChildRunInput" });
2090
+ var CreateChildFanOutInput = exports_child_orchestration_schema.FanOutDefinition.annotate({
2091
+ identifier: "Relay.Operation.CreateChildFanOutInput"
2092
+ });
2093
+ var CancelChildFanOutInput = Schema22.Struct({
2094
+ fan_out_id: exports_ids_schema.ChildFanOutId,
2095
+ cancelled_at: exports_shared_schema.TimestampMillis,
2096
+ reason: Schema22.optionalKey(Schema22.String)
2097
+ }).annotate({ identifier: "Relay.Operation.CancelChildFanOutInput" });
2098
+ var CancelChildFanOutResult = Schema22.Struct({
2099
+ fan_out: exports_child_orchestration_schema.FanOutState
2100
+ }).annotate({ identifier: "Relay.Operation.CancelChildFanOutResult" });
2101
+ var InspectChildFanOutInput = Schema22.Struct({
2102
+ fan_out_id: exports_ids_schema.ChildFanOutId
2103
+ }).annotate({ identifier: "Relay.Operation.InspectChildFanOutInput" });
2104
+ var InspectChildFanOutResult = Schema22.Struct({
2105
+ fan_out: Schema22.NullOr(exports_child_orchestration_schema.FanOutState)
2106
+ }).annotate({ identifier: "Relay.Operation.InspectChildFanOutResult" });
2107
+ var ResolveToolApprovalInput = Schema22.Struct({
2108
+ wait_id: exports_ids_schema.WaitId,
2109
+ approved: Schema22.Boolean,
2110
+ comment: Schema22.optionalKey(Schema22.String),
2111
+ resolved_at: exports_shared_schema.TimestampMillis
2112
+ }).annotate({ identifier: "Relay.Operation.ResolveToolApprovalInput" });
2113
+ var PermissionAnswer = Schema22.Literals(["Approved", "Denied", "Always"]).annotate({
2114
+ identifier: "Relay.Operation.PermissionAnswer"
2115
+ });
2116
+ var ResolvePermissionInput = Schema22.Struct({
2117
+ wait_id: exports_ids_schema.WaitId,
2118
+ answer: PermissionAnswer,
2119
+ reason: Schema22.optionalKey(Schema22.String),
2120
+ resolved_at: exports_shared_schema.TimestampMillis
2121
+ }).annotate({ identifier: "Relay.Operation.ResolvePermissionInput" });
2122
+ var SubmitInboundEnvelopeInput = Schema22.Struct({
2123
+ envelope: exports_envelope_schema.SendInput,
2124
+ wake: WakeInput
2125
+ }).annotate({ identifier: "Relay.Operation.SubmitInboundEnvelopeInput" });
2126
+ var SubmitInboundEnvelopeAccepted = Schema22.Struct({
2127
+ envelope: exports_envelope_schema.EnvelopeAccepted,
2128
+ wake: WakeAccepted
2129
+ }).annotate({ identifier: "Relay.Operation.SubmitInboundEnvelopeAccepted" });
2130
+ var ClaimEnvelopeReadyInput = Schema22.Struct({
2131
+ route_type: exports_address_schema.RouteKind,
2132
+ route_key: Schema22.optionalKey(Schema22.String),
2133
+ worker_id: exports_shared_schema.NonEmptyString,
2134
+ now: exports_shared_schema.TimestampMillis,
2135
+ claim_expires_at: exports_shared_schema.TimestampMillis
2136
+ }).annotate({ identifier: "Relay.Operation.ClaimEnvelopeReadyInput" });
2137
+ var EnvelopeReadyLease = Schema22.Struct({
2138
+ ready: exports_envelope_schema.EnvelopeReady,
2139
+ worker_id: exports_shared_schema.NonEmptyString,
2140
+ claim_expires_at: exports_shared_schema.TimestampMillis
2141
+ }).annotate({ identifier: "Relay.Operation.EnvelopeReadyLease" });
2142
+ var AckEnvelopeReadyInput = Schema22.Struct({
2143
+ envelope_ready_id: exports_ids_schema.EnvelopeReadyId,
2144
+ worker_id: exports_shared_schema.NonEmptyString,
2145
+ acknowledged_at: exports_shared_schema.TimestampMillis
2146
+ }).annotate({ identifier: "Relay.Operation.AckEnvelopeReadyInput" });
2147
+ var EnvelopeReadyAcked = Schema22.Struct({
2148
+ envelope_ready_id: exports_ids_schema.EnvelopeReadyId,
2149
+ state: Schema22.Literal("acknowledged"),
2150
+ acknowledged_at: exports_shared_schema.TimestampMillis
2151
+ }).annotate({ identifier: "Relay.Operation.EnvelopeReadyAcked" });
2152
+ var ReleaseEnvelopeReadyInput = Schema22.Struct({
2153
+ envelope_ready_id: exports_ids_schema.EnvelopeReadyId,
2154
+ worker_id: exports_shared_schema.NonEmptyString,
2155
+ next_available_at: exports_shared_schema.TimestampMillis,
2156
+ error: Schema22.optionalKey(Schema22.String)
2157
+ }).annotate({ identifier: "Relay.Operation.ReleaseEnvelopeReadyInput" });
2158
+ var EnvelopeReadyReleased = Schema22.Struct({
2159
+ envelope_ready_id: exports_ids_schema.EnvelopeReadyId,
2160
+ state: Schema22.Literal("ready"),
2161
+ next_available_at: exports_shared_schema.TimestampMillis
2162
+ }).annotate({ identifier: "Relay.Operation.EnvelopeReadyReleased" });
2163
+ var CreateScheduleInput = Schema22.Struct({
2164
+ schedule_id: exports_ids_schema.ScheduleId,
2165
+ kind: exports_schedule_schema.ScheduleKind,
2166
+ target_kind: exports_schedule_schema.ScheduleTargetKind,
2167
+ address_id: Schema22.optionalKey(exports_ids_schema.AddressId),
2168
+ wait_id: Schema22.optionalKey(exports_ids_schema.WaitId),
2169
+ cron_expr: Schema22.optionalKey(exports_shared_schema.NonEmptyString),
2170
+ input: Schema22.optionalKey(Schema22.Array(exports_content_schema.Part)),
2171
+ next_run_at: exports_shared_schema.TimestampMillis,
2172
+ idempotency_key: Schema22.optionalKey(exports_shared_schema.NonEmptyString),
2173
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata)
2174
+ }).annotate({ identifier: "Relay.Operation.CreateScheduleInput" });
2175
+ var CreateScheduleResult = Schema22.Struct({
2176
+ schedule: exports_schedule_schema.ScheduleRecord
2177
+ }).annotate({ identifier: "Relay.Operation.CreateScheduleResult" });
2178
+ var CancelScheduleInput = Schema22.Struct({
2179
+ schedule_id: exports_ids_schema.ScheduleId,
2180
+ cancelled_at: exports_shared_schema.TimestampMillis
2181
+ }).annotate({ identifier: "Relay.Operation.CancelScheduleInput" });
2182
+ var CancelScheduleResult = Schema22.Struct({
2183
+ schedule: exports_schedule_schema.ScheduleRecord
2184
+ }).annotate({ identifier: "Relay.Operation.CancelScheduleResult" });
2185
+ var ListSchedulesInput = Schema22.Struct({
2186
+ state: Schema22.optionalKey(exports_schedule_schema.ScheduleState)
2187
+ }).annotate({ identifier: "Relay.Operation.ListSchedulesInput" });
2188
+ var ListSchedulesResult = Schema22.Struct({
2189
+ schedules: Schema22.Array(exports_schedule_schema.ScheduleRecord)
2190
+ }).annotate({ identifier: "Relay.Operation.ListSchedulesResult" });
2191
+ var ListExecutionsInput = Schema22.Struct({
2192
+ root_address_id: Schema22.optionalKey(exports_ids_schema.AddressId),
2193
+ status: Schema22.optionalKey(exports_execution_schema.ExecutionStatus),
2194
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0))),
2195
+ cursor: Schema22.optionalKey(exports_pagination_schema.ExecutionCursor)
2196
+ }).annotate({ identifier: "Relay.Operation.ListExecutionsInput" });
2197
+ var SubscribeTopicInput = Schema22.Struct({
2198
+ topic_address_id: exports_ids_schema.AddressId,
2199
+ subscriber_execution_id: exports_ids_schema.ExecutionId,
2200
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata)
2201
+ }).annotate({ identifier: "Relay.Operation.SubscribeTopicInput" });
2202
+ var TopicSubscription = Schema22.Struct({
2203
+ topic_address_id: exports_ids_schema.AddressId,
2204
+ subscriber_execution_id: exports_ids_schema.ExecutionId,
2205
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata),
2206
+ created_at: exports_shared_schema.TimestampMillis
2207
+ }).annotate({ identifier: "Relay.Operation.TopicSubscription" });
2208
+ var PublishTopicInput = Schema22.Struct({
2209
+ topic_address_id: exports_ids_schema.AddressId,
2210
+ from: exports_ids_schema.AddressId,
2211
+ content: Schema22.Array(exports_content_schema.Part),
2212
+ metadata: Schema22.optionalKey(exports_shared_schema.Metadata),
2213
+ idempotency_key: Schema22.optionalKey(exports_shared_schema.NonEmptyString)
2214
+ }).annotate({ identifier: "Relay.Operation.PublishTopicInput" });
2215
+ var TopicPublishAccepted = Schema22.Struct({
2216
+ envelope_id: exports_ids_schema.EnvelopeId,
2217
+ subscriber_count: Schema22.Int.check(Schema22.isGreaterThanOrEqualTo(0))
2218
+ }).annotate({ identifier: "Relay.Operation.TopicPublishAccepted" });
2219
+ var UnsubscribeTopicInput = Schema22.Struct({
2220
+ topic_address_id: exports_ids_schema.AddressId,
2221
+ subscriber_execution_id: exports_ids_schema.ExecutionId
2222
+ }).annotate({ identifier: "Relay.Operation.UnsubscribeTopicInput" });
2223
+ var ListTopicSubscriptionsInput = Schema22.Struct({
2224
+ topic_address_id: Schema22.optionalKey(exports_ids_schema.AddressId),
2225
+ subscriber_execution_id: Schema22.optionalKey(exports_ids_schema.ExecutionId)
2226
+ }).annotate({ identifier: "Relay.Operation.ListTopicSubscriptionsInput" });
2227
+ var ListInboxMessagesInput = Schema22.Struct({
2228
+ execution_id: exports_ids_schema.ExecutionId,
2229
+ include_consumed: Schema22.optionalKey(Schema22.Boolean),
2230
+ after_sequence: Schema22.optionalKey(exports_inbox_schema.MessageSequence),
2231
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0)))
2232
+ }).annotate({ identifier: "Relay.Operation.ListInboxMessagesInput" });
2233
+ var ConversationKind = Schema22.Literals(["user-agent", "agent-agent"]).annotate({
2234
+ identifier: "Relay.Operation.ConversationKind"
2235
+ });
2236
+ var ConversationSummary = Schema22.Struct({
2237
+ execution_id: exports_ids_schema.ExecutionId,
2238
+ root_address_id: exports_ids_schema.AddressId,
2239
+ session_id: Schema22.optionalKey(exports_ids_schema.SessionId),
2240
+ status: exports_execution_schema.ExecutionStatus,
2241
+ kind: ConversationKind,
2242
+ agent_id: Schema22.optionalKey(exports_ids_schema.AgentId),
2243
+ metadata: exports_shared_schema.Metadata,
2244
+ created_at: exports_shared_schema.TimestampMillis,
2245
+ updated_at: exports_shared_schema.TimestampMillis
2246
+ }).annotate({ identifier: "Relay.Operation.ConversationSummary" });
2247
+ var ExecutionCursor2 = Schema22.Struct({
2248
+ execution_id: exports_ids_schema.ExecutionId,
2249
+ after_cursor: Schema22.optionalKey(exports_shared_schema.NonEmptyString)
2250
+ }).annotate({ identifier: "Relay.Operation.ExecutionCursor" });
2251
+
2252
+ class EventLogCursorNotFound extends Schema22.TaggedErrorClass()("EventLogCursorNotFound", { execution_id: exports_ids_schema.ExecutionId, cursor: exports_shared_schema.NonEmptyString }) {
2253
+ }
2254
+ var StreamSessionInput = Schema22.Struct({
2255
+ session_id: exports_ids_schema.SessionId,
2256
+ resume: Schema22.optionalKey(Schema22.Array(ExecutionCursor2))
2257
+ }).annotate({ identifier: "Relay.Operation.StreamSessionInput" });
2258
+ var SessionStreamItem = Schema22.Union([
2259
+ Schema22.TaggedStruct("execution_joined", { execution: ConversationSummary }),
2260
+ Schema22.TaggedStruct("execution_event", { event: exports_execution_schema.ExecutionEvent })
2261
+ ]).annotate({ identifier: "Relay.Operation.SessionStreamItem" });
2262
+ var WatchExecutionsInput = Schema22.Struct({
2263
+ root_address_id: Schema22.optionalKey(exports_ids_schema.AddressId),
2264
+ session_id: Schema22.optionalKey(exports_ids_schema.SessionId),
2265
+ status: Schema22.optionalKey(exports_execution_schema.ExecutionStatus),
2266
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0)))
2267
+ }).annotate({ identifier: "Relay.Operation.WatchExecutionsInput" });
2268
+ var ExecutionListChange = Schema22.Union([
2269
+ Schema22.TaggedStruct("snapshot", {
2270
+ records: Schema22.Array(ConversationSummary),
2271
+ next_cursor: Schema22.optionalKey(exports_pagination_schema.ExecutionCursor)
2272
+ }),
2273
+ Schema22.TaggedStruct("upsert", { record: ConversationSummary })
2274
+ ]).annotate({ identifier: "Relay.Operation.ExecutionListChange" });
2275
+ var ToolCallSummary = Schema22.Struct({
2276
+ tool_call_id: exports_ids_schema.ToolCallId,
2277
+ tool_name: exports_shared_schema.NonEmptyString,
2278
+ input: exports_shared_schema.JsonValue,
2279
+ metadata: exports_shared_schema.Metadata,
2280
+ requested_at: exports_shared_schema.TimestampMillis
2281
+ }).annotate({ identifier: "Relay.Operation.ToolCallSummary" });
2282
+ var ChildRunSummary = Schema22.Struct({
2283
+ child_execution_id: exports_ids_schema.ChildExecutionId,
2284
+ address_id: exports_ids_schema.AddressId,
2285
+ status: exports_execution_schema.ExecutionStatus,
2286
+ metadata: exports_shared_schema.Metadata,
2287
+ created_at: exports_shared_schema.TimestampMillis,
2288
+ updated_at: exports_shared_schema.TimestampMillis
2289
+ }).annotate({ identifier: "Relay.Operation.ChildRunSummary" });
2290
+ var ExecutionInspection = Schema22.Struct({
2291
+ execution_id: exports_ids_schema.ExecutionId,
2292
+ status: exports_execution_schema.ExecutionStatus,
2293
+ waiting_on: Schema22.Array(WaitView),
2294
+ pending_tool_calls: Schema22.Array(ToolCallSummary),
2295
+ child_runs: Schema22.Array(ChildRunSummary),
2296
+ last_event_cursor: Schema22.optionalKey(exports_shared_schema.NonEmptyString)
2297
+ }).annotate({ identifier: "Relay.Operation.ExecutionInspection" });
2298
+ var ListExecutionsResult = Schema22.Struct({
2299
+ records: Schema22.Array(ConversationSummary),
2300
+ next_cursor: Schema22.optionalKey(exports_pagination_schema.ExecutionCursor)
2301
+ }).annotate({ identifier: "Relay.Operation.ListExecutionsResult" });
2302
+ var ListSessionsInput = Schema22.Struct({
2303
+ root_address_id: Schema22.optionalKey(exports_ids_schema.AddressId),
2304
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0))),
2305
+ cursor: Schema22.optionalKey(exports_pagination_schema.SessionCursor)
2306
+ }).annotate({ identifier: "Relay.Operation.ListSessionsInput" });
2307
+ var SessionSummary = Schema22.Struct({
2308
+ session_id: exports_ids_schema.SessionId,
2309
+ root_address_id: exports_ids_schema.AddressId,
2310
+ metadata: exports_shared_schema.Metadata,
2311
+ created_at: exports_shared_schema.TimestampMillis,
2312
+ updated_at: exports_shared_schema.TimestampMillis
2313
+ }).annotate({ identifier: "Relay.Operation.SessionSummary" });
2314
+ var ListSessionsResult = Schema22.Struct({
2315
+ records: Schema22.Array(SessionSummary),
2316
+ next_cursor: Schema22.optionalKey(exports_pagination_schema.SessionCursor)
2317
+ }).annotate({ identifier: "Relay.Operation.ListSessionsResult" });
2318
+ var GetSessionInput = Schema22.Struct({
2319
+ session_id: exports_ids_schema.SessionId,
2320
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0))),
2321
+ cursor: Schema22.optionalKey(exports_pagination_schema.ExecutionCursor)
2322
+ }).annotate({ identifier: "Relay.Operation.GetSessionInput" });
2323
+ var GetSessionResult = Schema22.Struct({
2324
+ session: SessionSummary,
2325
+ executions: Schema22.Array(ConversationSummary),
2326
+ next_cursor: Schema22.optionalKey(exports_pagination_schema.ExecutionCursor)
2327
+ }).annotate({ identifier: "Relay.Operation.GetSessionResult" });
2328
+ var ReplayExecutionInput = Schema22.Struct({
2329
+ execution_id: exports_ids_schema.ExecutionId,
2330
+ after_cursor: Schema22.optionalKey(exports_shared_schema.NonEmptyString),
2331
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0)))
2332
+ }).annotate({ identifier: "Relay.Operation.ReplayExecutionInput" });
2333
+ var ReplayExecutionResult = Schema22.Struct({
2334
+ events: Schema22.Array(exports_execution_schema.ExecutionEvent)
2335
+ }).annotate({ identifier: "Relay.Operation.ReplayExecutionResult" });
2336
+ var ExecutionEventPageDirection = Schema22.Literals(["forward", "backward"]).annotate({
2337
+ identifier: "Relay.Operation.ExecutionEventPageDirection"
2338
+ });
2339
+ var PageExecutionEventsInput = Schema22.Struct({
2340
+ execution_id: exports_ids_schema.ExecutionId,
2341
+ direction: ExecutionEventPageDirection,
2342
+ after_cursor: Schema22.optionalKey(exports_shared_schema.NonEmptyString),
2343
+ before_cursor: Schema22.optionalKey(exports_shared_schema.NonEmptyString),
2344
+ limit: Schema22.optionalKey(Schema22.Int.check(Schema22.isGreaterThan(0), Schema22.isLessThanOrEqualTo(1000)))
2345
+ }).check(Schema22.makeFilter((input) => {
2346
+ if (input.direction === "forward") {
2347
+ return input.before_cursor === undefined ? undefined : { path: ["before_cursor"], issue: "forward pages accept only after_cursor" };
2348
+ }
2349
+ return input.after_cursor === undefined ? undefined : { path: ["after_cursor"], issue: "backward pages accept only before_cursor" };
2350
+ })).annotate({ identifier: "Relay.Operation.PageExecutionEventsInput" });
2351
+ var PageExecutionEventsResult = Schema22.Struct({
2352
+ events: Schema22.Array(exports_execution_schema.ExecutionEvent),
2353
+ has_more: Schema22.Boolean,
2354
+ oldest_cursor: Schema22.optionalKey(exports_shared_schema.NonEmptyString),
2355
+ newest_cursor: Schema22.optionalKey(exports_shared_schema.NonEmptyString)
2356
+ }).annotate({ identifier: "Relay.Operation.PageExecutionEventsResult" });
2357
+ var RunnerSummary = Schema22.Struct({
2358
+ address: Schema22.String,
2359
+ healthy: Schema22.Boolean,
2360
+ last_heartbeat: exports_shared_schema.TimestampMillis,
2361
+ owned_shards: Schema22.Int
2362
+ }).annotate({ identifier: "Relay.Operation.RunnerSummary" });
2363
+ var ListRunnersResult = Schema22.Struct({
2364
+ runners: Schema22.Array(RunnerSummary),
2365
+ total_shards: Schema22.Int
2366
+ }).annotate({ identifier: "Relay.Operation.ListRunnersResult" });
2367
+ var RouteExecutionResult = Schema22.Struct({
2368
+ execution_id: exports_ids_schema.ExecutionId,
2369
+ shard: Schema22.String,
2370
+ runner_address: Schema22.NullOr(Schema22.String),
2371
+ owned: Schema22.Boolean
2372
+ }).annotate({ identifier: "Relay.Operation.RouteExecutionResult" });
2373
+
2374
+ // src/command.ts
2375
+ var exports_command = {};
2376
+ __export(exports_command, {
2377
+ outputSchemaRef: () => outputSchemaRef,
2378
+ make: () => make,
2379
+ inputSchemaRef: () => inputSchemaRef,
2380
+ EntityNotFound: () => EntityNotFound,
2381
+ CommandTimedOut: () => CommandTimedOut,
2382
+ CommandReplyInvalid: () => CommandReplyInvalid
2383
+ });
2384
+ import { Function, Schema as Schema23 } from "effect";
2385
+ var make = Function.dual(2, (name, options) => ({ name, ...options }));
2386
+ var inputSchemaRef = (name) => `relay/command/${name}/input`;
2387
+ var outputSchemaRef = (name) => `relay/command/${name}/output`;
2388
+
2389
+ class CommandTimedOut extends Schema23.TaggedErrorClass()("CommandTimedOut", {
2390
+ command: exports_shared_schema.NonEmptyString,
2391
+ wait_id: exports_ids_schema.WaitId,
2392
+ timeout: Schema23.String
2393
+ }) {
2394
+ }
2395
+
2396
+ class CommandReplyInvalid extends Schema23.TaggedErrorClass()("CommandReplyInvalid", {
2397
+ command: exports_shared_schema.NonEmptyString,
2398
+ wait_id: exports_ids_schema.WaitId,
2399
+ message: Schema23.String
2400
+ }) {
2401
+ }
2402
+
2403
+ class EntityNotFound extends Schema23.TaggedErrorClass()("EntityNotFound", {
2404
+ kind: exports_ids_schema.EntityKindName,
2405
+ key: exports_ids_schema.EntityKey
2406
+ }) {
2407
+ }
2408
+
2409
+ // src/client-public.ts
2410
+ var exports_client_public = {};
2411
+ __export(exports_client_public, {
2412
+ watchPresence: () => watchPresence,
2413
+ watchExecutions: () => watchExecutions,
2414
+ wake: () => wake,
2415
+ unsubscribeTopic: () => unsubscribeTopic,
2416
+ subscribeTopic: () => subscribeTopic,
2417
+ submitInboundEnvelope: () => submitInboundEnvelope,
2418
+ streamSession: () => streamSession,
2419
+ streamExecution: () => streamExecution,
2420
+ steer: () => steer,
2421
+ startExecutionByAgentDefinition: () => startExecutionByAgentDefinition,
2422
+ startExecutionByAddress: () => startExecutionByAddress,
2423
+ startExecution: () => startExecution,
2424
+ spawnChildRun: () => spawnChildRun,
2425
+ send: () => send,
2426
+ routeExecution: () => routeExecution,
2427
+ resolveToolApproval: () => resolveToolApproval,
2428
+ resolvePermission: () => resolvePermission,
2429
+ replayExecution: () => replayExecution,
2430
+ releaseToolWork: () => releaseToolWork,
2431
+ releaseEnvelopeReady: () => releaseEnvelopeReady,
2432
+ registerEntityKind: () => registerEntityKind,
2433
+ registerAgentDefinition: () => registerAgentDefinition,
2434
+ registerAgent: () => registerAgent,
2435
+ registerAddressBookRoute: () => registerAddressBookRoute,
2436
+ publishTopic: () => publishTopic,
2437
+ pageExecutionEvents: () => pageExecutionEvents,
2438
+ listWaits: () => listWaits,
2439
+ listTopicSubscriptions: () => listTopicSubscriptions,
2440
+ listToolAttempts: () => listToolAttempts,
2441
+ listSkillDefinitions: () => listSkillDefinitions,
2442
+ listSkillDefinitionRevisions: () => listSkillDefinitionRevisions,
2443
+ listSessions: () => listSessions,
2444
+ listSchedules: () => listSchedules,
2445
+ listRunners: () => listRunners,
2446
+ listPendingToolCalls: () => listPendingToolCalls,
2447
+ listPendingApprovals: () => listPendingApprovals,
2448
+ listInboxMessages: () => listInboxMessages,
2449
+ listExecutions: () => listExecutions,
2450
+ listEntities: () => listEntities,
2451
+ listAgentDefinitions: () => listAgentDefinitions,
2452
+ listAgentDefinitionRevisions: () => listAgentDefinitionRevisions,
2453
+ listAddressBookRoutes: () => listAddressBookRoutes,
2454
+ inspectExecution: () => inspectExecution,
2455
+ inspectChildFanOut: () => inspectChildFanOut,
2456
+ getSkillDefinition: () => getSkillDefinition,
2457
+ getSession: () => getSession,
2458
+ getPresence: () => getPresence,
2459
+ getOrCreateEntity: () => getOrCreateEntity,
2460
+ getExecution: () => getExecution,
2461
+ getEntity: () => getEntity,
2462
+ getAgentDefinition: () => getAgentDefinition,
2463
+ getAddressBookRoute: () => getAddressBookRoute,
2464
+ fulfillToolCall: () => fulfillToolCall,
2465
+ followExecutionFrom: () => followExecutionFrom,
2466
+ followExecution: () => followExecution,
2467
+ destroyEntity: () => destroyEntity,
2468
+ createSchedule: () => createSchedule,
2469
+ createChildFanOut: () => createChildFanOut,
2470
+ completeToolWork: () => completeToolWork,
2471
+ claimToolWork: () => claimToolWork,
2472
+ claimEnvelopeReady: () => claimEnvelopeReady,
2473
+ cancelSchedule: () => cancelSchedule,
2474
+ cancelExecution: () => cancelExecution,
2475
+ cancelChildFanOut: () => cancelChildFanOut,
2476
+ awaitWait: () => awaitWait,
2477
+ askEntity: () => askEntity,
2478
+ ackEnvelopeReady: () => ackEnvelopeReady,
2479
+ WaitKindMismatch: () => WaitKindMismatch,
2480
+ StateVersionConflict: () => StateVersionConflict,
2481
+ Service: () => Service,
2482
+ ExecutionNotFound: () => ExecutionNotFound,
2483
+ EventLogCursorNotFound: () => EventLogCursorNotFound,
2484
+ EntityNamespaceReserved: () => EntityNamespaceReserved,
2485
+ ClientError: () => ClientError
2486
+ });
2487
+ import { Context, Effect, Schema as Schema24, Stream } from "effect";
2488
+
2489
+ class ClientError extends Schema24.TaggedErrorClass()("ClientError", {
2490
+ message: Schema24.String
2491
+ }) {
2492
+ }
2493
+
2494
+ class ExecutionNotFound extends Schema24.TaggedErrorClass()("ExecutionNotFound", {
2495
+ execution_id: exports_ids_schema.ExecutionId
2496
+ }) {
2497
+ }
2498
+
2499
+ class EntityNamespaceReserved extends Schema24.TaggedErrorClass()("EntityNamespaceReserved", { id: Schema24.String, message: Schema24.String }) {
2500
+ }
2501
+
2502
+ class WaitKindMismatch extends Schema24.TaggedErrorClass()("WaitKindMismatch", {
2503
+ wait_id: exports_ids_schema.WaitId,
2504
+ expected: Schema24.String,
2505
+ actual: Schema24.String,
2506
+ message: Schema24.String
2507
+ }) {
2508
+ }
2509
+
2510
+ class Service extends Context.Service()("@relayfx/sdk/client-public/Service") {
2511
+ }
2512
+ var followTerminalStatus = (type) => type === "execution.completed" ? "completed" : type === "execution.failed" ? "failed" : type === "execution.cancelled" ? "cancelled" : undefined;
2513
+ var followReconnectDelayMillis = (attempt) => Math.min(100 * 2 ** (attempt - 1), 5000);
2514
+ var followStopped = (reason, cursor) => ({
2515
+ _tag: "stopped",
2516
+ reason,
2517
+ cursor: cursor ?? null
2518
+ });
2519
+ var followExecutionFrom = (dependencies) => (input) => {
2520
+ const maxReconnects = input.max_reconnects ?? 10;
2521
+ const stopModes = input.stop_on_wait_modes;
2522
+ const inspect = Effect.suspend(() => dependencies.inspectExecution(input.execution_id)).pipe(Effect.catchTag("ExecutionNotFound", (error) => ClientError.make({ message: `execution ${error.execution_id} not found` })));
2523
+ const reconcile = (state, message) => Stream.unwrap(Effect.gen(function* () {
2524
+ const inspection = yield* inspect;
2525
+ const terminal = followTerminalStatus(`execution.${inspection.status}`);
2526
+ if (terminal !== undefined) {
2527
+ return Stream.make(followStopped({ _tag: "terminal", status: terminal }, state.cursor));
2528
+ }
2529
+ const actionable = stopModes === undefined ? undefined : inspection.waiting_on.find((wait) => wait.state === "open" && stopModes.includes(wait.mode));
2530
+ if (actionable !== undefined) {
2531
+ return Stream.make(followStopped({ _tag: "actionable_wait", wait: actionable }, state.cursor));
2532
+ }
2533
+ if (state.attempts >= maxReconnects) {
2534
+ return Stream.fail(ClientError.make({
2535
+ message: `follow of ${input.execution_id} exhausted ${maxReconnects} reconnects: ${message}`
2536
+ }));
2537
+ }
2538
+ state.attempts += 1;
2539
+ const reconnecting = { _tag: "reconnecting", message, attempt: state.attempts };
2540
+ return Stream.make(reconnecting).pipe(Stream.concat(Stream.fromEffect(Effect.sleep(followReconnectDelayMillis(state.attempts))).pipe(Stream.drain)), Stream.concat(Stream.suspend(() => connect(state))));
2541
+ }));
2542
+ const itemsFor = (state, event) => Effect.gen(function* () {
2543
+ if (event.sequence <= state.sequence)
2544
+ return [];
2545
+ state.sequence = event.sequence;
2546
+ state.cursor = event.cursor;
2547
+ state.emitted = true;
2548
+ state.attempts = 0;
2549
+ const items = [{ _tag: "event", event }];
2550
+ const terminal = followTerminalStatus(event.type);
2551
+ if (terminal !== undefined) {
2552
+ items.push(followStopped({ _tag: "terminal", status: terminal }, state.cursor));
2553
+ return items;
2554
+ }
2555
+ if (stopModes !== undefined && event.type === "wait.created") {
2556
+ const mode = event.data?.mode;
2557
+ if (typeof mode === "string" && stopModes.includes(mode)) {
2558
+ const inspection = yield* dependencies.inspectExecution(input.execution_id).pipe(Effect.catchTag("ExecutionNotFound", () => Effect.void));
2559
+ const actionable = inspection?.waiting_on.find((wait) => wait.state === "open" && wait.wait_id === event.data?.wait_id);
2560
+ if (actionable !== undefined) {
2561
+ items.push(followStopped({ _tag: "actionable_wait", wait: actionable }, state.cursor));
2562
+ }
2563
+ }
2564
+ }
2565
+ return items;
2566
+ });
2567
+ const connect = (state) => dependencies.streamExecution({
2568
+ execution_id: input.execution_id,
2569
+ ...state.cursor === undefined ? {} : { after_cursor: state.cursor }
2570
+ }).pipe(Stream.flatMap((event) => Stream.fromEffect(itemsFor(state, event)).pipe(Stream.flatMap((items) => Stream.fromIterable(items)))), Stream.catchTag("EventLogCursorNotFound", (error) => !state.emitted && input.after_cursor !== undefined ? Stream.fail(error) : reconcile(state, `cursor ${error.cursor} was not found`)), Stream.catchTag("ClientError", (error) => reconcile(state, `stream failed: ${error.message}`)), Stream.concat(Stream.suspend(() => reconcile(state, "stream ended before a terminal event"))));
2571
+ return Stream.unwrap(Effect.gen(function* () {
2572
+ const existing = yield* dependencies.getExecution(input.execution_id);
2573
+ if (existing === undefined) {
2574
+ return Stream.fail(ClientError.make({ message: `execution ${input.execution_id} not found` }));
2575
+ }
2576
+ const state = {
2577
+ cursor: input.after_cursor,
2578
+ sequence: -1,
2579
+ attempts: 0,
2580
+ emitted: false
2581
+ };
2582
+ return connect(state);
2583
+ })).pipe(Stream.takeUntil((item) => item._tag === "stopped"));
2584
+ };
2585
+ var registerAgentDefinition = Effect.fn("Client.registerAgentDefinition.call")(function* (input) {
2586
+ const service = yield* Service;
2587
+ return yield* service.registerAgentDefinition(input);
2588
+ });
2589
+ var registerEntityKind = Effect.fn("Client.registerEntityKind.call")(function* (input) {
2590
+ const service = yield* Service;
2591
+ return yield* service.registerEntityKind(input);
2592
+ });
2593
+ var getOrCreateEntity = Effect.fn("Client.getOrCreateEntity.call")(function* (input) {
2594
+ const service = yield* Service;
2595
+ return yield* service.getOrCreateEntity(input);
2596
+ });
2597
+ var getEntity = Effect.fn("Client.getEntity.call")(function* (input) {
2598
+ const service = yield* Service;
2599
+ return yield* service.getEntity(input);
2600
+ });
2601
+ var destroyEntity = Effect.fn("Client.destroyEntity.call")(function* (input) {
2602
+ const service = yield* Service;
2603
+ return yield* service.destroyEntity(input);
2604
+ });
2605
+ var listEntities = Effect.fn("Client.listEntities.call")(function* (input) {
2606
+ const service = yield* Service;
2607
+ return yield* service.listEntities(input);
2608
+ });
2609
+ function registerAgent(input) {
2610
+ return Effect.gen(function* () {
2611
+ const service = yield* Service;
2612
+ if (isRegisterBatonAgentInput(input))
2613
+ return yield* service.registerAgent(input);
2614
+ return yield* service.registerAgent(input);
2615
+ }).pipe(Effect.withSpan("Client.registerAgent.call"));
2616
+ }
2617
+ var isRegisterBatonAgentInput = (input) => ("agent" in input);
2618
+ var getAgentDefinition = Effect.fn("Client.getAgentDefinition.call")(function* (id2) {
2619
+ const service = yield* Service;
2620
+ return yield* service.getAgentDefinition(id2);
2621
+ });
2622
+ var listAgentDefinitions = Effect.fn("Client.listAgentDefinitions.call")(function* () {
2623
+ const service = yield* Service;
2624
+ return yield* service.listAgentDefinitions();
2625
+ });
2626
+ var listAgentDefinitionRevisions = Effect.fn("Client.listAgentDefinitionRevisions.call")(function* (id2) {
2627
+ const service = yield* Service;
2628
+ return yield* service.listAgentDefinitionRevisions(id2);
2629
+ });
2630
+ var getSkillDefinition = Effect.fn("Client.getSkillDefinition.call")(function* (id2) {
2631
+ const service = yield* Service;
2632
+ return yield* service.getSkillDefinition(id2);
2633
+ });
2634
+ var listSkillDefinitions = Effect.fn("Client.listSkillDefinitions.call")(function* () {
2635
+ const service = yield* Service;
2636
+ return yield* service.listSkillDefinitions();
2637
+ });
2638
+ var listSkillDefinitionRevisions = Effect.fn("Client.listSkillDefinitionRevisions.call")(function* (id2) {
2639
+ const service = yield* Service;
2640
+ return yield* service.listSkillDefinitionRevisions(id2);
2641
+ });
2642
+ var registerAddressBookRoute = Effect.fn("Client.registerAddressBookRoute.call")(function* (input) {
2643
+ const service = yield* Service;
2644
+ return yield* service.registerAddressBookRoute(input);
2645
+ });
2646
+ var getAddressBookRoute = Effect.fn("Client.getAddressBookRoute.call")(function* (id2) {
2647
+ const service = yield* Service;
2648
+ return yield* service.getAddressBookRoute(id2);
2649
+ });
2650
+ var listAddressBookRoutes = Effect.fn("Client.listAddressBookRoutes.call")(function* () {
2651
+ const service = yield* Service;
2652
+ return yield* service.listAddressBookRoutes();
2653
+ });
2654
+ var startExecution = Effect.fn("Client.startExecution.call")(function* (input) {
2655
+ const service = yield* Service;
2656
+ return yield* service.startExecution(input);
2657
+ });
2658
+ var startExecutionByAddress = Effect.fn("Client.startExecutionByAddress.call")(function* (input) {
2659
+ const service = yield* Service;
2660
+ return yield* service.startExecutionByAddress(input);
2661
+ });
2662
+ var startExecutionByAgentDefinition = Effect.fn("Client.startExecutionByAgentDefinition.call")(function* (input) {
2663
+ const service = yield* Service;
2664
+ return yield* service.startExecutionByAgentDefinition(input);
2665
+ });
2666
+ var cancelExecution = Effect.fn("Client.cancelExecution.call")(function* (input) {
2667
+ const service = yield* Service;
2668
+ return yield* service.cancelExecution(input);
2669
+ });
2670
+ var steer = Effect.fn("Client.steer.call")(function* (input) {
2671
+ const service = yield* Service;
2672
+ return yield* service.steer(input);
2673
+ });
2674
+ var getExecution = Effect.fn("Client.getExecution.call")(function* (id2) {
2675
+ const service = yield* Service;
2676
+ return yield* service.getExecution(id2);
2677
+ });
2678
+ var listExecutions = Effect.fn("Client.listExecutions.call")(function* (input) {
2679
+ const service = yield* Service;
2680
+ return yield* service.listExecutions(input);
2681
+ });
2682
+ var listSessions = Effect.fn("Client.listSessions.call")(function* (input) {
2683
+ const service = yield* Service;
2684
+ return yield* service.listSessions(input);
2685
+ });
2686
+ var getSession = Effect.fn("Client.getSession.call")(function* (input) {
2687
+ const service = yield* Service;
2688
+ return yield* service.getSession(input);
2689
+ });
2690
+ var listWaits = Effect.fn("Client.listWaits.call")(function* (input) {
2691
+ const service = yield* Service;
2692
+ return yield* service.listWaits(input);
2693
+ });
2694
+ var replayExecution = Effect.fn("Client.replayExecution.call")(function* (input) {
2695
+ const service = yield* Service;
2696
+ return yield* service.replayExecution(input);
2697
+ });
2698
+ var pageExecutionEvents = Effect.fn("Client.pageExecutionEvents.call")(function* (input) {
2699
+ const service = yield* Service;
2700
+ return yield* service.pageExecutionEvents(input);
2701
+ });
2702
+ var listRunners = Effect.fn("Client.listRunners.call")(function* () {
2703
+ const service = yield* Service;
2704
+ return yield* service.listRunners();
2705
+ });
2706
+ var routeExecution = Effect.fn("Client.routeExecution.call")(function* (executionId) {
2707
+ const service = yield* Service;
2708
+ return yield* service.routeExecution(executionId);
2709
+ });
2710
+ var subscribeTopic = Effect.fn("Client.subscribeTopic.call")(function* (input) {
2711
+ const service = yield* Service;
2712
+ return yield* service.subscribeTopic(input);
2713
+ });
2714
+ var unsubscribeTopic = Effect.fn("Client.unsubscribeTopic.call")(function* (input) {
2715
+ const service = yield* Service;
2716
+ return yield* service.unsubscribeTopic(input);
2717
+ });
2718
+ var publishTopic = Effect.fn("Client.publishTopic.call")(function* (input) {
2719
+ const service = yield* Service;
2720
+ return yield* service.publishTopic(input);
2721
+ });
2722
+ var listTopicSubscriptions = Effect.fn("Client.listTopicSubscriptions.call")(function* (input) {
2723
+ const service = yield* Service;
2724
+ return yield* service.listTopicSubscriptions(input);
2725
+ });
2726
+ var listInboxMessages = Effect.fn("Client.listInboxMessages.call")(function* (input) {
2727
+ const service = yield* Service;
2728
+ return yield* service.listInboxMessages(input);
2729
+ });
2730
+ var inspectExecution = Effect.fn("Client.inspectExecution.call")(function* (executionId) {
2731
+ const service = yield* Service;
2732
+ return yield* service.inspectExecution(executionId);
2733
+ });
2734
+ var send = Effect.fn("Client.send.call")(function* (input) {
2735
+ const service = yield* Service;
2736
+ return yield* service.send(input);
2737
+ });
2738
+ var streamExecution = (input) => Stream.unwrap(Service.pipe(Effect.map((service) => service.streamExecution(input))));
2739
+ var followExecution = (input) => Stream.unwrap(Service.pipe(Effect.map((service) => service.followExecution(input))));
2740
+ var streamSession = (input) => Stream.unwrap(Service.pipe(Effect.map((service) => service.streamSession(input))));
2741
+ var watchExecutions = (input) => Stream.unwrap(Service.pipe(Effect.map((service) => service.watchExecutions(input))));
2742
+ var getPresence = Effect.fn("Client.getPresence.call")(function* (scope) {
2743
+ const service = yield* Service;
2744
+ return yield* service.getPresence(scope);
2745
+ });
2746
+ var watchPresence = (scope) => Stream.unwrap(Service.pipe(Effect.map((service) => service.watchPresence(scope))));
2747
+ var wake = Effect.fn("Client.wake.call")(function* (input) {
2748
+ const service = yield* Service;
2749
+ return yield* service.wake(input);
2750
+ });
2751
+ var listPendingApprovals = Effect.fn("Client.listPendingApprovals.call")(function* (input) {
2752
+ const service = yield* Service;
2753
+ return yield* service.listPendingApprovals(input);
2754
+ });
2755
+ var resolveToolApproval = Effect.fn("Client.resolveToolApproval.call")(function* (input) {
2756
+ const service = yield* Service;
2757
+ return yield* service.resolveToolApproval(input);
2758
+ });
2759
+ var resolvePermission = Effect.fn("Client.resolvePermission.call")(function* (input) {
2760
+ const service = yield* Service;
2761
+ return yield* service.resolvePermission(input);
2762
+ });
2763
+ var listPendingToolCalls = Effect.fn("Client.listPendingToolCalls.call")(function* (input) {
2764
+ const service = yield* Service;
2765
+ return yield* service.listPendingToolCalls(input);
2766
+ });
2767
+ var fulfillToolCall = Effect.fn("Client.fulfillToolCall.call")(function* (input) {
2768
+ const service = yield* Service;
2769
+ return yield* service.fulfillToolCall(input);
2770
+ });
2771
+ var claimToolWork = Effect.fn("Client.claimToolWork.call")(function* (input) {
2772
+ const service = yield* Service;
2773
+ return yield* service.claimToolWork(input);
2774
+ });
2775
+ var completeToolWork = Effect.fn("Client.completeToolWork.call")(function* (input) {
2776
+ const service = yield* Service;
2777
+ return yield* service.completeToolWork(input);
2778
+ });
2779
+ var releaseToolWork = Effect.fn("Client.releaseToolWork.call")(function* (input) {
2780
+ const service = yield* Service;
2781
+ return yield* service.releaseToolWork(input);
2782
+ });
2783
+ var listToolAttempts = Effect.fn("Client.listToolAttempts.call")(function* (input) {
2784
+ const service = yield* Service;
2785
+ return yield* service.listToolAttempts(input);
2786
+ });
2787
+ var submitInboundEnvelope = Effect.fn("Client.submitInboundEnvelope.call")(function* (input) {
2788
+ const service = yield* Service;
2789
+ return yield* service.submitInboundEnvelope(input);
2790
+ });
2791
+ var spawnChildRun = Effect.fn("Client.spawnChildRun.call")(function* (input) {
2792
+ const service = yield* Service;
2793
+ return yield* service.spawnChildRun(input);
2794
+ });
2795
+ var createChildFanOut = Effect.fn("Client.createChildFanOut.call")(function* (input) {
2796
+ const service = yield* Service;
2797
+ return yield* service.createChildFanOut(input);
2798
+ });
2799
+ var cancelChildFanOut = Effect.fn("Client.cancelChildFanOut.call")(function* (input) {
2800
+ const service = yield* Service;
2801
+ return yield* service.cancelChildFanOut(input);
2802
+ });
2803
+ var inspectChildFanOut = Effect.fn("Client.inspectChildFanOut.call")(function* (input) {
2804
+ const service = yield* Service;
2805
+ return yield* service.inspectChildFanOut(input);
2806
+ });
2807
+ var claimEnvelopeReady = Effect.fn("Client.claimEnvelopeReady.call")(function* (input) {
2808
+ const service = yield* Service;
2809
+ return yield* service.claimEnvelopeReady(input);
2810
+ });
2811
+ var ackEnvelopeReady = Effect.fn("Client.ackEnvelopeReady.call")(function* (input) {
2812
+ const service = yield* Service;
2813
+ return yield* service.ackEnvelopeReady(input);
2814
+ });
2815
+ var releaseEnvelopeReady = Effect.fn("Client.releaseEnvelopeReady.call")(function* (input) {
2816
+ const service = yield* Service;
2817
+ return yield* service.releaseEnvelopeReady(input);
2818
+ });
2819
+ var createSchedule = Effect.fn("Client.createSchedule.call")(function* (input) {
2820
+ const service = yield* Service;
2821
+ return yield* service.createSchedule(input);
2822
+ });
2823
+ var cancelSchedule = Effect.fn("Client.cancelSchedule.call")(function* (input) {
2824
+ const service = yield* Service;
2825
+ return yield* service.cancelSchedule(input);
2826
+ });
2827
+ var listSchedules = Effect.fn("Client.listSchedules.call")(function* (input) {
2828
+ const service = yield* Service;
2829
+ return yield* service.listSchedules(input);
2830
+ });
2831
+ var askEntity = Effect.fn("Client.askEntity.call")(function* (input) {
2832
+ const service = yield* Service;
2833
+ return yield* service.askEntity(input);
2834
+ });
2835
+ var awaitWait = Effect.fn("Client.awaitWait.call")(function* (input) {
2836
+ const service = yield* Service;
2837
+ return yield* service.awaitWait(input);
2838
+ });
2839
+
2840
+ // ../runtime/src/presence/presence-contract.ts
2841
+ import { Context as Context2, Schema as Schema25 } from "effect";
2842
+
2843
+ class PresenceError extends Schema25.TaggedErrorClass()("PresenceError", {
2844
+ message: Schema25.String
2845
+ }) {
2846
+ }
2847
+
2848
+ class Service2 extends Context2.Service()("@relayfx/runtime/presence/presence-contract/Service") {
2849
+ }
2850
+ var PresenceIdentity = Context2.Reference("@relayfx/runtime/PresenceIdentity", { defaultValue: () => ({}) });
2851
+
2852
+ export { exports_address_schema, exports_ids_schema, exports_shared_schema, exports_agent_schema, exports_tool_schema, exports_child_orchestration_schema, exports_execution_schema, exports_content_schema, exports_envelope_schema, exports_entity_schema, exports_inbox_schema, exports_pagination_schema, exports_presence_schema, exports_schedule_schema, exports_skill_schema, exports_state_schema, exports_wait_schema, exports_workflow_schema, exports_workspace_schema, StateVersionConflict, EventLogCursorNotFound, exports_operation, inputSchemaRef, outputSchemaRef, CommandTimedOut, CommandReplyInvalid, EntityNotFound, exports_command, ClientError, ExecutionNotFound, EntityNamespaceReserved, WaitKindMismatch, Service, followExecutionFrom, exports_client_public, PresenceError, Service2 as Service1, PresenceIdentity };