@relayfx/sdk 0.2.12 → 0.2.14
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-15f2ewt8.js +69 -0
- package/dist/{index-33d4k6kk.js → index-9q3yh32k.js} +617 -526
- package/dist/{index-236a3f4t.js → index-gb7d1wfm.js} +745 -397
- package/dist/{index-aph699jp.js → index-qg0hy7s1.js} +1 -1
- package/dist/index.js +10 -4
- package/dist/mysql.js +122 -0
- package/dist/postgres.js +77 -0
- package/dist/sqlite.js +84 -3
- package/dist/types/relay/client.d.ts +6 -4
- package/dist/types/relay/index.d.ts +3 -1
- package/dist/types/relay/migration-errors.d.ts +4 -0
- package/dist/types/relay/mysql-migrations.d.ts +1 -0
- package/dist/types/relay/mysql.d.ts +13 -0
- package/dist/types/relay/postgres.d.ts +13 -0
- package/dist/types/relay/runtime-capability-policy.d.ts +19 -0
- package/dist/types/relay/runtime-database-adapter.d.ts +12 -0
- package/dist/types/relay/runtime-database.d.ts +21 -0
- package/dist/types/relay/runtime.d.ts +198 -0
- package/dist/types/relay/sqlite-runtime.d.ts +9 -0
- package/dist/types/relay/sqlite.d.ts +2 -0
- package/dist/types/runtime/child/child-fan-out-runtime.d.ts +2 -0
- package/dist/types/runtime/child/spawn-child-run-tool.d.ts +1 -0
- package/dist/types/runtime/runner/runner-runtime-service.d.ts +30 -30
- package/dist/types/runtime/workflow/definition-runtime.d.ts +2 -0
- package/dist/types/schema/execution-schema.d.ts +2 -0
- package/dist/types/store-sql/workflow/workflow-definition-repository.d.ts +6 -2
- package/package.json +11 -2
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
exports_child_execution_repository,
|
|
9
9
|
exports_child_fan_out_repository,
|
|
10
10
|
exports_child_fan_out_runtime,
|
|
11
|
+
exports_child_fan_out_transition_service,
|
|
11
12
|
exports_child_orchestration_schema,
|
|
12
13
|
exports_child_run_service,
|
|
13
14
|
exports_cluster_registry_repository,
|
|
@@ -29,7 +30,9 @@ import {
|
|
|
29
30
|
exports_ids_schema,
|
|
30
31
|
exports_inbox_repository,
|
|
31
32
|
exports_inbox_schema,
|
|
33
|
+
exports_language_model_service,
|
|
32
34
|
exports_presence_service,
|
|
35
|
+
exports_runner_runtime_service,
|
|
33
36
|
exports_schedule_repository,
|
|
34
37
|
exports_schedule_schema,
|
|
35
38
|
exports_scheduler_service,
|
|
@@ -41,6 +44,7 @@ import {
|
|
|
41
44
|
exports_state_schema,
|
|
42
45
|
exports_steering_repository,
|
|
43
46
|
exports_tool_call_repository,
|
|
47
|
+
exports_tool_runtime_service,
|
|
44
48
|
exports_tool_schema,
|
|
45
49
|
exports_tool_transition_coordinator,
|
|
46
50
|
exports_topic_service,
|
|
@@ -48,7 +52,7 @@ import {
|
|
|
48
52
|
exports_wait_service,
|
|
49
53
|
exports_wait_signal,
|
|
50
54
|
exports_workflow_definition_repository
|
|
51
|
-
} from "./index-
|
|
55
|
+
} from "./index-9q3yh32k.js";
|
|
52
56
|
|
|
53
57
|
// src/operation.ts
|
|
54
58
|
var exports_operation = {};
|
|
@@ -795,36 +799,60 @@ __export(exports_client, {
|
|
|
795
799
|
askEntity: () => askEntity,
|
|
796
800
|
ackEnvelopeReady: () => ackEnvelopeReady,
|
|
797
801
|
WaitKindMismatch: () => WaitKindMismatch,
|
|
798
|
-
Service: () =>
|
|
802
|
+
Service: () => Service2,
|
|
799
803
|
ExecutionNotFound: () => ExecutionNotFound,
|
|
800
804
|
EventLogCursorNotFound: () => EventLogCursorNotFound,
|
|
801
805
|
EntityNamespaceReserved: () => EntityNamespaceReserved,
|
|
802
806
|
ClientError: () => ClientError
|
|
803
807
|
});
|
|
804
|
-
import { Clock, Context, Effect, Layer, Option, Schema as
|
|
808
|
+
import { Clock, Context as Context2, Effect as Effect2, Layer as Layer2, Option, Schema as Schema4, SchemaGetter, SchemaIssue, Stream } from "effect";
|
|
805
809
|
import { EntityId, ShardId, Sharding, ShardingConfig } from "effect/unstable/cluster";
|
|
806
|
-
|
|
807
|
-
|
|
810
|
+
// src/runtime-capability-policy.ts
|
|
811
|
+
import { Context, Effect, Layer, Schema as Schema3 } from "effect";
|
|
812
|
+
|
|
813
|
+
class RuntimeCapabilityUnavailable extends Schema3.TaggedErrorClass()("RuntimeCapabilityUnavailable", {
|
|
814
|
+
capability: Schema3.Literals(["fan-out", "workflow-definition"]),
|
|
815
|
+
role: Schema3.Literals(["embedded", "runner", "client"]),
|
|
816
|
+
nextAction: Schema3.Literals(["enable-embedded-capability", "use-embedded-runtime"])
|
|
808
817
|
}) {
|
|
809
818
|
}
|
|
810
819
|
|
|
811
|
-
class
|
|
820
|
+
class Service extends Context.Service()("@relayfx/sdk/RuntimeCapabilityPolicy") {
|
|
821
|
+
}
|
|
822
|
+
var layer = (role, capabilities) => Layer.succeed(Service, {
|
|
823
|
+
admit: (capability) => {
|
|
824
|
+
const enabled = capability === "fan-out" ? capabilities.fanOut : capabilities.workflowDefinition;
|
|
825
|
+
return enabled ? Effect.void : Effect.fail(new RuntimeCapabilityUnavailable({
|
|
826
|
+
capability,
|
|
827
|
+
role,
|
|
828
|
+
nextAction: role === "embedded" ? "enable-embedded-capability" : "use-embedded-runtime"
|
|
829
|
+
}));
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
// src/client.ts
|
|
834
|
+
class ClientError extends Schema4.TaggedErrorClass()("ClientError", {
|
|
835
|
+
message: Schema4.String
|
|
836
|
+
}) {
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
class ExecutionNotFound extends Schema4.TaggedErrorClass()("ExecutionNotFound", {
|
|
812
840
|
execution_id: exports_ids_schema.ExecutionId
|
|
813
841
|
}) {
|
|
814
842
|
}
|
|
815
843
|
|
|
816
|
-
class EntityNamespaceReserved extends
|
|
844
|
+
class EntityNamespaceReserved extends Schema4.TaggedErrorClass()("EntityNamespaceReserved", { id: Schema4.String, message: Schema4.String }) {
|
|
817
845
|
}
|
|
818
846
|
|
|
819
|
-
class WaitKindMismatch extends
|
|
847
|
+
class WaitKindMismatch extends Schema4.TaggedErrorClass()("WaitKindMismatch", {
|
|
820
848
|
wait_id: exports_ids_schema.WaitId,
|
|
821
|
-
expected:
|
|
822
|
-
actual:
|
|
823
|
-
message:
|
|
849
|
+
expected: Schema4.String,
|
|
850
|
+
actual: Schema4.String,
|
|
851
|
+
message: Schema4.String
|
|
824
852
|
}) {
|
|
825
853
|
}
|
|
826
854
|
|
|
827
|
-
class
|
|
855
|
+
class Service2 extends Context2.Service()("@relayfx/sdk/Client") {
|
|
828
856
|
}
|
|
829
857
|
var followTerminalStatus = (type) => type === "execution.completed" ? "completed" : type === "execution.failed" ? "failed" : type === "execution.cancelled" ? "cancelled" : undefined;
|
|
830
858
|
var followReconnectDelayMillis = (attempt) => Math.min(100 * 2 ** (attempt - 1), 5000);
|
|
@@ -836,8 +864,8 @@ var followStopped = (reason, cursor) => ({
|
|
|
836
864
|
var followExecutionFrom = (dependencies) => (input) => {
|
|
837
865
|
const maxReconnects = input.max_reconnects ?? 10;
|
|
838
866
|
const stopModes = input.stop_on_wait_modes;
|
|
839
|
-
const inspect =
|
|
840
|
-
const reconcile = (state, message) => Stream.unwrap(
|
|
867
|
+
const inspect = Effect2.suspend(() => dependencies.inspectExecution(input.execution_id)).pipe(Effect2.catchTag("ExecutionNotFound", (error) => new ClientError({ message: `execution ${error.execution_id} not found` })));
|
|
868
|
+
const reconcile = (state, message) => Stream.unwrap(Effect2.gen(function* () {
|
|
841
869
|
const inspection = yield* inspect;
|
|
842
870
|
const terminal = followTerminalStatus(`execution.${inspection.status}`);
|
|
843
871
|
if (terminal !== undefined) {
|
|
@@ -854,9 +882,9 @@ var followExecutionFrom = (dependencies) => (input) => {
|
|
|
854
882
|
}
|
|
855
883
|
state.attempts += 1;
|
|
856
884
|
const reconnecting = { _tag: "reconnecting", message, attempt: state.attempts };
|
|
857
|
-
return Stream.make(reconnecting).pipe(Stream.concat(Stream.fromEffect(
|
|
885
|
+
return Stream.make(reconnecting).pipe(Stream.concat(Stream.fromEffect(Effect2.sleep(followReconnectDelayMillis(state.attempts))).pipe(Stream.drain)), Stream.concat(Stream.suspend(() => connect(state))));
|
|
858
886
|
}));
|
|
859
|
-
const itemsFor = (state, event) =>
|
|
887
|
+
const itemsFor = (state, event) => Effect2.gen(function* () {
|
|
860
888
|
if (event.sequence <= state.sequence)
|
|
861
889
|
return [];
|
|
862
890
|
state.sequence = event.sequence;
|
|
@@ -872,7 +900,7 @@ var followExecutionFrom = (dependencies) => (input) => {
|
|
|
872
900
|
if (stopModes !== undefined && event.type === "wait.created") {
|
|
873
901
|
const mode = event.data?.mode;
|
|
874
902
|
if (typeof mode === "string" && stopModes.includes(mode)) {
|
|
875
|
-
const inspection = yield* dependencies.inspectExecution(input.execution_id).pipe(
|
|
903
|
+
const inspection = yield* dependencies.inspectExecution(input.execution_id).pipe(Effect2.catchTag("ExecutionNotFound", () => Effect2.succeed(undefined)));
|
|
876
904
|
const actionable = inspection?.waiting_on.find((wait) => wait.state === "open" && wait.wait_id === event.data?.wait_id);
|
|
877
905
|
if (actionable !== undefined) {
|
|
878
906
|
items.push(followStopped({ _tag: "actionable_wait", wait: actionable }, state.cursor));
|
|
@@ -885,7 +913,7 @@ var followExecutionFrom = (dependencies) => (input) => {
|
|
|
885
913
|
execution_id: input.execution_id,
|
|
886
914
|
...state.cursor === undefined ? {} : { after_cursor: state.cursor }
|
|
887
915
|
}).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"))));
|
|
888
|
-
return Stream.unwrap(
|
|
916
|
+
return Stream.unwrap(Effect2.gen(function* () {
|
|
889
917
|
const existing = yield* dependencies.getExecution(input.execution_id);
|
|
890
918
|
if (existing === undefined) {
|
|
891
919
|
return Stream.fail(new ClientError({ message: `execution ${input.execution_id} not found` }));
|
|
@@ -911,7 +939,7 @@ var errorMessage = (error) => {
|
|
|
911
939
|
return String(error);
|
|
912
940
|
};
|
|
913
941
|
var toClientError = (error) => new ClientError({ message: errorMessage(error) });
|
|
914
|
-
var rejectReserved = (id, prefix) => id.startsWith(prefix) ?
|
|
942
|
+
var rejectReserved = (id, prefix) => id.startsWith(prefix) ? Effect2.fail(new EntityNamespaceReserved({ id, message: "start entities via Client.getOrCreateEntity" })) : Effect2.void;
|
|
915
943
|
var replyValueFrom = (content) => {
|
|
916
944
|
if (content === undefined || content.length === 0)
|
|
917
945
|
return Option.none();
|
|
@@ -927,30 +955,30 @@ var replyValueFrom = (content) => {
|
|
|
927
955
|
return Option.none();
|
|
928
956
|
}
|
|
929
957
|
};
|
|
930
|
-
var toStreamError = (error) => Option.match(
|
|
958
|
+
var toStreamError = (error) => Option.match(Schema4.decodeUnknownOption(EventLogCursorNotFound)(error), {
|
|
931
959
|
onNone: () => toClientError(error),
|
|
932
960
|
onSome: (cursorError) => cursorError
|
|
933
961
|
});
|
|
934
962
|
var malformedCursor = (wire) => new SchemaIssue.InvalidValue(Option.some(wire), { message: "Malformed pagination cursor" });
|
|
935
|
-
var decodeCursorFields = (wire) =>
|
|
936
|
-
const decoded = yield*
|
|
963
|
+
var decodeCursorFields = (wire) => Effect2.gen(function* () {
|
|
964
|
+
const decoded = yield* Effect2.try({
|
|
937
965
|
try: () => globalThis.atob(wire),
|
|
938
966
|
catch: () => malformedCursor(wire)
|
|
939
967
|
});
|
|
940
968
|
const separator = decoded.indexOf(":");
|
|
941
969
|
if (separator === -1)
|
|
942
|
-
return yield*
|
|
970
|
+
return yield* Effect2.fail(malformedCursor(wire));
|
|
943
971
|
const updatedAt = Number(decoded.slice(0, separator));
|
|
944
972
|
if (!Number.isFinite(updatedAt))
|
|
945
|
-
return yield*
|
|
973
|
+
return yield* Effect2.fail(malformedCursor(wire));
|
|
946
974
|
return { updatedAt, id: decoded.slice(separator + 1) };
|
|
947
975
|
});
|
|
948
|
-
var ExecutionCursorFromString = exports_shared_schema.NonEmptyString.pipe(
|
|
976
|
+
var ExecutionCursorFromString = exports_shared_schema.NonEmptyString.pipe(Schema4.decodeTo(Schema4.Struct({ updatedAt: Schema4.Int, id: exports_ids_schema.ExecutionId }), {
|
|
949
977
|
decode: SchemaGetter.transformOrFail((wire) => decodeCursorFields(wire)),
|
|
950
978
|
encode: SchemaGetter.transform((cursor) => globalThis.btoa(`${cursor.updatedAt}:${cursor.id}`))
|
|
951
979
|
})).annotate({ identifier: "Relay.Client.ExecutionCursor" });
|
|
952
|
-
var encodeExecutionCursor = (cursor) =>
|
|
953
|
-
var SessionCursorFromString = exports_shared_schema.NonEmptyString.pipe(
|
|
980
|
+
var encodeExecutionCursor = (cursor) => Schema4.encodeEffect(ExecutionCursorFromString)(cursor).pipe(Effect2.mapError(toClientError));
|
|
981
|
+
var SessionCursorFromString = exports_shared_schema.NonEmptyString.pipe(Schema4.decodeTo(Schema4.Struct({ updatedAt: Schema4.Int, id: exports_ids_schema.SessionId }), {
|
|
954
982
|
decode: SchemaGetter.transformOrFail((wire) => decodeCursorFields(wire)),
|
|
955
983
|
encode: SchemaGetter.transform((cursor) => globalThis.btoa(`${cursor.updatedAt}:${cursor.id}`))
|
|
956
984
|
})).annotate({ identifier: "Relay.Client.SessionCursor" });
|
|
@@ -1059,10 +1087,10 @@ var modelSelectionFromBatonAgent = (selection) => ({
|
|
|
1059
1087
|
model: selection.model,
|
|
1060
1088
|
...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
|
|
1061
1089
|
});
|
|
1062
|
-
var decodeBatonAgentName = (name) =>
|
|
1063
|
-
var decodeBatonAgentMetadata = (metadata) => metadata === undefined ?
|
|
1064
|
-
var decodeBatonMemorySubject = (subject) =>
|
|
1065
|
-
var metadataFromBatonAgent =
|
|
1090
|
+
var decodeBatonAgentName = (name) => Schema4.decodeUnknownEffect(exports_shared_schema.NonEmptyString)(name).pipe(Effect2.mapError(() => new ClientError({ message: "Baton agent name must not be blank" })));
|
|
1091
|
+
var decodeBatonAgentMetadata = (metadata) => metadata === undefined ? Effect2.succeed(undefined) : Schema4.decodeUnknownEffect(exports_shared_schema.Metadata)(metadata).pipe(Effect2.mapError(() => new ClientError({ message: "Baton agent metadata must be JSON metadata" })));
|
|
1092
|
+
var decodeBatonMemorySubject = (subject) => Schema4.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect2.mapError(() => new ClientError({ message: "Baton agent memory subject must be a MemorySubjectId" })));
|
|
1093
|
+
var metadataFromBatonAgent = Effect2.fn("Client.metadataFromBatonAgent")(function* (input) {
|
|
1066
1094
|
const agentMetadata = yield* decodeBatonAgentMetadata(input.agent.metadata);
|
|
1067
1095
|
const memorySubject = input.agent.memory === undefined ? undefined : yield* decodeBatonMemorySubject(input.agent.memory.subject);
|
|
1068
1096
|
const metadata = {
|
|
@@ -1074,35 +1102,35 @@ var metadataFromBatonAgent = Effect.fn("Client.metadataFromBatonAgent")(function
|
|
|
1074
1102
|
});
|
|
1075
1103
|
var modelSelectionFromRegisterInput = (input) => {
|
|
1076
1104
|
if (input.model !== undefined)
|
|
1077
|
-
return
|
|
1105
|
+
return Effect2.succeed(input.model);
|
|
1078
1106
|
if (input.agent.model !== undefined)
|
|
1079
|
-
return
|
|
1080
|
-
return
|
|
1107
|
+
return Effect2.succeed(modelSelectionFromBatonAgent(input.agent.model));
|
|
1108
|
+
return Effect2.fail(new ClientError({ message: "Client.registerAgent requires model or agent.model" }));
|
|
1081
1109
|
};
|
|
1082
1110
|
var batonTurnPolicyInvalid = (detail) => new ClientError({ message: `Baton agent turn policy is not durably portable: ${detail}` });
|
|
1083
|
-
var turnPolicySnapshotFromBaton =
|
|
1111
|
+
var turnPolicySnapshotFromBaton = Effect2.fn("Client.turnPolicySnapshotFromBaton")(function* (snapshot) {
|
|
1084
1112
|
let nodes = 0;
|
|
1085
|
-
const visit = (current, depth) =>
|
|
1113
|
+
const visit = (current, depth) => Effect2.gen(function* () {
|
|
1086
1114
|
if (typeof current !== "object" || current === null || Array.isArray(current)) {
|
|
1087
|
-
return yield*
|
|
1115
|
+
return yield* Effect2.fail(batonTurnPolicyInvalid("snapshot nodes must be objects"));
|
|
1088
1116
|
}
|
|
1089
1117
|
const node = current;
|
|
1090
1118
|
nodes += 1;
|
|
1091
1119
|
if (depth > exports_agent_schema.maxTurnPolicySnapshotDepth) {
|
|
1092
|
-
return yield*
|
|
1120
|
+
return yield* Effect2.fail(batonTurnPolicyInvalid(`depth exceeds ${exports_agent_schema.maxTurnPolicySnapshotDepth}`));
|
|
1093
1121
|
}
|
|
1094
1122
|
if (nodes > exports_agent_schema.maxTurnPolicySnapshotNodes) {
|
|
1095
|
-
return yield*
|
|
1123
|
+
return yield* Effect2.fail(batonTurnPolicyInvalid(`node count exceeds ${exports_agent_schema.maxTurnPolicySnapshotNodes}`));
|
|
1096
1124
|
}
|
|
1097
1125
|
switch (node._tag) {
|
|
1098
1126
|
case "Recurs":
|
|
1099
1127
|
if (typeof node.count !== "number" || !Number.isInteger(node.count) || node.count < 0) {
|
|
1100
|
-
return yield*
|
|
1128
|
+
return yield* Effect2.fail(batonTurnPolicyInvalid("recurs count must be a non-negative integer"));
|
|
1101
1129
|
}
|
|
1102
1130
|
return { kind: "recurs", count: node.count };
|
|
1103
1131
|
case "UntilToolCall":
|
|
1104
1132
|
if (typeof node.name !== "string" || node.name.trim().length === 0) {
|
|
1105
|
-
return yield*
|
|
1133
|
+
return yield* Effect2.fail(batonTurnPolicyInvalid("until-tool-call name must not be blank"));
|
|
1106
1134
|
}
|
|
1107
1135
|
return { kind: "until-tool-call", name: node.name };
|
|
1108
1136
|
case "Both":
|
|
@@ -1112,17 +1140,17 @@ var turnPolicySnapshotFromBaton = Effect.fn("Client.turnPolicySnapshotFromBaton"
|
|
|
1112
1140
|
second: yield* visit(node.second, depth + 1)
|
|
1113
1141
|
};
|
|
1114
1142
|
default:
|
|
1115
|
-
return yield*
|
|
1143
|
+
return yield* Effect2.fail(batonTurnPolicyInvalid("snapshot tag is not recognized"));
|
|
1116
1144
|
}
|
|
1117
1145
|
});
|
|
1118
1146
|
return yield* visit(snapshot, 1);
|
|
1119
1147
|
});
|
|
1120
|
-
var turnPolicyFieldsFromRegisterInput =
|
|
1148
|
+
var turnPolicyFieldsFromRegisterInput = Effect2.fn("Client.turnPolicyFieldsFromRegisterInput")(function* (input) {
|
|
1121
1149
|
if (input.max_tool_turns !== undefined)
|
|
1122
1150
|
return { max_tool_turns: input.max_tool_turns };
|
|
1123
1151
|
const snapshot = input.agent.policy.snapshot;
|
|
1124
1152
|
if (snapshot === undefined) {
|
|
1125
|
-
return yield*
|
|
1153
|
+
return yield* Effect2.fail(batonTurnPolicyInvalid("opaque policies require an explicit max_tool_turns replacement"));
|
|
1126
1154
|
}
|
|
1127
1155
|
const durable = yield* turnPolicySnapshotFromBaton(snapshot);
|
|
1128
1156
|
if (durable.kind === "recurs" && durable.count === 8)
|
|
@@ -1131,7 +1159,7 @@ var turnPolicyFieldsFromRegisterInput = Effect.fn("Client.turnPolicyFieldsFromRe
|
|
|
1131
1159
|
return { max_tool_turns: durable.count };
|
|
1132
1160
|
return { turn_policy: durable };
|
|
1133
1161
|
});
|
|
1134
|
-
var registerAgentPayload =
|
|
1162
|
+
var registerAgentPayload = Effect2.fn("Client.registerAgentPayload")(function* (input) {
|
|
1135
1163
|
if (!isRegisterBatonAgentInput(input))
|
|
1136
1164
|
return exports_agent_schema.define(input);
|
|
1137
1165
|
const name = yield* decodeBatonAgentName(input.agent.name);
|
|
@@ -1210,10 +1238,10 @@ var toToolWorkLease = (lease) => ({
|
|
|
1210
1238
|
idempotency_key: lease.idempotencyKey
|
|
1211
1239
|
});
|
|
1212
1240
|
var toolWaitId = (callId) => exports_ids_schema.WaitId.make(`wait:tool:${callId}`);
|
|
1213
|
-
var acceptedWaitOutcome = (wait) =>
|
|
1214
|
-
var resolveToolOutcomeWait =
|
|
1241
|
+
var acceptedWaitOutcome = (wait) => Schema4.decodeUnknownEffect(exports_tool_schema.ExternalOutcome)(wait.metadata.external_outcome).pipe(Effect2.mapError(toClientError));
|
|
1242
|
+
var resolveToolOutcomeWait = Effect2.fn("Client.resolveToolOutcomeWait")(function* (waits, eventLog, call, outcome, completedAt) {
|
|
1215
1243
|
const waitId = call.waitId ?? toolWaitId(call.call.id);
|
|
1216
|
-
const wait = yield* waits.get(waitId).pipe(
|
|
1244
|
+
const wait = yield* waits.get(waitId).pipe(Effect2.mapError(toClientError));
|
|
1217
1245
|
if (wait === undefined)
|
|
1218
1246
|
return yield* new ClientError({ message: `Tool wait not found: ${waitId}` });
|
|
1219
1247
|
if (wait.executionId !== call.executionId) {
|
|
@@ -1235,7 +1263,7 @@ var resolveToolOutcomeWait = Effect.fn("Client.resolveToolOutcomeWait")(function
|
|
|
1235
1263
|
resolvedAt: completedAt,
|
|
1236
1264
|
eventSequence,
|
|
1237
1265
|
metadata: { kind: "tool-placement", external_outcome: outcome }
|
|
1238
|
-
}).pipe(
|
|
1266
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1239
1267
|
if (!resolved.transitioned) {
|
|
1240
1268
|
const accepted = yield* acceptedWaitOutcome(resolved.wait);
|
|
1241
1269
|
if (exports_shared_schema.canonicalString(accepted) !== exports_shared_schema.canonicalString(outcome)) {
|
|
@@ -1244,14 +1272,14 @@ var resolveToolOutcomeWait = Effect.fn("Client.resolveToolOutcomeWait")(function
|
|
|
1244
1272
|
}
|
|
1245
1273
|
return resolved.wait;
|
|
1246
1274
|
});
|
|
1247
|
-
var signalToolOutcome =
|
|
1275
|
+
var signalToolOutcome = Effect2.fn("Client.signalToolOutcome")(function* (executionRepository, makeExecutionClient, wait, signaledAt) {
|
|
1248
1276
|
yield* exports_wait_signal.signalWorkflowWait({
|
|
1249
1277
|
makeExecutionClient,
|
|
1250
1278
|
executionId: wait.executionId,
|
|
1251
1279
|
waitId: wait.id,
|
|
1252
1280
|
state: "resolved",
|
|
1253
1281
|
signaledAt
|
|
1254
|
-
}).pipe(
|
|
1282
|
+
}).pipe(Effect2.provideService(exports_execution_repository.Service, executionRepository), Effect2.mapError(toClientError));
|
|
1255
1283
|
});
|
|
1256
1284
|
var toReady = (record) => ({
|
|
1257
1285
|
id: record.id,
|
|
@@ -1266,8 +1294,8 @@ var toLease = (record) => ({
|
|
|
1266
1294
|
worker_id: record.claimOwner ?? "unclaimed",
|
|
1267
1295
|
claim_expires_at: record.claimExpiresAt ?? record.updatedAt
|
|
1268
1296
|
});
|
|
1269
|
-
var nextEventSequence =
|
|
1270
|
-
const max = yield* eventLog.maxSequence(executionId).pipe(
|
|
1297
|
+
var nextEventSequence = Effect2.fn("Client.nextEventSequence")(function* (eventLog, executionId) {
|
|
1298
|
+
const max = yield* eventLog.maxSequence(executionId).pipe(Effect2.mapError(toClientError));
|
|
1271
1299
|
return max === undefined ? 0 : max + 1;
|
|
1272
1300
|
});
|
|
1273
1301
|
var waitSemanticKind = (wait) => wait.mode === "child" ? "child" : typeof wait.metadata.kind === "string" && wait.metadata.kind.length > 0 ? wait.metadata.kind : "general";
|
|
@@ -1275,8 +1303,8 @@ var terminalChildStatus = (metadata) => {
|
|
|
1275
1303
|
const status = metadata?.child_status;
|
|
1276
1304
|
return status === "completed" || status === "failed" || status === "cancelled";
|
|
1277
1305
|
};
|
|
1278
|
-
var wakeRuntime =
|
|
1279
|
-
const wait = yield* waits.get(input.wait_id).pipe(
|
|
1306
|
+
var wakeRuntime = Effect2.fn("Client.wakeRuntime")(function* (waits, eventLog, executionRepository, makeExecutionClient, input, accepts) {
|
|
1307
|
+
const wait = yield* waits.get(input.wait_id).pipe(Effect2.mapError(toClientError));
|
|
1280
1308
|
if (wait === undefined)
|
|
1281
1309
|
return yield* new ClientError({ message: `Wait not found: ${input.wait_id}` });
|
|
1282
1310
|
const kind = waitSemanticKind(wait);
|
|
@@ -1305,17 +1333,17 @@ var wakeRuntime = Effect.fn("Client.wakeRuntime")(function* (waits, eventLog, ex
|
|
|
1305
1333
|
resolvedAt: input.signaled_at,
|
|
1306
1334
|
eventSequence,
|
|
1307
1335
|
metadata: wakeMetadata(input)
|
|
1308
|
-
}).pipe(
|
|
1336
|
+
}).pipe(Effect2.mapError(toClientError)) : input.state === "timed_out" ? yield* waits.timeout({
|
|
1309
1337
|
waitId: input.wait_id,
|
|
1310
1338
|
timedOutAt: input.signaled_at,
|
|
1311
1339
|
eventSequence,
|
|
1312
1340
|
metadata: wakeMetadata(input)
|
|
1313
|
-
}).pipe(
|
|
1341
|
+
}).pipe(Effect2.mapError(toClientError)) : yield* waits.cancel({
|
|
1314
1342
|
waitId: input.wait_id,
|
|
1315
1343
|
cancelledAt: input.signaled_at,
|
|
1316
1344
|
eventSequence,
|
|
1317
1345
|
metadata: wakeMetadata(input)
|
|
1318
|
-
}).pipe(
|
|
1346
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1319
1347
|
if (result.transitioned) {
|
|
1320
1348
|
yield* exports_wait_signal.signalWorkflowWait({
|
|
1321
1349
|
makeExecutionClient,
|
|
@@ -1323,7 +1351,7 @@ var wakeRuntime = Effect.fn("Client.wakeRuntime")(function* (waits, eventLog, ex
|
|
|
1323
1351
|
waitId: result.wait.id,
|
|
1324
1352
|
state: input.state,
|
|
1325
1353
|
signaledAt: input.signaled_at
|
|
1326
|
-
}).pipe(
|
|
1354
|
+
}).pipe(Effect2.provideService(exports_execution_repository.Service, executionRepository), Effect2.mapError(toClientError));
|
|
1327
1355
|
}
|
|
1328
1356
|
return {
|
|
1329
1357
|
wait_id: result.wait.id,
|
|
@@ -1332,7 +1360,6 @@ var wakeRuntime = Effect.fn("Client.wakeRuntime")(function* (waits, eventLog, ex
|
|
|
1332
1360
|
};
|
|
1333
1361
|
});
|
|
1334
1362
|
var childJoinWaitId = (childExecutionId) => exports_ids_schema.WaitId.make(`wait:child:${childExecutionId}`);
|
|
1335
|
-
var childSessionId = (childExecutionId) => exports_ids_schema.SessionId.make(`session:child:${childExecutionId}`);
|
|
1336
1363
|
var childSpawnFingerprintKey = "relay_child_spawn_fingerprint";
|
|
1337
1364
|
var childExecutionIdForSpawn = (input) => input.child_execution_id ?? exports_ids_schema.ChildExecutionId.make(`${input.execution_id}:child:${input.address_id}`);
|
|
1338
1365
|
var parentContextFromDefinition = (definition, fingerprint) => ({
|
|
@@ -1370,7 +1397,7 @@ var childSpawnFingerprint = (record) => {
|
|
|
1370
1397
|
const fingerprint = parentMetadata[childSpawnFingerprintKey];
|
|
1371
1398
|
return typeof fingerprint === "string" ? fingerprint : undefined;
|
|
1372
1399
|
};
|
|
1373
|
-
var createChildJoinWait =
|
|
1400
|
+
var createChildJoinWait = Effect2.fn("Client.createChildJoinWait")(function* (waits, eventLog, input, accepted, createdAt) {
|
|
1374
1401
|
const waitId = childJoinWaitId(accepted.child_execution_id);
|
|
1375
1402
|
const eventSequence = yield* nextEventSequence(eventLog, input.execution_id);
|
|
1376
1403
|
yield* waits.createDetached({
|
|
@@ -1384,12 +1411,12 @@ var createChildJoinWait = Effect.fn("Client.createChildJoinWait")(function* (wai
|
|
|
1384
1411
|
},
|
|
1385
1412
|
eventSequence,
|
|
1386
1413
|
createdAt
|
|
1387
|
-
}).pipe(
|
|
1414
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1388
1415
|
return waitId;
|
|
1389
1416
|
});
|
|
1390
|
-
var reconcileExistingChildSpawn =
|
|
1417
|
+
var reconcileExistingChildSpawn = Effect2.fn("Client.reconcileExistingChildSpawn")(function* (childExecutions, waits, eventLog, input) {
|
|
1391
1418
|
const childExecutionId = childExecutionIdForSpawn(input);
|
|
1392
|
-
const existing = yield* childExecutions.get(childExecutionId).pipe(
|
|
1419
|
+
const existing = yield* childExecutions.get(childExecutionId).pipe(Effect2.mapError(toClientError));
|
|
1393
1420
|
if (existing === undefined)
|
|
1394
1421
|
return;
|
|
1395
1422
|
if (existing.executionId !== input.execution_id || existing.addressId !== input.address_id || childSpawnFingerprint(existing) !== exports_shared_schema.canonicalString(input)) {
|
|
@@ -1398,13 +1425,13 @@ var reconcileExistingChildSpawn = Effect.fn("Client.reconcileExistingChildSpawn"
|
|
|
1398
1425
|
const spawned = yield* eventLog.findByCursor({
|
|
1399
1426
|
executionId: input.execution_id,
|
|
1400
1427
|
cursor: `${input.execution_id}:child:${childExecutionId}:spawned`
|
|
1401
|
-
}).pipe(
|
|
1428
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1402
1429
|
if (Option.isNone(spawned)) {
|
|
1403
1430
|
return yield* new ClientError({ message: `Child spawn event missing: ${childExecutionId}` });
|
|
1404
1431
|
}
|
|
1405
1432
|
const parentWaitId = input.wait === true ? childJoinWaitId(childExecutionId) : undefined;
|
|
1406
1433
|
if (parentWaitId !== undefined) {
|
|
1407
|
-
const wait = yield* waits.get(parentWaitId).pipe(
|
|
1434
|
+
const wait = yield* waits.get(parentWaitId).pipe(Effect2.mapError(toClientError));
|
|
1408
1435
|
if (wait === undefined) {
|
|
1409
1436
|
return yield* new ClientError({ message: `Child join wait missing: ${childExecutionId}` });
|
|
1410
1437
|
}
|
|
@@ -1415,8 +1442,8 @@ var reconcileExistingChildSpawn = Effect.fn("Client.reconcileExistingChildSpawn"
|
|
|
1415
1442
|
parentWaitId
|
|
1416
1443
|
};
|
|
1417
1444
|
});
|
|
1418
|
-
var parentDefinitionPin =
|
|
1419
|
-
const record = yield* executionRepository.get(executionId).pipe(
|
|
1445
|
+
var parentDefinitionPin = Effect2.fn("Client.parentDefinitionPin")(function* (executionRepository, executionId) {
|
|
1446
|
+
const record = yield* executionRepository.get(executionId).pipe(Effect2.mapError(toClientError));
|
|
1420
1447
|
if (record === undefined) {
|
|
1421
1448
|
return yield* new ClientError({ message: `Execution not found: ${executionId}` });
|
|
1422
1449
|
}
|
|
@@ -1433,7 +1460,7 @@ var parentDefinitionPin = Effect.fn("Client.parentDefinitionPin")(function* (exe
|
|
|
1433
1460
|
var childStartInput = (input, accepted, pin, definition, createdAt, parentWaitId) => ({
|
|
1434
1461
|
execution_id: exports_ids_schema.ExecutionId.make(accepted.child_execution_id),
|
|
1435
1462
|
root_address_id: input.address_id,
|
|
1436
|
-
session_id: childSessionId(accepted.child_execution_id),
|
|
1463
|
+
session_id: exports_execution_schema.childSessionId(accepted.child_execution_id),
|
|
1437
1464
|
input: input.input === undefined ? [] : [...input.input],
|
|
1438
1465
|
event_sequence: 0,
|
|
1439
1466
|
started_at: createdAt,
|
|
@@ -1448,7 +1475,7 @@ var childStartInput = (input, accepted, pin, definition, createdAt, parentWaitId
|
|
|
1448
1475
|
...parentWaitId === undefined ? {} : { parent_wait_id: parentWaitId }
|
|
1449
1476
|
}
|
|
1450
1477
|
});
|
|
1451
|
-
var layerFromRuntime =
|
|
1478
|
+
var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
1452
1479
|
const makeExecutionClient = yield* exports_execution_entity.client;
|
|
1453
1480
|
const executions = yield* exports_execution_service.Service;
|
|
1454
1481
|
const envelopes = yield* exports_envelope_service.Service;
|
|
@@ -1478,28 +1505,29 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1478
1505
|
const skillRegistry = yield* exports_skill_registry_service.Service;
|
|
1479
1506
|
const toolTransitions = yield* exports_tool_transition_coordinator.Service;
|
|
1480
1507
|
const workflows = yield* exports_workflow_definition_repository.Service;
|
|
1481
|
-
const workflowRuntime = yield*
|
|
1482
|
-
const childFanOutRuntime = yield*
|
|
1483
|
-
const
|
|
1484
|
-
const
|
|
1485
|
-
const
|
|
1486
|
-
const
|
|
1508
|
+
const workflowRuntime = yield* Effect2.serviceOption(exports_definition_runtime.Service);
|
|
1509
|
+
const childFanOutRuntime = yield* Effect2.serviceOption(exports_child_fan_out_runtime.Service);
|
|
1510
|
+
const runtimeCapabilityPolicy = yield* Effect2.serviceOption(Service);
|
|
1511
|
+
const schemaRegistry = yield* Effect2.serviceOption(exports_schema_registry_service.Service);
|
|
1512
|
+
const coordinateToolTransition = (effect) => toolTransitions.coordinate(effect).pipe(Effect2.mapError(toClientError));
|
|
1513
|
+
const coordinateChildSpawn = (effect) => toolTransitions.coordinate(effect).pipe(Effect2.mapError(toClientError));
|
|
1514
|
+
const cancelFanOut = Effect2.fn("Client.runtime.cancelFanOut")(function* (input) {
|
|
1487
1515
|
if (Option.isSome(childFanOutRuntime)) {
|
|
1488
|
-
const fanOut = yield* childFanOutRuntime.value.cancel(input.fan_out_id, input.cancelled_at, input.reason ?? "child fan-out cancelled").pipe(
|
|
1516
|
+
const fanOut = yield* childFanOutRuntime.value.cancel(input.fan_out_id, input.cancelled_at, input.reason ?? "child fan-out cancelled").pipe(Effect2.mapError(toClientError));
|
|
1489
1517
|
if (fanOut === undefined)
|
|
1490
1518
|
return yield* new ClientError({ message: `Child fan-out not found: ${input.fan_out_id}` });
|
|
1491
1519
|
return { fan_out: fanOut };
|
|
1492
1520
|
}
|
|
1493
|
-
const result = yield* childFanOuts.cancel(input.fan_out_id, input.cancelled_at).pipe(
|
|
1521
|
+
const result = yield* childFanOuts.cancel(input.fan_out_id, input.cancelled_at).pipe(Effect2.mapError(toClientError));
|
|
1494
1522
|
if (result === undefined)
|
|
1495
1523
|
return yield* new ClientError({ message: `Child fan-out not found: ${input.fan_out_id}` });
|
|
1496
|
-
yield*
|
|
1524
|
+
yield* Effect2.forEach(result.activeChildExecutionIds, (childId) => makeExecutionClient(exports_ids_schema.ExecutionId.make(childId)).cancel({
|
|
1497
1525
|
execution_id: exports_ids_schema.ExecutionId.make(childId),
|
|
1498
1526
|
cancelled_at: input.cancelled_at,
|
|
1499
1527
|
reason: input.reason ?? "child fan-out cancelled"
|
|
1500
|
-
}).pipe(
|
|
1528
|
+
}).pipe(Effect2.mapError(toClientError)), { discard: true });
|
|
1501
1529
|
if (result.transitioned) {
|
|
1502
|
-
const max = yield* eventLog.maxSequence(result.fanOut.parent_execution_id).pipe(
|
|
1530
|
+
const max = yield* eventLog.maxSequence(result.fanOut.parent_execution_id).pipe(Effect2.mapError(toClientError));
|
|
1503
1531
|
yield* exports_event_log_service.appendIdempotentTo(eventLog, {
|
|
1504
1532
|
id: exports_ids_schema.EventId.make(`event:${result.fanOut.parent_execution_id}:fan-out:${input.fan_out_id}:terminal`),
|
|
1505
1533
|
execution_id: result.fanOut.parent_execution_id,
|
|
@@ -1508,26 +1536,26 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1508
1536
|
cursor: `${result.fanOut.parent_execution_id}:fan-out:${input.fan_out_id}:terminal`,
|
|
1509
1537
|
data: { fan_out_id: input.fan_out_id, state: "cancelled" },
|
|
1510
1538
|
created_at: input.cancelled_at
|
|
1511
|
-
}).pipe(
|
|
1539
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1512
1540
|
}
|
|
1513
1541
|
return { fan_out: result.fanOut };
|
|
1514
1542
|
});
|
|
1515
|
-
const sendEnvelope =
|
|
1543
|
+
const sendEnvelope = Effect2.fn("Client.runtime.send")(function* (input) {
|
|
1516
1544
|
const identity = input.idempotency_key ?? input.correlation_key ?? `${input.from}:${input.to}`;
|
|
1517
1545
|
const executionId = exports_ids_schema.ExecutionId.make(input.correlation_key ?? `execution:send:${identity}`);
|
|
1518
1546
|
const envelopeId = exports_ids_schema.EnvelopeId.make(`${executionId}:envelope:${identity}`);
|
|
1519
1547
|
const createdAt = yield* Clock.currentTimeMillis;
|
|
1520
|
-
const maxSequence = yield* eventLog.maxSequence(executionId).pipe(
|
|
1548
|
+
const maxSequence = yield* eventLog.maxSequence(executionId).pipe(Effect2.mapError(toClientError));
|
|
1521
1549
|
return yield* envelopes.send({
|
|
1522
1550
|
envelopeId,
|
|
1523
1551
|
executionId,
|
|
1524
1552
|
input,
|
|
1525
1553
|
eventSequence: maxSequence === undefined ? 0 : maxSequence + 1,
|
|
1526
1554
|
createdAt
|
|
1527
|
-
}).pipe(
|
|
1555
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1528
1556
|
});
|
|
1529
|
-
const waitOutcomeFrom =
|
|
1530
|
-
const reply = wait.state === "resolved" ? yield* envelopeReady.getEnvelope(exports_ids_schema.EnvelopeId.make(`envelope:reply:${wait.id}`)).pipe(
|
|
1557
|
+
const waitOutcomeFrom = Effect2.fn("Client.runtime.waitOutcome")(function* (wait) {
|
|
1558
|
+
const reply = wait.state === "resolved" ? yield* envelopeReady.getEnvelope(exports_ids_schema.EnvelopeId.make(`envelope:reply:${wait.id}`)).pipe(Effect2.mapError(toClientError)) : undefined;
|
|
1531
1559
|
return {
|
|
1532
1560
|
wait_id: wait.id,
|
|
1533
1561
|
state: wait.state,
|
|
@@ -1535,22 +1563,22 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1535
1563
|
...Object.keys(wait.metadata).length === 0 ? {} : { metadata: wait.metadata }
|
|
1536
1564
|
};
|
|
1537
1565
|
});
|
|
1538
|
-
const awaitWaitOperation =
|
|
1539
|
-
const current = yield* envelopeReady.getWait(input.wait_id).pipe(
|
|
1566
|
+
const awaitWaitOperation = Effect2.fn("Client.runtime.awaitWait")(function* (input) {
|
|
1567
|
+
const current = yield* envelopeReady.getWait(input.wait_id).pipe(Effect2.mapError(toClientError));
|
|
1540
1568
|
if (current === undefined) {
|
|
1541
1569
|
return yield* new ClientError({ message: `wait ${input.wait_id} not found` });
|
|
1542
1570
|
}
|
|
1543
1571
|
if (current.state !== "open")
|
|
1544
1572
|
return yield* waitOutcomeFrom(current);
|
|
1545
|
-
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,
|
|
1546
|
-
const terminal = yield* envelopeReady.getWait(input.wait_id).pipe(
|
|
1573
|
+
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
|
+
const terminal = yield* envelopeReady.getWait(input.wait_id).pipe(Effect2.mapError(toClientError));
|
|
1547
1575
|
if (terminal === undefined || terminal.state === "open") {
|
|
1548
1576
|
return yield* new ClientError({ message: `wait ${input.wait_id} did not reach a terminal state` });
|
|
1549
1577
|
}
|
|
1550
1578
|
return yield* waitOutcomeFrom(terminal);
|
|
1551
1579
|
});
|
|
1552
|
-
const getExecutionOperation =
|
|
1553
|
-
const record = yield* executionRepository.get(id).pipe(
|
|
1580
|
+
const getExecutionOperation = Effect2.fn("Client.runtime.getExecution")(function* (id) {
|
|
1581
|
+
const record = yield* executionRepository.get(id).pipe(Effect2.mapError(toClientError));
|
|
1554
1582
|
return record === undefined ? undefined : toExecutionView(record);
|
|
1555
1583
|
});
|
|
1556
1584
|
const streamExecutionOperation = (input) => executions.stream({
|
|
@@ -1558,16 +1586,16 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1558
1586
|
...input.after_cursor === undefined ? {} : { afterCursor: input.after_cursor },
|
|
1559
1587
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1560
1588
|
}).pipe(Stream.mapError(toStreamError));
|
|
1561
|
-
const inspectExecutionOperation =
|
|
1562
|
-
const execution = yield* executionRepository.get(executionId).pipe(
|
|
1589
|
+
const inspectExecutionOperation = Effect2.fn("Client.runtime.inspectExecution")(function* (executionId) {
|
|
1590
|
+
const execution = yield* executionRepository.get(executionId).pipe(Effect2.mapError(toClientError));
|
|
1563
1591
|
if (execution === undefined)
|
|
1564
1592
|
return yield* new ExecutionNotFound({ execution_id: executionId });
|
|
1565
|
-
const openWaits = yield* envelopeReady.listAllWaits({ executionId, state: "open" }).pipe(
|
|
1566
|
-
const calls = yield* toolCalls.listCalls(executionId).pipe(
|
|
1567
|
-
const pendingChunks = yield*
|
|
1568
|
-
const children = yield* childExecutions.listByExecution(executionId).pipe(
|
|
1569
|
-
const maxSequence = yield* eventLog.maxSequence(executionId).pipe(
|
|
1570
|
-
const lastEvent = maxSequence === undefined ? undefined : yield* eventLog.findBySequence({ executionId, sequence: maxSequence }).pipe(
|
|
1593
|
+
const openWaits = yield* envelopeReady.listAllWaits({ executionId, state: "open" }).pipe(Effect2.mapError(toClientError));
|
|
1594
|
+
const calls = yield* toolCalls.listCalls(executionId).pipe(Effect2.mapError(toClientError));
|
|
1595
|
+
const pendingChunks = yield* Effect2.forEach(calls, (call) => toolCalls.getResult(call.call.id).pipe(Effect2.mapError(toClientError), Effect2.map((result) => result === undefined ? [toToolCallSummary(call)] : [])));
|
|
1596
|
+
const children = yield* childExecutions.listByExecution(executionId).pipe(Effect2.mapError(toClientError));
|
|
1597
|
+
const maxSequence = yield* eventLog.maxSequence(executionId).pipe(Effect2.mapError(toClientError));
|
|
1598
|
+
const lastEvent = maxSequence === undefined ? undefined : yield* eventLog.findBySequence({ executionId, sequence: maxSequence }).pipe(Effect2.mapError(toClientError), Effect2.map(Option.getOrUndefined));
|
|
1571
1599
|
return {
|
|
1572
1600
|
execution_id: execution.id,
|
|
1573
1601
|
status: execution.status,
|
|
@@ -1577,108 +1605,110 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1577
1605
|
...lastEvent === undefined ? {} : { last_event_cursor: lastEvent.cursor }
|
|
1578
1606
|
};
|
|
1579
1607
|
});
|
|
1580
|
-
return
|
|
1581
|
-
registerEntityKind: (input) => entityRegistry.registerKind(input).pipe(
|
|
1608
|
+
return Service2.of({
|
|
1609
|
+
registerEntityKind: (input) => entityRegistry.registerKind(input).pipe(Effect2.mapError(toClientError)),
|
|
1582
1610
|
getOrCreateEntity: (input) => entities.getOrCreate({
|
|
1583
1611
|
kind: input.kind,
|
|
1584
1612
|
key: input.key,
|
|
1585
1613
|
createdAt: input.created_at,
|
|
1586
1614
|
...input.input === undefined ? {} : { input: input.input },
|
|
1587
1615
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
1588
|
-
}).pipe(
|
|
1589
|
-
getEntity: (input) => entities.get(input).pipe(
|
|
1616
|
+
}).pipe(Effect2.mapError(toClientError)),
|
|
1617
|
+
getEntity: (input) => entities.get(input).pipe(Effect2.mapError(toClientError)),
|
|
1590
1618
|
destroyEntity: (input) => entities.destroy({
|
|
1591
1619
|
kind: input.kind,
|
|
1592
1620
|
key: input.key,
|
|
1593
1621
|
destroyedAt: input.destroyed_at,
|
|
1594
1622
|
...input.reason === undefined ? {} : { reason: input.reason }
|
|
1595
|
-
}).pipe(
|
|
1623
|
+
}).pipe(Effect2.mapError(toClientError)),
|
|
1596
1624
|
listEntities: (input) => entities.list({
|
|
1597
1625
|
...input.kind === undefined ? {} : { kind: input.kind },
|
|
1598
1626
|
...input.after_kind === undefined ? {} : { afterKind: input.after_kind },
|
|
1599
1627
|
...input.after_key === undefined ? {} : { afterKey: input.after_key },
|
|
1600
1628
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1601
|
-
}).pipe(
|
|
1602
|
-
registerWorkflowDefinition:
|
|
1603
|
-
return { record: yield* workflows.register(input).pipe(
|
|
1629
|
+
}).pipe(Effect2.mapError(toClientError)),
|
|
1630
|
+
registerWorkflowDefinition: Effect2.fn("Client.runtime.registerWorkflowDefinition")(function* (input) {
|
|
1631
|
+
return { record: yield* workflows.register(input).pipe(Effect2.mapError(toClientError)) };
|
|
1604
1632
|
}),
|
|
1605
|
-
getWorkflowDefinitionRevision:
|
|
1606
|
-
return yield* workflows.get(id, revision).pipe(
|
|
1633
|
+
getWorkflowDefinitionRevision: Effect2.fn("Client.runtime.getWorkflowDefinitionRevision")(function* (id, revision) {
|
|
1634
|
+
return yield* workflows.get(id, revision).pipe(Effect2.mapError(toClientError));
|
|
1607
1635
|
}),
|
|
1608
|
-
listWorkflowDefinitionRevisions:
|
|
1609
|
-
return { records: yield* workflows.list(id).pipe(
|
|
1636
|
+
listWorkflowDefinitionRevisions: Effect2.fn("Client.runtime.listWorkflowDefinitionRevisions")(function* (id) {
|
|
1637
|
+
return { records: yield* workflows.list(id).pipe(Effect2.mapError(toClientError)) };
|
|
1610
1638
|
}),
|
|
1611
|
-
startWorkflowRun:
|
|
1639
|
+
startWorkflowRun: Effect2.fn("Client.runtime.startWorkflowRun")(function* (input) {
|
|
1640
|
+
if (Option.isSome(runtimeCapabilityPolicy))
|
|
1641
|
+
yield* runtimeCapabilityPolicy.value.admit("workflow-definition");
|
|
1612
1642
|
return yield* Option.match(workflowRuntime, {
|
|
1613
1643
|
onNone: () => workflows.start(input),
|
|
1614
1644
|
onSome: (runtime) => runtime.start(input)
|
|
1615
|
-
}).pipe(
|
|
1645
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1616
1646
|
}),
|
|
1617
|
-
inspectWorkflowRun:
|
|
1647
|
+
inspectWorkflowRun: Effect2.fn("Client.runtime.inspectWorkflowRun")(function* (id) {
|
|
1618
1648
|
return yield* Option.match(workflowRuntime, {
|
|
1619
1649
|
onNone: () => workflows.inspect(id),
|
|
1620
1650
|
onSome: (runtime) => runtime.inspect(id)
|
|
1621
|
-
}).pipe(
|
|
1651
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1622
1652
|
}),
|
|
1623
|
-
replayWorkflowRun:
|
|
1653
|
+
replayWorkflowRun: Effect2.fn("Client.runtime.replayWorkflowRun")(function* (id) {
|
|
1624
1654
|
return yield* Option.match(workflowRuntime, {
|
|
1625
1655
|
onNone: () => workflows.listLifecycle(id),
|
|
1626
1656
|
onSome: (runtime) => runtime.replay(id)
|
|
1627
|
-
}).pipe(
|
|
1657
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1628
1658
|
}),
|
|
1629
|
-
cancelWorkflowRun:
|
|
1659
|
+
cancelWorkflowRun: Effect2.fn("Client.runtime.cancelWorkflowRun")(function* (id) {
|
|
1630
1660
|
return yield* Option.match(workflowRuntime, {
|
|
1631
|
-
onNone: () => workflows.cancel(id),
|
|
1661
|
+
onNone: () => workflows.cancel(id).pipe(Effect2.map((result) => result.record)),
|
|
1632
1662
|
onSome: (runtime) => runtime.cancel(id)
|
|
1633
|
-
}).pipe(
|
|
1663
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1634
1664
|
}),
|
|
1635
|
-
registerAgent:
|
|
1665
|
+
registerAgent: Effect2.fn("Client.runtime.registerAgent")(function* (input) {
|
|
1636
1666
|
const payload = yield* registerAgentPayload(input);
|
|
1637
|
-
const registered = yield* agentRegistry.register(payload).pipe(
|
|
1667
|
+
const registered = yield* agentRegistry.register(payload).pipe(Effect2.mapError(toClientError));
|
|
1638
1668
|
if (input.address !== undefined) {
|
|
1639
|
-
yield* addressBook.register(input.address, { kind: "local-agent", route_key: payload.id }).pipe(
|
|
1669
|
+
yield* addressBook.register(input.address, { kind: "local-agent", route_key: payload.id }).pipe(Effect2.mapError(toClientError));
|
|
1640
1670
|
}
|
|
1641
1671
|
return registered;
|
|
1642
1672
|
}),
|
|
1643
|
-
registerAgentDefinition:
|
|
1644
|
-
return yield* agentRegistry.register(input).pipe(
|
|
1673
|
+
registerAgentDefinition: Effect2.fn("Client.runtime.registerAgentDefinition")(function* (input) {
|
|
1674
|
+
return yield* agentRegistry.register(input).pipe(Effect2.mapError(toClientError));
|
|
1645
1675
|
}),
|
|
1646
|
-
getAgentDefinition:
|
|
1647
|
-
return yield* agentRegistry.get(id).pipe(
|
|
1676
|
+
getAgentDefinition: Effect2.fn("Client.runtime.getAgentDefinition")(function* (id) {
|
|
1677
|
+
return yield* agentRegistry.get(id).pipe(Effect2.mapError(toClientError));
|
|
1648
1678
|
}),
|
|
1649
|
-
listAgentDefinitions:
|
|
1650
|
-
return yield* agentRegistry.list().pipe(
|
|
1679
|
+
listAgentDefinitions: Effect2.fn("Client.runtime.listAgentDefinitions")(function* () {
|
|
1680
|
+
return yield* agentRegistry.list().pipe(Effect2.mapError(toClientError));
|
|
1651
1681
|
}),
|
|
1652
|
-
listAgentDefinitionRevisions:
|
|
1653
|
-
return yield* agentRegistry.listRevisions(id).pipe(
|
|
1682
|
+
listAgentDefinitionRevisions: Effect2.fn("Client.runtime.listAgentDefinitionRevisions")(function* (id) {
|
|
1683
|
+
return yield* agentRegistry.listRevisions(id).pipe(Effect2.mapError(toClientError));
|
|
1654
1684
|
}),
|
|
1655
|
-
getSkillDefinition:
|
|
1656
|
-
return yield* skillRegistry.get(id).pipe(
|
|
1685
|
+
getSkillDefinition: Effect2.fn("Client.runtime.getSkillDefinition")(function* (id) {
|
|
1686
|
+
return yield* skillRegistry.get(id).pipe(Effect2.mapError(toClientError));
|
|
1657
1687
|
}),
|
|
1658
|
-
listSkillDefinitions:
|
|
1659
|
-
return yield* skillRegistry.list().pipe(
|
|
1688
|
+
listSkillDefinitions: Effect2.fn("Client.runtime.listSkillDefinitions")(function* () {
|
|
1689
|
+
return yield* skillRegistry.list().pipe(Effect2.mapError(toClientError));
|
|
1660
1690
|
}),
|
|
1661
|
-
listSkillDefinitionRevisions:
|
|
1662
|
-
return yield* skillRegistry.listRevisions(id).pipe(
|
|
1691
|
+
listSkillDefinitionRevisions: Effect2.fn("Client.runtime.listSkillDefinitionRevisions")(function* (id) {
|
|
1692
|
+
return yield* skillRegistry.listRevisions(id).pipe(Effect2.mapError(toClientError));
|
|
1663
1693
|
}),
|
|
1664
|
-
registerAddressBookRoute:
|
|
1694
|
+
registerAddressBookRoute: Effect2.fn("Client.runtime.registerAddressBookRoute")(function* (input) {
|
|
1665
1695
|
yield* rejectReserved(input.address_id, "address:entity:");
|
|
1666
|
-
return yield* addressBook.register(input.address_id, input.route).pipe(
|
|
1696
|
+
return yield* addressBook.register(input.address_id, input.route).pipe(Effect2.mapError(toClientError));
|
|
1667
1697
|
}),
|
|
1668
|
-
getAddressBookRoute:
|
|
1669
|
-
return yield* addressBook.get(id).pipe(
|
|
1698
|
+
getAddressBookRoute: Effect2.fn("Client.runtime.getAddressBookRoute")(function* (id) {
|
|
1699
|
+
return yield* addressBook.get(id).pipe(Effect2.mapError(toClientError));
|
|
1670
1700
|
}),
|
|
1671
|
-
listAddressBookRoutes:
|
|
1672
|
-
return yield* addressBook.list().pipe(
|
|
1701
|
+
listAddressBookRoutes: Effect2.fn("Client.runtime.listAddressBookRoutes")(function* () {
|
|
1702
|
+
return yield* addressBook.list().pipe(Effect2.mapError(toClientError));
|
|
1673
1703
|
}),
|
|
1674
|
-
startExecution:
|
|
1704
|
+
startExecution: Effect2.fn("Client.runtime.startExecution")(function* (input) {
|
|
1675
1705
|
yield* rejectReserved(input.execution_id, "execution:entity:");
|
|
1676
1706
|
if (input.session_id !== undefined)
|
|
1677
1707
|
yield* rejectReserved(input.session_id, "session:entity:");
|
|
1678
1708
|
const client = makeExecutionClient(input.execution_id);
|
|
1679
|
-
return yield* client.start(input).pipe(
|
|
1709
|
+
return yield* client.start(input).pipe(Effect2.mapError(toClientError));
|
|
1680
1710
|
}),
|
|
1681
|
-
startExecutionByAddress:
|
|
1711
|
+
startExecutionByAddress: Effect2.fn("Client.runtime.startExecutionByAddress")(function* (input) {
|
|
1682
1712
|
yield* rejectReserved(input.idempotency_key, "entity:");
|
|
1683
1713
|
if (input.execution_id !== undefined)
|
|
1684
1714
|
yield* rejectReserved(input.execution_id, "execution:entity:");
|
|
@@ -1686,25 +1716,25 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1686
1716
|
yield* rejectReserved(input.session_id, "session:entity:");
|
|
1687
1717
|
const payload = startExecutionByAddressPayload(input);
|
|
1688
1718
|
const client = makeExecutionClient(payload.execution_id);
|
|
1689
|
-
return yield* client.start(payload).pipe(
|
|
1719
|
+
return yield* client.start(payload).pipe(Effect2.mapError(toClientError));
|
|
1690
1720
|
}),
|
|
1691
|
-
startExecutionByAgentDefinition:
|
|
1721
|
+
startExecutionByAgentDefinition: Effect2.fn("Client.runtime.startExecutionByAgentDefinition")(function* (input) {
|
|
1692
1722
|
yield* rejectReserved(input.idempotency_key, "entity:");
|
|
1693
1723
|
if (input.execution_id !== undefined)
|
|
1694
1724
|
yield* rejectReserved(input.execution_id, "execution:entity:");
|
|
1695
1725
|
if (input.session_id !== undefined)
|
|
1696
1726
|
yield* rejectReserved(input.session_id, "session:entity:");
|
|
1697
|
-
const definition = yield* agentRegistry.getRevision({ id: input.agent_id, revision: input.agent_revision }).pipe(
|
|
1727
|
+
const definition = yield* agentRegistry.getRevision({ id: input.agent_id, revision: input.agent_revision }).pipe(Effect2.mapError(toClientError));
|
|
1698
1728
|
if (definition === undefined) {
|
|
1699
|
-
return yield*
|
|
1729
|
+
return yield* Effect2.fail(new ClientError({ message: `Agent revision not found: ${input.agent_id}@${input.agent_revision}` }));
|
|
1700
1730
|
}
|
|
1701
1731
|
const payload = startExecutionByAgentDefinitionPayload(input, definition);
|
|
1702
1732
|
const client = makeExecutionClient(payload.execution_id);
|
|
1703
|
-
return yield* client.start(payload).pipe(
|
|
1733
|
+
return yield* client.start(payload).pipe(Effect2.mapError(toClientError));
|
|
1704
1734
|
}),
|
|
1705
|
-
cancelExecution:
|
|
1706
|
-
const fanOuts = yield* childFanOuts.listNonTerminal(input.execution_id).pipe(
|
|
1707
|
-
yield*
|
|
1735
|
+
cancelExecution: Effect2.fn("Client.runtime.cancelExecution")(function* (input) {
|
|
1736
|
+
const fanOuts = yield* childFanOuts.listNonTerminal(input.execution_id).pipe(Effect2.mapError(toClientError));
|
|
1737
|
+
yield* Effect2.forEach(fanOuts, (fanOut) => cancelFanOut({
|
|
1708
1738
|
fan_out_id: fanOut.fan_out_id,
|
|
1709
1739
|
cancelled_at: input.cancelled_at,
|
|
1710
1740
|
...input.reason === undefined ? {} : { reason: input.reason }
|
|
@@ -1714,10 +1744,10 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1714
1744
|
execution_id: input.execution_id,
|
|
1715
1745
|
cancelled_at: input.cancelled_at,
|
|
1716
1746
|
...input.reason === undefined ? {} : { reason: input.reason }
|
|
1717
|
-
}).pipe(
|
|
1747
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1718
1748
|
}),
|
|
1719
|
-
steer:
|
|
1720
|
-
const execution = yield* executionRepository.get(input.execution_id).pipe(
|
|
1749
|
+
steer: Effect2.fn("Client.runtime.steer")(function* (input) {
|
|
1750
|
+
const execution = yield* executionRepository.get(input.execution_id).pipe(Effect2.mapError(toClientError));
|
|
1721
1751
|
if (execution === undefined) {
|
|
1722
1752
|
return yield* new ClientError({ message: `Execution not found: ${input.execution_id}` });
|
|
1723
1753
|
}
|
|
@@ -1729,7 +1759,7 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1729
1759
|
kind: input.kind,
|
|
1730
1760
|
content: input.content,
|
|
1731
1761
|
createdAt: input.created_at
|
|
1732
|
-
}).pipe(
|
|
1762
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1733
1763
|
return { execution_id: record.executionId, kind: record.kind, sequence: record.sequence };
|
|
1734
1764
|
}),
|
|
1735
1765
|
getExecution: getExecutionOperation,
|
|
@@ -1739,104 +1769,104 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1739
1769
|
inspectExecution: inspectExecutionOperation,
|
|
1740
1770
|
streamExecution: streamExecutionOperation
|
|
1741
1771
|
}),
|
|
1742
|
-
listWaits:
|
|
1772
|
+
listWaits: Effect2.fn("Client.runtime.listWaits")(function* (input) {
|
|
1743
1773
|
const records = yield* envelopeReady.listWaits({
|
|
1744
1774
|
...input.state === undefined ? {} : { state: input.state },
|
|
1745
1775
|
...input.execution_id === undefined ? {} : { executionId: input.execution_id },
|
|
1746
1776
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1747
|
-
}).pipe(
|
|
1777
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1748
1778
|
return records.map(toWaitView);
|
|
1749
1779
|
}),
|
|
1750
|
-
listExecutions:
|
|
1751
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
1780
|
+
listExecutions: Effect2.fn("Client.runtime.listExecutions")(function* (input) {
|
|
1781
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema4.decodeEffect(ExecutionCursorFromString)(input.cursor).pipe(Effect2.mapError(toClientError));
|
|
1752
1782
|
const result = yield* executionRepository.list({
|
|
1753
1783
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
1754
1784
|
...input.status === undefined ? {} : { status: input.status },
|
|
1755
1785
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
1756
1786
|
...cursor === undefined ? {} : { cursor }
|
|
1757
|
-
}).pipe(
|
|
1758
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
1787
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1788
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema4.encodeEffect(ExecutionCursorFromString)(result.nextCursor).pipe(Effect2.mapError(toClientError));
|
|
1759
1789
|
return {
|
|
1760
1790
|
records: result.records.map(toConversationSummary),
|
|
1761
1791
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
1762
1792
|
};
|
|
1763
1793
|
}),
|
|
1764
|
-
subscribeTopic:
|
|
1794
|
+
subscribeTopic: Effect2.fn("Client.runtime.subscribeTopic")(function* (input) {
|
|
1765
1795
|
return yield* topicService.subscribe({
|
|
1766
1796
|
topicAddressId: input.topic_address_id,
|
|
1767
1797
|
subscriberExecutionId: input.subscriber_execution_id,
|
|
1768
1798
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
1769
|
-
}).pipe(
|
|
1799
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1770
1800
|
}),
|
|
1771
|
-
unsubscribeTopic:
|
|
1801
|
+
unsubscribeTopic: Effect2.fn("Client.runtime.unsubscribeTopic")(function* (input) {
|
|
1772
1802
|
return yield* topicService.unsubscribe({
|
|
1773
1803
|
topicAddressId: input.topic_address_id,
|
|
1774
1804
|
subscriberExecutionId: input.subscriber_execution_id
|
|
1775
|
-
}).pipe(
|
|
1805
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1776
1806
|
}),
|
|
1777
|
-
publishTopic:
|
|
1807
|
+
publishTopic: Effect2.fn("Client.runtime.publishTopic")(function* (input) {
|
|
1778
1808
|
return yield* topicService.publish({
|
|
1779
1809
|
topicAddressId: input.topic_address_id,
|
|
1780
1810
|
from: input.from,
|
|
1781
1811
|
content: input.content,
|
|
1782
1812
|
...input.metadata === undefined ? {} : { metadata: input.metadata },
|
|
1783
1813
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key }
|
|
1784
|
-
}).pipe(
|
|
1814
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1785
1815
|
}),
|
|
1786
|
-
listTopicSubscriptions:
|
|
1816
|
+
listTopicSubscriptions: Effect2.fn("Client.runtime.listTopicSubscriptions")(function* (input) {
|
|
1787
1817
|
return yield* topicService.list({
|
|
1788
1818
|
...input.topic_address_id === undefined ? {} : { topicAddressId: input.topic_address_id },
|
|
1789
1819
|
...input.subscriber_execution_id === undefined ? {} : { subscriberExecutionId: input.subscriber_execution_id }
|
|
1790
|
-
}).pipe(
|
|
1820
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1791
1821
|
}),
|
|
1792
|
-
listInboxMessages:
|
|
1822
|
+
listInboxMessages: Effect2.fn("Client.runtime.listInboxMessages")(function* (input) {
|
|
1793
1823
|
return yield* inboxRepository.list({
|
|
1794
1824
|
executionId: input.execution_id,
|
|
1795
1825
|
...input.include_consumed === undefined ? {} : { includeConsumed: input.include_consumed },
|
|
1796
1826
|
...input.after_sequence === undefined ? {} : { afterSequence: input.after_sequence },
|
|
1797
1827
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1798
|
-
}).pipe(
|
|
1828
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1799
1829
|
}),
|
|
1800
|
-
listSessions:
|
|
1801
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
1830
|
+
listSessions: Effect2.fn("Client.runtime.listSessions")(function* (input) {
|
|
1831
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema4.decodeEffect(SessionCursorFromString)(input.cursor).pipe(Effect2.mapError(toClientError));
|
|
1802
1832
|
const result = yield* sessionRepository.list({
|
|
1803
1833
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
1804
1834
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
1805
1835
|
...cursor === undefined ? {} : { cursor }
|
|
1806
|
-
}).pipe(
|
|
1807
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
1836
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1837
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema4.encodeEffect(SessionCursorFromString)(result.nextCursor).pipe(Effect2.mapError(toClientError));
|
|
1808
1838
|
return {
|
|
1809
1839
|
records: result.records.map(toSessionSummary),
|
|
1810
1840
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
1811
1841
|
};
|
|
1812
1842
|
}),
|
|
1813
|
-
getSession:
|
|
1814
|
-
const session = yield* sessionRepository.get(input.session_id).pipe(
|
|
1843
|
+
getSession: Effect2.fn("Client.runtime.getSession")(function* (input) {
|
|
1844
|
+
const session = yield* sessionRepository.get(input.session_id).pipe(Effect2.mapError(toClientError));
|
|
1815
1845
|
if (session === undefined)
|
|
1816
1846
|
return yield* new ClientError({ message: `Session not found: ${input.session_id}` });
|
|
1817
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
1847
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema4.decodeEffect(ExecutionCursorFromString)(input.cursor).pipe(Effect2.mapError(toClientError));
|
|
1818
1848
|
const result = yield* executionRepository.list({
|
|
1819
1849
|
sessionId: input.session_id,
|
|
1820
1850
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
1821
1851
|
...cursor === undefined ? {} : { cursor }
|
|
1822
|
-
}).pipe(
|
|
1823
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
1852
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1853
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema4.encodeEffect(ExecutionCursorFromString)(result.nextCursor).pipe(Effect2.mapError(toClientError));
|
|
1824
1854
|
return {
|
|
1825
1855
|
session: toSessionSummary(session),
|
|
1826
1856
|
executions: result.records.map(toConversationSummary),
|
|
1827
1857
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
1828
1858
|
};
|
|
1829
1859
|
}),
|
|
1830
|
-
replayExecution:
|
|
1860
|
+
replayExecution: Effect2.fn("Client.runtime.replayExecution")(function* (input) {
|
|
1831
1861
|
const events = yield* eventLog.replay({
|
|
1832
1862
|
executionId: input.execution_id,
|
|
1833
1863
|
...input.after_cursor === undefined ? {} : { afterCursor: input.after_cursor },
|
|
1834
1864
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1835
|
-
}).pipe(
|
|
1865
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1836
1866
|
return { events };
|
|
1837
1867
|
}),
|
|
1838
|
-
listRunners:
|
|
1839
|
-
const runners = yield* clusterRegistry.listRunners().pipe(
|
|
1868
|
+
listRunners: Effect2.fn("Client.runtime.listRunners")(function* () {
|
|
1869
|
+
const runners = yield* clusterRegistry.listRunners().pipe(Effect2.mapError(toClientError));
|
|
1840
1870
|
return {
|
|
1841
1871
|
runners: runners.map((runner) => ({
|
|
1842
1872
|
address: runner.address,
|
|
@@ -1847,9 +1877,9 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1847
1877
|
total_shards: shardingConfig.shardsPerGroup * shardingConfig.availableShardGroups.length
|
|
1848
1878
|
};
|
|
1849
1879
|
}),
|
|
1850
|
-
routeExecution:
|
|
1880
|
+
routeExecution: Effect2.fn("Client.runtime.routeExecution")(function* (executionId) {
|
|
1851
1881
|
const shard = ShardId.toString(sharding.getShardId(EntityId.make(executionId), "execution"));
|
|
1852
|
-
const owner = yield* clusterRegistry.lockOwner(shard).pipe(
|
|
1882
|
+
const owner = yield* clusterRegistry.lockOwner(shard).pipe(Effect2.mapError(toClientError));
|
|
1853
1883
|
const runnerAddress = owner ?? null;
|
|
1854
1884
|
const self = Option.map(shardingConfig.runnerAddress, (address) => `${address.host}:${address.port}`);
|
|
1855
1885
|
return {
|
|
@@ -1860,12 +1890,12 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1860
1890
|
};
|
|
1861
1891
|
}),
|
|
1862
1892
|
send: sendEnvelope,
|
|
1863
|
-
askEntity:
|
|
1864
|
-
const instance = yield* entities.get({ kind: input.kind, key: input.key }).pipe(
|
|
1893
|
+
askEntity: Effect2.fn("Client.runtime.askEntity")(function* (input) {
|
|
1894
|
+
const instance = yield* entities.get({ kind: input.kind, key: input.key }).pipe(Effect2.mapError(toClientError));
|
|
1865
1895
|
if (instance === undefined || instance.status === "destroyed") {
|
|
1866
1896
|
return yield* new EntityNotFound({ kind: input.kind, key: input.key });
|
|
1867
1897
|
}
|
|
1868
|
-
const encoded = yield*
|
|
1898
|
+
const encoded = yield* Schema4.encodeUnknownEffect(input.command.input)(input.input).pipe(Effect2.mapError(toClientError));
|
|
1869
1899
|
const inputRef = inputSchemaRef(input.command.name);
|
|
1870
1900
|
const outputRef = outputSchemaRef(input.command.name);
|
|
1871
1901
|
if (Option.isSome(schemaRegistry)) {
|
|
@@ -1912,7 +1942,7 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1912
1942
|
message: "reply carried no decodable content"
|
|
1913
1943
|
});
|
|
1914
1944
|
}
|
|
1915
|
-
return yield*
|
|
1945
|
+
return yield* Schema4.decodeUnknownEffect(input.command.output)(replyValue.value).pipe(Effect2.mapError((issue) => new CommandReplyInvalid({
|
|
1916
1946
|
command: input.command.name,
|
|
1917
1947
|
wait_id: outcome.wait_id,
|
|
1918
1948
|
message: errorMessage(issue)
|
|
@@ -1934,49 +1964,49 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1934
1964
|
...input.session_id === undefined ? {} : { sessionId: input.session_id },
|
|
1935
1965
|
...input.status === undefined ? {} : { status: input.status },
|
|
1936
1966
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1937
|
-
}).pipe(Stream.mapEffect((change) => change._tag === "snapshot" ? change.nextCursor === undefined ?
|
|
1967
|
+
}).pipe(Stream.mapEffect((change) => change._tag === "snapshot" ? change.nextCursor === undefined ? Effect2.succeed({
|
|
1938
1968
|
_tag: "snapshot",
|
|
1939
1969
|
records: change.records.map(toConversationSummary)
|
|
1940
|
-
}) : encodeExecutionCursor(change.nextCursor).pipe(
|
|
1970
|
+
}) : encodeExecutionCursor(change.nextCursor).pipe(Effect2.map((next_cursor) => ({
|
|
1941
1971
|
_tag: "snapshot",
|
|
1942
1972
|
records: change.records.map(toConversationSummary),
|
|
1943
1973
|
next_cursor
|
|
1944
|
-
}))) :
|
|
1974
|
+
}))) : Effect2.succeed({
|
|
1945
1975
|
_tag: "upsert",
|
|
1946
1976
|
record: toConversationSummary(change.record)
|
|
1947
1977
|
})), Stream.mapError(toClientError)),
|
|
1948
|
-
getEntityState:
|
|
1949
|
-
putEntityState:
|
|
1978
|
+
getEntityState: Effect2.fn("Client.runtime.getEntityState")((input) => executionState.getRecord(input.execution_id, input.key).pipe(Effect2.mapError(toClientError))),
|
|
1979
|
+
putEntityState: Effect2.fn("Client.runtime.putEntityState")((input) => executionState.put({
|
|
1950
1980
|
executionId: input.execution_id,
|
|
1951
1981
|
key: exports_execution_state_service.key(input.key, exports_shared_schema.JsonValue),
|
|
1952
1982
|
value: input.value,
|
|
1953
1983
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
1954
1984
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
1955
1985
|
updatedAt: input.updated_at
|
|
1956
|
-
}).pipe(
|
|
1957
|
-
deleteEntityState:
|
|
1986
|
+
}).pipe(Effect2.mapError((error) => error instanceof exports_execution_state_service.StateVersionConflict ? error : toClientError(error)))),
|
|
1987
|
+
deleteEntityState: Effect2.fn("Client.runtime.deleteEntityState")((input) => executionState.remove({
|
|
1958
1988
|
executionId: input.execution_id,
|
|
1959
1989
|
key: input.key,
|
|
1960
1990
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
1961
1991
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
1962
1992
|
removedAt: input.removed_at
|
|
1963
|
-
}).pipe(
|
|
1964
|
-
listEntityState:
|
|
1993
|
+
}).pipe(Effect2.mapError((error) => error instanceof exports_execution_state_service.StateVersionConflict ? error : toClientError(error)))),
|
|
1994
|
+
listEntityState: Effect2.fn("Client.runtime.listEntityState")((input) => executionState.list({
|
|
1965
1995
|
executionId: input.execution_id,
|
|
1966
1996
|
...input.prefix === undefined ? {} : { prefix: input.prefix },
|
|
1967
1997
|
...input.after_key === undefined ? {} : { afterKey: input.after_key },
|
|
1968
1998
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1969
|
-
}).pipe(
|
|
1970
|
-
getPresence: (scope) => presence.list(scope).pipe(
|
|
1999
|
+
}).pipe(Effect2.mapError(toClientError))),
|
|
2000
|
+
getPresence: (scope) => presence.list(scope).pipe(Effect2.mapError(toClientError)),
|
|
1971
2001
|
watchPresence: (scope) => presence.watch(scope).pipe(Stream.mapError(toClientError)),
|
|
1972
|
-
wake:
|
|
2002
|
+
wake: Effect2.fn("Client.runtime.wake")(function* (input) {
|
|
1973
2003
|
return yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, input);
|
|
1974
2004
|
}),
|
|
1975
|
-
listPendingApprovals:
|
|
1976
|
-
const records = yield* envelopeReady.listWaits({ executionId: input.execution_id, state: "open" }).pipe(
|
|
2005
|
+
listPendingApprovals: Effect2.fn("Client.runtime.listPendingApprovals")(function* (input) {
|
|
2006
|
+
const records = yield* envelopeReady.listWaits({ executionId: input.execution_id, state: "open" }).pipe(Effect2.mapError(toClientError));
|
|
1977
2007
|
return { approvals: records.filter(isToolApprovalWait).map(toPendingToolApproval) };
|
|
1978
2008
|
}),
|
|
1979
|
-
resolveToolApproval:
|
|
2009
|
+
resolveToolApproval: Effect2.fn("Client.runtime.resolveToolApproval")(function* (input) {
|
|
1980
2010
|
return yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, {
|
|
1981
2011
|
wait_id: input.wait_id,
|
|
1982
2012
|
state: "resolved",
|
|
@@ -1987,7 +2017,7 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1987
2017
|
}
|
|
1988
2018
|
}, "tool-approval");
|
|
1989
2019
|
}),
|
|
1990
|
-
resolvePermission:
|
|
2020
|
+
resolvePermission: Effect2.fn("Client.runtime.resolvePermission")(function* (input) {
|
|
1991
2021
|
return yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, {
|
|
1992
2022
|
wait_id: input.wait_id,
|
|
1993
2023
|
state: "resolved",
|
|
@@ -1998,18 +2028,18 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1998
2028
|
}
|
|
1999
2029
|
}, "tool-permission");
|
|
2000
2030
|
}),
|
|
2001
|
-
listPendingToolCalls:
|
|
2031
|
+
listPendingToolCalls: Effect2.fn("Client.runtime.listPendingToolCalls")(function* (input) {
|
|
2002
2032
|
const openWaits = yield* envelopeReady.listAllWaits({
|
|
2003
2033
|
state: "open",
|
|
2004
2034
|
...input.execution_id === undefined ? {} : { executionId: input.execution_id }
|
|
2005
|
-
}).pipe(
|
|
2006
|
-
const records = yield*
|
|
2035
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
2036
|
+
const records = yield* Effect2.forEach(openWaits.filter((wait) => wait.metadata.kind === "tool-placement"), (wait) => toolCalls.getCall(exports_ids_schema.ToolCallId.make(String(wait.metadata.tool_call_id ?? ""))).pipe(Effect2.mapError(toClientError), Effect2.map((call) => call?.placement.kind === "client" && call.state === "waiting" ? toPendingToolCall(call) : undefined)));
|
|
2007
2037
|
const sorted = records.filter((record) => record !== undefined).toSorted((left, right) => left.requested_at - right.requested_at || left.call.id.localeCompare(right.call.id));
|
|
2008
2038
|
return { tool_calls: input.limit === undefined ? sorted : sorted.slice(0, input.limit) };
|
|
2009
2039
|
}),
|
|
2010
|
-
fulfillToolCall:
|
|
2011
|
-
const coordinated = yield* coordinateToolTransition(
|
|
2012
|
-
const call = yield* toolCalls.getCall(input.tool_call_id).pipe(
|
|
2040
|
+
fulfillToolCall: Effect2.fn("Client.runtime.fulfillToolCall")(function* (input) {
|
|
2041
|
+
const coordinated = yield* coordinateToolTransition(Effect2.gen(function* () {
|
|
2042
|
+
const call = yield* toolCalls.getCall(input.tool_call_id).pipe(Effect2.mapError(toClientError));
|
|
2013
2043
|
if (call === undefined || call.executionId !== input.execution_id || call.placement.kind !== "client") {
|
|
2014
2044
|
return yield* new ClientError({ message: `Client tool call not found: ${input.tool_call_id}` });
|
|
2015
2045
|
}
|
|
@@ -2019,24 +2049,24 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
2019
2049
|
callId: input.tool_call_id,
|
|
2020
2050
|
outcome: input.outcome,
|
|
2021
2051
|
submittedAt: input.fulfilled_at
|
|
2022
|
-
}).pipe(
|
|
2052
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
2023
2053
|
return { wait, accepted };
|
|
2024
2054
|
}));
|
|
2025
2055
|
yield* signalToolOutcome(executionRepository, makeExecutionClient, coordinated.wait, input.fulfilled_at);
|
|
2026
2056
|
return toToolOutcomeAccepted(coordinated.accepted);
|
|
2027
2057
|
}),
|
|
2028
|
-
claimToolWork:
|
|
2058
|
+
claimToolWork: Effect2.fn("Client.runtime.claimToolWork")(function* (input) {
|
|
2029
2059
|
const lease = yield* coordinateToolTransition(toolCalls.claimRemote({
|
|
2030
2060
|
queue: input.queue,
|
|
2031
2061
|
workerId: input.worker_id,
|
|
2032
2062
|
now: input.now,
|
|
2033
2063
|
claimExpiresAt: input.claim_expires_at
|
|
2034
|
-
}).pipe(
|
|
2064
|
+
}).pipe(Effect2.mapError(toClientError)));
|
|
2035
2065
|
return lease === undefined ? null : toToolWorkLease(lease);
|
|
2036
2066
|
}),
|
|
2037
|
-
completeToolWork:
|
|
2038
|
-
const coordinated = yield* coordinateToolTransition(
|
|
2039
|
-
const call = yield* toolCalls.getCall(input.tool_call_id).pipe(
|
|
2067
|
+
completeToolWork: Effect2.fn("Client.runtime.completeToolWork")(function* (input) {
|
|
2068
|
+
const coordinated = yield* coordinateToolTransition(Effect2.gen(function* () {
|
|
2069
|
+
const call = yield* toolCalls.getCall(input.tool_call_id).pipe(Effect2.mapError(toClientError));
|
|
2040
2070
|
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;
|
|
2041
2071
|
const acceptedRetry = call !== undefined && call.placement.kind === "remote" && call.state === "submitted" && call.activeAttemptId === input.attempt_id && call.externalOutcome !== undefined;
|
|
2042
2072
|
if (call === undefined || !active && !acceptedRetry) {
|
|
@@ -2049,13 +2079,13 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
2049
2079
|
workerId: input.worker_id,
|
|
2050
2080
|
outcome: input.outcome,
|
|
2051
2081
|
submittedAt: input.completed_at
|
|
2052
|
-
}).pipe(
|
|
2082
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
2053
2083
|
return { wait, accepted };
|
|
2054
2084
|
}));
|
|
2055
2085
|
yield* signalToolOutcome(executionRepository, makeExecutionClient, coordinated.wait, input.completed_at);
|
|
2056
2086
|
return toToolOutcomeAccepted(coordinated.accepted);
|
|
2057
2087
|
}),
|
|
2058
|
-
releaseToolWork:
|
|
2088
|
+
releaseToolWork: Effect2.fn("Client.runtime.releaseToolWork")(function* (input) {
|
|
2059
2089
|
const call = yield* coordinateToolTransition(toolCalls.releaseRemote({
|
|
2060
2090
|
callId: input.tool_call_id,
|
|
2061
2091
|
attemptId: input.attempt_id,
|
|
@@ -2063,94 +2093,96 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
2063
2093
|
releasedAt: input.released_at,
|
|
2064
2094
|
nextAvailableAt: input.next_available_at,
|
|
2065
2095
|
...input.error === undefined ? {} : { error: input.error }
|
|
2066
|
-
}).pipe(
|
|
2096
|
+
}).pipe(Effect2.mapError(toClientError)));
|
|
2067
2097
|
return {
|
|
2068
2098
|
tool_call_id: call.call.id,
|
|
2069
2099
|
state: "waiting",
|
|
2070
2100
|
next_available_at: call.availableAt
|
|
2071
2101
|
};
|
|
2072
2102
|
}),
|
|
2073
|
-
listToolAttempts:
|
|
2074
|
-
const attempts = yield* toolCalls.listAttempts(input.tool_call_id).pipe(
|
|
2103
|
+
listToolAttempts: Effect2.fn("Client.runtime.listToolAttempts")(function* (input) {
|
|
2104
|
+
const attempts = yield* toolCalls.listAttempts(input.tool_call_id).pipe(Effect2.mapError(toClientError));
|
|
2075
2105
|
return { attempts: attempts.map(toToolAttempt) };
|
|
2076
2106
|
}),
|
|
2077
|
-
submitInboundEnvelope:
|
|
2078
|
-
const envelope = yield* executions.send(input.envelope).pipe(
|
|
2107
|
+
submitInboundEnvelope: Effect2.fn("Client.runtime.submitInboundEnvelope")(function* (input) {
|
|
2108
|
+
const envelope = yield* executions.send(input.envelope).pipe(Effect2.mapError(toClientError));
|
|
2079
2109
|
const wakeResult = yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, input.wake);
|
|
2080
2110
|
return { envelope, wake: wakeResult };
|
|
2081
2111
|
}),
|
|
2082
|
-
spawnChildRun:
|
|
2112
|
+
spawnChildRun: Effect2.fn("Client.runtime.spawnChildRun")(function* (input) {
|
|
2083
2113
|
const pin = yield* parentDefinitionPin(executionRepository, input.execution_id);
|
|
2084
2114
|
const createdAt = yield* Clock.currentTimeMillis;
|
|
2085
2115
|
const internal = internalSpawnChildRunInput(input, pin, createdAt);
|
|
2086
|
-
const context = yield* exports_child_run_service.resolveForDispatch(internal).pipe(
|
|
2087
|
-
const definition = yield* exports_child_run_service.childDefinition(pin.agentSnapshot, context).pipe(
|
|
2088
|
-
const coordinated = yield* coordinateChildSpawn(
|
|
2116
|
+
const context = yield* exports_child_run_service.resolveForDispatch(internal).pipe(Effect2.mapError((error) => new ClientError({ message: error._tag })));
|
|
2117
|
+
const definition = yield* exports_child_run_service.childDefinition(pin.agentSnapshot, context).pipe(Effect2.mapError((error) => new ClientError({ message: error._tag })));
|
|
2118
|
+
const coordinated = yield* coordinateChildSpawn(Effect2.gen(function* () {
|
|
2089
2119
|
const existing = yield* reconcileExistingChildSpawn(childExecutions, waits, eventLog, input);
|
|
2090
2120
|
if (existing !== undefined)
|
|
2091
2121
|
return existing;
|
|
2092
|
-
const accepted = yield* executions.spawnChildRun(internal).pipe(
|
|
2122
|
+
const accepted = yield* executions.spawnChildRun(internal).pipe(Effect2.mapError(toClientError));
|
|
2093
2123
|
const parentWaitId = input.wait === true ? yield* createChildJoinWait(waits, eventLog, internal, accepted, createdAt) : undefined;
|
|
2094
2124
|
return { accepted, createdAt, parentWaitId };
|
|
2095
|
-
})).pipe(
|
|
2125
|
+
})).pipe(Effect2.catch((error) => error.message === "DuplicateChildExecution" ? coordinateChildSpawn(reconcileExistingChildSpawn(childExecutions, waits, eventLog, input).pipe(Effect2.flatMap((existing) => existing === undefined ? Effect2.fail(new ClientError({ message: `Child execution retry missing: ${input.execution_id}` })) : Effect2.succeed(existing)))) : Effect2.fail(error)));
|
|
2096
2126
|
const startPayload = childStartInput(internal, coordinated.accepted, pin, definition, coordinated.createdAt, coordinated.parentWaitId);
|
|
2097
2127
|
const client = makeExecutionClient(startPayload.execution_id);
|
|
2098
|
-
yield* client.dispatch(startPayload).pipe(
|
|
2128
|
+
yield* client.dispatch(startPayload).pipe(Effect2.mapError(toClientError));
|
|
2099
2129
|
return coordinated.accepted;
|
|
2100
2130
|
}),
|
|
2101
|
-
createChildFanOut:
|
|
2131
|
+
createChildFanOut: Effect2.fn("Client.runtime.createChildFanOut")(function* (input) {
|
|
2132
|
+
if (Option.isSome(runtimeCapabilityPolicy))
|
|
2133
|
+
yield* runtimeCapabilityPolicy.value.admit("fan-out");
|
|
2102
2134
|
if (Option.isNone(childFanOutRuntime)) {
|
|
2103
2135
|
return yield* new ClientError({
|
|
2104
2136
|
message: "Child fan-out runtime unavailable; provide ChildFanOutRuntime.Service to Client.layerFromRuntime"
|
|
2105
2137
|
});
|
|
2106
2138
|
}
|
|
2107
|
-
return yield* childFanOutRuntime.value.create(input).pipe(
|
|
2139
|
+
return yield* childFanOutRuntime.value.create(input).pipe(Effect2.mapError(toClientError));
|
|
2108
2140
|
}),
|
|
2109
|
-
cancelChildFanOut:
|
|
2141
|
+
cancelChildFanOut: Effect2.fn("Client.runtime.cancelChildFanOut")(function* (input) {
|
|
2110
2142
|
return yield* cancelFanOut(input);
|
|
2111
2143
|
}),
|
|
2112
|
-
inspectChildFanOut:
|
|
2144
|
+
inspectChildFanOut: Effect2.fn("Client.runtime.inspectChildFanOut")(function* (input) {
|
|
2113
2145
|
const fanOut = yield* Option.match(childFanOutRuntime, {
|
|
2114
2146
|
onNone: () => childFanOuts.get(input.fan_out_id),
|
|
2115
2147
|
onSome: (runtime) => runtime.inspect(input.fan_out_id)
|
|
2116
|
-
}).pipe(
|
|
2148
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
2117
2149
|
return { fan_out: fanOut ?? null };
|
|
2118
2150
|
}),
|
|
2119
|
-
claimEnvelopeReady:
|
|
2151
|
+
claimEnvelopeReady: Effect2.fn("Client.runtime.claimEnvelopeReady")(function* (input) {
|
|
2120
2152
|
return yield* envelopeReady.claimReady({
|
|
2121
2153
|
routeType: input.route_type,
|
|
2122
2154
|
...input.route_key === undefined ? {} : { routeKey: input.route_key },
|
|
2123
2155
|
workerId: input.worker_id,
|
|
2124
2156
|
now: input.now,
|
|
2125
2157
|
claimExpiresAt: input.claim_expires_at
|
|
2126
|
-
}).pipe(
|
|
2158
|
+
}).pipe(Effect2.map((record) => record === undefined ? null : toLease(record)), Effect2.mapError(toClientError));
|
|
2127
2159
|
}),
|
|
2128
|
-
ackEnvelopeReady:
|
|
2160
|
+
ackEnvelopeReady: Effect2.fn("Client.runtime.ackEnvelopeReady")(function* (input) {
|
|
2129
2161
|
return yield* envelopeReady.ackReady({
|
|
2130
2162
|
id: input.envelope_ready_id,
|
|
2131
2163
|
workerId: input.worker_id,
|
|
2132
2164
|
now: input.acknowledged_at
|
|
2133
|
-
}).pipe(
|
|
2165
|
+
}).pipe(Effect2.map((record) => ({
|
|
2134
2166
|
envelope_ready_id: record.id,
|
|
2135
2167
|
state: "acknowledged",
|
|
2136
2168
|
acknowledged_at: record.acknowledgedAt ?? input.acknowledged_at
|
|
2137
|
-
})),
|
|
2169
|
+
})), Effect2.mapError(toClientError));
|
|
2138
2170
|
}),
|
|
2139
|
-
releaseEnvelopeReady:
|
|
2171
|
+
releaseEnvelopeReady: Effect2.fn("Client.runtime.releaseEnvelopeReady")(function* (input) {
|
|
2140
2172
|
return yield* envelopeReady.releaseReady({
|
|
2141
2173
|
id: input.envelope_ready_id,
|
|
2142
2174
|
workerId: input.worker_id,
|
|
2143
2175
|
nextAvailableAt: input.next_available_at,
|
|
2144
2176
|
...input.error === undefined ? {} : { error: input.error }
|
|
2145
|
-
}).pipe(
|
|
2177
|
+
}).pipe(Effect2.map((record) => ({
|
|
2146
2178
|
envelope_ready_id: record.id,
|
|
2147
2179
|
state: "ready",
|
|
2148
2180
|
next_available_at: record.availableAt
|
|
2149
|
-
})),
|
|
2181
|
+
})), Effect2.mapError(toClientError));
|
|
2150
2182
|
}),
|
|
2151
|
-
createSchedule:
|
|
2183
|
+
createSchedule: Effect2.fn("Client.runtime.createSchedule")(function* (input) {
|
|
2152
2184
|
if (input.cron_expr !== undefined) {
|
|
2153
|
-
yield* exports_scheduler_service.parseCron(input.cron_expr).pipe(
|
|
2185
|
+
yield* exports_scheduler_service.parseCron(input.cron_expr).pipe(Effect2.mapError(toClientError));
|
|
2154
2186
|
}
|
|
2155
2187
|
const createdAt = yield* Clock.currentTimeMillis;
|
|
2156
2188
|
const schedule = yield* schedules.create({
|
|
@@ -2165,287 +2197,603 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
2165
2197
|
...input.input === undefined ? {} : { input: input.input },
|
|
2166
2198
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
2167
2199
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
2168
|
-
}).pipe(
|
|
2200
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
2169
2201
|
return { schedule };
|
|
2170
2202
|
}),
|
|
2171
|
-
cancelSchedule:
|
|
2172
|
-
const schedule = yield* schedules.cancel({ id: input.schedule_id, cancelledAt: input.cancelled_at }).pipe(
|
|
2203
|
+
cancelSchedule: Effect2.fn("Client.runtime.cancelSchedule")(function* (input) {
|
|
2204
|
+
const schedule = yield* schedules.cancel({ id: input.schedule_id, cancelledAt: input.cancelled_at }).pipe(Effect2.mapError(toClientError));
|
|
2173
2205
|
return { schedule };
|
|
2174
2206
|
}),
|
|
2175
|
-
listSchedules:
|
|
2176
|
-
const records = yield* schedules.list(input.state === undefined ? {} : { state: input.state }).pipe(
|
|
2207
|
+
listSchedules: Effect2.fn("Client.runtime.listSchedules")(function* (input) {
|
|
2208
|
+
const records = yield* schedules.list(input.state === undefined ? {} : { state: input.state }).pipe(Effect2.mapError(toClientError));
|
|
2177
2209
|
return { schedules: records };
|
|
2178
2210
|
})
|
|
2179
2211
|
});
|
|
2180
2212
|
}));
|
|
2181
|
-
var testLayer = (implementation) =>
|
|
2213
|
+
var testLayer = (implementation) => Layer2.succeed(Service2, Service2.of({
|
|
2182
2214
|
...implementation,
|
|
2183
2215
|
followExecution: implementation.followExecution ?? followExecutionFrom({
|
|
2184
2216
|
getExecution: implementation.getExecution,
|
|
2185
2217
|
inspectExecution: implementation.inspectExecution,
|
|
2186
2218
|
streamExecution: implementation.streamExecution
|
|
2187
2219
|
}),
|
|
2188
|
-
registerEntityKind: implementation.registerEntityKind ?? ((input) =>
|
|
2189
|
-
getOrCreateEntity: implementation.getOrCreateEntity ?? (() =>
|
|
2190
|
-
getEntity: implementation.getEntity ?? (() =>
|
|
2191
|
-
destroyEntity: implementation.destroyEntity ?? (() =>
|
|
2192
|
-
listEntities: implementation.listEntities ?? (() =>
|
|
2220
|
+
registerEntityKind: implementation.registerEntityKind ?? ((input) => Effect2.succeed(input)),
|
|
2221
|
+
getOrCreateEntity: implementation.getOrCreateEntity ?? (() => Effect2.fail(new ClientError({ message: "Entity service unavailable" }))),
|
|
2222
|
+
getEntity: implementation.getEntity ?? (() => Effect2.succeed(undefined)),
|
|
2223
|
+
destroyEntity: implementation.destroyEntity ?? (() => Effect2.fail(new ClientError({ message: "Entity service unavailable" }))),
|
|
2224
|
+
listEntities: implementation.listEntities ?? (() => Effect2.succeed([])),
|
|
2193
2225
|
streamSession: implementation.streamSession ?? (() => Stream.empty),
|
|
2194
2226
|
watchExecutions: implementation.watchExecutions ?? (() => Stream.empty),
|
|
2195
|
-
getPresence: implementation.getPresence ?? ((scope) =>
|
|
2227
|
+
getPresence: implementation.getPresence ?? ((scope) => Effect2.succeed({ scope, entries: [], observed_at: 0 })),
|
|
2196
2228
|
watchPresence: implementation.watchPresence ?? (() => Stream.empty),
|
|
2197
|
-
registerWorkflowDefinition: implementation.registerWorkflowDefinition ?? (() =>
|
|
2198
|
-
getWorkflowDefinitionRevision: implementation.getWorkflowDefinitionRevision ?? (() =>
|
|
2199
|
-
listWorkflowDefinitionRevisions: implementation.listWorkflowDefinitionRevisions ?? (() =>
|
|
2200
|
-
startWorkflowRun: implementation.startWorkflowRun ?? (() =>
|
|
2201
|
-
inspectWorkflowRun: implementation.inspectWorkflowRun ?? (() =>
|
|
2202
|
-
replayWorkflowRun: implementation.replayWorkflowRun ?? (() =>
|
|
2203
|
-
cancelWorkflowRun: implementation.cancelWorkflowRun ?? (() =>
|
|
2229
|
+
registerWorkflowDefinition: implementation.registerWorkflowDefinition ?? (() => Effect2.die("registerWorkflowDefinition not implemented")),
|
|
2230
|
+
getWorkflowDefinitionRevision: implementation.getWorkflowDefinitionRevision ?? (() => Effect2.die("getWorkflowDefinitionRevision not implemented")),
|
|
2231
|
+
listWorkflowDefinitionRevisions: implementation.listWorkflowDefinitionRevisions ?? (() => Effect2.die("listWorkflowDefinitionRevisions not implemented")),
|
|
2232
|
+
startWorkflowRun: implementation.startWorkflowRun ?? (() => Effect2.die("startWorkflowRun not implemented")),
|
|
2233
|
+
inspectWorkflowRun: implementation.inspectWorkflowRun ?? (() => Effect2.die("inspectWorkflowRun not implemented")),
|
|
2234
|
+
replayWorkflowRun: implementation.replayWorkflowRun ?? (() => Effect2.die("replayWorkflowRun not implemented")),
|
|
2235
|
+
cancelWorkflowRun: implementation.cancelWorkflowRun ?? (() => Effect2.die("cancelWorkflowRun not implemented"))
|
|
2204
2236
|
}));
|
|
2205
|
-
var registerAgentDefinition =
|
|
2206
|
-
const service = yield*
|
|
2237
|
+
var registerAgentDefinition = Effect2.fn("Client.registerAgentDefinition.call")(function* (input) {
|
|
2238
|
+
const service = yield* Service2;
|
|
2207
2239
|
return yield* service.registerAgentDefinition(input);
|
|
2208
2240
|
});
|
|
2209
|
-
var registerEntityKind =
|
|
2210
|
-
const service = yield*
|
|
2241
|
+
var registerEntityKind = Effect2.fn("Client.registerEntityKind.call")(function* (input) {
|
|
2242
|
+
const service = yield* Service2;
|
|
2211
2243
|
return yield* service.registerEntityKind(input);
|
|
2212
2244
|
});
|
|
2213
|
-
var getOrCreateEntity =
|
|
2214
|
-
const service = yield*
|
|
2245
|
+
var getOrCreateEntity = Effect2.fn("Client.getOrCreateEntity.call")(function* (input) {
|
|
2246
|
+
const service = yield* Service2;
|
|
2215
2247
|
return yield* service.getOrCreateEntity(input);
|
|
2216
2248
|
});
|
|
2217
|
-
var getEntity =
|
|
2218
|
-
const service = yield*
|
|
2249
|
+
var getEntity = Effect2.fn("Client.getEntity.call")(function* (input) {
|
|
2250
|
+
const service = yield* Service2;
|
|
2219
2251
|
return yield* service.getEntity(input);
|
|
2220
2252
|
});
|
|
2221
|
-
var destroyEntity =
|
|
2222
|
-
const service = yield*
|
|
2253
|
+
var destroyEntity = Effect2.fn("Client.destroyEntity.call")(function* (input) {
|
|
2254
|
+
const service = yield* Service2;
|
|
2223
2255
|
return yield* service.destroyEntity(input);
|
|
2224
2256
|
});
|
|
2225
|
-
var listEntities =
|
|
2226
|
-
const service = yield*
|
|
2257
|
+
var listEntities = Effect2.fn("Client.listEntities.call")(function* (input) {
|
|
2258
|
+
const service = yield* Service2;
|
|
2227
2259
|
return yield* service.listEntities(input);
|
|
2228
2260
|
});
|
|
2229
|
-
var registerAgent =
|
|
2230
|
-
const service = yield*
|
|
2261
|
+
var registerAgent = Effect2.fn("Client.registerAgent.call")(function* (input) {
|
|
2262
|
+
const service = yield* Service2;
|
|
2231
2263
|
return yield* service.registerAgent(input);
|
|
2232
2264
|
});
|
|
2233
|
-
var getAgentDefinition =
|
|
2234
|
-
const service = yield*
|
|
2265
|
+
var getAgentDefinition = Effect2.fn("Client.getAgentDefinition.call")(function* (id) {
|
|
2266
|
+
const service = yield* Service2;
|
|
2235
2267
|
return yield* service.getAgentDefinition(id);
|
|
2236
2268
|
});
|
|
2237
|
-
var listAgentDefinitions =
|
|
2238
|
-
const service = yield*
|
|
2269
|
+
var listAgentDefinitions = Effect2.fn("Client.listAgentDefinitions.call")(function* () {
|
|
2270
|
+
const service = yield* Service2;
|
|
2239
2271
|
return yield* service.listAgentDefinitions();
|
|
2240
2272
|
});
|
|
2241
|
-
var listAgentDefinitionRevisions =
|
|
2242
|
-
const service = yield*
|
|
2273
|
+
var listAgentDefinitionRevisions = Effect2.fn("Client.listAgentDefinitionRevisions.call")(function* (id) {
|
|
2274
|
+
const service = yield* Service2;
|
|
2243
2275
|
return yield* service.listAgentDefinitionRevisions(id);
|
|
2244
2276
|
});
|
|
2245
|
-
var getSkillDefinition =
|
|
2246
|
-
const service = yield*
|
|
2277
|
+
var getSkillDefinition = Effect2.fn("Client.getSkillDefinition.call")(function* (id) {
|
|
2278
|
+
const service = yield* Service2;
|
|
2247
2279
|
return yield* service.getSkillDefinition(id);
|
|
2248
2280
|
});
|
|
2249
|
-
var listSkillDefinitions =
|
|
2250
|
-
const service = yield*
|
|
2281
|
+
var listSkillDefinitions = Effect2.fn("Client.listSkillDefinitions.call")(function* () {
|
|
2282
|
+
const service = yield* Service2;
|
|
2251
2283
|
return yield* service.listSkillDefinitions();
|
|
2252
2284
|
});
|
|
2253
|
-
var listSkillDefinitionRevisions =
|
|
2254
|
-
const service = yield*
|
|
2285
|
+
var listSkillDefinitionRevisions = Effect2.fn("Client.listSkillDefinitionRevisions.call")(function* (id) {
|
|
2286
|
+
const service = yield* Service2;
|
|
2255
2287
|
return yield* service.listSkillDefinitionRevisions(id);
|
|
2256
2288
|
});
|
|
2257
|
-
var registerAddressBookRoute =
|
|
2258
|
-
const service = yield*
|
|
2289
|
+
var registerAddressBookRoute = Effect2.fn("Client.registerAddressBookRoute.call")(function* (input) {
|
|
2290
|
+
const service = yield* Service2;
|
|
2259
2291
|
return yield* service.registerAddressBookRoute(input);
|
|
2260
2292
|
});
|
|
2261
|
-
var getAddressBookRoute =
|
|
2262
|
-
const service = yield*
|
|
2293
|
+
var getAddressBookRoute = Effect2.fn("Client.getAddressBookRoute.call")(function* (id) {
|
|
2294
|
+
const service = yield* Service2;
|
|
2263
2295
|
return yield* service.getAddressBookRoute(id);
|
|
2264
2296
|
});
|
|
2265
|
-
var listAddressBookRoutes =
|
|
2266
|
-
const service = yield*
|
|
2297
|
+
var listAddressBookRoutes = Effect2.fn("Client.listAddressBookRoutes.call")(function* () {
|
|
2298
|
+
const service = yield* Service2;
|
|
2267
2299
|
return yield* service.listAddressBookRoutes();
|
|
2268
2300
|
});
|
|
2269
|
-
var startExecution =
|
|
2270
|
-
const service = yield*
|
|
2301
|
+
var startExecution = Effect2.fn("Client.startExecution.call")(function* (input) {
|
|
2302
|
+
const service = yield* Service2;
|
|
2271
2303
|
return yield* service.startExecution(input);
|
|
2272
2304
|
});
|
|
2273
|
-
var startExecutionByAddress =
|
|
2274
|
-
const service = yield*
|
|
2305
|
+
var startExecutionByAddress = Effect2.fn("Client.startExecutionByAddress.call")(function* (input) {
|
|
2306
|
+
const service = yield* Service2;
|
|
2275
2307
|
return yield* service.startExecutionByAddress(input);
|
|
2276
2308
|
});
|
|
2277
|
-
var startExecutionByAgentDefinition =
|
|
2278
|
-
const service = yield*
|
|
2309
|
+
var startExecutionByAgentDefinition = Effect2.fn("Client.startExecutionByAgentDefinition.call")(function* (input) {
|
|
2310
|
+
const service = yield* Service2;
|
|
2279
2311
|
return yield* service.startExecutionByAgentDefinition(input);
|
|
2280
2312
|
});
|
|
2281
|
-
var cancelExecution =
|
|
2282
|
-
const service = yield*
|
|
2313
|
+
var cancelExecution = Effect2.fn("Client.cancelExecution.call")(function* (input) {
|
|
2314
|
+
const service = yield* Service2;
|
|
2283
2315
|
return yield* service.cancelExecution(input);
|
|
2284
2316
|
});
|
|
2285
|
-
var steer =
|
|
2286
|
-
const service = yield*
|
|
2317
|
+
var steer = Effect2.fn("Client.steer.call")(function* (input) {
|
|
2318
|
+
const service = yield* Service2;
|
|
2287
2319
|
return yield* service.steer(input);
|
|
2288
2320
|
});
|
|
2289
|
-
var getExecution =
|
|
2290
|
-
const service = yield*
|
|
2321
|
+
var getExecution = Effect2.fn("Client.getExecution.call")(function* (id) {
|
|
2322
|
+
const service = yield* Service2;
|
|
2291
2323
|
return yield* service.getExecution(id);
|
|
2292
2324
|
});
|
|
2293
|
-
var listExecutions =
|
|
2294
|
-
const service = yield*
|
|
2325
|
+
var listExecutions = Effect2.fn("Client.listExecutions.call")(function* (input) {
|
|
2326
|
+
const service = yield* Service2;
|
|
2295
2327
|
return yield* service.listExecutions(input);
|
|
2296
2328
|
});
|
|
2297
|
-
var listSessions =
|
|
2298
|
-
const service = yield*
|
|
2329
|
+
var listSessions = Effect2.fn("Client.listSessions.call")(function* (input) {
|
|
2330
|
+
const service = yield* Service2;
|
|
2299
2331
|
return yield* service.listSessions(input);
|
|
2300
2332
|
});
|
|
2301
|
-
var getSession =
|
|
2302
|
-
const service = yield*
|
|
2333
|
+
var getSession = Effect2.fn("Client.getSession.call")(function* (input) {
|
|
2334
|
+
const service = yield* Service2;
|
|
2303
2335
|
return yield* service.getSession(input);
|
|
2304
2336
|
});
|
|
2305
|
-
var listWaits =
|
|
2306
|
-
const service = yield*
|
|
2337
|
+
var listWaits = Effect2.fn("Client.listWaits.call")(function* (input) {
|
|
2338
|
+
const service = yield* Service2;
|
|
2307
2339
|
return yield* service.listWaits(input);
|
|
2308
2340
|
});
|
|
2309
|
-
var replayExecution =
|
|
2310
|
-
const service = yield*
|
|
2341
|
+
var replayExecution = Effect2.fn("Client.replayExecution.call")(function* (input) {
|
|
2342
|
+
const service = yield* Service2;
|
|
2311
2343
|
return yield* service.replayExecution(input);
|
|
2312
2344
|
});
|
|
2313
|
-
var listRunners =
|
|
2314
|
-
const service = yield*
|
|
2345
|
+
var listRunners = Effect2.fn("Client.listRunners.call")(function* () {
|
|
2346
|
+
const service = yield* Service2;
|
|
2315
2347
|
return yield* service.listRunners();
|
|
2316
2348
|
});
|
|
2317
|
-
var routeExecution =
|
|
2318
|
-
const service = yield*
|
|
2349
|
+
var routeExecution = Effect2.fn("Client.routeExecution.call")(function* (executionId) {
|
|
2350
|
+
const service = yield* Service2;
|
|
2319
2351
|
return yield* service.routeExecution(executionId);
|
|
2320
2352
|
});
|
|
2321
|
-
var subscribeTopic =
|
|
2322
|
-
const service = yield*
|
|
2353
|
+
var subscribeTopic = Effect2.fn("Client.subscribeTopic.call")(function* (input) {
|
|
2354
|
+
const service = yield* Service2;
|
|
2323
2355
|
return yield* service.subscribeTopic(input);
|
|
2324
2356
|
});
|
|
2325
|
-
var unsubscribeTopic =
|
|
2326
|
-
const service = yield*
|
|
2357
|
+
var unsubscribeTopic = Effect2.fn("Client.unsubscribeTopic.call")(function* (input) {
|
|
2358
|
+
const service = yield* Service2;
|
|
2327
2359
|
return yield* service.unsubscribeTopic(input);
|
|
2328
2360
|
});
|
|
2329
|
-
var publishTopic =
|
|
2330
|
-
const service = yield*
|
|
2361
|
+
var publishTopic = Effect2.fn("Client.publishTopic.call")(function* (input) {
|
|
2362
|
+
const service = yield* Service2;
|
|
2331
2363
|
return yield* service.publishTopic(input);
|
|
2332
2364
|
});
|
|
2333
|
-
var listTopicSubscriptions =
|
|
2334
|
-
const service = yield*
|
|
2365
|
+
var listTopicSubscriptions = Effect2.fn("Client.listTopicSubscriptions.call")(function* (input) {
|
|
2366
|
+
const service = yield* Service2;
|
|
2335
2367
|
return yield* service.listTopicSubscriptions(input);
|
|
2336
2368
|
});
|
|
2337
|
-
var listInboxMessages =
|
|
2338
|
-
const service = yield*
|
|
2369
|
+
var listInboxMessages = Effect2.fn("Client.listInboxMessages.call")(function* (input) {
|
|
2370
|
+
const service = yield* Service2;
|
|
2339
2371
|
return yield* service.listInboxMessages(input);
|
|
2340
2372
|
});
|
|
2341
|
-
var inspectExecution =
|
|
2342
|
-
const service = yield*
|
|
2373
|
+
var inspectExecution = Effect2.fn("Client.inspectExecution.call")(function* (executionId) {
|
|
2374
|
+
const service = yield* Service2;
|
|
2343
2375
|
return yield* service.inspectExecution(executionId);
|
|
2344
2376
|
});
|
|
2345
|
-
var send =
|
|
2346
|
-
const service = yield*
|
|
2377
|
+
var send = Effect2.fn("Client.send.call")(function* (input) {
|
|
2378
|
+
const service = yield* Service2;
|
|
2347
2379
|
return yield* service.send(input);
|
|
2348
2380
|
});
|
|
2349
|
-
var streamExecution = (input) => Stream.unwrap(
|
|
2350
|
-
var followExecution = (input) => Stream.unwrap(
|
|
2351
|
-
var streamSession = (input) => Stream.unwrap(
|
|
2352
|
-
var watchExecutions = (input) => Stream.unwrap(
|
|
2353
|
-
var getPresence =
|
|
2354
|
-
const service = yield*
|
|
2381
|
+
var streamExecution = (input) => Stream.unwrap(Service2.pipe(Effect2.map((service) => service.streamExecution(input))));
|
|
2382
|
+
var followExecution = (input) => Stream.unwrap(Service2.pipe(Effect2.map((service) => service.followExecution(input))));
|
|
2383
|
+
var streamSession = (input) => Stream.unwrap(Service2.pipe(Effect2.map((service) => service.streamSession(input))));
|
|
2384
|
+
var watchExecutions = (input) => Stream.unwrap(Service2.pipe(Effect2.map((service) => service.watchExecutions(input))));
|
|
2385
|
+
var getPresence = Effect2.fn("Client.getPresence.call")(function* (scope) {
|
|
2386
|
+
const service = yield* Service2;
|
|
2355
2387
|
return yield* service.getPresence(scope);
|
|
2356
2388
|
});
|
|
2357
|
-
var watchPresence = (scope) => Stream.unwrap(
|
|
2358
|
-
var wake =
|
|
2359
|
-
const service = yield*
|
|
2389
|
+
var watchPresence = (scope) => Stream.unwrap(Service2.pipe(Effect2.map((service) => service.watchPresence(scope))));
|
|
2390
|
+
var wake = Effect2.fn("Client.wake.call")(function* (input) {
|
|
2391
|
+
const service = yield* Service2;
|
|
2360
2392
|
return yield* service.wake(input);
|
|
2361
2393
|
});
|
|
2362
|
-
var listPendingApprovals =
|
|
2363
|
-
const service = yield*
|
|
2394
|
+
var listPendingApprovals = Effect2.fn("Client.listPendingApprovals.call")(function* (input) {
|
|
2395
|
+
const service = yield* Service2;
|
|
2364
2396
|
return yield* service.listPendingApprovals(input);
|
|
2365
2397
|
});
|
|
2366
|
-
var resolveToolApproval =
|
|
2367
|
-
const service = yield*
|
|
2398
|
+
var resolveToolApproval = Effect2.fn("Client.resolveToolApproval.call")(function* (input) {
|
|
2399
|
+
const service = yield* Service2;
|
|
2368
2400
|
return yield* service.resolveToolApproval(input);
|
|
2369
2401
|
});
|
|
2370
|
-
var resolvePermission =
|
|
2371
|
-
const service = yield*
|
|
2402
|
+
var resolvePermission = Effect2.fn("Client.resolvePermission.call")(function* (input) {
|
|
2403
|
+
const service = yield* Service2;
|
|
2372
2404
|
return yield* service.resolvePermission(input);
|
|
2373
2405
|
});
|
|
2374
|
-
var listPendingToolCalls =
|
|
2375
|
-
const service = yield*
|
|
2406
|
+
var listPendingToolCalls = Effect2.fn("Client.listPendingToolCalls.call")(function* (input) {
|
|
2407
|
+
const service = yield* Service2;
|
|
2376
2408
|
return yield* service.listPendingToolCalls(input);
|
|
2377
2409
|
});
|
|
2378
|
-
var fulfillToolCall =
|
|
2379
|
-
const service = yield*
|
|
2410
|
+
var fulfillToolCall = Effect2.fn("Client.fulfillToolCall.call")(function* (input) {
|
|
2411
|
+
const service = yield* Service2;
|
|
2380
2412
|
return yield* service.fulfillToolCall(input);
|
|
2381
2413
|
});
|
|
2382
|
-
var claimToolWork =
|
|
2383
|
-
const service = yield*
|
|
2414
|
+
var claimToolWork = Effect2.fn("Client.claimToolWork.call")(function* (input) {
|
|
2415
|
+
const service = yield* Service2;
|
|
2384
2416
|
return yield* service.claimToolWork(input);
|
|
2385
2417
|
});
|
|
2386
|
-
var completeToolWork =
|
|
2387
|
-
const service = yield*
|
|
2418
|
+
var completeToolWork = Effect2.fn("Client.completeToolWork.call")(function* (input) {
|
|
2419
|
+
const service = yield* Service2;
|
|
2388
2420
|
return yield* service.completeToolWork(input);
|
|
2389
2421
|
});
|
|
2390
|
-
var releaseToolWork =
|
|
2391
|
-
const service = yield*
|
|
2422
|
+
var releaseToolWork = Effect2.fn("Client.releaseToolWork.call")(function* (input) {
|
|
2423
|
+
const service = yield* Service2;
|
|
2392
2424
|
return yield* service.releaseToolWork(input);
|
|
2393
2425
|
});
|
|
2394
|
-
var listToolAttempts =
|
|
2395
|
-
const service = yield*
|
|
2426
|
+
var listToolAttempts = Effect2.fn("Client.listToolAttempts.call")(function* (input) {
|
|
2427
|
+
const service = yield* Service2;
|
|
2396
2428
|
return yield* service.listToolAttempts(input);
|
|
2397
2429
|
});
|
|
2398
|
-
var submitInboundEnvelope =
|
|
2399
|
-
const service = yield*
|
|
2430
|
+
var submitInboundEnvelope = Effect2.fn("Client.submitInboundEnvelope.call")(function* (input) {
|
|
2431
|
+
const service = yield* Service2;
|
|
2400
2432
|
return yield* service.submitInboundEnvelope(input);
|
|
2401
2433
|
});
|
|
2402
|
-
var spawnChildRun =
|
|
2403
|
-
const service = yield*
|
|
2434
|
+
var spawnChildRun = Effect2.fn("Client.spawnChildRun.call")(function* (input) {
|
|
2435
|
+
const service = yield* Service2;
|
|
2404
2436
|
return yield* service.spawnChildRun(input);
|
|
2405
2437
|
});
|
|
2406
|
-
var createChildFanOut =
|
|
2407
|
-
const service = yield*
|
|
2438
|
+
var createChildFanOut = Effect2.fn("Client.createChildFanOut.call")(function* (input) {
|
|
2439
|
+
const service = yield* Service2;
|
|
2408
2440
|
return yield* service.createChildFanOut(input);
|
|
2409
2441
|
});
|
|
2410
|
-
var cancelChildFanOut =
|
|
2411
|
-
const service = yield*
|
|
2442
|
+
var cancelChildFanOut = Effect2.fn("Client.cancelChildFanOut.call")(function* (input) {
|
|
2443
|
+
const service = yield* Service2;
|
|
2412
2444
|
return yield* service.cancelChildFanOut(input);
|
|
2413
2445
|
});
|
|
2414
|
-
var inspectChildFanOut =
|
|
2415
|
-
const service = yield*
|
|
2446
|
+
var inspectChildFanOut = Effect2.fn("Client.inspectChildFanOut.call")(function* (input) {
|
|
2447
|
+
const service = yield* Service2;
|
|
2416
2448
|
return yield* service.inspectChildFanOut(input);
|
|
2417
2449
|
});
|
|
2418
|
-
var claimEnvelopeReady =
|
|
2419
|
-
const service = yield*
|
|
2450
|
+
var claimEnvelopeReady = Effect2.fn("Client.claimEnvelopeReady.call")(function* (input) {
|
|
2451
|
+
const service = yield* Service2;
|
|
2420
2452
|
return yield* service.claimEnvelopeReady(input);
|
|
2421
2453
|
});
|
|
2422
|
-
var ackEnvelopeReady =
|
|
2423
|
-
const service = yield*
|
|
2454
|
+
var ackEnvelopeReady = Effect2.fn("Client.ackEnvelopeReady.call")(function* (input) {
|
|
2455
|
+
const service = yield* Service2;
|
|
2424
2456
|
return yield* service.ackEnvelopeReady(input);
|
|
2425
2457
|
});
|
|
2426
|
-
var releaseEnvelopeReady =
|
|
2427
|
-
const service = yield*
|
|
2458
|
+
var releaseEnvelopeReady = Effect2.fn("Client.releaseEnvelopeReady.call")(function* (input) {
|
|
2459
|
+
const service = yield* Service2;
|
|
2428
2460
|
return yield* service.releaseEnvelopeReady(input);
|
|
2429
2461
|
});
|
|
2430
|
-
var createSchedule =
|
|
2431
|
-
const service = yield*
|
|
2462
|
+
var createSchedule = Effect2.fn("Client.createSchedule.call")(function* (input) {
|
|
2463
|
+
const service = yield* Service2;
|
|
2432
2464
|
return yield* service.createSchedule(input);
|
|
2433
2465
|
});
|
|
2434
|
-
var cancelSchedule =
|
|
2435
|
-
const service = yield*
|
|
2466
|
+
var cancelSchedule = Effect2.fn("Client.cancelSchedule.call")(function* (input) {
|
|
2467
|
+
const service = yield* Service2;
|
|
2436
2468
|
return yield* service.cancelSchedule(input);
|
|
2437
2469
|
});
|
|
2438
|
-
var listSchedules =
|
|
2439
|
-
const service = yield*
|
|
2470
|
+
var listSchedules = Effect2.fn("Client.listSchedules.call")(function* (input) {
|
|
2471
|
+
const service = yield* Service2;
|
|
2440
2472
|
return yield* service.listSchedules(input);
|
|
2441
2473
|
});
|
|
2442
|
-
var askEntity =
|
|
2443
|
-
const service = yield*
|
|
2474
|
+
var askEntity = Effect2.fn("Client.askEntity.call")(function* (input) {
|
|
2475
|
+
const service = yield* Service2;
|
|
2444
2476
|
return yield* service.askEntity(input);
|
|
2445
2477
|
});
|
|
2446
|
-
var awaitWait =
|
|
2447
|
-
const service = yield*
|
|
2478
|
+
var awaitWait = Effect2.fn("Client.awaitWait.call")(function* (input) {
|
|
2479
|
+
const service = yield* Service2;
|
|
2448
2480
|
return yield* service.awaitWait(input);
|
|
2449
2481
|
});
|
|
2450
2482
|
|
|
2451
|
-
|
|
2483
|
+
// src/runtime.ts
|
|
2484
|
+
var exports_runtime = {};
|
|
2485
|
+
__export(exports_runtime, {
|
|
2486
|
+
makeDatabaseIdentity: () => makeDatabaseIdentity,
|
|
2487
|
+
layerRunner: () => layerRunner,
|
|
2488
|
+
layerEmbedded: () => layerEmbedded,
|
|
2489
|
+
layerClient: () => layerClient,
|
|
2490
|
+
UnsupportedTopology: () => UnsupportedTopology,
|
|
2491
|
+
SqlFailure: () => SqlFailure,
|
|
2492
|
+
SqlDialect: () => SqlDialect,
|
|
2493
|
+
Service: () => Service4,
|
|
2494
|
+
SchemaHeadMismatch: () => SchemaHeadMismatch,
|
|
2495
|
+
RuntimeTopologyError: () => RuntimeTopologyError,
|
|
2496
|
+
RuntimeTopologyCause: () => RuntimeTopologyCause,
|
|
2497
|
+
RuntimeReadinessError: () => RuntimeReadinessError,
|
|
2498
|
+
RuntimeReadinessCause: () => RuntimeReadinessCause,
|
|
2499
|
+
RuntimeMigrationError: () => RuntimeMigrationError,
|
|
2500
|
+
RuntimeMigrationCause: () => RuntimeMigrationCause,
|
|
2501
|
+
RuntimeDatabase: () => exports_runtime_database,
|
|
2502
|
+
RuntimeConfigurationError: () => RuntimeConfigurationError,
|
|
2503
|
+
RuntimeConfigurationCause: () => RuntimeConfigurationCause,
|
|
2504
|
+
RuntimeCapabilityUnavailable: () => RuntimeCapabilityUnavailable,
|
|
2505
|
+
NotificationFailure: () => NotificationFailure,
|
|
2506
|
+
MigratorError: () => MigratorError,
|
|
2507
|
+
HostUnavailable: () => HostUnavailable,
|
|
2508
|
+
HostLayerError: () => HostLayerError,
|
|
2509
|
+
Dialect: () => Dialect,
|
|
2510
|
+
DatabaseIdentity: () => DatabaseIdentity,
|
|
2511
|
+
DatabaseDialectMismatch: () => DatabaseDialectMismatch,
|
|
2512
|
+
DatabaseDialect: () => DatabaseDialect,
|
|
2513
|
+
DatabaseAlreadyOwned: () => DatabaseAlreadyOwned,
|
|
2514
|
+
ConfigFailure: () => ConfigFailure,
|
|
2515
|
+
ClusterFailure: () => ClusterFailure
|
|
2516
|
+
});
|
|
2517
|
+
import { Cause, Context as Context4, Effect as Effect3, Layer as Layer3, Schema as Schema5 } from "effect";
|
|
2518
|
+
import { SqlClient } from "effect/unstable/sql/SqlClient";
|
|
2519
|
+
|
|
2520
|
+
// src/runtime-database.ts
|
|
2521
|
+
var exports_runtime_database = {};
|
|
2522
|
+
__export(exports_runtime_database, {
|
|
2523
|
+
Service: () => Service3,
|
|
2524
|
+
Dialect: () => Dialect
|
|
2525
|
+
});
|
|
2526
|
+
import { Context as Context3 } from "effect";
|
|
2527
|
+
|
|
2528
|
+
class Service3 extends Context3.Service()("@relayfx/sdk/RuntimeDatabase") {
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
// src/runtime.ts
|
|
2532
|
+
var DatabaseIdentity = Schema5.NonEmptyString.pipe(Schema5.brand("@relayfx/sdk/DatabaseIdentity"));
|
|
2533
|
+
var makeDatabaseIdentity = Schema5.decodeUnknownSync(DatabaseIdentity);
|
|
2534
|
+
var Dialect = Schema5.Literals(["pg", "mysql", "sqlite"]);
|
|
2535
|
+
var DatabaseDialect = Symbol("@relayfx/sdk/DatabaseDialect");
|
|
2536
|
+
|
|
2537
|
+
class HostLayerError extends Schema5.TaggedErrorClass()("HostLayerError", {
|
|
2538
|
+
service: Schema5.String,
|
|
2539
|
+
reason: Schema5.String
|
|
2540
|
+
}) {
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
class ConfigFailure extends Schema5.TaggedErrorClass()("ConfigFailure", {
|
|
2544
|
+
reason: Schema5.String
|
|
2545
|
+
}) {
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
class NotificationFailure extends Schema5.TaggedErrorClass()("NotificationFailure", {
|
|
2549
|
+
reason: Schema5.String
|
|
2550
|
+
}) {
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
class ClusterFailure extends Schema5.TaggedErrorClass()("ClusterFailure", {
|
|
2554
|
+
reason: Schema5.String
|
|
2555
|
+
}) {
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
class SqlFailure extends Schema5.TaggedErrorClass()("SqlFailure", {
|
|
2559
|
+
category: Schema5.Literals(["connection", "statement", "unknown"]),
|
|
2560
|
+
operation: Schema5.Literals(["acquire", "migrate", "verify", "notify", "readiness"]),
|
|
2561
|
+
retryable: Schema5.Boolean
|
|
2562
|
+
}) {
|
|
2563
|
+
}
|
|
2564
|
+
var SqlDialect = Schema5.Literals(["sqlite", "pg", "mysql", "mssql", "clickhouse"]);
|
|
2565
|
+
|
|
2566
|
+
class DatabaseDialectMismatch extends Schema5.TaggedErrorClass()("DatabaseDialectMismatch", { expected: Dialect, actual: SqlDialect }) {
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
class DatabaseAlreadyOwned extends Schema5.TaggedErrorClass()("DatabaseAlreadyOwned", {
|
|
2570
|
+
databaseIdentity: DatabaseIdentity
|
|
2571
|
+
}) {
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
class UnsupportedTopology extends Schema5.TaggedErrorClass()("UnsupportedTopology", {
|
|
2575
|
+
reason: Schema5.String
|
|
2576
|
+
}) {
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
class MigratorError extends Schema5.TaggedErrorClass()("MigratorError", {
|
|
2580
|
+
reason: Schema5.String
|
|
2581
|
+
}) {
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
class SchemaHeadMismatch extends Schema5.TaggedErrorClass()("SchemaHeadMismatch", {
|
|
2585
|
+
expected: Schema5.String,
|
|
2586
|
+
actual: Schema5.String
|
|
2587
|
+
}) {
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
class HostUnavailable extends Schema5.TaggedErrorClass()("HostUnavailable", {
|
|
2591
|
+
host: Schema5.String,
|
|
2592
|
+
reason: Schema5.String
|
|
2593
|
+
}) {
|
|
2594
|
+
}
|
|
2595
|
+
var RuntimeConfigurationCause = Schema5.Union([
|
|
2596
|
+
ConfigFailure,
|
|
2597
|
+
HostLayerError
|
|
2598
|
+
]);
|
|
2599
|
+
var RuntimeTopologyCause = Schema5.Union([
|
|
2600
|
+
ClusterFailure,
|
|
2601
|
+
DatabaseDialectMismatch,
|
|
2602
|
+
DatabaseAlreadyOwned,
|
|
2603
|
+
UnsupportedTopology
|
|
2604
|
+
]);
|
|
2605
|
+
var RuntimeMigrationCause = Schema5.Union([
|
|
2606
|
+
SqlFailure,
|
|
2607
|
+
MigratorError,
|
|
2608
|
+
SchemaHeadMismatch
|
|
2609
|
+
]);
|
|
2610
|
+
var RuntimeReadinessCause = Schema5.Union([
|
|
2611
|
+
SqlFailure,
|
|
2612
|
+
NotificationFailure,
|
|
2613
|
+
ClusterFailure,
|
|
2614
|
+
HostUnavailable
|
|
2615
|
+
]);
|
|
2616
|
+
|
|
2617
|
+
class RuntimeConfigurationError extends Schema5.TaggedErrorClass()("RuntimeConfigurationError", {
|
|
2618
|
+
setting: Schema5.String,
|
|
2619
|
+
nextAction: Schema5.Literals(["provide-setting", "provide-host-layer"]),
|
|
2620
|
+
cause: RuntimeConfigurationCause
|
|
2621
|
+
}) {
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
class RuntimeTopologyError extends Schema5.TaggedErrorClass()("RuntimeTopologyError", {
|
|
2625
|
+
dialect: Dialect,
|
|
2626
|
+
role: Schema5.Literals(["embedded", "runner", "client"]),
|
|
2627
|
+
nextAction: Schema5.Literals([
|
|
2628
|
+
"use-embedded",
|
|
2629
|
+
"use-postgres-or-mysql",
|
|
2630
|
+
"use-client-constructor",
|
|
2631
|
+
"reuse-runtime",
|
|
2632
|
+
"use-different-database"
|
|
2633
|
+
]),
|
|
2634
|
+
cause: RuntimeTopologyCause
|
|
2635
|
+
}) {
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
class RuntimeMigrationError extends Schema5.TaggedErrorClass()("RuntimeMigrationError", {
|
|
2639
|
+
dialect: Dialect,
|
|
2640
|
+
phase: Schema5.Literals(["apply", "verify"]),
|
|
2641
|
+
nextAction: Schema5.Literals(["retry", "inspect-schema", "run-compatible-release"]),
|
|
2642
|
+
cause: RuntimeMigrationCause
|
|
2643
|
+
}) {
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
class RuntimeReadinessError extends Schema5.TaggedErrorClass()("RuntimeReadinessError", {
|
|
2647
|
+
phase: Schema5.Literals(["database", "notification", "cluster", "hosts"]),
|
|
2648
|
+
cause: RuntimeReadinessCause
|
|
2649
|
+
}) {
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
class Service4 extends Context4.Service()("@relayfx/sdk/Runtime") {
|
|
2653
|
+
}
|
|
2654
|
+
var isAcquisitionError = (error) => typeof error === "object" && error !== null && ("_tag" in error) && (error._tag === "RuntimeConfigurationError" || error._tag === "RuntimeTopologyError" || error._tag === "RuntimeMigrationError");
|
|
2655
|
+
var normalizeHost = (layer2, role, dialect) => {
|
|
2656
|
+
const normalize = (error) => {
|
|
2657
|
+
if (isAcquisitionError(error))
|
|
2658
|
+
return error;
|
|
2659
|
+
if (typeof error === "object" && error !== null && "_tag" in error && error._tag === "ClusterConfigMismatch") {
|
|
2660
|
+
const clusterFailure = new ClusterFailure({ reason: "cluster configuration is incompatible" });
|
|
2661
|
+
Object.defineProperty(clusterFailure, "originalCause", { value: error, enumerable: false });
|
|
2662
|
+
return new RuntimeTopologyError({
|
|
2663
|
+
dialect,
|
|
2664
|
+
role,
|
|
2665
|
+
nextAction: role === "embedded" ? "use-embedded" : "use-different-database",
|
|
2666
|
+
cause: clusterFailure
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
const hostFailure = new HostLayerError({
|
|
2670
|
+
service: "Runtime host graph",
|
|
2671
|
+
reason: "host layer acquisition failed"
|
|
2672
|
+
});
|
|
2673
|
+
Object.defineProperty(hostFailure, "originalCause", { value: error, enumerable: false });
|
|
2674
|
+
return new RuntimeConfigurationError({
|
|
2675
|
+
setting: "host layers",
|
|
2676
|
+
nextAction: "provide-host-layer",
|
|
2677
|
+
cause: hostFailure
|
|
2678
|
+
});
|
|
2679
|
+
};
|
|
2680
|
+
return layer2.pipe(Layer3.catchCause((cause) => {
|
|
2681
|
+
if (Cause.hasInterrupts(cause))
|
|
2682
|
+
return Layer3.unwrap(Effect3.failCause(Cause.map(cause, normalize)));
|
|
2683
|
+
return Layer3.unwrap(Effect3.fail(normalize(Cause.squash(cause))));
|
|
2684
|
+
}));
|
|
2685
|
+
};
|
|
2686
|
+
var actualDialect = (sql) => sql.onDialectOrElse({
|
|
2687
|
+
sqlite: () => "sqlite",
|
|
2688
|
+
pg: () => "pg",
|
|
2689
|
+
mysql: () => "mysql",
|
|
2690
|
+
mssql: () => "mssql",
|
|
2691
|
+
clickhouse: () => "clickhouse",
|
|
2692
|
+
orElse: () => "clickhouse"
|
|
2693
|
+
});
|
|
2694
|
+
var ambientDatabaseLayer = Layer3.effect(SqlClient, SqlClient);
|
|
2695
|
+
var validatedDatabase = (databaseLayer, role) => {
|
|
2696
|
+
const validatedService = Layer3.effect(Service3, Effect3.gen(function* () {
|
|
2697
|
+
const database = yield* Service3;
|
|
2698
|
+
const sql = yield* SqlClient;
|
|
2699
|
+
const actual = actualDialect(sql);
|
|
2700
|
+
if (actual !== database.dialect) {
|
|
2701
|
+
return yield* new RuntimeTopologyError({
|
|
2702
|
+
dialect: database.dialect,
|
|
2703
|
+
role,
|
|
2704
|
+
nextAction: role === "embedded" ? "use-different-database" : "use-postgres-or-mysql",
|
|
2705
|
+
cause: new DatabaseDialectMismatch({ expected: database.dialect, actual })
|
|
2706
|
+
});
|
|
2707
|
+
}
|
|
2708
|
+
if (database.dialect === "sqlite") {
|
|
2709
|
+
yield* database.acquireSchema;
|
|
2710
|
+
} else {
|
|
2711
|
+
yield* database.verifySchema;
|
|
2712
|
+
}
|
|
2713
|
+
return database;
|
|
2714
|
+
}));
|
|
2715
|
+
const sqlLayer = Layer3.effect(SqlClient, SqlClient);
|
|
2716
|
+
return Layer3.merge(sqlLayer, validatedService).pipe(Layer3.provide(databaseLayer));
|
|
2717
|
+
};
|
|
2718
|
+
var runtimeServiceLayer = (role, capabilities) => Layer3.effect(Service4, Effect3.gen(function* () {
|
|
2719
|
+
const database = yield* Service3;
|
|
2720
|
+
const runner = yield* exports_runner_runtime_service.Service;
|
|
2721
|
+
return Service4.of({
|
|
2722
|
+
readiness: runner.check().pipe(Effect3.mapError((error) => {
|
|
2723
|
+
const cause = new SqlFailure({ category: "unknown", operation: "readiness", retryable: false });
|
|
2724
|
+
Object.defineProperty(cause, "originalCause", { value: error, enumerable: false });
|
|
2725
|
+
return new RuntimeReadinessError({ phase: "database", cause });
|
|
2726
|
+
}), Effect3.as({
|
|
2727
|
+
ready: true,
|
|
2728
|
+
role,
|
|
2729
|
+
dialect: database.dialect,
|
|
2730
|
+
databaseIdentity: database.databaseIdentity,
|
|
2731
|
+
schemaHead: database.schemaHead,
|
|
2732
|
+
notification: database.notification,
|
|
2733
|
+
capabilities: {
|
|
2734
|
+
fanOut: capabilities.fanOut ? { enabled: true, source: "local-host", health: "healthy" } : {
|
|
2735
|
+
enabled: false,
|
|
2736
|
+
source: role === "embedded" ? "local-host" : "role-unavailable",
|
|
2737
|
+
health: "not-applicable"
|
|
2738
|
+
},
|
|
2739
|
+
workflowDefinition: capabilities.workflowDefinition ? { enabled: true, source: "local-host", health: "healthy" } : {
|
|
2740
|
+
enabled: false,
|
|
2741
|
+
source: role === "embedded" ? "local-host" : "role-unavailable",
|
|
2742
|
+
health: "not-applicable"
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
}))
|
|
2746
|
+
});
|
|
2747
|
+
}));
|
|
2748
|
+
var publicGraph = (runner, databaseLayer, role, capabilities = { fanOut: false, workflowDefinition: false }) => {
|
|
2749
|
+
const database = validatedDatabase(databaseLayer, role);
|
|
2750
|
+
const graph = runner.pipe(Layer3.provideMerge(database));
|
|
2751
|
+
const policy = layer(role, capabilities);
|
|
2752
|
+
return Layer3.merge(Layer3.fresh(layerFromRuntime).pipe(Layer3.provideMerge(policy)), runtimeServiceLayer(role, capabilities)).pipe(Layer3.provide(graph));
|
|
2753
|
+
};
|
|
2754
|
+
var withHosts = (runner, options) => {
|
|
2755
|
+
const childHost = options.childFanOutHandlersLayer === undefined ? Layer3.empty : exports_child_fan_out_runtime.layerFromRuntime.pipe(Layer3.provide(options.childFanOutHandlersLayer), Layer3.provide(exports_child_fan_out_transition_service.layer), Layer3.provide(runner));
|
|
2756
|
+
const workflowHost = options.workflowDefinitionHandlersLayer === undefined ? Layer3.empty : exports_definition_runtime.layerFromRuntime.pipe(Layer3.provide(options.workflowDefinitionHandlersLayer), Layer3.provideMerge(childHost), Layer3.provide(runner));
|
|
2757
|
+
return Layer3.mergeAll(runner, childHost, workflowHost);
|
|
2758
|
+
};
|
|
2759
|
+
var layerEmbedded = (options) => {
|
|
2760
|
+
const runner = exports_runner_runtime_service.layerWithServices({
|
|
2761
|
+
databaseLayer: ambientDatabaseLayer,
|
|
2762
|
+
languageModelLayer: options.languageModelLayer,
|
|
2763
|
+
toolRuntimeLayer: options.toolRuntimeLayer,
|
|
2764
|
+
embeddingModelLayer: options.embeddingModelLayer,
|
|
2765
|
+
blobStoreLayer: options.blobStoreLayer,
|
|
2766
|
+
artifactStoreLayer: options.artifactStoreLayer,
|
|
2767
|
+
promptAssemblerLayer: options.promptAssemblerLayer,
|
|
2768
|
+
schemaRegistryLayer: options.schemaRegistryLayer
|
|
2769
|
+
});
|
|
2770
|
+
return normalizeHost(publicGraph(withHosts(runner, options), options.databaseLayer, "embedded", {
|
|
2771
|
+
fanOut: options.childFanOutHandlersLayer !== undefined,
|
|
2772
|
+
workflowDefinition: options.workflowDefinitionHandlersLayer !== undefined
|
|
2773
|
+
}), "embedded", options.databaseLayer[DatabaseDialect]);
|
|
2774
|
+
};
|
|
2775
|
+
var layerRunner = (options) => {
|
|
2776
|
+
const runner = exports_runner_runtime_service.layerWithServicesMultiNode({
|
|
2777
|
+
databaseLayer: ambientDatabaseLayer,
|
|
2778
|
+
languageModelLayer: options.languageModelLayer,
|
|
2779
|
+
toolRuntimeLayer: options.toolRuntimeLayer,
|
|
2780
|
+
embeddingModelLayer: options.embeddingModelLayer,
|
|
2781
|
+
blobStoreLayer: options.blobStoreLayer,
|
|
2782
|
+
artifactStoreLayer: options.artifactStoreLayer,
|
|
2783
|
+
promptAssemblerLayer: options.promptAssemblerLayer,
|
|
2784
|
+
schemaRegistryLayer: options.schemaRegistryLayer,
|
|
2785
|
+
cluster: options.cluster
|
|
2786
|
+
});
|
|
2787
|
+
return normalizeHost(publicGraph(runner, options.databaseLayer, "runner"), "runner", options.databaseLayer[DatabaseDialect]);
|
|
2788
|
+
};
|
|
2789
|
+
var layerClient = (options) => {
|
|
2790
|
+
const runner = exports_runner_runtime_service.layerWithServicesMultiNodeClientOnly({
|
|
2791
|
+
databaseLayer: ambientDatabaseLayer,
|
|
2792
|
+
languageModelLayer: exports_language_model_service.layer(),
|
|
2793
|
+
toolRuntimeLayer: exports_tool_runtime_service.layer(),
|
|
2794
|
+
cluster: options.cluster
|
|
2795
|
+
});
|
|
2796
|
+
return normalizeHost(publicGraph(runner, options.databaseLayer, "client"), "client", options.databaseLayer[DatabaseDialect]);
|
|
2797
|
+
};
|
|
2798
|
+
|
|
2799
|
+
export { exports_operation, exports_command, Service2 as Service, exports_client, exports_runtime_database, makeDatabaseIdentity, DatabaseDialect, ConfigFailure, SqlFailure, DatabaseAlreadyOwned, MigratorError, SchemaHeadMismatch, RuntimeConfigurationError, RuntimeTopologyError, RuntimeMigrationError, exports_runtime };
|