@relayfx/sdk 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.js +2 -2
- package/dist/{index-kghdnamr.js → index-d8q4kfjy.js} +1 -1
- package/dist/index-gxskhyra.js +69 -0
- package/dist/{index-rmaq3qc8.js → index-xbbfagnb.js} +744 -395
- package/dist/{index-3e4cs8s6.js → index-z9xk02sv.js} +650 -531
- package/dist/index.js +10 -4
- package/dist/mysql.js +122 -0
- package/dist/postgres.js +77 -0
- package/dist/sqlite.js +84 -3
- package/dist/types/relay/client.d.ts +6 -4
- package/dist/types/relay/index.d.ts +3 -1
- package/dist/types/relay/migration-errors.d.ts +4 -0
- package/dist/types/relay/mysql-migrations.d.ts +1 -0
- package/dist/types/relay/mysql.d.ts +13 -0
- package/dist/types/relay/operation.d.ts +60 -10
- package/dist/types/relay/postgres.d.ts +13 -0
- package/dist/types/relay/runtime-capability-policy.d.ts +19 -0
- package/dist/types/relay/runtime-database-adapter.d.ts +12 -0
- package/dist/types/relay/runtime-database.d.ts +21 -0
- package/dist/types/relay/runtime.d.ts +198 -0
- package/dist/types/relay/sqlite-runtime.d.ts +9 -0
- package/dist/types/relay/sqlite.d.ts +2 -0
- package/dist/types/runtime/address/address-resolution-service.d.ts +32 -10
- package/dist/types/runtime/agent/relay-compaction.d.ts +3 -2
- package/dist/types/runtime/child/child-fan-out-runtime.d.ts +2 -0
- package/dist/types/runtime/child/spawn-child-run-tool.d.ts +7 -0
- package/dist/types/runtime/model/language-model-service.d.ts +1 -0
- package/dist/types/runtime/runner/runner-runtime-service.d.ts +30 -30
- package/dist/types/runtime/workflow/definition-runtime.d.ts +2 -0
- package/dist/types/runtime/workflow/execution-workflow.d.ts +64 -20
- package/dist/types/schema/agent-schema.d.ts +220 -60
- package/dist/types/schema/child-orchestration-schema.d.ts +21 -0
- package/dist/types/schema/execution-schema.d.ts +74 -10
- package/dist/types/store-sql/workflow/workflow-definition-repository.d.ts +6 -2
- package/package.json +11 -2
|
@@ -328,7 +328,8 @@ var PositiveSafeInteger = Schema5.Number.check(Schema5.makeFilter((value) => Num
|
|
|
328
328
|
var CompactionPolicy = Schema5.Struct({
|
|
329
329
|
context_window: PositiveSafeInteger,
|
|
330
330
|
reserve_tokens: PositiveSafeInteger,
|
|
331
|
-
keep_recent_tokens: PositiveSafeInteger
|
|
331
|
+
keep_recent_tokens: PositiveSafeInteger,
|
|
332
|
+
summary_model: Schema5.optionalKey(ModelSelection)
|
|
332
333
|
}).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" });
|
|
333
334
|
var ChildRunWorkspacePolicy = Schema5.Struct({
|
|
334
335
|
mode: Schema5.Literals(["share", "fork"]),
|
|
@@ -2962,10 +2963,17 @@ var layer7 = Layer7.effect(Service7, Effect8.gen(function* () {
|
|
|
2962
2963
|
return yield* new ChildFanOutConflict({ fan_out_id: definition.fan_out_id });
|
|
2963
2964
|
return existing;
|
|
2964
2965
|
}
|
|
2965
|
-
|
|
2966
|
+
const inserted = sql.withTransaction(Effect8.gen(function* () {
|
|
2966
2967
|
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)})`;
|
|
2967
2968
|
yield* Effect8.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 });
|
|
2968
|
-
}))
|
|
2969
|
+
}));
|
|
2970
|
+
yield* inserted.pipe(Effect8.mapError(repositoryError), Effect8.catch((error) => Effect8.gen(function* () {
|
|
2971
|
+
const current2 = yield* load(tenantId, definition.fan_out_id).pipe(Effect8.mapError(repositoryError));
|
|
2972
|
+
if (current2 === undefined)
|
|
2973
|
+
return yield* error;
|
|
2974
|
+
if (!sameDefinition(cloneDefinition3(current2), definition))
|
|
2975
|
+
return yield* new ChildFanOutConflict({ fan_out_id: definition.fan_out_id });
|
|
2976
|
+
})));
|
|
2969
2977
|
const created = yield* load(tenantId, definition.fan_out_id).pipe(Effect8.mapError(repositoryError));
|
|
2970
2978
|
if (created === undefined)
|
|
2971
2979
|
return yield* new ChildFanOutRepositoryError({ message: "Fan-out insert returned no row" });
|
|
@@ -9706,12 +9714,20 @@ var memoryLayer27 = Layer28.sync(Service28, () => {
|
|
|
9706
9714
|
inspect,
|
|
9707
9715
|
listNonterminal: Effect29.fn("WorkflowDefinitionRepository.memory.listNonterminal")(() => Effect29.sync(() => [...runs.values()].filter((record2) => record2.status === "running").map(clone3))),
|
|
9708
9716
|
cancel: Effect29.fn("WorkflowDefinitionRepository.memory.cancel")(function* (id2) {
|
|
9717
|
+
const now = yield* Clock3.currentTimeMillis;
|
|
9709
9718
|
const record2 = runs.get(id2);
|
|
9710
9719
|
if (record2 === undefined)
|
|
9711
|
-
return;
|
|
9712
|
-
|
|
9720
|
+
return { transitioned: false, record: undefined };
|
|
9721
|
+
if (record2.status !== "running")
|
|
9722
|
+
return { transitioned: false, record: clone3(record2) };
|
|
9723
|
+
const updated = { ...record2, status: "cancelled", updated_at: now };
|
|
9713
9724
|
runs.set(id2, updated);
|
|
9714
|
-
|
|
9725
|
+
const events = lifecycle.get(id2) ?? [];
|
|
9726
|
+
lifecycle.set(id2, [
|
|
9727
|
+
...events,
|
|
9728
|
+
{ execution_id: id2, sequence: events.length + 1, type: "workflow.cancelled", created_at: now }
|
|
9729
|
+
]);
|
|
9730
|
+
return { transitioned: true, record: clone3(updated) };
|
|
9715
9731
|
}),
|
|
9716
9732
|
getOperation: Effect29.fn("WorkflowDefinitionRepository.memory.getOperation")((executionId, operationId2) => Effect29.sync(() => clone3(operations.get(`${executionId}:${operationId2}`)))),
|
|
9717
9733
|
putOperation: Effect29.fn("WorkflowDefinitionRepository.memory.putOperation")((state) => Effect29.sync(() => {
|
|
@@ -9726,18 +9742,34 @@ var memoryLayer27 = Layer28.sync(Service28, () => {
|
|
|
9726
9742
|
return clone3(stored);
|
|
9727
9743
|
})),
|
|
9728
9744
|
listLifecycle: Effect29.fn("WorkflowDefinitionRepository.memory.listLifecycle")((executionId) => Effect29.sync(() => clone3(lifecycle.get(executionId) ?? []))),
|
|
9729
|
-
finish: Effect29.fn("WorkflowDefinitionRepository.memory.finish")(function* (id2, status) {
|
|
9745
|
+
finish: Effect29.fn("WorkflowDefinitionRepository.memory.finish")(function* (id2, status, data) {
|
|
9746
|
+
const now = yield* Clock3.currentTimeMillis;
|
|
9730
9747
|
const record2 = runs.get(id2);
|
|
9731
|
-
if (record2 === undefined)
|
|
9732
|
-
return;
|
|
9733
|
-
const updated = { ...record2, status, updated_at:
|
|
9748
|
+
if (record2 === undefined || record2.status !== "running")
|
|
9749
|
+
return { transitioned: false, record: record2 === undefined ? undefined : clone3(record2) };
|
|
9750
|
+
const updated = { ...record2, status, updated_at: now };
|
|
9734
9751
|
runs.set(id2, updated);
|
|
9735
|
-
|
|
9752
|
+
const events = lifecycle.get(id2) ?? [];
|
|
9753
|
+
lifecycle.set(id2, [
|
|
9754
|
+
...events,
|
|
9755
|
+
{
|
|
9756
|
+
execution_id: id2,
|
|
9757
|
+
sequence: events.length + 1,
|
|
9758
|
+
type: status === "completed" ? "workflow.completed" : "workflow.failed",
|
|
9759
|
+
...data === undefined ? {} : { data: clone3(data) },
|
|
9760
|
+
created_at: now
|
|
9761
|
+
}
|
|
9762
|
+
]);
|
|
9763
|
+
return { transitioned: true, record: clone3(updated) };
|
|
9736
9764
|
})
|
|
9737
9765
|
});
|
|
9738
9766
|
});
|
|
9739
9767
|
var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
9740
9768
|
const sql = yield* SqlClient28;
|
|
9769
|
+
const operationUpsert = sql.onDialectOrElse({
|
|
9770
|
+
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)"),
|
|
9771
|
+
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")
|
|
9772
|
+
});
|
|
9741
9773
|
const register = Effect29.fn("WorkflowDefinitionRepository.register")(function* (input) {
|
|
9742
9774
|
const tenant = yield* current();
|
|
9743
9775
|
const digest = yield* Effect29.promise(() => exports_workflow_schema.digestDefinition(input.definition));
|
|
@@ -9768,7 +9800,7 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9768
9800
|
start: Effect29.fn("WorkflowDefinitionRepository.start")(function* (input) {
|
|
9769
9801
|
const tenant = yield* current();
|
|
9770
9802
|
const now = yield* Clock3.currentTimeMillis;
|
|
9771
|
-
|
|
9803
|
+
const insert = sql.withTransaction(Effect29.gen(function* () {
|
|
9772
9804
|
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}`;
|
|
9773
9805
|
if (old[0] !== undefined)
|
|
9774
9806
|
return decodeRun(old[0]);
|
|
@@ -9788,6 +9820,7 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9788
9820
|
updated_at: now
|
|
9789
9821
|
};
|
|
9790
9822
|
}));
|
|
9823
|
+
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]))))));
|
|
9791
9824
|
}),
|
|
9792
9825
|
inspect: Effect29.fn("WorkflowDefinitionRepository.inspect")(function* (id2) {
|
|
9793
9826
|
const tenant = yield* current();
|
|
@@ -9802,9 +9835,7 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9802
9835
|
cancel: Effect29.fn("WorkflowDefinitionRepository.cancel")(function* (id2) {
|
|
9803
9836
|
const tenant = yield* current();
|
|
9804
9837
|
const now = yield* Clock3.currentTimeMillis;
|
|
9805
|
-
yield* sql
|
|
9806
|
-
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}`;
|
|
9807
|
-
return rows[0] === undefined ? undefined : decodeRun(rows[0]);
|
|
9838
|
+
return yield* transition2(sql, tenant, id2, "cancelled", now);
|
|
9808
9839
|
}),
|
|
9809
9840
|
getOperation: Effect29.fn("WorkflowDefinitionRepository.getOperation")(function* (executionId, operationId2) {
|
|
9810
9841
|
const tenant = yield* current();
|
|
@@ -9813,8 +9844,7 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9813
9844
|
}),
|
|
9814
9845
|
putOperation: Effect29.fn("WorkflowDefinitionRepository.putOperation")(function* (state) {
|
|
9815
9846
|
const tenant = yield* current();
|
|
9816
|
-
yield* sql`
|
|
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)})`;
|
|
9847
|
+
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}`;
|
|
9818
9848
|
return state;
|
|
9819
9849
|
}),
|
|
9820
9850
|
listOperations: Effect29.fn("WorkflowDefinitionRepository.listOperations")(function* (executionId) {
|
|
@@ -9836,14 +9866,40 @@ var layer27 = Layer28.effect(Service28, Effect29.gen(function* () {
|
|
|
9836
9866
|
const rows = yield* sql`SELECT * FROM relay_workflow_lifecycle_events WHERE tenant_id=${tenant} AND execution_id=${executionId} ORDER BY sequence`;
|
|
9837
9867
|
return rows.map(decodeLifecycle);
|
|
9838
9868
|
}),
|
|
9839
|
-
finish: Effect29.fn("WorkflowDefinitionRepository.finish")(function* (id2, status) {
|
|
9869
|
+
finish: Effect29.fn("WorkflowDefinitionRepository.finish")(function* (id2, status, data) {
|
|
9840
9870
|
const tenant = yield* current();
|
|
9841
9871
|
const now = yield* Clock3.currentTimeMillis;
|
|
9842
|
-
yield* sql
|
|
9843
|
-
|
|
9844
|
-
|
|
9872
|
+
return yield* transition2(sql, tenant, id2, status, now, data);
|
|
9873
|
+
})
|
|
9874
|
+
});
|
|
9875
|
+
}));
|
|
9876
|
+
var transition2 = (sql, tenant, id2, status, now, data) => sql.withTransaction(Effect29.gen(function* () {
|
|
9877
|
+
const result = yield* sql.onDialectOrElse({
|
|
9878
|
+
mysql: () => Effect29.gen(function* () {
|
|
9879
|
+
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`;
|
|
9880
|
+
if (before[0] === undefined)
|
|
9881
|
+
return { transitioned: false, record: undefined };
|
|
9882
|
+
if (before[0].status !== "running")
|
|
9883
|
+
return { transitioned: false, record: decodeRun(before[0]) };
|
|
9884
|
+
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'`;
|
|
9885
|
+
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}`;
|
|
9886
|
+
return { transitioned: true, record: decodeRun(rows2[0]) };
|
|
9887
|
+
}),
|
|
9888
|
+
orElse: () => Effect29.gen(function* () {
|
|
9889
|
+
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`;
|
|
9890
|
+
if (changed[0] !== undefined)
|
|
9891
|
+
return { transitioned: true, record: decodeRun(changed[0]) };
|
|
9892
|
+
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}`;
|
|
9893
|
+
return { transitioned: false, record: rows2[0] === undefined ? undefined : decodeRun(rows2[0]) };
|
|
9845
9894
|
})
|
|
9846
9895
|
});
|
|
9896
|
+
if (!result.transitioned)
|
|
9897
|
+
return result;
|
|
9898
|
+
const rows = yield* sql`SELECT COALESCE(MAX(sequence), 0) AS sequence FROM relay_workflow_lifecycle_events WHERE tenant_id=${tenant} AND execution_id=${id2}`;
|
|
9899
|
+
const sequence = Number(rows[0]?.sequence ?? 0) + 1;
|
|
9900
|
+
const eventType = status === "cancelled" ? "workflow.cancelled" : status === "completed" ? "workflow.completed" : "workflow.failed";
|
|
9901
|
+
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)})`;
|
|
9902
|
+
return result;
|
|
9847
9903
|
}));
|
|
9848
9904
|
var decodeDefinition = (row) => ({
|
|
9849
9905
|
id: exports_ids_schema.WorkflowDefinitionId.make(row.workflow_definition_id),
|
|
@@ -10306,7 +10362,10 @@ var layerFromRepository2 = Layer30.effect(Service30, Effect32.gen(function* () {
|
|
|
10306
10362
|
yield* recordEventReplayed("repository", replay.history.length);
|
|
10307
10363
|
return replay.history;
|
|
10308
10364
|
}),
|
|
10309
|
-
stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect32.map(({ history, sequence }) =>
|
|
10365
|
+
stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect32.map(({ history, sequence }) => {
|
|
10366
|
+
const replay = Stream5.fromIterable(history);
|
|
10367
|
+
return history.some(isTerminal) ? replay : replay.pipe(Stream5.concat(liveTail(repository, hubs, input, history.at(-1)?.sequence ?? sequence).pipe(Stream5.takeUntil(isTerminal))));
|
|
10368
|
+
}))),
|
|
10310
10369
|
findBySequenceOrCursor: Effect32.fn("EventLog.repository.findBySequenceOrCursor")((input) => repository.findBySequenceOrCursor(input).pipe(Effect32.mapError(mapRepositoryFindError))),
|
|
10311
10370
|
findByCursor: Effect32.fn("EventLog.repository.findByCursor")((input) => repository.findByCursor(input).pipe(Effect32.mapError(mapRepositoryFindError))),
|
|
10312
10371
|
findBySequence: Effect32.fn("EventLog.repository.findBySequence")((input) => repository.findBySequence(input).pipe(Effect32.mapError(mapRepositoryFindError))),
|
|
@@ -10358,7 +10417,10 @@ var memoryLayer29 = Layer30.effect(Service30, Effect32.gen(function* () {
|
|
|
10358
10417
|
yield* recordEventReplayed("memory", replay.history.length);
|
|
10359
10418
|
return replay.history;
|
|
10360
10419
|
}),
|
|
10361
|
-
stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect32.map(({ history, sequence }) =>
|
|
10420
|
+
stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect32.map(({ history, sequence }) => {
|
|
10421
|
+
const replay = Stream5.fromIterable(history);
|
|
10422
|
+
return history.some(isTerminal) ? replay : replay.pipe(Stream5.concat(liveEvents(pubsub, input, history, sequence)));
|
|
10423
|
+
}))),
|
|
10362
10424
|
findBySequenceOrCursor: Effect32.fn("EventLog.memory.findBySequenceOrCursor")(function* (input) {
|
|
10363
10425
|
const executionEvents = yield* allEvents(input.executionId);
|
|
10364
10426
|
const event = executionEvents.find((item) => item.sequence === input.sequence || item.cursor === input.cursor);
|
|
@@ -13984,76 +14046,246 @@ var spawnDynamic = Effect58.fn("ChildRunService.spawnDynamic.call")(function* (i
|
|
|
13984
14046
|
return yield* service.spawnDynamic(input);
|
|
13985
14047
|
});
|
|
13986
14048
|
|
|
13987
|
-
// ../runtime/src/model/
|
|
13988
|
-
var
|
|
13989
|
-
__export(
|
|
14049
|
+
// ../runtime/src/model/embedding-model-service.ts
|
|
14050
|
+
var exports_embedding_model_service = {};
|
|
14051
|
+
__export(exports_embedding_model_service, {
|
|
13990
14052
|
testLayer: () => testLayer46,
|
|
13991
14053
|
registrations: () => registrations2,
|
|
13992
14054
|
registrationFromLayer: () => registrationFromLayer2,
|
|
13993
14055
|
register: () => register5,
|
|
13994
14056
|
provideForAgent: () => provideForAgent,
|
|
14057
|
+
provideDefault: () => provideDefault,
|
|
13995
14058
|
provide: () => provide2,
|
|
13996
14059
|
memoryLayer: () => memoryLayer35,
|
|
13997
14060
|
layerFromRegistrationEffects: () => layerFromRegistrationEffects2,
|
|
13998
14061
|
layer: () => layer40,
|
|
14062
|
+
deterministicTestLayer: () => deterministicTestLayer,
|
|
14063
|
+
deterministicRegistration: () => deterministicRegistration,
|
|
14064
|
+
deterministicLayer: () => deterministicLayer,
|
|
13999
14065
|
Service: () => Service38,
|
|
14066
|
+
EmbeddingModelNotRegistered: () => EmbeddingModelNotRegistered
|
|
14067
|
+
});
|
|
14068
|
+
import { Context as Context51, Effect as Effect59, Layer as Layer52, Ref as Ref16, Schema as Schema67 } from "effect";
|
|
14069
|
+
import { EmbeddingModel as EmbeddingModel2, Model as Model3 } from "effect/unstable/ai";
|
|
14070
|
+
|
|
14071
|
+
class EmbeddingModelNotRegistered extends Schema67.TaggedErrorClass()("EmbeddingModelNotRegistered", {
|
|
14072
|
+
provider: Schema67.String,
|
|
14073
|
+
model: Schema67.String,
|
|
14074
|
+
registration_key: Schema67.optionalKey(Schema67.String)
|
|
14075
|
+
}) {
|
|
14076
|
+
}
|
|
14077
|
+
|
|
14078
|
+
class Service38 extends Context51.Service()("@relayfx/runtime/EmbeddingModelService") {
|
|
14079
|
+
}
|
|
14080
|
+
var toRegistration = (input) => ({
|
|
14081
|
+
provider: input.provider,
|
|
14082
|
+
model: input.model,
|
|
14083
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
14084
|
+
layer: input.layer,
|
|
14085
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
14086
|
+
});
|
|
14087
|
+
var selectionError = (selection) => new EmbeddingModelNotRegistered({
|
|
14088
|
+
provider: selection.provider,
|
|
14089
|
+
model: selection.model,
|
|
14090
|
+
...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
|
|
14091
|
+
});
|
|
14092
|
+
var defaultSelectionError = () => new EmbeddingModelNotRegistered({ provider: "default", model: "default" });
|
|
14093
|
+
var matchesSelection2 = (selection, registration) => registration.provider === selection.provider && registration.model === selection.model && (selection.registrationKey === undefined || registration.registrationKey === selection.registrationKey);
|
|
14094
|
+
var resolve3 = (registrations2, selection) => {
|
|
14095
|
+
const matches2 = registrations2.filter((registration) => matchesSelection2(selection, registration));
|
|
14096
|
+
if (selection.registrationKey !== undefined)
|
|
14097
|
+
return matches2[0];
|
|
14098
|
+
if (matches2.length === 1)
|
|
14099
|
+
return matches2[0];
|
|
14100
|
+
return matches2.find((registration) => registration.registrationKey === undefined);
|
|
14101
|
+
};
|
|
14102
|
+
var resolveDefault = (registrations2, options) => {
|
|
14103
|
+
if (options?.defaultSelection !== undefined) {
|
|
14104
|
+
return resolve3(registrations2, options.defaultSelection);
|
|
14105
|
+
}
|
|
14106
|
+
return registrations2.length === 1 ? registrations2[0] : undefined;
|
|
14107
|
+
};
|
|
14108
|
+
var registrationFromLayer2 = (input) => Model3.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect59.map((layer40) => toRegistration({
|
|
14109
|
+
provider: input.provider,
|
|
14110
|
+
model: input.model,
|
|
14111
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
14112
|
+
layer: layer40,
|
|
14113
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
14114
|
+
})));
|
|
14115
|
+
var layer40 = (initialRegistrations = [], options) => Layer52.effect(Service38, Effect59.gen(function* () {
|
|
14116
|
+
const registry = yield* Ref16.make([...initialRegistrations]);
|
|
14117
|
+
const register5 = Effect59.fn("EmbeddingModelService.register")(function* (input) {
|
|
14118
|
+
const registration = toRegistration(input);
|
|
14119
|
+
yield* Ref16.update(registry, (current2) => [
|
|
14120
|
+
...current2.filter((item) => !(item.provider === registration.provider && item.model === registration.model && item.registrationKey === registration.registrationKey)),
|
|
14121
|
+
registration
|
|
14122
|
+
]);
|
|
14123
|
+
});
|
|
14124
|
+
const registrations2 = Ref16.get(registry);
|
|
14125
|
+
const provide2 = (selection, effect) => Effect59.gen(function* () {
|
|
14126
|
+
const current2 = yield* Ref16.get(registry);
|
|
14127
|
+
const registration = resolve3(current2, selection);
|
|
14128
|
+
if (registration === undefined)
|
|
14129
|
+
return yield* Effect59.fail(selectionError(selection));
|
|
14130
|
+
return yield* effect.pipe(Effect59.provide(registration.layer));
|
|
14131
|
+
});
|
|
14132
|
+
const provideDefault = (effect) => Effect59.gen(function* () {
|
|
14133
|
+
const current2 = yield* Ref16.get(registry);
|
|
14134
|
+
const registration = resolveDefault(current2, options);
|
|
14135
|
+
if (registration === undefined)
|
|
14136
|
+
return yield* Effect59.fail(defaultSelectionError());
|
|
14137
|
+
return yield* effect.pipe(Effect59.provide(registration.layer));
|
|
14138
|
+
});
|
|
14139
|
+
const provideForAgent = (agent, effect) => {
|
|
14140
|
+
return provideDefault(effect);
|
|
14141
|
+
};
|
|
14142
|
+
return Service38.of({ register: register5, registrations: registrations2, provide: provide2, provideDefault, provideForAgent });
|
|
14143
|
+
}));
|
|
14144
|
+
var layerFromRegistrationEffects2 = (registrations2, options) => Layer52.unwrap(Effect59.all(registrations2).pipe(Effect59.map((items) => layer40(items, options))));
|
|
14145
|
+
var memoryLayer35 = layer40;
|
|
14146
|
+
var testLayer46 = (implementation) => Layer52.succeed(Service38, Service38.of(implementation));
|
|
14147
|
+
var words = (input) => input.toLowerCase().match(/[a-z0-9]+/g) ?? [];
|
|
14148
|
+
var hashWord = (word) => {
|
|
14149
|
+
let hash = 2166136261;
|
|
14150
|
+
for (let index = 0;index < word.length; index += 1) {
|
|
14151
|
+
hash ^= word.charCodeAt(index);
|
|
14152
|
+
hash = Math.imul(hash, 16777619);
|
|
14153
|
+
}
|
|
14154
|
+
return hash >>> 0;
|
|
14155
|
+
};
|
|
14156
|
+
var deterministicVector = (input, dimensions) => {
|
|
14157
|
+
const vector = Array.from({ length: dimensions }, () => 0);
|
|
14158
|
+
for (const word of words(input)) {
|
|
14159
|
+
const hash = hashWord(word);
|
|
14160
|
+
const index = hash % dimensions;
|
|
14161
|
+
vector[index] = (vector[index] ?? 0) + 1;
|
|
14162
|
+
}
|
|
14163
|
+
return vector;
|
|
14164
|
+
};
|
|
14165
|
+
var deterministicLayer = (options = {}) => {
|
|
14166
|
+
const dimensions = options.dimensions ?? 64;
|
|
14167
|
+
return Layer52.mergeAll(Layer52.effect(EmbeddingModel2.EmbeddingModel, EmbeddingModel2.make({
|
|
14168
|
+
embedMany: ({ inputs }) => Effect59.succeed({
|
|
14169
|
+
results: inputs.map((input) => deterministicVector(input, dimensions)),
|
|
14170
|
+
usage: { inputTokens: inputs.reduce((total, input) => total + words(input).length, 0) }
|
|
14171
|
+
})
|
|
14172
|
+
})), Layer52.succeed(EmbeddingModel2.Dimensions, dimensions));
|
|
14173
|
+
};
|
|
14174
|
+
var deterministicRegistration = (options = {}) => registrationFromLayer2({
|
|
14175
|
+
provider: options.provider ?? "test",
|
|
14176
|
+
model: options.model ?? "deterministic-embedding",
|
|
14177
|
+
layer: deterministicLayer(options)
|
|
14178
|
+
});
|
|
14179
|
+
var deterministicTestLayer = (options = {}) => layerFromRegistrationEffects2([deterministicRegistration(options)], {
|
|
14180
|
+
defaultSelection: {
|
|
14181
|
+
provider: options.provider ?? "test",
|
|
14182
|
+
model: options.model ?? "deterministic-embedding"
|
|
14183
|
+
}
|
|
14184
|
+
});
|
|
14185
|
+
var register5 = Effect59.fn("EmbeddingModelService.register.call")(function* (input) {
|
|
14186
|
+
const service = yield* Service38;
|
|
14187
|
+
return yield* service.register(input);
|
|
14188
|
+
});
|
|
14189
|
+
var registrations2 = Effect59.fn("EmbeddingModelService.registrations.call")(function* () {
|
|
14190
|
+
const service = yield* Service38;
|
|
14191
|
+
return yield* service.registrations;
|
|
14192
|
+
});
|
|
14193
|
+
var provide2 = (selection, effect) => Effect59.gen(function* () {
|
|
14194
|
+
const service = yield* Service38;
|
|
14195
|
+
return yield* service.provide(selection, effect);
|
|
14196
|
+
});
|
|
14197
|
+
var provideDefault = (effect) => Effect59.gen(function* () {
|
|
14198
|
+
const service = yield* Service38;
|
|
14199
|
+
return yield* service.provideDefault(effect);
|
|
14200
|
+
});
|
|
14201
|
+
var provideForAgent = (agent, effect) => Effect59.gen(function* () {
|
|
14202
|
+
const service = yield* Service38;
|
|
14203
|
+
return yield* service.provideForAgent(agent, effect);
|
|
14204
|
+
});
|
|
14205
|
+
|
|
14206
|
+
// ../runtime/src/model/language-model-service.ts
|
|
14207
|
+
var exports_language_model_service = {};
|
|
14208
|
+
__export(exports_language_model_service, {
|
|
14209
|
+
testLayer: () => testLayer47,
|
|
14210
|
+
resolve: () => resolve4,
|
|
14211
|
+
registrations: () => registrations3,
|
|
14212
|
+
registrationFromLayer: () => registrationFromLayer3,
|
|
14213
|
+
register: () => register6,
|
|
14214
|
+
provideForAgent: () => provideForAgent2,
|
|
14215
|
+
provide: () => provide3,
|
|
14216
|
+
memoryLayer: () => memoryLayer36,
|
|
14217
|
+
layerFromRegistrationEffects: () => layerFromRegistrationEffects3,
|
|
14218
|
+
layer: () => layer41,
|
|
14219
|
+
Service: () => Service39,
|
|
14000
14220
|
LanguageModelNotRegistered: () => LanguageModelNotRegistered2
|
|
14001
14221
|
});
|
|
14002
|
-
import { Context as
|
|
14222
|
+
import { Context as Context52, Effect as Effect60, Layer as Layer53 } from "effect";
|
|
14003
14223
|
var LanguageModelNotRegistered2 = exports_model_registry.LanguageModelNotRegistered;
|
|
14004
14224
|
var toSelection = (selection) => ({
|
|
14005
14225
|
provider: selection.provider,
|
|
14006
14226
|
model: selection.model,
|
|
14007
14227
|
...selection.registration_key === undefined ? {} : { registrationKey: selection.registration_key }
|
|
14008
14228
|
});
|
|
14229
|
+
var registrationKey = (value) => value.registration_key ?? value.registrationKey;
|
|
14230
|
+
var matchesSelection3 = (selection, registration) => registration.provider === selection.provider && registration.model === selection.model && registrationKey(registration) === registrationKey(selection);
|
|
14231
|
+
var notRegistered = (selection) => new LanguageModelNotRegistered2({
|
|
14232
|
+
provider: selection.provider,
|
|
14233
|
+
model: selection.model,
|
|
14234
|
+
...selection.registration_key === undefined ? {} : { registration_key: selection.registration_key }
|
|
14235
|
+
});
|
|
14009
14236
|
|
|
14010
|
-
class
|
|
14237
|
+
class Service39 extends Context52.Service()("@relayfx/runtime/LanguageModelService") {
|
|
14011
14238
|
}
|
|
14012
|
-
var
|
|
14013
|
-
var
|
|
14239
|
+
var registrationFromLayer3 = exports_model_registry.registrationFromLayer;
|
|
14240
|
+
var layer41 = (initialRegistrations = [], options) => Layer53.effect(Service39, Effect60.gen(function* () {
|
|
14014
14241
|
const registry = yield* exports_model_registry.Service;
|
|
14015
|
-
return
|
|
14242
|
+
return Service39.of({
|
|
14016
14243
|
register: (input) => registry.register(input),
|
|
14017
14244
|
registrations: registry.registrations,
|
|
14018
14245
|
provide: (selection, effect) => registry.provide(toSelection(selection), effect),
|
|
14019
14246
|
provideForAgent: (agent, effect) => registry.provide(toSelection(agent.model), effect)
|
|
14020
14247
|
});
|
|
14021
|
-
})).pipe(
|
|
14022
|
-
var
|
|
14023
|
-
var
|
|
14024
|
-
var
|
|
14025
|
-
var
|
|
14026
|
-
const service = yield*
|
|
14248
|
+
})).pipe(Layer53.provide(exports_model_registry.layer(initialRegistrations, options)));
|
|
14249
|
+
var layerFromRegistrationEffects3 = (registrations3, options) => Layer53.unwrap(Effect60.all(registrations3).pipe(Effect60.map((items) => layer41(items, options))));
|
|
14250
|
+
var memoryLayer36 = layer41;
|
|
14251
|
+
var testLayer47 = (implementation) => Layer53.succeed(Service39, Service39.of(implementation));
|
|
14252
|
+
var register6 = Effect60.fn("LanguageModelService.register.call")(function* (input) {
|
|
14253
|
+
const service = yield* Service39;
|
|
14027
14254
|
return yield* service.register(input);
|
|
14028
14255
|
});
|
|
14029
|
-
var
|
|
14030
|
-
const service = yield*
|
|
14256
|
+
var registrations3 = Effect60.fn("LanguageModelService.registrations.call")(function* () {
|
|
14257
|
+
const service = yield* Service39;
|
|
14031
14258
|
return yield* service.registrations;
|
|
14032
14259
|
});
|
|
14033
|
-
var
|
|
14034
|
-
const service = yield*
|
|
14260
|
+
var resolve4 = Effect60.fn("LanguageModelService.resolve.call")(function* (selection) {
|
|
14261
|
+
const service = yield* Service39;
|
|
14262
|
+
const registered = yield* service.registrations;
|
|
14263
|
+
return yield* Effect60.fromNullishOr(registered.find((registration) => matchesSelection3(selection, registration))).pipe(Effect60.mapError(() => notRegistered(selection)));
|
|
14264
|
+
});
|
|
14265
|
+
var provide3 = (selection, effect) => Effect60.gen(function* () {
|
|
14266
|
+
const service = yield* Service39;
|
|
14035
14267
|
return yield* service.provide(selection, effect);
|
|
14036
14268
|
});
|
|
14037
|
-
var
|
|
14038
|
-
const service = yield*
|
|
14269
|
+
var provideForAgent2 = (agent, effect) => Effect60.gen(function* () {
|
|
14270
|
+
const service = yield* Service39;
|
|
14039
14271
|
return yield* service.provideForAgent(agent, effect);
|
|
14040
14272
|
});
|
|
14041
14273
|
|
|
14042
14274
|
// ../runtime/src/model/model-call-policy.ts
|
|
14043
14275
|
var exports_model_call_policy = {};
|
|
14044
14276
|
__export(exports_model_call_policy, {
|
|
14045
|
-
testLayer: () =>
|
|
14277
|
+
testLayer: () => testLayer48,
|
|
14046
14278
|
noRetryLayer: () => noRetryLayer,
|
|
14047
14279
|
make: () => make6,
|
|
14048
|
-
layer: () =>
|
|
14280
|
+
layer: () => layer42,
|
|
14049
14281
|
defaultSchedule: () => defaultSchedule,
|
|
14050
14282
|
defaultClassify: () => defaultClassify2,
|
|
14051
|
-
Service: () =>
|
|
14283
|
+
Service: () => Service40
|
|
14052
14284
|
});
|
|
14053
|
-
import { Context as
|
|
14285
|
+
import { Context as Context53, Duration as Duration3, Layer as Layer54, Schedule as Schedule5 } from "effect";
|
|
14054
14286
|
import { AiError as AiError4 } from "effect/unstable/ai";
|
|
14055
14287
|
|
|
14056
|
-
class
|
|
14288
|
+
class Service40 extends Context53.Service()("@relayfx/runtime/ModelCallPolicy") {
|
|
14057
14289
|
}
|
|
14058
14290
|
var isOutputValidationError = (error5) => AiError4.isAiError(error5) ? error5.reason._tag === "InvalidOutputError" : AiError4.isAiErrorReason(error5) && error5._tag === "InvalidOutputError";
|
|
14059
14291
|
var defaultClassify2 = (error5) => isOutputValidationError(error5) ? "terminal" : exports_model_resilience.defaultClassify(error5);
|
|
@@ -14062,58 +14294,58 @@ var make6 = (input) => ({
|
|
|
14062
14294
|
classify: input?.classify ?? defaultClassify2,
|
|
14063
14295
|
retrySchedule: input?.retrySchedule ?? defaultSchedule
|
|
14064
14296
|
});
|
|
14065
|
-
var
|
|
14066
|
-
var noRetryLayer =
|
|
14067
|
-
var
|
|
14297
|
+
var layer42 = (input) => Layer54.succeed(Service40, Service40.of(make6(input)));
|
|
14298
|
+
var noRetryLayer = layer42({ retrySchedule: Schedule5.recurs(0) });
|
|
14299
|
+
var testLayer48 = (implementation) => Layer54.succeed(Service40, Service40.of(implementation));
|
|
14068
14300
|
|
|
14069
14301
|
// ../runtime/src/presence/presence-service.ts
|
|
14070
14302
|
var exports_presence_service = {};
|
|
14071
14303
|
__export(exports_presence_service, {
|
|
14072
14304
|
watch: () => watch,
|
|
14073
|
-
testLayer: () =>
|
|
14074
|
-
register: () =>
|
|
14075
|
-
memoryLayer: () =>
|
|
14305
|
+
testLayer: () => testLayer49,
|
|
14306
|
+
register: () => register7,
|
|
14307
|
+
memoryLayer: () => memoryLayer37,
|
|
14076
14308
|
list: () => list14,
|
|
14077
14309
|
layerFromRepository: () => layerFromRepository3,
|
|
14078
|
-
Service: () =>
|
|
14310
|
+
Service: () => Service41,
|
|
14079
14311
|
PresenceIdentity: () => PresenceIdentity,
|
|
14080
14312
|
PresenceError: () => PresenceError
|
|
14081
14313
|
});
|
|
14082
|
-
import { Clock as Clock5, Config as Config2, Context as
|
|
14314
|
+
import { Clock as Clock5, Config as Config2, Context as Context54, Effect as Effect61, Layer as Layer55, Random, Schedule as Schedule6, Schema as Schema68, Stream as Stream10 } from "effect";
|
|
14083
14315
|
|
|
14084
|
-
class PresenceError extends
|
|
14085
|
-
message:
|
|
14316
|
+
class PresenceError extends Schema68.TaggedErrorClass()("PresenceError", {
|
|
14317
|
+
message: Schema68.String
|
|
14086
14318
|
}) {
|
|
14087
14319
|
}
|
|
14088
14320
|
|
|
14089
|
-
class
|
|
14321
|
+
class Service41 extends Context54.Service()("@relayfx/runtime/Presence") {
|
|
14090
14322
|
}
|
|
14091
|
-
var PresenceIdentity =
|
|
14323
|
+
var PresenceIdentity = Context54.Reference("@relayfx/runtime/PresenceIdentity", { defaultValue: () => ({}) });
|
|
14092
14324
|
var readError = (cause) => cause instanceof PresenceError ? cause : new PresenceError({ message: String(cause) });
|
|
14093
|
-
var warn = (operation) => (cause) =>
|
|
14094
|
-
var layerFromRepository3 =
|
|
14325
|
+
var warn = (operation) => (cause) => Effect61.logWarning(`Presence ${operation} failed`).pipe(Effect61.annotateLogs({ cause: String(cause) }));
|
|
14326
|
+
var layerFromRepository3 = Layer55.effect(Service41, Effect61.gen(function* () {
|
|
14095
14327
|
const repository = yield* exports_presence_repository.Service;
|
|
14096
14328
|
const heartbeatMillis = yield* Config2.number("RELAY_PRESENCE_HEARTBEAT_MILLIS").pipe(Config2.withDefault(15000));
|
|
14097
|
-
const write =
|
|
14329
|
+
const write = Effect61.fn("Presence.write")(function* (input, connectedAt, notify) {
|
|
14098
14330
|
const now = yield* Clock5.currentTimeMillis;
|
|
14099
14331
|
yield* repository.upsertHeartbeat({
|
|
14100
14332
|
...input,
|
|
14101
14333
|
connectedAt,
|
|
14102
14334
|
expiresAt: now + heartbeatMillis * 3
|
|
14103
|
-
}).pipe(
|
|
14335
|
+
}).pipe(Effect61.catch(warn("heartbeat")));
|
|
14104
14336
|
if (notify)
|
|
14105
|
-
yield* repository.notifyChanged(input.scope).pipe(
|
|
14337
|
+
yield* repository.notifyChanged(input.scope).pipe(Effect61.catch(warn("notification")));
|
|
14106
14338
|
});
|
|
14107
|
-
const
|
|
14108
|
-
const identity = yield*
|
|
14339
|
+
const register7 = Effect61.fn("Presence.register")(function* (input) {
|
|
14340
|
+
const identity = yield* Effect61.serviceOption(PresenceIdentity).pipe(Effect61.map((value) => value._tag === "Some" ? value.value : {}));
|
|
14109
14341
|
const registration = { ...input, metadata: { ...identity, ...input.metadata } };
|
|
14110
14342
|
const connectedAt = yield* Clock5.currentTimeMillis;
|
|
14111
|
-
yield*
|
|
14343
|
+
yield* Effect61.addFinalizer(() => repository.remove(registration).pipe(Effect61.catch(warn("release")), Effect61.andThen(repository.notifyChanged(input.scope).pipe(Effect61.catch(warn("notification"))))));
|
|
14112
14344
|
yield* write(registration, connectedAt, true);
|
|
14113
|
-
yield* write(registration, connectedAt, false).pipe(
|
|
14345
|
+
yield* write(registration, connectedAt, false).pipe(Effect61.delay(heartbeatMillis), Effect61.repeat(Schedule6.forever), Effect61.forkScoped);
|
|
14114
14346
|
});
|
|
14115
|
-
const list14 =
|
|
14116
|
-
const entries = yield* repository.listByScope(scope).pipe(
|
|
14347
|
+
const list14 = Effect61.fn("Presence.list")(function* (scope) {
|
|
14348
|
+
const entries = yield* repository.listByScope(scope).pipe(Effect61.mapError(readError));
|
|
14117
14349
|
const observed_at = yield* Clock5.currentTimeMillis;
|
|
14118
14350
|
return {
|
|
14119
14351
|
scope,
|
|
@@ -14126,23 +14358,23 @@ var layerFromRepository3 = Layer54.effect(Service40, Effect60.gen(function* () {
|
|
|
14126
14358
|
};
|
|
14127
14359
|
});
|
|
14128
14360
|
const watch = (scope) => Stream10.merge(repository.changedSignals(scope).pipe(Stream10.mapError(readError)), Stream10.tick(heartbeatMillis)).pipe(Stream10.mapEffect(() => list14(scope)), Stream10.changesWith((left, right) => JSON.stringify(left.entries) === JSON.stringify(right.entries)));
|
|
14129
|
-
const tracked = (scope, metadata10) => (stream3) => Stream10.scoped(Stream10.concat(Stream10.fromEffect(
|
|
14361
|
+
const tracked = (scope, metadata10) => (stream3) => Stream10.scoped(Stream10.concat(Stream10.fromEffect(Effect61.gen(function* () {
|
|
14130
14362
|
const id2 = `presence:${yield* Random.nextInt}`;
|
|
14131
|
-
yield*
|
|
14363
|
+
yield* register7({ id: id2, scope, ...metadata10 === undefined ? {} : { metadata: metadata10 } }).pipe(Effect61.forkScoped);
|
|
14132
14364
|
})).pipe(Stream10.drain), stream3));
|
|
14133
|
-
return
|
|
14365
|
+
return Service41.of({ register: register7, tracked, list: list14, watch });
|
|
14134
14366
|
}));
|
|
14135
|
-
var
|
|
14136
|
-
var
|
|
14137
|
-
var
|
|
14138
|
-
const service = yield*
|
|
14367
|
+
var memoryLayer37 = layerFromRepository3.pipe(Layer55.provide(exports_presence_repository.memoryLayer));
|
|
14368
|
+
var testLayer49 = (implementation) => Layer55.succeed(Service41, Service41.of(implementation));
|
|
14369
|
+
var register7 = Effect61.fn("Presence.register.call")(function* (input) {
|
|
14370
|
+
const service = yield* Service41;
|
|
14139
14371
|
return yield* service.register(input);
|
|
14140
14372
|
});
|
|
14141
|
-
var list14 =
|
|
14142
|
-
const service = yield*
|
|
14373
|
+
var list14 = Effect61.fn("Presence.list.call")(function* (scope) {
|
|
14374
|
+
const service = yield* Service41;
|
|
14143
14375
|
return yield* service.list(scope);
|
|
14144
14376
|
});
|
|
14145
|
-
var watch = (scope) => Stream10.unwrap(
|
|
14377
|
+
var watch = (scope) => Stream10.unwrap(Effect61.map(Service41, (service) => service.watch(scope)));
|
|
14146
14378
|
|
|
14147
14379
|
// ../runtime/src/presence/presence-tool.ts
|
|
14148
14380
|
var exports_presence_tool = {};
|
|
@@ -14153,11 +14385,11 @@ __export(exports_presence_tool, {
|
|
|
14153
14385
|
Output: () => Output,
|
|
14154
14386
|
Input: () => Input
|
|
14155
14387
|
});
|
|
14156
|
-
import { Effect as
|
|
14388
|
+
import { Effect as Effect62, Schema as Schema69 } from "effect";
|
|
14157
14389
|
var toolName = "relay_presence";
|
|
14158
14390
|
var permissionName = "relay.presence.read";
|
|
14159
|
-
var Input =
|
|
14160
|
-
var Output =
|
|
14391
|
+
var Input = Schema69.Struct({ scope: Schema69.optionalKey(exports_presence_schema.Scope) });
|
|
14392
|
+
var Output = Schema69.Struct({ watcher_count: Schema69.Number, entries: Schema69.Array(exports_presence_schema.Entry) });
|
|
14161
14393
|
var registeredTool = (presence) => tool(toolName, {
|
|
14162
14394
|
description: "List observers currently watching an execution or session.",
|
|
14163
14395
|
input: Input,
|
|
@@ -14165,7 +14397,7 @@ var registeredTool = (presence) => tool(toolName, {
|
|
|
14165
14397
|
permissions: [{ name: permissionName, value: true }],
|
|
14166
14398
|
requiredPermissions: [permissionName],
|
|
14167
14399
|
metadata: { relay_core_tool: true },
|
|
14168
|
-
run:
|
|
14400
|
+
run: Effect62.fn("PresenceTool.run")(function* (input, context) {
|
|
14169
14401
|
const scope = input.scope ?? { kind: "execution", id: exports_ids_schema.ExecutionId.make(context.executionId) };
|
|
14170
14402
|
const view = yield* presence.list(scope);
|
|
14171
14403
|
return { watcher_count: view.entries.length, entries: view.entries };
|
|
@@ -14175,21 +14407,21 @@ var registeredTool = (presence) => tool(toolName, {
|
|
|
14175
14407
|
// ../runtime/src/schema-registry/schema-registry-service.ts
|
|
14176
14408
|
var exports_schema_registry_service = {};
|
|
14177
14409
|
__export(exports_schema_registry_service, {
|
|
14178
|
-
testLayer: () =>
|
|
14179
|
-
resolve: () =>
|
|
14180
|
-
registrations: () =>
|
|
14181
|
-
register: () =>
|
|
14182
|
-
memoryLayer: () =>
|
|
14183
|
-
layer: () =>
|
|
14184
|
-
Service: () =>
|
|
14410
|
+
testLayer: () => testLayer50,
|
|
14411
|
+
resolve: () => resolve5,
|
|
14412
|
+
registrations: () => registrations4,
|
|
14413
|
+
register: () => register8,
|
|
14414
|
+
memoryLayer: () => memoryLayer38,
|
|
14415
|
+
layer: () => layer43,
|
|
14416
|
+
Service: () => Service42,
|
|
14185
14417
|
SchemaRefNotRegistered: () => SchemaRefNotRegistered
|
|
14186
14418
|
});
|
|
14187
|
-
import { Context as
|
|
14419
|
+
import { Context as Context55, Effect as Effect63, Layer as Layer56, Ref as Ref17, Schema as Schema70 } from "effect";
|
|
14188
14420
|
|
|
14189
|
-
class SchemaRefNotRegistered extends
|
|
14421
|
+
class SchemaRefNotRegistered extends Schema70.TaggedErrorClass()("SchemaRefNotRegistered", { schema_ref: exports_shared_schema.NonEmptyString }) {
|
|
14190
14422
|
}
|
|
14191
14423
|
|
|
14192
|
-
class
|
|
14424
|
+
class Service42 extends Context55.Service()("@relayfx/runtime/SchemaRegistry") {
|
|
14193
14425
|
}
|
|
14194
14426
|
var upsertRegistration2 = (registry, registration) => {
|
|
14195
14427
|
const exists = registry.some((item) => item.ref === registration.ref);
|
|
@@ -14197,63 +14429,63 @@ var upsertRegistration2 = (registry, registration) => {
|
|
|
14197
14429
|
return [...registry, registration];
|
|
14198
14430
|
return registry.map((item) => item.ref === registration.ref ? registration : item);
|
|
14199
14431
|
};
|
|
14200
|
-
var
|
|
14201
|
-
const registry = yield*
|
|
14202
|
-
const
|
|
14203
|
-
yield*
|
|
14204
|
-
});
|
|
14205
|
-
const
|
|
14206
|
-
const
|
|
14207
|
-
const items = yield*
|
|
14432
|
+
var layer43 = (initialRegistrations = []) => Layer56.effect(Service42, Effect63.gen(function* () {
|
|
14433
|
+
const registry = yield* Ref17.make(initialRegistrations.reduce(upsertRegistration2, []));
|
|
14434
|
+
const register8 = Effect63.fn("SchemaRegistry.register")(function* (registration) {
|
|
14435
|
+
yield* Ref17.update(registry, (items) => upsertRegistration2(items, registration));
|
|
14436
|
+
});
|
|
14437
|
+
const registrations4 = Ref17.get(registry);
|
|
14438
|
+
const resolve5 = Effect63.fn("SchemaRegistry.resolve")(function* (ref) {
|
|
14439
|
+
const items = yield* Ref17.get(registry);
|
|
14208
14440
|
const found = items.find((item) => item.ref === ref);
|
|
14209
14441
|
if (found === undefined) {
|
|
14210
|
-
return yield*
|
|
14442
|
+
return yield* Effect63.fail(new SchemaRefNotRegistered({ schema_ref: ref }));
|
|
14211
14443
|
}
|
|
14212
14444
|
return found;
|
|
14213
14445
|
});
|
|
14214
|
-
return
|
|
14446
|
+
return Service42.of({ register: register8, registrations: registrations4, resolve: resolve5 });
|
|
14215
14447
|
}));
|
|
14216
|
-
var
|
|
14217
|
-
var
|
|
14218
|
-
var
|
|
14219
|
-
const service = yield*
|
|
14448
|
+
var memoryLayer38 = layer43;
|
|
14449
|
+
var testLayer50 = (implementation) => Layer56.succeed(Service42, Service42.of(implementation));
|
|
14450
|
+
var register8 = Effect63.fn("SchemaRegistry.register.call")(function* (registration) {
|
|
14451
|
+
const service = yield* Service42;
|
|
14220
14452
|
return yield* service.register(registration);
|
|
14221
14453
|
});
|
|
14222
|
-
var
|
|
14223
|
-
const service = yield*
|
|
14454
|
+
var registrations4 = Effect63.fn("SchemaRegistry.registrations.call")(function* () {
|
|
14455
|
+
const service = yield* Service42;
|
|
14224
14456
|
return yield* service.registrations;
|
|
14225
14457
|
});
|
|
14226
|
-
var
|
|
14227
|
-
const service = yield*
|
|
14458
|
+
var resolve5 = Effect63.fn("SchemaRegistry.resolve.call")(function* (ref) {
|
|
14459
|
+
const service = yield* Service42;
|
|
14228
14460
|
return yield* service.resolve(ref);
|
|
14229
14461
|
});
|
|
14230
14462
|
|
|
14231
14463
|
// ../runtime/src/content/blob-store-service.ts
|
|
14232
14464
|
var exports_blob_store_service = {};
|
|
14233
14465
|
__export(exports_blob_store_service, {
|
|
14234
|
-
testLayer: () =>
|
|
14235
|
-
resolve: () =>
|
|
14466
|
+
testLayer: () => testLayer51,
|
|
14467
|
+
resolve: () => resolve6,
|
|
14236
14468
|
put: () => put3,
|
|
14237
14469
|
passthroughLayer: () => passthroughLayer,
|
|
14238
|
-
memoryLayer: () =>
|
|
14239
|
-
Service: () =>
|
|
14470
|
+
memoryLayer: () => memoryLayer39,
|
|
14471
|
+
Service: () => Service43,
|
|
14240
14472
|
BlobStoreError: () => BlobStoreError,
|
|
14241
14473
|
BlobNotResolvable: () => BlobNotResolvable
|
|
14242
14474
|
});
|
|
14243
|
-
import { Context as
|
|
14475
|
+
import { Context as Context56, Effect as Effect64, Layer as Layer57, Ref as Ref18, Schema as Schema71 } from "effect";
|
|
14244
14476
|
|
|
14245
|
-
class BlobNotResolvable extends
|
|
14246
|
-
uri:
|
|
14247
|
-
reason:
|
|
14477
|
+
class BlobNotResolvable extends Schema71.TaggedErrorClass()("BlobNotResolvable", {
|
|
14478
|
+
uri: Schema71.String,
|
|
14479
|
+
reason: Schema71.String
|
|
14248
14480
|
}) {
|
|
14249
14481
|
}
|
|
14250
14482
|
|
|
14251
|
-
class BlobStoreError extends
|
|
14252
|
-
message:
|
|
14483
|
+
class BlobStoreError extends Schema71.TaggedErrorClass()("BlobStoreError", {
|
|
14484
|
+
message: Schema71.String
|
|
14253
14485
|
}) {
|
|
14254
14486
|
}
|
|
14255
14487
|
|
|
14256
|
-
class
|
|
14488
|
+
class Service43 extends Context56.Service()("@relayfx/runtime/BlobStore") {
|
|
14257
14489
|
}
|
|
14258
14490
|
var urlResolution = (part) => ({
|
|
14259
14491
|
_tag: "Url",
|
|
@@ -14262,18 +14494,18 @@ var urlResolution = (part) => ({
|
|
|
14262
14494
|
...part.filename === undefined ? {} : { fileName: part.filename }
|
|
14263
14495
|
});
|
|
14264
14496
|
var passthroughInterface = {
|
|
14265
|
-
resolve: (part) =>
|
|
14266
|
-
put: () =>
|
|
14497
|
+
resolve: (part) => Effect64.succeed(urlResolution(part)),
|
|
14498
|
+
put: () => Effect64.fail(new BlobStoreError({ message: "BlobStore.put is not supported by the passthrough store" }))
|
|
14267
14499
|
};
|
|
14268
|
-
var passthroughLayer =
|
|
14269
|
-
var
|
|
14270
|
-
const counter = yield*
|
|
14500
|
+
var passthroughLayer = Layer57.succeed(Service43, Service43.of(passthroughInterface));
|
|
14501
|
+
var memoryLayer39 = Layer57.effect(Service43, Effect64.gen(function* () {
|
|
14502
|
+
const counter = yield* Ref18.make(0);
|
|
14271
14503
|
const blobs = new Map;
|
|
14272
|
-
return
|
|
14273
|
-
resolve:
|
|
14504
|
+
return Service43.of({
|
|
14505
|
+
resolve: Effect64.fn("BlobStore.memory.resolve")(function* (part) {
|
|
14274
14506
|
const blob = blobs.get(part.uri);
|
|
14275
14507
|
if (blob === undefined) {
|
|
14276
|
-
return yield*
|
|
14508
|
+
return yield* Effect64.fail(new BlobNotResolvable({ uri: part.uri, reason: "unknown blob uri" }));
|
|
14277
14509
|
}
|
|
14278
14510
|
return {
|
|
14279
14511
|
_tag: "Bytes",
|
|
@@ -14282,10 +14514,10 @@ var memoryLayer38 = Layer56.effect(Service42, Effect63.gen(function* () {
|
|
|
14282
14514
|
...blob.fileName === undefined ? {} : { fileName: blob.fileName }
|
|
14283
14515
|
};
|
|
14284
14516
|
}),
|
|
14285
|
-
put:
|
|
14286
|
-
const next = yield*
|
|
14517
|
+
put: Effect64.fn("BlobStore.memory.put")(function* (input) {
|
|
14518
|
+
const next = yield* Ref18.updateAndGet(counter, (value) => value + 1);
|
|
14287
14519
|
const uri = `memory://blob/${next}`;
|
|
14288
|
-
yield*
|
|
14520
|
+
yield* Effect64.sync(() => blobs.set(uri, {
|
|
14289
14521
|
bytes: input.bytes,
|
|
14290
14522
|
mediaType: input.mediaType,
|
|
14291
14523
|
...input.fileName === undefined ? {} : { fileName: input.fileName }
|
|
@@ -14300,48 +14532,48 @@ var memoryLayer38 = Layer56.effect(Service42, Effect63.gen(function* () {
|
|
|
14300
14532
|
})
|
|
14301
14533
|
});
|
|
14302
14534
|
}));
|
|
14303
|
-
var
|
|
14304
|
-
var
|
|
14305
|
-
const service = yield*
|
|
14535
|
+
var testLayer51 = (implementation) => Layer57.succeed(Service43, Service43.of(implementation));
|
|
14536
|
+
var resolve6 = Effect64.fn("BlobStore.resolve.call")(function* (part) {
|
|
14537
|
+
const service = yield* Service43;
|
|
14306
14538
|
return yield* service.resolve(part);
|
|
14307
14539
|
});
|
|
14308
|
-
var put3 =
|
|
14309
|
-
const service = yield*
|
|
14540
|
+
var put3 = Effect64.fn("BlobStore.put.call")(function* (input) {
|
|
14541
|
+
const service = yield* Service43;
|
|
14310
14542
|
return yield* service.put(input);
|
|
14311
14543
|
});
|
|
14312
14544
|
|
|
14313
14545
|
// ../runtime/src/skill/skill-registry-service.ts
|
|
14314
14546
|
var exports_skill_registry_service = {};
|
|
14315
14547
|
__export(exports_skill_registry_service, {
|
|
14316
|
-
testLayer: () =>
|
|
14548
|
+
testLayer: () => testLayer52,
|
|
14317
14549
|
sourceLayerForExecution: () => sourceLayerForExecution,
|
|
14318
14550
|
sourceForExecution: () => sourceForExecution,
|
|
14319
|
-
register: () =>
|
|
14551
|
+
register: () => register9,
|
|
14320
14552
|
pinExecution: () => pinExecution2,
|
|
14321
14553
|
listRevisions: () => listRevisions4,
|
|
14322
14554
|
listPins: () => listPins2,
|
|
14323
14555
|
list: () => list15,
|
|
14324
|
-
layer: () =>
|
|
14556
|
+
layer: () => layer44,
|
|
14325
14557
|
getRevision: () => getRevision4,
|
|
14326
14558
|
getPinned: () => getPinned2,
|
|
14327
14559
|
get: () => get14,
|
|
14328
14560
|
SkillRegistryError: () => SkillRegistryError,
|
|
14329
14561
|
SkillDefinitionInvalid: () => SkillDefinitionInvalid,
|
|
14330
|
-
Service: () =>
|
|
14562
|
+
Service: () => Service44
|
|
14331
14563
|
});
|
|
14332
|
-
import { Clock as Clock6, Context as
|
|
14564
|
+
import { Clock as Clock6, Context as Context57, Effect as Effect65, Layer as Layer58, Schema as Schema72 } from "effect";
|
|
14333
14565
|
|
|
14334
|
-
class SkillDefinitionInvalid extends
|
|
14335
|
-
message:
|
|
14566
|
+
class SkillDefinitionInvalid extends Schema72.TaggedErrorClass()("SkillDefinitionInvalid", {
|
|
14567
|
+
message: Schema72.String
|
|
14336
14568
|
}) {
|
|
14337
14569
|
}
|
|
14338
14570
|
|
|
14339
|
-
class SkillRegistryError extends
|
|
14340
|
-
message:
|
|
14571
|
+
class SkillRegistryError extends Schema72.TaggedErrorClass()("SkillRegistryError", {
|
|
14572
|
+
message: Schema72.String
|
|
14341
14573
|
}) {
|
|
14342
14574
|
}
|
|
14343
14575
|
|
|
14344
|
-
class
|
|
14576
|
+
class Service44 extends Context57.Service()("@relayfx/runtime/SkillRegistry") {
|
|
14345
14577
|
}
|
|
14346
14578
|
var toPublicRecord2 = (record2) => ({
|
|
14347
14579
|
id: record2.id,
|
|
@@ -14364,9 +14596,9 @@ var toPublicPinRecord = (record2) => ({
|
|
|
14364
14596
|
created_at: record2.createdAt
|
|
14365
14597
|
});
|
|
14366
14598
|
var mapRepositoryError7 = (error5) => new SkillRegistryError({ message: error5.message });
|
|
14367
|
-
var requireText2 = (value, field) => value.trim().length === 0 ?
|
|
14368
|
-
var requireOptionalText2 = (value, field) => value === undefined || value.trim().length > 0 ?
|
|
14369
|
-
var validateDefinition2 =
|
|
14599
|
+
var requireText2 = (value, field) => value.trim().length === 0 ? Effect65.fail(new SkillDefinitionInvalid({ message: `${field} must not be blank` })) : Effect65.void;
|
|
14600
|
+
var requireOptionalText2 = (value, field) => value === undefined || value.trim().length > 0 ? Effect65.void : Effect65.fail(new SkillDefinitionInvalid({ message: `${field} must not be blank` }));
|
|
14601
|
+
var validateDefinition2 = Effect65.fn("SkillRegistry.validateDefinition")(function* (definition) {
|
|
14370
14602
|
yield* requireText2(definition.frontmatter.name, "definition.frontmatter.name");
|
|
14371
14603
|
yield* requireText2(definition.frontmatter.description, "definition.frontmatter.description");
|
|
14372
14604
|
yield* requireOptionalText2(definition.frontmatter.when_to_use, "definition.frontmatter.when_to_use");
|
|
@@ -14397,124 +14629,124 @@ var toBatonSkill = (pin) => {
|
|
|
14397
14629
|
return {
|
|
14398
14630
|
frontmatter,
|
|
14399
14631
|
listing: exports_skill_source.makeListing(frontmatter),
|
|
14400
|
-
body:
|
|
14632
|
+
body: Effect65.succeed(pin.skill_definition_snapshot.body),
|
|
14401
14633
|
tools: []
|
|
14402
14634
|
};
|
|
14403
14635
|
};
|
|
14404
14636
|
var sourceError = (error5) => new exports_skill_source.SkillSourceError({ source: "relay.skill_registry", message: error5.message });
|
|
14405
|
-
var
|
|
14637
|
+
var layer44 = Layer58.effect(Service44, Effect65.gen(function* () {
|
|
14406
14638
|
const repository = yield* exports_skill_definition_repository.Service;
|
|
14407
|
-
return
|
|
14408
|
-
register:
|
|
14639
|
+
return Service44.of({
|
|
14640
|
+
register: Effect65.fn("SkillRegistry.register")(function* (input) {
|
|
14409
14641
|
yield* validateDefinition2(input.definition);
|
|
14410
14642
|
const now = yield* Clock6.currentTimeMillis;
|
|
14411
|
-
const record2 = yield* repository.put({ id: input.id, definition: input.definition, now }).pipe(
|
|
14643
|
+
const record2 = yield* repository.put({ id: input.id, definition: input.definition, now }).pipe(Effect65.mapError(mapRepositoryError7));
|
|
14412
14644
|
return { record: toPublicRecord2(record2) };
|
|
14413
14645
|
}),
|
|
14414
|
-
get:
|
|
14415
|
-
const record2 = yield* repository.get(id2).pipe(
|
|
14646
|
+
get: Effect65.fn("SkillRegistry.get")(function* (id2) {
|
|
14647
|
+
const record2 = yield* repository.get(id2).pipe(Effect65.mapError(mapRepositoryError7));
|
|
14416
14648
|
return record2 === undefined ? undefined : toPublicRecord2(record2);
|
|
14417
14649
|
}),
|
|
14418
|
-
getRevision:
|
|
14419
|
-
const record2 = yield* repository.getRevision(input).pipe(
|
|
14650
|
+
getRevision: Effect65.fn("SkillRegistry.getRevision")(function* (input) {
|
|
14651
|
+
const record2 = yield* repository.getRevision(input).pipe(Effect65.mapError(mapRepositoryError7));
|
|
14420
14652
|
return record2 === undefined ? undefined : toPublicRevisionRecord2(record2);
|
|
14421
14653
|
}),
|
|
14422
|
-
list:
|
|
14423
|
-
const records = yield* repository.list().pipe(
|
|
14654
|
+
list: Effect65.fn("SkillRegistry.list")(function* () {
|
|
14655
|
+
const records = yield* repository.list().pipe(Effect65.mapError(mapRepositoryError7));
|
|
14424
14656
|
return { records: records.map(toPublicRecord2) };
|
|
14425
14657
|
}),
|
|
14426
|
-
listRevisions:
|
|
14427
|
-
const records = yield* repository.listRevisions(id2).pipe(
|
|
14658
|
+
listRevisions: Effect65.fn("SkillRegistry.listRevisions")(function* (id2) {
|
|
14659
|
+
const records = yield* repository.listRevisions(id2).pipe(Effect65.mapError(mapRepositoryError7));
|
|
14428
14660
|
return { records: records.map(toPublicRevisionRecord2) };
|
|
14429
14661
|
}),
|
|
14430
|
-
pinExecution:
|
|
14662
|
+
pinExecution: Effect65.fn("SkillRegistry.pinExecution")(function* (input) {
|
|
14431
14663
|
const now = yield* Clock6.currentTimeMillis;
|
|
14432
14664
|
const records = yield* repository.pinExecution({
|
|
14433
14665
|
executionId: input.execution_id,
|
|
14434
14666
|
skillDefinitionIds: input.skill_definition_ids,
|
|
14435
14667
|
now
|
|
14436
|
-
}).pipe(
|
|
14668
|
+
}).pipe(Effect65.mapError(mapRepositoryError7));
|
|
14437
14669
|
return { records: records.map(toPublicPinRecord) };
|
|
14438
14670
|
}),
|
|
14439
|
-
listPins:
|
|
14440
|
-
const records = yield* repository.listPins(executionId).pipe(
|
|
14671
|
+
listPins: Effect65.fn("SkillRegistry.listPins")(function* (executionId) {
|
|
14672
|
+
const records = yield* repository.listPins(executionId).pipe(Effect65.mapError(mapRepositoryError7));
|
|
14441
14673
|
return { records: records.map(toPublicPinRecord) };
|
|
14442
14674
|
}),
|
|
14443
|
-
getPinned:
|
|
14444
|
-
const record2 = yield* repository.getPinned(input).pipe(
|
|
14675
|
+
getPinned: Effect65.fn("SkillRegistry.getPinned")(function* (input) {
|
|
14676
|
+
const record2 = yield* repository.getPinned(input).pipe(Effect65.mapError(mapRepositoryError7));
|
|
14445
14677
|
return record2 === undefined ? undefined : toPublicPinRecord(record2);
|
|
14446
14678
|
})
|
|
14447
14679
|
});
|
|
14448
14680
|
}));
|
|
14449
|
-
var
|
|
14450
|
-
var
|
|
14451
|
-
const service = yield*
|
|
14681
|
+
var testLayer52 = (implementation) => Layer58.succeed(Service44, Service44.of(implementation));
|
|
14682
|
+
var register9 = Effect65.fn("SkillRegistry.register.call")(function* (input) {
|
|
14683
|
+
const service = yield* Service44;
|
|
14452
14684
|
return yield* service.register(input);
|
|
14453
14685
|
});
|
|
14454
|
-
var get14 =
|
|
14455
|
-
const service = yield*
|
|
14686
|
+
var get14 = Effect65.fn("SkillRegistry.get.call")(function* (id2) {
|
|
14687
|
+
const service = yield* Service44;
|
|
14456
14688
|
return yield* service.get(id2);
|
|
14457
14689
|
});
|
|
14458
|
-
var getRevision4 =
|
|
14459
|
-
const service = yield*
|
|
14690
|
+
var getRevision4 = Effect65.fn("SkillRegistry.getRevision.call")(function* (input) {
|
|
14691
|
+
const service = yield* Service44;
|
|
14460
14692
|
return yield* service.getRevision(input);
|
|
14461
14693
|
});
|
|
14462
|
-
var list15 =
|
|
14463
|
-
const service = yield*
|
|
14694
|
+
var list15 = Effect65.fn("SkillRegistry.list.call")(function* () {
|
|
14695
|
+
const service = yield* Service44;
|
|
14464
14696
|
return yield* service.list();
|
|
14465
14697
|
});
|
|
14466
|
-
var listRevisions4 =
|
|
14467
|
-
const service = yield*
|
|
14698
|
+
var listRevisions4 = Effect65.fn("SkillRegistry.listRevisions.call")(function* (id2) {
|
|
14699
|
+
const service = yield* Service44;
|
|
14468
14700
|
return yield* service.listRevisions(id2);
|
|
14469
14701
|
});
|
|
14470
|
-
var pinExecution2 =
|
|
14471
|
-
const service = yield*
|
|
14702
|
+
var pinExecution2 = Effect65.fn("SkillRegistry.pinExecution.call")(function* (input) {
|
|
14703
|
+
const service = yield* Service44;
|
|
14472
14704
|
return yield* service.pinExecution(input);
|
|
14473
14705
|
});
|
|
14474
|
-
var listPins2 =
|
|
14475
|
-
const service = yield*
|
|
14706
|
+
var listPins2 = Effect65.fn("SkillRegistry.listPins.call")(function* (executionId) {
|
|
14707
|
+
const service = yield* Service44;
|
|
14476
14708
|
return yield* service.listPins(executionId);
|
|
14477
14709
|
});
|
|
14478
|
-
var getPinned2 =
|
|
14479
|
-
const service = yield*
|
|
14710
|
+
var getPinned2 = Effect65.fn("SkillRegistry.getPinned.call")(function* (input) {
|
|
14711
|
+
const service = yield* Service44;
|
|
14480
14712
|
return yield* service.getPinned(input);
|
|
14481
14713
|
});
|
|
14482
|
-
var sourceForExecution =
|
|
14483
|
-
const service = yield*
|
|
14484
|
-
const pins = yield* service.listPins(executionId).pipe(
|
|
14714
|
+
var sourceForExecution = Effect65.fn("SkillRegistry.sourceForExecution.call")(function* (executionId) {
|
|
14715
|
+
const service = yield* Service44;
|
|
14716
|
+
const pins = yield* service.listPins(executionId).pipe(Effect65.mapError(sourceError));
|
|
14485
14717
|
const skills = pins.records.map(toBatonSkill);
|
|
14486
14718
|
const byName = new Map(skills.map((skill) => [skill.frontmatter.name, skill]));
|
|
14487
14719
|
return exports_skill_source.SkillSource.of({
|
|
14488
|
-
all:
|
|
14489
|
-
get: (name) =>
|
|
14720
|
+
all: Effect65.succeed(skills),
|
|
14721
|
+
get: (name) => Effect65.succeed(byName.get(name))
|
|
14490
14722
|
});
|
|
14491
14723
|
});
|
|
14492
|
-
var sourceLayerForExecution = (executionId) =>
|
|
14724
|
+
var sourceLayerForExecution = (executionId) => Layer58.effect(exports_skill_source.SkillSource, sourceForExecution(executionId));
|
|
14493
14725
|
|
|
14494
14726
|
// ../runtime/src/execution/execution-service.ts
|
|
14495
14727
|
var exports_execution_service = {};
|
|
14496
14728
|
__export(exports_execution_service, {
|
|
14497
|
-
testLayer: () =>
|
|
14729
|
+
testLayer: () => testLayer53,
|
|
14498
14730
|
stream: () => stream3,
|
|
14499
14731
|
spawnChildRun: () => spawnChildRun,
|
|
14500
14732
|
send: () => send,
|
|
14501
14733
|
run: () => run2,
|
|
14502
|
-
memoryLayer: () =>
|
|
14503
|
-
layer: () =>
|
|
14734
|
+
memoryLayer: () => memoryLayer40,
|
|
14735
|
+
layer: () => layer45,
|
|
14504
14736
|
cancel: () => cancel4,
|
|
14505
14737
|
accept: () => accept,
|
|
14506
|
-
Service: () =>
|
|
14738
|
+
Service: () => Service45,
|
|
14507
14739
|
ExecutionServiceError: () => ExecutionServiceError
|
|
14508
14740
|
});
|
|
14509
|
-
import { Clock as Clock7, Context as
|
|
14741
|
+
import { Clock as Clock7, Context as Context58, Effect as Effect66, Layer as Layer59, Option as Option21, Schema as Schema73, Stream as Stream11 } from "effect";
|
|
14510
14742
|
import { ShardingConfig } from "effect/unstable/cluster";
|
|
14511
|
-
class ExecutionServiceError extends
|
|
14512
|
-
message:
|
|
14513
|
-
next_event_sequence:
|
|
14743
|
+
class ExecutionServiceError extends Schema73.TaggedErrorClass()("ExecutionServiceError", {
|
|
14744
|
+
message: Schema73.String,
|
|
14745
|
+
next_event_sequence: Schema73.optionalKey(exports_execution_schema.ExecutionEventSequence)
|
|
14514
14746
|
}) {
|
|
14515
14747
|
}
|
|
14516
14748
|
|
|
14517
|
-
class
|
|
14749
|
+
class Service45 extends Context58.Service()("@relayfx/runtime/ExecutionService") {
|
|
14518
14750
|
}
|
|
14519
14751
|
var toExecution = (record2) => ({
|
|
14520
14752
|
id: record2.id,
|
|
@@ -14538,11 +14770,11 @@ var hasCompleteAgentDefinitionPin2 = (input) => {
|
|
|
14538
14770
|
const count = present.filter(Boolean).length;
|
|
14539
14771
|
return count === 0 || count === present.length;
|
|
14540
14772
|
};
|
|
14541
|
-
var validateAcceptInput = (input) => !hasCompleteAgentDefinitionPin2(input) ?
|
|
14773
|
+
var validateAcceptInput = (input) => !hasCompleteAgentDefinitionPin2(input) ? Effect66.fail(new ExecutionServiceError({
|
|
14542
14774
|
message: "agent pin must include id, revision, and snapshot together"
|
|
14543
|
-
})) : input.agentToolInputSchemaDigests !== undefined && input.agentId === undefined ?
|
|
14775
|
+
})) : input.agentToolInputSchemaDigests !== undefined && input.agentId === undefined ? Effect66.fail(new ExecutionServiceError({
|
|
14544
14776
|
message: "agent tool input schema digests require a complete agent pin"
|
|
14545
|
-
})) :
|
|
14777
|
+
})) : Effect66.void;
|
|
14546
14778
|
var childContext = (input) => ({
|
|
14547
14779
|
toolNames: input.tool_names,
|
|
14548
14780
|
permissions: input.permissions,
|
|
@@ -14578,13 +14810,13 @@ var dynamicOverride = (input) => {
|
|
|
14578
14810
|
});
|
|
14579
14811
|
};
|
|
14580
14812
|
var presetMap = (presets) => new Map(Object.entries(presets ?? {}).map(([name, preset]) => [name, childOverride(preset)]));
|
|
14581
|
-
var nextEventSequence =
|
|
14813
|
+
var nextEventSequence = Effect66.fn("ExecutionService.nextEventSequence")(function* (eventLog, input) {
|
|
14582
14814
|
if (input.event_sequence !== undefined)
|
|
14583
14815
|
return input.event_sequence;
|
|
14584
|
-
const max = yield* eventLog.maxSequence(input.execution_id).pipe(
|
|
14816
|
+
const max = yield* eventLog.maxSequence(input.execution_id).pipe(Effect66.mapError(mapEventLogError4));
|
|
14585
14817
|
return max === undefined ? 0 : max + 1;
|
|
14586
14818
|
});
|
|
14587
|
-
var childRunBaseInput =
|
|
14819
|
+
var childRunBaseInput = Effect66.fn("ExecutionService.childRunBaseInput")(function* (eventLog, input) {
|
|
14588
14820
|
const eventSequence = yield* nextEventSequence(eventLog, input);
|
|
14589
14821
|
const createdAt = input.created_at ?? (yield* Clock7.currentTimeMillis);
|
|
14590
14822
|
return {
|
|
@@ -14645,8 +14877,8 @@ var failedEvent = (input, error5) => ({
|
|
|
14645
14877
|
created_at: input.completedAt
|
|
14646
14878
|
});
|
|
14647
14879
|
var terminalEvent = (events) => events.find((event) => event.type === "execution.completed" || event.type === "execution.failed");
|
|
14648
|
-
var existingTerminalExecution =
|
|
14649
|
-
const events = yield* eventLog.replay({ executionId: input.executionId }).pipe(
|
|
14880
|
+
var existingTerminalExecution = Effect66.fn("ExecutionService.existingTerminalExecution")(function* (repository, eventLog, input) {
|
|
14881
|
+
const events = yield* eventLog.replay({ executionId: input.executionId }).pipe(Effect66.mapError(mapEventLogError4));
|
|
14650
14882
|
const event = terminalEvent(events);
|
|
14651
14883
|
if (event === undefined)
|
|
14652
14884
|
return;
|
|
@@ -14673,26 +14905,26 @@ var cancelledEvent = (input) => ({
|
|
|
14673
14905
|
data: input.reason === undefined ? {} : { reason: input.reason },
|
|
14674
14906
|
created_at: input.cancelledAt
|
|
14675
14907
|
});
|
|
14676
|
-
var updateStatus2 =
|
|
14908
|
+
var updateStatus2 = Effect66.fn("ExecutionService.updateStatus")(function* (repository, id2, status, updatedAt, metadata10) {
|
|
14677
14909
|
const record2 = yield* repository.transition({
|
|
14678
14910
|
id: id2,
|
|
14679
14911
|
status,
|
|
14680
14912
|
updatedAt,
|
|
14681
14913
|
...metadata10 === undefined ? {} : { metadata: metadata10 }
|
|
14682
|
-
}).pipe(
|
|
14914
|
+
}).pipe(Effect66.mapError(mapRepositoryError8));
|
|
14683
14915
|
return toExecution(record2);
|
|
14684
14916
|
});
|
|
14685
|
-
var
|
|
14917
|
+
var layer45 = Layer59.effect(Service45, Effect66.gen(function* () {
|
|
14686
14918
|
const repository = yield* exports_execution_repository.Service;
|
|
14687
14919
|
const eventLog = yield* Service30;
|
|
14688
14920
|
const childRuns = yield* Service37;
|
|
14689
14921
|
const shardingConfig = yield* ShardingConfig.ShardingConfig;
|
|
14690
|
-
const sessions = yield*
|
|
14922
|
+
const sessions = yield* Effect66.serviceOption(exports_session_repository.Service);
|
|
14691
14923
|
const runnerAddress = runnerAddressOf(shardingConfig);
|
|
14692
|
-
return
|
|
14693
|
-
accept:
|
|
14924
|
+
return Service45.of({
|
|
14925
|
+
accept: Effect66.fn("ExecutionService.accept")(function* (input) {
|
|
14694
14926
|
yield* validateAcceptInput(input);
|
|
14695
|
-
yield*
|
|
14927
|
+
yield* Effect66.annotateCurrentSpan({
|
|
14696
14928
|
"relay.execution.id": input.executionId,
|
|
14697
14929
|
"relay.address.root": input.rootAddressId
|
|
14698
14930
|
});
|
|
@@ -14701,7 +14933,7 @@ var layer44 = Layer58.effect(Service44, Effect65.gen(function* () {
|
|
|
14701
14933
|
id: input.sessionId,
|
|
14702
14934
|
rootAddressId: input.rootAddressId,
|
|
14703
14935
|
now: input.createdAt
|
|
14704
|
-
}).pipe(
|
|
14936
|
+
}).pipe(Effect66.mapError((error5) => new ExecutionServiceError({ message: error5.message })));
|
|
14705
14937
|
}
|
|
14706
14938
|
const record2 = yield* repository.create({
|
|
14707
14939
|
id: input.executionId,
|
|
@@ -14714,33 +14946,33 @@ var layer44 = Layer58.effect(Service44, Effect65.gen(function* () {
|
|
|
14714
14946
|
...input.agentSnapshot === undefined ? {} : { agentSnapshot: input.agentSnapshot },
|
|
14715
14947
|
...input.agentToolInputSchemaDigests === undefined ? {} : { agentToolInputSchemaDigests: input.agentToolInputSchemaDigests },
|
|
14716
14948
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
14717
|
-
}).pipe(
|
|
14718
|
-
yield* eventLog.append(acceptedEvent(input)).pipe(
|
|
14949
|
+
}).pipe(Effect66.mapError(mapRepositoryError8));
|
|
14950
|
+
yield* eventLog.append(acceptedEvent(input)).pipe(Effect66.mapError(mapEventLogError4));
|
|
14719
14951
|
yield* recordExecutionAccepted;
|
|
14720
14952
|
return toExecution(record2);
|
|
14721
14953
|
}),
|
|
14722
|
-
run:
|
|
14723
|
-
yield*
|
|
14954
|
+
run: Effect66.fn("ExecutionService.run")(function* (input) {
|
|
14955
|
+
yield* Effect66.annotateCurrentSpan("relay.execution.id", input.executionId);
|
|
14724
14956
|
const existing = yield* existingTerminalExecution(repository, eventLog, input);
|
|
14725
14957
|
if (existing?.execution !== undefined)
|
|
14726
14958
|
return existing.execution;
|
|
14727
14959
|
if (existing?.failure !== undefined)
|
|
14728
|
-
return yield*
|
|
14960
|
+
return yield* Effect66.fail(existing.failure);
|
|
14729
14961
|
yield* updateStatus2(repository, input.executionId, "running", input.startedAt, undefined);
|
|
14730
|
-
yield* appendIdempotentTo(eventLog, startedEvent(input, runnerAddress)).pipe(
|
|
14731
|
-
return yield* input.program.pipe(
|
|
14732
|
-
onFailure: (error5) =>
|
|
14962
|
+
yield* appendIdempotentTo(eventLog, startedEvent(input, runnerAddress)).pipe(Effect66.mapError(mapEventLogError4));
|
|
14963
|
+
return yield* input.program.pipe(Effect66.matchEffect({
|
|
14964
|
+
onFailure: (error5) => Effect66.gen(function* () {
|
|
14733
14965
|
const failedExecution = yield* updateStatus2(repository, input.executionId, "failed", input.completedAt, {
|
|
14734
14966
|
message: error5.message
|
|
14735
14967
|
});
|
|
14736
14968
|
if (failedExecution.status !== "failed")
|
|
14737
14969
|
return failedExecution;
|
|
14738
|
-
yield* appendIdempotentTo(eventLog, failedEvent(input, error5)).pipe(
|
|
14970
|
+
yield* appendIdempotentTo(eventLog, failedEvent(input, error5)).pipe(Effect66.mapError(mapEventLogError4));
|
|
14739
14971
|
yield* recordExecutionFinished("failed");
|
|
14740
14972
|
yield* recordExecutionDuration("failed", failedExecution.updated_at - failedExecution.created_at);
|
|
14741
|
-
return yield*
|
|
14973
|
+
return yield* Effect66.fail(error5);
|
|
14742
14974
|
}),
|
|
14743
|
-
onSuccess: (result) =>
|
|
14975
|
+
onSuccess: (result) => Effect66.gen(function* () {
|
|
14744
14976
|
const resultMetadata = result.metadata ?? {};
|
|
14745
14977
|
if (result._tag === "waiting") {
|
|
14746
14978
|
const execution2 = yield* updateStatus2(repository, input.executionId, "waiting", input.completedAt, resultMetadata);
|
|
@@ -14750,31 +14982,31 @@ var layer44 = Layer58.effect(Service44, Effect65.gen(function* () {
|
|
|
14750
14982
|
const execution = yield* updateStatus2(repository, input.executionId, "completed", input.completedAt, resultMetadata);
|
|
14751
14983
|
if (execution.status !== "completed")
|
|
14752
14984
|
return execution;
|
|
14753
|
-
yield* appendIdempotentTo(eventLog, completedEvent(input, resultMetadata, completedSequence)).pipe(
|
|
14985
|
+
yield* appendIdempotentTo(eventLog, completedEvent(input, resultMetadata, completedSequence)).pipe(Effect66.mapError(mapEventLogError4));
|
|
14754
14986
|
yield* recordExecutionFinished("completed");
|
|
14755
14987
|
yield* recordExecutionDuration("completed", execution.updated_at - execution.created_at);
|
|
14756
14988
|
return execution;
|
|
14757
14989
|
})
|
|
14758
14990
|
}));
|
|
14759
14991
|
}),
|
|
14760
|
-
cancel:
|
|
14761
|
-
yield*
|
|
14762
|
-
const current2 = yield* repository.get(input.executionId).pipe(
|
|
14992
|
+
cancel: Effect66.fn("ExecutionService.cancel")(function* (input) {
|
|
14993
|
+
yield* Effect66.annotateCurrentSpan("relay.execution.id", input.executionId);
|
|
14994
|
+
const current2 = yield* repository.get(input.executionId).pipe(Effect66.mapError(mapRepositoryError8));
|
|
14763
14995
|
if (current2?.status === "cancelled")
|
|
14764
14996
|
return toExecution(current2);
|
|
14765
14997
|
const metadata10 = input.metadata ?? (input.reason === undefined ? {} : { reason: input.reason });
|
|
14766
14998
|
const execution = yield* updateStatus2(repository, input.executionId, "cancelled", input.cancelledAt, metadata10);
|
|
14767
14999
|
if (execution.status !== "cancelled")
|
|
14768
15000
|
return execution;
|
|
14769
|
-
yield* appendIdempotentTo(eventLog, cancelledEvent(input)).pipe(
|
|
15001
|
+
yield* appendIdempotentTo(eventLog, cancelledEvent(input)).pipe(Effect66.mapError(mapEventLogError4));
|
|
14770
15002
|
yield* recordExecutionFinished("cancelled");
|
|
14771
15003
|
yield* recordExecutionDuration("cancelled", execution.updated_at - execution.created_at);
|
|
14772
15004
|
return execution;
|
|
14773
15005
|
}),
|
|
14774
|
-
send:
|
|
15006
|
+
send: Effect66.fn("ExecutionService.send")(function* (input) {
|
|
14775
15007
|
const executionId = exports_ids_schema.ExecutionId.make(input.correlation_key ?? `${input.from}:${input.to}`);
|
|
14776
15008
|
const envelopeId = exports_ids_schema.EnvelopeId.make(`${executionId}:envelope`);
|
|
14777
|
-
yield*
|
|
15009
|
+
yield* Effect66.annotateCurrentSpan({
|
|
14778
15010
|
"relay.execution.id": executionId,
|
|
14779
15011
|
"relay.envelope.id": envelopeId,
|
|
14780
15012
|
"relay.address.from": input.from,
|
|
@@ -14788,11 +15020,11 @@ var layer44 = Layer58.effect(Service44, Effect65.gen(function* () {
|
|
|
14788
15020
|
cursor: `${executionId}:envelope:${envelopeId}:accepted`,
|
|
14789
15021
|
content: input.content,
|
|
14790
15022
|
created_at: 0
|
|
14791
|
-
}).pipe(
|
|
15023
|
+
}).pipe(Effect66.mapError(mapEventLogError4));
|
|
14792
15024
|
return { envelope_id: envelopeId, execution_id: executionId };
|
|
14793
15025
|
}),
|
|
14794
|
-
spawnChildRun:
|
|
14795
|
-
yield*
|
|
15026
|
+
spawnChildRun: Effect66.fn("ExecutionService.spawnChildRun")(function* (input) {
|
|
15027
|
+
yield* Effect66.annotateCurrentSpan({
|
|
14796
15028
|
"relay.execution.id": input.execution_id,
|
|
14797
15029
|
"relay.address.id": input.address_id
|
|
14798
15030
|
});
|
|
@@ -14802,13 +15034,13 @@ var layer44 = Layer58.effect(Service44, Effect65.gen(function* () {
|
|
|
14802
15034
|
...baseInput,
|
|
14803
15035
|
presets: presetMap(input.presets),
|
|
14804
15036
|
presetName: input.preset_name
|
|
14805
|
-
}).pipe(
|
|
15037
|
+
}).pipe(Effect66.mapError(mapChildRunError));
|
|
14806
15038
|
}
|
|
14807
15039
|
const override = dynamicOverride(input);
|
|
14808
15040
|
return yield* childRuns.spawnDynamic({
|
|
14809
15041
|
...baseInput,
|
|
14810
15042
|
...override === undefined ? {} : { override }
|
|
14811
|
-
}).pipe(
|
|
15043
|
+
}).pipe(Effect66.mapError(mapChildRunError));
|
|
14812
15044
|
}),
|
|
14813
15045
|
stream: (input) => {
|
|
14814
15046
|
const stream3 = eventLog.stream(input).pipe(Stream11.mapError((error5) => mapEventLogError4(error5)));
|
|
@@ -14816,29 +15048,29 @@ var layer44 = Layer58.effect(Service44, Effect65.gen(function* () {
|
|
|
14816
15048
|
}
|
|
14817
15049
|
});
|
|
14818
15050
|
}));
|
|
14819
|
-
var
|
|
14820
|
-
var
|
|
14821
|
-
var accept =
|
|
14822
|
-
const service = yield*
|
|
15051
|
+
var memoryLayer40 = layer45.pipe(Layer59.provide(layer39), Layer59.provide(exports_execution_repository.memoryLayer), Layer59.provide(exports_session_repository.memoryLayer), Layer59.provide(exports_child_execution_repository.memoryLayer), Layer59.provide(memoryLayer29), Layer59.provide(ShardingConfig.layer({ runnerAddress: Option21.none() })));
|
|
15052
|
+
var testLayer53 = (implementation) => Layer59.succeed(Service45, Service45.of(implementation));
|
|
15053
|
+
var accept = Effect66.fn("ExecutionService.accept.call")(function* (input) {
|
|
15054
|
+
const service = yield* Service45;
|
|
14823
15055
|
return yield* service.accept(input);
|
|
14824
15056
|
});
|
|
14825
|
-
var run2 =
|
|
14826
|
-
const service = yield*
|
|
15057
|
+
var run2 = Effect66.fn("ExecutionService.run.call")(function* (input) {
|
|
15058
|
+
const service = yield* Service45;
|
|
14827
15059
|
return yield* service.run(input);
|
|
14828
15060
|
});
|
|
14829
|
-
var cancel4 =
|
|
14830
|
-
const service = yield*
|
|
15061
|
+
var cancel4 = Effect66.fn("ExecutionService.cancel.call")(function* (input) {
|
|
15062
|
+
const service = yield* Service45;
|
|
14831
15063
|
return yield* service.cancel(input);
|
|
14832
15064
|
});
|
|
14833
|
-
var send =
|
|
14834
|
-
const service = yield*
|
|
15065
|
+
var send = Effect66.fn("ExecutionService.send.call")(function* (input) {
|
|
15066
|
+
const service = yield* Service45;
|
|
14835
15067
|
return yield* service.send(input);
|
|
14836
15068
|
});
|
|
14837
|
-
var spawnChildRun =
|
|
14838
|
-
const service = yield*
|
|
15069
|
+
var spawnChildRun = Effect66.fn("ExecutionService.spawnChildRun.call")(function* (input) {
|
|
15070
|
+
const service = yield* Service45;
|
|
14839
15071
|
return yield* service.spawnChildRun(input);
|
|
14840
15072
|
});
|
|
14841
|
-
var stream3 = (input) => Stream11.unwrap(
|
|
15073
|
+
var stream3 = (input) => Stream11.unwrap(Service45.pipe(Effect66.map((service) => service.stream(input))));
|
|
14842
15074
|
|
|
14843
15075
|
// ../runtime/src/workflow/execution-workflow.ts
|
|
14844
15076
|
var exports_execution_workflow = {};
|
|
@@ -14876,7 +15108,7 @@ import { Effect as Effect93, Exit as Exit2, Option as Option28, Schema as Schema
|
|
|
14876
15108
|
var exports_agent_loop_service = {};
|
|
14877
15109
|
__export(exports_agent_loop_service, {
|
|
14878
15110
|
toolFromDefinition: () => toolFromDefinition,
|
|
14879
|
-
testLayer: () =>
|
|
15111
|
+
testLayer: () => testLayer59,
|
|
14880
15112
|
run: () => run4,
|
|
14881
15113
|
mapBoundaryError: () => mapBoundaryError,
|
|
14882
15114
|
layer: () => layer57,
|
|
@@ -14890,44 +15122,53 @@ import { Cause as Cause5, Config as Config4, Context as Context67, Crypto as Cry
|
|
|
14890
15122
|
import { AiError as AiError5, Chat as Chat3, LanguageModel as LanguageModel7, Prompt as Prompt16, Tokenizer as Tokenizer4, Toolkit as Toolkit8 } from "effect/unstable/ai";
|
|
14891
15123
|
|
|
14892
15124
|
// ../runtime/src/child/spawn-child-run-tool.ts
|
|
14893
|
-
import { Effect as
|
|
15125
|
+
import { Effect as Effect67, Schema as Schema74 } from "effect";
|
|
14894
15126
|
var toolName2 = "spawn_child_run";
|
|
14895
15127
|
var permissionName2 = "relay.child_run.spawn";
|
|
14896
|
-
var Input2 =
|
|
14897
|
-
preset_name:
|
|
14898
|
-
instructions:
|
|
14899
|
-
model:
|
|
14900
|
-
compaction_policy:
|
|
14901
|
-
tool_names:
|
|
14902
|
-
permissions:
|
|
14903
|
-
output_schema_ref:
|
|
14904
|
-
metadata:
|
|
14905
|
-
input:
|
|
15128
|
+
var Input2 = Schema74.Struct({
|
|
15129
|
+
preset_name: Schema74.optionalKey(exports_shared_schema.NonEmptyString),
|
|
15130
|
+
instructions: Schema74.optionalKey(Schema74.String),
|
|
15131
|
+
model: Schema74.optionalKey(exports_agent_schema.ModelSelection),
|
|
15132
|
+
compaction_policy: Schema74.optionalKey(exports_agent_schema.CompactionPolicy),
|
|
15133
|
+
tool_names: Schema74.optionalKey(Schema74.Array(Schema74.String)),
|
|
15134
|
+
permissions: Schema74.optionalKey(Schema74.Array(Schema74.String)),
|
|
15135
|
+
output_schema_ref: Schema74.optionalKey(Schema74.String),
|
|
15136
|
+
metadata: Schema74.optionalKey(exports_shared_schema.Metadata),
|
|
15137
|
+
input: Schema74.optionalKey(Schema74.Array(exports_content_schema.Part))
|
|
14906
15138
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Input" });
|
|
14907
|
-
var Output2 =
|
|
15139
|
+
var Output2 = Schema74.Struct({
|
|
14908
15140
|
child_execution_id: exports_ids_schema.ChildExecutionId,
|
|
14909
|
-
status:
|
|
14910
|
-
output:
|
|
15141
|
+
status: Schema74.Literals(["completed", "failed", "cancelled"]),
|
|
15142
|
+
output: Schema74.Array(exports_content_schema.Part)
|
|
14911
15143
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Output" });
|
|
14912
|
-
var TransferInput =
|
|
14913
|
-
input:
|
|
15144
|
+
var TransferInput = Schema74.Struct({
|
|
15145
|
+
input: Schema74.optionalKey(Schema74.Array(exports_content_schema.Part))
|
|
14914
15146
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.TransferInput" });
|
|
14915
|
-
var ModelInput =
|
|
14916
|
-
preset_name:
|
|
14917
|
-
instructions:
|
|
14918
|
-
model:
|
|
14919
|
-
provider:
|
|
14920
|
-
model:
|
|
14921
|
-
registration_key:
|
|
15147
|
+
var ModelInput = Schema74.Struct({
|
|
15148
|
+
preset_name: Schema74.optionalKey(Schema74.NullOr(Schema74.String)),
|
|
15149
|
+
instructions: Schema74.optionalKey(Schema74.String),
|
|
15150
|
+
model: Schema74.optionalKey(Schema74.NullOr(Schema74.Struct({
|
|
15151
|
+
provider: Schema74.String,
|
|
15152
|
+
model: Schema74.String,
|
|
15153
|
+
registration_key: Schema74.optionalKey(Schema74.String)
|
|
14922
15154
|
}))),
|
|
14923
|
-
compaction_policy:
|
|
14924
|
-
|
|
14925
|
-
|
|
14926
|
-
|
|
14927
|
-
|
|
15155
|
+
compaction_policy: Schema74.optionalKey(Schema74.Struct({
|
|
15156
|
+
context_window: Schema74.Number,
|
|
15157
|
+
reserve_tokens: Schema74.Number,
|
|
15158
|
+
keep_recent_tokens: Schema74.Number,
|
|
15159
|
+
summary_model: Schema74.optionalKey(Schema74.Struct({
|
|
15160
|
+
provider: Schema74.String,
|
|
15161
|
+
model: Schema74.String,
|
|
15162
|
+
registration_key: Schema74.optionalKey(Schema74.String)
|
|
15163
|
+
}))
|
|
15164
|
+
})),
|
|
15165
|
+
tool_names: Schema74.optionalKey(Schema74.Array(Schema74.String)),
|
|
15166
|
+
permissions: Schema74.optionalKey(Schema74.Array(Schema74.String)),
|
|
15167
|
+
output_schema_ref: Schema74.optionalKey(Schema74.NullOr(Schema74.String)),
|
|
15168
|
+
input: Schema74.optionalKey(Schema74.Array(Schema74.Struct({ type: Schema74.Literal("text"), text: Schema74.String })))
|
|
14928
15169
|
});
|
|
14929
|
-
var ModelTransferInput =
|
|
14930
|
-
input:
|
|
15170
|
+
var ModelTransferInput = Schema74.Struct({
|
|
15171
|
+
input: Schema74.optionalKey(Schema74.Array(Schema74.Struct({ type: Schema74.Literal("text"), text: Schema74.String })))
|
|
14931
15172
|
});
|
|
14932
15173
|
var normalizeModelInput = (input) => {
|
|
14933
15174
|
const { preset_name: presetName, model, output_schema_ref: outputSchemaRef, ...rest } = input;
|
|
@@ -14961,7 +15202,7 @@ var hasDynamicOverride = (input) => input.instructions !== undefined || input.mo
|
|
|
14961
15202
|
var childExecutionId2 = (context) => exports_ids_schema.ChildExecutionId.make(`${context.executionId}:child:${context.call.id}`);
|
|
14962
15203
|
var childAddressId = (id2) => exports_ids_schema.AddressId.make(`address:child:${id2}`);
|
|
14963
15204
|
var childWaitId = (id2) => exports_ids_schema.WaitId.make(`wait:child:${id2}`);
|
|
14964
|
-
var nextEventSequence2 = (eventLog, executionId) => eventLog.maxSequence(executionId).pipe(
|
|
15205
|
+
var nextEventSequence2 = (eventLog, executionId) => eventLog.maxSequence(executionId).pipe(Effect67.map((max) => max === undefined ? 0 : max + 1), Effect67.mapError((error5) => new ToolRuntimeError({ message: error5.message })));
|
|
14965
15206
|
var mapChildRunError2 = (activeToolName, error5) => new ToolExecutionFailed({ tool_name: activeToolName, message: error5._tag });
|
|
14966
15207
|
var mapWaitError = (error5) => new ToolRuntimeError({ message: error5._tag === "WaitNotFound" ? error5.wait_id : error5.message });
|
|
14967
15208
|
var spawnInput = (config, input, context, id2) => ({
|
|
@@ -14983,10 +15224,10 @@ var spawnInput = (config, input, context, id2) => ({
|
|
|
14983
15224
|
event_sequence: context.eventSequence + 1,
|
|
14984
15225
|
created_at: context.createdAt + 1
|
|
14985
15226
|
});
|
|
14986
|
-
var ensureStaticOrDynamic = (input) => input.preset_name !== undefined && hasDynamicOverride(input) ?
|
|
15227
|
+
var ensureStaticOrDynamic = (input) => input.preset_name !== undefined && hasDynamicOverride(input) ? Effect67.fail(new ToolExecutionFailed({
|
|
14987
15228
|
tool_name: toolName2,
|
|
14988
15229
|
message: "preset_name cannot be combined with dynamic child-run overrides"
|
|
14989
|
-
})) :
|
|
15230
|
+
})) : Effect67.void;
|
|
14990
15231
|
var childOverride2 = (input) => {
|
|
14991
15232
|
if (!hasDynamicOverride(input))
|
|
14992
15233
|
return;
|
|
@@ -15013,7 +15254,7 @@ var presetMap2 = (agent) => new Map(Object.entries(agent.child_run_presets ?? {}
|
|
|
15013
15254
|
...preset.metadata === undefined ? {} : { metadata: preset.metadata }
|
|
15014
15255
|
}
|
|
15015
15256
|
]));
|
|
15016
|
-
var createJoinWait =
|
|
15257
|
+
var createJoinWait = Effect67.fn("SpawnChildRunTool.createJoinWait")(function* (config, input, id2, waitId, createdAt) {
|
|
15017
15258
|
const eventSequence = yield* nextEventSequence2(config.eventLog, input.execution_id);
|
|
15018
15259
|
yield* config.waits.createDetached({
|
|
15019
15260
|
waitId,
|
|
@@ -15026,9 +15267,9 @@ var createJoinWait = Effect66.fn("SpawnChildRunTool.createJoinWait")(function* (
|
|
|
15026
15267
|
},
|
|
15027
15268
|
eventSequence,
|
|
15028
15269
|
createdAt
|
|
15029
|
-
}).pipe(
|
|
15270
|
+
}).pipe(Effect67.mapError(mapWaitError));
|
|
15030
15271
|
});
|
|
15031
|
-
var dispatchChild =
|
|
15272
|
+
var dispatchChild = Effect67.fn("SpawnChildRunTool.dispatchChild")(function* (config, input, id2, definition, waitId) {
|
|
15032
15273
|
yield* config.dispatch({
|
|
15033
15274
|
executionId: exports_ids_schema.ExecutionId.make(id2),
|
|
15034
15275
|
rootAddressId: input.address_id,
|
|
@@ -15046,38 +15287,38 @@ var dispatchChild = Effect66.fn("SpawnChildRunTool.dispatchChild")(function* (co
|
|
|
15046
15287
|
child_execution_id: id2,
|
|
15047
15288
|
parent_wait_id: waitId
|
|
15048
15289
|
}
|
|
15049
|
-
}).pipe(
|
|
15290
|
+
}).pipe(Effect67.mapError((error5) => new ToolRuntimeError({ message: String(error5) })));
|
|
15050
15291
|
});
|
|
15051
15292
|
var childStatus = (wait) => {
|
|
15052
15293
|
const status = wait.metadata.child_status;
|
|
15053
15294
|
if (status === "completed" || status === "failed" || status === "cancelled")
|
|
15054
|
-
return
|
|
15055
|
-
return
|
|
15295
|
+
return Effect67.succeed(status);
|
|
15296
|
+
return Effect67.fail(new ToolRuntimeError({ message: "Child join wait resolved without child_status" }));
|
|
15056
15297
|
};
|
|
15057
|
-
var terminalEvent2 =
|
|
15058
|
-
const events = yield* eventLog.replay({ executionId, limit: 1e4 }).pipe(
|
|
15298
|
+
var terminalEvent2 = Effect67.fn("SpawnChildRunTool.terminalEvent")(function* (eventLog, executionId, id2) {
|
|
15299
|
+
const events = yield* eventLog.replay({ executionId, limit: 1e4 }).pipe(Effect67.mapError((error5) => new ToolRuntimeError({ message: error5._tag })));
|
|
15059
15300
|
return events.find((event) => event.type === "child_run.event" && event.child_execution_id === id2);
|
|
15060
15301
|
});
|
|
15061
|
-
var resultFromTerminal =
|
|
15302
|
+
var resultFromTerminal = Effect67.fn("SpawnChildRunTool.resultFromTerminal")(function* (config, id2, wait) {
|
|
15062
15303
|
const status = yield* childStatus(wait);
|
|
15063
15304
|
const event = yield* terminalEvent2(config.eventLog, wait.executionId, id2);
|
|
15064
15305
|
const output = event?.content ?? [];
|
|
15065
15306
|
return { child_execution_id: id2, status, output };
|
|
15066
15307
|
});
|
|
15067
|
-
var run3 =
|
|
15308
|
+
var run3 = Effect67.fn("SpawnChildRunTool.run")(function* (config, activeToolName, input, context, enforceStaticOrDynamic) {
|
|
15068
15309
|
if (enforceStaticOrDynamic)
|
|
15069
15310
|
yield* ensureStaticOrDynamic(input);
|
|
15070
15311
|
const id2 = childExecutionId2(context);
|
|
15071
15312
|
const waitId = childWaitId(id2);
|
|
15072
|
-
const existingWait = yield* config.waits.get(waitId).pipe(
|
|
15313
|
+
const existingWait = yield* config.waits.get(waitId).pipe(Effect67.mapError(mapWaitError));
|
|
15073
15314
|
if (existingWait?.state === "open") {
|
|
15074
|
-
return yield*
|
|
15315
|
+
return yield* Effect67.fail(new ToolExecutionWaitRequested({ tool_name: activeToolName, wait_id: waitId }));
|
|
15075
15316
|
}
|
|
15076
15317
|
if (existingWait !== undefined)
|
|
15077
15318
|
return yield* resultFromTerminal(config, id2, existingWait);
|
|
15078
15319
|
const spawn = spawnInput(config, input, context, id2);
|
|
15079
|
-
const resolved = yield* resolveForDispatch(spawn).pipe(
|
|
15080
|
-
const definition = yield* childDefinition(config.agent, resolved).pipe(
|
|
15320
|
+
const resolved = yield* resolveForDispatch(spawn).pipe(Effect67.mapError((error5) => mapChildRunError2(activeToolName, error5)));
|
|
15321
|
+
const definition = yield* childDefinition(config.agent, resolved).pipe(Effect67.mapError((error5) => mapChildRunError2(activeToolName, error5)));
|
|
15081
15322
|
if (input.preset_name !== undefined) {
|
|
15082
15323
|
yield* config.childRuns.spawnStatic({
|
|
15083
15324
|
childExecutionId: id2,
|
|
@@ -15088,7 +15329,7 @@ var run3 = Effect66.fn("SpawnChildRunTool.run")(function* (config, activeToolNam
|
|
|
15088
15329
|
presetName: input.preset_name,
|
|
15089
15330
|
eventSequence: context.eventSequence + 1,
|
|
15090
15331
|
createdAt: context.createdAt + 1
|
|
15091
|
-
}).pipe(
|
|
15332
|
+
}).pipe(Effect67.mapError((error5) => mapChildRunError2(activeToolName, error5)));
|
|
15092
15333
|
} else {
|
|
15093
15334
|
const override = childOverride2(input);
|
|
15094
15335
|
yield* config.childRuns.spawnDynamic({
|
|
@@ -15099,11 +15340,11 @@ var run3 = Effect66.fn("SpawnChildRunTool.run")(function* (config, activeToolNam
|
|
|
15099
15340
|
...override === undefined ? {} : { override },
|
|
15100
15341
|
eventSequence: context.eventSequence + 1,
|
|
15101
15342
|
createdAt: context.createdAt + 1
|
|
15102
|
-
}).pipe(
|
|
15343
|
+
}).pipe(Effect67.mapError((error5) => mapChildRunError2(activeToolName, error5)));
|
|
15103
15344
|
}
|
|
15104
15345
|
yield* createJoinWait(config, spawn, id2, waitId, context.createdAt + 2);
|
|
15105
15346
|
yield* dispatchChild(config, spawn, id2, definition, waitId);
|
|
15106
|
-
return yield*
|
|
15347
|
+
return yield* Effect67.fail(new ToolExecutionWaitRequested({ tool_name: activeToolName, wait_id: waitId }));
|
|
15107
15348
|
});
|
|
15108
15349
|
var registeredTool2 = (config) => tool(toolName2, {
|
|
15109
15350
|
description: "Spawn a durable child run and wait for its terminal output.",
|
|
@@ -15112,7 +15353,7 @@ var registeredTool2 = (config) => tool(toolName2, {
|
|
|
15112
15353
|
permissions: [{ name: permissionName2, value: true }],
|
|
15113
15354
|
requiredPermissions: [permissionName2],
|
|
15114
15355
|
metadata: { relay_core_tool: true },
|
|
15115
|
-
run: (input, context) =>
|
|
15356
|
+
run: (input, context) => Schema74.decodeUnknownEffect(Input2)(normalizeModelInput(input)).pipe(Effect67.flatMap((decoded) => run3(config, toolName2, decoded, context, true)))
|
|
15116
15357
|
});
|
|
15117
15358
|
var transferToolName2 = (name) => `transfer_to_${name.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g, "_").replaceAll(/^_+|_+$/g, "")}`;
|
|
15118
15359
|
var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target) => {
|
|
@@ -15124,141 +15365,13 @@ var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target
|
|
|
15124
15365
|
permissions: [{ name: permissionName2, value: true }],
|
|
15125
15366
|
requiredPermissions: [permissionName2],
|
|
15126
15367
|
metadata: { relay_core_tool: true, handoff_target: target.name, preset_name: target.preset_name },
|
|
15127
|
-
run: (input, context) =>
|
|
15368
|
+
run: (input, context) => Schema74.decodeUnknownEffect(TransferInput)(input).pipe(Effect67.flatMap((decoded) => run3(config, name, { preset_name: target.preset_name, input: decoded.input ?? [] }, context, false)))
|
|
15128
15369
|
});
|
|
15129
15370
|
});
|
|
15130
15371
|
|
|
15131
15372
|
// ../runtime/src/memory/memory-service.ts
|
|
15132
15373
|
import { Clock as Clock8, Context as Context59, Effect as Effect68, Layer as Layer60, Schema as Schema75 } from "effect";
|
|
15133
15374
|
import { EmbeddingModel as EmbeddingModel3, Prompt as Prompt13 } from "effect/unstable/ai";
|
|
15134
|
-
|
|
15135
|
-
// ../runtime/src/model/embedding-model-service.ts
|
|
15136
|
-
import { Context as Context58, Effect as Effect67, Layer as Layer59, Ref as Ref18, Schema as Schema74 } from "effect";
|
|
15137
|
-
import { EmbeddingModel as EmbeddingModel2, Model as Model3 } from "effect/unstable/ai";
|
|
15138
|
-
|
|
15139
|
-
class EmbeddingModelNotRegistered extends Schema74.TaggedErrorClass()("EmbeddingModelNotRegistered", {
|
|
15140
|
-
provider: Schema74.String,
|
|
15141
|
-
model: Schema74.String,
|
|
15142
|
-
registration_key: Schema74.optionalKey(Schema74.String)
|
|
15143
|
-
}) {
|
|
15144
|
-
}
|
|
15145
|
-
|
|
15146
|
-
class Service45 extends Context58.Service()("@relayfx/runtime/EmbeddingModelService") {
|
|
15147
|
-
}
|
|
15148
|
-
var toRegistration = (input) => ({
|
|
15149
|
-
provider: input.provider,
|
|
15150
|
-
model: input.model,
|
|
15151
|
-
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
15152
|
-
layer: input.layer,
|
|
15153
|
-
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
15154
|
-
});
|
|
15155
|
-
var selectionError = (selection) => new EmbeddingModelNotRegistered({
|
|
15156
|
-
provider: selection.provider,
|
|
15157
|
-
model: selection.model,
|
|
15158
|
-
...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
|
|
15159
|
-
});
|
|
15160
|
-
var defaultSelectionError = () => new EmbeddingModelNotRegistered({ provider: "default", model: "default" });
|
|
15161
|
-
var matchesSelection2 = (selection, registration) => registration.provider === selection.provider && registration.model === selection.model && (selection.registrationKey === undefined || registration.registrationKey === selection.registrationKey);
|
|
15162
|
-
var resolve5 = (registrations4, selection) => {
|
|
15163
|
-
const matches2 = registrations4.filter((registration) => matchesSelection2(selection, registration));
|
|
15164
|
-
if (selection.registrationKey !== undefined)
|
|
15165
|
-
return matches2[0];
|
|
15166
|
-
if (matches2.length === 1)
|
|
15167
|
-
return matches2[0];
|
|
15168
|
-
return matches2.find((registration) => registration.registrationKey === undefined);
|
|
15169
|
-
};
|
|
15170
|
-
var resolveDefault = (registrations4, options) => {
|
|
15171
|
-
if (options?.defaultSelection !== undefined) {
|
|
15172
|
-
return resolve5(registrations4, options.defaultSelection);
|
|
15173
|
-
}
|
|
15174
|
-
return registrations4.length === 1 ? registrations4[0] : undefined;
|
|
15175
|
-
};
|
|
15176
|
-
var registrationFromLayer3 = (input) => Model3.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect67.map((layer45) => toRegistration({
|
|
15177
|
-
provider: input.provider,
|
|
15178
|
-
model: input.model,
|
|
15179
|
-
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
15180
|
-
layer: layer45,
|
|
15181
|
-
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
15182
|
-
})));
|
|
15183
|
-
var layer45 = (initialRegistrations = [], options) => Layer59.effect(Service45, Effect67.gen(function* () {
|
|
15184
|
-
const registry = yield* Ref18.make([...initialRegistrations]);
|
|
15185
|
-
const register9 = Effect67.fn("EmbeddingModelService.register")(function* (input) {
|
|
15186
|
-
const registration = toRegistration(input);
|
|
15187
|
-
yield* Ref18.update(registry, (current2) => [
|
|
15188
|
-
...current2.filter((item) => !(item.provider === registration.provider && item.model === registration.model && item.registrationKey === registration.registrationKey)),
|
|
15189
|
-
registration
|
|
15190
|
-
]);
|
|
15191
|
-
});
|
|
15192
|
-
const registrations4 = Ref18.get(registry);
|
|
15193
|
-
const provide3 = (selection, effect) => Effect67.gen(function* () {
|
|
15194
|
-
const current2 = yield* Ref18.get(registry);
|
|
15195
|
-
const registration = resolve5(current2, selection);
|
|
15196
|
-
if (registration === undefined)
|
|
15197
|
-
return yield* Effect67.fail(selectionError(selection));
|
|
15198
|
-
return yield* effect.pipe(Effect67.provide(registration.layer));
|
|
15199
|
-
});
|
|
15200
|
-
const provideDefault = (effect) => Effect67.gen(function* () {
|
|
15201
|
-
const current2 = yield* Ref18.get(registry);
|
|
15202
|
-
const registration = resolveDefault(current2, options);
|
|
15203
|
-
if (registration === undefined)
|
|
15204
|
-
return yield* Effect67.fail(defaultSelectionError());
|
|
15205
|
-
return yield* effect.pipe(Effect67.provide(registration.layer));
|
|
15206
|
-
});
|
|
15207
|
-
const provideForAgent2 = (agent, effect) => {
|
|
15208
|
-
return provideDefault(effect);
|
|
15209
|
-
};
|
|
15210
|
-
return Service45.of({ register: register9, registrations: registrations4, provide: provide3, provideDefault, provideForAgent: provideForAgent2 });
|
|
15211
|
-
}));
|
|
15212
|
-
var layerFromRegistrationEffects3 = (registrations4, options) => Layer59.unwrap(Effect67.all(registrations4).pipe(Effect67.map((items) => layer45(items, options))));
|
|
15213
|
-
var memoryLayer40 = layer45;
|
|
15214
|
-
var words = (input) => input.toLowerCase().match(/[a-z0-9]+/g) ?? [];
|
|
15215
|
-
var hashWord = (word) => {
|
|
15216
|
-
let hash = 2166136261;
|
|
15217
|
-
for (let index = 0;index < word.length; index += 1) {
|
|
15218
|
-
hash ^= word.charCodeAt(index);
|
|
15219
|
-
hash = Math.imul(hash, 16777619);
|
|
15220
|
-
}
|
|
15221
|
-
return hash >>> 0;
|
|
15222
|
-
};
|
|
15223
|
-
var deterministicVector = (input, dimensions) => {
|
|
15224
|
-
const vector = Array.from({ length: dimensions }, () => 0);
|
|
15225
|
-
for (const word of words(input)) {
|
|
15226
|
-
const hash = hashWord(word);
|
|
15227
|
-
const index = hash % dimensions;
|
|
15228
|
-
vector[index] = (vector[index] ?? 0) + 1;
|
|
15229
|
-
}
|
|
15230
|
-
return vector;
|
|
15231
|
-
};
|
|
15232
|
-
var deterministicLayer = (options = {}) => {
|
|
15233
|
-
const dimensions = options.dimensions ?? 64;
|
|
15234
|
-
return Layer59.mergeAll(Layer59.effect(EmbeddingModel2.EmbeddingModel, EmbeddingModel2.make({
|
|
15235
|
-
embedMany: ({ inputs }) => Effect67.succeed({
|
|
15236
|
-
results: inputs.map((input) => deterministicVector(input, dimensions)),
|
|
15237
|
-
usage: { inputTokens: inputs.reduce((total, input) => total + words(input).length, 0) }
|
|
15238
|
-
})
|
|
15239
|
-
})), Layer59.succeed(EmbeddingModel2.Dimensions, dimensions));
|
|
15240
|
-
};
|
|
15241
|
-
var deterministicRegistration = (options = {}) => registrationFromLayer3({
|
|
15242
|
-
provider: options.provider ?? "test",
|
|
15243
|
-
model: options.model ?? "deterministic-embedding",
|
|
15244
|
-
layer: deterministicLayer(options)
|
|
15245
|
-
});
|
|
15246
|
-
var deterministicTestLayer = (options = {}) => layerFromRegistrationEffects3([deterministicRegistration(options)], {
|
|
15247
|
-
defaultSelection: {
|
|
15248
|
-
provider: options.provider ?? "test",
|
|
15249
|
-
model: options.model ?? "deterministic-embedding"
|
|
15250
|
-
}
|
|
15251
|
-
});
|
|
15252
|
-
var register9 = Effect67.fn("EmbeddingModelService.register.call")(function* (input) {
|
|
15253
|
-
const service = yield* Service45;
|
|
15254
|
-
return yield* service.register(input);
|
|
15255
|
-
});
|
|
15256
|
-
var registrations4 = Effect67.fn("EmbeddingModelService.registrations.call")(function* () {
|
|
15257
|
-
const service = yield* Service45;
|
|
15258
|
-
return yield* service.registrations;
|
|
15259
|
-
});
|
|
15260
|
-
|
|
15261
|
-
// ../runtime/src/memory/memory-service.ts
|
|
15262
15375
|
class Service46 extends Context59.Service()("@relayfx/runtime/MemoryService") {
|
|
15263
15376
|
}
|
|
15264
15377
|
var defaultTopK = 5;
|
|
@@ -15334,7 +15447,7 @@ var embed = (models, text2, options) => {
|
|
|
15334
15447
|
};
|
|
15335
15448
|
var make7 = (options = {}) => Effect68.gen(function* () {
|
|
15336
15449
|
const repository = yield* exports_memory_repository.Service;
|
|
15337
|
-
const models = yield*
|
|
15450
|
+
const models = yield* Service38;
|
|
15338
15451
|
const recall = Effect68.fn("MemoryService.recall")(function* (input) {
|
|
15339
15452
|
const text2 = latestUserText(input.prompt);
|
|
15340
15453
|
if (text2 === undefined)
|
|
@@ -15408,7 +15521,7 @@ var forget2 = Effect68.fn("MemoryService.forget.call")(function* (input) {
|
|
|
15408
15521
|
// ../runtime/src/state/execution-state-service.ts
|
|
15409
15522
|
var exports_execution_state_service = {};
|
|
15410
15523
|
__export(exports_execution_state_service, {
|
|
15411
|
-
testLayer: () =>
|
|
15524
|
+
testLayer: () => testLayer54,
|
|
15412
15525
|
memoryLayer: () => memoryLayer41,
|
|
15413
15526
|
layer: () => layer47,
|
|
15414
15527
|
key: () => key3,
|
|
@@ -15441,7 +15554,7 @@ var stateError = (cause) => new ExecutionStateError({ message: String(cause) });
|
|
|
15441
15554
|
var invalid = (stateKey, cause) => new StateValueInvalid({ key: stateKey, message: String(cause) });
|
|
15442
15555
|
var layer47 = Layer61.effect(Service47, Effect69.gen(function* () {
|
|
15443
15556
|
const repository = yield* exports_execution_state_repository.Service;
|
|
15444
|
-
const blobs = yield*
|
|
15557
|
+
const blobs = yield* Service43;
|
|
15445
15558
|
const eventInlineMaxBytes = yield* Config3.number("RELAY_STATE_EVENT_INLINE_MAX_BYTES").pipe(Config3.withDefault(65536), Effect69.orDie);
|
|
15446
15559
|
const get15 = Effect69.fn("ExecutionStateService.get")(function* (executionId, stateKey) {
|
|
15447
15560
|
const row = yield* repository.get(executionId, stateKey.name).pipe(Effect69.mapError(stateError));
|
|
@@ -15479,7 +15592,7 @@ var layer47 = Layer61.effect(Service47, Effect69.gen(function* () {
|
|
|
15479
15592
|
}));
|
|
15480
15593
|
var memoryRepositoryDependencies = Layer61.mergeAll(exports_execution_repository.memoryLayer, exports_execution_event_repository.memoryLayer);
|
|
15481
15594
|
var memoryLayer41 = layer47.pipe(Layer61.provide(exports_execution_state_repository.memoryLayer.pipe(Layer61.provide(memoryRepositoryDependencies))));
|
|
15482
|
-
var
|
|
15595
|
+
var testLayer54 = (implementation) => Layer61.succeed(Service47, Service47.of(implementation));
|
|
15483
15596
|
|
|
15484
15597
|
// ../runtime/src/state/state-tools.ts
|
|
15485
15598
|
import { Effect as Effect70, Schema as Schema77 } from "effect";
|
|
@@ -15820,15 +15933,15 @@ var makeLayer = (signalDependencies) => Layer63.effect(Service49, Effect73.gen(f
|
|
|
15820
15933
|
if (wait?.state === "open") {
|
|
15821
15934
|
const waitId = wait.id;
|
|
15822
15935
|
const sequence = yield* nextSequence(eventLog, input.executionId).pipe(Effect73.mapError((error5) => new InboxDeliveryError({ execution_id: input.executionId, message: error5._tag })));
|
|
15823
|
-
const
|
|
15936
|
+
const transition3 = yield* waits.wake({ waitId, resolvedAt: input.createdAt, eventSequence: sequence }).pipe(Effect73.mapError((error5) => new InboxDeliveryError({
|
|
15824
15937
|
execution_id: input.executionId,
|
|
15825
15938
|
message: error5._tag === "WaitNotFound" ? error5.wait_id : error5.message
|
|
15826
15939
|
})));
|
|
15827
|
-
if (
|
|
15940
|
+
if (transition3.transitioned && signalDependencies !== undefined) {
|
|
15828
15941
|
yield* signalWorkflowWait({
|
|
15829
15942
|
makeExecutionClient: signalDependencies.makeExecutionClient,
|
|
15830
|
-
executionId:
|
|
15831
|
-
waitId:
|
|
15943
|
+
executionId: transition3.wait.executionId,
|
|
15944
|
+
waitId: transition3.wait.id,
|
|
15832
15945
|
state: "resolved",
|
|
15833
15946
|
signaledAt: input.createdAt
|
|
15834
15947
|
}).pipe(Effect73.provideService(exports_execution_repository.Service, signalDependencies.executionRepository), Effect73.mapError((error5) => new InboxDeliveryError({ execution_id: input.executionId, message: String(error5) })));
|
|
@@ -15866,14 +15979,14 @@ var makeLayer = (signalDependencies) => Layer63.effect(Service49, Effect73.gen(f
|
|
|
15866
15979
|
}
|
|
15867
15980
|
}).pipe(Effect73.mapError((error5) => new InboxDeliveryError({ execution_id: wait.executionId, message: error5.message })));
|
|
15868
15981
|
const sequence = yield* nextSequence(eventLog, wait.executionId).pipe(Effect73.mapError((error5) => new InboxDeliveryError({ execution_id: wait.executionId, message: error5._tag })));
|
|
15869
|
-
const
|
|
15870
|
-
if (!
|
|
15982
|
+
const transition3 = yield* waits.wake({ waitId, resolvedAt: input.createdAt, eventSequence: sequence }).pipe(Effect73.mapError(() => new InboxReplyTokenInvalid({ reply_token: input.replyToken })));
|
|
15983
|
+
if (!transition3.transitioned)
|
|
15871
15984
|
return yield* new InboxReplyTokenInvalid({ reply_token: input.replyToken });
|
|
15872
15985
|
if (signalDependencies !== undefined) {
|
|
15873
15986
|
yield* signalWorkflowWait({
|
|
15874
15987
|
makeExecutionClient: signalDependencies.makeExecutionClient,
|
|
15875
|
-
executionId:
|
|
15876
|
-
waitId:
|
|
15988
|
+
executionId: transition3.wait.executionId,
|
|
15989
|
+
waitId: transition3.wait.id,
|
|
15877
15990
|
state: "resolved",
|
|
15878
15991
|
signaledAt: input.createdAt
|
|
15879
15992
|
}).pipe(Effect73.provideService(exports_execution_repository.Service, signalDependencies.executionRepository), Effect73.mapError((error5) => new InboxDeliveryError({ execution_id: wait.executionId, message: String(error5) })));
|
|
@@ -15890,7 +16003,7 @@ var memoryLayer42 = layer48.pipe(Layer63.provide(exports_inbox_repository.memory
|
|
|
15890
16003
|
var exports_topic_service = {};
|
|
15891
16004
|
__export(exports_topic_service, {
|
|
15892
16005
|
unsubscribe: () => unsubscribe,
|
|
15893
|
-
testLayer: () =>
|
|
16006
|
+
testLayer: () => testLayer55,
|
|
15894
16007
|
subscribe: () => subscribe,
|
|
15895
16008
|
publish: () => publish,
|
|
15896
16009
|
memoryLayer: () => memoryLayer43,
|
|
@@ -15974,7 +16087,7 @@ var layer49 = Layer64.effect(Service50, Effect74.gen(function* () {
|
|
|
15974
16087
|
return Service50.of({ subscribe, unsubscribe, publish, list: list16 });
|
|
15975
16088
|
}));
|
|
15976
16089
|
var memoryLayer43 = layer49.pipe(Layer64.provide(exports_topic_repository.memoryLayer));
|
|
15977
|
-
var
|
|
16090
|
+
var testLayer55 = (implementation) => Layer64.succeed(Service50, Service50.of(implementation));
|
|
15978
16091
|
var subscribe = (input) => Effect74.flatMap(Service50, (service) => service.subscribe(input));
|
|
15979
16092
|
var unsubscribe = (input) => Effect74.flatMap(Service50, (service) => service.unsubscribe(input));
|
|
15980
16093
|
var publish = (input) => Effect74.flatMap(Service50, (service) => service.publish(input));
|
|
@@ -16075,8 +16188,8 @@ var registeredTool4 = (config) => tool(toolName4, {
|
|
|
16075
16188
|
}).pipe(Effect76.mapError((error5) => new ToolRuntimeError({ message: error5.message })));
|
|
16076
16189
|
if ((yield* config.inbox.undrainedCount(context.executionId).pipe(Effect76.mapError((error5) => new ToolRuntimeError({ message: error5.message })))) > 0) {
|
|
16077
16190
|
const sequence = yield* config.eventLog.maxSequence(context.executionId).pipe(Effect76.map((value) => (value ?? -1) + 1), Effect76.mapError((error5) => new ToolRuntimeError({ message: error5._tag })));
|
|
16078
|
-
const
|
|
16079
|
-
if (
|
|
16191
|
+
const transition3 = yield* config.waits.wake({ waitId, resolvedAt: context.createdAt, eventSequence: sequence }).pipe(Effect76.mapError((error5) => new ToolRuntimeError({ message: error5._tag })));
|
|
16192
|
+
if (transition3.transitioned) {
|
|
16080
16193
|
const drained = yield* drain3();
|
|
16081
16194
|
return { status: "messages", messages: drained.map(project2) };
|
|
16082
16195
|
}
|
|
@@ -16132,7 +16245,7 @@ var registeredTool5 = (config) => tool(toolName5, {
|
|
|
16132
16245
|
// ../runtime/src/envelope/envelope-service.ts
|
|
16133
16246
|
var exports_envelope_service = {};
|
|
16134
16247
|
__export(exports_envelope_service, {
|
|
16135
|
-
testLayer: () =>
|
|
16248
|
+
testLayer: () => testLayer56,
|
|
16136
16249
|
send: () => send2,
|
|
16137
16250
|
memoryLayer: () => memoryLayer44,
|
|
16138
16251
|
layer: () => layer50,
|
|
@@ -16337,7 +16450,7 @@ var layer50 = Layer65.effect(Service51, Effect78.gen(function* () {
|
|
|
16337
16450
|
});
|
|
16338
16451
|
}));
|
|
16339
16452
|
var memoryLayer44 = (routes = []) => layer50.pipe(Layer65.provide(memoryLayer28(routes)), Layer65.provide(exports_envelope_repository.memoryLayer), Layer65.provide(memoryLayer29));
|
|
16340
|
-
var
|
|
16453
|
+
var testLayer56 = (implementation) => Layer65.succeed(Service51, Service51.of(implementation));
|
|
16341
16454
|
var send2 = Effect78.fn("EnvelopeService.send.call")(function* (input) {
|
|
16342
16455
|
const service = yield* Service51;
|
|
16343
16456
|
return yield* service.send(input);
|
|
@@ -16346,7 +16459,7 @@ var send2 = Effect78.fn("EnvelopeService.send.call")(function* (input) {
|
|
|
16346
16459
|
// ../runtime/src/agent/prompt-assembler-service.ts
|
|
16347
16460
|
var exports_prompt_assembler_service = {};
|
|
16348
16461
|
__export(exports_prompt_assembler_service, {
|
|
16349
|
-
testLayer: () =>
|
|
16462
|
+
testLayer: () => testLayer58,
|
|
16350
16463
|
layer: () => layer51,
|
|
16351
16464
|
defaultLayerWithStores: () => defaultLayerWithStores,
|
|
16352
16465
|
defaultLayer: () => defaultLayer,
|
|
@@ -16361,8 +16474,8 @@ import { Prompt as Prompt14 } from "effect/unstable/ai";
|
|
|
16361
16474
|
// ../runtime/src/content/artifact-store-service.ts
|
|
16362
16475
|
var exports_artifact_store_service = {};
|
|
16363
16476
|
__export(exports_artifact_store_service, {
|
|
16364
|
-
testLayer: () =>
|
|
16365
|
-
resolve: () =>
|
|
16477
|
+
testLayer: () => testLayer57,
|
|
16478
|
+
resolve: () => resolve7,
|
|
16366
16479
|
register: () => register10,
|
|
16367
16480
|
passthroughLayer: () => passthroughLayer2,
|
|
16368
16481
|
memoryLayer: () => memoryLayer45,
|
|
@@ -16405,8 +16518,8 @@ var memoryServiceLayer = Layer66.effect(Service52, Effect79.gen(function* () {
|
|
|
16405
16518
|
return Service52.of({ resolve: memory.resolve });
|
|
16406
16519
|
}));
|
|
16407
16520
|
var memoryLayer45 = memoryServiceLayer.pipe(Layer66.provideMerge(Layer66.effect(Memory2, makeMemory2)));
|
|
16408
|
-
var
|
|
16409
|
-
var
|
|
16521
|
+
var testLayer57 = (implementation) => Layer66.succeed(Service52, Service52.of(implementation));
|
|
16522
|
+
var resolve7 = Effect79.fn("ArtifactStore.resolve.call")(function* (part) {
|
|
16410
16523
|
const service = yield* Service52;
|
|
16411
16524
|
return yield* service.resolve(part);
|
|
16412
16525
|
});
|
|
@@ -16502,13 +16615,13 @@ var makeDefaultInterface = (blobs, artifacts) => ({
|
|
|
16502
16615
|
assemble: (input) => defaultPrompt(blobs, artifacts, input.input).pipe(Effect80.map((prompt) => ({ system: defaultSystem(input.agent, input.tools), prompt })))
|
|
16503
16616
|
});
|
|
16504
16617
|
var defaultLayerWithStores = Layer67.effect(Service53, Effect80.gen(function* () {
|
|
16505
|
-
const blobs = yield*
|
|
16618
|
+
const blobs = yield* Service43;
|
|
16506
16619
|
const artifacts = yield* Service52;
|
|
16507
16620
|
return Service53.of(makeDefaultInterface(blobs, artifacts));
|
|
16508
16621
|
}));
|
|
16509
16622
|
var defaultLayer = defaultLayerWithStores.pipe(Layer67.provide(Layer67.mergeAll(passthroughLayer, passthroughLayer2)));
|
|
16510
16623
|
var layer51 = (implementation) => Layer67.succeed(Service53, Service53.of(implementation));
|
|
16511
|
-
var
|
|
16624
|
+
var testLayer58 = (implementation) => Layer67.succeed(Service53, Service53.of(implementation));
|
|
16512
16625
|
var assemble = Effect80.fn("PromptAssembler.assemble.call")(function* (input) {
|
|
16513
16626
|
const service = yield* Service53;
|
|
16514
16627
|
return yield* service.assemble(input);
|
|
@@ -16541,7 +16654,7 @@ var strategy2 = (config) => {
|
|
|
16541
16654
|
const existing = yield* config.repository.get({ executionId: config.executionId, checkpointId: id2 }).pipe(Effect81.mapError(mapRepositoryError10));
|
|
16542
16655
|
if (existing !== undefined)
|
|
16543
16656
|
return existing.summary;
|
|
16544
|
-
const summary = yield* base2.summarize(plan2, request);
|
|
16657
|
+
const summary = yield* config.options?.summaryModel === undefined ? base2.summarize(plan2, request) : config.options.summaryModel.pipe(Effect81.flatMap((model) => base2.summarize(plan2, request).pipe(Effect81.provide(model))));
|
|
16545
16658
|
const createdAt = yield* Clock12.currentTimeMillis;
|
|
16546
16659
|
const input = {
|
|
16547
16660
|
executionId: config.executionId,
|
|
@@ -16926,7 +17039,7 @@ var store = (blobStore, toolCallId, content) => {
|
|
|
16926
17039
|
var make11 = (blobStore) => ({
|
|
16927
17040
|
put: (toolCallId, content) => store(blobStore, toolCallId, content)
|
|
16928
17041
|
});
|
|
16929
|
-
var layer56 = Layer72.effect(exports_tool_output.ToolOutputStore,
|
|
17042
|
+
var layer56 = Layer72.effect(exports_tool_output.ToolOutputStore, Service43.pipe(Effect85.map((blobStore) => exports_tool_output.ToolOutputStore.of(make11(blobStore)))));
|
|
16930
17043
|
|
|
16931
17044
|
// ../runtime/src/agent/sequence-allocator.ts
|
|
16932
17045
|
import { Effect as Effect86, Ref as Ref20 } from "effect";
|
|
@@ -17327,22 +17440,22 @@ var compactionOptions = (agent) => agent.compaction_policy === undefined ? undef
|
|
|
17327
17440
|
};
|
|
17328
17441
|
var layer57 = Layer73.effect(Service54, Effect87.gen(function* () {
|
|
17329
17442
|
const eventLog = yield* Service30;
|
|
17330
|
-
const languageModels = yield*
|
|
17443
|
+
const languageModels = yield* Service39;
|
|
17331
17444
|
const tools = yield* Service32;
|
|
17332
17445
|
const childRuns = yield* Effect87.serviceOption(Service37);
|
|
17333
17446
|
const chats = yield* exports_agent_chat_repository.Service;
|
|
17334
|
-
const policy = yield*
|
|
17447
|
+
const policy = yield* Service40;
|
|
17335
17448
|
const assembler = yield* Service53;
|
|
17336
|
-
const schemas = yield*
|
|
17449
|
+
const schemas = yield* Service42;
|
|
17337
17450
|
const durableMemory = yield* Effect87.serviceOption(Service46);
|
|
17338
|
-
const blobStore = yield* Effect87.serviceOption(
|
|
17451
|
+
const blobStore = yield* Effect87.serviceOption(Service43);
|
|
17339
17452
|
const compactionRepository = yield* Effect87.serviceOption(exports_compaction_repository.Service);
|
|
17340
17453
|
const contextEpochs = yield* Effect87.serviceOption(exports_context_epoch_repository.Service);
|
|
17341
17454
|
const sessionRepository = yield* Effect87.serviceOption(exports_session_repository.Service);
|
|
17342
17455
|
const permissionRules = yield* Effect87.serviceOption(exports_permission_rule_repository.Service);
|
|
17343
17456
|
const steeringRepository = yield* Effect87.serviceOption(exports_steering_repository.Service);
|
|
17344
17457
|
const waits = yield* Effect87.serviceOption(Service31);
|
|
17345
|
-
const presence = yield* Effect87.serviceOption(
|
|
17458
|
+
const presence = yield* Effect87.serviceOption(Service41);
|
|
17346
17459
|
const inbox = yield* Effect87.serviceOption(Service49);
|
|
17347
17460
|
const topics = yield* Effect87.serviceOption(Service50);
|
|
17348
17461
|
const envelopes = yield* Effect87.serviceOption(Service51);
|
|
@@ -17387,7 +17500,16 @@ var layer57 = Layer73.effect(Service54, Effect87.gen(function* () {
|
|
|
17387
17500
|
yield* appendEvent(eventLog, inputPreparedEvent(input, definitions2), input.eventSequence + 1);
|
|
17388
17501
|
const toolOutputMaxBytes = yield* effectiveToolOutputMaxBytes(input);
|
|
17389
17502
|
const compactionPolicy = input.agent.compaction_policy;
|
|
17390
|
-
const
|
|
17503
|
+
const configuredCompactionOptions = compactionOptions(input.agent);
|
|
17504
|
+
const activeCompactionOptions = configuredCompactionOptions === undefined ? undefined : {
|
|
17505
|
+
...configuredCompactionOptions,
|
|
17506
|
+
...compactionPolicy?.summary_model === undefined ? {} : {
|
|
17507
|
+
summaryModel: resolve4(compactionPolicy.summary_model).pipe(Effect87.provideService(Service39, languageModels), Effect87.map((registration) => registration.layer), Effect87.mapError((error5) => new exports_compaction.CompactionError({
|
|
17508
|
+
message: `LanguageModelNotRegistered: ${error5.provider}/${error5.model}`,
|
|
17509
|
+
cause: error5
|
|
17510
|
+
})))
|
|
17511
|
+
}
|
|
17512
|
+
};
|
|
17391
17513
|
const runTokenizer = yield* Effect87.serviceOption(Tokenizer4.Tokenizer);
|
|
17392
17514
|
const activeTokenizer = Option25.isSome(runTokenizer) ? runTokenizer : tokenizer;
|
|
17393
17515
|
const allocator = yield* make12(input.eventSequence + 1);
|
|
@@ -17622,7 +17744,7 @@ var layer57 = Layer73.effect(Service54, Effect87.gen(function* () {
|
|
|
17622
17744
|
})
|
|
17623
17745
|
});
|
|
17624
17746
|
}));
|
|
17625
|
-
var
|
|
17747
|
+
var testLayer59 = (implementation) => Layer73.succeed(Service54, Service54.of(implementation));
|
|
17626
17748
|
var run4 = Effect87.fn("AgentLoop.run.call")(function* (input) {
|
|
17627
17749
|
const service = yield* Service54;
|
|
17628
17750
|
return yield* service.run(input);
|
|
@@ -18848,12 +18970,14 @@ var signalWait = Effect93.fn("ExecutionWorkflow.signalWait")(function* (input) {
|
|
|
18848
18970
|
var exports_child_fan_out_runtime = {};
|
|
18849
18971
|
__export(exports_child_fan_out_runtime, {
|
|
18850
18972
|
testHandlersLayer: () => testHandlersLayer,
|
|
18973
|
+
layerFromRuntime: () => layerFromRuntime,
|
|
18851
18974
|
layer: () => layer62,
|
|
18975
|
+
handlersLayer: () => handlersLayer,
|
|
18852
18976
|
Service: () => Service61,
|
|
18853
18977
|
HandlerService: () => HandlerService,
|
|
18854
18978
|
ChildFanOutRuntimeError: () => ChildFanOutRuntimeError
|
|
18855
18979
|
});
|
|
18856
|
-
import { Clock as Clock15, Context as Context74, Effect as Effect95, Layer as Layer81, Schema as Schema95 } from "effect";
|
|
18980
|
+
import { Clock as Clock15, Context as Context74, Effect as Effect95, FiberMap, Layer as Layer81, Schema as Schema95 } from "effect";
|
|
18857
18981
|
|
|
18858
18982
|
// ../runtime/src/child/child-fan-out-transition-service.ts
|
|
18859
18983
|
var exports_child_fan_out_transition_service = {};
|
|
@@ -18937,11 +19061,11 @@ class ChildFanOutRuntimeError extends Schema95.TaggedErrorClass()("ChildFanOutRu
|
|
|
18937
19061
|
class Service61 extends Context74.Service()("@relayfx/runtime/ChildFanOutRuntime") {
|
|
18938
19062
|
}
|
|
18939
19063
|
var runtimeError = (error5) => new ChildFanOutRuntimeError({ message: String(error5) });
|
|
18940
|
-
var
|
|
19064
|
+
var layerFromRuntime = Layer81.effect(Service61, Effect95.gen(function* () {
|
|
18941
19065
|
const repository = yield* exports_child_fan_out_repository.Service;
|
|
18942
19066
|
const transitions = yield* Service60;
|
|
18943
19067
|
const handlers = yield* HandlerService;
|
|
18944
|
-
const
|
|
19068
|
+
const hosts = yield* FiberMap.make();
|
|
18945
19069
|
const run5 = Effect95.fn("ChildFanOutRuntime.run")(function* (fanOutId) {
|
|
18946
19070
|
while (true) {
|
|
18947
19071
|
const fanOut2 = yield* repository.get(fanOutId);
|
|
@@ -18971,7 +19095,7 @@ var layer62 = Layer81.effect(Service61, Effect95.gen(function* () {
|
|
|
18971
19095
|
})), { concurrency: fanOut2.max_concurrency, discard: true });
|
|
18972
19096
|
}
|
|
18973
19097
|
});
|
|
18974
|
-
const launch = (fanOutId) => run5(fanOutId).pipe(Effect95.ignore,
|
|
19098
|
+
const launch = (fanOutId) => FiberMap.run(hosts, fanOutId, run5(fanOutId).pipe(Effect95.ignore), { onlyIfMissing: true }).pipe(Effect95.asVoid);
|
|
18975
19099
|
const recover = Effect95.fn("ChildFanOutRuntime.recover")(function* () {
|
|
18976
19100
|
const fanOuts = yield* repository.listNonTerminal();
|
|
18977
19101
|
yield* Effect95.forEach(fanOuts, (fanOut2) => launch(fanOut2.fan_out_id), { discard: true });
|
|
@@ -18996,7 +19120,9 @@ var layer62 = Layer81.effect(Service61, Effect95.gen(function* () {
|
|
|
18996
19120
|
yield* recover().pipe(Effect95.mapError(runtimeError));
|
|
18997
19121
|
return service;
|
|
18998
19122
|
}).pipe(Effect95.mapError(runtimeError)));
|
|
18999
|
-
var
|
|
19123
|
+
var layer62 = layerFromRuntime;
|
|
19124
|
+
var handlersLayer = (handlers) => Layer81.succeed(HandlerService, handlers);
|
|
19125
|
+
var testHandlersLayer = handlersLayer;
|
|
19000
19126
|
|
|
19001
19127
|
// ../runtime/src/cluster/execution-entity.ts
|
|
19002
19128
|
var exports_execution_entity = {};
|
|
@@ -19050,7 +19176,7 @@ var client2 = entity.client;
|
|
|
19050
19176
|
var exports_scheduler_service = {};
|
|
19051
19177
|
__export(exports_scheduler_service, {
|
|
19052
19178
|
workerIdConfig: () => workerIdConfig,
|
|
19053
|
-
testLayer: () =>
|
|
19179
|
+
testLayer: () => testLayer60,
|
|
19054
19180
|
startIdempotencyKey: () => startIdempotencyKey,
|
|
19055
19181
|
runOnce: () => runOnce2,
|
|
19056
19182
|
pollIntervalMillisConfig: () => pollIntervalMillisConfig,
|
|
@@ -19216,7 +19342,7 @@ var layer64 = Layer82.effect(Service62, Effect96.gen(function* () {
|
|
|
19216
19342
|
return service;
|
|
19217
19343
|
}));
|
|
19218
19344
|
var memoryLayer47 = Layer82.effect(Service62, make15);
|
|
19219
|
-
var
|
|
19345
|
+
var testLayer60 = (implementation) => Layer82.succeed(Service62, Service62.of(implementation));
|
|
19220
19346
|
var runOnce2 = Effect96.fn("SchedulerService.runOnce.call")(function* () {
|
|
19221
19347
|
const service = yield* Service62;
|
|
19222
19348
|
return yield* service.runOnce;
|
|
@@ -19228,7 +19354,7 @@ __export(exports_runner_runtime_service, {
|
|
|
19228
19354
|
testLayerWithServices: () => testLayerWithServices,
|
|
19229
19355
|
testLayerWithLanguageModelService: () => testLayerWithLanguageModelService,
|
|
19230
19356
|
testLayerWithDatabaseCheck: () => testLayerWithDatabaseCheck,
|
|
19231
|
-
testLayer: () =>
|
|
19357
|
+
testLayer: () => testLayer65,
|
|
19232
19358
|
testClientLayerWithDatabaseCheck: () => testClientLayerWithDatabaseCheck,
|
|
19233
19359
|
testClientLayer: () => testClientLayer,
|
|
19234
19360
|
shardingConfigFromEnv: () => shardingConfigFromEnv,
|
|
@@ -19274,7 +19400,7 @@ import { LanguageModel as LanguageModel8 } from "effect/unstable/ai";
|
|
|
19274
19400
|
// ../runtime/src/execution/execution-watch-service.ts
|
|
19275
19401
|
var exports_execution_watch_service = {};
|
|
19276
19402
|
__export(exports_execution_watch_service, {
|
|
19277
|
-
testLayer: () =>
|
|
19403
|
+
testLayer: () => testLayer61,
|
|
19278
19404
|
memoryLayer: () => memoryLayer48,
|
|
19279
19405
|
layerFromServices: () => layerFromServices,
|
|
19280
19406
|
Service: () => Service63,
|
|
@@ -19330,12 +19456,12 @@ var layerFromServices = Layer83.effect(Service63, Effect97.gen(function* () {
|
|
|
19330
19456
|
});
|
|
19331
19457
|
}));
|
|
19332
19458
|
var memoryLayer48 = layerFromServices;
|
|
19333
|
-
var
|
|
19459
|
+
var testLayer61 = (implementation) => Layer83.succeed(Service63, Service63.of(implementation));
|
|
19334
19460
|
|
|
19335
19461
|
// ../runtime/src/entity/entity-registry-service.ts
|
|
19336
19462
|
var exports_entity_registry_service = {};
|
|
19337
19463
|
__export(exports_entity_registry_service, {
|
|
19338
|
-
testLayer: () =>
|
|
19464
|
+
testLayer: () => testLayer62,
|
|
19339
19465
|
layer: () => layer65,
|
|
19340
19466
|
Service: () => Service64,
|
|
19341
19467
|
EntityRegistryError: () => EntityRegistryError,
|
|
@@ -19385,12 +19511,12 @@ var layer65 = Layer84.effect(Service64, Effect98.gen(function* () {
|
|
|
19385
19511
|
listKinds: () => repository.listKinds().pipe(Effect98.mapError(repositoryError4))
|
|
19386
19512
|
});
|
|
19387
19513
|
}));
|
|
19388
|
-
var
|
|
19514
|
+
var testLayer62 = (implementation) => Layer84.succeed(Service64, Service64.of(implementation));
|
|
19389
19515
|
|
|
19390
19516
|
// ../runtime/src/entity/entity-instance-service.ts
|
|
19391
19517
|
var exports_entity_instance_service = {};
|
|
19392
19518
|
__export(exports_entity_instance_service, {
|
|
19393
|
-
testLayer: () =>
|
|
19519
|
+
testLayer: () => testLayer63,
|
|
19394
19520
|
layer: () => layer66,
|
|
19395
19521
|
entitySessionId: () => entitySessionId,
|
|
19396
19522
|
entityExecutionId: () => entityExecutionId,
|
|
@@ -19515,12 +19641,12 @@ var layer66 = Layer85.effect(Service65, Effect99.gen(function* () {
|
|
|
19515
19641
|
list: (input) => repository.list(input).pipe(Effect99.mapError(serviceError2))
|
|
19516
19642
|
});
|
|
19517
19643
|
}));
|
|
19518
|
-
var
|
|
19644
|
+
var testLayer63 = (implementation) => Layer85.succeed(Service65, Service65.of(implementation));
|
|
19519
19645
|
|
|
19520
19646
|
// ../runtime/src/execution/session-stream-service.ts
|
|
19521
19647
|
var exports_session_stream_service = {};
|
|
19522
19648
|
__export(exports_session_stream_service, {
|
|
19523
|
-
testLayer: () =>
|
|
19649
|
+
testLayer: () => testLayer64,
|
|
19524
19650
|
memoryLayer: () => memoryLayer49,
|
|
19525
19651
|
layerFromServices: () => layerFromServices2,
|
|
19526
19652
|
SessionStreamError: () => SessionStreamError,
|
|
@@ -19560,7 +19686,7 @@ var layerFromServices2 = Layer86.effect(Service66, Effect100.gen(function* () {
|
|
|
19560
19686
|
});
|
|
19561
19687
|
}));
|
|
19562
19688
|
var memoryLayer49 = layerFromServices2;
|
|
19563
|
-
var
|
|
19689
|
+
var testLayer64 = (implementation) => Layer86.succeed(Service66, Service66.of(implementation));
|
|
19564
19690
|
|
|
19565
19691
|
// ../runtime/src/runner/runner-runtime-service.ts
|
|
19566
19692
|
var DatabaseMode = Schema102.Literals(["sql", "pg", "mysql", "sqlite", "memory"]).annotate({
|
|
@@ -19687,7 +19813,8 @@ var assertClusterConfig = Effect101.fn("RunnerRuntime.assertClusterConfig")(func
|
|
|
19687
19813
|
return yield* new ClusterConfigMismatch({ field: "availableShardGroups", expected: want, actual });
|
|
19688
19814
|
}
|
|
19689
19815
|
});
|
|
19690
|
-
var
|
|
19816
|
+
var sqlNotificationLayer = exports_notification_bus.layerFromDialect;
|
|
19817
|
+
var sqlRepositoryBaseLayer = Layer87.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(Layer87.provideMerge(sqlNotificationLayer));
|
|
19691
19818
|
var sqlRepositoryLayer = Layer87.mergeAll(sqlRepositoryBaseLayer, exports_execution_state_repository.layer.pipe(Layer87.provide(sqlRepositoryBaseLayer)));
|
|
19692
19819
|
var memoryRepositoryBaseLayer = Layer87.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);
|
|
19693
19820
|
var memoryRepositoryLayer = Layer87.mergeAll(memoryRepositoryBaseLayer, exports_execution_state_repository.memoryLayer.pipe(Layer87.provide(memoryRepositoryBaseLayer)));
|
|
@@ -19695,7 +19822,7 @@ var testCryptoLayer = Layer87.succeed(Crypto4.Crypto, Crypto4.make({
|
|
|
19695
19822
|
randomBytes: (size) => new Uint8Array(size),
|
|
19696
19823
|
digest: (algorithm, data) => Effect101.promise(() => globalThis.crypto.subtle.digest(algorithm, data).then((buffer) => new Uint8Array(buffer)))
|
|
19697
19824
|
}));
|
|
19698
|
-
var executionServiceLayer =
|
|
19825
|
+
var executionServiceLayer = layer45.pipe(Layer87.provideMerge(layer39));
|
|
19699
19826
|
var addressResolutionLayerWith = (toolRuntimeLayer) => layer31.pipe(Layer87.provideMerge(layerFromRepository), Layer87.provideMerge(layer30.pipe(Layer87.provideMerge(toolRuntimeLayer))));
|
|
19700
19827
|
var parentNotifierLayer = Layer87.effect(Service55, Effect101.gen(function* () {
|
|
19701
19828
|
const makeExecutionClient = yield* client2;
|
|
@@ -19710,7 +19837,7 @@ var parentNotifierLayer = Layer87.effect(Service55, Effect101.gen(function* () {
|
|
|
19710
19837
|
}).pipe(Effect101.provideService(exports_execution_repository.Service, executionRepository))
|
|
19711
19838
|
});
|
|
19712
19839
|
}));
|
|
19713
|
-
var agentLoopLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer) => layer57.pipe(Layer87.provideMerge(toolRuntimeLayer), Layer87.provideMerge(layer39), Layer87.provideMerge(
|
|
19840
|
+
var agentLoopLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer) => layer57.pipe(Layer87.provideMerge(toolRuntimeLayer), Layer87.provideMerge(layer39), Layer87.provideMerge(layer42()), Layer87.provideMerge(promptAssemblerLayer), Layer87.provideMerge(schemaRegistryLayer));
|
|
19714
19841
|
var runtimeServicesLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer) => {
|
|
19715
19842
|
const inboxLayer = Layer87.unwrap(Effect101.gen(function* () {
|
|
19716
19843
|
const makeExecutionClient = yield* client2;
|
|
@@ -19722,7 +19849,7 @@ var runtimeServicesLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRe
|
|
|
19722
19849
|
const agentLayer = agentLoopLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer).pipe(Layer87.provideMerge(inboxLayer), Layer87.provideMerge(envelopeLayer), Layer87.provideMerge(topicLayer));
|
|
19723
19850
|
const entityRegistryLayer = layer65.pipe(Layer87.provideMerge(layer30));
|
|
19724
19851
|
const entityInstanceLayer = layer66.pipe(Layer87.provideMerge(entityRegistryLayer), Layer87.provideMerge(layerFromRepository), Layer87.provideMerge(layerFromRepository2));
|
|
19725
|
-
return Layer87.mergeAll(addressResolutionLayerWith(toolRuntimeLayer),
|
|
19852
|
+
return Layer87.mergeAll(addressResolutionLayerWith(toolRuntimeLayer), layer44, executionServiceLayer, layerFromServices, layerFromServices2, layerFromRepository3, agentLayer, layer59, parentNotifierLayer, inboxLayer, envelopeLayer, topicLayer, entityRegistryLayer, entityInstanceLayer, toolTransitionCoordinatorLayer, layer58).pipe(Layer87.provideMerge(layer47), Layer87.provideMerge(layer28), Layer87.provideMerge(layerFromRepository2));
|
|
19726
19853
|
};
|
|
19727
19854
|
var workflowLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer) => layer60.pipe(Layer87.provideMerge(runtimeServicesLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer)));
|
|
19728
19855
|
var workflowAndEntityLayerWith = (toolRuntimeLayer, schedulerLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer) => Layer87.mergeAll(layer63, schedulerLayer).pipe(Layer87.provideMerge(workflowLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer, toolTransitionCoordinatorLayer)));
|
|
@@ -19805,8 +19932,8 @@ var deterministicTestModelLayer = Layer87.effect(LanguageModel8.LanguageModel, L
|
|
|
19805
19932
|
generateText: () => Effect101.succeed([{ type: "text", text: "deterministic test response" }]),
|
|
19806
19933
|
streamText: () => Stream15.make({ type: "text-delta", id: "text", delta: "deterministic test response" })
|
|
19807
19934
|
}));
|
|
19808
|
-
var testLanguageModelLayer =
|
|
19809
|
-
|
|
19935
|
+
var testLanguageModelLayer = layerFromRegistrationEffects3([
|
|
19936
|
+
registrationFromLayer3({
|
|
19810
19937
|
provider: "test",
|
|
19811
19938
|
model: "deterministic",
|
|
19812
19939
|
layer: deterministicTestModelLayer
|
|
@@ -19818,8 +19945,8 @@ var layerWith = (options) => {
|
|
|
19818
19945
|
const blobStoreLayer = options.blobStoreLayer ?? passthroughLayer;
|
|
19819
19946
|
const artifactStoreLayer = options.artifactStoreLayer ?? passthroughLayer2;
|
|
19820
19947
|
const promptAssemblerLayer = options.promptAssemblerLayer ?? defaultPromptAssemblerLayer(blobStoreLayer, artifactStoreLayer);
|
|
19821
|
-
const schemaRegistryLayer = options.schemaRegistryLayer ??
|
|
19822
|
-
const embeddingModelLayer = options.embeddingModelLayer ??
|
|
19948
|
+
const schemaRegistryLayer = options.schemaRegistryLayer ?? layer43();
|
|
19949
|
+
const embeddingModelLayer = options.embeddingModelLayer ?? memoryLayer35();
|
|
19823
19950
|
const memoryLayer50 = layer46().pipe(Layer87.provideMerge(embeddingModelLayer));
|
|
19824
19951
|
const clusterContextLayer = Layer87.mergeAll(options.languageModelLayer, memoryLayer50, blobStoreLayer, artifactStoreLayer, promptAssemblerLayer, schemaRegistryLayer);
|
|
19825
19952
|
const clusterLayer = options.clusterLayer.pipe(Layer87.provide(clusterContextLayer));
|
|
@@ -19829,8 +19956,8 @@ var layerWithClient = (options) => {
|
|
|
19829
19956
|
const blobStoreLayer = options.blobStoreLayer ?? passthroughLayer;
|
|
19830
19957
|
const artifactStoreLayer = options.artifactStoreLayer ?? passthroughLayer2;
|
|
19831
19958
|
const promptAssemblerLayer = options.promptAssemblerLayer ?? defaultPromptAssemblerLayer(blobStoreLayer, artifactStoreLayer);
|
|
19832
|
-
const schemaRegistryLayer = options.schemaRegistryLayer ??
|
|
19833
|
-
const embeddingModelLayer = options.embeddingModelLayer ??
|
|
19959
|
+
const schemaRegistryLayer = options.schemaRegistryLayer ?? layer43();
|
|
19960
|
+
const embeddingModelLayer = options.embeddingModelLayer ?? memoryLayer35();
|
|
19834
19961
|
const memoryLayer50 = layer46().pipe(Layer87.provideMerge(embeddingModelLayer));
|
|
19835
19962
|
return Layer87.mergeAll(options.checkLayer, runtimeServicesLayerWith(options.toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer, options.toolTransitionCoordinatorLayer)).pipe(Layer87.provideMerge(options.languageModelLayer), Layer87.provide(memoryLayer50), Layer87.provideMerge(options.clusterLayer), Layer87.provideMerge(options.repositoryLayer), Layer87.provideMerge(blobStoreLayer), Layer87.provideMerge(artifactStoreLayer));
|
|
19836
19963
|
};
|
|
@@ -19890,8 +20017,8 @@ var layer67 = layerWith({
|
|
|
19890
20017
|
checkLayer: sqlCheckLayer,
|
|
19891
20018
|
clusterLayer: sqlClusterLayer,
|
|
19892
20019
|
repositoryLayer: sqlRepositoryLayer,
|
|
19893
|
-
languageModelLayer:
|
|
19894
|
-
embeddingModelLayer:
|
|
20020
|
+
languageModelLayer: memoryLayer36(),
|
|
20021
|
+
embeddingModelLayer: memoryLayer35(),
|
|
19895
20022
|
toolRuntimeLayer: layer29(),
|
|
19896
20023
|
schedulerLayer: layer64
|
|
19897
20024
|
});
|
|
@@ -19906,7 +20033,7 @@ var testLayerWithServices = (options) => layerWith({
|
|
|
19906
20033
|
schedulerLayer: memoryLayer47
|
|
19907
20034
|
}).pipe(Layer87.provideMerge(testCryptoLayer));
|
|
19908
20035
|
var testLayerWithLanguageModelService = (languageModelLayer) => testLayerWithServices({ languageModelLayer, toolRuntimeLayer: layer29() });
|
|
19909
|
-
var
|
|
20036
|
+
var testLayer65 = testLayerWithServices({
|
|
19910
20037
|
languageModelLayer: testLanguageModelLayer,
|
|
19911
20038
|
toolRuntimeLayer: layer29()
|
|
19912
20039
|
});
|
|
@@ -19949,7 +20076,9 @@ __export(exports_definition_runtime, {
|
|
|
19949
20076
|
validate: () => validate,
|
|
19950
20077
|
testHandlersLayer: () => testHandlersLayer2,
|
|
19951
20078
|
run: () => run5,
|
|
20079
|
+
layerFromRuntime: () => layerFromRuntime2,
|
|
19952
20080
|
layer: () => layer68,
|
|
20081
|
+
handlersLayer: () => handlersLayer2,
|
|
19953
20082
|
fanOutIdFor: () => fanOutIdFor,
|
|
19954
20083
|
WorkflowJoining: () => WorkflowJoining,
|
|
19955
20084
|
WorkflowCancelled: () => WorkflowCancelled,
|
|
@@ -19960,7 +20089,7 @@ __export(exports_definition_runtime, {
|
|
|
19960
20089
|
PinnedDefinitionMismatch: () => PinnedDefinitionMismatch,
|
|
19961
20090
|
HandlerService: () => HandlerService2
|
|
19962
20091
|
});
|
|
19963
|
-
import { Cause as Cause6, Clock as Clock17, Context as Context81, Effect as Effect102, Exit as Exit3, Layer as Layer88, Option as Option31, Schema as Schema103 } from "effect";
|
|
20092
|
+
import { Cause as Cause6, Clock as Clock17, Context as Context81, Effect as Effect102, Exit as Exit3, FiberMap as FiberMap2, Layer as Layer88, Option as Option31, Schema as Schema103 } from "effect";
|
|
19964
20093
|
|
|
19965
20094
|
class UnsupportedOperation extends Schema103.TaggedErrorClass()("UnsupportedWorkflowOperation", { operation_id: exports_ids_schema.WorkflowOperationId, kind: Schema103.String }) {
|
|
19966
20095
|
}
|
|
@@ -20258,7 +20387,7 @@ var run5 = Effect102.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
20258
20387
|
});
|
|
20259
20388
|
break;
|
|
20260
20389
|
}
|
|
20261
|
-
const
|
|
20390
|
+
const completedAt = yield* Clock17.currentTimeMillis;
|
|
20262
20391
|
const current2 = yield* repository.getOperation(executionId, id2);
|
|
20263
20392
|
yield* repository.putOperation({
|
|
20264
20393
|
execution_id: executionId,
|
|
@@ -20268,15 +20397,15 @@ var run5 = Effect102.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
20268
20397
|
...current2?.decision === undefined ? {} : { decision: current2.decision },
|
|
20269
20398
|
...current2?.fan_out_id === undefined ? {} : { fan_out_id: current2.fan_out_id },
|
|
20270
20399
|
started_at: startedAt,
|
|
20271
|
-
completed_at:
|
|
20272
|
-
updated_at:
|
|
20400
|
+
completed_at: completedAt,
|
|
20401
|
+
updated_at: completedAt
|
|
20273
20402
|
});
|
|
20274
20403
|
yield* repository.appendLifecycle({
|
|
20275
20404
|
execution_id: executionId,
|
|
20276
20405
|
operation_id: id2,
|
|
20277
20406
|
type: "operation.completed",
|
|
20278
20407
|
...output2 === undefined ? {} : { data: output2 },
|
|
20279
|
-
created_at:
|
|
20408
|
+
created_at: completedAt
|
|
20280
20409
|
});
|
|
20281
20410
|
return output2;
|
|
20282
20411
|
});
|
|
@@ -20286,11 +20415,7 @@ var run5 = Effect102.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
20286
20415
|
if (Option31.isSome(failure3) && failure3.value instanceof WorkflowJoining)
|
|
20287
20416
|
return yield* result;
|
|
20288
20417
|
const currentRun = yield* repository.inspect(executionId);
|
|
20289
|
-
const now = yield* Clock17.currentTimeMillis;
|
|
20290
20418
|
if (currentRun?.status === "cancelled") {
|
|
20291
|
-
const events = yield* repository.listLifecycle(executionId);
|
|
20292
|
-
if (!events.some((event) => event.type === "workflow.cancelled"))
|
|
20293
|
-
yield* repository.appendLifecycle({ execution_id: executionId, type: "workflow.cancelled", created_at: now });
|
|
20294
20419
|
return yield* result;
|
|
20295
20420
|
}
|
|
20296
20421
|
const states = yield* repository.listOperations(executionId);
|
|
@@ -20306,45 +20431,35 @@ var run5 = Effect102.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
20306
20431
|
created_at: yield* Clock17.currentTimeMillis
|
|
20307
20432
|
});
|
|
20308
20433
|
yield* execute(state.compensation_operation_id);
|
|
20309
|
-
const
|
|
20434
|
+
const completedAt = yield* Clock17.currentTimeMillis;
|
|
20310
20435
|
yield* repository.putOperation({
|
|
20311
20436
|
...state,
|
|
20312
20437
|
status: "compensated",
|
|
20313
|
-
completed_at:
|
|
20314
|
-
updated_at:
|
|
20438
|
+
completed_at: completedAt,
|
|
20439
|
+
updated_at: completedAt
|
|
20315
20440
|
});
|
|
20316
20441
|
yield* repository.appendLifecycle({
|
|
20317
20442
|
execution_id: executionId,
|
|
20318
20443
|
operation_id: state.operation_id,
|
|
20319
20444
|
type: "compensation.completed",
|
|
20320
|
-
created_at:
|
|
20445
|
+
created_at: completedAt
|
|
20321
20446
|
});
|
|
20322
20447
|
}
|
|
20323
20448
|
yield* repository.finish(executionId, "failed");
|
|
20324
|
-
yield* repository.appendLifecycle({
|
|
20325
|
-
execution_id: executionId,
|
|
20326
|
-
type: "workflow.failed",
|
|
20327
|
-
created_at: yield* Clock17.currentTimeMillis
|
|
20328
|
-
});
|
|
20329
20449
|
return yield* result;
|
|
20330
20450
|
}
|
|
20331
20451
|
const output = result.value;
|
|
20332
|
-
|
|
20333
|
-
yield* repository.finish(executionId, "completed");
|
|
20334
|
-
yield* repository.appendLifecycle({
|
|
20335
|
-
execution_id: executionId,
|
|
20336
|
-
type: "workflow.completed",
|
|
20337
|
-
...output === undefined ? {} : { data: output },
|
|
20338
|
-
created_at: completedAt
|
|
20339
|
-
});
|
|
20452
|
+
yield* repository.finish(executionId, "completed", output);
|
|
20340
20453
|
return output;
|
|
20341
20454
|
});
|
|
20342
|
-
var
|
|
20343
|
-
var
|
|
20455
|
+
var handlersLayer2 = (handlers) => Layer88.succeed(HandlerService2, handlers);
|
|
20456
|
+
var testHandlersLayer2 = handlersLayer2;
|
|
20457
|
+
var layerFromRuntime2 = Layer88.effect(Service68, Effect102.gen(function* () {
|
|
20344
20458
|
const repository = yield* exports_workflow_definition_repository.Service;
|
|
20345
20459
|
const handlers = yield* HandlerService2;
|
|
20460
|
+
const hosts = yield* FiberMap2.make();
|
|
20346
20461
|
const execute = (executionId) => run5(executionId).pipe(Effect102.provideService(HandlerService2, handlers), Effect102.provideService(exports_workflow_definition_repository.Service, repository));
|
|
20347
|
-
const launch = Effect102.fn("WorkflowDefinitionRuntime.launch")((executionId) => execute(executionId).pipe(Effect102.ignore,
|
|
20462
|
+
const launch = Effect102.fn("WorkflowDefinitionRuntime.launch")((executionId) => FiberMap2.run(hosts, executionId, execute(executionId).pipe(Effect102.ignore), { onlyIfMissing: true }).pipe(Effect102.asVoid));
|
|
20348
20463
|
const recover = Effect102.fn("WorkflowDefinitionRuntime.recover")(function* () {
|
|
20349
20464
|
const records = yield* repository.listNonterminal();
|
|
20350
20465
|
yield* Effect102.forEach(records, (record2) => launch(record2.execution_id), { discard: true });
|
|
@@ -20360,11 +20475,15 @@ var layer68 = Layer88.effect(Service68, Effect102.gen(function* () {
|
|
|
20360
20475
|
recover,
|
|
20361
20476
|
inspect: repository.inspect,
|
|
20362
20477
|
replay: repository.listLifecycle,
|
|
20363
|
-
cancel:
|
|
20478
|
+
cancel: Effect102.fn("WorkflowDefinitionRuntime.cancel")(function* (executionId) {
|
|
20479
|
+
const cancelled = yield* repository.cancel(executionId);
|
|
20480
|
+
return cancelled.record;
|
|
20481
|
+
})
|
|
20364
20482
|
});
|
|
20365
20483
|
yield* recover();
|
|
20366
20484
|
return service;
|
|
20367
20485
|
}));
|
|
20486
|
+
var layer68 = layerFromRuntime2;
|
|
20368
20487
|
|
|
20369
20488
|
// ../runtime/src/workflow/activity-version-registry.ts
|
|
20370
20489
|
var exports_activity_version_registry = {};
|
|
@@ -20680,4 +20799,4 @@ var recoverAll = Effect104.fn("ChildFanOutAdmissionService.recoverAll.call")(fun
|
|
|
20680
20799
|
const service = yield* Service69;
|
|
20681
20800
|
return yield* service.recoverAll(inputFor);
|
|
20682
20801
|
});
|
|
20683
|
-
export { __export, exports_ids_schema, exports_shared_schema, exports_address_schema, exports_tool_schema, exports_agent_schema, exports_content_schema, exports_execution_schema, exports_child_orchestration_schema, exports_envelope_schema, exports_inbox_schema, exports_entity_schema, exports_presence_schema, exports_schedule_schema, exports_skill_schema, exports_state_schema, exports_wait_schema, exports_workflow_schema, Dialect, dialect, fromDbTimestamp, fromNullableDbTimestamp, timestampParam, encodeJson, decodeJson, decodeBool, exports_child_execution_repository, exports_child_fan_out_repository, exports_cluster_registry_repository, exports_envelope_repository, exports_notification_bus, exports_execution_event_repository, exports_execution_repository, exports_inbox_repository, exports_schedule_repository, exports_session_repository, exports_skill_definition_repository, exports_steering_repository, exports_tool_call_repository, exports_workflow_definition_repository, exports_address_book_service, exports_event_log_service, exports_wait_service, exports_tool_runtime_service, exports_agent_registry_service, exports_address_resolution_service, exports_agent_event, exports_tool_context, exports_tool_executor, exports_approvals, exports_session, exports_tool_output, exports_compaction, exports_instructions, exports_memory, exports_model_middleware, exports_model_registry, exports_model_resilience, exports_permissions, exports_skill_source, exports_steering, exports_turn_policy, exports_agent, exports_agent_tool, exports_guardrail, exports_handoff, AiError3 as AiError, Chat2 as Chat, EmbeddingModel, IdGenerator, LanguageModel6 as LanguageModel, Model2 as Model, Prompt12 as Prompt, Response8 as Response, ResponseIdTracker, Telemetry2 as Telemetry, Tokenizer3 as Tokenizer, Tool8 as Tool, Toolkit7 as Toolkit, exports_child_run_service, exports_language_model_service, exports_model_call_policy, exports_presence_service, exports_presence_tool, exports_schema_registry_service, exports_blob_store_service, exports_execution_state_service, exports_skill_registry_service, exports_execution_service, exports_tool_transition_coordinator, exports_execution_workflow, exports_wait_signal, exports_topic_service, exports_envelope_service, exports_artifact_store_service, exports_prompt_assembler_service, exports_agent_loop_service, exports_child_fan_out_transition_service, exports_child_fan_out_runtime, exports_execution_entity, exports_entity_registry_service, exports_entity_instance_service, exports_execution_watch_service, exports_session_stream_service, exports_scheduler_service, exports_runner_runtime_service, exports_definition_runtime, exports_activity_version_registry };
|
|
20802
|
+
export { __export, exports_ids_schema, exports_shared_schema, exports_address_schema, exports_tool_schema, exports_agent_schema, exports_content_schema, exports_execution_schema, exports_child_orchestration_schema, exports_envelope_schema, exports_inbox_schema, exports_entity_schema, exports_presence_schema, exports_schedule_schema, exports_skill_schema, exports_state_schema, exports_wait_schema, exports_workflow_schema, Dialect, dialect, fromDbTimestamp, fromNullableDbTimestamp, timestampParam, encodeJson, decodeJson, decodeBool, exports_child_execution_repository, exports_child_fan_out_repository, exports_cluster_registry_repository, exports_envelope_repository, exports_notification_bus, exports_execution_event_repository, exports_execution_repository, exports_inbox_repository, exports_schedule_repository, exports_session_repository, exports_skill_definition_repository, exports_steering_repository, exports_tool_call_repository, exports_workflow_definition_repository, exports_address_book_service, exports_event_log_service, exports_wait_service, exports_tool_runtime_service, exports_agent_registry_service, exports_address_resolution_service, exports_agent_event, exports_tool_context, exports_tool_executor, exports_approvals, exports_session, exports_tool_output, exports_compaction, exports_instructions, exports_memory, exports_model_middleware, exports_model_registry, exports_model_resilience, exports_permissions, exports_skill_source, exports_steering, exports_turn_policy, exports_agent, exports_agent_tool, exports_guardrail, exports_handoff, AiError3 as AiError, Chat2 as Chat, EmbeddingModel, IdGenerator, LanguageModel6 as LanguageModel, Model2 as Model, Prompt12 as Prompt, Response8 as Response, ResponseIdTracker, Telemetry2 as Telemetry, Tokenizer3 as Tokenizer, Tool8 as Tool, Toolkit7 as Toolkit, exports_child_run_service, exports_embedding_model_service, exports_language_model_service, exports_model_call_policy, exports_presence_service, exports_presence_tool, exports_schema_registry_service, exports_blob_store_service, exports_execution_state_service, exports_skill_registry_service, exports_execution_service, exports_tool_transition_coordinator, exports_execution_workflow, exports_wait_signal, exports_topic_service, exports_envelope_service, exports_artifact_store_service, exports_prompt_assembler_service, exports_agent_loop_service, exports_child_fan_out_transition_service, exports_child_fan_out_runtime, exports_execution_entity, exports_entity_registry_service, exports_entity_instance_service, exports_execution_watch_service, exports_session_stream_service, exports_scheduler_service, exports_runner_runtime_service, exports_definition_runtime, exports_activity_version_registry };
|