@relayfx/sdk 0.0.47 → 0.0.49

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 (34) hide show
  1. package/dist/ai.js +2050 -579
  2. package/dist/index.js +2879 -862
  3. package/dist/migrations/20260709214238_faithful_black_widow/migration.sql +53 -0
  4. package/dist/migrations/20260709214238_faithful_black_widow/snapshot.json +5426 -0
  5. package/dist/migrations/20260709220016_fearless_aaron_stack/migration.sql +2 -0
  6. package/dist/migrations/20260709220016_fearless_aaron_stack/snapshot.json +5426 -0
  7. package/dist/migrations/mysql/0002_durable_tool_placement.sql +75 -0
  8. package/dist/migrations/pg/20260709214238_faithful_black_widow/migration.sql +53 -0
  9. package/dist/migrations/pg/20260709214238_faithful_black_widow/snapshot.json +5426 -0
  10. package/dist/migrations/pg/20260709220016_fearless_aaron_stack/migration.sql +2 -0
  11. package/dist/migrations/pg/20260709220016_fearless_aaron_stack/snapshot.json +5426 -0
  12. package/dist/migrations/sqlite/0002_durable_tool_placement.sql +71 -0
  13. package/dist/types/relay/client.d.ts +27 -6
  14. package/dist/types/relay/index.d.ts +1 -0
  15. package/dist/types/relay/operation.d.ts +525 -53
  16. package/dist/types/relay/tool-worker.d.ts +19 -0
  17. package/dist/types/runtime/address/address-resolution-service.d.ts +69 -54
  18. package/dist/types/runtime/agent/relay-compaction.d.ts +1 -0
  19. package/dist/types/runtime/cluster/execution-entity.d.ts +10 -477
  20. package/dist/types/runtime/execution/event-log-service.d.ts +6 -0
  21. package/dist/types/runtime/index.d.ts +1 -0
  22. package/dist/types/runtime/runner/runner-runtime-service.d.ts +18 -15
  23. package/dist/types/runtime/tool/tool-runtime-service.d.ts +17 -1
  24. package/dist/types/runtime/tool/tool-transition-coordinator.d.ts +13 -0
  25. package/dist/types/runtime/workflow/execution-workflow.d.ts +146 -114
  26. package/dist/types/schema/agent-schema.d.ts +431 -320
  27. package/dist/types/schema/execution-schema.d.ts +69 -53
  28. package/dist/types/schema/ids-schema.d.ts +4 -0
  29. package/dist/types/schema/tool-schema.d.ts +29 -0
  30. package/dist/types/store-sql/envelope/envelope-repository.d.ts +6 -0
  31. package/dist/types/store-sql/execution/execution-event-repository.d.ts +6 -0
  32. package/dist/types/store-sql/schema/relay-schema.d.ts +386 -7
  33. package/dist/types/store-sql/tool/tool-call-repository.d.ts +160 -1
  34. package/package.json +3 -3
@@ -1,4 +1,5 @@
1
1
  import { Schema } from "effect";
2
+ import { Definition } from "./agent-schema";
2
3
  export declare const ExecutionStatus: Schema.Literals<readonly ["queued", "running", "waiting", "completed", "failed", "cancelled"]>;
3
4
  export type ExecutionStatus = typeof ExecutionStatus.Type;
