@relayfx/sdk 0.6.1 → 0.7.1
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-fh2ftte9.js → index-q7xzf506.js} +6 -0
- package/dist/{index-5vjhqzbk.js → index-qa93yf6j.js} +1516 -800
- package/dist/{index-dm4yqr8f.js → index-rppc919a.js} +1 -1
- package/dist/{index-ftgf8py0.js → index-s3mmg704.js} +1174 -1070
- package/dist/index.js +265 -229
- package/dist/mysql.js +4 -4
- package/dist/postgres.js +4 -4
- 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/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 +7 -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* () {
|
|
@@ -6208,68 +6288,34 @@ __export(exports_session_repository, {
|
|
|
6208
6288
|
Service: () => Service35,
|
|
6209
6289
|
DuplicateSession: () => DuplicateSession
|
|
6210
6290
|
});
|
|
6211
|
-
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";
|
|
6212
6292
|
|
|
6213
6293
|
// ../store-sql/src/session/session-entry-records.ts
|
|
6214
|
-
import { Effect as Effect39, Schema as
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
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])
|
|
6223
6302
|
}).annotate({ identifier: "Relay.SessionEntry.Row" });
|
|
6224
|
-
var
|
|
6225
|
-
Schema37.TaggedStruct("String", { value: Schema37.String }),
|
|
6226
|
-
Schema37.TaggedStruct("Bytes", { value: Schema37.Array(Schema37.Finite) }),
|
|
6227
|
-
Schema37.TaggedStruct("Url", { value: Schema37.String })
|
|
6228
|
-
]);
|
|
6229
|
-
var CheckpointPromptWire = Schema37.TaggedStruct("RelaySessionCheckpointPromptV1", {
|
|
6303
|
+
var CheckpointPromptWire = Schema38.TaggedStruct("RelaySessionCheckpointPromptV1", {
|
|
6230
6304
|
prompt: exports_shared_schema.JsonValue
|
|
6231
6305
|
});
|
|
6232
|
-
var
|
|
6233
|
-
var encodePromptMessage = (prompt, message, messageIndex) => ({
|
|
6234
|
-
...message,
|
|
6235
|
-
content: Array.isArray(message.content) ? message.content.map((part, partIndex) => {
|
|
6236
|
-
const actualContent = prompt.content[messageIndex]?.content;
|
|
6237
|
-
const actualPart = Array.isArray(actualContent) ? actualContent[partIndex] : undefined;
|
|
6238
|
-
return part.type === "file" && actualPart?.type === "file" ? { ...part, data: fileDataToWire(actualPart.data) } : part;
|
|
6239
|
-
}) : message.content
|
|
6240
|
-
});
|
|
6241
|
-
var encodePromptContent = (prompt) => {
|
|
6242
|
-
const encoded = Schema37.encodeSync(Prompt3.Prompt)(prompt);
|
|
6243
|
-
return Schema37.decodeUnknownSync(exports_shared_schema.JsonValue)({
|
|
6244
|
-
content: encoded.content.map((message, messageIndex) => encodePromptMessage(prompt, message, messageIndex))
|
|
6245
|
-
});
|
|
6246
|
-
};
|
|
6247
|
-
var decodePromptContent = (value) => {
|
|
6248
|
-
const content = typeof value === "object" && value !== null && !Array.isArray(value) && "content" in value ? value.content : undefined;
|
|
6249
|
-
const decodedContent = Array.isArray(content) ? content.map((message) => {
|
|
6250
|
-
if (typeof message !== "object" || message === null || Array.isArray(message))
|
|
6251
|
-
return message;
|
|
6252
|
-
const messageContent = message.content;
|
|
6253
|
-
return {
|
|
6254
|
-
...message,
|
|
6255
|
-
content: Array.isArray(messageContent) ? messageContent.map((part) => {
|
|
6256
|
-
if (typeof part !== "object" || part === null || Array.isArray(part) || part.type !== "file") {
|
|
6257
|
-
return part;
|
|
6258
|
-
}
|
|
6259
|
-
const data = Schema37.decodeUnknownSync(FileDataWire)(part.data);
|
|
6260
|
-
return {
|
|
6261
|
-
...part,
|
|
6262
|
-
data: data._tag === "String" ? data.value : data._tag === "Bytes" ? Uint8Array.from(data.value) : new URL(data.value)
|
|
6263
|
-
};
|
|
6264
|
-
}) : messageContent
|
|
6265
|
-
};
|
|
6266
|
-
}) : content;
|
|
6267
|
-
return Schema37.decodeUnknownSync(Prompt3.Prompt)({ content: decodedContent });
|
|
6268
|
-
};
|
|
6269
|
-
var encodeCheckpointPrompt = (prompt) => Schema37.encodeSync(CheckpointPromptWire)({
|
|
6306
|
+
var encodeCheckpointPrompt = (prompt) => Schema38.encodeSync(CheckpointPromptWire)({
|
|
6270
6307
|
_tag: "RelaySessionCheckpointPromptV1",
|
|
6271
|
-
prompt:
|
|
6272
|
-
});
|
|
6308
|
+
prompt: encodePrompt(prompt)
|
|
6309
|
+
});
|
|
6310
|
+
var CheckpointTelemetryWire = Schema38.Array(exports_model_telemetry.Event);
|
|
6311
|
+
var encodeTelemetryEvents = Schema38.encodeSync(CheckpointTelemetryWire);
|
|
6312
|
+
var jsonRoundTrip = Schema38.encodeSync(Schema38.UnknownFromJsonString);
|
|
6313
|
+
var canonicalJson = (value) => JSON.parse(jsonRoundTrip(value));
|
|
6314
|
+
var encodeCheckpointTelemetry = (telemetry) => canonicalJson(encodeTelemetryEvents(telemetry));
|
|
6315
|
+
var decodeCheckpointTelemetry = (value) => Array.isArray(value) ? value : [];
|
|
6316
|
+
var CheckpointCommitWire = exports_model_telemetry.CompactionCommit;
|
|
6317
|
+
var encodeCheckpointCommit = Schema38.encodeSync(CheckpointCommitWire);
|
|
6318
|
+
var decodeCheckpointCommit = Schema38.decodeUnknownSync(CheckpointCommitWire);
|
|
6273
6319
|
var comparableEntry = (entry) => {
|
|
6274
6320
|
const { createdAt: _createdAt, ...value } = entry;
|
|
6275
6321
|
return value;
|
|
@@ -6303,6 +6349,8 @@ var appendToRecord = (input) => {
|
|
|
6303
6349
|
_tag: "Compaction",
|
|
6304
6350
|
version: 2,
|
|
6305
6351
|
projectedHistory: input.input.projectedHistory,
|
|
6352
|
+
telemetry: input.input.telemetry,
|
|
6353
|
+
...input.input.compactionCommit === undefined ? {} : { compactionCommit: input.input.compactionCommit },
|
|
6306
6354
|
...input.input.summary === undefined ? {} : { summary: input.input.summary }
|
|
6307
6355
|
} : {
|
|
6308
6356
|
...base,
|
|
@@ -6316,13 +6364,13 @@ var appendToRecord = (input) => {
|
|
|
6316
6364
|
};
|
|
6317
6365
|
var makeSessionEntryRecords = (errors) => {
|
|
6318
6366
|
const { SessionRepositoryError, SessionConflict } = errors;
|
|
6319
|
-
const decodeCheckpointPrompt = (value) =>
|
|
6320
|
-
try: () =>
|
|
6367
|
+
const decodeCheckpointPrompt = (value) => Schema38.decodeUnknownEffect(CheckpointPromptWire)(value).pipe(Effect39.flatMap((wire) => Effect39.try({
|
|
6368
|
+
try: () => decodePrompt(wire.prompt),
|
|
6321
6369
|
catch: (error5) => SessionRepositoryError.make({ message: `Invalid Session checkpoint prompt: ${String(error5)}` })
|
|
6322
|
-
})), Effect39.mapError((error5) =>
|
|
6370
|
+
})), Effect39.mapError((error5) => Schema38.is(SessionRepositoryError)(error5) ? error5 : SessionRepositoryError.make({ message: `Invalid Session checkpoint prompt: ${String(error5)}` })));
|
|
6323
6371
|
const clonePrompt = (prompt) => {
|
|
6324
|
-
const wire = prompt.pipe(encodeCheckpointPrompt,
|
|
6325
|
-
return
|
|
6372
|
+
const wire = prompt.pipe(encodeCheckpointPrompt, Schema38.decodeUnknownSync(CheckpointPromptWire));
|
|
6373
|
+
return decodePrompt(wire.prompt);
|
|
6326
6374
|
};
|
|
6327
6375
|
const payloadFromInput = (input) => {
|
|
6328
6376
|
switch (input._tag) {
|
|
@@ -6367,6 +6415,8 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6367
6415
|
return input.version === 2 ? {
|
|
6368
6416
|
version: 2,
|
|
6369
6417
|
projectedHistory: encodeCheckpointPrompt(input.projectedHistory),
|
|
6418
|
+
telemetry: encodeCheckpointTelemetry(input.telemetry),
|
|
6419
|
+
...input.compactionCommit === undefined ? {} : { compactionCommit: encodeCheckpointCommit(input.compactionCommit) },
|
|
6370
6420
|
...input.summary === undefined ? {} : { summary: input.summary },
|
|
6371
6421
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
6372
6422
|
} : {
|
|
@@ -6436,11 +6486,22 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6436
6486
|
summary: String(payload.summary ?? "")
|
|
6437
6487
|
});
|
|
6438
6488
|
case "Compaction":
|
|
6439
|
-
return payload.version === 2 ? decodeCheckpointPrompt(payload.projectedHistory).pipe(Effect39.
|
|
6489
|
+
return payload.version === 2 ? decodeCheckpointPrompt(payload.projectedHistory).pipe(Effect39.flatMap((projectedHistory) => Effect39.try({
|
|
6490
|
+
try: () => ({
|
|
6491
|
+
projectedHistory,
|
|
6492
|
+
telemetry: payload.telemetry === undefined ? [] : decodeCheckpointTelemetry(payload.telemetry),
|
|
6493
|
+
compactionCommit: payload.compactionCommit === undefined ? undefined : decodeCheckpointCommit(payload.compactionCommit)
|
|
6494
|
+
}),
|
|
6495
|
+
catch: (error5) => SessionRepositoryError.make({
|
|
6496
|
+
message: `Invalid Session checkpoint telemetry: ${String(error5)}`
|
|
6497
|
+
})
|
|
6498
|
+
})), Effect39.map(({ projectedHistory, telemetry, compactionCommit }) => ({
|
|
6440
6499
|
...base,
|
|
6441
6500
|
_tag: "Compaction",
|
|
6442
6501
|
version: 2,
|
|
6443
6502
|
projectedHistory,
|
|
6503
|
+
telemetry,
|
|
6504
|
+
...compactionCommit === undefined ? {} : { compactionCommit },
|
|
6444
6505
|
...payload.summary === undefined ? {} : { summary: String(payload.summary) }
|
|
6445
6506
|
}))) : Effect39.succeed({
|
|
6446
6507
|
...base,
|
|
@@ -6459,9 +6520,19 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6459
6520
|
}
|
|
6460
6521
|
};
|
|
6461
6522
|
const promptEquivalence = (left, right) => exports_shared_schema.canonicalEquals(encodeCheckpointPrompt(left), encodeCheckpointPrompt(right));
|
|
6523
|
+
const telemetryEquivalence = (left, right) => exports_shared_schema.canonicalEquals(canonicalJson(left), canonicalJson(right));
|
|
6524
|
+
const commitEquivalence = (left, right) => {
|
|
6525
|
+
if (left._tag !== "Compaction" || left.version !== 2 || right._tag !== "Compaction" || right.version !== 2) {
|
|
6526
|
+
return false;
|
|
6527
|
+
}
|
|
6528
|
+
if (left.compactionCommit === undefined || right.compactionCommit === undefined) {
|
|
6529
|
+
return left.compactionCommit === right.compactionCommit;
|
|
6530
|
+
}
|
|
6531
|
+
return exports_shared_schema.canonicalEquals(canonicalJson(left.compactionCommit), canonicalJson(right.compactionCommit));
|
|
6532
|
+
};
|
|
6462
6533
|
const sameEntry = (left, right) => {
|
|
6463
6534
|
if (left._tag === "Compaction" && left.version === 2 && right._tag === "Compaction" && right.version === 2) {
|
|
6464
|
-
return left.id === right.id && left.sessionId === right.sessionId && left.parentId === right.parentId && left.summary === right.summary && promptEquivalence(left.projectedHistory, right.projectedHistory);
|
|
6535
|
+
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);
|
|
6465
6536
|
}
|
|
6466
6537
|
return exports_shared_schema.canonicalEquals(comparableEntry(left), comparableEntry(right));
|
|
6467
6538
|
};
|
|
@@ -6491,25 +6562,25 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6491
6562
|
};
|
|
6492
6563
|
|
|
6493
6564
|
// ../store-sql/src/session/session-records.ts
|
|
6494
|
-
import { Effect as Effect40, Schema as
|
|
6565
|
+
import { Effect as Effect40, Schema as Schema40 } from "effect";
|
|
6495
6566
|
import { SqlClient as SqlClient23 } from "effect/unstable/sql/SqlClient";
|
|
6496
6567
|
|
|
6497
6568
|
// ../store-sql/src/session/session-row.ts
|
|
6498
|
-
import { Schema as
|
|
6499
|
-
var sessionRow =
|
|
6500
|
-
id:
|
|
6501
|
-
root_address_id:
|
|
6502
|
-
leaf_entry_id:
|
|
6503
|
-
owner_execution_id:
|
|
6504
|
-
owner_epoch:
|
|
6505
|
-
owner_released:
|
|
6506
|
-
metadata_json:
|
|
6507
|
-
created_at:
|
|
6508
|
-
updated_at:
|
|
6569
|
+
import { Schema as Schema39 } from "effect";
|
|
6570
|
+
var sessionRow = Schema39.Struct({
|
|
6571
|
+
id: Schema39.String,
|
|
6572
|
+
root_address_id: Schema39.String,
|
|
6573
|
+
leaf_entry_id: Schema39.Union([Schema39.String, Schema39.Null, Schema39.Undefined]),
|
|
6574
|
+
owner_execution_id: Schema39.Union([Schema39.String, Schema39.Null, Schema39.Undefined]),
|
|
6575
|
+
owner_epoch: Schema39.Union([Schema39.Finite, Schema39.String, Schema39.BigInt]),
|
|
6576
|
+
owner_released: Schema39.Union([Schema39.Boolean, Schema39.Finite, Schema39.String, Schema39.BigInt]),
|
|
6577
|
+
metadata_json: Schema39.Unknown,
|
|
6578
|
+
created_at: Schema39.Union([Schema39.Date, Schema39.String, Schema39.Finite]),
|
|
6579
|
+
updated_at: Schema39.Union([Schema39.Date, Schema39.String, Schema39.Finite])
|
|
6509
6580
|
}).annotate({ identifier: "Relay.Session.Row" });
|
|
6510
6581
|
var releasedFlag = (value) => value === true || value === 1 || value === "1" || value === 1n || value === "true";
|
|
6511
|
-
var CountRow =
|
|
6512
|
-
value:
|
|
6582
|
+
var CountRow = Schema39.Struct({
|
|
6583
|
+
value: Schema39.Union([Schema39.Finite, Schema39.String, Schema39.BigInt])
|
|
6513
6584
|
}).annotate({ identifier: "Relay.SessionEntry.CountRow" });
|
|
6514
6585
|
var metadata7 = (input) => input ?? {};
|
|
6515
6586
|
var toSessionRecord = (row) => ({
|
|
@@ -6588,9 +6659,9 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6588
6659
|
return toRepositoryError12(error5);
|
|
6589
6660
|
}));
|
|
6590
6661
|
}
|
|
6591
|
-
const decodeSessionRow = (row) =>
|
|
6592
|
-
const decodeEntryRow = (row) =>
|
|
6593
|
-
const decodeCountRow = (row) =>
|
|
6662
|
+
const decodeSessionRow = (row) => Schema40.decodeUnknownEffect(sessionRow)(row).pipe(Effect40.mapError(toRepositoryError12));
|
|
6663
|
+
const decodeEntryRow = (row) => Schema40.decodeUnknownEffect(sessionEntryRow)(row).pipe(Effect40.mapError(toRepositoryError12));
|
|
6664
|
+
const decodeCountRow = (row) => Schema40.decodeUnknownEffect(CountRow)(row).pipe(Effect40.mapError(toRepositoryError12));
|
|
6594
6665
|
const selectSessionByKey = (tenantId, id) => sql`
|
|
6595
6666
|
SELECT id, root_address_id, leaf_entry_id, owner_execution_id, owner_epoch, owner_released, metadata_json, created_at, updated_at
|
|
6596
6667
|
FROM relay_sessions
|
|
@@ -6824,6 +6895,8 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6824
6895
|
_tag: "Compaction",
|
|
6825
6896
|
version: 2,
|
|
6826
6897
|
projectedHistory: input.projectedHistory,
|
|
6898
|
+
telemetry: input.telemetry,
|
|
6899
|
+
...input.compactionCommit === undefined ? {} : { compactionCommit: input.compactionCommit },
|
|
6827
6900
|
...input.summary === undefined ? {} : { summary: input.summary }
|
|
6828
6901
|
},
|
|
6829
6902
|
createdAt: input.createdAt
|
|
@@ -6914,19 +6987,19 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6914
6987
|
});
|
|
6915
6988
|
|
|
6916
6989
|
// ../store-sql/src/session/session-repository.ts
|
|
6917
|
-
class SessionRepositoryError extends
|
|
6918
|
-
message:
|
|
6990
|
+
class SessionRepositoryError extends Schema41.TaggedErrorClass()("SessionRepositoryError", {
|
|
6991
|
+
message: Schema41.String
|
|
6919
6992
|
}) {
|
|
6920
6993
|
}
|
|
6921
6994
|
|
|
6922
|
-
class DuplicateSession extends
|
|
6995
|
+
class DuplicateSession extends Schema41.TaggedErrorClass()("DuplicateSession", {
|
|
6923
6996
|
id: exports_ids_schema.SessionId
|
|
6924
6997
|
}) {
|
|
6925
6998
|
}
|
|
6926
6999
|
|
|
6927
|
-
class SessionConflict extends
|
|
6928
|
-
reason:
|
|
6929
|
-
message:
|
|
7000
|
+
class SessionConflict extends Schema41.TaggedErrorClass()("SessionConflict", {
|
|
7001
|
+
reason: Schema41.Literals(["stale-leaf", "checkpoint-id-reused", "checkpoint-not-on-active-path", "fenced"]),
|
|
7002
|
+
message: Schema41.String
|
|
6930
7003
|
}) {
|
|
6931
7004
|
}
|
|
6932
7005
|
|
|
@@ -7093,6 +7166,8 @@ var memoryLayer26 = Layer35.sync(Service35, () => {
|
|
|
7093
7166
|
_tag: "Compaction",
|
|
7094
7167
|
version: 2,
|
|
7095
7168
|
projectedHistory: input.projectedHistory,
|
|
7169
|
+
telemetry: input.telemetry,
|
|
7170
|
+
...input.compactionCommit === undefined ? {} : { compactionCommit: input.compactionCommit },
|
|
7096
7171
|
...input.summary === undefined ? {} : { summary: input.summary }
|
|
7097
7172
|
},
|
|
7098
7173
|
createdAt: input.createdAt
|
|
@@ -7216,36 +7291,36 @@ __export(exports_skill_definition_repository, {
|
|
|
7216
7291
|
Service: () => Service36,
|
|
7217
7292
|
ExecutionSkillPinRow: () => ExecutionSkillPinRow
|
|
7218
7293
|
});
|
|
7219
|
-
import { Context as Context34, Effect as Effect42, HashSet, Layer as Layer36, Schema as
|
|
7294
|
+
import { Context as Context34, Effect as Effect42, HashSet, Layer as Layer36, Schema as Schema42, Semaphore as Semaphore4 } from "effect";
|
|
7220
7295
|
import { SqlClient as SqlClient24 } from "effect/unstable/sql/SqlClient";
|
|
7221
|
-
class SkillDefinitionRepositoryError extends
|
|
7222
|
-
message:
|
|
7296
|
+
class SkillDefinitionRepositoryError extends Schema42.TaggedErrorClass()("SkillDefinitionRepositoryError", {
|
|
7297
|
+
message: Schema42.String
|
|
7223
7298
|
}) {
|
|
7224
7299
|
}
|
|
7225
7300
|
|
|
7226
7301
|
class Service36 extends Context34.Service()("@relayfx/store-sql/skill/skill-definition-repository/Service") {
|
|
7227
7302
|
}
|
|
7228
|
-
var SkillDefinitionRow =
|
|
7229
|
-
id:
|
|
7230
|
-
current_revision:
|
|
7231
|
-
definition_json:
|
|
7232
|
-
created_at:
|
|
7233
|
-
updated_at:
|
|
7303
|
+
var SkillDefinitionRow = Schema42.Struct({
|
|
7304
|
+
id: Schema42.String,
|
|
7305
|
+
current_revision: Schema42.Finite,
|
|
7306
|
+
definition_json: Schema42.Unknown,
|
|
7307
|
+
created_at: Schema42.Union([Schema42.Date, Schema42.String, Schema42.Finite]),
|
|
7308
|
+
updated_at: Schema42.Union([Schema42.Date, Schema42.String, Schema42.Finite])
|
|
7234
7309
|
}).annotate({ identifier: "Relay.SkillDefinition.Row" });
|
|
7235
|
-
var SkillDefinitionRevisionRow =
|
|
7236
|
-
skill_definition_id:
|
|
7237
|
-
revision:
|
|
7238
|
-
definition_json:
|
|
7239
|
-
created_at:
|
|
7310
|
+
var SkillDefinitionRevisionRow = Schema42.Struct({
|
|
7311
|
+
skill_definition_id: Schema42.String,
|
|
7312
|
+
revision: Schema42.Finite,
|
|
7313
|
+
definition_json: Schema42.Unknown,
|
|
7314
|
+
created_at: Schema42.Union([Schema42.Date, Schema42.String, Schema42.Finite])
|
|
7240
7315
|
}).annotate({ identifier: "Relay.SkillDefinitionRevision.Row" });
|
|
7241
|
-
var ExecutionSkillPinRow =
|
|
7242
|
-
execution_id:
|
|
7243
|
-
skill_definition_id:
|
|
7244
|
-
skill_definition_revision:
|
|
7245
|
-
skill_definition_snapshot_json:
|
|
7246
|
-
created_at:
|
|
7316
|
+
var ExecutionSkillPinRow = Schema42.Struct({
|
|
7317
|
+
execution_id: Schema42.String,
|
|
7318
|
+
skill_definition_id: Schema42.String,
|
|
7319
|
+
skill_definition_revision: Schema42.Finite,
|
|
7320
|
+
skill_definition_snapshot_json: Schema42.Unknown,
|
|
7321
|
+
created_at: Schema42.Union([Schema42.Date, Schema42.String, Schema42.Finite])
|
|
7247
7322
|
}).annotate({ identifier: "Relay.ExecutionSkillPin.Row" });
|
|
7248
|
-
var cloneDefinition3 = (definition) =>
|
|
7323
|
+
var cloneDefinition3 = (definition) => Schema42.decodeUnknownSync(exports_skill_schema.Definition)(globalThis.structuredClone(definition));
|
|
7249
7324
|
var toRecord10 = (row) => ({
|
|
7250
7325
|
id: exports_ids_schema.SkillDefinitionId.make(row.id),
|
|
7251
7326
|
currentRevision: row.current_revision,
|
|
@@ -7301,11 +7376,11 @@ var missingSkillMessage = (requested, records) => {
|
|
|
7301
7376
|
return `Skill definition not found: ${requested.find((id) => !HashSet.has(found, id)) ?? requested[0]}`;
|
|
7302
7377
|
};
|
|
7303
7378
|
var toRepositoryError12 = (error5) => SkillDefinitionRepositoryError.make({ message: String(error5) });
|
|
7304
|
-
var mapPutError2 = (error5) =>
|
|
7305
|
-
var isUniqueViolation = (error5) => !
|
|
7306
|
-
var decodeRow12 = (row) =>
|
|
7307
|
-
var decodeRevisionRow2 = (row) =>
|
|
7308
|
-
var decodePinRow = (row) =>
|
|
7379
|
+
var mapPutError2 = (error5) => Schema42.is(SkillDefinitionRepositoryError)(error5) ? error5 : toRepositoryError12(error5);
|
|
7380
|
+
var isUniqueViolation = (error5) => !Schema42.is(SkillDefinitionRepositoryError)(error5) && /unique|duplicate/i.test(String(error5));
|
|
7381
|
+
var decodeRow12 = (row) => Schema42.decodeUnknownEffect(SkillDefinitionRow)(row).pipe(Effect42.mapError(toRepositoryError12));
|
|
7382
|
+
var decodeRevisionRow2 = (row) => Schema42.decodeUnknownEffect(SkillDefinitionRevisionRow)(row).pipe(Effect42.mapError(toRepositoryError12));
|
|
7383
|
+
var decodePinRow = (row) => Schema42.decodeUnknownEffect(ExecutionSkillPinRow)(row).pipe(Effect42.mapError(toRepositoryError12));
|
|
7309
7384
|
var layer29 = Layer36.effect(Service36, Effect42.gen(function* () {
|
|
7310
7385
|
const sql = yield* SqlClient24;
|
|
7311
7386
|
const columns3 = sql.literal(["id", "current_revision", "definition_json", "created_at", "updated_at"].join(", "));
|
|
@@ -7642,37 +7717,37 @@ __export(exports_steering_repository, {
|
|
|
7642
7717
|
SteeringDrainRow: () => SteeringDrainRow,
|
|
7643
7718
|
Service: () => Service37
|
|
7644
7719
|
});
|
|
7645
|
-
import { Context as Context35, Effect as Effect43, Layer as Layer37, Ref as Ref9, Schema as
|
|
7720
|
+
import { Context as Context35, Effect as Effect43, Layer as Layer37, Ref as Ref9, Schema as Schema43 } from "effect";
|
|
7646
7721
|
import { SqlClient as SqlClient25 } from "effect/unstable/sql/SqlClient";
|
|
7647
|
-
class SteeringRepositoryError extends
|
|
7648
|
-
message:
|
|
7722
|
+
class SteeringRepositoryError extends Schema43.TaggedErrorClass()("SteeringRepositoryError", {
|
|
7723
|
+
message: Schema43.String
|
|
7649
7724
|
}) {
|
|
7650
7725
|
}
|
|
7651
7726
|
|
|
7652
7727
|
class Service37 extends Context35.Service()("@relayfx/store-sql/steering/steering-repository/Service") {
|
|
7653
7728
|
}
|
|
7654
|
-
var SteeringKindSchema =
|
|
7655
|
-
var DbTimestamp4 =
|
|
7656
|
-
var SteeringMessageRow =
|
|
7657
|
-
execution_id:
|
|
7729
|
+
var SteeringKindSchema = Schema43.Literals(["steering", "follow_up"]);
|
|
7730
|
+
var DbTimestamp4 = Schema43.Union([Schema43.Date, Schema43.String, Schema43.Finite]);
|
|
7731
|
+
var SteeringMessageRow = Schema43.Struct({
|
|
7732
|
+
execution_id: Schema43.String,
|
|
7658
7733
|
kind: SteeringKindSchema,
|
|
7659
|
-
sequence:
|
|
7660
|
-
content_json:
|
|
7661
|
-
drain_id:
|
|
7662
|
-
consumed_at:
|
|
7734
|
+
sequence: Schema43.Union([Schema43.Finite, Schema43.String]),
|
|
7735
|
+
content_json: Schema43.Unknown,
|
|
7736
|
+
drain_id: Schema43.NullishOr(Schema43.String),
|
|
7737
|
+
consumed_at: Schema43.NullishOr(DbTimestamp4),
|
|
7663
7738
|
created_at: DbTimestamp4
|
|
7664
7739
|
}).annotate({ identifier: "Relay.SteeringMessage.Row" });
|
|
7665
|
-
var SteeringDrainRow =
|
|
7666
|
-
execution_id:
|
|
7740
|
+
var SteeringDrainRow = Schema43.Struct({
|
|
7741
|
+
execution_id: Schema43.String,
|
|
7667
7742
|
kind: SteeringKindSchema,
|
|
7668
|
-
drain_id:
|
|
7669
|
-
message_sequences_json:
|
|
7743
|
+
drain_id: Schema43.String,
|
|
7744
|
+
message_sequences_json: Schema43.Unknown,
|
|
7670
7745
|
created_at: DbTimestamp4
|
|
7671
7746
|
}).annotate({ identifier: "Relay.SteeringDrain.Row" });
|
|
7672
7747
|
var toRepositoryError13 = (error5) => SteeringRepositoryError.make({ message: String(error5) });
|
|
7673
|
-
var mapTransactionError = (effect) => effect.pipe(Effect43.mapError((error5) =>
|
|
7674
|
-
var decodeMessageRow = (row) =>
|
|
7675
|
-
var decodeDrainRow = (row) =>
|
|
7748
|
+
var mapTransactionError = (effect) => effect.pipe(Effect43.mapError((error5) => Schema43.is(SteeringRepositoryError)(error5) ? error5 : toRepositoryError13(error5)));
|
|
7749
|
+
var decodeMessageRow = (row) => Schema43.decodeUnknownEffect(SteeringMessageRow)(row).pipe(Effect43.mapError(toRepositoryError13));
|
|
7750
|
+
var decodeDrainRow = (row) => Schema43.decodeUnknownEffect(SteeringDrainRow)(row).pipe(Effect43.mapError(toRepositoryError13));
|
|
7676
7751
|
var toMessageRecord = (row) => {
|
|
7677
7752
|
const consumedAt = fromNullableDbTimestamp(row.consumed_at);
|
|
7678
7753
|
return {
|
|
@@ -7981,29 +8056,29 @@ __export(exports_tool_call_repository, {
|
|
|
7981
8056
|
DuplicateToolResult: () => DuplicateToolResult,
|
|
7982
8057
|
DuplicateToolCall: () => DuplicateToolCall
|
|
7983
8058
|
});
|
|
7984
|
-
import { Context as Context36, Effect as Effect47, Layer as Layer38, Schema as
|
|
8059
|
+
import { Context as Context36, Effect as Effect47, Layer as Layer38, Schema as Schema47 } from "effect";
|
|
7985
8060
|
import { dual } from "effect/Function";
|
|
7986
8061
|
|
|
7987
8062
|
// ../store-sql/src/tool/tool-call-records.ts
|
|
7988
|
-
import { Effect as Effect46, Schema as
|
|
8063
|
+
import { Effect as Effect46, Schema as Schema46 } from "effect";
|
|
7989
8064
|
import { SqlClient as SqlClient26 } from "effect/unstable/sql/SqlClient";
|
|
7990
8065
|
import { isSqlError as isSqlError2 } from "effect/unstable/sql/SqlError";
|
|
7991
8066
|
|
|
7992
8067
|
// ../store-sql/src/tool/tool-attempt-records.ts
|
|
7993
|
-
import { Effect as Effect44, Schema as
|
|
7994
|
-
var toolAttemptRow =
|
|
7995
|
-
id:
|
|
7996
|
-
tool_call_id:
|
|
7997
|
-
attempt_number:
|
|
7998
|
-
state:
|
|
7999
|
-
worker_id:
|
|
8000
|
-
claim_expires_at:
|
|
8001
|
-
error:
|
|
8002
|
-
created_at:
|
|
8003
|
-
completed_at:
|
|
8068
|
+
import { Effect as Effect44, Schema as Schema44 } from "effect";
|
|
8069
|
+
var toolAttemptRow = Schema44.Struct({
|
|
8070
|
+
id: Schema44.String,
|
|
8071
|
+
tool_call_id: Schema44.String,
|
|
8072
|
+
attempt_number: Schema44.Union([Schema44.Finite, Schema44.String, Schema44.BigInt]),
|
|
8073
|
+
state: Schema44.String,
|
|
8074
|
+
worker_id: Schema44.NullishOr(Schema44.String),
|
|
8075
|
+
claim_expires_at: Schema44.NullishOr(Schema44.Union([Schema44.Date, Schema44.String, Schema44.Finite])),
|
|
8076
|
+
error: Schema44.NullishOr(Schema44.String),
|
|
8077
|
+
created_at: Schema44.Union([Schema44.Date, Schema44.String, Schema44.Finite]),
|
|
8078
|
+
completed_at: Schema44.NullishOr(Schema44.Union([Schema44.Date, Schema44.String, Schema44.Finite]))
|
|
8004
8079
|
}).annotate({ identifier: "Relay.ToolAttempt.Row" });
|
|
8005
|
-
var MaxAttemptRow =
|
|
8006
|
-
max_attempt:
|
|
8080
|
+
var MaxAttemptRow = Schema44.Struct({
|
|
8081
|
+
max_attempt: Schema44.NullishOr(Schema44.Union([Schema44.Finite, Schema44.String, Schema44.BigInt]))
|
|
8007
8082
|
});
|
|
8008
8083
|
var toolAttemptId = (attemptNumber) => exports_ids_schema.ToolAttemptId.make(`tool-attempt:${attemptNumber}`);
|
|
8009
8084
|
var makeToolAttemptRecordOperations = ({
|
|
@@ -8027,15 +8102,15 @@ var makeToolAttemptRecordOperations = ({
|
|
|
8027
8102
|
id: exports_ids_schema.ToolAttemptId.make(row.id),
|
|
8028
8103
|
callId: exports_ids_schema.ToolCallId.make(row.tool_call_id),
|
|
8029
8104
|
attemptNumber: Number(row.attempt_number),
|
|
8030
|
-
state:
|
|
8105
|
+
state: Schema44.decodeUnknownSync(exports_tool_schema.AttemptState)(row.state),
|
|
8031
8106
|
...row.worker_id === null || row.worker_id === undefined ? {} : { workerId: row.worker_id },
|
|
8032
8107
|
...row.claim_expires_at === null || row.claim_expires_at === undefined ? {} : { claimExpiresAt: fromDbTimestamp(row.claim_expires_at) },
|
|
8033
8108
|
...row.error === null || row.error === undefined ? {} : { error: row.error },
|
|
8034
8109
|
createdAt: fromDbTimestamp(row.created_at),
|
|
8035
8110
|
...row.completed_at === null || row.completed_at === undefined ? {} : { completedAt: fromDbTimestamp(row.completed_at) }
|
|
8036
8111
|
});
|
|
8037
|
-
const decodeAttemptRow = (row) =>
|
|
8038
|
-
const decodeMaxAttemptRow = (row) =>
|
|
8112
|
+
const decodeAttemptRow = (row) => Schema44.decodeUnknownEffect(toolAttemptRow)(row).pipe(Effect44.mapError(toRepositoryError14));
|
|
8113
|
+
const decodeMaxAttemptRow = (row) => Schema44.decodeUnknownEffect(Schema44.UndefinedOr(MaxAttemptRow))(row).pipe(Effect44.mapError(toRepositoryError14));
|
|
8039
8114
|
const selectAttempts = (tenantId, executionId, callId) => sql`
|
|
8040
8115
|
SELECT ${attemptColumns}
|
|
8041
8116
|
FROM relay_tool_attempts
|
|
@@ -8118,13 +8193,13 @@ var makeToolAttemptRecordOperations = ({
|
|
|
8118
8193
|
};
|
|
8119
8194
|
|
|
8120
8195
|
// ../store-sql/src/tool/tool-work-operations.ts
|
|
8121
|
-
import { Effect as Effect45, Schema as
|
|
8122
|
-
var ExpiredCallRow =
|
|
8123
|
-
id:
|
|
8124
|
-
execution_id:
|
|
8125
|
-
active_attempt_id:
|
|
8196
|
+
import { Effect as Effect45, Schema as Schema45 } from "effect";
|
|
8197
|
+
var ExpiredCallRow = Schema45.Struct({
|
|
8198
|
+
id: Schema45.String,
|
|
8199
|
+
execution_id: Schema45.String,
|
|
8200
|
+
active_attempt_id: Schema45.NullishOr(Schema45.String)
|
|
8126
8201
|
});
|
|
8127
|
-
var IdRow =
|
|
8202
|
+
var IdRow = Schema45.Struct({ id: Schema45.String, execution_id: Schema45.String });
|
|
8128
8203
|
var makeToolWorkOperations = ({
|
|
8129
8204
|
records,
|
|
8130
8205
|
attempts,
|
|
@@ -8287,7 +8362,7 @@ var makeToolWorkOperations = ({
|
|
|
8287
8362
|
WHERE tenant_id = ${tenantId} AND placement_kind = 'remote' AND placement_key = ${input.queue}
|
|
8288
8363
|
AND state = 'running' AND claim_expires_at IS NOT NULL AND claim_expires_at <= ${ts(input.now)}
|
|
8289
8364
|
`.pipe(Effect45.mapError(toRepositoryError14));
|
|
8290
|
-
const expired = yield*
|
|
8365
|
+
const expired = yield* Schema45.decodeUnknownEffect(Schema45.Array(ExpiredCallRow))(expiredRows).pipe(Effect45.mapError(toRepositoryError14));
|
|
8291
8366
|
for (const row of expired) {
|
|
8292
8367
|
const executionId2 = exports_ids_schema.ExecutionId.make(row.execution_id);
|
|
8293
8368
|
if (row.active_attempt_id !== null && row.active_attempt_id !== undefined) {
|
|
@@ -8301,7 +8376,7 @@ var makeToolWorkOperations = ({
|
|
|
8301
8376
|
`.pipe(Effect45.mapError(toRepositoryError14));
|
|
8302
8377
|
}
|
|
8303
8378
|
const candidateRows = yield* selectClaimCandidate(tenantId, input).pipe(Effect45.mapError(toRepositoryError14));
|
|
8304
|
-
const candidates = yield*
|
|
8379
|
+
const candidates = yield* Schema45.decodeUnknownEffect(Schema45.Array(IdRow))(candidateRows).pipe(Effect45.mapError(toRepositoryError14));
|
|
8305
8380
|
const candidate = candidates[0];
|
|
8306
8381
|
if (candidate === undefined)
|
|
8307
8382
|
return;
|
|
@@ -8476,54 +8551,54 @@ var makeToolWorkOperations = ({
|
|
|
8476
8551
|
};
|
|
8477
8552
|
|
|
8478
8553
|
// ../store-sql/src/tool/tool-call-records.ts
|
|
8479
|
-
var toolCallRow =
|
|
8480
|
-
id:
|
|
8481
|
-
execution_id:
|
|
8482
|
-
name:
|
|
8483
|
-
input_json:
|
|
8484
|
-
definition_json:
|
|
8485
|
-
placement_kind:
|
|
8486
|
-
placement_key:
|
|
8487
|
-
state:
|
|
8488
|
-
wait_id:
|
|
8489
|
-
idempotency_key:
|
|
8490
|
-
available_at:
|
|
8491
|
-
active_attempt_id:
|
|
8492
|
-
claim_owner:
|
|
8493
|
-
claimed_at:
|
|
8494
|
-
claim_expires_at:
|
|
8495
|
-
external_outcome_json:
|
|
8496
|
-
external_outcome_at:
|
|
8497
|
-
metadata_json:
|
|
8498
|
-
created_at:
|
|
8499
|
-
updated_at:
|
|
8554
|
+
var toolCallRow = Schema46.Struct({
|
|
8555
|
+
id: Schema46.String,
|
|
8556
|
+
execution_id: Schema46.String,
|
|
8557
|
+
name: Schema46.String,
|
|
8558
|
+
input_json: Schema46.Unknown,
|
|
8559
|
+
definition_json: Schema46.NullishOr(Schema46.Unknown),
|
|
8560
|
+
placement_kind: Schema46.String,
|
|
8561
|
+
placement_key: Schema46.NullishOr(Schema46.String),
|
|
8562
|
+
state: Schema46.String,
|
|
8563
|
+
wait_id: Schema46.NullishOr(Schema46.String),
|
|
8564
|
+
idempotency_key: Schema46.String,
|
|
8565
|
+
available_at: Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite]),
|
|
8566
|
+
active_attempt_id: Schema46.NullishOr(Schema46.String),
|
|
8567
|
+
claim_owner: Schema46.NullishOr(Schema46.String),
|
|
8568
|
+
claimed_at: Schema46.NullishOr(Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])),
|
|
8569
|
+
claim_expires_at: Schema46.NullishOr(Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])),
|
|
8570
|
+
external_outcome_json: Schema46.NullishOr(Schema46.Unknown),
|
|
8571
|
+
external_outcome_at: Schema46.NullishOr(Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])),
|
|
8572
|
+
metadata_json: Schema46.Unknown,
|
|
8573
|
+
created_at: Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite]),
|
|
8574
|
+
updated_at: Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])
|
|
8500
8575
|
}).annotate({ identifier: "Relay.ToolCall.Row" });
|
|
8501
|
-
var toolResultRow =
|
|
8502
|
-
tool_call_id:
|
|
8503
|
-
output_json:
|
|
8504
|
-
error:
|
|
8505
|
-
metadata_json:
|
|
8506
|
-
created_at:
|
|
8576
|
+
var toolResultRow = Schema46.Struct({
|
|
8577
|
+
tool_call_id: Schema46.String,
|
|
8578
|
+
output_json: Schema46.Unknown,
|
|
8579
|
+
error: Schema46.NullishOr(Schema46.String),
|
|
8580
|
+
metadata_json: Schema46.Unknown,
|
|
8581
|
+
created_at: Schema46.Union([Schema46.Date, Schema46.String, Schema46.Finite])
|
|
8507
8582
|
}).annotate({ identifier: "Relay.ToolResult.Row" });
|
|
8508
8583
|
var metadata8 = (input) => input ?? {};
|
|
8509
8584
|
var normalizeCall = (call) => ({ ...call, metadata: metadata8(call.metadata) });
|
|
8510
8585
|
var sameCallIdentity = (left, right) => exports_shared_schema.canonicalEquals(normalizeCall(left), normalizeCall(right));
|
|
8511
8586
|
var toolCallRecordIdentity = { sameCallIdentity };
|
|
8512
|
-
var placementFromRow = (row) =>
|
|
8587
|
+
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 });
|
|
8513
8588
|
var toCallRecord = (row) => {
|
|
8514
|
-
const definition = row.definition_json === null || row.definition_json === undefined ? undefined :
|
|
8515
|
-
const outcome = row.external_outcome_json === null || row.external_outcome_json === undefined ? undefined :
|
|
8589
|
+
const definition = row.definition_json === null || row.definition_json === undefined ? undefined : Schema46.decodeUnknownSync(exports_tool_schema.Definition)(decodeJson(row.definition_json));
|
|
8590
|
+
const outcome = row.external_outcome_json === null || row.external_outcome_json === undefined ? undefined : Schema46.decodeUnknownSync(exports_tool_schema.ExternalOutcome)(decodeJson(row.external_outcome_json));
|
|
8516
8591
|
return {
|
|
8517
8592
|
executionId: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
8518
8593
|
call: normalizeCall({
|
|
8519
8594
|
id: exports_ids_schema.ToolCallId.make(row.id),
|
|
8520
8595
|
name: row.name,
|
|
8521
|
-
input:
|
|
8522
|
-
metadata:
|
|
8596
|
+
input: Schema46.decodeUnknownSync(exports_shared_schema.JsonValue)(decodeJson(row.input_json)),
|
|
8597
|
+
metadata: Schema46.decodeUnknownSync(exports_shared_schema.Metadata)(decodeJson(row.metadata_json))
|
|
8523
8598
|
}),
|
|
8524
8599
|
...definition === undefined ? {} : { definition },
|
|
8525
8600
|
placement: placementFromRow(row),
|
|
8526
|
-
state:
|
|
8601
|
+
state: Schema46.decodeUnknownSync(exports_tool_schema.CallState)(row.state),
|
|
8527
8602
|
...row.wait_id === null || row.wait_id === undefined ? {} : { waitId: exports_ids_schema.WaitId.make(row.wait_id) },
|
|
8528
8603
|
idempotencyKey: row.idempotency_key,
|
|
8529
8604
|
availableAt: fromDbTimestamp(row.available_at),
|
|
@@ -8540,9 +8615,9 @@ var toCallRecord = (row) => {
|
|
|
8540
8615
|
var toResultRecord = (row) => ({
|
|
8541
8616
|
result: {
|
|
8542
8617
|
call_id: exports_ids_schema.ToolCallId.make(row.tool_call_id),
|
|
8543
|
-
output:
|
|
8618
|
+
output: Schema46.decodeUnknownSync(exports_shared_schema.JsonValue)(decodeJson(row.output_json)),
|
|
8544
8619
|
...row.error === null || row.error === undefined ? {} : { error: row.error },
|
|
8545
|
-
metadata:
|
|
8620
|
+
metadata: Schema46.decodeUnknownSync(exports_shared_schema.Metadata)(decodeJson(row.metadata_json))
|
|
8546
8621
|
},
|
|
8547
8622
|
createdAt: fromDbTimestamp(row.created_at)
|
|
8548
8623
|
});
|
|
@@ -8659,8 +8734,8 @@ var makeToolCallRecordSupport = ({ sql, errors, toolCallIdempotencyKey }) => {
|
|
|
8659
8734
|
`,
|
|
8660
8735
|
orElse: () => selectCallByKey
|
|
8661
8736
|
});
|
|
8662
|
-
const decodeCallRow = (row) =>
|
|
8663
|
-
const decodeResultRow = (row) =>
|
|
8737
|
+
const decodeCallRow = (row) => Schema46.decodeUnknownEffect(toolCallRow)(row).pipe(Effect46.mapError(toRepositoryError14));
|
|
8738
|
+
const decodeResultRow = (row) => Schema46.decodeUnknownEffect(toolResultRow)(row).pipe(Effect46.mapError(toRepositoryError14));
|
|
8664
8739
|
const decodeCall = Effect46.fn("ToolCallRepository.decodeCall")(function* (row) {
|
|
8665
8740
|
const decoded = yield* decodeCallRow(row);
|
|
8666
8741
|
return yield* Effect46.try({ try: () => toCallRecord(decoded), catch: toRepositoryError14 });
|
|
@@ -8792,44 +8867,44 @@ var makeToolCallRepository = ({
|
|
|
8792
8867
|
});
|
|
8793
8868
|
|
|
8794
8869
|
// ../store-sql/src/tool/tool-call-repository.ts
|
|
8795
|
-
class ToolCallRepositoryError extends
|
|
8796
|
-
message:
|
|
8870
|
+
class ToolCallRepositoryError extends Schema47.TaggedErrorClass()("ToolCallRepositoryError", {
|
|
8871
|
+
message: Schema47.String
|
|
8797
8872
|
}) {
|
|
8798
8873
|
}
|
|
8799
8874
|
|
|
8800
|
-
class ToolCallNotFound extends
|
|
8875
|
+
class ToolCallNotFound extends Schema47.TaggedErrorClass()("ToolCallNotFound", {
|
|
8801
8876
|
id: exports_ids_schema.ToolCallId
|
|
8802
8877
|
}) {
|
|
8803
8878
|
}
|
|
8804
8879
|
|
|
8805
|
-
class DuplicateToolCall extends
|
|
8880
|
+
class DuplicateToolCall extends Schema47.TaggedErrorClass()("DuplicateToolCall", {
|
|
8806
8881
|
id: exports_ids_schema.ToolCallId
|
|
8807
8882
|
}) {
|
|
8808
8883
|
}
|
|
8809
8884
|
|
|
8810
|
-
class DuplicateToolResult extends
|
|
8885
|
+
class DuplicateToolResult extends Schema47.TaggedErrorClass()("DuplicateToolResult", {
|
|
8811
8886
|
call_id: exports_ids_schema.ToolCallId
|
|
8812
8887
|
}) {
|
|
8813
8888
|
}
|
|
8814
8889
|
|
|
8815
|
-
class ToolCallConflict extends
|
|
8890
|
+
class ToolCallConflict extends Schema47.TaggedErrorClass()("ToolCallConflict", {
|
|
8816
8891
|
id: exports_ids_schema.ToolCallId
|
|
8817
8892
|
}) {
|
|
8818
8893
|
}
|
|
8819
8894
|
|
|
8820
|
-
class ToolCallTransitionRejected extends
|
|
8895
|
+
class ToolCallTransitionRejected extends Schema47.TaggedErrorClass()("ToolCallTransitionRejected", {
|
|
8821
8896
|
id: exports_ids_schema.ToolCallId,
|
|
8822
|
-
message:
|
|
8897
|
+
message: Schema47.String
|
|
8823
8898
|
}) {
|
|
8824
8899
|
}
|
|
8825
8900
|
|
|
8826
|
-
class ToolOutcomeConflict extends
|
|
8901
|
+
class ToolOutcomeConflict extends Schema47.TaggedErrorClass()("ToolOutcomeConflict", {
|
|
8827
8902
|
id: exports_ids_schema.ToolCallId
|
|
8828
8903
|
}) {
|
|
8829
8904
|
}
|
|
8830
8905
|
|
|
8831
|
-
class ToolClaimRejected extends
|
|
8832
|
-
message:
|
|
8906
|
+
class ToolClaimRejected extends Schema47.TaggedErrorClass()("ToolClaimRejected", {
|
|
8907
|
+
message: Schema47.String
|
|
8833
8908
|
}) {
|
|
8834
8909
|
}
|
|
8835
8910
|
var lengthPrefixed = (value) => `${[...value].length}:${value}`;
|
|
@@ -9296,57 +9371,57 @@ __export(exports_workspace_lease_repository, {
|
|
|
9296
9371
|
Service: () => Service39,
|
|
9297
9372
|
DuplicateWorkspaceLease: () => DuplicateWorkspaceLease
|
|
9298
9373
|
});
|
|
9299
|
-
import { Context as Context37, Effect as Effect48, Layer as Layer39, Schema as
|
|
9374
|
+
import { Context as Context37, Effect as Effect48, Layer as Layer39, Schema as Schema48 } from "effect";
|
|
9300
9375
|
import { SqlClient as SqlClient27 } from "effect/unstable/sql/SqlClient";
|
|
9301
|
-
class WorkspaceLeaseRepositoryError extends
|
|
9302
|
-
message:
|
|
9376
|
+
class WorkspaceLeaseRepositoryError extends Schema48.TaggedErrorClass()("WorkspaceLeaseRepositoryError", {
|
|
9377
|
+
message: Schema48.String
|
|
9303
9378
|
}) {
|
|
9304
9379
|
}
|
|
9305
9380
|
|
|
9306
|
-
class DuplicateWorkspaceLease extends
|
|
9381
|
+
class DuplicateWorkspaceLease extends Schema48.TaggedErrorClass()("DuplicateWorkspaceLease", {
|
|
9307
9382
|
execution_id: exports_ids_schema.ExecutionId
|
|
9308
9383
|
}) {
|
|
9309
9384
|
}
|
|
9310
9385
|
|
|
9311
|
-
class WorkspaceLeaseNotFound extends
|
|
9386
|
+
class WorkspaceLeaseNotFound extends Schema48.TaggedErrorClass()("WorkspaceLeaseNotFound", {
|
|
9312
9387
|
execution_id: exports_ids_schema.ExecutionId
|
|
9313
9388
|
}) {
|
|
9314
9389
|
}
|
|
9315
9390
|
|
|
9316
9391
|
class Service39 extends Context37.Service()("@relayfx/store-sql/workspace/workspace-lease-repository/Service") {
|
|
9317
9392
|
}
|
|
9318
|
-
var WorkspaceLeaseRow =
|
|
9319
|
-
id:
|
|
9320
|
-
execution_id:
|
|
9321
|
-
provider_key:
|
|
9322
|
-
sandbox_ref:
|
|
9323
|
-
latest_snapshot_ref:
|
|
9324
|
-
status:
|
|
9325
|
-
resume_strategy:
|
|
9326
|
-
region:
|
|
9327
|
-
request_json:
|
|
9328
|
-
metadata_json:
|
|
9329
|
-
created_at:
|
|
9330
|
-
updated_at:
|
|
9393
|
+
var WorkspaceLeaseRow = Schema48.Struct({
|
|
9394
|
+
id: Schema48.String,
|
|
9395
|
+
execution_id: Schema48.String,
|
|
9396
|
+
provider_key: Schema48.String,
|
|
9397
|
+
sandbox_ref: Schema48.NullishOr(Schema48.String),
|
|
9398
|
+
latest_snapshot_ref: Schema48.NullishOr(Schema48.String),
|
|
9399
|
+
status: Schema48.String,
|
|
9400
|
+
resume_strategy: Schema48.String,
|
|
9401
|
+
region: Schema48.NullishOr(Schema48.String),
|
|
9402
|
+
request_json: Schema48.NullishOr(Schema48.Unknown),
|
|
9403
|
+
metadata_json: Schema48.Unknown,
|
|
9404
|
+
created_at: Schema48.Union([Schema48.Date, Schema48.String, Schema48.Finite]),
|
|
9405
|
+
updated_at: Schema48.Union([Schema48.Date, Schema48.String, Schema48.Finite])
|
|
9331
9406
|
}).annotate({ identifier: "Relay.WorkspaceLease.Row" });
|
|
9332
|
-
var WorkspaceSnapshotRow =
|
|
9333
|
-
id:
|
|
9334
|
-
lease_id:
|
|
9335
|
-
execution_id:
|
|
9336
|
-
reason:
|
|
9337
|
-
snapshot_ref:
|
|
9338
|
-
metadata_json:
|
|
9339
|
-
created_at:
|
|
9407
|
+
var WorkspaceSnapshotRow = Schema48.Struct({
|
|
9408
|
+
id: Schema48.String,
|
|
9409
|
+
lease_id: Schema48.String,
|
|
9410
|
+
execution_id: Schema48.String,
|
|
9411
|
+
reason: Schema48.String,
|
|
9412
|
+
snapshot_ref: Schema48.String,
|
|
9413
|
+
metadata_json: Schema48.Unknown,
|
|
9414
|
+
created_at: Schema48.Union([Schema48.Date, Schema48.String, Schema48.Finite])
|
|
9340
9415
|
}).annotate({ identifier: "Relay.WorkspaceSnapshot.Row" });
|
|
9341
9416
|
var metadata9 = (input) => input ?? {};
|
|
9342
9417
|
var terminalStatuses = new Set(["released", "failed"]);
|
|
9343
9418
|
var isActive = (record2) => !terminalStatuses.has(record2.status);
|
|
9344
|
-
var cloneLease = (record2) =>
|
|
9345
|
-
var cloneSnapshot = (record2) =>
|
|
9419
|
+
var cloneLease = (record2) => Schema48.decodeUnknownSync(exports_workspace_schema.WorkspaceLeaseRecord)(globalThis.structuredClone(record2));
|
|
9420
|
+
var cloneSnapshot = (record2) => Schema48.decodeUnknownSync(exports_workspace_schema.WorkspaceSnapshotRecord)(globalThis.structuredClone(record2));
|
|
9346
9421
|
var toRepositoryError14 = (error5) => WorkspaceLeaseRepositoryError.make({ message: String(error5) });
|
|
9347
|
-
var decodeLeaseRow = (row) =>
|
|
9348
|
-
var decodeSnapshotRow = (row) =>
|
|
9349
|
-
var decodeRequest = (value) =>
|
|
9422
|
+
var decodeLeaseRow = (row) => Schema48.decodeUnknownEffect(WorkspaceLeaseRow)(row).pipe(Effect48.mapError(toRepositoryError14));
|
|
9423
|
+
var decodeSnapshotRow = (row) => Schema48.decodeUnknownEffect(WorkspaceSnapshotRow)(row).pipe(Effect48.mapError(toRepositoryError14));
|
|
9424
|
+
var decodeRequest = (value) => Schema48.decodeUnknownSync(exports_workspace_schema.WorkspaceRequest)(decodeJson(value));
|
|
9350
9425
|
var toLeaseRecord = (row) => ({
|
|
9351
9426
|
id: exports_ids_schema.WorkspaceLeaseId.make(row.id),
|
|
9352
9427
|
execution_id: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
@@ -9699,10 +9774,10 @@ __export(exports_workflow_definition_repository, {
|
|
|
9699
9774
|
Service: () => Service40,
|
|
9700
9775
|
RepositoryError: () => RepositoryError
|
|
9701
9776
|
});
|
|
9702
|
-
import { Clock as Clock4, Context as Context38, Effect as Effect49, Layer as Layer40, Schema as
|
|
9777
|
+
import { Clock as Clock4, Context as Context38, Effect as Effect49, Layer as Layer40, Schema as Schema49 } from "effect";
|
|
9703
9778
|
import { SqlClient as SqlClient28 } from "effect/unstable/sql/SqlClient";
|
|
9704
|
-
class RepositoryError extends
|
|
9705
|
-
message:
|
|
9779
|
+
class RepositoryError extends Schema49.TaggedErrorClass()("WorkflowDefinitionRepositoryError", {
|
|
9780
|
+
message: Schema49.String
|
|
9706
9781
|
}) {
|
|
9707
9782
|
}
|
|
9708
9783
|
|
|
@@ -9956,8 +10031,8 @@ var transition2 = (sql, tenant, id, status, now, data) => sql.withTransaction(Ef
|
|
|
9956
10031
|
var decodeDefinition = (row) => ({
|
|
9957
10032
|
id: exports_ids_schema.WorkflowDefinitionId.make(row.workflow_definition_id),
|
|
9958
10033
|
revision: Number(row.revision),
|
|
9959
|
-
digest:
|
|
9960
|
-
definition:
|
|
10034
|
+
digest: Schema49.decodeUnknownSync(exports_workflow_schema.DefinitionDigest)(row.digest),
|
|
10035
|
+
definition: Schema49.decodeUnknownSync(exports_workflow_schema.Definition)(decodeJson(row.definition_json)),
|
|
9961
10036
|
created_at: fromDbTimestamp(row.created_at)
|
|
9962
10037
|
});
|
|
9963
10038
|
var decodeRun = (row) => ({
|
|
@@ -9965,19 +10040,19 @@ var decodeRun = (row) => ({
|
|
|
9965
10040
|
pin: {
|
|
9966
10041
|
workflow_definition_id: exports_ids_schema.WorkflowDefinitionId.make(row.workflow_definition_id),
|
|
9967
10042
|
workflow_definition_revision: Number(row.workflow_definition_revision),
|
|
9968
|
-
workflow_definition_digest:
|
|
10043
|
+
workflow_definition_digest: Schema49.decodeUnknownSync(exports_workflow_schema.DefinitionDigest)(row.workflow_definition_digest)
|
|
9969
10044
|
},
|
|
9970
|
-
status:
|
|
10045
|
+
status: Schema49.decodeUnknownSync(exports_workflow_schema.RunStatus)(row.status),
|
|
9971
10046
|
created_at: fromDbTimestamp(row.created_at),
|
|
9972
10047
|
updated_at: fromDbTimestamp(row.updated_at)
|
|
9973
10048
|
});
|
|
9974
10049
|
var decodeOperation = (row) => ({
|
|
9975
10050
|
execution_id: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
9976
10051
|
operation_id: exports_ids_schema.WorkflowOperationId.make(row.operation_id),
|
|
9977
|
-
status:
|
|
10052
|
+
status: Schema49.decodeUnknownSync(exports_workflow_schema.OperationStatus)(row.status),
|
|
9978
10053
|
...row.fan_out_id === null || row.fan_out_id === undefined ? {} : { fan_out_id: exports_ids_schema.ChildFanOutId.make(row.fan_out_id) },
|
|
9979
10054
|
...row.decision === null || row.decision === undefined ? {} : { decision: Boolean(row.decision) },
|
|
9980
|
-
...row.output_json === null || row.output_json === undefined ? {} : { output:
|
|
10055
|
+
...row.output_json === null || row.output_json === undefined ? {} : { output: Schema49.decodeUnknownSync(exports_workflow_schema.OperationState.fields.output)(decodeJson(row.output_json)) },
|
|
9981
10056
|
...row.attempt === null || row.attempt === undefined ? {} : { attempt: Number(row.attempt) },
|
|
9982
10057
|
...row.backoff_until === null || row.backoff_until === undefined ? {} : { backoff_until: fromDbTimestamp(row.backoff_until) },
|
|
9983
10058
|
...row.compensation_operation_id === null || row.compensation_operation_id === undefined ? {} : { compensation_operation_id: exports_ids_schema.WorkflowOperationId.make(row.compensation_operation_id) },
|
|
@@ -9988,17 +10063,17 @@ var decodeOperation = (row) => ({
|
|
|
9988
10063
|
var decodeLifecycle = (row) => ({
|
|
9989
10064
|
execution_id: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
9990
10065
|
sequence: Number(row.sequence),
|
|
9991
|
-
type:
|
|
10066
|
+
type: Schema49.decodeUnknownSync(exports_workflow_schema.LifecycleEventType)(row.event_type),
|
|
9992
10067
|
...row.operation_id === null || row.operation_id === undefined ? {} : { operation_id: exports_ids_schema.WorkflowOperationId.make(row.operation_id) },
|
|
9993
|
-
...row.data_json === null || row.data_json === undefined ? {} : { data:
|
|
10068
|
+
...row.data_json === null || row.data_json === undefined ? {} : { data: Schema49.decodeUnknownSync(exports_workflow_schema.LifecycleEvent.fields.data)(decodeJson(row.data_json)) },
|
|
9994
10069
|
created_at: fromDbTimestamp(row.created_at)
|
|
9995
10070
|
});
|
|
9996
10071
|
// ../runtime/src/tool/tool-runtime-service.ts
|
|
9997
10072
|
import { Tool as AiTool } from "effect/unstable/ai";
|
|
9998
|
-
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
|
|
10073
|
+
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";
|
|
9999
10074
|
|
|
10000
10075
|
// ../runtime/src/execution/event-log-service.ts
|
|
10001
|
-
import { Context as Context39, Effect as Effect53, Function as Function7, Layer as Layer43, Option as Option10, Schema as
|
|
10076
|
+
import { Context as Context39, Effect as Effect53, Function as Function7, Layer as Layer43, Option as Option10, Schema as Schema50, Stream as Stream9 } from "effect";
|
|
10002
10077
|
|
|
10003
10078
|
// ../runtime/src/execution/event-log-memory.ts
|
|
10004
10079
|
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";
|
|
@@ -10351,14 +10426,14 @@ var makeRepositoryLayer = (eventLog) => {
|
|
|
10351
10426
|
};
|
|
10352
10427
|
|
|
10353
10428
|
// ../runtime/src/execution/event-log-service.ts
|
|
10354
|
-
class EventLogCursorNotFound2 extends
|
|
10429
|
+
class EventLogCursorNotFound2 extends Schema50.TaggedErrorClass()("EventLogCursorNotFound", {
|
|
10355
10430
|
execution_id: exports_ids_schema.ExecutionId,
|
|
10356
10431
|
cursor: exports_shared_schema.NonEmptyString
|
|
10357
10432
|
}) {
|
|
10358
10433
|
}
|
|
10359
10434
|
|
|
10360
|
-
class EventLogError extends
|
|
10361
|
-
message:
|
|
10435
|
+
class EventLogError extends Schema50.TaggedErrorClass()("EventLogError", {
|
|
10436
|
+
message: Schema50.String
|
|
10362
10437
|
}) {
|
|
10363
10438
|
}
|
|
10364
10439
|
|
|
@@ -10427,19 +10502,19 @@ var sumUsage2 = Effect53.fn("EventLog.sumUsage.call")(function* (executionId) {
|
|
|
10427
10502
|
});
|
|
10428
10503
|
|
|
10429
10504
|
// ../runtime/src/wait/wait-service.ts
|
|
10430
|
-
import { Context as Context40, Duration as Duration2, Effect as Effect54, Layer as Layer44, Option as Option11, Schema as
|
|
10431
|
-
class WaitNotFound2 extends
|
|
10505
|
+
import { Context as Context40, Duration as Duration2, Effect as Effect54, Layer as Layer44, Option as Option11, Schema as Schema51 } from "effect";
|
|
10506
|
+
class WaitNotFound2 extends Schema51.TaggedErrorClass()("WaitNotFound", {
|
|
10432
10507
|
wait_id: exports_ids_schema.WaitId
|
|
10433
10508
|
}) {
|
|
10434
10509
|
}
|
|
10435
10510
|
|
|
10436
|
-
class WaitDefinitionMissing extends
|
|
10511
|
+
class WaitDefinitionMissing extends Schema51.TaggedErrorClass()("WaitDefinitionMissing", {
|
|
10437
10512
|
envelope_id: exports_ids_schema.EnvelopeId
|
|
10438
10513
|
}) {
|
|
10439
10514
|
}
|
|
10440
10515
|
|
|
10441
|
-
class WaitServiceError extends
|
|
10442
|
-
message:
|
|
10516
|
+
class WaitServiceError extends Schema51.TaggedErrorClass()("WaitServiceError", {
|
|
10517
|
+
message: Schema51.String
|
|
10443
10518
|
}) {
|
|
10444
10519
|
}
|
|
10445
10520
|
|
|
@@ -10719,20 +10794,20 @@ var upsertTool = (registry, tool) => {
|
|
|
10719
10794
|
return Chunk.map(registry, (registered) => registered.definition.name === tool.definition.name ? tool : registered);
|
|
10720
10795
|
};
|
|
10721
10796
|
var registerTool = (tools, tool) => Ref12.update(tools, (registry) => upsertTool(registry, tool));
|
|
10722
|
-
var jsonValue2 = (value) =>
|
|
10723
|
-
var fallbackParametersSchema =
|
|
10797
|
+
var jsonValue2 = (value) => Schema52.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
10798
|
+
var fallbackParametersSchema = Schema52.Struct({});
|
|
10724
10799
|
var parametersForInputSchema = (inputSchema) => {
|
|
10725
10800
|
const schema = exports_tool_schema.parametersSchema(inputSchema);
|
|
10726
10801
|
return schema.ast._tag === "Unknown" || schema.ast._tag === "Declaration" ? { parameters: fallbackParametersSchema, jsonSchema: inputSchema } : { parameters: schema };
|
|
10727
10802
|
};
|
|
10728
10803
|
var attachJsonSchema = (tool, jsonSchema) => jsonSchema === undefined ? tool : Object.assign(tool, { jsonSchema });
|
|
10729
|
-
var isStructFieldMap = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((field) =>
|
|
10804
|
+
var isStructFieldMap = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((field) => Schema52.isSchema(field));
|
|
10730
10805
|
var jsonSchemaFromEffectToolParameters = (tool) => {
|
|
10731
10806
|
const parameters = tool.parametersSchema;
|
|
10732
|
-
if (
|
|
10807
|
+
if (Schema52.isSchema(parameters))
|
|
10733
10808
|
return AiTool.getJsonSchema(tool);
|
|
10734
10809
|
if (isStructFieldMap(parameters))
|
|
10735
|
-
return AiTool.getJsonSchemaFromSchema(
|
|
10810
|
+
return AiTool.getJsonSchemaFromSchema(Schema52.Struct(parameters));
|
|
10736
10811
|
return AiTool.getJsonSchema(tool);
|
|
10737
10812
|
};
|
|
10738
10813
|
var runHandledToolkitTool = (toolkit, name, input, services) => {
|
|
@@ -10746,7 +10821,7 @@ var runHandledToolkitTool = (toolkit, name, input, services) => {
|
|
|
10746
10821
|
message: "Tool handler did not produce a final result"
|
|
10747
10822
|
})),
|
|
10748
10823
|
onSome: (result) => result.isFailure ? Effect55.fail(ToolExecutionFailed.make({ tool_name: String(name), message: String(result.result) })) : Effect55.succeed(jsonValue2(result.encodedResult))
|
|
10749
|
-
})), Effect55.provide(services), Effect55.mapError((error5) =>
|
|
10824
|
+
})), Effect55.provide(services), Effect55.mapError((error5) => Schema52.is(ToolExecutionFailed)(error5) ? error5 : ToolExecutionFailed.make({ tool_name: String(name), message: String(error5) })));
|
|
10750
10825
|
};
|
|
10751
10826
|
var finalToolResult = (tool, input, idempotencyKey) => Effect55.gen(function* () {
|
|
10752
10827
|
if (tool.run === undefined) {
|
|
@@ -10843,7 +10918,7 @@ var recordRequested = (repository, eventLog, input, tool) => repository.ensureCa
|
|
|
10843
10918
|
var repairResultEvent = (eventLog, input, record2) => ensureToolEvent(eventLog, resultEvent({ ...input, createdAt: record2.createdAt - 1 }, record2.result, input.eventSequence + 1));
|
|
10844
10919
|
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));
|
|
10845
10920
|
var recordReceived = (eventLog, input, record2) => ensureToolEvent(eventLog, resultEvent({ ...input, createdAt: record2.createdAt - 1 }, record2.result, input.eventSequence + 1)).pipe(Effect55.as(record2.result));
|
|
10846
|
-
var nonEmptyName = (name) =>
|
|
10921
|
+
var nonEmptyName = (name) => Schema52.decodeUnknownSync(exports_shared_schema.NonEmptyString)(name);
|
|
10847
10922
|
var needsApprovalFromEffectTool = (tool) => tool.needsApproval === undefined ? undefined : typeof tool.needsApproval === "boolean" ? tool.needsApproval : true;
|
|
10848
10923
|
var definitionFromEffectTool = (modelTool, options) => ({
|
|
10849
10924
|
name: modelTool.name,
|
|
@@ -10884,8 +10959,8 @@ var tool = Function8.dual(2, (name, options) => {
|
|
|
10884
10959
|
tool: effectTool,
|
|
10885
10960
|
...options.placement === undefined ? {} : { placement: options.placement },
|
|
10886
10961
|
...options.requiredPermissions === undefined ? {} : { requiredPermissions: options.requiredPermissions },
|
|
10887
|
-
validateInput: (input) =>
|
|
10888
|
-
run: (input, context) =>
|
|
10962
|
+
validateInput: (input) => Schema52.decodeUnknownEffect(inputSchema)(input).pipe(Effect55.mapError((error5) => ToolInputInvalid.make({ tool_name: name, message: error5.message })), Effect55.asVoid),
|
|
10963
|
+
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))
|
|
10889
10964
|
};
|
|
10890
10965
|
});
|
|
10891
10966
|
var dynamicTool = Function8.dual(2, (name, options) => {
|
|
@@ -10893,7 +10968,7 @@ var dynamicTool = Function8.dual(2, (name, options) => {
|
|
|
10893
10968
|
const modelTool = attachJsonSchema(AiTool.dynamic(name, {
|
|
10894
10969
|
description: options.description,
|
|
10895
10970
|
parameters: parameters.parameters,
|
|
10896
|
-
success:
|
|
10971
|
+
success: Schema52.Unknown,
|
|
10897
10972
|
needsApproval: options.needsApproval
|
|
10898
10973
|
}), parameters.jsonSchema);
|
|
10899
10974
|
return {
|
|
@@ -10938,7 +11013,7 @@ var externalOutcomeResult = (call, input) => {
|
|
|
10938
11013
|
return Effect55.succeed(placementFailureResult(input, call.externalOutcome.message));
|
|
10939
11014
|
}
|
|
10940
11015
|
const placement = call.placement.kind;
|
|
10941
|
-
return
|
|
11016
|
+
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}`))));
|
|
10942
11017
|
};
|
|
10943
11018
|
var runExternalTool = (repository, waits, call, input) => Effect55.gen(function* () {
|
|
10944
11019
|
const waitId2 = placementWaitId(input);
|
|
@@ -10972,7 +11047,7 @@ var runExternalTool = (repository, waits, call, input) => Effect55.gen(function*
|
|
|
10972
11047
|
return placementFailureResult(input, "Tool execution timed out");
|
|
10973
11048
|
if (wait.state === "cancelled")
|
|
10974
11049
|
return placementFailureResult(input, "Tool execution cancelled");
|
|
10975
|
-
const repairedCall = waitingCall.externalOutcome === undefined && waitingCall.placement.kind === "client" ? yield*
|
|
11050
|
+
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({
|
|
10976
11051
|
executionId: input.executionId,
|
|
10977
11052
|
callId: input.call.id,
|
|
10978
11053
|
outcome,
|
|
@@ -11137,11 +11212,11 @@ __export(exports_runtime, {
|
|
|
11137
11212
|
});
|
|
11138
11213
|
|
|
11139
11214
|
// ../runtime/src/child/child-fan-out-runtime.ts
|
|
11140
|
-
import { Clock as Clock5, Context as Context44, Effect as Effect58, FiberMap, Layer as Layer48, Schema as
|
|
11215
|
+
import { Clock as Clock5, Context as Context44, Effect as Effect58, FiberMap, Layer as Layer48, Schema as Schema55 } from "effect";
|
|
11141
11216
|
|
|
11142
11217
|
// ../runtime/src/child/child-fan-out-transition-service.ts
|
|
11143
|
-
import { Context as Context43, Effect as Effect57, Layer as Layer47, Option as Option13, Schema as
|
|
11144
|
-
class ChildFanOutTransitionError extends
|
|
11218
|
+
import { Context as Context43, Effect as Effect57, Layer as Layer47, Option as Option13, Schema as Schema54 } from "effect";
|
|
11219
|
+
class ChildFanOutTransitionError extends Schema54.TaggedErrorClass()("ChildFanOutTransitionError", { message: Schema54.String }) {
|
|
11145
11220
|
}
|
|
11146
11221
|
|
|
11147
11222
|
class Service43 extends Context43.Service()("@relayfx/runtime/child/child-fan-out-transition-service/Service") {
|
|
@@ -11208,7 +11283,7 @@ var terminal2 = Effect57.fn("ChildFanOutTransitionService.terminal.call")(functi
|
|
|
11208
11283
|
class HandlerService extends Context44.Service()("@relayfx/runtime/child/child-fan-out-runtime/HandlerService") {
|
|
11209
11284
|
}
|
|
11210
11285
|
|
|
11211
|
-
class ChildFanOutRuntimeError extends
|
|
11286
|
+
class ChildFanOutRuntimeError extends Schema55.TaggedErrorClass()("ChildFanOutRuntimeError", { message: Schema55.String }) {
|
|
11212
11287
|
}
|
|
11213
11288
|
|
|
11214
11289
|
class Service44 extends Context44.Service()("@relayfx/runtime/child/child-fan-out-runtime/Service") {
|
|
@@ -11275,17 +11350,17 @@ var layerFromRuntime = Layer48.effect(Service44, Effect58.gen(function* () {
|
|
|
11275
11350
|
}).pipe(Effect58.mapError(runtimeError)));
|
|
11276
11351
|
|
|
11277
11352
|
// ../runtime/src/state/execution-state-service.ts
|
|
11278
|
-
import { Config as Config2, Context as Context45, Effect as Effect59, Function as Function10, Layer as Layer49, Schema as
|
|
11353
|
+
import { Config as Config2, Context as Context45, Effect as Effect59, Function as Function10, Layer as Layer49, Schema as Schema56 } from "effect";
|
|
11279
11354
|
var StateVersionConflict3 = exports_execution_state_repository.StateVersionConflict;
|
|
11280
11355
|
|
|
11281
|
-
class StateValueInvalid extends
|
|
11282
|
-
key:
|
|
11283
|
-
message:
|
|
11356
|
+
class StateValueInvalid extends Schema56.TaggedErrorClass()("StateValueInvalid", {
|
|
11357
|
+
key: Schema56.String,
|
|
11358
|
+
message: Schema56.String
|
|
11284
11359
|
}) {
|
|
11285
11360
|
}
|
|
11286
11361
|
|
|
11287
|
-
class ExecutionStateError extends
|
|
11288
|
-
message:
|
|
11362
|
+
class ExecutionStateError extends Schema56.TaggedErrorClass()("ExecutionStateError", {
|
|
11363
|
+
message: Schema56.String
|
|
11289
11364
|
}) {
|
|
11290
11365
|
}
|
|
11291
11366
|
var key3 = Function10.dual(2, (name, schema) => ({
|
|
@@ -11305,7 +11380,7 @@ var layer38 = Layer49.effect(Service45, Effect59.gen(function* () {
|
|
|
11305
11380
|
const row = yield* repository.get(executionId, stateKey.name).pipe(Effect59.mapError(stateError));
|
|
11306
11381
|
if (row === undefined)
|
|
11307
11382
|
return;
|
|
11308
|
-
return yield*
|
|
11383
|
+
return yield* Schema56.decodeUnknownEffect(stateKey.schema)(row.value).pipe(Effect59.mapError((cause) => invalid(stateKey.name, cause)));
|
|
11309
11384
|
});
|
|
11310
11385
|
const getRecord = Effect59.fn("ExecutionStateService.getRecord")((executionId, stateKey) => repository.get(executionId, stateKey).pipe(Effect59.mapError(stateError)));
|
|
11311
11386
|
const put4 = Effect59.fn("ExecutionStateService.put")(function* (input) {
|
|
@@ -11314,8 +11389,8 @@ var layer38 = Layer49.effect(Service45, Effect59.gen(function* () {
|
|
|
11314
11389
|
if (replay2 !== undefined && replay2.key === input.key.name && replay2.op === "put" && replay2.record !== undefined)
|
|
11315
11390
|
return replay2.record;
|
|
11316
11391
|
}
|
|
11317
|
-
const value = yield*
|
|
11318
|
-
const encoded = yield*
|
|
11392
|
+
const value = yield* Schema56.encodeUnknownEffect(input.key.schema)(input.value).pipe(Effect59.mapError((cause) => invalid(input.key.name, cause)));
|
|
11393
|
+
const encoded = yield* Schema56.encodeEffect(Schema56.UnknownFromJsonString)(value).pipe(Effect59.mapError((cause) => invalid(input.key.name, cause)));
|
|
11319
11394
|
const bytes = new TextEncoder().encode(encoded);
|
|
11320
11395
|
let eventValue = { value };
|
|
11321
11396
|
if (bytes.byteLength > eventInlineMaxBytes) {
|
|
@@ -11330,9 +11405,9 @@ var layer38 = Layer49.effect(Service45, Effect59.gen(function* () {
|
|
|
11330
11405
|
...input.expectedVersion === undefined ? {} : { expectedVersion: input.expectedVersion },
|
|
11331
11406
|
...input.idempotencyKey === undefined ? {} : { idempotencyKey: input.idempotencyKey },
|
|
11332
11407
|
updatedAt: input.updatedAt
|
|
11333
|
-
}).pipe(Effect59.mapError((cause) =>
|
|
11408
|
+
}).pipe(Effect59.mapError((cause) => Schema56.is(exports_execution_state_repository.StateVersionConflict)(cause) ? cause : stateError(cause)));
|
|
11334
11409
|
});
|
|
11335
|
-
const remove3 = Effect59.fn("ExecutionStateService.remove")((input) => repository.remove(input).pipe(Effect59.mapError((cause) =>
|
|
11410
|
+
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))));
|
|
11336
11411
|
const list12 = Effect59.fn("ExecutionStateService.list")((input) => repository.list(input).pipe(Effect59.mapError(stateError)));
|
|
11337
11412
|
return Service45.of({ getRecord, get: get12, put: put4, remove: remove3, list: list12 });
|
|
11338
11413
|
}));
|
|
@@ -11340,7 +11415,7 @@ var memoryRepositoryDependencies = Layer49.mergeAll(exports_execution_repository
|
|
|
11340
11415
|
var memoryLayer36 = layer38.pipe(Layer49.provide(exports_execution_state_repository.memoryLayer.pipe(Layer49.provide(memoryRepositoryDependencies))));
|
|
11341
11416
|
|
|
11342
11417
|
// ../runtime/src/runner/runner-runtime-service.ts
|
|
11343
|
-
import { Config as Config8, Context as Context70, Crypto as Crypto4, Duration as Duration7, Effect as Effect99, Layer as Layer81, Option as Option26, Schema as
|
|
11418
|
+
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";
|
|
11344
11419
|
import {
|
|
11345
11420
|
ClusterWorkflowEngine,
|
|
11346
11421
|
HttpRunner,
|
|
@@ -11361,7 +11436,7 @@ import { WorkflowEngine as WorkflowEngine2 } from "effect/unstable/workflow";
|
|
|
11361
11436
|
import { LanguageModel as LanguageModel2 } from "effect/unstable/ai";
|
|
11362
11437
|
|
|
11363
11438
|
// ../runtime/src/agent/agent-registry-service.ts
|
|
11364
|
-
import { Clock as Clock6, Context as Context46, Crypto as Crypto2, Effect as Effect61, HashSet as HashSet4, Layer as Layer50, Option as Option14, Schema as
|
|
11439
|
+
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";
|
|
11365
11440
|
|
|
11366
11441
|
// ../runtime/src/tool/tool-input-schema-digest.ts
|
|
11367
11442
|
import { Crypto, Effect as Effect60, Encoding } from "effect";
|
|
@@ -11383,13 +11458,13 @@ var digestDefinitions = Effect60.fn("ToolInputSchemaDigest.digestDefinitions")(f
|
|
|
11383
11458
|
});
|
|
11384
11459
|
|
|
11385
11460
|
// ../runtime/src/agent/agent-registry-service.ts
|
|
11386
|
-
class AgentDefinitionInvalid extends
|
|
11387
|
-
message:
|
|
11461
|
+
class AgentDefinitionInvalid extends Schema57.TaggedErrorClass()("AgentDefinitionInvalid", {
|
|
11462
|
+
message: Schema57.String
|
|
11388
11463
|
}) {
|
|
11389
11464
|
}
|
|
11390
11465
|
|
|
11391
|
-
class AgentRegistryError extends
|
|
11392
|
-
message:
|
|
11466
|
+
class AgentRegistryError extends Schema57.TaggedErrorClass()("AgentRegistryError", {
|
|
11467
|
+
message: Schema57.String
|
|
11393
11468
|
}) {
|
|
11394
11469
|
}
|
|
11395
11470
|
|
|
@@ -11431,7 +11506,7 @@ var transferToolName = (name) => `transfer_to_${name.trim().toLowerCase().replac
|
|
|
11431
11506
|
var validateTurnPolicySnapshot = Effect61.fn("AgentRegistry.validateTurnPolicySnapshot")(function* (snapshot) {
|
|
11432
11507
|
if (snapshot === undefined)
|
|
11433
11508
|
return;
|
|
11434
|
-
const decoded = yield*
|
|
11509
|
+
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" })));
|
|
11435
11510
|
let nodes = 0;
|
|
11436
11511
|
const pending = [
|
|
11437
11512
|
{ snapshot: decoded, depth: 1 }
|
|
@@ -11575,35 +11650,35 @@ var listRevisions3 = Effect61.fn("AgentRegistry.listRevisions.call")(function* (
|
|
|
11575
11650
|
});
|
|
11576
11651
|
|
|
11577
11652
|
// ../runtime/src/agent/agent-loop-service.ts
|
|
11578
|
-
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
|
|
11579
|
-
import { AiError as AiError3, Chat, LanguageModel, Prompt as
|
|
11653
|
+
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";
|
|
11654
|
+
import { AiError as AiError3, Chat, LanguageModel, Prompt as Prompt7, Tokenizer, Tool as AiTool2, Toolkit as Toolkit2 } from "effect/unstable/ai";
|
|
11580
11655
|
|
|
11581
11656
|
// ../runtime/src/child/child-run-service.ts
|
|
11582
|
-
import { Context as Context48, Effect as Effect63, Function as Function12, HashSet as HashSet5, Layer as Layer52, Option as Option15, Result as Result2, Schema as
|
|
11657
|
+
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";
|
|
11583
11658
|
|
|
11584
11659
|
// ../runtime/src/workspace/workspace-provider-service.ts
|
|
11585
|
-
import { Context as Context47, Effect as Effect62, Function as Function11, Layer as Layer51, Ref as Ref13, Schema as
|
|
11660
|
+
import { Context as Context47, Effect as Effect62, Function as Function11, Layer as Layer51, Ref as Ref13, Schema as Schema58 } from "effect";
|
|
11586
11661
|
|
|
11587
|
-
class WorkspaceNotFound extends
|
|
11662
|
+
class WorkspaceNotFound extends Schema58.TaggedErrorClass()("WorkspaceNotFound", {
|
|
11588
11663
|
sandbox_ref: exports_ids_schema.WorkspaceRef
|
|
11589
11664
|
}) {
|
|
11590
11665
|
}
|
|
11591
11666
|
|
|
11592
|
-
class WorkspaceUnavailable extends
|
|
11667
|
+
class WorkspaceUnavailable extends Schema58.TaggedErrorClass()("WorkspaceUnavailable", {
|
|
11593
11668
|
sandbox_ref: exports_ids_schema.WorkspaceRef,
|
|
11594
|
-
message:
|
|
11669
|
+
message: Schema58.String
|
|
11595
11670
|
}) {
|
|
11596
11671
|
}
|
|
11597
11672
|
|
|
11598
|
-
class WorkspaceCapabilityUnsupported extends
|
|
11599
|
-
capability:
|
|
11673
|
+
class WorkspaceCapabilityUnsupported extends Schema58.TaggedErrorClass()("WorkspaceCapabilityUnsupported", {
|
|
11674
|
+
capability: Schema58.Literals(["suspend", "snapshot", "fork"]),
|
|
11600
11675
|
provider_key: exports_workspace_schema.WorkspaceProviderKey
|
|
11601
11676
|
}) {
|
|
11602
11677
|
}
|
|
11603
11678
|
|
|
11604
|
-
class WorkspaceProviderError extends
|
|
11679
|
+
class WorkspaceProviderError extends Schema58.TaggedErrorClass()("WorkspaceProviderError", {
|
|
11605
11680
|
provider_key: exports_workspace_schema.WorkspaceProviderKey,
|
|
11606
|
-
message:
|
|
11681
|
+
message: Schema58.String
|
|
11607
11682
|
}) {
|
|
11608
11683
|
}
|
|
11609
11684
|
|
|
@@ -11656,28 +11731,28 @@ var destroy = Effect62.fn("WorkspaceProvider.destroy.call")(function* (ref) {
|
|
|
11656
11731
|
});
|
|
11657
11732
|
|
|
11658
11733
|
// ../runtime/src/child/child-run-service.ts
|
|
11659
|
-
class StaticChildRunPresetNotFound extends
|
|
11734
|
+
class StaticChildRunPresetNotFound extends Schema59.TaggedErrorClass()("StaticChildRunPresetNotFound", {
|
|
11660
11735
|
preset_name: exports_shared_schema.NonEmptyString
|
|
11661
11736
|
}) {
|
|
11662
11737
|
}
|
|
11663
11738
|
|
|
11664
|
-
class ChildRunScopeBroadened extends
|
|
11665
|
-
field:
|
|
11739
|
+
class ChildRunScopeBroadened extends Schema59.TaggedErrorClass()("ChildRunScopeBroadened", {
|
|
11740
|
+
field: Schema59.Literals(["tool_names", "permissions"]),
|
|
11666
11741
|
value: exports_shared_schema.NonEmptyString
|
|
11667
11742
|
}) {
|
|
11668
11743
|
}
|
|
11669
11744
|
|
|
11670
|
-
class ChildRunServiceError extends
|
|
11671
|
-
message:
|
|
11745
|
+
class ChildRunServiceError extends Schema59.TaggedErrorClass()("ChildRunServiceError", {
|
|
11746
|
+
message: Schema59.String
|
|
11672
11747
|
}) {
|
|
11673
11748
|
}
|
|
11674
11749
|
|
|
11675
|
-
class ChildRunWorkspaceUnavailable extends
|
|
11676
|
-
reason:
|
|
11750
|
+
class ChildRunWorkspaceUnavailable extends Schema59.TaggedErrorClass()("ChildRunWorkspaceUnavailable", {
|
|
11751
|
+
reason: Schema59.String
|
|
11677
11752
|
}) {
|
|
11678
11753
|
}
|
|
11679
11754
|
|
|
11680
|
-
class ChildRunModelMissing extends
|
|
11755
|
+
class ChildRunModelMissing extends Schema59.TaggedErrorClass()("ChildRunModelMissing", {}) {
|
|
11681
11756
|
}
|
|
11682
11757
|
|
|
11683
11758
|
class Service48 extends Context48.Service()("@relayfx/runtime/child/child-run-service/Service") {
|
|
@@ -11913,53 +11988,53 @@ var spawnDynamic = Effect63.fn("ChildRunService.spawnDynamic.call")(function* (i
|
|
|
11913
11988
|
});
|
|
11914
11989
|
|
|
11915
11990
|
// ../runtime/src/child/spawn-child-run-tool.ts
|
|
11916
|
-
import { Effect as Effect64, Schema as
|
|
11991
|
+
import { Effect as Effect64, Schema as Schema60 } from "effect";
|
|
11917
11992
|
var toolName = "spawn_child_run";
|
|
11918
11993
|
var permissionName = "relay.child_run.spawn";
|
|
11919
|
-
var Input =
|
|
11920
|
-
preset_name:
|
|
11921
|
-
instructions:
|
|
11922
|
-
model:
|
|
11923
|
-
compaction_policy:
|
|
11924
|
-
tool_names:
|
|
11925
|
-
permissions:
|
|
11926
|
-
output_schema_ref:
|
|
11927
|
-
metadata:
|
|
11928
|
-
input:
|
|
11994
|
+
var Input = Schema60.Struct({
|
|
11995
|
+
preset_name: Schema60.optionalKey(exports_shared_schema.NonEmptyString),
|
|
11996
|
+
instructions: Schema60.optionalKey(Schema60.String),
|
|
11997
|
+
model: Schema60.optionalKey(exports_agent_schema.ModelSelection),
|
|
11998
|
+
compaction_policy: Schema60.optionalKey(exports_agent_schema.CompactionPolicy),
|
|
11999
|
+
tool_names: Schema60.optionalKey(Schema60.Array(Schema60.String)),
|
|
12000
|
+
permissions: Schema60.optionalKey(Schema60.Array(Schema60.String)),
|
|
12001
|
+
output_schema_ref: Schema60.optionalKey(Schema60.String),
|
|
12002
|
+
metadata: Schema60.optionalKey(exports_shared_schema.Metadata),
|
|
12003
|
+
input: Schema60.optionalKey(Schema60.Array(exports_content_schema.Part))
|
|
11929
12004
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Input" });
|
|
11930
|
-
var Output =
|
|
12005
|
+
var Output = Schema60.Struct({
|
|
11931
12006
|
child_execution_id: exports_ids_schema.ChildExecutionId,
|
|
11932
|
-
status:
|
|
11933
|
-
output:
|
|
12007
|
+
status: Schema60.Literals(["completed", "failed", "cancelled"]),
|
|
12008
|
+
output: Schema60.Array(exports_content_schema.Part)
|
|
11934
12009
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Output" });
|
|
11935
|
-
var TransferInput =
|
|
11936
|
-
input:
|
|
12010
|
+
var TransferInput = Schema60.Struct({
|
|
12011
|
+
input: Schema60.optionalKey(Schema60.Array(exports_content_schema.Part))
|
|
11937
12012
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.TransferInput" });
|
|
11938
|
-
var ModelInput =
|
|
11939
|
-
preset_name:
|
|
11940
|
-
instructions:
|
|
11941
|
-
model:
|
|
11942
|
-
provider:
|
|
11943
|
-
model:
|
|
11944
|
-
registration_key:
|
|
12013
|
+
var ModelInput = Schema60.Struct({
|
|
12014
|
+
preset_name: Schema60.optionalKey(Schema60.NullOr(Schema60.String)),
|
|
12015
|
+
instructions: Schema60.optionalKey(Schema60.String),
|
|
12016
|
+
model: Schema60.optionalKey(Schema60.NullOr(Schema60.Struct({
|
|
12017
|
+
provider: Schema60.String,
|
|
12018
|
+
model: Schema60.String,
|
|
12019
|
+
registration_key: Schema60.optionalKey(Schema60.String)
|
|
11945
12020
|
}))),
|
|
11946
|
-
compaction_policy:
|
|
11947
|
-
context_window:
|
|
11948
|
-
reserve_tokens:
|
|
11949
|
-
keep_recent_tokens:
|
|
11950
|
-
summary_model:
|
|
11951
|
-
provider:
|
|
11952
|
-
model:
|
|
11953
|
-
registration_key:
|
|
12021
|
+
compaction_policy: Schema60.optionalKey(Schema60.Struct({
|
|
12022
|
+
context_window: Schema60.Finite,
|
|
12023
|
+
reserve_tokens: Schema60.Finite,
|
|
12024
|
+
keep_recent_tokens: Schema60.Finite,
|
|
12025
|
+
summary_model: Schema60.optionalKey(Schema60.Struct({
|
|
12026
|
+
provider: Schema60.String,
|
|
12027
|
+
model: Schema60.String,
|
|
12028
|
+
registration_key: Schema60.optionalKey(Schema60.String)
|
|
11954
12029
|
}))
|
|
11955
12030
|
})),
|
|
11956
|
-
tool_names:
|
|
11957
|
-
permissions:
|
|
11958
|
-
output_schema_ref:
|
|
11959
|
-
input:
|
|
12031
|
+
tool_names: Schema60.optionalKey(Schema60.Array(Schema60.String)),
|
|
12032
|
+
permissions: Schema60.optionalKey(Schema60.Array(Schema60.String)),
|
|
12033
|
+
output_schema_ref: Schema60.optionalKey(Schema60.NullOr(Schema60.String)),
|
|
12034
|
+
input: Schema60.optionalKey(Schema60.Array(Schema60.Struct({ type: Schema60.Literal("text"), text: Schema60.String })))
|
|
11960
12035
|
});
|
|
11961
|
-
var ModelTransferInput =
|
|
11962
|
-
input:
|
|
12036
|
+
var ModelTransferInput = Schema60.Struct({
|
|
12037
|
+
input: Schema60.optionalKey(Schema60.Array(Schema60.Struct({ type: Schema60.Literal("text"), text: Schema60.String })))
|
|
11963
12038
|
});
|
|
11964
12039
|
var normalizeModelInput = (input) => {
|
|
11965
12040
|
const { preset_name: presetName, model, output_schema_ref: outputSchemaRef2, ...rest } = input;
|
|
@@ -12144,7 +12219,7 @@ var registeredTool = (config) => tool(toolName, {
|
|
|
12144
12219
|
permissions: [{ name: permissionName, value: true }],
|
|
12145
12220
|
requiredPermissions: [permissionName],
|
|
12146
12221
|
metadata: { relay_core_tool: true },
|
|
12147
|
-
run: (input, context) =>
|
|
12222
|
+
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)))
|
|
12148
12223
|
});
|
|
12149
12224
|
var transferToolName2 = (name) => `transfer_to_${name.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g, "_").replaceAll(/^_+|_+$/g, "")}`;
|
|
12150
12225
|
var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target) => {
|
|
@@ -12156,21 +12231,21 @@ var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target
|
|
|
12156
12231
|
permissions: [{ name: permissionName, value: true }],
|
|
12157
12232
|
requiredPermissions: [permissionName],
|
|
12158
12233
|
metadata: { relay_core_tool: true, handoff_target: target.name, preset_name: target.preset_name },
|
|
12159
|
-
run: (input, context) =>
|
|
12234
|
+
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)))
|
|
12160
12235
|
});
|
|
12161
12236
|
});
|
|
12162
12237
|
|
|
12163
12238
|
// ../runtime/src/memory/memory-service.ts
|
|
12164
|
-
import { Clock as Clock7, Context as Context49, Effect as Effect65, Layer as Layer53, Schema as
|
|
12165
|
-
import { EmbeddingModel as EmbeddingModel2, Prompt as
|
|
12239
|
+
import { Clock as Clock7, Context as Context49, Effect as Effect65, Layer as Layer53, Schema as Schema61 } from "effect";
|
|
12240
|
+
import { EmbeddingModel as EmbeddingModel2, Prompt as Prompt5 } from "effect/unstable/ai";
|
|
12166
12241
|
class Service49 extends Context49.Service()("@relayfx/runtime/memory/memory-service/Service") {
|
|
12167
12242
|
}
|
|
12168
12243
|
var defaultTopK = 5;
|
|
12169
12244
|
var memoryError = (error5) => exports_memory.MemoryError.make({
|
|
12170
12245
|
message: error5 instanceof Error ? `${error5.name}: ${error5.message}` : String(error5)
|
|
12171
12246
|
});
|
|
12172
|
-
var decodeSubject = (subject) =>
|
|
12173
|
-
var textPart = (text) =>
|
|
12247
|
+
var decodeSubject = (subject) => Schema61.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect65.mapError(memoryError));
|
|
12248
|
+
var textPart = (text) => Prompt5.makePart("text", { text });
|
|
12174
12249
|
var textFromParts = (parts) => parts.filter((part) => part.type === "text").map((part) => part.text).join(`
|
|
12175
12250
|
`).trim();
|
|
12176
12251
|
var latestUserText = (prompt) => {
|
|
@@ -12332,8 +12407,8 @@ var layer42 = (input) => Layer54.succeed(Service50, Service50.of(make4(input)));
|
|
|
12332
12407
|
var noRetryLayer = layer42({ retrySchedule: Schedule3.recurs(0) });
|
|
12333
12408
|
|
|
12334
12409
|
// ../runtime/src/presence/presence-service.ts
|
|
12335
|
-
import { Clock as Clock8, Config as Config3, Effect as Effect66, Layer as Layer55, Random, Schedule as Schedule4, Schema as
|
|
12336
|
-
var isPresenceError =
|
|
12410
|
+
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";
|
|
12411
|
+
var isPresenceError = Schema62.is(PresenceError);
|
|
12337
12412
|
var readError = (cause) => isPresenceError(cause) ? cause : PresenceError.make({ message: String(cause) });
|
|
12338
12413
|
var warn = (operation) => (cause) => Effect66.logWarning(`Presence ${operation} failed`).pipe(Effect66.annotateLogs({ cause: String(cause) }));
|
|
12339
12414
|
var layerFromRepository2 = Layer55.effect(Service2, Effect66.gen(function* () {
|
|
@@ -12388,11 +12463,11 @@ var list13 = Effect66.fn("Presence.list.call")(function* (scope) {
|
|
|
12388
12463
|
});
|
|
12389
12464
|
|
|
12390
12465
|
// ../runtime/src/presence/presence-tool.ts
|
|
12391
|
-
import { Effect as Effect67, Schema as
|
|
12466
|
+
import { Effect as Effect67, Schema as Schema63 } from "effect";
|
|
12392
12467
|
var toolName2 = "relay_presence";
|
|
12393
12468
|
var permissionName2 = "relay.presence.read";
|
|
12394
|
-
var Input2 =
|
|
12395
|
-
var Output2 =
|
|
12469
|
+
var Input2 = Schema63.Struct({ scope: Schema63.optionalKey(exports_presence_schema.Scope) });
|
|
12470
|
+
var Output2 = Schema63.Struct({ watcher_count: Schema63.Finite, entries: Schema63.Array(exports_presence_schema.Entry) });
|
|
12396
12471
|
var registeredTool2 = (presence) => tool(toolName2, {
|
|
12397
12472
|
description: "List observers currently watching an execution or session.",
|
|
12398
12473
|
input: Input2,
|
|
@@ -12408,24 +12483,24 @@ var registeredTool2 = (presence) => tool(toolName2, {
|
|
|
12408
12483
|
});
|
|
12409
12484
|
|
|
12410
12485
|
// ../runtime/src/state/state-tools.ts
|
|
12411
|
-
import { Effect as Effect68, Schema as
|
|
12412
|
-
var GetInput =
|
|
12413
|
-
var GetOutput =
|
|
12414
|
-
value:
|
|
12415
|
-
version:
|
|
12486
|
+
import { Effect as Effect68, Schema as Schema64 } from "effect";
|
|
12487
|
+
var GetInput = Schema64.Struct({ key: exports_shared_schema.NonEmptyString });
|
|
12488
|
+
var GetOutput = Schema64.Struct({
|
|
12489
|
+
value: Schema64.optionalKey(exports_shared_schema.JsonValue),
|
|
12490
|
+
version: Schema64.optionalKey(Schema64.Int)
|
|
12416
12491
|
});
|
|
12417
|
-
var PutInput =
|
|
12492
|
+
var PutInput = Schema64.Struct({
|
|
12418
12493
|
key: exports_shared_schema.NonEmptyString,
|
|
12419
12494
|
value: exports_shared_schema.JsonValue,
|
|
12420
|
-
expected_version:
|
|
12495
|
+
expected_version: Schema64.optionalKey(Schema64.Int.check(Schema64.isGreaterThanOrEqualTo(0)))
|
|
12421
12496
|
});
|
|
12422
|
-
var DeleteInput =
|
|
12423
|
-
var ListInput =
|
|
12424
|
-
prefix:
|
|
12425
|
-
after_key:
|
|
12426
|
-
limit:
|
|
12497
|
+
var DeleteInput = Schema64.Struct({ key: exports_shared_schema.NonEmptyString, expected_version: Schema64.optionalKey(Schema64.Int) });
|
|
12498
|
+
var ListInput = Schema64.Struct({
|
|
12499
|
+
prefix: Schema64.optionalKey(Schema64.String),
|
|
12500
|
+
after_key: Schema64.optionalKey(Schema64.String),
|
|
12501
|
+
limit: Schema64.optionalKey(Schema64.Int)
|
|
12427
12502
|
});
|
|
12428
|
-
var RecordOutput =
|
|
12503
|
+
var RecordOutput = Schema64.Struct({
|
|
12429
12504
|
execution_id: exports_state_schema.StateRecordView.fields.execution_id,
|
|
12430
12505
|
key: exports_state_schema.StateRecordView.fields.key,
|
|
12431
12506
|
value: exports_state_schema.StateRecordView.fields.value,
|
|
@@ -12433,8 +12508,8 @@ var RecordOutput = Schema63.Struct({
|
|
|
12433
12508
|
created_at: exports_state_schema.StateRecordView.fields.created_at,
|
|
12434
12509
|
updated_at: exports_state_schema.StateRecordView.fields.updated_at
|
|
12435
12510
|
});
|
|
12436
|
-
var PutOutput =
|
|
12437
|
-
var DeleteOutput =
|
|
12511
|
+
var PutOutput = Schema64.Struct({ key: exports_state_schema.StateKey, version: exports_state_schema.StateVersion });
|
|
12512
|
+
var DeleteOutput = Schema64.Struct({ deleted: Schema64.Boolean, version: Schema64.optionalKey(Schema64.Int) });
|
|
12438
12513
|
var enabled2 = (agent) => agent.metadata?.state_enabled === true;
|
|
12439
12514
|
var mapStateError = (toolName3) => (error5) => ToolExecutionFailed.make({ tool_name: toolName3, message: error5._tag });
|
|
12440
12515
|
var registeredTools2 = (state) => [
|
|
@@ -12475,7 +12550,7 @@ var registeredTools2 = (state) => [
|
|
|
12475
12550
|
tool("state_list", {
|
|
12476
12551
|
description: "List durable execution state",
|
|
12477
12552
|
input: ListInput,
|
|
12478
|
-
output:
|
|
12553
|
+
output: Schema64.Array(RecordOutput),
|
|
12479
12554
|
metadata: { relay_core_tool: true },
|
|
12480
12555
|
run: (input, context) => state.list({
|
|
12481
12556
|
executionId: context.executionId,
|
|
@@ -12548,6 +12623,8 @@ var recordAppendInput = (record2) => {
|
|
|
12548
12623
|
_tag: "Compaction",
|
|
12549
12624
|
version: 2,
|
|
12550
12625
|
projectedHistory: record2.projectedHistory,
|
|
12626
|
+
telemetry: record2.telemetry,
|
|
12627
|
+
...record2.compactionCommit === undefined ? {} : { compactionCommit: record2.compactionCommit },
|
|
12551
12628
|
...record2.summary === undefined ? {} : { summary: record2.summary },
|
|
12552
12629
|
...record2.metadata === undefined ? {} : { metadata: record2.metadata }
|
|
12553
12630
|
} : {
|
|
@@ -12686,6 +12763,8 @@ var make5 = Effect69.fn("RelaySessionStore.make")(function* (sessionId, entrySco
|
|
|
12686
12763
|
sessionId,
|
|
12687
12764
|
parentId: checkpoint.parentId === null ? null : entryId(checkpoint.parentId),
|
|
12688
12765
|
projectedHistory: checkpoint.projectedHistory,
|
|
12766
|
+
telemetry: checkpoint.telemetry,
|
|
12767
|
+
...checkpoint.compactionCommit === undefined ? {} : { compactionCommit: checkpoint.compactionCommit },
|
|
12689
12768
|
...checkpoint.summary === undefined ? {} : { summary: checkpoint.summary },
|
|
12690
12769
|
createdAt: now,
|
|
12691
12770
|
...makeOptions?.writer === undefined ? {} : { expectedWriter: makeOptions.writer }
|
|
@@ -12736,43 +12815,43 @@ var layer43 = Function13.dual((args) => typeof args[0] === "string" && String(ar
|
|
|
12736
12815
|
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)));
|
|
12737
12816
|
|
|
12738
12817
|
// ../runtime/src/inbox/inbox-service.ts
|
|
12739
|
-
import { Clock as Clock12, Context as Context61, Effect as Effect81, Layer as Layer67, Schema as
|
|
12818
|
+
import { Clock as Clock12, Context as Context61, Effect as Effect81, Layer as Layer67, Schema as Schema76 } from "effect";
|
|
12740
12819
|
|
|
12741
12820
|
// ../runtime/src/wait/wait-signal.ts
|
|
12742
|
-
import { Effect as Effect80, Schema as
|
|
12821
|
+
import { Effect as Effect80, Schema as Schema75 } from "effect";
|
|
12743
12822
|
|
|
12744
12823
|
// ../runtime/src/workflow/execution-workflow.ts
|
|
12745
12824
|
import { Activity, DurableDeferred, Workflow as Workflow2, WorkflowEngine } from "effect/unstable/workflow";
|
|
12746
|
-
import { Cause, Effect as Effect79, Exit, Function as Function14, Layer as Layer66, Option as Option20, Schema as
|
|
12825
|
+
import { Cause, Effect as Effect79, Exit, Function as Function14, Layer as Layer66, Option as Option20, Schema as Schema74 } from "effect";
|
|
12747
12826
|
|
|
12748
12827
|
// ../runtime/src/address/address-resolution-service.ts
|
|
12749
|
-
import { Context as Context53, Effect as Effect71, Layer as Layer58, Schema as
|
|
12828
|
+
import { Context as Context53, Effect as Effect71, Layer as Layer58, Schema as Schema66 } from "effect";
|
|
12750
12829
|
|
|
12751
12830
|
// ../runtime/src/address/address-book-service.ts
|
|
12752
|
-
import { Context as Context52, Effect as Effect70, Layer as Layer57, Ref as Ref15, Schema as
|
|
12831
|
+
import { Context as Context52, Effect as Effect70, Layer as Layer57, Ref as Ref15, Schema as Schema65 } from "effect";
|
|
12753
12832
|
var RouteKind2 = exports_address_schema.RouteKind;
|
|
12754
12833
|
var Route = exports_address_schema.Route;
|
|
12755
12834
|
var RouteRecord = exports_address_schema.RouteRecord;
|
|
12756
12835
|
|
|
12757
|
-
class AddressNotFound2 extends
|
|
12836
|
+
class AddressNotFound2 extends Schema65.TaggedErrorClass()("AddressNotFound", {
|
|
12758
12837
|
address_id: exports_ids_schema.AddressId
|
|
12759
12838
|
}) {
|
|
12760
12839
|
}
|
|
12761
12840
|
|
|
12762
|
-
class AddressUnavailable extends
|
|
12841
|
+
class AddressUnavailable extends Schema65.TaggedErrorClass()("AddressUnavailable", {
|
|
12763
12842
|
address_id: exports_ids_schema.AddressId,
|
|
12764
|
-
route_key:
|
|
12843
|
+
route_key: Schema65.String
|
|
12765
12844
|
}) {
|
|
12766
12845
|
}
|
|
12767
12846
|
|
|
12768
|
-
class AddressDeferred extends
|
|
12847
|
+
class AddressDeferred extends Schema65.TaggedErrorClass()("AddressDeferred", {
|
|
12769
12848
|
address_id: exports_ids_schema.AddressId,
|
|
12770
|
-
route_key:
|
|
12849
|
+
route_key: Schema65.String
|
|
12771
12850
|
}) {
|
|
12772
12851
|
}
|
|
12773
12852
|
|
|
12774
|
-
class AddressBookServiceError extends
|
|
12775
|
-
message:
|
|
12853
|
+
class AddressBookServiceError extends Schema65.TaggedErrorClass()("AddressBookServiceError", {
|
|
12854
|
+
message: Schema65.String
|
|
12776
12855
|
}) {
|
|
12777
12856
|
}
|
|
12778
12857
|
|
|
@@ -12800,7 +12879,7 @@ var recordFromEntry = (entry) => ({
|
|
|
12800
12879
|
updated_at: entry.updatedAt
|
|
12801
12880
|
});
|
|
12802
12881
|
var entryIdFor = (addressId) => exports_ids_schema.AddressBookEntryId.make(`address-book:${addressId}`);
|
|
12803
|
-
var validateRoute = (route) =>
|
|
12882
|
+
var validateRoute = (route) => Schema65.decodeUnknownEffect(Route)(route).pipe(Effect70.mapError((error5) => AddressBookServiceError.make({ message: String(error5) })));
|
|
12804
12883
|
var mapRepositoryError5 = (error5) => {
|
|
12805
12884
|
if (error5._tag === "AddressNotFound") {
|
|
12806
12885
|
return AddressNotFound2.make({ address_id: error5.address_id });
|
|
@@ -12865,41 +12944,41 @@ var list14 = Effect70.fn("AddressBook.list.call")(function* () {
|
|
|
12865
12944
|
});
|
|
12866
12945
|
|
|
12867
12946
|
// ../runtime/src/address/address-resolution-service.ts
|
|
12868
|
-
class AddressRouteNotFound extends
|
|
12947
|
+
class AddressRouteNotFound extends Schema66.TaggedErrorClass()("AddressRouteNotFound", {
|
|
12869
12948
|
address_id: exports_ids_schema.AddressId
|
|
12870
12949
|
}) {
|
|
12871
12950
|
}
|
|
12872
12951
|
|
|
12873
|
-
class AddressRouteKindMismatch extends
|
|
12952
|
+
class AddressRouteKindMismatch extends Schema66.TaggedErrorClass()("AddressRouteKindMismatch", {
|
|
12874
12953
|
address_id: exports_ids_schema.AddressId,
|
|
12875
|
-
expected:
|
|
12954
|
+
expected: Schema66.Literal("local-agent"),
|
|
12876
12955
|
actual: exports_address_schema.RouteKind,
|
|
12877
|
-
route_key:
|
|
12956
|
+
route_key: Schema66.String
|
|
12878
12957
|
}) {
|
|
12879
12958
|
}
|
|
12880
12959
|
|
|
12881
|
-
class AddressAgentDefinitionNotFound extends
|
|
12960
|
+
class AddressAgentDefinitionNotFound extends Schema66.TaggedErrorClass()("AddressAgentDefinitionNotFound", {
|
|
12882
12961
|
address_id: exports_ids_schema.AddressId,
|
|
12883
12962
|
agent_id: exports_ids_schema.AgentId
|
|
12884
12963
|
}) {
|
|
12885
12964
|
}
|
|
12886
12965
|
|
|
12887
|
-
class AddressResolutionError extends
|
|
12888
|
-
message:
|
|
12966
|
+
class AddressResolutionError extends Schema66.TaggedErrorClass()("AddressResolutionError", {
|
|
12967
|
+
message: Schema66.String
|
|
12889
12968
|
}) {
|
|
12890
12969
|
}
|
|
12891
|
-
var LocalAgentRoute =
|
|
12892
|
-
kind:
|
|
12970
|
+
var LocalAgentRoute = Schema66.Struct({
|
|
12971
|
+
kind: Schema66.Literal("local-agent"),
|
|
12893
12972
|
route_key: exports_shared_schema.NonEmptyString,
|
|
12894
|
-
metadata:
|
|
12973
|
+
metadata: Schema66.optionalKey(exports_shared_schema.Metadata)
|
|
12895
12974
|
}).annotate({ identifier: "Relay.AddressResolution.LocalAgentRoute" });
|
|
12896
|
-
var LocalAgentTarget =
|
|
12975
|
+
var LocalAgentTarget = Schema66.Struct({
|
|
12897
12976
|
address_id: exports_ids_schema.AddressId,
|
|
12898
12977
|
route: LocalAgentRoute,
|
|
12899
12978
|
agent_id: exports_ids_schema.AgentId,
|
|
12900
12979
|
agent_revision: exports_agent_schema.DefinitionRevision,
|
|
12901
12980
|
agent_snapshot: exports_agent_schema.Definition,
|
|
12902
|
-
tool_input_schema_digests:
|
|
12981
|
+
tool_input_schema_digests: Schema66.optionalKey(exports_agent_schema.ToolInputSchemaDigests)
|
|
12903
12982
|
}).annotate({ identifier: "Relay.AddressResolution.LocalAgentTarget" });
|
|
12904
12983
|
|
|
12905
12984
|
class Service53 extends Context53.Service()("@relayfx/runtime/address/address-resolution-service/Service") {
|
|
@@ -12932,7 +13011,7 @@ var layer44 = Layer58.effect(Service53, Effect71.gen(function* () {
|
|
|
12932
13011
|
return yield* AddressRouteNotFound.make({ address_id: addressId });
|
|
12933
13012
|
}
|
|
12934
13013
|
const route = yield* routeToLocalAgent(addressId, record2.route);
|
|
12935
|
-
const agentId = yield*
|
|
13014
|
+
const agentId = yield* Schema66.decodeUnknownEffect(exports_ids_schema.AgentId)(route.route_key).pipe(Effect71.mapError((error5) => AddressResolutionError.make({ message: String(error5) })));
|
|
12936
13015
|
const definition = yield* agentRegistry.get(agentId).pipe(Effect71.mapError(mapAgentRegistryError));
|
|
12937
13016
|
if (definition === undefined) {
|
|
12938
13017
|
return yield* AddressAgentDefinitionNotFound.make({
|
|
@@ -12961,13 +13040,13 @@ var resolveLocalAgent = Effect71.fn("AddressResolution.resolveLocalAgent.call")(
|
|
|
12961
13040
|
});
|
|
12962
13041
|
|
|
12963
13042
|
// ../runtime/src/agent/agent-loop-error.ts
|
|
12964
|
-
import { Schema as
|
|
13043
|
+
import { Schema as Schema67 } from "effect";
|
|
12965
13044
|
import { AiError as AiError2 } from "effect/unstable/ai";
|
|
12966
13045
|
|
|
12967
|
-
class AgentLoopError extends
|
|
12968
|
-
message:
|
|
12969
|
-
failure_classification:
|
|
12970
|
-
baton_failure:
|
|
13046
|
+
class AgentLoopError extends Schema67.TaggedErrorClass()("AgentLoopError", {
|
|
13047
|
+
message: Schema67.String,
|
|
13048
|
+
failure_classification: Schema67.optionalKey(Schema67.Literal("context-overflow")),
|
|
13049
|
+
baton_failure: Schema67.optionalKey(Schema67.Union([
|
|
12971
13050
|
exports_agent_event.AgentError,
|
|
12972
13051
|
exports_agent_event.ResumeMismatch,
|
|
12973
13052
|
exports_turn_policy.TurnPolicyError,
|
|
@@ -12981,25 +13060,25 @@ class AgentLoopError extends Schema66.TaggedErrorClass()("AgentLoopError", {
|
|
|
12981
13060
|
exports_model_registry.LanguageModelNotRegistered,
|
|
12982
13061
|
exports_tool_executor.FrameworkFailure
|
|
12983
13062
|
])),
|
|
12984
|
-
next_event_sequence:
|
|
13063
|
+
next_event_sequence: Schema67.optionalKey(exports_execution_schema.ExecutionEventSequence)
|
|
12985
13064
|
}) {
|
|
12986
13065
|
}
|
|
12987
13066
|
|
|
12988
|
-
class AgentLoopBudgetExceeded extends
|
|
12989
|
-
tokens_used:
|
|
12990
|
-
token_budget:
|
|
13067
|
+
class AgentLoopBudgetExceeded extends Schema67.TaggedErrorClass()("AgentLoopBudgetExceeded", {
|
|
13068
|
+
tokens_used: Schema67.Int,
|
|
13069
|
+
token_budget: Schema67.Int,
|
|
12991
13070
|
next_event_sequence: exports_execution_schema.ExecutionEventSequence
|
|
12992
13071
|
}) {
|
|
12993
13072
|
}
|
|
12994
|
-
var AgentTerminalFailure =
|
|
13073
|
+
var AgentTerminalFailure = Schema67.Union([AgentLoopError, AgentLoopBudgetExceeded]);
|
|
12995
13074
|
|
|
12996
13075
|
// ../runtime/src/child/parent-notifier-service.ts
|
|
12997
|
-
import { Context as Context54, Effect as Effect72, Layer as Layer59, Option as Option16, Ref as Ref16, Schema as
|
|
12998
|
-
class ParentNotifyError extends
|
|
12999
|
-
message:
|
|
13076
|
+
import { Context as Context54, Effect as Effect72, Layer as Layer59, Option as Option16, Ref as Ref16, Schema as Schema68 } from "effect";
|
|
13077
|
+
class ParentNotifyError extends Schema68.TaggedErrorClass()("ParentNotifyError", {
|
|
13078
|
+
message: Schema68.String
|
|
13000
13079
|
}) {
|
|
13001
13080
|
}
|
|
13002
|
-
var ChildTerminalStatus =
|
|
13081
|
+
var ChildTerminalStatus = Schema68.Literals(["completed", "failed", "cancelled"]).annotate({
|
|
13003
13082
|
identifier: "Relay.ParentNotifier.ChildTerminalStatus"
|
|
13004
13083
|
});
|
|
13005
13084
|
|
|
@@ -13080,15 +13159,15 @@ var notify = Effect72.fn("ParentNotifier.notify.call")(function* (input) {
|
|
|
13080
13159
|
});
|
|
13081
13160
|
|
|
13082
13161
|
// ../runtime/src/skill/skill-registry-service.ts
|
|
13083
|
-
import { Clock as Clock10, Context as Context55, Effect as Effect73, Layer as Layer60, Schema as
|
|
13162
|
+
import { Clock as Clock10, Context as Context55, Effect as Effect73, Layer as Layer60, Schema as Schema69 } from "effect";
|
|
13084
13163
|
|
|
13085
|
-
class SkillDefinitionInvalid extends
|
|
13086
|
-
message:
|
|
13164
|
+
class SkillDefinitionInvalid extends Schema69.TaggedErrorClass()("SkillDefinitionInvalid", {
|
|
13165
|
+
message: Schema69.String
|
|
13087
13166
|
}) {
|
|
13088
13167
|
}
|
|
13089
13168
|
|
|
13090
|
-
class SkillRegistryError extends
|
|
13091
|
-
message:
|
|
13169
|
+
class SkillRegistryError extends Schema69.TaggedErrorClass()("SkillRegistryError", {
|
|
13170
|
+
message: Schema69.String
|
|
13092
13171
|
}) {
|
|
13093
13172
|
}
|
|
13094
13173
|
|
|
@@ -13241,16 +13320,16 @@ var sourceForExecution = Effect73.fn("SkillRegistry.sourceForExecution.call")(fu
|
|
|
13241
13320
|
});
|
|
13242
13321
|
|
|
13243
13322
|
// ../runtime/src/execution/execution-service.ts
|
|
13244
|
-
import { Clock as Clock11, Context as Context56, Effect as Effect74, Layer as Layer61, Option as Option17, Schema as
|
|
13323
|
+
import { Clock as Clock11, Context as Context56, Effect as Effect74, Layer as Layer61, Option as Option17, Schema as Schema70, Stream as Stream12 } from "effect";
|
|
13245
13324
|
import { ShardingConfig } from "effect/unstable/cluster";
|
|
13246
13325
|
var ExecutionServiceErrorDetails = exports_shared_schema.JsonValue.annotate({
|
|
13247
13326
|
identifier: "Relay.ExecutionServiceErrorDetails"
|
|
13248
13327
|
});
|
|
13249
13328
|
|
|
13250
|
-
class ExecutionServiceError extends
|
|
13251
|
-
message:
|
|
13252
|
-
details:
|
|
13253
|
-
next_event_sequence:
|
|
13329
|
+
class ExecutionServiceError extends Schema70.TaggedErrorClass()("ExecutionServiceError", {
|
|
13330
|
+
message: Schema70.String,
|
|
13331
|
+
details: Schema70.optionalKey(ExecutionServiceErrorDetails),
|
|
13332
|
+
next_event_sequence: Schema70.optionalKey(exports_execution_schema.ExecutionEventSequence)
|
|
13254
13333
|
}) {
|
|
13255
13334
|
}
|
|
13256
13335
|
|
|
@@ -13431,7 +13510,7 @@ var existingTerminalExecution = Effect74.fn("ExecutionService.existingTerminalEx
|
|
|
13431
13510
|
execution: undefined,
|
|
13432
13511
|
failure: ExecutionServiceError.make({
|
|
13433
13512
|
message: typeof metadata11.message === "string" ? metadata11.message : "Execution failed",
|
|
13434
|
-
...
|
|
13513
|
+
...Schema70.is(ExecutionServiceErrorDetails)(metadata11.details) ? { details: metadata11.details } : {},
|
|
13435
13514
|
next_event_sequence: event.sequence
|
|
13436
13515
|
})
|
|
13437
13516
|
};
|
|
@@ -13674,13 +13753,13 @@ var coordinate = Effect76.fn("ToolTransitionCoordinator.coordinate")(function* (
|
|
|
13674
13753
|
});
|
|
13675
13754
|
|
|
13676
13755
|
// ../runtime/src/workspace/workspace-planner-service.ts
|
|
13677
|
-
import { Context as Context60, Effect as Effect78, HashSet as HashSet6, Layer as Layer65, Option as Option18, Schema as
|
|
13756
|
+
import { Context as Context60, Effect as Effect78, HashSet as HashSet6, Layer as Layer65, Option as Option18, Schema as Schema72 } from "effect";
|
|
13678
13757
|
|
|
13679
13758
|
// ../runtime/src/workspace/workspace-runtime-service.ts
|
|
13680
|
-
import { Context as Context59, Effect as Effect77, Layer as Layer64, Schema as
|
|
13759
|
+
import { Context as Context59, Effect as Effect77, Layer as Layer64, Schema as Schema71 } from "effect";
|
|
13681
13760
|
|
|
13682
|
-
class WorkspaceRuntimeError extends
|
|
13683
|
-
message:
|
|
13761
|
+
class WorkspaceRuntimeError extends Schema71.TaggedErrorClass()("WorkspaceRuntimeError", {
|
|
13762
|
+
message: Schema71.String
|
|
13684
13763
|
}) {
|
|
13685
13764
|
}
|
|
13686
13765
|
|
|
@@ -13708,18 +13787,18 @@ var exec = Effect77.fn("WorkspaceRuntime.exec.call")(function* (input) {
|
|
|
13708
13787
|
});
|
|
13709
13788
|
|
|
13710
13789
|
// ../runtime/src/workspace/workspace-planner-service.ts
|
|
13711
|
-
class WorkspaceRuntimeMissing extends
|
|
13790
|
+
class WorkspaceRuntimeMissing extends Schema72.TaggedErrorClass()("WorkspaceRuntimeMissing", {
|
|
13712
13791
|
execution_id: exports_ids_schema.ExecutionId
|
|
13713
13792
|
}) {
|
|
13714
13793
|
}
|
|
13715
13794
|
|
|
13716
|
-
class WorkspaceLeaseMissingRef extends
|
|
13795
|
+
class WorkspaceLeaseMissingRef extends Schema72.TaggedErrorClass()("WorkspaceLeaseMissingRef", {
|
|
13717
13796
|
execution_id: exports_ids_schema.ExecutionId
|
|
13718
13797
|
}) {
|
|
13719
13798
|
}
|
|
13720
13799
|
|
|
13721
|
-
class WorkspacePlannerError extends
|
|
13722
|
-
message:
|
|
13800
|
+
class WorkspacePlannerError extends Schema72.TaggedErrorClass()("WorkspacePlannerError", {
|
|
13801
|
+
message: Schema72.String
|
|
13723
13802
|
}) {
|
|
13724
13803
|
}
|
|
13725
13804
|
|
|
@@ -13905,7 +13984,7 @@ var fail = Effect78.fn("WorkspacePlanner.fail.call")(function* (input) {
|
|
|
13905
13984
|
});
|
|
13906
13985
|
|
|
13907
13986
|
// ../runtime/src/workflow/execution-workflow-state.ts
|
|
13908
|
-
import { Option as Option19, Schema as
|
|
13987
|
+
import { Option as Option19, Schema as Schema73 } from "effect";
|
|
13909
13988
|
var toWaitSnapshot = (record2) => ({
|
|
13910
13989
|
id: record2.id,
|
|
13911
13990
|
execution_id: record2.executionId,
|
|
@@ -13973,7 +14052,7 @@ var waitIdFromExecution = (execution) => {
|
|
|
13973
14052
|
};
|
|
13974
14053
|
var pendingSuspensionFromExecution = (execution) => {
|
|
13975
14054
|
const pending = execution.metadata?.pending_agent_suspension;
|
|
13976
|
-
return
|
|
14055
|
+
return Schema73.decodeUnknownOption(exports_agent_event.AgentSuspended)(pending).pipe(Option19.getOrUndefined);
|
|
13977
14056
|
};
|
|
13978
14057
|
var ExecutionWorkflowState = {
|
|
13979
14058
|
agentDefinitionPinCount,
|
|
@@ -14014,74 +14093,74 @@ var {
|
|
|
14014
14093
|
workflowGenerationFromRecord: workflowGenerationFromRecord2
|
|
14015
14094
|
} = ExecutionWorkflowState;
|
|
14016
14095
|
|
|
14017
|
-
class ExecutionWorkflowFailed extends
|
|
14018
|
-
message:
|
|
14019
|
-
terminal_failure:
|
|
14096
|
+
class ExecutionWorkflowFailed extends Schema74.TaggedErrorClass()("ExecutionWorkflowFailed", {
|
|
14097
|
+
message: Schema74.String,
|
|
14098
|
+
terminal_failure: Schema74.optionalKey(AgentTerminalFailure)
|
|
14020
14099
|
}) {
|
|
14021
14100
|
}
|
|
14022
14101
|
|
|
14023
|
-
class AgentCheckpointCompatibilityError extends
|
|
14024
|
-
message:
|
|
14102
|
+
class AgentCheckpointCompatibilityError extends Schema74.TaggedErrorClass()("AgentCheckpointCompatibilityError", {
|
|
14103
|
+
message: Schema74.String
|
|
14025
14104
|
}) {
|
|
14026
14105
|
}
|
|
14027
|
-
var ExecutionWorkflowError =
|
|
14028
|
-
var StartInput =
|
|
14106
|
+
var ExecutionWorkflowError = Schema74.Union([ExecutionWorkflowFailed, AgentCheckpointCompatibilityError]);
|
|
14107
|
+
var StartInput = Schema74.Struct({
|
|
14029
14108
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14030
14109
|
root_address_id: exports_ids_schema.AddressId,
|
|
14031
|
-
session_id:
|
|
14032
|
-
input:
|
|
14110
|
+
session_id: Schema74.optionalKey(exports_ids_schema.SessionId),
|
|
14111
|
+
input: Schema74.optionalKey(Schema74.Array(exports_content_schema.Part)),
|
|
14033
14112
|
event_sequence: exports_execution_schema.ExecutionEventSequence,
|
|
14034
14113
|
started_at: exports_shared_schema.TimestampMillis,
|
|
14035
14114
|
completed_at: exports_shared_schema.TimestampMillis,
|
|
14036
|
-
agent_id:
|
|
14037
|
-
agent_revision:
|
|
14038
|
-
agent_snapshot:
|
|
14039
|
-
agent_tool_input_schema_digests:
|
|
14040
|
-
wait_id:
|
|
14041
|
-
resume_suspension:
|
|
14042
|
-
workflow_generation:
|
|
14043
|
-
metadata:
|
|
14115
|
+
agent_id: Schema74.optionalKey(exports_ids_schema.AgentId),
|
|
14116
|
+
agent_revision: Schema74.optionalKey(exports_agent_schema.DefinitionRevision),
|
|
14117
|
+
agent_snapshot: Schema74.optionalKey(exports_agent_schema.Definition),
|
|
14118
|
+
agent_tool_input_schema_digests: Schema74.optionalKey(exports_agent_schema.ToolInputSchemaDigests),
|
|
14119
|
+
wait_id: Schema74.optionalKey(exports_ids_schema.WaitId),
|
|
14120
|
+
resume_suspension: Schema74.optionalKey(exports_agent_event.AgentSuspended),
|
|
14121
|
+
workflow_generation: Schema74.optionalKey(Schema74.Int.check(Schema74.isGreaterThanOrEqualTo(0))),
|
|
14122
|
+
metadata: Schema74.optionalKey(exports_shared_schema.Metadata)
|
|
14044
14123
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.StartInput" });
|
|
14045
|
-
var WaitSignalState =
|
|
14124
|
+
var WaitSignalState = Schema74.Literals(["resolved", "timed_out", "cancelled"]).annotate({
|
|
14046
14125
|
identifier: "Relay.ExecutionWorkflow.WaitSignalState"
|
|
14047
14126
|
});
|
|
14048
|
-
var WaitSignal =
|
|
14127
|
+
var WaitSignal = Schema74.Struct({
|
|
14049
14128
|
wait_id: exports_ids_schema.WaitId,
|
|
14050
14129
|
state: WaitSignalState,
|
|
14051
14130
|
signaled_at: exports_shared_schema.TimestampMillis
|
|
14052
14131
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.WaitSignal" });
|
|
14053
|
-
var SignalWaitInput =
|
|
14054
|
-
workflow_execution_id:
|
|
14132
|
+
var SignalWaitInput = Schema74.Struct({
|
|
14133
|
+
workflow_execution_id: Schema74.String,
|
|
14055
14134
|
wait_id: exports_ids_schema.WaitId,
|
|
14056
14135
|
state: WaitSignalState,
|
|
14057
14136
|
signaled_at: exports_shared_schema.TimestampMillis
|
|
14058
14137
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.SignalWaitInput" });
|
|
14059
|
-
var CancelExecutionInput =
|
|
14138
|
+
var CancelExecutionInput = Schema74.Struct({
|
|
14060
14139
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14061
14140
|
cancelled_at: exports_shared_schema.TimestampMillis,
|
|
14062
|
-
reason:
|
|
14141
|
+
reason: Schema74.optionalKey(Schema74.String)
|
|
14063
14142
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.CancelExecutionInput" });
|
|
14064
|
-
var CancelExecutionResult =
|
|
14143
|
+
var CancelExecutionResult = Schema74.Struct({
|
|
14065
14144
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14066
14145
|
status: exports_execution_schema.ExecutionStatus
|
|
14067
14146
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.CancelExecutionResult" });
|
|
14068
|
-
var WaitSnapshot =
|
|
14147
|
+
var WaitSnapshot = Schema74.Struct({
|
|
14069
14148
|
id: exports_ids_schema.WaitId,
|
|
14070
14149
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14071
|
-
envelope_id:
|
|
14150
|
+
envelope_id: Schema74.optionalKey(exports_ids_schema.EnvelopeId),
|
|
14072
14151
|
mode: exports_envelope_schema.WaitMode,
|
|
14073
|
-
correlation_key:
|
|
14074
|
-
state:
|
|
14152
|
+
correlation_key: Schema74.optionalKey(Schema74.String),
|
|
14153
|
+
state: Schema74.Literals(["open", "resolved", "timed_out", "cancelled"]),
|
|
14075
14154
|
metadata: exports_shared_schema.Metadata,
|
|
14076
14155
|
created_at: exports_shared_schema.TimestampMillis,
|
|
14077
|
-
resolved_at:
|
|
14156
|
+
resolved_at: Schema74.optionalKey(exports_shared_schema.TimestampMillis)
|
|
14078
14157
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.WaitSnapshot" });
|
|
14079
|
-
var StartResult =
|
|
14158
|
+
var StartResult = Schema74.Struct({
|
|
14080
14159
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14081
14160
|
status: exports_execution_schema.ExecutionStatus,
|
|
14082
|
-
wait_id:
|
|
14083
|
-
wait_state:
|
|
14084
|
-
metadata:
|
|
14161
|
+
wait_id: Schema74.optionalKey(exports_ids_schema.WaitId),
|
|
14162
|
+
wait_state: Schema74.optionalKey(Schema74.Literals(["resolved", "timed_out", "cancelled"])),
|
|
14163
|
+
metadata: Schema74.optionalKey(exports_shared_schema.Metadata)
|
|
14085
14164
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.StartResult" });
|
|
14086
14165
|
var StartExecutionWorkflowName = "Relay/Execution/Start";
|
|
14087
14166
|
var ActivityNames = {
|
|
@@ -14129,12 +14208,12 @@ var StartExecutionWorkflow = Workflow2.make(StartExecutionWorkflowName, {
|
|
|
14129
14208
|
var mapExecutionError = (error5) => {
|
|
14130
14209
|
if (error5.details === undefined)
|
|
14131
14210
|
return ExecutionWorkflowFailed.make({ message: error5.message });
|
|
14132
|
-
const terminalFailure =
|
|
14211
|
+
const terminalFailure = Schema74.decodeUnknownOption(AgentTerminalFailure)(error5.details).pipe(Option20.getOrUndefined);
|
|
14133
14212
|
return terminalFailure === undefined ? ExecutionWorkflowFailed.make({ message: "Malformed durable agent failure details" }) : ExecutionWorkflowFailed.make({ message: error5.message, terminal_failure: terminalFailure });
|
|
14134
14213
|
};
|
|
14135
14214
|
var mapAgentLoopError = (error5) => ExecutionServiceError.make({
|
|
14136
14215
|
message: error5._tag === "AgentLoopBudgetExceeded" ? `AgentLoopBudgetExceeded: used ${error5.tokens_used} of ${error5.token_budget} tokens` : error5.message,
|
|
14137
|
-
details: error5.pipe(
|
|
14216
|
+
details: error5.pipe(Schema74.encodeSync(AgentTerminalFailure), Schema74.decodeUnknownSync(exports_shared_schema.JsonValue)),
|
|
14138
14217
|
...error5.next_event_sequence === undefined ? {} : { next_event_sequence: error5.next_event_sequence }
|
|
14139
14218
|
});
|
|
14140
14219
|
var mapWaitError2 = (error5) => ExecutionWorkflowFailed.make({
|
|
@@ -14283,7 +14362,7 @@ var prepareCancellation = Effect79.fn("ExecutionWorkflow.prepareCancellation")(f
|
|
|
14283
14362
|
signals,
|
|
14284
14363
|
terminalNoop: false
|
|
14285
14364
|
};
|
|
14286
|
-
})).pipe(Effect79.mapError((error5) =>
|
|
14365
|
+
})).pipe(Effect79.mapError((error5) => Schema74.is(ExecutionWorkflowFailed)(error5) ? error5 : ExecutionWorkflowFailed.make({ message: "Tool cancellation transaction failed" })));
|
|
14287
14366
|
});
|
|
14288
14367
|
var signalPreparedCancellation = Effect79.fn("ExecutionWorkflow.signalPreparedCancellation")(function* (prepared, signaledAt) {
|
|
14289
14368
|
for (const pending of prepared.signals) {
|
|
@@ -14360,7 +14439,7 @@ var cancelExecution = (input, turn, reason) => Activity.make({
|
|
|
14360
14439
|
});
|
|
14361
14440
|
var loadCancellationRequested = (input, turn) => Activity.make({
|
|
14362
14441
|
name: ActivityNames.checkCancel(turn),
|
|
14363
|
-
success:
|
|
14442
|
+
success: Schema74.Boolean,
|
|
14364
14443
|
error: ExecutionWorkflowFailed,
|
|
14365
14444
|
execute: Effect79.gen(function* () {
|
|
14366
14445
|
const repository = yield* exports_execution_repository.Service;
|
|
@@ -14370,7 +14449,7 @@ var loadCancellationRequested = (input, turn) => Activity.make({
|
|
|
14370
14449
|
});
|
|
14371
14450
|
var loadWait = (name, waitId2) => Activity.make({
|
|
14372
14451
|
name,
|
|
14373
|
-
success:
|
|
14452
|
+
success: Schema74.UndefinedOr(WaitSnapshot),
|
|
14374
14453
|
error: ExecutionWorkflowFailed,
|
|
14375
14454
|
execute: get11(waitId2).pipe(Effect79.map((record2) => record2 === undefined ? undefined : toWaitSnapshot2(record2)), Effect79.mapError(mapWaitError2))
|
|
14376
14455
|
});
|
|
@@ -14413,7 +14492,7 @@ var decodeOptionalNumberSetting = (value, key4, valid) => {
|
|
|
14413
14492
|
var optionalNumberForStart = (input, key4, valid) => decodeOptionalNumberSetting(metadataSetting2(input, key4), key4, valid).pipe(Effect79.map((value) => value === null ? undefined : value));
|
|
14414
14493
|
var continueAsNewAfterTurnsForStart = (input) => optionalNumberForStart(input, continueAsNewAfterTurnsMetadataKey2, (value) => Number.isInteger(value) && value > 0);
|
|
14415
14494
|
var toolOutputMaxBytesForStart = (input) => decodeOptionalNumberSetting(metadataSetting2(input, toolOutputMaxBytesMetadataKey2), toolOutputMaxBytesMetadataKey2, (value) => value >= 0);
|
|
14416
|
-
var decodeMemorySubject = (value) => typeof value === "string" ?
|
|
14495
|
+
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" }));
|
|
14417
14496
|
var memorySubjectForStart = Effect79.fn("ExecutionWorkflow.memorySubjectForStart")(function* (input) {
|
|
14418
14497
|
const executionSubject = memorySubjectFromMetadata2(input.metadata);
|
|
14419
14498
|
if (executionSubject !== undefined)
|
|
@@ -14424,7 +14503,7 @@ var memorySubjectForStart = Effect79.fn("ExecutionWorkflow.memorySubjectForStart
|
|
|
14424
14503
|
var nextEventSequence4 = (eventLog, executionId) => eventLog.maxSequence(executionId).pipe(Effect79.map((max) => max === undefined ? 0 : max + 1), Effect79.mapError(mapEventLogError6));
|
|
14425
14504
|
var ensureWorkspace = (input) => Activity.make({
|
|
14426
14505
|
name: ActivityNames.ensureWorkspace,
|
|
14427
|
-
success:
|
|
14506
|
+
success: Schema74.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14428
14507
|
error: ExecutionWorkflowFailed,
|
|
14429
14508
|
execute: Effect79.gen(function* () {
|
|
14430
14509
|
if (input.agent_snapshot === undefined)
|
|
@@ -14441,19 +14520,19 @@ var ensureWorkspace = (input) => Activity.make({
|
|
|
14441
14520
|
});
|
|
14442
14521
|
var suspendWorkspace = (input, key4) => Activity.make({
|
|
14443
14522
|
name: ActivityNames.suspendWorkspace(key4),
|
|
14444
|
-
success:
|
|
14523
|
+
success: Schema74.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14445
14524
|
error: ExecutionWorkflowFailed,
|
|
14446
14525
|
execute: suspend2({ executionId: input.execution_id, now: input.started_at }).pipe(Effect79.mapError(mapWorkspaceError))
|
|
14447
14526
|
});
|
|
14448
14527
|
var resumeWorkspace = (input, key4) => Activity.make({
|
|
14449
14528
|
name: ActivityNames.resumeWorkspace(key4),
|
|
14450
|
-
success:
|
|
14529
|
+
success: Schema74.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14451
14530
|
error: ExecutionWorkflowFailed,
|
|
14452
14531
|
execute: resume2({ executionId: input.execution_id, now: input.started_at }).pipe(Effect79.map((plan2) => plan2?.lease), Effect79.mapError(mapWorkspaceError))
|
|
14453
14532
|
});
|
|
14454
14533
|
var releaseWorkspace = (input) => Activity.make({
|
|
14455
14534
|
name: ActivityNames.releaseWorkspace,
|
|
14456
|
-
success:
|
|
14535
|
+
success: Schema74.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14457
14536
|
error: ExecutionWorkflowFailed,
|
|
14458
14537
|
execute: release2({ executionId: input.execution_id, now: input.completed_at }).pipe(Effect79.mapError(mapWorkspaceError))
|
|
14459
14538
|
});
|
|
@@ -14529,7 +14608,7 @@ var completeExecution = (input, waitId2, waitState, workspaceRuntimeLayer, turn,
|
|
|
14529
14608
|
...input.metadata,
|
|
14530
14609
|
wait_id: wait.wait_id,
|
|
14531
14610
|
wait_state: "open",
|
|
14532
|
-
pending_agent_suspension: wait.suspension.pipe(
|
|
14611
|
+
pending_agent_suspension: wait.suspension.pipe(Schema74.encodeSync(exports_agent_event.AgentSuspended), Schema74.decodeUnknownSync(exports_shared_schema.JsonValue)),
|
|
14533
14612
|
...generationMetadata2(workflowGenerationForStart2(input))
|
|
14534
14613
|
},
|
|
14535
14614
|
nextEventSequence: wait.next_event_sequence
|
|
@@ -14545,12 +14624,12 @@ var completeExecution = (input, waitId2, waitState, workspaceRuntimeLayer, turn,
|
|
|
14545
14624
|
});
|
|
14546
14625
|
var failIncompatibleCheckpoint = (input, error5) => Activity.make({
|
|
14547
14626
|
name: ActivityNames.failIncompatibleCheckpoint,
|
|
14548
|
-
success:
|
|
14627
|
+
success: Schema74.Void,
|
|
14549
14628
|
error: ExecutionWorkflowFailed,
|
|
14550
14629
|
execute: Effect79.gen(function* () {
|
|
14551
14630
|
const eventLog = yield* Service41;
|
|
14552
14631
|
const eventSequence = yield* nextEventSequence4(eventLog, input.execution_id);
|
|
14553
|
-
const details = yield* error5.pipe(
|
|
14632
|
+
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" })));
|
|
14554
14633
|
yield* run4({
|
|
14555
14634
|
executionId: input.execution_id,
|
|
14556
14635
|
eventSequence,
|
|
@@ -14565,7 +14644,7 @@ var failIncompatibleCheckpoint = (input, error5) => Activity.make({
|
|
|
14565
14644
|
});
|
|
14566
14645
|
var loadChildCancellationRequested = (input) => Activity.make({
|
|
14567
14646
|
name: ActivityNames.checkQueuedChildCancellation,
|
|
14568
|
-
success:
|
|
14647
|
+
success: Schema74.Boolean,
|
|
14569
14648
|
error: ExecutionWorkflowFailed,
|
|
14570
14649
|
execute: Effect79.gen(function* () {
|
|
14571
14650
|
const context = childDispatchContext2(input);
|
|
@@ -14577,7 +14656,7 @@ var loadChildCancellationRequested = (input) => Activity.make({
|
|
|
14577
14656
|
});
|
|
14578
14657
|
var notifyParentActivity = (input, context, status, output) => Activity.make({
|
|
14579
14658
|
name: ActivityNames.notifyParent(status),
|
|
14580
|
-
success:
|
|
14659
|
+
success: Schema74.Void,
|
|
14581
14660
|
error: ExecutionWorkflowFailed,
|
|
14582
14661
|
execute: Effect79.gen(function* () {
|
|
14583
14662
|
const notifier = yield* Effect79.serviceOption(Service54);
|
|
@@ -14855,8 +14934,8 @@ var signalWait = Effect79.fn("ExecutionWorkflow.signalWait")(function* (input) {
|
|
|
14855
14934
|
});
|
|
14856
14935
|
|
|
14857
14936
|
// ../runtime/src/wait/wait-signal.ts
|
|
14858
|
-
class WaitSignalError extends
|
|
14859
|
-
message:
|
|
14937
|
+
class WaitSignalError extends Schema75.TaggedErrorClass()("WaitSignalError", {
|
|
14938
|
+
message: Schema75.String
|
|
14860
14939
|
}) {
|
|
14861
14940
|
}
|
|
14862
14941
|
var signalWorkflowWait = Effect80.fn("WaitSignal.signalWorkflowWait")(function* (input) {
|
|
@@ -14875,19 +14954,19 @@ var signalWorkflowWait = Effect80.fn("WaitSignal.signalWorkflowWait")(function*
|
|
|
14875
14954
|
});
|
|
14876
14955
|
|
|
14877
14956
|
// ../runtime/src/inbox/inbox-service.ts
|
|
14878
|
-
class InboxDeliveryError extends
|
|
14957
|
+
class InboxDeliveryError extends Schema76.TaggedErrorClass()("InboxDeliveryError", {
|
|
14879
14958
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14880
|
-
message:
|
|
14959
|
+
message: Schema76.String
|
|
14881
14960
|
}) {
|
|
14882
14961
|
}
|
|
14883
14962
|
|
|
14884
|
-
class InboxReplyTokenInvalid extends
|
|
14885
|
-
reply_token:
|
|
14963
|
+
class InboxReplyTokenInvalid extends Schema76.TaggedErrorClass()("InboxReplyTokenInvalid", {
|
|
14964
|
+
reply_token: Schema76.String
|
|
14886
14965
|
}) {
|
|
14887
14966
|
}
|
|
14888
14967
|
|
|
14889
|
-
class InboxServiceError extends
|
|
14890
|
-
message:
|
|
14968
|
+
class InboxServiceError extends Schema76.TaggedErrorClass()("InboxServiceError", {
|
|
14969
|
+
message: Schema76.String
|
|
14891
14970
|
}) {
|
|
14892
14971
|
}
|
|
14893
14972
|
|
|
@@ -14995,9 +15074,9 @@ var layerWithSignal = (dependencies) => makeLayer2(dependencies);
|
|
|
14995
15074
|
var memoryLayer42 = layer50.pipe(Layer67.provide(exports_inbox_repository.memoryLayer), Layer67.provide(exports_envelope_repository.memoryLayer));
|
|
14996
15075
|
|
|
14997
15076
|
// ../runtime/src/topic/topic-service.ts
|
|
14998
|
-
import { Clock as Clock13, Context as Context62, Effect as Effect82, Layer as Layer68, Random as Random2, Schema as
|
|
14999
|
-
class TopicServiceError extends
|
|
15000
|
-
message:
|
|
15077
|
+
import { Clock as Clock13, Context as Context62, Effect as Effect82, Layer as Layer68, Random as Random2, Schema as Schema77 } from "effect";
|
|
15078
|
+
class TopicServiceError extends Schema77.TaggedErrorClass()("TopicServiceError", {
|
|
15079
|
+
message: Schema77.String
|
|
15001
15080
|
}) {
|
|
15002
15081
|
}
|
|
15003
15082
|
|
|
@@ -15073,17 +15152,17 @@ var layer51 = Layer68.effect(Service63, Effect82.gen(function* () {
|
|
|
15073
15152
|
var memoryLayer43 = layer51.pipe(Layer68.provide(exports_topic_repository.memoryLayer));
|
|
15074
15153
|
|
|
15075
15154
|
// ../runtime/src/topic/publish-to-topic-tool.ts
|
|
15076
|
-
import { Effect as Effect83, Schema as
|
|
15155
|
+
import { Effect as Effect83, Schema as Schema78 } from "effect";
|
|
15077
15156
|
var toolName3 = "publish_to_topic";
|
|
15078
15157
|
var permissionName3 = "relay.topic.publish";
|
|
15079
|
-
var ContentInput =
|
|
15080
|
-
var Input3 =
|
|
15081
|
-
topic:
|
|
15158
|
+
var ContentInput = Schema78.Union([Schema78.String, Schema78.Array(exports_content_schema.TextPart)]);
|
|
15159
|
+
var Input3 = Schema78.Struct({
|
|
15160
|
+
topic: Schema78.String,
|
|
15082
15161
|
content: ContentInput
|
|
15083
15162
|
}).annotate({ identifier: "Relay.PublishToTopicTool.Input" });
|
|
15084
|
-
var Output3 =
|
|
15085
|
-
envelope_id:
|
|
15086
|
-
subscriber_count:
|
|
15163
|
+
var Output3 = Schema78.Struct({
|
|
15164
|
+
envelope_id: Schema78.String,
|
|
15165
|
+
subscriber_count: Schema78.Int
|
|
15087
15166
|
}).annotate({ identifier: "Relay.PublishToTopicTool.Output" });
|
|
15088
15167
|
var registeredTool3 = (config) => tool(toolName3, {
|
|
15089
15168
|
description: "Publish a durable message to every subscriber of a topic.",
|
|
@@ -15105,23 +15184,23 @@ var registeredTool3 = (config) => tool(toolName3, {
|
|
|
15105
15184
|
});
|
|
15106
15185
|
|
|
15107
15186
|
// ../runtime/src/inbox/wait-for-messages-tool.ts
|
|
15108
|
-
import { Effect as Effect84, Schema as
|
|
15187
|
+
import { Effect as Effect84, Schema as Schema79 } from "effect";
|
|
15109
15188
|
var toolName4 = "wait_for_messages";
|
|
15110
15189
|
var permissionName4 = "relay.inbox.wait";
|
|
15111
|
-
var Input4 =
|
|
15190
|
+
var Input4 = Schema79.Struct({ timeout: Schema79.optionalKey(Schema79.String) }).annotate({
|
|
15112
15191
|
identifier: "Relay.WaitForMessagesTool.Input"
|
|
15113
15192
|
});
|
|
15114
|
-
var MessageView =
|
|
15115
|
-
sequence:
|
|
15116
|
-
from:
|
|
15117
|
-
content:
|
|
15118
|
-
reply_token:
|
|
15119
|
-
correlation_key:
|
|
15120
|
-
metadata:
|
|
15193
|
+
var MessageView = Schema79.Struct({
|
|
15194
|
+
sequence: Schema79.Int,
|
|
15195
|
+
from: Schema79.String,
|
|
15196
|
+
content: Schema79.Array(exports_content_schema.TextPart),
|
|
15197
|
+
reply_token: Schema79.optionalKey(Schema79.String),
|
|
15198
|
+
correlation_key: Schema79.optionalKey(Schema79.String),
|
|
15199
|
+
metadata: Schema79.optionalKey(exports_shared_schema.Metadata)
|
|
15121
15200
|
}).annotate({ identifier: "Relay.WaitForMessagesTool.MessageView" });
|
|
15122
|
-
var Output4 =
|
|
15123
|
-
status:
|
|
15124
|
-
messages:
|
|
15201
|
+
var Output4 = Schema79.Struct({
|
|
15202
|
+
status: Schema79.Literals(["messages", "timed_out"]),
|
|
15203
|
+
messages: Schema79.Array(MessageView)
|
|
15125
15204
|
}).annotate({ identifier: "Relay.WaitForMessagesTool.Output" });
|
|
15126
15205
|
var project = (message) => ({
|
|
15127
15206
|
sequence: message.sequence,
|
|
@@ -15178,18 +15257,18 @@ var registeredTool4 = (config) => tool(toolName4, {
|
|
|
15178
15257
|
});
|
|
15179
15258
|
|
|
15180
15259
|
// ../runtime/src/inbox/send-message-tool.ts
|
|
15181
|
-
import { Effect as Effect85, Schema as
|
|
15260
|
+
import { Effect as Effect85, Schema as Schema80 } from "effect";
|
|
15182
15261
|
var toolName5 = "send_message";
|
|
15183
15262
|
var permissionName5 = "relay.inbox.send";
|
|
15184
|
-
var ContentInput2 =
|
|
15185
|
-
var Input5 =
|
|
15186
|
-
to:
|
|
15263
|
+
var ContentInput2 = Schema80.Union([Schema80.String, Schema80.Array(exports_content_schema.TextPart)]);
|
|
15264
|
+
var Input5 = Schema80.Struct({
|
|
15265
|
+
to: Schema80.String,
|
|
15187
15266
|
content: ContentInput2,
|
|
15188
|
-
reply_token:
|
|
15267
|
+
reply_token: Schema80.optionalKey(Schema80.String)
|
|
15189
15268
|
}).annotate({ identifier: "Relay.SendMessageTool.Input" });
|
|
15190
|
-
var Output5 =
|
|
15191
|
-
envelope_id:
|
|
15192
|
-
delivered:
|
|
15269
|
+
var Output5 = Schema80.Struct({
|
|
15270
|
+
envelope_id: Schema80.String,
|
|
15271
|
+
delivered: Schema80.Literals(["inbox", "outbox", "reply"])
|
|
15193
15272
|
}).annotate({ identifier: "Relay.SendMessageTool.Output" });
|
|
15194
15273
|
var registeredTool5 = (config) => tool(toolName5, {
|
|
15195
15274
|
description: "Send a durable message to an address or reply to an inbox message.",
|
|
@@ -15227,26 +15306,26 @@ var registeredTool5 = (config) => tool(toolName5, {
|
|
|
15227
15306
|
});
|
|
15228
15307
|
|
|
15229
15308
|
// ../runtime/src/envelope/envelope-service.ts
|
|
15230
|
-
import { Context as Context63, Effect as Effect86, Layer as Layer69, Schema as
|
|
15231
|
-
class EnvelopeAddressNotFound extends
|
|
15309
|
+
import { Context as Context63, Effect as Effect86, Layer as Layer69, Schema as Schema81 } from "effect";
|
|
15310
|
+
class EnvelopeAddressNotFound extends Schema81.TaggedErrorClass()("EnvelopeAddressNotFound", {
|
|
15232
15311
|
address_id: exports_ids_schema.AddressId
|
|
15233
15312
|
}) {
|
|
15234
15313
|
}
|
|
15235
15314
|
|
|
15236
|
-
class EnvelopeRouteUnavailable extends
|
|
15315
|
+
class EnvelopeRouteUnavailable extends Schema81.TaggedErrorClass()("EnvelopeRouteUnavailable", {
|
|
15237
15316
|
address_id: exports_ids_schema.AddressId,
|
|
15238
|
-
route_key:
|
|
15317
|
+
route_key: Schema81.String
|
|
15239
15318
|
}) {
|
|
15240
15319
|
}
|
|
15241
15320
|
|
|
15242
|
-
class EnvelopeRouteDeferred extends
|
|
15321
|
+
class EnvelopeRouteDeferred extends Schema81.TaggedErrorClass()("EnvelopeRouteDeferred", {
|
|
15243
15322
|
address_id: exports_ids_schema.AddressId,
|
|
15244
|
-
route_key:
|
|
15323
|
+
route_key: Schema81.String
|
|
15245
15324
|
}) {
|
|
15246
15325
|
}
|
|
15247
15326
|
|
|
15248
|
-
class EnvelopeServiceError extends
|
|
15249
|
-
message:
|
|
15327
|
+
class EnvelopeServiceError extends Schema81.TaggedErrorClass()("EnvelopeServiceError", {
|
|
15328
|
+
message: Schema81.String
|
|
15250
15329
|
}) {
|
|
15251
15330
|
}
|
|
15252
15331
|
|
|
@@ -15453,6 +15532,7 @@ var strategy = (config) => {
|
|
|
15453
15532
|
const existing = yield* config.repository.get({ executionId: config.executionId, checkpointId: id }).pipe(Effect87.mapError(mapRepositoryError11));
|
|
15454
15533
|
if (existing !== undefined)
|
|
15455
15534
|
return existing.summary;
|
|
15535
|
+
yield* config.onSummarizeStarted?.({ turn: request.turn, overflow: request.overflow }) ?? Effect87.void;
|
|
15456
15536
|
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))));
|
|
15457
15537
|
const createdAt = yield* Clock14.currentTimeMillis;
|
|
15458
15538
|
const input = {
|
|
@@ -15478,9 +15558,9 @@ var make8 = (config) => exports_compaction.make(strategy(config), defaultOptions
|
|
|
15478
15558
|
var layerFromEpoch = (epoch) => exports_instructions.layer(epoch.baseline.length === 0 ? [] : [exports_instructions.staticSource("relay:context-epoch", epoch.baseline)]);
|
|
15479
15559
|
|
|
15480
15560
|
// ../runtime/src/agent/relay-permissions.ts
|
|
15481
|
-
import { Clock as Clock15, Effect as Effect88, Layer as Layer71, Option as Option21, Schema as
|
|
15561
|
+
import { Clock as Clock15, Effect as Effect88, Layer as Layer71, Option as Option21, Schema as Schema82 } from "effect";
|
|
15482
15562
|
var permissionTokenPrefix = "wait:permission:";
|
|
15483
|
-
var jsonValue3 = (value) =>
|
|
15563
|
+
var jsonValue3 = (value) => Schema82.decodeUnknownSync(exports_shared_schema.JsonValue)(value === undefined ? null : value);
|
|
15484
15564
|
var waitIdForToolCall = (executionId, toolCallId) => Identifiers.waitId("permission", executionId, toolCallId);
|
|
15485
15565
|
var tokenFor = (executionId, request) => waitIdForToolCall(executionId, request.call.id);
|
|
15486
15566
|
var matchingRule = (rules, tool3, params) => {
|
|
@@ -15642,7 +15722,7 @@ var awaitAnswer = Effect88.fn("RelayPermissions.awaitAnswer")(function* (config,
|
|
|
15642
15722
|
var resolve8 = (config, pending) => pending.token.startsWith(permissionTokenPrefix) ? awaitAnswer(config, pending).pipe(Effect88.orDie) : Effect88.succeed({ _tag: "Approved" });
|
|
15643
15723
|
var rememberRule = Effect88.fn("RelayPermissions.rememberRule")(function* (config, rule) {
|
|
15644
15724
|
const createdAt = yield* Clock15.currentTimeMillis;
|
|
15645
|
-
const decodedRule = yield*
|
|
15725
|
+
const decodedRule = yield* Schema82.decodeUnknownEffect(exports_agent_schema.PermissionRule)(rule).pipe(Effect88.mapError((error5) => permissionError(error5.message)));
|
|
15646
15726
|
yield* config.repository.remember({
|
|
15647
15727
|
agent: config.agentName,
|
|
15648
15728
|
scope: config.scope,
|
|
@@ -15660,9 +15740,9 @@ var layer54 = (config) => Layer71.mergeAll(Layer71.succeed(exports_permissions.P
|
|
|
15660
15740
|
})));
|
|
15661
15741
|
|
|
15662
15742
|
// ../runtime/src/agent/relay-steering.ts
|
|
15663
|
-
import { Clock as Clock16, Effect as Effect89, Layer as Layer72, Schema as
|
|
15664
|
-
import { Prompt as
|
|
15665
|
-
var jsonValue4 = (value) =>
|
|
15743
|
+
import { Clock as Clock16, Effect as Effect89, Layer as Layer72, Schema as Schema83 } from "effect";
|
|
15744
|
+
import { Prompt as Prompt6 } from "effect/unstable/ai";
|
|
15745
|
+
var jsonValue4 = (value) => Schema83.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
15666
15746
|
var stringifyJson2 = (value) => JSON.stringify(jsonValue4(value));
|
|
15667
15747
|
var createdAtForSequence2 = (config, sequence) => config.startedAt + sequence - config.eventSequence;
|
|
15668
15748
|
var drainId = (config, kind, sequence) => `drain:${config.executionId}:steering:${kind}:sequence:${sequence}`;
|
|
@@ -15680,22 +15760,22 @@ var purePromptPart = (part) => {
|
|
|
15680
15760
|
};
|
|
15681
15761
|
var contentToPromptPart2 = (part) => {
|
|
15682
15762
|
const pure = purePromptPart(part);
|
|
15683
|
-
return pure === undefined ?
|
|
15763
|
+
return pure === undefined ? Prompt6.makePart("text", { text: stringifyJson2(part) }) : contentToPromptPart(pure);
|
|
15684
15764
|
};
|
|
15685
|
-
var promptForContent = (content) =>
|
|
15686
|
-
|
|
15687
|
-
content: content.length === 0 ? [
|
|
15765
|
+
var promptForContent = (content) => Prompt6.fromMessages([
|
|
15766
|
+
Prompt6.makeMessage("user", {
|
|
15767
|
+
content: content.length === 0 ? [Prompt6.makePart("text", { text: "" })] : content.map((part) => contentToPromptPart2(part))
|
|
15688
15768
|
})
|
|
15689
15769
|
]);
|
|
15690
15770
|
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)] : []));
|
|
15691
15771
|
var contentFromMessage = (message) => {
|
|
15692
15772
|
if (typeof message.prompt === "string")
|
|
15693
15773
|
return [exports_content_schema.text(message.prompt)];
|
|
15694
|
-
const prompt =
|
|
15774
|
+
const prompt = Prompt6.make(message.prompt);
|
|
15695
15775
|
const textParts = promptTextParts(prompt);
|
|
15696
15776
|
if (textParts.length > 0)
|
|
15697
15777
|
return textParts;
|
|
15698
|
-
return [exports_content_schema.text(prompt.pipe(
|
|
15778
|
+
return [exports_content_schema.text(prompt.pipe(Schema83.encodeSync(Prompt6.Prompt), stringifyJson2))];
|
|
15699
15779
|
};
|
|
15700
15780
|
var steeringDeliveredEvent = (config, kind, drain2, messages, sequence) => ({
|
|
15701
15781
|
id: exports_ids_schema.EventId.make(`event:${drain2.drainId}:delivered`),
|
|
@@ -15740,8 +15820,8 @@ var layer55 = (config) => Layer72.succeed(exports_steering.Steering, exports_ste
|
|
|
15740
15820
|
}));
|
|
15741
15821
|
|
|
15742
15822
|
// ../runtime/src/agent/relay-tool-executor.ts
|
|
15743
|
-
import { Deferred as Deferred3, Effect as Effect90, Layer as Layer73, Option as Option22, Schema as
|
|
15744
|
-
var jsonValue5 = (value) =>
|
|
15823
|
+
import { Deferred as Deferred3, Effect as Effect90, Layer as Layer73, Option as Option22, Schema as Schema84 } from "effect";
|
|
15824
|
+
var jsonValue5 = (value) => Schema84.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
15745
15825
|
var errorDetail = (error5) => {
|
|
15746
15826
|
switch (error5._tag) {
|
|
15747
15827
|
case "ToolNotRegistered":
|
|
@@ -16057,7 +16137,7 @@ var {
|
|
|
16057
16137
|
usageReportedEvent: usageReportedEvent2
|
|
16058
16138
|
} = AgentLoopEvents;
|
|
16059
16139
|
|
|
16060
|
-
class AgentLoopWaitRequested extends
|
|
16140
|
+
class AgentLoopWaitRequested extends Schema85.TaggedErrorClass()("AgentLoopWaitRequested", {
|
|
16061
16141
|
wait_id: exports_ids_schema.WaitId,
|
|
16062
16142
|
tool_call: exports_tool_schema.Call,
|
|
16063
16143
|
suspension: exports_agent_event.AgentSuspended,
|
|
@@ -16067,7 +16147,7 @@ class AgentLoopWaitRequested extends Schema84.TaggedErrorClass()("AgentLoopWaitR
|
|
|
16067
16147
|
|
|
16068
16148
|
class Service61 extends Context64.Service()("@relayfx/runtime/agent/agent-loop-service/Service") {
|
|
16069
16149
|
}
|
|
16070
|
-
var jsonValue6 = (value) =>
|
|
16150
|
+
var jsonValue6 = (value) => Schema85.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
16071
16151
|
var toolNames = (agent) => HashSet7.fromIterable(agent.tool_names);
|
|
16072
16152
|
var turnPolicyFromSnapshot = (snapshot2) => {
|
|
16073
16153
|
switch (snapshot2.kind) {
|
|
@@ -16159,7 +16239,7 @@ var runStructuredTurn = Effect93.fn("AgentLoop.runStructuredTurn")(function* (la
|
|
|
16159
16239
|
prompt: STRUCTURED_TURN_PROMPT,
|
|
16160
16240
|
schema: registration.schema,
|
|
16161
16241
|
objectName: "output"
|
|
16162
|
-
})).pipe(Effect93.mapError((error5) =>
|
|
16242
|
+
})).pipe(Effect93.mapError((error5) => Schema85.is(AgentLoopError)(error5) ? error5 : loopError(error5, sequence)));
|
|
16163
16243
|
return jsonValue6(response.value);
|
|
16164
16244
|
});
|
|
16165
16245
|
var loopError = (error5, nextEventSequence5) => AgentLoopError.make({
|
|
@@ -16168,6 +16248,23 @@ var loopError = (error5, nextEventSequence5) => AgentLoopError.make({
|
|
|
16168
16248
|
});
|
|
16169
16249
|
var appendEvent = (eventLog, allocator, event, nextEventSequence5) => appendIdempotentTo(eventLog, event).pipe(Effect93.tap((appended) => allocator.advanceTo(appended.sequence + 1)), Effect93.mapError((error5) => loopError(error5, nextEventSequence5)));
|
|
16170
16250
|
var compactionCommittedCursor = (executionId, checkpointId2) => `execution:${executionId}:agent-compaction:${checkpointId2}:committed`;
|
|
16251
|
+
var appendCompactionStartedEvent = Effect93.fn("AgentLoop.appendCompactionStartedEvent")(function* (eventLog, allocator, input, info) {
|
|
16252
|
+
const cursor = `execution:${input.executionId}:agent-compaction:turn:${info.turn}:started`;
|
|
16253
|
+
const existing = yield* eventLog.findByCursor({ executionId: input.executionId, cursor }).pipe(Effect93.mapError((error5) => loopError(error5, input.eventSequence + 1)));
|
|
16254
|
+
if (Option24.isSome(existing))
|
|
16255
|
+
return;
|
|
16256
|
+
const sequence = yield* allocator.allocate(1);
|
|
16257
|
+
const data = { turn: info.turn, overflow: info.overflow };
|
|
16258
|
+
yield* appendEvent(eventLog, allocator, {
|
|
16259
|
+
id: exports_ids_schema.EventId.make(`event:${input.executionId}:agent-compaction:turn:${info.turn}:started`),
|
|
16260
|
+
execution_id: input.executionId,
|
|
16261
|
+
type: "agent.compaction.started",
|
|
16262
|
+
sequence,
|
|
16263
|
+
cursor,
|
|
16264
|
+
data,
|
|
16265
|
+
created_at: input.startedAt + (sequence - input.eventSequence)
|
|
16266
|
+
}, sequence + 1);
|
|
16267
|
+
});
|
|
16171
16268
|
var appendCompactionCommittedEvent = Effect93.fn("AgentLoop.appendCompactionCommittedEvent")(function* (eventLog, allocator, input, checkpoint) {
|
|
16172
16269
|
if (input.sessionId === undefined)
|
|
16173
16270
|
return;
|
|
@@ -16193,8 +16290,8 @@ var appendCompactionCommittedEvent = Effect93.fn("AgentLoop.appendCompactionComm
|
|
|
16193
16290
|
});
|
|
16194
16291
|
var toolFromDefinition = (definition) => AiTool2.dynamic(definition.name, {
|
|
16195
16292
|
description: definition.description,
|
|
16196
|
-
parameters:
|
|
16197
|
-
success:
|
|
16293
|
+
parameters: Schema85.make(exports_tool_schema.parametersSchema(definition.input_schema).ast),
|
|
16294
|
+
success: Schema85.Unknown,
|
|
16198
16295
|
...definition.needs_approval === undefined ? {} : { needsApproval: definition.needs_approval }
|
|
16199
16296
|
});
|
|
16200
16297
|
var toolkitFromRegistered = (registered) => Toolkit2.make(...registered.map((tool3) => toolFromDefinition(tool3.definition)));
|
|
@@ -16224,7 +16321,7 @@ var restoreHistory = Effect93.fn("AgentLoop.restoreHistory")(function* (chats, i
|
|
|
16224
16321
|
}
|
|
16225
16322
|
return history;
|
|
16226
16323
|
});
|
|
16227
|
-
var promptEquivalence =
|
|
16324
|
+
var promptEquivalence = Schema85.toEquivalence(Prompt7.Prompt);
|
|
16228
16325
|
var reconcileCompactionCheckpoint = Effect93.fn("AgentLoop.reconcileCompactionCheckpoint")(function* (sessions, chats, input, restoredHistory, onCheckpointCommitted, failOnMismatch = false) {
|
|
16229
16326
|
if (input.sessionId === undefined)
|
|
16230
16327
|
return restoredHistory;
|
|
@@ -16267,10 +16364,10 @@ var toolCallDecodeMaxRetriesConfig = Config4.int("RELAY_AGENT_TOOL_CALL_DECODE_M
|
|
|
16267
16364
|
var isToolCallDecodeError = (error5) => AiError3.isAiError(error5) && error5.method === "streamText" && error5.reason._tag === "InvalidOutputError";
|
|
16268
16365
|
var toolCallDecodeFeedback = (error5, availableToolNames) => {
|
|
16269
16366
|
const tools = availableToolNames.length === 0 ? "(no tools are available)" : availableToolNames.join(", ");
|
|
16270
|
-
return
|
|
16271
|
-
|
|
16367
|
+
return Prompt7.fromMessages([
|
|
16368
|
+
Prompt7.makeMessage("user", {
|
|
16272
16369
|
content: [
|
|
16273
|
-
|
|
16370
|
+
Prompt7.makePart("text", {
|
|
16274
16371
|
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.`
|
|
16275
16372
|
})
|
|
16276
16373
|
]
|
|
@@ -16291,7 +16388,7 @@ var withToolCallDecodeResilience = (base, availableToolNames, maxRetries, record
|
|
|
16291
16388
|
if (Cause2.hasInterrupts(cause))
|
|
16292
16389
|
return Stream13.failCause(cause);
|
|
16293
16390
|
const error5 = Cause2.squash(cause);
|
|
16294
|
-
const continuation = !emitted && retriesLeft > 0 && isToolCallDecodeError(error5) ? attempt(
|
|
16391
|
+
const continuation = !emitted && retriesLeft > 0 && isToolCallDecodeError(error5) ? attempt(Prompt7.concat(Prompt7.make(prompt), toolCallDecodeFeedback(error5, availableToolNames)), retriesLeft - 1) : Stream13.failCause(cause);
|
|
16295
16392
|
return Stream13.unwrap(recordFailureClassification(exports_model_registry.classifyFailure(base, error5)).pipe(Effect93.as(continuation)));
|
|
16296
16393
|
}));
|
|
16297
16394
|
}))));
|
|
@@ -16316,7 +16413,7 @@ var restoreContextEpoch = Effect93.fn("AgentLoop.restoreContextEpoch")(function*
|
|
|
16316
16413
|
return { baseline: epoch.baseline, dynamicSourceIds: epoch.dynamicSourceIds };
|
|
16317
16414
|
});
|
|
16318
16415
|
var mapBatonRunError = (error5, current2) => {
|
|
16319
|
-
if (
|
|
16416
|
+
if (Schema85.is(exports_agent_event.AgentSuspended)(error5)) {
|
|
16320
16417
|
return AgentLoopWaitRequested.make({
|
|
16321
16418
|
wait_id: exports_ids_schema.WaitId.make(error5.token),
|
|
16322
16419
|
tool_call: {
|
|
@@ -16328,30 +16425,36 @@ var mapBatonRunError = (error5, current2) => {
|
|
|
16328
16425
|
next_event_sequence: current2
|
|
16329
16426
|
});
|
|
16330
16427
|
}
|
|
16428
|
+
if (Schema85.is(exports_model_telemetry.DeliveryFailed)(error5)) {
|
|
16429
|
+
return AgentLoopError.make({
|
|
16430
|
+
message: `Telemetry delivery failed: ${error5.message}`,
|
|
16431
|
+
next_event_sequence: current2
|
|
16432
|
+
});
|
|
16433
|
+
}
|
|
16331
16434
|
let message;
|
|
16332
|
-
if (
|
|
16435
|
+
if (Schema85.is(exports_agent_event.AgentError)(error5))
|
|
16333
16436
|
message = error5.message;
|
|
16334
|
-
else if (
|
|
16437
|
+
else if (Schema85.is(exports_agent_event.ResumeMismatch)(error5))
|
|
16335
16438
|
message = `Resume mismatch: ${error5.reason}`;
|
|
16336
|
-
else if (
|
|
16439
|
+
else if (Schema85.is(exports_turn_policy.TurnPolicyError)(error5))
|
|
16337
16440
|
message = error5.message;
|
|
16338
|
-
else if (
|
|
16441
|
+
else if (Schema85.is(exports_agent_event.TurnPolicyStopped)(error5))
|
|
16339
16442
|
message = `Turn policy stopped at turn ${error5.turn}`;
|
|
16340
|
-
else if (
|
|
16443
|
+
else if (Schema85.is(exports_agent_event.TurnLimitExceeded)(error5))
|
|
16341
16444
|
message = "Tool call turn limit exceeded";
|
|
16342
|
-
else if (
|
|
16445
|
+
else if (Schema85.is(exports_agent_event.MiddlewareViolation)(error5))
|
|
16343
16446
|
message = `ModelMiddleware violation at turn ${error5.turn}: ${error5.detail}`;
|
|
16344
|
-
else if (
|
|
16447
|
+
else if (Schema85.is(exports_agent_event.DuplicateToolCallId)(error5))
|
|
16345
16448
|
message = `Duplicate tool call id: ${error5.id}`;
|
|
16346
|
-
else if (
|
|
16449
|
+
else if (Schema85.is(exports_agent_event.ProgressOverflow)(error5))
|
|
16347
16450
|
message = `Tool progress overflow: ${error5.toolCallId}`;
|
|
16348
|
-
else if (
|
|
16451
|
+
else if (Schema85.is(exports_agent_event.ToolNameCollision)(error5))
|
|
16349
16452
|
message = `Tool name collision: ${error5.name}`;
|
|
16350
|
-
else if (
|
|
16453
|
+
else if (Schema85.is(AiError3.AiError)(error5))
|
|
16351
16454
|
message = error5.message;
|
|
16352
|
-
else if (
|
|
16455
|
+
else if (Schema85.is(exports_model_registry.LanguageModelNotRegistered)(error5))
|
|
16353
16456
|
message = `Language model not registered: ${error5.provider}/${error5.model}`;
|
|
16354
|
-
else if (
|
|
16457
|
+
else if (Schema85.is(exports_tool_executor.FrameworkFailure)(error5))
|
|
16355
16458
|
message = error5.message;
|
|
16356
16459
|
else {
|
|
16357
16460
|
const exhaustive = error5;
|
|
@@ -16359,14 +16462,14 @@ var mapBatonRunError = (error5, current2) => {
|
|
|
16359
16462
|
}
|
|
16360
16463
|
return AgentLoopError.make({ message, baton_failure: error5, next_event_sequence: current2 });
|
|
16361
16464
|
};
|
|
16362
|
-
var isBatonRunError = (error5) =>
|
|
16465
|
+
var isBatonRunError = (error5) => Schema85.is(exports_model_telemetry.DeliveryFailed)(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);
|
|
16363
16466
|
var mapBoundaryError = (errorOrCurrent, current2, failureClassification) => {
|
|
16364
16467
|
if (current2 === undefined) {
|
|
16365
16468
|
const sequence = errorOrCurrent;
|
|
16366
16469
|
return (error6) => mapBoundaryError(error6, sequence);
|
|
16367
16470
|
}
|
|
16368
16471
|
const error5 = errorOrCurrent;
|
|
16369
|
-
if (
|
|
16472
|
+
if (Schema85.is(AgentLoopError)(error5) || Schema85.is(AgentLoopWaitRequested)(error5) || Schema85.is(AgentLoopBudgetExceeded)(error5))
|
|
16370
16473
|
return error5;
|
|
16371
16474
|
const mapped = isBatonRunError(error5) ? mapBatonRunError(error5, current2) : loopError(error5, current2);
|
|
16372
16475
|
return mapped._tag === "AgentLoopError" && failureClassification === "context-overflow" ? AgentLoopError.make({
|
|
@@ -16384,9 +16487,9 @@ var terminalMemoryTranscript = (prompt, text) => {
|
|
|
16384
16487
|
return;
|
|
16385
16488
|
if (promptHasAssistantText(prompt, text))
|
|
16386
16489
|
return prompt;
|
|
16387
|
-
return
|
|
16490
|
+
return Prompt7.fromMessages([
|
|
16388
16491
|
...prompt.content,
|
|
16389
|
-
|
|
16492
|
+
Prompt7.makeMessage("assistant", { content: [Prompt7.makePart("text", { text })] })
|
|
16390
16493
|
]);
|
|
16391
16494
|
};
|
|
16392
16495
|
var recallOnlyMemory = (memory) => exports_memory.Memory.of({
|
|
@@ -16609,7 +16712,8 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16609
16712
|
const compactionService = activeCompactionOptions === undefined ? undefined : exports_compaction.Compaction.of(make8({
|
|
16610
16713
|
executionId: input.executionId,
|
|
16611
16714
|
repository: activeCompactionRepository,
|
|
16612
|
-
options: activeCompactionOptions
|
|
16715
|
+
options: activeCompactionOptions,
|
|
16716
|
+
onSummarizeStarted: (info) => appendCompactionStartedEvent(eventLog, allocator, input, info).pipe(Effect93.mapError((error5) => exports_compaction.CompactionError.make({ message: error5.message, cause: error5 })))
|
|
16613
16717
|
}));
|
|
16614
16718
|
if (memory !== undefined && Option24.isNone(durableMemory)) {
|
|
16615
16719
|
return yield* AgentLoopError.make({
|
|
@@ -16752,7 +16856,7 @@ var run5 = Effect93.fn("AgentLoop.run.call")(function* (input) {
|
|
|
16752
16856
|
// ../runtime/src/cluster/execution-entity.ts
|
|
16753
16857
|
import { ClusterSchema, Entity } from "effect/unstable/cluster";
|
|
16754
16858
|
import { Rpc } from "effect/unstable/rpc";
|
|
16755
|
-
import { Schema as
|
|
16859
|
+
import { Schema as Schema86 } from "effect";
|
|
16756
16860
|
var Start = Rpc.make("start", {
|
|
16757
16861
|
payload: StartInput,
|
|
16758
16862
|
success: StartResult,
|
|
@@ -16760,12 +16864,12 @@ var Start = Rpc.make("start", {
|
|
|
16760
16864
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
16761
16865
|
var SignalWait = Rpc.make("signalWait", {
|
|
16762
16866
|
payload: SignalWaitInput,
|
|
16763
|
-
success:
|
|
16867
|
+
success: Schema86.Void,
|
|
16764
16868
|
error: ExecutionWorkflowFailed
|
|
16765
16869
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
16766
16870
|
var Dispatch = Rpc.make("dispatch", {
|
|
16767
16871
|
payload: StartInput,
|
|
16768
|
-
success:
|
|
16872
|
+
success: Schema86.Void,
|
|
16769
16873
|
error: ExecutionWorkflowError
|
|
16770
16874
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
16771
16875
|
var Cancel = Rpc.make("cancel", {
|
|
@@ -16788,10 +16892,10 @@ var layer59 = entity.toLayer(entity.of({
|
|
|
16788
16892
|
var client = entity.client;
|
|
16789
16893
|
|
|
16790
16894
|
// ../runtime/src/execution/execution-watch-service.ts
|
|
16791
|
-
import { Config as Config5, Context as Context65, Duration as Duration4, Effect as Effect94, Layer as Layer76, Ref as Ref20, Schema as
|
|
16895
|
+
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";
|
|
16792
16896
|
|
|
16793
|
-
class ExecutionWatchError extends
|
|
16794
|
-
message:
|
|
16897
|
+
class ExecutionWatchError extends Schema87.TaggedErrorClass()("ExecutionWatchError", {
|
|
16898
|
+
message: Schema87.String
|
|
16795
16899
|
}) {
|
|
16796
16900
|
}
|
|
16797
16901
|
|
|
@@ -16839,20 +16943,20 @@ var layerFromServices = Layer76.effect(Service65, Effect94.gen(function* () {
|
|
|
16839
16943
|
}));
|
|
16840
16944
|
|
|
16841
16945
|
// ../runtime/src/resident/resident-registry-service.ts
|
|
16842
|
-
import { Context as Context66, Effect as Effect95, Layer as Layer77, Schema as
|
|
16843
|
-
class ResidentKindNotFound extends
|
|
16946
|
+
import { Context as Context66, Effect as Effect95, Layer as Layer77, Schema as Schema88 } from "effect";
|
|
16947
|
+
class ResidentKindNotFound extends Schema88.TaggedErrorClass()("ResidentKindNotFound", {
|
|
16844
16948
|
kind: exports_ids_schema.ResidentKindName
|
|
16845
16949
|
}) {
|
|
16846
16950
|
}
|
|
16847
16951
|
|
|
16848
|
-
class ResidentKindInvalid extends
|
|
16952
|
+
class ResidentKindInvalid extends Schema88.TaggedErrorClass()("ResidentKindInvalid", {
|
|
16849
16953
|
kind: exports_ids_schema.ResidentKindName,
|
|
16850
|
-
message:
|
|
16954
|
+
message: Schema88.String
|
|
16851
16955
|
}) {
|
|
16852
16956
|
}
|
|
16853
16957
|
|
|
16854
|
-
class ResidentRegistryError extends
|
|
16855
|
-
message:
|
|
16958
|
+
class ResidentRegistryError extends Schema88.TaggedErrorClass()("ResidentRegistryError", {
|
|
16959
|
+
message: Schema88.String
|
|
16856
16960
|
}) {
|
|
16857
16961
|
}
|
|
16858
16962
|
|
|
@@ -16884,21 +16988,21 @@ var layer60 = Layer77.effect(Service66, Effect95.gen(function* () {
|
|
|
16884
16988
|
}));
|
|
16885
16989
|
|
|
16886
16990
|
// ../runtime/src/resident/resident-instance-service.ts
|
|
16887
|
-
import { Context as Context67, Effect as Effect96, Function as Function16, Layer as Layer78, Schema as
|
|
16888
|
-
class ResidentDestroyed extends
|
|
16991
|
+
import { Context as Context67, Effect as Effect96, Function as Function16, Layer as Layer78, Schema as Schema89 } from "effect";
|
|
16992
|
+
class ResidentDestroyed extends Schema89.TaggedErrorClass()("ResidentDestroyed", {
|
|
16889
16993
|
kind: exports_ids_schema.ResidentKindName,
|
|
16890
16994
|
key: exports_ids_schema.ResidentKey
|
|
16891
16995
|
}) {
|
|
16892
16996
|
}
|
|
16893
16997
|
|
|
16894
|
-
class ResidentNotFound2 extends
|
|
16998
|
+
class ResidentNotFound2 extends Schema89.TaggedErrorClass()("ResidentNotFound", {
|
|
16895
16999
|
kind: exports_ids_schema.ResidentKindName,
|
|
16896
17000
|
key: exports_ids_schema.ResidentKey
|
|
16897
17001
|
}) {
|
|
16898
17002
|
}
|
|
16899
17003
|
|
|
16900
|
-
class ResidentServiceError extends
|
|
16901
|
-
message:
|
|
17004
|
+
class ResidentServiceError extends Schema89.TaggedErrorClass()("ResidentServiceError", {
|
|
17005
|
+
message: Schema89.String
|
|
16902
17006
|
}) {
|
|
16903
17007
|
}
|
|
16904
17008
|
|
|
@@ -17001,9 +17105,9 @@ var layer61 = Layer78.effect(Service67, Effect96.gen(function* () {
|
|
|
17001
17105
|
}));
|
|
17002
17106
|
|
|
17003
17107
|
// ../runtime/src/execution/session-stream-service.ts
|
|
17004
|
-
import { Config as Config6, Context as Context68, Duration as Duration5, Effect as Effect97, HashSet as HashSet8, Layer as Layer79, Ref as Ref21, Schema as
|
|
17005
|
-
class SessionStreamError extends
|
|
17006
|
-
message:
|
|
17108
|
+
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";
|
|
17109
|
+
class SessionStreamError extends Schema90.TaggedErrorClass()("SessionStreamError", {
|
|
17110
|
+
message: Schema90.String
|
|
17007
17111
|
}) {
|
|
17008
17112
|
}
|
|
17009
17113
|
|
|
@@ -17036,15 +17140,15 @@ var layerFromServices2 = Layer79.effect(Service68, Effect97.gen(function* () {
|
|
|
17036
17140
|
}));
|
|
17037
17141
|
|
|
17038
17142
|
// ../runtime/src/schedule/scheduler-service.ts
|
|
17039
|
-
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
|
|
17040
|
-
class SchedulerError extends
|
|
17041
|
-
message:
|
|
17143
|
+
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";
|
|
17144
|
+
class SchedulerError extends Schema91.TaggedErrorClass()("SchedulerError", {
|
|
17145
|
+
message: Schema91.String
|
|
17042
17146
|
}) {
|
|
17043
17147
|
}
|
|
17044
17148
|
|
|
17045
|
-
class ScheduleCronInvalid extends
|
|
17046
|
-
cron_expr:
|
|
17047
|
-
message:
|
|
17149
|
+
class ScheduleCronInvalid extends Schema91.TaggedErrorClass()("ScheduleCronInvalid", {
|
|
17150
|
+
cron_expr: Schema91.String,
|
|
17151
|
+
message: Schema91.String
|
|
17048
17152
|
}) {
|
|
17049
17153
|
}
|
|
17050
17154
|
|
|
@@ -17199,25 +17303,25 @@ var runOnce2 = Effect98.fn("SchedulerService.runOnce.call")(function* () {
|
|
|
17199
17303
|
});
|
|
17200
17304
|
|
|
17201
17305
|
// ../runtime/src/runner/runner-runtime-service.ts
|
|
17202
|
-
var DatabaseMode =
|
|
17306
|
+
var DatabaseMode = Schema92.Literals(["sql", "pg", "mysql", "sqlite", "memory"]).annotate({
|
|
17203
17307
|
identifier: "Relay.RunnerRuntime.DatabaseMode"
|
|
17204
17308
|
});
|
|
17205
|
-
var ReadinessStatus =
|
|
17309
|
+
var ReadinessStatus = Schema92.Struct({
|
|
17206
17310
|
database: DatabaseMode,
|
|
17207
|
-
cluster:
|
|
17208
|
-
workflow:
|
|
17209
|
-
executionEntity:
|
|
17311
|
+
cluster: Schema92.Literal("ready"),
|
|
17312
|
+
workflow: Schema92.Literals(["ready", "client"]),
|
|
17313
|
+
executionEntity: Schema92.Literals(["registered", "client"])
|
|
17210
17314
|
}).annotate({ identifier: "Relay.RunnerRuntime.ReadinessStatus" });
|
|
17211
17315
|
|
|
17212
|
-
class RunnerRuntimeError extends
|
|
17213
|
-
message:
|
|
17316
|
+
class RunnerRuntimeError extends Schema92.TaggedErrorClass()("RunnerRuntimeError", {
|
|
17317
|
+
message: Schema92.String
|
|
17214
17318
|
}) {
|
|
17215
17319
|
}
|
|
17216
17320
|
|
|
17217
|
-
class ClusterConfigMismatch extends
|
|
17218
|
-
field:
|
|
17219
|
-
expected:
|
|
17220
|
-
actual:
|
|
17321
|
+
class ClusterConfigMismatch extends Schema92.TaggedErrorClass()("ClusterConfigMismatch", {
|
|
17322
|
+
field: Schema92.String,
|
|
17323
|
+
expected: Schema92.String,
|
|
17324
|
+
actual: Schema92.String
|
|
17221
17325
|
}) {
|
|
17222
17326
|
}
|
|
17223
17327
|
|
|
@@ -17231,7 +17335,7 @@ var memoryClusterLayer = Sharding.layer.pipe(Layer81.provideMerge(Runners.layerN
|
|
|
17231
17335
|
var clusterHost = Config8.string("RELAY_CLUSTER_HOST").pipe(Config8.withDefault("localhost"));
|
|
17232
17336
|
var clusterPort = Config8.int("RELAY_CLUSTER_PORT").pipe(Config8.withDefault(34431));
|
|
17233
17337
|
var clusterShardsPerGroup = Config8.int("RELAY_CLUSTER_SHARDS_PER_GROUP").pipe(Config8.withDefault(300));
|
|
17234
|
-
var clusterShardGroups = Config8.schema(Config8.Array(
|
|
17338
|
+
var clusterShardGroups = Config8.schema(Config8.Array(Schema92.String), "RELAY_CLUSTER_SHARD_GROUPS").pipe(Config8.withDefault(["default", "execution"]));
|
|
17235
17339
|
var runnerAddressKey = (address) => `${address.host}:${address.port}`;
|
|
17236
17340
|
var runnerAddressEquals = (left, right) => left.host === right.host && left.port === right.port;
|
|
17237
17341
|
var shardingConfigFromEnv = Layer81.effect(ShardingConfig2.ShardingConfig, Effect99.gen(function* () {
|
|
@@ -17562,24 +17666,24 @@ var check = Effect99.fn("RunnerRuntime.check.call")(function* () {
|
|
|
17562
17666
|
});
|
|
17563
17667
|
|
|
17564
17668
|
// ../runtime/src/workflow/definition-runtime.ts
|
|
17565
|
-
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
|
|
17669
|
+
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";
|
|
17566
17670
|
import { dual as dual2 } from "effect/Function";
|
|
17567
17671
|
|
|
17568
|
-
class UnsupportedOperation extends
|
|
17672
|
+
class UnsupportedOperation extends Schema93.TaggedErrorClass()("UnsupportedWorkflowOperation", { operation_id: exports_ids_schema.WorkflowOperationId, kind: Schema93.String }) {
|
|
17569
17673
|
}
|
|
17570
17674
|
|
|
17571
|
-
class PinnedDefinitionNotFound extends
|
|
17675
|
+
class PinnedDefinitionNotFound extends Schema93.TaggedErrorClass()("PinnedWorkflowDefinitionNotFound", { execution_id: exports_ids_schema.ExecutionId }) {
|
|
17572
17676
|
}
|
|
17573
17677
|
|
|
17574
|
-
class PinnedDefinitionMismatch extends
|
|
17678
|
+
class PinnedDefinitionMismatch extends Schema93.TaggedErrorClass()("PinnedWorkflowDefinitionMismatch", { execution_id: exports_ids_schema.ExecutionId }) {
|
|
17575
17679
|
}
|
|
17576
17680
|
|
|
17577
|
-
class WorkflowRuntimeError extends
|
|
17578
|
-
message:
|
|
17681
|
+
class WorkflowRuntimeError extends Schema93.TaggedErrorClass()("WorkflowRuntimeError", {
|
|
17682
|
+
message: Schema93.String
|
|
17579
17683
|
}) {
|
|
17580
17684
|
}
|
|
17581
17685
|
|
|
17582
|
-
class WorkflowJoinPolicyNotSatisfied extends
|
|
17686
|
+
class WorkflowJoinPolicyNotSatisfied extends Schema93.TaggedErrorClass()("WorkflowJoinPolicyNotSatisfied", { policy: Schema93.String }) {
|
|
17583
17687
|
}
|
|
17584
17688
|
var runtimeError2 = (error5) => WorkflowRuntimeError.make({ message: String(error5) });
|
|
17585
17689
|
var mapRuntimeError2 = Effect100.mapError(runtimeError2);
|
|
@@ -17592,13 +17696,13 @@ class Service71 extends Context71.Service()("@relayfx/runtime/workflow/definitio
|
|
|
17592
17696
|
var fanOutIdFor = dual2(2, (executionId, fanOutKey) => exports_ids_schema.ChildFanOutId.make(`workflow:${executionId}:fan-out:${fanOutKey}`));
|
|
17593
17697
|
var childExecutionIdFor = (fanOutId, operationId2) => exports_ids_schema.ChildExecutionId.make(`${fanOutId}:member:${operationId2}`);
|
|
17594
17698
|
|
|
17595
|
-
class WorkflowCancelled extends
|
|
17699
|
+
class WorkflowCancelled extends Schema93.TaggedErrorClass()("WorkflowCancelled", {}) {
|
|
17596
17700
|
}
|
|
17597
17701
|
|
|
17598
|
-
class WorkflowBudgetExceeded extends
|
|
17702
|
+
class WorkflowBudgetExceeded extends Schema93.TaggedErrorClass()("WorkflowBudgetExceeded", { operation_id: exports_ids_schema.WorkflowOperationId }) {
|
|
17599
17703
|
}
|
|
17600
17704
|
|
|
17601
|
-
class WorkflowJoining extends
|
|
17705
|
+
class WorkflowJoining extends Schema93.TaggedErrorClass()("WorkflowJoining", {
|
|
17602
17706
|
fan_out_id: exports_ids_schema.ChildFanOutId
|
|
17603
17707
|
}) {
|
|
17604
17708
|
}
|
|
@@ -17853,7 +17957,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17853
17957
|
break;
|
|
17854
17958
|
}
|
|
17855
17959
|
case "cancellation":
|
|
17856
|
-
output2 = yield* execute(operation.operation).pipe(Effect100.catchIf(
|
|
17960
|
+
output2 = yield* execute(operation.operation).pipe(Effect100.catchIf(Schema93.is(WorkflowCancelled), () => operation.on_cancel === undefined ? Effect100.fail(WorkflowCancelled.make()) : execute(operation.on_cancel)));
|
|
17857
17961
|
break;
|
|
17858
17962
|
case "compensation":
|
|
17859
17963
|
output2 = yield* execute(operation.operation);
|
|
@@ -17900,7 +18004,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17900
18004
|
const result = yield* Effect100.exit(execute(revision.definition.entry_operation_id));
|
|
17901
18005
|
if (Exit2.isFailure(result)) {
|
|
17902
18006
|
const failure2 = Cause3.findErrorOption(result.cause);
|
|
17903
|
-
if (Option27.isSome(failure2) &&
|
|
18007
|
+
if (Option27.isSome(failure2) && Schema93.is(WorkflowJoining)(failure2.value))
|
|
17904
18008
|
return yield* result;
|
|
17905
18009
|
const currentRun = yield* repository.inspect(executionId);
|
|
17906
18010
|
if (currentRun?.status === "cancelled") {
|
|
@@ -17971,12 +18075,12 @@ var layerFromRuntime2 = Layer82.effect(Service71, Effect100.gen(function* () {
|
|
|
17971
18075
|
}));
|
|
17972
18076
|
|
|
17973
18077
|
// src/runtime.ts
|
|
17974
|
-
import { Cause as Cause5, Context as Context74, Effect as Effect112, Layer as Layer86, Option as Option31, Schema as
|
|
18078
|
+
import { Cause as Cause5, Context as Context74, Effect as Effect112, Layer as Layer86, Option as Option31, Schema as Schema101 } from "effect";
|
|
17975
18079
|
import { SqlClient as SqlClient31 } from "effect/unstable/sql/SqlClient";
|
|
17976
18080
|
|
|
17977
18081
|
// src/runtime-acquisition-error.ts
|
|
17978
|
-
import { Cause as Cause4, Function as Function17, Schema as
|
|
17979
|
-
var RuntimeConfigurationCategory =
|
|
18082
|
+
import { Cause as Cause4, Function as Function17, Schema as Schema94 } from "effect";
|
|
18083
|
+
var RuntimeConfigurationCategory = Schema94.Literals([
|
|
17980
18084
|
"missing-http-client",
|
|
17981
18085
|
"provider-config",
|
|
17982
18086
|
"model-registration",
|
|
@@ -17984,31 +18088,31 @@ var RuntimeConfigurationCategory = Schema93.Literals([
|
|
|
17984
18088
|
"database-config",
|
|
17985
18089
|
"unknown-host-layer"
|
|
17986
18090
|
]);
|
|
17987
|
-
var RuntimeConfigurationScope =
|
|
18091
|
+
var RuntimeConfigurationScope = Schema94.Literals(["host-layer", "database-client"]);
|
|
17988
18092
|
|
|
17989
|
-
class RuntimeHostLayerFailure extends
|
|
18093
|
+
class RuntimeHostLayerFailure extends Schema94.TaggedErrorClass()("RuntimeHostLayerFailure", { category: RuntimeConfigurationCategory }) {
|
|
17990
18094
|
}
|
|
17991
|
-
var SafeCauseReason =
|
|
18095
|
+
var SafeCauseReason = Schema94.TaggedUnion({
|
|
17992
18096
|
Fail: {
|
|
17993
18097
|
category: RuntimeConfigurationCategory,
|
|
17994
|
-
errorTag:
|
|
18098
|
+
errorTag: Schema94.Literals(["RuntimeHostLayerFailure", "UnknownTypedFailure"])
|
|
17995
18099
|
},
|
|
17996
|
-
Die: { defectTag:
|
|
18100
|
+
Die: { defectTag: Schema94.Literal("UnknownDefect") },
|
|
17997
18101
|
Interrupt: {}
|
|
17998
18102
|
});
|
|
17999
|
-
var SafeCause =
|
|
18000
|
-
reasons:
|
|
18001
|
-
truncated:
|
|
18103
|
+
var SafeCause = Schema94.Struct({
|
|
18104
|
+
reasons: Schema94.Array(SafeCauseReason).check(Schema94.isMaxLength(16)),
|
|
18105
|
+
truncated: Schema94.Boolean
|
|
18002
18106
|
});
|
|
18003
18107
|
|
|
18004
|
-
class RuntimeConfigurationError extends
|
|
18108
|
+
class RuntimeConfigurationError extends Schema94.TaggedErrorClass()("RuntimeConfigurationError", {
|
|
18005
18109
|
category: RuntimeConfigurationCategory,
|
|
18006
18110
|
scope: RuntimeConfigurationScope,
|
|
18007
18111
|
cause: SafeCause
|
|
18008
18112
|
}) {
|
|
18009
18113
|
}
|
|
18010
18114
|
var typedFailure = (error5) => {
|
|
18011
|
-
if (
|
|
18115
|
+
if (Schema94.is(RuntimeHostLayerFailure)(error5)) {
|
|
18012
18116
|
return { _tag: "Fail", category: error5.category, errorTag: "RuntimeHostLayerFailure" };
|
|
18013
18117
|
}
|
|
18014
18118
|
return { _tag: "Fail", category: "unknown-host-layer", errorTag: "UnknownTypedFailure" };
|
|
@@ -18027,11 +18131,11 @@ var safeCause = (cause) => {
|
|
|
18027
18131
|
var normalizeAcquisitionCauseImpl = (cause, scope, preserve) => {
|
|
18028
18132
|
const summary = safeCause(cause);
|
|
18029
18133
|
return Cause4.map(cause, (error5) => {
|
|
18030
|
-
if (
|
|
18134
|
+
if (Schema94.is(RuntimeConfigurationError)(error5) || preserve !== undefined && preserve(error5))
|
|
18031
18135
|
return error5;
|
|
18032
18136
|
const reason = typedFailure(error5);
|
|
18033
18137
|
return RuntimeConfigurationError.make({
|
|
18034
|
-
category:
|
|
18138
|
+
category: Schema94.is(RuntimeHostLayerFailure)(error5) ? reason.category : scope === "database-client" ? "database-config" : "unknown-host-layer",
|
|
18035
18139
|
scope,
|
|
18036
18140
|
cause: summary
|
|
18037
18141
|
});
|
|
@@ -18053,16 +18157,16 @@ var renderConfigurationError = (error5) => {
|
|
|
18053
18157
|
return `Runtime configuration error [${error5.category}/${error5.scope}]: ${remediation}; causes=${reasons}${error5.cause.truncated ? ",truncated" : ""}`;
|
|
18054
18158
|
};
|
|
18055
18159
|
// src/internal-client.ts
|
|
18056
|
-
import { Clock as Clock19, Effect as Effect109, Layer as Layer84, Option as Option30, Random as Random4, Schema as
|
|
18160
|
+
import { Clock as Clock19, Effect as Effect109, Layer as Layer84, Option as Option30, Random as Random4, Schema as Schema100, Stream as Stream17 } from "effect";
|
|
18057
18161
|
import { EntityId, ShardId, Sharding as Sharding2, ShardingConfig as ShardingConfig3 } from "effect/unstable/cluster";
|
|
18058
18162
|
|
|
18059
18163
|
// src/runtime-capability-policy.ts
|
|
18060
|
-
import { Context as Context72, Effect as Effect101, Function as Function18, Layer as Layer83, Schema as
|
|
18164
|
+
import { Context as Context72, Effect as Effect101, Function as Function18, Layer as Layer83, Schema as Schema95 } from "effect";
|
|
18061
18165
|
|
|
18062
|
-
class RuntimeCapabilityUnavailable extends
|
|
18063
|
-
capability:
|
|
18064
|
-
role:
|
|
18065
|
-
nextAction:
|
|
18166
|
+
class RuntimeCapabilityUnavailable extends Schema95.TaggedErrorClass()("RuntimeCapabilityUnavailable", {
|
|
18167
|
+
capability: Schema95.Literals(["fan-out", "workflow-definition"]),
|
|
18168
|
+
role: Schema95.Literals(["embedded", "runner", "client"]),
|
|
18169
|
+
nextAction: Schema95.Literals(["enable-embedded-capability", "use-embedded-runtime"])
|
|
18066
18170
|
}) {
|
|
18067
18171
|
}
|
|
18068
18172
|
|
|
@@ -18080,7 +18184,7 @@ var layer64 = Function18.dual(2, (role, capabilities) => Layer83.succeed(Service
|
|
|
18080
18184
|
}));
|
|
18081
18185
|
|
|
18082
18186
|
// src/client-baton-agent.ts
|
|
18083
|
-
import { Effect as Effect102, Schema as
|
|
18187
|
+
import { Effect as Effect102, Schema as Schema96 } from "effect";
|
|
18084
18188
|
var isRegisterBatonAgentInput = (input) => ("agent" in input);
|
|
18085
18189
|
var toolRefsFromBatonAgent = (agent) => Object.values(agent.toolkit.tools).map((tool3) => ({ name: tool3.name }));
|
|
18086
18190
|
var modelSelectionFromBatonAgent = (selection) => ({
|
|
@@ -18088,9 +18192,9 @@ var modelSelectionFromBatonAgent = (selection) => ({
|
|
|
18088
18192
|
model: selection.model,
|
|
18089
18193
|
...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
|
|
18090
18194
|
});
|
|
18091
|
-
var decodeBatonAgentName = (name) =>
|
|
18092
|
-
var decodeBatonAgentMetadata = (metadata11) => metadata11 === undefined ? Effect102.void :
|
|
18093
|
-
var decodeBatonMemorySubject = (subject) =>
|
|
18195
|
+
var decodeBatonAgentName = (name) => Schema96.decodeUnknownEffect(exports_shared_schema.NonEmptyString)(name).pipe(Effect102.mapError(() => ClientError.make({ message: "Baton agent name must not be blank" })));
|
|
18196
|
+
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" })));
|
|
18197
|
+
var decodeBatonMemorySubject = (subject) => Schema96.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect102.mapError(() => ClientError.make({ message: "Baton agent memory subject must be a MemorySubjectId" })));
|
|
18094
18198
|
var metadataFromBatonAgent = Effect102.fn("Client.metadataFromBatonAgent")(function* (input) {
|
|
18095
18199
|
const agentMetadata = yield* decodeBatonAgentMetadata(input.agent.metadata);
|
|
18096
18200
|
const memorySubject = input.agent.memory === undefined ? undefined : yield* decodeBatonMemorySubject(input.agent.memory.subject);
|
|
@@ -18199,10 +18303,10 @@ import { Effect as Effect104, Option as Option29 } from "effect";
|
|
|
18199
18303
|
import { Effect as Effect103 } from "effect";
|
|
18200
18304
|
|
|
18201
18305
|
// src/client-error-mapping.ts
|
|
18202
|
-
import { Option as Option28, Schema as
|
|
18306
|
+
import { Option as Option28, Schema as Schema97 } from "effect";
|
|
18203
18307
|
var errorMessage2 = (error5) => error5 instanceof Error ? error5.message : String(error5);
|
|
18204
18308
|
var toClientError = (error5) => ClientError.make({ message: errorMessage2(error5) });
|
|
18205
|
-
var toStreamError = (error5) => Option28.match(
|
|
18309
|
+
var toStreamError = (error5) => Option28.match(Schema97.decodeUnknownOption(EventLogCursorNotFound)(error5), {
|
|
18206
18310
|
onNone: () => toClientError(error5),
|
|
18207
18311
|
onSome: (cursorError) => cursorError
|
|
18208
18312
|
});
|
|
@@ -18333,8 +18437,8 @@ var childStartInput = (input, accepted2, pin, definition, createdAt, parentWaitI
|
|
|
18333
18437
|
var childRunInternals = { childStartInput, internalSpawnChildRunInput };
|
|
18334
18438
|
|
|
18335
18439
|
// src/client-execution-payloads.ts
|
|
18336
|
-
import { Effect as Effect105, Schema as
|
|
18337
|
-
var encodeExecutionCursor = (cursor) =>
|
|
18440
|
+
import { Effect as Effect105, Schema as Schema98 } from "effect";
|
|
18441
|
+
var encodeExecutionCursor = (cursor) => Schema98.encodeEffect(exports_pagination_schema.ExecutionCursorCodec)({ id: cursor.id, at: cursor.updatedAt }).pipe(Effect105.mapError(toClientError));
|
|
18338
18442
|
var executionIdFromIdempotencyKey = (idempotencyKey) => exports_ids_schema.ExecutionId.make(`execution:${idempotencyKey}`);
|
|
18339
18443
|
var metadataWithIdempotencyKey = (metadata11, idempotencyKey) => ({
|
|
18340
18444
|
...metadata11,
|
|
@@ -18451,9 +18555,9 @@ var wakeRuntime = Effect107.fn("Client.waits.wakeRuntime")(function* (waits, eve
|
|
|
18451
18555
|
var runtimeWakeInternals = { wakeRuntime };
|
|
18452
18556
|
|
|
18453
18557
|
// src/client-tool-outcome.ts
|
|
18454
|
-
import { Effect as Effect108, Schema as
|
|
18558
|
+
import { Effect as Effect108, Schema as Schema99 } from "effect";
|
|
18455
18559
|
var toolWaitId = (executionId, callId) => Identifiers.waitId("tool", executionId, callId);
|
|
18456
|
-
var acceptedWaitOutcome = (wait) =>
|
|
18560
|
+
var acceptedWaitOutcome = (wait) => Schema99.decodeUnknownEffect(exports_tool_schema.ExternalOutcome)(wait.metadata.external_outcome).pipe(Effect108.mapError(toClientError));
|
|
18457
18561
|
var resolveToolOutcomeWait = Effect108.fn("Client.resolveToolOutcomeWait")(function* (waits, eventLog, call, outcome, completedAt) {
|
|
18458
18562
|
const waitId2 = call.waitId ?? toolWaitId(call.executionId, call.call.id);
|
|
18459
18563
|
const wait = yield* waits.get(waitId2).pipe(Effect108.mapError(toClientError));
|
|
@@ -18734,7 +18838,7 @@ var replyValueFrom = (content) => {
|
|
|
18734
18838
|
const text = content.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
18735
18839
|
if (text.length === 0)
|
|
18736
18840
|
return Option30.none();
|
|
18737
|
-
return
|
|
18841
|
+
return Schema100.decodeUnknownOption(Schema100.UnknownFromJsonString)(text);
|
|
18738
18842
|
};
|
|
18739
18843
|
var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
18740
18844
|
const makeExecutionClient = yield* client;
|
|
@@ -18814,7 +18918,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18814
18918
|
status: "queued",
|
|
18815
18919
|
metadata: { operation: "envelope-send" },
|
|
18816
18920
|
createdAt
|
|
18817
|
-
}).pipe(Effect109.catchIf(
|
|
18921
|
+
}).pipe(Effect109.catchIf(Schema100.is(exports_execution_repository.DuplicateExecution), () => Effect109.void), Effect109.mapError(toClientError));
|
|
18818
18922
|
}
|
|
18819
18923
|
const maxSequence3 = yield* eventLog.maxSequence(executionId).pipe(Effect109.mapError(toClientError));
|
|
18820
18924
|
return yield* envelopes.send({
|
|
@@ -19060,7 +19164,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19060
19164
|
return records.map(toWaitView);
|
|
19061
19165
|
}),
|
|
19062
19166
|
listExecutions: Effect109.fn("Client.runtime.listExecutions")(function* (input) {
|
|
19063
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19167
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema100.decodeEffect(exports_pagination_schema.ExecutionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })));
|
|
19064
19168
|
const result = yield* executionRepository.list({
|
|
19065
19169
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
19066
19170
|
...input.status === undefined ? {} : { status: input.status },
|
|
@@ -19110,13 +19214,13 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19110
19214
|
}).pipe(Effect109.mapError(toClientError));
|
|
19111
19215
|
}),
|
|
19112
19216
|
listSessions: Effect109.fn("Client.runtime.listSessions")(function* (input) {
|
|
19113
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19217
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema100.decodeEffect(exports_pagination_schema.SessionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })));
|
|
19114
19218
|
const result = yield* sessionRepository.list({
|
|
19115
19219
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
19116
19220
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
19117
19221
|
...cursor === undefined ? {} : { cursor }
|
|
19118
19222
|
});
|
|
19119
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
19223
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema100.encodeEffect(exports_pagination_schema.SessionCursorCodec)({
|
|
19120
19224
|
id: result.nextCursor.id,
|
|
19121
19225
|
at: result.nextCursor.updatedAt
|
|
19122
19226
|
});
|
|
@@ -19129,7 +19233,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19129
19233
|
const session = yield* sessionRepository.get(input.session_id).pipe(Effect109.mapError(toClientError));
|
|
19130
19234
|
if (session === undefined)
|
|
19131
19235
|
return yield* ClientError.make({ message: `Session not found: ${input.session_id}` });
|
|
19132
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19236
|
+
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));
|
|
19133
19237
|
const result = yield* executionRepository.list({
|
|
19134
19238
|
sessionId: input.session_id,
|
|
19135
19239
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
@@ -19200,7 +19304,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19200
19304
|
if (instance === undefined || instance.status === "destroyed") {
|
|
19201
19305
|
return yield* ResidentNotFound.make({ kind: input.kind, key: input.key });
|
|
19202
19306
|
}
|
|
19203
|
-
const encoded = yield*
|
|
19307
|
+
const encoded = yield* Schema100.encodeUnknownEffect(input.command.input)(input.input).pipe(Effect109.mapError(toClientError));
|
|
19204
19308
|
const inputRef = inputSchemaRef(input.command.name);
|
|
19205
19309
|
const outputRef = outputSchemaRef(input.command.name);
|
|
19206
19310
|
if (Option30.isSome(schemaRegistry)) {
|
|
@@ -19247,7 +19351,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19247
19351
|
message: "reply carried no decodable content"
|
|
19248
19352
|
});
|
|
19249
19353
|
}
|
|
19250
|
-
return yield*
|
|
19354
|
+
return yield* Schema100.decodeUnknownEffect(input.command.output)(replyValue.value).pipe(Effect109.mapError((issue) => CommandReplyInvalid.make({
|
|
19251
19355
|
command: input.command.name,
|
|
19252
19356
|
wait_id: outcome.wait_id,
|
|
19253
19357
|
message: errorMessage2(issue)
|
|
@@ -19288,14 +19392,14 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19288
19392
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
19289
19393
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
19290
19394
|
updatedAt: input.updated_at
|
|
19291
|
-
}).pipe(Effect109.mapError((error5) =>
|
|
19395
|
+
}).pipe(Effect109.mapError((error5) => Schema100.is(StateVersionConflict3)(error5) ? StateVersionConflict.make(error5) : toClientError(error5)))),
|
|
19292
19396
|
deleteResidentState: Effect109.fn("Client.runtime.deleteResidentState")((input) => executionState.remove({
|
|
19293
19397
|
executionId: input.execution_id,
|
|
19294
19398
|
key: input.key,
|
|
19295
19399
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
19296
19400
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
19297
19401
|
removedAt: input.removed_at
|
|
19298
|
-
}).pipe(Effect109.mapError((error5) =>
|
|
19402
|
+
}).pipe(Effect109.mapError((error5) => Schema100.is(StateVersionConflict3)(error5) ? StateVersionConflict.make(error5) : toClientError(error5)))),
|
|
19299
19403
|
listResidentState: Effect109.fn("Client.runtime.listResidentState")((input) => executionState.list({
|
|
19300
19404
|
executionId: input.execution_id,
|
|
19301
19405
|
...input.prefix === undefined ? {} : { prefix: input.prefix },
|
|
@@ -19554,77 +19658,77 @@ import { Effect as Effect111 } from "effect";
|
|
|
19554
19658
|
var recoverPersistedFanOut = (recover) => recover().pipe(Effect111.mapError((error5) => WorkflowRuntimeError.make({ message: error5._tag })), Effect111.asVoid);
|
|
19555
19659
|
|
|
19556
19660
|
// src/runtime.ts
|
|
19557
|
-
var Dialect2 =
|
|
19661
|
+
var Dialect2 = Schema101.Literals(["pg", "mysql", "sqlite"]);
|
|
19558
19662
|
|
|
19559
|
-
class NotificationFailure extends
|
|
19560
|
-
reason:
|
|
19663
|
+
class NotificationFailure extends Schema101.TaggedErrorClass()("NotificationFailure", {
|
|
19664
|
+
reason: Schema101.String
|
|
19561
19665
|
}) {
|
|
19562
19666
|
}
|
|
19563
19667
|
|
|
19564
|
-
class ClusterFailure extends
|
|
19565
|
-
reason:
|
|
19668
|
+
class ClusterFailure extends Schema101.TaggedErrorClass()("ClusterFailure", {
|
|
19669
|
+
reason: Schema101.String
|
|
19566
19670
|
}) {
|
|
19567
19671
|
}
|
|
19568
19672
|
|
|
19569
|
-
class SqlFailure extends
|
|
19570
|
-
category:
|
|
19571
|
-
operation:
|
|
19572
|
-
retryable:
|
|
19673
|
+
class SqlFailure extends Schema101.TaggedErrorClass()("SqlFailure", {
|
|
19674
|
+
category: Schema101.Literals(["connection", "statement", "unknown"]),
|
|
19675
|
+
operation: Schema101.Literals(["acquire", "migrate", "verify", "notify", "readiness"]),
|
|
19676
|
+
retryable: Schema101.Boolean
|
|
19573
19677
|
}) {
|
|
19574
19678
|
}
|
|
19575
|
-
var SqlDialect =
|
|
19679
|
+
var SqlDialect = Schema101.Literals(["sqlite", "pg", "mysql", "mssql", "clickhouse"]);
|
|
19576
19680
|
|
|
19577
|
-
class DatabaseDialectMismatch extends
|
|
19681
|
+
class DatabaseDialectMismatch extends Schema101.TaggedErrorClass()("DatabaseDialectMismatch", { expected: Dialect2, actual: SqlDialect }) {
|
|
19578
19682
|
}
|
|
19579
19683
|
|
|
19580
|
-
class DatabaseAlreadyOwned extends
|
|
19684
|
+
class DatabaseAlreadyOwned extends Schema101.TaggedErrorClass()("DatabaseAlreadyOwned", {
|
|
19581
19685
|
databaseIdentity: DatabaseIdentity
|
|
19582
19686
|
}) {
|
|
19583
19687
|
}
|
|
19584
19688
|
|
|
19585
|
-
class UnsupportedTopology extends
|
|
19586
|
-
reason:
|
|
19689
|
+
class UnsupportedTopology extends Schema101.TaggedErrorClass()("UnsupportedTopology", {
|
|
19690
|
+
reason: Schema101.String
|
|
19587
19691
|
}) {
|
|
19588
19692
|
}
|
|
19589
19693
|
|
|
19590
|
-
class MigratorError extends
|
|
19591
|
-
reason:
|
|
19694
|
+
class MigratorError extends Schema101.TaggedErrorClass()("MigratorError", {
|
|
19695
|
+
reason: Schema101.String
|
|
19592
19696
|
}) {
|
|
19593
19697
|
}
|
|
19594
19698
|
|
|
19595
|
-
class SchemaHeadMismatch extends
|
|
19596
|
-
expected:
|
|
19597
|
-
actual:
|
|
19699
|
+
class SchemaHeadMismatch extends Schema101.TaggedErrorClass()("SchemaHeadMismatch", {
|
|
19700
|
+
expected: Schema101.String,
|
|
19701
|
+
actual: Schema101.String
|
|
19598
19702
|
}) {
|
|
19599
19703
|
}
|
|
19600
19704
|
|
|
19601
|
-
class HostUnavailable extends
|
|
19602
|
-
host:
|
|
19603
|
-
reason:
|
|
19705
|
+
class HostUnavailable extends Schema101.TaggedErrorClass()("HostUnavailable", {
|
|
19706
|
+
host: Schema101.String,
|
|
19707
|
+
reason: Schema101.String
|
|
19604
19708
|
}) {
|
|
19605
19709
|
}
|
|
19606
|
-
var RuntimeTopologyCause =
|
|
19710
|
+
var RuntimeTopologyCause = Schema101.Union([
|
|
19607
19711
|
ClusterFailure,
|
|
19608
19712
|
DatabaseDialectMismatch,
|
|
19609
19713
|
DatabaseAlreadyOwned,
|
|
19610
19714
|
UnsupportedTopology
|
|
19611
19715
|
]);
|
|
19612
|
-
var RuntimeMigrationCause =
|
|
19716
|
+
var RuntimeMigrationCause = Schema101.Union([
|
|
19613
19717
|
SqlFailure,
|
|
19614
19718
|
MigratorError,
|
|
19615
19719
|
SchemaHeadMismatch
|
|
19616
19720
|
]);
|
|
19617
|
-
var RuntimeReadinessCause =
|
|
19721
|
+
var RuntimeReadinessCause = Schema101.Union([
|
|
19618
19722
|
SqlFailure,
|
|
19619
19723
|
NotificationFailure,
|
|
19620
19724
|
ClusterFailure,
|
|
19621
19725
|
HostUnavailable
|
|
19622
19726
|
]);
|
|
19623
19727
|
|
|
19624
|
-
class RuntimeTopologyError extends
|
|
19728
|
+
class RuntimeTopologyError extends Schema101.TaggedErrorClass()("RuntimeTopologyError", {
|
|
19625
19729
|
dialect: Dialect2,
|
|
19626
|
-
role:
|
|
19627
|
-
nextAction:
|
|
19730
|
+
role: Schema101.Literals(["embedded", "runner", "client"]),
|
|
19731
|
+
nextAction: Schema101.Literals([
|
|
19628
19732
|
"use-embedded",
|
|
19629
19733
|
"use-postgres-or-mysql",
|
|
19630
19734
|
"use-client-constructor",
|
|
@@ -19635,39 +19739,39 @@ class RuntimeTopologyError extends Schema100.TaggedErrorClass()("RuntimeTopology
|
|
|
19635
19739
|
}) {
|
|
19636
19740
|
}
|
|
19637
19741
|
|
|
19638
|
-
class RuntimeMigrationError extends
|
|
19742
|
+
class RuntimeMigrationError extends Schema101.TaggedErrorClass()("RuntimeMigrationError", {
|
|
19639
19743
|
dialect: Dialect2,
|
|
19640
|
-
phase:
|
|
19641
|
-
nextAction:
|
|
19744
|
+
phase: Schema101.Literals(["apply", "verify"]),
|
|
19745
|
+
nextAction: Schema101.Literals(["retry", "inspect-schema", "run-compatible-release"]),
|
|
19642
19746
|
cause: RuntimeMigrationCause
|
|
19643
19747
|
}) {
|
|
19644
19748
|
}
|
|
19645
19749
|
|
|
19646
|
-
class RuntimeReadinessError extends
|
|
19647
|
-
phase:
|
|
19750
|
+
class RuntimeReadinessError extends Schema101.TaggedErrorClass()("RuntimeReadinessError", {
|
|
19751
|
+
phase: Schema101.Literals(["database", "notification", "cluster", "hosts"]),
|
|
19648
19752
|
cause: RuntimeReadinessCause
|
|
19649
19753
|
}) {
|
|
19650
19754
|
}
|
|
19651
|
-
var RuntimeCapabilityStatus =
|
|
19652
|
-
|
|
19653
|
-
enabled:
|
|
19654
|
-
source:
|
|
19655
|
-
health:
|
|
19755
|
+
var RuntimeCapabilityStatus = Schema101.Union([
|
|
19756
|
+
Schema101.Struct({
|
|
19757
|
+
enabled: Schema101.Literal(false),
|
|
19758
|
+
source: Schema101.Literals(["local-host", "role-unavailable"]),
|
|
19759
|
+
health: Schema101.Literal("not-applicable")
|
|
19656
19760
|
}),
|
|
19657
|
-
|
|
19658
|
-
enabled:
|
|
19659
|
-
source:
|
|
19660
|
-
health:
|
|
19761
|
+
Schema101.Struct({
|
|
19762
|
+
enabled: Schema101.Literal(true),
|
|
19763
|
+
source: Schema101.Literal("local-host"),
|
|
19764
|
+
health: Schema101.Literals(["healthy", "unhealthy"])
|
|
19661
19765
|
})
|
|
19662
19766
|
]);
|
|
19663
|
-
var ReadinessStatus2 =
|
|
19664
|
-
ready:
|
|
19665
|
-
role:
|
|
19767
|
+
var ReadinessStatus2 = Schema101.Struct({
|
|
19768
|
+
ready: Schema101.Literal(true),
|
|
19769
|
+
role: Schema101.Literals(["embedded", "runner", "client"]),
|
|
19666
19770
|
dialect: Dialect2,
|
|
19667
19771
|
databaseIdentity: DatabaseIdentity,
|
|
19668
|
-
schemaHead:
|
|
19669
|
-
notification:
|
|
19670
|
-
capabilities:
|
|
19772
|
+
schemaHead: Schema101.String,
|
|
19773
|
+
notification: Schema101.Literals(["pg-listen-notify", "polling", "in-process"]),
|
|
19774
|
+
capabilities: Schema101.Struct({
|
|
19671
19775
|
fanOut: RuntimeCapabilityStatus,
|
|
19672
19776
|
workflowDefinition: RuntimeCapabilityStatus
|
|
19673
19777
|
})
|
|
@@ -19681,7 +19785,7 @@ var normalizeHost = (layer65, _role, _dialect) => layer65.pipe(Layer86.catchCaus
|
|
|
19681
19785
|
role: _role,
|
|
19682
19786
|
nextAction: _role === "embedded" ? "use-embedded" : "use-different-database",
|
|
19683
19787
|
cause: ClusterFailure.make({ reason: "cluster configuration is incompatible" })
|
|
19684
|
-
}) : error5), "host-layer", (error5) =>
|
|
19788
|
+
}) : error5), "host-layer", (error5) => Schema101.is(RuntimeConfigurationError)(error5) || Schema101.is(RuntimeTopologyError)(error5) || Schema101.is(RuntimeMigrationError)(error5))))));
|
|
19685
19789
|
var actualDialect = (sql) => sql.onDialectOrElse({
|
|
19686
19790
|
sqlite: () => "sqlite",
|
|
19687
19791
|
pg: () => "pg",
|