@relayfx/test 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +177 -95
- package/dist/types/runtime/address/address-resolution-service.d.ts +32 -10
- package/dist/types/runtime/agent/relay-compaction.d.ts +3 -2
- package/dist/types/runtime/child/child-fan-out-runtime.d.ts +2 -0
- package/dist/types/runtime/child/spawn-child-run-tool.d.ts +7 -0
- package/dist/types/runtime/model/language-model-service.d.ts +1 -0
- package/dist/types/runtime/runner/runner-runtime-service.d.ts +30 -30
- package/dist/types/runtime/workflow/definition-runtime.d.ts +2 -0
- package/dist/types/runtime/workflow/execution-workflow.d.ts +64 -20
- package/dist/types/schema/agent-schema.d.ts +220 -60
- package/dist/types/schema/child-orchestration-schema.d.ts +21 -0
- package/dist/types/schema/execution-schema.d.ts +74 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ __export(exports_scripted_model, {
|
|
|
21
21
|
responseParts: () => responseParts,
|
|
22
22
|
registration: () => registration,
|
|
23
23
|
nextTurn: () => nextTurn,
|
|
24
|
-
layer: () =>
|
|
24
|
+
layer: () => layer67
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
// ../schema/src/address-schema.ts
|
|
@@ -341,7 +341,8 @@ var PositiveSafeInteger = Schema5.Number.check(Schema5.makeFilter((value) => Num
|
|
|
341
341
|
var CompactionPolicy = Schema5.Struct({
|
|
342
342
|
context_window: PositiveSafeInteger,
|
|
343
343
|
reserve_tokens: PositiveSafeInteger,
|
|
344
|
-
keep_recent_tokens: PositiveSafeInteger
|
|
344
|
+
keep_recent_tokens: PositiveSafeInteger,
|
|
345
|
+
summary_model: Schema5.optionalKey(ModelSelection)
|
|
345
346
|
}).check(Schema5.makeFilter((policy) => policy.reserve_tokens + policy.keep_recent_tokens < policy.context_window ? undefined : "reserve_tokens + keep_recent_tokens must be less than context_window")).annotate({ identifier: "Relay.Agent.CompactionPolicy" });
|
|
346
347
|
var ChildRunWorkspacePolicy = Schema5.Struct({
|
|
347
348
|
mode: Schema5.Literals(["share", "fork"]),
|
|
@@ -2504,10 +2505,17 @@ var layer6 = Layer6.effect(Service6, Effect7.gen(function* () {
|
|
|
2504
2505
|
return yield* new ChildFanOutConflict({ fan_out_id: definition.fan_out_id });
|
|
2505
2506
|
return existing;
|
|
2506
2507
|
}
|
|
2507
|
-
|
|
2508
|
+
const inserted = sql.withTransaction(Effect7.gen(function* () {
|
|
2508
2509
|
yield* sql`INSERT INTO relay_child_fan_outs (tenant_id, id, parent_execution_id, definition_json, state, created_at) VALUES (${tenantId}, ${definition.fan_out_id}, ${definition.parent_execution_id}, ${encodeJson(definition)}, 'joining', ${timestampParam(sql, definition.created_at)})`;
|
|
2509
2510
|
yield* Effect7.forEach(definition.children, (child, ordinal) => sql`INSERT INTO relay_child_fan_out_members (tenant_id, fan_out_id, child_execution_id, ordinal, state) VALUES (${tenantId}, ${definition.fan_out_id}, ${child.child_execution_id}, ${ordinal}, 'queued')`, { discard: true });
|
|
2510
|
-
}))
|
|
2511
|
+
}));
|
|
2512
|
+
yield* inserted.pipe(Effect7.mapError(repositoryError), Effect7.catch((error) => Effect7.gen(function* () {
|
|
2513
|
+
const current2 = yield* load(tenantId, definition.fan_out_id).pipe(Effect7.mapError(repositoryError));
|
|
2514
|
+
if (current2 === undefined)
|
|
2515
|
+
return yield* error;
|
|
2516
|
+
if (!sameDefinition(cloneDefinition2(current2), definition))
|
|
2517
|
+
return yield* new ChildFanOutConflict({ fan_out_id: definition.fan_out_id });
|
|
2518
|
+
})));
|
|
2511
2519
|
const created = yield* load(tenantId, definition.fan_out_id).pipe(Effect7.mapError(repositoryError));
|
|
2512
2520
|
if (created === undefined)
|
|
2513
2521
|
return yield* new ChildFanOutRepositoryError({ message: "Fan-out insert returned no row" });
|
|
@@ -9676,12 +9684,20 @@ var memoryLayer27 = Layer28.sync(Service28, () => {
|
|
|
9676
9684
|
inspect,
|
|
9677
9685
|
listNonterminal: Effect29.fn("WorkflowDefinitionRepository.memory.listNonterminal")(() => Effect29.sync(() => [...runs.values()].filter((record2) => record2.status === "running").map(clone3))),
|
|
9678
9686
|
cancel: Effect29.fn("WorkflowDefinitionRepository.memory.cancel")(function* (id2) {
|
|
9687
|
+
const now = yield* Clock3.currentTimeMillis;
|
|
9679
9688
|
const record2 = runs.get(id2);
|
|
9680
9689
|
if (record2 === undefined)
|
|
9681
|
-
return;
|
|
9682
|
-
|
|
9690
|
+
return { transitioned: false, record: undefined };
|
|
9691
|
+
if (record2.status !== "running")
|
|
9692
|
+
return { transitioned: false, record: clone3(record2) };
|
|
9693
|
+
const updated = { ...record2, status: "cancelled", updated_at: now };
|
|
9683
9694
|
runs.set(id2, updated);
|
|
9684
|
-
|
|
9695
|
+
const events = lifecycle.get(id2) ?? [];
|
|
9696
|
+
lifecycle.set(id2, [
|
|
9697
|
+
...events,
|
|
9698
|
+
{ execution_id: id2, sequence: events.length + 1, type: "workflow.cancelled", created_at: now }
|
|
9699
|
+
]);
|
|
9700
|
+
return { transitioned: true, record: clone3(updated) };
|
|
9685
9701
|
}),
|
|
9686
9702
|
getOperation: Effect29.fn("WorkflowDefinitionRepository.memory.getOperation")((executionId, operationId2) => Effect29.sync(() => clone3(operations.get(`${executionId}:${operationId2}`)))),
|
|
9687
9703
|
putOperation: Effect29.fn("WorkflowDefinitionRepository.memory.putOperation")((state) => Effect29.sync(() => {
|
|
@@ -9696,18 +9712,34 @@ var memoryLayer27 = Layer28.sync(Service28, () => {
|
|
|
9696
9712
|
return clone3(stored);
|
|
9697
9713
|
})),
|
|
9698
9714
|
listLifecycle: Effect29.fn("WorkflowDefinitionRepository.memory.listLifecycle")((executionId) => Effect29.sync(() => clone3(lifecycle.get(executionId) ?? []))),
|
|
9699
|
-
finish: Effect29.fn("WorkflowDefinitionRepository.memory.finish")(function* (id2, status) {
|
|
9715
|
+
finish: Effect29.fn("WorkflowDefinitionRepository.memory.finish")(function* (id2, status, data) {
|
|
9716
|
+
const now = yield* Clock3.currentTimeMillis;
|
|
9700
9717
|
const record2 = runs.get(id2);
|
|
9701
|
-
if (record2 === undefined)
|
|
9702
|
-
return;
|
|
9703
|
-
const updated = { ...record2, status, updated_at:
|
|
9718
|
+
if (record2 === undefined || record2.status !== "running")
|
|
9719
|
+
return { transitioned: false, record: record2 === undefined ? undefined : clone3(record2) };
|
|
9720
|
+
const updated = { ...record2, status, updated_at: now };
|
|
9704
9721
|
runs.set(id2, updated);
|
|
9705
|
-
|
|
9722
|
+
const events = lifecycle.get(id2) ?? [];
|
|
9723
|
+
lifecycle.set(id2, [
|
|
9724
|
+
...events,
|
|
9725
|
+
{
|
|
9726
|
+
execution_id: id2,
|
|
9727
|
+
sequence: events.length + 1,
|
|
9728
|
+
type: status === "completed" ? "workflow.completed" : "workflow.failed",
|
|
9729
|
+
...data === undefined ? {} : { data: clone3(data) },
|
|
9730
|
+
created_at: now
|
|
9731
|
+
}
|
|
9732
|
+
]);
|
|
9733
|
+
return { transitioned: true, record: clone3(updated) };
|
|
9706
9734
|
})
|
|
9707
9735
|
});
|
|
9708
9736
|
});
|
|
9709
9737
|
var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
9710
9738
|
const sql = yield* SqlClient28;
|
|
9739
|
+
const operationUpsert = sql.onDialectOrElse({
|
|
9740
|
+
mysql: () => sql.literal("ON DUPLICATE KEY UPDATE status=VALUES(status), fan_out_id=VALUES(fan_out_id), decision=VALUES(decision), output_json=VALUES(output_json), attempt=VALUES(attempt), backoff_until=VALUES(backoff_until), compensation_operation_id=VALUES(compensation_operation_id), started_at=VALUES(started_at), completed_at=VALUES(completed_at), updated_at=VALUES(updated_at)"),
|
|
9741
|
+
orElse: () => sql.literal("ON CONFLICT (tenant_id, execution_id, operation_id) DO UPDATE SET status=excluded.status, fan_out_id=excluded.fan_out_id, decision=excluded.decision, output_json=excluded.output_json, attempt=excluded.attempt, backoff_until=excluded.backoff_until, compensation_operation_id=excluded.compensation_operation_id, started_at=excluded.started_at, completed_at=excluded.completed_at, updated_at=excluded.updated_at")
|
|
9742
|
+
});
|
|
9711
9743
|
const register = Effect29.fn("WorkflowDefinitionRepository.register")(function* (input) {
|
|
9712
9744
|
const tenant = yield* current();
|
|
9713
9745
|
const digest = yield* Effect29.promise(() => exports_workflow_schema.digestDefinition(input.definition));
|
|
@@ -9738,7 +9770,7 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9738
9770
|
start: Effect29.fn("WorkflowDefinitionRepository.start")(function* (input) {
|
|
9739
9771
|
const tenant = yield* current();
|
|
9740
9772
|
const now = yield* Clock3.currentTimeMillis;
|
|
9741
|
-
|
|
9773
|
+
const insert = sql.withTransaction(Effect29.gen(function* () {
|
|
9742
9774
|
const old = yield* sql`SELECT execution_id, workflow_definition_id, workflow_definition_revision, workflow_definition_digest, status, created_at, updated_at FROM relay_workflow_runs WHERE tenant_id=${tenant} AND execution_id=${input.execution_id}`;
|
|
9743
9775
|
if (old[0] !== undefined)
|
|
9744
9776
|
return decodeRun(old[0]);
|
|
@@ -9758,6 +9790,7 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9758
9790
|
updated_at: now
|
|
9759
9791
|
};
|
|
9760
9792
|
}));
|
|
9793
|
+
return yield* insert.pipe(Effect29.catch((error5) => sql`SELECT execution_id, workflow_definition_id, workflow_definition_revision, workflow_definition_digest, status, created_at, updated_at FROM relay_workflow_runs WHERE tenant_id=${tenant} AND execution_id=${input.execution_id}`.pipe(Effect29.flatMap((rows) => rows[0] === undefined ? Effect29.fail(error5) : Effect29.succeed(decodeRun(rows[0]))))));
|
|
9761
9794
|
}),
|
|
9762
9795
|
inspect: Effect29.fn("WorkflowDefinitionRepository.inspect")(function* (id2) {
|
|
9763
9796
|
const tenant = yield* current();
|
|
@@ -9772,9 +9805,7 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9772
9805
|
cancel: Effect29.fn("WorkflowDefinitionRepository.cancel")(function* (id2) {
|
|
9773
9806
|
const tenant = yield* current();
|
|
9774
9807
|
const now = yield* Clock3.currentTimeMillis;
|
|
9775
|
-
yield* sql
|
|
9776
|
-
const rows = yield* sql`SELECT execution_id, workflow_definition_id, workflow_definition_revision, workflow_definition_digest, status, created_at, updated_at FROM relay_workflow_runs WHERE tenant_id=${tenant} AND execution_id=${id2}`;
|
|
9777
|
-
return rows[0] === undefined ? undefined : decodeRun(rows[0]);
|
|
9808
|
+
return yield* transition2(sql, tenant, id2, "cancelled", now);
|
|
9778
9809
|
}),
|
|
9779
9810
|
getOperation: Effect29.fn("WorkflowDefinitionRepository.getOperation")(function* (executionId, operationId2) {
|
|
9780
9811
|
const tenant = yield* current();
|
|
@@ -9783,8 +9814,7 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9783
9814
|
}),
|
|
9784
9815
|
putOperation: Effect29.fn("WorkflowDefinitionRepository.putOperation")(function* (state) {
|
|
9785
9816
|
const tenant = yield* current();
|
|
9786
|
-
yield* sql`
|
|
9787
|
-
yield* sql`INSERT INTO relay_workflow_operation_states (tenant_id, execution_id, operation_id, status, fan_out_id, decision, output_json, attempt, backoff_until, compensation_operation_id, started_at, completed_at, updated_at) VALUES (${tenant}, ${state.execution_id}, ${state.operation_id}, ${state.status}, ${state.fan_out_id ?? null}, ${state.decision === undefined ? null : state.decision}, ${state.output === undefined ? null : encodeJson(state.output)}, ${state.attempt ?? null}, ${state.backoff_until === undefined ? null : timestampParam(sql, state.backoff_until)}, ${state.compensation_operation_id ?? null}, ${state.started_at === undefined ? null : timestampParam(sql, state.started_at)}, ${state.completed_at === undefined ? null : timestampParam(sql, state.completed_at)}, ${timestampParam(sql, state.updated_at)})`;
|
|
9817
|
+
yield* sql`INSERT INTO relay_workflow_operation_states (tenant_id, execution_id, operation_id, status, fan_out_id, decision, output_json, attempt, backoff_until, compensation_operation_id, started_at, completed_at, updated_at) VALUES (${tenant}, ${state.execution_id}, ${state.operation_id}, ${state.status}, ${state.fan_out_id ?? null}, ${state.decision === undefined ? null : state.decision}, ${state.output === undefined ? null : encodeJson(state.output)}, ${state.attempt ?? null}, ${state.backoff_until === undefined ? null : timestampParam(sql, state.backoff_until)}, ${state.compensation_operation_id ?? null}, ${state.started_at === undefined ? null : timestampParam(sql, state.started_at)}, ${state.completed_at === undefined ? null : timestampParam(sql, state.completed_at)}, ${timestampParam(sql, state.updated_at)}) ${operationUpsert}`;
|
|
9788
9818
|
return state;
|
|
9789
9819
|
}),
|
|
9790
9820
|
listOperations: Effect29.fn("WorkflowDefinitionRepository.listOperations")(function* (executionId) {
|
|
@@ -9806,14 +9836,40 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9806
9836
|
const rows = yield* sql`SELECT * FROM relay_workflow_lifecycle_events WHERE tenant_id=${tenant} AND execution_id=${executionId} ORDER BY sequence`;
|
|
9807
9837
|
return rows.map(decodeLifecycle);
|
|
9808
9838
|
}),
|
|
9809
|
-
finish: Effect29.fn("WorkflowDefinitionRepository.finish")(function* (id2, status) {
|
|
9839
|
+
finish: Effect29.fn("WorkflowDefinitionRepository.finish")(function* (id2, status, data) {
|
|
9810
9840
|
const tenant = yield* current();
|
|
9811
9841
|
const now = yield* Clock3.currentTimeMillis;
|
|
9812
|
-
yield* sql
|
|
9813
|
-
|
|
9814
|
-
|
|
9842
|
+
return yield* transition2(sql, tenant, id2, status, now, data);
|
|
9843
|
+
})
|
|
9844
|
+
});
|
|
9845
|
+
}));
|
|
9846
|
+
var transition2 = (sql, tenant, id2, status, now, data) => sql.withTransaction(Effect29.gen(function* () {
|
|
9847
|
+
const result = yield* sql.onDialectOrElse({
|
|
9848
|
+
mysql: () => Effect29.gen(function* () {
|
|
9849
|
+
const before = yield* sql`SELECT execution_id, workflow_definition_id, workflow_definition_revision, workflow_definition_digest, status, created_at, updated_at FROM relay_workflow_runs WHERE tenant_id=${tenant} AND execution_id=${id2} FOR UPDATE`;
|
|
9850
|
+
if (before[0] === undefined)
|
|
9851
|
+
return { transitioned: false, record: undefined };
|
|
9852
|
+
if (before[0].status !== "running")
|
|
9853
|
+
return { transitioned: false, record: decodeRun(before[0]) };
|
|
9854
|
+
yield* sql`UPDATE relay_workflow_runs SET status=${status}, updated_at=${timestampParam(sql, now)} WHERE tenant_id=${tenant} AND execution_id=${id2} AND status='running'`;
|
|
9855
|
+
const rows2 = yield* sql`SELECT execution_id, workflow_definition_id, workflow_definition_revision, workflow_definition_digest, status, created_at, updated_at FROM relay_workflow_runs WHERE tenant_id=${tenant} AND execution_id=${id2}`;
|
|
9856
|
+
return { transitioned: true, record: decodeRun(rows2[0]) };
|
|
9857
|
+
}),
|
|
9858
|
+
orElse: () => Effect29.gen(function* () {
|
|
9859
|
+
const changed = yield* sql`UPDATE relay_workflow_runs SET status=${status}, updated_at=${timestampParam(sql, now)} WHERE tenant_id=${tenant} AND execution_id=${id2} AND status='running' RETURNING execution_id, workflow_definition_id, workflow_definition_revision, workflow_definition_digest, status, created_at, updated_at`;
|
|
9860
|
+
if (changed[0] !== undefined)
|
|
9861
|
+
return { transitioned: true, record: decodeRun(changed[0]) };
|
|
9862
|
+
const rows2 = yield* sql`SELECT execution_id, workflow_definition_id, workflow_definition_revision, workflow_definition_digest, status, created_at, updated_at FROM relay_workflow_runs WHERE tenant_id=${tenant} AND execution_id=${id2}`;
|
|
9863
|
+
return { transitioned: false, record: rows2[0] === undefined ? undefined : decodeRun(rows2[0]) };
|
|
9815
9864
|
})
|
|
9816
9865
|
});
|
|
9866
|
+
if (!result.transitioned)
|
|
9867
|
+
return result;
|
|
9868
|
+
const rows = yield* sql`SELECT COALESCE(MAX(sequence), 0) AS sequence FROM relay_workflow_lifecycle_events WHERE tenant_id=${tenant} AND execution_id=${id2}`;
|
|
9869
|
+
const sequence = Number(rows[0]?.sequence ?? 0) + 1;
|
|
9870
|
+
const eventType = status === "cancelled" ? "workflow.cancelled" : status === "completed" ? "workflow.completed" : "workflow.failed";
|
|
9871
|
+
yield* sql`INSERT INTO relay_workflow_lifecycle_events (tenant_id, execution_id, sequence, event_type, operation_id, data_json, created_at) VALUES (${tenant}, ${id2}, ${sequence}, ${eventType}, ${null}, ${data === undefined ? null : encodeJson(data)}, ${timestampParam(sql, now)})`;
|
|
9872
|
+
return result;
|
|
9817
9873
|
}));
|
|
9818
9874
|
var decodeDefinition = (row) => ({
|
|
9819
9875
|
id: exports_ids_schema.WorkflowDefinitionId.make(row.workflow_definition_id),
|
|
@@ -10248,7 +10304,10 @@ var layerFromRepository2 = Layer30.effect(Service30, Effect33.gen(function* () {
|
|
|
10248
10304
|
yield* recordEventReplayed("repository", replay.history.length);
|
|
10249
10305
|
return replay.history;
|
|
10250
10306
|
}),
|
|
10251
|
-
stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect33.map(({ history, sequence }) =>
|
|
10307
|
+
stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect33.map(({ history, sequence }) => {
|
|
10308
|
+
const replay = Stream5.fromIterable(history);
|
|
10309
|
+
return history.some(isTerminal) ? replay : replay.pipe(Stream5.concat(liveTail(repository, hubs, input, history.at(-1)?.sequence ?? sequence).pipe(Stream5.takeUntil(isTerminal))));
|
|
10310
|
+
}))),
|
|
10252
10311
|
findBySequenceOrCursor: Effect33.fn("EventLog.repository.findBySequenceOrCursor")((input) => repository.findBySequenceOrCursor(input).pipe(Effect33.mapError(mapRepositoryFindError))),
|
|
10253
10312
|
findByCursor: Effect33.fn("EventLog.repository.findByCursor")((input) => repository.findByCursor(input).pipe(Effect33.mapError(mapRepositoryFindError))),
|
|
10254
10313
|
findBySequence: Effect33.fn("EventLog.repository.findBySequence")((input) => repository.findBySequence(input).pipe(Effect33.mapError(mapRepositoryFindError))),
|
|
@@ -10300,7 +10359,10 @@ var memoryLayer28 = Layer30.effect(Service30, Effect33.gen(function* () {
|
|
|
10300
10359
|
yield* recordEventReplayed("memory", replay.history.length);
|
|
10301
10360
|
return replay.history;
|
|
10302
10361
|
}),
|
|
10303
|
-
stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect33.map(({ history, sequence }) =>
|
|
10362
|
+
stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect33.map(({ history, sequence }) => {
|
|
10363
|
+
const replay = Stream5.fromIterable(history);
|
|
10364
|
+
return history.some(isTerminal) ? replay : replay.pipe(Stream5.concat(liveEvents(pubsub, input, history, sequence)));
|
|
10365
|
+
}))),
|
|
10304
10366
|
findBySequenceOrCursor: Effect33.fn("EventLog.memory.findBySequenceOrCursor")(function* (input) {
|
|
10305
10367
|
const executionEvents = yield* allEvents(input.executionId);
|
|
10306
10368
|
const event = executionEvents.find((item) => item.sequence === input.sequence || item.cursor === input.cursor);
|
|
@@ -13640,7 +13702,16 @@ var ModelInput = Schema65.Struct({
|
|
|
13640
13702
|
model: Schema65.String,
|
|
13641
13703
|
registration_key: Schema65.optionalKey(Schema65.String)
|
|
13642
13704
|
}))),
|
|
13643
|
-
compaction_policy: Schema65.optionalKey(
|
|
13705
|
+
compaction_policy: Schema65.optionalKey(Schema65.Struct({
|
|
13706
|
+
context_window: Schema65.Number,
|
|
13707
|
+
reserve_tokens: Schema65.Number,
|
|
13708
|
+
keep_recent_tokens: Schema65.Number,
|
|
13709
|
+
summary_model: Schema65.optionalKey(Schema65.Struct({
|
|
13710
|
+
provider: Schema65.String,
|
|
13711
|
+
model: Schema65.String,
|
|
13712
|
+
registration_key: Schema65.optionalKey(Schema65.String)
|
|
13713
|
+
}))
|
|
13714
|
+
})),
|
|
13644
13715
|
tool_names: Schema65.optionalKey(Schema65.Array(Schema65.String)),
|
|
13645
13716
|
permissions: Schema65.optionalKey(Schema65.Array(Schema65.String)),
|
|
13646
13717
|
output_schema_ref: Schema65.optionalKey(Schema65.NullOr(Schema65.String)),
|
|
@@ -14129,6 +14200,7 @@ var forget2 = Effect58.fn("MemoryService.forget.call")(function* (input) {
|
|
|
14129
14200
|
var exports_language_model_service = {};
|
|
14130
14201
|
__export(exports_language_model_service, {
|
|
14131
14202
|
testLayer: () => testLayer39,
|
|
14203
|
+
resolve: () => resolve4,
|
|
14132
14204
|
registrations: () => registrations3,
|
|
14133
14205
|
registrationFromLayer: () => registrationFromLayer3,
|
|
14134
14206
|
register: () => register6,
|
|
@@ -14147,6 +14219,13 @@ var toSelection = (selection) => ({
|
|
|
14147
14219
|
model: selection.model,
|
|
14148
14220
|
...selection.registration_key === undefined ? {} : { registrationKey: selection.registration_key }
|
|
14149
14221
|
});
|
|
14222
|
+
var registrationKey = (value) => value.registration_key ?? value.registrationKey;
|
|
14223
|
+
var matchesSelection3 = (selection, registration) => registration.provider === selection.provider && registration.model === selection.model && registrationKey(registration) === registrationKey(selection);
|
|
14224
|
+
var notRegistered = (selection) => new LanguageModelNotRegistered2({
|
|
14225
|
+
provider: selection.provider,
|
|
14226
|
+
model: selection.model,
|
|
14227
|
+
...selection.registration_key === undefined ? {} : { registration_key: selection.registration_key }
|
|
14228
|
+
});
|
|
14150
14229
|
|
|
14151
14230
|
class Service40 extends Context53.Service()("@relayfx/runtime/LanguageModelService") {
|
|
14152
14231
|
}
|
|
@@ -14171,6 +14250,11 @@ var registrations3 = Effect59.fn("LanguageModelService.registrations.call")(func
|
|
|
14171
14250
|
const service = yield* Service40;
|
|
14172
14251
|
return yield* service.registrations;
|
|
14173
14252
|
});
|
|
14253
|
+
var resolve4 = Effect59.fn("LanguageModelService.resolve.call")(function* (selection) {
|
|
14254
|
+
const service = yield* Service40;
|
|
14255
|
+
const registered = yield* service.registrations;
|
|
14256
|
+
return yield* Effect59.fromNullishOr(registered.find((registration) => matchesSelection3(selection, registration))).pipe(Effect59.mapError(() => notRegistered(selection)));
|
|
14257
|
+
});
|
|
14174
14258
|
var provide2 = (selection, effect) => Effect59.gen(function* () {
|
|
14175
14259
|
const service = yield* Service40;
|
|
14176
14260
|
return yield* service.provide(selection, effect);
|
|
@@ -14300,7 +14384,7 @@ var layer44 = (initialRegistrations = []) => Layer57.effect(Service43, Effect62.
|
|
|
14300
14384
|
yield* Ref17.update(registry, (items) => upsertRegistration2(items, registration));
|
|
14301
14385
|
});
|
|
14302
14386
|
const registrations4 = Ref17.get(registry);
|
|
14303
|
-
const
|
|
14387
|
+
const resolve5 = Effect62.fn("SchemaRegistry.resolve")(function* (ref) {
|
|
14304
14388
|
const items = yield* Ref17.get(registry);
|
|
14305
14389
|
const found = items.find((item) => item.ref === ref);
|
|
14306
14390
|
if (found === undefined) {
|
|
@@ -14308,7 +14392,7 @@ var layer44 = (initialRegistrations = []) => Layer57.effect(Service43, Effect62.
|
|
|
14308
14392
|
}
|
|
14309
14393
|
return found;
|
|
14310
14394
|
});
|
|
14311
|
-
return Service43.of({ register: register8, registrations: registrations4, resolve:
|
|
14395
|
+
return Service43.of({ register: register8, registrations: registrations4, resolve: resolve5 });
|
|
14312
14396
|
}));
|
|
14313
14397
|
var register8 = Effect62.fn("SchemaRegistry.register.call")(function* (registration) {
|
|
14314
14398
|
const service = yield* Service43;
|
|
@@ -14318,7 +14402,7 @@ var registrations4 = Effect62.fn("SchemaRegistry.registrations.call")(function*
|
|
|
14318
14402
|
const service = yield* Service43;
|
|
14319
14403
|
return yield* service.registrations;
|
|
14320
14404
|
});
|
|
14321
|
-
var
|
|
14405
|
+
var resolve5 = Effect62.fn("SchemaRegistry.resolve.call")(function* (ref) {
|
|
14322
14406
|
const service = yield* Service43;
|
|
14323
14407
|
return yield* service.resolve(ref);
|
|
14324
14408
|
});
|
|
@@ -14387,7 +14471,7 @@ var memoryLayer37 = Layer58.effect(Service44, Effect63.gen(function* () {
|
|
|
14387
14471
|
})
|
|
14388
14472
|
});
|
|
14389
14473
|
}));
|
|
14390
|
-
var
|
|
14474
|
+
var resolve6 = Effect63.fn("BlobStore.resolve.call")(function* (part) {
|
|
14391
14475
|
const service = yield* Service44;
|
|
14392
14476
|
return yield* service.resolve(part);
|
|
14393
14477
|
});
|
|
@@ -16500,15 +16584,15 @@ var makeLayer = (signalDependencies) => Layer69.effect(Service55, Effect76.gen(f
|
|
|
16500
16584
|
if (wait?.state === "open") {
|
|
16501
16585
|
const waitId = wait.id;
|
|
16502
16586
|
const sequence = yield* nextSequence(eventLog, input.executionId).pipe(Effect76.mapError((error5) => new InboxDeliveryError({ execution_id: input.executionId, message: error5._tag })));
|
|
16503
|
-
const
|
|
16587
|
+
const transition3 = yield* waits.wake({ waitId, resolvedAt: input.createdAt, eventSequence: sequence }).pipe(Effect76.mapError((error5) => new InboxDeliveryError({
|
|
16504
16588
|
execution_id: input.executionId,
|
|
16505
16589
|
message: error5._tag === "WaitNotFound" ? error5.wait_id : error5.message
|
|
16506
16590
|
})));
|
|
16507
|
-
if (
|
|
16591
|
+
if (transition3.transitioned && signalDependencies !== undefined) {
|
|
16508
16592
|
yield* signalWorkflowWait({
|
|
16509
16593
|
makeExecutionClient: signalDependencies.makeExecutionClient,
|
|
16510
|
-
executionId:
|
|
16511
|
-
waitId:
|
|
16594
|
+
executionId: transition3.wait.executionId,
|
|
16595
|
+
waitId: transition3.wait.id,
|
|
16512
16596
|
state: "resolved",
|
|
16513
16597
|
signaledAt: input.createdAt
|
|
16514
16598
|
}).pipe(Effect76.provideService(exports_execution_repository.Service, signalDependencies.executionRepository), Effect76.mapError((error5) => new InboxDeliveryError({ execution_id: input.executionId, message: String(error5) })));
|
|
@@ -16546,14 +16630,14 @@ var makeLayer = (signalDependencies) => Layer69.effect(Service55, Effect76.gen(f
|
|
|
16546
16630
|
}
|
|
16547
16631
|
}).pipe(Effect76.mapError((error5) => new InboxDeliveryError({ execution_id: wait.executionId, message: error5.message })));
|
|
16548
16632
|
const sequence = yield* nextSequence(eventLog, wait.executionId).pipe(Effect76.mapError((error5) => new InboxDeliveryError({ execution_id: wait.executionId, message: error5._tag })));
|
|
16549
|
-
const
|
|
16550
|
-
if (!
|
|
16633
|
+
const transition3 = yield* waits.wake({ waitId, resolvedAt: input.createdAt, eventSequence: sequence }).pipe(Effect76.mapError(() => new InboxReplyTokenInvalid({ reply_token: input.replyToken })));
|
|
16634
|
+
if (!transition3.transitioned)
|
|
16551
16635
|
return yield* new InboxReplyTokenInvalid({ reply_token: input.replyToken });
|
|
16552
16636
|
if (signalDependencies !== undefined) {
|
|
16553
16637
|
yield* signalWorkflowWait({
|
|
16554
16638
|
makeExecutionClient: signalDependencies.makeExecutionClient,
|
|
16555
|
-
executionId:
|
|
16556
|
-
waitId:
|
|
16639
|
+
executionId: transition3.wait.executionId,
|
|
16640
|
+
waitId: transition3.wait.id,
|
|
16557
16641
|
state: "resolved",
|
|
16558
16642
|
signaledAt: input.createdAt
|
|
16559
16643
|
}).pipe(Effect76.provideService(exports_execution_repository.Service, signalDependencies.executionRepository), Effect76.mapError((error5) => new InboxDeliveryError({ execution_id: wait.executionId, message: String(error5) })));
|
|
@@ -16738,8 +16822,8 @@ var registeredTool4 = (config) => tool(toolName4, {
|
|
|
16738
16822
|
}).pipe(Effect79.mapError((error5) => new ToolRuntimeError({ message: error5.message })));
|
|
16739
16823
|
if ((yield* config.inbox.undrainedCount(context.executionId).pipe(Effect79.mapError((error5) => new ToolRuntimeError({ message: error5.message })))) > 0) {
|
|
16740
16824
|
const sequence = yield* config.eventLog.maxSequence(context.executionId).pipe(Effect79.map((value) => (value ?? -1) + 1), Effect79.mapError((error5) => new ToolRuntimeError({ message: error5._tag })));
|
|
16741
|
-
const
|
|
16742
|
-
if (
|
|
16825
|
+
const transition3 = yield* config.waits.wake({ waitId, resolvedAt: context.createdAt, eventSequence: sequence }).pipe(Effect79.mapError((error5) => new ToolRuntimeError({ message: error5._tag })));
|
|
16826
|
+
if (transition3.transitioned) {
|
|
16743
16827
|
const drained = yield* drain3();
|
|
16744
16828
|
return { status: "messages", messages: drained.map(project2) };
|
|
16745
16829
|
}
|
|
@@ -17032,7 +17116,7 @@ var memoryServiceLayer = Layer72.effect(Service58, Effect82.gen(function* () {
|
|
|
17032
17116
|
return Service58.of({ resolve: memory.resolve });
|
|
17033
17117
|
}));
|
|
17034
17118
|
var memoryLayer44 = memoryServiceLayer.pipe(Layer72.provideMerge(Layer72.effect(Memory2, makeMemory2)));
|
|
17035
|
-
var
|
|
17119
|
+
var resolve7 = Effect82.fn("ArtifactStore.resolve.call")(function* (part) {
|
|
17036
17120
|
const service = yield* Service58;
|
|
17037
17121
|
return yield* service.resolve(part);
|
|
17038
17122
|
});
|
|
@@ -17165,7 +17249,7 @@ var strategy2 = (config) => {
|
|
|
17165
17249
|
const existing = yield* config.repository.get({ executionId: config.executionId, checkpointId: id2 }).pipe(Effect84.mapError(mapRepositoryError12));
|
|
17166
17250
|
if (existing !== undefined)
|
|
17167
17251
|
return existing.summary;
|
|
17168
|
-
const summary = yield* base2.summarize(plan2, request);
|
|
17252
|
+
const summary = yield* config.options?.summaryModel === undefined ? base2.summarize(plan2, request) : config.options.summaryModel.pipe(Effect84.flatMap((model) => base2.summarize(plan2, request).pipe(Effect84.provide(model))));
|
|
17169
17253
|
const createdAt = yield* Clock12.currentTimeMillis;
|
|
17170
17254
|
const input = {
|
|
17171
17255
|
executionId: config.executionId,
|
|
@@ -18001,7 +18085,16 @@ var layer59 = Layer79.effect(Service54, Effect90.gen(function* () {
|
|
|
18001
18085
|
yield* appendEvent(eventLog, inputPreparedEvent(input, definitions2), input.eventSequence + 1);
|
|
18002
18086
|
const toolOutputMaxBytes = yield* effectiveToolOutputMaxBytes(input);
|
|
18003
18087
|
const compactionPolicy = input.agent.compaction_policy;
|
|
18004
|
-
const
|
|
18088
|
+
const configuredCompactionOptions = compactionOptions(input.agent);
|
|
18089
|
+
const activeCompactionOptions = configuredCompactionOptions === undefined ? undefined : {
|
|
18090
|
+
...configuredCompactionOptions,
|
|
18091
|
+
...compactionPolicy?.summary_model === undefined ? {} : {
|
|
18092
|
+
summaryModel: resolve4(compactionPolicy.summary_model).pipe(Effect90.provideService(Service40, languageModels), Effect90.map((registration) => registration.layer), Effect90.mapError((error5) => new exports_compaction.CompactionError({
|
|
18093
|
+
message: `LanguageModelNotRegistered: ${error5.provider}/${error5.model}`,
|
|
18094
|
+
cause: error5
|
|
18095
|
+
})))
|
|
18096
|
+
}
|
|
18097
|
+
};
|
|
18005
18098
|
const runTokenizer = yield* Effect90.serviceOption(Tokenizer4.Tokenizer);
|
|
18006
18099
|
const activeTokenizer = Option27.isSome(runTokenizer) ? runTokenizer : tokenizer;
|
|
18007
18100
|
const allocator = yield* make14(input.eventSequence + 1);
|
|
@@ -18368,7 +18461,7 @@ var terminal2 = Effect92.fn("ChildFanOutTransitionService.terminal.call")(functi
|
|
|
18368
18461
|
return yield* service.terminal(input);
|
|
18369
18462
|
});
|
|
18370
18463
|
// ../runtime/src/child/child-fan-out-runtime.ts
|
|
18371
|
-
import { Clock as Clock15, Context as Context75, Effect as Effect93, Layer as Layer82, Schema as Schema94 } from "effect";
|
|
18464
|
+
import { Clock as Clock15, Context as Context75, Effect as Effect93, FiberMap, Layer as Layer82, Schema as Schema94 } from "effect";
|
|
18372
18465
|
class HandlerService extends Context75.Service()("@relayfx/runtime/ChildFanOutRuntimeHandlers") {
|
|
18373
18466
|
}
|
|
18374
18467
|
|
|
@@ -18378,11 +18471,11 @@ class ChildFanOutRuntimeError extends Schema94.TaggedErrorClass()("ChildFanOutRu
|
|
|
18378
18471
|
class Service62 extends Context75.Service()("@relayfx/runtime/ChildFanOutRuntime") {
|
|
18379
18472
|
}
|
|
18380
18473
|
var runtimeError = (error5) => new ChildFanOutRuntimeError({ message: String(error5) });
|
|
18381
|
-
var
|
|
18474
|
+
var layerFromRuntime = Layer82.effect(Service62, Effect93.gen(function* () {
|
|
18382
18475
|
const repository = yield* exports_child_fan_out_repository.Service;
|
|
18383
18476
|
const transitions = yield* Service61;
|
|
18384
18477
|
const handlers = yield* HandlerService;
|
|
18385
|
-
const
|
|
18478
|
+
const hosts = yield* FiberMap.make();
|
|
18386
18479
|
const run5 = Effect93.fn("ChildFanOutRuntime.run")(function* (fanOutId) {
|
|
18387
18480
|
while (true) {
|
|
18388
18481
|
const fanOut = yield* repository.get(fanOutId);
|
|
@@ -18412,7 +18505,7 @@ var layer62 = Layer82.effect(Service62, Effect93.gen(function* () {
|
|
|
18412
18505
|
})), { concurrency: fanOut.max_concurrency, discard: true });
|
|
18413
18506
|
}
|
|
18414
18507
|
});
|
|
18415
|
-
const launch = (fanOutId) => run5(fanOutId).pipe(Effect93.ignore,
|
|
18508
|
+
const launch = (fanOutId) => FiberMap.run(hosts, fanOutId, run5(fanOutId).pipe(Effect93.ignore), { onlyIfMissing: true }).pipe(Effect93.asVoid);
|
|
18416
18509
|
const recover2 = Effect93.fn("ChildFanOutRuntime.recover")(function* () {
|
|
18417
18510
|
const fanOuts = yield* repository.listNonTerminal();
|
|
18418
18511
|
yield* Effect93.forEach(fanOuts, (fanOut) => launch(fanOut.fan_out_id), { discard: true });
|
|
@@ -18467,7 +18560,7 @@ var entity = Entity2.make("Relay/Execution", [
|
|
|
18467
18560
|
SignalWait,
|
|
18468
18561
|
Cancel
|
|
18469
18562
|
]).annotate(ClusterSchema.ShardGroup, () => "execution");
|
|
18470
|
-
var
|
|
18563
|
+
var layer62 = entity.toLayer(entity.of({
|
|
18471
18564
|
start: (request) => startRequest(request.payload),
|
|
18472
18565
|
dispatch: (request) => dispatchRequest(request.payload),
|
|
18473
18566
|
signalWait: (request) => signalWait(request.payload),
|
|
@@ -18498,7 +18591,7 @@ class EntityRegistryError extends Schema96.TaggedErrorClass()("EntityRegistryErr
|
|
|
18498
18591
|
class Service63 extends Context76.Service()("@relayfx/runtime/EntityRegistry") {
|
|
18499
18592
|
}
|
|
18500
18593
|
var repositoryError4 = (error5) => new EntityRegistryError({ message: error5.message });
|
|
18501
|
-
var
|
|
18594
|
+
var layer63 = Layer83.effect(Service63, Effect94.gen(function* () {
|
|
18502
18595
|
const repository = yield* exports_entity_repository.Service;
|
|
18503
18596
|
const agents = yield* Service33;
|
|
18504
18597
|
return Service63.of({
|
|
@@ -18556,7 +18649,7 @@ var lifecycleEvent = (instance, type, at, sequence) => ({
|
|
|
18556
18649
|
data: { kind: instance.kind, key: instance.key, generation: instance.generation },
|
|
18557
18650
|
created_at: at
|
|
18558
18651
|
});
|
|
18559
|
-
var
|
|
18652
|
+
var layer64 = Layer84.effect(Service64, Effect95.gen(function* () {
|
|
18560
18653
|
const repository = yield* exports_entity_repository.Service;
|
|
18561
18654
|
const registry = yield* Service63;
|
|
18562
18655
|
const agents = yield* Service33;
|
|
@@ -18737,7 +18830,7 @@ __export(exports_runner_runtime_service, {
|
|
|
18737
18830
|
layerWithLanguageModelService: () => layerWithLanguageModelService,
|
|
18738
18831
|
layerWithClient: () => layerWithClient,
|
|
18739
18832
|
layerWith: () => layerWith,
|
|
18740
|
-
layer: () =>
|
|
18833
|
+
layer: () => layer66,
|
|
18741
18834
|
clusterShardingConfigLayer: () => clusterShardingConfigLayer,
|
|
18742
18835
|
clusterLayerHttpClientOnly: () => clusterLayerHttpClientOnly,
|
|
18743
18836
|
clusterLayerHttp: () => clusterLayerHttp,
|
|
@@ -18913,7 +19006,7 @@ var pollLoop = (service, pollIntervalMillis) => Effect98.gen(function* () {
|
|
|
18913
19006
|
}
|
|
18914
19007
|
}
|
|
18915
19008
|
});
|
|
18916
|
-
var
|
|
19009
|
+
var layer65 = Layer87.effect(Service67, Effect98.gen(function* () {
|
|
18917
19010
|
const service = yield* make15;
|
|
18918
19011
|
const enabled3 = yield* enabledConfig;
|
|
18919
19012
|
const pollIntervalMillis = yield* pollIntervalMillisConfig;
|
|
@@ -19053,7 +19146,8 @@ var assertClusterConfig = Effect99.fn("RunnerRuntime.assertClusterConfig")(funct
|
|
|
19053
19146
|
return yield* new ClusterConfigMismatch({ field: "availableShardGroups", expected: want, actual });
|
|
19054
19147
|
}
|
|
19055
19148
|
});
|
|
19056
|
-
var
|
|
19149
|
+
var sqlNotificationLayer = exports_notification_bus.layerFromDialect;
|
|
19150
|
+
var sqlRepositoryBaseLayer = Layer88.mergeAll(exports_address_book_repository.layer, exports_agent_chat_repository.layer, exports_agent_definition_repository.layer, exports_workflow_definition_repository.layer, exports_child_execution_repository.layer, exports_child_fan_out_repository.layer, exports_cluster_registry_repository.layer, exports_compaction_repository.layer, exports_context_epoch_repository.layer, exports_execution_repository.layerWithoutBus, exports_envelope_repository.layer, exports_entity_repository.layer, exports_execution_event_repository.layer, exports_inbox_repository.layer, exports_memory_repository.layer, exports_topic_repository.layer, exports_permission_rule_repository.layer, exports_presence_repository.layer, exports_schedule_repository.layer, exports_session_repository.layer, exports_skill_definition_repository.layer, exports_steering_repository.layer, exports_tool_call_repository.layer, exports_workspace_lease_repository.layer).pipe(Layer88.provideMerge(sqlNotificationLayer));
|
|
19057
19151
|
var sqlRepositoryLayer = Layer88.mergeAll(sqlRepositoryBaseLayer, exports_execution_state_repository.layer.pipe(Layer88.provide(sqlRepositoryBaseLayer)));
|
|
19058
19152
|
var memoryRepositoryBaseLayer = Layer88.mergeAll(exports_address_book_repository.memoryLayer, exports_agent_chat_repository.memoryLayer, exports_agent_definition_repository.memoryLayer, exports_workflow_definition_repository.memoryLayer, exports_child_execution_repository.memoryLayer, exports_child_fan_out_repository.memoryLayer, exports_cluster_registry_repository.memoryLayer, exports_compaction_repository.memoryLayer, exports_context_epoch_repository.memoryLayer, exports_execution_repository.memoryLayer, exports_envelope_repository.memoryLayer, exports_entity_repository.memoryLayer, exports_execution_event_repository.memoryLayer, exports_inbox_repository.memoryLayer, exports_memory_repository.memoryLayer, exports_topic_repository.memoryLayer, exports_permission_rule_repository.memoryLayer, exports_presence_repository.memoryLayer, exports_schedule_repository.memoryLayer, exports_session_repository.memoryLayer, exports_skill_definition_repository.memoryLayer, exports_steering_repository.memoryLayer, exports_tool_call_repository.memoryLayer, exports_workspace_lease_repository.memoryLayer);
|
|
19059
19153
|
var memoryRepositoryLayer = Layer88.mergeAll(memoryRepositoryBaseLayer, exports_execution_state_repository.memoryLayer.pipe(Layer88.provide(memoryRepositoryBaseLayer)));
|
|
@@ -19086,12 +19180,12 @@ var runtimeServicesLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRe
|
|
|
19086
19180
|
const envelopeLayer = layer53.pipe(Layer88.provideMerge(layerFromRepository), Layer88.provideMerge(inboxLayer));
|
|
19087
19181
|
const topicLayer = layer52.pipe(Layer88.provideMerge(inboxLayer));
|
|
19088
19182
|
const agentLayer = agentLoopLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer).pipe(Layer88.provideMerge(inboxLayer), Layer88.provideMerge(envelopeLayer), Layer88.provideMerge(topicLayer));
|
|
19089
|
-
const entityRegistryLayer =
|
|
19090
|
-
const entityInstanceLayer =
|
|
19183
|
+
const entityRegistryLayer = layer63.pipe(Layer88.provideMerge(layer30));
|
|
19184
|
+
const entityInstanceLayer = layer64.pipe(Layer88.provideMerge(entityRegistryLayer), Layer88.provideMerge(layerFromRepository), Layer88.provideMerge(layerFromRepository2));
|
|
19091
19185
|
return Layer88.mergeAll(addressResolutionLayerWith(toolRuntimeLayer), layer46, executionServiceLayer, layerFromServices, layerFromServices2, layerFromRepository3, agentLayer, layer49, parentNotifierLayer, inboxLayer, envelopeLayer, topicLayer, entityRegistryLayer, entityInstanceLayer, toolTransitionCoordinatorLayer, layer48).pipe(Layer88.provideMerge(layer45), Layer88.provideMerge(layer28), Layer88.provideMerge(layerFromRepository2));
|
|
19092
19186
|
};
|
|
19093
19187
|
var workflowLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer) => layer50.pipe(Layer88.provideMerge(runtimeServicesLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer)));
|
|
19094
|
-
var workflowAndEntityLayerWith = (toolRuntimeLayer, schedulerLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer) => Layer88.mergeAll(
|
|
19188
|
+
var workflowAndEntityLayerWith = (toolRuntimeLayer, schedulerLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer) => Layer88.mergeAll(layer62, schedulerLayer).pipe(Layer88.provideMerge(workflowLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer)));
|
|
19095
19189
|
var makeService2 = (database, checkDatabase) => Effect99.gen(function* () {
|
|
19096
19190
|
const sharding = yield* Sharding.Sharding;
|
|
19097
19191
|
const workflow = yield* WorkflowEngine.WorkflowEngine;
|
|
@@ -19209,7 +19303,7 @@ var layerWithServices = (options) => {
|
|
|
19209
19303
|
languageModelLayer: options.languageModelLayer,
|
|
19210
19304
|
embeddingModelLayer: options.embeddingModelLayer,
|
|
19211
19305
|
toolRuntimeLayer: options.toolRuntimeLayer,
|
|
19212
|
-
schedulerLayer:
|
|
19306
|
+
schedulerLayer: layer65,
|
|
19213
19307
|
promptAssemblerLayer: options.promptAssemblerLayer,
|
|
19214
19308
|
blobStoreLayer: options.blobStoreLayer,
|
|
19215
19309
|
artifactStoreLayer: options.artifactStoreLayer,
|
|
@@ -19226,7 +19320,7 @@ var layerWithServicesMultiNode = (options) => {
|
|
|
19226
19320
|
languageModelLayer: options.languageModelLayer,
|
|
19227
19321
|
embeddingModelLayer: options.embeddingModelLayer,
|
|
19228
19322
|
toolRuntimeLayer: options.toolRuntimeLayer,
|
|
19229
|
-
schedulerLayer:
|
|
19323
|
+
schedulerLayer: layer65,
|
|
19230
19324
|
promptAssemblerLayer: options.promptAssemblerLayer,
|
|
19231
19325
|
blobStoreLayer: options.blobStoreLayer,
|
|
19232
19326
|
artifactStoreLayer: options.artifactStoreLayer,
|
|
@@ -19251,7 +19345,7 @@ var layerWithServicesMultiNodeClientOnly = (options) => {
|
|
|
19251
19345
|
return runtime.pipe(Layer88.provide(options.databaseLayer));
|
|
19252
19346
|
};
|
|
19253
19347
|
var layerWithLanguageModelService = (options) => layerWithServices({ ...options, toolRuntimeLayer: layer29() });
|
|
19254
|
-
var
|
|
19348
|
+
var layer66 = layerWith({
|
|
19255
19349
|
toolTransitionCoordinatorLayer: sqlLayer,
|
|
19256
19350
|
checkLayer: sqlCheckLayer,
|
|
19257
19351
|
clusterLayer: sqlClusterLayer,
|
|
@@ -19259,7 +19353,7 @@ var layer67 = layerWith({
|
|
|
19259
19353
|
languageModelLayer: memoryLayer35(),
|
|
19260
19354
|
embeddingModelLayer: memoryLayer34(),
|
|
19261
19355
|
toolRuntimeLayer: layer29(),
|
|
19262
|
-
schedulerLayer:
|
|
19356
|
+
schedulerLayer: layer65
|
|
19263
19357
|
});
|
|
19264
19358
|
var testLayerWithServices = (options) => layerWith({
|
|
19265
19359
|
toolTransitionCoordinatorLayer: memoryLayer40,
|
|
@@ -19309,7 +19403,7 @@ var check = Effect99.fn("RunnerRuntime.check.call")(function* () {
|
|
|
19309
19403
|
return yield* service.check();
|
|
19310
19404
|
});
|
|
19311
19405
|
// ../runtime/src/workflow/definition-runtime.ts
|
|
19312
|
-
import { Cause as Cause5, Clock as Clock17, Context as Context82, Effect as Effect100, Exit as Exit3, Layer as Layer89, Option as Option30, Schema as Schema102 } from "effect";
|
|
19406
|
+
import { Cause as Cause5, Clock as Clock17, Context as Context82, Effect as Effect100, Exit as Exit3, FiberMap as FiberMap2, Layer as Layer89, Option as Option30, Schema as Schema102 } from "effect";
|
|
19313
19407
|
|
|
19314
19408
|
class UnsupportedOperation extends Schema102.TaggedErrorClass()("UnsupportedWorkflowOperation", { operation_id: exports_ids_schema.WorkflowOperationId, kind: Schema102.String }) {
|
|
19315
19409
|
}
|
|
@@ -19607,7 +19701,7 @@ var run5 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
19607
19701
|
});
|
|
19608
19702
|
break;
|
|
19609
19703
|
}
|
|
19610
|
-
const
|
|
19704
|
+
const completedAt = yield* Clock17.currentTimeMillis;
|
|
19611
19705
|
const current2 = yield* repository.getOperation(executionId, id2);
|
|
19612
19706
|
yield* repository.putOperation({
|
|
19613
19707
|
execution_id: executionId,
|
|
@@ -19617,15 +19711,15 @@ var run5 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
19617
19711
|
...current2?.decision === undefined ? {} : { decision: current2.decision },
|
|
19618
19712
|
...current2?.fan_out_id === undefined ? {} : { fan_out_id: current2.fan_out_id },
|
|
19619
19713
|
started_at: startedAt,
|
|
19620
|
-
completed_at:
|
|
19621
|
-
updated_at:
|
|
19714
|
+
completed_at: completedAt,
|
|
19715
|
+
updated_at: completedAt
|
|
19622
19716
|
});
|
|
19623
19717
|
yield* repository.appendLifecycle({
|
|
19624
19718
|
execution_id: executionId,
|
|
19625
19719
|
operation_id: id2,
|
|
19626
19720
|
type: "operation.completed",
|
|
19627
19721
|
...output2 === undefined ? {} : { data: output2 },
|
|
19628
|
-
created_at:
|
|
19722
|
+
created_at: completedAt
|
|
19629
19723
|
});
|
|
19630
19724
|
return output2;
|
|
19631
19725
|
});
|
|
@@ -19635,11 +19729,7 @@ var run5 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
19635
19729
|
if (Option30.isSome(failure3) && failure3.value instanceof WorkflowJoining)
|
|
19636
19730
|
return yield* result;
|
|
19637
19731
|
const currentRun = yield* repository.inspect(executionId);
|
|
19638
|
-
const now = yield* Clock17.currentTimeMillis;
|
|
19639
19732
|
if (currentRun?.status === "cancelled") {
|
|
19640
|
-
const events = yield* repository.listLifecycle(executionId);
|
|
19641
|
-
if (!events.some((event) => event.type === "workflow.cancelled"))
|
|
19642
|
-
yield* repository.appendLifecycle({ execution_id: executionId, type: "workflow.cancelled", created_at: now });
|
|
19643
19733
|
return yield* result;
|
|
19644
19734
|
}
|
|
19645
19735
|
const states = yield* repository.listOperations(executionId);
|
|
@@ -19655,44 +19745,33 @@ var run5 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
19655
19745
|
created_at: yield* Clock17.currentTimeMillis
|
|
19656
19746
|
});
|
|
19657
19747
|
yield* execute(state.compensation_operation_id);
|
|
19658
|
-
const
|
|
19748
|
+
const completedAt = yield* Clock17.currentTimeMillis;
|
|
19659
19749
|
yield* repository.putOperation({
|
|
19660
19750
|
...state,
|
|
19661
19751
|
status: "compensated",
|
|
19662
|
-
completed_at:
|
|
19663
|
-
updated_at:
|
|
19752
|
+
completed_at: completedAt,
|
|
19753
|
+
updated_at: completedAt
|
|
19664
19754
|
});
|
|
19665
19755
|
yield* repository.appendLifecycle({
|
|
19666
19756
|
execution_id: executionId,
|
|
19667
19757
|
operation_id: state.operation_id,
|
|
19668
19758
|
type: "compensation.completed",
|
|
19669
|
-
created_at:
|
|
19759
|
+
created_at: completedAt
|
|
19670
19760
|
});
|
|
19671
19761
|
}
|
|
19672
19762
|
yield* repository.finish(executionId, "failed");
|
|
19673
|
-
yield* repository.appendLifecycle({
|
|
19674
|
-
execution_id: executionId,
|
|
19675
|
-
type: "workflow.failed",
|
|
19676
|
-
created_at: yield* Clock17.currentTimeMillis
|
|
19677
|
-
});
|
|
19678
19763
|
return yield* result;
|
|
19679
19764
|
}
|
|
19680
19765
|
const output = result.value;
|
|
19681
|
-
|
|
19682
|
-
yield* repository.finish(executionId, "completed");
|
|
19683
|
-
yield* repository.appendLifecycle({
|
|
19684
|
-
execution_id: executionId,
|
|
19685
|
-
type: "workflow.completed",
|
|
19686
|
-
...output === undefined ? {} : { data: output },
|
|
19687
|
-
created_at: completedAt
|
|
19688
|
-
});
|
|
19766
|
+
yield* repository.finish(executionId, "completed", output);
|
|
19689
19767
|
return output;
|
|
19690
19768
|
});
|
|
19691
|
-
var
|
|
19769
|
+
var layerFromRuntime2 = Layer89.effect(Service69, Effect100.gen(function* () {
|
|
19692
19770
|
const repository = yield* exports_workflow_definition_repository.Service;
|
|
19693
19771
|
const handlers = yield* HandlerService2;
|
|
19772
|
+
const hosts = yield* FiberMap2.make();
|
|
19694
19773
|
const execute = (executionId) => run5(executionId).pipe(Effect100.provideService(HandlerService2, handlers), Effect100.provideService(exports_workflow_definition_repository.Service, repository));
|
|
19695
|
-
const launch = Effect100.fn("WorkflowDefinitionRuntime.launch")((executionId) => execute(executionId).pipe(Effect100.ignore,
|
|
19774
|
+
const launch = Effect100.fn("WorkflowDefinitionRuntime.launch")((executionId) => FiberMap2.run(hosts, executionId, execute(executionId).pipe(Effect100.ignore), { onlyIfMissing: true }).pipe(Effect100.asVoid));
|
|
19696
19775
|
const recover2 = Effect100.fn("WorkflowDefinitionRuntime.recover")(function* () {
|
|
19697
19776
|
const records = yield* repository.listNonterminal();
|
|
19698
19777
|
yield* Effect100.forEach(records, (record2) => launch(record2.execution_id), { discard: true });
|
|
@@ -19708,7 +19787,10 @@ var layer68 = Layer89.effect(Service69, Effect100.gen(function* () {
|
|
|
19708
19787
|
recover: recover2,
|
|
19709
19788
|
inspect: repository.inspect,
|
|
19710
19789
|
replay: repository.listLifecycle,
|
|
19711
|
-
cancel:
|
|
19790
|
+
cancel: Effect100.fn("WorkflowDefinitionRuntime.cancel")(function* (executionId) {
|
|
19791
|
+
const cancelled = yield* repository.cancel(executionId);
|
|
19792
|
+
return cancelled.record;
|
|
19793
|
+
})
|
|
19712
19794
|
});
|
|
19713
19795
|
yield* recover2();
|
|
19714
19796
|
return service;
|
|
@@ -19982,7 +20064,7 @@ var nextTurn = (cursor, turns) => Ref26.getAndUpdate(cursor, (index) => index +
|
|
|
19982
20064
|
}
|
|
19983
20065
|
return Effect102.succeed(turn);
|
|
19984
20066
|
}));
|
|
19985
|
-
var
|
|
20067
|
+
var layer67 = (turns) => {
|
|
19986
20068
|
const cursor = Effect102.runSync(Ref26.make(0));
|
|
19987
20069
|
return Layer90.effect(LanguageModel9.LanguageModel, LanguageModel9.make({
|
|
19988
20070
|
generateText: () => nextTurn(cursor, turns).pipe(Effect102.map((turn) => [...responseParts(turn)])),
|
|
@@ -19992,7 +20074,7 @@ var layer69 = (turns) => {
|
|
|
19992
20074
|
var registration = (turns, options) => Effect102.runSync(exports_language_model_service.registrationFromLayer({
|
|
19993
20075
|
provider: options?.provider ?? "test",
|
|
19994
20076
|
model: options?.model ?? "scripted",
|
|
19995
|
-
layer:
|
|
20077
|
+
layer: layer67(turns),
|
|
19996
20078
|
...options?.registrationKey === undefined ? {} : { registrationKey: options.registrationKey }
|
|
19997
20079
|
}));
|
|
19998
20080
|
// src/captured-model.ts
|
|
@@ -20005,16 +20087,16 @@ import { LanguageModel as LanguageModel10 } from "effect/unstable/ai";
|
|
|
20005
20087
|
var make16 = (turns, options) => Effect103.gen(function* () {
|
|
20006
20088
|
const captured = yield* Ref27.make([]);
|
|
20007
20089
|
const cursor = yield* Ref27.make(0);
|
|
20008
|
-
const
|
|
20090
|
+
const layer68 = Layer91.effect(LanguageModel10.LanguageModel, LanguageModel10.make({
|
|
20009
20091
|
generateText: (request) => Ref27.update(captured, (prompts) => [...prompts, request.prompt]).pipe(Effect103.andThen(nextTurn(cursor, turns)), Effect103.map((turn) => [...responseParts(turn)])),
|
|
20010
20092
|
streamText: (request) => Stream17.unwrap(Ref27.update(captured, (prompts) => [...prompts, request.prompt]).pipe(Effect103.andThen(nextTurn(cursor, turns)), Effect103.map((turn) => Stream17.fromIterable(streamParts(turn)))))
|
|
20011
20093
|
}));
|
|
20012
20094
|
const registration2 = yield* exports_language_model_service.registrationFromLayer({
|
|
20013
20095
|
provider: options?.provider ?? "test",
|
|
20014
20096
|
model: options?.model ?? "scripted",
|
|
20015
|
-
layer:
|
|
20097
|
+
layer: layer68
|
|
20016
20098
|
});
|
|
20017
|
-
return { layer:
|
|
20099
|
+
return { layer: layer68, registration: registration2, prompts: Ref27.get(captured) };
|
|
20018
20100
|
});
|
|
20019
20101
|
// src/test-tools.ts
|
|
20020
20102
|
var exports_test_tools = {};
|
|
@@ -20051,9 +20133,9 @@ var waitingTool = (options) => exports_tool_runtime_service.dynamicTool(options.
|
|
|
20051
20133
|
var exports_test_runtime = {};
|
|
20052
20134
|
__export(exports_test_runtime, {
|
|
20053
20135
|
layerWith: () => layerWith2,
|
|
20054
|
-
layer: () =>
|
|
20136
|
+
layer: () => layer68
|
|
20055
20137
|
});
|
|
20056
|
-
var
|
|
20138
|
+
var layer68 = exports_runner_runtime_service.testLayer;
|
|
20057
20139
|
var normalizeModel = (model) => {
|
|
20058
20140
|
if (model === undefined)
|
|
20059
20141
|
return exports_language_model_service.memoryLayer();
|