4
5
  export declare const Execution: Schema.Struct<{
@@ -16,61 +17,76 @@ export declare const Execution: Schema.Struct<{
16
17
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.AgentId">;
17
18
  }>;
18
19
  readonly agent_revision: Schema.optionalKey<Schema.Int>;
19
- readonly agent_snapshot: Schema.optionalKey<Schema.Struct<{
20
- readonly name: Schema.String;
21
- readonly instructions: Schema.optionalKey<Schema.String>;
22
- readonly model: Schema.Struct<{
23
- readonly provider: Schema.String;
24
- readonly model: Schema.String;
25
- readonly registration_key: Schema.optionalKey<Schema.String>;
26
- readonly request_options: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
27
- readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
28
- }>;
29
- readonly tool_names: Schema.$Array<Schema.String>;
30
- readonly permissions: Schema.$Array<Schema.Struct<{
31
- readonly name: Schema.String;
32
- readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
33
- readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
34
- }>>;
35
- readonly skill_definition_ids: Schema.optionalKey<Schema.$Array<Schema.brand<Schema.String, "Relay.SkillDefinitionId"> & {
36
- make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.SkillDefinitionId">;
37
- }>>;
38
- readonly permission_rules: Schema.optionalKey<Schema.Struct<{
39
- readonly rules: Schema.$Array<Schema.Struct<{
40
- readonly pattern: Schema.String;
41
- readonly level: Schema.Literals<readonly ["allow", "deny", "ask"]>;
42
- readonly reason: Schema.optionalKey<Schema.String>;
43
- }>>;
44
- readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["allow", "deny", "ask"]>>;
45
- }>>;
46
- readonly max_tool_turns: Schema.optionalKey<Schema.Int>;
47
- readonly max_wait_turns: Schema.optionalKey<Schema.Int>;
48
- readonly token_budget: Schema.optionalKey<Schema.Int>;
49
- readonly child_run_presets: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
50
- readonly instructions: Schema.optionalKey<Schema.String>;
51
- readonly model: Schema.optionalKey<Schema.Struct<{
52
- readonly provider: Schema.String;
53
- readonly model: Schema.String;
54
- readonly registration_key: Schema.optionalKey<Schema.String>;
55
- readonly request_options: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
56
- readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
57
- }>>;
58
- readonly tool_names: Schema.optionalKey<Schema.$Array<Schema.String>>;
59
- readonly permissions: Schema.optionalKey<Schema.$Array<Schema.String>>;
60
- readonly workspace_policy: Schema.optionalKey<Schema.Struct<{
61
- readonly mode: Schema.Literals<readonly ["share", "fork"]>;
62
- readonly fallback: Schema.optionalKey<Schema.Literals<readonly ["fail", "fresh"]>>;
63
- }>>;
64
- readonly output_schema_ref: Schema.optionalKey<Schema.String>;
65
- readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
66
- }>>>;
67
- readonly handoff_targets: Schema.optionalKey<Schema.$Array<Schema.Struct<{
20
+ readonly agent_snapshot: Schema.optionalKey<Schema.Codec<Definition, {
21
+ readonly name: string;
22
+ readonly permissions: readonly {
23
+ readonly name: string;
24
+ readonly value: Schema.Json;
25
+ readonly metadata?: {
26
+ readonly [x: string]: Schema.Json;
27
+ };
28
+ }[];
29
+ readonly model: {
30
+ readonly provider: string;
31
+ readonly model: string;
32
+ readonly metadata?: {
33
+ readonly [x: string]: Schema.Json;
34
+ };
35
+ readonly registration_key?: string;
36
+ readonly request_options?: {
37
+ readonly [x: string]: Schema.Json;
38
+ };
39
+ };
40
+ readonly tool_names: readonly string[];
41
+ readonly metadata?: {
42
+ readonly [x: string]: Schema.Json;
43
+ };
44
+ readonly instructions?: string;
45
+ readonly output_schema_ref?: string;
46
+ readonly skill_definition_ids?: readonly string[];
47
+ readonly permission_rules?: {
48
+ readonly rules: readonly {
49
+ readonly pattern: string;
50
+ readonly level: "allow" | "deny" | "ask";
51
+ readonly reason?: string;
52
+ }[];
53
+ readonly fallback?: "allow" | "deny" | "ask";
54
+ };
55
+ readonly turn_policy?: import("./agent-schema").TurnPolicySnapshot;
56
+ readonly max_tool_turns?: number;
57
+ readonly max_wait_turns?: number;
58
+ readonly token_budget?: number;
59
+ readonly child_run_presets?: {
60
+ readonly [x: string]: {
61
+ readonly metadata?: {
62
+ readonly [x: string]: Schema.Json;
63
+ };
64
+ readonly permissions?: readonly string[];
65
+ readonly model?: {
66
+ readonly provider: string;
67
+ readonly model: string;
68
+ readonly metadata?: {
69
+ readonly [x: string]: Schema.Json;
70
+ };
71
+ readonly registration_key?: string;
72
+ readonly request_options?: {
73
+ readonly [x: string]: Schema.Json;
74
+ };
75
+ };
76
+ readonly instructions?: string;
77
+ readonly tool_names?: readonly string[];
78
+ readonly workspace_policy?: {
79
+ readonly mode: "share" | "fork";
80
+ readonly fallback?: "fail" | "fresh";
81
+ };
82
+ readonly output_schema_ref?: string;
83
+ };
84
+ };
85
+ readonly handoff_targets?: readonly Schema.Struct.ReadonlySide<{
68
86
  readonly name: Schema.String;
69
87
  readonly preset_name: Schema.String;
70
- }>>>;
71
- readonly output_schema_ref: Schema.optionalKey<Schema.String>;
72
- readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
73
- }>>;
88
+ }, "Encoded">[];
89
+ }, never, never>>;
74
90
  readonly agent_tool_input_schema_digests: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
