@relayfx/sdk 0.7.3 → 0.7.5
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-5y7758mg.js → index-6rpm95kc.js} +601 -206
- package/dist/{index-qa93yf6j.js → index-etc2cnk2.js} +47 -47
- package/dist/{index-pa991hq0.js → index-m8bs31hg.js} +1 -1
- package/dist/{index-syx9q5v3.js → index-nb078xsy.js} +831 -592
- package/dist/index.js +11 -11
- package/dist/mysql.js +4 -4
- package/dist/postgres.js +4 -4
- package/dist/sqlite.js +4 -4
- package/dist/types/relay/client-child-runs.d.ts +11 -0
- package/dist/types/relay/client-public-executions.d.ts +2 -2
- package/dist/types/relay/client-public.d.ts +2 -0
- package/dist/types/relay/operation.d.ts +282 -5
- package/dist/types/runtime/address/address-resolution-service.d.ts +1 -1
- package/dist/types/runtime/agent/agent-loop-events.d.ts +16 -5
- package/dist/types/runtime/agent/agent-loop-service.d.ts +1 -0
- package/dist/types/runtime/child/spawn-child-run-tool.d.ts +2 -0
- package/dist/types/runtime/workflow/execution-workflow.d.ts +22 -2
- package/dist/types/schema/agent-schema.d.ts +8 -8
- package/dist/types/schema/execution-analytics-schema.d.ts +507 -0
- package/dist/types/schema/execution-schema.d.ts +34 -20
- package/dist/types/store-sql/child/child-fan-out-repository.d.ts +2 -0
- package/dist/types/store-sql/prompt-wire.d.ts +2 -0
- package/package.json +4 -4
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
exports_tool_executor,
|
|
18
18
|
exports_tool_output,
|
|
19
19
|
exports_turn_policy
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-etc2cnk2.js";
|
|
21
21
|
import {
|
|
22
22
|
ClientError,
|
|
23
23
|
EventLogCursorNotFound,
|
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
exports_workflow_schema,
|
|
48
48
|
exports_workspace_schema,
|
|
49
49
|
followExecutionFrom
|
|
50
|
-
} from "./index-
|
|
50
|
+
} from "./index-nb078xsy.js";
|
|
51
51
|
import {
|
|
52
52
|
__export
|
|
53
53
|
} from "./index-nb39b5ae.js";
|
|
@@ -1066,6 +1066,16 @@ var encodePrompt = (prompt) => {
|
|
|
1066
1066
|
content: encoded.content.map((message, messageIndex) => encodeMessage(prompt, message, messageIndex))
|
|
1067
1067
|
});
|
|
1068
1068
|
};
|
|
1069
|
+
var encodePromptMessage = (message) => {
|
|
1070
|
+
const encoded = encodePrompt(Prompt2.fromMessages([message]));
|
|
1071
|
+
if (typeof encoded !== "object" || encoded === null || !("content" in encoded) || !Array.isArray(encoded.content)) {
|
|
1072
|
+
throw new TypeError("Encoded prompt did not contain a message");
|
|
1073
|
+
}
|
|
1074
|
+
const value = encoded.content[0];
|
|
1075
|
+
if (value === undefined)
|
|
1076
|
+
throw new TypeError("Encoded prompt did not contain a message");
|
|
1077
|
+
return value;
|
|
1078
|
+
};
|
|
1069
1079
|
var decodePrompt = (value) => {
|
|
1070
1080
|
const content = typeof value === "object" && value !== null && !Array.isArray(value) && "content" in value ? value.content : undefined;
|
|
1071
1081
|
const decodedContent = Array.isArray(content) ? content.map((message) => {
|
|
@@ -1078,6 +1088,8 @@ var decodePrompt = (value) => {
|
|
|
1078
1088
|
if (typeof part !== "object" || part === null || Array.isArray(part) || part.type !== "file") {
|
|
1079
1089
|
return part;
|
|
1080
1090
|
}
|
|
1091
|
+
if (typeof part.data === "string")
|
|
1092
|
+
return part;
|
|
1081
1093
|
const data = Schema14.decodeUnknownSync(FileDataWire)(part.data);
|
|
1082
1094
|
return {
|
|
1083
1095
|
...part,
|
|
@@ -1088,6 +1100,12 @@ var decodePrompt = (value) => {
|
|
|
1088
1100
|
}) : content;
|
|
1089
1101
|
return Schema14.decodeUnknownSync(Prompt2.Prompt)({ content: decodedContent });
|
|
1090
1102
|
};
|
|
1103
|
+
var decodePromptMessage = (value) => {
|
|
1104
|
+
const message = decodePrompt({ content: [value] }).content[0];
|
|
1105
|
+
if (message === undefined)
|
|
1106
|
+
throw new TypeError("Decoded prompt did not contain a message");
|
|
1107
|
+
return message;
|
|
1108
|
+
};
|
|
1091
1109
|
|
|
1092
1110
|
// ../store-sql/src/chat/agent-chat-repository.ts
|
|
1093
1111
|
class AgentChatRepositoryError extends Schema15.TaggedErrorClass()("AgentChatRepositoryError", {
|
|
@@ -1685,6 +1703,7 @@ __export(exports_child_fan_out_repository, {
|
|
|
1685
1703
|
recordTerminal: () => recordTerminal,
|
|
1686
1704
|
memoryLayer: () => memoryLayer10,
|
|
1687
1705
|
listNonTerminal: () => listNonTerminal,
|
|
1706
|
+
listByParent: () => listByParent,
|
|
1688
1707
|
layer: () => layer12,
|
|
1689
1708
|
get: () => get4,
|
|
1690
1709
|
create: () => create2,
|
|
@@ -1885,7 +1904,18 @@ var layer12 = Layer16.effect(Service18, Effect17.gen(function* () {
|
|
|
1885
1904
|
}
|
|
1886
1905
|
return states;
|
|
1887
1906
|
});
|
|
1888
|
-
|
|
1907
|
+
const listByParent = Effect17.fn("ChildFanOutRepository.listByParent")(function* (parentExecutionId) {
|
|
1908
|
+
const tenantId = yield* current();
|
|
1909
|
+
const rows = yield* sql`SELECT id FROM relay_child_fan_outs WHERE tenant_id = ${tenantId} AND parent_execution_id = ${parentExecutionId} ORDER BY created_at ASC, id ASC`.pipe(Effect17.mapError(repositoryError));
|
|
1910
|
+
const states = [];
|
|
1911
|
+
for (const row of rows) {
|
|
1912
|
+
const state = yield* load(tenantId, exports_ids_schema.ChildFanOutId.make(String(row.id))).pipe(Effect17.mapError(repositoryError));
|
|
1913
|
+
if (state !== undefined)
|
|
1914
|
+
states.push(state);
|
|
1915
|
+
}
|
|
1916
|
+
return states;
|
|
1917
|
+
});
|
|
1918
|
+
return Service18.of({ create: create2, get: get4, claimAdmissions, recordTerminal, cancel, listNonTerminal, listByParent });
|
|
1889
1919
|
}));
|
|
1890
1920
|
var memoryLayer10 = Layer16.effect(Service18, Effect17.gen(function* () {
|
|
1891
1921
|
const records = new Map;
|
|
@@ -1978,7 +2008,8 @@ var memoryLayer10 = Layer16.effect(Service18, Effect17.gen(function* () {
|
|
|
1978
2008
|
return { fanOut: globalThis.structuredClone(fanOut), transitioned, activeChildExecutionIds };
|
|
1979
2009
|
})));
|
|
1980
2010
|
const listNonTerminal = Effect17.fn("ChildFanOutRepository.memory.listNonTerminal")((parentExecutionId) => Effect17.sync(() => [...records.values()].filter((state) => state.state === "joining" && (parentExecutionId === undefined || state.parent_execution_id === parentExecutionId)).toSorted((left, right) => left.created_at - right.created_at || left.fan_out_id.localeCompare(right.fan_out_id)).map((state) => globalThis.structuredClone(state))));
|
|
1981
|
-
|
|
2011
|
+
const listByParent = Effect17.fn("ChildFanOutRepository.memory.listByParent")((parentExecutionId) => Effect17.sync(() => [...records.values()].filter((state) => state.parent_execution_id === parentExecutionId).toSorted((left, right) => left.created_at - right.created_at || left.fan_out_id.localeCompare(right.fan_out_id)).map((state) => globalThis.structuredClone(state))));
|
|
2012
|
+
return Service18.of({ create: create2, get: get4, claimAdmissions, recordTerminal, cancel, listNonTerminal, listByParent });
|
|
1982
2013
|
}));
|
|
1983
2014
|
var create2 = Effect17.fn("ChildFanOutRepository.create.call")(function* (definition) {
|
|
1984
2015
|
const repository = yield* Service18;
|
|
@@ -2004,6 +2035,10 @@ var listNonTerminal = Effect17.fn("ChildFanOutRepository.listNonTerminal.call")(
|
|
|
2004
2035
|
const repository = yield* Service18;
|
|
2005
2036
|
return yield* repository.listNonTerminal(parentExecutionId);
|
|
2006
2037
|
});
|
|
2038
|
+
var listByParent = Effect17.fn("ChildFanOutRepository.listByParent.call")(function* (parentExecutionId) {
|
|
2039
|
+
const repository = yield* Service18;
|
|
2040
|
+
return yield* repository.listByParent(parentExecutionId);
|
|
2041
|
+
});
|
|
2007
2042
|
// ../store-sql/src/cluster/cluster-registry-repository.ts
|
|
2008
2043
|
var exports_cluster_registry_repository = {};
|
|
2009
2044
|
__export(exports_cluster_registry_repository, {
|
|
@@ -6376,7 +6411,7 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6376
6411
|
switch (input._tag) {
|
|
6377
6412
|
case "Message":
|
|
6378
6413
|
return {
|
|
6379
|
-
message: input.message,
|
|
6414
|
+
message: encodePromptMessage(input.message),
|
|
6380
6415
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
6381
6416
|
};
|
|
6382
6417
|
case "ToolCall":
|
|
@@ -6402,7 +6437,7 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6402
6437
|
};
|
|
6403
6438
|
case "Steering":
|
|
6404
6439
|
return {
|
|
6405
|
-
message: input.message,
|
|
6440
|
+
message: encodePromptMessage(input.message),
|
|
6406
6441
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
6407
6442
|
};
|
|
6408
6443
|
case "Handoff":
|
|
@@ -6442,10 +6477,13 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6442
6477
|
};
|
|
6443
6478
|
switch (row.tag) {
|
|
6444
6479
|
case "Message":
|
|
6445
|
-
return Effect39.
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6480
|
+
return Effect39.try({
|
|
6481
|
+
try: () => ({
|
|
6482
|
+
...base,
|
|
6483
|
+
_tag: "Message",
|
|
6484
|
+
message: decodePromptMessage(payload.message)
|
|
6485
|
+
}),
|
|
6486
|
+
catch: (error5) => SessionRepositoryError.make({ message: `Invalid Session message: ${String(error5)}` })
|
|
6449
6487
|
});
|
|
6450
6488
|
case "ToolCall":
|
|
6451
6489
|
return Effect39.succeed({
|
|
@@ -6473,10 +6511,13 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6473
6511
|
body: String(payload.body ?? "")
|
|
6474
6512
|
});
|
|
6475
6513
|
case "Steering":
|
|
6476
|
-
return Effect39.
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6514
|
+
return Effect39.try({
|
|
6515
|
+
try: () => ({
|
|
6516
|
+
...base,
|
|
6517
|
+
_tag: "Steering",
|
|
6518
|
+
message: decodePromptMessage(payload.message)
|
|
6519
|
+
}),
|
|
6520
|
+
catch: (error5) => SessionRepositoryError.make({ message: `Invalid Session steering message: ${String(error5)}` })
|
|
6480
6521
|
});
|
|
6481
6522
|
case "Handoff":
|
|
6482
6523
|
return Effect39.succeed({
|
|
@@ -6880,6 +6921,9 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6880
6921
|
});
|
|
6881
6922
|
const appendCheckpoint = Effect40.fn("SessionRepository.appendCheckpoint")(function* (input) {
|
|
6882
6923
|
const tenantId = yield* current();
|
|
6924
|
+
if (input.compactionCommit !== undefined && input.compactionCommit.checkpointId !== input.id) {
|
|
6925
|
+
return yield* conflict4("checkpoint-id-reused", "Compaction commit checkpoint does not match entry");
|
|
6926
|
+
}
|
|
6883
6927
|
return yield* mapRepositoryError(sql.withTransaction(Effect40.gen(function* () {
|
|
6884
6928
|
yield* lockSession(tenantId, input.sessionId);
|
|
6885
6929
|
const session = yield* requireSession(tenantId, input.sessionId);
|
|
@@ -7157,6 +7201,9 @@ var memoryLayer26 = Layer35.sync(Service35, () => {
|
|
|
7157
7201
|
return cloneEntry(desired);
|
|
7158
7202
|
}),
|
|
7159
7203
|
appendCheckpoint: Effect41.fn("SessionRepository.memory.appendCheckpoint")(function* (input) {
|
|
7204
|
+
if (input.compactionCommit !== undefined && input.compactionCommit.checkpointId !== input.id) {
|
|
7205
|
+
return yield* conflict4("checkpoint-id-reused", "Compaction commit checkpoint does not match entry");
|
|
7206
|
+
}
|
|
7160
7207
|
const session = sessions.get(input.sessionId);
|
|
7161
7208
|
if (session === undefined)
|
|
7162
7209
|
return yield* missingSession(input.sessionId);
|
|
@@ -11655,7 +11702,7 @@ var listRevisions3 = Effect61.fn("AgentRegistry.listRevisions.call")(function* (
|
|
|
11655
11702
|
});
|
|
11656
11703
|
|
|
11657
11704
|
// ../runtime/src/agent/agent-loop-service.ts
|
|
11658
|
-
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";
|
|
11705
|
+
import { Cause as Cause2, Clock as Clock17, 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";
|
|
11659
11706
|
import { AiError as AiError3, Chat, LanguageModel, Prompt as Prompt7, Tokenizer, Tool as AiTool2, Toolkit as Toolkit2 } from "effect/unstable/ai";
|
|
11660
11707
|
|
|
11661
11708
|
// ../runtime/src/child/child-run-service.ts
|
|
@@ -11977,6 +12024,7 @@ var childDefinition = Function12.dual(2, (parentDefinition, context) => context.
|
|
|
11977
12024
|
child_run_presets: {},
|
|
11978
12025
|
...context.compactionPolicy === undefined ? {} : { compaction_policy: context.compactionPolicy },
|
|
11979
12026
|
...parentDefinition.turn_policy === undefined ? {} : { turn_policy: parentDefinition.turn_policy },
|
|
12027
|
+
...parentDefinition.tool_execution === undefined ? {} : { tool_execution: parentDefinition.tool_execution },
|
|
11980
12028
|
...parentDefinition.max_tool_turns === undefined ? {} : { max_tool_turns: parentDefinition.max_tool_turns },
|
|
11981
12029
|
...parentDefinition.max_wait_turns === undefined ? {} : { max_wait_turns: parentDefinition.max_wait_turns },
|
|
11982
12030
|
...parentDefinition.token_budget === undefined ? {} : { token_budget: parentDefinition.token_budget },
|
|
@@ -12143,6 +12191,7 @@ var createJoinWait = Effect64.fn("SpawnChildRunTool.createJoinWait")(function* (
|
|
|
12143
12191
|
var dispatchChild = Effect64.fn("SpawnChildRunTool.dispatchChild")(function* (config, input, id, definition, waitId2) {
|
|
12144
12192
|
yield* config.dispatch({
|
|
12145
12193
|
executionId: exports_ids_schema.ExecutionId.make(id),
|
|
12194
|
+
...config.origin === undefined ? {} : { origin: config.origin },
|
|
12146
12195
|
rootAddressId: input.address_id,
|
|
12147
12196
|
sessionId: exports_execution_schema.childSessionId(id),
|
|
12148
12197
|
input: input.input ?? [],
|
|
@@ -12156,7 +12205,9 @@ var dispatchChild = Effect64.fn("SpawnChildRunTool.dispatchChild")(function* (co
|
|
|
12156
12205
|
metadata: {
|
|
12157
12206
|
parent_execution_id: input.execution_id,
|
|
12158
12207
|
child_execution_id: id,
|
|
12159
|
-
parent_wait_id: waitId2
|
|
12208
|
+
parent_wait_id: waitId2,
|
|
12209
|
+
child_purpose: "child-run",
|
|
12210
|
+
...input.preset_name === undefined ? {} : { child_profile: input.preset_name }
|
|
12160
12211
|
}
|
|
12161
12212
|
}).pipe(Effect64.mapError((error5) => ToolRuntimeError.make({ message: String(error5) })));
|
|
12162
12213
|
});
|
|
@@ -13530,14 +13581,20 @@ var cancelledEvent = (input) => ({
|
|
|
13530
13581
|
created_at: input.cancelledAt
|
|
13531
13582
|
});
|
|
13532
13583
|
var updateStatus2 = Effect74.fn("ExecutionService.updateStatus")(function* (repository, id, status, updatedAt, metadata11) {
|
|
13584
|
+
const current2 = yield* repository.get(id);
|
|
13585
|
+
const origin = current2?.metadata[exports_execution_schema.executionOriginMetadataKey];
|
|
13586
|
+
const nextMetadata = metadata11 === undefined ? undefined : {
|
|
13587
|
+
...metadata11,
|
|
13588
|
+
...origin === undefined ? {} : { [exports_execution_schema.executionOriginMetadataKey]: origin }
|
|
13589
|
+
};
|
|
13533
13590
|
const record2 = yield* repository.transition({
|
|
13534
13591
|
id,
|
|
13535
13592
|
status,
|
|
13536
13593
|
updatedAt,
|
|
13537
|
-
...
|
|
13538
|
-
})
|
|
13594
|
+
...nextMetadata === undefined ? {} : { metadata: nextMetadata }
|
|
13595
|
+
});
|
|
13539
13596
|
return toExecution(record2);
|
|
13540
|
-
});
|
|
13597
|
+
}, Effect74.mapError(mapRepositoryError7));
|
|
13541
13598
|
var layer46 = Layer61.effect(Service56, Effect74.gen(function* () {
|
|
13542
13599
|
const repository = yield* exports_execution_repository.Service;
|
|
13543
13600
|
const eventLog = yield* Service41;
|
|
@@ -14124,6 +14181,7 @@ var StartInput = Schema74.Struct({
|
|
|
14124
14181
|
wait_id: Schema74.optionalKey(exports_ids_schema.WaitId),
|
|
14125
14182
|
resume_suspension: Schema74.optionalKey(exports_agent_event.AgentSuspended),
|
|
14126
14183
|
workflow_generation: Schema74.optionalKey(Schema74.Int.check(Schema74.isGreaterThanOrEqualTo(0))),
|
|
14184
|
+
origin: Schema74.optionalKey(exports_execution_schema.ExecutionOrigin),
|
|
14127
14185
|
metadata: Schema74.optionalKey(exports_shared_schema.Metadata)
|
|
14128
14186
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.StartInput" });
|
|
14129
14187
|
var WaitSignalState = Schema74.Literals(["resolved", "timed_out", "cancelled"]).annotate({
|
|
@@ -14277,7 +14335,12 @@ var acceptExecution = (input) => Activity.make({
|
|
|
14277
14335
|
...input.agent_revision === undefined ? {} : { agentRevision: input.agent_revision },
|
|
14278
14336
|
...input.agent_snapshot === undefined ? {} : { agentSnapshot: input.agent_snapshot },
|
|
14279
14337
|
...input.agent_tool_input_schema_digests === undefined ? {} : { agentToolInputSchemaDigests: input.agent_tool_input_schema_digests },
|
|
14280
|
-
...input.metadata === undefined ? {} : {
|
|
14338
|
+
...input.metadata === undefined && input.origin === undefined ? {} : {
|
|
14339
|
+
metadata: {
|
|
14340
|
+
...Object.fromEntries(Object.entries(input.metadata ?? {}).filter(([key4]) => key4 !== exports_execution_schema.executionOriginMetadataKey)),
|
|
14341
|
+
...input.origin === undefined ? {} : { [exports_execution_schema.executionOriginMetadataKey]: input.origin }
|
|
14342
|
+
}
|
|
14343
|
+
}
|
|
14281
14344
|
}).pipe(Effect79.mapError(mapExecutionError));
|
|
14282
14345
|
const skillDefinitionIds = input.agent_snapshot?.skill_definition_ids ?? [];
|
|
14283
14346
|
if (skillDefinitionIds.length > 0) {
|
|
@@ -14565,6 +14628,7 @@ var completeExecution = (input, waitId2, waitState, workspaceRuntimeLayer, turn,
|
|
|
14565
14628
|
const skillDefinitionIds = input.agent_snapshot.skill_definition_ids ?? [];
|
|
14566
14629
|
const loopProgram = agentLoop.run({
|
|
14567
14630
|
executionId: input.execution_id,
|
|
14631
|
+
...input.origin === undefined ? {} : { origin: input.origin },
|
|
14568
14632
|
...input.session_id === undefined ? {} : {
|
|
14569
14633
|
sessionId: input.session_id,
|
|
14570
14634
|
sessionEntryScope: sessionEntryScope(input, turn)
|
|
@@ -14593,6 +14657,7 @@ var completeExecution = (input, waitId2, waitState, workspaceRuntimeLayer, turn,
|
|
|
14593
14657
|
agent_revision: child.agentRevision,
|
|
14594
14658
|
agent_snapshot: child.agentSnapshot,
|
|
14595
14659
|
...child.agentToolInputSchemaDigests === undefined ? {} : { agent_tool_input_schema_digests: child.agentToolInputSchemaDigests },
|
|
14660
|
+
...child.origin === undefined ? {} : { origin: child.origin },
|
|
14596
14661
|
metadata: child.metadata
|
|
14597
14662
|
}, { discard: true }).pipe(Effect79.provideService(WorkflowEngine.WorkflowEngine, workflowEngine), Effect79.asVoid)
|
|
14598
14663
|
});
|
|
@@ -15987,12 +16052,169 @@ var modelMetadata = (agent) => ({
|
|
|
15987
16052
|
model: agent.model.model,
|
|
15988
16053
|
...agent.model.registration_key === undefined ? {} : { registration_key: agent.model.registration_key }
|
|
15989
16054
|
});
|
|
15990
|
-
var
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
|
|
15995
|
-
|
|
16055
|
+
var usage = (value) => ({
|
|
16056
|
+
input_tokens: value.inputTokens.total ?? null,
|
|
16057
|
+
input_tokens_uncached: value.inputTokens.uncached ?? null,
|
|
16058
|
+
input_tokens_cache_read: value.inputTokens.cacheRead ?? null,
|
|
16059
|
+
input_tokens_cache_write: value.inputTokens.cacheWrite ?? null,
|
|
16060
|
+
output_tokens: value.outputTokens.total ?? null,
|
|
16061
|
+
output_tokens_reasoning: value.outputTokens.reasoning ?? null,
|
|
16062
|
+
output_tokens_text: value.outputTokens.text ?? null
|
|
16063
|
+
});
|
|
16064
|
+
var legacyTelemetryIdentity = (event) => {
|
|
16065
|
+
switch (event._tag) {
|
|
16066
|
+
case "ModelAttemptStarted":
|
|
16067
|
+
case "ModelAttemptCompleted":
|
|
16068
|
+
case "ModelAttemptFailed":
|
|
16069
|
+
return event.modelAttemptId;
|
|
16070
|
+
case "ModelAttemptFirstOutput":
|
|
16071
|
+
return `${event.modelAttemptId}:${event.kind}`;
|
|
16072
|
+
case "ModelRetryScheduled":
|
|
16073
|
+
return `${event.modelCallId}:${event.attempt}`;
|
|
16074
|
+
case "CompactionStarted":
|
|
16075
|
+
case "CompactionCompleted":
|
|
16076
|
+
case "CompactionFailed":
|
|
16077
|
+
return event.compactionId;
|
|
16078
|
+
default:
|
|
16079
|
+
return event.modelCallId;
|
|
16080
|
+
}
|
|
16081
|
+
};
|
|
16082
|
+
var legacyTelemetryCursor = (input, event) => `${input.executionId}:telemetry:${event._tag}:${legacyTelemetryIdentity(event)}`;
|
|
16083
|
+
var legacyUsageCursor = (input, event) => `${input.executionId}:model-usage:${event.modelCallId}:${event.modelAttemptId}`;
|
|
16084
|
+
var telemetryEvent = (input, sessionId, event, sequence, createdAt) => {
|
|
16085
|
+
const type = {
|
|
16086
|
+
ModelCallStarted: "model.call.started",
|
|
16087
|
+
ModelAttemptStarted: "model.attempt.started",
|
|
16088
|
+
ModelAttemptFirstOutput: "model.attempt.first_output",
|
|
16089
|
+
ModelAttemptCompleted: "model.attempt.completed",
|
|
16090
|
+
ModelAttemptFailed: "model.attempt.failed",
|
|
16091
|
+
ModelRetryScheduled: "model.retry.scheduled",
|
|
16092
|
+
ModelCallCompleted: "model.call.completed",
|
|
16093
|
+
ModelCallFailed: "model.call.failed",
|
|
16094
|
+
CompactionStarted: "agent.compaction.started",
|
|
16095
|
+
CompactionCompleted: "agent.compaction.completed",
|
|
16096
|
+
CompactionFailed: "agent.compaction.failed"
|
|
16097
|
+
}[event._tag];
|
|
16098
|
+
const common = "modelCallId" in event ? {
|
|
16099
|
+
turn: event.turn,
|
|
16100
|
+
model_call_id: event.modelCallId,
|
|
16101
|
+
telemetry_session_id: sessionId,
|
|
16102
|
+
delivery_id: event.deliveryId
|
|
16103
|
+
} : {
|
|
16104
|
+
turn: event.turn,
|
|
16105
|
+
compaction_id: event.compactionId,
|
|
16106
|
+
telemetry_session_id: sessionId,
|
|
16107
|
+
delivery_id: event.deliveryId
|
|
16108
|
+
};
|
|
16109
|
+
let data;
|
|
16110
|
+
switch (event._tag) {
|
|
16111
|
+
case "ModelCallStarted":
|
|
16112
|
+
data = {
|
|
16113
|
+
...common,
|
|
16114
|
+
purpose: event.purpose,
|
|
16115
|
+
started_at: event.startedAt,
|
|
16116
|
+
...event.provider === undefined ? {} : { provider: event.provider },
|
|
16117
|
+
...event.model === undefined ? {} : { model: event.model },
|
|
16118
|
+
...event.compactionId === undefined ? {} : { compaction_id: event.compactionId }
|
|
16119
|
+
};
|
|
16120
|
+
break;
|
|
16121
|
+
case "ModelAttemptStarted":
|
|
16122
|
+
data = { ...common, model_attempt_id: event.modelAttemptId, attempt: event.attempt, started_at: event.startedAt };
|
|
16123
|
+
break;
|
|
16124
|
+
case "ModelAttemptFirstOutput":
|
|
16125
|
+
data = {
|
|
16126
|
+
...common,
|
|
16127
|
+
model_attempt_id: event.modelAttemptId,
|
|
16128
|
+
attempt: event.attempt,
|
|
16129
|
+
kind: event.kind,
|
|
16130
|
+
at: event.at
|
|
16131
|
+
};
|
|
16132
|
+
break;
|
|
16133
|
+
case "ModelAttemptCompleted":
|
|
16134
|
+
data = {
|
|
16135
|
+
...common,
|
|
16136
|
+
model_attempt_id: event.modelAttemptId,
|
|
16137
|
+
attempt: event.attempt,
|
|
16138
|
+
completed_at: event.completedAt,
|
|
16139
|
+
...event.usage === undefined ? {} : { usage: usage(event.usage) },
|
|
16140
|
+
...event.usageAt === undefined ? {} : { usage_at: event.usageAt },
|
|
16141
|
+
...event.finishReason === undefined ? {} : { finish_reason: event.finishReason },
|
|
16142
|
+
...event.requestId === undefined ? {} : { request_id: event.requestId },
|
|
16143
|
+
...event.responseModel === undefined ? {} : { response_model: event.responseModel },
|
|
16144
|
+
...event.serviceTier === undefined ? {} : { service_tier: event.serviceTier },
|
|
16145
|
+
...event.cost === undefined ? {} : { cost: event.cost }
|
|
16146
|
+
};
|
|
16147
|
+
break;
|
|
16148
|
+
case "ModelAttemptFailed":
|
|
16149
|
+
data = {
|
|
16150
|
+
...common,
|
|
16151
|
+
model_attempt_id: event.modelAttemptId,
|
|
16152
|
+
attempt: event.attempt,
|
|
16153
|
+
failed_at: event.failedAt,
|
|
16154
|
+
category: event.category,
|
|
16155
|
+
classification: event.classification
|
|
16156
|
+
};
|
|
16157
|
+
break;
|
|
16158
|
+
case "ModelRetryScheduled":
|
|
16159
|
+
data = {
|
|
16160
|
+
...common,
|
|
16161
|
+
attempt: event.attempt,
|
|
16162
|
+
reason: event.reason,
|
|
16163
|
+
category: event.category,
|
|
16164
|
+
delay_millis: event.delayMillis,
|
|
16165
|
+
at: event.at
|
|
16166
|
+
};
|
|
16167
|
+
break;
|
|
16168
|
+
case "ModelCallCompleted":
|
|
16169
|
+
data = {
|
|
16170
|
+
...common,
|
|
16171
|
+
purpose: event.purpose,
|
|
16172
|
+
attempts: event.attempts,
|
|
16173
|
+
completed_at: event.completedAt,
|
|
16174
|
+
...event.usage === undefined ? {} : { usage: usage(event.usage) },
|
|
16175
|
+
...event.finishReason === undefined ? {} : { finish_reason: event.finishReason }
|
|
16176
|
+
};
|
|
16177
|
+
break;
|
|
16178
|
+
case "ModelCallFailed":
|
|
16179
|
+
data = {
|
|
16180
|
+
...common,
|
|
16181
|
+
purpose: event.purpose,
|
|
16182
|
+
attempts: event.attempts,
|
|
16183
|
+
failed_at: event.failedAt,
|
|
16184
|
+
category: event.category
|
|
16185
|
+
};
|
|
16186
|
+
break;
|
|
16187
|
+
case "CompactionStarted":
|
|
16188
|
+
data = {
|
|
16189
|
+
...common,
|
|
16190
|
+
trigger: event.trigger,
|
|
16191
|
+
started_at: event.startedAt,
|
|
16192
|
+
...event.contextTokensBefore === undefined ? {} : { context_tokens_before: event.contextTokensBefore },
|
|
16193
|
+
...event.entriesBefore === undefined ? {} : { entries_before: event.entriesBefore }
|
|
16194
|
+
};
|
|
16195
|
+
break;
|
|
16196
|
+
case "CompactionCompleted":
|
|
16197
|
+
data = {
|
|
16198
|
+
...common,
|
|
16199
|
+
kind: event.kind,
|
|
16200
|
+
completed_at: event.completedAt,
|
|
16201
|
+
...event.summaryModelCallId === undefined ? {} : { summary_model_call_id: event.summaryModelCallId }
|
|
16202
|
+
};
|
|
16203
|
+
break;
|
|
16204
|
+
case "CompactionFailed":
|
|
16205
|
+
data = { ...common, failed_at: event.failedAt };
|
|
16206
|
+
break;
|
|
16207
|
+
}
|
|
16208
|
+
const cursor = `${input.executionId}:telemetry:${sessionId}:${event.deliveryId}`;
|
|
16209
|
+
return {
|
|
16210
|
+
id: exports_ids_schema.EventId.make(`event:${cursor}`),
|
|
16211
|
+
execution_id: input.executionId,
|
|
16212
|
+
type,
|
|
16213
|
+
sequence,
|
|
16214
|
+
cursor,
|
|
16215
|
+
data,
|
|
16216
|
+
created_at: createdAt
|
|
16217
|
+
};
|
|
15996
16218
|
};
|
|
15997
16219
|
var inputPreparedEvent = (input, definitions2) => ({
|
|
15998
16220
|
id: exports_ids_schema.EventId.make(`event:${input.executionId}:model:${input.eventSequence}:input-prepared`),
|
|
@@ -16009,28 +16231,31 @@ var inputPreparedEvent = (input, definitions2) => ({
|
|
|
16009
16231
|
},
|
|
16010
16232
|
created_at: input.startedAt
|
|
16011
16233
|
});
|
|
16012
|
-
var usageReportedEvent = (input,
|
|
16013
|
-
const
|
|
16234
|
+
var usageReportedEvent = (input, sessionId, event, sequence, createdAt) => {
|
|
16235
|
+
const cursor = `${input.executionId}:model-usage:${sessionId}:${event.deliveryId}`;
|
|
16236
|
+
const reported = event.usage;
|
|
16014
16237
|
return {
|
|
16015
|
-
id: exports_ids_schema.EventId.make(`event:${
|
|
16238
|
+
id: exports_ids_schema.EventId.make(`event:${cursor}`),
|
|
16016
16239
|
execution_id: input.executionId,
|
|
16017
16240
|
type: "model.usage.reported",
|
|
16018
16241
|
sequence,
|
|
16019
|
-
cursor
|
|
16242
|
+
cursor,
|
|
16020
16243
|
data: {
|
|
16244
|
+
turn: event.turn,
|
|
16245
|
+
model_call_id: event.modelCallId,
|
|
16246
|
+
model_attempt_id: event.modelAttemptId,
|
|
16247
|
+
attempt: event.attempt,
|
|
16248
|
+
telemetry_session_id: sessionId,
|
|
16249
|
+
delivery_id: event.deliveryId,
|
|
16021
16250
|
provider: input.agent.model.provider,
|
|
16022
16251
|
model: input.agent.model.model,
|
|
16023
|
-
...
|
|
16024
|
-
...
|
|
16025
|
-
finish_reason:
|
|
16026
|
-
|
|
16027
|
-
|
|
16028
|
-
input_tokens_cache_read: part.usage.inputTokens.cacheRead ?? null,
|
|
16029
|
-
input_tokens_cache_write: part.usage.inputTokens.cacheWrite ?? null,
|
|
16030
|
-
output_tokens: part.usage.outputTokens.total ?? null,
|
|
16031
|
-
output_tokens_reasoning: part.usage.outputTokens.reasoning ?? null
|
|
16252
|
+
...event.responseModel === undefined ? {} : { model_snapshot: event.responseModel },
|
|
16253
|
+
...event.serviceTier === undefined ? {} : { service_tier: event.serviceTier },
|
|
16254
|
+
...event.finishReason === undefined ? {} : { finish_reason: event.finishReason },
|
|
16255
|
+
usage_at: event.usageAt ?? event.completedAt,
|
|
16256
|
+
...usage(reported)
|
|
16032
16257
|
},
|
|
16033
|
-
created_at:
|
|
16258
|
+
created_at: createdAt
|
|
16034
16259
|
};
|
|
16035
16260
|
};
|
|
16036
16261
|
var budgetExceededEvent = (input, tokensUsed, tokenBudget, sequence) => ({
|
|
@@ -16049,7 +16274,7 @@ var budgetExceededEvent = (input, tokensUsed, tokenBudget, sequence) => ({
|
|
|
16049
16274
|
created_at: input.startedAt + (sequence - input.eventSequence)
|
|
16050
16275
|
});
|
|
16051
16276
|
var outputCompletedCursor = (input, sequence) => `${input.executionId}:model:${sequence}:output-completed`;
|
|
16052
|
-
var outputDeltaEvent = (input, part, deltaIndex) => {
|
|
16277
|
+
var outputDeltaEvent = (input, modelPart, part, deltaIndex, createdAt) => {
|
|
16053
16278
|
const sequence = input.eventSequence + 1 + deltaIndex;
|
|
16054
16279
|
return {
|
|
16055
16280
|
id: exports_ids_schema.EventId.make(`event:${input.executionId}:model:${sequence}:output-delta:${deltaIndex}`),
|
|
@@ -16058,12 +16283,19 @@ var outputDeltaEvent = (input, part, deltaIndex) => {
|
|
|
16058
16283
|
sequence,
|
|
16059
16284
|
cursor: `${input.executionId}:model:${sequence}:output-delta:${deltaIndex}`,
|
|
16060
16285
|
content: [exports_content_schema.text(part.delta)],
|
|
16061
|
-
data: {
|
|
16062
|
-
|
|
16286
|
+
data: {
|
|
16287
|
+
delta: part.delta,
|
|
16288
|
+
delta_index: deltaIndex,
|
|
16289
|
+
part_id: part.id,
|
|
16290
|
+
model_call_id: modelPart.modelCallId,
|
|
16291
|
+
model_attempt_id: modelPart.modelAttemptId,
|
|
16292
|
+
attempt: modelPart.attempt
|
|
16293
|
+
},
|
|
16294
|
+
created_at: createdAt
|
|
16063
16295
|
};
|
|
16064
16296
|
};
|
|
16065
16297
|
var reasoningText = (part) => part.type === "reasoning" ? part.text : part.delta;
|
|
16066
|
-
var reasoningDeltaEvent = (input, part, deltaIndex) => {
|
|
16298
|
+
var reasoningDeltaEvent = (input, modelPart, part, deltaIndex, createdAt) => {
|
|
16067
16299
|
const sequence = input.eventSequence + 1 + deltaIndex;
|
|
16068
16300
|
const delta = reasoningText(part);
|
|
16069
16301
|
return {
|
|
@@ -16076,12 +16308,15 @@ var reasoningDeltaEvent = (input, part, deltaIndex) => {
|
|
|
16076
16308
|
data: {
|
|
16077
16309
|
delta,
|
|
16078
16310
|
delta_index: deltaIndex,
|
|
16079
|
-
...part.type === "reasoning-delta" ? { part_id: part.id } : {}
|
|
16311
|
+
...part.type === "reasoning-delta" ? { part_id: part.id } : {},
|
|
16312
|
+
model_call_id: modelPart.modelCallId,
|
|
16313
|
+
model_attempt_id: modelPart.modelAttemptId,
|
|
16314
|
+
attempt: modelPart.attempt
|
|
16080
16315
|
},
|
|
16081
|
-
created_at:
|
|
16316
|
+
created_at: createdAt
|
|
16082
16317
|
};
|
|
16083
16318
|
};
|
|
16084
|
-
var toolCallDeltaEvent = (input, part, toolCallName, sequence, deltaIndex) => ({
|
|
16319
|
+
var toolCallDeltaEvent = (input, modelPart, part, toolCallName, sequence, deltaIndex, createdAt) => ({
|
|
16085
16320
|
id: exports_ids_schema.EventId.make(`event:${input.executionId}:model:${sequence}:toolcall-delta:${part.id}:${deltaIndex}`),
|
|
16086
16321
|
execution_id: input.executionId,
|
|
16087
16322
|
type: "model.toolcall.delta",
|
|
@@ -16091,11 +16326,14 @@ var toolCallDeltaEvent = (input, part, toolCallName, sequence, deltaIndex) => ({
|
|
|
16091
16326
|
tool_call_id: part.id,
|
|
16092
16327
|
...toolCallName === undefined ? {} : { tool_name: toolCallName },
|
|
16093
16328
|
delta: part.delta,
|
|
16094
|
-
delta_index: deltaIndex
|
|
16329
|
+
delta_index: deltaIndex,
|
|
16330
|
+
model_call_id: modelPart.modelCallId,
|
|
16331
|
+
model_attempt_id: modelPart.modelAttemptId,
|
|
16332
|
+
attempt: modelPart.attempt
|
|
16095
16333
|
},
|
|
16096
|
-
created_at:
|
|
16334
|
+
created_at: createdAt
|
|
16097
16335
|
});
|
|
16098
|
-
var outputCompletedEvent = (input, content, outputText, sequence, structuredOutput) => ({
|
|
16336
|
+
var outputCompletedEvent = (input, content, outputText, sequence, structuredOutput, structuredIdentity) => ({
|
|
16099
16337
|
id: exports_ids_schema.EventId.make(`event:${input.executionId}:model:${sequence}:output-completed`),
|
|
16100
16338
|
execution_id: input.executionId,
|
|
16101
16339
|
type: "model.output.completed",
|
|
@@ -16104,7 +16342,12 @@ var outputCompletedEvent = (input, content, outputText, sequence, structuredOutp
|
|
|
16104
16342
|
content,
|
|
16105
16343
|
data: {
|
|
16106
16344
|
model_output: outputText,
|
|
16107
|
-
...structuredOutput === undefined ? {} : { structured_output: structuredOutput }
|
|
16345
|
+
...structuredOutput === undefined ? {} : { structured_output: structuredOutput },
|
|
16346
|
+
...structuredIdentity === undefined ? {} : {
|
|
16347
|
+
structured_output_model_call_id: structuredIdentity.modelCallId,
|
|
16348
|
+
structured_output_model_attempt_id: structuredIdentity.modelAttemptId,
|
|
16349
|
+
structured_output_attempt: structuredIdentity.attempt
|
|
16350
|
+
}
|
|
16108
16351
|
},
|
|
16109
16352
|
created_at: input.completedAt
|
|
16110
16353
|
});
|
|
@@ -16121,11 +16364,14 @@ var AgentLoopEvents = {
|
|
|
16121
16364
|
budgetExceededEvent,
|
|
16122
16365
|
completedContent,
|
|
16123
16366
|
inputPreparedEvent,
|
|
16367
|
+
legacyTelemetryCursor,
|
|
16368
|
+
legacyUsageCursor,
|
|
16124
16369
|
modelOutputMetadata,
|
|
16125
16370
|
outputCompletedEvent,
|
|
16126
16371
|
outputDeltaEvent,
|
|
16127
16372
|
reasoningDeltaEvent,
|
|
16128
16373
|
toolCallDeltaEvent,
|
|
16374
|
+
telemetryEvent,
|
|
16129
16375
|
usageReportedEvent
|
|
16130
16376
|
};
|
|
16131
16377
|
|
|
@@ -16134,11 +16380,14 @@ var {
|
|
|
16134
16380
|
budgetExceededEvent: budgetExceededEvent2,
|
|
16135
16381
|
completedContent: completedContent2,
|
|
16136
16382
|
inputPreparedEvent: inputPreparedEvent2,
|
|
16383
|
+
legacyTelemetryCursor: legacyTelemetryCursor2,
|
|
16384
|
+
legacyUsageCursor: legacyUsageCursor2,
|
|
16137
16385
|
modelOutputMetadata: modelOutputMetadata2,
|
|
16138
16386
|
outputCompletedEvent: outputCompletedEvent2,
|
|
16139
16387
|
outputDeltaEvent: outputDeltaEvent2,
|
|
16140
16388
|
reasoningDeltaEvent: reasoningDeltaEvent2,
|
|
16141
16389
|
toolCallDeltaEvent: toolCallDeltaEvent2,
|
|
16390
|
+
telemetryEvent: telemetryEvent2,
|
|
16142
16391
|
usageReportedEvent: usageReportedEvent2
|
|
16143
16392
|
} = AgentLoopEvents;
|
|
16144
16393
|
|
|
@@ -16212,6 +16461,7 @@ var childRunCoreTools = (input, childRuns, eventLog, waits) => {
|
|
|
16212
16461
|
return Effect93.succeed([
|
|
16213
16462
|
registeredTool({
|
|
16214
16463
|
agent: input.agent,
|
|
16464
|
+
...input.origin === undefined ? {} : { origin: input.origin },
|
|
16215
16465
|
agentId: input.agentId,
|
|
16216
16466
|
agentRevision: input.agentRevision,
|
|
16217
16467
|
...input.agentToolInputSchemaDigests === undefined ? {} : { agentToolInputSchemaDigests: input.agentToolInputSchemaDigests },
|
|
@@ -16222,6 +16472,7 @@ var childRunCoreTools = (input, childRuns, eventLog, waits) => {
|
|
|
16222
16472
|
}),
|
|
16223
16473
|
...transferTools({
|
|
16224
16474
|
agent: input.agent,
|
|
16475
|
+
...input.origin === undefined ? {} : { origin: input.origin },
|
|
16225
16476
|
agentId: input.agentId,
|
|
16226
16477
|
agentRevision: input.agentRevision,
|
|
16227
16478
|
...input.agentToolInputSchemaDigests === undefined ? {} : { agentToolInputSchemaDigests: input.agentToolInputSchemaDigests },
|
|
@@ -16238,59 +16489,79 @@ var existingOutput = (eventLog, input) => eventLog.findFirstByTypeAfterSequence(
|
|
|
16238
16489
|
afterSequence: input.eventSequence
|
|
16239
16490
|
}).pipe(Effect93.map(Option24.getOrUndefined), Effect93.mapError((error5) => loopError(error5, input.eventSequence + 2)));
|
|
16240
16491
|
var STRUCTURED_TURN_PROMPT = "Return the final structured output for the task above.";
|
|
16241
|
-
var runStructuredTurn = Effect93.fn("AgentLoop.runStructuredTurn")(function* (languageModels, schemas, chat, input, schemaRef, sequence) {
|
|
16242
|
-
const registration = yield* schemas.resolve(schemaRef).pipe(Effect93.mapError((error5) => loopError(error5, sequence)));
|
|
16243
|
-
const response = yield* languageModels.provideForAgent(input.agent, chat.generateObject({
|
|
16244
|
-
prompt: STRUCTURED_TURN_PROMPT,
|
|
16245
|
-
schema: registration.schema,
|
|
16246
|
-
objectName: "output"
|
|
16247
|
-
})).pipe(Effect93.mapError((error5) => Schema85.is(AgentLoopError)(error5) ? error5 : loopError(error5, sequence)));
|
|
16248
|
-
return jsonValue6(response.value);
|
|
16249
|
-
});
|
|
16250
16492
|
var loopError = (error5, nextEventSequence5) => AgentLoopError.make({
|
|
16251
16493
|
message: error5 instanceof Error ? `${error5.name}: ${error5.message}` : String(error5),
|
|
16252
16494
|
next_event_sequence: nextEventSequence5
|
|
16253
16495
|
});
|
|
16254
16496
|
var appendEvent = (eventLog, allocator, event, nextEventSequence5) => appendIdempotentTo(eventLog, event).pipe(Effect93.tap((appended) => allocator.advanceTo(appended.sequence + 1)), Effect93.mapError((error5) => loopError(error5, nextEventSequence5)));
|
|
16255
|
-
var
|
|
16256
|
-
|
|
16257
|
-
|
|
16258
|
-
|
|
16259
|
-
|
|
16260
|
-
|
|
16261
|
-
|
|
16262
|
-
|
|
16263
|
-
|
|
16264
|
-
|
|
16265
|
-
|
|
16266
|
-
|
|
16267
|
-
|
|
16268
|
-
|
|
16269
|
-
|
|
16270
|
-
|
|
16271
|
-
|
|
16497
|
+
var deliverTelemetry = Effect93.fn("AgentLoop.deliverTelemetry")(function* (eventLog, allocator, input, batch) {
|
|
16498
|
+
for (const event of batch.events) {
|
|
16499
|
+
const createdAt = yield* Clock17.currentTimeMillis;
|
|
16500
|
+
const candidate = telemetryEvent2(input, batch.sessionId, event, 0, createdAt);
|
|
16501
|
+
const existing = yield* eventLog.findByCursor({ executionId: input.executionId, cursor: candidate.cursor });
|
|
16502
|
+
const legacy = yield* eventLog.findByCursor({
|
|
16503
|
+
executionId: input.executionId,
|
|
16504
|
+
cursor: legacyTelemetryCursor2(input, event)
|
|
16505
|
+
});
|
|
16506
|
+
if (Option24.isNone(existing) && Option24.isNone(legacy)) {
|
|
16507
|
+
const sequence = yield* allocator.allocate(1);
|
|
16508
|
+
yield* appendEvent(eventLog, allocator, { ...candidate, sequence }, sequence + 1);
|
|
16509
|
+
}
|
|
16510
|
+
if (event._tag === "ModelAttemptCompleted" && event.usage !== undefined) {
|
|
16511
|
+
const usageCreatedAt = yield* Clock17.currentTimeMillis;
|
|
16512
|
+
const usageCandidate = usageReportedEvent2(input, batch.sessionId, event, 0, usageCreatedAt);
|
|
16513
|
+
const existingUsage = yield* eventLog.findByCursor({
|
|
16514
|
+
executionId: input.executionId,
|
|
16515
|
+
cursor: usageCandidate.cursor
|
|
16516
|
+
});
|
|
16517
|
+
const legacyUsage = yield* eventLog.findByCursor({
|
|
16518
|
+
executionId: input.executionId,
|
|
16519
|
+
cursor: legacyUsageCursor2(input, event)
|
|
16520
|
+
});
|
|
16521
|
+
if (Option24.isNone(existingUsage) && Option24.isNone(legacyUsage)) {
|
|
16522
|
+
const sequence = yield* allocator.allocate(1);
|
|
16523
|
+
yield* appendEvent(eventLog, allocator, { ...usageCandidate, sequence }, sequence + 1);
|
|
16524
|
+
}
|
|
16525
|
+
}
|
|
16526
|
+
}
|
|
16527
|
+
});
|
|
16528
|
+
var telemetryDelivery = (eventLog, allocator, input) => exports_model_telemetry.Delivery.of({
|
|
16529
|
+
deliver: (batch) => deliverTelemetry(eventLog, allocator, input, batch).pipe(Effect93.mapError((error5) => exports_model_telemetry.DeliveryFailed.make({
|
|
16530
|
+
message: "Relay could not durably project model telemetry",
|
|
16531
|
+
cause: error5
|
|
16532
|
+
})))
|
|
16272
16533
|
});
|
|
16534
|
+
var compactionCommittedCursor = (executionId, checkpointId2) => `execution:${executionId}:agent-compaction-commit:v2:${checkpointId2}`;
|
|
16273
16535
|
var appendCompactionCommittedEvent = Effect93.fn("AgentLoop.appendCompactionCommittedEvent")(function* (eventLog, allocator, input, checkpoint) {
|
|
16274
16536
|
if (input.sessionId === undefined)
|
|
16275
16537
|
return;
|
|
16276
|
-
const
|
|
16538
|
+
const commit = checkpoint.compactionCommit;
|
|
16539
|
+
if (commit === undefined)
|
|
16540
|
+
return;
|
|
16541
|
+
const cursor = compactionCommittedCursor(input.executionId, exports_ids_schema.SessionEntryId.make(commit.checkpointId));
|
|
16277
16542
|
const existing = yield* eventLog.findByCursor({ executionId: input.executionId, cursor }).pipe(Effect93.mapError((error5) => loopError(error5, input.eventSequence + 1)));
|
|
16278
16543
|
if (Option24.isSome(existing))
|
|
16279
16544
|
return;
|
|
16280
16545
|
const sequence = yield* allocator.allocate(1);
|
|
16546
|
+
const createdAt = yield* Clock17.currentTimeMillis;
|
|
16281
16547
|
const data = {
|
|
16282
|
-
checkpoint_id: exports_ids_schema.SessionEntryId.make(
|
|
16548
|
+
checkpoint_id: exports_ids_schema.SessionEntryId.make(commit.checkpointId),
|
|
16283
16549
|
session_id: input.sessionId,
|
|
16284
|
-
|
|
16550
|
+
compaction_id: commit.compactionId,
|
|
16551
|
+
...commit.summaryModelCallId === undefined ? {} : { summary_model_call_id: commit.summaryModelCallId },
|
|
16552
|
+
...commit.contextTokensBefore === undefined ? {} : { context_tokens_before: commit.contextTokensBefore },
|
|
16553
|
+
...commit.contextTokensAfter === undefined ? {} : { context_tokens_after: commit.contextTokensAfter },
|
|
16554
|
+
...commit.entriesBefore === undefined ? {} : { entries_before: commit.entriesBefore },
|
|
16555
|
+
...commit.entriesAfter === undefined ? {} : { entries_after: commit.entriesAfter }
|
|
16285
16556
|
};
|
|
16286
16557
|
yield* appendEvent(eventLog, allocator, {
|
|
16287
|
-
id: exports_ids_schema.EventId.make(`event:${input.executionId}:agent-compaction:${
|
|
16558
|
+
id: exports_ids_schema.EventId.make(`event:${input.executionId}:agent-compaction-commit:v2:${commit.checkpointId}`),
|
|
16288
16559
|
execution_id: input.executionId,
|
|
16289
16560
|
type: "agent.compaction.committed",
|
|
16290
16561
|
sequence,
|
|
16291
16562
|
cursor,
|
|
16292
16563
|
data,
|
|
16293
|
-
created_at:
|
|
16564
|
+
created_at: createdAt
|
|
16294
16565
|
}, sequence + 1);
|
|
16295
16566
|
});
|
|
16296
16567
|
var toolFromDefinition = (definition) => AiTool2.dynamic(definition.name, {
|
|
@@ -16327,7 +16598,7 @@ var restoreHistory = Effect93.fn("AgentLoop.restoreHistory")(function* (chats, i
|
|
|
16327
16598
|
return history;
|
|
16328
16599
|
});
|
|
16329
16600
|
var promptEquivalence = Schema85.toEquivalence(Prompt7.Prompt);
|
|
16330
|
-
var reconcileCompactionCheckpoint = Effect93.fn("AgentLoop.reconcileCompactionCheckpoint")(function* (sessions, chats, input, restoredHistory, onCheckpointCommitted, failOnMismatch = false) {
|
|
16601
|
+
var reconcileCompactionCheckpoint = Effect93.fn("AgentLoop.reconcileCompactionCheckpoint")(function* (sessions, chats, eventLog, allocator, input, restoredHistory, onCheckpointCommitted, failOnMismatch = false) {
|
|
16331
16602
|
if (input.sessionId === undefined)
|
|
16332
16603
|
return restoredHistory;
|
|
16333
16604
|
const path2 = yield* sessions.path({ sessionId: input.sessionId }).pipe(Effect93.mapError((error5) => loopError(error5, input.eventSequence + 1)));
|
|
@@ -16342,6 +16613,10 @@ var reconcileCompactionCheckpoint = Effect93.fn("AgentLoop.reconcileCompactionCh
|
|
|
16342
16613
|
checkpoint,
|
|
16343
16614
|
leafId: checkpoint.id
|
|
16344
16615
|
};
|
|
16616
|
+
yield* deliverTelemetry(eventLog, allocator, input, {
|
|
16617
|
+
sessionId: input.sessionId,
|
|
16618
|
+
events: checkpoint.telemetry
|
|
16619
|
+
}).pipe(Effect93.mapError((error5) => loopError(error5, input.eventSequence + 1)));
|
|
16345
16620
|
const repaired = exports_session.buildContext(path2);
|
|
16346
16621
|
if (restoredHistory === undefined) {
|
|
16347
16622
|
yield* persistTranscript(chats, input, repaired);
|
|
@@ -16603,7 +16878,7 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16603
16878
|
};
|
|
16604
16879
|
const storedHistory = resumeToolCall === undefined ? yield* loadStoredHistory(chats, input) : yield* restoreHistory(chats, input);
|
|
16605
16880
|
const onCheckpointCommitted = (result) => appendCompactionCommittedEvent(eventLog, allocator, input, result.checkpoint).pipe(Effect93.andThen(layerOptions?.onCheckpointCommitted?.(result) ?? Effect93.void));
|
|
16606
|
-
const durableHistory = Option24.isNone(sessionRepository) ? storedHistory : yield* reconcileCompactionCheckpoint(sessionRepository.value, chats, input, storedHistory, onCheckpointCommitted, resumeSuspension === undefined);
|
|
16881
|
+
const durableHistory = Option24.isNone(sessionRepository) ? storedHistory : yield* reconcileCompactionCheckpoint(sessionRepository.value, chats, eventLog, allocator, input, storedHistory, onCheckpointCommitted, resumeSuspension === undefined);
|
|
16607
16882
|
const continuingDurableHistory = durableHistory !== undefined;
|
|
16608
16883
|
const permissionsLayer = input.agent.permission_rules === undefined ? Layer75.empty : Option24.isNone(permissionRules) || Option24.isNone(waits) ? yield* AgentLoopError.make({
|
|
16609
16884
|
message: "Execution permission rules require PermissionRuleRepository and WaitService in context",
|
|
@@ -16693,11 +16968,20 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16693
16968
|
next_event_sequence: input.eventSequence + 1
|
|
16694
16969
|
});
|
|
16695
16970
|
}
|
|
16971
|
+
const schemaRef = input.agent.output_schema_ref;
|
|
16972
|
+
const structuredRegistration = schemaRef === undefined ? undefined : yield* schemas.resolve(schemaRef).pipe(Effect93.mapError((error5) => loopError(error5, input.eventSequence + 1)));
|
|
16696
16973
|
const batonCompaction = compactionPolicy === undefined ? undefined : { contextWindow: compactionPolicy.context_window };
|
|
16697
16974
|
const batonOptions = {
|
|
16698
16975
|
...options,
|
|
16699
16976
|
...toolOutputMaxBytes === undefined ? {} : { toolOutputMaxBytes },
|
|
16700
|
-
...batonCompaction === undefined ? {} : { compaction: batonCompaction }
|
|
16977
|
+
...batonCompaction === undefined ? {} : { compaction: batonCompaction },
|
|
16978
|
+
...structuredRegistration === undefined ? {} : {
|
|
16979
|
+
output: {
|
|
16980
|
+
schema: structuredRegistration.schema,
|
|
16981
|
+
name: "output",
|
|
16982
|
+
prompt: STRUCTURED_TURN_PROMPT
|
|
16983
|
+
}
|
|
16984
|
+
}
|
|
16701
16985
|
};
|
|
16702
16986
|
const batonMemory = memory === undefined || Option24.isNone(durableMemory) ? undefined : recallOnlyMemory(durableMemory.value);
|
|
16703
16987
|
const executorLayer = layer56({
|
|
@@ -16717,8 +17001,7 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16717
17001
|
const compactionService = activeCompactionOptions === undefined ? undefined : exports_compaction.Compaction.of(make8({
|
|
16718
17002
|
executionId: input.executionId,
|
|
16719
17003
|
repository: activeCompactionRepository,
|
|
16720
|
-
options: activeCompactionOptions
|
|
16721
|
-
onSummarizeStarted: (info) => appendCompactionStartedEvent(eventLog, allocator, input, info).pipe(Effect93.mapError((error5) => exports_compaction.CompactionError.make({ message: error5.message, cause: error5 })))
|
|
17004
|
+
options: activeCompactionOptions
|
|
16722
17005
|
}));
|
|
16723
17006
|
if (memory !== undefined && Option24.isNone(durableMemory)) {
|
|
16724
17007
|
return yield* AgentLoopError.make({
|
|
@@ -16738,18 +17021,55 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16738
17021
|
});
|
|
16739
17022
|
const foldEvent = (state, event) => Effect93.gen(function* () {
|
|
16740
17023
|
switch (event._tag) {
|
|
17024
|
+
case "ModelCallStarted":
|
|
17025
|
+
case "ModelAttemptStarted":
|
|
17026
|
+
case "ModelAttemptFirstOutput":
|
|
17027
|
+
case "ModelAttemptCompleted":
|
|
17028
|
+
case "ModelAttemptFailed":
|
|
17029
|
+
case "ModelRetryScheduled":
|
|
17030
|
+
case "ModelCallCompleted":
|
|
17031
|
+
case "ModelCallFailed":
|
|
17032
|
+
case "CompactionStarted":
|
|
17033
|
+
case "CompactionCompleted":
|
|
17034
|
+
case "CompactionFailed": {
|
|
17035
|
+
const createdAt = yield* Clock17.currentTimeMillis;
|
|
17036
|
+
const candidate = telemetryEvent2(input, input.sessionId ?? input.executionId, event, 0, createdAt);
|
|
17037
|
+
const existingTelemetry = yield* eventLog.findByCursor({
|
|
17038
|
+
executionId: input.executionId,
|
|
17039
|
+
cursor: candidate.cursor
|
|
17040
|
+
});
|
|
17041
|
+
if (Option24.isNone(existingTelemetry)) {
|
|
17042
|
+
const sequence = yield* allocator.allocate(1);
|
|
17043
|
+
yield* appendEvent(eventLog, allocator, { ...candidate, sequence }, sequence + 1);
|
|
17044
|
+
}
|
|
17045
|
+
if (event._tag === "ModelAttemptCompleted" && event.usage !== undefined) {
|
|
17046
|
+
const usageCreatedAt = yield* Clock17.currentTimeMillis;
|
|
17047
|
+
const usageCandidate = usageReportedEvent2(input, input.sessionId ?? input.executionId, event, 0, usageCreatedAt);
|
|
17048
|
+
const existingUsage = yield* eventLog.findByCursor({
|
|
17049
|
+
executionId: input.executionId,
|
|
17050
|
+
cursor: usageCandidate.cursor
|
|
17051
|
+
});
|
|
17052
|
+
if (Option24.isNone(existingUsage)) {
|
|
17053
|
+
const usageSequence = yield* allocator.allocate(1);
|
|
17054
|
+
yield* appendEvent(eventLog, allocator, { ...usageCandidate, sequence: usageSequence }, usageSequence + 1);
|
|
17055
|
+
}
|
|
17056
|
+
}
|
|
17057
|
+
return state;
|
|
17058
|
+
}
|
|
16741
17059
|
case "ModelPart": {
|
|
16742
17060
|
const part = event.part;
|
|
16743
17061
|
if (part.type === "text-delta") {
|
|
16744
17062
|
const sequence = yield* allocator.allocate(1);
|
|
16745
17063
|
const deltaIndex = sequence - input.eventSequence - 1;
|
|
16746
|
-
|
|
17064
|
+
const createdAt = yield* Clock17.currentTimeMillis;
|
|
17065
|
+
yield* appendEvent(eventLog, allocator, outputDeltaEvent2(input, event, part, deltaIndex, createdAt), sequence + 1);
|
|
16747
17066
|
return { ...state, text: `${state.text}${part.delta}` };
|
|
16748
17067
|
}
|
|
16749
17068
|
if (part.type === "reasoning" || part.type === "reasoning-delta") {
|
|
16750
17069
|
const sequence = yield* allocator.allocate(1);
|
|
16751
17070
|
const deltaIndex = sequence - input.eventSequence - 1;
|
|
16752
|
-
|
|
17071
|
+
const createdAt = yield* Clock17.currentTimeMillis;
|
|
17072
|
+
yield* appendEvent(eventLog, allocator, reasoningDeltaEvent2(input, event, part, deltaIndex, createdAt), sequence + 1);
|
|
16753
17073
|
return state;
|
|
16754
17074
|
}
|
|
16755
17075
|
if (part.type === "tool-params-start") {
|
|
@@ -16760,7 +17080,8 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16760
17080
|
if (part.type === "tool-params-delta") {
|
|
16761
17081
|
const sequence = yield* allocator.allocate(1);
|
|
16762
17082
|
const deltaIndex = state.toolCallDeltaIndexes[part.id] ?? 0;
|
|
16763
|
-
|
|
17083
|
+
const createdAt = yield* Clock17.currentTimeMillis;
|
|
17084
|
+
yield* appendEvent(eventLog, allocator, toolCallDeltaEvent2(input, event, part, state.toolCallNames[part.id], sequence, deltaIndex, createdAt), sequence + 1);
|
|
16764
17085
|
return {
|
|
16765
17086
|
...state,
|
|
16766
17087
|
toolCallDeltaIndexes: { ...state.toolCallDeltaIndexes, [part.id]: deltaIndex + 1 }
|
|
@@ -16768,8 +17089,6 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16768
17089
|
}
|
|
16769
17090
|
if (part.type === "finish") {
|
|
16770
17091
|
const finish = part;
|
|
16771
|
-
const sequence = yield* allocator.allocate(1);
|
|
16772
|
-
yield* appendEvent(eventLog, allocator, usageReportedEvent2(input, finish, state.modelId, sequence), sequence + 1);
|
|
16773
17092
|
yield* recordModelUsage({
|
|
16774
17093
|
provider: input.agent.model.provider,
|
|
16775
17094
|
model: input.agent.model.model,
|
|
@@ -16798,6 +17117,17 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16798
17117
|
case "Completed": {
|
|
16799
17118
|
return { ...state, text: event.text, transcript: event.transcript, turn: event.turns - 1 };
|
|
16800
17119
|
}
|
|
17120
|
+
case "StructuredOutput": {
|
|
17121
|
+
return {
|
|
17122
|
+
...state,
|
|
17123
|
+
structuredOutput: jsonValue6(event.value),
|
|
17124
|
+
structuredIdentity: {
|
|
17125
|
+
modelCallId: event.modelCallId,
|
|
17126
|
+
modelAttemptId: event.modelAttemptId,
|
|
17127
|
+
attempt: event.attempt
|
|
17128
|
+
}
|
|
17129
|
+
};
|
|
17130
|
+
}
|
|
16801
17131
|
default:
|
|
16802
17132
|
return state;
|
|
16803
17133
|
}
|
|
@@ -16809,7 +17139,7 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16809
17139
|
onCheckpointCommitted: (result) => onCheckpointCommitted(result).pipe(Effect93.orDie),
|
|
16810
17140
|
...sessionWriter === undefined ? {} : { writer: sessionWriter }
|
|
16811
17141
|
}).pipe(Effect93.provideService(exports_session_repository.Service, sessionRepository.value)) : undefined;
|
|
16812
|
-
const foldContext = yield* Layer75.build(Layer75.mergeAll(executorLayer, handlerLayer, approvalsLayer, exports_model_middleware.layerIdentity, instructionsLayer, permissionsLayer, steeringLayer));
|
|
17142
|
+
const foldContext = yield* Layer75.build(Layer75.mergeAll(executorLayer, handlerLayer, approvalsLayer, exports_model_middleware.layerIdentity, instructionsLayer, permissionsLayer, steeringLayer, Layer75.succeed(exports_model_telemetry.Delivery, telemetryDelivery(eventLog, allocator, input))));
|
|
16813
17143
|
const folded = exports_agent.stream(agent, batonOptions).pipe(Stream13.runFoldEffect(() => ({
|
|
16814
17144
|
text: "",
|
|
16815
17145
|
transcript: undefined,
|
|
@@ -16837,10 +17167,9 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16837
17167
|
yield* durableMemory.value.remember({ key: memory.key, turn: finalState.turn ?? 0, transcript, terminal: true }).pipe(Effect93.mapError((error5) => loopError(error5, completedSequence + 1)));
|
|
16838
17168
|
}
|
|
16839
17169
|
}
|
|
16840
|
-
const
|
|
16841
|
-
const structuredOutput = schemaRef === undefined || finalState.transcript === undefined ? undefined : yield* Chat.fromPrompt(finalState.transcript).pipe(Effect93.flatMap((chat) => runStructuredTurn(languageModels, schemas, chat, input, schemaRef, completedSequence + 1)));
|
|
17170
|
+
const structuredOutput = finalState.structuredOutput;
|
|
16842
17171
|
const structuredPart = structuredOutput === undefined || schemaRef === undefined ? [] : [{ type: "structured", value: structuredOutput, schema_ref: schemaRef }];
|
|
16843
|
-
yield* appendEvent(eventLog, allocator, outputCompletedEvent2(input, [...completedContent2(finalState.text), ...structuredPart], finalState.text, completedSequence, structuredOutput), completedSequence + 1);
|
|
17172
|
+
yield* appendEvent(eventLog, allocator, outputCompletedEvent2(input, [...completedContent2(finalState.text), ...structuredPart], finalState.text, completedSequence, structuredOutput, finalState.structuredIdentity), completedSequence + 1);
|
|
16844
17173
|
return {
|
|
16845
17174
|
metadata: {
|
|
16846
17175
|
model_output: finalState.text,
|
|
@@ -17145,7 +17474,7 @@ var layerFromServices2 = Layer79.effect(Service68, Effect97.gen(function* () {
|
|
|
17145
17474
|
}));
|
|
17146
17475
|
|
|
17147
17476
|
// ../runtime/src/schedule/scheduler-service.ts
|
|
17148
|
-
import { Clock as
|
|
17477
|
+
import { Clock as Clock18, 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";
|
|
17149
17478
|
class SchedulerError extends Schema91.TaggedErrorClass()("SchedulerError", {
|
|
17150
17479
|
message: Schema91.String
|
|
17151
17480
|
}) {
|
|
@@ -17270,7 +17599,7 @@ var make13 = Effect98.gen(function* () {
|
|
|
17270
17599
|
const runOnce2 = Effect98.gen(function* () {
|
|
17271
17600
|
let dispatched = 0;
|
|
17272
17601
|
while (true) {
|
|
17273
|
-
const now = yield*
|
|
17602
|
+
const now = yield* Clock18.currentTimeMillis;
|
|
17274
17603
|
const claimed = yield* schedules.claimDue({ workerId, now, claimExpiresAt: now + claimTtlMillis }).pipe(Effect98.mapError(toSchedulerError));
|
|
17275
17604
|
if (claimed === undefined)
|
|
17276
17605
|
return dispatched;
|
|
@@ -17671,7 +18000,7 @@ var check = Effect99.fn("RunnerRuntime.check.call")(function* () {
|
|
|
17671
18000
|
});
|
|
17672
18001
|
|
|
17673
18002
|
// ../runtime/src/workflow/definition-runtime.ts
|
|
17674
|
-
import { Cause as Cause3, Clock as
|
|
18003
|
+
import { Cause as Cause3, Clock as Clock19, Context as Context71, Effect as Effect100, Exit as Exit2, FiberMap as FiberMap2, Layer as Layer82, Option as Option27, Schema as Schema93 } from "effect";
|
|
17675
18004
|
import { dual as dual2 } from "effect/Function";
|
|
17676
18005
|
|
|
17677
18006
|
class UnsupportedOperation extends Schema93.TaggedErrorClass()("UnsupportedWorkflowOperation", { operation_id: exports_ids_schema.WorkflowOperationId, kind: Schema93.String }) {
|
|
@@ -17736,7 +18065,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17736
18065
|
yield* repository.appendLifecycle({
|
|
17737
18066
|
execution_id: executionId,
|
|
17738
18067
|
type: "workflow.started",
|
|
17739
|
-
created_at: yield*
|
|
18068
|
+
created_at: yield* Clock19.currentTimeMillis
|
|
17740
18069
|
});
|
|
17741
18070
|
const byId = new Map(revision.definition.operations.map((operation) => [operation.id, operation]));
|
|
17742
18071
|
const execute = (id) => Effect100.gen(function* () {
|
|
@@ -17749,7 +18078,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17749
18078
|
const operation = byId.get(id);
|
|
17750
18079
|
if (operation === undefined)
|
|
17751
18080
|
return yield* Effect100.die(new Error(`validated workflow operation missing: ${id}`));
|
|
17752
|
-
const startedAt = persisted?.started_at ?? (yield*
|
|
18081
|
+
const startedAt = persisted?.started_at ?? (yield* Clock19.currentTimeMillis);
|
|
17753
18082
|
const sideEffectContext = {
|
|
17754
18083
|
execution_id: executionId,
|
|
17755
18084
|
operation_id: id,
|
|
@@ -17791,7 +18120,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17791
18120
|
return yield* UnsupportedOperation.make({ operation_id: operation.id, kind: operation.kind });
|
|
17792
18121
|
const fanOutId = persisted?.fan_out_id ?? fanOutIdFor(executionId, operation.fan_out_key);
|
|
17793
18122
|
if (persisted?.fan_out_id === undefined) {
|
|
17794
|
-
const now = yield*
|
|
18123
|
+
const now = yield* Clock19.currentTimeMillis;
|
|
17795
18124
|
yield* repository.putOperation({
|
|
17796
18125
|
execution_id: executionId,
|
|
17797
18126
|
operation_id: id,
|
|
@@ -17849,7 +18178,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17849
18178
|
return yield* Effect100.die(new Error(`workflow fan-out state missing: ${operation.parallel_operation}`));
|
|
17850
18179
|
const fanOut = yield* handlers.inspectChildFanOut(parallelState.fan_out_id);
|
|
17851
18180
|
if (fanOut === undefined || fanOut.state === "joining") {
|
|
17852
|
-
const now = yield*
|
|
18181
|
+
const now = yield* Clock19.currentTimeMillis;
|
|
17853
18182
|
yield* repository.putOperation({
|
|
17854
18183
|
execution_id: executionId,
|
|
17855
18184
|
operation_id: id,
|
|
@@ -17892,7 +18221,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17892
18221
|
break;
|
|
17893
18222
|
case "branch": {
|
|
17894
18223
|
const decision = persisted?.decision ?? (yield* handlers.branch(executionId, operation, sideEffectContext));
|
|
17895
|
-
const now = yield*
|
|
18224
|
+
const now = yield* Clock19.currentTimeMillis;
|
|
17896
18225
|
yield* repository.putOperation({
|
|
17897
18226
|
execution_id: executionId,
|
|
17898
18227
|
operation_id: id,
|
|
@@ -17911,7 +18240,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17911
18240
|
let attempt = persisted?.attempt ?? 0;
|
|
17912
18241
|
while (attempt < operation.max_attempts) {
|
|
17913
18242
|
if (persisted?.backoff_until !== undefined) {
|
|
17914
|
-
const remaining = persisted.backoff_until - (yield*
|
|
18243
|
+
const remaining = persisted.backoff_until - (yield* Clock19.currentTimeMillis);
|
|
17915
18244
|
if (remaining > 0)
|
|
17916
18245
|
yield* Effect100.sleep(`${remaining} millis`);
|
|
17917
18246
|
}
|
|
@@ -17923,7 +18252,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17923
18252
|
attempt += 1;
|
|
17924
18253
|
if (attempt >= operation.max_attempts)
|
|
17925
18254
|
return yield* result2;
|
|
17926
|
-
const now = yield*
|
|
18255
|
+
const now = yield* Clock19.currentTimeMillis;
|
|
17927
18256
|
const backoffUntil = now + attempt * 1000;
|
|
17928
18257
|
yield* repository.putOperation({
|
|
17929
18258
|
execution_id: executionId,
|
|
@@ -17946,9 +18275,9 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17946
18275
|
}
|
|
17947
18276
|
case "budget": {
|
|
17948
18277
|
const states = yield* repository.listOperations(executionId);
|
|
17949
|
-
const used = operation.unit === "milliseconds" ? (yield*
|
|
18278
|
+
const used = operation.unit === "milliseconds" ? (yield* Clock19.currentTimeMillis) - startedAt : states.filter((state) => state.status === "completed").length;
|
|
17950
18279
|
if (used >= operation.limit) {
|
|
17951
|
-
const now = yield*
|
|
18280
|
+
const now = yield* Clock19.currentTimeMillis;
|
|
17952
18281
|
yield* repository.appendLifecycle({
|
|
17953
18282
|
execution_id: executionId,
|
|
17954
18283
|
operation_id: id,
|
|
@@ -17973,18 +18302,18 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17973
18302
|
...output2 === undefined ? {} : { output: output2 },
|
|
17974
18303
|
compensation_operation_id: operation.compensate_with,
|
|
17975
18304
|
started_at: startedAt,
|
|
17976
|
-
updated_at: yield*
|
|
18305
|
+
updated_at: yield* Clock19.currentTimeMillis
|
|
17977
18306
|
});
|
|
17978
18307
|
yield* repository.appendLifecycle({
|
|
17979
18308
|
execution_id: executionId,
|
|
17980
18309
|
operation_id: id,
|
|
17981
18310
|
type: "compensation.recorded",
|
|
17982
18311
|
data: { compensate_with: operation.compensate_with },
|
|
17983
|
-
created_at: yield*
|
|
18312
|
+
created_at: yield* Clock19.currentTimeMillis
|
|
17984
18313
|
});
|
|
17985
18314
|
break;
|
|
17986
18315
|
}
|
|
17987
|
-
const completedAt = yield*
|
|
18316
|
+
const completedAt = yield* Clock19.currentTimeMillis;
|
|
17988
18317
|
const current2 = yield* repository.getOperation(executionId, id);
|
|
17989
18318
|
yield* repository.putOperation({
|
|
17990
18319
|
execution_id: executionId,
|
|
@@ -18020,15 +18349,15 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
18020
18349
|
for (const state of compensationStack) {
|
|
18021
18350
|
if (state.compensation_operation_id === undefined || state.status === "compensated")
|
|
18022
18351
|
continue;
|
|
18023
|
-
yield* repository.putOperation({ ...state, status: "compensating", updated_at: yield*
|
|
18352
|
+
yield* repository.putOperation({ ...state, status: "compensating", updated_at: yield* Clock19.currentTimeMillis });
|
|
18024
18353
|
yield* repository.appendLifecycle({
|
|
18025
18354
|
execution_id: executionId,
|
|
18026
18355
|
operation_id: state.operation_id,
|
|
18027
18356
|
type: "compensation.started",
|
|
18028
|
-
created_at: yield*
|
|
18357
|
+
created_at: yield* Clock19.currentTimeMillis
|
|
18029
18358
|
});
|
|
18030
18359
|
yield* execute(state.compensation_operation_id);
|
|
18031
|
-
const completedAt = yield*
|
|
18360
|
+
const completedAt = yield* Clock19.currentTimeMillis;
|
|
18032
18361
|
yield* repository.putOperation({
|
|
18033
18362
|
...state,
|
|
18034
18363
|
status: "compensated",
|
|
@@ -18080,7 +18409,7 @@ var layerFromRuntime2 = Layer82.effect(Service71, Effect100.gen(function* () {
|
|
|
18080
18409
|
}));
|
|
18081
18410
|
|
|
18082
18411
|
// src/runtime.ts
|
|
18083
|
-
import { Cause as Cause5, Context as Context74, Effect as Effect112, Layer as Layer86, Option as
|
|
18412
|
+
import { Cause as Cause5, Context as Context74, Effect as Effect112, Layer as Layer86, Option as Option32, Schema as Schema103 } from "effect";
|
|
18084
18413
|
import { SqlClient as SqlClient31 } from "effect/unstable/sql/SqlClient";
|
|
18085
18414
|
|
|
18086
18415
|
// src/runtime-acquisition-error.ts
|
|
@@ -18162,7 +18491,7 @@ var renderConfigurationError = (error5) => {
|
|
|
18162
18491
|
return `Runtime configuration error [${error5.category}/${error5.scope}]: ${remediation}; causes=${reasons}${error5.cause.truncated ? ",truncated" : ""}`;
|
|
18163
18492
|
};
|
|
18164
18493
|
// src/internal-client.ts
|
|
18165
|
-
import { Clock as
|
|
18494
|
+
import { Clock as Clock20, Effect as Effect109, Layer as Layer84, Option as Option31, Random as Random4, Schema as Schema102, Stream as Stream17 } from "effect";
|
|
18166
18495
|
import { EntityId, ShardId, Sharding as Sharding2, ShardingConfig as ShardingConfig3 } from "effect/unstable/cluster";
|
|
18167
18496
|
|
|
18168
18497
|
// src/runtime-capability-policy.ts
|
|
@@ -18302,7 +18631,7 @@ var registerAgentPayload = Effect102.fn("Client.agents.registerPayload")(functio
|
|
|
18302
18631
|
});
|
|
18303
18632
|
|
|
18304
18633
|
// src/client-child-runs.ts
|
|
18305
|
-
import { Effect as Effect104, Option as Option29 } from "effect";
|
|
18634
|
+
import { Effect as Effect104, Option as Option29, Schema as Schema98 } from "effect";
|
|
18306
18635
|
|
|
18307
18636
|
// src/client-event-sequence.ts
|
|
18308
18637
|
import { Effect as Effect103 } from "effect";
|
|
@@ -18418,7 +18747,8 @@ var parentDefinitionPin = Effect104.fn("Client.parentDefinitionPin")(function* (
|
|
|
18418
18747
|
agentId: record2.agentId,
|
|
18419
18748
|
agentRevision: record2.agentRevision,
|
|
18420
18749
|
agentSnapshot: record2.agentSnapshot,
|
|
18421
|
-
...record2.agentToolInputSchemaDigests === undefined ? {} : { agentToolInputSchemaDigests: record2.agentToolInputSchemaDigests }
|
|
18750
|
+
...record2.agentToolInputSchemaDigests === undefined ? {} : { agentToolInputSchemaDigests: record2.agentToolInputSchemaDigests },
|
|
18751
|
+
...Schema98.decodeUnknownOption(exports_execution_schema.ExecutionOrigin)(record2.metadata[exports_execution_schema.executionOriginMetadataKey]).pipe(Option29.match({ onNone: () => ({}), onSome: (origin) => ({ origin }) }))
|
|
18422
18752
|
};
|
|
18423
18753
|
});
|
|
18424
18754
|
var childStartInput = (input, accepted2, pin, definition, createdAt, parentWaitId) => ({
|
|
@@ -18433,21 +18763,27 @@ var childStartInput = (input, accepted2, pin, definition, createdAt, parentWaitI
|
|
|
18433
18763
|
agent_revision: pin.agentRevision,
|
|
18434
18764
|
agent_snapshot: definition,
|
|
18435
18765
|
...pin.agentToolInputSchemaDigests === undefined ? {} : { agent_tool_input_schema_digests: pin.agentToolInputSchemaDigests },
|
|
18766
|
+
...pin.origin === undefined ? {} : { origin: pin.origin },
|
|
18436
18767
|
metadata: {
|
|
18768
|
+
...input.metadata,
|
|
18437
18769
|
parent_execution_id: input.execution_id,
|
|
18438
18770
|
child_execution_id: accepted2.child_execution_id,
|
|
18771
|
+
child_purpose: "child-run",
|
|
18772
|
+
...input.preset_name === undefined ? {} : { child_profile: input.preset_name },
|
|
18773
|
+
...pin.origin === undefined ? {} : { [exports_execution_schema.executionOriginMetadataKey]: pin.origin },
|
|
18439
18774
|
...parentWaitId === undefined ? {} : { parent_wait_id: parentWaitId }
|
|
18440
18775
|
}
|
|
18441
18776
|
});
|
|
18442
18777
|
var childRunInternals = { childStartInput, internalSpawnChildRunInput };
|
|
18443
18778
|
|
|
18444
18779
|
// src/client-execution-payloads.ts
|
|
18445
|
-
import { Effect as Effect105, Schema as
|
|
18446
|
-
var encodeExecutionCursor = (cursor) =>
|
|
18780
|
+
import { Effect as Effect105, Schema as Schema99 } from "effect";
|
|
18781
|
+
var encodeExecutionCursor = (cursor) => Schema99.encodeEffect(exports_pagination_schema.ExecutionCursorCodec)({ id: cursor.id, at: cursor.updatedAt }).pipe(Effect105.mapError(toClientError));
|
|
18447
18782
|
var executionIdFromIdempotencyKey = (idempotencyKey) => exports_ids_schema.ExecutionId.make(`execution:${idempotencyKey}`);
|
|
18448
|
-
var metadataWithIdempotencyKey = (metadata11, idempotencyKey) => ({
|
|
18783
|
+
var metadataWithIdempotencyKey = (metadata11, idempotencyKey, origin) => ({
|
|
18449
18784
|
...metadata11,
|
|
18450
|
-
idempotency_key: idempotencyKey
|
|
18785
|
+
idempotency_key: idempotencyKey,
|
|
18786
|
+
...origin === undefined ? {} : { [exports_execution_schema.executionOriginMetadataKey]: origin }
|
|
18451
18787
|
});
|
|
18452
18788
|
var startExecutionByAddressPayload = (input) => ({
|
|
18453
18789
|
execution_id: input.execution_id ?? executionIdFromIdempotencyKey(input.idempotency_key),
|
|
@@ -18458,7 +18794,8 @@ var startExecutionByAddressPayload = (input) => ({
|
|
|
18458
18794
|
started_at: input.started_at,
|
|
18459
18795
|
completed_at: input.completed_at,
|
|
18460
18796
|
...input.wait_id === undefined ? {} : { wait_id: input.wait_id },
|
|
18461
|
-
|
|
18797
|
+
...input.origin === undefined ? {} : { origin: input.origin },
|
|
18798
|
+
metadata: metadataWithIdempotencyKey(input.metadata, input.idempotency_key, input.origin)
|
|
18462
18799
|
});
|
|
18463
18800
|
var startExecutionByAgentDefinitionPayload = (input, definition) => ({
|
|
18464
18801
|
execution_id: input.execution_id ?? executionIdFromIdempotencyKey(input.idempotency_key),
|
|
@@ -18473,7 +18810,8 @@ var startExecutionByAgentDefinitionPayload = (input, definition) => ({
|
|
|
18473
18810
|
agent_snapshot: definition.definition,
|
|
18474
18811
|
...definition.tool_input_schema_digests === undefined ? {} : { agent_tool_input_schema_digests: definition.tool_input_schema_digests },
|
|
18475
18812
|
...input.wait_id === undefined ? {} : { wait_id: input.wait_id },
|
|
18476
|
-
|
|
18813
|
+
...input.origin === undefined ? {} : { origin: input.origin },
|
|
18814
|
+
metadata: metadataWithIdempotencyKey(input.metadata, input.idempotency_key, input.origin)
|
|
18477
18815
|
});
|
|
18478
18816
|
var executionPayloadInternals = { startExecutionByAgentDefinitionPayload };
|
|
18479
18817
|
|
|
@@ -18560,9 +18898,9 @@ var wakeRuntime = Effect107.fn("Client.waits.wakeRuntime")(function* (waits, eve
|
|
|
18560
18898
|
var runtimeWakeInternals = { wakeRuntime };
|
|
18561
18899
|
|
|
18562
18900
|
// src/client-tool-outcome.ts
|
|
18563
|
-
import { Effect as Effect108, Schema as
|
|
18901
|
+
import { Effect as Effect108, Schema as Schema100 } from "effect";
|
|
18564
18902
|
var toolWaitId = (executionId, callId) => Identifiers.waitId("tool", executionId, callId);
|
|
18565
|
-
var acceptedWaitOutcome = (wait) =>
|
|
18903
|
+
var acceptedWaitOutcome = (wait) => Schema100.decodeUnknownEffect(exports_tool_schema.ExternalOutcome)(wait.metadata.external_outcome).pipe(Effect108.mapError(toClientError));
|
|
18566
18904
|
var resolveToolOutcomeWait = Effect108.fn("Client.resolveToolOutcomeWait")(function* (waits, eventLog, call, outcome, completedAt) {
|
|
18567
18905
|
const waitId2 = call.waitId ?? toolWaitId(call.executionId, call.call.id);
|
|
18568
18906
|
const wait = yield* waits.get(waitId2).pipe(Effect108.mapError(toClientError));
|
|
@@ -18608,6 +18946,7 @@ var signalToolOutcome = Effect108.fn("Client.signalToolOutcome")(function* (exec
|
|
|
18608
18946
|
var toolOutcomeInternals = { signalToolOutcome };
|
|
18609
18947
|
|
|
18610
18948
|
// src/client-view-mappers.ts
|
|
18949
|
+
import { Option as Option30, Schema as Schema101 } from "effect";
|
|
18611
18950
|
var conversationKind = (metadata11) => metadata11.kind === "agent-agent" ? "agent-agent" : "user-agent";
|
|
18612
18951
|
var toConversationSummary = (record2) => ({
|
|
18613
18952
|
execution_id: record2.id,
|
|
@@ -18629,6 +18968,7 @@ var toExecutionView = (record2) => ({
|
|
|
18629
18968
|
...record2.agentRevision === undefined ? {} : { agent_revision: record2.agentRevision },
|
|
18630
18969
|
...record2.agentSnapshot === undefined ? {} : { agent_snapshot: record2.agentSnapshot },
|
|
18631
18970
|
...record2.agentToolInputSchemaDigests === undefined ? {} : { agent_tool_input_schema_digests: record2.agentToolInputSchemaDigests },
|
|
18971
|
+
...Schema101.decodeUnknownOption(exports_execution_schema.ExecutionOrigin)(record2.metadata[exports_execution_schema.executionOriginMetadataKey]).pipe(Option30.match({ onNone: () => ({}), onSome: (origin) => ({ origin }) })),
|
|
18632
18972
|
metadata: record2.metadata,
|
|
18633
18973
|
created_at: record2.createdAt,
|
|
18634
18974
|
updated_at: record2.updatedAt
|
|
@@ -18836,14 +19176,14 @@ var groupImplementation = (implementation) => ({
|
|
|
18836
19176
|
var rejectReserved = (id, prefix) => id.startsWith(prefix) ? Effect109.fail(ResidentNamespaceReserved.make({ id, message: "start residents via Client.residents.spawn" })) : Effect109.void;
|
|
18837
19177
|
var replyValueFrom = (content) => {
|
|
18838
19178
|
if (content === undefined || content.length === 0)
|
|
18839
|
-
return
|
|
19179
|
+
return Option31.none();
|
|
18840
19180
|
const structured = content.find((part) => part.type === "structured");
|
|
18841
19181
|
if (structured !== undefined)
|
|
18842
|
-
return
|
|
19182
|
+
return Option31.some(structured.value);
|
|
18843
19183
|
const text = content.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
18844
19184
|
if (text.length === 0)
|
|
18845
|
-
return
|
|
18846
|
-
return
|
|
19185
|
+
return Option31.none();
|
|
19186
|
+
return Schema102.decodeUnknownOption(Schema102.UnknownFromJsonString)(text);
|
|
18847
19187
|
};
|
|
18848
19188
|
var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
18849
19189
|
const makeExecutionClient = yield* client;
|
|
@@ -18882,7 +19222,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18882
19222
|
const coordinateToolTransition = (effect) => toolTransitions.coordinate(effect).pipe(Effect109.mapError(toClientError));
|
|
18883
19223
|
const coordinateChildSpawn = (effect) => toolTransitions.coordinate(effect).pipe(Effect109.mapError(toClientError));
|
|
18884
19224
|
const cancelFanOut = Effect109.fn("Client.runtime.cancelFanOut")(function* (input) {
|
|
18885
|
-
if (
|
|
19225
|
+
if (Option31.isSome(childFanOutRuntime)) {
|
|
18886
19226
|
const fanOut = yield* childFanOutRuntime.value.cancel(input.fan_out_id, input.cancelled_at, input.reason ?? "child fan-out cancelled").pipe(Effect109.mapError(toClientError));
|
|
18887
19227
|
if (fanOut === undefined)
|
|
18888
19228
|
return yield* ClientError.make({ message: `Child fan-out not found: ${input.fan_out_id}` });
|
|
@@ -18914,7 +19254,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18914
19254
|
const identity2 = input.idempotency_key ?? input.correlation_key ?? `${input.from}:${input.to}`;
|
|
18915
19255
|
const executionId = exports_ids_schema.ExecutionId.make(input.correlation_key ?? `execution:send:${identity2}`);
|
|
18916
19256
|
const envelopeId = exports_ids_schema.EnvelopeId.make(`${executionId}:envelope:${identity2}`);
|
|
18917
|
-
const createdAt = yield*
|
|
19257
|
+
const createdAt = yield* Clock20.currentTimeMillis;
|
|
18918
19258
|
const execution = yield* executionRepository.get(executionId).pipe(Effect109.mapError(toClientError));
|
|
18919
19259
|
if (execution === undefined) {
|
|
18920
19260
|
yield* executionRepository.create({
|
|
@@ -18923,7 +19263,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18923
19263
|
status: "queued",
|
|
18924
19264
|
metadata: { operation: "envelope-send" },
|
|
18925
19265
|
createdAt
|
|
18926
|
-
}).pipe(Effect109.catchIf(
|
|
19266
|
+
}).pipe(Effect109.catchIf(Schema102.is(exports_execution_repository.DuplicateExecution), () => Effect109.void), Effect109.mapError(toClientError));
|
|
18927
19267
|
}
|
|
18928
19268
|
const maxSequence3 = yield* eventLog.maxSequence(executionId).pipe(Effect109.mapError(toClientError));
|
|
18929
19269
|
return yield* envelopes.send({
|
|
@@ -18970,18 +19310,73 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18970
19310
|
const execution = yield* executionRepository.get(executionId).pipe(Effect109.mapError(toClientError));
|
|
18971
19311
|
if (execution === undefined)
|
|
18972
19312
|
return yield* ExecutionNotFound.make({ execution_id: executionId });
|
|
18973
|
-
const
|
|
19313
|
+
const waitRecords = yield* envelopeReady.listAllWaits({ executionId }).pipe(Effect109.mapError(toClientError));
|
|
19314
|
+
const openWaits = waitRecords.filter((wait) => wait.state === "open");
|
|
18974
19315
|
const calls = yield* toolCalls2.listCalls(executionId).pipe(Effect109.mapError(toClientError));
|
|
19316
|
+
const attemptsByCall = yield* Effect109.forEach(calls, (call) => toolCalls2.listAttempts(executionId, call.call.id).pipe(Effect109.mapError(toClientError), Effect109.map((attempts) => ({ call, attempts }))));
|
|
18975
19317
|
const pendingChunks = yield* Effect109.forEach(calls, (call) => toolCalls2.getResult(call.executionId, call.call.id).pipe(Effect109.mapError(toClientError), Effect109.map((result) => result === undefined ? [toToolCallSummary(call)] : [])));
|
|
18976
19318
|
const children = yield* childExecutions.listByExecution(executionId).pipe(Effect109.mapError(toClientError));
|
|
19319
|
+
const childTree = [];
|
|
19320
|
+
const queue = [{ executionId, depth: 1 }];
|
|
19321
|
+
const expanded = new Set;
|
|
19322
|
+
const edges = new Set;
|
|
19323
|
+
while (queue.length > 0) {
|
|
19324
|
+
const parent = queue.shift();
|
|
19325
|
+
if (expanded.has(parent.executionId))
|
|
19326
|
+
continue;
|
|
19327
|
+
expanded.add(parent.executionId);
|
|
19328
|
+
const descendants = yield* childExecutions.listByExecution(parent.executionId).pipe(Effect109.mapError(toClientError));
|
|
19329
|
+
for (const child of descendants) {
|
|
19330
|
+
const edge = `${parent.executionId}:${child.id}`;
|
|
19331
|
+
if (edges.has(edge))
|
|
19332
|
+
continue;
|
|
19333
|
+
edges.add(edge);
|
|
19334
|
+
if (edges.size > 1000) {
|
|
19335
|
+
return yield* ClientError.make({ message: "Execution child tree exceeds the 1000 edge inspection limit" });
|
|
19336
|
+
}
|
|
19337
|
+
childTree.push({
|
|
19338
|
+
parent_execution_id: parent.executionId,
|
|
19339
|
+
child_execution_id: child.id,
|
|
19340
|
+
address_id: child.addressId,
|
|
19341
|
+
depth: parent.depth,
|
|
19342
|
+
status: child.status,
|
|
19343
|
+
metadata: child.metadata,
|
|
19344
|
+
created_at: child.createdAt,
|
|
19345
|
+
updated_at: child.updatedAt
|
|
19346
|
+
});
|
|
19347
|
+
const childExecutionId3 = exports_ids_schema.ExecutionId.make(child.id);
|
|
19348
|
+
if (!expanded.has(childExecutionId3))
|
|
19349
|
+
queue.push({ executionId: childExecutionId3, depth: parent.depth + 1 });
|
|
19350
|
+
}
|
|
19351
|
+
}
|
|
19352
|
+
const fanOuts = yield* childFanOuts.listByParent(executionId).pipe(Effect109.mapError(toClientError));
|
|
18977
19353
|
const maxSequence3 = yield* eventLog.maxSequence(executionId).pipe(Effect109.mapError(toClientError));
|
|
18978
|
-
const lastEvent = maxSequence3 === undefined ? undefined : yield* eventLog.findBySequence({ executionId, sequence: maxSequence3 }).pipe(Effect109.mapError(toClientError), Effect109.map(
|
|
19354
|
+
const lastEvent = maxSequence3 === undefined ? undefined : yield* eventLog.findBySequence({ executionId, sequence: maxSequence3 }).pipe(Effect109.mapError(toClientError), Effect109.map(Option31.getOrUndefined));
|
|
18979
19355
|
return {
|
|
18980
19356
|
execution_id: execution.id,
|
|
18981
19357
|
status: execution.status,
|
|
18982
19358
|
waiting_on: openWaits.map(toWaitView),
|
|
19359
|
+
waits: waitRecords.map(toWaitView),
|
|
18983
19360
|
pending_tool_calls: pendingChunks.flat(),
|
|
19361
|
+
tool_attempts: attemptsByCall.flatMap(({ attempts }) => attempts.map(toToolAttempt)),
|
|
19362
|
+
tool_invocations: attemptsByCall.flatMap(({ call, attempts }) => call.placement.kind !== "local" && call.placement.kind !== "mcp" ? [] : attempts.map((attempt) => ({
|
|
19363
|
+
invocation_id: `tool-invocation:${executionId}:${call.call.id}:${attempt.id}`,
|
|
19364
|
+
tool_call_id: call.call.id,
|
|
19365
|
+
attempt_id: attempt.id,
|
|
19366
|
+
placement: call.placement.kind,
|
|
19367
|
+
state: attempt.state,
|
|
19368
|
+
...attempt.state === "completed" ? { outcome: "success" } : attempt.state === "failed" ? {
|
|
19369
|
+
outcome: "failure",
|
|
19370
|
+
failure_category: "handler"
|
|
19371
|
+
} : attempt.state === "abandoned" ? { outcome: "abandoned", failure_category: "abandoned" } : {},
|
|
19372
|
+
started_at: attempt.createdAt,
|
|
19373
|
+
...attempt.completedAt === undefined ? {} : { completed_at: attempt.completedAt },
|
|
19374
|
+
...attempt.claimExpiresAt === undefined ? {} : { claim_expires_at: attempt.claimExpiresAt },
|
|
19375
|
+
...call.placement.kind !== "remote" || attempt.workerId === undefined ? {} : { worker_id: exports_tool_schema.WorkerId.make(attempt.workerId) }
|
|
19376
|
+
}))),
|
|
18984
19377
|
child_runs: children.map(toChildRunSummary),
|
|
19378
|
+
child_tree: childTree,
|
|
19379
|
+
fan_outs: fanOuts,
|
|
18985
19380
|
...lastEvent === undefined ? {} : { last_event_cursor: lastEvent.cursor }
|
|
18986
19381
|
};
|
|
18987
19382
|
});
|
|
@@ -19017,27 +19412,27 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19017
19412
|
return { records: yield* workflows.list(id).pipe(Effect109.mapError(toClientError)) };
|
|
19018
19413
|
}),
|
|
19019
19414
|
startWorkflowRun: Effect109.fn("Client.runtime.startWorkflowRun")(function* (input) {
|
|
19020
|
-
if (
|
|
19415
|
+
if (Option31.isSome(runtimeCapabilityPolicy))
|
|
19021
19416
|
yield* runtimeCapabilityPolicy.value.admit("workflow-definition");
|
|
19022
|
-
return yield*
|
|
19417
|
+
return yield* Option31.match(workflowRuntime, {
|
|
19023
19418
|
onNone: () => workflows.start(input),
|
|
19024
19419
|
onSome: (runtime) => runtime.start(input)
|
|
19025
19420
|
}).pipe(Effect109.mapError(toClientError));
|
|
19026
19421
|
}),
|
|
19027
19422
|
inspectWorkflowRun: Effect109.fn("Client.runtime.inspectWorkflowRun")(function* (id) {
|
|
19028
|
-
return yield*
|
|
19423
|
+
return yield* Option31.match(workflowRuntime, {
|
|
19029
19424
|
onNone: () => workflows.inspect(id),
|
|
19030
19425
|
onSome: (runtime) => runtime.inspect(id)
|
|
19031
19426
|
}).pipe(Effect109.mapError(toClientError));
|
|
19032
19427
|
}),
|
|
19033
19428
|
replayWorkflowRun: Effect109.fn("Client.runtime.replayWorkflowRun")(function* (id) {
|
|
19034
|
-
return yield*
|
|
19429
|
+
return yield* Option31.match(workflowRuntime, {
|
|
19035
19430
|
onNone: () => workflows.listLifecycle(id),
|
|
19036
19431
|
onSome: (runtime) => runtime.replay(id)
|
|
19037
19432
|
}).pipe(Effect109.mapError(toClientError));
|
|
19038
19433
|
}),
|
|
19039
19434
|
cancelWorkflowRun: Effect109.fn("Client.runtime.cancelWorkflowRun")(function* (id) {
|
|
19040
|
-
return yield*
|
|
19435
|
+
return yield* Option31.match(workflowRuntime, {
|
|
19041
19436
|
onNone: () => workflows.cancel(id).pipe(Effect109.map((result) => result.record)),
|
|
19042
19437
|
onSome: (runtime) => runtime.cancel(id)
|
|
19043
19438
|
}).pipe(Effect109.mapError(toClientError));
|
|
@@ -19169,7 +19564,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19169
19564
|
return records.map(toWaitView);
|
|
19170
19565
|
}),
|
|
19171
19566
|
listExecutions: Effect109.fn("Client.runtime.listExecutions")(function* (input) {
|
|
19172
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19567
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema102.decodeEffect(exports_pagination_schema.ExecutionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })));
|
|
19173
19568
|
const result = yield* executionRepository.list({
|
|
19174
19569
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
19175
19570
|
...input.status === undefined ? {} : { status: input.status },
|
|
@@ -19219,13 +19614,13 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19219
19614
|
}).pipe(Effect109.mapError(toClientError));
|
|
19220
19615
|
}),
|
|
19221
19616
|
listSessions: Effect109.fn("Client.runtime.listSessions")(function* (input) {
|
|
19222
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19617
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema102.decodeEffect(exports_pagination_schema.SessionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })));
|
|
19223
19618
|
const result = yield* sessionRepository.list({
|
|
19224
19619
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
19225
19620
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
19226
19621
|
...cursor === undefined ? {} : { cursor }
|
|
19227
19622
|
});
|
|
19228
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
19623
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema102.encodeEffect(exports_pagination_schema.SessionCursorCodec)({
|
|
19229
19624
|
id: result.nextCursor.id,
|
|
19230
19625
|
at: result.nextCursor.updatedAt
|
|
19231
19626
|
});
|
|
@@ -19238,7 +19633,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19238
19633
|
const session = yield* sessionRepository.get(input.session_id).pipe(Effect109.mapError(toClientError));
|
|
19239
19634
|
if (session === undefined)
|
|
19240
19635
|
return yield* ClientError.make({ message: `Session not found: ${input.session_id}` });
|
|
19241
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19636
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema102.decodeEffect(exports_pagination_schema.ExecutionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })), Effect109.mapError(toClientError));
|
|
19242
19637
|
const result = yield* executionRepository.list({
|
|
19243
19638
|
sessionId: input.session_id,
|
|
19244
19639
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
@@ -19295,12 +19690,12 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19295
19690
|
const shard = ShardId.toString(sharding.getShardId(EntityId.make(executionId), "execution"));
|
|
19296
19691
|
const owner = yield* clusterRegistry.lockOwner(shard).pipe(Effect109.mapError(toClientError));
|
|
19297
19692
|
const runnerAddress = owner ?? null;
|
|
19298
|
-
const self =
|
|
19693
|
+
const self = Option31.map(shardingConfig2.runnerAddress, (address) => `${address.host}:${address.port}`);
|
|
19299
19694
|
return {
|
|
19300
19695
|
execution_id: executionId,
|
|
19301
19696
|
shard,
|
|
19302
19697
|
runner_address: runnerAddress,
|
|
19303
|
-
owned: runnerAddress !== null &&
|
|
19698
|
+
owned: runnerAddress !== null && Option31.getOrNull(self) === runnerAddress
|
|
19304
19699
|
};
|
|
19305
19700
|
}),
|
|
19306
19701
|
send: sendEnvelope,
|
|
@@ -19309,10 +19704,10 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19309
19704
|
if (instance === undefined || instance.status === "destroyed") {
|
|
19310
19705
|
return yield* ResidentNotFound.make({ kind: input.kind, key: input.key });
|
|
19311
19706
|
}
|
|
19312
|
-
const encoded = yield*
|
|
19707
|
+
const encoded = yield* Schema102.encodeUnknownEffect(input.command.input)(input.input).pipe(Effect109.mapError(toClientError));
|
|
19313
19708
|
const inputRef = inputSchemaRef(input.command.name);
|
|
19314
19709
|
const outputRef = outputSchemaRef(input.command.name);
|
|
19315
|
-
if (
|
|
19710
|
+
if (Option31.isSome(schemaRegistry)) {
|
|
19316
19711
|
yield* schemaRegistry.value.register({ ref: inputRef, schema: input.command.input });
|
|
19317
19712
|
yield* schemaRegistry.value.register({ ref: outputRef, schema: input.command.output });
|
|
19318
19713
|
}
|
|
@@ -19356,7 +19751,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19356
19751
|
message: "reply carried no decodable content"
|
|
19357
19752
|
});
|
|
19358
19753
|
}
|
|
19359
|
-
return yield*
|
|
19754
|
+
return yield* Schema102.decodeUnknownEffect(input.command.output)(replyValue.value).pipe(Effect109.mapError((issue) => CommandReplyInvalid.make({
|
|
19360
19755
|
command: input.command.name,
|
|
19361
19756
|
wait_id: outcome.wait_id,
|
|
19362
19757
|
message: errorMessage2(issue)
|
|
@@ -19397,14 +19792,14 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19397
19792
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
19398
19793
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
19399
19794
|
updatedAt: input.updated_at
|
|
19400
|
-
}).pipe(Effect109.mapError((error5) =>
|
|
19795
|
+
}).pipe(Effect109.mapError((error5) => Schema102.is(StateVersionConflict3)(error5) ? StateVersionConflict.make(error5) : toClientError(error5)))),
|
|
19401
19796
|
deleteResidentState: Effect109.fn("Client.runtime.deleteResidentState")((input) => executionState.remove({
|
|
19402
19797
|
executionId: input.execution_id,
|
|
19403
19798
|
key: input.key,
|
|
19404
19799
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
19405
19800
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
19406
19801
|
removedAt: input.removed_at
|
|
19407
|
-
}).pipe(Effect109.mapError((error5) =>
|
|
19802
|
+
}).pipe(Effect109.mapError((error5) => Schema102.is(StateVersionConflict3)(error5) ? StateVersionConflict.make(error5) : toClientError(error5)))),
|
|
19408
19803
|
listResidentState: Effect109.fn("Client.runtime.listResidentState")((input) => executionState.list({
|
|
19409
19804
|
executionId: input.execution_id,
|
|
19410
19805
|
...input.prefix === undefined ? {} : { prefix: input.prefix },
|
|
@@ -19527,7 +19922,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19527
19922
|
}),
|
|
19528
19923
|
spawnChildRun: Effect109.fn("Client.runtime.spawnChildRun")(function* (input) {
|
|
19529
19924
|
const pin = yield* parentDefinitionPin(executionRepository, input.execution_id);
|
|
19530
|
-
const createdAt = yield*
|
|
19925
|
+
const createdAt = yield* Clock20.currentTimeMillis;
|
|
19531
19926
|
const internal = childRunInternals.internalSpawnChildRunInput(input, pin, createdAt);
|
|
19532
19927
|
const context = yield* resolveForDispatch(internal).pipe(Effect109.mapError((error5) => ClientError.make({ message: error5._tag })));
|
|
19533
19928
|
const definition = yield* childDefinition(pin.agentSnapshot, context).pipe(Effect109.mapError((error5) => ClientError.make({ message: error5._tag })));
|
|
@@ -19545,9 +19940,9 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19545
19940
|
return coordinated.accepted;
|
|
19546
19941
|
}),
|
|
19547
19942
|
createChildFanOut: Effect109.fn("Client.runtime.createChildFanOut")(function* (input) {
|
|
19548
|
-
if (
|
|
19943
|
+
if (Option31.isSome(runtimeCapabilityPolicy))
|
|
19549
19944
|
yield* runtimeCapabilityPolicy.value.admit("fan-out");
|
|
19550
|
-
if (
|
|
19945
|
+
if (Option31.isNone(childFanOutRuntime)) {
|
|
19551
19946
|
return yield* ClientError.make({
|
|
19552
19947
|
message: "Child fan-out runtime unavailable"
|
|
19553
19948
|
});
|
|
@@ -19558,7 +19953,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19558
19953
|
return yield* cancelFanOut(input);
|
|
19559
19954
|
}),
|
|
19560
19955
|
inspectChildFanOut: Effect109.fn("Client.runtime.inspectChildFanOut")(function* (input) {
|
|
19561
|
-
const fanOut = yield*
|
|
19956
|
+
const fanOut = yield* Option31.match(childFanOutRuntime, {
|
|
19562
19957
|
onNone: () => childFanOuts.get(input.fan_out_id),
|
|
19563
19958
|
onSome: (runtime) => runtime.inspect(input.fan_out_id)
|
|
19564
19959
|
}).pipe(Effect109.mapError(toClientError));
|
|
@@ -19600,7 +19995,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19600
19995
|
if (input.cron_expr !== undefined) {
|
|
19601
19996
|
yield* parseCron(input.cron_expr).pipe(Effect109.mapError(toClientError));
|
|
19602
19997
|
}
|
|
19603
|
-
const createdAt = yield*
|
|
19998
|
+
const createdAt = yield* Clock20.currentTimeMillis;
|
|
19604
19999
|
const schedule = yield* schedules.create({
|
|
19605
20000
|
id: input.schedule_id,
|
|
19606
20001
|
kind: input.kind,
|
|
@@ -19663,77 +20058,77 @@ import { Effect as Effect111 } from "effect";
|
|
|
19663
20058
|
var recoverPersistedFanOut = (recover) => recover().pipe(Effect111.mapError((error5) => WorkflowRuntimeError.make({ message: error5._tag })), Effect111.asVoid);
|
|
19664
20059
|
|
|
19665
20060
|
// src/runtime.ts
|
|
19666
|
-
var Dialect2 =
|
|
20061
|
+
var Dialect2 = Schema103.Literals(["pg", "mysql", "sqlite"]);
|
|
19667
20062
|
|
|
19668
|
-
class NotificationFailure extends
|
|
19669
|
-
reason:
|
|
20063
|
+
class NotificationFailure extends Schema103.TaggedErrorClass()("NotificationFailure", {
|
|
20064
|
+
reason: Schema103.String
|
|
19670
20065
|
}) {
|
|
19671
20066
|
}
|
|
19672
20067
|
|
|
19673
|
-
class ClusterFailure extends
|
|
19674
|
-
reason:
|
|
20068
|
+
class ClusterFailure extends Schema103.TaggedErrorClass()("ClusterFailure", {
|
|
20069
|
+
reason: Schema103.String
|
|
19675
20070
|
}) {
|
|
19676
20071
|
}
|
|
19677
20072
|
|
|
19678
|
-
class SqlFailure extends
|
|
19679
|
-
category:
|
|
19680
|
-
operation:
|
|
19681
|
-
retryable:
|
|
20073
|
+
class SqlFailure extends Schema103.TaggedErrorClass()("SqlFailure", {
|
|
20074
|
+
category: Schema103.Literals(["connection", "statement", "unknown"]),
|
|
20075
|
+
operation: Schema103.Literals(["acquire", "migrate", "verify", "notify", "readiness"]),
|
|
20076
|
+
retryable: Schema103.Boolean
|
|
19682
20077
|
}) {
|
|
19683
20078
|
}
|
|
19684
|
-
var SqlDialect =
|
|
20079
|
+
var SqlDialect = Schema103.Literals(["sqlite", "pg", "mysql", "mssql", "clickhouse"]);
|
|
19685
20080
|
|
|
19686
|
-
class DatabaseDialectMismatch extends
|
|
20081
|
+
class DatabaseDialectMismatch extends Schema103.TaggedErrorClass()("DatabaseDialectMismatch", { expected: Dialect2, actual: SqlDialect }) {
|
|
19687
20082
|
}
|
|
19688
20083
|
|
|
19689
|
-
class DatabaseAlreadyOwned extends
|
|
20084
|
+
class DatabaseAlreadyOwned extends Schema103.TaggedErrorClass()("DatabaseAlreadyOwned", {
|
|
19690
20085
|
databaseIdentity: DatabaseIdentity
|
|
19691
20086
|
}) {
|
|
19692
20087
|
}
|
|
19693
20088
|
|
|
19694
|
-
class UnsupportedTopology extends
|
|
19695
|
-
reason:
|
|
20089
|
+
class UnsupportedTopology extends Schema103.TaggedErrorClass()("UnsupportedTopology", {
|
|
20090
|
+
reason: Schema103.String
|
|
19696
20091
|
}) {
|
|
19697
20092
|
}
|
|
19698
20093
|
|
|
19699
|
-
class MigratorError extends
|
|
19700
|
-
reason:
|
|
20094
|
+
class MigratorError extends Schema103.TaggedErrorClass()("MigratorError", {
|
|
20095
|
+
reason: Schema103.String
|
|
19701
20096
|
}) {
|
|
19702
20097
|
}
|
|
19703
20098
|
|
|
19704
|
-
class SchemaHeadMismatch extends
|
|
19705
|
-
expected:
|
|
19706
|
-
actual:
|
|
20099
|
+
class SchemaHeadMismatch extends Schema103.TaggedErrorClass()("SchemaHeadMismatch", {
|
|
20100
|
+
expected: Schema103.String,
|
|
20101
|
+
actual: Schema103.String
|
|
19707
20102
|
}) {
|
|
19708
20103
|
}
|
|
19709
20104
|
|
|
19710
|
-
class HostUnavailable extends
|
|
19711
|
-
host:
|
|
19712
|
-
reason:
|
|
20105
|
+
class HostUnavailable extends Schema103.TaggedErrorClass()("HostUnavailable", {
|
|
20106
|
+
host: Schema103.String,
|
|
20107
|
+
reason: Schema103.String
|
|
19713
20108
|
}) {
|
|
19714
20109
|
}
|
|
19715
|
-
var RuntimeTopologyCause =
|
|
20110
|
+
var RuntimeTopologyCause = Schema103.Union([
|
|
19716
20111
|
ClusterFailure,
|
|
19717
20112
|
DatabaseDialectMismatch,
|
|
19718
20113
|
DatabaseAlreadyOwned,
|
|
19719
20114
|
UnsupportedTopology
|
|
19720
20115
|
]);
|
|
19721
|
-
var RuntimeMigrationCause =
|
|
20116
|
+
var RuntimeMigrationCause = Schema103.Union([
|
|
19722
20117
|
SqlFailure,
|
|
19723
20118
|
MigratorError,
|
|
19724
20119
|
SchemaHeadMismatch
|
|
19725
20120
|
]);
|
|
19726
|
-
var RuntimeReadinessCause =
|
|
20121
|
+
var RuntimeReadinessCause = Schema103.Union([
|
|
19727
20122
|
SqlFailure,
|
|
19728
20123
|
NotificationFailure,
|
|
19729
20124
|
ClusterFailure,
|
|
19730
20125
|
HostUnavailable
|
|
19731
20126
|
]);
|
|
19732
20127
|
|
|
19733
|
-
class RuntimeTopologyError extends
|
|
20128
|
+
class RuntimeTopologyError extends Schema103.TaggedErrorClass()("RuntimeTopologyError", {
|
|
19734
20129
|
dialect: Dialect2,
|
|
19735
|
-
role:
|
|
19736
|
-
nextAction:
|
|
20130
|
+
role: Schema103.Literals(["embedded", "runner", "client"]),
|
|
20131
|
+
nextAction: Schema103.Literals([
|
|
19737
20132
|
"use-embedded",
|
|
19738
20133
|
"use-postgres-or-mysql",
|
|
19739
20134
|
"use-client-constructor",
|
|
@@ -19744,39 +20139,39 @@ class RuntimeTopologyError extends Schema101.TaggedErrorClass()("RuntimeTopology
|
|
|
19744
20139
|
}) {
|
|
19745
20140
|
}
|
|
19746
20141
|
|
|
19747
|
-
class RuntimeMigrationError extends
|
|
20142
|
+
class RuntimeMigrationError extends Schema103.TaggedErrorClass()("RuntimeMigrationError", {
|
|
19748
20143
|
dialect: Dialect2,
|
|
19749
|
-
phase:
|
|
19750
|
-
nextAction:
|
|
20144
|
+
phase: Schema103.Literals(["apply", "verify"]),
|
|
20145
|
+
nextAction: Schema103.Literals(["retry", "inspect-schema", "run-compatible-release"]),
|
|
19751
20146
|
cause: RuntimeMigrationCause
|
|
19752
20147
|
}) {
|
|
19753
20148
|
}
|
|
19754
20149
|
|
|
19755
|
-
class RuntimeReadinessError extends
|
|
19756
|
-
phase:
|
|
20150
|
+
class RuntimeReadinessError extends Schema103.TaggedErrorClass()("RuntimeReadinessError", {
|
|
20151
|
+
phase: Schema103.Literals(["database", "notification", "cluster", "hosts"]),
|
|
19757
20152
|
cause: RuntimeReadinessCause
|
|
19758
20153
|
}) {
|
|
19759
20154
|
}
|
|
19760
|
-
var RuntimeCapabilityStatus =
|
|
19761
|
-
|
|
19762
|
-
enabled:
|
|
19763
|
-
source:
|
|
19764
|
-
health:
|
|
20155
|
+
var RuntimeCapabilityStatus = Schema103.Union([
|
|
20156
|
+
Schema103.Struct({
|
|
20157
|
+
enabled: Schema103.Literal(false),
|
|
20158
|
+
source: Schema103.Literals(["local-host", "role-unavailable"]),
|
|
20159
|
+
health: Schema103.Literal("not-applicable")
|
|
19765
20160
|
}),
|
|
19766
|
-
|
|
19767
|
-
enabled:
|
|
19768
|
-
source:
|
|
19769
|
-
health:
|
|
20161
|
+
Schema103.Struct({
|
|
20162
|
+
enabled: Schema103.Literal(true),
|
|
20163
|
+
source: Schema103.Literal("local-host"),
|
|
20164
|
+
health: Schema103.Literals(["healthy", "unhealthy"])
|
|
19770
20165
|
})
|
|
19771
20166
|
]);
|
|
19772
|
-
var ReadinessStatus2 =
|
|
19773
|
-
ready:
|
|
19774
|
-
role:
|
|
20167
|
+
var ReadinessStatus2 = Schema103.Struct({
|
|
20168
|
+
ready: Schema103.Literal(true),
|
|
20169
|
+
role: Schema103.Literals(["embedded", "runner", "client"]),
|
|
19775
20170
|
dialect: Dialect2,
|
|
19776
20171
|
databaseIdentity: DatabaseIdentity,
|
|
19777
|
-
schemaHead:
|
|
19778
|
-
notification:
|
|
19779
|
-
capabilities:
|
|
20172
|
+
schemaHead: Schema103.String,
|
|
20173
|
+
notification: Schema103.Literals(["pg-listen-notify", "polling", "in-process"]),
|
|
20174
|
+
capabilities: Schema103.Struct({
|
|
19780
20175
|
fanOut: RuntimeCapabilityStatus,
|
|
19781
20176
|
workflowDefinition: RuntimeCapabilityStatus
|
|
19782
20177
|
})
|
|
@@ -19790,7 +20185,7 @@ var normalizeHost = (layer65, _role, _dialect) => layer65.pipe(Layer86.catchCaus
|
|
|
19790
20185
|
role: _role,
|
|
19791
20186
|
nextAction: _role === "embedded" ? "use-embedded" : "use-different-database",
|
|
19792
20187
|
cause: ClusterFailure.make({ reason: "cluster configuration is incompatible" })
|
|
19793
|
-
}) : error5), "host-layer", (error5) =>
|
|
20188
|
+
}) : error5), "host-layer", (error5) => Schema103.is(RuntimeConfigurationError)(error5) || Schema103.is(RuntimeTopologyError)(error5) || Schema103.is(RuntimeMigrationError)(error5))))));
|
|
19794
20189
|
var actualDialect = (sql) => sql.onDialectOrElse({
|
|
19795
20190
|
sqlite: () => "sqlite",
|
|
19796
20191
|
pg: () => "pg",
|
|
@@ -19883,7 +20278,7 @@ var withHosts = (runner, options) => {
|
|
|
19883
20278
|
const childFanOut = yield* Effect112.serviceOption(Service44);
|
|
19884
20279
|
const mapError2 = (effect) => effect.pipe(Effect112.mapError((error5) => WorkflowRuntimeError.make({ message: error5.message })));
|
|
19885
20280
|
return HandlerService2.of({
|
|
19886
|
-
...
|
|
20281
|
+
...Option32.isNone(childFanOut) ? {} : {
|
|
19887
20282
|
createChildFanOut: (definition) => childFanOut.value.create(definition).pipe(Effect112.mapError((error5) => WorkflowRuntimeError.make({ message: error5._tag }))),
|
|
19888
20283
|
admitChildFanOut: () => recoverPersistedFanOut(childFanOut.value.recover),
|
|
19889
20284
|
inspectChildFanOut: (fanOutId) => childFanOut.value.inspect(fanOutId).pipe(Effect112.mapError((error5) => WorkflowRuntimeError.make({ message: error5._tag })))
|