@relayfx/sdk 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.js +1 -1
- package/dist/http-server.js +1 -1
- package/dist/{index-0jx86sx3.js → index-7mmmxqw7.js} +1 -1
- package/dist/{index-96b7htye.js → index-n5sqnw4s.js} +1178 -1070
- package/dist/{index-fh2ftte9.js → index-q7xzf506.js} +6 -0
- package/dist/{index-c6jave5p.js → index-qa93yf6j.js} +1518 -796
- package/dist/index.js +265 -212
- package/dist/mysql.js +4 -4
- package/dist/postgres.js +6 -5
- package/dist/sqlite.js +4 -4
- package/dist/types/relay/client-public-executions.d.ts +2 -2
- package/dist/types/relay/operation.d.ts +4 -4
- package/dist/types/runtime/agent/agent-loop-error.d.ts +2 -2
- package/dist/types/runtime/agent/relay-compaction.d.ts +4 -0
- package/dist/types/schema/execution-schema.d.ts +8 -2
- package/dist/types/store-sql/prompt-wire.d.ts +4 -0
- package/dist/types/store-sql/session/session-entry-records.d.ts +3 -0
- package/dist/types/store-sql/session/session-repository.d.ts +9 -0
- package/package.json +15 -4
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
exports_model_middleware,
|
|
10
10
|
exports_model_registry,
|
|
11
11
|
exports_model_resilience,
|
|
12
|
+
exports_model_telemetry,
|
|
12
13
|
exports_permissions,
|
|
13
14
|
exports_session,
|
|
14
15
|
exports_skill_source,
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
16
17
|
exports_tool_executor,
|
|
17
18
|
exports_tool_output,
|
|
18
19
|
exports_turn_policy
|
|
19
|
-
} from "./index-
|
|
20
|
+
} from "./index-qa93yf6j.js";
|
|
20
21
|
import {
|
|
21
22
|
ClientError,
|
|
22
23
|
EventLogCursorNotFound,
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
exports_workflow_schema,
|
|
47
48
|
exports_workspace_schema,
|
|
48
49
|
followExecutionFrom
|
|
49
|
-
} from "./index-
|
|
50
|
+
} from "./index-q7xzf506.js";
|
|
50
51
|
import {
|
|
51
52
|
__export
|
|
52
53
|
} from "./index-nb39b5ae.js";
|
|
@@ -298,14 +299,20 @@ var contentToPromptPart = (part) => {
|
|
|
298
299
|
var toAssemblerError = (error) => PromptAssemblerError.make({
|
|
299
300
|
message: error.reason !== undefined ? `${error._tag}: ${error.reason}` : error.message !== undefined ? `${error._tag}: ${error.message}` : error._tag
|
|
300
301
|
});
|
|
301
|
-
var resolveBlobPart = (blobs, part) => blobs.resolve(part).pipe(Effect4.
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
302
|
+
var resolveBlobPart = (blobs, part) => blobs.resolve(part).pipe(Effect4.mapError(toAssemblerError), Effect4.flatMap((resolved) => Effect4.gen(function* () {
|
|
303
|
+
const data = resolved._tag === "Bytes" ? resolved.bytes : yield* Effect4.try({
|
|
304
|
+
try: () => new URL(resolved.url),
|
|
305
|
+
catch: () => PromptAssemblerError.make({ message: "BlobStore resolved an invalid URL" })
|
|
306
|
+
});
|
|
307
|
+
return [
|
|
308
|
+
Prompt.makePart("file", {
|
|
309
|
+
mediaType: resolved.mediaType,
|
|
310
|
+
data,
|
|
311
|
+
...resolved.fileName === undefined ? {} : { fileName: resolved.fileName },
|
|
312
|
+
...part.provider_options === undefined ? {} : { options: part.provider_options }
|
|
313
|
+
})
|
|
314
|
+
];
|
|
315
|
+
})));
|
|
309
316
|
var resolveNestedPart = (blobs, part) => {
|
|
310
317
|
switch (part.type) {
|
|
311
318
|
case "blob-reference":
|
|
@@ -1031,27 +1038,91 @@ __export(exports_agent_chat_repository, {
|
|
|
1031
1038
|
AgentChatRow: () => AgentChatRow,
|
|
1032
1039
|
AgentChatRepositoryError: () => AgentChatRepositoryError
|
|
1033
1040
|
});
|
|
1034
|
-
import { Context as Context13, Effect as Effect14, Layer as Layer13, Schema as
|
|
1041
|
+
import { Context as Context13, Effect as Effect14, Layer as Layer13, Schema as Schema15 } from "effect";
|
|
1042
|
+
import { Prompt as Prompt3 } from "effect/unstable/ai";
|
|
1035
1043
|
import { SqlClient as SqlClient3 } from "effect/unstable/sql/SqlClient";
|
|
1036
|
-
|
|
1037
|
-
|
|
1044
|
+
|
|
1045
|
+
// ../store-sql/src/prompt-wire.ts
|
|
1046
|
+
import { Schema as Schema14 } from "effect";
|
|
1047
|
+
import { Prompt as Prompt2 } from "effect/unstable/ai";
|
|
1048
|
+
var Byte = Schema14.Int.check(Schema14.isBetween({ minimum: 0, maximum: 255 }));
|
|
1049
|
+
var FileDataWire = Schema14.Union([
|
|
1050
|
+
Schema14.TaggedStruct("String", { value: Schema14.String }),
|
|
1051
|
+
Schema14.TaggedStruct("Bytes", { value: Schema14.Array(Byte) }),
|
|
1052
|
+
Schema14.TaggedStruct("Url", { value: Schema14.String })
|
|
1053
|
+
]);
|
|
1054
|
+
var fileDataToWire = (data) => typeof data === "string" ? { _tag: "String", value: data } : data instanceof Uint8Array ? { _tag: "Bytes", value: Array.from(data) } : { _tag: "Url", value: data.toString() };
|
|
1055
|
+
var encodeMessage = (prompt, message, messageIndex) => ({
|
|
1056
|
+
...message,
|
|
1057
|
+
content: Array.isArray(message.content) ? message.content.map((part, partIndex) => {
|
|
1058
|
+
const actualContent = prompt.content[messageIndex]?.content;
|
|
1059
|
+
const actualPart = Array.isArray(actualContent) ? actualContent[partIndex] : undefined;
|
|
1060
|
+
return part.type === "file" && actualPart?.type === "file" ? { ...part, data: fileDataToWire(actualPart.data) } : part;
|
|
1061
|
+
}) : message.content
|
|
1062
|
+
});
|
|
1063
|
+
var encodePrompt = (prompt) => {
|
|
1064
|
+
const encoded = Schema14.encodeSync(Prompt2.Prompt)(prompt);
|
|
1065
|
+
return Schema14.decodeUnknownSync(exports_shared_schema.JsonValue)({
|
|
1066
|
+
content: encoded.content.map((message, messageIndex) => encodeMessage(prompt, message, messageIndex))
|
|
1067
|
+
});
|
|
1068
|
+
};
|
|
1069
|
+
var decodePrompt = (value) => {
|
|
1070
|
+
const content = typeof value === "object" && value !== null && !Array.isArray(value) && "content" in value ? value.content : undefined;
|
|
1071
|
+
const decodedContent = Array.isArray(content) ? content.map((message) => {
|
|
1072
|
+
if (typeof message !== "object" || message === null || Array.isArray(message))
|
|
1073
|
+
return message;
|
|
1074
|
+
const messageContent = message.content;
|
|
1075
|
+
return {
|
|
1076
|
+
...message,
|
|
1077
|
+
content: Array.isArray(messageContent) ? messageContent.map((part) => {
|
|
1078
|
+
if (typeof part !== "object" || part === null || Array.isArray(part) || part.type !== "file") {
|
|
1079
|
+
return part;
|
|
1080
|
+
}
|
|
1081
|
+
const data = Schema14.decodeUnknownSync(FileDataWire)(part.data);
|
|
1082
|
+
return {
|
|
1083
|
+
...part,
|
|
1084
|
+
data: data._tag === "String" ? data.value : data._tag === "Bytes" ? Uint8Array.from(data.value) : new URL(data.value)
|
|
1085
|
+
};
|
|
1086
|
+
}) : messageContent
|
|
1087
|
+
};
|
|
1088
|
+
}) : content;
|
|
1089
|
+
return Schema14.decodeUnknownSync(Prompt2.Prompt)({ content: decodedContent });
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
// ../store-sql/src/chat/agent-chat-repository.ts
|
|
1093
|
+
class AgentChatRepositoryError extends Schema15.TaggedErrorClass()("AgentChatRepositoryError", {
|
|
1094
|
+
message: Schema15.String
|
|
1038
1095
|
}) {
|
|
1039
1096
|
}
|
|
1040
1097
|
|
|
1041
1098
|
class Service15 extends Context13.Service()("@relayfx/store-sql/chat/agent-chat-repository/Service") {
|
|
1042
1099
|
}
|
|
1043
|
-
var AgentChatRow =
|
|
1044
|
-
execution_id:
|
|
1045
|
-
export_json:
|
|
1046
|
-
updated_at:
|
|
1100
|
+
var AgentChatRow = Schema15.Struct({
|
|
1101
|
+
execution_id: Schema15.String,
|
|
1102
|
+
export_json: Schema15.Unknown,
|
|
1103
|
+
updated_at: Schema15.Union([Schema15.Date, Schema15.String, Schema15.Finite])
|
|
1047
1104
|
}).annotate({ identifier: "Relay.AgentChat.Row" });
|
|
1048
|
-
var
|
|
1049
|
-
|
|
1050
|
-
exportData: decodeJson(row.export_json),
|
|
1051
|
-
updatedAt: fromDbTimestamp(row.updated_at)
|
|
1105
|
+
var AgentChatExportWire = Schema15.TaggedStruct("RelayAgentChatExportV1", {
|
|
1106
|
+
prompt: exports_shared_schema.JsonValue
|
|
1052
1107
|
});
|
|
1053
1108
|
var toRepositoryError2 = (error) => AgentChatRepositoryError.make({ message: String(error) });
|
|
1054
|
-
var
|
|
1109
|
+
var encodeExport = (exportData) => {
|
|
1110
|
+
const prompt = Schema15.decodeUnknownSync(Prompt3.Prompt)(exportData);
|
|
1111
|
+
return Schema15.encodeSync(AgentChatExportWire)({ _tag: "RelayAgentChatExportV1", prompt: encodePrompt(prompt) });
|
|
1112
|
+
};
|
|
1113
|
+
var decodeExport = (value) => {
|
|
1114
|
+
const wire = Schema15.decodeUnknownSync(AgentChatExportWire)(decodeJson(value));
|
|
1115
|
+
return Schema15.encodeSync(Prompt3.Prompt)(decodePrompt(wire.prompt));
|
|
1116
|
+
};
|
|
1117
|
+
var toRecord = (row) => Effect14.try({
|
|
1118
|
+
try: () => ({
|
|
1119
|
+
executionId: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
1120
|
+
exportData: decodeExport(row.export_json),
|
|
1121
|
+
updatedAt: fromDbTimestamp(row.updated_at)
|
|
1122
|
+
}),
|
|
1123
|
+
catch: toRepositoryError2
|
|
1124
|
+
});
|
|
1125
|
+
var decodeRow2 = (row) => Schema15.decodeUnknownEffect(AgentChatRow)(row).pipe(Effect14.mapError(toRepositoryError2));
|
|
1055
1126
|
var layer9 = Layer13.effect(Service15, Effect14.gen(function* () {
|
|
1056
1127
|
const sql = yield* SqlClient3;
|
|
1057
1128
|
const selectByKey = (tenantId, executionId) => sql`
|
|
@@ -1060,19 +1131,19 @@ var layer9 = Layer13.effect(Service15, Effect14.gen(function* () {
|
|
|
1060
1131
|
WHERE tenant_id = ${tenantId} AND execution_id = ${executionId}
|
|
1061
1132
|
`;
|
|
1062
1133
|
const upsert2 = sql.onDialectOrElse({
|
|
1063
|
-
mysql: () => (tenantId, input) => sql.withTransaction(Effect14.gen(function* () {
|
|
1134
|
+
mysql: () => (tenantId, input, exportData) => sql.withTransaction(Effect14.gen(function* () {
|
|
1064
1135
|
yield* sql`
|
|
1065
1136
|
INSERT INTO relay_agent_chats (tenant_id, execution_id, export_json, updated_at)
|
|
1066
|
-
VALUES (${tenantId}, ${input.executionId}, ${encodeJson(
|
|
1137
|
+
VALUES (${tenantId}, ${input.executionId}, ${encodeJson(exportData)}, ${timestampParam(sql, input.updatedAt)})
|
|
1067
1138
|
ON DUPLICATE KEY UPDATE
|
|
1068
1139
|
export_json = VALUES(export_json),
|
|
1069
1140
|
updated_at = VALUES(updated_at)
|
|
1070
1141
|
`;
|
|
1071
1142
|
return yield* selectByKey(tenantId, input.executionId);
|
|
1072
1143
|
})),
|
|
1073
|
-
orElse: () => (tenantId, input) => sql`
|
|
1144
|
+
orElse: () => (tenantId, input, exportData) => sql`
|
|
1074
1145
|
INSERT INTO relay_agent_chats (tenant_id, execution_id, export_json, updated_at)
|
|
1075
|
-
VALUES (${tenantId}, ${input.executionId}, ${encodeJson(
|
|
1146
|
+
VALUES (${tenantId}, ${input.executionId}, ${encodeJson(exportData)}, ${timestampParam(sql, input.updatedAt)})
|
|
1076
1147
|
ON CONFLICT (tenant_id, execution_id) DO UPDATE SET
|
|
1077
1148
|
export_json = excluded.export_json,
|
|
1078
1149
|
updated_at = excluded.updated_at
|
|
@@ -1081,34 +1152,43 @@ var layer9 = Layer13.effect(Service15, Effect14.gen(function* () {
|
|
|
1081
1152
|
});
|
|
1082
1153
|
const save = Effect14.fn("AgentChatRepository.save")(function* (input) {
|
|
1083
1154
|
const tenantId = yield* current();
|
|
1084
|
-
const
|
|
1155
|
+
const exportData = yield* Effect14.try({ try: () => encodeExport(input.exportData), catch: toRepositoryError2 });
|
|
1156
|
+
const rows = yield* upsert2(tenantId, input, exportData).pipe(Effect14.mapError(toRepositoryError2));
|
|
1085
1157
|
const row = rows[0];
|
|
1086
1158
|
if (row === undefined) {
|
|
1087
1159
|
return yield* AgentChatRepositoryError.make({ message: "Agent chat upsert returned no row" });
|
|
1088
1160
|
}
|
|
1089
|
-
return toRecord(yield* decodeRow2(row));
|
|
1161
|
+
return yield* toRecord(yield* decodeRow2(row));
|
|
1090
1162
|
});
|
|
1091
1163
|
const get = Effect14.fn("AgentChatRepository.get")(function* (executionId) {
|
|
1092
1164
|
const tenantId = yield* current();
|
|
1093
1165
|
const rows = yield* selectByKey(tenantId, executionId).pipe(Effect14.mapError(toRepositoryError2));
|
|
1094
|
-
return rows[0] === undefined ? undefined : toRecord(yield* decodeRow2(rows[0]));
|
|
1166
|
+
return rows[0] === undefined ? undefined : yield* toRecord(yield* decodeRow2(rows[0]));
|
|
1095
1167
|
});
|
|
1096
1168
|
return Service15.of({ save, get });
|
|
1097
1169
|
}));
|
|
1098
1170
|
var memoryLayer7 = Layer13.sync(Service15, () => {
|
|
1099
1171
|
const chats = new Map;
|
|
1172
|
+
const cloneExport = (exportData) => Effect14.try({
|
|
1173
|
+
try: () => decodeExport(encodeExport(exportData)),
|
|
1174
|
+
catch: toRepositoryError2
|
|
1175
|
+
});
|
|
1100
1176
|
return Service15.of({
|
|
1101
1177
|
save: Effect14.fn("AgentChatRepository.memory.save")(function* (input) {
|
|
1178
|
+
const exportData = yield* cloneExport(input.exportData);
|
|
1102
1179
|
const record = {
|
|
1103
1180
|
executionId: input.executionId,
|
|
1104
|
-
exportData
|
|
1181
|
+
exportData,
|
|
1105
1182
|
updatedAt: input.updatedAt
|
|
1106
1183
|
};
|
|
1107
1184
|
yield* Effect14.sync(() => chats.set(input.executionId, record));
|
|
1108
|
-
return record;
|
|
1185
|
+
return { ...record, exportData: yield* cloneExport(record.exportData) };
|
|
1109
1186
|
}),
|
|
1110
1187
|
get: Effect14.fn("AgentChatRepository.memory.get")(function* (executionId) {
|
|
1111
|
-
|
|
1188
|
+
const record = yield* Effect14.sync(() => chats.get(executionId));
|
|
1189
|
+
if (record === undefined)
|
|
1190
|
+
return;
|
|
1191
|
+
return { ...record, exportData: yield* cloneExport(record.exportData) };
|
|
1112
1192
|
})
|
|
1113
1193
|
});
|
|
1114
1194
|
});
|
|
@@ -1137,32 +1217,32 @@ __export(exports_agent_definition_repository, {
|
|
|
1137
1217
|
AgentDefinitionRevisionRow: () => AgentDefinitionRevisionRow,
|
|
1138
1218
|
AgentDefinitionRepositoryError: () => AgentDefinitionRepositoryError
|
|
1139
1219
|
});
|
|
1140
|
-
import { Context as Context14, Effect as Effect15, Layer as Layer14, Schema as
|
|
1220
|
+
import { Context as Context14, Effect as Effect15, Layer as Layer14, Schema as Schema16 } from "effect";
|
|
1141
1221
|
import { SqlClient as SqlClient4 } from "effect/unstable/sql/SqlClient";
|
|
1142
|
-
class AgentDefinitionRepositoryError extends
|
|
1143
|
-
message:
|
|
1222
|
+
class AgentDefinitionRepositoryError extends Schema16.TaggedErrorClass()("AgentDefinitionRepositoryError", {
|
|
1223
|
+
message: Schema16.String
|
|
1144
1224
|
}) {
|
|
1145
1225
|
}
|
|
1146
1226
|
|
|
1147
1227
|
class Service16 extends Context14.Service()("@relayfx/store-sql/agent/agent-definition-repository/Service") {
|
|
1148
1228
|
}
|
|
1149
|
-
var AgentDefinitionRow =
|
|
1150
|
-
id:
|
|
1151
|
-
current_revision:
|
|
1152
|
-
definition_json:
|
|
1153
|
-
tool_input_schema_digests_json:
|
|
1154
|
-
created_at:
|
|
1155
|
-
updated_at:
|
|
1229
|
+
var AgentDefinitionRow = Schema16.Struct({
|
|
1230
|
+
id: Schema16.String,
|
|
1231
|
+
current_revision: Schema16.Finite,
|
|
1232
|
+
definition_json: Schema16.Unknown,
|
|
1233
|
+
tool_input_schema_digests_json: Schema16.Unknown,
|
|
1234
|
+
created_at: Schema16.Union([Schema16.Date, Schema16.String, Schema16.Finite]),
|
|
1235
|
+
updated_at: Schema16.Union([Schema16.Date, Schema16.String, Schema16.Finite])
|
|
1156
1236
|
}).annotate({ identifier: "Relay.AgentDefinition.Row" });
|
|
1157
|
-
var AgentDefinitionRevisionRow =
|
|
1158
|
-
agent_id:
|
|
1159
|
-
revision:
|
|
1160
|
-
definition_json:
|
|
1161
|
-
tool_input_schema_digests_json:
|
|
1162
|
-
created_at:
|
|
1237
|
+
var AgentDefinitionRevisionRow = Schema16.Struct({
|
|
1238
|
+
agent_id: Schema16.String,
|
|
1239
|
+
revision: Schema16.Finite,
|
|
1240
|
+
definition_json: Schema16.Unknown,
|
|
1241
|
+
tool_input_schema_digests_json: Schema16.Unknown,
|
|
1242
|
+
created_at: Schema16.Union([Schema16.Date, Schema16.String, Schema16.Finite])
|
|
1163
1243
|
}).annotate({ identifier: "Relay.AgentDefinitionRevision.Row" });
|
|
1164
1244
|
var nonEmptyDigests = (digests) => digests === undefined || Object.keys(digests).length === 0 ? undefined : structuredClone(digests);
|
|
1165
|
-
var cloneDefinition = (definition) =>
|
|
1245
|
+
var cloneDefinition = (definition) => Schema16.decodeUnknownSync(exports_agent_schema.Definition)(globalThis.structuredClone(definition));
|
|
1166
1246
|
var rowDigests = (json) => nonEmptyDigests(decodeJson(json));
|
|
1167
1247
|
var toRecord2 = (row) => {
|
|
1168
1248
|
const toolInputSchemaDigests = rowDigests(row.tool_input_schema_digests_json);
|
|
@@ -1201,9 +1281,9 @@ var compareByCreatedAtDesc = (left, right) => {
|
|
|
1201
1281
|
return createdAt === 0 ? left.id.localeCompare(right.id) : createdAt;
|
|
1202
1282
|
};
|
|
1203
1283
|
var toRepositoryError3 = (error) => AgentDefinitionRepositoryError.make({ message: String(error) });
|
|
1204
|
-
var mapPutError = (error) =>
|
|
1205
|
-
var decodeRow3 = (row) =>
|
|
1206
|
-
var decodeRevisionRow = (row) =>
|
|
1284
|
+
var mapPutError = (error) => Schema16.is(AgentDefinitionRepositoryError)(error) ? error : toRepositoryError3(error);
|
|
1285
|
+
var decodeRow3 = (row) => Schema16.decodeUnknownEffect(AgentDefinitionRow)(row).pipe(Effect15.mapError(toRepositoryError3));
|
|
1286
|
+
var decodeRevisionRow = (row) => Schema16.decodeUnknownEffect(AgentDefinitionRevisionRow)(row).pipe(Effect15.mapError(toRepositoryError3));
|
|
1207
1287
|
var layer10 = Layer14.effect(Service16, Effect15.gen(function* () {
|
|
1208
1288
|
const sql = yield* SqlClient4;
|
|
1209
1289
|
const columns = sql.literal(["id", "current_revision", "definition_json", "tool_input_schema_digests_json", "created_at", "updated_at"].join(", "));
|
|
@@ -1407,34 +1487,34 @@ __export(exports_child_execution_repository, {
|
|
|
1407
1487
|
ChildExecutionRepositoryError: () => ChildExecutionRepositoryError,
|
|
1408
1488
|
ChildExecutionNotFound: () => ChildExecutionNotFound
|
|
1409
1489
|
});
|
|
1410
|
-
import { Context as Context15, Effect as Effect16, Layer as Layer15, Predicate, Schema as
|
|
1490
|
+
import { Context as Context15, Effect as Effect16, Layer as Layer15, Predicate, Schema as Schema17 } from "effect";
|
|
1411
1491
|
import { SqlClient as SqlClient5 } from "effect/unstable/sql/SqlClient";
|
|
1412
1492
|
import { isSqlError } from "effect/unstable/sql/SqlError";
|
|
1413
|
-
class ChildExecutionRepositoryError extends
|
|
1414
|
-
message:
|
|
1493
|
+
class ChildExecutionRepositoryError extends Schema17.TaggedErrorClass()("ChildExecutionRepositoryError", {
|
|
1494
|
+
message: Schema17.String
|
|
1415
1495
|
}) {
|
|
1416
1496
|
}
|
|
1417
1497
|
|
|
1418
|
-
class DuplicateChildExecution extends
|
|
1498
|
+
class DuplicateChildExecution extends Schema17.TaggedErrorClass()("DuplicateChildExecution", {
|
|
1419
1499
|
id: exports_ids_schema.ChildExecutionId
|
|
1420
1500
|
}) {
|
|
1421
1501
|
}
|
|
1422
1502
|
|
|
1423
|
-
class ChildExecutionNotFound extends
|
|
1503
|
+
class ChildExecutionNotFound extends Schema17.TaggedErrorClass()("ChildExecutionNotFound", {
|
|
1424
1504
|
id: exports_ids_schema.ChildExecutionId
|
|
1425
1505
|
}) {
|
|
1426
1506
|
}
|
|
1427
1507
|
|
|
1428
1508
|
class Service17 extends Context15.Service()("@relayfx/store-sql/child/child-execution-repository/Service") {
|
|
1429
1509
|
}
|
|
1430
|
-
var ChildExecutionRow =
|
|
1431
|
-
id:
|
|
1432
|
-
execution_id:
|
|
1433
|
-
address_id:
|
|
1434
|
-
status:
|
|
1435
|
-
metadata_json:
|
|
1436
|
-
created_at:
|
|
1437
|
-
updated_at:
|
|
1510
|
+
var ChildExecutionRow = Schema17.Struct({
|
|
1511
|
+
id: Schema17.String,
|
|
1512
|
+
execution_id: Schema17.String,
|
|
1513
|
+
address_id: Schema17.String,
|
|
1514
|
+
status: Schema17.String,
|
|
1515
|
+
metadata_json: Schema17.Unknown,
|
|
1516
|
+
created_at: Schema17.Union([Schema17.Date, Schema17.String, Schema17.Finite]),
|
|
1517
|
+
updated_at: Schema17.Union([Schema17.Date, Schema17.String, Schema17.Finite])
|
|
1438
1518
|
}).annotate({ identifier: "Relay.ChildExecution.Row" });
|
|
1439
1519
|
var metadata2 = (input) => input ?? {};
|
|
1440
1520
|
var toRecord3 = (row) => ({
|
|
@@ -1457,7 +1537,7 @@ var isDuplicateConstraint = (error) => {
|
|
|
1457
1537
|
const cause = error.reason.cause;
|
|
1458
1538
|
return Predicate.hasProperty(cause, "code") && (cause.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || cause.code === 1555) || Predicate.hasProperty(cause, "errno") && cause.errno === 1555;
|
|
1459
1539
|
};
|
|
1460
|
-
var decodeRow4 = (row) =>
|
|
1540
|
+
var decodeRow4 = (row) => Schema17.decodeUnknownEffect(ChildExecutionRow)(row).pipe(Effect16.mapError(toRepositoryError4));
|
|
1461
1541
|
var layer11 = Layer15.effect(Service17, Effect16.gen(function* () {
|
|
1462
1542
|
const sql = yield* SqlClient5;
|
|
1463
1543
|
const columns = sql.literal(["id", "execution_id", "address_id", "status", "metadata_json", "created_at", "updated_at"].join(", "));
|
|
@@ -1614,35 +1694,35 @@ __export(exports_child_fan_out_repository, {
|
|
|
1614
1694
|
ChildFanOutRepositoryError: () => ChildFanOutRepositoryError,
|
|
1615
1695
|
ChildFanOutConflict: () => ChildFanOutConflict
|
|
1616
1696
|
});
|
|
1617
|
-
import { Context as Context16, Effect as Effect17, Layer as Layer16, Schema as
|
|
1697
|
+
import { Context as Context16, Effect as Effect17, Layer as Layer16, Schema as Schema18, Semaphore } from "effect";
|
|
1618
1698
|
import { SqlClient as SqlClient6 } from "effect/unstable/sql/SqlClient";
|
|
1619
|
-
class ChildFanOutRepositoryError extends
|
|
1699
|
+
class ChildFanOutRepositoryError extends Schema18.TaggedErrorClass()("ChildFanOutRepositoryError", { message: Schema18.String }) {
|
|
1620
1700
|
}
|
|
1621
1701
|
|
|
1622
|
-
class ChildFanOutConflict extends
|
|
1702
|
+
class ChildFanOutConflict extends Schema18.TaggedErrorClass()("ChildFanOutConflict", {
|
|
1623
1703
|
fan_out_id: exports_ids_schema.ChildFanOutId
|
|
1624
1704
|
}) {
|
|
1625
1705
|
}
|
|
1626
1706
|
|
|
1627
1707
|
class Service18 extends Context16.Service()("@relayfx/store-sql/child/child-fan-out-repository/Service") {
|
|
1628
1708
|
}
|
|
1629
|
-
var FanOutRow =
|
|
1630
|
-
definition_json:
|
|
1709
|
+
var FanOutRow = Schema18.Struct({
|
|
1710
|
+
definition_json: Schema18.Unknown,
|
|
1631
1711
|
state: exports_child_orchestration_schema.AggregateState,
|
|
1632
|
-
satisfied_at:
|
|
1633
|
-
failed_at:
|
|
1634
|
-
cancelled_at:
|
|
1712
|
+
satisfied_at: Schema18.NullOr(Schema18.Union([Schema18.Date, Schema18.String, Schema18.Finite])),
|
|
1713
|
+
failed_at: Schema18.NullOr(Schema18.Union([Schema18.Date, Schema18.String, Schema18.Finite])),
|
|
1714
|
+
cancelled_at: Schema18.NullOr(Schema18.Union([Schema18.Date, Schema18.String, Schema18.Finite]))
|
|
1635
1715
|
});
|
|
1636
|
-
var MemberRow =
|
|
1637
|
-
child_execution_id:
|
|
1638
|
-
ordinal:
|
|
1716
|
+
var MemberRow = Schema18.Struct({
|
|
1717
|
+
child_execution_id: Schema18.String,
|
|
1718
|
+
ordinal: Schema18.Finite,
|
|
1639
1719
|
state: exports_child_orchestration_schema.MemberState,
|
|
1640
|
-
output_json:
|
|
1641
|
-
error:
|
|
1642
|
-
completed_at:
|
|
1720
|
+
output_json: Schema18.NullOr(Schema18.Unknown),
|
|
1721
|
+
error: Schema18.NullOr(Schema18.String),
|
|
1722
|
+
completed_at: Schema18.NullOr(Schema18.Union([Schema18.Date, Schema18.String, Schema18.Finite]))
|
|
1643
1723
|
});
|
|
1644
1724
|
var repositoryError = (error) => ChildFanOutRepositoryError.make({ message: String(error) });
|
|
1645
|
-
var cloneDefinition2 = (value) =>
|
|
1725
|
+
var cloneDefinition2 = (value) => Schema18.decodeUnknownSync(exports_child_orchestration_schema.FanOutDefinition)(globalThis.structuredClone(value));
|
|
1646
1726
|
var sameDefinition = (left, right) => exports_shared_schema.canonicalEquals(left, right);
|
|
1647
1727
|
var terminal = (state) => state === "completed" || state === "failed" || state === "cancelled";
|
|
1648
1728
|
var foldState = (state) => {
|
|
@@ -1685,9 +1765,9 @@ var layer12 = Layer16.effect(Service18, Effect17.gen(function* () {
|
|
|
1685
1765
|
const rows = yield* sql`SELECT definition_json, state, satisfied_at, failed_at, cancelled_at FROM relay_child_fan_outs WHERE tenant_id = ${tenantId} AND id = ${id}`;
|
|
1686
1766
|
if (rows[0] === undefined)
|
|
1687
1767
|
return;
|
|
1688
|
-
const row = yield*
|
|
1768
|
+
const row = yield* Schema18.decodeUnknownEffect(FanOutRow)(rows[0]);
|
|
1689
1769
|
const memberRows = yield* sql`SELECT child_execution_id, ordinal, state, output_json, error, completed_at FROM relay_child_fan_out_members WHERE tenant_id = ${tenantId} AND fan_out_id = ${id} ORDER BY ordinal ASC`;
|
|
1690
|
-
const decodedMembers = yield* Effect17.forEach(memberRows, (member) =>
|
|
1770
|
+
const decodedMembers = yield* Effect17.forEach(memberRows, (member) => Schema18.decodeUnknownEffect(MemberRow)(member));
|
|
1691
1771
|
const definition = cloneDefinition2(decodeJson(row.definition_json));
|
|
1692
1772
|
return {
|
|
1693
1773
|
...definition,
|
|
@@ -1937,23 +2017,23 @@ __export(exports_cluster_registry_repository, {
|
|
|
1937
2017
|
LockRow: () => LockRow,
|
|
1938
2018
|
ClusterRegistryError: () => ClusterRegistryError
|
|
1939
2019
|
});
|
|
1940
|
-
import { Context as Context17, Effect as Effect18, Layer as Layer17, Schema as
|
|
2020
|
+
import { Context as Context17, Effect as Effect18, Layer as Layer17, Schema as Schema19 } from "effect";
|
|
1941
2021
|
import { SqlClient as SqlClient7 } from "effect/unstable/sql/SqlClient";
|
|
1942
|
-
class ClusterRegistryError extends
|
|
1943
|
-
message:
|
|
2022
|
+
class ClusterRegistryError extends Schema19.TaggedErrorClass()("ClusterRegistryError", {
|
|
2023
|
+
message: Schema19.String
|
|
1944
2024
|
}) {
|
|
1945
2025
|
}
|
|
1946
2026
|
|
|
1947
2027
|
class Service19 extends Context17.Service()("@relayfx/store-sql/cluster/cluster-registry-repository/Service") {
|
|
1948
2028
|
}
|
|
1949
|
-
var RunnerRow =
|
|
1950
|
-
address:
|
|
1951
|
-
healthy:
|
|
1952
|
-
last_heartbeat:
|
|
1953
|
-
owned_shards:
|
|
2029
|
+
var RunnerRow = Schema19.Struct({
|
|
2030
|
+
address: Schema19.String,
|
|
2031
|
+
healthy: Schema19.Union([Schema19.Boolean, Schema19.Finite, Schema19.String]),
|
|
2032
|
+
last_heartbeat: Schema19.Union([Schema19.Date, Schema19.String, Schema19.Finite]),
|
|
2033
|
+
owned_shards: Schema19.Union([Schema19.Finite, Schema19.String, Schema19.BigInt])
|
|
1954
2034
|
}).annotate({ identifier: "Relay.ClusterRegistry.RunnerRow" });
|
|
1955
|
-
var LockRow =
|
|
1956
|
-
address:
|
|
2035
|
+
var LockRow = Schema19.Struct({
|
|
2036
|
+
address: Schema19.String
|
|
1957
2037
|
}).annotate({ identifier: "Relay.ClusterRegistry.LockRow" });
|
|
1958
2038
|
var toRunnerRecord = (row) => ({
|
|
1959
2039
|
address: row.address,
|
|
@@ -1962,8 +2042,8 @@ var toRunnerRecord = (row) => ({
|
|
|
1962
2042
|
ownedShards: Number(row.owned_shards)
|
|
1963
2043
|
});
|
|
1964
2044
|
var toRegistryError = (error) => ClusterRegistryError.make({ message: String(error) });
|
|
1965
|
-
var decodeRunnerRow = (row) =>
|
|
1966
|
-
var decodeLockRow = (row) =>
|
|
2045
|
+
var decodeRunnerRow = (row) => Schema19.decodeUnknownEffect(RunnerRow)(row).pipe(Effect18.mapError(toRegistryError));
|
|
2046
|
+
var decodeLockRow = (row) => Schema19.decodeUnknownEffect(LockRow)(row).pipe(Effect18.mapError(toRegistryError));
|
|
1967
2047
|
var layer13 = Layer17.effect(Service19, Effect18.gen(function* () {
|
|
1968
2048
|
const sql = yield* SqlClient7;
|
|
1969
2049
|
const selectRunners = () => sql`
|
|
@@ -2010,22 +2090,22 @@ __export(exports_compaction_repository, {
|
|
|
2010
2090
|
CompactionRepositoryError: () => CompactionRepositoryError,
|
|
2011
2091
|
CompactionCheckpointRow: () => CompactionCheckpointRow
|
|
2012
2092
|
});
|
|
2013
|
-
import { Context as Context18, Effect as Effect19, Layer as Layer18, Schema as
|
|
2093
|
+
import { Context as Context18, Effect as Effect19, Layer as Layer18, Schema as Schema20 } from "effect";
|
|
2014
2094
|
import { SqlClient as SqlClient8 } from "effect/unstable/sql/SqlClient";
|
|
2015
|
-
class CompactionRepositoryError extends
|
|
2016
|
-
message:
|
|
2095
|
+
class CompactionRepositoryError extends Schema20.TaggedErrorClass()("CompactionRepositoryError", {
|
|
2096
|
+
message: Schema20.String
|
|
2017
2097
|
}) {
|
|
2018
2098
|
}
|
|
2019
2099
|
|
|
2020
2100
|
class Service20 extends Context18.Service()("@relayfx/store-sql/compaction/compaction-repository/Service") {
|
|
2021
2101
|
}
|
|
2022
|
-
var CompactionCheckpointRow =
|
|
2023
|
-
execution_id:
|
|
2024
|
-
checkpoint_id:
|
|
2025
|
-
summary:
|
|
2026
|
-
first_kept_entry_id:
|
|
2027
|
-
turn:
|
|
2028
|
-
created_at:
|
|
2102
|
+
var CompactionCheckpointRow = Schema20.Struct({
|
|
2103
|
+
execution_id: Schema20.String,
|
|
2104
|
+
checkpoint_id: Schema20.String,
|
|
2105
|
+
summary: Schema20.String,
|
|
2106
|
+
first_kept_entry_id: Schema20.String,
|
|
2107
|
+
turn: Schema20.Finite,
|
|
2108
|
+
created_at: Schema20.Union([Schema20.Date, Schema20.String, Schema20.Finite])
|
|
2029
2109
|
}).annotate({ identifier: "Relay.CompactionCheckpoint.Row" });
|
|
2030
2110
|
var toRecord4 = (row) => ({
|
|
2031
2111
|
executionId: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
@@ -2036,7 +2116,7 @@ var toRecord4 = (row) => ({
|
|
|
2036
2116
|
createdAt: fromDbTimestamp(row.created_at)
|
|
2037
2117
|
});
|
|
2038
2118
|
var toRepositoryError5 = (error) => CompactionRepositoryError.make({ message: String(error) });
|
|
2039
|
-
var decodeRow5 = (row) =>
|
|
2119
|
+
var decodeRow5 = (row) => Schema20.decodeUnknownEffect(CompactionCheckpointRow)(row).pipe(Effect19.mapError(toRepositoryError5));
|
|
2040
2120
|
var key = (input) => `${input.executionId}:${input.checkpointId}`;
|
|
2041
2121
|
var sameCheckpoint = (record, input) => record.summary === input.summary && record.firstKeptEntryId === input.firstKeptEntryId && record.turn === input.turn;
|
|
2042
2122
|
var conflict = (input) => CompactionRepositoryError.make({
|
|
@@ -2160,20 +2240,20 @@ __export(exports_context_epoch_repository, {
|
|
|
2160
2240
|
ContextEpochRow: () => ContextEpochRow,
|
|
2161
2241
|
ContextEpochRepositoryError: () => ContextEpochRepositoryError
|
|
2162
2242
|
});
|
|
2163
|
-
import { Context as Context19, Effect as Effect20, Layer as Layer19, Schema as
|
|
2243
|
+
import { Context as Context19, Effect as Effect20, Layer as Layer19, Schema as Schema21 } from "effect";
|
|
2164
2244
|
import { SqlClient as SqlClient9 } from "effect/unstable/sql/SqlClient";
|
|
2165
|
-
class ContextEpochRepositoryError extends
|
|
2166
|
-
message:
|
|
2245
|
+
class ContextEpochRepositoryError extends Schema21.TaggedErrorClass()("ContextEpochRepositoryError", {
|
|
2246
|
+
message: Schema21.String
|
|
2167
2247
|
}) {
|
|
2168
2248
|
}
|
|
2169
2249
|
|
|
2170
2250
|
class Service21 extends Context19.Service()("@relayfx/store-sql/session/context-epoch-repository/Service") {
|
|
2171
2251
|
}
|
|
2172
|
-
var ContextEpochRow =
|
|
2173
|
-
execution_id:
|
|
2174
|
-
baseline:
|
|
2175
|
-
dynamic_source_ids_json:
|
|
2176
|
-
opened_at:
|
|
2252
|
+
var ContextEpochRow = Schema21.Struct({
|
|
2253
|
+
execution_id: Schema21.String,
|
|
2254
|
+
baseline: Schema21.String,
|
|
2255
|
+
dynamic_source_ids_json: Schema21.Unknown,
|
|
2256
|
+
opened_at: Schema21.Union([Schema21.Date, Schema21.String, Schema21.Finite])
|
|
2177
2257
|
}).annotate({ identifier: "Relay.ContextEpoch.Row" });
|
|
2178
2258
|
var toRecord5 = (row) => ({
|
|
2179
2259
|
executionId: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
@@ -2182,7 +2262,7 @@ var toRecord5 = (row) => ({
|
|
|
2182
2262
|
openedAt: fromDbTimestamp(row.opened_at)
|
|
2183
2263
|
});
|
|
2184
2264
|
var toRepositoryError6 = (error) => ContextEpochRepositoryError.make({ message: String(error) });
|
|
2185
|
-
var decodeRow6 = (row) =>
|
|
2265
|
+
var decodeRow6 = (row) => Schema21.decodeUnknownEffect(ContextEpochRow)(row).pipe(Effect20.mapError(toRepositoryError6));
|
|
2186
2266
|
var sameEpoch = (record2, input) => record2.baseline === input.baseline && exports_shared_schema.canonicalEquals(record2.dynamicSourceIds, input.dynamicSourceIds);
|
|
2187
2267
|
var conflict2 = (executionId) => ContextEpochRepositoryError.make({ message: `Context epoch already exists with different payload: ${executionId}` });
|
|
2188
2268
|
var cloneRecord3 = (record2) => structuredClone(record2);
|
|
@@ -2296,30 +2376,30 @@ __export(exports_envelope_repository, {
|
|
|
2296
2376
|
EnvelopeReadyClaimMismatch: () => EnvelopeReadyClaimMismatch,
|
|
2297
2377
|
EnvelopeNotFound: () => EnvelopeNotFound
|
|
2298
2378
|
});
|
|
2299
|
-
import { Context as Context20, Effect as Effect24, Layer as Layer20, Schema as
|
|
2379
|
+
import { Context as Context20, Effect as Effect24, Layer as Layer20, Schema as Schema25 } from "effect";
|
|
2300
2380
|
|
|
2301
2381
|
// ../store-sql/src/envelope/envelope-records.ts
|
|
2302
|
-
import { Effect as Effect23, Schema as
|
|
2382
|
+
import { Effect as Effect23, Schema as Schema24 } from "effect";
|
|
2303
2383
|
import { SqlClient as SqlClient10 } from "effect/unstable/sql/SqlClient";
|
|
2304
2384
|
|
|
2305
2385
|
// ../store-sql/src/envelope/envelope-ready-records.ts
|
|
2306
|
-
import { Effect as Effect21, Schema as
|
|
2307
|
-
var DbTimestamp =
|
|
2308
|
-
var NullableDbTimestamp =
|
|
2309
|
-
var NullableString =
|
|
2310
|
-
var envelopeReadyRow =
|
|
2311
|
-
id:
|
|
2312
|
-
envelope_id:
|
|
2313
|
-
route_type:
|
|
2314
|
-
route_key:
|
|
2315
|
-
state:
|
|
2386
|
+
import { Effect as Effect21, Schema as Schema22 } from "effect";
|
|
2387
|
+
var DbTimestamp = Schema22.Union([Schema22.Date, Schema22.String, Schema22.Finite]);
|
|
2388
|
+
var NullableDbTimestamp = Schema22.Union([Schema22.Date, Schema22.String, Schema22.Finite, Schema22.Null]);
|
|
2389
|
+
var NullableString = Schema22.Union([Schema22.String, Schema22.Null]);
|
|
2390
|
+
var envelopeReadyRow = Schema22.Struct({
|
|
2391
|
+
id: Schema22.String,
|
|
2392
|
+
envelope_id: Schema22.String,
|
|
2393
|
+
route_type: Schema22.String,
|
|
2394
|
+
route_key: Schema22.String,
|
|
2395
|
+
state: Schema22.String,
|
|
2316
2396
|
available_at: DbTimestamp,
|
|
2317
|
-
attempt:
|
|
2397
|
+
attempt: Schema22.Finite,
|
|
2318
2398
|
claim_owner: NullableString,
|
|
2319
2399
|
claim_expires_at: NullableDbTimestamp,
|
|
2320
2400
|
last_error: NullableString,
|
|
2321
2401
|
idempotency_key: NullableString,
|
|
2322
|
-
metadata_json:
|
|
2402
|
+
metadata_json: Schema22.Unknown,
|
|
2323
2403
|
created_at: DbTimestamp,
|
|
2324
2404
|
updated_at: DbTimestamp,
|
|
2325
2405
|
claimed_at: NullableDbTimestamp,
|
|
@@ -2352,7 +2432,7 @@ var toReadyRecord = (row) => {
|
|
|
2352
2432
|
var makeEnvelopeReadyRecordOperations = ({ sql, ts, errors }) => {
|
|
2353
2433
|
const { EnvelopeRepositoryError, EnvelopeReadyNotFound, EnvelopeReadyClaimMismatch } = errors;
|
|
2354
2434
|
const toRepositoryError7 = (error) => EnvelopeRepositoryError.make({ message: String(error) });
|
|
2355
|
-
const decodeReadyRow = (row) =>
|
|
2435
|
+
const decodeReadyRow = (row) => Schema22.decodeUnknownEffect(envelopeReadyRow)(row).pipe(Effect21.mapError(toRepositoryError7));
|
|
2356
2436
|
const readyColumns = sql.literal("id, envelope_id, route_type, route_key, state, available_at, attempt, claim_owner, claim_expires_at, last_error, idempotency_key, metadata_json, created_at, updated_at, claimed_at, acknowledged_at");
|
|
2357
2437
|
const selectReadyById = (tenantId, id) => sql`
|
|
2358
2438
|
SELECT ${readyColumns}
|
|
@@ -2525,18 +2605,18 @@ var makeEnvelopeReadyRecordOperations = ({ sql, ts, errors }) => {
|
|
|
2525
2605
|
};
|
|
2526
2606
|
|
|
2527
2607
|
// ../store-sql/src/envelope/wait-records.ts
|
|
2528
|
-
import { Effect as Effect22, Schema as
|
|
2529
|
-
var DbTimestamp2 =
|
|
2530
|
-
var NullableDbTimestamp2 =
|
|
2531
|
-
var NullableString2 =
|
|
2532
|
-
var waitRow =
|
|
2533
|
-
id:
|
|
2534
|
-
execution_id:
|
|
2608
|
+
import { Effect as Effect22, Schema as Schema23 } from "effect";
|
|
2609
|
+
var DbTimestamp2 = Schema23.Union([Schema23.Date, Schema23.String, Schema23.Finite]);
|
|
2610
|
+
var NullableDbTimestamp2 = Schema23.Union([Schema23.Date, Schema23.String, Schema23.Finite, Schema23.Null]);
|
|
2611
|
+
var NullableString2 = Schema23.Union([Schema23.String, Schema23.Null]);
|
|
2612
|
+
var waitRow = Schema23.Struct({
|
|
2613
|
+
id: Schema23.String,
|
|
2614
|
+
execution_id: Schema23.String,
|
|
2535
2615
|
envelope_id: NullableString2,
|
|
2536
|
-
mode:
|
|
2616
|
+
mode: Schema23.String,
|
|
2537
2617
|
correlation_key: NullableString2,
|
|
2538
|
-
state:
|
|
2539
|
-
metadata_json:
|
|
2618
|
+
state: Schema23.String,
|
|
2619
|
+
metadata_json: Schema23.Unknown,
|
|
2540
2620
|
created_at: DbTimestamp2,
|
|
2541
2621
|
resolved_at: NullableDbTimestamp2
|
|
2542
2622
|
}).annotate({ identifier: "Relay.Wait.Row" });
|
|
@@ -2564,7 +2644,7 @@ var waitRecordOrdering = { compareWaitsDesc };
|
|
|
2564
2644
|
var makeWaitRecordOperations = ({ sql, ts, errors }) => {
|
|
2565
2645
|
const { EnvelopeRepositoryError, WaitNotFound } = errors;
|
|
2566
2646
|
const toRepositoryError7 = (error) => EnvelopeRepositoryError.make({ message: String(error) });
|
|
2567
|
-
const decodeWaitRow = (row) =>
|
|
2647
|
+
const decodeWaitRow = (row) => Schema23.decodeUnknownEffect(waitRow)(row).pipe(Effect22.mapError(toRepositoryError7));
|
|
2568
2648
|
const waitColumns = sql.literal("id, execution_id, envelope_id, mode, correlation_key, state, metadata_json, created_at, resolved_at");
|
|
2569
2649
|
const selectWaitById = (tenantId, id) => sql`
|
|
2570
2650
|
SELECT ${waitColumns}
|
|
@@ -2705,17 +2785,17 @@ var makeWaitRecordOperations = ({ sql, ts, errors }) => {
|
|
|
2705
2785
|
};
|
|
2706
2786
|
|
|
2707
2787
|
// ../store-sql/src/envelope/envelope-records.ts
|
|
2708
|
-
var DbTimestamp3 =
|
|
2709
|
-
var NullableString3 =
|
|
2710
|
-
var envelopeRow =
|
|
2711
|
-
id:
|
|
2712
|
-
execution_id:
|
|
2713
|
-
from_address_id:
|
|
2714
|
-
to_address_id:
|
|
2715
|
-
content_json:
|
|
2716
|
-
wait_json:
|
|
2788
|
+
var DbTimestamp3 = Schema24.Union([Schema24.Date, Schema24.String, Schema24.Finite]);
|
|
2789
|
+
var NullableString3 = Schema24.Union([Schema24.String, Schema24.Null]);
|
|
2790
|
+
var envelopeRow = Schema24.Struct({
|
|
2791
|
+
id: Schema24.String,
|
|
2792
|
+
execution_id: Schema24.String,
|
|
2793
|
+
from_address_id: Schema24.String,
|
|
2794
|
+
to_address_id: Schema24.String,
|
|
2795
|
+
content_json: Schema24.Unknown,
|
|
2796
|
+
wait_json: Schema24.Unknown,
|
|
2717
2797
|
correlation_key: NullableString3,
|
|
2718
|
-
metadata_json:
|
|
2798
|
+
metadata_json: Schema24.Unknown,
|
|
2719
2799
|
created_at: DbTimestamp3
|
|
2720
2800
|
}).annotate({ identifier: "Relay.Envelope.Row" });
|
|
2721
2801
|
var decodeMetadata3 = (value) => decodeJson(value);
|
|
@@ -2744,7 +2824,7 @@ var makeEnvelopeRepository = (errors) => Effect23.gen(function* () {
|
|
|
2744
2824
|
const toRepositoryError7 = (error) => EnvelopeRepositoryError.make({ message: String(error) });
|
|
2745
2825
|
const ts = (millis) => timestampParam(sql, millis);
|
|
2746
2826
|
const envelopeColumns = sql.literal("id, execution_id, from_address_id, to_address_id, content_json, wait_json, correlation_key, metadata_json, created_at");
|
|
2747
|
-
const decodeEnvelopeRow = (row) =>
|
|
2827
|
+
const decodeEnvelopeRow = (row) => Schema24.decodeUnknownEffect(envelopeRow)(row).pipe(Effect23.mapError(toRepositoryError7));
|
|
2748
2828
|
const acceptEnvelope = Effect23.fn("EnvelopeRepository.acceptEnvelope")(function* (input) {
|
|
2749
2829
|
const tenantId = yield* current();
|
|
2750
2830
|
const envelope = input.envelope;
|
|
@@ -2804,36 +2884,36 @@ var makeEnvelopeRepository = (errors) => Effect23.gen(function* () {
|
|
|
2804
2884
|
});
|
|
2805
2885
|
|
|
2806
2886
|
// ../store-sql/src/envelope/envelope-repository.ts
|
|
2807
|
-
var WaitState =
|
|
2887
|
+
var WaitState = Schema25.Literals(["open", "resolved", "timed_out", "cancelled"]).annotate({
|
|
2808
2888
|
identifier: "Relay.Store.WaitState"
|
|
2809
2889
|
});
|
|
2810
|
-
var EnvelopeReadyState =
|
|
2890
|
+
var EnvelopeReadyState = Schema25.Literals(["ready", "claimed", "acknowledged"]).annotate({
|
|
2811
2891
|
identifier: "Relay.Store.EnvelopeReadyState"
|
|
2812
2892
|
});
|
|
2813
2893
|
|
|
2814
|
-
class EnvelopeRepositoryError extends
|
|
2815
|
-
message:
|
|
2894
|
+
class EnvelopeRepositoryError extends Schema25.TaggedErrorClass()("EnvelopeRepositoryError", {
|
|
2895
|
+
message: Schema25.String
|
|
2816
2896
|
}) {
|
|
2817
2897
|
}
|
|
2818
2898
|
|
|
2819
|
-
class EnvelopeNotFound extends
|
|
2899
|
+
class EnvelopeNotFound extends Schema25.TaggedErrorClass()("EnvelopeNotFound", {
|
|
2820
2900
|
id: exports_ids_schema.EnvelopeId
|
|
2821
2901
|
}) {
|
|
2822
2902
|
}
|
|
2823
2903
|
|
|
2824
|
-
class WaitNotFound extends
|
|
2904
|
+
class WaitNotFound extends Schema25.TaggedErrorClass()("WaitNotFound", {
|
|
2825
2905
|
id: exports_ids_schema.WaitId
|
|
2826
2906
|
}) {
|
|
2827
2907
|
}
|
|
2828
2908
|
|
|
2829
|
-
class EnvelopeReadyNotFound extends
|
|
2909
|
+
class EnvelopeReadyNotFound extends Schema25.TaggedErrorClass()("EnvelopeReadyNotFound", {
|
|
2830
2910
|
id: exports_ids_schema.EnvelopeReadyId
|
|
2831
2911
|
}) {
|
|
2832
2912
|
}
|
|
2833
2913
|
|
|
2834
|
-
class EnvelopeReadyClaimMismatch extends
|
|
2914
|
+
class EnvelopeReadyClaimMismatch extends Schema25.TaggedErrorClass()("EnvelopeReadyClaimMismatch", {
|
|
2835
2915
|
id: exports_ids_schema.EnvelopeReadyId,
|
|
2836
|
-
worker_id:
|
|
2916
|
+
worker_id: Schema25.String
|
|
2837
2917
|
}) {
|
|
2838
2918
|
}
|
|
2839
2919
|
|
|
@@ -3052,35 +3132,35 @@ __export(exports_resident_repository, {
|
|
|
3052
3132
|
Service: () => Service23,
|
|
3053
3133
|
ResidentRepositoryError: () => ResidentRepositoryError
|
|
3054
3134
|
});
|
|
3055
|
-
import { Clock as Clock2, Context as Context21, Effect as Effect25, Layer as Layer21, Ref as Ref4, Schema as
|
|
3135
|
+
import { Clock as Clock2, Context as Context21, Effect as Effect25, Layer as Layer21, Ref as Ref4, Schema as Schema26, SchemaGetter } from "effect";
|
|
3056
3136
|
import { SqlClient as SqlClient11 } from "effect/unstable/sql/SqlClient";
|
|
3057
|
-
class ResidentRepositoryError extends
|
|
3058
|
-
message:
|
|
3137
|
+
class ResidentRepositoryError extends Schema26.TaggedErrorClass()("ResidentRepositoryError", {
|
|
3138
|
+
message: Schema26.String
|
|
3059
3139
|
}) {
|
|
3060
3140
|
}
|
|
3061
3141
|
|
|
3062
3142
|
class Service23 extends Context21.Service()("@relayfx/store-sql/resident/resident-repository/Service") {
|
|
3063
3143
|
}
|
|
3064
|
-
var KindRow =
|
|
3065
|
-
kind:
|
|
3066
|
-
agent_id:
|
|
3067
|
-
inbox_policy_json:
|
|
3068
|
-
state_enabled:
|
|
3144
|
+
var KindRow = Schema26.Struct({
|
|
3145
|
+
kind: Schema26.String,
|
|
3146
|
+
agent_id: Schema26.String,
|
|
3147
|
+
inbox_policy_json: Schema26.Unknown,
|
|
3148
|
+
state_enabled: Schema26.NullOr(Schema26.Union([Schema26.Boolean, Schema26.Finite])).pipe(Schema26.decodeTo(Schema26.NullOr(Schema26.Boolean), {
|
|
3069
3149
|
decode: SchemaGetter.transform((value) => value === null ? null : value === true || value === 1),
|
|
3070
3150
|
encode: SchemaGetter.transform((value) => value === null ? null : value ? 1 : 0)
|
|
3071
3151
|
})),
|
|
3072
|
-
continue_as_new_after_turns:
|
|
3073
|
-
metadata_json:
|
|
3074
|
-
});
|
|
3075
|
-
var InstanceRow =
|
|
3076
|
-
kind:
|
|
3077
|
-
key:
|
|
3078
|
-
address_id:
|
|
3079
|
-
execution_id:
|
|
3080
|
-
generation:
|
|
3081
|
-
status:
|
|
3082
|
-
created_at:
|
|
3083
|
-
destroyed_at:
|
|
3152
|
+
continue_as_new_after_turns: Schema26.NullOr(Schema26.Finite),
|
|
3153
|
+
metadata_json: Schema26.Unknown
|
|
3154
|
+
});
|
|
3155
|
+
var InstanceRow = Schema26.Struct({
|
|
3156
|
+
kind: Schema26.String,
|
|
3157
|
+
key: Schema26.String,
|
|
3158
|
+
address_id: Schema26.String,
|
|
3159
|
+
execution_id: Schema26.String,
|
|
3160
|
+
generation: Schema26.Finite,
|
|
3161
|
+
status: Schema26.String,
|
|
3162
|
+
created_at: Schema26.Union([Schema26.Date, Schema26.String, Schema26.Finite]),
|
|
3163
|
+
destroyed_at: Schema26.NullOr(Schema26.Union([Schema26.Date, Schema26.String, Schema26.Finite]))
|
|
3084
3164
|
});
|
|
3085
3165
|
var repositoryError2 = (error) => ResidentRepositoryError.make({ message: String(error) });
|
|
3086
3166
|
var toKind = (row) => ({
|
|
@@ -3101,8 +3181,8 @@ var toInstance = (row) => ({
|
|
|
3101
3181
|
created_at: fromDbTimestamp(row.created_at),
|
|
3102
3182
|
...row.destroyed_at === null ? {} : { destroyed_at: fromDbTimestamp(row.destroyed_at) }
|
|
3103
3183
|
});
|
|
3104
|
-
var decodeKind = (row) =>
|
|
3105
|
-
var decodeInstance = (row) =>
|
|
3184
|
+
var decodeKind = (row) => Schema26.decodeUnknownEffect(KindRow)(row).pipe(Effect25.map(toKind), Effect25.mapError(repositoryError2));
|
|
3185
|
+
var decodeInstance = (row) => Schema26.decodeUnknownEffect(InstanceRow)(row).pipe(Effect25.map(toInstance), Effect25.mapError(repositoryError2));
|
|
3106
3186
|
var layer17 = Layer21.effect(Service23, Effect25.gen(function* () {
|
|
3107
3187
|
const sql = yield* SqlClient11;
|
|
3108
3188
|
const getKind = Effect25.fn("ResidentRepository.getKind")(function* (kind) {
|
|
@@ -3264,7 +3344,7 @@ __export(exports_execution_event_repository, {
|
|
|
3264
3344
|
ExecutionEventCursorNotFound: () => ExecutionEventCursorNotFound,
|
|
3265
3345
|
DuplicateExecutionEvent: () => DuplicateExecutionEvent
|
|
3266
3346
|
});
|
|
3267
|
-
import { Context as Context23, Effect as Effect29, Layer as Layer25, Schema as
|
|
3347
|
+
import { Context as Context23, Effect as Effect29, Layer as Layer25, Schema as Schema28, Stream as Stream4 } from "effect";
|
|
3268
3348
|
|
|
3269
3349
|
// ../store-sql/src/database/notification-bus.ts
|
|
3270
3350
|
var exports_notification_bus = {};
|
|
@@ -3458,7 +3538,7 @@ var makeMemoryLayer = (repository) => {
|
|
|
3458
3538
|
};
|
|
3459
3539
|
|
|
3460
3540
|
// ../store-sql/src/execution/execution-event-repository-sql.ts
|
|
3461
|
-
import { Effect as Effect28, Filter, Layer as Layer24, Option as Option3, Schema as
|
|
3541
|
+
import { Effect as Effect28, Filter, Layer as Layer24, Option as Option3, Schema as Schema27, Stream as Stream3 } from "effect";
|
|
3462
3542
|
import { SqlClient as SqlClient13 } from "effect/unstable/sql/SqlClient";
|
|
3463
3543
|
var pageResult2 = (events, limit, direction) => {
|
|
3464
3544
|
const hasMore = events.length > limit;
|
|
@@ -3502,7 +3582,7 @@ var makeLayer = (repository) => {
|
|
|
3502
3582
|
};
|
|
3503
3583
|
};
|
|
3504
3584
|
const toRepositoryError7 = (error) => ExecutionEventRepositoryError.make({ message: String(error) });
|
|
3505
|
-
const decodeRow7 = (row) =>
|
|
3585
|
+
const decodeRow7 = (row) => Schema27.decodeUnknownEffect(ExecutionEventRow)(row).pipe(Effect28.mapError(toRepositoryError7));
|
|
3506
3586
|
const parsePointer = (executionId, payload) => {
|
|
3507
3587
|
const separator = payload.lastIndexOf(":");
|
|
3508
3588
|
if (separator <= 0 || separator === payload.length - 1)
|
|
@@ -3616,7 +3696,7 @@ var makeLayer = (repository) => {
|
|
|
3616
3696
|
return yield* ExecutionEventRepositoryError.make({ message: "Execution event append returned no row" });
|
|
3617
3697
|
}
|
|
3618
3698
|
return toEvent(yield* decodeRow7(row));
|
|
3619
|
-
})).pipe(Effect28.mapError((error) =>
|
|
3699
|
+
})).pipe(Effect28.mapError((error) => Schema27.is(DuplicateExecutionEvent)(error) || Schema27.is(ExecutionEventOrderViolation)(error) ? error : toRepositoryError7(error)));
|
|
3620
3700
|
});
|
|
3621
3701
|
const appendNext = Effect28.fn("ExecutionEventRepository.appendNext")(function* (input) {
|
|
3622
3702
|
const tenantId = yield* current();
|
|
@@ -3654,7 +3734,7 @@ var makeLayer = (repository) => {
|
|
|
3654
3734
|
return yield* ExecutionEventRepositoryError.make({ message: "Execution event append returned no row" });
|
|
3655
3735
|
}
|
|
3656
3736
|
return { event: toEvent(yield* decodeRow7(row)), inserted: true };
|
|
3657
|
-
})).pipe(Effect28.mapError((error) =>
|
|
3737
|
+
})).pipe(Effect28.mapError((error) => Schema27.is(DuplicateExecutionEvent)(error) ? error : toRepositoryError7(error)));
|
|
3658
3738
|
});
|
|
3659
3739
|
const list4 = Effect28.fn("ExecutionEventRepository.list")(function* (input) {
|
|
3660
3740
|
const tenantId = yield* current();
|
|
@@ -3739,10 +3819,10 @@ var makeLayer = (repository) => {
|
|
|
3739
3819
|
const row = rows[0];
|
|
3740
3820
|
return row === undefined ? Option3.none() : Option3.some(toEvent(yield* decodeRow7(row)));
|
|
3741
3821
|
});
|
|
3742
|
-
const AggregateRow =
|
|
3743
|
-
value:
|
|
3822
|
+
const AggregateRow = Schema27.Struct({
|
|
3823
|
+
value: Schema27.NullishOr(Schema27.Union([Schema27.Finite, Schema27.String, Schema27.BigInt]))
|
|
3744
3824
|
});
|
|
3745
|
-
const decodeAggregate = (row) =>
|
|
3825
|
+
const decodeAggregate = (row) => Schema27.decodeUnknownEffect(AggregateRow)(row).pipe(Effect28.mapError(toRepositoryError7));
|
|
3746
3826
|
const maxSequence = Effect28.fn("ExecutionEventRepository.maxSequence")(function* (executionId) {
|
|
3747
3827
|
const tenantId = yield* current();
|
|
3748
3828
|
const rows = yield* sql`
|
|
@@ -3856,43 +3936,43 @@ var makeLayer = (repository) => {
|
|
|
3856
3936
|
// ../store-sql/src/execution/execution-event-repository.ts
|
|
3857
3937
|
var executionEventsChannel = "relay_execution_events";
|
|
3858
3938
|
|
|
3859
|
-
class DuplicateExecutionEvent extends
|
|
3939
|
+
class DuplicateExecutionEvent extends Schema28.TaggedErrorClass()("DuplicateExecutionEvent", {
|
|
3860
3940
|
execution_id: exports_ids_schema.ExecutionId,
|
|
3861
3941
|
sequence: exports_execution_schema.ExecutionEventSequence,
|
|
3862
3942
|
cursor: exports_shared_schema.NonEmptyString
|
|
3863
3943
|
}) {
|
|
3864
3944
|
}
|
|
3865
3945
|
|
|
3866
|
-
class ExecutionEventOrderViolation extends
|
|
3946
|
+
class ExecutionEventOrderViolation extends Schema28.TaggedErrorClass()("ExecutionEventOrderViolation", {
|
|
3867
3947
|
execution_id: exports_ids_schema.ExecutionId,
|
|
3868
3948
|
sequence: exports_execution_schema.ExecutionEventSequence,
|
|
3869
3949
|
previous_sequence: exports_execution_schema.ExecutionEventSequence
|
|
3870
3950
|
}) {
|
|
3871
3951
|
}
|
|
3872
3952
|
|
|
3873
|
-
class ExecutionEventCursorNotFound extends
|
|
3953
|
+
class ExecutionEventCursorNotFound extends Schema28.TaggedErrorClass()("ExecutionEventCursorNotFound", {
|
|
3874
3954
|
execution_id: exports_ids_schema.ExecutionId,
|
|
3875
3955
|
cursor: exports_shared_schema.NonEmptyString
|
|
3876
3956
|
}) {
|
|
3877
3957
|
}
|
|
3878
3958
|
|
|
3879
|
-
class ExecutionEventRepositoryError extends
|
|
3880
|
-
message:
|
|
3959
|
+
class ExecutionEventRepositoryError extends Schema28.TaggedErrorClass()("ExecutionEventRepositoryError", {
|
|
3960
|
+
message: Schema28.String
|
|
3881
3961
|
}) {
|
|
3882
3962
|
}
|
|
3883
3963
|
|
|
3884
3964
|
class Service25 extends Context23.Service()("@relayfx/store-sql/execution/execution-event-repository/Service") {
|
|
3885
3965
|
}
|
|
3886
|
-
var ExecutionEventRow =
|
|
3887
|
-
id:
|
|
3888
|
-
execution_id:
|
|
3889
|
-
child_execution_id:
|
|
3890
|
-
type:
|
|
3891
|
-
sequence:
|
|
3892
|
-
cursor:
|
|
3893
|
-
content_json:
|
|
3894
|
-
data_json:
|
|
3895
|
-
created_at:
|
|
3966
|
+
var ExecutionEventRow = Schema28.Struct({
|
|
3967
|
+
id: Schema28.String,
|
|
3968
|
+
execution_id: Schema28.String,
|
|
3969
|
+
child_execution_id: Schema28.NullishOr(Schema28.String),
|
|
3970
|
+
type: Schema28.String,
|
|
3971
|
+
sequence: Schema28.Union([Schema28.Finite, Schema28.String]),
|
|
3972
|
+
cursor: Schema28.String,
|
|
3973
|
+
content_json: Schema28.NullishOr(Schema28.Unknown),
|
|
3974
|
+
data_json: Schema28.Unknown,
|
|
3975
|
+
created_at: Schema28.Union([Schema28.Date, Schema28.String, Schema28.Finite])
|
|
3896
3976
|
}).annotate({ identifier: "Relay.ExecutionEvent.Row" });
|
|
3897
3977
|
var layer18 = makeLayer({
|
|
3898
3978
|
DuplicateExecutionEvent,
|
|
@@ -3982,19 +4062,19 @@ __export(exports_execution_repository, {
|
|
|
3982
4062
|
ExecutionNotFound: () => ExecutionNotFound2,
|
|
3983
4063
|
DuplicateExecution: () => DuplicateExecution
|
|
3984
4064
|
});
|
|
3985
|
-
import { Context as Context24, Effect as Effect30, Filter as Filter2, Layer as Layer26, Option as Option5, PubSub as PubSub3, Schema as
|
|
4065
|
+
import { Context as Context24, Effect as Effect30, Filter as Filter2, Layer as Layer26, Option as Option5, PubSub as PubSub3, Schema as Schema29, Stream as Stream5 } from "effect";
|
|
3986
4066
|
import { SqlClient as SqlClient14 } from "effect/unstable/sql/SqlClient";
|
|
3987
|
-
class ExecutionRepositoryError extends
|
|
3988
|
-
message:
|
|
4067
|
+
class ExecutionRepositoryError extends Schema29.TaggedErrorClass()("ExecutionRepositoryError", {
|
|
4068
|
+
message: Schema29.String
|
|
3989
4069
|
}) {
|
|
3990
4070
|
}
|
|
3991
4071
|
|
|
3992
|
-
class DuplicateExecution extends
|
|
4072
|
+
class DuplicateExecution extends Schema29.TaggedErrorClass()("DuplicateExecution", {
|
|
3993
4073
|
id: exports_ids_schema.ExecutionId
|
|
3994
4074
|
}) {
|
|
3995
4075
|
}
|
|
3996
4076
|
|
|
3997
|
-
class ExecutionNotFound2 extends
|
|
4077
|
+
class ExecutionNotFound2 extends Schema29.TaggedErrorClass()("ExecutionNotFound", {
|
|
3998
4078
|
id: exports_ids_schema.ExecutionId
|
|
3999
4079
|
}) {
|
|
4000
4080
|
}
|
|
@@ -4002,18 +4082,18 @@ var executionsChangedChannel = "relay_executions_changed";
|
|
|
4002
4082
|
|
|
4003
4083
|
class Service26 extends Context24.Service()("@relayfx/store-sql/execution/execution-repository/Service") {
|
|
4004
4084
|
}
|
|
4005
|
-
var ExecutionRow =
|
|
4006
|
-
id:
|
|
4007
|
-
root_address_id:
|
|
4008
|
-
session_id:
|
|
4009
|
-
status:
|
|
4010
|
-
agent_id:
|
|
4011
|
-
agent_revision:
|
|
4012
|
-
agent_snapshot_json:
|
|
4013
|
-
agent_tool_input_schema_digests_json:
|
|
4014
|
-
metadata_json:
|
|
4015
|
-
created_at:
|
|
4016
|
-
updated_at:
|
|
4085
|
+
var ExecutionRow = Schema29.Struct({
|
|
4086
|
+
id: Schema29.String,
|
|
4087
|
+
root_address_id: Schema29.String,
|
|
4088
|
+
session_id: Schema29.NullishOr(Schema29.String),
|
|
4089
|
+
status: Schema29.String,
|
|
4090
|
+
agent_id: Schema29.NullishOr(Schema29.String),
|
|
4091
|
+
agent_revision: Schema29.NullishOr(Schema29.Finite),
|
|
4092
|
+
agent_snapshot_json: Schema29.NullishOr(Schema29.Unknown),
|
|
4093
|
+
agent_tool_input_schema_digests_json: Schema29.Unknown,
|
|
4094
|
+
metadata_json: Schema29.Unknown,
|
|
4095
|
+
created_at: Schema29.Union([Schema29.Date, Schema29.String, Schema29.Finite]),
|
|
4096
|
+
updated_at: Schema29.Union([Schema29.Date, Schema29.String, Schema29.Finite])
|
|
4017
4097
|
}).annotate({ identifier: "Relay.Execution.Row" });
|
|
4018
4098
|
var metadata4 = (input) => input ?? {};
|
|
4019
4099
|
var nonEmptyDigests2 = (digests) => digests === undefined || Object.keys(digests).length === 0 ? undefined : structuredClone(digests);
|
|
@@ -4036,7 +4116,7 @@ var validateCreateInput = (input) => {
|
|
|
4036
4116
|
}
|
|
4037
4117
|
return Effect30.void;
|
|
4038
4118
|
};
|
|
4039
|
-
var cloneAgentDefinition = (definition) =>
|
|
4119
|
+
var cloneAgentDefinition = (definition) => Schema29.decodeUnknownSync(exports_agent_schema.Definition)(globalThis.structuredClone(definition));
|
|
4040
4120
|
var cloneRecord4 = (record2) => ({
|
|
4041
4121
|
...record2,
|
|
4042
4122
|
metadata: globalThis.structuredClone(record2.metadata),
|
|
@@ -4065,9 +4145,9 @@ var parsePointer = (tenantId, payload) => {
|
|
|
4065
4145
|
const prefix = `${tenantId}:`;
|
|
4066
4146
|
if (!payload.startsWith(prefix) || payload.length === prefix.length)
|
|
4067
4147
|
return Option5.none();
|
|
4068
|
-
return
|
|
4148
|
+
return Schema29.decodeUnknownOption(exports_ids_schema.ExecutionId)(payload.slice(prefix.length));
|
|
4069
4149
|
};
|
|
4070
|
-
var decodeRow7 = (row) =>
|
|
4150
|
+
var decodeRow7 = (row) => Schema29.decodeUnknownEffect(ExecutionRow)(row).pipe(Effect30.mapError(toRepositoryError7));
|
|
4071
4151
|
var maxListLimit = 100;
|
|
4072
4152
|
var defaultListLimit = 50;
|
|
4073
4153
|
var listLimit = (input) => Math.min(Math.max(input.limit ?? defaultListLimit, 1), maxListLimit);
|
|
@@ -4332,29 +4412,29 @@ __export(exports_execution_state_repository, {
|
|
|
4332
4412
|
ExecutionStateRepositoryError: () => ExecutionStateRepositoryError,
|
|
4333
4413
|
ExecutionStateExecutionNotFound: () => ExecutionStateExecutionNotFound
|
|
4334
4414
|
});
|
|
4335
|
-
import { Context as Context25, Effect as Effect31, Layer as Layer27, Option as Option6, Schema as
|
|
4415
|
+
import { Context as Context25, Effect as Effect31, Layer as Layer27, Option as Option6, Schema as Schema30 } from "effect";
|
|
4336
4416
|
import { SqlClient as SqlClient15 } from "effect/unstable/sql/SqlClient";
|
|
4337
|
-
class StateVersionConflict2 extends
|
|
4417
|
+
class StateVersionConflict2 extends Schema30.TaggedErrorClass()("StateVersionConflict", {
|
|
4338
4418
|
execution_id: exports_ids_schema.ExecutionId,
|
|
4339
|
-
key:
|
|
4340
|
-
expected_version:
|
|
4341
|
-
actual_version:
|
|
4419
|
+
key: Schema30.String,
|
|
4420
|
+
expected_version: Schema30.Int,
|
|
4421
|
+
actual_version: Schema30.Int
|
|
4342
4422
|
}) {
|
|
4343
4423
|
}
|
|
4344
4424
|
|
|
4345
|
-
class ExecutionStateRepositoryError extends
|
|
4425
|
+
class ExecutionStateRepositoryError extends Schema30.TaggedErrorClass()("ExecutionStateRepositoryError", { message: Schema30.String }) {
|
|
4346
4426
|
}
|
|
4347
4427
|
|
|
4348
|
-
class ExecutionStateExecutionNotFound extends
|
|
4428
|
+
class ExecutionStateExecutionNotFound extends Schema30.TaggedErrorClass()("ExecutionStateExecutionNotFound", { execution_id: exports_ids_schema.ExecutionId }) {
|
|
4349
4429
|
}
|
|
4350
4430
|
|
|
4351
|
-
class StateIdempotencyConflict extends
|
|
4431
|
+
class StateIdempotencyConflict extends Schema30.TaggedErrorClass()("StateIdempotencyConflict", {
|
|
4352
4432
|
execution_id: exports_ids_schema.ExecutionId,
|
|
4353
|
-
idempotency_key:
|
|
4354
|
-
recorded_key:
|
|
4355
|
-
requested_key:
|
|
4356
|
-
recorded_op:
|
|
4357
|
-
requested_op:
|
|
4433
|
+
idempotency_key: Schema30.String,
|
|
4434
|
+
recorded_key: Schema30.String,
|
|
4435
|
+
requested_key: Schema30.String,
|
|
4436
|
+
recorded_op: Schema30.Literals(["put", "delete"]),
|
|
4437
|
+
requested_op: Schema30.Literals(["put", "delete"])
|
|
4358
4438
|
}) {
|
|
4359
4439
|
}
|
|
4360
4440
|
|
|
@@ -4570,7 +4650,7 @@ var layer20 = Layer27.effect(Service27, Effect31.gen(function* () {
|
|
|
4570
4650
|
})).pipe(Effect31.tap((record2) => eventRepository.findByCursor({
|
|
4571
4651
|
executionId: input.executionId,
|
|
4572
4652
|
cursor: `${input.executionId}:state:${input.key}:${record2.version}`
|
|
4573
|
-
}).pipe(Effect31.flatMap(Option6.match({ onNone: () => Effect31.void, onSome: eventRepository.notifyAppended })))), Effect31.mapError((cause) =>
|
|
4653
|
+
}).pipe(Effect31.flatMap(Option6.match({ onNone: () => Effect31.void, onSome: eventRepository.notifyAppended })))), Effect31.mapError((cause) => Schema30.is(StateVersionConflict2)(cause) || Schema30.is(StateIdempotencyConflict)(cause) || Schema30.is(ExecutionStateExecutionNotFound)(cause) ? cause : error(cause)));
|
|
4574
4654
|
});
|
|
4575
4655
|
const remove = Effect31.fn("ExecutionStateRepository.remove")(function* (input) {
|
|
4576
4656
|
const tenant = yield* current();
|
|
@@ -4615,7 +4695,7 @@ var layer20 = Layer27.effect(Service27, Effect31.gen(function* () {
|
|
|
4615
4695
|
})).pipe(Effect31.tap((record2) => record2 === undefined ? Effect31.void : eventRepository.findByCursor({
|
|
4616
4696
|
executionId: input.executionId,
|
|
4617
4697
|
cursor: `${input.executionId}:state:${input.key}:${record2.version + 1}`
|
|
4618
|
-
}).pipe(Effect31.flatMap(Option6.match({ onNone: () => Effect31.void, onSome: eventRepository.notifyAppended })))), Effect31.mapError((cause) =>
|
|
4698
|
+
}).pipe(Effect31.flatMap(Option6.match({ onNone: () => Effect31.void, onSome: eventRepository.notifyAppended })))), Effect31.mapError((cause) => Schema30.is(StateVersionConflict2)(cause) || Schema30.is(StateIdempotencyConflict)(cause) || Schema30.is(ExecutionStateExecutionNotFound)(cause) ? cause : error(cause)));
|
|
4619
4699
|
});
|
|
4620
4700
|
const list6 = Effect31.fn("ExecutionStateRepository.list")(function* (input) {
|
|
4621
4701
|
const tenant = yield* current();
|
|
@@ -4630,26 +4710,26 @@ var layer20 = Layer27.effect(Service27, Effect31.gen(function* () {
|
|
|
4630
4710
|
}));
|
|
4631
4711
|
var testLayer22 = (implementation) => Layer27.succeed(Service27, Service27.of(implementation));
|
|
4632
4712
|
// ../store-sql/src/idempotency/idempotency-repository.ts
|
|
4633
|
-
import { Context as Context26, Effect as Effect32, HashMap, Layer as Layer28, Option as Option7, Ref as Ref5, Schema as
|
|
4713
|
+
import { Context as Context26, Effect as Effect32, HashMap, Layer as Layer28, Option as Option7, Ref as Ref5, Schema as Schema31, Semaphore as Semaphore3 } from "effect";
|
|
4634
4714
|
import { SqlClient as SqlClient16 } from "effect/unstable/sql/SqlClient";
|
|
4635
|
-
class IdempotencyRepositoryError extends
|
|
4636
|
-
message:
|
|
4715
|
+
class IdempotencyRepositoryError extends Schema31.TaggedErrorClass()("IdempotencyRepositoryError", {
|
|
4716
|
+
message: Schema31.String
|
|
4637
4717
|
}) {
|
|
4638
4718
|
}
|
|
4639
4719
|
|
|
4640
4720
|
class Service28 extends Context26.Service()("@relayfx/store-sql/idempotency/idempotency-repository/Service") {
|
|
4641
4721
|
}
|
|
4642
|
-
var IdempotencyRow =
|
|
4643
|
-
scope:
|
|
4644
|
-
operation:
|
|
4645
|
-
key:
|
|
4646
|
-
result_json:
|
|
4647
|
-
metadata_json:
|
|
4648
|
-
created_at:
|
|
4649
|
-
expires_at:
|
|
4722
|
+
var IdempotencyRow = Schema31.Struct({
|
|
4723
|
+
scope: Schema31.String,
|
|
4724
|
+
operation: Schema31.String,
|
|
4725
|
+
key: Schema31.String,
|
|
4726
|
+
result_json: Schema31.NullishOr(Schema31.Unknown),
|
|
4727
|
+
metadata_json: Schema31.Unknown,
|
|
4728
|
+
created_at: Schema31.Union([Schema31.Date, Schema31.String, Schema31.Finite]),
|
|
4729
|
+
expires_at: Schema31.NullishOr(Schema31.Union([Schema31.Date, Schema31.String, Schema31.Finite]))
|
|
4650
4730
|
}).annotate({ identifier: "Relay.Idempotency.Row" });
|
|
4651
|
-
var AffectedRow =
|
|
4652
|
-
affected:
|
|
4731
|
+
var AffectedRow = Schema31.Struct({
|
|
4732
|
+
affected: Schema31.Union([Schema31.Finite, Schema31.String, Schema31.BigInt])
|
|
4653
4733
|
}).annotate({ identifier: "Relay.Idempotency.AffectedRow" });
|
|
4654
4734
|
var operationId = (input) => `${input.scope}:${input.operation}:${input.key}`;
|
|
4655
4735
|
var metadata5 = (input) => input ?? {};
|
|
@@ -4665,8 +4745,8 @@ var toRecord7 = (row) => {
|
|
|
4665
4745
|
...expiresAt === undefined ? {} : { expiresAt }
|
|
4666
4746
|
};
|
|
4667
4747
|
};
|
|
4668
|
-
var toRepositoryError8 = (error2) =>
|
|
4669
|
-
var decodeRow8 = (row) =>
|
|
4748
|
+
var toRepositoryError8 = (error2) => Schema31.is(IdempotencyRepositoryError)(error2) ? error2 : IdempotencyRepositoryError.make({ message: String(error2) });
|
|
4749
|
+
var decodeRow8 = (row) => Schema31.decodeUnknownEffect(IdempotencyRow)(row).pipe(Effect32.mapError(toRepositoryError8));
|
|
4670
4750
|
var layer21 = Layer28.effect(Service28, Effect32.gen(function* () {
|
|
4671
4751
|
const sql = yield* SqlClient16;
|
|
4672
4752
|
const keyColumn = sql.onDialectOrElse({
|
|
@@ -4708,7 +4788,7 @@ var layer21 = Layer28.effect(Service28, Effect32.gen(function* () {
|
|
|
4708
4788
|
mysql: () => (tenantId, input) => Effect32.gen(function* () {
|
|
4709
4789
|
yield* sql`INSERT IGNORE ${claimBody(tenantId, input)}`;
|
|
4710
4790
|
const rows = yield* sql`SELECT ROW_COUNT() AS affected`;
|
|
4711
|
-
const decoded = yield*
|
|
4791
|
+
const decoded = yield* Schema31.decodeUnknownEffect(AffectedRow)(rows[0]);
|
|
4712
4792
|
return Number(decoded.affected) > 0;
|
|
4713
4793
|
}),
|
|
4714
4794
|
orElse: () => (tenantId, input) => sql`INSERT ${claimBody(tenantId, input)} ON CONFLICT DO NOTHING RETURNING scope`.pipe(Effect32.map((rows) => rows.length > 0))
|
|
@@ -4798,34 +4878,34 @@ __export(exports_inbox_repository, {
|
|
|
4798
4878
|
Service: () => Service29,
|
|
4799
4879
|
InboxRepositoryError: () => InboxRepositoryError
|
|
4800
4880
|
});
|
|
4801
|
-
import { Context as Context27, Effect as Effect33, Layer as Layer29, Ref as Ref6, Schema as
|
|
4881
|
+
import { Context as Context27, Effect as Effect33, Layer as Layer29, Ref as Ref6, Schema as Schema32 } from "effect";
|
|
4802
4882
|
import { SqlClient as SqlClient17 } from "effect/unstable/sql/SqlClient";
|
|
4803
|
-
class InboxRepositoryError extends
|
|
4804
|
-
message:
|
|
4883
|
+
class InboxRepositoryError extends Schema32.TaggedErrorClass()("InboxRepositoryError", {
|
|
4884
|
+
message: Schema32.String
|
|
4805
4885
|
}) {
|
|
4806
4886
|
}
|
|
4807
4887
|
|
|
4808
4888
|
class Service29 extends Context27.Service()("@relayfx/store-sql/inbox/inbox-repository/Service") {
|
|
4809
4889
|
}
|
|
4810
|
-
var error2 = (e) =>
|
|
4890
|
+
var error2 = (e) => Schema32.is(InboxRepositoryError)(e) ? e : InboxRepositoryError.make({
|
|
4811
4891
|
message: `${e.message}: ${String(e.cause)}`
|
|
4812
4892
|
});
|
|
4813
|
-
var DbNumber =
|
|
4814
|
-
var InboxRow =
|
|
4815
|
-
execution_id:
|
|
4893
|
+
var DbNumber = Schema32.Union([Schema32.Finite, Schema32.FiniteFromString]);
|
|
4894
|
+
var InboxRow = Schema32.Struct({
|
|
4895
|
+
execution_id: Schema32.String,
|
|
4816
4896
|
sequence: DbNumber,
|
|
4817
|
-
from_address_id:
|
|
4818
|
-
envelope_id:
|
|
4819
|
-
content_json:
|
|
4820
|
-
reply_wait_id:
|
|
4821
|
-
correlation_key:
|
|
4822
|
-
idempotency_key:
|
|
4823
|
-
drain_id:
|
|
4824
|
-
consumed_at:
|
|
4825
|
-
metadata_json:
|
|
4826
|
-
created_at:
|
|
4827
|
-
});
|
|
4828
|
-
var rowToMessage = (value) =>
|
|
4897
|
+
from_address_id: Schema32.String,
|
|
4898
|
+
envelope_id: Schema32.NullOr(Schema32.String),
|
|
4899
|
+
content_json: Schema32.Unknown,
|
|
4900
|
+
reply_wait_id: Schema32.NullOr(Schema32.String),
|
|
4901
|
+
correlation_key: Schema32.NullOr(Schema32.String),
|
|
4902
|
+
idempotency_key: Schema32.NullOr(Schema32.String),
|
|
4903
|
+
drain_id: Schema32.NullOr(Schema32.String),
|
|
4904
|
+
consumed_at: Schema32.NullOr(Schema32.Union([Schema32.Date, Schema32.String, Schema32.Finite])),
|
|
4905
|
+
metadata_json: Schema32.NullOr(Schema32.Unknown),
|
|
4906
|
+
created_at: Schema32.Union([Schema32.Date, Schema32.String, Schema32.Finite])
|
|
4907
|
+
});
|
|
4908
|
+
var rowToMessage = (value) => Schema32.decodeUnknownEffect(InboxRow)(value).pipe(Effect33.flatMap((row) => Schema32.decodeUnknownEffect(exports_inbox_schema.Message)({
|
|
4829
4909
|
execution_id: row.execution_id,
|
|
4830
4910
|
sequence: row.sequence,
|
|
4831
4911
|
from: row.from_address_id,
|
|
@@ -4900,10 +4980,10 @@ var layer22 = Layer29.effect(Service29, Effect33.gen(function* () {
|
|
|
4900
4980
|
const old = yield* sql`SELECT message_sequences_json FROM relay_inbox_drains WHERE tenant_id=${tenant} AND execution_id=${input.executionId} AND drain_id=${input.drainId}`;
|
|
4901
4981
|
let sequences;
|
|
4902
4982
|
if (old[0] !== undefined)
|
|
4903
|
-
sequences = yield*
|
|
4983
|
+
sequences = yield* Schema32.decodeUnknownEffect(Schema32.Array(DbNumber))(decodeJson(old[0].message_sequences_json)).pipe(Effect33.mapError((cause) => InboxRepositoryError.make({ message: String(cause) })));
|
|
4904
4984
|
else {
|
|
4905
4985
|
const rows2 = yield* sql`SELECT sequence FROM relay_inbox_messages WHERE tenant_id=${tenant} AND execution_id=${input.executionId} AND consumed_at IS NULL ORDER BY sequence ASC LIMIT ${sql.literal(String(input.maxBatch ?? 100))}`;
|
|
4906
|
-
sequences = yield* Effect33.forEach(rows2, (row) =>
|
|
4986
|
+
sequences = yield* Effect33.forEach(rows2, (row) => Schema32.decodeUnknownEffect(Schema32.Struct({ sequence: DbNumber }))(row).pipe(Effect33.map((decoded) => decoded.sequence), Effect33.mapError((cause) => InboxRepositoryError.make({ message: String(cause) }))));
|
|
4907
4987
|
if (sequences.length === 0)
|
|
4908
4988
|
return [];
|
|
4909
4989
|
yield* sql`UPDATE relay_inbox_messages SET drain_id=${input.drainId}, consumed_at=${timestampParam(sql, input.consumedAt)} WHERE tenant_id=${tenant} AND execution_id=${input.executionId} AND ${sql.in("sequence", sequences)}`;
|
|
@@ -4990,10 +5070,10 @@ __export(exports_topic_repository, {
|
|
|
4990
5070
|
TopicRepositoryError: () => TopicRepositoryError,
|
|
4991
5071
|
Service: () => Service30
|
|
4992
5072
|
});
|
|
4993
|
-
import { Context as Context28, Effect as Effect34, Layer as Layer30, Ref as Ref7, Schema as
|
|
5073
|
+
import { Context as Context28, Effect as Effect34, Layer as Layer30, Ref as Ref7, Schema as Schema33 } from "effect";
|
|
4994
5074
|
import { SqlClient as SqlClient18 } from "effect/unstable/sql/SqlClient";
|
|
4995
|
-
class TopicRepositoryError extends
|
|
4996
|
-
message:
|
|
5075
|
+
class TopicRepositoryError extends Schema33.TaggedErrorClass()("TopicRepositoryError", {
|
|
5076
|
+
message: Schema33.String
|
|
4997
5077
|
}) {
|
|
4998
5078
|
}
|
|
4999
5079
|
|
|
@@ -5093,47 +5173,47 @@ __export(exports_memory_repository, {
|
|
|
5093
5173
|
MemoryRow: () => MemoryRow,
|
|
5094
5174
|
MemoryRepositoryError: () => MemoryRepositoryError
|
|
5095
5175
|
});
|
|
5096
|
-
import { Context as Context29, Effect as Effect35, Layer as Layer31, Ref as Ref8, Schema as
|
|
5097
|
-
import { Prompt as
|
|
5176
|
+
import { Context as Context29, Effect as Effect35, Layer as Layer31, Ref as Ref8, Schema as Schema34 } from "effect";
|
|
5177
|
+
import { Prompt as Prompt4 } from "effect/unstable/ai";
|
|
5098
5178
|
import { SqlClient as SqlClient19 } from "effect/unstable/sql/SqlClient";
|
|
5099
|
-
class MemoryRepositoryError extends
|
|
5100
|
-
message:
|
|
5179
|
+
class MemoryRepositoryError extends Schema34.TaggedErrorClass()("MemoryRepositoryError", {
|
|
5180
|
+
message: Schema34.String
|
|
5101
5181
|
}) {
|
|
5102
5182
|
}
|
|
5103
5183
|
|
|
5104
5184
|
class Service31 extends Context29.Service()("@relayfx/store-sql/memory/memory-repository/Service") {
|
|
5105
5185
|
}
|
|
5106
5186
|
var recallCandidateCap = 1000;
|
|
5107
|
-
var MemoryRow =
|
|
5108
|
-
id:
|
|
5109
|
-
agent:
|
|
5110
|
-
subject:
|
|
5111
|
-
embedding:
|
|
5112
|
-
parts_json:
|
|
5113
|
-
metadata_json:
|
|
5114
|
-
created_at:
|
|
5187
|
+
var MemoryRow = Schema34.Struct({
|
|
5188
|
+
id: Schema34.String,
|
|
5189
|
+
agent: Schema34.String,
|
|
5190
|
+
subject: Schema34.String,
|
|
5191
|
+
embedding: Schema34.Union([Schema34.Array(Schema34.Finite), Schema34.String]),
|
|
5192
|
+
parts_json: Schema34.Unknown,
|
|
5193
|
+
metadata_json: Schema34.Unknown,
|
|
5194
|
+
created_at: Schema34.Union([Schema34.Date, Schema34.String, Schema34.Finite])
|
|
5115
5195
|
}).annotate({ identifier: "Relay.Memory.Row" });
|
|
5116
5196
|
var toRepositoryError9 = (error4) => MemoryRepositoryError.make({ message: String(error4) });
|
|
5117
|
-
var decodeRow9 = (row) =>
|
|
5118
|
-
var MemoryFileDataWire =
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5197
|
+
var decodeRow9 = (row) => Schema34.decodeUnknownEffect(MemoryRow)(row).pipe(Effect35.mapError(toRepositoryError9));
|
|
5198
|
+
var MemoryFileDataWire = Schema34.Union([
|
|
5199
|
+
Schema34.TaggedStruct("String", { value: Schema34.String }),
|
|
5200
|
+
Schema34.TaggedStruct("Bytes", { value: Schema34.Array(Schema34.Finite) }),
|
|
5201
|
+
Schema34.TaggedStruct("Url", { value: Schema34.String })
|
|
5122
5202
|
]);
|
|
5123
|
-
var MemoryPartWire =
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
type:
|
|
5127
|
-
mediaType:
|
|
5128
|
-
fileName:
|
|
5203
|
+
var MemoryPartWire = Schema34.Union([
|
|
5204
|
+
Schema34.Struct({ type: Schema34.Literal("text"), text: Schema34.String, options: Prompt4.ProviderOptions }),
|
|
5205
|
+
Schema34.Struct({
|
|
5206
|
+
type: Schema34.Literal("file"),
|
|
5207
|
+
mediaType: Schema34.String,
|
|
5208
|
+
fileName: Schema34.optional(Schema34.String),
|
|
5129
5209
|
data: MemoryFileDataWire,
|
|
5130
|
-
options:
|
|
5210
|
+
options: Prompt4.ProviderOptions
|
|
5131
5211
|
})
|
|
5132
5212
|
]);
|
|
5133
|
-
var MemoryPartsWire =
|
|
5134
|
-
parts:
|
|
5213
|
+
var MemoryPartsWire = Schema34.TaggedStruct("RelayMemoryPartsV1", {
|
|
5214
|
+
parts: Schema34.Array(MemoryPartWire)
|
|
5135
5215
|
});
|
|
5136
|
-
var LegacyMemoryParts =
|
|
5216
|
+
var LegacyMemoryParts = Schema34.Array(Schema34.Union([Prompt4.TextPart, Prompt4.FilePart]));
|
|
5137
5217
|
var encodeParts = (parts) => {
|
|
5138
5218
|
const wireParts = parts.map((part) => {
|
|
5139
5219
|
if (part.type === "text")
|
|
@@ -5149,18 +5229,18 @@ var encodeParts = (parts) => {
|
|
|
5149
5229
|
options: part.options
|
|
5150
5230
|
};
|
|
5151
5231
|
});
|
|
5152
|
-
return
|
|
5232
|
+
return Schema34.encodeSync(MemoryPartsWire)({ _tag: "RelayMemoryPartsV1", parts: wireParts });
|
|
5153
5233
|
};
|
|
5154
5234
|
var decodeParts = (value) => {
|
|
5155
5235
|
const decoded = decodeJson(value);
|
|
5156
5236
|
if (typeof decoded !== "object" || decoded === null || !("_tag" in decoded)) {
|
|
5157
|
-
return
|
|
5237
|
+
return Schema34.decodeUnknownEffect(LegacyMemoryParts)(decoded).pipe(Effect35.mapError(toRepositoryError9));
|
|
5158
5238
|
}
|
|
5159
|
-
return
|
|
5239
|
+
return Schema34.decodeUnknownEffect(MemoryPartsWire)(decoded).pipe(Effect35.map((wire) => wire.parts.map((part) => {
|
|
5160
5240
|
if (part.type === "text")
|
|
5161
|
-
return
|
|
5241
|
+
return Prompt4.makePart("text", { text: part.text, options: part.options });
|
|
5162
5242
|
const data = part.data._tag === "String" ? part.data.value : part.data._tag === "Bytes" ? new Uint8Array(part.data.value) : new URL(part.data.value);
|
|
5163
|
-
return
|
|
5243
|
+
return Prompt4.makePart("file", {
|
|
5164
5244
|
mediaType: part.mediaType,
|
|
5165
5245
|
...part.fileName === undefined ? {} : { fileName: part.fileName },
|
|
5166
5246
|
data,
|
|
@@ -5168,7 +5248,7 @@ var decodeParts = (value) => {
|
|
|
5168
5248
|
});
|
|
5169
5249
|
})), Effect35.mapError(toRepositoryError9));
|
|
5170
5250
|
};
|
|
5171
|
-
var decodeMetadata4 = (value) =>
|
|
5251
|
+
var decodeMetadata4 = (value) => Schema34.decodeUnknownEffect(exports_shared_schema.Metadata)(decodeJson(value)).pipe(Effect35.mapError(toRepositoryError9));
|
|
5172
5252
|
var parsePgFloatArray = (value) => {
|
|
5173
5253
|
const body = value.startsWith("{") && value.endsWith("}") ? value.slice(1, -1) : value;
|
|
5174
5254
|
if (body.length === 0)
|
|
@@ -5221,7 +5301,7 @@ var clonePart = (part) => {
|
|
|
5221
5301
|
if (part.type !== "file")
|
|
5222
5302
|
return structuredClone(part);
|
|
5223
5303
|
const data = typeof part.data === "string" ? part.data : part.data instanceof Uint8Array ? new Uint8Array(part.data) : new URL(part.data.toString());
|
|
5224
|
-
return
|
|
5304
|
+
return Prompt4.makePart("file", {
|
|
5225
5305
|
mediaType: part.mediaType,
|
|
5226
5306
|
...part.fileName === undefined ? {} : { fileName: part.fileName },
|
|
5227
5307
|
data,
|
|
@@ -5243,7 +5323,7 @@ var layer24 = Layer31.effect(Service31, Effect35.gen(function* () {
|
|
|
5243
5323
|
});
|
|
5244
5324
|
const decodeEmbedding = sql.onDialectOrElse({
|
|
5245
5325
|
pg: () => (value) => typeof value === "string" ? parsePgFloatArray(value) : value,
|
|
5246
|
-
orElse: () => (value) => typeof value === "string" ?
|
|
5326
|
+
orElse: () => (value) => typeof value === "string" ? Schema34.decodeUnknownSync(Schema34.fromJsonString(Schema34.Array(Schema34.Finite)))(value) : value
|
|
5247
5327
|
});
|
|
5248
5328
|
const toRecord8 = (row) => Effect35.all({ parts: decodeParts(row.parts_json), metadata: decodeMetadata4(row.metadata_json) }).pipe(Effect35.map(({ metadata: metadata6, parts }) => ({
|
|
5249
5329
|
id: row.id,
|
|
@@ -5409,20 +5489,20 @@ __export(exports_permission_rule_repository, {
|
|
|
5409
5489
|
PermissionRuleRow: () => PermissionRuleRow,
|
|
5410
5490
|
PermissionRuleRepositoryError: () => PermissionRuleRepositoryError
|
|
5411
5491
|
});
|
|
5412
|
-
import { Context as Context30, Effect as Effect36, Layer as Layer32, Schema as
|
|
5492
|
+
import { Context as Context30, Effect as Effect36, Layer as Layer32, Schema as Schema35 } from "effect";
|
|
5413
5493
|
import { SqlClient as SqlClient20 } from "effect/unstable/sql/SqlClient";
|
|
5414
|
-
class PermissionRuleRepositoryError extends
|
|
5415
|
-
message:
|
|
5494
|
+
class PermissionRuleRepositoryError extends Schema35.TaggedErrorClass()("PermissionRuleRepositoryError", {
|
|
5495
|
+
message: Schema35.String
|
|
5416
5496
|
}) {
|
|
5417
5497
|
}
|
|
5418
5498
|
|
|
5419
5499
|
class Service32 extends Context30.Service()("@relayfx/store-sql/permission/permission-rule-repository/Service") {
|
|
5420
5500
|
}
|
|
5421
|
-
var PermissionRuleRow =
|
|
5422
|
-
agent:
|
|
5423
|
-
scope:
|
|
5424
|
-
rule_json:
|
|
5425
|
-
created_at:
|
|
5501
|
+
var PermissionRuleRow = Schema35.Struct({
|
|
5502
|
+
agent: Schema35.String,
|
|
5503
|
+
scope: Schema35.String,
|
|
5504
|
+
rule_json: Schema35.Unknown,
|
|
5505
|
+
created_at: Schema35.Union([Schema35.Date, Schema35.String, Schema35.Finite])
|
|
5426
5506
|
}).annotate({ identifier: "Relay.PermissionRule.Row" });
|
|
5427
5507
|
var toRecord8 = (row) => ({
|
|
5428
5508
|
agent: row.agent,
|
|
@@ -5431,7 +5511,7 @@ var toRecord8 = (row) => ({
|
|
|
5431
5511
|
createdAt: fromDbTimestamp(row.created_at)
|
|
5432
5512
|
});
|
|
5433
5513
|
var toRepositoryError10 = (error4) => PermissionRuleRepositoryError.make({ message: String(error4) });
|
|
5434
|
-
var decodeRow10 = (row) =>
|
|
5514
|
+
var decodeRow10 = (row) => Schema35.decodeUnknownEffect(PermissionRuleRow)(row).pipe(Effect36.mapError(toRepositoryError10));
|
|
5435
5515
|
var memoryKey = (agent, scope, pattern) => `${agent}\x00${scope}\x00${pattern}`;
|
|
5436
5516
|
var layer25 = Layer32.effect(Service32, Effect36.gen(function* () {
|
|
5437
5517
|
const sql = yield* SqlClient20;
|
|
@@ -5528,24 +5608,24 @@ __export(exports_presence_repository, {
|
|
|
5528
5608
|
Service: () => Service33,
|
|
5529
5609
|
PresenceRepositoryError: () => PresenceRepositoryError
|
|
5530
5610
|
});
|
|
5531
|
-
import { Clock as Clock3, Context as Context31, Effect as Effect37, Layer as Layer33, PubSub as PubSub4, Schema as
|
|
5611
|
+
import { Clock as Clock3, Context as Context31, Effect as Effect37, Layer as Layer33, PubSub as PubSub4, Schema as Schema36, Stream as Stream6 } from "effect";
|
|
5532
5612
|
import { SqlClient as SqlClient21 } from "effect/unstable/sql/SqlClient";
|
|
5533
5613
|
var presenceChangedChannel = "relay_presence";
|
|
5534
5614
|
|
|
5535
|
-
class PresenceRepositoryError extends
|
|
5615
|
+
class PresenceRepositoryError extends Schema36.TaggedErrorClass()("PresenceRepositoryError", { message: Schema36.String }) {
|
|
5536
5616
|
}
|
|
5537
5617
|
|
|
5538
5618
|
class Service33 extends Context31.Service()("@relayfx/store-sql/presence/presence-repository/Service") {
|
|
5539
5619
|
}
|
|
5540
5620
|
var pointer = (scope) => `${scope.kind}:${scope.id}`;
|
|
5541
5621
|
var error4 = (cause) => PresenceRepositoryError.make({ message: String(cause) });
|
|
5542
|
-
var Row =
|
|
5543
|
-
id:
|
|
5544
|
-
scope_kind:
|
|
5545
|
-
scope_id:
|
|
5546
|
-
metadata_json:
|
|
5547
|
-
connected_at:
|
|
5548
|
-
expires_at:
|
|
5622
|
+
var Row = Schema36.Struct({
|
|
5623
|
+
id: Schema36.String,
|
|
5624
|
+
scope_kind: Schema36.String,
|
|
5625
|
+
scope_id: Schema36.String,
|
|
5626
|
+
metadata_json: Schema36.Unknown,
|
|
5627
|
+
connected_at: Schema36.Union([Schema36.Date, Schema36.String, Schema36.Finite]),
|
|
5628
|
+
expires_at: Schema36.Union([Schema36.Date, Schema36.String, Schema36.Finite])
|
|
5549
5629
|
});
|
|
5550
5630
|
var layer26 = Layer33.effect(Service33, Effect37.gen(function* () {
|
|
5551
5631
|
const sql = yield* SqlClient21;
|
|
@@ -5576,7 +5656,7 @@ var layer26 = Layer33.effect(Service33, Effect37.gen(function* () {
|
|
|
5576
5656
|
const rows = yield* sql`SELECT id, scope_kind, scope_id, metadata_json, connected_at, expires_at FROM relay_presence
|
|
5577
5657
|
WHERE tenant_id = ${tenant} AND scope_kind = ${scope.kind} AND scope_id = ${scope.id} AND expires_at > ${now}
|
|
5578
5658
|
ORDER BY connected_at, id`.pipe(Effect37.mapError(error4));
|
|
5579
|
-
return yield* Effect37.forEach(rows, (value) =>
|
|
5659
|
+
return yield* Effect37.forEach(rows, (value) => Schema36.decodeUnknownEffect(Row)(value).pipe(Effect37.map((row) => ({
|
|
5580
5660
|
id: row.id,
|
|
5581
5661
|
scope: { kind: row.scope_kind, id: row.scope_id },
|
|
5582
5662
|
metadata: decodeJson(row.metadata_json),
|
|
@@ -5658,44 +5738,44 @@ __export(exports_schedule_repository, {
|
|
|
5658
5738
|
ScheduleNotFound: () => ScheduleNotFound,
|
|
5659
5739
|
ScheduleClaimMismatch: () => ScheduleClaimMismatch
|
|
5660
5740
|
});
|
|
5661
|
-
import { Context as Context32, Effect as Effect38, Layer as Layer34, Schema as
|
|
5741
|
+
import { Context as Context32, Effect as Effect38, Layer as Layer34, Schema as Schema37 } from "effect";
|
|
5662
5742
|
import { SqlClient as SqlClient22 } from "effect/unstable/sql/SqlClient";
|
|
5663
|
-
class ScheduleRepositoryError extends
|
|
5664
|
-
message:
|
|
5743
|
+
class ScheduleRepositoryError extends Schema37.TaggedErrorClass()("ScheduleRepositoryError", {
|
|
5744
|
+
message: Schema37.String
|
|
5665
5745
|
}) {
|
|
5666
5746
|
}
|
|
5667
5747
|
|
|
5668
|
-
class ScheduleNotFound extends
|
|
5748
|
+
class ScheduleNotFound extends Schema37.TaggedErrorClass()("ScheduleNotFound", {
|
|
5669
5749
|
id: exports_ids_schema.ScheduleId
|
|
5670
5750
|
}) {
|
|
5671
5751
|
}
|
|
5672
5752
|
|
|
5673
|
-
class ScheduleClaimMismatch extends
|
|
5753
|
+
class ScheduleClaimMismatch extends Schema37.TaggedErrorClass()("ScheduleClaimMismatch", {
|
|
5674
5754
|
id: exports_ids_schema.ScheduleId,
|
|
5675
|
-
worker_id:
|
|
5755
|
+
worker_id: Schema37.String
|
|
5676
5756
|
}) {
|
|
5677
5757
|
}
|
|
5678
5758
|
|
|
5679
5759
|
class Service34 extends Context32.Service()("@relayfx/store-sql/schedule/schedule-repository/Service") {
|
|
5680
5760
|
}
|
|
5681
|
-
var ScheduleRow =
|
|
5682
|
-
id:
|
|
5683
|
-
kind:
|
|
5684
|
-
target_kind:
|
|
5685
|
-
address_id:
|
|
5686
|
-
wait_id:
|
|
5687
|
-
cron_expr:
|
|
5688
|
-
input_json:
|
|
5689
|
-
state:
|
|
5690
|
-
next_run_at:
|
|
5691
|
-
attempt:
|
|
5692
|
-
claim_owner:
|
|
5693
|
-
claim_expires_at:
|
|
5694
|
-
last_error:
|
|
5695
|
-
idempotency_key:
|
|
5696
|
-
metadata_json:
|
|
5697
|
-
created_at:
|
|
5698
|
-
updated_at:
|
|
5761
|
+
var ScheduleRow = Schema37.Struct({
|
|
5762
|
+
id: Schema37.String,
|
|
5763
|
+
kind: Schema37.String,
|
|
5764
|
+
target_kind: Schema37.String,
|
|
5765
|
+
address_id: Schema37.NullishOr(Schema37.String),
|
|
5766
|
+
wait_id: Schema37.NullishOr(Schema37.String),
|
|
5767
|
+
cron_expr: Schema37.NullishOr(Schema37.String),
|
|
5768
|
+
input_json: Schema37.NullishOr(Schema37.Unknown),
|
|
5769
|
+
state: Schema37.String,
|
|
5770
|
+
next_run_at: Schema37.Union([Schema37.Date, Schema37.String, Schema37.Finite]),
|
|
5771
|
+
attempt: Schema37.Union([Schema37.Finite, Schema37.String, Schema37.BigInt]),
|
|
5772
|
+
claim_owner: Schema37.NullishOr(Schema37.String),
|
|
5773
|
+
claim_expires_at: Schema37.NullishOr(Schema37.Union([Schema37.Date, Schema37.String, Schema37.Finite])),
|
|
5774
|
+
last_error: Schema37.NullishOr(Schema37.String),
|
|
5775
|
+
idempotency_key: Schema37.NullishOr(Schema37.String),
|
|
5776
|
+
metadata_json: Schema37.Unknown,
|
|
5777
|
+
created_at: Schema37.Union([Schema37.Date, Schema37.String, Schema37.Finite]),
|
|
5778
|
+
updated_at: Schema37.Union([Schema37.Date, Schema37.String, Schema37.Finite])
|
|
5699
5779
|
}).annotate({ identifier: "Relay.Schedule.Row" });
|
|
5700
5780
|
var metadata6 = (input) => input ?? {};
|
|
5701
5781
|
var validationError = (input) => {
|
|
@@ -5733,7 +5813,7 @@ var toRecord9 = (row) => {
|
|
|
5733
5813
|
};
|
|
5734
5814
|
};
|
|
5735
5815
|
var toRepositoryError11 = (error5) => ScheduleRepositoryError.make({ message: String(error5) });
|
|
5736
|
-
var decodeRow11 = (row) =>
|
|
5816
|
+
var decodeRow11 = (row) => Schema37.decodeUnknownEffect(ScheduleRow)(row).pipe(Effect38.mapError(toRepositoryError11));
|
|
5737
5817
|
var cancellableStates = new Set(["active", "claimed"]);
|
|
5738
5818
|
var columnsText = "id, kind, target_kind, address_id, wait_id, cron_expr, input_json, state, next_run_at, attempt, claim_owner, claim_expires_at, last_error, idempotency_key, metadata_json, created_at, updated_at";
|
|
5739
5819
|
var layer27 = Layer34.effect(Service34, Effect38.gen(function* () {
|
|
@@ -6187,6 +6267,7 @@ __export(exports_session_repository, {
|
|
|
6187
6267
|
touch: () => touch,
|
|
6188
6268
|
testLayer: () => testLayer29,
|
|
6189
6269
|
setLeaf: () => setLeaf,
|
|
6270
|
+
releaseWriter: () => releaseWriter,
|
|
6190
6271
|
path: () => path,
|
|
6191
6272
|
memoryLayer: () => memoryLayer26,
|
|
6192
6273
|
list: () => list10,
|
|
@@ -6197,6 +6278,7 @@ __export(exports_session_repository, {
|
|
|
6197
6278
|
ensure: () => ensure,
|
|
6198
6279
|
create: () => create5,
|
|
6199
6280
|
countEntries: () => countEntries,
|
|
6281
|
+
claimWriter: () => claimWriter,
|
|
6200
6282
|
appendEntry: () => appendEntry,
|
|
6201
6283
|
appendCheckpoint: () => appendCheckpoint,
|
|
6202
6284
|
SessionRow: () => SessionRow,
|
|
@@ -6206,68 +6288,31 @@ __export(exports_session_repository, {
|
|
|
6206
6288
|
Service: () => Service35,
|
|
6207
6289
|
DuplicateSession: () => DuplicateSession
|
|
6208
6290
|
});
|
|
6209
|
-
import { Context as Context33, Effect as Effect41, Layer as Layer35, Schema as
|
|
6291
|
+
import { Context as Context33, Effect as Effect41, Layer as Layer35, Schema as Schema41 } from "effect";
|
|
6210
6292
|
|
|
6211
6293
|
// ../store-sql/src/session/session-entry-records.ts
|
|
6212
|
-
import { Effect as Effect39, Schema as
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
created_at: Schema37.Union([Schema37.Date, Schema37.String, Schema37.Finite])
|
|
6294
|
+
import { Effect as Effect39, Schema as Schema38 } from "effect";
|
|
6295
|
+
var sessionEntryRow = Schema38.Struct({
|
|
6296
|
+
id: Schema38.String,
|
|
6297
|
+
session_id: Schema38.String,
|
|
6298
|
+
parent_id: Schema38.Union([Schema38.String, Schema38.Null, Schema38.Undefined]),
|
|
6299
|
+
tag: Schema38.String,
|
|
6300
|
+
payload_json: Schema38.Unknown,
|
|
6301
|
+
created_at: Schema38.Union([Schema38.Date, Schema38.String, Schema38.Finite])
|
|
6221
6302
|
}).annotate({ identifier: "Relay.SessionEntry.Row" });
|
|
6222
|
-
var
|
|
6223
|
-
Schema37.TaggedStruct("String", { value: Schema37.String }),
|
|
6224
|
-
Schema37.TaggedStruct("Bytes", { value: Schema37.Array(Schema37.Finite) }),
|
|
6225
|
-
Schema37.TaggedStruct("Url", { value: Schema37.String })
|
|
6226
|
-
]);
|
|
6227
|
-
var CheckpointPromptWire = Schema37.TaggedStruct("RelaySessionCheckpointPromptV1", {
|
|
6303
|
+
var CheckpointPromptWire = Schema38.TaggedStruct("RelaySessionCheckpointPromptV1", {
|
|
6228
6304
|
prompt: exports_shared_schema.JsonValue
|
|
6229
6305
|
});
|
|
6230
|
-
var
|
|
6231
|
-
var encodePromptMessage = (prompt, message, messageIndex) => ({
|
|
6232
|
-
...message,
|
|
6233
|
-
content: Array.isArray(message.content) ? message.content.map((part, partIndex) => {
|
|
6234
|
-
const actualContent = prompt.content[messageIndex]?.content;
|
|
6235
|
-
const actualPart = Array.isArray(actualContent) ? actualContent[partIndex] : undefined;
|
|
6236
|
-
return part.type === "file" && actualPart?.type === "file" ? { ...part, data: fileDataToWire(actualPart.data) } : part;
|
|
6237
|
-
}) : message.content
|
|
6238
|
-
});
|
|
6239
|
-
var encodePromptContent = (prompt) => {
|
|
6240
|
-
const encoded = Schema37.encodeSync(Prompt3.Prompt)(prompt);
|
|
6241
|
-
return Schema37.decodeUnknownSync(exports_shared_schema.JsonValue)({
|
|
6242
|
-
content: encoded.content.map((message, messageIndex) => encodePromptMessage(prompt, message, messageIndex))
|
|
6243
|
-
});
|
|
6244
|
-
};
|
|
6245
|
-
var decodePromptContent = (value) => {
|
|
6246
|
-
const content = typeof value === "object" && value !== null && !Array.isArray(value) && "content" in value ? value.content : undefined;
|
|
6247
|
-
const decodedContent = Array.isArray(content) ? content.map((message) => {
|
|
6248
|
-
if (typeof message !== "object" || message === null || Array.isArray(message))
|
|
6249
|
-
return message;
|
|
6250
|
-
const messageContent = message.content;
|
|
6251
|
-
return {
|
|
6252
|
-
...message,
|
|
6253
|
-
content: Array.isArray(messageContent) ? messageContent.map((part) => {
|
|
6254
|
-
if (typeof part !== "object" || part === null || Array.isArray(part) || part.type !== "file") {
|
|
6255
|
-
return part;
|
|
6256
|
-
}
|
|
6257
|
-
const data = Schema37.decodeUnknownSync(FileDataWire)(part.data);
|
|
6258
|
-
return {
|
|
6259
|
-
...part,
|
|
6260
|
-
data: data._tag === "String" ? data.value : data._tag === "Bytes" ? Uint8Array.from(data.value) : new URL(data.value)
|
|
6261
|
-
};
|
|
6262
|
-
}) : messageContent
|
|
6263
|
-
};
|
|
6264
|
-
}) : content;
|
|
6265
|
-
return Schema37.decodeUnknownSync(Prompt3.Prompt)({ content: decodedContent });
|
|
6266
|
-
};
|
|
6267
|
-
var encodeCheckpointPrompt = (prompt) => Schema37.encodeSync(CheckpointPromptWire)({
|
|
6306
|
+
var encodeCheckpointPrompt = (prompt) => Schema38.encodeSync(CheckpointPromptWire)({
|
|
6268
6307
|
_tag: "RelaySessionCheckpointPromptV1",
|
|
6269
|
-
prompt:
|
|
6270
|
-
});
|
|
6308
|
+
prompt: encodePrompt(prompt)
|
|
6309
|
+
});
|
|
6310
|
+
var CheckpointTelemetryWire = Schema38.Array(exports_model_telemetry.Event);
|
|
6311
|
+
var encodeCheckpointTelemetry = Schema38.encodeSync(CheckpointTelemetryWire);
|
|
6312
|
+
var decodeCheckpointTelemetry = Schema38.decodeUnknownSync(CheckpointTelemetryWire);
|
|
6313
|
+
var CheckpointCommitWire = exports_model_telemetry.CompactionCommit;
|
|
6314
|
+
var encodeCheckpointCommit = Schema38.encodeSync(CheckpointCommitWire);
|
|
6315
|
+
var decodeCheckpointCommit = Schema38.decodeUnknownSync(CheckpointCommitWire);
|
|
6271
6316
|
var comparableEntry = (entry) => {
|
|
6272
6317
|
const { createdAt: _createdAt, ...value } = entry;
|
|
6273
6318
|
return value;
|
|
@@ -6301,6 +6346,8 @@ var appendToRecord = (input) => {
|
|
|
6301
6346
|
_tag: "Compaction",
|
|
6302
6347
|
version: 2,
|
|
6303
6348
|
projectedHistory: input.input.projectedHistory,
|
|
6349
|
+
telemetry: input.input.telemetry,
|
|
6350
|
+
...input.input.compactionCommit === undefined ? {} : { compactionCommit: input.input.compactionCommit },
|
|
6304
6351
|
...input.input.summary === undefined ? {} : { summary: input.input.summary }
|
|
6305
6352
|
} : {
|
|
6306
6353
|
...base,
|
|
@@ -6314,13 +6361,13 @@ var appendToRecord = (input) => {
|
|
|
6314
6361
|
};
|
|
6315
6362
|
var makeSessionEntryRecords = (errors) => {
|
|
6316
6363
|
const { SessionRepositoryError, SessionConflict } = errors;
|
|
6317
|
-
const decodeCheckpointPrompt = (value) =>
|
|
6318
|
-
try: () =>
|
|
6364
|
+
const decodeCheckpointPrompt = (value) => Schema38.decodeUnknownEffect(CheckpointPromptWire)(value).pipe(Effect39.flatMap((wire) => Effect39.try({
|
|
6365
|
+
try: () => decodePrompt(wire.prompt),
|
|
6319
6366
|
catch: (error5) => SessionRepositoryError.make({ message: `Invalid Session checkpoint prompt: ${String(error5)}` })
|
|
6320
|
-
})), Effect39.mapError((error5) =>
|
|
6367
|
+
})), Effect39.mapError((error5) => Schema38.is(SessionRepositoryError)(error5) ? error5 : SessionRepositoryError.make({ message: `Invalid Session checkpoint prompt: ${String(error5)}` })));
|
|
6321
6368
|
const clonePrompt = (prompt) => {
|
|
6322
|
-
const wire = prompt.pipe(encodeCheckpointPrompt,
|
|
6323
|
-
return
|
|
6369
|
+
const wire = prompt.pipe(encodeCheckpointPrompt, Schema38.decodeUnknownSync(CheckpointPromptWire));
|
|
6370
|
+
return decodePrompt(wire.prompt);
|
|
6324
6371
|
};
|
|
6325
6372
|
const payloadFromInput = (input) => {
|
|
6326
6373
|
switch (input._tag) {
|
|
@@ -6365,6 +6412,8 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6365
6412
|
return input.version === 2 ? {
|
|
6366
6413
|
version: 2,
|
|
6367
6414
|
projectedHistory: encodeCheckpointPrompt(input.projectedHistory),
|
|
6415
|
+
telemetry: encodeCheckpointTelemetry(input.telemetry),
|
|
6416
|
+
...input.compactionCommit === undefined ? {} : { compactionCommit: encodeCheckpointCommit(input.compactionCommit) },
|
|
6368
6417
|
...input.summary === undefined ? {} : { summary: input.summary },
|
|
6369
6418
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
6370
6419
|
} : {
|
|
@@ -6434,11 +6483,22 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6434
6483
|
summary: String(payload.summary ?? "")
|
|
6435
6484
|
});
|
|
6436
6485
|
case "Compaction":
|
|
6437
|
-
return payload.version === 2 ? decodeCheckpointPrompt(payload.projectedHistory).pipe(Effect39.
|
|
6486
|
+
return payload.version === 2 ? decodeCheckpointPrompt(payload.projectedHistory).pipe(Effect39.flatMap((projectedHistory) => Effect39.try({
|
|
6487
|
+
try: () => ({
|
|
6488
|
+
projectedHistory,
|
|
6489
|
+
telemetry: payload.telemetry === undefined ? [] : decodeCheckpointTelemetry(payload.telemetry),
|
|
6490
|
+
compactionCommit: payload.compactionCommit === undefined ? undefined : decodeCheckpointCommit(payload.compactionCommit)
|
|
6491
|
+
}),
|
|
6492
|
+
catch: (error5) => SessionRepositoryError.make({
|
|
6493
|
+
message: `Invalid Session checkpoint telemetry: ${String(error5)}`
|
|
6494
|
+
})
|
|
6495
|
+
})), Effect39.map(({ projectedHistory, telemetry, compactionCommit }) => ({
|
|
6438
6496
|
...base,
|
|
6439
6497
|
_tag: "Compaction",
|
|
6440
6498
|
version: 2,
|
|
6441
6499
|
projectedHistory,
|
|
6500
|
+
telemetry,
|
|
6501
|
+
...compactionCommit === undefined ? {} : { compactionCommit },
|
|
6442
6502
|
...payload.summary === undefined ? {} : { summary: String(payload.summary) }
|
|
6443
6503
|
}))) : Effect39.succeed({
|
|
6444
6504
|
...base,
|
|
@@ -6457,9 +6517,19 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6457
6517
|
}
|
|
6458
6518
|
};
|
|
6459
6519
|
const promptEquivalence = (left, right) => exports_shared_schema.canonicalEquals(encodeCheckpointPrompt(left), encodeCheckpointPrompt(right));
|
|
6520
|
+
const telemetryEquivalence = (left, right) => exports_shared_schema.canonicalEquals(encodeCheckpointTelemetry(left), encodeCheckpointTelemetry(right));
|
|
6521
|
+
const commitEquivalence = (left, right) => {
|
|
6522
|
+
if (left._tag !== "Compaction" || left.version !== 2 || right._tag !== "Compaction" || right.version !== 2) {
|
|
6523
|
+
return false;
|
|
6524
|
+
}
|
|
6525
|
+
if (left.compactionCommit === undefined || right.compactionCommit === undefined) {
|
|
6526
|
+
return left.compactionCommit === right.compactionCommit;
|
|
6527
|
+
}
|
|
6528
|
+
return exports_shared_schema.canonicalEquals(encodeCheckpointCommit(left.compactionCommit), encodeCheckpointCommit(right.compactionCommit));
|
|
6529
|
+
};
|
|
6460
6530
|
const sameEntry = (left, right) => {
|
|
6461
6531
|
if (left._tag === "Compaction" && left.version === 2 && right._tag === "Compaction" && right.version === 2) {
|
|
6462
|
-
return left.id === right.id && left.sessionId === right.sessionId && left.parentId === right.parentId && left.summary === right.summary && promptEquivalence(left.projectedHistory, right.projectedHistory);
|
|
6532
|
+
return left.id === right.id && left.sessionId === right.sessionId && left.parentId === right.parentId && left.summary === right.summary && promptEquivalence(left.projectedHistory, right.projectedHistory) && telemetryEquivalence(left.telemetry, right.telemetry) && commitEquivalence(left, right);
|
|
6463
6533
|
}
|
|
6464
6534
|
return exports_shared_schema.canonicalEquals(comparableEntry(left), comparableEntry(right));
|
|
6465
6535
|
};
|
|
@@ -6489,25 +6559,25 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6489
6559
|
};
|
|
6490
6560
|
|
|
6491
6561
|
// ../store-sql/src/session/session-records.ts
|
|
6492
|
-
import { Effect as Effect40, Schema as
|
|
6562
|
+
import { Effect as Effect40, Schema as Schema40 } from "effect";
|
|
6493
6563
|
import { SqlClient as SqlClient23 } from "effect/unstable/sql/SqlClient";
|
|
6494
6564
|
|
|
6495
6565
|
// ../store-sql/src/session/session-row.ts
|
|
6496
|
-
import { Schema as
|
|
6497
|
-
var sessionRow =
|
|
6498
|
-
id:
|
|
6499
|
-
root_address_id:
|
|
6500
|
-
leaf_entry_id:
|
|
6501
|
-
owner_execution_id:
|
|
6502
|
-
owner_epoch:
|
|
6503
|
-
owner_released:
|
|
6504
|
-
metadata_json:
|
|
6505
|
-
created_at:
|
|
6506
|
-
updated_at:
|
|
6566
|
+
import { Schema as Schema39 } from "effect";
|
|
6567
|
+
var sessionRow = Schema39.Struct({
|
|
6568
|
+
id: Schema39.String,
|
|
6569
|
+
root_address_id: Schema39.String,
|
|
6570
|
+
leaf_entry_id: Schema39.Union([Schema39.String, Schema39.Null, Schema39.Undefined]),
|
|
6571
|
+
owner_execution_id: Schema39.Union([Schema39.String, Schema39.Null, Schema39.Undefined]),
|
|
6572
|
+
owner_epoch: Schema39.Union([Schema39.Finite, Schema39.String, Schema39.BigInt]),
|
|
6573
|
+
owner_released: Schema39.Union([Schema39.Boolean, Schema39.Finite, Schema39.String, Schema39.BigInt]),
|
|
6574
|
+
metadata_json: Schema39.Unknown,
|
|
6575
|
+
created_at: Schema39.Union([Schema39.Date, Schema39.String, Schema39.Finite]),
|
|
6576
|
+
updated_at: Schema39.Union([Schema39.Date, Schema39.String, Schema39.Finite])
|
|
6507
6577
|
}).annotate({ identifier: "Relay.Session.Row" });
|
|
6508
6578
|
var releasedFlag = (value) => value === true || value === 1 || value === "1" || value === 1n || value === "true";
|
|
6509
|
-
var CountRow =
|
|
6510
|
-
value:
|
|
6579
|
+
var CountRow = Schema39.Struct({
|
|
6580
|
+
value: Schema39.Union([Schema39.Finite, Schema39.String, Schema39.BigInt])
|
|
6511
6581
|
}).annotate({ identifier: "Relay.SessionEntry.CountRow" });
|
|
6512
6582
|
var metadata7 = (input) => input ?? {};
|
|
6513
6583
|
var toSessionRecord = (row) => ({
|
|
@@ -6586,9 +6656,9 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6586
6656
|
return toRepositoryError12(error5);
|
|
6587
6657
|
}));
|
|
6588
6658
|
}
|
|
6589
|
-
const decodeSessionRow = (row) =>
|
|
6590
|
-
const decodeEntryRow = (row) =>
|
|
6591
|
-
const decodeCountRow = (row) =>
|
|
6659
|
+
const decodeSessionRow = (row) => Schema40.decodeUnknownEffect(sessionRow)(row).pipe(Effect40.mapError(toRepositoryError12));
|
|
6660
|
+
const decodeEntryRow = (row) => Schema40.decodeUnknownEffect(sessionEntryRow)(row).pipe(Effect40.mapError(toRepositoryError12));
|
|
6661
|
+
const decodeCountRow = (row) => Schema40.decodeUnknownEffect(CountRow)(row).pipe(Effect40.mapError(toRepositoryError12));
|
|
6592
6662
|
const selectSessionByKey = (tenantId, id) => sql`
|
|
6593
6663
|
SELECT id, root_address_id, leaf_entry_id, owner_execution_id, owner_epoch, owner_released, metadata_json, created_at, updated_at
|
|
6594
6664
|
FROM relay_sessions
|
|
@@ -6822,6 +6892,8 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6822
6892
|
_tag: "Compaction",
|
|
6823
6893
|
version: 2,
|
|
6824
6894
|
projectedHistory: input.projectedHistory,
|
|
6895
|
+
telemetry: input.telemetry,
|
|
6896
|
+
...input.compactionCommit === undefined ? {} : { compactionCommit: input.compactionCommit },
|
|
6825
6897
|
...input.summary === undefined ? {} : { summary: input.summary }
|
|
6826
6898
|
},
|
|
6827
6899
|
createdAt: input.createdAt
|
|
@@ -6912,19 +6984,19 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6912
6984
|
});
|
|
6913
6985
|
|
|
6914
6986
|
// ../store-sql/src/session/session-repository.ts
|
|
6915
|
-
class SessionRepositoryError extends
|
|
6916
|
-
message:
|
|
6987
|
+
class SessionRepositoryError extends Schema41.TaggedErrorClass()("SessionRepositoryError", {
|
|
6988
|
+
message: Schema41.String
|
|
6917
6989
|
}) {
|
|
6918
6990
|
}
|
|
6919
6991
|
|
|
6920
|
-
class DuplicateSession extends
|
|
6992
|
+
class DuplicateSession extends Schema41.TaggedErrorClass()("DuplicateSession", {
|
|
6921
6993
|
id: exports_ids_schema.SessionId
|
|
6922
6994
|
}) {
|
|
6923
6995
|
}
|
|
6924
6996
|
|
|
6925
|
-
class SessionConflict extends
|
|
6926
|
-
reason:
|
|
6927
|
-
message:
|
|
6997
|
+
class SessionConflict extends Schema41.TaggedErrorClass()("SessionConflict", {
|
|
6998
|
+
reason: Schema41.Literals(["stale-leaf", "checkpoint-id-reused", "checkpoint-not-on-active-path", "fenced"]),
|
|
6999
|
+
message: Schema41.String
|
|
6928
7000
|
}) {
|
|
6929
7001
|
}
|
|
6930
7002
|
|
|
@@ -7091,6 +7163,8 @@ var memoryLayer26 = Layer35.sync(Service35, () => {
|
|
|
7091
7163
|
_tag: "Compaction",
|
|
7092
7164
|
version: 2,
|
|
7093
7165
|
projectedHistory: input.projectedHistory,
|
|
7166
|
+
telemetry: input.telemetry,
|
|
7167
|
+
...input.compactionCommit === undefined ? {} : { compactionCommit: input.compactionCommit },
|
|
7094
7168
|
...input.summary === undefined ? {} : { summary: input.summary }
|
|
7095
7169
|
},
|
|
7096
7170
|
createdAt: input.createdAt
|
|
@@ -7150,6 +7224,14 @@ var ensure = Effect41.fn("SessionRepository.ensure.call")(function* (input) {
|
|
|
7150
7224
|
const repository = yield* Service35;
|
|
7151
7225
|
return yield* repository.ensure(input);
|
|
7152
7226
|
});
|
|
7227
|
+
var claimWriter = Effect41.fn("SessionRepository.claimWriter.call")(function* (input) {
|
|
7228
|
+
const repository = yield* Service35;
|
|
7229
|
+
return yield* repository.claimWriter(input);
|
|
7230
|
+
});
|
|
7231
|
+
var releaseWriter = Effect41.fn("SessionRepository.releaseWriter.call")(function* (input) {
|
|
7232
|
+
const repository = yield* Service35;
|
|
7233
|
+
return yield* repository.releaseWriter(input);
|
|
7234
|
+
});
|
|
7153
7235
|
var get9 = Effect41.fn("SessionRepository.get.call")(function* (id) {
|
|
7154
7236
|
const repository = yield* Service35;
|
|
7155
7237
|
return yield* repository.get(id);
|
|
@@ -7206,36 +7288,36 @@ __export(exports_skill_definition_repository, {
|
|
|
7206
7288
|
Service: () => Service36,
|
|
7207
7289
|
ExecutionSkillPinRow: () => ExecutionSkillPinRow
|
|
7208
7290
|
});
|
|
7209
|
-
import { Context as Context34, Effect as Effect42, HashSet, Layer as Layer36, Schema as
|
|
7291
|
+
import { Context as Context34, Effect as Effect42, HashSet, Layer as Layer36, Schema as Schema42, Semaphore as Semaphore4 } from "effect";
|
|
7210
7292
|
import { SqlClient as SqlClient24 } from "effect/unstable/sql/SqlClient";
|
|
7211
|
-
class SkillDefinitionRepositoryError extends
|
|
7212
|
-
message:
|
|
7293
|
+
class SkillDefinitionRepositoryError extends Schema42.TaggedErrorClass()("SkillDefinitionRepositoryError", {
|
|
7294
|
+
message: Schema42.String
|
|
7213
7295
|
}) {
|
|
7214
7296
|
}
|
|
7215
7297
|
|
|
7216
7298
|
class Service36 extends Context34.Service()("@relayfx/store-sql/skill/skill-definition-repository/Service") {
|
|
7217
7299
|
}
|
|
7218
|
-
var SkillDefinitionRow =
|
|
7219
|
-
id:
|
|
7220
|
-
current_revision:
|
|
7221
|
-
definition_json:
|
|
7222
|
-
created_at:
|
|
7223
|
-
updated_at:
|
|
7300
|
+
var SkillDefinitionRow = Schema42.Struct({
|
|
7301
|
+
id: Schema42.String,
|
|
7302
|
+
current_revision: Schema42.Finite,
|
|
7303
|
+
definition_json: Schema42.Unknown,
|
|
7304
|
+
created_at: Schema42.Union([Schema42.Date, Schema42.String, Schema42.Finite]),
|
|
7305
|
+
updated_at: Schema42.Union([Schema42.Date, Schema42.String, Schema42.Finite])
|
|
7224
7306
|
}).annotate({ identifier: "Relay.SkillDefinition.Row" });
|
|
7225
|
-
var SkillDefinitionRevisionRow =
|
|
7226
|
-
skill_definition_id:
|
|
7227
|
-
revision:
|
|
7228
|
-
definition_json:
|
|
7229
|
-
created_at:
|
|
7307
|
+
var SkillDefinitionRevisionRow = Schema42.Struct({
|
|
7308
|
+
skill_definition_id: Schema42.String,
|
|
7309
|
+
revision: Schema42.Finite,
|
|
7310
|
+
definition_json: Schema42.Unknown,
|
|
7311
|
+
created_at: Schema42.Union([Schema42.Date, Schema42.String, Schema42.Finite])
|
|
7230
7312
|
}).annotate({ identifier: "Relay.SkillDefinitionRevision.Row" });
|
|
7231
|
-
var ExecutionSkillPinRow =
|
|
7232
|
-
execution_id:
|
|
7233
|
-
skill_definition_id:
|
|
7234
|
-
skill_definition_revision:
|
|
7235
|
-
skill_definition_snapshot_json:
|
|
7236
|
-
created_at:
|
|
7313
|
+
var ExecutionSkillPinRow = Schema42.Struct({
|
|
7314
|
+
execution_id: Schema42.String,
|
|
7315
|
+
skill_definition_id: Schema42.String,
|
|
7316
|
+
skill_definition_revision: Schema42.Finite,
|
|
7317
|
+
skill_definition_snapshot_json: Schema42.Unknown,
|
|
7318
|
+
created_at: Schema42.Union([Schema42.Date, Schema42.String, Schema42.Finite])
|
|
7237
7319
|
}).annotate({ identifier: "Relay.ExecutionSkillPin.Row" });
|
|
7238
|
-
var cloneDefinition3 = (definition) =>
|
|
7320
|
+
var cloneDefinition3 = (definition) => Schema42.decodeUnknownSync(exports_skill_schema.Definition)(globalThis.structuredClone(definition));
|
|
7239
7321
|
var toRecord10 = (row) => ({
|
|
7240
7322
|
id: exports_ids_schema.SkillDefinitionId.make(row.id),
|
|
7241
7323
|
currentRevision: row.current_revision,
|
|
@@ -7291,11 +7373,11 @@ var missingSkillMessage = (requested, records) => {
|
|
|
7291
7373
|
return `Skill definition not found: ${requested.find((id) => !HashSet.has(found, id)) ?? requested[0]}`;
|
|
7292
7374
|
};
|
|
7293
7375
|
var toRepositoryError12 = (error5) => SkillDefinitionRepositoryError.make({ message: String(error5) });
|
|
7294
|
-
var mapPutError2 = (error5) =>
|
|
7295
|
-
var isUniqueViolation = (error5) => !
|
|
7296
|
-
var decodeRow12 = (row) =>
|
|
7297
|
-
var decodeRevisionRow2 = (row) =>
|
|
7298
|
-
var decodePinRow = (row) =>
|
|
7376
|
+
var mapPutError2 = (error5) => Schema42.is(SkillDefinitionRepositoryError)(error5) ? error5 : toRepositoryError12(error5);
|
|
7377
|
+
var isUniqueViolation = (error5) => !Schema42.is(SkillDefinitionRepositoryError)(error5) && /unique|duplicate/i.test(String(error5));
|
|
7378
|
+
var decodeRow12 = (row) => Schema42.decodeUnknownEffect(SkillDefinitionRow)(row).pipe(Effect42.mapError(toRepositoryError12));
|
|
7379
|
+
var decodeRevisionRow2 = (row) => Schema42.decodeUnknownEffect(SkillDefinitionRevisionRow)(row).pipe(Effect42.mapError(toRepositoryError12));
|
|
7380
|
+
var decodePinRow = (row) => Schema42.decodeUnknownEffect(ExecutionSkillPinRow)(row).pipe(Effect42.mapError(toRepositoryError12));
|
|
7299
7381
|
var layer29 = Layer36.effect(Service36, Effect42.gen(function* () {
|
|
7300
7382
|
const sql = yield* SqlClient24;
|
|
7301
7383
|
const columns3 = sql.literal(["id", "current_revision", "definition_json", "created_at", "updated_at"].join(", "));
|
|
@@ -7632,37 +7714,37 @@ __export(exports_steering_repository, {
|
|
|
7632
7714
|
SteeringDrainRow: () => SteeringDrainRow,
|
|
7633
7715
|
Service: () => Service37
|
|
7634
7716
|
});
|
|
7635
|
-
import { Context as Context35, Effect as Effect43, Layer as Layer37, Ref as Ref9, Schema as
|
|
7717
|
+
import { Context as Context35, Effect as Effect43, Layer as Layer37, Ref as Ref9, Schema as Schema43 } from "effect";
|
|
7636
7718
|
import { SqlClient as SqlClient25 } from "effect/unstable/sql/SqlClient";
|
|
7637
|
-
class SteeringRepositoryError extends
|
|
7638
|
-
message:
|
|
7719
|
+
class SteeringRepositoryError extends Schema43.TaggedErrorClass()("SteeringRepositoryError", {
|
|
7720
|
+
message: Schema43.String
|
|
7639
7721
|
}) {
|
|
7640
7722
|
}
|
|
7641
7723
|
|
|
7642
7724
|
class Service37 extends Context35.Service()("@relayfx/store-sql/steering/steering-repository/Service") {
|
|
7643
7725
|
}
|
|
7644
|
-
var SteeringKindSchema =
|
|
7645
|
-
var DbTimestamp4 =
|
|
7646
|
-
var SteeringMessageRow =
|
|
7647
|
-
execution_id:
|
|
7726
|
+
var SteeringKindSchema = Schema43.Literals(["steering", "follow_up"]);
|
|
7727
|
+
var DbTimestamp4 = Schema43.Union([Schema43.Date, Schema43.String, Schema43.Finite]);
|
|
7728
|
+
var SteeringMessageRow = Schema43.Struct({
|
|
7729
|
+
execution_id: Schema43.String,
|
|
7648
7730
|
kind: SteeringKindSchema,
|
|
7649
|
-
sequence:
|
|
7650
|
-
content_json:
|
|
7651
|
-
drain_id:
|
|
7652
|
-
consumed_at:
|
|
7731
|
+
sequence: Schema43.Union([Schema43.Finite, Schema43.String]),
|
|
7732
|
+
content_json: Schema43.Unknown,
|
|
7733
|
+
drain_id: Schema43.NullishOr(Schema43.String),
|
|
7734
|
+
consumed_at: Schema43.NullishOr(DbTimestamp4),
|
|
7653
7735
|
created_at: DbTimestamp4
|
|
7654
7736
|
}).annotate({ identifier: "Relay.SteeringMessage.Row" });
|
|
7655
|
-
var SteeringDrainRow =
|
|
7656
|
-
execution_id:
|
|
7737
|
+
var SteeringDrainRow = Schema43.Struct({
|
|
7738
|
+
execution_id: Schema43.String,
|
|
7657
7739
|
kind: SteeringKindSchema,
|
|
7658
|
-
drain_id:
|
|
7659
|
-
message_sequences_json:
|
|
7740
|
+
drain_id: Schema43.String,
|
|
7741
|
+
message_sequences_json: Schema43.Unknown,
|
|
7660
7742
|
created_at: DbTimestamp4
|
|
7661
7743
|
}).annotate({ identifier: "Relay.SteeringDrain.Row" });
|
|
7662
7744
|
var toRepositoryError13 = (error5) => SteeringRepositoryError.make({ message: String(error5) });
|
|
7663
|
-
var mapTransactionError = (effect) => effect.pipe(Effect43.mapError((error5) =>
|
|
7664
|
-
var decodeMessageRow = (row) =>
|
|
7665
|
-
var decodeDrainRow = (row) =>
|
|
7745
|
+
var mapTransactionError = (effect) => effect.pipe(Effect43.mapError((error5) => Schema43.is(SteeringRepositoryError)(error5) ? error5 : toRepositoryError13(error5)));
|
|
7746
|
+
var decodeMessageRow = (row) => Schema43.decodeUnknownEffect(SteeringMessageRow)(row).pipe(Effect43.mapError(toRepositoryError13));
|
|
7747
|
+
var decodeDrainRow = (row) => Schema43.decodeUnknownEffect(SteeringDrainRow)(row).pipe(Effect43.mapError(toRepositoryError13));
|
|
7666
7748
|
var toMessageRecord = (row) => {
|
|
7667
7749
|
const consumedAt = fromNullableDbTimestamp(row.consumed_at);
|
|
7668
7750
|
return {
|
|
@@ -7971,29 +8053,29 @@ __export(exports_tool_call_repository, {
|
|
|
7971
8053
|
DuplicateToolResult: () => DuplicateToolResult,
|
|
7972
8054
|
DuplicateToolCall: () => DuplicateToolCall
|
|
7973
8055
|
});
|
|
7974
|
-
import { Context as Context36, Effect as Effect47, Layer as Layer38, Schema as
|
|
8056
|
+
import { Context as Context36, Effect as Effect47, Layer as Layer38, Schema as Schema47 } from "effect";
|
|
7975
8057
|
import { dual } from "effect/Function";
|
|
7976
8058
|
|
|
7977
8059
|
// ../store-sql/src/tool/tool-call-records.ts
|
|
7978
|
-
import { Effect as Effect46, Schema as
|
|
8060
|
+
import { Effect as Effect46, Schema as Schema46 } from "effect";
|
|
7979
8061
|
import { SqlClient as SqlClient26 } from "effect/unstable/sql/SqlClient";
|
|
7980
8062
|
import { isSqlError as isSqlError2 } from "effect/unstable/sql/SqlError";
|
|
7981
8063
|
|
|
7982
8064
|
// ../store-sql/src/tool/tool-attempt-records.ts
|
|
7983
|
-
import { Effect as Effect44, Schema as
|
|
7984
|
-
var toolAttemptRow =
|
|
7985
|
-
id:
|
|
7986
|
-
tool_call_id:
|
|
7987
|
-
attempt_number:
|
|
7988
|
-
state:
|
|
7989
|
-
worker_id:
|
|
7990
|
-
claim_expires_at:
|
|
7991
|
-
error:
|
|
7992
|
-
created_at:
|
|
7993
|
-
completed_at:
|
|
8065
|
+
import { Effect as Effect44, Schema as Schema44 } from "effect";
|
|
8066
|
+
var toolAttemptRow = Schema44.Struct({
|
|
8067
|
+
id: Schema44.String,
|
|
8068
|
+
tool_call_id: Schema44.String,
|
|
8069
|
+
attempt_number: Schema44.Union([Schema44.Finite, Schema44.String, Schema44.BigInt]),
|
|
8070
|
+
state: Schema44.String,
|
|
8071
|
+
worker_id: Schema44.NullishOr(Schema44.String),
|
|
8072
|
+
claim_expires_at: Schema44.NullishOr(Schema44.Union([Schema44.Date, Schema44.String, Schema44.Finite])),
|
|
8073
|
+
error: Schema44.NullishOr(Schema44.String),
|
|
8074
|
+
created_at: Schema44.Union([Schema44.Date, Schema44.String, Schema44.Finite]),
|
|
8075
|
+
completed_at: Schema44.NullishOr(Schema44.Union([Schema44.Date, Schema44.String, Schema44.Finite]))
|
|
7994
8076
|
}).annotate({ identifier: "Relay.ToolAttempt.Row" });
|
|
7995
|
-
var MaxAttemptRow =
|
|
7996
|
-
max_attempt:
|
|
8077
|
+
var MaxAttemptRow = Schema44.Struct({
|
|
8078
|
+
max_attempt: Schema44.NullishOr(Schema44.Union([Schema44.Finite, Schema44.String, Schema44.BigInt]))
|
|
7997
8079
|
});
|
|
7998
8080
|
var toolAttemptId = (attemptNumber) => exports_ids_schema.ToolAttemptId.make(`tool-attempt:${attemptNumber}`);
|
|
7999
8081
|
var makeToolAttemptRecordOperations = ({
|
|
@@ -8017,15 +8099,15 @@ var makeToolAttemptRecordOperations = ({
|
|
|
8017
8099
|
id: exports_ids_schema.ToolAttemptId.make(row.id),
|
|
8018
8100
|
callId: exports_ids_schema.ToolCallId.make(row.tool_call_id),
|
|
8019
8101
|
attemptNumber: Number(row.attempt_number),
|
|
8020
|
-
state:
|
|
8102
|
+
state: Schema44.decodeUnknownSync(exports_tool_schema.AttemptState)(row.state),
|
|
8021
8103
|
...row.worker_id === null || row.worker_id === undefined ? {} : { workerId: row.worker_id },
|
|
8022
8104
|
...row.claim_expires_at === null || row.claim_expires_at === undefined ? {} : { claimExpiresAt: fromDbTimestamp(row.claim_expires_at) },
|
|
8023
8105
|
...row.error === null || row.error === undefined ? {} : { error: row.error },
|
|
8024
8106
|
createdAt: fromDbTimestamp(row.created_at),
|
|
8025
8107
|
...row.completed_at === null || row.completed_at === undefined ? {} : { completedAt: fromDbTimestamp(row.completed_at) }
|
|
8026
8108
|
});
|
|
8027
|
-
const decodeAttemptRow = (row) =>
|
|
8028
|
-
const decodeMaxAttemptRow = (row) =>
|
|
8109
|
+
const decodeAttemptRow = (row) => Schema44.decodeUnknownEffect(toolAttemptRow)(row).pipe(Effect44.mapError(toRepositoryError14));
|
|
8110
|
+
const decodeMaxAttemptRow = (row) => Schema44.decodeUnknownEffect(Schema44.UndefinedOr(MaxAttemptRow))(row).pipe(Effect44.mapError(toRepositoryError14));
|
|
8029
8111
|
const selectAttempts = (tenantId, executionId, callId) => sql`
|
|
8030
8112
|
SELECT ${attemptColumns}
|
|
8031
8113
|
FROM relay_tool_attempts
|
|
@@ -8108,13 +8190,13 @@ var makeToolAttemptRecordOperations = ({
|
|
|
8108
8190
|
};
|
|
8109
8191
|
|
|
8110
8192
|
// ../store-sql/src/tool/tool-work-operations.ts
|
|
8111
|
-
import { Effect as Effect45, Schema as
|
|
8112
|
-
var ExpiredCallRow =
|
|
8113
|
-
id:
|
|
8114
|
-
execution_id:
|
|
8115
|
-
active_attempt_id:
|
|
8193
|
+
import { Effect as Effect45, Schema as Schema45 } from "effect";
|
|
8194
|
+
var ExpiredCallRow = Schema45.Struct({
|
|
8195
|
+
id: Schema45.String,
|
|
8196
|
+
execution_id: Schema45.String,
|
|
8197
|
+
active_attempt_id: Schema45.NullishOr(Schema45.String)
|
|
8116
8198
|
});
|
|
8117
|
-
var IdRow =
|
|
8199
|
+
var IdRow = Schema45.Struct({ id: Schema45.String, execution_id: Schema45.String });
|
|
8118
8200
|
var makeToolWorkOperations = ({
|
|
8119
8201
|
records,
|
|
8120
8202
|
attempts,
|
|
@@ -8277,7 +8359,7 @@ var makeToolWorkOperations = ({
|
|
|
8277
8359
|
WHERE tenant_id = ${tenantId} AND placement_kind = 'remote' AND placement_key = ${input.queue}
|
|
8278
8360
|
AND state = 'running' AND claim_expires_at IS NOT NULL AND claim_expires_at <= ${ts(input.now)}
|
|
8279
8361
|
`.pipe(Effect45.mapError(toRepositoryError14));
|
|
8280
|
-
const expired = yield*
|
|
8362
|
+
const expired = yield* Schema45.decodeUnknownEffect(Schema45.Array(ExpiredCallRow))(expiredRows).pipe(Effect45.mapError(toRepositoryError14));
|
|
8281
8363
|
for (const row of expired) {
|
|
8282
8364
|
const executionId2 = exports_ids_schema.ExecutionId.make(row.execution_id);
|
|
8283
8365
|
if (row.active_attempt_id !== null && row.active_attempt_id !== undefined) {
|
|
@@ -8291,7 +8373,7 @@ var makeToolWorkOperations = ({
|
|
|
8291
8373
|
`.pipe(Effect45.mapError(toRepositoryError14));
|
|
8292
8374
|
}
|
|
8293
8375
|
const candidateRows = yield* selectClaimCandidate(tenantId, input).pipe(Effect45.mapError(toRepositoryError14));
|
|
8294
|
-
const candidates = yield*
|
|
8376
|
+
const candidates = yield* Schema45.decodeUnknownEffect(Schema45.Array(IdRow))(candidateRows).pipe(Effect45.mapError(toRepositoryError14));
|
|
8295
8377
|
const candidate = candidates[0];
|
|
8296
8378
|
if (candidate === undefined)
|
|
8297
8379
|
return;
|
|
@@ -8466,54 +8548,54 @@ var makeToolWorkOperations = ({
|
|
|
8466
8548
|
};
|
|
8467
8549
|
|
|
8468
8550
|
// ../store-sql/src/tool/tool-call-records.ts
|
|
8469
|
-
var toolCallRow =
|
|
8470
|
-
id:
|
|
8471
|
-
execution_id:
|
|
8472
|
-
name:
|
|
8473
|
-
input_json:
|
|
8474
|
-
definition_json:
|
|
8475
|
-
placement_kind:
|
|
8476
|
-
placement_key:
|
|
8477
|
-
state:
|
|
8478
|
-
wait_id:
|
|
8479
|
-
idempotency_key:
|
|
8480
|
-
available_at:
|
|
8481
|
-
active_attempt_id:
|
|
8482
|
-
claim_owner:
|
|
8483
|
-
claimed_at:
|
|
8484
|
-
claim_expires_at:
|
|
8485
|
-
external_outcome_json:
|
|
8486
|
-
external_outcome_at:
|
|
8487
|
-
metadata_json:
|
|
8488
|
-
created_at:
|
|
8489
|
-
updated_at:
|
|
8551
|
+
var toolCallRow = Schema46.Struct({
|
|
8552
|
+
id: Schema46.String,
|
|
8553
|
+
execution_id: Schema46.String,
|
|
8554
|
+
name: Schema46.String,
|
|
8555
|
+
input_json: Schema46.Unknown,
|
|
8556
|
+
definition_json: Schema46.NullishOr(Schema46.Unknown),
|
|
8557
|
+
placement_kind: Schema46.String,
|
|
8558
|
+
placement_key: Schema46.NullishOr(Schema46.String),
|
|
8559
|
+
state: Schema46.String,
|
|
8560
|
+
wait_id: Schema46.NullishOr(Schema46.String),
|
|
8561
|
+
idempotency_key: Schema46.String,
|
|
8562
|
+
available_at: Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite]),
|
|
8563
|
+
active_attempt_id: Schema46.NullishOr(Schema46.String),
|
|
8564
|
+
claim_owner: Schema46.NullishOr(Schema46.String),
|
|
8565
|
+
claimed_at: Schema46.NullishOr(Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])),
|
|
8566
|
+
claim_expires_at: Schema46.NullishOr(Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])),
|
|
8567
|
+
external_outcome_json: Schema46.NullishOr(Schema46.Unknown),
|
|
8568
|
+
external_outcome_at: Schema46.NullishOr(Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])),
|
|
8569
|
+
metadata_json: Schema46.Unknown,
|
|
8570
|
+
created_at: Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite]),
|
|
8571
|
+
updated_at: Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])
|
|
8490
8572
|
}).annotate({ identifier: "Relay.ToolCall.Row" });
|
|
8491
|
-
var toolResultRow =
|
|
8492
|
-
tool_call_id:
|
|
8493
|
-
output_json:
|
|
8494
|
-
error:
|
|
8495
|
-
metadata_json:
|
|
8496
|
-
created_at:
|
|
8573
|
+
var toolResultRow = Schema46.Struct({
|
|
8574
|
+
tool_call_id: Schema46.String,
|
|
8575
|
+
output_json: Schema46.Unknown,
|
|
8576
|
+
error: Schema46.NullishOr(Schema46.String),
|
|
8577
|
+
metadata_json: Schema46.Unknown,
|
|
8578
|
+
created_at: Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])
|
|
8497
8579
|
}).annotate({ identifier: "Relay.ToolResult.Row" });
|
|
8498
8580
|
var metadata8 = (input) => input ?? {};
|
|
8499
8581
|
var normalizeCall = (call) => ({ ...call, metadata: metadata8(call.metadata) });
|
|
8500
8582
|
var sameCallIdentity = (left, right) => exports_shared_schema.canonicalEquals(normalizeCall(left), normalizeCall(right));
|
|
8501
8583
|
var toolCallRecordIdentity = { sameCallIdentity };
|
|
8502
|
-
var placementFromRow = (row) =>
|
|
8584
|
+
var placementFromRow = (row) => Schema46.decodeUnknownSync(exports_tool_schema.Placement)(row.placement_kind === "remote" ? { kind: "remote", queue: row.placement_key } : row.placement_kind === "mcp" ? { kind: "mcp", server_id: row.placement_key } : { kind: row.placement_kind });
|
|
8503
8585
|
var toCallRecord = (row) => {
|
|
8504
|
-
const definition = row.definition_json === null || row.definition_json === undefined ? undefined :
|
|
8505
|
-
const outcome = row.external_outcome_json === null || row.external_outcome_json === undefined ? undefined :
|
|
8586
|
+
const definition = row.definition_json === null || row.definition_json === undefined ? undefined : Schema46.decodeUnknownSync(exports_tool_schema.Definition)(decodeJson(row.definition_json));
|
|
8587
|
+
const outcome = row.external_outcome_json === null || row.external_outcome_json === undefined ? undefined : Schema46.decodeUnknownSync(exports_tool_schema.ExternalOutcome)(decodeJson(row.external_outcome_json));
|
|
8506
8588
|
return {
|
|
8507
8589
|
executionId: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
8508
8590
|
call: normalizeCall({
|
|
8509
8591
|
id: exports_ids_schema.ToolCallId.make(row.id),
|
|
8510
8592
|
name: row.name,
|
|
8511
|
-
input:
|
|
8512
|
-
metadata:
|
|
8593
|
+
input: Schema46.decodeUnknownSync(exports_shared_schema.JsonValue)(decodeJson(row.input_json)),
|
|
8594
|
+
metadata: Schema46.decodeUnknownSync(exports_shared_schema.Metadata)(decodeJson(row.metadata_json))
|
|
8513
8595
|
}),
|
|
8514
8596
|
...definition === undefined ? {} : { definition },
|
|
8515
8597
|
placement: placementFromRow(row),
|
|
8516
|
-
state:
|
|
8598
|
+
state: Schema46.decodeUnknownSync(exports_tool_schema.CallState)(row.state),
|
|
8517
8599
|
...row.wait_id === null || row.wait_id === undefined ? {} : { waitId: exports_ids_schema.WaitId.make(row.wait_id) },
|
|
8518
8600
|
idempotencyKey: row.idempotency_key,
|
|
8519
8601
|
availableAt: fromDbTimestamp(row.available_at),
|
|
@@ -8530,9 +8612,9 @@ var toCallRecord = (row) => {
|
|
|
8530
8612
|
var toResultRecord = (row) => ({
|
|
8531
8613
|
result: {
|
|
8532
8614
|
call_id: exports_ids_schema.ToolCallId.make(row.tool_call_id),
|
|
8533
|
-
output:
|
|
8615
|
+
output: Schema46.decodeUnknownSync(exports_shared_schema.JsonValue)(decodeJson(row.output_json)),
|
|
8534
8616
|
...row.error === null || row.error === undefined ? {} : { error: row.error },
|
|
8535
|
-
metadata:
|
|
8617
|
+
metadata: Schema46.decodeUnknownSync(exports_shared_schema.Metadata)(decodeJson(row.metadata_json))
|
|
8536
8618
|
},
|
|
8537
8619
|
createdAt: fromDbTimestamp(row.created_at)
|
|
8538
8620
|
});
|
|
@@ -8649,8 +8731,8 @@ var makeToolCallRecordSupport = ({ sql, errors, toolCallIdempotencyKey }) => {
|
|
|
8649
8731
|
`,
|
|
8650
8732
|
orElse: () => selectCallByKey
|
|
8651
8733
|
});
|
|
8652
|
-
const decodeCallRow = (row) =>
|
|
8653
|
-
const decodeResultRow = (row) =>
|
|
8734
|
+
const decodeCallRow = (row) => Schema46.decodeUnknownEffect(toolCallRow)(row).pipe(Effect46.mapError(toRepositoryError14));
|
|
8735
|
+
const decodeResultRow = (row) => Schema46.decodeUnknownEffect(toolResultRow)(row).pipe(Effect46.mapError(toRepositoryError14));
|
|
8654
8736
|
const decodeCall = Effect46.fn("ToolCallRepository.decodeCall")(function* (row) {
|
|
8655
8737
|
const decoded = yield* decodeCallRow(row);
|
|
8656
8738
|
return yield* Effect46.try({ try: () => toCallRecord(decoded), catch: toRepositoryError14 });
|
|
@@ -8782,44 +8864,44 @@ var makeToolCallRepository = ({
|
|
|
8782
8864
|
});
|
|
8783
8865
|
|
|
8784
8866
|
// ../store-sql/src/tool/tool-call-repository.ts
|
|
8785
|
-
class ToolCallRepositoryError extends
|
|
8786
|
-
message:
|
|
8867
|
+
class ToolCallRepositoryError extends Schema47.TaggedErrorClass()("ToolCallRepositoryError", {
|
|
8868
|
+
message: Schema47.String
|
|
8787
8869
|
}) {
|
|
8788
8870
|
}
|
|
8789
8871
|
|
|
8790
|
-
class ToolCallNotFound extends
|
|
8872
|
+
class ToolCallNotFound extends Schema47.TaggedErrorClass()("ToolCallNotFound", {
|
|
8791
8873
|
id: exports_ids_schema.ToolCallId
|
|
8792
8874
|
}) {
|
|
8793
8875
|
}
|
|
8794
8876
|
|
|
8795
|
-
class DuplicateToolCall extends
|
|
8877
|
+
class DuplicateToolCall extends Schema47.TaggedErrorClass()("DuplicateToolCall", {
|
|
8796
8878
|
id: exports_ids_schema.ToolCallId
|
|
8797
8879
|
}) {
|
|
8798
8880
|
}
|
|
8799
8881
|
|
|
8800
|
-
class DuplicateToolResult extends
|
|
8882
|
+
class DuplicateToolResult extends Schema47.TaggedErrorClass()("DuplicateToolResult", {
|
|
8801
8883
|
call_id: exports_ids_schema.ToolCallId
|
|
8802
8884
|
}) {
|
|
8803
8885
|
}
|
|
8804
8886
|
|
|
8805
|
-
class ToolCallConflict extends
|
|
8887
|
+
class ToolCallConflict extends Schema47.TaggedErrorClass()("ToolCallConflict", {
|
|
8806
8888
|
id: exports_ids_schema.ToolCallId
|
|
8807
8889
|
}) {
|
|
8808
8890
|
}
|
|
8809
8891
|
|
|
8810
|
-
class ToolCallTransitionRejected extends
|
|
8892
|
+
class ToolCallTransitionRejected extends Schema47.TaggedErrorClass()("ToolCallTransitionRejected", {
|
|
8811
8893
|
id: exports_ids_schema.ToolCallId,
|
|
8812
|
-
message:
|
|
8894
|
+
message: Schema47.String
|
|
8813
8895
|
}) {
|
|
8814
8896
|
}
|
|
8815
8897
|
|
|
8816
|
-
class ToolOutcomeConflict extends
|
|
8898
|
+
class ToolOutcomeConflict extends Schema47.TaggedErrorClass()("ToolOutcomeConflict", {
|
|
8817
8899
|
id: exports_ids_schema.ToolCallId
|
|
8818
8900
|
}) {
|
|
8819
8901
|
}
|
|
8820
8902
|
|
|
8821
|
-
class ToolClaimRejected extends
|
|
8822
|
-
message:
|
|
8903
|
+
class ToolClaimRejected extends Schema47.TaggedErrorClass()("ToolClaimRejected", {
|
|
8904
|
+
message: Schema47.String
|
|
8823
8905
|
}) {
|
|
8824
8906
|
}
|
|
8825
8907
|
var lengthPrefixed = (value) => `${[...value].length}:${value}`;
|
|
@@ -9286,57 +9368,57 @@ __export(exports_workspace_lease_repository, {
|
|
|
9286
9368
|
Service: () => Service39,
|
|
9287
9369
|
DuplicateWorkspaceLease: () => DuplicateWorkspaceLease
|
|
9288
9370
|
});
|
|
9289
|
-
import { Context as Context37, Effect as Effect48, Layer as Layer39, Schema as
|
|
9371
|
+
import { Context as Context37, Effect as Effect48, Layer as Layer39, Schema as Schema48 } from "effect";
|
|
9290
9372
|
import { SqlClient as SqlClient27 } from "effect/unstable/sql/SqlClient";
|
|
9291
|
-
class WorkspaceLeaseRepositoryError extends
|
|
9292
|
-
message:
|
|
9373
|
+
class WorkspaceLeaseRepositoryError extends Schema48.TaggedErrorClass()("WorkspaceLeaseRepositoryError", {
|
|
9374
|
+
message: Schema48.String
|
|
9293
9375
|
}) {
|
|
9294
9376
|
}
|
|
9295
9377
|
|
|
9296
|
-
class DuplicateWorkspaceLease extends
|
|
9378
|
+
class DuplicateWorkspaceLease extends Schema48.TaggedErrorClass()("DuplicateWorkspaceLease", {
|
|
9297
9379
|
execution_id: exports_ids_schema.ExecutionId
|
|
9298
9380
|
}) {
|
|
9299
9381
|
}
|
|
9300
9382
|
|
|
9301
|
-
class WorkspaceLeaseNotFound extends
|
|
9383
|
+
class WorkspaceLeaseNotFound extends Schema48.TaggedErrorClass()("WorkspaceLeaseNotFound", {
|
|
9302
9384
|
execution_id: exports_ids_schema.ExecutionId
|
|
9303
9385
|
}) {
|
|
9304
9386
|
}
|
|
9305
9387
|
|
|
9306
9388
|
class Service39 extends Context37.Service()("@relayfx/store-sql/workspace/workspace-lease-repository/Service") {
|
|
9307
9389
|
}
|
|
9308
|
-
var WorkspaceLeaseRow =
|
|
9309
|
-
id:
|
|
9310
|
-
execution_id:
|
|
9311
|
-
provider_key:
|
|
9312
|
-
sandbox_ref:
|
|
9313
|
-
latest_snapshot_ref:
|
|
9314
|
-
status:
|
|
9315
|
-
resume_strategy:
|
|
9316
|
-
region:
|
|
9317
|
-
request_json:
|
|
9318
|
-
metadata_json:
|
|
9319
|
-
created_at:
|
|
9320
|
-
updated_at:
|
|
9390
|
+
var WorkspaceLeaseRow = Schema48.Struct({
|
|
9391
|
+
id: Schema48.String,
|
|
9392
|
+
execution_id: Schema48.String,
|
|
9393
|
+
provider_key: Schema48.String,
|
|
9394
|
+
sandbox_ref: Schema48.NullishOr(Schema48.String),
|
|
9395
|
+
latest_snapshot_ref: Schema48.NullishOr(Schema48.String),
|
|
9396
|
+
status: Schema48.String,
|
|
9397
|
+
resume_strategy: Schema48.String,
|
|
9398
|
+
region: Schema48.NullishOr(Schema48.String),
|
|
9399
|
+
request_json: Schema48.NullishOr(Schema48.Unknown),
|
|
9400
|
+
metadata_json: Schema48.Unknown,
|
|
9401
|
+
created_at: Schema48.Union([Schema48.Date, Schema48.String, Schema48.Finite]),
|
|
9402
|
+
updated_at: Schema48.Union([Schema48.Date, Schema48.String, Schema48.Finite])
|
|
9321
9403
|
}).annotate({ identifier: "Relay.WorkspaceLease.Row" });
|
|
9322
|
-
var WorkspaceSnapshotRow =
|
|
9323
|
-
id:
|
|
9324
|
-
lease_id:
|
|
9325
|
-
execution_id:
|
|
9326
|
-
reason:
|
|
9327
|
-
snapshot_ref:
|
|
9328
|
-
metadata_json:
|
|
9329
|
-
created_at:
|
|
9404
|
+
var WorkspaceSnapshotRow = Schema48.Struct({
|
|
9405
|
+
id: Schema48.String,
|
|
9406
|
+
lease_id: Schema48.String,
|
|
9407
|
+
execution_id: Schema48.String,
|
|
9408
|
+
reason: Schema48.String,
|
|
9409
|
+
snapshot_ref: Schema48.String,
|
|
9410
|
+
metadata_json: Schema48.Unknown,
|
|
9411
|
+
created_at: Schema48.Union([Schema48.Date, Schema48.String, Schema48.Finite])
|
|
9330
9412
|
}).annotate({ identifier: "Relay.WorkspaceSnapshot.Row" });
|
|
9331
9413
|
var metadata9 = (input) => input ?? {};
|
|
9332
9414
|
var terminalStatuses = new Set(["released", "failed"]);
|
|
9333
9415
|
var isActive = (record2) => !terminalStatuses.has(record2.status);
|
|
9334
|
-
var cloneLease = (record2) =>
|
|
9335
|
-
var cloneSnapshot = (record2) =>
|
|
9416
|
+
var cloneLease = (record2) => Schema48.decodeUnknownSync(exports_workspace_schema.WorkspaceLeaseRecord)(globalThis.structuredClone(record2));
|
|
9417
|
+
var cloneSnapshot = (record2) => Schema48.decodeUnknownSync(exports_workspace_schema.WorkspaceSnapshotRecord)(globalThis.structuredClone(record2));
|
|
9336
9418
|
var toRepositoryError14 = (error5) => WorkspaceLeaseRepositoryError.make({ message: String(error5) });
|
|
9337
|
-
var decodeLeaseRow = (row) =>
|
|
9338
|
-
var decodeSnapshotRow = (row) =>
|
|
9339
|
-
var decodeRequest = (value) =>
|
|
9419
|
+
var decodeLeaseRow = (row) => Schema48.decodeUnknownEffect(WorkspaceLeaseRow)(row).pipe(Effect48.mapError(toRepositoryError14));
|
|
9420
|
+
var decodeSnapshotRow = (row) => Schema48.decodeUnknownEffect(WorkspaceSnapshotRow)(row).pipe(Effect48.mapError(toRepositoryError14));
|
|
9421
|
+
var decodeRequest = (value) => Schema48.decodeUnknownSync(exports_workspace_schema.WorkspaceRequest)(decodeJson(value));
|
|
9340
9422
|
var toLeaseRecord = (row) => ({
|
|
9341
9423
|
id: exports_ids_schema.WorkspaceLeaseId.make(row.id),
|
|
9342
9424
|
execution_id: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
@@ -9689,10 +9771,10 @@ __export(exports_workflow_definition_repository, {
|
|
|
9689
9771
|
Service: () => Service40,
|
|
9690
9772
|
RepositoryError: () => RepositoryError
|
|
9691
9773
|
});
|
|
9692
|
-
import { Clock as Clock4, Context as Context38, Effect as Effect49, Layer as Layer40, Schema as
|
|
9774
|
+
import { Clock as Clock4, Context as Context38, Effect as Effect49, Layer as Layer40, Schema as Schema49 } from "effect";
|
|
9693
9775
|
import { SqlClient as SqlClient28 } from "effect/unstable/sql/SqlClient";
|
|
9694
|
-
class RepositoryError extends
|
|
9695
|
-
message:
|
|
9776
|
+
class RepositoryError extends Schema49.TaggedErrorClass()("WorkflowDefinitionRepositoryError", {
|
|
9777
|
+
message: Schema49.String
|
|
9696
9778
|
}) {
|
|
9697
9779
|
}
|
|
9698
9780
|
|
|
@@ -9946,8 +10028,8 @@ var transition2 = (sql, tenant, id, status, now, data) => sql.withTransaction(Ef
|
|
|
9946
10028
|
var decodeDefinition = (row) => ({
|
|
9947
10029
|
id: exports_ids_schema.WorkflowDefinitionId.make(row.workflow_definition_id),
|
|
9948
10030
|
revision: Number(row.revision),
|
|
9949
|
-
digest:
|
|
9950
|
-
definition:
|
|
10031
|
+
digest: Schema49.decodeUnknownSync(exports_workflow_schema.DefinitionDigest)(row.digest),
|
|
10032
|
+
definition: Schema49.decodeUnknownSync(exports_workflow_schema.Definition)(decodeJson(row.definition_json)),
|
|
9951
10033
|
created_at: fromDbTimestamp(row.created_at)
|
|
9952
10034
|
});
|
|
9953
10035
|
var decodeRun = (row) => ({
|
|
@@ -9955,19 +10037,19 @@ var decodeRun = (row) => ({
|
|
|
9955
10037
|
pin: {
|
|
9956
10038
|
workflow_definition_id: exports_ids_schema.WorkflowDefinitionId.make(row.workflow_definition_id),
|
|
9957
10039
|
workflow_definition_revision: Number(row.workflow_definition_revision),
|
|
9958
|
-
workflow_definition_digest:
|
|
10040
|
+
workflow_definition_digest: Schema49.decodeUnknownSync(exports_workflow_schema.DefinitionDigest)(row.workflow_definition_digest)
|
|
9959
10041
|
},
|
|
9960
|
-
status:
|
|
10042
|
+
status: Schema49.decodeUnknownSync(exports_workflow_schema.RunStatus)(row.status),
|
|
9961
10043
|
created_at: fromDbTimestamp(row.created_at),
|
|
9962
10044
|
updated_at: fromDbTimestamp(row.updated_at)
|
|
9963
10045
|
});
|
|
9964
10046
|
var decodeOperation = (row) => ({
|
|
9965
10047
|
execution_id: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
9966
10048
|
operation_id: exports_ids_schema.WorkflowOperationId.make(row.operation_id),
|
|
9967
|
-
status:
|
|
10049
|
+
status: Schema49.decodeUnknownSync(exports_workflow_schema.OperationStatus)(row.status),
|
|
9968
10050
|
...row.fan_out_id === null || row.fan_out_id === undefined ? {} : { fan_out_id: exports_ids_schema.ChildFanOutId.make(row.fan_out_id) },
|
|
9969
10051
|
...row.decision === null || row.decision === undefined ? {} : { decision: Boolean(row.decision) },
|
|
9970
|
-
...row.output_json === null || row.output_json === undefined ? {} : { output:
|
|
10052
|
+
...row.output_json === null || row.output_json === undefined ? {} : { output: Schema49.decodeUnknownSync(exports_workflow_schema.OperationState.fields.output)(decodeJson(row.output_json)) },
|
|
9971
10053
|
...row.attempt === null || row.attempt === undefined ? {} : { attempt: Number(row.attempt) },
|
|
9972
10054
|
...row.backoff_until === null || row.backoff_until === undefined ? {} : { backoff_until: fromDbTimestamp(row.backoff_until) },
|
|
9973
10055
|
...row.compensation_operation_id === null || row.compensation_operation_id === undefined ? {} : { compensation_operation_id: exports_ids_schema.WorkflowOperationId.make(row.compensation_operation_id) },
|
|
@@ -9978,17 +10060,17 @@ var decodeOperation = (row) => ({
|
|
|
9978
10060
|
var decodeLifecycle = (row) => ({
|
|
9979
10061
|
execution_id: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
9980
10062
|
sequence: Number(row.sequence),
|
|
9981
|
-
type:
|
|
10063
|
+
type: Schema49.decodeUnknownSync(exports_workflow_schema.LifecycleEventType)(row.event_type),
|
|
9982
10064
|
...row.operation_id === null || row.operation_id === undefined ? {} : { operation_id: exports_ids_schema.WorkflowOperationId.make(row.operation_id) },
|
|
9983
|
-
...row.data_json === null || row.data_json === undefined ? {} : { data:
|
|
10065
|
+
...row.data_json === null || row.data_json === undefined ? {} : { data: Schema49.decodeUnknownSync(exports_workflow_schema.LifecycleEvent.fields.data)(decodeJson(row.data_json)) },
|
|
9984
10066
|
created_at: fromDbTimestamp(row.created_at)
|
|
9985
10067
|
});
|
|
9986
10068
|
// ../runtime/src/tool/tool-runtime-service.ts
|
|
9987
10069
|
import { Tool as AiTool } from "effect/unstable/ai";
|
|
9988
|
-
import { Chunk, Context as Context41, Effect as Effect55, Function as Function8, HashSet as HashSet3, Layer as Layer45, Option as Option12, Ref as Ref12, Schema as
|
|
10070
|
+
import { Chunk, Context as Context41, Effect as Effect55, Function as Function8, HashSet as HashSet3, Layer as Layer45, Option as Option12, Ref as Ref12, Schema as Schema52, Sink, Stream as Stream10 } from "effect";
|
|
9989
10071
|
|
|
9990
10072
|
// ../runtime/src/execution/event-log-service.ts
|
|
9991
|
-
import { Context as Context39, Effect as Effect53, Function as Function7, Layer as Layer43, Option as Option10, Schema as
|
|
10073
|
+
import { Context as Context39, Effect as Effect53, Function as Function7, Layer as Layer43, Option as Option10, Schema as Schema50, Stream as Stream9 } from "effect";
|
|
9992
10074
|
|
|
9993
10075
|
// ../runtime/src/execution/event-log-memory.ts
|
|
9994
10076
|
import { Effect as Effect51, HashMap as HashMap2, HashSet as HashSet2, Layer as Layer41, Option as Option8, PubSub as PubSub5, Ref as Ref10, Stream as Stream7 } from "effect";
|
|
@@ -10341,14 +10423,14 @@ var makeRepositoryLayer = (eventLog) => {
|
|
|
10341
10423
|
};
|
|
10342
10424
|
|
|
10343
10425
|
// ../runtime/src/execution/event-log-service.ts
|
|
10344
|
-
class EventLogCursorNotFound2 extends
|
|
10426
|
+
class EventLogCursorNotFound2 extends Schema50.TaggedErrorClass()("EventLogCursorNotFound", {
|
|
10345
10427
|
execution_id: exports_ids_schema.ExecutionId,
|
|
10346
10428
|
cursor: exports_shared_schema.NonEmptyString
|
|
10347
10429
|
}) {
|
|
10348
10430
|
}
|
|
10349
10431
|
|
|
10350
|
-
class EventLogError extends
|
|
10351
|
-
message:
|
|
10432
|
+
class EventLogError extends Schema50.TaggedErrorClass()("EventLogError", {
|
|
10433
|
+
message: Schema50.String
|
|
10352
10434
|
}) {
|
|
10353
10435
|
}
|
|
10354
10436
|
|
|
@@ -10417,19 +10499,19 @@ var sumUsage2 = Effect53.fn("EventLog.sumUsage.call")(function* (executionId) {
|
|
|
10417
10499
|
});
|
|
10418
10500
|
|
|
10419
10501
|
// ../runtime/src/wait/wait-service.ts
|
|
10420
|
-
import { Context as Context40, Duration as Duration2, Effect as Effect54, Layer as Layer44, Option as Option11, Schema as
|
|
10421
|
-
class WaitNotFound2 extends
|
|
10502
|
+
import { Context as Context40, Duration as Duration2, Effect as Effect54, Layer as Layer44, Option as Option11, Schema as Schema51 } from "effect";
|
|
10503
|
+
class WaitNotFound2 extends Schema51.TaggedErrorClass()("WaitNotFound", {
|
|
10422
10504
|
wait_id: exports_ids_schema.WaitId
|
|
10423
10505
|
}) {
|
|
10424
10506
|
}
|
|
10425
10507
|
|
|
10426
|
-
class WaitDefinitionMissing extends
|
|
10508
|
+
class WaitDefinitionMissing extends Schema51.TaggedErrorClass()("WaitDefinitionMissing", {
|
|
10427
10509
|
envelope_id: exports_ids_schema.EnvelopeId
|
|
10428
10510
|
}) {
|
|
10429
10511
|
}
|
|
10430
10512
|
|
|
10431
|
-
class WaitServiceError extends
|
|
10432
|
-
message:
|
|
10513
|
+
class WaitServiceError extends Schema51.TaggedErrorClass()("WaitServiceError", {
|
|
10514
|
+
message: Schema51.String
|
|
10433
10515
|
}) {
|
|
10434
10516
|
}
|
|
10435
10517
|
|
|
@@ -10709,20 +10791,20 @@ var upsertTool = (registry, tool) => {
|
|
|
10709
10791
|
return Chunk.map(registry, (registered) => registered.definition.name === tool.definition.name ? tool : registered);
|
|
10710
10792
|
};
|
|
10711
10793
|
var registerTool = (tools, tool) => Ref12.update(tools, (registry) => upsertTool(registry, tool));
|
|
10712
|
-
var jsonValue2 = (value) =>
|
|
10713
|
-
var fallbackParametersSchema =
|
|
10794
|
+
var jsonValue2 = (value) => Schema52.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
10795
|
+
var fallbackParametersSchema = Schema52.Struct({});
|
|
10714
10796
|
var parametersForInputSchema = (inputSchema) => {
|
|
10715
10797
|
const schema = exports_tool_schema.parametersSchema(inputSchema);
|
|
10716
10798
|
return schema.ast._tag === "Unknown" || schema.ast._tag === "Declaration" ? { parameters: fallbackParametersSchema, jsonSchema: inputSchema } : { parameters: schema };
|
|
10717
10799
|
};
|
|
10718
10800
|
var attachJsonSchema = (tool, jsonSchema) => jsonSchema === undefined ? tool : Object.assign(tool, { jsonSchema });
|
|
10719
|
-
var isStructFieldMap = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((field) =>
|
|
10801
|
+
var isStructFieldMap = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((field) => Schema52.isSchema(field));
|
|
10720
10802
|
var jsonSchemaFromEffectToolParameters = (tool) => {
|
|
10721
10803
|
const parameters = tool.parametersSchema;
|
|
10722
|
-
if (
|
|
10804
|
+
if (Schema52.isSchema(parameters))
|
|
10723
10805
|
return AiTool.getJsonSchema(tool);
|
|
10724
10806
|
if (isStructFieldMap(parameters))
|
|
10725
|
-
return AiTool.getJsonSchemaFromSchema(
|
|
10807
|
+
return AiTool.getJsonSchemaFromSchema(Schema52.Struct(parameters));
|
|
10726
10808
|
return AiTool.getJsonSchema(tool);
|
|
10727
10809
|
};
|
|
10728
10810
|
var runHandledToolkitTool = (toolkit, name, input, services) => {
|
|
@@ -10736,7 +10818,7 @@ var runHandledToolkitTool = (toolkit, name, input, services) => {
|
|
|
10736
10818
|
message: "Tool handler did not produce a final result"
|
|
10737
10819
|
})),
|
|
10738
10820
|
onSome: (result) => result.isFailure ? Effect55.fail(ToolExecutionFailed.make({ tool_name: String(name), message: String(result.result) })) : Effect55.succeed(jsonValue2(result.encodedResult))
|
|
10739
|
-
})), Effect55.provide(services), Effect55.mapError((error5) =>
|
|
10821
|
+
})), Effect55.provide(services), Effect55.mapError((error5) => Schema52.is(ToolExecutionFailed)(error5) ? error5 : ToolExecutionFailed.make({ tool_name: String(name), message: String(error5) })));
|
|
10740
10822
|
};
|
|
10741
10823
|
var finalToolResult = (tool, input, idempotencyKey) => Effect55.gen(function* () {
|
|
10742
10824
|
if (tool.run === undefined) {
|
|
@@ -10833,7 +10915,7 @@ var recordRequested = (repository, eventLog, input, tool) => repository.ensureCa
|
|
|
10833
10915
|
var repairResultEvent = (eventLog, input, record2) => ensureToolEvent(eventLog, resultEvent({ ...input, createdAt: record2.createdAt - 1 }, record2.result, input.eventSequence + 1));
|
|
10834
10916
|
var persistReceived = (repository, input, result) => repository.recordResult({ executionId: input.executionId, result, createdAt: input.createdAt + 1 }).pipe(Effect55.catchTag("DuplicateToolResult", () => repository.getResult(input.executionId, result.call_id).pipe(Effect55.mapError(mapRepositoryError2), Effect55.flatMap((existing) => existing === undefined ? Effect55.fail(ToolRuntimeError.make({ message: "DuplicateToolResult" })) : Effect55.succeed(existing)))), Effect55.mapError(preserveRecordResultError));
|
|
10835
10917
|
var recordReceived = (eventLog, input, record2) => ensureToolEvent(eventLog, resultEvent({ ...input, createdAt: record2.createdAt - 1 }, record2.result, input.eventSequence + 1)).pipe(Effect55.as(record2.result));
|
|
10836
|
-
var nonEmptyName = (name) =>
|
|
10918
|
+
var nonEmptyName = (name) => Schema52.decodeUnknownSync(exports_shared_schema.NonEmptyString)(name);
|
|
10837
10919
|
var needsApprovalFromEffectTool = (tool) => tool.needsApproval === undefined ? undefined : typeof tool.needsApproval === "boolean" ? tool.needsApproval : true;
|
|
10838
10920
|
var definitionFromEffectTool = (modelTool, options) => ({
|
|
10839
10921
|
name: modelTool.name,
|
|
@@ -10874,8 +10956,8 @@ var tool = Function8.dual(2, (name, options) => {
|
|
|
10874
10956
|
tool: effectTool,
|
|
10875
10957
|
...options.placement === undefined ? {} : { placement: options.placement },
|
|
10876
10958
|
...options.requiredPermissions === undefined ? {} : { requiredPermissions: options.requiredPermissions },
|
|
10877
|
-
validateInput: (input) =>
|
|
10878
|
-
run: (input, context) =>
|
|
10959
|
+
validateInput: (input) => Schema52.decodeUnknownEffect(inputSchema)(input).pipe(Effect55.mapError((error5) => ToolInputInvalid.make({ tool_name: name, message: error5.message })), Effect55.asVoid),
|
|
10960
|
+
run: (input, context) => Schema52.decodeUnknownEffect(inputSchema)(input).pipe(Effect55.mapError((error5) => ToolExecutionFailed.make({ tool_name: name, message: error5.message })), Effect55.flatMap((decoded) => options.run(decoded, context)), Effect55.provideService(ToolCallInfo, context), Effect55.flatMap((output) => Schema52.encodeUnknownEffect(outputSchema)(output).pipe(Effect55.mapError((error5) => ToolExecutionFailed.make({ tool_name: name, message: error5.message })))), Effect55.map(jsonValue2))
|
|
10879
10961
|
};
|
|
10880
10962
|
});
|
|
10881
10963
|
var dynamicTool = Function8.dual(2, (name, options) => {
|
|
@@ -10883,7 +10965,7 @@ var dynamicTool = Function8.dual(2, (name, options) => {
|
|
|
10883
10965
|
const modelTool = attachJsonSchema(AiTool.dynamic(name, {
|
|
10884
10966
|
description: options.description,
|
|
10885
10967
|
parameters: parameters.parameters,
|
|
10886
|
-
success:
|
|
10968
|
+
success: Schema52.Unknown,
|
|
10887
10969
|
needsApproval: options.needsApproval
|
|
10888
10970
|
}), parameters.jsonSchema);
|
|
10889
10971
|
return {
|
|
@@ -10928,7 +11010,7 @@ var externalOutcomeResult = (call, input) => {
|
|
|
10928
11010
|
return Effect55.succeed(placementFailureResult(input, call.externalOutcome.message));
|
|
10929
11011
|
}
|
|
10930
11012
|
const placement = call.placement.kind;
|
|
10931
|
-
return
|
|
11013
|
+
return Schema52.decodeUnknownEffect(exports_tool_schema.resultSchema(call.definition.output_schema))(call.externalOutcome.output).pipe(Effect55.map((output) => ({ call_id: input.call.id, output: jsonValue2(output) })), Effect55.catch((error5) => Effect55.succeed(placementFailureResult(input, `invalid ${placement} result: ${error5.message}`))));
|
|
10932
11014
|
};
|
|
10933
11015
|
var runExternalTool = (repository, waits, call, input) => Effect55.gen(function* () {
|
|
10934
11016
|
const waitId2 = placementWaitId(input);
|
|
@@ -10962,7 +11044,7 @@ var runExternalTool = (repository, waits, call, input) => Effect55.gen(function*
|
|
|
10962
11044
|
return placementFailureResult(input, "Tool execution timed out");
|
|
10963
11045
|
if (wait.state === "cancelled")
|
|
10964
11046
|
return placementFailureResult(input, "Tool execution cancelled");
|
|
10965
|
-
const repairedCall = waitingCall.externalOutcome === undefined && waitingCall.placement.kind === "client" ? yield*
|
|
11047
|
+
const repairedCall = waitingCall.externalOutcome === undefined && waitingCall.placement.kind === "client" ? yield* Schema52.decodeUnknownEffect(exports_tool_schema.ExternalOutcome)(wait.metadata.external_outcome).pipe(Effect55.mapError((error5) => ToolRuntimeError.make({ message: error5.message })), Effect55.flatMap((outcome) => repository.acceptClientOutcome({
|
|
10966
11048
|
executionId: input.executionId,
|
|
10967
11049
|
callId: input.call.id,
|
|
10968
11050
|
outcome,
|
|
@@ -11127,11 +11209,11 @@ __export(exports_runtime, {
|
|
|
11127
11209
|
});
|
|
11128
11210
|
|
|
11129
11211
|
// ../runtime/src/child/child-fan-out-runtime.ts
|
|
11130
|
-
import { Clock as Clock5, Context as Context44, Effect as Effect58, FiberMap, Layer as Layer48, Schema as
|
|
11212
|
+
import { Clock as Clock5, Context as Context44, Effect as Effect58, FiberMap, Layer as Layer48, Schema as Schema55 } from "effect";
|
|
11131
11213
|
|
|
11132
11214
|
// ../runtime/src/child/child-fan-out-transition-service.ts
|
|
11133
|
-
import { Context as Context43, Effect as Effect57, Layer as Layer47, Option as Option13, Schema as
|
|
11134
|
-
class ChildFanOutTransitionError extends
|
|
11215
|
+
import { Context as Context43, Effect as Effect57, Layer as Layer47, Option as Option13, Schema as Schema54 } from "effect";
|
|
11216
|
+
class ChildFanOutTransitionError extends Schema54.TaggedErrorClass()("ChildFanOutTransitionError", { message: Schema54.String }) {
|
|
11135
11217
|
}
|
|
11136
11218
|
|
|
11137
11219
|
class Service43 extends Context43.Service()("@relayfx/runtime/child/child-fan-out-transition-service/Service") {
|
|
@@ -11198,7 +11280,7 @@ var terminal2 = Effect57.fn("ChildFanOutTransitionService.terminal.call")(functi
|
|
|
11198
11280
|
class HandlerService extends Context44.Service()("@relayfx/runtime/child/child-fan-out-runtime/HandlerService") {
|
|
11199
11281
|
}
|
|
11200
11282
|
|
|
11201
|
-
class ChildFanOutRuntimeError extends
|
|
11283
|
+
class ChildFanOutRuntimeError extends Schema55.TaggedErrorClass()("ChildFanOutRuntimeError", { message: Schema55.String }) {
|
|
11202
11284
|
}
|
|
11203
11285
|
|
|
11204
11286
|
class Service44 extends Context44.Service()("@relayfx/runtime/child/child-fan-out-runtime/Service") {
|
|
@@ -11265,17 +11347,17 @@ var layerFromRuntime = Layer48.effect(Service44, Effect58.gen(function* () {
|
|
|
11265
11347
|
}).pipe(Effect58.mapError(runtimeError)));
|
|
11266
11348
|
|
|
11267
11349
|
// ../runtime/src/state/execution-state-service.ts
|
|
11268
|
-
import { Config as Config2, Context as Context45, Effect as Effect59, Function as Function10, Layer as Layer49, Schema as
|
|
11350
|
+
import { Config as Config2, Context as Context45, Effect as Effect59, Function as Function10, Layer as Layer49, Schema as Schema56 } from "effect";
|
|
11269
11351
|
var StateVersionConflict3 = exports_execution_state_repository.StateVersionConflict;
|
|
11270
11352
|
|
|
11271
|
-
class StateValueInvalid extends
|
|
11272
|
-
key:
|
|
11273
|
-
message:
|
|
11353
|
+
class StateValueInvalid extends Schema56.TaggedErrorClass()("StateValueInvalid", {
|
|
11354
|
+
key: Schema56.String,
|
|
11355
|
+
message: Schema56.String
|
|
11274
11356
|
}) {
|
|
11275
11357
|
}
|
|
11276
11358
|
|
|
11277
|
-
class ExecutionStateError extends
|
|
11278
|
-
message:
|
|
11359
|
+
class ExecutionStateError extends Schema56.TaggedErrorClass()("ExecutionStateError", {
|
|
11360
|
+
message: Schema56.String
|
|
11279
11361
|
}) {
|
|
11280
11362
|
}
|
|
11281
11363
|
var key3 = Function10.dual(2, (name, schema) => ({
|
|
@@ -11295,7 +11377,7 @@ var layer38 = Layer49.effect(Service45, Effect59.gen(function* () {
|
|
|
11295
11377
|
const row = yield* repository.get(executionId, stateKey.name).pipe(Effect59.mapError(stateError));
|
|
11296
11378
|
if (row === undefined)
|
|
11297
11379
|
return;
|
|
11298
|
-
return yield*
|
|
11380
|
+
return yield* Schema56.decodeUnknownEffect(stateKey.schema)(row.value).pipe(Effect59.mapError((cause) => invalid(stateKey.name, cause)));
|
|
11299
11381
|
});
|
|
11300
11382
|
const getRecord = Effect59.fn("ExecutionStateService.getRecord")((executionId, stateKey) => repository.get(executionId, stateKey).pipe(Effect59.mapError(stateError)));
|
|
11301
11383
|
const put4 = Effect59.fn("ExecutionStateService.put")(function* (input) {
|
|
@@ -11304,8 +11386,8 @@ var layer38 = Layer49.effect(Service45, Effect59.gen(function* () {
|
|
|
11304
11386
|
if (replay2 !== undefined && replay2.key === input.key.name && replay2.op === "put" && replay2.record !== undefined)
|
|
11305
11387
|
return replay2.record;
|
|
11306
11388
|
}
|
|
11307
|
-
const value = yield*
|
|
11308
|
-
const encoded = yield*
|
|
11389
|
+
const value = yield* Schema56.encodeUnknownEffect(input.key.schema)(input.value).pipe(Effect59.mapError((cause) => invalid(input.key.name, cause)));
|
|
11390
|
+
const encoded = yield* Schema56.encodeEffect(Schema56.UnknownFromJsonString)(value).pipe(Effect59.mapError((cause) => invalid(input.key.name, cause)));
|
|
11309
11391
|
const bytes = new TextEncoder().encode(encoded);
|
|
11310
11392
|
let eventValue = { value };
|
|
11311
11393
|
if (bytes.byteLength > eventInlineMaxBytes) {
|
|
@@ -11320,9 +11402,9 @@ var layer38 = Layer49.effect(Service45, Effect59.gen(function* () {
|
|
|
11320
11402
|
...input.expectedVersion === undefined ? {} : { expectedVersion: input.expectedVersion },
|
|
11321
11403
|
...input.idempotencyKey === undefined ? {} : { idempotencyKey: input.idempotencyKey },
|
|
11322
11404
|
updatedAt: input.updatedAt
|
|
11323
|
-
}).pipe(Effect59.mapError((cause) =>
|
|
11405
|
+
}).pipe(Effect59.mapError((cause) => Schema56.is(exports_execution_state_repository.StateVersionConflict)(cause) ? cause : stateError(cause)));
|
|
11324
11406
|
});
|
|
11325
|
-
const remove3 = Effect59.fn("ExecutionStateService.remove")((input) => repository.remove(input).pipe(Effect59.mapError((cause) =>
|
|
11407
|
+
const remove3 = Effect59.fn("ExecutionStateService.remove")((input) => repository.remove(input).pipe(Effect59.mapError((cause) => Schema56.is(exports_execution_state_repository.StateVersionConflict)(cause) ? cause : stateError(cause))));
|
|
11326
11408
|
const list12 = Effect59.fn("ExecutionStateService.list")((input) => repository.list(input).pipe(Effect59.mapError(stateError)));
|
|
11327
11409
|
return Service45.of({ getRecord, get: get12, put: put4, remove: remove3, list: list12 });
|
|
11328
11410
|
}));
|
|
@@ -11330,7 +11412,7 @@ var memoryRepositoryDependencies = Layer49.mergeAll(exports_execution_repository
|
|
|
11330
11412
|
var memoryLayer36 = layer38.pipe(Layer49.provide(exports_execution_state_repository.memoryLayer.pipe(Layer49.provide(memoryRepositoryDependencies))));
|
|
11331
11413
|
|
|
11332
11414
|
// ../runtime/src/runner/runner-runtime-service.ts
|
|
11333
|
-
import { Config as Config8, Context as Context70, Crypto as Crypto4, Duration as Duration7, Effect as Effect99, Layer as Layer81, Option as Option26, Schema as
|
|
11415
|
+
import { Config as Config8, Context as Context70, Crypto as Crypto4, Duration as Duration7, Effect as Effect99, Layer as Layer81, Option as Option26, Schema as Schema92, Stream as Stream16 } from "effect";
|
|
11334
11416
|
import {
|
|
11335
11417
|
ClusterWorkflowEngine,
|
|
11336
11418
|
HttpRunner,
|
|
@@ -11351,7 +11433,7 @@ import { WorkflowEngine as WorkflowEngine2 } from "effect/unstable/workflow";
|
|
|
11351
11433
|
import { LanguageModel as LanguageModel2 } from "effect/unstable/ai";
|
|
11352
11434
|
|
|
11353
11435
|
// ../runtime/src/agent/agent-registry-service.ts
|
|
11354
|
-
import { Clock as Clock6, Context as Context46, Crypto as Crypto2, Effect as Effect61, HashSet as HashSet4, Layer as Layer50, Option as Option14, Schema as
|
|
11436
|
+
import { Clock as Clock6, Context as Context46, Crypto as Crypto2, Effect as Effect61, HashSet as HashSet4, Layer as Layer50, Option as Option14, Schema as Schema57 } from "effect";
|
|
11355
11437
|
|
|
11356
11438
|
// ../runtime/src/tool/tool-input-schema-digest.ts
|
|
11357
11439
|
import { Crypto, Effect as Effect60, Encoding } from "effect";
|
|
@@ -11373,13 +11455,13 @@ var digestDefinitions = Effect60.fn("ToolInputSchemaDigest.digestDefinitions")(f
|
|
|
11373
11455
|
});
|
|
11374
11456
|
|
|
11375
11457
|
// ../runtime/src/agent/agent-registry-service.ts
|
|
11376
|
-
class AgentDefinitionInvalid extends
|
|
11377
|
-
message:
|
|
11458
|
+
class AgentDefinitionInvalid extends Schema57.TaggedErrorClass()("AgentDefinitionInvalid", {
|
|
11459
|
+
message: Schema57.String
|
|
11378
11460
|
}) {
|
|
11379
11461
|
}
|
|
11380
11462
|
|
|
11381
|
-
class AgentRegistryError extends
|
|
11382
|
-
message:
|
|
11463
|
+
class AgentRegistryError extends Schema57.TaggedErrorClass()("AgentRegistryError", {
|
|
11464
|
+
message: Schema57.String
|
|
11383
11465
|
}) {
|
|
11384
11466
|
}
|
|
11385
11467
|
|
|
@@ -11421,7 +11503,7 @@ var transferToolName = (name) => `transfer_to_${name.trim().toLowerCase().replac
|
|
|
11421
11503
|
var validateTurnPolicySnapshot = Effect61.fn("AgentRegistry.validateTurnPolicySnapshot")(function* (snapshot) {
|
|
11422
11504
|
if (snapshot === undefined)
|
|
11423
11505
|
return;
|
|
11424
|
-
const decoded = yield*
|
|
11506
|
+
const decoded = yield* Schema57.decodeUnknownEffect(exports_agent_schema.TurnPolicySnapshot)(snapshot).pipe(Effect61.mapError(() => AgentDefinitionInvalid.make({ message: "definition.turn_policy must be a valid turn policy snapshot" })));
|
|
11425
11507
|
let nodes = 0;
|
|
11426
11508
|
const pending = [
|
|
11427
11509
|
{ snapshot: decoded, depth: 1 }
|
|
@@ -11565,35 +11647,35 @@ var listRevisions3 = Effect61.fn("AgentRegistry.listRevisions.call")(function* (
|
|
|
11565
11647
|
});
|
|
11566
11648
|
|
|
11567
11649
|
// ../runtime/src/agent/agent-loop-service.ts
|
|
11568
|
-
import { Cause as Cause2, Config as Config4, Context as Context64, Crypto as Crypto3, Effect as Effect93, HashSet as HashSet7, Layer as Layer75, Option as Option24, Ref as Ref19, Schema as
|
|
11569
|
-
import { AiError as AiError3, Chat, LanguageModel, Prompt as
|
|
11650
|
+
import { Cause as Cause2, Config as Config4, Context as Context64, Crypto as Crypto3, Effect as Effect93, HashSet as HashSet7, Layer as Layer75, Option as Option24, Ref as Ref19, Schema as Schema85, Stream as Stream13 } from "effect";
|
|
11651
|
+
import { AiError as AiError3, Chat, LanguageModel, Prompt as Prompt7, Tokenizer, Tool as AiTool2, Toolkit as Toolkit2 } from "effect/unstable/ai";
|
|
11570
11652
|
|
|
11571
11653
|
// ../runtime/src/child/child-run-service.ts
|
|
11572
|
-
import { Context as Context48, Effect as Effect63, Function as Function12, HashSet as HashSet5, Layer as Layer52, Option as Option15, Result as Result2, Schema as
|
|
11654
|
+
import { Context as Context48, Effect as Effect63, Function as Function12, HashSet as HashSet5, Layer as Layer52, Option as Option15, Result as Result2, Schema as Schema59 } from "effect";
|
|
11573
11655
|
|
|
11574
11656
|
// ../runtime/src/workspace/workspace-provider-service.ts
|
|
11575
|
-
import { Context as Context47, Effect as Effect62, Function as Function11, Layer as Layer51, Ref as Ref13, Schema as
|
|
11657
|
+
import { Context as Context47, Effect as Effect62, Function as Function11, Layer as Layer51, Ref as Ref13, Schema as Schema58 } from "effect";
|
|
11576
11658
|
|
|
11577
|
-
class WorkspaceNotFound extends
|
|
11659
|
+
class WorkspaceNotFound extends Schema58.TaggedErrorClass()("WorkspaceNotFound", {
|
|
11578
11660
|
sandbox_ref: exports_ids_schema.WorkspaceRef
|
|
11579
11661
|
}) {
|
|
11580
11662
|
}
|
|
11581
11663
|
|
|
11582
|
-
class WorkspaceUnavailable extends
|
|
11664
|
+
class WorkspaceUnavailable extends Schema58.TaggedErrorClass()("WorkspaceUnavailable", {
|
|
11583
11665
|
sandbox_ref: exports_ids_schema.WorkspaceRef,
|
|
11584
|
-
message:
|
|
11666
|
+
message: Schema58.String
|
|
11585
11667
|
}) {
|
|
11586
11668
|
}
|
|
11587
11669
|
|
|
11588
|
-
class WorkspaceCapabilityUnsupported extends
|
|
11589
|
-
capability:
|
|
11670
|
+
class WorkspaceCapabilityUnsupported extends Schema58.TaggedErrorClass()("WorkspaceCapabilityUnsupported", {
|
|
11671
|
+
capability: Schema58.Literals(["suspend", "snapshot", "fork"]),
|
|
11590
11672
|
provider_key: exports_workspace_schema.WorkspaceProviderKey
|
|
11591
11673
|
}) {
|
|
11592
11674
|
}
|
|
11593
11675
|
|
|
11594
|
-
class WorkspaceProviderError extends
|
|
11676
|
+
class WorkspaceProviderError extends Schema58.TaggedErrorClass()("WorkspaceProviderError", {
|
|
11595
11677
|
provider_key: exports_workspace_schema.WorkspaceProviderKey,
|
|
11596
|
-
message:
|
|
11678
|
+
message: Schema58.String
|
|
11597
11679
|
}) {
|
|
11598
11680
|
}
|
|
11599
11681
|
|
|
@@ -11646,28 +11728,28 @@ var destroy = Effect62.fn("WorkspaceProvider.destroy.call")(function* (ref) {
|
|
|
11646
11728
|
});
|
|
11647
11729
|
|
|
11648
11730
|
// ../runtime/src/child/child-run-service.ts
|
|
11649
|
-
class StaticChildRunPresetNotFound extends
|
|
11731
|
+
class StaticChildRunPresetNotFound extends Schema59.TaggedErrorClass()("StaticChildRunPresetNotFound", {
|
|
11650
11732
|
preset_name: exports_shared_schema.NonEmptyString
|
|
11651
11733
|
}) {
|
|
11652
11734
|
}
|
|
11653
11735
|
|
|
11654
|
-
class ChildRunScopeBroadened extends
|
|
11655
|
-
field:
|
|
11736
|
+
class ChildRunScopeBroadened extends Schema59.TaggedErrorClass()("ChildRunScopeBroadened", {
|
|
11737
|
+
field: Schema59.Literals(["tool_names", "permissions"]),
|
|
11656
11738
|
value: exports_shared_schema.NonEmptyString
|
|
11657
11739
|
}) {
|
|
11658
11740
|
}
|
|
11659
11741
|
|
|
11660
|
-
class ChildRunServiceError extends
|
|
11661
|
-
message:
|
|
11742
|
+
class ChildRunServiceError extends Schema59.TaggedErrorClass()("ChildRunServiceError", {
|
|
11743
|
+
message: Schema59.String
|
|
11662
11744
|
}) {
|
|
11663
11745
|
}
|
|
11664
11746
|
|
|
11665
|
-
class ChildRunWorkspaceUnavailable extends
|
|
11666
|
-
reason:
|
|
11747
|
+
class ChildRunWorkspaceUnavailable extends Schema59.TaggedErrorClass()("ChildRunWorkspaceUnavailable", {
|
|
11748
|
+
reason: Schema59.String
|
|
11667
11749
|
}) {
|
|
11668
11750
|
}
|
|
11669
11751
|
|
|
11670
|
-
class ChildRunModelMissing extends
|
|
11752
|
+
class ChildRunModelMissing extends Schema59.TaggedErrorClass()("ChildRunModelMissing", {}) {
|
|
11671
11753
|
}
|
|
11672
11754
|
|
|
11673
11755
|
class Service48 extends Context48.Service()("@relayfx/runtime/child/child-run-service/Service") {
|
|
@@ -11903,53 +11985,53 @@ var spawnDynamic = Effect63.fn("ChildRunService.spawnDynamic.call")(function* (i
|
|
|
11903
11985
|
});
|
|
11904
11986
|
|
|
11905
11987
|
// ../runtime/src/child/spawn-child-run-tool.ts
|
|
11906
|
-
import { Effect as Effect64, Schema as
|
|
11988
|
+
import { Effect as Effect64, Schema as Schema60 } from "effect";
|
|
11907
11989
|
var toolName = "spawn_child_run";
|
|
11908
11990
|
var permissionName = "relay.child_run.spawn";
|
|
11909
|
-
var Input =
|
|
11910
|
-
preset_name:
|
|
11911
|
-
instructions:
|
|
11912
|
-
model:
|
|
11913
|
-
compaction_policy:
|
|
11914
|
-
tool_names:
|
|
11915
|
-
permissions:
|
|
11916
|
-
output_schema_ref:
|
|
11917
|
-
metadata:
|
|
11918
|
-
input:
|
|
11991
|
+
var Input = Schema60.Struct({
|
|
11992
|
+
preset_name: Schema60.optionalKey(exports_shared_schema.NonEmptyString),
|
|
11993
|
+
instructions: Schema60.optionalKey(Schema60.String),
|
|
11994
|
+
model: Schema60.optionalKey(exports_agent_schema.ModelSelection),
|
|
11995
|
+
compaction_policy: Schema60.optionalKey(exports_agent_schema.CompactionPolicy),
|
|
11996
|
+
tool_names: Schema60.optionalKey(Schema60.Array(Schema60.String)),
|
|
11997
|
+
permissions: Schema60.optionalKey(Schema60.Array(Schema60.String)),
|
|
11998
|
+
output_schema_ref: Schema60.optionalKey(Schema60.String),
|
|
11999
|
+
metadata: Schema60.optionalKey(exports_shared_schema.Metadata),
|
|
12000
|
+
input: Schema60.optionalKey(Schema60.Array(exports_content_schema.Part))
|
|
11919
12001
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Input" });
|
|
11920
|
-
var Output =
|
|
12002
|
+
var Output = Schema60.Struct({
|
|
11921
12003
|
child_execution_id: exports_ids_schema.ChildExecutionId,
|
|
11922
|
-
status:
|
|
11923
|
-
output:
|
|
12004
|
+
status: Schema60.Literals(["completed", "failed", "cancelled"]),
|
|
12005
|
+
output: Schema60.Array(exports_content_schema.Part)
|
|
11924
12006
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Output" });
|
|
11925
|
-
var TransferInput =
|
|
11926
|
-
input:
|
|
12007
|
+
var TransferInput = Schema60.Struct({
|
|
12008
|
+
input: Schema60.optionalKey(Schema60.Array(exports_content_schema.Part))
|
|
11927
12009
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.TransferInput" });
|
|
11928
|
-
var ModelInput =
|
|
11929
|
-
preset_name:
|
|
11930
|
-
instructions:
|
|
11931
|
-
model:
|
|
11932
|
-
provider:
|
|
11933
|
-
model:
|
|
11934
|
-
registration_key:
|
|
12010
|
+
var ModelInput = Schema60.Struct({
|
|
12011
|
+
preset_name: Schema60.optionalKey(Schema60.NullOr(Schema60.String)),
|
|
12012
|
+
instructions: Schema60.optionalKey(Schema60.String),
|
|
12013
|
+
model: Schema60.optionalKey(Schema60.NullOr(Schema60.Struct({
|
|
12014
|
+
provider: Schema60.String,
|
|
12015
|
+
model: Schema60.String,
|
|
12016
|
+
registration_key: Schema60.optionalKey(Schema60.String)
|
|
11935
12017
|
}))),
|
|
11936
|
-
compaction_policy:
|
|
11937
|
-
context_window:
|
|
11938
|
-
reserve_tokens:
|
|
11939
|
-
keep_recent_tokens:
|
|
11940
|
-
summary_model:
|
|
11941
|
-
provider:
|
|
11942
|
-
model:
|
|
11943
|
-
registration_key:
|
|
12018
|
+
compaction_policy: Schema60.optionalKey(Schema60.Struct({
|
|
12019
|
+
context_window: Schema60.Finite,
|
|
12020
|
+
reserve_tokens: Schema60.Finite,
|
|
12021
|
+
keep_recent_tokens: Schema60.Finite,
|
|
12022
|
+
summary_model: Schema60.optionalKey(Schema60.Struct({
|
|
12023
|
+
provider: Schema60.String,
|
|
12024
|
+
model: Schema60.String,
|
|
12025
|
+
registration_key: Schema60.optionalKey(Schema60.String)
|
|
11944
12026
|
}))
|
|
11945
12027
|
})),
|
|
11946
|
-
tool_names:
|
|
11947
|
-
permissions:
|
|
11948
|
-
output_schema_ref:
|
|
11949
|
-
input:
|
|
12028
|
+
tool_names: Schema60.optionalKey(Schema60.Array(Schema60.String)),
|
|
12029
|
+
permissions: Schema60.optionalKey(Schema60.Array(Schema60.String)),
|
|
12030
|
+
output_schema_ref: Schema60.optionalKey(Schema60.NullOr(Schema60.String)),
|
|
12031
|
+
input: Schema60.optionalKey(Schema60.Array(Schema60.Struct({ type: Schema60.Literal("text"), text: Schema60.String })))
|
|
11950
12032
|
});
|
|
11951
|
-
var ModelTransferInput =
|
|
11952
|
-
input:
|
|
12033
|
+
var ModelTransferInput = Schema60.Struct({
|
|
12034
|
+
input: Schema60.optionalKey(Schema60.Array(Schema60.Struct({ type: Schema60.Literal("text"), text: Schema60.String })))
|
|
11953
12035
|
});
|
|
11954
12036
|
var normalizeModelInput = (input) => {
|
|
11955
12037
|
const { preset_name: presetName, model, output_schema_ref: outputSchemaRef2, ...rest } = input;
|
|
@@ -12134,7 +12216,7 @@ var registeredTool = (config) => tool(toolName, {
|
|
|
12134
12216
|
permissions: [{ name: permissionName, value: true }],
|
|
12135
12217
|
requiredPermissions: [permissionName],
|
|
12136
12218
|
metadata: { relay_core_tool: true },
|
|
12137
|
-
run: (input, context) =>
|
|
12219
|
+
run: (input, context) => Schema60.decodeUnknownEffect(Input)(normalizeModelInput(input)).pipe(Effect64.mapError((error5) => ToolExecutionFailed.make({ tool_name: toolName, message: error5.message })), Effect64.flatMap((decoded) => run3(config, toolName, decoded, context, true)))
|
|
12138
12220
|
});
|
|
12139
12221
|
var transferToolName2 = (name) => `transfer_to_${name.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g, "_").replaceAll(/^_+|_+$/g, "")}`;
|
|
12140
12222
|
var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target) => {
|
|
@@ -12146,21 +12228,21 @@ var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target
|
|
|
12146
12228
|
permissions: [{ name: permissionName, value: true }],
|
|
12147
12229
|
requiredPermissions: [permissionName],
|
|
12148
12230
|
metadata: { relay_core_tool: true, handoff_target: target.name, preset_name: target.preset_name },
|
|
12149
|
-
run: (input, context) =>
|
|
12231
|
+
run: (input, context) => Schema60.decodeUnknownEffect(TransferInput)(input).pipe(Effect64.mapError((error5) => ToolExecutionFailed.make({ tool_name: name, message: error5.message })), Effect64.flatMap((decoded) => run3(config, name, { preset_name: target.preset_name, input: decoded.input ?? [] }, context, false)))
|
|
12150
12232
|
});
|
|
12151
12233
|
});
|
|
12152
12234
|
|
|
12153
12235
|
// ../runtime/src/memory/memory-service.ts
|
|
12154
|
-
import { Clock as Clock7, Context as Context49, Effect as Effect65, Layer as Layer53, Schema as
|
|
12155
|
-
import { EmbeddingModel as EmbeddingModel2, Prompt as
|
|
12236
|
+
import { Clock as Clock7, Context as Context49, Effect as Effect65, Layer as Layer53, Schema as Schema61 } from "effect";
|
|
12237
|
+
import { EmbeddingModel as EmbeddingModel2, Prompt as Prompt5 } from "effect/unstable/ai";
|
|
12156
12238
|
class Service49 extends Context49.Service()("@relayfx/runtime/memory/memory-service/Service") {
|
|
12157
12239
|
}
|
|
12158
12240
|
var defaultTopK = 5;
|
|
12159
12241
|
var memoryError = (error5) => exports_memory.MemoryError.make({
|
|
12160
12242
|
message: error5 instanceof Error ? `${error5.name}: ${error5.message}` : String(error5)
|
|
12161
12243
|
});
|
|
12162
|
-
var decodeSubject = (subject) =>
|
|
12163
|
-
var textPart = (text) =>
|
|
12244
|
+
var decodeSubject = (subject) => Schema61.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect65.mapError(memoryError));
|
|
12245
|
+
var textPart = (text) => Prompt5.makePart("text", { text });
|
|
12164
12246
|
var textFromParts = (parts) => parts.filter((part) => part.type === "text").map((part) => part.text).join(`
|
|
12165
12247
|
`).trim();
|
|
12166
12248
|
var latestUserText = (prompt) => {
|
|
@@ -12322,8 +12404,8 @@ var layer42 = (input) => Layer54.succeed(Service50, Service50.of(make4(input)));
|
|
|
12322
12404
|
var noRetryLayer = layer42({ retrySchedule: Schedule3.recurs(0) });
|
|
12323
12405
|
|
|
12324
12406
|
// ../runtime/src/presence/presence-service.ts
|
|
12325
|
-
import { Clock as Clock8, Config as Config3, Effect as Effect66, Layer as Layer55, Random, Schedule as Schedule4, Schema as
|
|
12326
|
-
var isPresenceError =
|
|
12407
|
+
import { Clock as Clock8, Config as Config3, Effect as Effect66, Layer as Layer55, Random, Schedule as Schedule4, Schema as Schema62, Stream as Stream11 } from "effect";
|
|
12408
|
+
var isPresenceError = Schema62.is(PresenceError);
|
|
12327
12409
|
var readError = (cause) => isPresenceError(cause) ? cause : PresenceError.make({ message: String(cause) });
|
|
12328
12410
|
var warn = (operation) => (cause) => Effect66.logWarning(`Presence ${operation} failed`).pipe(Effect66.annotateLogs({ cause: String(cause) }));
|
|
12329
12411
|
var layerFromRepository2 = Layer55.effect(Service2, Effect66.gen(function* () {
|
|
@@ -12378,11 +12460,11 @@ var list13 = Effect66.fn("Presence.list.call")(function* (scope) {
|
|
|
12378
12460
|
});
|
|
12379
12461
|
|
|
12380
12462
|
// ../runtime/src/presence/presence-tool.ts
|
|
12381
|
-
import { Effect as Effect67, Schema as
|
|
12463
|
+
import { Effect as Effect67, Schema as Schema63 } from "effect";
|
|
12382
12464
|
var toolName2 = "relay_presence";
|
|
12383
12465
|
var permissionName2 = "relay.presence.read";
|
|
12384
|
-
var Input2 =
|
|
12385
|
-
var Output2 =
|
|
12466
|
+
var Input2 = Schema63.Struct({ scope: Schema63.optionalKey(exports_presence_schema.Scope) });
|
|
12467
|
+
var Output2 = Schema63.Struct({ watcher_count: Schema63.Finite, entries: Schema63.Array(exports_presence_schema.Entry) });
|
|
12386
12468
|
var registeredTool2 = (presence) => tool(toolName2, {
|
|
12387
12469
|
description: "List observers currently watching an execution or session.",
|
|
12388
12470
|
input: Input2,
|
|
@@ -12398,24 +12480,24 @@ var registeredTool2 = (presence) => tool(toolName2, {
|
|
|
12398
12480
|
});
|
|
12399
12481
|
|
|
12400
12482
|
// ../runtime/src/state/state-tools.ts
|
|
12401
|
-
import { Effect as Effect68, Schema as
|
|
12402
|
-
var GetInput =
|
|
12403
|
-
var GetOutput =
|
|
12404
|
-
value:
|
|
12405
|
-
version:
|
|
12483
|
+
import { Effect as Effect68, Schema as Schema64 } from "effect";
|
|
12484
|
+
var GetInput = Schema64.Struct({ key: exports_shared_schema.NonEmptyString });
|
|
12485
|
+
var GetOutput = Schema64.Struct({
|
|
12486
|
+
value: Schema64.optionalKey(exports_shared_schema.JsonValue),
|
|
12487
|
+
version: Schema64.optionalKey(Schema64.Int)
|
|
12406
12488
|
});
|
|
12407
|
-
var PutInput =
|
|
12489
|
+
var PutInput = Schema64.Struct({
|
|
12408
12490
|
key: exports_shared_schema.NonEmptyString,
|
|
12409
12491
|
value: exports_shared_schema.JsonValue,
|
|
12410
|
-
expected_version:
|
|
12492
|
+
expected_version: Schema64.optionalKey(Schema64.Int.check(Schema64.isGreaterThanOrEqualTo(0)))
|
|
12411
12493
|
});
|
|
12412
|
-
var DeleteInput =
|
|
12413
|
-
var ListInput =
|
|
12414
|
-
prefix:
|
|
12415
|
-
after_key:
|
|
12416
|
-
limit:
|
|
12494
|
+
var DeleteInput = Schema64.Struct({ key: exports_shared_schema.NonEmptyString, expected_version: Schema64.optionalKey(Schema64.Int) });
|
|
12495
|
+
var ListInput = Schema64.Struct({
|
|
12496
|
+
prefix: Schema64.optionalKey(Schema64.String),
|
|
12497
|
+
after_key: Schema64.optionalKey(Schema64.String),
|
|
12498
|
+
limit: Schema64.optionalKey(Schema64.Int)
|
|
12417
12499
|
});
|
|
12418
|
-
var RecordOutput =
|
|
12500
|
+
var RecordOutput = Schema64.Struct({
|
|
12419
12501
|
execution_id: exports_state_schema.StateRecordView.fields.execution_id,
|
|
12420
12502
|
key: exports_state_schema.StateRecordView.fields.key,
|
|
12421
12503
|
value: exports_state_schema.StateRecordView.fields.value,
|
|
@@ -12423,8 +12505,8 @@ var RecordOutput = Schema63.Struct({
|
|
|
12423
12505
|
created_at: exports_state_schema.StateRecordView.fields.created_at,
|
|
12424
12506
|
updated_at: exports_state_schema.StateRecordView.fields.updated_at
|
|
12425
12507
|
});
|
|
12426
|
-
var PutOutput =
|
|
12427
|
-
var DeleteOutput =
|
|
12508
|
+
var PutOutput = Schema64.Struct({ key: exports_state_schema.StateKey, version: exports_state_schema.StateVersion });
|
|
12509
|
+
var DeleteOutput = Schema64.Struct({ deleted: Schema64.Boolean, version: Schema64.optionalKey(Schema64.Int) });
|
|
12428
12510
|
var enabled2 = (agent) => agent.metadata?.state_enabled === true;
|
|
12429
12511
|
var mapStateError = (toolName3) => (error5) => ToolExecutionFailed.make({ tool_name: toolName3, message: error5._tag });
|
|
12430
12512
|
var registeredTools2 = (state) => [
|
|
@@ -12465,7 +12547,7 @@ var registeredTools2 = (state) => [
|
|
|
12465
12547
|
tool("state_list", {
|
|
12466
12548
|
description: "List durable execution state",
|
|
12467
12549
|
input: ListInput,
|
|
12468
|
-
output:
|
|
12550
|
+
output: Schema64.Array(RecordOutput),
|
|
12469
12551
|
metadata: { relay_core_tool: true },
|
|
12470
12552
|
run: (input, context) => state.list({
|
|
12471
12553
|
executionId: context.executionId,
|
|
@@ -12538,6 +12620,8 @@ var recordAppendInput = (record2) => {
|
|
|
12538
12620
|
_tag: "Compaction",
|
|
12539
12621
|
version: 2,
|
|
12540
12622
|
projectedHistory: record2.projectedHistory,
|
|
12623
|
+
telemetry: record2.telemetry,
|
|
12624
|
+
...record2.compactionCommit === undefined ? {} : { compactionCommit: record2.compactionCommit },
|
|
12541
12625
|
...record2.summary === undefined ? {} : { summary: record2.summary },
|
|
12542
12626
|
...record2.metadata === undefined ? {} : { metadata: record2.metadata }
|
|
12543
12627
|
} : {
|
|
@@ -12676,6 +12760,8 @@ var make5 = Effect69.fn("RelaySessionStore.make")(function* (sessionId, entrySco
|
|
|
12676
12760
|
sessionId,
|
|
12677
12761
|
parentId: checkpoint.parentId === null ? null : entryId(checkpoint.parentId),
|
|
12678
12762
|
projectedHistory: checkpoint.projectedHistory,
|
|
12763
|
+
telemetry: checkpoint.telemetry,
|
|
12764
|
+
...checkpoint.compactionCommit === undefined ? {} : { compactionCommit: checkpoint.compactionCommit },
|
|
12679
12765
|
...checkpoint.summary === undefined ? {} : { summary: checkpoint.summary },
|
|
12680
12766
|
createdAt: now,
|
|
12681
12767
|
...makeOptions?.writer === undefined ? {} : { expectedWriter: makeOptions.writer }
|
|
@@ -12726,43 +12812,43 @@ var layer43 = Function13.dual((args) => typeof args[0] === "string" && String(ar
|
|
|
12726
12812
|
var memoryLayer39 = Function13.dual((args) => typeof args[0] === "string" && String(args[0]).startsWith("session:"), (sessionId, entryScope = "default") => layer43(sessionId, entryScope).pipe(Layer56.provide(exports_session_repository.memoryLayer)));
|
|
12727
12813
|
|
|
12728
12814
|
// ../runtime/src/inbox/inbox-service.ts
|
|
12729
|
-
import { Clock as Clock12, Context as Context61, Effect as Effect81, Layer as Layer67, Schema as
|
|
12815
|
+
import { Clock as Clock12, Context as Context61, Effect as Effect81, Layer as Layer67, Schema as Schema76 } from "effect";
|
|
12730
12816
|
|
|
12731
12817
|
// ../runtime/src/wait/wait-signal.ts
|
|
12732
|
-
import { Effect as Effect80, Schema as
|
|
12818
|
+
import { Effect as Effect80, Schema as Schema75 } from "effect";
|
|
12733
12819
|
|
|
12734
12820
|
// ../runtime/src/workflow/execution-workflow.ts
|
|
12735
12821
|
import { Activity, DurableDeferred, Workflow as Workflow2, WorkflowEngine } from "effect/unstable/workflow";
|
|
12736
|
-
import { Cause, Effect as Effect79, Exit, Function as Function14, Layer as Layer66, Option as Option20, Schema as
|
|
12822
|
+
import { Cause, Effect as Effect79, Exit, Function as Function14, Layer as Layer66, Option as Option20, Schema as Schema74 } from "effect";
|
|
12737
12823
|
|
|
12738
12824
|
// ../runtime/src/address/address-resolution-service.ts
|
|
12739
|
-
import { Context as Context53, Effect as Effect71, Layer as Layer58, Schema as
|
|
12825
|
+
import { Context as Context53, Effect as Effect71, Layer as Layer58, Schema as Schema66 } from "effect";
|
|
12740
12826
|
|
|
12741
12827
|
// ../runtime/src/address/address-book-service.ts
|
|
12742
|
-
import { Context as Context52, Effect as Effect70, Layer as Layer57, Ref as Ref15, Schema as
|
|
12828
|
+
import { Context as Context52, Effect as Effect70, Layer as Layer57, Ref as Ref15, Schema as Schema65 } from "effect";
|
|
12743
12829
|
var RouteKind2 = exports_address_schema.RouteKind;
|
|
12744
12830
|
var Route = exports_address_schema.Route;
|
|
12745
12831
|
var RouteRecord = exports_address_schema.RouteRecord;
|
|
12746
12832
|
|
|
12747
|
-
class AddressNotFound2 extends
|
|
12833
|
+
class AddressNotFound2 extends Schema65.TaggedErrorClass()("AddressNotFound", {
|
|
12748
12834
|
address_id: exports_ids_schema.AddressId
|
|
12749
12835
|
}) {
|
|
12750
12836
|
}
|
|
12751
12837
|
|
|
12752
|
-
class AddressUnavailable extends
|
|
12838
|
+
class AddressUnavailable extends Schema65.TaggedErrorClass()("AddressUnavailable", {
|
|
12753
12839
|
address_id: exports_ids_schema.AddressId,
|
|
12754
|
-
route_key:
|
|
12840
|
+
route_key: Schema65.String
|
|
12755
12841
|
}) {
|
|
12756
12842
|
}
|
|
12757
12843
|
|
|
12758
|
-
class AddressDeferred extends
|
|
12844
|
+
class AddressDeferred extends Schema65.TaggedErrorClass()("AddressDeferred", {
|
|
12759
12845
|
address_id: exports_ids_schema.AddressId,
|
|
12760
|
-
route_key:
|
|
12846
|
+
route_key: Schema65.String
|
|
12761
12847
|
}) {
|
|
12762
12848
|
}
|
|
12763
12849
|
|
|
12764
|
-
class AddressBookServiceError extends
|
|
12765
|
-
message:
|
|
12850
|
+
class AddressBookServiceError extends Schema65.TaggedErrorClass()("AddressBookServiceError", {
|
|
12851
|
+
message: Schema65.String
|
|
12766
12852
|
}) {
|
|
12767
12853
|
}
|
|
12768
12854
|
|
|
@@ -12790,7 +12876,7 @@ var recordFromEntry = (entry) => ({
|
|
|
12790
12876
|
updated_at: entry.updatedAt
|
|
12791
12877
|
});
|
|
12792
12878
|
var entryIdFor = (addressId) => exports_ids_schema.AddressBookEntryId.make(`address-book:${addressId}`);
|
|
12793
|
-
var validateRoute = (route) =>
|
|
12879
|
+
var validateRoute = (route) => Schema65.decodeUnknownEffect(Route)(route).pipe(Effect70.mapError((error5) => AddressBookServiceError.make({ message: String(error5) })));
|
|
12794
12880
|
var mapRepositoryError5 = (error5) => {
|
|
12795
12881
|
if (error5._tag === "AddressNotFound") {
|
|
12796
12882
|
return AddressNotFound2.make({ address_id: error5.address_id });
|
|
@@ -12855,41 +12941,41 @@ var list14 = Effect70.fn("AddressBook.list.call")(function* () {
|
|
|
12855
12941
|
});
|
|
12856
12942
|
|
|
12857
12943
|
// ../runtime/src/address/address-resolution-service.ts
|
|
12858
|
-
class AddressRouteNotFound extends
|
|
12944
|
+
class AddressRouteNotFound extends Schema66.TaggedErrorClass()("AddressRouteNotFound", {
|
|
12859
12945
|
address_id: exports_ids_schema.AddressId
|
|
12860
12946
|
}) {
|
|
12861
12947
|
}
|
|
12862
12948
|
|
|
12863
|
-
class AddressRouteKindMismatch extends
|
|
12949
|
+
class AddressRouteKindMismatch extends Schema66.TaggedErrorClass()("AddressRouteKindMismatch", {
|
|
12864
12950
|
address_id: exports_ids_schema.AddressId,
|
|
12865
|
-
expected:
|
|
12951
|
+
expected: Schema66.Literal("local-agent"),
|
|
12866
12952
|
actual: exports_address_schema.RouteKind,
|
|
12867
|
-
route_key:
|
|
12953
|
+
route_key: Schema66.String
|
|
12868
12954
|
}) {
|
|
12869
12955
|
}
|
|
12870
12956
|
|
|
12871
|
-
class AddressAgentDefinitionNotFound extends
|
|
12957
|
+
class AddressAgentDefinitionNotFound extends Schema66.TaggedErrorClass()("AddressAgentDefinitionNotFound", {
|
|
12872
12958
|
address_id: exports_ids_schema.AddressId,
|
|
12873
12959
|
agent_id: exports_ids_schema.AgentId
|
|
12874
12960
|
}) {
|
|
12875
12961
|
}
|
|
12876
12962
|
|
|
12877
|
-
class AddressResolutionError extends
|
|
12878
|
-
message:
|
|
12963
|
+
class AddressResolutionError extends Schema66.TaggedErrorClass()("AddressResolutionError", {
|
|
12964
|
+
message: Schema66.String
|
|
12879
12965
|
}) {
|
|
12880
12966
|
}
|
|
12881
|
-
var LocalAgentRoute =
|
|
12882
|
-
kind:
|
|
12967
|
+
var LocalAgentRoute = Schema66.Struct({
|
|
12968
|
+
kind: Schema66.Literal("local-agent"),
|
|
12883
12969
|
route_key: exports_shared_schema.NonEmptyString,
|
|
12884
|
-
metadata:
|
|
12970
|
+
metadata: Schema66.optionalKey(exports_shared_schema.Metadata)
|
|
12885
12971
|
}).annotate({ identifier: "Relay.AddressResolution.LocalAgentRoute" });
|
|
12886
|
-
var LocalAgentTarget =
|
|
12972
|
+
var LocalAgentTarget = Schema66.Struct({
|
|
12887
12973
|
address_id: exports_ids_schema.AddressId,
|
|
12888
12974
|
route: LocalAgentRoute,
|
|
12889
12975
|
agent_id: exports_ids_schema.AgentId,
|
|
12890
12976
|
agent_revision: exports_agent_schema.DefinitionRevision,
|
|
12891
12977
|
agent_snapshot: exports_agent_schema.Definition,
|
|
12892
|
-
tool_input_schema_digests:
|
|
12978
|
+
tool_input_schema_digests: Schema66.optionalKey(exports_agent_schema.ToolInputSchemaDigests)
|
|
12893
12979
|
}).annotate({ identifier: "Relay.AddressResolution.LocalAgentTarget" });
|
|
12894
12980
|
|
|
12895
12981
|
class Service53 extends Context53.Service()("@relayfx/runtime/address/address-resolution-service/Service") {
|
|
@@ -12922,7 +13008,7 @@ var layer44 = Layer58.effect(Service53, Effect71.gen(function* () {
|
|
|
12922
13008
|
return yield* AddressRouteNotFound.make({ address_id: addressId });
|
|
12923
13009
|
}
|
|
12924
13010
|
const route = yield* routeToLocalAgent(addressId, record2.route);
|
|
12925
|
-
const agentId = yield*
|
|
13011
|
+
const agentId = yield* Schema66.decodeUnknownEffect(exports_ids_schema.AgentId)(route.route_key).pipe(Effect71.mapError((error5) => AddressResolutionError.make({ message: String(error5) })));
|
|
12926
13012
|
const definition = yield* agentRegistry.get(agentId).pipe(Effect71.mapError(mapAgentRegistryError));
|
|
12927
13013
|
if (definition === undefined) {
|
|
12928
13014
|
return yield* AddressAgentDefinitionNotFound.make({
|
|
@@ -12951,13 +13037,14 @@ var resolveLocalAgent = Effect71.fn("AddressResolution.resolveLocalAgent.call")(
|
|
|
12951
13037
|
});
|
|
12952
13038
|
|
|
12953
13039
|
// ../runtime/src/agent/agent-loop-error.ts
|
|
12954
|
-
import { Schema as
|
|
13040
|
+
import { Schema as Schema67 } from "effect";
|
|
12955
13041
|
import { AiError as AiError2 } from "effect/unstable/ai";
|
|
12956
13042
|
|
|
12957
|
-
class AgentLoopError extends
|
|
12958
|
-
message:
|
|
12959
|
-
failure_classification:
|
|
12960
|
-
baton_failure:
|
|
13043
|
+
class AgentLoopError extends Schema67.TaggedErrorClass()("AgentLoopError", {
|
|
13044
|
+
message: Schema67.String,
|
|
13045
|
+
failure_classification: Schema67.optionalKey(Schema67.Literal("context-overflow")),
|
|
13046
|
+
baton_failure: Schema67.optionalKey(Schema67.Union([
|
|
13047
|
+
exports_model_telemetry.DeliveryFailed,
|
|
12961
13048
|
exports_agent_event.AgentError,
|
|
12962
13049
|
exports_agent_event.ResumeMismatch,
|
|
12963
13050
|
exports_turn_policy.TurnPolicyError,
|
|
@@ -12971,25 +13058,25 @@ class AgentLoopError extends Schema66.TaggedErrorClass()("AgentLoopError", {
|
|
|
12971
13058
|
exports_model_registry.LanguageModelNotRegistered,
|
|
12972
13059
|
exports_tool_executor.FrameworkFailure
|
|
12973
13060
|
])),
|
|
12974
|
-
next_event_sequence:
|
|
13061
|
+
next_event_sequence: Schema67.optionalKey(exports_execution_schema.ExecutionEventSequence)
|
|
12975
13062
|
}) {
|
|
12976
13063
|
}
|
|
12977
13064
|
|
|
12978
|
-
class AgentLoopBudgetExceeded extends
|
|
12979
|
-
tokens_used:
|
|
12980
|
-
token_budget:
|
|
13065
|
+
class AgentLoopBudgetExceeded extends Schema67.TaggedErrorClass()("AgentLoopBudgetExceeded", {
|
|
13066
|
+
tokens_used: Schema67.Int,
|
|
13067
|
+
token_budget: Schema67.Int,
|
|
12981
13068
|
next_event_sequence: exports_execution_schema.ExecutionEventSequence
|
|
12982
13069
|
}) {
|
|
12983
13070
|
}
|
|
12984
|
-
var AgentTerminalFailure =
|
|
13071
|
+
var AgentTerminalFailure = Schema67.Union([AgentLoopError, AgentLoopBudgetExceeded]);
|
|
12985
13072
|
|
|
12986
13073
|
// ../runtime/src/child/parent-notifier-service.ts
|
|
12987
|
-
import { Context as Context54, Effect as Effect72, Layer as Layer59, Option as Option16, Ref as Ref16, Schema as
|
|
12988
|
-
class ParentNotifyError extends
|
|
12989
|
-
message:
|
|
13074
|
+
import { Context as Context54, Effect as Effect72, Layer as Layer59, Option as Option16, Ref as Ref16, Schema as Schema68 } from "effect";
|
|
13075
|
+
class ParentNotifyError extends Schema68.TaggedErrorClass()("ParentNotifyError", {
|
|
13076
|
+
message: Schema68.String
|
|
12990
13077
|
}) {
|
|
12991
13078
|
}
|
|
12992
|
-
var ChildTerminalStatus =
|
|
13079
|
+
var ChildTerminalStatus = Schema68.Literals(["completed", "failed", "cancelled"]).annotate({
|
|
12993
13080
|
identifier: "Relay.ParentNotifier.ChildTerminalStatus"
|
|
12994
13081
|
});
|
|
12995
13082
|
|
|
@@ -13070,15 +13157,15 @@ var notify = Effect72.fn("ParentNotifier.notify.call")(function* (input) {
|
|
|
13070
13157
|
});
|
|
13071
13158
|
|
|
13072
13159
|
// ../runtime/src/skill/skill-registry-service.ts
|
|
13073
|
-
import { Clock as Clock10, Context as Context55, Effect as Effect73, Layer as Layer60, Schema as
|
|
13160
|
+
import { Clock as Clock10, Context as Context55, Effect as Effect73, Layer as Layer60, Schema as Schema69 } from "effect";
|
|
13074
13161
|
|
|
13075
|
-
class SkillDefinitionInvalid extends
|
|
13076
|
-
message:
|
|
13162
|
+
class SkillDefinitionInvalid extends Schema69.TaggedErrorClass()("SkillDefinitionInvalid", {
|
|
13163
|
+
message: Schema69.String
|
|
13077
13164
|
}) {
|
|
13078
13165
|
}
|
|
13079
13166
|
|
|
13080
|
-
class SkillRegistryError extends
|
|
13081
|
-
message:
|
|
13167
|
+
class SkillRegistryError extends Schema69.TaggedErrorClass()("SkillRegistryError", {
|
|
13168
|
+
message: Schema69.String
|
|
13082
13169
|
}) {
|
|
13083
13170
|
}
|
|
13084
13171
|
|
|
@@ -13231,16 +13318,16 @@ var sourceForExecution = Effect73.fn("SkillRegistry.sourceForExecution.call")(fu
|
|
|
13231
13318
|
});
|
|
13232
13319
|
|
|
13233
13320
|
// ../runtime/src/execution/execution-service.ts
|
|
13234
|
-
import { Clock as Clock11, Context as Context56, Effect as Effect74, Layer as Layer61, Option as Option17, Schema as
|
|
13321
|
+
import { Clock as Clock11, Context as Context56, Effect as Effect74, Layer as Layer61, Option as Option17, Schema as Schema70, Stream as Stream12 } from "effect";
|
|
13235
13322
|
import { ShardingConfig } from "effect/unstable/cluster";
|
|
13236
13323
|
var ExecutionServiceErrorDetails = exports_shared_schema.JsonValue.annotate({
|
|
13237
13324
|
identifier: "Relay.ExecutionServiceErrorDetails"
|
|
13238
13325
|
});
|
|
13239
13326
|
|
|
13240
|
-
class ExecutionServiceError extends
|
|
13241
|
-
message:
|
|
13242
|
-
details:
|
|
13243
|
-
next_event_sequence:
|
|
13327
|
+
class ExecutionServiceError extends Schema70.TaggedErrorClass()("ExecutionServiceError", {
|
|
13328
|
+
message: Schema70.String,
|
|
13329
|
+
details: Schema70.optionalKey(ExecutionServiceErrorDetails),
|
|
13330
|
+
next_event_sequence: Schema70.optionalKey(exports_execution_schema.ExecutionEventSequence)
|
|
13244
13331
|
}) {
|
|
13245
13332
|
}
|
|
13246
13333
|
|
|
@@ -13421,7 +13508,7 @@ var existingTerminalExecution = Effect74.fn("ExecutionService.existingTerminalEx
|
|
|
13421
13508
|
execution: undefined,
|
|
13422
13509
|
failure: ExecutionServiceError.make({
|
|
13423
13510
|
message: typeof metadata11.message === "string" ? metadata11.message : "Execution failed",
|
|
13424
|
-
...
|
|
13511
|
+
...Schema70.is(ExecutionServiceErrorDetails)(metadata11.details) ? { details: metadata11.details } : {},
|
|
13425
13512
|
next_event_sequence: event.sequence
|
|
13426
13513
|
})
|
|
13427
13514
|
};
|
|
@@ -13664,13 +13751,13 @@ var coordinate = Effect76.fn("ToolTransitionCoordinator.coordinate")(function* (
|
|
|
13664
13751
|
});
|
|
13665
13752
|
|
|
13666
13753
|
// ../runtime/src/workspace/workspace-planner-service.ts
|
|
13667
|
-
import { Context as Context60, Effect as Effect78, HashSet as HashSet6, Layer as Layer65, Option as Option18, Schema as
|
|
13754
|
+
import { Context as Context60, Effect as Effect78, HashSet as HashSet6, Layer as Layer65, Option as Option18, Schema as Schema72 } from "effect";
|
|
13668
13755
|
|
|
13669
13756
|
// ../runtime/src/workspace/workspace-runtime-service.ts
|
|
13670
|
-
import { Context as Context59, Effect as Effect77, Layer as Layer64, Schema as
|
|
13757
|
+
import { Context as Context59, Effect as Effect77, Layer as Layer64, Schema as Schema71 } from "effect";
|
|
13671
13758
|
|
|
13672
|
-
class WorkspaceRuntimeError extends
|
|
13673
|
-
message:
|
|
13759
|
+
class WorkspaceRuntimeError extends Schema71.TaggedErrorClass()("WorkspaceRuntimeError", {
|
|
13760
|
+
message: Schema71.String
|
|
13674
13761
|
}) {
|
|
13675
13762
|
}
|
|
13676
13763
|
|
|
@@ -13698,18 +13785,18 @@ var exec = Effect77.fn("WorkspaceRuntime.exec.call")(function* (input) {
|
|
|
13698
13785
|
});
|
|
13699
13786
|
|
|
13700
13787
|
// ../runtime/src/workspace/workspace-planner-service.ts
|
|
13701
|
-
class WorkspaceRuntimeMissing extends
|
|
13788
|
+
class WorkspaceRuntimeMissing extends Schema72.TaggedErrorClass()("WorkspaceRuntimeMissing", {
|
|
13702
13789
|
execution_id: exports_ids_schema.ExecutionId
|
|
13703
13790
|
}) {
|
|
13704
13791
|
}
|
|
13705
13792
|
|
|
13706
|
-
class WorkspaceLeaseMissingRef extends
|
|
13793
|
+
class WorkspaceLeaseMissingRef extends Schema72.TaggedErrorClass()("WorkspaceLeaseMissingRef", {
|
|
13707
13794
|
execution_id: exports_ids_schema.ExecutionId
|
|
13708
13795
|
}) {
|
|
13709
13796
|
}
|
|
13710
13797
|
|
|
13711
|
-
class WorkspacePlannerError extends
|
|
13712
|
-
message:
|
|
13798
|
+
class WorkspacePlannerError extends Schema72.TaggedErrorClass()("WorkspacePlannerError", {
|
|
13799
|
+
message: Schema72.String
|
|
13713
13800
|
}) {
|
|
13714
13801
|
}
|
|
13715
13802
|
|
|
@@ -13895,7 +13982,7 @@ var fail = Effect78.fn("WorkspacePlanner.fail.call")(function* (input) {
|
|
|
13895
13982
|
});
|
|
13896
13983
|
|
|
13897
13984
|
// ../runtime/src/workflow/execution-workflow-state.ts
|
|
13898
|
-
import { Option as Option19, Schema as
|
|
13985
|
+
import { Option as Option19, Schema as Schema73 } from "effect";
|
|
13899
13986
|
var toWaitSnapshot = (record2) => ({
|
|
13900
13987
|
id: record2.id,
|
|
13901
13988
|
execution_id: record2.executionId,
|
|
@@ -13963,7 +14050,7 @@ var waitIdFromExecution = (execution) => {
|
|
|
13963
14050
|
};
|
|
13964
14051
|
var pendingSuspensionFromExecution = (execution) => {
|
|
13965
14052
|
const pending = execution.metadata?.pending_agent_suspension;
|
|
13966
|
-
return
|
|
14053
|
+
return Schema73.decodeUnknownOption(exports_agent_event.AgentSuspended)(pending).pipe(Option19.getOrUndefined);
|
|
13967
14054
|
};
|
|
13968
14055
|
var ExecutionWorkflowState = {
|
|
13969
14056
|
agentDefinitionPinCount,
|
|
@@ -14004,74 +14091,74 @@ var {
|
|
|
14004
14091
|
workflowGenerationFromRecord: workflowGenerationFromRecord2
|
|
14005
14092
|
} = ExecutionWorkflowState;
|
|
14006
14093
|
|
|
14007
|
-
class ExecutionWorkflowFailed extends
|
|
14008
|
-
message:
|
|
14009
|
-
terminal_failure:
|
|
14094
|
+
class ExecutionWorkflowFailed extends Schema74.TaggedErrorClass()("ExecutionWorkflowFailed", {
|
|
14095
|
+
message: Schema74.String,
|
|
14096
|
+
terminal_failure: Schema74.optionalKey(AgentTerminalFailure)
|
|
14010
14097
|
}) {
|
|
14011
14098
|
}
|
|
14012
14099
|
|
|
14013
|
-
class AgentCheckpointCompatibilityError extends
|
|
14014
|
-
message:
|
|
14100
|
+
class AgentCheckpointCompatibilityError extends Schema74.TaggedErrorClass()("AgentCheckpointCompatibilityError", {
|
|
14101
|
+
message: Schema74.String
|
|
14015
14102
|
}) {
|
|
14016
14103
|
}
|
|
14017
|
-
var ExecutionWorkflowError =
|
|
14018
|
-
var StartInput =
|
|
14104
|
+
var ExecutionWorkflowError = Schema74.Union([ExecutionWorkflowFailed, AgentCheckpointCompatibilityError]);
|
|
14105
|
+
var StartInput = Schema74.Struct({
|
|
14019
14106
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14020
14107
|
root_address_id: exports_ids_schema.AddressId,
|
|
14021
|
-
session_id:
|
|
14022
|
-
input:
|
|
14108
|
+
session_id: Schema74.optionalKey(exports_ids_schema.SessionId),
|
|
14109
|
+
input: Schema74.optionalKey(Schema74.Array(exports_content_schema.Part)),
|
|
14023
14110
|
event_sequence: exports_execution_schema.ExecutionEventSequence,
|
|
14024
14111
|
started_at: exports_shared_schema.TimestampMillis,
|
|
14025
14112
|
completed_at: exports_shared_schema.TimestampMillis,
|
|
14026
|
-
agent_id:
|
|
14027
|
-
agent_revision:
|
|
14028
|
-
agent_snapshot:
|
|
14029
|
-
agent_tool_input_schema_digests:
|
|
14030
|
-
wait_id:
|
|
14031
|
-
resume_suspension:
|
|
14032
|
-
workflow_generation:
|
|
14033
|
-
metadata:
|
|
14113
|
+
agent_id: Schema74.optionalKey(exports_ids_schema.AgentId),
|
|
14114
|
+
agent_revision: Schema74.optionalKey(exports_agent_schema.DefinitionRevision),
|
|
14115
|
+
agent_snapshot: Schema74.optionalKey(exports_agent_schema.Definition),
|
|
14116
|
+
agent_tool_input_schema_digests: Schema74.optionalKey(exports_agent_schema.ToolInputSchemaDigests),
|
|
14117
|
+
wait_id: Schema74.optionalKey(exports_ids_schema.WaitId),
|
|
14118
|
+
resume_suspension: Schema74.optionalKey(exports_agent_event.AgentSuspended),
|
|
14119
|
+
workflow_generation: Schema74.optionalKey(Schema74.Int.check(Schema74.isGreaterThanOrEqualTo(0))),
|
|
14120
|
+
metadata: Schema74.optionalKey(exports_shared_schema.Metadata)
|
|
14034
14121
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.StartInput" });
|
|
14035
|
-
var WaitSignalState =
|
|
14122
|
+
var WaitSignalState = Schema74.Literals(["resolved", "timed_out", "cancelled"]).annotate({
|
|
14036
14123
|
identifier: "Relay.ExecutionWorkflow.WaitSignalState"
|
|
14037
14124
|
});
|
|
14038
|
-
var WaitSignal =
|
|
14125
|
+
var WaitSignal = Schema74.Struct({
|
|
14039
14126
|
wait_id: exports_ids_schema.WaitId,
|
|
14040
14127
|
state: WaitSignalState,
|
|
14041
14128
|
signaled_at: exports_shared_schema.TimestampMillis
|
|
14042
14129
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.WaitSignal" });
|
|
14043
|
-
var SignalWaitInput =
|
|
14044
|
-
workflow_execution_id:
|
|
14130
|
+
var SignalWaitInput = Schema74.Struct({
|
|
14131
|
+
workflow_execution_id: Schema74.String,
|
|
14045
14132
|
wait_id: exports_ids_schema.WaitId,
|
|
14046
14133
|
state: WaitSignalState,
|
|
14047
14134
|
signaled_at: exports_shared_schema.TimestampMillis
|
|
14048
14135
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.SignalWaitInput" });
|
|
14049
|
-
var CancelExecutionInput =
|
|
14136
|
+
var CancelExecutionInput = Schema74.Struct({
|
|
14050
14137
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14051
14138
|
cancelled_at: exports_shared_schema.TimestampMillis,
|
|
14052
|
-
reason:
|
|
14139
|
+
reason: Schema74.optionalKey(Schema74.String)
|
|
14053
14140
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.CancelExecutionInput" });
|
|
14054
|
-
var CancelExecutionResult =
|
|
14141
|
+
var CancelExecutionResult = Schema74.Struct({
|
|
14055
14142
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14056
14143
|
status: exports_execution_schema.ExecutionStatus
|
|
14057
14144
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.CancelExecutionResult" });
|
|
14058
|
-
var WaitSnapshot =
|
|
14145
|
+
var WaitSnapshot = Schema74.Struct({
|
|
14059
14146
|
id: exports_ids_schema.WaitId,
|
|
14060
14147
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14061
|
-
envelope_id:
|
|
14148
|
+
envelope_id: Schema74.optionalKey(exports_ids_schema.EnvelopeId),
|
|
14062
14149
|
mode: exports_envelope_schema.WaitMode,
|
|
14063
|
-
correlation_key:
|
|
14064
|
-
state:
|
|
14150
|
+
correlation_key: Schema74.optionalKey(Schema74.String),
|
|
14151
|
+
state: Schema74.Literals(["open", "resolved", "timed_out", "cancelled"]),
|
|
14065
14152
|
metadata: exports_shared_schema.Metadata,
|
|
14066
14153
|
created_at: exports_shared_schema.TimestampMillis,
|
|
14067
|
-
resolved_at:
|
|
14154
|
+
resolved_at: Schema74.optionalKey(exports_shared_schema.TimestampMillis)
|
|
14068
14155
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.WaitSnapshot" });
|
|
14069
|
-
var StartResult =
|
|
14156
|
+
var StartResult = Schema74.Struct({
|
|
14070
14157
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14071
14158
|
status: exports_execution_schema.ExecutionStatus,
|
|
14072
|
-
wait_id:
|
|
14073
|
-
wait_state:
|
|
14074
|
-
metadata:
|
|
14159
|
+
wait_id: Schema74.optionalKey(exports_ids_schema.WaitId),
|
|
14160
|
+
wait_state: Schema74.optionalKey(Schema74.Literals(["resolved", "timed_out", "cancelled"])),
|
|
14161
|
+
metadata: Schema74.optionalKey(exports_shared_schema.Metadata)
|
|
14075
14162
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.StartResult" });
|
|
14076
14163
|
var StartExecutionWorkflowName = "Relay/Execution/Start";
|
|
14077
14164
|
var ActivityNames = {
|
|
@@ -14119,12 +14206,12 @@ var StartExecutionWorkflow = Workflow2.make(StartExecutionWorkflowName, {
|
|
|
14119
14206
|
var mapExecutionError = (error5) => {
|
|
14120
14207
|
if (error5.details === undefined)
|
|
14121
14208
|
return ExecutionWorkflowFailed.make({ message: error5.message });
|
|
14122
|
-
const terminalFailure =
|
|
14209
|
+
const terminalFailure = Schema74.decodeUnknownOption(AgentTerminalFailure)(error5.details).pipe(Option20.getOrUndefined);
|
|
14123
14210
|
return terminalFailure === undefined ? ExecutionWorkflowFailed.make({ message: "Malformed durable agent failure details" }) : ExecutionWorkflowFailed.make({ message: error5.message, terminal_failure: terminalFailure });
|
|
14124
14211
|
};
|
|
14125
14212
|
var mapAgentLoopError = (error5) => ExecutionServiceError.make({
|
|
14126
14213
|
message: error5._tag === "AgentLoopBudgetExceeded" ? `AgentLoopBudgetExceeded: used ${error5.tokens_used} of ${error5.token_budget} tokens` : error5.message,
|
|
14127
|
-
details: error5.pipe(
|
|
14214
|
+
details: error5.pipe(Schema74.encodeSync(AgentTerminalFailure), Schema74.decodeUnknownSync(exports_shared_schema.JsonValue)),
|
|
14128
14215
|
...error5.next_event_sequence === undefined ? {} : { next_event_sequence: error5.next_event_sequence }
|
|
14129
14216
|
});
|
|
14130
14217
|
var mapWaitError2 = (error5) => ExecutionWorkflowFailed.make({
|
|
@@ -14273,7 +14360,7 @@ var prepareCancellation = Effect79.fn("ExecutionWorkflow.prepareCancellation")(f
|
|
|
14273
14360
|
signals,
|
|
14274
14361
|
terminalNoop: false
|
|
14275
14362
|
};
|
|
14276
|
-
})).pipe(Effect79.mapError((error5) =>
|
|
14363
|
+
})).pipe(Effect79.mapError((error5) => Schema74.is(ExecutionWorkflowFailed)(error5) ? error5 : ExecutionWorkflowFailed.make({ message: "Tool cancellation transaction failed" })));
|
|
14277
14364
|
});
|
|
14278
14365
|
var signalPreparedCancellation = Effect79.fn("ExecutionWorkflow.signalPreparedCancellation")(function* (prepared, signaledAt) {
|
|
14279
14366
|
for (const pending of prepared.signals) {
|
|
@@ -14350,7 +14437,7 @@ var cancelExecution = (input, turn, reason) => Activity.make({
|
|
|
14350
14437
|
});
|
|
14351
14438
|
var loadCancellationRequested = (input, turn) => Activity.make({
|
|
14352
14439
|
name: ActivityNames.checkCancel(turn),
|
|
14353
|
-
success:
|
|
14440
|
+
success: Schema74.Boolean,
|
|
14354
14441
|
error: ExecutionWorkflowFailed,
|
|
14355
14442
|
execute: Effect79.gen(function* () {
|
|
14356
14443
|
const repository = yield* exports_execution_repository.Service;
|
|
@@ -14360,7 +14447,7 @@ var loadCancellationRequested = (input, turn) => Activity.make({
|
|
|
14360
14447
|
});
|
|
14361
14448
|
var loadWait = (name, waitId2) => Activity.make({
|
|
14362
14449
|
name,
|
|
14363
|
-
success:
|
|
14450
|
+
success: Schema74.UndefinedOr(WaitSnapshot),
|
|
14364
14451
|
error: ExecutionWorkflowFailed,
|
|
14365
14452
|
execute: get11(waitId2).pipe(Effect79.map((record2) => record2 === undefined ? undefined : toWaitSnapshot2(record2)), Effect79.mapError(mapWaitError2))
|
|
14366
14453
|
});
|
|
@@ -14403,7 +14490,7 @@ var decodeOptionalNumberSetting = (value, key4, valid) => {
|
|
|
14403
14490
|
var optionalNumberForStart = (input, key4, valid) => decodeOptionalNumberSetting(metadataSetting2(input, key4), key4, valid).pipe(Effect79.map((value) => value === null ? undefined : value));
|
|
14404
14491
|
var continueAsNewAfterTurnsForStart = (input) => optionalNumberForStart(input, continueAsNewAfterTurnsMetadataKey2, (value) => Number.isInteger(value) && value > 0);
|
|
14405
14492
|
var toolOutputMaxBytesForStart = (input) => decodeOptionalNumberSetting(metadataSetting2(input, toolOutputMaxBytesMetadataKey2), toolOutputMaxBytesMetadataKey2, (value) => value >= 0);
|
|
14406
|
-
var decodeMemorySubject = (value) => typeof value === "string" ?
|
|
14493
|
+
var decodeMemorySubject = (value) => typeof value === "string" ? Schema74.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(value).pipe(Effect79.mapError(() => ExecutionWorkflowFailed.make({ message: `Invalid memory_subject_id metadata value: ${value}` }))) : Effect79.fail(ExecutionWorkflowFailed.make({ message: "memory_subject_id metadata value must be a string" }));
|
|
14407
14494
|
var memorySubjectForStart = Effect79.fn("ExecutionWorkflow.memorySubjectForStart")(function* (input) {
|
|
14408
14495
|
const executionSubject = memorySubjectFromMetadata2(input.metadata);
|
|
14409
14496
|
if (executionSubject !== undefined)
|
|
@@ -14414,7 +14501,7 @@ var memorySubjectForStart = Effect79.fn("ExecutionWorkflow.memorySubjectForStart
|
|
|
14414
14501
|
var nextEventSequence4 = (eventLog, executionId) => eventLog.maxSequence(executionId).pipe(Effect79.map((max) => max === undefined ? 0 : max + 1), Effect79.mapError(mapEventLogError6));
|
|
14415
14502
|
var ensureWorkspace = (input) => Activity.make({
|
|
14416
14503
|
name: ActivityNames.ensureWorkspace,
|
|
14417
|
-
success:
|
|
14504
|
+
success: Schema74.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14418
14505
|
error: ExecutionWorkflowFailed,
|
|
14419
14506
|
execute: Effect79.gen(function* () {
|
|
14420
14507
|
if (input.agent_snapshot === undefined)
|
|
@@ -14431,19 +14518,19 @@ var ensureWorkspace = (input) => Activity.make({
|
|
|
14431
14518
|
});
|
|
14432
14519
|
var suspendWorkspace = (input, key4) => Activity.make({
|
|
14433
14520
|
name: ActivityNames.suspendWorkspace(key4),
|
|
14434
|
-
success:
|
|
14521
|
+
success: Schema74.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14435
14522
|
error: ExecutionWorkflowFailed,
|
|
14436
14523
|
execute: suspend2({ executionId: input.execution_id, now: input.started_at }).pipe(Effect79.mapError(mapWorkspaceError))
|
|
14437
14524
|
});
|
|
14438
14525
|
var resumeWorkspace = (input, key4) => Activity.make({
|
|
14439
14526
|
name: ActivityNames.resumeWorkspace(key4),
|
|
14440
|
-
success:
|
|
14527
|
+
success: Schema74.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14441
14528
|
error: ExecutionWorkflowFailed,
|
|
14442
14529
|
execute: resume2({ executionId: input.execution_id, now: input.started_at }).pipe(Effect79.map((plan2) => plan2?.lease), Effect79.mapError(mapWorkspaceError))
|
|
14443
14530
|
});
|
|
14444
14531
|
var releaseWorkspace = (input) => Activity.make({
|
|
14445
14532
|
name: ActivityNames.releaseWorkspace,
|
|
14446
|
-
success:
|
|
14533
|
+
success: Schema74.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14447
14534
|
error: ExecutionWorkflowFailed,
|
|
14448
14535
|
execute: release2({ executionId: input.execution_id, now: input.completed_at }).pipe(Effect79.mapError(mapWorkspaceError))
|
|
14449
14536
|
});
|
|
@@ -14519,7 +14606,7 @@ var completeExecution = (input, waitId2, waitState, workspaceRuntimeLayer, turn,
|
|
|
14519
14606
|
...input.metadata,
|
|
14520
14607
|
wait_id: wait.wait_id,
|
|
14521
14608
|
wait_state: "open",
|
|
14522
|
-
pending_agent_suspension: wait.suspension.pipe(
|
|
14609
|
+
pending_agent_suspension: wait.suspension.pipe(Schema74.encodeSync(exports_agent_event.AgentSuspended), Schema74.decodeUnknownSync(exports_shared_schema.JsonValue)),
|
|
14523
14610
|
...generationMetadata2(workflowGenerationForStart2(input))
|
|
14524
14611
|
},
|
|
14525
14612
|
nextEventSequence: wait.next_event_sequence
|
|
@@ -14535,12 +14622,12 @@ var completeExecution = (input, waitId2, waitState, workspaceRuntimeLayer, turn,
|
|
|
14535
14622
|
});
|
|
14536
14623
|
var failIncompatibleCheckpoint = (input, error5) => Activity.make({
|
|
14537
14624
|
name: ActivityNames.failIncompatibleCheckpoint,
|
|
14538
|
-
success:
|
|
14625
|
+
success: Schema74.Void,
|
|
14539
14626
|
error: ExecutionWorkflowFailed,
|
|
14540
14627
|
execute: Effect79.gen(function* () {
|
|
14541
14628
|
const eventLog = yield* Service41;
|
|
14542
14629
|
const eventSequence = yield* nextEventSequence4(eventLog, input.execution_id);
|
|
14543
|
-
const details = yield* error5.pipe(
|
|
14630
|
+
const details = yield* error5.pipe(Schema74.encodeEffect(AgentCheckpointCompatibilityError), Effect79.flatMap(Schema74.decodeUnknownEffect(exports_shared_schema.JsonValue)), Effect79.mapError(() => ExecutionWorkflowFailed.make({ message: "Invalid checkpoint failure details" })));
|
|
14544
14631
|
yield* run4({
|
|
14545
14632
|
executionId: input.execution_id,
|
|
14546
14633
|
eventSequence,
|
|
@@ -14555,7 +14642,7 @@ var failIncompatibleCheckpoint = (input, error5) => Activity.make({
|
|
|
14555
14642
|
});
|
|
14556
14643
|
var loadChildCancellationRequested = (input) => Activity.make({
|
|
14557
14644
|
name: ActivityNames.checkQueuedChildCancellation,
|
|
14558
|
-
success:
|
|
14645
|
+
success: Schema74.Boolean,
|
|
14559
14646
|
error: ExecutionWorkflowFailed,
|
|
14560
14647
|
execute: Effect79.gen(function* () {
|
|
14561
14648
|
const context = childDispatchContext2(input);
|
|
@@ -14567,7 +14654,7 @@ var loadChildCancellationRequested = (input) => Activity.make({
|
|
|
14567
14654
|
});
|
|
14568
14655
|
var notifyParentActivity = (input, context, status, output) => Activity.make({
|
|
14569
14656
|
name: ActivityNames.notifyParent(status),
|
|
14570
|
-
success:
|
|
14657
|
+
success: Schema74.Void,
|
|
14571
14658
|
error: ExecutionWorkflowFailed,
|
|
14572
14659
|
execute: Effect79.gen(function* () {
|
|
14573
14660
|
const notifier = yield* Effect79.serviceOption(Service54);
|
|
@@ -14845,8 +14932,8 @@ var signalWait = Effect79.fn("ExecutionWorkflow.signalWait")(function* (input) {
|
|
|
14845
14932
|
});
|
|
14846
14933
|
|
|
14847
14934
|
// ../runtime/src/wait/wait-signal.ts
|
|
14848
|
-
class WaitSignalError extends
|
|
14849
|
-
message:
|
|
14935
|
+
class WaitSignalError extends Schema75.TaggedErrorClass()("WaitSignalError", {
|
|
14936
|
+
message: Schema75.String
|
|
14850
14937
|
}) {
|
|
14851
14938
|
}
|
|
14852
14939
|
var signalWorkflowWait = Effect80.fn("WaitSignal.signalWorkflowWait")(function* (input) {
|
|
@@ -14865,19 +14952,19 @@ var signalWorkflowWait = Effect80.fn("WaitSignal.signalWorkflowWait")(function*
|
|
|
14865
14952
|
});
|
|
14866
14953
|
|
|
14867
14954
|
// ../runtime/src/inbox/inbox-service.ts
|
|
14868
|
-
class InboxDeliveryError extends
|
|
14955
|
+
class InboxDeliveryError extends Schema76.TaggedErrorClass()("InboxDeliveryError", {
|
|
14869
14956
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14870
|
-
message:
|
|
14957
|
+
message: Schema76.String
|
|
14871
14958
|
}) {
|
|
14872
14959
|
}
|
|
14873
14960
|
|
|
14874
|
-
class InboxReplyTokenInvalid extends
|
|
14875
|
-
reply_token:
|
|
14961
|
+
class InboxReplyTokenInvalid extends Schema76.TaggedErrorClass()("InboxReplyTokenInvalid", {
|
|
14962
|
+
reply_token: Schema76.String
|
|
14876
14963
|
}) {
|
|
14877
14964
|
}
|
|
14878
14965
|
|
|
14879
|
-
class InboxServiceError extends
|
|
14880
|
-
message:
|
|
14966
|
+
class InboxServiceError extends Schema76.TaggedErrorClass()("InboxServiceError", {
|
|
14967
|
+
message: Schema76.String
|
|
14881
14968
|
}) {
|
|
14882
14969
|
}
|
|
14883
14970
|
|
|
@@ -14985,9 +15072,9 @@ var layerWithSignal = (dependencies) => makeLayer2(dependencies);
|
|
|
14985
15072
|
var memoryLayer42 = layer50.pipe(Layer67.provide(exports_inbox_repository.memoryLayer), Layer67.provide(exports_envelope_repository.memoryLayer));
|
|
14986
15073
|
|
|
14987
15074
|
// ../runtime/src/topic/topic-service.ts
|
|
14988
|
-
import { Clock as Clock13, Context as Context62, Effect as Effect82, Layer as Layer68, Random as Random2, Schema as
|
|
14989
|
-
class TopicServiceError extends
|
|
14990
|
-
message:
|
|
15075
|
+
import { Clock as Clock13, Context as Context62, Effect as Effect82, Layer as Layer68, Random as Random2, Schema as Schema77 } from "effect";
|
|
15076
|
+
class TopicServiceError extends Schema77.TaggedErrorClass()("TopicServiceError", {
|
|
15077
|
+
message: Schema77.String
|
|
14991
15078
|
}) {
|
|
14992
15079
|
}
|
|
14993
15080
|
|
|
@@ -15063,17 +15150,17 @@ var layer51 = Layer68.effect(Service63, Effect82.gen(function* () {
|
|
|
15063
15150
|
var memoryLayer43 = layer51.pipe(Layer68.provide(exports_topic_repository.memoryLayer));
|
|
15064
15151
|
|
|
15065
15152
|
// ../runtime/src/topic/publish-to-topic-tool.ts
|
|
15066
|
-
import { Effect as Effect83, Schema as
|
|
15153
|
+
import { Effect as Effect83, Schema as Schema78 } from "effect";
|
|
15067
15154
|
var toolName3 = "publish_to_topic";
|
|
15068
15155
|
var permissionName3 = "relay.topic.publish";
|
|
15069
|
-
var ContentInput =
|
|
15070
|
-
var Input3 =
|
|
15071
|
-
topic:
|
|
15156
|
+
var ContentInput = Schema78.Union([Schema78.String, Schema78.Array(exports_content_schema.TextPart)]);
|
|
15157
|
+
var Input3 = Schema78.Struct({
|
|
15158
|
+
topic: Schema78.String,
|
|
15072
15159
|
content: ContentInput
|
|
15073
15160
|
}).annotate({ identifier: "Relay.PublishToTopicTool.Input" });
|
|
15074
|
-
var Output3 =
|
|
15075
|
-
envelope_id:
|
|
15076
|
-
subscriber_count:
|
|
15161
|
+
var Output3 = Schema78.Struct({
|
|
15162
|
+
envelope_id: Schema78.String,
|
|
15163
|
+
subscriber_count: Schema78.Int
|
|
15077
15164
|
}).annotate({ identifier: "Relay.PublishToTopicTool.Output" });
|
|
15078
15165
|
var registeredTool3 = (config) => tool(toolName3, {
|
|
15079
15166
|
description: "Publish a durable message to every subscriber of a topic.",
|
|
@@ -15095,23 +15182,23 @@ var registeredTool3 = (config) => tool(toolName3, {
|
|
|
15095
15182
|
});
|
|
15096
15183
|
|
|
15097
15184
|
// ../runtime/src/inbox/wait-for-messages-tool.ts
|
|
15098
|
-
import { Effect as Effect84, Schema as
|
|
15185
|
+
import { Effect as Effect84, Schema as Schema79 } from "effect";
|
|
15099
15186
|
var toolName4 = "wait_for_messages";
|
|
15100
15187
|
var permissionName4 = "relay.inbox.wait";
|
|
15101
|
-
var Input4 =
|
|
15188
|
+
var Input4 = Schema79.Struct({ timeout: Schema79.optionalKey(Schema79.String) }).annotate({
|
|
15102
15189
|
identifier: "Relay.WaitForMessagesTool.Input"
|
|
15103
15190
|
});
|
|
15104
|
-
var MessageView =
|
|
15105
|
-
sequence:
|
|
15106
|
-
from:
|
|
15107
|
-
content:
|
|
15108
|
-
reply_token:
|
|
15109
|
-
correlation_key:
|
|
15110
|
-
metadata:
|
|
15191
|
+
var MessageView = Schema79.Struct({
|
|
15192
|
+
sequence: Schema79.Int,
|
|
15193
|
+
from: Schema79.String,
|
|
15194
|
+
content: Schema79.Array(exports_content_schema.TextPart),
|
|
15195
|
+
reply_token: Schema79.optionalKey(Schema79.String),
|
|
15196
|
+
correlation_key: Schema79.optionalKey(Schema79.String),
|
|
15197
|
+
metadata: Schema79.optionalKey(exports_shared_schema.Metadata)
|
|
15111
15198
|
}).annotate({ identifier: "Relay.WaitForMessagesTool.MessageView" });
|
|
15112
|
-
var Output4 =
|
|
15113
|
-
status:
|
|
15114
|
-
messages:
|
|
15199
|
+
var Output4 = Schema79.Struct({
|
|
15200
|
+
status: Schema79.Literals(["messages", "timed_out"]),
|
|
15201
|
+
messages: Schema79.Array(MessageView)
|
|
15115
15202
|
}).annotate({ identifier: "Relay.WaitForMessagesTool.Output" });
|
|
15116
15203
|
var project = (message) => ({
|
|
15117
15204
|
sequence: message.sequence,
|
|
@@ -15168,18 +15255,18 @@ var registeredTool4 = (config) => tool(toolName4, {
|
|
|
15168
15255
|
});
|
|
15169
15256
|
|
|
15170
15257
|
// ../runtime/src/inbox/send-message-tool.ts
|
|
15171
|
-
import { Effect as Effect85, Schema as
|
|
15258
|
+
import { Effect as Effect85, Schema as Schema80 } from "effect";
|
|
15172
15259
|
var toolName5 = "send_message";
|
|
15173
15260
|
var permissionName5 = "relay.inbox.send";
|
|
15174
|
-
var ContentInput2 =
|
|
15175
|
-
var Input5 =
|
|
15176
|
-
to:
|
|
15261
|
+
var ContentInput2 = Schema80.Union([Schema80.String, Schema80.Array(exports_content_schema.TextPart)]);
|
|
15262
|
+
var Input5 = Schema80.Struct({
|
|
15263
|
+
to: Schema80.String,
|
|
15177
15264
|
content: ContentInput2,
|
|
15178
|
-
reply_token:
|
|
15265
|
+
reply_token: Schema80.optionalKey(Schema80.String)
|
|
15179
15266
|
}).annotate({ identifier: "Relay.SendMessageTool.Input" });
|
|
15180
|
-
var Output5 =
|
|
15181
|
-
envelope_id:
|
|
15182
|
-
delivered:
|
|
15267
|
+
var Output5 = Schema80.Struct({
|
|
15268
|
+
envelope_id: Schema80.String,
|
|
15269
|
+
delivered: Schema80.Literals(["inbox", "outbox", "reply"])
|
|
15183
15270
|
}).annotate({ identifier: "Relay.SendMessageTool.Output" });
|
|
15184
15271
|
var registeredTool5 = (config) => tool(toolName5, {
|
|
15185
15272
|
description: "Send a durable message to an address or reply to an inbox message.",
|
|
@@ -15217,26 +15304,26 @@ var registeredTool5 = (config) => tool(toolName5, {
|
|
|
15217
15304
|
});
|
|
15218
15305
|
|
|
15219
15306
|
// ../runtime/src/envelope/envelope-service.ts
|
|
15220
|
-
import { Context as Context63, Effect as Effect86, Layer as Layer69, Schema as
|
|
15221
|
-
class EnvelopeAddressNotFound extends
|
|
15307
|
+
import { Context as Context63, Effect as Effect86, Layer as Layer69, Schema as Schema81 } from "effect";
|
|
15308
|
+
class EnvelopeAddressNotFound extends Schema81.TaggedErrorClass()("EnvelopeAddressNotFound", {
|
|
15222
15309
|
address_id: exports_ids_schema.AddressId
|
|
15223
15310
|
}) {
|
|
15224
15311
|
}
|
|
15225
15312
|
|
|
15226
|
-
class EnvelopeRouteUnavailable extends
|
|
15313
|
+
class EnvelopeRouteUnavailable extends Schema81.TaggedErrorClass()("EnvelopeRouteUnavailable", {
|
|
15227
15314
|
address_id: exports_ids_schema.AddressId,
|
|
15228
|
-
route_key:
|
|
15315
|
+
route_key: Schema81.String
|
|
15229
15316
|
}) {
|
|
15230
15317
|
}
|
|
15231
15318
|
|
|
15232
|
-
class EnvelopeRouteDeferred extends
|
|
15319
|
+
class EnvelopeRouteDeferred extends Schema81.TaggedErrorClass()("EnvelopeRouteDeferred", {
|
|
15233
15320
|
address_id: exports_ids_schema.AddressId,
|
|
15234
|
-
route_key:
|
|
15321
|
+
route_key: Schema81.String
|
|
15235
15322
|
}) {
|
|
15236
15323
|
}
|
|
15237
15324
|
|
|
15238
|
-
class EnvelopeServiceError extends
|
|
15239
|
-
message:
|
|
15325
|
+
class EnvelopeServiceError extends Schema81.TaggedErrorClass()("EnvelopeServiceError", {
|
|
15326
|
+
message: Schema81.String
|
|
15240
15327
|
}) {
|
|
15241
15328
|
}
|
|
15242
15329
|
|
|
@@ -15443,6 +15530,7 @@ var strategy = (config) => {
|
|
|
15443
15530
|
const existing = yield* config.repository.get({ executionId: config.executionId, checkpointId: id }).pipe(Effect87.mapError(mapRepositoryError11));
|
|
15444
15531
|
if (existing !== undefined)
|
|
15445
15532
|
return existing.summary;
|
|
15533
|
+
yield* config.onSummarizeStarted?.({ turn: request.turn, overflow: request.overflow }) ?? Effect87.void;
|
|
15446
15534
|
const summary = yield* config.options?.summaryModel === undefined ? base.summarize(plan2, request) : Effect87.scoped(config.options.summaryModel.pipe(Effect87.flatMap(Layer70.build), Effect87.flatMap((context) => Effect87.provide(base.summarize(plan2, request), context))));
|
|
15447
15535
|
const createdAt = yield* Clock14.currentTimeMillis;
|
|
15448
15536
|
const input = {
|
|
@@ -15468,9 +15556,9 @@ var make8 = (config) => exports_compaction.make(strategy(config), defaultOptions
|
|
|
15468
15556
|
var layerFromEpoch = (epoch) => exports_instructions.layer(epoch.baseline.length === 0 ? [] : [exports_instructions.staticSource("relay:context-epoch", epoch.baseline)]);
|
|
15469
15557
|
|
|
15470
15558
|
// ../runtime/src/agent/relay-permissions.ts
|
|
15471
|
-
import { Clock as Clock15, Effect as Effect88, Layer as Layer71, Option as Option21, Schema as
|
|
15559
|
+
import { Clock as Clock15, Effect as Effect88, Layer as Layer71, Option as Option21, Schema as Schema82 } from "effect";
|
|
15472
15560
|
var permissionTokenPrefix = "wait:permission:";
|
|
15473
|
-
var jsonValue3 = (value) =>
|
|
15561
|
+
var jsonValue3 = (value) => Schema82.decodeUnknownSync(exports_shared_schema.JsonValue)(value === undefined ? null : value);
|
|
15474
15562
|
var waitIdForToolCall = (executionId, toolCallId) => Identifiers.waitId("permission", executionId, toolCallId);
|
|
15475
15563
|
var tokenFor = (executionId, request) => waitIdForToolCall(executionId, request.call.id);
|
|
15476
15564
|
var matchingRule = (rules, tool3, params) => {
|
|
@@ -15632,7 +15720,7 @@ var awaitAnswer = Effect88.fn("RelayPermissions.awaitAnswer")(function* (config,
|
|
|
15632
15720
|
var resolve8 = (config, pending) => pending.token.startsWith(permissionTokenPrefix) ? awaitAnswer(config, pending).pipe(Effect88.orDie) : Effect88.succeed({ _tag: "Approved" });
|
|
15633
15721
|
var rememberRule = Effect88.fn("RelayPermissions.rememberRule")(function* (config, rule) {
|
|
15634
15722
|
const createdAt = yield* Clock15.currentTimeMillis;
|
|
15635
|
-
const decodedRule = yield*
|
|
15723
|
+
const decodedRule = yield* Schema82.decodeUnknownEffect(exports_agent_schema.PermissionRule)(rule).pipe(Effect88.mapError((error5) => permissionError(error5.message)));
|
|
15636
15724
|
yield* config.repository.remember({
|
|
15637
15725
|
agent: config.agentName,
|
|
15638
15726
|
scope: config.scope,
|
|
@@ -15650,9 +15738,9 @@ var layer54 = (config) => Layer71.mergeAll(Layer71.succeed(exports_permissions.P
|
|
|
15650
15738
|
})));
|
|
15651
15739
|
|
|
15652
15740
|
// ../runtime/src/agent/relay-steering.ts
|
|
15653
|
-
import { Clock as Clock16, Effect as Effect89, Layer as Layer72, Schema as
|
|
15654
|
-
import { Prompt as
|
|
15655
|
-
var jsonValue4 = (value) =>
|
|
15741
|
+
import { Clock as Clock16, Effect as Effect89, Layer as Layer72, Schema as Schema83 } from "effect";
|
|
15742
|
+
import { Prompt as Prompt6 } from "effect/unstable/ai";
|
|
15743
|
+
var jsonValue4 = (value) => Schema83.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
15656
15744
|
var stringifyJson2 = (value) => JSON.stringify(jsonValue4(value));
|
|
15657
15745
|
var createdAtForSequence2 = (config, sequence) => config.startedAt + sequence - config.eventSequence;
|
|
15658
15746
|
var drainId = (config, kind, sequence) => `drain:${config.executionId}:steering:${kind}:sequence:${sequence}`;
|
|
@@ -15670,22 +15758,22 @@ var purePromptPart = (part) => {
|
|
|
15670
15758
|
};
|
|
15671
15759
|
var contentToPromptPart2 = (part) => {
|
|
15672
15760
|
const pure = purePromptPart(part);
|
|
15673
|
-
return pure === undefined ?
|
|
15761
|
+
return pure === undefined ? Prompt6.makePart("text", { text: stringifyJson2(part) }) : contentToPromptPart(pure);
|
|
15674
15762
|
};
|
|
15675
|
-
var promptForContent = (content) =>
|
|
15676
|
-
|
|
15677
|
-
content: content.length === 0 ? [
|
|
15763
|
+
var promptForContent = (content) => Prompt6.fromMessages([
|
|
15764
|
+
Prompt6.makeMessage("user", {
|
|
15765
|
+
content: content.length === 0 ? [Prompt6.makePart("text", { text: "" })] : content.map((part) => contentToPromptPart2(part))
|
|
15678
15766
|
})
|
|
15679
15767
|
]);
|
|
15680
15768
|
var promptTextParts = (prompt) => prompt.content.flatMap((message) => typeof message.content === "string" ? [exports_content_schema.text(message.content)] : message.content.flatMap((part) => part.type === "text" ? [exports_content_schema.text(part.text)] : []));
|
|
15681
15769
|
var contentFromMessage = (message) => {
|
|
15682
15770
|
if (typeof message.prompt === "string")
|
|
15683
15771
|
return [exports_content_schema.text(message.prompt)];
|
|
15684
|
-
const prompt =
|
|
15772
|
+
const prompt = Prompt6.make(message.prompt);
|
|
15685
15773
|
const textParts = promptTextParts(prompt);
|
|
15686
15774
|
if (textParts.length > 0)
|
|
15687
15775
|
return textParts;
|
|
15688
|
-
return [exports_content_schema.text(prompt.pipe(
|
|
15776
|
+
return [exports_content_schema.text(prompt.pipe(Schema83.encodeSync(Prompt6.Prompt), stringifyJson2))];
|
|
15689
15777
|
};
|
|
15690
15778
|
var steeringDeliveredEvent = (config, kind, drain2, messages, sequence) => ({
|
|
15691
15779
|
id: exports_ids_schema.EventId.make(`event:${drain2.drainId}:delivered`),
|
|
@@ -15730,8 +15818,8 @@ var layer55 = (config) => Layer72.succeed(exports_steering.Steering, exports_ste
|
|
|
15730
15818
|
}));
|
|
15731
15819
|
|
|
15732
15820
|
// ../runtime/src/agent/relay-tool-executor.ts
|
|
15733
|
-
import { Deferred as Deferred3, Effect as Effect90, Layer as Layer73, Option as Option22, Schema as
|
|
15734
|
-
var jsonValue5 = (value) =>
|
|
15821
|
+
import { Deferred as Deferred3, Effect as Effect90, Layer as Layer73, Option as Option22, Schema as Schema84 } from "effect";
|
|
15822
|
+
var jsonValue5 = (value) => Schema84.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
15735
15823
|
var errorDetail = (error5) => {
|
|
15736
15824
|
switch (error5._tag) {
|
|
15737
15825
|
case "ToolNotRegistered":
|
|
@@ -16047,7 +16135,7 @@ var {
|
|
|
16047
16135
|
usageReportedEvent: usageReportedEvent2
|
|
16048
16136
|
} = AgentLoopEvents;
|
|
16049
16137
|
|
|
16050
|
-
class AgentLoopWaitRequested extends
|
|
16138
|
+
class AgentLoopWaitRequested extends Schema85.TaggedErrorClass()("AgentLoopWaitRequested", {
|
|
16051
16139
|
wait_id: exports_ids_schema.WaitId,
|
|
16052
16140
|
tool_call: exports_tool_schema.Call,
|
|
16053
16141
|
suspension: exports_agent_event.AgentSuspended,
|
|
@@ -16057,7 +16145,7 @@ class AgentLoopWaitRequested extends Schema84.TaggedErrorClass()("AgentLoopWaitR
|
|
|
16057
16145
|
|
|
16058
16146
|
class Service61 extends Context64.Service()("@relayfx/runtime/agent/agent-loop-service/Service") {
|
|
16059
16147
|
}
|
|
16060
|
-
var jsonValue6 = (value) =>
|
|
16148
|
+
var jsonValue6 = (value) => Schema85.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
16061
16149
|
var toolNames = (agent) => HashSet7.fromIterable(agent.tool_names);
|
|
16062
16150
|
var turnPolicyFromSnapshot = (snapshot2) => {
|
|
16063
16151
|
switch (snapshot2.kind) {
|
|
@@ -16149,7 +16237,7 @@ var runStructuredTurn = Effect93.fn("AgentLoop.runStructuredTurn")(function* (la
|
|
|
16149
16237
|
prompt: STRUCTURED_TURN_PROMPT,
|
|
16150
16238
|
schema: registration.schema,
|
|
16151
16239
|
objectName: "output"
|
|
16152
|
-
})).pipe(Effect93.mapError((error5) =>
|
|
16240
|
+
})).pipe(Effect93.mapError((error5) => Schema85.is(AgentLoopError)(error5) ? error5 : loopError(error5, sequence)));
|
|
16153
16241
|
return jsonValue6(response.value);
|
|
16154
16242
|
});
|
|
16155
16243
|
var loopError = (error5, nextEventSequence5) => AgentLoopError.make({
|
|
@@ -16158,6 +16246,23 @@ var loopError = (error5, nextEventSequence5) => AgentLoopError.make({
|
|
|
16158
16246
|
});
|
|
16159
16247
|
var appendEvent = (eventLog, allocator, event, nextEventSequence5) => appendIdempotentTo(eventLog, event).pipe(Effect93.tap((appended) => allocator.advanceTo(appended.sequence + 1)), Effect93.mapError((error5) => loopError(error5, nextEventSequence5)));
|
|
16160
16248
|
var compactionCommittedCursor = (executionId, checkpointId2) => `execution:${executionId}:agent-compaction:${checkpointId2}:committed`;
|
|
16249
|
+
var appendCompactionStartedEvent = Effect93.fn("AgentLoop.appendCompactionStartedEvent")(function* (eventLog, allocator, input, info) {
|
|
16250
|
+
const cursor = `execution:${input.executionId}:agent-compaction:turn:${info.turn}:started`;
|
|
16251
|
+
const existing = yield* eventLog.findByCursor({ executionId: input.executionId, cursor }).pipe(Effect93.mapError((error5) => loopError(error5, input.eventSequence + 1)));
|
|
16252
|
+
if (Option24.isSome(existing))
|
|
16253
|
+
return;
|
|
16254
|
+
const sequence = yield* allocator.allocate(1);
|
|
16255
|
+
const data = { turn: info.turn, overflow: info.overflow };
|
|
16256
|
+
yield* appendEvent(eventLog, allocator, {
|
|
16257
|
+
id: exports_ids_schema.EventId.make(`event:${input.executionId}:agent-compaction:turn:${info.turn}:started`),
|
|
16258
|
+
execution_id: input.executionId,
|
|
16259
|
+
type: "agent.compaction.started",
|
|
16260
|
+
sequence,
|
|
16261
|
+
cursor,
|
|
16262
|
+
data,
|
|
16263
|
+
created_at: input.startedAt + (sequence - input.eventSequence)
|
|
16264
|
+
}, sequence + 1);
|
|
16265
|
+
});
|
|
16161
16266
|
var appendCompactionCommittedEvent = Effect93.fn("AgentLoop.appendCompactionCommittedEvent")(function* (eventLog, allocator, input, checkpoint) {
|
|
16162
16267
|
if (input.sessionId === undefined)
|
|
16163
16268
|
return;
|
|
@@ -16183,8 +16288,8 @@ var appendCompactionCommittedEvent = Effect93.fn("AgentLoop.appendCompactionComm
|
|
|
16183
16288
|
});
|
|
16184
16289
|
var toolFromDefinition = (definition) => AiTool2.dynamic(definition.name, {
|
|
16185
16290
|
description: definition.description,
|
|
16186
|
-
parameters:
|
|
16187
|
-
success:
|
|
16291
|
+
parameters: Schema85.make(exports_tool_schema.parametersSchema(definition.input_schema).ast),
|
|
16292
|
+
success: Schema85.Unknown,
|
|
16188
16293
|
...definition.needs_approval === undefined ? {} : { needsApproval: definition.needs_approval }
|
|
16189
16294
|
});
|
|
16190
16295
|
var toolkitFromRegistered = (registered) => Toolkit2.make(...registered.map((tool3) => toolFromDefinition(tool3.definition)));
|
|
@@ -16214,7 +16319,7 @@ var restoreHistory = Effect93.fn("AgentLoop.restoreHistory")(function* (chats, i
|
|
|
16214
16319
|
}
|
|
16215
16320
|
return history;
|
|
16216
16321
|
});
|
|
16217
|
-
var promptEquivalence =
|
|
16322
|
+
var promptEquivalence = Schema85.toEquivalence(Prompt7.Prompt);
|
|
16218
16323
|
var reconcileCompactionCheckpoint = Effect93.fn("AgentLoop.reconcileCompactionCheckpoint")(function* (sessions, chats, input, restoredHistory, onCheckpointCommitted, failOnMismatch = false) {
|
|
16219
16324
|
if (input.sessionId === undefined)
|
|
16220
16325
|
return restoredHistory;
|
|
@@ -16257,10 +16362,10 @@ var toolCallDecodeMaxRetriesConfig = Config4.int("RELAY_AGENT_TOOL_CALL_DECODE_M
|
|
|
16257
16362
|
var isToolCallDecodeError = (error5) => AiError3.isAiError(error5) && error5.method === "streamText" && error5.reason._tag === "InvalidOutputError";
|
|
16258
16363
|
var toolCallDecodeFeedback = (error5, availableToolNames) => {
|
|
16259
16364
|
const tools = availableToolNames.length === 0 ? "(no tools are available)" : availableToolNames.join(", ");
|
|
16260
|
-
return
|
|
16261
|
-
|
|
16365
|
+
return Prompt7.fromMessages([
|
|
16366
|
+
Prompt7.makeMessage("user", {
|
|
16262
16367
|
content: [
|
|
16263
|
-
|
|
16368
|
+
Prompt7.makePart("text", {
|
|
16264
16369
|
text: `Your previous response contained an invalid tool call: ${error5.reason.message}. Only call these tools with arguments matching their input schemas: ${tools}. Re-issue the intended tool calls.`
|
|
16265
16370
|
})
|
|
16266
16371
|
]
|
|
@@ -16281,7 +16386,7 @@ var withToolCallDecodeResilience = (base, availableToolNames, maxRetries, record
|
|
|
16281
16386
|
if (Cause2.hasInterrupts(cause))
|
|
16282
16387
|
return Stream13.failCause(cause);
|
|
16283
16388
|
const error5 = Cause2.squash(cause);
|
|
16284
|
-
const continuation = !emitted && retriesLeft > 0 && isToolCallDecodeError(error5) ? attempt(
|
|
16389
|
+
const continuation = !emitted && retriesLeft > 0 && isToolCallDecodeError(error5) ? attempt(Prompt7.concat(Prompt7.make(prompt), toolCallDecodeFeedback(error5, availableToolNames)), retriesLeft - 1) : Stream13.failCause(cause);
|
|
16285
16390
|
return Stream13.unwrap(recordFailureClassification(exports_model_registry.classifyFailure(base, error5)).pipe(Effect93.as(continuation)));
|
|
16286
16391
|
}));
|
|
16287
16392
|
}))));
|
|
@@ -16306,7 +16411,7 @@ var restoreContextEpoch = Effect93.fn("AgentLoop.restoreContextEpoch")(function*
|
|
|
16306
16411
|
return { baseline: epoch.baseline, dynamicSourceIds: epoch.dynamicSourceIds };
|
|
16307
16412
|
});
|
|
16308
16413
|
var mapBatonRunError = (error5, current2) => {
|
|
16309
|
-
if (
|
|
16414
|
+
if (Schema85.is(exports_agent_event.AgentSuspended)(error5)) {
|
|
16310
16415
|
return AgentLoopWaitRequested.make({
|
|
16311
16416
|
wait_id: exports_ids_schema.WaitId.make(error5.token),
|
|
16312
16417
|
tool_call: {
|
|
@@ -16319,29 +16424,31 @@ var mapBatonRunError = (error5, current2) => {
|
|
|
16319
16424
|
});
|
|
16320
16425
|
}
|
|
16321
16426
|
let message;
|
|
16322
|
-
if (
|
|
16427
|
+
if (Schema85.is(exports_model_telemetry.DeliveryFailed)(error5))
|
|
16428
|
+
message = `Telemetry delivery failed: ${error5.message}`;
|
|
16429
|
+
else if (Schema85.is(exports_agent_event.AgentError)(error5))
|
|
16323
16430
|
message = error5.message;
|
|
16324
|
-
else if (
|
|
16431
|
+
else if (Schema85.is(exports_agent_event.ResumeMismatch)(error5))
|
|
16325
16432
|
message = `Resume mismatch: ${error5.reason}`;
|
|
16326
|
-
else if (
|
|
16433
|
+
else if (Schema85.is(exports_turn_policy.TurnPolicyError)(error5))
|
|
16327
16434
|
message = error5.message;
|
|
16328
|
-
else if (
|
|
16435
|
+
else if (Schema85.is(exports_agent_event.TurnPolicyStopped)(error5))
|
|
16329
16436
|
message = `Turn policy stopped at turn ${error5.turn}`;
|
|
16330
|
-
else if (
|
|
16437
|
+
else if (Schema85.is(exports_agent_event.TurnLimitExceeded)(error5))
|
|
16331
16438
|
message = "Tool call turn limit exceeded";
|
|
16332
|
-
else if (
|
|
16439
|
+
else if (Schema85.is(exports_agent_event.MiddlewareViolation)(error5))
|
|
16333
16440
|
message = `ModelMiddleware violation at turn ${error5.turn}: ${error5.detail}`;
|
|
16334
|
-
else if (
|
|
16441
|
+
else if (Schema85.is(exports_agent_event.DuplicateToolCallId)(error5))
|
|
16335
16442
|
message = `Duplicate tool call id: ${error5.id}`;
|
|
16336
|
-
else if (
|
|
16443
|
+
else if (Schema85.is(exports_agent_event.ProgressOverflow)(error5))
|
|
16337
16444
|
message = `Tool progress overflow: ${error5.toolCallId}`;
|
|
16338
|
-
else if (
|
|
16445
|
+
else if (Schema85.is(exports_agent_event.ToolNameCollision)(error5))
|
|
16339
16446
|
message = `Tool name collision: ${error5.name}`;
|
|
16340
|
-
else if (
|
|
16447
|
+
else if (Schema85.is(AiError3.AiError)(error5))
|
|
16341
16448
|
message = error5.message;
|
|
16342
|
-
else if (
|
|
16449
|
+
else if (Schema85.is(exports_model_registry.LanguageModelNotRegistered)(error5))
|
|
16343
16450
|
message = `Language model not registered: ${error5.provider}/${error5.model}`;
|
|
16344
|
-
else if (
|
|
16451
|
+
else if (Schema85.is(exports_tool_executor.FrameworkFailure)(error5))
|
|
16345
16452
|
message = error5.message;
|
|
16346
16453
|
else {
|
|
16347
16454
|
const exhaustive = error5;
|
|
@@ -16349,14 +16456,14 @@ var mapBatonRunError = (error5, current2) => {
|
|
|
16349
16456
|
}
|
|
16350
16457
|
return AgentLoopError.make({ message, baton_failure: error5, next_event_sequence: current2 });
|
|
16351
16458
|
};
|
|
16352
|
-
var isBatonRunError = (error5) =>
|
|
16459
|
+
var isBatonRunError = (error5) => Schema85.is(exports_agent_event.AgentSuspended)(error5) || Schema85.is(exports_agent_event.ResumeMismatch)(error5) || Schema85.is(exports_turn_policy.TurnPolicyError)(error5) || Schema85.is(exports_agent_event.TurnPolicyStopped)(error5) || Schema85.is(exports_agent_event.TurnLimitExceeded)(error5) || Schema85.is(exports_agent_event.MiddlewareViolation)(error5) || Schema85.is(exports_agent_event.DuplicateToolCallId)(error5) || Schema85.is(exports_agent_event.ProgressOverflow)(error5) || Schema85.is(exports_agent_event.ToolNameCollision)(error5) || Schema85.is(exports_agent_event.AgentError)(error5) || Schema85.is(AiError3.AiError)(error5) || Schema85.is(exports_model_registry.LanguageModelNotRegistered)(error5) || Schema85.is(exports_tool_executor.FrameworkFailure)(error5);
|
|
16353
16460
|
var mapBoundaryError = (errorOrCurrent, current2, failureClassification) => {
|
|
16354
16461
|
if (current2 === undefined) {
|
|
16355
16462
|
const sequence = errorOrCurrent;
|
|
16356
16463
|
return (error6) => mapBoundaryError(error6, sequence);
|
|
16357
16464
|
}
|
|
16358
16465
|
const error5 = errorOrCurrent;
|
|
16359
|
-
if (
|
|
16466
|
+
if (Schema85.is(AgentLoopError)(error5) || Schema85.is(AgentLoopWaitRequested)(error5) || Schema85.is(AgentLoopBudgetExceeded)(error5))
|
|
16360
16467
|
return error5;
|
|
16361
16468
|
const mapped = isBatonRunError(error5) ? mapBatonRunError(error5, current2) : loopError(error5, current2);
|
|
16362
16469
|
return mapped._tag === "AgentLoopError" && failureClassification === "context-overflow" ? AgentLoopError.make({
|
|
@@ -16374,9 +16481,9 @@ var terminalMemoryTranscript = (prompt, text) => {
|
|
|
16374
16481
|
return;
|
|
16375
16482
|
if (promptHasAssistantText(prompt, text))
|
|
16376
16483
|
return prompt;
|
|
16377
|
-
return
|
|
16484
|
+
return Prompt7.fromMessages([
|
|
16378
16485
|
...prompt.content,
|
|
16379
|
-
|
|
16486
|
+
Prompt7.makeMessage("assistant", { content: [Prompt7.makePart("text", { text })] })
|
|
16380
16487
|
]);
|
|
16381
16488
|
};
|
|
16382
16489
|
var recallOnlyMemory = (memory) => exports_memory.Memory.of({
|
|
@@ -16599,7 +16706,8 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16599
16706
|
const compactionService = activeCompactionOptions === undefined ? undefined : exports_compaction.Compaction.of(make8({
|
|
16600
16707
|
executionId: input.executionId,
|
|
16601
16708
|
repository: activeCompactionRepository,
|
|
16602
|
-
options: activeCompactionOptions
|
|
16709
|
+
options: activeCompactionOptions,
|
|
16710
|
+
onSummarizeStarted: (info) => appendCompactionStartedEvent(eventLog, allocator, input, info).pipe(Effect93.mapError((error5) => exports_compaction.CompactionError.make({ message: error5.message, cause: error5 })))
|
|
16603
16711
|
}));
|
|
16604
16712
|
if (memory !== undefined && Option24.isNone(durableMemory)) {
|
|
16605
16713
|
return yield* AgentLoopError.make({
|
|
@@ -16742,7 +16850,7 @@ var run5 = Effect93.fn("AgentLoop.run.call")(function* (input) {
|
|
|
16742
16850
|
// ../runtime/src/cluster/execution-entity.ts
|
|
16743
16851
|
import { ClusterSchema, Entity } from "effect/unstable/cluster";
|
|
16744
16852
|
import { Rpc } from "effect/unstable/rpc";
|
|
16745
|
-
import { Schema as
|
|
16853
|
+
import { Schema as Schema86 } from "effect";
|
|
16746
16854
|
var Start = Rpc.make("start", {
|
|
16747
16855
|
payload: StartInput,
|
|
16748
16856
|
success: StartResult,
|
|
@@ -16750,12 +16858,12 @@ var Start = Rpc.make("start", {
|
|
|
16750
16858
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
16751
16859
|
var SignalWait = Rpc.make("signalWait", {
|
|
16752
16860
|
payload: SignalWaitInput,
|
|
16753
|
-
success:
|
|
16861
|
+
success: Schema86.Void,
|
|
16754
16862
|
error: ExecutionWorkflowFailed
|
|
16755
16863
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
16756
16864
|
var Dispatch = Rpc.make("dispatch", {
|
|
16757
16865
|
payload: StartInput,
|
|
16758
|
-
success:
|
|
16866
|
+
success: Schema86.Void,
|
|
16759
16867
|
error: ExecutionWorkflowError
|
|
16760
16868
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
16761
16869
|
var Cancel = Rpc.make("cancel", {
|
|
@@ -16778,10 +16886,10 @@ var layer59 = entity.toLayer(entity.of({
|
|
|
16778
16886
|
var client = entity.client;
|
|
16779
16887
|
|
|
16780
16888
|
// ../runtime/src/execution/execution-watch-service.ts
|
|
16781
|
-
import { Config as Config5, Context as Context65, Duration as Duration4, Effect as Effect94, Layer as Layer76, Ref as Ref20, Schema as
|
|
16889
|
+
import { Config as Config5, Context as Context65, Duration as Duration4, Effect as Effect94, Layer as Layer76, Ref as Ref20, Schema as Schema87, Stream as Stream14 } from "effect";
|
|
16782
16890
|
|
|
16783
|
-
class ExecutionWatchError extends
|
|
16784
|
-
message:
|
|
16891
|
+
class ExecutionWatchError extends Schema87.TaggedErrorClass()("ExecutionWatchError", {
|
|
16892
|
+
message: Schema87.String
|
|
16785
16893
|
}) {
|
|
16786
16894
|
}
|
|
16787
16895
|
|
|
@@ -16829,20 +16937,20 @@ var layerFromServices = Layer76.effect(Service65, Effect94.gen(function* () {
|
|
|
16829
16937
|
}));
|
|
16830
16938
|
|
|
16831
16939
|
// ../runtime/src/resident/resident-registry-service.ts
|
|
16832
|
-
import { Context as Context66, Effect as Effect95, Layer as Layer77, Schema as
|
|
16833
|
-
class ResidentKindNotFound extends
|
|
16940
|
+
import { Context as Context66, Effect as Effect95, Layer as Layer77, Schema as Schema88 } from "effect";
|
|
16941
|
+
class ResidentKindNotFound extends Schema88.TaggedErrorClass()("ResidentKindNotFound", {
|
|
16834
16942
|
kind: exports_ids_schema.ResidentKindName
|
|
16835
16943
|
}) {
|
|
16836
16944
|
}
|
|
16837
16945
|
|
|
16838
|
-
class ResidentKindInvalid extends
|
|
16946
|
+
class ResidentKindInvalid extends Schema88.TaggedErrorClass()("ResidentKindInvalid", {
|
|
16839
16947
|
kind: exports_ids_schema.ResidentKindName,
|
|
16840
|
-
message:
|
|
16948
|
+
message: Schema88.String
|
|
16841
16949
|
}) {
|
|
16842
16950
|
}
|
|
16843
16951
|
|
|
16844
|
-
class ResidentRegistryError extends
|
|
16845
|
-
message:
|
|
16952
|
+
class ResidentRegistryError extends Schema88.TaggedErrorClass()("ResidentRegistryError", {
|
|
16953
|
+
message: Schema88.String
|
|
16846
16954
|
}) {
|
|
16847
16955
|
}
|
|
16848
16956
|
|
|
@@ -16874,21 +16982,21 @@ var layer60 = Layer77.effect(Service66, Effect95.gen(function* () {
|
|
|
16874
16982
|
}));
|
|
16875
16983
|
|
|
16876
16984
|
// ../runtime/src/resident/resident-instance-service.ts
|
|
16877
|
-
import { Context as Context67, Effect as Effect96, Function as Function16, Layer as Layer78, Schema as
|
|
16878
|
-
class ResidentDestroyed extends
|
|
16985
|
+
import { Context as Context67, Effect as Effect96, Function as Function16, Layer as Layer78, Schema as Schema89 } from "effect";
|
|
16986
|
+
class ResidentDestroyed extends Schema89.TaggedErrorClass()("ResidentDestroyed", {
|
|
16879
16987
|
kind: exports_ids_schema.ResidentKindName,
|
|
16880
16988
|
key: exports_ids_schema.ResidentKey
|
|
16881
16989
|
}) {
|
|
16882
16990
|
}
|
|
16883
16991
|
|
|
16884
|
-
class ResidentNotFound2 extends
|
|
16992
|
+
class ResidentNotFound2 extends Schema89.TaggedErrorClass()("ResidentNotFound", {
|
|
16885
16993
|
kind: exports_ids_schema.ResidentKindName,
|
|
16886
16994
|
key: exports_ids_schema.ResidentKey
|
|
16887
16995
|
}) {
|
|
16888
16996
|
}
|
|
16889
16997
|
|
|
16890
|
-
class ResidentServiceError extends
|
|
16891
|
-
message:
|
|
16998
|
+
class ResidentServiceError extends Schema89.TaggedErrorClass()("ResidentServiceError", {
|
|
16999
|
+
message: Schema89.String
|
|
16892
17000
|
}) {
|
|
16893
17001
|
}
|
|
16894
17002
|
|
|
@@ -16991,9 +17099,9 @@ var layer61 = Layer78.effect(Service67, Effect96.gen(function* () {
|
|
|
16991
17099
|
}));
|
|
16992
17100
|
|
|
16993
17101
|
// ../runtime/src/execution/session-stream-service.ts
|
|
16994
|
-
import { Config as Config6, Context as Context68, Duration as Duration5, Effect as Effect97, HashSet as HashSet8, Layer as Layer79, Ref as Ref21, Schema as
|
|
16995
|
-
class SessionStreamError extends
|
|
16996
|
-
message:
|
|
17102
|
+
import { Config as Config6, Context as Context68, Duration as Duration5, Effect as Effect97, HashSet as HashSet8, Layer as Layer79, Ref as Ref21, Schema as Schema90, Stream as Stream15 } from "effect";
|
|
17103
|
+
class SessionStreamError extends Schema90.TaggedErrorClass()("SessionStreamError", {
|
|
17104
|
+
message: Schema90.String
|
|
16997
17105
|
}) {
|
|
16998
17106
|
}
|
|
16999
17107
|
|
|
@@ -17026,15 +17134,15 @@ var layerFromServices2 = Layer79.effect(Service68, Effect97.gen(function* () {
|
|
|
17026
17134
|
}));
|
|
17027
17135
|
|
|
17028
17136
|
// ../runtime/src/schedule/scheduler-service.ts
|
|
17029
|
-
import { Clock as Clock17, Config as Config7, Context as Context69, Cron, DateTime as DateTime2, Duration as Duration6, Effect as Effect98, Layer as Layer80, Option as Option25, Random as Random3, Result as Result3, Schema as
|
|
17030
|
-
class SchedulerError extends
|
|
17031
|
-
message:
|
|
17137
|
+
import { Clock as Clock17, Config as Config7, Context as Context69, Cron, DateTime as DateTime2, Duration as Duration6, Effect as Effect98, Layer as Layer80, Option as Option25, Random as Random3, Result as Result3, Schema as Schema91 } from "effect";
|
|
17138
|
+
class SchedulerError extends Schema91.TaggedErrorClass()("SchedulerError", {
|
|
17139
|
+
message: Schema91.String
|
|
17032
17140
|
}) {
|
|
17033
17141
|
}
|
|
17034
17142
|
|
|
17035
|
-
class ScheduleCronInvalid extends
|
|
17036
|
-
cron_expr:
|
|
17037
|
-
message:
|
|
17143
|
+
class ScheduleCronInvalid extends Schema91.TaggedErrorClass()("ScheduleCronInvalid", {
|
|
17144
|
+
cron_expr: Schema91.String,
|
|
17145
|
+
message: Schema91.String
|
|
17038
17146
|
}) {
|
|
17039
17147
|
}
|
|
17040
17148
|
|
|
@@ -17189,25 +17297,25 @@ var runOnce2 = Effect98.fn("SchedulerService.runOnce.call")(function* () {
|
|
|
17189
17297
|
});
|
|
17190
17298
|
|
|
17191
17299
|
// ../runtime/src/runner/runner-runtime-service.ts
|
|
17192
|
-
var DatabaseMode =
|
|
17300
|
+
var DatabaseMode = Schema92.Literals(["sql", "pg", "mysql", "sqlite", "memory"]).annotate({
|
|
17193
17301
|
identifier: "Relay.RunnerRuntime.DatabaseMode"
|
|
17194
17302
|
});
|
|
17195
|
-
var ReadinessStatus =
|
|
17303
|
+
var ReadinessStatus = Schema92.Struct({
|
|
17196
17304
|
database: DatabaseMode,
|
|
17197
|
-
cluster:
|
|
17198
|
-
workflow:
|
|
17199
|
-
executionEntity:
|
|
17305
|
+
cluster: Schema92.Literal("ready"),
|
|
17306
|
+
workflow: Schema92.Literals(["ready", "client"]),
|
|
17307
|
+
executionEntity: Schema92.Literals(["registered", "client"])
|
|
17200
17308
|
}).annotate({ identifier: "Relay.RunnerRuntime.ReadinessStatus" });
|
|
17201
17309
|
|
|
17202
|
-
class RunnerRuntimeError extends
|
|
17203
|
-
message:
|
|
17310
|
+
class RunnerRuntimeError extends Schema92.TaggedErrorClass()("RunnerRuntimeError", {
|
|
17311
|
+
message: Schema92.String
|
|
17204
17312
|
}) {
|
|
17205
17313
|
}
|
|
17206
17314
|
|
|
17207
|
-
class ClusterConfigMismatch extends
|
|
17208
|
-
field:
|
|
17209
|
-
expected:
|
|
17210
|
-
actual:
|
|
17315
|
+
class ClusterConfigMismatch extends Schema92.TaggedErrorClass()("ClusterConfigMismatch", {
|
|
17316
|
+
field: Schema92.String,
|
|
17317
|
+
expected: Schema92.String,
|
|
17318
|
+
actual: Schema92.String
|
|
17211
17319
|
}) {
|
|
17212
17320
|
}
|
|
17213
17321
|
|
|
@@ -17221,7 +17329,7 @@ var memoryClusterLayer = Sharding.layer.pipe(Layer81.provideMerge(Runners.layerN
|
|
|
17221
17329
|
var clusterHost = Config8.string("RELAY_CLUSTER_HOST").pipe(Config8.withDefault("localhost"));
|
|
17222
17330
|
var clusterPort = Config8.int("RELAY_CLUSTER_PORT").pipe(Config8.withDefault(34431));
|
|
17223
17331
|
var clusterShardsPerGroup = Config8.int("RELAY_CLUSTER_SHARDS_PER_GROUP").pipe(Config8.withDefault(300));
|
|
17224
|
-
var clusterShardGroups = Config8.schema(Config8.Array(
|
|
17332
|
+
var clusterShardGroups = Config8.schema(Config8.Array(Schema92.String), "RELAY_CLUSTER_SHARD_GROUPS").pipe(Config8.withDefault(["default", "execution"]));
|
|
17225
17333
|
var runnerAddressKey = (address) => `${address.host}:${address.port}`;
|
|
17226
17334
|
var runnerAddressEquals = (left, right) => left.host === right.host && left.port === right.port;
|
|
17227
17335
|
var shardingConfigFromEnv = Layer81.effect(ShardingConfig2.ShardingConfig, Effect99.gen(function* () {
|
|
@@ -17552,24 +17660,24 @@ var check = Effect99.fn("RunnerRuntime.check.call")(function* () {
|
|
|
17552
17660
|
});
|
|
17553
17661
|
|
|
17554
17662
|
// ../runtime/src/workflow/definition-runtime.ts
|
|
17555
|
-
import { Cause as Cause3, Clock as Clock18, Context as Context71, Effect as Effect100, Exit as Exit2, FiberMap as FiberMap2, Layer as Layer82, Option as Option27, Schema as
|
|
17663
|
+
import { Cause as Cause3, Clock as Clock18, Context as Context71, Effect as Effect100, Exit as Exit2, FiberMap as FiberMap2, Layer as Layer82, Option as Option27, Schema as Schema93 } from "effect";
|
|
17556
17664
|
import { dual as dual2 } from "effect/Function";
|
|
17557
17665
|
|
|
17558
|
-
class UnsupportedOperation extends
|
|
17666
|
+
class UnsupportedOperation extends Schema93.TaggedErrorClass()("UnsupportedWorkflowOperation", { operation_id: exports_ids_schema.WorkflowOperationId, kind: Schema93.String }) {
|
|
17559
17667
|
}
|
|
17560
17668
|
|
|
17561
|
-
class PinnedDefinitionNotFound extends
|
|
17669
|
+
class PinnedDefinitionNotFound extends Schema93.TaggedErrorClass()("PinnedWorkflowDefinitionNotFound", { execution_id: exports_ids_schema.ExecutionId }) {
|
|
17562
17670
|
}
|
|
17563
17671
|
|
|
17564
|
-
class PinnedDefinitionMismatch extends
|
|
17672
|
+
class PinnedDefinitionMismatch extends Schema93.TaggedErrorClass()("PinnedWorkflowDefinitionMismatch", { execution_id: exports_ids_schema.ExecutionId }) {
|
|
17565
17673
|
}
|
|
17566
17674
|
|
|
17567
|
-
class WorkflowRuntimeError extends
|
|
17568
|
-
message:
|
|
17675
|
+
class WorkflowRuntimeError extends Schema93.TaggedErrorClass()("WorkflowRuntimeError", {
|
|
17676
|
+
message: Schema93.String
|
|
17569
17677
|
}) {
|
|
17570
17678
|
}
|
|
17571
17679
|
|
|
17572
|
-
class WorkflowJoinPolicyNotSatisfied extends
|
|
17680
|
+
class WorkflowJoinPolicyNotSatisfied extends Schema93.TaggedErrorClass()("WorkflowJoinPolicyNotSatisfied", { policy: Schema93.String }) {
|
|
17573
17681
|
}
|
|
17574
17682
|
var runtimeError2 = (error5) => WorkflowRuntimeError.make({ message: String(error5) });
|
|
17575
17683
|
var mapRuntimeError2 = Effect100.mapError(runtimeError2);
|
|
@@ -17582,13 +17690,13 @@ class Service71 extends Context71.Service()("@relayfx/runtime/workflow/definitio
|
|
|
17582
17690
|
var fanOutIdFor = dual2(2, (executionId, fanOutKey) => exports_ids_schema.ChildFanOutId.make(`workflow:${executionId}:fan-out:${fanOutKey}`));
|
|
17583
17691
|
var childExecutionIdFor = (fanOutId, operationId2) => exports_ids_schema.ChildExecutionId.make(`${fanOutId}:member:${operationId2}`);
|
|
17584
17692
|
|
|
17585
|
-
class WorkflowCancelled extends
|
|
17693
|
+
class WorkflowCancelled extends Schema93.TaggedErrorClass()("WorkflowCancelled", {}) {
|
|
17586
17694
|
}
|
|
17587
17695
|
|
|
17588
|
-
class WorkflowBudgetExceeded extends
|
|
17696
|
+
class WorkflowBudgetExceeded extends Schema93.TaggedErrorClass()("WorkflowBudgetExceeded", { operation_id: exports_ids_schema.WorkflowOperationId }) {
|
|
17589
17697
|
}
|
|
17590
17698
|
|
|
17591
|
-
class WorkflowJoining extends
|
|
17699
|
+
class WorkflowJoining extends Schema93.TaggedErrorClass()("WorkflowJoining", {
|
|
17592
17700
|
fan_out_id: exports_ids_schema.ChildFanOutId
|
|
17593
17701
|
}) {
|
|
17594
17702
|
}
|
|
@@ -17843,7 +17951,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17843
17951
|
break;
|
|
17844
17952
|
}
|
|
17845
17953
|
case "cancellation":
|
|
17846
|
-
output2 = yield* execute(operation.operation).pipe(Effect100.catchIf(
|
|
17954
|
+
output2 = yield* execute(operation.operation).pipe(Effect100.catchIf(Schema93.is(WorkflowCancelled), () => operation.on_cancel === undefined ? Effect100.fail(WorkflowCancelled.make()) : execute(operation.on_cancel)));
|
|
17847
17955
|
break;
|
|
17848
17956
|
case "compensation":
|
|
17849
17957
|
output2 = yield* execute(operation.operation);
|
|
@@ -17890,7 +17998,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17890
17998
|
const result = yield* Effect100.exit(execute(revision.definition.entry_operation_id));
|
|
17891
17999
|
if (Exit2.isFailure(result)) {
|
|
17892
18000
|
const failure2 = Cause3.findErrorOption(result.cause);
|
|
17893
|
-
if (Option27.isSome(failure2) &&
|
|
18001
|
+
if (Option27.isSome(failure2) && Schema93.is(WorkflowJoining)(failure2.value))
|
|
17894
18002
|
return yield* result;
|
|
17895
18003
|
const currentRun = yield* repository.inspect(executionId);
|
|
17896
18004
|
if (currentRun?.status === "cancelled") {
|
|
@@ -17961,12 +18069,12 @@ var layerFromRuntime2 = Layer82.effect(Service71, Effect100.gen(function* () {
|
|
|
17961
18069
|
}));
|
|
17962
18070
|
|
|
17963
18071
|
// src/runtime.ts
|
|
17964
|
-
import { Cause as Cause5, Context as Context74, Effect as Effect112, Layer as Layer86, Option as Option31, Schema as
|
|
18072
|
+
import { Cause as Cause5, Context as Context74, Effect as Effect112, Layer as Layer86, Option as Option31, Schema as Schema101 } from "effect";
|
|
17965
18073
|
import { SqlClient as SqlClient31 } from "effect/unstable/sql/SqlClient";
|
|
17966
18074
|
|
|
17967
18075
|
// src/runtime-acquisition-error.ts
|
|
17968
|
-
import { Cause as Cause4, Function as Function17, Schema as
|
|
17969
|
-
var RuntimeConfigurationCategory =
|
|
18076
|
+
import { Cause as Cause4, Function as Function17, Schema as Schema94 } from "effect";
|
|
18077
|
+
var RuntimeConfigurationCategory = Schema94.Literals([
|
|
17970
18078
|
"missing-http-client",
|
|
17971
18079
|
"provider-config",
|
|
17972
18080
|
"model-registration",
|
|
@@ -17974,31 +18082,31 @@ var RuntimeConfigurationCategory = Schema93.Literals([
|
|
|
17974
18082
|
"database-config",
|
|
17975
18083
|
"unknown-host-layer"
|
|
17976
18084
|
]);
|
|
17977
|
-
var RuntimeConfigurationScope =
|
|
18085
|
+
var RuntimeConfigurationScope = Schema94.Literals(["host-layer", "database-client"]);
|
|
17978
18086
|
|
|
17979
|
-
class RuntimeHostLayerFailure extends
|
|
18087
|
+
class RuntimeHostLayerFailure extends Schema94.TaggedErrorClass()("RuntimeHostLayerFailure", { category: RuntimeConfigurationCategory }) {
|
|
17980
18088
|
}
|
|
17981
|
-
var SafeCauseReason =
|
|
18089
|
+
var SafeCauseReason = Schema94.TaggedUnion({
|
|
17982
18090
|
Fail: {
|
|
17983
18091
|
category: RuntimeConfigurationCategory,
|
|
17984
|
-
errorTag:
|
|
18092
|
+
errorTag: Schema94.Literals(["RuntimeHostLayerFailure", "UnknownTypedFailure"])
|
|
17985
18093
|
},
|
|
17986
|
-
Die: { defectTag:
|
|
18094
|
+
Die: { defectTag: Schema94.Literal("UnknownDefect") },
|
|
17987
18095
|
Interrupt: {}
|
|
17988
18096
|
});
|
|
17989
|
-
var SafeCause =
|
|
17990
|
-
reasons:
|
|
17991
|
-
truncated:
|
|
18097
|
+
var SafeCause = Schema94.Struct({
|
|
18098
|
+
reasons: Schema94.Array(SafeCauseReason).check(Schema94.isMaxLength(16)),
|
|
18099
|
+
truncated: Schema94.Boolean
|
|
17992
18100
|
});
|
|
17993
18101
|
|
|
17994
|
-
class RuntimeConfigurationError extends
|
|
18102
|
+
class RuntimeConfigurationError extends Schema94.TaggedErrorClass()("RuntimeConfigurationError", {
|
|
17995
18103
|
category: RuntimeConfigurationCategory,
|
|
17996
18104
|
scope: RuntimeConfigurationScope,
|
|
17997
18105
|
cause: SafeCause
|
|
17998
18106
|
}) {
|
|
17999
18107
|
}
|
|
18000
18108
|
var typedFailure = (error5) => {
|
|
18001
|
-
if (
|
|
18109
|
+
if (Schema94.is(RuntimeHostLayerFailure)(error5)) {
|
|
18002
18110
|
return { _tag: "Fail", category: error5.category, errorTag: "RuntimeHostLayerFailure" };
|
|
18003
18111
|
}
|
|
18004
18112
|
return { _tag: "Fail", category: "unknown-host-layer", errorTag: "UnknownTypedFailure" };
|
|
@@ -18017,11 +18125,11 @@ var safeCause = (cause) => {
|
|
|
18017
18125
|
var normalizeAcquisitionCauseImpl = (cause, scope, preserve) => {
|
|
18018
18126
|
const summary = safeCause(cause);
|
|
18019
18127
|
return Cause4.map(cause, (error5) => {
|
|
18020
|
-
if (
|
|
18128
|
+
if (Schema94.is(RuntimeConfigurationError)(error5) || preserve !== undefined && preserve(error5))
|
|
18021
18129
|
return error5;
|
|
18022
18130
|
const reason = typedFailure(error5);
|
|
18023
18131
|
return RuntimeConfigurationError.make({
|
|
18024
|
-
category:
|
|
18132
|
+
category: Schema94.is(RuntimeHostLayerFailure)(error5) ? reason.category : scope === "database-client" ? "database-config" : "unknown-host-layer",
|
|
18025
18133
|
scope,
|
|
18026
18134
|
cause: summary
|
|
18027
18135
|
});
|
|
@@ -18043,16 +18151,16 @@ var renderConfigurationError = (error5) => {
|
|
|
18043
18151
|
return `Runtime configuration error [${error5.category}/${error5.scope}]: ${remediation}; causes=${reasons}${error5.cause.truncated ? ",truncated" : ""}`;
|
|
18044
18152
|
};
|
|
18045
18153
|
// src/internal-client.ts
|
|
18046
|
-
import { Clock as Clock19, Effect as Effect109, Layer as Layer84, Option as Option30, Random as Random4, Schema as
|
|
18154
|
+
import { Clock as Clock19, Effect as Effect109, Layer as Layer84, Option as Option30, Random as Random4, Schema as Schema100, Stream as Stream17 } from "effect";
|
|
18047
18155
|
import { EntityId, ShardId, Sharding as Sharding2, ShardingConfig as ShardingConfig3 } from "effect/unstable/cluster";
|
|
18048
18156
|
|
|
18049
18157
|
// src/runtime-capability-policy.ts
|
|
18050
|
-
import { Context as Context72, Effect as Effect101, Function as Function18, Layer as Layer83, Schema as
|
|
18158
|
+
import { Context as Context72, Effect as Effect101, Function as Function18, Layer as Layer83, Schema as Schema95 } from "effect";
|
|
18051
18159
|
|
|
18052
|
-
class RuntimeCapabilityUnavailable extends
|
|
18053
|
-
capability:
|
|
18054
|
-
role:
|
|
18055
|
-
nextAction:
|
|
18160
|
+
class RuntimeCapabilityUnavailable extends Schema95.TaggedErrorClass()("RuntimeCapabilityUnavailable", {
|
|
18161
|
+
capability: Schema95.Literals(["fan-out", "workflow-definition"]),
|
|
18162
|
+
role: Schema95.Literals(["embedded", "runner", "client"]),
|
|
18163
|
+
nextAction: Schema95.Literals(["enable-embedded-capability", "use-embedded-runtime"])
|
|
18056
18164
|
}) {
|
|
18057
18165
|
}
|
|
18058
18166
|
|
|
@@ -18070,7 +18178,7 @@ var layer64 = Function18.dual(2, (role, capabilities) => Layer83.succeed(Service
|
|
|
18070
18178
|
}));
|
|
18071
18179
|
|
|
18072
18180
|
// src/client-baton-agent.ts
|
|
18073
|
-
import { Effect as Effect102, Schema as
|
|
18181
|
+
import { Effect as Effect102, Schema as Schema96 } from "effect";
|
|
18074
18182
|
var isRegisterBatonAgentInput = (input) => ("agent" in input);
|
|
18075
18183
|
var toolRefsFromBatonAgent = (agent) => Object.values(agent.toolkit.tools).map((tool3) => ({ name: tool3.name }));
|
|
18076
18184
|
var modelSelectionFromBatonAgent = (selection) => ({
|
|
@@ -18078,9 +18186,9 @@ var modelSelectionFromBatonAgent = (selection) => ({
|
|
|
18078
18186
|
model: selection.model,
|
|
18079
18187
|
...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
|
|
18080
18188
|
});
|
|
18081
|
-
var decodeBatonAgentName = (name) =>
|
|
18082
|
-
var decodeBatonAgentMetadata = (metadata11) => metadata11 === undefined ? Effect102.void :
|
|
18083
|
-
var decodeBatonMemorySubject = (subject) =>
|
|
18189
|
+
var decodeBatonAgentName = (name) => Schema96.decodeUnknownEffect(exports_shared_schema.NonEmptyString)(name).pipe(Effect102.mapError(() => ClientError.make({ message: "Baton agent name must not be blank" })));
|
|
18190
|
+
var decodeBatonAgentMetadata = (metadata11) => metadata11 === undefined ? Effect102.void : Schema96.decodeUnknownEffect(exports_shared_schema.Metadata)(metadata11).pipe(Effect102.mapError(() => ClientError.make({ message: "Baton agent metadata must be JSON metadata" })));
|
|
18191
|
+
var decodeBatonMemorySubject = (subject) => Schema96.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect102.mapError(() => ClientError.make({ message: "Baton agent memory subject must be a MemorySubjectId" })));
|
|
18084
18192
|
var metadataFromBatonAgent = Effect102.fn("Client.metadataFromBatonAgent")(function* (input) {
|
|
18085
18193
|
const agentMetadata = yield* decodeBatonAgentMetadata(input.agent.metadata);
|
|
18086
18194
|
const memorySubject = input.agent.memory === undefined ? undefined : yield* decodeBatonMemorySubject(input.agent.memory.subject);
|
|
@@ -18189,10 +18297,10 @@ import { Effect as Effect104, Option as Option29 } from "effect";
|
|
|
18189
18297
|
import { Effect as Effect103 } from "effect";
|
|
18190
18298
|
|
|
18191
18299
|
// src/client-error-mapping.ts
|
|
18192
|
-
import { Option as Option28, Schema as
|
|
18300
|
+
import { Option as Option28, Schema as Schema97 } from "effect";
|
|
18193
18301
|
var errorMessage2 = (error5) => error5 instanceof Error ? error5.message : String(error5);
|
|
18194
18302
|
var toClientError = (error5) => ClientError.make({ message: errorMessage2(error5) });
|
|
18195
|
-
var toStreamError = (error5) => Option28.match(
|
|
18303
|
+
var toStreamError = (error5) => Option28.match(Schema97.decodeUnknownOption(EventLogCursorNotFound)(error5), {
|
|
18196
18304
|
onNone: () => toClientError(error5),
|
|
18197
18305
|
onSome: (cursorError) => cursorError
|
|
18198
18306
|
});
|
|
@@ -18323,8 +18431,8 @@ var childStartInput = (input, accepted2, pin, definition, createdAt, parentWaitI
|
|
|
18323
18431
|
var childRunInternals = { childStartInput, internalSpawnChildRunInput };
|
|
18324
18432
|
|
|
18325
18433
|
// src/client-execution-payloads.ts
|
|
18326
|
-
import { Effect as Effect105, Schema as
|
|
18327
|
-
var encodeExecutionCursor = (cursor) =>
|
|
18434
|
+
import { Effect as Effect105, Schema as Schema98 } from "effect";
|
|
18435
|
+
var encodeExecutionCursor = (cursor) => Schema98.encodeEffect(exports_pagination_schema.ExecutionCursorCodec)({ id: cursor.id, at: cursor.updatedAt }).pipe(Effect105.mapError(toClientError));
|
|
18328
18436
|
var executionIdFromIdempotencyKey = (idempotencyKey) => exports_ids_schema.ExecutionId.make(`execution:${idempotencyKey}`);
|
|
18329
18437
|
var metadataWithIdempotencyKey = (metadata11, idempotencyKey) => ({
|
|
18330
18438
|
...metadata11,
|
|
@@ -18441,9 +18549,9 @@ var wakeRuntime = Effect107.fn("Client.waits.wakeRuntime")(function* (waits, eve
|
|
|
18441
18549
|
var runtimeWakeInternals = { wakeRuntime };
|
|
18442
18550
|
|
|
18443
18551
|
// src/client-tool-outcome.ts
|
|
18444
|
-
import { Effect as Effect108, Schema as
|
|
18552
|
+
import { Effect as Effect108, Schema as Schema99 } from "effect";
|
|
18445
18553
|
var toolWaitId = (executionId, callId) => Identifiers.waitId("tool", executionId, callId);
|
|
18446
|
-
var acceptedWaitOutcome = (wait) =>
|
|
18554
|
+
var acceptedWaitOutcome = (wait) => Schema99.decodeUnknownEffect(exports_tool_schema.ExternalOutcome)(wait.metadata.external_outcome).pipe(Effect108.mapError(toClientError));
|
|
18447
18555
|
var resolveToolOutcomeWait = Effect108.fn("Client.resolveToolOutcomeWait")(function* (waits, eventLog, call, outcome, completedAt) {
|
|
18448
18556
|
const waitId2 = call.waitId ?? toolWaitId(call.executionId, call.call.id);
|
|
18449
18557
|
const wait = yield* waits.get(waitId2).pipe(Effect108.mapError(toClientError));
|
|
@@ -18724,7 +18832,7 @@ var replyValueFrom = (content) => {
|
|
|
18724
18832
|
const text = content.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
18725
18833
|
if (text.length === 0)
|
|
18726
18834
|
return Option30.none();
|
|
18727
|
-
return
|
|
18835
|
+
return Schema100.decodeUnknownOption(Schema100.UnknownFromJsonString)(text);
|
|
18728
18836
|
};
|
|
18729
18837
|
var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
18730
18838
|
const makeExecutionClient = yield* client;
|
|
@@ -18804,7 +18912,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18804
18912
|
status: "queued",
|
|
18805
18913
|
metadata: { operation: "envelope-send" },
|
|
18806
18914
|
createdAt
|
|
18807
|
-
}).pipe(Effect109.catchIf(
|
|
18915
|
+
}).pipe(Effect109.catchIf(Schema100.is(exports_execution_repository.DuplicateExecution), () => Effect109.void), Effect109.mapError(toClientError));
|
|
18808
18916
|
}
|
|
18809
18917
|
const maxSequence3 = yield* eventLog.maxSequence(executionId).pipe(Effect109.mapError(toClientError));
|
|
18810
18918
|
return yield* envelopes.send({
|
|
@@ -19050,7 +19158,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19050
19158
|
return records.map(toWaitView);
|
|
19051
19159
|
}),
|
|
19052
19160
|
listExecutions: Effect109.fn("Client.runtime.listExecutions")(function* (input) {
|
|
19053
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19161
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema100.decodeEffect(exports_pagination_schema.ExecutionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })));
|
|
19054
19162
|
const result = yield* executionRepository.list({
|
|
19055
19163
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
19056
19164
|
...input.status === undefined ? {} : { status: input.status },
|
|
@@ -19100,13 +19208,13 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19100
19208
|
}).pipe(Effect109.mapError(toClientError));
|
|
19101
19209
|
}),
|
|
19102
19210
|
listSessions: Effect109.fn("Client.runtime.listSessions")(function* (input) {
|
|
19103
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19211
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema100.decodeEffect(exports_pagination_schema.SessionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })));
|
|
19104
19212
|
const result = yield* sessionRepository.list({
|
|
19105
19213
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
19106
19214
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
19107
19215
|
...cursor === undefined ? {} : { cursor }
|
|
19108
19216
|
});
|
|
19109
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
19217
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema100.encodeEffect(exports_pagination_schema.SessionCursorCodec)({
|
|
19110
19218
|
id: result.nextCursor.id,
|
|
19111
19219
|
at: result.nextCursor.updatedAt
|
|
19112
19220
|
});
|
|
@@ -19119,7 +19227,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19119
19227
|
const session = yield* sessionRepository.get(input.session_id).pipe(Effect109.mapError(toClientError));
|
|
19120
19228
|
if (session === undefined)
|
|
19121
19229
|
return yield* ClientError.make({ message: `Session not found: ${input.session_id}` });
|
|
19122
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19230
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema100.decodeEffect(exports_pagination_schema.ExecutionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })), Effect109.mapError(toClientError));
|
|
19123
19231
|
const result = yield* executionRepository.list({
|
|
19124
19232
|
sessionId: input.session_id,
|
|
19125
19233
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
@@ -19190,7 +19298,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19190
19298
|
if (instance === undefined || instance.status === "destroyed") {
|
|
19191
19299
|
return yield* ResidentNotFound.make({ kind: input.kind, key: input.key });
|
|
19192
19300
|
}
|
|
19193
|
-
const encoded = yield*
|
|
19301
|
+
const encoded = yield* Schema100.encodeUnknownEffect(input.command.input)(input.input).pipe(Effect109.mapError(toClientError));
|
|
19194
19302
|
const inputRef = inputSchemaRef(input.command.name);
|
|
19195
19303
|
const outputRef = outputSchemaRef(input.command.name);
|
|
19196
19304
|
if (Option30.isSome(schemaRegistry)) {
|
|
@@ -19237,7 +19345,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19237
19345
|
message: "reply carried no decodable content"
|
|
19238
19346
|
});
|
|
19239
19347
|
}
|
|
19240
|
-
return yield*
|
|
19348
|
+
return yield* Schema100.decodeUnknownEffect(input.command.output)(replyValue.value).pipe(Effect109.mapError((issue) => CommandReplyInvalid.make({
|
|
19241
19349
|
command: input.command.name,
|
|
19242
19350
|
wait_id: outcome.wait_id,
|
|
19243
19351
|
message: errorMessage2(issue)
|
|
@@ -19278,14 +19386,14 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19278
19386
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
19279
19387
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
19280
19388
|
updatedAt: input.updated_at
|
|
19281
|
-
}).pipe(Effect109.mapError((error5) =>
|
|
19389
|
+
}).pipe(Effect109.mapError((error5) => Schema100.is(StateVersionConflict3)(error5) ? StateVersionConflict.make(error5) : toClientError(error5)))),
|
|
19282
19390
|
deleteResidentState: Effect109.fn("Client.runtime.deleteResidentState")((input) => executionState.remove({
|
|
19283
19391
|
executionId: input.execution_id,
|
|
19284
19392
|
key: input.key,
|
|
19285
19393
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
19286
19394
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
19287
19395
|
removedAt: input.removed_at
|
|
19288
|
-
}).pipe(Effect109.mapError((error5) =>
|
|
19396
|
+
}).pipe(Effect109.mapError((error5) => Schema100.is(StateVersionConflict3)(error5) ? StateVersionConflict.make(error5) : toClientError(error5)))),
|
|
19289
19397
|
listResidentState: Effect109.fn("Client.runtime.listResidentState")((input) => executionState.list({
|
|
19290
19398
|
executionId: input.execution_id,
|
|
19291
19399
|
...input.prefix === undefined ? {} : { prefix: input.prefix },
|
|
@@ -19544,77 +19652,77 @@ import { Effect as Effect111 } from "effect";
|
|
|
19544
19652
|
var recoverPersistedFanOut = (recover) => recover().pipe(Effect111.mapError((error5) => WorkflowRuntimeError.make({ message: error5._tag })), Effect111.asVoid);
|
|
19545
19653
|
|
|
19546
19654
|
// src/runtime.ts
|
|
19547
|
-
var Dialect2 =
|
|
19655
|
+
var Dialect2 = Schema101.Literals(["pg", "mysql", "sqlite"]);
|
|
19548
19656
|
|
|
19549
|
-
class NotificationFailure extends
|
|
19550
|
-
reason:
|
|
19657
|
+
class NotificationFailure extends Schema101.TaggedErrorClass()("NotificationFailure", {
|
|
19658
|
+
reason: Schema101.String
|
|
19551
19659
|
}) {
|
|
19552
19660
|
}
|
|
19553
19661
|
|
|
19554
|
-
class ClusterFailure extends
|
|
19555
|
-
reason:
|
|
19662
|
+
class ClusterFailure extends Schema101.TaggedErrorClass()("ClusterFailure", {
|
|
19663
|
+
reason: Schema101.String
|
|
19556
19664
|
}) {
|
|
19557
19665
|
}
|
|
19558
19666
|
|
|
19559
|
-
class SqlFailure extends
|
|
19560
|
-
category:
|
|
19561
|
-
operation:
|
|
19562
|
-
retryable:
|
|
19667
|
+
class SqlFailure extends Schema101.TaggedErrorClass()("SqlFailure", {
|
|
19668
|
+
category: Schema101.Literals(["connection", "statement", "unknown"]),
|
|
19669
|
+
operation: Schema101.Literals(["acquire", "migrate", "verify", "notify", "readiness"]),
|
|
19670
|
+
retryable: Schema101.Boolean
|
|
19563
19671
|
}) {
|
|
19564
19672
|
}
|
|
19565
|
-
var SqlDialect =
|
|
19673
|
+
var SqlDialect = Schema101.Literals(["sqlite", "pg", "mysql", "mssql", "clickhouse"]);
|
|
19566
19674
|
|
|
19567
|
-
class DatabaseDialectMismatch extends
|
|
19675
|
+
class DatabaseDialectMismatch extends Schema101.TaggedErrorClass()("DatabaseDialectMismatch", { expected: Dialect2, actual: SqlDialect }) {
|
|
19568
19676
|
}
|
|
19569
19677
|
|
|
19570
|
-
class DatabaseAlreadyOwned extends
|
|
19678
|
+
class DatabaseAlreadyOwned extends Schema101.TaggedErrorClass()("DatabaseAlreadyOwned", {
|
|
19571
19679
|
databaseIdentity: DatabaseIdentity
|
|
19572
19680
|
}) {
|
|
19573
19681
|
}
|
|
19574
19682
|
|
|
19575
|
-
class UnsupportedTopology extends
|
|
19576
|
-
reason:
|
|
19683
|
+
class UnsupportedTopology extends Schema101.TaggedErrorClass()("UnsupportedTopology", {
|
|
19684
|
+
reason: Schema101.String
|
|
19577
19685
|
}) {
|
|
19578
19686
|
}
|
|
19579
19687
|
|
|
19580
|
-
class MigratorError extends
|
|
19581
|
-
reason:
|
|
19688
|
+
class MigratorError extends Schema101.TaggedErrorClass()("MigratorError", {
|
|
19689
|
+
reason: Schema101.String
|
|
19582
19690
|
}) {
|
|
19583
19691
|
}
|
|
19584
19692
|
|
|
19585
|
-
class SchemaHeadMismatch extends
|
|
19586
|
-
expected:
|
|
19587
|
-
actual:
|
|
19693
|
+
class SchemaHeadMismatch extends Schema101.TaggedErrorClass()("SchemaHeadMismatch", {
|
|
19694
|
+
expected: Schema101.String,
|
|
19695
|
+
actual: Schema101.String
|
|
19588
19696
|
}) {
|
|
19589
19697
|
}
|
|
19590
19698
|
|
|
19591
|
-
class HostUnavailable extends
|
|
19592
|
-
host:
|
|
19593
|
-
reason:
|
|
19699
|
+
class HostUnavailable extends Schema101.TaggedErrorClass()("HostUnavailable", {
|
|
19700
|
+
host: Schema101.String,
|
|
19701
|
+
reason: Schema101.String
|
|
19594
19702
|
}) {
|
|
19595
19703
|
}
|
|
19596
|
-
var RuntimeTopologyCause =
|
|
19704
|
+
var RuntimeTopologyCause = Schema101.Union([
|
|
19597
19705
|
ClusterFailure,
|
|
19598
19706
|
DatabaseDialectMismatch,
|
|
19599
19707
|
DatabaseAlreadyOwned,
|
|
19600
19708
|
UnsupportedTopology
|
|
19601
19709
|
]);
|
|
19602
|
-
var RuntimeMigrationCause =
|
|
19710
|
+
var RuntimeMigrationCause = Schema101.Union([
|
|
19603
19711
|
SqlFailure,
|
|
19604
19712
|
MigratorError,
|
|
19605
19713
|
SchemaHeadMismatch
|
|
19606
19714
|
]);
|
|
19607
|
-
var RuntimeReadinessCause =
|
|
19715
|
+
var RuntimeReadinessCause = Schema101.Union([
|
|
19608
19716
|
SqlFailure,
|
|
19609
19717
|
NotificationFailure,
|
|
19610
19718
|
ClusterFailure,
|
|
19611
19719
|
HostUnavailable
|
|
19612
19720
|
]);
|
|
19613
19721
|
|
|
19614
|
-
class RuntimeTopologyError extends
|
|
19722
|
+
class RuntimeTopologyError extends Schema101.TaggedErrorClass()("RuntimeTopologyError", {
|
|
19615
19723
|
dialect: Dialect2,
|
|
19616
|
-
role:
|
|
19617
|
-
nextAction:
|
|
19724
|
+
role: Schema101.Literals(["embedded", "runner", "client"]),
|
|
19725
|
+
nextAction: Schema101.Literals([
|
|
19618
19726
|
"use-embedded",
|
|
19619
19727
|
"use-postgres-or-mysql",
|
|
19620
19728
|
"use-client-constructor",
|
|
@@ -19625,39 +19733,39 @@ class RuntimeTopologyError extends Schema100.TaggedErrorClass()("RuntimeTopology
|
|
|
19625
19733
|
}) {
|
|
19626
19734
|
}
|
|
19627
19735
|
|
|
19628
|
-
class RuntimeMigrationError extends
|
|
19736
|
+
class RuntimeMigrationError extends Schema101.TaggedErrorClass()("RuntimeMigrationError", {
|
|
19629
19737
|
dialect: Dialect2,
|
|
19630
|
-
phase:
|
|
19631
|
-
nextAction:
|
|
19738
|
+
phase: Schema101.Literals(["apply", "verify"]),
|
|
19739
|
+
nextAction: Schema101.Literals(["retry", "inspect-schema", "run-compatible-release"]),
|
|
19632
19740
|
cause: RuntimeMigrationCause
|
|
19633
19741
|
}) {
|
|
19634
19742
|
}
|
|
19635
19743
|
|
|
19636
|
-
class RuntimeReadinessError extends
|
|
19637
|
-
phase:
|
|
19744
|
+
class RuntimeReadinessError extends Schema101.TaggedErrorClass()("RuntimeReadinessError", {
|
|
19745
|
+
phase: Schema101.Literals(["database", "notification", "cluster", "hosts"]),
|
|
19638
19746
|
cause: RuntimeReadinessCause
|
|
19639
19747
|
}) {
|
|
19640
19748
|
}
|
|
19641
|
-
var RuntimeCapabilityStatus =
|
|
19642
|
-
|
|
19643
|
-
enabled:
|
|
19644
|
-
source:
|
|
19645
|
-
health:
|
|
19749
|
+
var RuntimeCapabilityStatus = Schema101.Union([
|
|
19750
|
+
Schema101.Struct({
|
|
19751
|
+
enabled: Schema101.Literal(false),
|
|
19752
|
+
source: Schema101.Literals(["local-host", "role-unavailable"]),
|
|
19753
|
+
health: Schema101.Literal("not-applicable")
|
|
19646
19754
|
}),
|
|
19647
|
-
|
|
19648
|
-
enabled:
|
|
19649
|
-
source:
|
|
19650
|
-
health:
|
|
19755
|
+
Schema101.Struct({
|
|
19756
|
+
enabled: Schema101.Literal(true),
|
|
19757
|
+
source: Schema101.Literal("local-host"),
|
|
19758
|
+
health: Schema101.Literals(["healthy", "unhealthy"])
|
|
19651
19759
|
})
|
|
19652
19760
|
]);
|
|
19653
|
-
var ReadinessStatus2 =
|
|
19654
|
-
ready:
|
|
19655
|
-
role:
|
|
19761
|
+
var ReadinessStatus2 = Schema101.Struct({
|
|
19762
|
+
ready: Schema101.Literal(true),
|
|
19763
|
+
role: Schema101.Literals(["embedded", "runner", "client"]),
|
|
19656
19764
|
dialect: Dialect2,
|
|
19657
19765
|
databaseIdentity: DatabaseIdentity,
|
|
19658
|
-
schemaHead:
|
|
19659
|
-
notification:
|
|
19660
|
-
capabilities:
|
|
19766
|
+
schemaHead: Schema101.String,
|
|
19767
|
+
notification: Schema101.Literals(["pg-listen-notify", "polling", "in-process"]),
|
|
19768
|
+
capabilities: Schema101.Struct({
|
|
19661
19769
|
fanOut: RuntimeCapabilityStatus,
|
|
19662
19770
|
workflowDefinition: RuntimeCapabilityStatus
|
|
19663
19771
|
})
|
|
@@ -19671,7 +19779,7 @@ var normalizeHost = (layer65, _role, _dialect) => layer65.pipe(Layer86.catchCaus
|
|
|
19671
19779
|
role: _role,
|
|
19672
19780
|
nextAction: _role === "embedded" ? "use-embedded" : "use-different-database",
|
|
19673
19781
|
cause: ClusterFailure.make({ reason: "cluster configuration is incompatible" })
|
|
19674
|
-
}) : error5), "host-layer", (error5) =>
|
|
19782
|
+
}) : error5), "host-layer", (error5) => Schema101.is(RuntimeConfigurationError)(error5) || Schema101.is(RuntimeTopologyError)(error5) || Schema101.is(RuntimeMigrationError)(error5))))));
|
|
19675
19783
|
var actualDialect = (sql) => sql.onDialectOrElse({
|
|
19676
19784
|
sqlite: () => "sqlite",
|
|
19677
19785
|
pg: () => "pg",
|