75
91
  readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
76
92
  readonly created_at: Schema.Int;
@@ -68,6 +68,10 @@ export declare const ToolCallId: Schema.brand<Schema.String, "Relay.ToolCallId">
68
68
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ToolCallId">;
69
69
  };
70
70
  export type ToolCallId = typeof ToolCallId.Type;
71
+ export declare const ToolAttemptId: Schema.brand<Schema.String, "Relay.ToolAttemptId"> & {
72
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ToolAttemptId">;
73
+ };
74
+ export type ToolAttemptId = typeof ToolAttemptId.Type;
71
75
  export declare const WaitId: Schema.brand<Schema.String, "Relay.WaitId"> & {
72
76
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.WaitId">;
73
77
  };
@@ -13,6 +13,34 @@ export declare const RuntimeRequirement: Schema.Union<readonly [Schema.Struct<{
13
13
  }>]>;
14
14
  export interface RuntimeRequirement extends Schema.Schema.Type<typeof RuntimeRequirement> {
15
15
  }
16
+ export declare const PlacementKey: Schema.String;
17
+ export type PlacementKey = typeof PlacementKey.Type;
18
+ export declare const WorkerId: Schema.String;
19
+ export type WorkerId = typeof WorkerId.Type;
20
+ export declare const Placement: Schema.Union<readonly [Schema.Struct<{
21
+ readonly kind: Schema.Literal<"local">;
22
+ }>, Schema.Struct<{
23
+ readonly kind: Schema.Literal<"client">;
24
+ }>, Schema.Struct<{
25
+ readonly kind: Schema.Literal<"remote">;
26
+ readonly queue: Schema.String;
27
+ }>, Schema.Struct<{
28
+ readonly kind: Schema.Literal<"mcp">;
29
+ readonly server_id: Schema.String;
30
+ }>]>;
31
+ export type Placement = typeof Placement.Type;
32
+ export declare const ExternalOutcome: Schema.Union<readonly [Schema.Struct<{
33
+ readonly kind: Schema.Literal<"success">;
34
+ readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
35
+ }>, Schema.Struct<{
36
+ readonly kind: Schema.Literal<"failure">;
37
+ readonly message: Schema.String;
38
+ }>]>;
39
+ export type ExternalOutcome = typeof ExternalOutcome.Type;
40
+ export declare const CallState: Schema.Literals<readonly ["requested", "waiting", "running", "submitted", "completed", "failed"]>;
41
+ export type CallState = typeof CallState.Type;
42
+ export declare const AttemptState: Schema.Literals<readonly ["running", "completed", "failed", "released", "expired", "abandoned"]>;
43
+ export type AttemptState = typeof AttemptState.Type;
16
44
  export declare const Definition: Schema.Struct<{
17
45
  readonly name: Schema.String;
18
46
  readonly description: Schema.String;
@@ -53,3 +81,4 @@ export declare const Result: Schema.Struct<{
53
81
  export interface Result extends Schema.Schema.Type<typeof Result> {
54
82
  }
55
83
  export declare const parametersSchema: (inputSchema: JsonValue) => Schema.Top;
84
+ export declare const resultSchema: (outputSchema: JsonValue) => Schema.Codec<unknown>;
@@ -117,6 +117,10 @@ export interface ListWaitsInput {
117
117
  readonly executionId?: Ids.ExecutionId;
118
118
  readonly limit?: number;
119
119
  }
120
+ export interface ListAllWaitsInput {
121
+ readonly state?: WaitState;
122
+ readonly executionId?: Ids.ExecutionId;
123
+ }
120
124
  export interface CompleteWaitInput {
121
125
  readonly waitId: Ids.WaitId;
122
126
  readonly state: Exclude<WaitState, "open">;
@@ -133,6 +137,7 @@ export interface Interface {
133
137
  readonly getWait: (id: Ids.WaitId) => Effect.Effect<WaitRecord | undefined, EnvelopeRepositoryError>;
134
138
  readonly createWait: (input: CreateWaitInput) => Effect.Effect<WaitRecord, EnvelopeRepositoryError>;
135
139
  readonly listWaits: (input: ListWaitsInput) => Effect.Effect<ReadonlyArray<WaitRecord>, EnvelopeRepositoryError>;
140
+ readonly listAllWaits: (input: ListAllWaitsInput) => Effect.Effect<ReadonlyArray<WaitRecord>, EnvelopeRepositoryError>;
136
141
  readonly claimReady: (input: ClaimReadyInput) => Effect.Effect<EnvelopeReadyRecord | undefined, EnvelopeRepositoryError>;
137
142
  readonly releaseReady: (input: ReleaseReadyInput) => Effect.Effect<EnvelopeReadyRecord, EnvelopeReadyNotFound | EnvelopeReadyClaimMismatch | EnvelopeRepositoryError>;
138
143
  readonly ackReady: (input: AckReadyInput) => Effect.Effect<EnvelopeReadyRecord, EnvelopeReadyNotFound | EnvelopeReadyClaimMismatch | EnvelopeRepositoryError>;
@@ -190,6 +195,7 @@ export declare const getEnvelope: (id: string & import("effect/Brand").Brand<"Re
190
195
  export declare const getWait: (id: string & import("effect/Brand").Brand<"Relay.WaitId">) => Effect.Effect<WaitRecord | undefined, EnvelopeRepositoryError, Service>;
191
196
  export declare const createWait: (input: CreateWaitInput) => Effect.Effect<WaitRecord, EnvelopeRepositoryError, Service>;
192
197
  export declare const listWaits: (input: ListWaitsInput) => Effect.Effect<readonly WaitRecord[], EnvelopeRepositoryError, Service>;
198
+ export declare const listAllWaits: (input: ListAllWaitsInput) => Effect.Effect<readonly WaitRecord[], EnvelopeRepositoryError, Service>;
193
199
  export declare const claimReady: (input: ClaimReadyInput) => Effect.Effect<EnvelopeReadyRecord | undefined, EnvelopeRepositoryError, Service>;
194
200
  export declare const releaseReady: (input: ReleaseReadyInput) => Effect.Effect<EnvelopeReadyRecord, EnvelopeRepositoryError | EnvelopeReadyNotFound | EnvelopeReadyClaimMismatch, Service>;
195
201
  export declare const ackReady: (input: AckReadyInput) => Effect.Effect<EnvelopeReadyRecord, EnvelopeRepositoryError | EnvelopeReadyNotFound | EnvelopeReadyClaimMismatch, Service>;
@@ -48,6 +48,10 @@ export interface FindByCursorInput {
48
48
  readonly executionId: Ids.ExecutionId;
49
49
  readonly cursor: string;
50
50
  }
51
+ export interface FindBySequenceInput {
52
+ readonly executionId: Ids.ExecutionId;
53
+ readonly sequence: Execution.ExecutionEventSequence;
54
+ }
51
55
  export interface FindFirstByTypeAfterSequenceInput {
52
56
  readonly executionId: Ids.ExecutionId;
53
57
  readonly type: Execution.ExecutionEventType;
@@ -63,6 +67,7 @@ export interface Interface {
63
67
  readonly list: (input: ListInput) => Effect.Effect<ReadonlyArray<Execution.ExecutionEvent>, ExecutionEventCursorNotFound | ExecutionEventRepositoryError>;
64
68
  readonly findBySequenceOrCursor: (input: FindBySequenceOrCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError>;
65
69
  readonly findByCursor: (input: FindByCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError>;
70
+ readonly findBySequence: (input: FindBySequenceInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError>;
66
71
  readonly findFirstByTypeAfterSequence: (input: FindFirstByTypeAfterSequenceInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError>;
67
72
  readonly maxSequence: (executionId: Ids.ExecutionId) => Effect.Effect<Execution.ExecutionEventSequence | undefined, ExecutionEventRepositoryError>;
68
73
  readonly sumUsage: (executionId: Ids.ExecutionId) => Effect.Effect<number, ExecutionEventRepositoryError>;
@@ -92,6 +97,7 @@ export declare const append: (input: Execution.ExecutionEvent) => Effect.Effect<
92
97
  export declare const list: (input: ListInput) => Effect.Effect<readonly Execution.ExecutionEvent[], ExecutionEventCursorNotFound | ExecutionEventRepositoryError, Service>;
93
98
  export declare const findBySequenceOrCursor: (input: FindBySequenceOrCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError, Service>;
94
99
  export declare const findByCursor: (input: FindByCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError, Service>;
100
+ export declare const findBySequence: (input: FindBySequenceInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError, Service>;
95
101
  export declare const findFirstByTypeAfterSequence: (input: FindFirstByTypeAfterSequenceInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError, Service>;
96
102
  export declare const maxSequence: (executionId: string & import("effect/Brand").Brand<"Relay.ExecutionId">) => Effect.Effect<number | undefined, ExecutionEventRepositoryError, Service>;
97
103
  export declare const sumUsage: (executionId: string & import("effect/Brand").Brand<"Relay.ExecutionId">) => Effect.Effect<number, ExecutionEventRepositoryError, Service>;