@relayfx/sdk 0.2.15 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.js +2 -2
- package/dist/{index-z9xk02sv.js → index-c2skef55.js} +1898 -1556
- package/dist/{index-d8q4kfjy.js → index-d3dme13d.js} +12 -8
- package/dist/{index-xbbfagnb.js → index-pn652eef.js} +166 -105
- package/dist/{index-gxskhyra.js → index-vwbatywf.js} +8 -8
- package/dist/index.js +5 -5
- package/dist/mysql.js +24 -9
- package/dist/postgres.js +18 -13
- package/dist/sqlite.js +26 -29
- package/dist/types/ai/embedding-model/embedding-model-registration.d.ts +2 -2
- package/dist/types/relay/adapter-outbox.d.ts +1 -1
- package/dist/types/relay/client.d.ts +32 -30
- package/dist/types/relay/command.d.ts +10 -4
- package/dist/types/relay/database.d.ts +4 -4
- package/dist/types/relay/migration-errors.d.ts +8 -2
- package/dist/types/relay/mysql.d.ts +2 -2
- package/dist/types/relay/operation.d.ts +211 -126
- package/dist/types/relay/postgres.d.ts +2 -2
- package/dist/types/relay/runtime-capability-policy.d.ts +11 -5
- package/dist/types/relay/runtime-database.d.ts +1 -1
- package/dist/types/relay/runtime.d.ts +4 -4
- package/dist/types/relay/sqlite-migrations.d.ts +1 -1
- package/dist/types/relay/sqlite-runtime.d.ts +10 -5
- package/dist/types/relay/tool-worker.d.ts +6 -5
- package/dist/types/runtime/address/address-book-service.d.ts +3 -3
- package/dist/types/runtime/address/address-resolution-service.d.ts +41 -41
- package/dist/types/runtime/agent/agent-loop-service.d.ts +14 -5
- package/dist/types/runtime/agent/agent-registry-service.d.ts +2 -2
- package/dist/types/runtime/agent/prompt-assembler-service.d.ts +1 -1
- package/dist/types/runtime/agent/relay-tool-output.d.ts +4 -1
- package/dist/types/runtime/child/child-fan-out-admission-service.d.ts +1 -1
- package/dist/types/runtime/child/child-fan-out-runtime.d.ts +12 -8
- package/dist/types/runtime/child/child-fan-out-transition-service.d.ts +1 -1
- package/dist/types/runtime/child/child-run-service.d.ts +7 -4
- package/dist/types/runtime/child/parent-notifier-service.d.ts +4 -2
- package/dist/types/runtime/child/spawn-child-run-tool.d.ts +5 -4
- package/dist/types/runtime/cluster/execution-entity.d.ts +2 -2
- package/dist/types/runtime/content/artifact-store-service.d.ts +2 -2
- package/dist/types/runtime/content/blob-store-service.d.ts +1 -1
- package/dist/types/runtime/entity/entity-instance-service.d.ts +14 -5
- package/dist/types/runtime/entity/entity-registry-service.d.ts +2 -2
- package/dist/types/runtime/envelope/envelope-service.d.ts +2 -2
- package/dist/types/runtime/execution/active-execution-registry.d.ts +1 -1
- package/dist/types/runtime/execution/event-log-service.d.ts +28 -3
- package/dist/types/runtime/execution/execution-service.d.ts +1 -1
- package/dist/types/runtime/execution/execution-watch-service.d.ts +1 -1
- package/dist/types/runtime/execution/session-stream-service.d.ts +1 -1
- package/dist/types/runtime/inbox/inbox-service.d.ts +1 -1
- package/dist/types/runtime/memory/memory-service.d.ts +1 -1
- package/dist/types/runtime/model/embedding-model-service.d.ts +23 -10
- package/dist/types/runtime/model/language-model-service.d.ts +19 -6
- package/dist/types/runtime/model/model-call-policy.d.ts +1 -1
- package/dist/types/runtime/observability/runtime-metrics.d.ts +12 -3
- package/dist/types/runtime/presence/presence-service.d.ts +1 -1
- package/dist/types/runtime/presence/presence-tool.d.ts +1 -1
- package/dist/types/runtime/runner/runner-runtime-service.d.ts +19 -19
- package/dist/types/runtime/schedule/scheduler-service.d.ts +3 -3
- package/dist/types/runtime/schema-registry/schema-registry-service.d.ts +2 -2
- package/dist/types/runtime/session/session-store-service.d.ts +13 -4
- package/dist/types/runtime/skill/skill-registry-service.d.ts +2 -2
- package/dist/types/runtime/state/execution-state-service.d.ts +5 -2
- package/dist/types/runtime/tool/tool-runtime-service.d.ts +42 -19
- package/dist/types/runtime/tool/tool-transition-coordinator.d.ts +2 -2
- package/dist/types/runtime/topic/topic-service.d.ts +1 -1
- package/dist/types/runtime/wait/wait-service.d.ts +1 -1
- package/dist/types/runtime/wait/wait-signal.d.ts +12 -3
- package/dist/types/runtime/workflow/activity-version-registry.d.ts +7 -3
- package/dist/types/runtime/workflow/definition-runtime.d.ts +37 -22
- package/dist/types/runtime/workflow/execution-workflow.d.ts +105 -110
- package/dist/types/runtime/workspace/workspace-planner-service.d.ts +6 -6
- package/dist/types/runtime/workspace/workspace-provider-service.d.ts +11 -7
- package/dist/types/runtime/workspace/workspace-runtime-service.d.ts +1 -1
- package/dist/types/schema/agent-schema.d.ts +246 -246
- package/dist/types/schema/child-orchestration-schema.d.ts +64 -64
- package/dist/types/schema/execution-schema.d.ts +57 -57
- package/dist/types/schema/workflow-schema.d.ts +243 -243
- package/dist/types/schema/workspace-schema.d.ts +1 -1
- package/dist/types/store-sql/address/address-book-repository.d.ts +5 -5
- package/dist/types/store-sql/agent/agent-definition-repository.d.ts +7 -7
- package/dist/types/store-sql/chat/agent-chat-repository.d.ts +2 -2
- package/dist/types/store-sql/child/child-execution-repository.d.ts +4 -4
- package/dist/types/store-sql/child/child-fan-out-repository.d.ts +2 -2
- package/dist/types/store-sql/cluster/cluster-registry-repository.d.ts +5 -5
- package/dist/types/store-sql/compaction/compaction-repository.d.ts +3 -3
- package/dist/types/store-sql/database/database-service.d.ts +3 -3
- package/dist/types/store-sql/database/notification-bus.d.ts +1 -1
- package/dist/types/store-sql/database/sql-dialect.d.ts +4 -1
- package/dist/types/store-sql/entity/entity-repository.d.ts +2 -2
- package/dist/types/store-sql/envelope/envelope-repository.d.ts +13 -13
- package/dist/types/store-sql/execution/execution-event-repository.d.ts +27 -5
- package/dist/types/store-sql/execution/execution-repository.d.ts +8 -8
- package/dist/types/store-sql/idempotency/idempotency-repository.d.ts +5 -5
- package/dist/types/store-sql/inbox/inbox-repository.d.ts +1 -1
- package/dist/types/store-sql/memory/memory-repository.d.ts +3 -3
- package/dist/types/store-sql/permission/permission-rule-repository.d.ts +2 -2
- package/dist/types/store-sql/presence/presence-repository.d.ts +2 -2
- package/dist/types/store-sql/schedule/schedule-repository.d.ts +9 -9
- package/dist/types/store-sql/schema/relay-schema.d.ts +257 -257
- package/dist/types/store-sql/session/context-epoch-repository.d.ts +2 -2
- package/dist/types/store-sql/session/session-repository.d.ts +5 -5
- package/dist/types/store-sql/skill/skill-definition-repository.d.ts +9 -9
- package/dist/types/store-sql/state/execution-state-repository.d.ts +2 -2
- package/dist/types/store-sql/steering/steering-repository.d.ts +5 -5
- package/dist/types/store-sql/tenant/tenant-id.d.ts +2 -2
- package/dist/types/store-sql/tool/tool-call-repository.d.ts +19 -16
- package/dist/types/store-sql/topic/topic-repository.d.ts +1 -1
- package/dist/types/store-sql/workflow/workflow-definition-repository.d.ts +16 -14
- package/dist/types/store-sql/workspace/workspace-lease-repository.d.ts +11 -11
- package/package.json +3 -3
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
exports_wait_service,
|
|
53
53
|
exports_wait_signal,
|
|
54
54
|
exports_workflow_definition_repository
|
|
55
|
-
} from "./index-
|
|
55
|
+
} from "./index-c2skef55.js";
|
|
56
56
|
|
|
57
57
|
// src/operation.ts
|
|
58
58
|
var exports_operation = {};
|
|
@@ -101,6 +101,8 @@ __export(exports_operation, {
|
|
|
101
101
|
PendingToolCall: () => PendingToolCall,
|
|
102
102
|
PendingToolApprovalList: () => PendingToolApprovalList,
|
|
103
103
|
PendingToolApproval: () => PendingToolApproval,
|
|
104
|
+
PageExecutionEventsResult: () => PageExecutionEventsResult,
|
|
105
|
+
PageExecutionEventsInput: () => PageExecutionEventsInput,
|
|
104
106
|
ListWaitsInput: () => ListWaitsInput,
|
|
105
107
|
ListTopicSubscriptionsInput: () => ListTopicSubscriptionsInput,
|
|
106
108
|
ListToolAttemptsInput: () => ListToolAttemptsInput,
|
|
@@ -129,6 +131,7 @@ __export(exports_operation, {
|
|
|
129
131
|
FollowExecutionInput: () => FollowExecutionInput,
|
|
130
132
|
ExecutionListChange: () => ExecutionListChange,
|
|
131
133
|
ExecutionInspection: () => ExecutionInspection,
|
|
134
|
+
ExecutionEventPageDirection: () => ExecutionEventPageDirection,
|
|
132
135
|
ExecutionCursor: () => ExecutionCursor,
|
|
133
136
|
EventLogCursorNotFound: () => EventLogCursorNotFound,
|
|
134
137
|
EnvelopeReadyReleased: () => EnvelopeReadyReleased,
|
|
@@ -675,6 +678,27 @@ var ReplayExecutionInput = Schema.Struct({
|
|
|
675
678
|
var ReplayExecutionResult = Schema.Struct({
|
|
676
679
|
events: Schema.Array(exports_execution_schema.ExecutionEvent)
|
|
677
680
|
}).annotate({ identifier: "Relay.Operation.ReplayExecutionResult" });
|
|
681
|
+
var ExecutionEventPageDirection = Schema.Literals(["forward", "backward"]).annotate({
|
|
682
|
+
identifier: "Relay.Operation.ExecutionEventPageDirection"
|
|
683
|
+
});
|
|
684
|
+
var PageExecutionEventsInput = Schema.Struct({
|
|
685
|
+
execution_id: exports_ids_schema.ExecutionId,
|
|
686
|
+
direction: ExecutionEventPageDirection,
|
|
687
|
+
after_cursor: Schema.optionalKey(exports_shared_schema.NonEmptyString),
|
|
688
|
+
before_cursor: Schema.optionalKey(exports_shared_schema.NonEmptyString),
|
|
689
|
+
limit: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(1000)))
|
|
690
|
+
}).check(Schema.makeFilter((input) => {
|
|
691
|
+
if (input.direction === "forward") {
|
|
692
|
+
return input.before_cursor === undefined ? undefined : { path: ["before_cursor"], issue: "forward pages accept only after_cursor" };
|
|
693
|
+
}
|
|
694
|
+
return input.after_cursor === undefined ? undefined : { path: ["after_cursor"], issue: "backward pages accept only before_cursor" };
|
|
695
|
+
})).annotate({ identifier: "Relay.Operation.PageExecutionEventsInput" });
|
|
696
|
+
var PageExecutionEventsResult = Schema.Struct({
|
|
697
|
+
events: Schema.Array(exports_execution_schema.ExecutionEvent),
|
|
698
|
+
has_more: Schema.Boolean,
|
|
699
|
+
oldest_cursor: Schema.optionalKey(exports_shared_schema.NonEmptyString),
|
|
700
|
+
newest_cursor: Schema.optionalKey(exports_shared_schema.NonEmptyString)
|
|
701
|
+
}).annotate({ identifier: "Relay.Operation.PageExecutionEventsResult" });
|
|
678
702
|
var RunnerSummary = Schema.Struct({
|
|
679
703
|
address: Schema.String,
|
|
680
704
|
healthy: Schema.Boolean,
|
|
@@ -702,8 +726,8 @@ __export(exports_command, {
|
|
|
702
726
|
CommandTimedOut: () => CommandTimedOut,
|
|
703
727
|
CommandReplyInvalid: () => CommandReplyInvalid
|
|
704
728
|
});
|
|
705
|
-
import { Schema as Schema2 } from "effect";
|
|
706
|
-
var make = (name, options) => ({ name, ...options });
|
|
729
|
+
import { Function, Schema as Schema2 } from "effect";
|
|
730
|
+
var make = Function.dual(2, (name, options) => ({ name, ...options }));
|
|
707
731
|
var inputSchemaRef = (name) => `relay/command/${name}/input`;
|
|
708
732
|
var outputSchemaRef = (name) => `relay/command/${name}/output`;
|
|
709
733
|
|
|
@@ -756,6 +780,7 @@ __export(exports_client, {
|
|
|
756
780
|
registerAgent: () => registerAgent,
|
|
757
781
|
registerAddressBookRoute: () => registerAddressBookRoute,
|
|
758
782
|
publishTopic: () => publishTopic,
|
|
783
|
+
pageExecutionEvents: () => pageExecutionEvents,
|
|
759
784
|
listWaits: () => listWaits,
|
|
760
785
|
listTopicSubscriptions: () => listTopicSubscriptions,
|
|
761
786
|
listToolAttempts: () => listToolAttempts,
|
|
@@ -805,10 +830,10 @@ __export(exports_client, {
|
|
|
805
830
|
EntityNamespaceReserved: () => EntityNamespaceReserved,
|
|
806
831
|
ClientError: () => ClientError
|
|
807
832
|
});
|
|
808
|
-
import { Clock, Context as Context2, Effect as Effect2, Layer as Layer2, Option, Schema as Schema4, SchemaGetter, SchemaIssue, Stream } from "effect";
|
|
833
|
+
import { Clock, Context as Context2, Effect as Effect2, Layer as Layer2, Option, Random, Schema as Schema4, SchemaGetter, SchemaIssue, Stream } from "effect";
|
|
809
834
|
import { EntityId, ShardId, Sharding, ShardingConfig } from "effect/unstable/cluster";
|
|
810
835
|
// src/runtime-capability-policy.ts
|
|
811
|
-
import { Context, Effect, Layer, Schema as Schema3 } from "effect";
|
|
836
|
+
import { Context, Effect, Function as Function2, Layer, Schema as Schema3 } from "effect";
|
|
812
837
|
|
|
813
838
|
class RuntimeCapabilityUnavailable extends Schema3.TaggedErrorClass()("RuntimeCapabilityUnavailable", {
|
|
814
839
|
capability: Schema3.Literals(["fan-out", "workflow-definition"]),
|
|
@@ -817,18 +842,18 @@ class RuntimeCapabilityUnavailable extends Schema3.TaggedErrorClass()("RuntimeCa
|
|
|
817
842
|
}) {
|
|
818
843
|
}
|
|
819
844
|
|
|
820
|
-
class Service extends Context.Service()("@relayfx/sdk/
|
|
845
|
+
class Service extends Context.Service()("@relayfx/sdk/runtime-capability-policy/Service") {
|
|
821
846
|
}
|
|
822
|
-
var layer = (role, capabilities) => Layer.succeed(Service, {
|
|
847
|
+
var layer = Function2.dual(2, (role, capabilities) => Layer.succeed(Service, {
|
|
823
848
|
admit: (capability) => {
|
|
824
849
|
const enabled = capability === "fan-out" ? capabilities.fanOut : capabilities.workflowDefinition;
|
|
825
|
-
return enabled ? Effect.void : Effect.fail(
|
|
850
|
+
return enabled ? Effect.void : Effect.fail(RuntimeCapabilityUnavailable.make({
|
|
826
851
|
capability,
|
|
827
852
|
role,
|
|
828
853
|
nextAction: role === "embedded" ? "enable-embedded-capability" : "use-embedded-runtime"
|
|
829
854
|
}));
|
|
830
855
|
}
|
|
831
|
-
});
|
|
856
|
+
}));
|
|
832
857
|
|
|
833
858
|
// src/client.ts
|
|
834
859
|
class ClientError extends Schema4.TaggedErrorClass()("ClientError", {
|
|
@@ -852,7 +877,7 @@ class WaitKindMismatch extends Schema4.TaggedErrorClass()("WaitKindMismatch", {
|
|
|
852
877
|
}) {
|
|
853
878
|
}
|
|
854
879
|
|
|
855
|
-
class Service2 extends Context2.Service()("@relayfx/sdk/
|
|
880
|
+
class Service2 extends Context2.Service()("@relayfx/sdk/client/Service") {
|
|
856
881
|
}
|
|
857
882
|
var followTerminalStatus = (type) => type === "execution.completed" ? "completed" : type === "execution.failed" ? "failed" : type === "execution.cancelled" ? "cancelled" : undefined;
|
|
858
883
|
var followReconnectDelayMillis = (attempt) => Math.min(100 * 2 ** (attempt - 1), 5000);
|
|
@@ -864,7 +889,7 @@ var followStopped = (reason, cursor) => ({
|
|
|
864
889
|
var followExecutionFrom = (dependencies) => (input) => {
|
|
865
890
|
const maxReconnects = input.max_reconnects ?? 10;
|
|
866
891
|
const stopModes = input.stop_on_wait_modes;
|
|
867
|
-
const inspect = Effect2.suspend(() => dependencies.inspectExecution(input.execution_id)).pipe(Effect2.catchTag("ExecutionNotFound", (error) =>
|
|
892
|
+
const inspect = Effect2.suspend(() => dependencies.inspectExecution(input.execution_id)).pipe(Effect2.catchTag("ExecutionNotFound", (error) => ClientError.make({ message: `execution ${error.execution_id} not found` })));
|
|
868
893
|
const reconcile = (state, message) => Stream.unwrap(Effect2.gen(function* () {
|
|
869
894
|
const inspection = yield* inspect;
|
|
870
895
|
const terminal = followTerminalStatus(`execution.${inspection.status}`);
|
|
@@ -876,7 +901,7 @@ var followExecutionFrom = (dependencies) => (input) => {
|
|
|
876
901
|
return Stream.make(followStopped({ _tag: "actionable_wait", wait: actionable }, state.cursor));
|
|
877
902
|
}
|
|
878
903
|
if (state.attempts >= maxReconnects) {
|
|
879
|
-
return Stream.fail(
|
|
904
|
+
return Stream.fail(ClientError.make({
|
|
880
905
|
message: `follow of ${input.execution_id} exhausted ${maxReconnects} reconnects: ${message}`
|
|
881
906
|
}));
|
|
882
907
|
}
|
|
@@ -900,7 +925,7 @@ var followExecutionFrom = (dependencies) => (input) => {
|
|
|
900
925
|
if (stopModes !== undefined && event.type === "wait.created") {
|
|
901
926
|
const mode = event.data?.mode;
|
|
902
927
|
if (typeof mode === "string" && stopModes.includes(mode)) {
|
|
903
|
-
const inspection = yield* dependencies.inspectExecution(input.execution_id).pipe(Effect2.catchTag("ExecutionNotFound", () => Effect2.
|
|
928
|
+
const inspection = yield* dependencies.inspectExecution(input.execution_id).pipe(Effect2.catchTag("ExecutionNotFound", () => Effect2.void));
|
|
904
929
|
const actionable = inspection?.waiting_on.find((wait) => wait.state === "open" && wait.wait_id === event.data?.wait_id);
|
|
905
930
|
if (actionable !== undefined) {
|
|
906
931
|
items.push(followStopped({ _tag: "actionable_wait", wait: actionable }, state.cursor));
|
|
@@ -916,7 +941,7 @@ var followExecutionFrom = (dependencies) => (input) => {
|
|
|
916
941
|
return Stream.unwrap(Effect2.gen(function* () {
|
|
917
942
|
const existing = yield* dependencies.getExecution(input.execution_id);
|
|
918
943
|
if (existing === undefined) {
|
|
919
|
-
return Stream.fail(
|
|
944
|
+
return Stream.fail(ClientError.make({ message: `execution ${input.execution_id} not found` }));
|
|
920
945
|
}
|
|
921
946
|
const state = {
|
|
922
947
|
cursor: input.after_cursor,
|
|
@@ -938,8 +963,8 @@ var errorMessage = (error) => {
|
|
|
938
963
|
}
|
|
939
964
|
return String(error);
|
|
940
965
|
};
|
|
941
|
-
var toClientError = (error) =>
|
|
942
|
-
var rejectReserved = (id, prefix) => id.startsWith(prefix) ? Effect2.fail(
|
|
966
|
+
var toClientError = (error) => ClientError.make({ message: errorMessage(error) });
|
|
967
|
+
var rejectReserved = (id, prefix) => id.startsWith(prefix) ? Effect2.fail(EntityNamespaceReserved.make({ id, message: "start entities via Client.getOrCreateEntity" })) : Effect2.void;
|
|
943
968
|
var replyValueFrom = (content) => {
|
|
944
969
|
if (content === undefined || content.length === 0)
|
|
945
970
|
return Option.none();
|
|
@@ -1087,9 +1112,9 @@ var modelSelectionFromBatonAgent = (selection) => ({
|
|
|
1087
1112
|
model: selection.model,
|
|
1088
1113
|
...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
|
|
1089
1114
|
});
|
|
1090
|
-
var decodeBatonAgentName = (name) => Schema4.decodeUnknownEffect(exports_shared_schema.NonEmptyString)(name).pipe(Effect2.mapError(() =>
|
|
1091
|
-
var decodeBatonAgentMetadata = (metadata) => metadata === undefined ? Effect2.
|
|
1092
|
-
var decodeBatonMemorySubject = (subject) => Schema4.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect2.mapError(() =>
|
|
1115
|
+
var decodeBatonAgentName = (name) => Schema4.decodeUnknownEffect(exports_shared_schema.NonEmptyString)(name).pipe(Effect2.mapError(() => ClientError.make({ message: "Baton agent name must not be blank" })));
|
|
1116
|
+
var decodeBatonAgentMetadata = (metadata) => metadata === undefined ? Effect2.void : Schema4.decodeUnknownEffect(exports_shared_schema.Metadata)(metadata).pipe(Effect2.mapError(() => ClientError.make({ message: "Baton agent metadata must be JSON metadata" })));
|
|
1117
|
+
var decodeBatonMemorySubject = (subject) => Schema4.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect2.mapError(() => ClientError.make({ message: "Baton agent memory subject must be a MemorySubjectId" })));
|
|
1093
1118
|
var metadataFromBatonAgent = Effect2.fn("Client.metadataFromBatonAgent")(function* (input) {
|
|
1094
1119
|
const agentMetadata = yield* decodeBatonAgentMetadata(input.agent.metadata);
|
|
1095
1120
|
const memorySubject = input.agent.memory === undefined ? undefined : yield* decodeBatonMemorySubject(input.agent.memory.subject);
|
|
@@ -1105,32 +1130,32 @@ var modelSelectionFromRegisterInput = (input) => {
|
|
|
1105
1130
|
return Effect2.succeed(input.model);
|
|
1106
1131
|
if (input.agent.model !== undefined)
|
|
1107
1132
|
return Effect2.succeed(modelSelectionFromBatonAgent(input.agent.model));
|
|
1108
|
-
return Effect2.fail(
|
|
1133
|
+
return Effect2.fail(ClientError.make({ message: "Client.registerAgent requires model or agent.model" }));
|
|
1109
1134
|
};
|
|
1110
|
-
var batonTurnPolicyInvalid = (detail) =>
|
|
1135
|
+
var batonTurnPolicyInvalid = (detail) => ClientError.make({ message: `Baton agent turn policy is not durably portable: ${detail}` });
|
|
1111
1136
|
var turnPolicySnapshotFromBaton = Effect2.fn("Client.turnPolicySnapshotFromBaton")(function* (snapshot) {
|
|
1112
1137
|
let nodes = 0;
|
|
1113
1138
|
const visit = (current, depth) => Effect2.gen(function* () {
|
|
1114
1139
|
if (typeof current !== "object" || current === null || Array.isArray(current)) {
|
|
1115
|
-
return yield*
|
|
1140
|
+
return yield* batonTurnPolicyInvalid("snapshot nodes must be objects");
|
|
1116
1141
|
}
|
|
1117
1142
|
const node = current;
|
|
1118
1143
|
nodes += 1;
|
|
1119
1144
|
if (depth > exports_agent_schema.maxTurnPolicySnapshotDepth) {
|
|
1120
|
-
return yield*
|
|
1145
|
+
return yield* batonTurnPolicyInvalid(`depth exceeds ${exports_agent_schema.maxTurnPolicySnapshotDepth}`);
|
|
1121
1146
|
}
|
|
1122
1147
|
if (nodes > exports_agent_schema.maxTurnPolicySnapshotNodes) {
|
|
1123
|
-
return yield*
|
|
1148
|
+
return yield* batonTurnPolicyInvalid(`node count exceeds ${exports_agent_schema.maxTurnPolicySnapshotNodes}`);
|
|
1124
1149
|
}
|
|
1125
1150
|
switch (node._tag) {
|
|
1126
1151
|
case "Recurs":
|
|
1127
1152
|
if (typeof node.count !== "number" || !Number.isInteger(node.count) || node.count < 0) {
|
|
1128
|
-
return yield*
|
|
1153
|
+
return yield* batonTurnPolicyInvalid("recurs count must be a non-negative integer");
|
|
1129
1154
|
}
|
|
1130
1155
|
return { kind: "recurs", count: node.count };
|
|
1131
1156
|
case "UntilToolCall":
|
|
1132
1157
|
if (typeof node.name !== "string" || node.name.trim().length === 0) {
|
|
1133
|
-
return yield*
|
|
1158
|
+
return yield* batonTurnPolicyInvalid("until-tool-call name must not be blank");
|
|
1134
1159
|
}
|
|
1135
1160
|
return { kind: "until-tool-call", name: node.name };
|
|
1136
1161
|
case "Both":
|
|
@@ -1140,7 +1165,7 @@ var turnPolicySnapshotFromBaton = Effect2.fn("Client.turnPolicySnapshotFromBaton
|
|
|
1140
1165
|
second: yield* visit(node.second, depth + 1)
|
|
1141
1166
|
};
|
|
1142
1167
|
default:
|
|
1143
|
-
return yield*
|
|
1168
|
+
return yield* batonTurnPolicyInvalid("snapshot tag is not recognized");
|
|
1144
1169
|
}
|
|
1145
1170
|
});
|
|
1146
1171
|
return yield* visit(snapshot, 1);
|
|
@@ -1150,7 +1175,7 @@ var turnPolicyFieldsFromRegisterInput = Effect2.fn("Client.turnPolicyFieldsFromR
|
|
|
1150
1175
|
return { max_tool_turns: input.max_tool_turns };
|
|
1151
1176
|
const snapshot = input.agent.policy.snapshot;
|
|
1152
1177
|
if (snapshot === undefined) {
|
|
1153
|
-
return yield*
|
|
1178
|
+
return yield* batonTurnPolicyInvalid("opaque policies require an explicit max_tool_turns replacement");
|
|
1154
1179
|
}
|
|
1155
1180
|
const durable = yield* turnPolicySnapshotFromBaton(snapshot);
|
|
1156
1181
|
if (durable.kind === "recurs" && durable.count === 8)
|
|
@@ -1243,19 +1268,19 @@ var resolveToolOutcomeWait = Effect2.fn("Client.resolveToolOutcomeWait")(functio
|
|
|
1243
1268
|
const waitId = call.waitId ?? toolWaitId(call.call.id);
|
|
1244
1269
|
const wait = yield* waits.get(waitId).pipe(Effect2.mapError(toClientError));
|
|
1245
1270
|
if (wait === undefined)
|
|
1246
|
-
return yield*
|
|
1271
|
+
return yield* ClientError.make({ message: `Tool wait not found: ${waitId}` });
|
|
1247
1272
|
if (wait.executionId !== call.executionId) {
|
|
1248
|
-
return yield*
|
|
1273
|
+
return yield* ClientError.make({ message: `Tool wait does not match call: ${call.call.id}` });
|
|
1249
1274
|
}
|
|
1250
1275
|
if (wait.state === "resolved") {
|
|
1251
1276
|
const accepted = yield* acceptedWaitOutcome(wait);
|
|
1252
1277
|
if (exports_shared_schema.canonicalString(accepted) !== exports_shared_schema.canonicalString(outcome)) {
|
|
1253
|
-
return yield*
|
|
1278
|
+
return yield* ClientError.make({ message: `Tool outcome conflicts with accepted wait: ${call.call.id}` });
|
|
1254
1279
|
}
|
|
1255
1280
|
return wait;
|
|
1256
1281
|
}
|
|
1257
1282
|
if (wait.state !== "open") {
|
|
1258
|
-
return yield*
|
|
1283
|
+
return yield* ClientError.make({ message: `Tool wait is ${wait.state}: ${call.call.id}` });
|
|
1259
1284
|
}
|
|
1260
1285
|
const eventSequence = yield* nextEventSequence(eventLog, call.executionId);
|
|
1261
1286
|
const resolved = yield* waits.wake({
|
|
@@ -1267,19 +1292,19 @@ var resolveToolOutcomeWait = Effect2.fn("Client.resolveToolOutcomeWait")(functio
|
|
|
1267
1292
|
if (!resolved.transitioned) {
|
|
1268
1293
|
const accepted = yield* acceptedWaitOutcome(resolved.wait);
|
|
1269
1294
|
if (exports_shared_schema.canonicalString(accepted) !== exports_shared_schema.canonicalString(outcome)) {
|
|
1270
|
-
return yield*
|
|
1295
|
+
return yield* ClientError.make({ message: `Tool outcome conflicts with accepted wait: ${call.call.id}` });
|
|
1271
1296
|
}
|
|
1272
1297
|
}
|
|
1273
1298
|
return resolved.wait;
|
|
1274
1299
|
});
|
|
1275
1300
|
var signalToolOutcome = Effect2.fn("Client.signalToolOutcome")(function* (executionRepository, makeExecutionClient, wait, signaledAt) {
|
|
1276
|
-
yield* exports_wait_signal.signalWorkflowWait({
|
|
1277
|
-
makeExecutionClient,
|
|
1301
|
+
yield* Effect2.mapError(Effect2.orDie(exports_wait_signal.signalWorkflowWait({
|
|
1302
|
+
makeExecutionClient: typedWaitSignalClient(makeExecutionClient),
|
|
1278
1303
|
executionId: wait.executionId,
|
|
1279
1304
|
waitId: wait.id,
|
|
1280
1305
|
state: "resolved",
|
|
1281
1306
|
signaledAt
|
|
1282
|
-
}).pipe(Effect2.provideService(exports_execution_repository.Service, executionRepository),
|
|
1307
|
+
}).pipe(Effect2.provideService(exports_execution_repository.Service, executionRepository))), toClientError);
|
|
1283
1308
|
});
|
|
1284
1309
|
var toReady = (record) => ({
|
|
1285
1310
|
id: record.id,
|
|
@@ -1294,6 +1319,12 @@ var toLease = (record) => ({
|
|
|
1294
1319
|
worker_id: record.claimOwner ?? "unclaimed",
|
|
1295
1320
|
claim_expires_at: record.claimExpiresAt ?? record.updatedAt
|
|
1296
1321
|
});
|
|
1322
|
+
var typedWaitSignalClient = (makeExecutionClient) => (executionId) => {
|
|
1323
|
+
const client = makeExecutionClient(executionId);
|
|
1324
|
+
return {
|
|
1325
|
+
signalWait: (input) => client.signalWait(input).pipe(Effect2.mapError((error) => exports_wait_signal.WaitSignalError.make({ message: String(error) })))
|
|
1326
|
+
};
|
|
1327
|
+
};
|
|
1297
1328
|
var nextEventSequence = Effect2.fn("Client.nextEventSequence")(function* (eventLog, executionId) {
|
|
1298
1329
|
const max = yield* eventLog.maxSequence(executionId).pipe(Effect2.mapError(toClientError));
|
|
1299
1330
|
return max === undefined ? 0 : max + 1;
|
|
@@ -1306,10 +1337,10 @@ var terminalChildStatus = (metadata) => {
|
|
|
1306
1337
|
var wakeRuntime = Effect2.fn("Client.wakeRuntime")(function* (waits, eventLog, executionRepository, makeExecutionClient, input, accepts) {
|
|
1307
1338
|
const wait = yield* waits.get(input.wait_id).pipe(Effect2.mapError(toClientError));
|
|
1308
1339
|
if (wait === undefined)
|
|
1309
|
-
return yield*
|
|
1340
|
+
return yield* ClientError.make({ message: `Wait not found: ${input.wait_id}` });
|
|
1310
1341
|
const kind = waitSemanticKind(wait);
|
|
1311
1342
|
if (accepts !== undefined && kind !== accepts) {
|
|
1312
|
-
return yield*
|
|
1343
|
+
return yield* WaitKindMismatch.make({
|
|
1313
1344
|
wait_id: input.wait_id,
|
|
1314
1345
|
expected: accepts,
|
|
1315
1346
|
actual: kind,
|
|
@@ -1317,7 +1348,7 @@ var wakeRuntime = Effect2.fn("Client.wakeRuntime")(function* (waits, eventLog, e
|
|
|
1317
1348
|
});
|
|
1318
1349
|
}
|
|
1319
1350
|
if (accepts === undefined && kind === "child" && !terminalChildStatus(input.metadata)) {
|
|
1320
|
-
return yield*
|
|
1351
|
+
return yield* WaitKindMismatch.make({
|
|
1321
1352
|
wait_id: input.wait_id,
|
|
1322
1353
|
expected: 'child wake with terminal metadata.child_status ("completed" | "failed" | "cancelled")',
|
|
1323
1354
|
actual: kind,
|
|
@@ -1325,7 +1356,7 @@ var wakeRuntime = Effect2.fn("Client.wakeRuntime")(function* (waits, eventLog, e
|
|
|
1325
1356
|
});
|
|
1326
1357
|
}
|
|
1327
1358
|
if (input.state === "cancelled" && wait.metadata.kind === "tool-placement") {
|
|
1328
|
-
return yield*
|
|
1359
|
+
return yield* ClientError.make({ message: "Tool placement waits must be cancelled through cancelExecution" });
|
|
1329
1360
|
}
|
|
1330
1361
|
const eventSequence = yield* nextEventSequence(eventLog, wait.executionId);
|
|
1331
1362
|
const result = input.state === "resolved" ? yield* waits.wake({
|
|
@@ -1345,13 +1376,13 @@ var wakeRuntime = Effect2.fn("Client.wakeRuntime")(function* (waits, eventLog, e
|
|
|
1345
1376
|
metadata: wakeMetadata(input)
|
|
1346
1377
|
}).pipe(Effect2.mapError(toClientError));
|
|
1347
1378
|
if (result.transitioned) {
|
|
1348
|
-
yield* exports_wait_signal.signalWorkflowWait({
|
|
1349
|
-
makeExecutionClient,
|
|
1379
|
+
yield* Effect2.mapError(Effect2.orDie(exports_wait_signal.signalWorkflowWait({
|
|
1380
|
+
makeExecutionClient: typedWaitSignalClient(makeExecutionClient),
|
|
1350
1381
|
executionId: result.wait.executionId,
|
|
1351
1382
|
waitId: result.wait.id,
|
|
1352
1383
|
state: input.state,
|
|
1353
1384
|
signaledAt: input.signaled_at
|
|
1354
|
-
}).pipe(Effect2.provideService(exports_execution_repository.Service, executionRepository),
|
|
1385
|
+
}).pipe(Effect2.provideService(exports_execution_repository.Service, executionRepository))), toClientError);
|
|
1355
1386
|
}
|
|
1356
1387
|
return {
|
|
1357
1388
|
wait_id: result.wait.id,
|
|
@@ -1420,20 +1451,20 @@ var reconcileExistingChildSpawn = Effect2.fn("Client.reconcileExistingChildSpawn
|
|
|
1420
1451
|
if (existing === undefined)
|
|
1421
1452
|
return;
|
|
1422
1453
|
if (existing.executionId !== input.execution_id || existing.addressId !== input.address_id || childSpawnFingerprint(existing) !== exports_shared_schema.canonicalString(input)) {
|
|
1423
|
-
return yield*
|
|
1454
|
+
return yield* ClientError.make({ message: `Child execution conflicts: ${childExecutionId}` });
|
|
1424
1455
|
}
|
|
1425
1456
|
const spawned = yield* eventLog.findByCursor({
|
|
1426
1457
|
executionId: input.execution_id,
|
|
1427
1458
|
cursor: `${input.execution_id}:child:${childExecutionId}:spawned`
|
|
1428
1459
|
}).pipe(Effect2.mapError(toClientError));
|
|
1429
1460
|
if (Option.isNone(spawned)) {
|
|
1430
|
-
return yield*
|
|
1461
|
+
return yield* ClientError.make({ message: `Child spawn event missing: ${childExecutionId}` });
|
|
1431
1462
|
}
|
|
1432
1463
|
const parentWaitId = input.wait === true ? childJoinWaitId(childExecutionId) : undefined;
|
|
1433
1464
|
if (parentWaitId !== undefined) {
|
|
1434
1465
|
const wait = yield* waits.get(parentWaitId).pipe(Effect2.mapError(toClientError));
|
|
1435
1466
|
if (wait === undefined) {
|
|
1436
|
-
return yield*
|
|
1467
|
+
return yield* ClientError.make({ message: `Child join wait missing: ${childExecutionId}` });
|
|
1437
1468
|
}
|
|
1438
1469
|
}
|
|
1439
1470
|
return {
|
|
@@ -1445,10 +1476,10 @@ var reconcileExistingChildSpawn = Effect2.fn("Client.reconcileExistingChildSpawn
|
|
|
1445
1476
|
var parentDefinitionPin = Effect2.fn("Client.parentDefinitionPin")(function* (executionRepository, executionId) {
|
|
1446
1477
|
const record = yield* executionRepository.get(executionId).pipe(Effect2.mapError(toClientError));
|
|
1447
1478
|
if (record === undefined) {
|
|
1448
|
-
return yield*
|
|
1479
|
+
return yield* ClientError.make({ message: `Execution not found: ${executionId}` });
|
|
1449
1480
|
}
|
|
1450
1481
|
if (record.agentId === undefined || record.agentRevision === undefined || record.agentSnapshot === undefined) {
|
|
1451
|
-
return yield*
|
|
1482
|
+
return yield* ClientError.make({ message: `Parent execution is not pinned to an agent: ${executionId}` });
|
|
1452
1483
|
}
|
|
1453
1484
|
return {
|
|
1454
1485
|
agentId: record.agentId,
|
|
@@ -1515,12 +1546,12 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1515
1546
|
if (Option.isSome(childFanOutRuntime)) {
|
|
1516
1547
|
const fanOut = yield* childFanOutRuntime.value.cancel(input.fan_out_id, input.cancelled_at, input.reason ?? "child fan-out cancelled").pipe(Effect2.mapError(toClientError));
|
|
1517
1548
|
if (fanOut === undefined)
|
|
1518
|
-
return yield*
|
|
1549
|
+
return yield* ClientError.make({ message: `Child fan-out not found: ${input.fan_out_id}` });
|
|
1519
1550
|
return { fan_out: fanOut };
|
|
1520
1551
|
}
|
|
1521
1552
|
const result = yield* childFanOuts.cancel(input.fan_out_id, input.cancelled_at).pipe(Effect2.mapError(toClientError));
|
|
1522
1553
|
if (result === undefined)
|
|
1523
|
-
return yield*
|
|
1554
|
+
return yield* ClientError.make({ message: `Child fan-out not found: ${input.fan_out_id}` });
|
|
1524
1555
|
yield* Effect2.forEach(result.activeChildExecutionIds, (childId) => makeExecutionClient(exports_ids_schema.ExecutionId.make(childId)).cancel({
|
|
1525
1556
|
execution_id: exports_ids_schema.ExecutionId.make(childId),
|
|
1526
1557
|
cancelled_at: input.cancelled_at,
|
|
@@ -1566,14 +1597,14 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1566
1597
|
const awaitWaitOperation = Effect2.fn("Client.runtime.awaitWait")(function* (input) {
|
|
1567
1598
|
const current = yield* envelopeReady.getWait(input.wait_id).pipe(Effect2.mapError(toClientError));
|
|
1568
1599
|
if (current === undefined) {
|
|
1569
|
-
return yield*
|
|
1600
|
+
return yield* ClientError.make({ message: `wait ${input.wait_id} not found` });
|
|
1570
1601
|
}
|
|
1571
1602
|
if (current.state !== "open")
|
|
1572
1603
|
return yield* waitOutcomeFrom(current);
|
|
1573
1604
|
yield* eventLog.stream({ executionId: input.execution_id }).pipe(Stream.filter((event) => (event.type === "wait.woken" || event.type === "wait.timed_out" || event.type === "wait.cancelled") && event.data?.wait_id === input.wait_id), Stream.take(1), Stream.runDrain, Effect2.mapError(toClientError));
|
|
1574
1605
|
const terminal = yield* envelopeReady.getWait(input.wait_id).pipe(Effect2.mapError(toClientError));
|
|
1575
1606
|
if (terminal === undefined || terminal.state === "open") {
|
|
1576
|
-
return yield*
|
|
1607
|
+
return yield* ClientError.make({ message: `wait ${input.wait_id} did not reach a terminal state` });
|
|
1577
1608
|
}
|
|
1578
1609
|
return yield* waitOutcomeFrom(terminal);
|
|
1579
1610
|
});
|
|
@@ -1589,7 +1620,7 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1589
1620
|
const inspectExecutionOperation = Effect2.fn("Client.runtime.inspectExecution")(function* (executionId) {
|
|
1590
1621
|
const execution = yield* executionRepository.get(executionId).pipe(Effect2.mapError(toClientError));
|
|
1591
1622
|
if (execution === undefined)
|
|
1592
|
-
return yield*
|
|
1623
|
+
return yield* ExecutionNotFound.make({ execution_id: executionId });
|
|
1593
1624
|
const openWaits = yield* envelopeReady.listAllWaits({ executionId, state: "open" }).pipe(Effect2.mapError(toClientError));
|
|
1594
1625
|
const calls = yield* toolCalls.listCalls(executionId).pipe(Effect2.mapError(toClientError));
|
|
1595
1626
|
const pendingChunks = yield* Effect2.forEach(calls, (call) => toolCalls.getResult(call.call.id).pipe(Effect2.mapError(toClientError), Effect2.map((result) => result === undefined ? [toToolCallSummary(call)] : [])));
|
|
@@ -1676,8 +1707,8 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1676
1707
|
getAgentDefinition: Effect2.fn("Client.runtime.getAgentDefinition")(function* (id) {
|
|
1677
1708
|
return yield* agentRegistry.get(id).pipe(Effect2.mapError(toClientError));
|
|
1678
1709
|
}),
|
|
1679
|
-
listAgentDefinitions: Effect2.fn("Client.runtime.listAgentDefinitions")(function* () {
|
|
1680
|
-
return yield* agentRegistry.list
|
|
1710
|
+
listAgentDefinitions: Effect2.fn("Client.runtime.listAgentDefinitions")(function* (_) {
|
|
1711
|
+
return yield* agentRegistry.list.pipe(Effect2.mapError(toClientError));
|
|
1681
1712
|
}),
|
|
1682
1713
|
listAgentDefinitionRevisions: Effect2.fn("Client.runtime.listAgentDefinitionRevisions")(function* (id) {
|
|
1683
1714
|
return yield* agentRegistry.listRevisions(id).pipe(Effect2.mapError(toClientError));
|
|
@@ -1685,8 +1716,8 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1685
1716
|
getSkillDefinition: Effect2.fn("Client.runtime.getSkillDefinition")(function* (id) {
|
|
1686
1717
|
return yield* skillRegistry.get(id).pipe(Effect2.mapError(toClientError));
|
|
1687
1718
|
}),
|
|
1688
|
-
listSkillDefinitions: Effect2.fn("Client.runtime.listSkillDefinitions")(function* () {
|
|
1689
|
-
return yield* skillRegistry.list
|
|
1719
|
+
listSkillDefinitions: Effect2.fn("Client.runtime.listSkillDefinitions")(function* (_) {
|
|
1720
|
+
return yield* skillRegistry.list.pipe(Effect2.mapError(toClientError));
|
|
1690
1721
|
}),
|
|
1691
1722
|
listSkillDefinitionRevisions: Effect2.fn("Client.runtime.listSkillDefinitionRevisions")(function* (id) {
|
|
1692
1723
|
return yield* skillRegistry.listRevisions(id).pipe(Effect2.mapError(toClientError));
|
|
@@ -1698,8 +1729,8 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1698
1729
|
getAddressBookRoute: Effect2.fn("Client.runtime.getAddressBookRoute")(function* (id) {
|
|
1699
1730
|
return yield* addressBook.get(id).pipe(Effect2.mapError(toClientError));
|
|
1700
1731
|
}),
|
|
1701
|
-
listAddressBookRoutes: Effect2.fn("Client.runtime.listAddressBookRoutes")(function* () {
|
|
1702
|
-
return yield* addressBook.list
|
|
1732
|
+
listAddressBookRoutes: Effect2.fn("Client.runtime.listAddressBookRoutes")(function* (_) {
|
|
1733
|
+
return yield* addressBook.list.pipe(Effect2.mapError(toClientError));
|
|
1703
1734
|
}),
|
|
1704
1735
|
startExecution: Effect2.fn("Client.runtime.startExecution")(function* (input) {
|
|
1705
1736
|
yield* rejectReserved(input.execution_id, "execution:entity:");
|
|
@@ -1726,7 +1757,9 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1726
1757
|
yield* rejectReserved(input.session_id, "session:entity:");
|
|
1727
1758
|
const definition = yield* agentRegistry.getRevision({ id: input.agent_id, revision: input.agent_revision }).pipe(Effect2.mapError(toClientError));
|
|
1728
1759
|
if (definition === undefined) {
|
|
1729
|
-
return yield*
|
|
1760
|
+
return yield* ClientError.make({
|
|
1761
|
+
message: `Agent revision not found: ${input.agent_id}@${input.agent_revision}`
|
|
1762
|
+
});
|
|
1730
1763
|
}
|
|
1731
1764
|
const payload = startExecutionByAgentDefinitionPayload(input, definition);
|
|
1732
1765
|
const client = makeExecutionClient(payload.execution_id);
|
|
@@ -1749,10 +1782,10 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1749
1782
|
steer: Effect2.fn("Client.runtime.steer")(function* (input) {
|
|
1750
1783
|
const execution = yield* executionRepository.get(input.execution_id).pipe(Effect2.mapError(toClientError));
|
|
1751
1784
|
if (execution === undefined) {
|
|
1752
|
-
return yield*
|
|
1785
|
+
return yield* ClientError.make({ message: `Execution not found: ${input.execution_id}` });
|
|
1753
1786
|
}
|
|
1754
1787
|
if (execution.status !== "running") {
|
|
1755
|
-
return yield*
|
|
1788
|
+
return yield* ClientError.make({ message: `Execution is not running: ${input.execution_id}` });
|
|
1756
1789
|
}
|
|
1757
1790
|
const record = yield* steering.appendForRunning({
|
|
1758
1791
|
executionId: input.execution_id,
|
|
@@ -1778,19 +1811,19 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1778
1811
|
return records.map(toWaitView);
|
|
1779
1812
|
}),
|
|
1780
1813
|
listExecutions: Effect2.fn("Client.runtime.listExecutions")(function* (input) {
|
|
1781
|
-
const cursor = input.cursor === undefined ? undefined : yield* Schema4.decodeEffect(ExecutionCursorFromString)(input.cursor)
|
|
1814
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema4.decodeEffect(ExecutionCursorFromString)(input.cursor);
|
|
1782
1815
|
const result = yield* executionRepository.list({
|
|
1783
1816
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
1784
1817
|
...input.status === undefined ? {} : { status: input.status },
|
|
1785
1818
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
1786
1819
|
...cursor === undefined ? {} : { cursor }
|
|
1787
|
-
})
|
|
1788
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema4.encodeEffect(ExecutionCursorFromString)(result.nextCursor)
|
|
1820
|
+
});
|
|
1821
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema4.encodeEffect(ExecutionCursorFromString)(result.nextCursor);
|
|
1789
1822
|
return {
|
|
1790
1823
|
records: result.records.map(toConversationSummary),
|
|
1791
1824
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
1792
1825
|
};
|
|
1793
|
-
}),
|
|
1826
|
+
}, Effect2.mapError(toClientError)),
|
|
1794
1827
|
subscribeTopic: Effect2.fn("Client.runtime.subscribeTopic")(function* (input) {
|
|
1795
1828
|
return yield* topicService.subscribe({
|
|
1796
1829
|
topicAddressId: input.topic_address_id,
|
|
@@ -1828,22 +1861,22 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1828
1861
|
}).pipe(Effect2.mapError(toClientError));
|
|
1829
1862
|
}),
|
|
1830
1863
|
listSessions: Effect2.fn("Client.runtime.listSessions")(function* (input) {
|
|
1831
|
-
const cursor = input.cursor === undefined ? undefined : yield* Schema4.decodeEffect(SessionCursorFromString)(input.cursor)
|
|
1864
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema4.decodeEffect(SessionCursorFromString)(input.cursor);
|
|
1832
1865
|
const result = yield* sessionRepository.list({
|
|
1833
1866
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
1834
1867
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
1835
1868
|
...cursor === undefined ? {} : { cursor }
|
|
1836
|
-
})
|
|
1837
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema4.encodeEffect(SessionCursorFromString)(result.nextCursor)
|
|
1869
|
+
});
|
|
1870
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema4.encodeEffect(SessionCursorFromString)(result.nextCursor);
|
|
1838
1871
|
return {
|
|
1839
1872
|
records: result.records.map(toSessionSummary),
|
|
1840
1873
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
1841
1874
|
};
|
|
1842
|
-
}),
|
|
1875
|
+
}, Effect2.mapError(toClientError)),
|
|
1843
1876
|
getSession: Effect2.fn("Client.runtime.getSession")(function* (input) {
|
|
1844
1877
|
const session = yield* sessionRepository.get(input.session_id).pipe(Effect2.mapError(toClientError));
|
|
1845
1878
|
if (session === undefined)
|
|
1846
|
-
return yield*
|
|
1879
|
+
return yield* ClientError.make({ message: `Session not found: ${input.session_id}` });
|
|
1847
1880
|
const cursor = input.cursor === undefined ? undefined : yield* Schema4.decodeEffect(ExecutionCursorFromString)(input.cursor).pipe(Effect2.mapError(toClientError));
|
|
1848
1881
|
const result = yield* executionRepository.list({
|
|
1849
1882
|
sessionId: input.session_id,
|
|
@@ -1865,7 +1898,27 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1865
1898
|
}).pipe(Effect2.mapError(toClientError));
|
|
1866
1899
|
return { events };
|
|
1867
1900
|
}),
|
|
1868
|
-
|
|
1901
|
+
pageExecutionEvents: Effect2.fn("Client.runtime.pageExecutionEvents")(function* (input) {
|
|
1902
|
+
const pageInput = input.direction === "forward" ? {
|
|
1903
|
+
executionId: input.execution_id,
|
|
1904
|
+
direction: "forward",
|
|
1905
|
+
...input.after_cursor === undefined ? {} : { afterCursor: input.after_cursor },
|
|
1906
|
+
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1907
|
+
} : {
|
|
1908
|
+
executionId: input.execution_id,
|
|
1909
|
+
direction: "backward",
|
|
1910
|
+
...input.before_cursor === undefined ? {} : { beforeCursor: input.before_cursor },
|
|
1911
|
+
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1912
|
+
};
|
|
1913
|
+
const result = yield* eventLog.page(pageInput).pipe(Effect2.mapError(toStreamError));
|
|
1914
|
+
return {
|
|
1915
|
+
events: result.events,
|
|
1916
|
+
has_more: result.hasMore,
|
|
1917
|
+
...result.oldestCursor === undefined ? {} : { oldest_cursor: result.oldestCursor },
|
|
1918
|
+
...result.newestCursor === undefined ? {} : { newest_cursor: result.newestCursor }
|
|
1919
|
+
};
|
|
1920
|
+
}),
|
|
1921
|
+
listRunners: Effect2.fn("Client.runtime.listRunners")(function* (_) {
|
|
1869
1922
|
const runners = yield* clusterRegistry.listRunners().pipe(Effect2.mapError(toClientError));
|
|
1870
1923
|
return {
|
|
1871
1924
|
runners: runners.map((runner) => ({
|
|
@@ -1893,7 +1946,7 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1893
1946
|
askEntity: Effect2.fn("Client.runtime.askEntity")(function* (input) {
|
|
1894
1947
|
const instance = yield* entities.get({ kind: input.kind, key: input.key }).pipe(Effect2.mapError(toClientError));
|
|
1895
1948
|
if (instance === undefined || instance.status === "destroyed") {
|
|
1896
|
-
return yield*
|
|
1949
|
+
return yield* EntityNotFound.make({ kind: input.kind, key: input.key });
|
|
1897
1950
|
}
|
|
1898
1951
|
const encoded = yield* Schema4.encodeUnknownEffect(input.command.input)(input.input).pipe(Effect2.mapError(toClientError));
|
|
1899
1952
|
const inputRef = inputSchemaRef(input.command.name);
|
|
@@ -1902,7 +1955,7 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1902
1955
|
yield* schemaRegistry.value.register({ ref: inputRef, schema: input.command.input });
|
|
1903
1956
|
yield* schemaRegistry.value.register({ ref: outputRef, schema: input.command.output });
|
|
1904
1957
|
}
|
|
1905
|
-
const correlation = `command:${input.command.name}:${
|
|
1958
|
+
const correlation = `command:${input.command.name}:${yield* Random.nextInt}`;
|
|
1906
1959
|
const accepted = yield* sendEnvelope({
|
|
1907
1960
|
from: input.from,
|
|
1908
1961
|
to: instance.address_id,
|
|
@@ -1921,28 +1974,28 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1921
1974
|
}
|
|
1922
1975
|
});
|
|
1923
1976
|
if (accepted.wait_id === undefined) {
|
|
1924
|
-
return yield*
|
|
1977
|
+
return yield* ClientError.make({ message: "askEntity send did not create a reply wait" });
|
|
1925
1978
|
}
|
|
1926
1979
|
const outcome = yield* awaitWaitOperation({ wait_id: accepted.wait_id, execution_id: accepted.execution_id });
|
|
1927
1980
|
if (outcome.state === "timed_out") {
|
|
1928
|
-
return yield*
|
|
1981
|
+
return yield* CommandTimedOut.make({
|
|
1929
1982
|
command: input.command.name,
|
|
1930
1983
|
wait_id: outcome.wait_id,
|
|
1931
1984
|
timeout: input.timeout ?? "unspecified"
|
|
1932
1985
|
});
|
|
1933
1986
|
}
|
|
1934
1987
|
if (outcome.state === "cancelled") {
|
|
1935
|
-
return yield*
|
|
1988
|
+
return yield* ClientError.make({ message: `reply wait ${outcome.wait_id} was cancelled` });
|
|
1936
1989
|
}
|
|
1937
1990
|
const replyValue = replyValueFrom(outcome.content);
|
|
1938
1991
|
if (replyValue._tag === "None") {
|
|
1939
|
-
return yield*
|
|
1992
|
+
return yield* CommandReplyInvalid.make({
|
|
1940
1993
|
command: input.command.name,
|
|
1941
1994
|
wait_id: outcome.wait_id,
|
|
1942
1995
|
message: "reply carried no decodable content"
|
|
1943
1996
|
});
|
|
1944
1997
|
}
|
|
1945
|
-
return yield* Schema4.decodeUnknownEffect(input.command.output)(replyValue.value).pipe(Effect2.mapError((issue) =>
|
|
1998
|
+
return yield* Schema4.decodeUnknownEffect(input.command.output)(replyValue.value).pipe(Effect2.mapError((issue) => CommandReplyInvalid.make({
|
|
1946
1999
|
command: input.command.name,
|
|
1947
2000
|
wait_id: outcome.wait_id,
|
|
1948
2001
|
message: errorMessage(issue)
|
|
@@ -1983,14 +2036,14 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
1983
2036
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
1984
2037
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
1985
2038
|
updatedAt: input.updated_at
|
|
1986
|
-
}).pipe(Effect2.mapError((error) =>
|
|
2039
|
+
}).pipe(Effect2.mapError((error) => Schema4.is(exports_execution_state_service.StateVersionConflict)(error) ? error : toClientError(error)))),
|
|
1987
2040
|
deleteEntityState: Effect2.fn("Client.runtime.deleteEntityState")((input) => executionState.remove({
|
|
1988
2041
|
executionId: input.execution_id,
|
|
1989
2042
|
key: input.key,
|
|
1990
2043
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
1991
2044
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
1992
2045
|
removedAt: input.removed_at
|
|
1993
|
-
}).pipe(Effect2.mapError((error) =>
|
|
2046
|
+
}).pipe(Effect2.mapError((error) => Schema4.is(exports_execution_state_service.StateVersionConflict)(error) ? error : toClientError(error)))),
|
|
1994
2047
|
listEntityState: Effect2.fn("Client.runtime.listEntityState")((input) => executionState.list({
|
|
1995
2048
|
executionId: input.execution_id,
|
|
1996
2049
|
...input.prefix === undefined ? {} : { prefix: input.prefix },
|
|
@@ -2041,7 +2094,7 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
2041
2094
|
const coordinated = yield* coordinateToolTransition(Effect2.gen(function* () {
|
|
2042
2095
|
const call = yield* toolCalls.getCall(input.tool_call_id).pipe(Effect2.mapError(toClientError));
|
|
2043
2096
|
if (call === undefined || call.executionId !== input.execution_id || call.placement.kind !== "client") {
|
|
2044
|
-
return yield*
|
|
2097
|
+
return yield* ClientError.make({ message: `Client tool call not found: ${input.tool_call_id}` });
|
|
2045
2098
|
}
|
|
2046
2099
|
const wait = yield* resolveToolOutcomeWait(waits, eventLog, call, input.outcome, input.fulfilled_at);
|
|
2047
2100
|
const accepted = yield* toolCalls.acceptClientOutcome({
|
|
@@ -2070,7 +2123,7 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
2070
2123
|
const active = call !== undefined && call.placement.kind === "remote" && call.state === "running" && call.activeAttemptId === input.attempt_id && call.claimOwner === input.worker_id && call.claimExpiresAt !== undefined && call.claimExpiresAt > input.completed_at;
|
|
2071
2124
|
const acceptedRetry = call !== undefined && call.placement.kind === "remote" && call.state === "submitted" && call.activeAttemptId === input.attempt_id && call.externalOutcome !== undefined;
|
|
2072
2125
|
if (call === undefined || !active && !acceptedRetry) {
|
|
2073
|
-
return yield*
|
|
2126
|
+
return yield* ClientError.make({ message: `Remote tool claim is not active: ${input.tool_call_id}` });
|
|
2074
2127
|
}
|
|
2075
2128
|
const wait = yield* resolveToolOutcomeWait(waits, eventLog, call, input.outcome, input.completed_at);
|
|
2076
2129
|
const accepted = yield* toolCalls.acceptRemoteOutcome({
|
|
@@ -2113,8 +2166,8 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
2113
2166
|
const pin = yield* parentDefinitionPin(executionRepository, input.execution_id);
|
|
2114
2167
|
const createdAt = yield* Clock.currentTimeMillis;
|
|
2115
2168
|
const internal = internalSpawnChildRunInput(input, pin, createdAt);
|
|
2116
|
-
const context = yield* exports_child_run_service.resolveForDispatch(internal).pipe(Effect2.mapError((error) =>
|
|
2117
|
-
const definition = yield* exports_child_run_service.childDefinition(pin.agentSnapshot, context).pipe(Effect2.mapError((error) =>
|
|
2169
|
+
const context = yield* exports_child_run_service.resolveForDispatch(internal).pipe(Effect2.mapError((error) => ClientError.make({ message: error._tag })));
|
|
2170
|
+
const definition = yield* exports_child_run_service.childDefinition(pin.agentSnapshot, context).pipe(Effect2.mapError((error) => ClientError.make({ message: error._tag })));
|
|
2118
2171
|
const coordinated = yield* coordinateChildSpawn(Effect2.gen(function* () {
|
|
2119
2172
|
const existing = yield* reconcileExistingChildSpawn(childExecutions, waits, eventLog, input);
|
|
2120
2173
|
if (existing !== undefined)
|
|
@@ -2122,7 +2175,7 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
2122
2175
|
const accepted = yield* executions.spawnChildRun(internal).pipe(Effect2.mapError(toClientError));
|
|
2123
2176
|
const parentWaitId = input.wait === true ? yield* createChildJoinWait(waits, eventLog, internal, accepted, createdAt) : undefined;
|
|
2124
2177
|
return { accepted, createdAt, parentWaitId };
|
|
2125
|
-
})).pipe(Effect2.catch((error) => error.message === "DuplicateChildExecution" ? coordinateChildSpawn(reconcileExistingChildSpawn(childExecutions, waits, eventLog, input).pipe(Effect2.flatMap((existing) => existing === undefined ? Effect2.fail(
|
|
2178
|
+
})).pipe(Effect2.catch((error) => error.message === "DuplicateChildExecution" ? coordinateChildSpawn(reconcileExistingChildSpawn(childExecutions, waits, eventLog, input).pipe(Effect2.flatMap((existing) => existing === undefined ? Effect2.fail(ClientError.make({ message: `Child execution retry missing: ${input.execution_id}` })) : Effect2.succeed(existing)))) : Effect2.fail(error)));
|
|
2126
2179
|
const startPayload = childStartInput(internal, coordinated.accepted, pin, definition, coordinated.createdAt, coordinated.parentWaitId);
|
|
2127
2180
|
const client = makeExecutionClient(startPayload.execution_id);
|
|
2128
2181
|
yield* client.dispatch(startPayload).pipe(Effect2.mapError(toClientError));
|
|
@@ -2132,7 +2185,7 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
|
2132
2185
|
if (Option.isSome(runtimeCapabilityPolicy))
|
|
2133
2186
|
yield* runtimeCapabilityPolicy.value.admit("fan-out");
|
|
2134
2187
|
if (Option.isNone(childFanOutRuntime)) {
|
|
2135
|
-
return yield*
|
|
2188
|
+
return yield* ClientError.make({
|
|
2136
2189
|
message: "Child fan-out runtime unavailable; provide ChildFanOutRuntime.Service to Client.layerFromRuntime"
|
|
2137
2190
|
});
|
|
2138
2191
|
}
|
|
@@ -2218,10 +2271,11 @@ var testLayer = (implementation) => Layer2.succeed(Service2, Service2.of({
|
|
|
2218
2271
|
streamExecution: implementation.streamExecution
|
|
2219
2272
|
}),
|
|
2220
2273
|
registerEntityKind: implementation.registerEntityKind ?? ((input) => Effect2.succeed(input)),
|
|
2221
|
-
getOrCreateEntity: implementation.getOrCreateEntity ?? (() => Effect2.fail(
|
|
2222
|
-
getEntity: implementation.getEntity ?? (() => Effect2.
|
|
2223
|
-
destroyEntity: implementation.destroyEntity ?? (() => Effect2.fail(
|
|
2274
|
+
getOrCreateEntity: implementation.getOrCreateEntity ?? (() => Effect2.fail(ClientError.make({ message: "Entity service unavailable" }))),
|
|
2275
|
+
getEntity: implementation.getEntity ?? (() => Effect2.void.pipe(Effect2.as(undefined))),
|
|
2276
|
+
destroyEntity: implementation.destroyEntity ?? (() => Effect2.fail(ClientError.make({ message: "Entity service unavailable" }))),
|
|
2224
2277
|
listEntities: implementation.listEntities ?? (() => Effect2.succeed([])),
|
|
2278
|
+
pageExecutionEvents: implementation.pageExecutionEvents ?? (() => Effect2.fail(ClientError.make({ message: "Execution event paging unavailable" }))),
|
|
2225
2279
|
streamSession: implementation.streamSession ?? (() => Stream.empty),
|
|
2226
2280
|
watchExecutions: implementation.watchExecutions ?? (() => Stream.empty),
|
|
2227
2281
|
getPresence: implementation.getPresence ?? ((scope) => Effect2.succeed({ scope, entries: [], observed_at: 0 })),
|
|
@@ -2342,6 +2396,10 @@ var replayExecution = Effect2.fn("Client.replayExecution.call")(function* (input
|
|
|
2342
2396
|
const service = yield* Service2;
|
|
2343
2397
|
return yield* service.replayExecution(input);
|
|
2344
2398
|
});
|
|
2399
|
+
var pageExecutionEvents = Effect2.fn("Client.pageExecutionEvents.call")(function* (input) {
|
|
2400
|
+
const service = yield* Service2;
|
|
2401
|
+
return yield* service.pageExecutionEvents(input);
|
|
2402
|
+
});
|
|
2345
2403
|
var listRunners = Effect2.fn("Client.listRunners.call")(function* () {
|
|
2346
2404
|
const service = yield* Service2;
|
|
2347
2405
|
return yield* service.listRunners();
|
|
@@ -2525,12 +2583,13 @@ __export(exports_runtime_database, {
|
|
|
2525
2583
|
});
|
|
2526
2584
|
import { Context as Context3 } from "effect";
|
|
2527
2585
|
|
|
2528
|
-
class Service3 extends Context3.Service()("@relayfx/sdk/
|
|
2586
|
+
class Service3 extends Context3.Service()("@relayfx/sdk/runtime-database/Service") {
|
|
2529
2587
|
}
|
|
2530
2588
|
|
|
2531
2589
|
// src/runtime.ts
|
|
2532
2590
|
var DatabaseIdentity = Schema5.NonEmptyString.pipe(Schema5.brand("@relayfx/sdk/DatabaseIdentity"));
|
|
2533
|
-
var
|
|
2591
|
+
var decodeDatabaseIdentity = Schema5.decodeUnknownSync(DatabaseIdentity);
|
|
2592
|
+
var makeDatabaseIdentity = (input) => decodeDatabaseIdentity(input);
|
|
2534
2593
|
var Dialect = Schema5.Literals(["pg", "mysql", "sqlite"]);
|
|
2535
2594
|
var DatabaseDialect = Symbol("@relayfx/sdk/DatabaseDialect");
|
|
2536
2595
|
|
|
@@ -2649,29 +2708,30 @@ class RuntimeReadinessError extends Schema5.TaggedErrorClass()("RuntimeReadiness
|
|
|
2649
2708
|
}) {
|
|
2650
2709
|
}
|
|
2651
2710
|
|
|
2652
|
-
class Service4 extends Context4.Service()("@relayfx/sdk/
|
|
2711
|
+
class Service4 extends Context4.Service()("@relayfx/sdk/runtime/Service") {
|
|
2653
2712
|
}
|
|
2713
|
+
var embeddedOutput = (layer2) => layer2;
|
|
2654
2714
|
var isAcquisitionError = (error) => typeof error === "object" && error !== null && ("_tag" in error) && (error._tag === "RuntimeConfigurationError" || error._tag === "RuntimeTopologyError" || error._tag === "RuntimeMigrationError");
|
|
2655
2715
|
var normalizeHost = (layer2, role, dialect) => {
|
|
2656
2716
|
const normalize = (error) => {
|
|
2657
2717
|
if (isAcquisitionError(error))
|
|
2658
2718
|
return error;
|
|
2659
2719
|
if (typeof error === "object" && error !== null && "_tag" in error && error._tag === "ClusterConfigMismatch") {
|
|
2660
|
-
const clusterFailure =
|
|
2720
|
+
const clusterFailure = ClusterFailure.make({ reason: "cluster configuration is incompatible" });
|
|
2661
2721
|
Object.defineProperty(clusterFailure, "originalCause", { value: error, enumerable: false });
|
|
2662
|
-
return
|
|
2722
|
+
return RuntimeTopologyError.make({
|
|
2663
2723
|
dialect,
|
|
2664
2724
|
role,
|
|
2665
2725
|
nextAction: role === "embedded" ? "use-embedded" : "use-different-database",
|
|
2666
2726
|
cause: clusterFailure
|
|
2667
2727
|
});
|
|
2668
2728
|
}
|
|
2669
|
-
const hostFailure =
|
|
2729
|
+
const hostFailure = HostLayerError.make({
|
|
2670
2730
|
service: "Runtime host graph",
|
|
2671
2731
|
reason: "host layer acquisition failed"
|
|
2672
2732
|
});
|
|
2673
2733
|
Object.defineProperty(hostFailure, "originalCause", { value: error, enumerable: false });
|
|
2674
|
-
return
|
|
2734
|
+
return RuntimeConfigurationError.make({
|
|
2675
2735
|
setting: "host layers",
|
|
2676
2736
|
nextAction: "provide-host-layer",
|
|
2677
2737
|
cause: hostFailure
|
|
@@ -2698,11 +2758,11 @@ var validatedDatabase = (databaseLayer, role) => {
|
|
|
2698
2758
|
const sql = yield* SqlClient;
|
|
2699
2759
|
const actual = actualDialect(sql);
|
|
2700
2760
|
if (actual !== database.dialect) {
|
|
2701
|
-
return yield*
|
|
2761
|
+
return yield* RuntimeTopologyError.make({
|
|
2702
2762
|
dialect: database.dialect,
|
|
2703
2763
|
role,
|
|
2704
2764
|
nextAction: role === "embedded" ? "use-different-database" : "use-postgres-or-mysql",
|
|
2705
|
-
cause:
|
|
2765
|
+
cause: DatabaseDialectMismatch.make({ expected: database.dialect, actual })
|
|
2706
2766
|
});
|
|
2707
2767
|
}
|
|
2708
2768
|
if (database.dialect === "sqlite") {
|
|
@@ -2719,10 +2779,10 @@ var runtimeServiceLayer = (role, capabilities) => Layer3.effect(Service4, Effect
|
|
|
2719
2779
|
const database = yield* Service3;
|
|
2720
2780
|
const runner = yield* exports_runner_runtime_service.Service;
|
|
2721
2781
|
return Service4.of({
|
|
2722
|
-
readiness: runner.check
|
|
2723
|
-
const cause =
|
|
2782
|
+
readiness: runner.check.pipe(Effect3.mapError((error) => {
|
|
2783
|
+
const cause = SqlFailure.make({ category: "unknown", operation: "readiness", retryable: false });
|
|
2724
2784
|
Object.defineProperty(cause, "originalCause", { value: error, enumerable: false });
|
|
2725
|
-
return
|
|
2785
|
+
return RuntimeReadinessError.make({ phase: "database", cause });
|
|
2726
2786
|
}), Effect3.as({
|
|
2727
2787
|
ready: true,
|
|
2728
2788
|
role,
|
|
@@ -2756,7 +2816,7 @@ var withHosts = (runner, options) => {
|
|
|
2756
2816
|
const workflowHost = options.workflowDefinitionHandlersLayer === undefined ? Layer3.empty : exports_definition_runtime.layerFromRuntime.pipe(Layer3.provide(options.workflowDefinitionHandlersLayer), Layer3.provideMerge(childHost), Layer3.provide(runner));
|
|
2757
2817
|
return Layer3.mergeAll(runner, childHost, workflowHost);
|
|
2758
2818
|
};
|
|
2759
|
-
|
|
2819
|
+
function layerEmbedded(options) {
|
|
2760
2820
|
const runner = exports_runner_runtime_service.layerWithServices({
|
|
2761
2821
|
databaseLayer: ambientDatabaseLayer,
|
|
2762
2822
|
languageModelLayer: options.languageModelLayer,
|
|
@@ -2767,11 +2827,12 @@ var layerEmbedded = (options) => {
|
|
|
2767
2827
|
promptAssemblerLayer: options.promptAssemblerLayer,
|
|
2768
2828
|
schemaRegistryLayer: options.schemaRegistryLayer
|
|
2769
2829
|
});
|
|
2770
|
-
|
|
2830
|
+
const host = normalizeHost(publicGraph(withHosts(runner, options), options.databaseLayer, "embedded", {
|
|
2771
2831
|
fanOut: options.childFanOutHandlersLayer !== undefined,
|
|
2772
2832
|
workflowDefinition: options.workflowDefinitionHandlersLayer !== undefined
|
|
2773
2833
|
}), "embedded", options.databaseLayer[DatabaseDialect]);
|
|
2774
|
-
|
|
2834
|
+
return embeddedOutput(host);
|
|
2835
|
+
}
|
|
2775
2836
|
var layerRunner = (options) => {
|
|
2776
2837
|
const runner = exports_runner_runtime_service.layerWithServicesMultiNode({
|
|
2777
2838
|
databaseLayer: ambientDatabaseLayer,
|