@relayfx/sdk 0.2.13 → 0.2.15
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-kghdnamr.js → index-d8q4kfjy.js} +1 -1
- package/dist/index-gxskhyra.js +69 -0
- package/dist/{index-rmaq3qc8.js → index-xbbfagnb.js} +744 -395
- package/dist/{index-3e4cs8s6.js → index-z9xk02sv.js} +650 -531
- 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/operation.d.ts +60 -10
- 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/address/address-resolution-service.d.ts +32 -10
- package/dist/types/runtime/agent/relay-compaction.d.ts +3 -2
- package/dist/types/runtime/child/child-fan-out-runtime.d.ts +2 -0
- package/dist/types/runtime/child/spawn-child-run-tool.d.ts +7 -0
- package/dist/types/runtime/model/language-model-service.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/runtime/workflow/execution-workflow.d.ts +64 -20
- package/dist/types/schema/agent-schema.d.ts +220 -60
- package/dist/types/schema/child-orchestration-schema.d.ts +21 -0
- package/dist/types/schema/execution-schema.d.ts +74 -10
- 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-z9xk02sv.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,
|
|
@@ -1369,7 +1397,7 @@ var childSpawnFingerprint = (record) => {
|
|
|
1369
1397
|
const fingerprint = parentMetadata[childSpawnFingerprintKey];
|
|
1370
1398
|
return typeof fingerprint === "string" ? fingerprint : undefined;
|
|
1371
1399
|
};
|
|
1372
|
-
var createChildJoinWait =
|
|
1400
|
+
var createChildJoinWait = Effect2.fn("Client.createChildJoinWait")(function* (waits, eventLog, input, accepted, createdAt) {
|
|
1373
1401
|
const waitId = childJoinWaitId(accepted.child_execution_id);
|
|
1374
1402
|
const eventSequence = yield* nextEventSequence(eventLog, input.execution_id);
|
|
1375
1403
|
yield* waits.createDetached({
|
|
@@ -1383,12 +1411,12 @@ var createChildJoinWait = Effect.fn("Client.createChildJoinWait")(function* (wai
|
|
|
1383
1411
|
},
|
|
1384
1412
|
eventSequence,
|
|
1385
1413
|
createdAt
|
|
1386
|
-
}).pipe(
|
|
1414
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1387
1415
|
return waitId;
|
|
1388
1416
|
});
|
|
1389
|
-
var reconcileExistingChildSpawn =
|
|
1417
|
+
var reconcileExistingChildSpawn = Effect2.fn("Client.reconcileExistingChildSpawn")(function* (childExecutions, waits, eventLog, input) {
|
|
1390
1418
|
const childExecutionId = childExecutionIdForSpawn(input);
|
|
1391
|
-
const existing = yield* childExecutions.get(childExecutionId).pipe(
|
|
1419
|
+
const existing = yield* childExecutions.get(childExecutionId).pipe(Effect2.mapError(toClientError));
|
|
1392
1420
|
if (existing === undefined)
|
|
1393
1421
|
return;
|
|
1394
1422
|
if (existing.executionId !== input.execution_id || existing.addressId !== input.address_id || childSpawnFingerprint(existing) !== exports_shared_schema.canonicalString(input)) {
|
|
@@ -1397,13 +1425,13 @@ var reconcileExistingChildSpawn = Effect.fn("Client.reconcileExistingChildSpawn"
|
|
|
1397
1425
|
const spawned = yield* eventLog.findByCursor({
|
|
1398
1426
|
executionId: input.execution_id,
|
|
1399
1427
|
cursor: `${input.execution_id}:child:${childExecutionId}:spawned`
|
|
1400
|
-
}).pipe(
|
|
1428
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1401
1429
|
if (Option.isNone(spawned)) {
|
|
1402
1430
|
return yield* new ClientError({ message: `Child spawn event missing: ${childExecutionId}` });
|
|
1403
1431
|
}
|
|
1404
1432
|
const parentWaitId = input.wait === true ? childJoinWaitId(childExecutionId) : undefined;
|
|
1405
1433
|
if (parentWaitId !== undefined) {
|
|
1406
|
-
const wait = yield* waits.get(parentWaitId).pipe(
|
|
1434
|
+
const wait = yield* waits.get(parentWaitId).pipe(Effect2.mapError(toClientError));
|
|
1407
1435
|
if (wait === undefined) {
|
|
1408
1436
|
return yield* new ClientError({ message: `Child join wait missing: ${childExecutionId}` });
|
|
1409
1437
|
}
|
|
@@ -1414,8 +1442,8 @@ var reconcileExistingChildSpawn = Effect.fn("Client.reconcileExistingChildSpawn"
|
|
|
1414
1442
|
parentWaitId
|
|
1415
1443
|
};
|
|
1416
1444
|
});
|
|
1417
|
-
var parentDefinitionPin =
|
|
1418
|
-
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));
|
|
1419
1447
|
if (record === undefined) {
|
|
1420
1448
|
return yield* new ClientError({ message: `Execution not found: ${executionId}` });
|
|
1421
1449
|
}
|
|
@@ -1447,7 +1475,7 @@ var childStartInput = (input, accepted, pin, definition, createdAt, parentWaitId
|
|
|
1447
1475
|
...parentWaitId === undefined ? {} : { parent_wait_id: parentWaitId }
|
|
1448
1476
|
}
|
|
1449
1477
|
});
|
|
1450
|
-
var layerFromRuntime =
|
|
1478
|
+
var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
|
|
1451
1479
|
const makeExecutionClient = yield* exports_execution_entity.client;
|
|
1452
1480
|
const executions = yield* exports_execution_service.Service;
|
|
1453
1481
|
const envelopes = yield* exports_envelope_service.Service;
|
|
@@ -1477,28 +1505,29 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1477
1505
|
const skillRegistry = yield* exports_skill_registry_service.Service;
|
|
1478
1506
|
const toolTransitions = yield* exports_tool_transition_coordinator.Service;
|
|
1479
1507
|
const workflows = yield* exports_workflow_definition_repository.Service;
|
|
1480
|
-
const workflowRuntime = yield*
|
|
1481
|
-
const childFanOutRuntime = yield*
|
|
1482
|
-
const
|
|
1483
|
-
const
|
|
1484
|
-
const
|
|
1485
|
-
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) {
|
|
1486
1515
|
if (Option.isSome(childFanOutRuntime)) {
|
|
1487
|
-
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));
|
|
1488
1517
|
if (fanOut === undefined)
|
|
1489
1518
|
return yield* new ClientError({ message: `Child fan-out not found: ${input.fan_out_id}` });
|
|
1490
1519
|
return { fan_out: fanOut };
|
|
1491
1520
|
}
|
|
1492
|
-
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));
|
|
1493
1522
|
if (result === undefined)
|
|
1494
1523
|
return yield* new ClientError({ message: `Child fan-out not found: ${input.fan_out_id}` });
|
|
1495
|
-
yield*
|
|
1524
|
+
yield* Effect2.forEach(result.activeChildExecutionIds, (childId) => makeExecutionClient(exports_ids_schema.ExecutionId.make(childId)).cancel({
|
|
1496
1525
|
execution_id: exports_ids_schema.ExecutionId.make(childId),
|
|
1497
1526
|
cancelled_at: input.cancelled_at,
|
|
1498
1527
|
reason: input.reason ?? "child fan-out cancelled"
|
|
1499
|
-
}).pipe(
|
|
1528
|
+
}).pipe(Effect2.mapError(toClientError)), { discard: true });
|
|
1500
1529
|
if (result.transitioned) {
|
|
1501
|
-
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));
|
|
1502
1531
|
yield* exports_event_log_service.appendIdempotentTo(eventLog, {
|
|
1503
1532
|
id: exports_ids_schema.EventId.make(`event:${result.fanOut.parent_execution_id}:fan-out:${input.fan_out_id}:terminal`),
|
|
1504
1533
|
execution_id: result.fanOut.parent_execution_id,
|
|
@@ -1507,26 +1536,26 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1507
1536
|
cursor: `${result.fanOut.parent_execution_id}:fan-out:${input.fan_out_id}:terminal`,
|
|
1508
1537
|
data: { fan_out_id: input.fan_out_id, state: "cancelled" },
|
|
1509
1538
|
created_at: input.cancelled_at
|
|
1510
|
-
}).pipe(
|
|
1539
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1511
1540
|
}
|
|
1512
1541
|
return { fan_out: result.fanOut };
|
|
1513
1542
|
});
|
|
1514
|
-
const sendEnvelope =
|
|
1543
|
+
const sendEnvelope = Effect2.fn("Client.runtime.send")(function* (input) {
|
|
1515
1544
|
const identity = input.idempotency_key ?? input.correlation_key ?? `${input.from}:${input.to}`;
|
|
1516
1545
|
const executionId = exports_ids_schema.ExecutionId.make(input.correlation_key ?? `execution:send:${identity}`);
|
|
1517
1546
|
const envelopeId = exports_ids_schema.EnvelopeId.make(`${executionId}:envelope:${identity}`);
|
|
1518
1547
|
const createdAt = yield* Clock.currentTimeMillis;
|
|
1519
|
-
const maxSequence = yield* eventLog.maxSequence(executionId).pipe(
|
|
1548
|
+
const maxSequence = yield* eventLog.maxSequence(executionId).pipe(Effect2.mapError(toClientError));
|
|
1520
1549
|
return yield* envelopes.send({
|
|
1521
1550
|
envelopeId,
|
|
1522
1551
|
executionId,
|
|
1523
1552
|
input,
|
|
1524
1553
|
eventSequence: maxSequence === undefined ? 0 : maxSequence + 1,
|
|
1525
1554
|
createdAt
|
|
1526
|
-
}).pipe(
|
|
1555
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1527
1556
|
});
|
|
1528
|
-
const waitOutcomeFrom =
|
|
1529
|
-
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;
|
|
1530
1559
|
return {
|
|
1531
1560
|
wait_id: wait.id,
|
|
1532
1561
|
state: wait.state,
|
|
@@ -1534,22 +1563,22 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1534
1563
|
...Object.keys(wait.metadata).length === 0 ? {} : { metadata: wait.metadata }
|
|
1535
1564
|
};
|
|
1536
1565
|
});
|
|
1537
|
-
const awaitWaitOperation =
|
|
1538
|
-
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));
|
|
1539
1568
|
if (current === undefined) {
|
|
1540
1569
|
return yield* new ClientError({ message: `wait ${input.wait_id} not found` });
|
|
1541
1570
|
}
|
|
1542
1571
|
if (current.state !== "open")
|
|
1543
1572
|
return yield* waitOutcomeFrom(current);
|
|
1544
|
-
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,
|
|
1545
|
-
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));
|
|
1546
1575
|
if (terminal === undefined || terminal.state === "open") {
|
|
1547
1576
|
return yield* new ClientError({ message: `wait ${input.wait_id} did not reach a terminal state` });
|
|
1548
1577
|
}
|
|
1549
1578
|
return yield* waitOutcomeFrom(terminal);
|
|
1550
1579
|
});
|
|
1551
|
-
const getExecutionOperation =
|
|
1552
|
-
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));
|
|
1553
1582
|
return record === undefined ? undefined : toExecutionView(record);
|
|
1554
1583
|
});
|
|
1555
1584
|
const streamExecutionOperation = (input) => executions.stream({
|
|
@@ -1557,16 +1586,16 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1557
1586
|
...input.after_cursor === undefined ? {} : { afterCursor: input.after_cursor },
|
|
1558
1587
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1559
1588
|
}).pipe(Stream.mapError(toStreamError));
|
|
1560
|
-
const inspectExecutionOperation =
|
|
1561
|
-
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));
|
|
1562
1591
|
if (execution === undefined)
|
|
1563
1592
|
return yield* new ExecutionNotFound({ execution_id: executionId });
|
|
1564
|
-
const openWaits = yield* envelopeReady.listAllWaits({ executionId, state: "open" }).pipe(
|
|
1565
|
-
const calls = yield* toolCalls.listCalls(executionId).pipe(
|
|
1566
|
-
const pendingChunks = yield*
|
|
1567
|
-
const children = yield* childExecutions.listByExecution(executionId).pipe(
|
|
1568
|
-
const maxSequence = yield* eventLog.maxSequence(executionId).pipe(
|
|
1569
|
-
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));
|
|
1570
1599
|
return {
|
|
1571
1600
|
execution_id: execution.id,
|
|
1572
1601
|
status: execution.status,
|
|
@@ -1576,108 +1605,110 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1576
1605
|
...lastEvent === undefined ? {} : { last_event_cursor: lastEvent.cursor }
|
|
1577
1606
|
};
|
|
1578
1607
|
});
|
|
1579
|
-
return
|
|
1580
|
-
registerEntityKind: (input) => entityRegistry.registerKind(input).pipe(
|
|
1608
|
+
return Service2.of({
|
|
1609
|
+
registerEntityKind: (input) => entityRegistry.registerKind(input).pipe(Effect2.mapError(toClientError)),
|
|
1581
1610
|
getOrCreateEntity: (input) => entities.getOrCreate({
|
|
1582
1611
|
kind: input.kind,
|
|
1583
1612
|
key: input.key,
|
|
1584
1613
|
createdAt: input.created_at,
|
|
1585
1614
|
...input.input === undefined ? {} : { input: input.input },
|
|
1586
1615
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
1587
|
-
}).pipe(
|
|
1588
|
-
getEntity: (input) => entities.get(input).pipe(
|
|
1616
|
+
}).pipe(Effect2.mapError(toClientError)),
|
|
1617
|
+
getEntity: (input) => entities.get(input).pipe(Effect2.mapError(toClientError)),
|
|
1589
1618
|
destroyEntity: (input) => entities.destroy({
|
|
1590
1619
|
kind: input.kind,
|
|
1591
1620
|
key: input.key,
|
|
1592
1621
|
destroyedAt: input.destroyed_at,
|
|
1593
1622
|
...input.reason === undefined ? {} : { reason: input.reason }
|
|
1594
|
-
}).pipe(
|
|
1623
|
+
}).pipe(Effect2.mapError(toClientError)),
|
|
1595
1624
|
listEntities: (input) => entities.list({
|
|
1596
1625
|
...input.kind === undefined ? {} : { kind: input.kind },
|
|
1597
1626
|
...input.after_kind === undefined ? {} : { afterKind: input.after_kind },
|
|
1598
1627
|
...input.after_key === undefined ? {} : { afterKey: input.after_key },
|
|
1599
1628
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1600
|
-
}).pipe(
|
|
1601
|
-
registerWorkflowDefinition:
|
|
1602
|
-
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)) };
|
|
1603
1632
|
}),
|
|
1604
|
-
getWorkflowDefinitionRevision:
|
|
1605
|
-
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));
|
|
1606
1635
|
}),
|
|
1607
|
-
listWorkflowDefinitionRevisions:
|
|
1608
|
-
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)) };
|
|
1609
1638
|
}),
|
|
1610
|
-
startWorkflowRun:
|
|
1639
|
+
startWorkflowRun: Effect2.fn("Client.runtime.startWorkflowRun")(function* (input) {
|
|
1640
|
+
if (Option.isSome(runtimeCapabilityPolicy))
|
|
1641
|
+
yield* runtimeCapabilityPolicy.value.admit("workflow-definition");
|
|
1611
1642
|
return yield* Option.match(workflowRuntime, {
|
|
1612
1643
|
onNone: () => workflows.start(input),
|
|
1613
1644
|
onSome: (runtime) => runtime.start(input)
|
|
1614
|
-
}).pipe(
|
|
1645
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1615
1646
|
}),
|
|
1616
|
-
inspectWorkflowRun:
|
|
1647
|
+
inspectWorkflowRun: Effect2.fn("Client.runtime.inspectWorkflowRun")(function* (id) {
|
|
1617
1648
|
return yield* Option.match(workflowRuntime, {
|
|
1618
1649
|
onNone: () => workflows.inspect(id),
|
|
1619
1650
|
onSome: (runtime) => runtime.inspect(id)
|
|
1620
|
-
}).pipe(
|
|
1651
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1621
1652
|
}),
|
|
1622
|
-
replayWorkflowRun:
|
|
1653
|
+
replayWorkflowRun: Effect2.fn("Client.runtime.replayWorkflowRun")(function* (id) {
|
|
1623
1654
|
return yield* Option.match(workflowRuntime, {
|
|
1624
1655
|
onNone: () => workflows.listLifecycle(id),
|
|
1625
1656
|
onSome: (runtime) => runtime.replay(id)
|
|
1626
|
-
}).pipe(
|
|
1657
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1627
1658
|
}),
|
|
1628
|
-
cancelWorkflowRun:
|
|
1659
|
+
cancelWorkflowRun: Effect2.fn("Client.runtime.cancelWorkflowRun")(function* (id) {
|
|
1629
1660
|
return yield* Option.match(workflowRuntime, {
|
|
1630
|
-
onNone: () => workflows.cancel(id),
|
|
1661
|
+
onNone: () => workflows.cancel(id).pipe(Effect2.map((result) => result.record)),
|
|
1631
1662
|
onSome: (runtime) => runtime.cancel(id)
|
|
1632
|
-
}).pipe(
|
|
1663
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1633
1664
|
}),
|
|
1634
|
-
registerAgent:
|
|
1665
|
+
registerAgent: Effect2.fn("Client.runtime.registerAgent")(function* (input) {
|
|
1635
1666
|
const payload = yield* registerAgentPayload(input);
|
|
1636
|
-
const registered = yield* agentRegistry.register(payload).pipe(
|
|
1667
|
+
const registered = yield* agentRegistry.register(payload).pipe(Effect2.mapError(toClientError));
|
|
1637
1668
|
if (input.address !== undefined) {
|
|
1638
|
-
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));
|
|
1639
1670
|
}
|
|
1640
1671
|
return registered;
|
|
1641
1672
|
}),
|
|
1642
|
-
registerAgentDefinition:
|
|
1643
|
-
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));
|
|
1644
1675
|
}),
|
|
1645
|
-
getAgentDefinition:
|
|
1646
|
-
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));
|
|
1647
1678
|
}),
|
|
1648
|
-
listAgentDefinitions:
|
|
1649
|
-
return yield* agentRegistry.list().pipe(
|
|
1679
|
+
listAgentDefinitions: Effect2.fn("Client.runtime.listAgentDefinitions")(function* () {
|
|
1680
|
+
return yield* agentRegistry.list().pipe(Effect2.mapError(toClientError));
|
|
1650
1681
|
}),
|
|
1651
|
-
listAgentDefinitionRevisions:
|
|
1652
|
-
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));
|
|
1653
1684
|
}),
|
|
1654
|
-
getSkillDefinition:
|
|
1655
|
-
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));
|
|
1656
1687
|
}),
|
|
1657
|
-
listSkillDefinitions:
|
|
1658
|
-
return yield* skillRegistry.list().pipe(
|
|
1688
|
+
listSkillDefinitions: Effect2.fn("Client.runtime.listSkillDefinitions")(function* () {
|
|
1689
|
+
return yield* skillRegistry.list().pipe(Effect2.mapError(toClientError));
|
|
1659
1690
|
}),
|
|
1660
|
-
listSkillDefinitionRevisions:
|
|
1661
|
-
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));
|
|
1662
1693
|
}),
|
|
1663
|
-
registerAddressBookRoute:
|
|
1694
|
+
registerAddressBookRoute: Effect2.fn("Client.runtime.registerAddressBookRoute")(function* (input) {
|
|
1664
1695
|
yield* rejectReserved(input.address_id, "address:entity:");
|
|
1665
|
-
return yield* addressBook.register(input.address_id, input.route).pipe(
|
|
1696
|
+
return yield* addressBook.register(input.address_id, input.route).pipe(Effect2.mapError(toClientError));
|
|
1666
1697
|
}),
|
|
1667
|
-
getAddressBookRoute:
|
|
1668
|
-
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));
|
|
1669
1700
|
}),
|
|
1670
|
-
listAddressBookRoutes:
|
|
1671
|
-
return yield* addressBook.list().pipe(
|
|
1701
|
+
listAddressBookRoutes: Effect2.fn("Client.runtime.listAddressBookRoutes")(function* () {
|
|
1702
|
+
return yield* addressBook.list().pipe(Effect2.mapError(toClientError));
|
|
1672
1703
|
}),
|
|
1673
|
-
startExecution:
|
|
1704
|
+
startExecution: Effect2.fn("Client.runtime.startExecution")(function* (input) {
|
|
1674
1705
|
yield* rejectReserved(input.execution_id, "execution:entity:");
|
|
1675
1706
|
if (input.session_id !== undefined)
|
|
1676
1707
|
yield* rejectReserved(input.session_id, "session:entity:");
|
|
1677
1708
|
const client = makeExecutionClient(input.execution_id);
|
|
1678
|
-
return yield* client.start(input).pipe(
|
|
1709
|
+
return yield* client.start(input).pipe(Effect2.mapError(toClientError));
|
|
1679
1710
|
}),
|
|
1680
|
-
startExecutionByAddress:
|
|
1711
|
+
startExecutionByAddress: Effect2.fn("Client.runtime.startExecutionByAddress")(function* (input) {
|
|
1681
1712
|
yield* rejectReserved(input.idempotency_key, "entity:");
|
|
1682
1713
|
if (input.execution_id !== undefined)
|
|
1683
1714
|
yield* rejectReserved(input.execution_id, "execution:entity:");
|
|
@@ -1685,25 +1716,25 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1685
1716
|
yield* rejectReserved(input.session_id, "session:entity:");
|
|
1686
1717
|
const payload = startExecutionByAddressPayload(input);
|
|
1687
1718
|
const client = makeExecutionClient(payload.execution_id);
|
|
1688
|
-
return yield* client.start(payload).pipe(
|
|
1719
|
+
return yield* client.start(payload).pipe(Effect2.mapError(toClientError));
|
|
1689
1720
|
}),
|
|
1690
|
-
startExecutionByAgentDefinition:
|
|
1721
|
+
startExecutionByAgentDefinition: Effect2.fn("Client.runtime.startExecutionByAgentDefinition")(function* (input) {
|
|
1691
1722
|
yield* rejectReserved(input.idempotency_key, "entity:");
|
|
1692
1723
|
if (input.execution_id !== undefined)
|
|
1693
1724
|
yield* rejectReserved(input.execution_id, "execution:entity:");
|
|
1694
1725
|
if (input.session_id !== undefined)
|
|
1695
1726
|
yield* rejectReserved(input.session_id, "session:entity:");
|
|
1696
|
-
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));
|
|
1697
1728
|
if (definition === undefined) {
|
|
1698
|
-
return yield*
|
|
1729
|
+
return yield* Effect2.fail(new ClientError({ message: `Agent revision not found: ${input.agent_id}@${input.agent_revision}` }));
|
|
1699
1730
|
}
|
|
1700
1731
|
const payload = startExecutionByAgentDefinitionPayload(input, definition);
|
|
1701
1732
|
const client = makeExecutionClient(payload.execution_id);
|
|
1702
|
-
return yield* client.start(payload).pipe(
|
|
1733
|
+
return yield* client.start(payload).pipe(Effect2.mapError(toClientError));
|
|
1703
1734
|
}),
|
|
1704
|
-
cancelExecution:
|
|
1705
|
-
const fanOuts = yield* childFanOuts.listNonTerminal(input.execution_id).pipe(
|
|
1706
|
-
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({
|
|
1707
1738
|
fan_out_id: fanOut.fan_out_id,
|
|
1708
1739
|
cancelled_at: input.cancelled_at,
|
|
1709
1740
|
...input.reason === undefined ? {} : { reason: input.reason }
|
|
@@ -1713,10 +1744,10 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1713
1744
|
execution_id: input.execution_id,
|
|
1714
1745
|
cancelled_at: input.cancelled_at,
|
|
1715
1746
|
...input.reason === undefined ? {} : { reason: input.reason }
|
|
1716
|
-
}).pipe(
|
|
1747
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1717
1748
|
}),
|
|
1718
|
-
steer:
|
|
1719
|
-
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));
|
|
1720
1751
|
if (execution === undefined) {
|
|
1721
1752
|
return yield* new ClientError({ message: `Execution not found: ${input.execution_id}` });
|
|
1722
1753
|
}
|
|
@@ -1728,7 +1759,7 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1728
1759
|
kind: input.kind,
|
|
1729
1760
|
content: input.content,
|
|
1730
1761
|
createdAt: input.created_at
|
|
1731
|
-
}).pipe(
|
|
1762
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1732
1763
|
return { execution_id: record.executionId, kind: record.kind, sequence: record.sequence };
|
|
1733
1764
|
}),
|
|
1734
1765
|
getExecution: getExecutionOperation,
|
|
@@ -1738,104 +1769,104 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1738
1769
|
inspectExecution: inspectExecutionOperation,
|
|
1739
1770
|
streamExecution: streamExecutionOperation
|
|
1740
1771
|
}),
|
|
1741
|
-
listWaits:
|
|
1772
|
+
listWaits: Effect2.fn("Client.runtime.listWaits")(function* (input) {
|
|
1742
1773
|
const records = yield* envelopeReady.listWaits({
|
|
1743
1774
|
...input.state === undefined ? {} : { state: input.state },
|
|
1744
1775
|
...input.execution_id === undefined ? {} : { executionId: input.execution_id },
|
|
1745
1776
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1746
|
-
}).pipe(
|
|
1777
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1747
1778
|
return records.map(toWaitView);
|
|
1748
1779
|
}),
|
|
1749
|
-
listExecutions:
|
|
1750
|
-
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));
|
|
1751
1782
|
const result = yield* executionRepository.list({
|
|
1752
1783
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
1753
1784
|
...input.status === undefined ? {} : { status: input.status },
|
|
1754
1785
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
1755
1786
|
...cursor === undefined ? {} : { cursor }
|
|
1756
|
-
}).pipe(
|
|
1757
|
-
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));
|
|
1758
1789
|
return {
|
|
1759
1790
|
records: result.records.map(toConversationSummary),
|
|
1760
1791
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
1761
1792
|
};
|
|
1762
1793
|
}),
|
|
1763
|
-
subscribeTopic:
|
|
1794
|
+
subscribeTopic: Effect2.fn("Client.runtime.subscribeTopic")(function* (input) {
|
|
1764
1795
|
return yield* topicService.subscribe({
|
|
1765
1796
|
topicAddressId: input.topic_address_id,
|
|
1766
1797
|
subscriberExecutionId: input.subscriber_execution_id,
|
|
1767
1798
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
1768
|
-
}).pipe(
|
|
1799
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1769
1800
|
}),
|
|
1770
|
-
unsubscribeTopic:
|
|
1801
|
+
unsubscribeTopic: Effect2.fn("Client.runtime.unsubscribeTopic")(function* (input) {
|
|
1771
1802
|
return yield* topicService.unsubscribe({
|
|
1772
1803
|
topicAddressId: input.topic_address_id,
|
|
1773
1804
|
subscriberExecutionId: input.subscriber_execution_id
|
|
1774
|
-
}).pipe(
|
|
1805
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1775
1806
|
}),
|
|
1776
|
-
publishTopic:
|
|
1807
|
+
publishTopic: Effect2.fn("Client.runtime.publishTopic")(function* (input) {
|
|
1777
1808
|
return yield* topicService.publish({
|
|
1778
1809
|
topicAddressId: input.topic_address_id,
|
|
1779
1810
|
from: input.from,
|
|
1780
1811
|
content: input.content,
|
|
1781
1812
|
...input.metadata === undefined ? {} : { metadata: input.metadata },
|
|
1782
1813
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key }
|
|
1783
|
-
}).pipe(
|
|
1814
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1784
1815
|
}),
|
|
1785
|
-
listTopicSubscriptions:
|
|
1816
|
+
listTopicSubscriptions: Effect2.fn("Client.runtime.listTopicSubscriptions")(function* (input) {
|
|
1786
1817
|
return yield* topicService.list({
|
|
1787
1818
|
...input.topic_address_id === undefined ? {} : { topicAddressId: input.topic_address_id },
|
|
1788
1819
|
...input.subscriber_execution_id === undefined ? {} : { subscriberExecutionId: input.subscriber_execution_id }
|
|
1789
|
-
}).pipe(
|
|
1820
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1790
1821
|
}),
|
|
1791
|
-
listInboxMessages:
|
|
1822
|
+
listInboxMessages: Effect2.fn("Client.runtime.listInboxMessages")(function* (input) {
|
|
1792
1823
|
return yield* inboxRepository.list({
|
|
1793
1824
|
executionId: input.execution_id,
|
|
1794
1825
|
...input.include_consumed === undefined ? {} : { includeConsumed: input.include_consumed },
|
|
1795
1826
|
...input.after_sequence === undefined ? {} : { afterSequence: input.after_sequence },
|
|
1796
1827
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1797
|
-
}).pipe(
|
|
1828
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1798
1829
|
}),
|
|
1799
|
-
listSessions:
|
|
1800
|
-
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));
|
|
1801
1832
|
const result = yield* sessionRepository.list({
|
|
1802
1833
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
1803
1834
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
1804
1835
|
...cursor === undefined ? {} : { cursor }
|
|
1805
|
-
}).pipe(
|
|
1806
|
-
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));
|
|
1807
1838
|
return {
|
|
1808
1839
|
records: result.records.map(toSessionSummary),
|
|
1809
1840
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
1810
1841
|
};
|
|
1811
1842
|
}),
|
|
1812
|
-
getSession:
|
|
1813
|
-
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));
|
|
1814
1845
|
if (session === undefined)
|
|
1815
1846
|
return yield* new ClientError({ message: `Session not found: ${input.session_id}` });
|
|
1816
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
1847
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema4.decodeEffect(ExecutionCursorFromString)(input.cursor).pipe(Effect2.mapError(toClientError));
|
|
1817
1848
|
const result = yield* executionRepository.list({
|
|
1818
1849
|
sessionId: input.session_id,
|
|
1819
1850
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
1820
1851
|
...cursor === undefined ? {} : { cursor }
|
|
1821
|
-
}).pipe(
|
|
1822
|
-
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));
|
|
1823
1854
|
return {
|
|
1824
1855
|
session: toSessionSummary(session),
|
|
1825
1856
|
executions: result.records.map(toConversationSummary),
|
|
1826
1857
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
1827
1858
|
};
|
|
1828
1859
|
}),
|
|
1829
|
-
replayExecution:
|
|
1860
|
+
replayExecution: Effect2.fn("Client.runtime.replayExecution")(function* (input) {
|
|
1830
1861
|
const events = yield* eventLog.replay({
|
|
1831
1862
|
executionId: input.execution_id,
|
|
1832
1863
|
...input.after_cursor === undefined ? {} : { afterCursor: input.after_cursor },
|
|
1833
1864
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1834
|
-
}).pipe(
|
|
1865
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
1835
1866
|
return { events };
|
|
1836
1867
|
}),
|
|
1837
|
-
listRunners:
|
|
1838
|
-
const runners = yield* clusterRegistry.listRunners().pipe(
|
|
1868
|
+
listRunners: Effect2.fn("Client.runtime.listRunners")(function* () {
|
|
1869
|
+
const runners = yield* clusterRegistry.listRunners().pipe(Effect2.mapError(toClientError));
|
|
1839
1870
|
return {
|
|
1840
1871
|
runners: runners.map((runner) => ({
|
|
1841
1872
|
address: runner.address,
|
|
@@ -1846,9 +1877,9 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1846
1877
|
total_shards: shardingConfig.shardsPerGroup * shardingConfig.availableShardGroups.length
|
|
1847
1878
|
};
|
|
1848
1879
|
}),
|
|
1849
|
-
routeExecution:
|
|
1880
|
+
routeExecution: Effect2.fn("Client.runtime.routeExecution")(function* (executionId) {
|
|
1850
1881
|
const shard = ShardId.toString(sharding.getShardId(EntityId.make(executionId), "execution"));
|
|
1851
|
-
const owner = yield* clusterRegistry.lockOwner(shard).pipe(
|
|
1882
|
+
const owner = yield* clusterRegistry.lockOwner(shard).pipe(Effect2.mapError(toClientError));
|
|
1852
1883
|
const runnerAddress = owner ?? null;
|
|
1853
1884
|
const self = Option.map(shardingConfig.runnerAddress, (address) => `${address.host}:${address.port}`);
|
|
1854
1885
|
return {
|
|
@@ -1859,12 +1890,12 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1859
1890
|
};
|
|
1860
1891
|
}),
|
|
1861
1892
|
send: sendEnvelope,
|
|
1862
|
-
askEntity:
|
|
1863
|
-
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));
|
|
1864
1895
|
if (instance === undefined || instance.status === "destroyed") {
|
|
1865
1896
|
return yield* new EntityNotFound({ kind: input.kind, key: input.key });
|
|
1866
1897
|
}
|
|
1867
|
-
const encoded = yield*
|
|
1898
|
+
const encoded = yield* Schema4.encodeUnknownEffect(input.command.input)(input.input).pipe(Effect2.mapError(toClientError));
|
|
1868
1899
|
const inputRef = inputSchemaRef(input.command.name);
|
|
1869
1900
|
const outputRef = outputSchemaRef(input.command.name);
|
|
1870
1901
|
if (Option.isSome(schemaRegistry)) {
|
|
@@ -1911,7 +1942,7 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1911
1942
|
message: "reply carried no decodable content"
|
|
1912
1943
|
});
|
|
1913
1944
|
}
|
|
1914
|
-
return yield*
|
|
1945
|
+
return yield* Schema4.decodeUnknownEffect(input.command.output)(replyValue.value).pipe(Effect2.mapError((issue) => new CommandReplyInvalid({
|
|
1915
1946
|
command: input.command.name,
|
|
1916
1947
|
wait_id: outcome.wait_id,
|
|
1917
1948
|
message: errorMessage(issue)
|
|
@@ -1933,49 +1964,49 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1933
1964
|
...input.session_id === undefined ? {} : { sessionId: input.session_id },
|
|
1934
1965
|
...input.status === undefined ? {} : { status: input.status },
|
|
1935
1966
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1936
|
-
}).pipe(Stream.mapEffect((change) => change._tag === "snapshot" ? change.nextCursor === undefined ?
|
|
1967
|
+
}).pipe(Stream.mapEffect((change) => change._tag === "snapshot" ? change.nextCursor === undefined ? Effect2.succeed({
|
|
1937
1968
|
_tag: "snapshot",
|
|
1938
1969
|
records: change.records.map(toConversationSummary)
|
|
1939
|
-
}) : encodeExecutionCursor(change.nextCursor).pipe(
|
|
1970
|
+
}) : encodeExecutionCursor(change.nextCursor).pipe(Effect2.map((next_cursor) => ({
|
|
1940
1971
|
_tag: "snapshot",
|
|
1941
1972
|
records: change.records.map(toConversationSummary),
|
|
1942
1973
|
next_cursor
|
|
1943
|
-
}))) :
|
|
1974
|
+
}))) : Effect2.succeed({
|
|
1944
1975
|
_tag: "upsert",
|
|
1945
1976
|
record: toConversationSummary(change.record)
|
|
1946
1977
|
})), Stream.mapError(toClientError)),
|
|
1947
|
-
getEntityState:
|
|
1948
|
-
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({
|
|
1949
1980
|
executionId: input.execution_id,
|
|
1950
1981
|
key: exports_execution_state_service.key(input.key, exports_shared_schema.JsonValue),
|
|
1951
1982
|
value: input.value,
|
|
1952
1983
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
1953
1984
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
1954
1985
|
updatedAt: input.updated_at
|
|
1955
|
-
}).pipe(
|
|
1956
|
-
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({
|
|
1957
1988
|
executionId: input.execution_id,
|
|
1958
1989
|
key: input.key,
|
|
1959
1990
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
1960
1991
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
1961
1992
|
removedAt: input.removed_at
|
|
1962
|
-
}).pipe(
|
|
1963
|
-
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({
|
|
1964
1995
|
executionId: input.execution_id,
|
|
1965
1996
|
...input.prefix === undefined ? {} : { prefix: input.prefix },
|
|
1966
1997
|
...input.after_key === undefined ? {} : { afterKey: input.after_key },
|
|
1967
1998
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
1968
|
-
}).pipe(
|
|
1969
|
-
getPresence: (scope) => presence.list(scope).pipe(
|
|
1999
|
+
}).pipe(Effect2.mapError(toClientError))),
|
|
2000
|
+
getPresence: (scope) => presence.list(scope).pipe(Effect2.mapError(toClientError)),
|
|
1970
2001
|
watchPresence: (scope) => presence.watch(scope).pipe(Stream.mapError(toClientError)),
|
|
1971
|
-
wake:
|
|
2002
|
+
wake: Effect2.fn("Client.runtime.wake")(function* (input) {
|
|
1972
2003
|
return yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, input);
|
|
1973
2004
|
}),
|
|
1974
|
-
listPendingApprovals:
|
|
1975
|
-
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));
|
|
1976
2007
|
return { approvals: records.filter(isToolApprovalWait).map(toPendingToolApproval) };
|
|
1977
2008
|
}),
|
|
1978
|
-
resolveToolApproval:
|
|
2009
|
+
resolveToolApproval: Effect2.fn("Client.runtime.resolveToolApproval")(function* (input) {
|
|
1979
2010
|
return yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, {
|
|
1980
2011
|
wait_id: input.wait_id,
|
|
1981
2012
|
state: "resolved",
|
|
@@ -1986,7 +2017,7 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1986
2017
|
}
|
|
1987
2018
|
}, "tool-approval");
|
|
1988
2019
|
}),
|
|
1989
|
-
resolvePermission:
|
|
2020
|
+
resolvePermission: Effect2.fn("Client.runtime.resolvePermission")(function* (input) {
|
|
1990
2021
|
return yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, {
|
|
1991
2022
|
wait_id: input.wait_id,
|
|
1992
2023
|
state: "resolved",
|
|
@@ -1997,18 +2028,18 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
1997
2028
|
}
|
|
1998
2029
|
}, "tool-permission");
|
|
1999
2030
|
}),
|
|
2000
|
-
listPendingToolCalls:
|
|
2031
|
+
listPendingToolCalls: Effect2.fn("Client.runtime.listPendingToolCalls")(function* (input) {
|
|
2001
2032
|
const openWaits = yield* envelopeReady.listAllWaits({
|
|
2002
2033
|
state: "open",
|
|
2003
2034
|
...input.execution_id === undefined ? {} : { executionId: input.execution_id }
|
|
2004
|
-
}).pipe(
|
|
2005
|
-
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)));
|
|
2006
2037
|
const sorted = records.filter((record) => record !== undefined).toSorted((left, right) => left.requested_at - right.requested_at || left.call.id.localeCompare(right.call.id));
|
|
2007
2038
|
return { tool_calls: input.limit === undefined ? sorted : sorted.slice(0, input.limit) };
|
|
2008
2039
|
}),
|
|
2009
|
-
fulfillToolCall:
|
|
2010
|
-
const coordinated = yield* coordinateToolTransition(
|
|
2011
|
-
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));
|
|
2012
2043
|
if (call === undefined || call.executionId !== input.execution_id || call.placement.kind !== "client") {
|
|
2013
2044
|
return yield* new ClientError({ message: `Client tool call not found: ${input.tool_call_id}` });
|
|
2014
2045
|
}
|
|
@@ -2018,24 +2049,24 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
2018
2049
|
callId: input.tool_call_id,
|
|
2019
2050
|
outcome: input.outcome,
|
|
2020
2051
|
submittedAt: input.fulfilled_at
|
|
2021
|
-
}).pipe(
|
|
2052
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
2022
2053
|
return { wait, accepted };
|
|
2023
2054
|
}));
|
|
2024
2055
|
yield* signalToolOutcome(executionRepository, makeExecutionClient, coordinated.wait, input.fulfilled_at);
|
|
2025
2056
|
return toToolOutcomeAccepted(coordinated.accepted);
|
|
2026
2057
|
}),
|
|
2027
|
-
claimToolWork:
|
|
2058
|
+
claimToolWork: Effect2.fn("Client.runtime.claimToolWork")(function* (input) {
|
|
2028
2059
|
const lease = yield* coordinateToolTransition(toolCalls.claimRemote({
|
|
2029
2060
|
queue: input.queue,
|
|
2030
2061
|
workerId: input.worker_id,
|
|
2031
2062
|
now: input.now,
|
|
2032
2063
|
claimExpiresAt: input.claim_expires_at
|
|
2033
|
-
}).pipe(
|
|
2064
|
+
}).pipe(Effect2.mapError(toClientError)));
|
|
2034
2065
|
return lease === undefined ? null : toToolWorkLease(lease);
|
|
2035
2066
|
}),
|
|
2036
|
-
completeToolWork:
|
|
2037
|
-
const coordinated = yield* coordinateToolTransition(
|
|
2038
|
-
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));
|
|
2039
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;
|
|
2040
2071
|
const acceptedRetry = call !== undefined && call.placement.kind === "remote" && call.state === "submitted" && call.activeAttemptId === input.attempt_id && call.externalOutcome !== undefined;
|
|
2041
2072
|
if (call === undefined || !active && !acceptedRetry) {
|
|
@@ -2048,13 +2079,13 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
2048
2079
|
workerId: input.worker_id,
|
|
2049
2080
|
outcome: input.outcome,
|
|
2050
2081
|
submittedAt: input.completed_at
|
|
2051
|
-
}).pipe(
|
|
2082
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
2052
2083
|
return { wait, accepted };
|
|
2053
2084
|
}));
|
|
2054
2085
|
yield* signalToolOutcome(executionRepository, makeExecutionClient, coordinated.wait, input.completed_at);
|
|
2055
2086
|
return toToolOutcomeAccepted(coordinated.accepted);
|
|
2056
2087
|
}),
|
|
2057
|
-
releaseToolWork:
|
|
2088
|
+
releaseToolWork: Effect2.fn("Client.runtime.releaseToolWork")(function* (input) {
|
|
2058
2089
|
const call = yield* coordinateToolTransition(toolCalls.releaseRemote({
|
|
2059
2090
|
callId: input.tool_call_id,
|
|
2060
2091
|
attemptId: input.attempt_id,
|
|
@@ -2062,94 +2093,96 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
2062
2093
|
releasedAt: input.released_at,
|
|
2063
2094
|
nextAvailableAt: input.next_available_at,
|
|
2064
2095
|
...input.error === undefined ? {} : { error: input.error }
|
|
2065
|
-
}).pipe(
|
|
2096
|
+
}).pipe(Effect2.mapError(toClientError)));
|
|
2066
2097
|
return {
|
|
2067
2098
|
tool_call_id: call.call.id,
|
|
2068
2099
|
state: "waiting",
|
|
2069
2100
|
next_available_at: call.availableAt
|
|
2070
2101
|
};
|
|
2071
2102
|
}),
|
|
2072
|
-
listToolAttempts:
|
|
2073
|
-
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));
|
|
2074
2105
|
return { attempts: attempts.map(toToolAttempt) };
|
|
2075
2106
|
}),
|
|
2076
|
-
submitInboundEnvelope:
|
|
2077
|
-
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));
|
|
2078
2109
|
const wakeResult = yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, input.wake);
|
|
2079
2110
|
return { envelope, wake: wakeResult };
|
|
2080
2111
|
}),
|
|
2081
|
-
spawnChildRun:
|
|
2112
|
+
spawnChildRun: Effect2.fn("Client.runtime.spawnChildRun")(function* (input) {
|
|
2082
2113
|
const pin = yield* parentDefinitionPin(executionRepository, input.execution_id);
|
|
2083
2114
|
const createdAt = yield* Clock.currentTimeMillis;
|
|
2084
2115
|
const internal = internalSpawnChildRunInput(input, pin, createdAt);
|
|
2085
|
-
const context = yield* exports_child_run_service.resolveForDispatch(internal).pipe(
|
|
2086
|
-
const definition = yield* exports_child_run_service.childDefinition(pin.agentSnapshot, context).pipe(
|
|
2087
|
-
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* () {
|
|
2088
2119
|
const existing = yield* reconcileExistingChildSpawn(childExecutions, waits, eventLog, input);
|
|
2089
2120
|
if (existing !== undefined)
|
|
2090
2121
|
return existing;
|
|
2091
|
-
const accepted = yield* executions.spawnChildRun(internal).pipe(
|
|
2122
|
+
const accepted = yield* executions.spawnChildRun(internal).pipe(Effect2.mapError(toClientError));
|
|
2092
2123
|
const parentWaitId = input.wait === true ? yield* createChildJoinWait(waits, eventLog, internal, accepted, createdAt) : undefined;
|
|
2093
2124
|
return { accepted, createdAt, parentWaitId };
|
|
2094
|
-
})).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)));
|
|
2095
2126
|
const startPayload = childStartInput(internal, coordinated.accepted, pin, definition, coordinated.createdAt, coordinated.parentWaitId);
|
|
2096
2127
|
const client = makeExecutionClient(startPayload.execution_id);
|
|
2097
|
-
yield* client.dispatch(startPayload).pipe(
|
|
2128
|
+
yield* client.dispatch(startPayload).pipe(Effect2.mapError(toClientError));
|
|
2098
2129
|
return coordinated.accepted;
|
|
2099
2130
|
}),
|
|
2100
|
-
createChildFanOut:
|
|
2131
|
+
createChildFanOut: Effect2.fn("Client.runtime.createChildFanOut")(function* (input) {
|
|
2132
|
+
if (Option.isSome(runtimeCapabilityPolicy))
|
|
2133
|
+
yield* runtimeCapabilityPolicy.value.admit("fan-out");
|
|
2101
2134
|
if (Option.isNone(childFanOutRuntime)) {
|
|
2102
2135
|
return yield* new ClientError({
|
|
2103
2136
|
message: "Child fan-out runtime unavailable; provide ChildFanOutRuntime.Service to Client.layerFromRuntime"
|
|
2104
2137
|
});
|
|
2105
2138
|
}
|
|
2106
|
-
return yield* childFanOutRuntime.value.create(input).pipe(
|
|
2139
|
+
return yield* childFanOutRuntime.value.create(input).pipe(Effect2.mapError(toClientError));
|
|
2107
2140
|
}),
|
|
2108
|
-
cancelChildFanOut:
|
|
2141
|
+
cancelChildFanOut: Effect2.fn("Client.runtime.cancelChildFanOut")(function* (input) {
|
|
2109
2142
|
return yield* cancelFanOut(input);
|
|
2110
2143
|
}),
|
|
2111
|
-
inspectChildFanOut:
|
|
2144
|
+
inspectChildFanOut: Effect2.fn("Client.runtime.inspectChildFanOut")(function* (input) {
|
|
2112
2145
|
const fanOut = yield* Option.match(childFanOutRuntime, {
|
|
2113
2146
|
onNone: () => childFanOuts.get(input.fan_out_id),
|
|
2114
2147
|
onSome: (runtime) => runtime.inspect(input.fan_out_id)
|
|
2115
|
-
}).pipe(
|
|
2148
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
2116
2149
|
return { fan_out: fanOut ?? null };
|
|
2117
2150
|
}),
|
|
2118
|
-
claimEnvelopeReady:
|
|
2151
|
+
claimEnvelopeReady: Effect2.fn("Client.runtime.claimEnvelopeReady")(function* (input) {
|
|
2119
2152
|
return yield* envelopeReady.claimReady({
|
|
2120
2153
|
routeType: input.route_type,
|
|
2121
2154
|
...input.route_key === undefined ? {} : { routeKey: input.route_key },
|
|
2122
2155
|
workerId: input.worker_id,
|
|
2123
2156
|
now: input.now,
|
|
2124
2157
|
claimExpiresAt: input.claim_expires_at
|
|
2125
|
-
}).pipe(
|
|
2158
|
+
}).pipe(Effect2.map((record) => record === undefined ? null : toLease(record)), Effect2.mapError(toClientError));
|
|
2126
2159
|
}),
|
|
2127
|
-
ackEnvelopeReady:
|
|
2160
|
+
ackEnvelopeReady: Effect2.fn("Client.runtime.ackEnvelopeReady")(function* (input) {
|
|
2128
2161
|
return yield* envelopeReady.ackReady({
|
|
2129
2162
|
id: input.envelope_ready_id,
|
|
2130
2163
|
workerId: input.worker_id,
|
|
2131
2164
|
now: input.acknowledged_at
|
|
2132
|
-
}).pipe(
|
|
2165
|
+
}).pipe(Effect2.map((record) => ({
|
|
2133
2166
|
envelope_ready_id: record.id,
|
|
2134
2167
|
state: "acknowledged",
|
|
2135
2168
|
acknowledged_at: record.acknowledgedAt ?? input.acknowledged_at
|
|
2136
|
-
})),
|
|
2169
|
+
})), Effect2.mapError(toClientError));
|
|
2137
2170
|
}),
|
|
2138
|
-
releaseEnvelopeReady:
|
|
2171
|
+
releaseEnvelopeReady: Effect2.fn("Client.runtime.releaseEnvelopeReady")(function* (input) {
|
|
2139
2172
|
return yield* envelopeReady.releaseReady({
|
|
2140
2173
|
id: input.envelope_ready_id,
|
|
2141
2174
|
workerId: input.worker_id,
|
|
2142
2175
|
nextAvailableAt: input.next_available_at,
|
|
2143
2176
|
...input.error === undefined ? {} : { error: input.error }
|
|
2144
|
-
}).pipe(
|
|
2177
|
+
}).pipe(Effect2.map((record) => ({
|
|
2145
2178
|
envelope_ready_id: record.id,
|
|
2146
2179
|
state: "ready",
|
|
2147
2180
|
next_available_at: record.availableAt
|
|
2148
|
-
})),
|
|
2181
|
+
})), Effect2.mapError(toClientError));
|
|
2149
2182
|
}),
|
|
2150
|
-
createSchedule:
|
|
2183
|
+
createSchedule: Effect2.fn("Client.runtime.createSchedule")(function* (input) {
|
|
2151
2184
|
if (input.cron_expr !== undefined) {
|
|
2152
|
-
yield* exports_scheduler_service.parseCron(input.cron_expr).pipe(
|
|
2185
|
+
yield* exports_scheduler_service.parseCron(input.cron_expr).pipe(Effect2.mapError(toClientError));
|
|
2153
2186
|
}
|
|
2154
2187
|
const createdAt = yield* Clock.currentTimeMillis;
|
|
2155
2188
|
const schedule = yield* schedules.create({
|
|
@@ -2164,287 +2197,603 @@ var layerFromRuntime = Layer.effect(Service, Effect.gen(function* () {
|
|
|
2164
2197
|
...input.input === undefined ? {} : { input: input.input },
|
|
2165
2198
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
2166
2199
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
2167
|
-
}).pipe(
|
|
2200
|
+
}).pipe(Effect2.mapError(toClientError));
|
|
2168
2201
|
return { schedule };
|
|
2169
2202
|
}),
|
|
2170
|
-
cancelSchedule:
|
|
2171
|
-
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));
|
|
2172
2205
|
return { schedule };
|
|
2173
2206
|
}),
|
|
2174
|
-
listSchedules:
|
|
2175
|
-
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));
|
|
2176
2209
|
return { schedules: records };
|
|
2177
2210
|
})
|
|
2178
2211
|
});
|
|
2179
2212
|
}));
|
|
2180
|
-
var testLayer = (implementation) =>
|
|
2213
|
+
var testLayer = (implementation) => Layer2.succeed(Service2, Service2.of({
|
|
2181
2214
|
...implementation,
|
|
2182
2215
|
followExecution: implementation.followExecution ?? followExecutionFrom({
|
|
2183
2216
|
getExecution: implementation.getExecution,
|
|
2184
2217
|
inspectExecution: implementation.inspectExecution,
|
|
2185
2218
|
streamExecution: implementation.streamExecution
|
|
2186
2219
|
}),
|
|
2187
|
-
registerEntityKind: implementation.registerEntityKind ?? ((input) =>
|
|
2188
|
-
getOrCreateEntity: implementation.getOrCreateEntity ?? (() =>
|
|
2189
|
-
getEntity: implementation.getEntity ?? (() =>
|
|
2190
|
-
destroyEntity: implementation.destroyEntity ?? (() =>
|
|
2191
|
-
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([])),
|
|
2192
2225
|
streamSession: implementation.streamSession ?? (() => Stream.empty),
|
|
2193
2226
|
watchExecutions: implementation.watchExecutions ?? (() => Stream.empty),
|
|
2194
|
-
getPresence: implementation.getPresence ?? ((scope) =>
|
|
2227
|
+
getPresence: implementation.getPresence ?? ((scope) => Effect2.succeed({ scope, entries: [], observed_at: 0 })),
|
|
2195
2228
|
watchPresence: implementation.watchPresence ?? (() => Stream.empty),
|
|
2196
|
-
registerWorkflowDefinition: implementation.registerWorkflowDefinition ?? (() =>
|
|
2197
|
-
getWorkflowDefinitionRevision: implementation.getWorkflowDefinitionRevision ?? (() =>
|
|
2198
|
-
listWorkflowDefinitionRevisions: implementation.listWorkflowDefinitionRevisions ?? (() =>
|
|
2199
|
-
startWorkflowRun: implementation.startWorkflowRun ?? (() =>
|
|
2200
|
-
inspectWorkflowRun: implementation.inspectWorkflowRun ?? (() =>
|
|
2201
|
-
replayWorkflowRun: implementation.replayWorkflowRun ?? (() =>
|
|
2202
|
-
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"))
|
|
2203
2236
|
}));
|
|
2204
|
-
var registerAgentDefinition =
|
|
2205
|
-
const service = yield*
|
|
2237
|
+
var registerAgentDefinition = Effect2.fn("Client.registerAgentDefinition.call")(function* (input) {
|
|
2238
|
+
const service = yield* Service2;
|
|
2206
2239
|
return yield* service.registerAgentDefinition(input);
|
|
2207
2240
|
});
|
|
2208
|
-
var registerEntityKind =
|
|
2209
|
-
const service = yield*
|
|
2241
|
+
var registerEntityKind = Effect2.fn("Client.registerEntityKind.call")(function* (input) {
|
|
2242
|
+
const service = yield* Service2;
|
|
2210
2243
|
return yield* service.registerEntityKind(input);
|
|
2211
2244
|
});
|
|
2212
|
-
var getOrCreateEntity =
|
|
2213
|
-
const service = yield*
|
|
2245
|
+
var getOrCreateEntity = Effect2.fn("Client.getOrCreateEntity.call")(function* (input) {
|
|
2246
|
+
const service = yield* Service2;
|
|
2214
2247
|
return yield* service.getOrCreateEntity(input);
|
|
2215
2248
|
});
|
|
2216
|
-
var getEntity =
|
|
2217
|
-
const service = yield*
|
|
2249
|
+
var getEntity = Effect2.fn("Client.getEntity.call")(function* (input) {
|
|
2250
|
+
const service = yield* Service2;
|
|
2218
2251
|
return yield* service.getEntity(input);
|
|
2219
2252
|
});
|
|
2220
|
-
var destroyEntity =
|
|
2221
|
-
const service = yield*
|
|
2253
|
+
var destroyEntity = Effect2.fn("Client.destroyEntity.call")(function* (input) {
|
|
2254
|
+
const service = yield* Service2;
|
|
2222
2255
|
return yield* service.destroyEntity(input);
|
|
2223
2256
|
});
|
|
2224
|
-
var listEntities =
|
|
2225
|
-
const service = yield*
|
|
2257
|
+
var listEntities = Effect2.fn("Client.listEntities.call")(function* (input) {
|
|
2258
|
+
const service = yield* Service2;
|
|
2226
2259
|
return yield* service.listEntities(input);
|
|
2227
2260
|
});
|
|
2228
|
-
var registerAgent =
|
|
2229
|
-
const service = yield*
|
|
2261
|
+
var registerAgent = Effect2.fn("Client.registerAgent.call")(function* (input) {
|
|
2262
|
+
const service = yield* Service2;
|
|
2230
2263
|
return yield* service.registerAgent(input);
|
|
2231
2264
|
});
|
|
2232
|
-
var getAgentDefinition =
|
|
2233
|
-
const service = yield*
|
|
2265
|
+
var getAgentDefinition = Effect2.fn("Client.getAgentDefinition.call")(function* (id) {
|
|
2266
|
+
const service = yield* Service2;
|
|
2234
2267
|
return yield* service.getAgentDefinition(id);
|
|
2235
2268
|
});
|
|
2236
|
-
var listAgentDefinitions =
|
|
2237
|
-
const service = yield*
|
|
2269
|
+
var listAgentDefinitions = Effect2.fn("Client.listAgentDefinitions.call")(function* () {
|
|
2270
|
+
const service = yield* Service2;
|
|
2238
2271
|
return yield* service.listAgentDefinitions();
|
|
2239
2272
|
});
|
|
2240
|
-
var listAgentDefinitionRevisions =
|
|
2241
|
-
const service = yield*
|
|
2273
|
+
var listAgentDefinitionRevisions = Effect2.fn("Client.listAgentDefinitionRevisions.call")(function* (id) {
|
|
2274
|
+
const service = yield* Service2;
|
|
2242
2275
|
return yield* service.listAgentDefinitionRevisions(id);
|
|
2243
2276
|
});
|
|
2244
|
-
var getSkillDefinition =
|
|
2245
|
-
const service = yield*
|
|
2277
|
+
var getSkillDefinition = Effect2.fn("Client.getSkillDefinition.call")(function* (id) {
|
|
2278
|
+
const service = yield* Service2;
|
|
2246
2279
|
return yield* service.getSkillDefinition(id);
|
|
2247
2280
|
});
|
|
2248
|
-
var listSkillDefinitions =
|
|
2249
|
-
const service = yield*
|
|
2281
|
+
var listSkillDefinitions = Effect2.fn("Client.listSkillDefinitions.call")(function* () {
|
|
2282
|
+
const service = yield* Service2;
|
|
2250
2283
|
return yield* service.listSkillDefinitions();
|
|
2251
2284
|
});
|
|
2252
|
-
var listSkillDefinitionRevisions =
|
|
2253
|
-
const service = yield*
|
|
2285
|
+
var listSkillDefinitionRevisions = Effect2.fn("Client.listSkillDefinitionRevisions.call")(function* (id) {
|
|
2286
|
+
const service = yield* Service2;
|
|
2254
2287
|
return yield* service.listSkillDefinitionRevisions(id);
|
|
2255
2288
|
});
|
|
2256
|
-
var registerAddressBookRoute =
|
|
2257
|
-
const service = yield*
|
|
2289
|
+
var registerAddressBookRoute = Effect2.fn("Client.registerAddressBookRoute.call")(function* (input) {
|
|
2290
|
+
const service = yield* Service2;
|
|
2258
2291
|
return yield* service.registerAddressBookRoute(input);
|
|
2259
2292
|
});
|
|
2260
|
-
var getAddressBookRoute =
|
|
2261
|
-
const service = yield*
|
|
2293
|
+
var getAddressBookRoute = Effect2.fn("Client.getAddressBookRoute.call")(function* (id) {
|
|
2294
|
+
const service = yield* Service2;
|
|
2262
2295
|
return yield* service.getAddressBookRoute(id);
|
|
2263
2296
|
});
|
|
2264
|
-
var listAddressBookRoutes =
|
|
2265
|
-
const service = yield*
|
|
2297
|
+
var listAddressBookRoutes = Effect2.fn("Client.listAddressBookRoutes.call")(function* () {
|
|
2298
|
+
const service = yield* Service2;
|
|
2266
2299
|
return yield* service.listAddressBookRoutes();
|
|
2267
2300
|
});
|
|
2268
|
-
var startExecution =
|
|
2269
|
-
const service = yield*
|
|
2301
|
+
var startExecution = Effect2.fn("Client.startExecution.call")(function* (input) {
|
|
2302
|
+
const service = yield* Service2;
|
|
2270
2303
|
return yield* service.startExecution(input);
|
|
2271
2304
|
});
|
|
2272
|
-
var startExecutionByAddress =
|
|
2273
|
-
const service = yield*
|
|
2305
|
+
var startExecutionByAddress = Effect2.fn("Client.startExecutionByAddress.call")(function* (input) {
|
|
2306
|
+
const service = yield* Service2;
|
|
2274
2307
|
return yield* service.startExecutionByAddress(input);
|
|
2275
2308
|
});
|
|
2276
|
-
var startExecutionByAgentDefinition =
|
|
2277
|
-
const service = yield*
|
|
2309
|
+
var startExecutionByAgentDefinition = Effect2.fn("Client.startExecutionByAgentDefinition.call")(function* (input) {
|
|
2310
|
+
const service = yield* Service2;
|
|
2278
2311
|
return yield* service.startExecutionByAgentDefinition(input);
|
|
2279
2312
|
});
|
|
2280
|
-
var cancelExecution =
|
|
2281
|
-
const service = yield*
|
|
2313
|
+
var cancelExecution = Effect2.fn("Client.cancelExecution.call")(function* (input) {
|
|
2314
|
+
const service = yield* Service2;
|
|
2282
2315
|
return yield* service.cancelExecution(input);
|
|
2283
2316
|
});
|
|
2284
|
-
var steer =
|
|
2285
|
-
const service = yield*
|
|
2317
|
+
var steer = Effect2.fn("Client.steer.call")(function* (input) {
|
|
2318
|
+
const service = yield* Service2;
|
|
2286
2319
|
return yield* service.steer(input);
|
|
2287
2320
|
});
|
|
2288
|
-
var getExecution =
|
|
2289
|
-
const service = yield*
|
|
2321
|
+
var getExecution = Effect2.fn("Client.getExecution.call")(function* (id) {
|
|
2322
|
+
const service = yield* Service2;
|
|
2290
2323
|
return yield* service.getExecution(id);
|
|
2291
2324
|
});
|
|
2292
|
-
var listExecutions =
|
|
2293
|
-
const service = yield*
|
|
2325
|
+
var listExecutions = Effect2.fn("Client.listExecutions.call")(function* (input) {
|
|
2326
|
+
const service = yield* Service2;
|
|
2294
2327
|
return yield* service.listExecutions(input);
|
|
2295
2328
|
});
|
|
2296
|
-
var listSessions =
|
|
2297
|
-
const service = yield*
|
|
2329
|
+
var listSessions = Effect2.fn("Client.listSessions.call")(function* (input) {
|
|
2330
|
+
const service = yield* Service2;
|
|
2298
2331
|
return yield* service.listSessions(input);
|
|
2299
2332
|
});
|
|
2300
|
-
var getSession =
|
|
2301
|
-
const service = yield*
|
|
2333
|
+
var getSession = Effect2.fn("Client.getSession.call")(function* (input) {
|
|
2334
|
+
const service = yield* Service2;
|
|
2302
2335
|
return yield* service.getSession(input);
|
|
2303
2336
|
});
|
|
2304
|
-
var listWaits =
|
|
2305
|
-
const service = yield*
|
|
2337
|
+
var listWaits = Effect2.fn("Client.listWaits.call")(function* (input) {
|
|
2338
|
+
const service = yield* Service2;
|
|
2306
2339
|
return yield* service.listWaits(input);
|
|
2307
2340
|
});
|
|
2308
|
-
var replayExecution =
|
|
2309
|
-
const service = yield*
|
|
2341
|
+
var replayExecution = Effect2.fn("Client.replayExecution.call")(function* (input) {
|
|
2342
|
+
const service = yield* Service2;
|
|
2310
2343
|
return yield* service.replayExecution(input);
|
|
2311
2344
|
});
|
|
2312
|
-
var listRunners =
|
|
2313
|
-
const service = yield*
|
|
2345
|
+
var listRunners = Effect2.fn("Client.listRunners.call")(function* () {
|
|
2346
|
+
const service = yield* Service2;
|
|
2314
2347
|
return yield* service.listRunners();
|
|
2315
2348
|
});
|
|
2316
|
-
var routeExecution =
|
|
2317
|
-
const service = yield*
|
|
2349
|
+
var routeExecution = Effect2.fn("Client.routeExecution.call")(function* (executionId) {
|
|
2350
|
+
const service = yield* Service2;
|
|
2318
2351
|
return yield* service.routeExecution(executionId);
|
|
2319
2352
|
});
|
|
2320
|
-
var subscribeTopic =
|
|
2321
|
-
const service = yield*
|
|
2353
|
+
var subscribeTopic = Effect2.fn("Client.subscribeTopic.call")(function* (input) {
|
|
2354
|
+
const service = yield* Service2;
|
|
2322
2355
|
return yield* service.subscribeTopic(input);
|
|
2323
2356
|
});
|
|
2324
|
-
var unsubscribeTopic =
|
|
2325
|
-
const service = yield*
|
|
2357
|
+
var unsubscribeTopic = Effect2.fn("Client.unsubscribeTopic.call")(function* (input) {
|
|
2358
|
+
const service = yield* Service2;
|
|
2326
2359
|
return yield* service.unsubscribeTopic(input);
|
|
2327
2360
|
});
|
|
2328
|
-
var publishTopic =
|
|
2329
|
-
const service = yield*
|
|
2361
|
+
var publishTopic = Effect2.fn("Client.publishTopic.call")(function* (input) {
|
|
2362
|
+
const service = yield* Service2;
|
|
2330
2363
|
return yield* service.publishTopic(input);
|
|
2331
2364
|
});
|
|
2332
|
-
var listTopicSubscriptions =
|
|
2333
|
-
const service = yield*
|
|
2365
|
+
var listTopicSubscriptions = Effect2.fn("Client.listTopicSubscriptions.call")(function* (input) {
|
|
2366
|
+
const service = yield* Service2;
|
|
2334
2367
|
return yield* service.listTopicSubscriptions(input);
|
|
2335
2368
|
});
|
|
2336
|
-
var listInboxMessages =
|
|
2337
|
-
const service = yield*
|
|
2369
|
+
var listInboxMessages = Effect2.fn("Client.listInboxMessages.call")(function* (input) {
|
|
2370
|
+
const service = yield* Service2;
|
|
2338
2371
|
return yield* service.listInboxMessages(input);
|
|
2339
2372
|
});
|
|
2340
|
-
var inspectExecution =
|
|
2341
|
-
const service = yield*
|
|
2373
|
+
var inspectExecution = Effect2.fn("Client.inspectExecution.call")(function* (executionId) {
|
|
2374
|
+
const service = yield* Service2;
|
|
2342
2375
|
return yield* service.inspectExecution(executionId);
|
|
2343
2376
|
});
|
|
2344
|
-
var send =
|
|
2345
|
-
const service = yield*
|
|
2377
|
+
var send = Effect2.fn("Client.send.call")(function* (input) {
|
|
2378
|
+
const service = yield* Service2;
|
|
2346
2379
|
return yield* service.send(input);
|
|
2347
2380
|
});
|
|
2348
|
-
var streamExecution = (input) => Stream.unwrap(
|
|
2349
|
-
var followExecution = (input) => Stream.unwrap(
|
|
2350
|
-
var streamSession = (input) => Stream.unwrap(
|
|
2351
|
-
var watchExecutions = (input) => Stream.unwrap(
|
|
2352
|
-
var getPresence =
|
|
2353
|
-
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;
|
|
2354
2387
|
return yield* service.getPresence(scope);
|
|
2355
2388
|
});
|
|
2356
|
-
var watchPresence = (scope) => Stream.unwrap(
|
|
2357
|
-
var wake =
|
|
2358
|
-
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;
|
|
2359
2392
|
return yield* service.wake(input);
|
|
2360
2393
|
});
|
|
2361
|
-
var listPendingApprovals =
|
|
2362
|
-
const service = yield*
|
|
2394
|
+
var listPendingApprovals = Effect2.fn("Client.listPendingApprovals.call")(function* (input) {
|
|
2395
|
+
const service = yield* Service2;
|
|
2363
2396
|
return yield* service.listPendingApprovals(input);
|
|
2364
2397
|
});
|
|
2365
|
-
var resolveToolApproval =
|
|
2366
|
-
const service = yield*
|
|
2398
|
+
var resolveToolApproval = Effect2.fn("Client.resolveToolApproval.call")(function* (input) {
|
|
2399
|
+
const service = yield* Service2;
|
|
2367
2400
|
return yield* service.resolveToolApproval(input);
|
|
2368
2401
|
});
|
|
2369
|
-
var resolvePermission =
|
|
2370
|
-
const service = yield*
|
|
2402
|
+
var resolvePermission = Effect2.fn("Client.resolvePermission.call")(function* (input) {
|
|
2403
|
+
const service = yield* Service2;
|
|
2371
2404
|
return yield* service.resolvePermission(input);
|
|
2372
2405
|
});
|
|
2373
|
-
var listPendingToolCalls =
|
|
2374
|
-
const service = yield*
|
|
2406
|
+
var listPendingToolCalls = Effect2.fn("Client.listPendingToolCalls.call")(function* (input) {
|
|
2407
|
+
const service = yield* Service2;
|
|
2375
2408
|
return yield* service.listPendingToolCalls(input);
|
|
2376
2409
|
});
|
|
2377
|
-
var fulfillToolCall =
|
|
2378
|
-
const service = yield*
|
|
2410
|
+
var fulfillToolCall = Effect2.fn("Client.fulfillToolCall.call")(function* (input) {
|
|
2411
|
+
const service = yield* Service2;
|
|
2379
2412
|
return yield* service.fulfillToolCall(input);
|
|
2380
2413
|
});
|
|
2381
|
-
var claimToolWork =
|
|
2382
|
-
const service = yield*
|
|
2414
|
+
var claimToolWork = Effect2.fn("Client.claimToolWork.call")(function* (input) {
|
|
2415
|
+
const service = yield* Service2;
|
|
2383
2416
|
return yield* service.claimToolWork(input);
|
|
2384
2417
|
});
|
|
2385
|
-
var completeToolWork =
|
|
2386
|
-
const service = yield*
|
|
2418
|
+
var completeToolWork = Effect2.fn("Client.completeToolWork.call")(function* (input) {
|
|
2419
|
+
const service = yield* Service2;
|
|
2387
2420
|
return yield* service.completeToolWork(input);
|
|
2388
2421
|
});
|
|
2389
|
-
var releaseToolWork =
|
|
2390
|
-
const service = yield*
|
|
2422
|
+
var releaseToolWork = Effect2.fn("Client.releaseToolWork.call")(function* (input) {
|
|
2423
|
+
const service = yield* Service2;
|
|
2391
2424
|
return yield* service.releaseToolWork(input);
|
|
2392
2425
|
});
|
|
2393
|
-
var listToolAttempts =
|
|
2394
|
-
const service = yield*
|
|
2426
|
+
var listToolAttempts = Effect2.fn("Client.listToolAttempts.call")(function* (input) {
|
|
2427
|
+
const service = yield* Service2;
|
|
2395
2428
|
return yield* service.listToolAttempts(input);
|
|
2396
2429
|
});
|
|
2397
|
-
var submitInboundEnvelope =
|
|
2398
|
-
const service = yield*
|
|
2430
|
+
var submitInboundEnvelope = Effect2.fn("Client.submitInboundEnvelope.call")(function* (input) {
|
|
2431
|
+
const service = yield* Service2;
|
|
2399
2432
|
return yield* service.submitInboundEnvelope(input);
|
|
2400
2433
|
});
|
|
2401
|
-
var spawnChildRun =
|
|
2402
|
-
const service = yield*
|
|
2434
|
+
var spawnChildRun = Effect2.fn("Client.spawnChildRun.call")(function* (input) {
|
|
2435
|
+
const service = yield* Service2;
|
|
2403
2436
|
return yield* service.spawnChildRun(input);
|
|
2404
2437
|
});
|
|
2405
|
-
var createChildFanOut =
|
|
2406
|
-
const service = yield*
|
|
2438
|
+
var createChildFanOut = Effect2.fn("Client.createChildFanOut.call")(function* (input) {
|
|
2439
|
+
const service = yield* Service2;
|
|
2407
2440
|
return yield* service.createChildFanOut(input);
|
|
2408
2441
|
});
|
|
2409
|
-
var cancelChildFanOut =
|
|
2410
|
-
const service = yield*
|
|
2442
|
+
var cancelChildFanOut = Effect2.fn("Client.cancelChildFanOut.call")(function* (input) {
|
|
2443
|
+
const service = yield* Service2;
|
|
2411
2444
|
return yield* service.cancelChildFanOut(input);
|
|
2412
2445
|
});
|
|
2413
|
-
var inspectChildFanOut =
|
|
2414
|
-
const service = yield*
|
|
2446
|
+
var inspectChildFanOut = Effect2.fn("Client.inspectChildFanOut.call")(function* (input) {
|
|
2447
|
+
const service = yield* Service2;
|
|
2415
2448
|
return yield* service.inspectChildFanOut(input);
|
|
2416
2449
|
});
|
|
2417
|
-
var claimEnvelopeReady =
|
|
2418
|
-
const service = yield*
|
|
2450
|
+
var claimEnvelopeReady = Effect2.fn("Client.claimEnvelopeReady.call")(function* (input) {
|
|
2451
|
+
const service = yield* Service2;
|
|
2419
2452
|
return yield* service.claimEnvelopeReady(input);
|
|
2420
2453
|
});
|
|
2421
|
-
var ackEnvelopeReady =
|
|
2422
|
-
const service = yield*
|
|
2454
|
+
var ackEnvelopeReady = Effect2.fn("Client.ackEnvelopeReady.call")(function* (input) {
|
|
2455
|
+
const service = yield* Service2;
|
|
2423
2456
|
return yield* service.ackEnvelopeReady(input);
|
|
2424
2457
|
});
|
|
2425
|
-
var releaseEnvelopeReady =
|
|
2426
|
-
const service = yield*
|
|
2458
|
+
var releaseEnvelopeReady = Effect2.fn("Client.releaseEnvelopeReady.call")(function* (input) {
|
|
2459
|
+
const service = yield* Service2;
|
|
2427
2460
|
return yield* service.releaseEnvelopeReady(input);
|
|
2428
2461
|
});
|
|
2429
|
-
var createSchedule =
|
|
2430
|
-
const service = yield*
|
|
2462
|
+
var createSchedule = Effect2.fn("Client.createSchedule.call")(function* (input) {
|
|
2463
|
+
const service = yield* Service2;
|
|
2431
2464
|
return yield* service.createSchedule(input);
|
|
2432
2465
|
});
|
|
2433
|
-
var cancelSchedule =
|
|
2434
|
-
const service = yield*
|
|
2466
|
+
var cancelSchedule = Effect2.fn("Client.cancelSchedule.call")(function* (input) {
|
|
2467
|
+
const service = yield* Service2;
|
|
2435
2468
|
return yield* service.cancelSchedule(input);
|
|
2436
2469
|
});
|
|
2437
|
-
var listSchedules =
|
|
2438
|
-
const service = yield*
|
|
2470
|
+
var listSchedules = Effect2.fn("Client.listSchedules.call")(function* (input) {
|
|
2471
|
+
const service = yield* Service2;
|
|
2439
2472
|
return yield* service.listSchedules(input);
|
|
2440
2473
|
});
|
|
2441
|
-
var askEntity =
|
|
2442
|
-
const service = yield*
|
|
2474
|
+
var askEntity = Effect2.fn("Client.askEntity.call")(function* (input) {
|
|
2475
|
+
const service = yield* Service2;
|
|
2443
2476
|
return yield* service.askEntity(input);
|
|
2444
2477
|
});
|
|
2445
|
-
var awaitWait =
|
|
2446
|
-
const service = yield*
|
|
2478
|
+
var awaitWait = Effect2.fn("Client.awaitWait.call")(function* (input) {
|
|
2479
|
+
const service = yield* Service2;
|
|
2447
2480
|
return yield* service.awaitWait(input);
|
|
2448
2481
|
});
|
|
2449
2482
|
|
|
2450
|
-
|
|
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 };
|