@relayfx/sdk 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.js +1 -1
- package/dist/{index-x32kbvxv.js → index-5vjhqzbk.js} +995 -958
- package/dist/{index-h1cf8za4.js → index-dm4yqr8f.js} +1 -1
- package/dist/{index-8asvg7x0.js → index-ftgf8py0.js} +888 -706
- package/dist/index.js +269 -117
- package/dist/migrations/20260721170000_session_writer_ownership/migration.sql +5 -0
- package/dist/migrations/mysql/0014_session_writer_ownership.sql +5 -0
- package/dist/migrations/pg/20260721170000_session_writer_ownership/migration.sql +5 -0
- package/dist/migrations/sqlite/0014_session_writer_ownership.sql +5 -0
- package/dist/mysql.js +13 -4
- package/dist/postgres.js +9 -5
- package/dist/sqlite.js +13 -4
- package/dist/types/ai/language-model/language-model-registration.d.ts +23 -11
- package/dist/types/relay/language-model-registration.d.ts +25 -11
- package/dist/types/relay/mysql-migrations.d.ts +1 -1
- package/dist/types/relay/sqlite-migrations.d.ts +6 -1
- package/dist/types/runtime/agent/agent-loop-error.d.ts +1 -1
- package/dist/types/runtime/agent/relay-permissions.d.ts +2 -2
- package/dist/types/runtime/execution/active-execution-registry.d.ts +1 -0
- package/dist/types/runtime/model/model-hub.d.ts +5 -5
- package/dist/types/runtime/runner/runner-runtime-service.d.ts +4 -4
- package/dist/types/runtime/session/session-store-service.d.ts +1 -0
- package/dist/types/store-sql/schema/session-schema.d.ts +45 -0
- package/dist/types/store-sql/session/session-records.d.ts +5 -47
- package/dist/types/store-sql/session/session-repository.d.ts +37 -1
- package/dist/types/store-sql/session/session-row.d.ts +60 -0
- package/package.json +3 -3
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
exports_tool_executor,
|
|
17
17
|
exports_tool_output,
|
|
18
18
|
exports_turn_policy
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-5vjhqzbk.js";
|
|
20
20
|
import {
|
|
21
21
|
ClientError,
|
|
22
22
|
EventLogCursorNotFound,
|
|
@@ -550,12 +550,12 @@ var notRegistered = (selection) => LanguageModelNotRegistered.make({
|
|
|
550
550
|
|
|
551
551
|
class Service8 extends Context6.Service()("@relayfx/runtime/model/language-model-service/Service") {
|
|
552
552
|
}
|
|
553
|
-
var registrationFromLayer2 = exports_model_registry.
|
|
553
|
+
var registrationFromLayer2 = exports_model_registry.registration;
|
|
554
554
|
var fromModelRegistry = (registry) => Service8.of({
|
|
555
555
|
register: (input) => registry.register(input),
|
|
556
556
|
registrations: registry.registrations,
|
|
557
|
-
provide: (selection, effect) => registry.
|
|
558
|
-
provideForAgent: (agent, effect) => registry.
|
|
557
|
+
provide: (selection, effect) => registry.operate(toSelection(selection), effect),
|
|
558
|
+
provideForAgent: (agent, effect) => registry.operate(toSelection(agent.model), effect)
|
|
559
559
|
});
|
|
560
560
|
var testLayer5 = (implementation) => Layer6.succeed(Service8, Service8.of(implementation));
|
|
561
561
|
var register3 = Effect6.fn("LanguageModelService.register.call")(function* (input) {
|
|
@@ -616,9 +616,9 @@ var validate = (registrations3) => Effect7.gen(function* () {
|
|
|
616
616
|
return registrations3;
|
|
617
617
|
});
|
|
618
618
|
var fromRegistrations = (registrations3, options) => {
|
|
619
|
-
const registryLayer = exports_model_registry.layer(registrations3, options);
|
|
619
|
+
const registryLayer = exports_model_registry.layer(registrations3.map((registration) => Effect7.succeed(registration)), options);
|
|
620
620
|
const hubLayer = Layer7.effect(Service9, Effect7.gen(function* () {
|
|
621
|
-
const modelRegistry = yield* exports_model_registry.
|
|
621
|
+
const modelRegistry = yield* exports_model_registry.ModelRegistry;
|
|
622
622
|
return Service9.of({
|
|
623
623
|
modelRegistry,
|
|
624
624
|
languageModelService: fromModelRegistry(modelRegistry)
|
|
@@ -633,7 +633,7 @@ var layer4 = Function4.dual((args) => Array.isArray(args[0]), (registrations3, o
|
|
|
633
633
|
var layerFromRegistrationEffects2 = Function4.dual((args) => Array.isArray(args[0]), (declarations, options) => Layer7.unwrap(Effect7.all(declarations).pipe(Effect7.flatMap(validate), Effect7.map((items) => fromRegistrations(items, options)))));
|
|
634
634
|
var testLayer6 = (modelRegistry) => {
|
|
635
635
|
const languageModelService = fromModelRegistry(modelRegistry);
|
|
636
|
-
return Layer7.mergeAll(Layer7.succeed(Service9, Service9.of({ modelRegistry, languageModelService })), Layer7.succeed(exports_model_registry.
|
|
636
|
+
return Layer7.mergeAll(Layer7.succeed(Service9, Service9.of({ modelRegistry, languageModelService })), Layer7.succeed(exports_model_registry.ModelRegistry, modelRegistry), Layer7.succeed(Service8, languageModelService));
|
|
637
637
|
};
|
|
638
638
|
|
|
639
639
|
// ../runtime/src/schema-registry/schema-registry-service.ts
|
|
@@ -6187,6 +6187,7 @@ __export(exports_session_repository, {
|
|
|
6187
6187
|
touch: () => touch,
|
|
6188
6188
|
testLayer: () => testLayer29,
|
|
6189
6189
|
setLeaf: () => setLeaf,
|
|
6190
|
+
releaseWriter: () => releaseWriter,
|
|
6190
6191
|
path: () => path,
|
|
6191
6192
|
memoryLayer: () => memoryLayer26,
|
|
6192
6193
|
list: () => list10,
|
|
@@ -6197,6 +6198,7 @@ __export(exports_session_repository, {
|
|
|
6197
6198
|
ensure: () => ensure,
|
|
6198
6199
|
create: () => create5,
|
|
6199
6200
|
countEntries: () => countEntries,
|
|
6201
|
+
claimWriter: () => claimWriter,
|
|
6200
6202
|
appendEntry: () => appendEntry,
|
|
6201
6203
|
appendCheckpoint: () => appendCheckpoint,
|
|
6202
6204
|
SessionRow: () => SessionRow,
|
|
@@ -6206,7 +6208,7 @@ __export(exports_session_repository, {
|
|
|
6206
6208
|
Service: () => Service35,
|
|
6207
6209
|
DuplicateSession: () => DuplicateSession
|
|
6208
6210
|
});
|
|
6209
|
-
import { Context as Context33, Effect as Effect41, Layer as Layer35, Schema as
|
|
6211
|
+
import { Context as Context33, Effect as Effect41, Layer as Layer35, Schema as Schema40 } from "effect";
|
|
6210
6212
|
|
|
6211
6213
|
// ../store-sql/src/session/session-entry-records.ts
|
|
6212
6214
|
import { Effect as Effect39, Schema as Schema37 } from "effect";
|
|
@@ -6489,16 +6491,23 @@ var makeSessionEntryRecords = (errors) => {
|
|
|
6489
6491
|
};
|
|
6490
6492
|
|
|
6491
6493
|
// ../store-sql/src/session/session-records.ts
|
|
6492
|
-
import { Effect as Effect40, Schema as
|
|
6494
|
+
import { Effect as Effect40, Schema as Schema39 } from "effect";
|
|
6493
6495
|
import { SqlClient as SqlClient23 } from "effect/unstable/sql/SqlClient";
|
|
6496
|
+
|
|
6497
|
+
// ../store-sql/src/session/session-row.ts
|
|
6498
|
+
import { Schema as Schema38 } from "effect";
|
|
6494
6499
|
var sessionRow = Schema38.Struct({
|
|
6495
6500
|
id: Schema38.String,
|
|
6496
6501
|
root_address_id: Schema38.String,
|
|
6497
6502
|
leaf_entry_id: Schema38.Union([Schema38.String, Schema38.Null, Schema38.Undefined]),
|
|
6503
|
+
owner_execution_id: Schema38.Union([Schema38.String, Schema38.Null, Schema38.Undefined]),
|
|
6504
|
+
owner_epoch: Schema38.Union([Schema38.Finite, Schema38.String, Schema38.BigInt]),
|
|
6505
|
+
owner_released: Schema38.Union([Schema38.Boolean, Schema38.Finite, Schema38.String, Schema38.BigInt]),
|
|
6498
6506
|
metadata_json: Schema38.Unknown,
|
|
6499
6507
|
created_at: Schema38.Union([Schema38.Date, Schema38.String, Schema38.Finite]),
|
|
6500
6508
|
updated_at: Schema38.Union([Schema38.Date, Schema38.String, Schema38.Finite])
|
|
6501
6509
|
}).annotate({ identifier: "Relay.Session.Row" });
|
|
6510
|
+
var releasedFlag = (value) => value === true || value === 1 || value === "1" || value === 1n || value === "true";
|
|
6502
6511
|
var CountRow = Schema38.Struct({
|
|
6503
6512
|
value: Schema38.Union([Schema38.Finite, Schema38.String, Schema38.BigInt])
|
|
6504
6513
|
}).annotate({ identifier: "Relay.SessionEntry.CountRow" });
|
|
@@ -6507,6 +6516,13 @@ var toSessionRecord = (row) => ({
|
|
|
6507
6516
|
id: exports_ids_schema.SessionId.make(row.id),
|
|
6508
6517
|
rootAddressId: exports_ids_schema.AddressId.make(row.root_address_id),
|
|
6509
6518
|
...row.leaf_entry_id === null || row.leaf_entry_id === undefined ? {} : { leafEntryId: exports_ids_schema.SessionEntryId.make(row.leaf_entry_id) },
|
|
6519
|
+
...row.owner_execution_id === null || row.owner_execution_id === undefined ? {} : {
|
|
6520
|
+
writer: {
|
|
6521
|
+
executionId: exports_ids_schema.ExecutionId.make(row.owner_execution_id),
|
|
6522
|
+
epoch: Number(row.owner_epoch),
|
|
6523
|
+
released: releasedFlag(row.owner_released)
|
|
6524
|
+
}
|
|
6525
|
+
},
|
|
6510
6526
|
metadata: decodeJson(row.metadata_json),
|
|
6511
6527
|
createdAt: fromDbTimestamp(row.created_at),
|
|
6512
6528
|
updatedAt: fromDbTimestamp(row.updated_at)
|
|
@@ -6527,9 +6543,29 @@ var makeSessionRecordSupport = (errors) => {
|
|
|
6527
6543
|
missingSession: (id) => SessionRepositoryError.make({ message: `Session ${id} does not exist` }),
|
|
6528
6544
|
rootMismatch: (id) => SessionRepositoryError.make({ message: `Session ${id} already exists for a different root address` }),
|
|
6529
6545
|
cloneSession: (record2) => structuredClone(record2),
|
|
6530
|
-
currentLeaf: (session) => session.leafEntryId ?? null
|
|
6546
|
+
currentLeaf: (session) => session.leafEntryId ?? null,
|
|
6547
|
+
writerFenceViolation: (session, expected) => {
|
|
6548
|
+
if (expected === undefined)
|
|
6549
|
+
return;
|
|
6550
|
+
const writer = session.writer;
|
|
6551
|
+
if (writer === undefined)
|
|
6552
|
+
return `Session ${session.id} has no writer claim`;
|
|
6553
|
+
if (writer.released)
|
|
6554
|
+
return `Session ${session.id} writer claim was released`;
|
|
6555
|
+
if (writer.executionId !== expected.executionId || writer.epoch !== expected.epoch)
|
|
6556
|
+
return `Session ${session.id} is owned by ${writer.executionId} at epoch ${writer.epoch}`;
|
|
6557
|
+
return;
|
|
6558
|
+
},
|
|
6559
|
+
nextWriterClaim: (current2, executionId) => {
|
|
6560
|
+
if (current2 === undefined || current2.released)
|
|
6561
|
+
return { _tag: "Claimed", writer: { executionId, epoch: (current2?.epoch ?? 0) + 1, released: false } };
|
|
6562
|
+
if (current2.executionId === executionId)
|
|
6563
|
+
return { _tag: "Claimed", writer: { executionId, epoch: current2.epoch, released: false } };
|
|
6564
|
+
return { _tag: "Busy", writer: current2 };
|
|
6565
|
+
}
|
|
6531
6566
|
};
|
|
6532
6567
|
};
|
|
6568
|
+
// ../store-sql/src/session/session-records.ts
|
|
6533
6569
|
var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
6534
6570
|
const { SessionRepositoryError, DuplicateSession } = errors;
|
|
6535
6571
|
const {
|
|
@@ -6542,7 +6578,7 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6542
6578
|
toEntryRecord,
|
|
6543
6579
|
validateCompaction
|
|
6544
6580
|
} = makeSessionEntryRecords(errors);
|
|
6545
|
-
const { currentLeaf, missingSession, rootMismatch } = makeSessionRecordSupport(errors);
|
|
6581
|
+
const { currentLeaf, missingSession, nextWriterClaim, rootMismatch, writerFenceViolation } = makeSessionRecordSupport(errors);
|
|
6546
6582
|
const sql = yield* SqlClient23;
|
|
6547
6583
|
const toRepositoryError12 = (error5) => SessionRepositoryError.make({ message: String(error5) });
|
|
6548
6584
|
function mapRepositoryError(effect) {
|
|
@@ -6552,14 +6588,23 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6552
6588
|
return toRepositoryError12(error5);
|
|
6553
6589
|
}));
|
|
6554
6590
|
}
|
|
6555
|
-
const decodeSessionRow = (row) =>
|
|
6556
|
-
const decodeEntryRow = (row) =>
|
|
6557
|
-
const decodeCountRow = (row) =>
|
|
6591
|
+
const decodeSessionRow = (row) => Schema39.decodeUnknownEffect(sessionRow)(row).pipe(Effect40.mapError(toRepositoryError12));
|
|
6592
|
+
const decodeEntryRow = (row) => Schema39.decodeUnknownEffect(sessionEntryRow)(row).pipe(Effect40.mapError(toRepositoryError12));
|
|
6593
|
+
const decodeCountRow = (row) => Schema39.decodeUnknownEffect(CountRow)(row).pipe(Effect40.mapError(toRepositoryError12));
|
|
6558
6594
|
const selectSessionByKey = (tenantId, id) => sql`
|
|
6559
|
-
SELECT id, root_address_id, leaf_entry_id, metadata_json, created_at, updated_at
|
|
6595
|
+
SELECT id, root_address_id, leaf_entry_id, owner_execution_id, owner_epoch, owner_released, metadata_json, created_at, updated_at
|
|
6560
6596
|
FROM relay_sessions
|
|
6561
6597
|
WHERE tenant_id = ${tenantId} AND id = ${id}
|
|
6562
6598
|
`;
|
|
6599
|
+
const releasedParam = sql.onDialectOrElse({
|
|
6600
|
+
pg: () => (released) => released,
|
|
6601
|
+
orElse: () => (released) => released ? 1 : 0
|
|
6602
|
+
});
|
|
6603
|
+
const updateWriter = (tenantId, input) => sql`
|
|
6604
|
+
UPDATE relay_sessions
|
|
6605
|
+
SET owner_execution_id = ${input.writer.executionId}, owner_epoch = ${input.writer.epoch}, owner_released = ${releasedParam(input.writer.released)}, updated_at = ${timestampParam(sql, input.updatedAt)}
|
|
6606
|
+
WHERE tenant_id = ${tenantId} AND id = ${input.sessionId}
|
|
6607
|
+
`;
|
|
6563
6608
|
const lockSession = sql.onDialectOrElse({
|
|
6564
6609
|
pg: () => (tenantId, id) => sql`SELECT id FROM relay_sessions WHERE tenant_id = ${tenantId} AND id = ${id} FOR UPDATE`,
|
|
6565
6610
|
mysql: () => (tenantId, id) => sql`SELECT id FROM relay_sessions WHERE tenant_id = ${tenantId} AND id = ${id} FOR UPDATE`,
|
|
@@ -6689,14 +6734,14 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6689
6734
|
]));
|
|
6690
6735
|
}
|
|
6691
6736
|
const rows = yield* mapRepositoryError(sql`
|
|
6692
|
-
SELECT id, root_address_id, leaf_entry_id, metadata_json, created_at, updated_at
|
|
6737
|
+
SELECT id, root_address_id, leaf_entry_id, owner_execution_id, owner_epoch, owner_released, metadata_json, created_at, updated_at
|
|
6693
6738
|
FROM relay_sessions
|
|
6694
6739
|
WHERE ${sql.and(conditions)}
|
|
6695
6740
|
ORDER BY updated_at DESC, id DESC
|
|
6696
6741
|
LIMIT ${sql.literal(String(limit + 1))}
|
|
6697
6742
|
`);
|
|
6698
6743
|
const records = yield* Effect40.forEach(rows.slice(0, limit), (row) => decodeSessionRow(row).pipe(Effect40.map(toSessionRecord)));
|
|
6699
|
-
const nextCursor =
|
|
6744
|
+
const nextCursor = sessionRecordPaging.nextCursorOf(records, rows.length, limit);
|
|
6700
6745
|
return nextCursor === undefined ? { records } : { records, nextCursor };
|
|
6701
6746
|
});
|
|
6702
6747
|
const touch = Effect40.fn("SessionRepository.touch")(function* (input) {
|
|
@@ -6727,6 +6772,9 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6727
6772
|
return yield* mapRepositoryError(sql.withTransaction(Effect40.gen(function* () {
|
|
6728
6773
|
yield* lockSession(tenantId, input.sessionId);
|
|
6729
6774
|
const session = yield* requireSession(tenantId, input.sessionId);
|
|
6775
|
+
const fence = writerFenceViolation(session, input.expectedWriter);
|
|
6776
|
+
if (fence !== undefined)
|
|
6777
|
+
return yield* conflict4("fenced", fence);
|
|
6730
6778
|
if (input.expectedLeafId !== undefined && input.expectedLeafId !== currentLeaf(session)) {
|
|
6731
6779
|
return yield* conflict4("stale-leaf", `Expected Session leaf ${String(input.expectedLeafId)} but found ${String(currentLeaf(session))}`);
|
|
6732
6780
|
}
|
|
@@ -6764,6 +6812,9 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6764
6812
|
return yield* mapRepositoryError(sql.withTransaction(Effect40.gen(function* () {
|
|
6765
6813
|
yield* lockSession(tenantId, input.sessionId);
|
|
6766
6814
|
const session = yield* requireSession(tenantId, input.sessionId);
|
|
6815
|
+
const checkpointFence = writerFenceViolation(session, input.expectedWriter);
|
|
6816
|
+
if (checkpointFence !== undefined)
|
|
6817
|
+
return yield* conflict4("fenced", checkpointFence);
|
|
6767
6818
|
const existing = yield* entryById(tenantId, input.sessionId, input.id);
|
|
6768
6819
|
const appendInput = {
|
|
6769
6820
|
id: input.id,
|
|
@@ -6816,9 +6867,40 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6816
6867
|
const counted = yield* decodeCountRow(rows[0]);
|
|
6817
6868
|
return Number(counted.value);
|
|
6818
6869
|
});
|
|
6870
|
+
const claimWriter = Effect40.fn("SessionRepository.claimWriter")(function* (input) {
|
|
6871
|
+
const tenantId = yield* current();
|
|
6872
|
+
return yield* mapRepositoryError(sql.withTransaction(Effect40.gen(function* () {
|
|
6873
|
+
yield* lockSession(tenantId, input.sessionId);
|
|
6874
|
+
const session = yield* requireSession(tenantId, input.sessionId);
|
|
6875
|
+
const claim = nextWriterClaim(session.writer, input.executionId);
|
|
6876
|
+
if (claim._tag === "Busy")
|
|
6877
|
+
return claim;
|
|
6878
|
+
yield* updateWriter(tenantId, { sessionId: input.sessionId, writer: claim.writer, updatedAt: input.now });
|
|
6879
|
+
return claim;
|
|
6880
|
+
})));
|
|
6881
|
+
});
|
|
6882
|
+
const releaseWriter = Effect40.fn("SessionRepository.releaseWriter")(function* (input) {
|
|
6883
|
+
const tenantId = yield* current();
|
|
6884
|
+
yield* mapRepositoryError(sql.withTransaction(Effect40.gen(function* () {
|
|
6885
|
+
yield* lockSession(tenantId, input.sessionId);
|
|
6886
|
+
const session = yield* getForTenant(tenantId, input.sessionId);
|
|
6887
|
+
const writer = session?.writer;
|
|
6888
|
+
if (session === undefined || writer === undefined || writer.executionId !== input.executionId)
|
|
6889
|
+
return;
|
|
6890
|
+
if (writer.released)
|
|
6891
|
+
return;
|
|
6892
|
+
yield* updateWriter(tenantId, {
|
|
6893
|
+
sessionId: input.sessionId,
|
|
6894
|
+
writer: { ...writer, released: true },
|
|
6895
|
+
updatedAt: input.now
|
|
6896
|
+
});
|
|
6897
|
+
})));
|
|
6898
|
+
});
|
|
6819
6899
|
return {
|
|
6820
6900
|
create: create5,
|
|
6821
6901
|
ensure,
|
|
6902
|
+
claimWriter,
|
|
6903
|
+
releaseWriter,
|
|
6822
6904
|
get: get9,
|
|
6823
6905
|
list: list10,
|
|
6824
6906
|
touch,
|
|
@@ -6832,19 +6914,19 @@ var makeSessionRepository = (errors) => Effect40.gen(function* () {
|
|
|
6832
6914
|
});
|
|
6833
6915
|
|
|
6834
6916
|
// ../store-sql/src/session/session-repository.ts
|
|
6835
|
-
class SessionRepositoryError extends
|
|
6836
|
-
message:
|
|
6917
|
+
class SessionRepositoryError extends Schema40.TaggedErrorClass()("SessionRepositoryError", {
|
|
6918
|
+
message: Schema40.String
|
|
6837
6919
|
}) {
|
|
6838
6920
|
}
|
|
6839
6921
|
|
|
6840
|
-
class DuplicateSession extends
|
|
6922
|
+
class DuplicateSession extends Schema40.TaggedErrorClass()("DuplicateSession", {
|
|
6841
6923
|
id: exports_ids_schema.SessionId
|
|
6842
6924
|
}) {
|
|
6843
6925
|
}
|
|
6844
6926
|
|
|
6845
|
-
class SessionConflict extends
|
|
6846
|
-
reason:
|
|
6847
|
-
message:
|
|
6927
|
+
class SessionConflict extends Schema40.TaggedErrorClass()("SessionConflict", {
|
|
6928
|
+
reason: Schema40.Literals(["stale-leaf", "checkpoint-id-reused", "checkpoint-not-on-active-path", "fenced"]),
|
|
6929
|
+
message: Schema40.String
|
|
6848
6930
|
}) {
|
|
6849
6931
|
}
|
|
6850
6932
|
|
|
@@ -6863,7 +6945,7 @@ var {
|
|
|
6863
6945
|
sameEntry,
|
|
6864
6946
|
validateCompaction
|
|
6865
6947
|
} = makeSessionEntryRecords(repositoryErrors);
|
|
6866
|
-
var { cloneSession, currentLeaf, missingSession, rootMismatch } = makeSessionRecordSupport(repositoryErrors);
|
|
6948
|
+
var { cloneSession, currentLeaf, missingSession, nextWriterClaim, rootMismatch, writerFenceViolation } = makeSessionRecordSupport(repositoryErrors);
|
|
6867
6949
|
var { afterCursor: afterCursor3, compareDesc: compareDesc3, nextCursorOf: nextCursorOf3 } = sessionRecordPaging;
|
|
6868
6950
|
var layer28 = Layer35.effect(Service35, makeSessionRepository(repositoryErrors).pipe(Effect41.map(Service35.of)));
|
|
6869
6951
|
var layerFromTenant = layer28;
|
|
@@ -6931,6 +7013,25 @@ var memoryLayer26 = Layer35.sync(Service35, () => {
|
|
|
6931
7013
|
sessions.set(input.id, record2);
|
|
6932
7014
|
return cloneSession(record2);
|
|
6933
7015
|
}),
|
|
7016
|
+
claimWriter: Effect41.fn("SessionRepository.memory.claimWriter")(function* (input) {
|
|
7017
|
+
const session = sessions.get(input.sessionId);
|
|
7018
|
+
if (session === undefined)
|
|
7019
|
+
return yield* missingSession(input.sessionId);
|
|
7020
|
+
const claim = nextWriterClaim(session.writer, input.executionId);
|
|
7021
|
+
if (claim._tag === "Busy")
|
|
7022
|
+
return claim;
|
|
7023
|
+
sessions.set(input.sessionId, { ...session, writer: claim.writer, updatedAt: input.now });
|
|
7024
|
+
return claim;
|
|
7025
|
+
}),
|
|
7026
|
+
releaseWriter: Effect41.fn("SessionRepository.memory.releaseWriter")((input) => Effect41.sync(() => {
|
|
7027
|
+
const session = sessions.get(input.sessionId);
|
|
7028
|
+
const writer = session?.writer;
|
|
7029
|
+
if (session === undefined || writer === undefined || writer.executionId !== input.executionId)
|
|
7030
|
+
return;
|
|
7031
|
+
if (writer.released)
|
|
7032
|
+
return;
|
|
7033
|
+
sessions.set(input.sessionId, { ...session, writer: { ...writer, released: true }, updatedAt: input.now });
|
|
7034
|
+
})),
|
|
6934
7035
|
get: Effect41.fn("SessionRepository.memory.get")((id) => Effect41.sync(() => {
|
|
6935
7036
|
const record2 = sessions.get(id);
|
|
6936
7037
|
return record2 === undefined ? undefined : cloneSession(record2);
|
|
@@ -6954,6 +7055,9 @@ var memoryLayer26 = Layer35.sync(Service35, () => {
|
|
|
6954
7055
|
const session = sessions.get(input.sessionId);
|
|
6955
7056
|
if (session === undefined)
|
|
6956
7057
|
return yield* missingSession(input.sessionId);
|
|
7058
|
+
const fence = writerFenceViolation(session, input.expectedWriter);
|
|
7059
|
+
if (fence !== undefined)
|
|
7060
|
+
return yield* conflict4("fenced", fence);
|
|
6957
7061
|
if (input.expectedLeafId !== undefined && input.expectedLeafId !== currentLeaf(session)) {
|
|
6958
7062
|
return yield* conflict4("stale-leaf", `Expected Session leaf ${String(input.expectedLeafId)} but found ${String(currentLeaf(session))}`);
|
|
6959
7063
|
}
|
|
@@ -6978,6 +7082,9 @@ var memoryLayer26 = Layer35.sync(Service35, () => {
|
|
|
6978
7082
|
const session = sessions.get(input.sessionId);
|
|
6979
7083
|
if (session === undefined)
|
|
6980
7084
|
return yield* missingSession(input.sessionId);
|
|
7085
|
+
const fence = writerFenceViolation(session, input.expectedWriter);
|
|
7086
|
+
if (fence !== undefined)
|
|
7087
|
+
return yield* conflict4("fenced", fence);
|
|
6981
7088
|
const appendInput = {
|
|
6982
7089
|
id: input.id,
|
|
6983
7090
|
sessionId: input.sessionId,
|
|
@@ -7045,6 +7152,14 @@ var ensure = Effect41.fn("SessionRepository.ensure.call")(function* (input) {
|
|
|
7045
7152
|
const repository = yield* Service35;
|
|
7046
7153
|
return yield* repository.ensure(input);
|
|
7047
7154
|
});
|
|
7155
|
+
var claimWriter = Effect41.fn("SessionRepository.claimWriter.call")(function* (input) {
|
|
7156
|
+
const repository = yield* Service35;
|
|
7157
|
+
return yield* repository.claimWriter(input);
|
|
7158
|
+
});
|
|
7159
|
+
var releaseWriter = Effect41.fn("SessionRepository.releaseWriter.call")(function* (input) {
|
|
7160
|
+
const repository = yield* Service35;
|
|
7161
|
+
return yield* repository.releaseWriter(input);
|
|
7162
|
+
});
|
|
7048
7163
|
var get9 = Effect41.fn("SessionRepository.get.call")(function* (id) {
|
|
7049
7164
|
const repository = yield* Service35;
|
|
7050
7165
|
return yield* repository.get(id);
|
|
@@ -7101,36 +7216,36 @@ __export(exports_skill_definition_repository, {
|
|
|
7101
7216
|
Service: () => Service36,
|
|
7102
7217
|
ExecutionSkillPinRow: () => ExecutionSkillPinRow
|
|
7103
7218
|
});
|
|
7104
|
-
import { Context as Context34, Effect as Effect42, HashSet, Layer as Layer36, Schema as
|
|
7219
|
+
import { Context as Context34, Effect as Effect42, HashSet, Layer as Layer36, Schema as Schema41, Semaphore as Semaphore4 } from "effect";
|
|
7105
7220
|
import { SqlClient as SqlClient24 } from "effect/unstable/sql/SqlClient";
|
|
7106
|
-
class SkillDefinitionRepositoryError extends
|
|
7107
|
-
message:
|
|
7221
|
+
class SkillDefinitionRepositoryError extends Schema41.TaggedErrorClass()("SkillDefinitionRepositoryError", {
|
|
7222
|
+
message: Schema41.String
|
|
7108
7223
|
}) {
|
|
7109
7224
|
}
|
|
7110
7225
|
|
|
7111
7226
|
class Service36 extends Context34.Service()("@relayfx/store-sql/skill/skill-definition-repository/Service") {
|
|
7112
7227
|
}
|
|
7113
|
-
var SkillDefinitionRow =
|
|
7114
|
-
id:
|
|
7115
|
-
current_revision:
|
|
7116
|
-
definition_json:
|
|
7117
|
-
created_at:
|
|
7118
|
-
updated_at:
|
|
7228
|
+
var SkillDefinitionRow = Schema41.Struct({
|
|
7229
|
+
id: Schema41.String,
|
|
7230
|
+
current_revision: Schema41.Finite,
|
|
7231
|
+
definition_json: Schema41.Unknown,
|
|
7232
|
+
created_at: Schema41.Union([Schema41.Date, Schema41.String, Schema41.Finite]),
|
|
7233
|
+
updated_at: Schema41.Union([Schema41.Date, Schema41.String, Schema41.Finite])
|
|
7119
7234
|
}).annotate({ identifier: "Relay.SkillDefinition.Row" });
|
|
7120
|
-
var SkillDefinitionRevisionRow =
|
|
7121
|
-
skill_definition_id:
|
|
7122
|
-
revision:
|
|
7123
|
-
definition_json:
|
|
7124
|
-
created_at:
|
|
7235
|
+
var SkillDefinitionRevisionRow = Schema41.Struct({
|
|
7236
|
+
skill_definition_id: Schema41.String,
|
|
7237
|
+
revision: Schema41.Finite,
|
|
7238
|
+
definition_json: Schema41.Unknown,
|
|
7239
|
+
created_at: Schema41.Union([Schema41.Date, Schema41.String, Schema41.Finite])
|
|
7125
7240
|
}).annotate({ identifier: "Relay.SkillDefinitionRevision.Row" });
|
|
7126
|
-
var ExecutionSkillPinRow =
|
|
7127
|
-
execution_id:
|
|
7128
|
-
skill_definition_id:
|
|
7129
|
-
skill_definition_revision:
|
|
7130
|
-
skill_definition_snapshot_json:
|
|
7131
|
-
created_at:
|
|
7241
|
+
var ExecutionSkillPinRow = Schema41.Struct({
|
|
7242
|
+
execution_id: Schema41.String,
|
|
7243
|
+
skill_definition_id: Schema41.String,
|
|
7244
|
+
skill_definition_revision: Schema41.Finite,
|
|
7245
|
+
skill_definition_snapshot_json: Schema41.Unknown,
|
|
7246
|
+
created_at: Schema41.Union([Schema41.Date, Schema41.String, Schema41.Finite])
|
|
7132
7247
|
}).annotate({ identifier: "Relay.ExecutionSkillPin.Row" });
|
|
7133
|
-
var cloneDefinition3 = (definition) =>
|
|
7248
|
+
var cloneDefinition3 = (definition) => Schema41.decodeUnknownSync(exports_skill_schema.Definition)(globalThis.structuredClone(definition));
|
|
7134
7249
|
var toRecord10 = (row) => ({
|
|
7135
7250
|
id: exports_ids_schema.SkillDefinitionId.make(row.id),
|
|
7136
7251
|
currentRevision: row.current_revision,
|
|
@@ -7186,11 +7301,11 @@ var missingSkillMessage = (requested, records) => {
|
|
|
7186
7301
|
return `Skill definition not found: ${requested.find((id) => !HashSet.has(found, id)) ?? requested[0]}`;
|
|
7187
7302
|
};
|
|
7188
7303
|
var toRepositoryError12 = (error5) => SkillDefinitionRepositoryError.make({ message: String(error5) });
|
|
7189
|
-
var mapPutError2 = (error5) =>
|
|
7190
|
-
var isUniqueViolation = (error5) => !
|
|
7191
|
-
var decodeRow12 = (row) =>
|
|
7192
|
-
var decodeRevisionRow2 = (row) =>
|
|
7193
|
-
var decodePinRow = (row) =>
|
|
7304
|
+
var mapPutError2 = (error5) => Schema41.is(SkillDefinitionRepositoryError)(error5) ? error5 : toRepositoryError12(error5);
|
|
7305
|
+
var isUniqueViolation = (error5) => !Schema41.is(SkillDefinitionRepositoryError)(error5) && /unique|duplicate/i.test(String(error5));
|
|
7306
|
+
var decodeRow12 = (row) => Schema41.decodeUnknownEffect(SkillDefinitionRow)(row).pipe(Effect42.mapError(toRepositoryError12));
|
|
7307
|
+
var decodeRevisionRow2 = (row) => Schema41.decodeUnknownEffect(SkillDefinitionRevisionRow)(row).pipe(Effect42.mapError(toRepositoryError12));
|
|
7308
|
+
var decodePinRow = (row) => Schema41.decodeUnknownEffect(ExecutionSkillPinRow)(row).pipe(Effect42.mapError(toRepositoryError12));
|
|
7194
7309
|
var layer29 = Layer36.effect(Service36, Effect42.gen(function* () {
|
|
7195
7310
|
const sql = yield* SqlClient24;
|
|
7196
7311
|
const columns3 = sql.literal(["id", "current_revision", "definition_json", "created_at", "updated_at"].join(", "));
|
|
@@ -7527,37 +7642,37 @@ __export(exports_steering_repository, {
|
|
|
7527
7642
|
SteeringDrainRow: () => SteeringDrainRow,
|
|
7528
7643
|
Service: () => Service37
|
|
7529
7644
|
});
|
|
7530
|
-
import { Context as Context35, Effect as Effect43, Layer as Layer37, Ref as Ref9, Schema as
|
|
7645
|
+
import { Context as Context35, Effect as Effect43, Layer as Layer37, Ref as Ref9, Schema as Schema42 } from "effect";
|
|
7531
7646
|
import { SqlClient as SqlClient25 } from "effect/unstable/sql/SqlClient";
|
|
7532
|
-
class SteeringRepositoryError extends
|
|
7533
|
-
message:
|
|
7647
|
+
class SteeringRepositoryError extends Schema42.TaggedErrorClass()("SteeringRepositoryError", {
|
|
7648
|
+
message: Schema42.String
|
|
7534
7649
|
}) {
|
|
7535
7650
|
}
|
|
7536
7651
|
|
|
7537
7652
|
class Service37 extends Context35.Service()("@relayfx/store-sql/steering/steering-repository/Service") {
|
|
7538
7653
|
}
|
|
7539
|
-
var SteeringKindSchema =
|
|
7540
|
-
var DbTimestamp4 =
|
|
7541
|
-
var SteeringMessageRow =
|
|
7542
|
-
execution_id:
|
|
7654
|
+
var SteeringKindSchema = Schema42.Literals(["steering", "follow_up"]);
|
|
7655
|
+
var DbTimestamp4 = Schema42.Union([Schema42.Date, Schema42.String, Schema42.Finite]);
|
|
7656
|
+
var SteeringMessageRow = Schema42.Struct({
|
|
7657
|
+
execution_id: Schema42.String,
|
|
7543
7658
|
kind: SteeringKindSchema,
|
|
7544
|
-
sequence:
|
|
7545
|
-
content_json:
|
|
7546
|
-
drain_id:
|
|
7547
|
-
consumed_at:
|
|
7659
|
+
sequence: Schema42.Union([Schema42.Finite, Schema42.String]),
|
|
7660
|
+
content_json: Schema42.Unknown,
|
|
7661
|
+
drain_id: Schema42.NullishOr(Schema42.String),
|
|
7662
|
+
consumed_at: Schema42.NullishOr(DbTimestamp4),
|
|
7548
7663
|
created_at: DbTimestamp4
|
|
7549
7664
|
}).annotate({ identifier: "Relay.SteeringMessage.Row" });
|
|
7550
|
-
var SteeringDrainRow =
|
|
7551
|
-
execution_id:
|
|
7665
|
+
var SteeringDrainRow = Schema42.Struct({
|
|
7666
|
+
execution_id: Schema42.String,
|
|
7552
7667
|
kind: SteeringKindSchema,
|
|
7553
|
-
drain_id:
|
|
7554
|
-
message_sequences_json:
|
|
7668
|
+
drain_id: Schema42.String,
|
|
7669
|
+
message_sequences_json: Schema42.Unknown,
|
|
7555
7670
|
created_at: DbTimestamp4
|
|
7556
7671
|
}).annotate({ identifier: "Relay.SteeringDrain.Row" });
|
|
7557
7672
|
var toRepositoryError13 = (error5) => SteeringRepositoryError.make({ message: String(error5) });
|
|
7558
|
-
var mapTransactionError = (effect) => effect.pipe(Effect43.mapError((error5) =>
|
|
7559
|
-
var decodeMessageRow = (row) =>
|
|
7560
|
-
var decodeDrainRow = (row) =>
|
|
7673
|
+
var mapTransactionError = (effect) => effect.pipe(Effect43.mapError((error5) => Schema42.is(SteeringRepositoryError)(error5) ? error5 : toRepositoryError13(error5)));
|
|
7674
|
+
var decodeMessageRow = (row) => Schema42.decodeUnknownEffect(SteeringMessageRow)(row).pipe(Effect43.mapError(toRepositoryError13));
|
|
7675
|
+
var decodeDrainRow = (row) => Schema42.decodeUnknownEffect(SteeringDrainRow)(row).pipe(Effect43.mapError(toRepositoryError13));
|
|
7561
7676
|
var toMessageRecord = (row) => {
|
|
7562
7677
|
const consumedAt = fromNullableDbTimestamp(row.consumed_at);
|
|
7563
7678
|
return {
|
|
@@ -7866,29 +7981,29 @@ __export(exports_tool_call_repository, {
|
|
|
7866
7981
|
DuplicateToolResult: () => DuplicateToolResult,
|
|
7867
7982
|
DuplicateToolCall: () => DuplicateToolCall
|
|
7868
7983
|
});
|
|
7869
|
-
import { Context as Context36, Effect as Effect47, Layer as Layer38, Schema as
|
|
7984
|
+
import { Context as Context36, Effect as Effect47, Layer as Layer38, Schema as Schema46 } from "effect";
|
|
7870
7985
|
import { dual } from "effect/Function";
|
|
7871
7986
|
|
|
7872
7987
|
// ../store-sql/src/tool/tool-call-records.ts
|
|
7873
|
-
import { Effect as Effect46, Schema as
|
|
7988
|
+
import { Effect as Effect46, Schema as Schema45 } from "effect";
|
|
7874
7989
|
import { SqlClient as SqlClient26 } from "effect/unstable/sql/SqlClient";
|
|
7875
7990
|
import { isSqlError as isSqlError2 } from "effect/unstable/sql/SqlError";
|
|
7876
7991
|
|
|
7877
7992
|
// ../store-sql/src/tool/tool-attempt-records.ts
|
|
7878
|
-
import { Effect as Effect44, Schema as
|
|
7879
|
-
var toolAttemptRow =
|
|
7880
|
-
id:
|
|
7881
|
-
tool_call_id:
|
|
7882
|
-
attempt_number:
|
|
7883
|
-
state:
|
|
7884
|
-
worker_id:
|
|
7885
|
-
claim_expires_at:
|
|
7886
|
-
error:
|
|
7887
|
-
created_at:
|
|
7888
|
-
completed_at:
|
|
7993
|
+
import { Effect as Effect44, Schema as Schema43 } from "effect";
|
|
7994
|
+
var toolAttemptRow = Schema43.Struct({
|
|
7995
|
+
id: Schema43.String,
|
|
7996
|
+
tool_call_id: Schema43.String,
|
|
7997
|
+
attempt_number: Schema43.Union([Schema43.Finite, Schema43.String, Schema43.BigInt]),
|
|
7998
|
+
state: Schema43.String,
|
|
7999
|
+
worker_id: Schema43.NullishOr(Schema43.String),
|
|
8000
|
+
claim_expires_at: Schema43.NullishOr(Schema43.Union([Schema43.Date, Schema43.String, Schema43.Finite])),
|
|
8001
|
+
error: Schema43.NullishOr(Schema43.String),
|
|
8002
|
+
created_at: Schema43.Union([Schema43.Date, Schema43.String, Schema43.Finite]),
|
|
8003
|
+
completed_at: Schema43.NullishOr(Schema43.Union([Schema43.Date, Schema43.String, Schema43.Finite]))
|
|
7889
8004
|
}).annotate({ identifier: "Relay.ToolAttempt.Row" });
|
|
7890
|
-
var MaxAttemptRow =
|
|
7891
|
-
max_attempt:
|
|
8005
|
+
var MaxAttemptRow = Schema43.Struct({
|
|
8006
|
+
max_attempt: Schema43.NullishOr(Schema43.Union([Schema43.Finite, Schema43.String, Schema43.BigInt]))
|
|
7892
8007
|
});
|
|
7893
8008
|
var toolAttemptId = (attemptNumber) => exports_ids_schema.ToolAttemptId.make(`tool-attempt:${attemptNumber}`);
|
|
7894
8009
|
var makeToolAttemptRecordOperations = ({
|
|
@@ -7912,15 +8027,15 @@ var makeToolAttemptRecordOperations = ({
|
|
|
7912
8027
|
id: exports_ids_schema.ToolAttemptId.make(row.id),
|
|
7913
8028
|
callId: exports_ids_schema.ToolCallId.make(row.tool_call_id),
|
|
7914
8029
|
attemptNumber: Number(row.attempt_number),
|
|
7915
|
-
state:
|
|
8030
|
+
state: Schema43.decodeUnknownSync(exports_tool_schema.AttemptState)(row.state),
|
|
7916
8031
|
...row.worker_id === null || row.worker_id === undefined ? {} : { workerId: row.worker_id },
|
|
7917
8032
|
...row.claim_expires_at === null || row.claim_expires_at === undefined ? {} : { claimExpiresAt: fromDbTimestamp(row.claim_expires_at) },
|
|
7918
8033
|
...row.error === null || row.error === undefined ? {} : { error: row.error },
|
|
7919
8034
|
createdAt: fromDbTimestamp(row.created_at),
|
|
7920
8035
|
...row.completed_at === null || row.completed_at === undefined ? {} : { completedAt: fromDbTimestamp(row.completed_at) }
|
|
7921
8036
|
});
|
|
7922
|
-
const decodeAttemptRow = (row) =>
|
|
7923
|
-
const decodeMaxAttemptRow = (row) =>
|
|
8037
|
+
const decodeAttemptRow = (row) => Schema43.decodeUnknownEffect(toolAttemptRow)(row).pipe(Effect44.mapError(toRepositoryError14));
|
|
8038
|
+
const decodeMaxAttemptRow = (row) => Schema43.decodeUnknownEffect(Schema43.UndefinedOr(MaxAttemptRow))(row).pipe(Effect44.mapError(toRepositoryError14));
|
|
7924
8039
|
const selectAttempts = (tenantId, executionId, callId) => sql`
|
|
7925
8040
|
SELECT ${attemptColumns}
|
|
7926
8041
|
FROM relay_tool_attempts
|
|
@@ -8003,13 +8118,13 @@ var makeToolAttemptRecordOperations = ({
|
|
|
8003
8118
|
};
|
|
8004
8119
|
|
|
8005
8120
|
// ../store-sql/src/tool/tool-work-operations.ts
|
|
8006
|
-
import { Effect as Effect45, Schema as
|
|
8007
|
-
var ExpiredCallRow =
|
|
8008
|
-
id:
|
|
8009
|
-
execution_id:
|
|
8010
|
-
active_attempt_id:
|
|
8121
|
+
import { Effect as Effect45, Schema as Schema44 } from "effect";
|
|
8122
|
+
var ExpiredCallRow = Schema44.Struct({
|
|
8123
|
+
id: Schema44.String,
|
|
8124
|
+
execution_id: Schema44.String,
|
|
8125
|
+
active_attempt_id: Schema44.NullishOr(Schema44.String)
|
|
8011
8126
|
});
|
|
8012
|
-
var IdRow =
|
|
8127
|
+
var IdRow = Schema44.Struct({ id: Schema44.String, execution_id: Schema44.String });
|
|
8013
8128
|
var makeToolWorkOperations = ({
|
|
8014
8129
|
records,
|
|
8015
8130
|
attempts,
|
|
@@ -8172,7 +8287,7 @@ var makeToolWorkOperations = ({
|
|
|
8172
8287
|
WHERE tenant_id = ${tenantId} AND placement_kind = 'remote' AND placement_key = ${input.queue}
|
|
8173
8288
|
AND state = 'running' AND claim_expires_at IS NOT NULL AND claim_expires_at <= ${ts(input.now)}
|
|
8174
8289
|
`.pipe(Effect45.mapError(toRepositoryError14));
|
|
8175
|
-
const expired = yield*
|
|
8290
|
+
const expired = yield* Schema44.decodeUnknownEffect(Schema44.Array(ExpiredCallRow))(expiredRows).pipe(Effect45.mapError(toRepositoryError14));
|
|
8176
8291
|
for (const row of expired) {
|
|
8177
8292
|
const executionId2 = exports_ids_schema.ExecutionId.make(row.execution_id);
|
|
8178
8293
|
if (row.active_attempt_id !== null && row.active_attempt_id !== undefined) {
|
|
@@ -8186,7 +8301,7 @@ var makeToolWorkOperations = ({
|
|
|
8186
8301
|
`.pipe(Effect45.mapError(toRepositoryError14));
|
|
8187
8302
|
}
|
|
8188
8303
|
const candidateRows = yield* selectClaimCandidate(tenantId, input).pipe(Effect45.mapError(toRepositoryError14));
|
|
8189
|
-
const candidates = yield*
|
|
8304
|
+
const candidates = yield* Schema44.decodeUnknownEffect(Schema44.Array(IdRow))(candidateRows).pipe(Effect45.mapError(toRepositoryError14));
|
|
8190
8305
|
const candidate = candidates[0];
|
|
8191
8306
|
if (candidate === undefined)
|
|
8192
8307
|
return;
|
|
@@ -8361,54 +8476,54 @@ var makeToolWorkOperations = ({
|
|
|
8361
8476
|
};
|
|
8362
8477
|
|
|
8363
8478
|
// ../store-sql/src/tool/tool-call-records.ts
|
|
8364
|
-
var toolCallRow =
|
|
8365
|
-
id:
|
|
8366
|
-
execution_id:
|
|
8367
|
-
name:
|
|
8368
|
-
input_json:
|
|
8369
|
-
definition_json:
|
|
8370
|
-
placement_kind:
|
|
8371
|
-
placement_key:
|
|
8372
|
-
state:
|
|
8373
|
-
wait_id:
|
|
8374
|
-
idempotency_key:
|
|
8375
|
-
available_at:
|
|
8376
|
-
active_attempt_id:
|
|
8377
|
-
claim_owner:
|
|
8378
|
-
claimed_at:
|
|
8379
|
-
claim_expires_at:
|
|
8380
|
-
external_outcome_json:
|
|
8381
|
-
external_outcome_at:
|
|
8382
|
-
metadata_json:
|
|
8383
|
-
created_at:
|
|
8384
|
-
updated_at:
|
|
8479
|
+
var toolCallRow = Schema45.Struct({
|
|
8480
|
+
id: Schema45.String,
|
|
8481
|
+
execution_id: Schema45.String,
|
|
8482
|
+
name: Schema45.String,
|
|
8483
|
+
input_json: Schema45.Unknown,
|
|
8484
|
+
definition_json: Schema45.NullishOr(Schema45.Unknown),
|
|
8485
|
+
placement_kind: Schema45.String,
|
|
8486
|
+
placement_key: Schema45.NullishOr(Schema45.String),
|
|
8487
|
+
state: Schema45.String,
|
|
8488
|
+
wait_id: Schema45.NullishOr(Schema45.String),
|
|
8489
|
+
idempotency_key: Schema45.String,
|
|
8490
|
+
available_at: Schema45.Union([Schema45.Date, Schema45.String, Schema45.Finite]),
|
|
8491
|
+
active_attempt_id: Schema45.NullishOr(Schema45.String),
|
|
8492
|
+
claim_owner: Schema45.NullishOr(Schema45.String),
|
|
8493
|
+
claimed_at: Schema45.NullishOr(Schema45.Union([Schema45.Date, Schema45.String, Schema45.Finite])),
|
|
8494
|
+
claim_expires_at: Schema45.NullishOr(Schema45.Union([Schema45.Date, Schema45.String, Schema45.Finite])),
|
|
8495
|
+
external_outcome_json: Schema45.NullishOr(Schema45.Unknown),
|
|
8496
|
+
external_outcome_at: Schema45.NullishOr(Schema45.Union([Schema45.Date, Schema45.String, Schema45.Finite])),
|
|
8497
|
+
metadata_json: Schema45.Unknown,
|
|
8498
|
+
created_at: Schema45.Union([Schema45.Date, Schema45.String, Schema45.Finite]),
|
|
8499
|
+
updated_at: Schema45.Union([Schema45.Date, Schema45.String, Schema45.Finite])
|
|
8385
8500
|
}).annotate({ identifier: "Relay.ToolCall.Row" });
|
|
8386
|
-
var toolResultRow =
|
|
8387
|
-
tool_call_id:
|
|
8388
|
-
output_json:
|
|
8389
|
-
error:
|
|
8390
|
-
metadata_json:
|
|
8391
|
-
created_at:
|
|
8501
|
+
var toolResultRow = Schema45.Struct({
|
|
8502
|
+
tool_call_id: Schema45.String,
|
|
8503
|
+
output_json: Schema45.Unknown,
|
|
8504
|
+
error: Schema45.NullishOr(Schema45.String),
|
|
8505
|
+
metadata_json: Schema45.Unknown,
|
|
8506
|
+
created_at: Schema45.Union([Schema45.Date, Schema45.String, Schema45.Finite])
|
|
8392
8507
|
}).annotate({ identifier: "Relay.ToolResult.Row" });
|
|
8393
8508
|
var metadata8 = (input) => input ?? {};
|
|
8394
8509
|
var normalizeCall = (call) => ({ ...call, metadata: metadata8(call.metadata) });
|
|
8395
8510
|
var sameCallIdentity = (left, right) => exports_shared_schema.canonicalEquals(normalizeCall(left), normalizeCall(right));
|
|
8396
8511
|
var toolCallRecordIdentity = { sameCallIdentity };
|
|
8397
|
-
var placementFromRow = (row) =>
|
|
8512
|
+
var placementFromRow = (row) => Schema45.decodeUnknownSync(exports_tool_schema.Placement)(row.placement_kind === "remote" ? { kind: "remote", queue: row.placement_key } : row.placement_kind === "mcp" ? { kind: "mcp", server_id: row.placement_key } : { kind: row.placement_kind });
|
|
8398
8513
|
var toCallRecord = (row) => {
|
|
8399
|
-
const definition = row.definition_json === null || row.definition_json === undefined ? undefined :
|
|
8400
|
-
const outcome = row.external_outcome_json === null || row.external_outcome_json === undefined ? undefined :
|
|
8514
|
+
const definition = row.definition_json === null || row.definition_json === undefined ? undefined : Schema45.decodeUnknownSync(exports_tool_schema.Definition)(decodeJson(row.definition_json));
|
|
8515
|
+
const outcome = row.external_outcome_json === null || row.external_outcome_json === undefined ? undefined : Schema45.decodeUnknownSync(exports_tool_schema.ExternalOutcome)(decodeJson(row.external_outcome_json));
|
|
8401
8516
|
return {
|
|
8402
8517
|
executionId: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
8403
8518
|
call: normalizeCall({
|
|
8404
8519
|
id: exports_ids_schema.ToolCallId.make(row.id),
|
|
8405
8520
|
name: row.name,
|
|
8406
|
-
input:
|
|
8407
|
-
metadata:
|
|
8521
|
+
input: Schema45.decodeUnknownSync(exports_shared_schema.JsonValue)(decodeJson(row.input_json)),
|
|
8522
|
+
metadata: Schema45.decodeUnknownSync(exports_shared_schema.Metadata)(decodeJson(row.metadata_json))
|
|
8408
8523
|
}),
|
|
8409
8524
|
...definition === undefined ? {} : { definition },
|
|
8410
8525
|
placement: placementFromRow(row),
|
|
8411
|
-
state:
|
|
8526
|
+
state: Schema45.decodeUnknownSync(exports_tool_schema.CallState)(row.state),
|
|
8412
8527
|
...row.wait_id === null || row.wait_id === undefined ? {} : { waitId: exports_ids_schema.WaitId.make(row.wait_id) },
|
|
8413
8528
|
idempotencyKey: row.idempotency_key,
|
|
8414
8529
|
availableAt: fromDbTimestamp(row.available_at),
|
|
@@ -8425,9 +8540,9 @@ var toCallRecord = (row) => {
|
|
|
8425
8540
|
var toResultRecord = (row) => ({
|
|
8426
8541
|
result: {
|
|
8427
8542
|
call_id: exports_ids_schema.ToolCallId.make(row.tool_call_id),
|
|
8428
|
-
output:
|
|
8543
|
+
output: Schema45.decodeUnknownSync(exports_shared_schema.JsonValue)(decodeJson(row.output_json)),
|
|
8429
8544
|
...row.error === null || row.error === undefined ? {} : { error: row.error },
|
|
8430
|
-
metadata:
|
|
8545
|
+
metadata: Schema45.decodeUnknownSync(exports_shared_schema.Metadata)(decodeJson(row.metadata_json))
|
|
8431
8546
|
},
|
|
8432
8547
|
createdAt: fromDbTimestamp(row.created_at)
|
|
8433
8548
|
});
|
|
@@ -8544,8 +8659,8 @@ var makeToolCallRecordSupport = ({ sql, errors, toolCallIdempotencyKey }) => {
|
|
|
8544
8659
|
`,
|
|
8545
8660
|
orElse: () => selectCallByKey
|
|
8546
8661
|
});
|
|
8547
|
-
const decodeCallRow = (row) =>
|
|
8548
|
-
const decodeResultRow = (row) =>
|
|
8662
|
+
const decodeCallRow = (row) => Schema45.decodeUnknownEffect(toolCallRow)(row).pipe(Effect46.mapError(toRepositoryError14));
|
|
8663
|
+
const decodeResultRow = (row) => Schema45.decodeUnknownEffect(toolResultRow)(row).pipe(Effect46.mapError(toRepositoryError14));
|
|
8549
8664
|
const decodeCall = Effect46.fn("ToolCallRepository.decodeCall")(function* (row) {
|
|
8550
8665
|
const decoded = yield* decodeCallRow(row);
|
|
8551
8666
|
return yield* Effect46.try({ try: () => toCallRecord(decoded), catch: toRepositoryError14 });
|
|
@@ -8677,44 +8792,44 @@ var makeToolCallRepository = ({
|
|
|
8677
8792
|
});
|
|
8678
8793
|
|
|
8679
8794
|
// ../store-sql/src/tool/tool-call-repository.ts
|
|
8680
|
-
class ToolCallRepositoryError extends
|
|
8681
|
-
message:
|
|
8795
|
+
class ToolCallRepositoryError extends Schema46.TaggedErrorClass()("ToolCallRepositoryError", {
|
|
8796
|
+
message: Schema46.String
|
|
8682
8797
|
}) {
|
|
8683
8798
|
}
|
|
8684
8799
|
|
|
8685
|
-
class ToolCallNotFound extends
|
|
8800
|
+
class ToolCallNotFound extends Schema46.TaggedErrorClass()("ToolCallNotFound", {
|
|
8686
8801
|
id: exports_ids_schema.ToolCallId
|
|
8687
8802
|
}) {
|
|
8688
8803
|
}
|
|
8689
8804
|
|
|
8690
|
-
class DuplicateToolCall extends
|
|
8805
|
+
class DuplicateToolCall extends Schema46.TaggedErrorClass()("DuplicateToolCall", {
|
|
8691
8806
|
id: exports_ids_schema.ToolCallId
|
|
8692
8807
|
}) {
|
|
8693
8808
|
}
|
|
8694
8809
|
|
|
8695
|
-
class DuplicateToolResult extends
|
|
8810
|
+
class DuplicateToolResult extends Schema46.TaggedErrorClass()("DuplicateToolResult", {
|
|
8696
8811
|
call_id: exports_ids_schema.ToolCallId
|
|
8697
8812
|
}) {
|
|
8698
8813
|
}
|
|
8699
8814
|
|
|
8700
|
-
class ToolCallConflict extends
|
|
8815
|
+
class ToolCallConflict extends Schema46.TaggedErrorClass()("ToolCallConflict", {
|
|
8701
8816
|
id: exports_ids_schema.ToolCallId
|
|
8702
8817
|
}) {
|
|
8703
8818
|
}
|
|
8704
8819
|
|
|
8705
|
-
class ToolCallTransitionRejected extends
|
|
8820
|
+
class ToolCallTransitionRejected extends Schema46.TaggedErrorClass()("ToolCallTransitionRejected", {
|
|
8706
8821
|
id: exports_ids_schema.ToolCallId,
|
|
8707
|
-
message:
|
|
8822
|
+
message: Schema46.String
|
|
8708
8823
|
}) {
|
|
8709
8824
|
}
|
|
8710
8825
|
|
|
8711
|
-
class ToolOutcomeConflict extends
|
|
8826
|
+
class ToolOutcomeConflict extends Schema46.TaggedErrorClass()("ToolOutcomeConflict", {
|
|
8712
8827
|
id: exports_ids_schema.ToolCallId
|
|
8713
8828
|
}) {
|
|
8714
8829
|
}
|
|
8715
8830
|
|
|
8716
|
-
class ToolClaimRejected extends
|
|
8717
|
-
message:
|
|
8831
|
+
class ToolClaimRejected extends Schema46.TaggedErrorClass()("ToolClaimRejected", {
|
|
8832
|
+
message: Schema46.String
|
|
8718
8833
|
}) {
|
|
8719
8834
|
}
|
|
8720
8835
|
var lengthPrefixed = (value) => `${[...value].length}:${value}`;
|
|
@@ -9181,57 +9296,57 @@ __export(exports_workspace_lease_repository, {
|
|
|
9181
9296
|
Service: () => Service39,
|
|
9182
9297
|
DuplicateWorkspaceLease: () => DuplicateWorkspaceLease
|
|
9183
9298
|
});
|
|
9184
|
-
import { Context as Context37, Effect as Effect48, Layer as Layer39, Schema as
|
|
9299
|
+
import { Context as Context37, Effect as Effect48, Layer as Layer39, Schema as Schema47 } from "effect";
|
|
9185
9300
|
import { SqlClient as SqlClient27 } from "effect/unstable/sql/SqlClient";
|
|
9186
|
-
class WorkspaceLeaseRepositoryError extends
|
|
9187
|
-
message:
|
|
9301
|
+
class WorkspaceLeaseRepositoryError extends Schema47.TaggedErrorClass()("WorkspaceLeaseRepositoryError", {
|
|
9302
|
+
message: Schema47.String
|
|
9188
9303
|
}) {
|
|
9189
9304
|
}
|
|
9190
9305
|
|
|
9191
|
-
class DuplicateWorkspaceLease extends
|
|
9306
|
+
class DuplicateWorkspaceLease extends Schema47.TaggedErrorClass()("DuplicateWorkspaceLease", {
|
|
9192
9307
|
execution_id: exports_ids_schema.ExecutionId
|
|
9193
9308
|
}) {
|
|
9194
9309
|
}
|
|
9195
9310
|
|
|
9196
|
-
class WorkspaceLeaseNotFound extends
|
|
9311
|
+
class WorkspaceLeaseNotFound extends Schema47.TaggedErrorClass()("WorkspaceLeaseNotFound", {
|
|
9197
9312
|
execution_id: exports_ids_schema.ExecutionId
|
|
9198
9313
|
}) {
|
|
9199
9314
|
}
|
|
9200
9315
|
|
|
9201
9316
|
class Service39 extends Context37.Service()("@relayfx/store-sql/workspace/workspace-lease-repository/Service") {
|
|
9202
9317
|
}
|
|
9203
|
-
var WorkspaceLeaseRow =
|
|
9204
|
-
id:
|
|
9205
|
-
execution_id:
|
|
9206
|
-
provider_key:
|
|
9207
|
-
sandbox_ref:
|
|
9208
|
-
latest_snapshot_ref:
|
|
9209
|
-
status:
|
|
9210
|
-
resume_strategy:
|
|
9211
|
-
region:
|
|
9212
|
-
request_json:
|
|
9213
|
-
metadata_json:
|
|
9214
|
-
created_at:
|
|
9215
|
-
updated_at:
|
|
9318
|
+
var WorkspaceLeaseRow = Schema47.Struct({
|
|
9319
|
+
id: Schema47.String,
|
|
9320
|
+
execution_id: Schema47.String,
|
|
9321
|
+
provider_key: Schema47.String,
|
|
9322
|
+
sandbox_ref: Schema47.NullishOr(Schema47.String),
|
|
9323
|
+
latest_snapshot_ref: Schema47.NullishOr(Schema47.String),
|
|
9324
|
+
status: Schema47.String,
|
|
9325
|
+
resume_strategy: Schema47.String,
|
|
9326
|
+
region: Schema47.NullishOr(Schema47.String),
|
|
9327
|
+
request_json: Schema47.NullishOr(Schema47.Unknown),
|
|
9328
|
+
metadata_json: Schema47.Unknown,
|
|
9329
|
+
created_at: Schema47.Union([Schema47.Date, Schema47.String, Schema47.Finite]),
|
|
9330
|
+
updated_at: Schema47.Union([Schema47.Date, Schema47.String, Schema47.Finite])
|
|
9216
9331
|
}).annotate({ identifier: "Relay.WorkspaceLease.Row" });
|
|
9217
|
-
var WorkspaceSnapshotRow =
|
|
9218
|
-
id:
|
|
9219
|
-
lease_id:
|
|
9220
|
-
execution_id:
|
|
9221
|
-
reason:
|
|
9222
|
-
snapshot_ref:
|
|
9223
|
-
metadata_json:
|
|
9224
|
-
created_at:
|
|
9332
|
+
var WorkspaceSnapshotRow = Schema47.Struct({
|
|
9333
|
+
id: Schema47.String,
|
|
9334
|
+
lease_id: Schema47.String,
|
|
9335
|
+
execution_id: Schema47.String,
|
|
9336
|
+
reason: Schema47.String,
|
|
9337
|
+
snapshot_ref: Schema47.String,
|
|
9338
|
+
metadata_json: Schema47.Unknown,
|
|
9339
|
+
created_at: Schema47.Union([Schema47.Date, Schema47.String, Schema47.Finite])
|
|
9225
9340
|
}).annotate({ identifier: "Relay.WorkspaceSnapshot.Row" });
|
|
9226
9341
|
var metadata9 = (input) => input ?? {};
|
|
9227
9342
|
var terminalStatuses = new Set(["released", "failed"]);
|
|
9228
9343
|
var isActive = (record2) => !terminalStatuses.has(record2.status);
|
|
9229
|
-
var cloneLease = (record2) =>
|
|
9230
|
-
var cloneSnapshot = (record2) =>
|
|
9344
|
+
var cloneLease = (record2) => Schema47.decodeUnknownSync(exports_workspace_schema.WorkspaceLeaseRecord)(globalThis.structuredClone(record2));
|
|
9345
|
+
var cloneSnapshot = (record2) => Schema47.decodeUnknownSync(exports_workspace_schema.WorkspaceSnapshotRecord)(globalThis.structuredClone(record2));
|
|
9231
9346
|
var toRepositoryError14 = (error5) => WorkspaceLeaseRepositoryError.make({ message: String(error5) });
|
|
9232
|
-
var decodeLeaseRow = (row) =>
|
|
9233
|
-
var decodeSnapshotRow = (row) =>
|
|
9234
|
-
var decodeRequest = (value) =>
|
|
9347
|
+
var decodeLeaseRow = (row) => Schema47.decodeUnknownEffect(WorkspaceLeaseRow)(row).pipe(Effect48.mapError(toRepositoryError14));
|
|
9348
|
+
var decodeSnapshotRow = (row) => Schema47.decodeUnknownEffect(WorkspaceSnapshotRow)(row).pipe(Effect48.mapError(toRepositoryError14));
|
|
9349
|
+
var decodeRequest = (value) => Schema47.decodeUnknownSync(exports_workspace_schema.WorkspaceRequest)(decodeJson(value));
|
|
9235
9350
|
var toLeaseRecord = (row) => ({
|
|
9236
9351
|
id: exports_ids_schema.WorkspaceLeaseId.make(row.id),
|
|
9237
9352
|
execution_id: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
@@ -9584,10 +9699,10 @@ __export(exports_workflow_definition_repository, {
|
|
|
9584
9699
|
Service: () => Service40,
|
|
9585
9700
|
RepositoryError: () => RepositoryError
|
|
9586
9701
|
});
|
|
9587
|
-
import { Clock as Clock4, Context as Context38, Effect as Effect49, Layer as Layer40, Schema as
|
|
9702
|
+
import { Clock as Clock4, Context as Context38, Effect as Effect49, Layer as Layer40, Schema as Schema48 } from "effect";
|
|
9588
9703
|
import { SqlClient as SqlClient28 } from "effect/unstable/sql/SqlClient";
|
|
9589
|
-
class RepositoryError extends
|
|
9590
|
-
message:
|
|
9704
|
+
class RepositoryError extends Schema48.TaggedErrorClass()("WorkflowDefinitionRepositoryError", {
|
|
9705
|
+
message: Schema48.String
|
|
9591
9706
|
}) {
|
|
9592
9707
|
}
|
|
9593
9708
|
|
|
@@ -9841,8 +9956,8 @@ var transition2 = (sql, tenant, id, status, now, data) => sql.withTransaction(Ef
|
|
|
9841
9956
|
var decodeDefinition = (row) => ({
|
|
9842
9957
|
id: exports_ids_schema.WorkflowDefinitionId.make(row.workflow_definition_id),
|
|
9843
9958
|
revision: Number(row.revision),
|
|
9844
|
-
digest:
|
|
9845
|
-
definition:
|
|
9959
|
+
digest: Schema48.decodeUnknownSync(exports_workflow_schema.DefinitionDigest)(row.digest),
|
|
9960
|
+
definition: Schema48.decodeUnknownSync(exports_workflow_schema.Definition)(decodeJson(row.definition_json)),
|
|
9846
9961
|
created_at: fromDbTimestamp(row.created_at)
|
|
9847
9962
|
});
|
|
9848
9963
|
var decodeRun = (row) => ({
|
|
@@ -9850,19 +9965,19 @@ var decodeRun = (row) => ({
|
|
|
9850
9965
|
pin: {
|
|
9851
9966
|
workflow_definition_id: exports_ids_schema.WorkflowDefinitionId.make(row.workflow_definition_id),
|
|
9852
9967
|
workflow_definition_revision: Number(row.workflow_definition_revision),
|
|
9853
|
-
workflow_definition_digest:
|
|
9968
|
+
workflow_definition_digest: Schema48.decodeUnknownSync(exports_workflow_schema.DefinitionDigest)(row.workflow_definition_digest)
|
|
9854
9969
|
},
|
|
9855
|
-
status:
|
|
9970
|
+
status: Schema48.decodeUnknownSync(exports_workflow_schema.RunStatus)(row.status),
|
|
9856
9971
|
created_at: fromDbTimestamp(row.created_at),
|
|
9857
9972
|
updated_at: fromDbTimestamp(row.updated_at)
|
|
9858
9973
|
});
|
|
9859
9974
|
var decodeOperation = (row) => ({
|
|
9860
9975
|
execution_id: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
9861
9976
|
operation_id: exports_ids_schema.WorkflowOperationId.make(row.operation_id),
|
|
9862
|
-
status:
|
|
9977
|
+
status: Schema48.decodeUnknownSync(exports_workflow_schema.OperationStatus)(row.status),
|
|
9863
9978
|
...row.fan_out_id === null || row.fan_out_id === undefined ? {} : { fan_out_id: exports_ids_schema.ChildFanOutId.make(row.fan_out_id) },
|
|
9864
9979
|
...row.decision === null || row.decision === undefined ? {} : { decision: Boolean(row.decision) },
|
|
9865
|
-
...row.output_json === null || row.output_json === undefined ? {} : { output:
|
|
9980
|
+
...row.output_json === null || row.output_json === undefined ? {} : { output: Schema48.decodeUnknownSync(exports_workflow_schema.OperationState.fields.output)(decodeJson(row.output_json)) },
|
|
9866
9981
|
...row.attempt === null || row.attempt === undefined ? {} : { attempt: Number(row.attempt) },
|
|
9867
9982
|
...row.backoff_until === null || row.backoff_until === undefined ? {} : { backoff_until: fromDbTimestamp(row.backoff_until) },
|
|
9868
9983
|
...row.compensation_operation_id === null || row.compensation_operation_id === undefined ? {} : { compensation_operation_id: exports_ids_schema.WorkflowOperationId.make(row.compensation_operation_id) },
|
|
@@ -9873,17 +9988,17 @@ var decodeOperation = (row) => ({
|
|
|
9873
9988
|
var decodeLifecycle = (row) => ({
|
|
9874
9989
|
execution_id: exports_ids_schema.ExecutionId.make(row.execution_id),
|
|
9875
9990
|
sequence: Number(row.sequence),
|
|
9876
|
-
type:
|
|
9991
|
+
type: Schema48.decodeUnknownSync(exports_workflow_schema.LifecycleEventType)(row.event_type),
|
|
9877
9992
|
...row.operation_id === null || row.operation_id === undefined ? {} : { operation_id: exports_ids_schema.WorkflowOperationId.make(row.operation_id) },
|
|
9878
|
-
...row.data_json === null || row.data_json === undefined ? {} : { data:
|
|
9993
|
+
...row.data_json === null || row.data_json === undefined ? {} : { data: Schema48.decodeUnknownSync(exports_workflow_schema.LifecycleEvent.fields.data)(decodeJson(row.data_json)) },
|
|
9879
9994
|
created_at: fromDbTimestamp(row.created_at)
|
|
9880
9995
|
});
|
|
9881
9996
|
// ../runtime/src/tool/tool-runtime-service.ts
|
|
9882
9997
|
import { Tool as AiTool } from "effect/unstable/ai";
|
|
9883
|
-
import { Chunk, Context as Context41, Effect as Effect55, Function as Function8, HashSet as HashSet3, Layer as Layer45, Option as Option12, Ref as Ref12, Schema as
|
|
9998
|
+
import { Chunk, Context as Context41, Effect as Effect55, Function as Function8, HashSet as HashSet3, Layer as Layer45, Option as Option12, Ref as Ref12, Schema as Schema51, Sink, Stream as Stream10 } from "effect";
|
|
9884
9999
|
|
|
9885
10000
|
// ../runtime/src/execution/event-log-service.ts
|
|
9886
|
-
import { Context as Context39, Effect as Effect53, Function as Function7, Layer as Layer43, Option as Option10, Schema as
|
|
10001
|
+
import { Context as Context39, Effect as Effect53, Function as Function7, Layer as Layer43, Option as Option10, Schema as Schema49, Stream as Stream9 } from "effect";
|
|
9887
10002
|
|
|
9888
10003
|
// ../runtime/src/execution/event-log-memory.ts
|
|
9889
10004
|
import { Effect as Effect51, HashMap as HashMap2, HashSet as HashSet2, Layer as Layer41, Option as Option8, PubSub as PubSub5, Ref as Ref10, Stream as Stream7 } from "effect";
|
|
@@ -10236,14 +10351,14 @@ var makeRepositoryLayer = (eventLog) => {
|
|
|
10236
10351
|
};
|
|
10237
10352
|
|
|
10238
10353
|
// ../runtime/src/execution/event-log-service.ts
|
|
10239
|
-
class EventLogCursorNotFound2 extends
|
|
10354
|
+
class EventLogCursorNotFound2 extends Schema49.TaggedErrorClass()("EventLogCursorNotFound", {
|
|
10240
10355
|
execution_id: exports_ids_schema.ExecutionId,
|
|
10241
10356
|
cursor: exports_shared_schema.NonEmptyString
|
|
10242
10357
|
}) {
|
|
10243
10358
|
}
|
|
10244
10359
|
|
|
10245
|
-
class EventLogError extends
|
|
10246
|
-
message:
|
|
10360
|
+
class EventLogError extends Schema49.TaggedErrorClass()("EventLogError", {
|
|
10361
|
+
message: Schema49.String
|
|
10247
10362
|
}) {
|
|
10248
10363
|
}
|
|
10249
10364
|
|
|
@@ -10312,19 +10427,19 @@ var sumUsage2 = Effect53.fn("EventLog.sumUsage.call")(function* (executionId) {
|
|
|
10312
10427
|
});
|
|
10313
10428
|
|
|
10314
10429
|
// ../runtime/src/wait/wait-service.ts
|
|
10315
|
-
import { Context as Context40, Duration as Duration2, Effect as Effect54, Layer as Layer44, Option as Option11, Schema as
|
|
10316
|
-
class WaitNotFound2 extends
|
|
10430
|
+
import { Context as Context40, Duration as Duration2, Effect as Effect54, Layer as Layer44, Option as Option11, Schema as Schema50 } from "effect";
|
|
10431
|
+
class WaitNotFound2 extends Schema50.TaggedErrorClass()("WaitNotFound", {
|
|
10317
10432
|
wait_id: exports_ids_schema.WaitId
|
|
10318
10433
|
}) {
|
|
10319
10434
|
}
|
|
10320
10435
|
|
|
10321
|
-
class WaitDefinitionMissing extends
|
|
10436
|
+
class WaitDefinitionMissing extends Schema50.TaggedErrorClass()("WaitDefinitionMissing", {
|
|
10322
10437
|
envelope_id: exports_ids_schema.EnvelopeId
|
|
10323
10438
|
}) {
|
|
10324
10439
|
}
|
|
10325
10440
|
|
|
10326
|
-
class WaitServiceError extends
|
|
10327
|
-
message:
|
|
10441
|
+
class WaitServiceError extends Schema50.TaggedErrorClass()("WaitServiceError", {
|
|
10442
|
+
message: Schema50.String
|
|
10328
10443
|
}) {
|
|
10329
10444
|
}
|
|
10330
10445
|
|
|
@@ -10604,20 +10719,20 @@ var upsertTool = (registry, tool) => {
|
|
|
10604
10719
|
return Chunk.map(registry, (registered) => registered.definition.name === tool.definition.name ? tool : registered);
|
|
10605
10720
|
};
|
|
10606
10721
|
var registerTool = (tools, tool) => Ref12.update(tools, (registry) => upsertTool(registry, tool));
|
|
10607
|
-
var jsonValue2 = (value) =>
|
|
10608
|
-
var fallbackParametersSchema =
|
|
10722
|
+
var jsonValue2 = (value) => Schema51.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
10723
|
+
var fallbackParametersSchema = Schema51.Struct({});
|
|
10609
10724
|
var parametersForInputSchema = (inputSchema) => {
|
|
10610
10725
|
const schema = exports_tool_schema.parametersSchema(inputSchema);
|
|
10611
10726
|
return schema.ast._tag === "Unknown" || schema.ast._tag === "Declaration" ? { parameters: fallbackParametersSchema, jsonSchema: inputSchema } : { parameters: schema };
|
|
10612
10727
|
};
|
|
10613
10728
|
var attachJsonSchema = (tool, jsonSchema) => jsonSchema === undefined ? tool : Object.assign(tool, { jsonSchema });
|
|
10614
|
-
var isStructFieldMap = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((field) =>
|
|
10729
|
+
var isStructFieldMap = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((field) => Schema51.isSchema(field));
|
|
10615
10730
|
var jsonSchemaFromEffectToolParameters = (tool) => {
|
|
10616
10731
|
const parameters = tool.parametersSchema;
|
|
10617
|
-
if (
|
|
10732
|
+
if (Schema51.isSchema(parameters))
|
|
10618
10733
|
return AiTool.getJsonSchema(tool);
|
|
10619
10734
|
if (isStructFieldMap(parameters))
|
|
10620
|
-
return AiTool.getJsonSchemaFromSchema(
|
|
10735
|
+
return AiTool.getJsonSchemaFromSchema(Schema51.Struct(parameters));
|
|
10621
10736
|
return AiTool.getJsonSchema(tool);
|
|
10622
10737
|
};
|
|
10623
10738
|
var runHandledToolkitTool = (toolkit, name, input, services) => {
|
|
@@ -10631,7 +10746,7 @@ var runHandledToolkitTool = (toolkit, name, input, services) => {
|
|
|
10631
10746
|
message: "Tool handler did not produce a final result"
|
|
10632
10747
|
})),
|
|
10633
10748
|
onSome: (result) => result.isFailure ? Effect55.fail(ToolExecutionFailed.make({ tool_name: String(name), message: String(result.result) })) : Effect55.succeed(jsonValue2(result.encodedResult))
|
|
10634
|
-
})), Effect55.provide(services), Effect55.mapError((error5) =>
|
|
10749
|
+
})), Effect55.provide(services), Effect55.mapError((error5) => Schema51.is(ToolExecutionFailed)(error5) ? error5 : ToolExecutionFailed.make({ tool_name: String(name), message: String(error5) })));
|
|
10635
10750
|
};
|
|
10636
10751
|
var finalToolResult = (tool, input, idempotencyKey) => Effect55.gen(function* () {
|
|
10637
10752
|
if (tool.run === undefined) {
|
|
@@ -10728,7 +10843,7 @@ var recordRequested = (repository, eventLog, input, tool) => repository.ensureCa
|
|
|
10728
10843
|
var repairResultEvent = (eventLog, input, record2) => ensureToolEvent(eventLog, resultEvent({ ...input, createdAt: record2.createdAt - 1 }, record2.result, input.eventSequence + 1));
|
|
10729
10844
|
var persistReceived = (repository, input, result) => repository.recordResult({ executionId: input.executionId, result, createdAt: input.createdAt + 1 }).pipe(Effect55.catchTag("DuplicateToolResult", () => repository.getResult(input.executionId, result.call_id).pipe(Effect55.mapError(mapRepositoryError2), Effect55.flatMap((existing) => existing === undefined ? Effect55.fail(ToolRuntimeError.make({ message: "DuplicateToolResult" })) : Effect55.succeed(existing)))), Effect55.mapError(preserveRecordResultError));
|
|
10730
10845
|
var recordReceived = (eventLog, input, record2) => ensureToolEvent(eventLog, resultEvent({ ...input, createdAt: record2.createdAt - 1 }, record2.result, input.eventSequence + 1)).pipe(Effect55.as(record2.result));
|
|
10731
|
-
var nonEmptyName = (name) =>
|
|
10846
|
+
var nonEmptyName = (name) => Schema51.decodeUnknownSync(exports_shared_schema.NonEmptyString)(name);
|
|
10732
10847
|
var needsApprovalFromEffectTool = (tool) => tool.needsApproval === undefined ? undefined : typeof tool.needsApproval === "boolean" ? tool.needsApproval : true;
|
|
10733
10848
|
var definitionFromEffectTool = (modelTool, options) => ({
|
|
10734
10849
|
name: modelTool.name,
|
|
@@ -10769,8 +10884,8 @@ var tool = Function8.dual(2, (name, options) => {
|
|
|
10769
10884
|
tool: effectTool,
|
|
10770
10885
|
...options.placement === undefined ? {} : { placement: options.placement },
|
|
10771
10886
|
...options.requiredPermissions === undefined ? {} : { requiredPermissions: options.requiredPermissions },
|
|
10772
|
-
validateInput: (input) =>
|
|
10773
|
-
run: (input, context) =>
|
|
10887
|
+
validateInput: (input) => Schema51.decodeUnknownEffect(inputSchema)(input).pipe(Effect55.mapError((error5) => ToolInputInvalid.make({ tool_name: name, message: error5.message })), Effect55.asVoid),
|
|
10888
|
+
run: (input, context) => Schema51.decodeUnknownEffect(inputSchema)(input).pipe(Effect55.mapError((error5) => ToolExecutionFailed.make({ tool_name: name, message: error5.message })), Effect55.flatMap((decoded) => options.run(decoded, context)), Effect55.provideService(ToolCallInfo, context), Effect55.flatMap((output) => Schema51.encodeUnknownEffect(outputSchema)(output).pipe(Effect55.mapError((error5) => ToolExecutionFailed.make({ tool_name: name, message: error5.message })))), Effect55.map(jsonValue2))
|
|
10774
10889
|
};
|
|
10775
10890
|
});
|
|
10776
10891
|
var dynamicTool = Function8.dual(2, (name, options) => {
|
|
@@ -10778,7 +10893,7 @@ var dynamicTool = Function8.dual(2, (name, options) => {
|
|
|
10778
10893
|
const modelTool = attachJsonSchema(AiTool.dynamic(name, {
|
|
10779
10894
|
description: options.description,
|
|
10780
10895
|
parameters: parameters.parameters,
|
|
10781
|
-
success:
|
|
10896
|
+
success: Schema51.Unknown,
|
|
10782
10897
|
needsApproval: options.needsApproval
|
|
10783
10898
|
}), parameters.jsonSchema);
|
|
10784
10899
|
return {
|
|
@@ -10823,7 +10938,7 @@ var externalOutcomeResult = (call, input) => {
|
|
|
10823
10938
|
return Effect55.succeed(placementFailureResult(input, call.externalOutcome.message));
|
|
10824
10939
|
}
|
|
10825
10940
|
const placement = call.placement.kind;
|
|
10826
|
-
return
|
|
10941
|
+
return Schema51.decodeUnknownEffect(exports_tool_schema.resultSchema(call.definition.output_schema))(call.externalOutcome.output).pipe(Effect55.map((output) => ({ call_id: input.call.id, output: jsonValue2(output) })), Effect55.catch((error5) => Effect55.succeed(placementFailureResult(input, `invalid ${placement} result: ${error5.message}`))));
|
|
10827
10942
|
};
|
|
10828
10943
|
var runExternalTool = (repository, waits, call, input) => Effect55.gen(function* () {
|
|
10829
10944
|
const waitId2 = placementWaitId(input);
|
|
@@ -10857,7 +10972,7 @@ var runExternalTool = (repository, waits, call, input) => Effect55.gen(function*
|
|
|
10857
10972
|
return placementFailureResult(input, "Tool execution timed out");
|
|
10858
10973
|
if (wait.state === "cancelled")
|
|
10859
10974
|
return placementFailureResult(input, "Tool execution cancelled");
|
|
10860
|
-
const repairedCall = waitingCall.externalOutcome === undefined && waitingCall.placement.kind === "client" ? yield*
|
|
10975
|
+
const repairedCall = waitingCall.externalOutcome === undefined && waitingCall.placement.kind === "client" ? yield* Schema51.decodeUnknownEffect(exports_tool_schema.ExternalOutcome)(wait.metadata.external_outcome).pipe(Effect55.mapError((error5) => ToolRuntimeError.make({ message: error5.message })), Effect55.flatMap((outcome) => repository.acceptClientOutcome({
|
|
10861
10976
|
executionId: input.executionId,
|
|
10862
10977
|
callId: input.call.id,
|
|
10863
10978
|
outcome,
|
|
@@ -11022,11 +11137,11 @@ __export(exports_runtime, {
|
|
|
11022
11137
|
});
|
|
11023
11138
|
|
|
11024
11139
|
// ../runtime/src/child/child-fan-out-runtime.ts
|
|
11025
|
-
import { Clock as Clock5, Context as Context44, Effect as Effect58, FiberMap, Layer as Layer48, Schema as
|
|
11140
|
+
import { Clock as Clock5, Context as Context44, Effect as Effect58, FiberMap, Layer as Layer48, Schema as Schema54 } from "effect";
|
|
11026
11141
|
|
|
11027
11142
|
// ../runtime/src/child/child-fan-out-transition-service.ts
|
|
11028
|
-
import { Context as Context43, Effect as Effect57, Layer as Layer47, Option as Option13, Schema as
|
|
11029
|
-
class ChildFanOutTransitionError extends
|
|
11143
|
+
import { Context as Context43, Effect as Effect57, Layer as Layer47, Option as Option13, Schema as Schema53 } from "effect";
|
|
11144
|
+
class ChildFanOutTransitionError extends Schema53.TaggedErrorClass()("ChildFanOutTransitionError", { message: Schema53.String }) {
|
|
11030
11145
|
}
|
|
11031
11146
|
|
|
11032
11147
|
class Service43 extends Context43.Service()("@relayfx/runtime/child/child-fan-out-transition-service/Service") {
|
|
@@ -11093,7 +11208,7 @@ var terminal2 = Effect57.fn("ChildFanOutTransitionService.terminal.call")(functi
|
|
|
11093
11208
|
class HandlerService extends Context44.Service()("@relayfx/runtime/child/child-fan-out-runtime/HandlerService") {
|
|
11094
11209
|
}
|
|
11095
11210
|
|
|
11096
|
-
class ChildFanOutRuntimeError extends
|
|
11211
|
+
class ChildFanOutRuntimeError extends Schema54.TaggedErrorClass()("ChildFanOutRuntimeError", { message: Schema54.String }) {
|
|
11097
11212
|
}
|
|
11098
11213
|
|
|
11099
11214
|
class Service44 extends Context44.Service()("@relayfx/runtime/child/child-fan-out-runtime/Service") {
|
|
@@ -11160,17 +11275,17 @@ var layerFromRuntime = Layer48.effect(Service44, Effect58.gen(function* () {
|
|
|
11160
11275
|
}).pipe(Effect58.mapError(runtimeError)));
|
|
11161
11276
|
|
|
11162
11277
|
// ../runtime/src/state/execution-state-service.ts
|
|
11163
|
-
import { Config as Config2, Context as Context45, Effect as Effect59, Function as Function10, Layer as Layer49, Schema as
|
|
11278
|
+
import { Config as Config2, Context as Context45, Effect as Effect59, Function as Function10, Layer as Layer49, Schema as Schema55 } from "effect";
|
|
11164
11279
|
var StateVersionConflict3 = exports_execution_state_repository.StateVersionConflict;
|
|
11165
11280
|
|
|
11166
|
-
class StateValueInvalid extends
|
|
11167
|
-
key:
|
|
11168
|
-
message:
|
|
11281
|
+
class StateValueInvalid extends Schema55.TaggedErrorClass()("StateValueInvalid", {
|
|
11282
|
+
key: Schema55.String,
|
|
11283
|
+
message: Schema55.String
|
|
11169
11284
|
}) {
|
|
11170
11285
|
}
|
|
11171
11286
|
|
|
11172
|
-
class ExecutionStateError extends
|
|
11173
|
-
message:
|
|
11287
|
+
class ExecutionStateError extends Schema55.TaggedErrorClass()("ExecutionStateError", {
|
|
11288
|
+
message: Schema55.String
|
|
11174
11289
|
}) {
|
|
11175
11290
|
}
|
|
11176
11291
|
var key3 = Function10.dual(2, (name, schema) => ({
|
|
@@ -11190,7 +11305,7 @@ var layer38 = Layer49.effect(Service45, Effect59.gen(function* () {
|
|
|
11190
11305
|
const row = yield* repository.get(executionId, stateKey.name).pipe(Effect59.mapError(stateError));
|
|
11191
11306
|
if (row === undefined)
|
|
11192
11307
|
return;
|
|
11193
|
-
return yield*
|
|
11308
|
+
return yield* Schema55.decodeUnknownEffect(stateKey.schema)(row.value).pipe(Effect59.mapError((cause) => invalid(stateKey.name, cause)));
|
|
11194
11309
|
});
|
|
11195
11310
|
const getRecord = Effect59.fn("ExecutionStateService.getRecord")((executionId, stateKey) => repository.get(executionId, stateKey).pipe(Effect59.mapError(stateError)));
|
|
11196
11311
|
const put4 = Effect59.fn("ExecutionStateService.put")(function* (input) {
|
|
@@ -11199,8 +11314,8 @@ var layer38 = Layer49.effect(Service45, Effect59.gen(function* () {
|
|
|
11199
11314
|
if (replay2 !== undefined && replay2.key === input.key.name && replay2.op === "put" && replay2.record !== undefined)
|
|
11200
11315
|
return replay2.record;
|
|
11201
11316
|
}
|
|
11202
|
-
const value = yield*
|
|
11203
|
-
const encoded = yield*
|
|
11317
|
+
const value = yield* Schema55.encodeUnknownEffect(input.key.schema)(input.value).pipe(Effect59.mapError((cause) => invalid(input.key.name, cause)));
|
|
11318
|
+
const encoded = yield* Schema55.encodeEffect(Schema55.UnknownFromJsonString)(value).pipe(Effect59.mapError((cause) => invalid(input.key.name, cause)));
|
|
11204
11319
|
const bytes = new TextEncoder().encode(encoded);
|
|
11205
11320
|
let eventValue = { value };
|
|
11206
11321
|
if (bytes.byteLength > eventInlineMaxBytes) {
|
|
@@ -11215,9 +11330,9 @@ var layer38 = Layer49.effect(Service45, Effect59.gen(function* () {
|
|
|
11215
11330
|
...input.expectedVersion === undefined ? {} : { expectedVersion: input.expectedVersion },
|
|
11216
11331
|
...input.idempotencyKey === undefined ? {} : { idempotencyKey: input.idempotencyKey },
|
|
11217
11332
|
updatedAt: input.updatedAt
|
|
11218
|
-
}).pipe(Effect59.mapError((cause) =>
|
|
11333
|
+
}).pipe(Effect59.mapError((cause) => Schema55.is(exports_execution_state_repository.StateVersionConflict)(cause) ? cause : stateError(cause)));
|
|
11219
11334
|
});
|
|
11220
|
-
const remove3 = Effect59.fn("ExecutionStateService.remove")((input) => repository.remove(input).pipe(Effect59.mapError((cause) =>
|
|
11335
|
+
const remove3 = Effect59.fn("ExecutionStateService.remove")((input) => repository.remove(input).pipe(Effect59.mapError((cause) => Schema55.is(exports_execution_state_repository.StateVersionConflict)(cause) ? cause : stateError(cause))));
|
|
11221
11336
|
const list12 = Effect59.fn("ExecutionStateService.list")((input) => repository.list(input).pipe(Effect59.mapError(stateError)));
|
|
11222
11337
|
return Service45.of({ getRecord, get: get12, put: put4, remove: remove3, list: list12 });
|
|
11223
11338
|
}));
|
|
@@ -11225,7 +11340,7 @@ var memoryRepositoryDependencies = Layer49.mergeAll(exports_execution_repository
|
|
|
11225
11340
|
var memoryLayer36 = layer38.pipe(Layer49.provide(exports_execution_state_repository.memoryLayer.pipe(Layer49.provide(memoryRepositoryDependencies))));
|
|
11226
11341
|
|
|
11227
11342
|
// ../runtime/src/runner/runner-runtime-service.ts
|
|
11228
|
-
import { Config as Config8, Context as Context70, Crypto as Crypto4, Duration as Duration7, Effect as Effect99, Layer as Layer81, Option as Option26, Schema as
|
|
11343
|
+
import { Config as Config8, Context as Context70, Crypto as Crypto4, Duration as Duration7, Effect as Effect99, Layer as Layer81, Option as Option26, Schema as Schema91, Stream as Stream16 } from "effect";
|
|
11229
11344
|
import {
|
|
11230
11345
|
ClusterWorkflowEngine,
|
|
11231
11346
|
HttpRunner,
|
|
@@ -11246,7 +11361,7 @@ import { WorkflowEngine as WorkflowEngine2 } from "effect/unstable/workflow";
|
|
|
11246
11361
|
import { LanguageModel as LanguageModel2 } from "effect/unstable/ai";
|
|
11247
11362
|
|
|
11248
11363
|
// ../runtime/src/agent/agent-registry-service.ts
|
|
11249
|
-
import { Clock as Clock6, Context as Context46, Crypto as Crypto2, Effect as Effect61, HashSet as HashSet4, Layer as Layer50, Option as Option14, Schema as
|
|
11364
|
+
import { Clock as Clock6, Context as Context46, Crypto as Crypto2, Effect as Effect61, HashSet as HashSet4, Layer as Layer50, Option as Option14, Schema as Schema56 } from "effect";
|
|
11250
11365
|
|
|
11251
11366
|
// ../runtime/src/tool/tool-input-schema-digest.ts
|
|
11252
11367
|
import { Crypto, Effect as Effect60, Encoding } from "effect";
|
|
@@ -11268,13 +11383,13 @@ var digestDefinitions = Effect60.fn("ToolInputSchemaDigest.digestDefinitions")(f
|
|
|
11268
11383
|
});
|
|
11269
11384
|
|
|
11270
11385
|
// ../runtime/src/agent/agent-registry-service.ts
|
|
11271
|
-
class AgentDefinitionInvalid extends
|
|
11272
|
-
message:
|
|
11386
|
+
class AgentDefinitionInvalid extends Schema56.TaggedErrorClass()("AgentDefinitionInvalid", {
|
|
11387
|
+
message: Schema56.String
|
|
11273
11388
|
}) {
|
|
11274
11389
|
}
|
|
11275
11390
|
|
|
11276
|
-
class AgentRegistryError extends
|
|
11277
|
-
message:
|
|
11391
|
+
class AgentRegistryError extends Schema56.TaggedErrorClass()("AgentRegistryError", {
|
|
11392
|
+
message: Schema56.String
|
|
11278
11393
|
}) {
|
|
11279
11394
|
}
|
|
11280
11395
|
|
|
@@ -11316,7 +11431,7 @@ var transferToolName = (name) => `transfer_to_${name.trim().toLowerCase().replac
|
|
|
11316
11431
|
var validateTurnPolicySnapshot = Effect61.fn("AgentRegistry.validateTurnPolicySnapshot")(function* (snapshot) {
|
|
11317
11432
|
if (snapshot === undefined)
|
|
11318
11433
|
return;
|
|
11319
|
-
const decoded = yield*
|
|
11434
|
+
const decoded = yield* Schema56.decodeUnknownEffect(exports_agent_schema.TurnPolicySnapshot)(snapshot).pipe(Effect61.mapError(() => AgentDefinitionInvalid.make({ message: "definition.turn_policy must be a valid turn policy snapshot" })));
|
|
11320
11435
|
let nodes = 0;
|
|
11321
11436
|
const pending = [
|
|
11322
11437
|
{ snapshot: decoded, depth: 1 }
|
|
@@ -11460,35 +11575,35 @@ var listRevisions3 = Effect61.fn("AgentRegistry.listRevisions.call")(function* (
|
|
|
11460
11575
|
});
|
|
11461
11576
|
|
|
11462
11577
|
// ../runtime/src/agent/agent-loop-service.ts
|
|
11463
|
-
import { Cause as Cause2, Config as Config4, Context as Context64, Crypto as Crypto3, Effect as Effect93, HashSet as HashSet7, Layer as Layer75, Option as Option24, Ref as Ref19, Schema as
|
|
11578
|
+
import { Cause as Cause2, Config as Config4, Context as Context64, Crypto as Crypto3, Effect as Effect93, HashSet as HashSet7, Layer as Layer75, Option as Option24, Ref as Ref19, Schema as Schema84, Stream as Stream13 } from "effect";
|
|
11464
11579
|
import { AiError as AiError3, Chat, LanguageModel, Prompt as Prompt6, Tokenizer, Tool as AiTool2, Toolkit as Toolkit2 } from "effect/unstable/ai";
|
|
11465
11580
|
|
|
11466
11581
|
// ../runtime/src/child/child-run-service.ts
|
|
11467
|
-
import { Context as Context48, Effect as Effect63, Function as Function12, HashSet as HashSet5, Layer as Layer52, Option as Option15, Result as Result2, Schema as
|
|
11582
|
+
import { Context as Context48, Effect as Effect63, Function as Function12, HashSet as HashSet5, Layer as Layer52, Option as Option15, Result as Result2, Schema as Schema58 } from "effect";
|
|
11468
11583
|
|
|
11469
11584
|
// ../runtime/src/workspace/workspace-provider-service.ts
|
|
11470
|
-
import { Context as Context47, Effect as Effect62, Function as Function11, Layer as Layer51, Ref as Ref13, Schema as
|
|
11585
|
+
import { Context as Context47, Effect as Effect62, Function as Function11, Layer as Layer51, Ref as Ref13, Schema as Schema57 } from "effect";
|
|
11471
11586
|
|
|
11472
|
-
class WorkspaceNotFound extends
|
|
11587
|
+
class WorkspaceNotFound extends Schema57.TaggedErrorClass()("WorkspaceNotFound", {
|
|
11473
11588
|
sandbox_ref: exports_ids_schema.WorkspaceRef
|
|
11474
11589
|
}) {
|
|
11475
11590
|
}
|
|
11476
11591
|
|
|
11477
|
-
class WorkspaceUnavailable extends
|
|
11592
|
+
class WorkspaceUnavailable extends Schema57.TaggedErrorClass()("WorkspaceUnavailable", {
|
|
11478
11593
|
sandbox_ref: exports_ids_schema.WorkspaceRef,
|
|
11479
|
-
message:
|
|
11594
|
+
message: Schema57.String
|
|
11480
11595
|
}) {
|
|
11481
11596
|
}
|
|
11482
11597
|
|
|
11483
|
-
class WorkspaceCapabilityUnsupported extends
|
|
11484
|
-
capability:
|
|
11598
|
+
class WorkspaceCapabilityUnsupported extends Schema57.TaggedErrorClass()("WorkspaceCapabilityUnsupported", {
|
|
11599
|
+
capability: Schema57.Literals(["suspend", "snapshot", "fork"]),
|
|
11485
11600
|
provider_key: exports_workspace_schema.WorkspaceProviderKey
|
|
11486
11601
|
}) {
|
|
11487
11602
|
}
|
|
11488
11603
|
|
|
11489
|
-
class WorkspaceProviderError extends
|
|
11604
|
+
class WorkspaceProviderError extends Schema57.TaggedErrorClass()("WorkspaceProviderError", {
|
|
11490
11605
|
provider_key: exports_workspace_schema.WorkspaceProviderKey,
|
|
11491
|
-
message:
|
|
11606
|
+
message: Schema57.String
|
|
11492
11607
|
}) {
|
|
11493
11608
|
}
|
|
11494
11609
|
|
|
@@ -11541,28 +11656,28 @@ var destroy = Effect62.fn("WorkspaceProvider.destroy.call")(function* (ref) {
|
|
|
11541
11656
|
});
|
|
11542
11657
|
|
|
11543
11658
|
// ../runtime/src/child/child-run-service.ts
|
|
11544
|
-
class StaticChildRunPresetNotFound extends
|
|
11659
|
+
class StaticChildRunPresetNotFound extends Schema58.TaggedErrorClass()("StaticChildRunPresetNotFound", {
|
|
11545
11660
|
preset_name: exports_shared_schema.NonEmptyString
|
|
11546
11661
|
}) {
|
|
11547
11662
|
}
|
|
11548
11663
|
|
|
11549
|
-
class ChildRunScopeBroadened extends
|
|
11550
|
-
field:
|
|
11664
|
+
class ChildRunScopeBroadened extends Schema58.TaggedErrorClass()("ChildRunScopeBroadened", {
|
|
11665
|
+
field: Schema58.Literals(["tool_names", "permissions"]),
|
|
11551
11666
|
value: exports_shared_schema.NonEmptyString
|
|
11552
11667
|
}) {
|
|
11553
11668
|
}
|
|
11554
11669
|
|
|
11555
|
-
class ChildRunServiceError extends
|
|
11556
|
-
message:
|
|
11670
|
+
class ChildRunServiceError extends Schema58.TaggedErrorClass()("ChildRunServiceError", {
|
|
11671
|
+
message: Schema58.String
|
|
11557
11672
|
}) {
|
|
11558
11673
|
}
|
|
11559
11674
|
|
|
11560
|
-
class ChildRunWorkspaceUnavailable extends
|
|
11561
|
-
reason:
|
|
11675
|
+
class ChildRunWorkspaceUnavailable extends Schema58.TaggedErrorClass()("ChildRunWorkspaceUnavailable", {
|
|
11676
|
+
reason: Schema58.String
|
|
11562
11677
|
}) {
|
|
11563
11678
|
}
|
|
11564
11679
|
|
|
11565
|
-
class ChildRunModelMissing extends
|
|
11680
|
+
class ChildRunModelMissing extends Schema58.TaggedErrorClass()("ChildRunModelMissing", {}) {
|
|
11566
11681
|
}
|
|
11567
11682
|
|
|
11568
11683
|
class Service48 extends Context48.Service()("@relayfx/runtime/child/child-run-service/Service") {
|
|
@@ -11798,53 +11913,53 @@ var spawnDynamic = Effect63.fn("ChildRunService.spawnDynamic.call")(function* (i
|
|
|
11798
11913
|
});
|
|
11799
11914
|
|
|
11800
11915
|
// ../runtime/src/child/spawn-child-run-tool.ts
|
|
11801
|
-
import { Effect as Effect64, Schema as
|
|
11916
|
+
import { Effect as Effect64, Schema as Schema59 } from "effect";
|
|
11802
11917
|
var toolName = "spawn_child_run";
|
|
11803
11918
|
var permissionName = "relay.child_run.spawn";
|
|
11804
|
-
var Input =
|
|
11805
|
-
preset_name:
|
|
11806
|
-
instructions:
|
|
11807
|
-
model:
|
|
11808
|
-
compaction_policy:
|
|
11809
|
-
tool_names:
|
|
11810
|
-
permissions:
|
|
11811
|
-
output_schema_ref:
|
|
11812
|
-
metadata:
|
|
11813
|
-
input:
|
|
11919
|
+
var Input = Schema59.Struct({
|
|
11920
|
+
preset_name: Schema59.optionalKey(exports_shared_schema.NonEmptyString),
|
|
11921
|
+
instructions: Schema59.optionalKey(Schema59.String),
|
|
11922
|
+
model: Schema59.optionalKey(exports_agent_schema.ModelSelection),
|
|
11923
|
+
compaction_policy: Schema59.optionalKey(exports_agent_schema.CompactionPolicy),
|
|
11924
|
+
tool_names: Schema59.optionalKey(Schema59.Array(Schema59.String)),
|
|
11925
|
+
permissions: Schema59.optionalKey(Schema59.Array(Schema59.String)),
|
|
11926
|
+
output_schema_ref: Schema59.optionalKey(Schema59.String),
|
|
11927
|
+
metadata: Schema59.optionalKey(exports_shared_schema.Metadata),
|
|
11928
|
+
input: Schema59.optionalKey(Schema59.Array(exports_content_schema.Part))
|
|
11814
11929
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Input" });
|
|
11815
|
-
var Output =
|
|
11930
|
+
var Output = Schema59.Struct({
|
|
11816
11931
|
child_execution_id: exports_ids_schema.ChildExecutionId,
|
|
11817
|
-
status:
|
|
11818
|
-
output:
|
|
11932
|
+
status: Schema59.Literals(["completed", "failed", "cancelled"]),
|
|
11933
|
+
output: Schema59.Array(exports_content_schema.Part)
|
|
11819
11934
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Output" });
|
|
11820
|
-
var TransferInput =
|
|
11821
|
-
input:
|
|
11935
|
+
var TransferInput = Schema59.Struct({
|
|
11936
|
+
input: Schema59.optionalKey(Schema59.Array(exports_content_schema.Part))
|
|
11822
11937
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.TransferInput" });
|
|
11823
|
-
var ModelInput =
|
|
11824
|
-
preset_name:
|
|
11825
|
-
instructions:
|
|
11826
|
-
model:
|
|
11827
|
-
provider:
|
|
11828
|
-
model:
|
|
11829
|
-
registration_key:
|
|
11938
|
+
var ModelInput = Schema59.Struct({
|
|
11939
|
+
preset_name: Schema59.optionalKey(Schema59.NullOr(Schema59.String)),
|
|
11940
|
+
instructions: Schema59.optionalKey(Schema59.String),
|
|
11941
|
+
model: Schema59.optionalKey(Schema59.NullOr(Schema59.Struct({
|
|
11942
|
+
provider: Schema59.String,
|
|
11943
|
+
model: Schema59.String,
|
|
11944
|
+
registration_key: Schema59.optionalKey(Schema59.String)
|
|
11830
11945
|
}))),
|
|
11831
|
-
compaction_policy:
|
|
11832
|
-
context_window:
|
|
11833
|
-
reserve_tokens:
|
|
11834
|
-
keep_recent_tokens:
|
|
11835
|
-
summary_model:
|
|
11836
|
-
provider:
|
|
11837
|
-
model:
|
|
11838
|
-
registration_key:
|
|
11946
|
+
compaction_policy: Schema59.optionalKey(Schema59.Struct({
|
|
11947
|
+
context_window: Schema59.Finite,
|
|
11948
|
+
reserve_tokens: Schema59.Finite,
|
|
11949
|
+
keep_recent_tokens: Schema59.Finite,
|
|
11950
|
+
summary_model: Schema59.optionalKey(Schema59.Struct({
|
|
11951
|
+
provider: Schema59.String,
|
|
11952
|
+
model: Schema59.String,
|
|
11953
|
+
registration_key: Schema59.optionalKey(Schema59.String)
|
|
11839
11954
|
}))
|
|
11840
11955
|
})),
|
|
11841
|
-
tool_names:
|
|
11842
|
-
permissions:
|
|
11843
|
-
output_schema_ref:
|
|
11844
|
-
input:
|
|
11956
|
+
tool_names: Schema59.optionalKey(Schema59.Array(Schema59.String)),
|
|
11957
|
+
permissions: Schema59.optionalKey(Schema59.Array(Schema59.String)),
|
|
11958
|
+
output_schema_ref: Schema59.optionalKey(Schema59.NullOr(Schema59.String)),
|
|
11959
|
+
input: Schema59.optionalKey(Schema59.Array(Schema59.Struct({ type: Schema59.Literal("text"), text: Schema59.String })))
|
|
11845
11960
|
});
|
|
11846
|
-
var ModelTransferInput =
|
|
11847
|
-
input:
|
|
11961
|
+
var ModelTransferInput = Schema59.Struct({
|
|
11962
|
+
input: Schema59.optionalKey(Schema59.Array(Schema59.Struct({ type: Schema59.Literal("text"), text: Schema59.String })))
|
|
11848
11963
|
});
|
|
11849
11964
|
var normalizeModelInput = (input) => {
|
|
11850
11965
|
const { preset_name: presetName, model, output_schema_ref: outputSchemaRef2, ...rest } = input;
|
|
@@ -12029,7 +12144,7 @@ var registeredTool = (config) => tool(toolName, {
|
|
|
12029
12144
|
permissions: [{ name: permissionName, value: true }],
|
|
12030
12145
|
requiredPermissions: [permissionName],
|
|
12031
12146
|
metadata: { relay_core_tool: true },
|
|
12032
|
-
run: (input, context) =>
|
|
12147
|
+
run: (input, context) => Schema59.decodeUnknownEffect(Input)(normalizeModelInput(input)).pipe(Effect64.mapError((error5) => ToolExecutionFailed.make({ tool_name: toolName, message: error5.message })), Effect64.flatMap((decoded) => run3(config, toolName, decoded, context, true)))
|
|
12033
12148
|
});
|
|
12034
12149
|
var transferToolName2 = (name) => `transfer_to_${name.trim().toLowerCase().replaceAll(/[^a-z0-9]+/g, "_").replaceAll(/^_+|_+$/g, "")}`;
|
|
12035
12150
|
var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target) => {
|
|
@@ -12041,12 +12156,12 @@ var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target
|
|
|
12041
12156
|
permissions: [{ name: permissionName, value: true }],
|
|
12042
12157
|
requiredPermissions: [permissionName],
|
|
12043
12158
|
metadata: { relay_core_tool: true, handoff_target: target.name, preset_name: target.preset_name },
|
|
12044
|
-
run: (input, context) =>
|
|
12159
|
+
run: (input, context) => Schema59.decodeUnknownEffect(TransferInput)(input).pipe(Effect64.mapError((error5) => ToolExecutionFailed.make({ tool_name: name, message: error5.message })), Effect64.flatMap((decoded) => run3(config, name, { preset_name: target.preset_name, input: decoded.input ?? [] }, context, false)))
|
|
12045
12160
|
});
|
|
12046
12161
|
});
|
|
12047
12162
|
|
|
12048
12163
|
// ../runtime/src/memory/memory-service.ts
|
|
12049
|
-
import { Clock as Clock7, Context as Context49, Effect as Effect65, Layer as Layer53, Schema as
|
|
12164
|
+
import { Clock as Clock7, Context as Context49, Effect as Effect65, Layer as Layer53, Schema as Schema60 } from "effect";
|
|
12050
12165
|
import { EmbeddingModel as EmbeddingModel2, Prompt as Prompt4 } from "effect/unstable/ai";
|
|
12051
12166
|
class Service49 extends Context49.Service()("@relayfx/runtime/memory/memory-service/Service") {
|
|
12052
12167
|
}
|
|
@@ -12054,7 +12169,7 @@ var defaultTopK = 5;
|
|
|
12054
12169
|
var memoryError = (error5) => exports_memory.MemoryError.make({
|
|
12055
12170
|
message: error5 instanceof Error ? `${error5.name}: ${error5.message}` : String(error5)
|
|
12056
12171
|
});
|
|
12057
|
-
var decodeSubject = (subject) =>
|
|
12172
|
+
var decodeSubject = (subject) => Schema60.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect65.mapError(memoryError));
|
|
12058
12173
|
var textPart = (text) => Prompt4.makePart("text", { text });
|
|
12059
12174
|
var textFromParts = (parts) => parts.filter((part) => part.type === "text").map((part) => part.text).join(`
|
|
12060
12175
|
`).trim();
|
|
@@ -12217,8 +12332,8 @@ var layer42 = (input) => Layer54.succeed(Service50, Service50.of(make4(input)));
|
|
|
12217
12332
|
var noRetryLayer = layer42({ retrySchedule: Schedule3.recurs(0) });
|
|
12218
12333
|
|
|
12219
12334
|
// ../runtime/src/presence/presence-service.ts
|
|
12220
|
-
import { Clock as Clock8, Config as Config3, Effect as Effect66, Layer as Layer55, Random, Schedule as Schedule4, Schema as
|
|
12221
|
-
var isPresenceError =
|
|
12335
|
+
import { Clock as Clock8, Config as Config3, Effect as Effect66, Layer as Layer55, Random, Schedule as Schedule4, Schema as Schema61, Stream as Stream11 } from "effect";
|
|
12336
|
+
var isPresenceError = Schema61.is(PresenceError);
|
|
12222
12337
|
var readError = (cause) => isPresenceError(cause) ? cause : PresenceError.make({ message: String(cause) });
|
|
12223
12338
|
var warn = (operation) => (cause) => Effect66.logWarning(`Presence ${operation} failed`).pipe(Effect66.annotateLogs({ cause: String(cause) }));
|
|
12224
12339
|
var layerFromRepository2 = Layer55.effect(Service2, Effect66.gen(function* () {
|
|
@@ -12273,11 +12388,11 @@ var list13 = Effect66.fn("Presence.list.call")(function* (scope) {
|
|
|
12273
12388
|
});
|
|
12274
12389
|
|
|
12275
12390
|
// ../runtime/src/presence/presence-tool.ts
|
|
12276
|
-
import { Effect as Effect67, Schema as
|
|
12391
|
+
import { Effect as Effect67, Schema as Schema62 } from "effect";
|
|
12277
12392
|
var toolName2 = "relay_presence";
|
|
12278
12393
|
var permissionName2 = "relay.presence.read";
|
|
12279
|
-
var Input2 =
|
|
12280
|
-
var Output2 =
|
|
12394
|
+
var Input2 = Schema62.Struct({ scope: Schema62.optionalKey(exports_presence_schema.Scope) });
|
|
12395
|
+
var Output2 = Schema62.Struct({ watcher_count: Schema62.Finite, entries: Schema62.Array(exports_presence_schema.Entry) });
|
|
12281
12396
|
var registeredTool2 = (presence) => tool(toolName2, {
|
|
12282
12397
|
description: "List observers currently watching an execution or session.",
|
|
12283
12398
|
input: Input2,
|
|
@@ -12293,24 +12408,24 @@ var registeredTool2 = (presence) => tool(toolName2, {
|
|
|
12293
12408
|
});
|
|
12294
12409
|
|
|
12295
12410
|
// ../runtime/src/state/state-tools.ts
|
|
12296
|
-
import { Effect as Effect68, Schema as
|
|
12297
|
-
var GetInput =
|
|
12298
|
-
var GetOutput =
|
|
12299
|
-
value:
|
|
12300
|
-
version:
|
|
12411
|
+
import { Effect as Effect68, Schema as Schema63 } from "effect";
|
|
12412
|
+
var GetInput = Schema63.Struct({ key: exports_shared_schema.NonEmptyString });
|
|
12413
|
+
var GetOutput = Schema63.Struct({
|
|
12414
|
+
value: Schema63.optionalKey(exports_shared_schema.JsonValue),
|
|
12415
|
+
version: Schema63.optionalKey(Schema63.Int)
|
|
12301
12416
|
});
|
|
12302
|
-
var PutInput =
|
|
12417
|
+
var PutInput = Schema63.Struct({
|
|
12303
12418
|
key: exports_shared_schema.NonEmptyString,
|
|
12304
12419
|
value: exports_shared_schema.JsonValue,
|
|
12305
|
-
expected_version:
|
|
12420
|
+
expected_version: Schema63.optionalKey(Schema63.Int.check(Schema63.isGreaterThanOrEqualTo(0)))
|
|
12306
12421
|
});
|
|
12307
|
-
var DeleteInput =
|
|
12308
|
-
var ListInput =
|
|
12309
|
-
prefix:
|
|
12310
|
-
after_key:
|
|
12311
|
-
limit:
|
|
12422
|
+
var DeleteInput = Schema63.Struct({ key: exports_shared_schema.NonEmptyString, expected_version: Schema63.optionalKey(Schema63.Int) });
|
|
12423
|
+
var ListInput = Schema63.Struct({
|
|
12424
|
+
prefix: Schema63.optionalKey(Schema63.String),
|
|
12425
|
+
after_key: Schema63.optionalKey(Schema63.String),
|
|
12426
|
+
limit: Schema63.optionalKey(Schema63.Int)
|
|
12312
12427
|
});
|
|
12313
|
-
var RecordOutput =
|
|
12428
|
+
var RecordOutput = Schema63.Struct({
|
|
12314
12429
|
execution_id: exports_state_schema.StateRecordView.fields.execution_id,
|
|
12315
12430
|
key: exports_state_schema.StateRecordView.fields.key,
|
|
12316
12431
|
value: exports_state_schema.StateRecordView.fields.value,
|
|
@@ -12318,8 +12433,8 @@ var RecordOutput = Schema62.Struct({
|
|
|
12318
12433
|
created_at: exports_state_schema.StateRecordView.fields.created_at,
|
|
12319
12434
|
updated_at: exports_state_schema.StateRecordView.fields.updated_at
|
|
12320
12435
|
});
|
|
12321
|
-
var PutOutput =
|
|
12322
|
-
var DeleteOutput =
|
|
12436
|
+
var PutOutput = Schema63.Struct({ key: exports_state_schema.StateKey, version: exports_state_schema.StateVersion });
|
|
12437
|
+
var DeleteOutput = Schema63.Struct({ deleted: Schema63.Boolean, version: Schema63.optionalKey(Schema63.Int) });
|
|
12323
12438
|
var enabled2 = (agent) => agent.metadata?.state_enabled === true;
|
|
12324
12439
|
var mapStateError = (toolName3) => (error5) => ToolExecutionFailed.make({ tool_name: toolName3, message: error5._tag });
|
|
12325
12440
|
var registeredTools2 = (state) => [
|
|
@@ -12360,7 +12475,7 @@ var registeredTools2 = (state) => [
|
|
|
12360
12475
|
tool("state_list", {
|
|
12361
12476
|
description: "List durable execution state",
|
|
12362
12477
|
input: ListInput,
|
|
12363
|
-
output:
|
|
12478
|
+
output: Schema63.Array(RecordOutput),
|
|
12364
12479
|
metadata: { relay_core_tool: true },
|
|
12365
12480
|
run: (input, context) => state.list({
|
|
12366
12481
|
executionId: context.executionId,
|
|
@@ -12537,7 +12652,8 @@ var make5 = Effect69.fn("RelaySessionStore.make")(function* (sessionId, entrySco
|
|
|
12537
12652
|
parentId: current2.leaf,
|
|
12538
12653
|
input: toAppendInput(input),
|
|
12539
12654
|
createdAt: now,
|
|
12540
|
-
...expectedLeafId === undefined ? {} : { expectedLeafId: expectedLeafId === null ? null : entryId(expectedLeafId) }
|
|
12655
|
+
...expectedLeafId === undefined ? {} : { expectedLeafId: expectedLeafId === null ? null : entryId(expectedLeafId) },
|
|
12656
|
+
...makeOptions?.writer === undefined ? {} : { expectedWriter: makeOptions.writer }
|
|
12541
12657
|
}).pipe(Effect69.mapError(mapWriteError));
|
|
12542
12658
|
yield* Ref14.set(state, { leaf: entry.id, next: current2.next + 1 });
|
|
12543
12659
|
return entry;
|
|
@@ -12571,7 +12687,8 @@ var make5 = Effect69.fn("RelaySessionStore.make")(function* (sessionId, entrySco
|
|
|
12571
12687
|
parentId: checkpoint.parentId === null ? null : entryId(checkpoint.parentId),
|
|
12572
12688
|
projectedHistory: checkpoint.projectedHistory,
|
|
12573
12689
|
...checkpoint.summary === undefined ? {} : { summary: checkpoint.summary },
|
|
12574
|
-
createdAt: now
|
|
12690
|
+
createdAt: now,
|
|
12691
|
+
...makeOptions?.writer === undefined ? {} : { expectedWriter: makeOptions.writer }
|
|
12575
12692
|
}).pipe(Effect69.mapError(mapWriteError));
|
|
12576
12693
|
const current2 = yield* Ref14.get(state);
|
|
12577
12694
|
if (current2 === undefined) {
|
|
@@ -12619,43 +12736,43 @@ var layer43 = Function13.dual((args) => typeof args[0] === "string" && String(ar
|
|
|
12619
12736
|
var memoryLayer39 = Function13.dual((args) => typeof args[0] === "string" && String(args[0]).startsWith("session:"), (sessionId, entryScope = "default") => layer43(sessionId, entryScope).pipe(Layer56.provide(exports_session_repository.memoryLayer)));
|
|
12620
12737
|
|
|
12621
12738
|
// ../runtime/src/inbox/inbox-service.ts
|
|
12622
|
-
import { Clock as Clock12, Context as Context61, Effect as Effect81, Layer as Layer67, Schema as
|
|
12739
|
+
import { Clock as Clock12, Context as Context61, Effect as Effect81, Layer as Layer67, Schema as Schema75 } from "effect";
|
|
12623
12740
|
|
|
12624
12741
|
// ../runtime/src/wait/wait-signal.ts
|
|
12625
|
-
import { Effect as Effect80, Schema as
|
|
12742
|
+
import { Effect as Effect80, Schema as Schema74 } from "effect";
|
|
12626
12743
|
|
|
12627
12744
|
// ../runtime/src/workflow/execution-workflow.ts
|
|
12628
12745
|
import { Activity, DurableDeferred, Workflow as Workflow2, WorkflowEngine } from "effect/unstable/workflow";
|
|
12629
|
-
import { Cause, Effect as Effect79, Exit, Function as Function14, Layer as Layer66, Option as Option20, Schema as
|
|
12746
|
+
import { Cause, Effect as Effect79, Exit, Function as Function14, Layer as Layer66, Option as Option20, Schema as Schema73 } from "effect";
|
|
12630
12747
|
|
|
12631
12748
|
// ../runtime/src/address/address-resolution-service.ts
|
|
12632
|
-
import { Context as Context53, Effect as Effect71, Layer as Layer58, Schema as
|
|
12749
|
+
import { Context as Context53, Effect as Effect71, Layer as Layer58, Schema as Schema65 } from "effect";
|
|
12633
12750
|
|
|
12634
12751
|
// ../runtime/src/address/address-book-service.ts
|
|
12635
|
-
import { Context as Context52, Effect as Effect70, Layer as Layer57, Ref as Ref15, Schema as
|
|
12752
|
+
import { Context as Context52, Effect as Effect70, Layer as Layer57, Ref as Ref15, Schema as Schema64 } from "effect";
|
|
12636
12753
|
var RouteKind2 = exports_address_schema.RouteKind;
|
|
12637
12754
|
var Route = exports_address_schema.Route;
|
|
12638
12755
|
var RouteRecord = exports_address_schema.RouteRecord;
|
|
12639
12756
|
|
|
12640
|
-
class AddressNotFound2 extends
|
|
12757
|
+
class AddressNotFound2 extends Schema64.TaggedErrorClass()("AddressNotFound", {
|
|
12641
12758
|
address_id: exports_ids_schema.AddressId
|
|
12642
12759
|
}) {
|
|
12643
12760
|
}
|
|
12644
12761
|
|
|
12645
|
-
class AddressUnavailable extends
|
|
12762
|
+
class AddressUnavailable extends Schema64.TaggedErrorClass()("AddressUnavailable", {
|
|
12646
12763
|
address_id: exports_ids_schema.AddressId,
|
|
12647
|
-
route_key:
|
|
12764
|
+
route_key: Schema64.String
|
|
12648
12765
|
}) {
|
|
12649
12766
|
}
|
|
12650
12767
|
|
|
12651
|
-
class AddressDeferred extends
|
|
12768
|
+
class AddressDeferred extends Schema64.TaggedErrorClass()("AddressDeferred", {
|
|
12652
12769
|
address_id: exports_ids_schema.AddressId,
|
|
12653
|
-
route_key:
|
|
12770
|
+
route_key: Schema64.String
|
|
12654
12771
|
}) {
|
|
12655
12772
|
}
|
|
12656
12773
|
|
|
12657
|
-
class AddressBookServiceError extends
|
|
12658
|
-
message:
|
|
12774
|
+
class AddressBookServiceError extends Schema64.TaggedErrorClass()("AddressBookServiceError", {
|
|
12775
|
+
message: Schema64.String
|
|
12659
12776
|
}) {
|
|
12660
12777
|
}
|
|
12661
12778
|
|
|
@@ -12683,7 +12800,7 @@ var recordFromEntry = (entry) => ({
|
|
|
12683
12800
|
updated_at: entry.updatedAt
|
|
12684
12801
|
});
|
|
12685
12802
|
var entryIdFor = (addressId) => exports_ids_schema.AddressBookEntryId.make(`address-book:${addressId}`);
|
|
12686
|
-
var validateRoute = (route) =>
|
|
12803
|
+
var validateRoute = (route) => Schema64.decodeUnknownEffect(Route)(route).pipe(Effect70.mapError((error5) => AddressBookServiceError.make({ message: String(error5) })));
|
|
12687
12804
|
var mapRepositoryError5 = (error5) => {
|
|
12688
12805
|
if (error5._tag === "AddressNotFound") {
|
|
12689
12806
|
return AddressNotFound2.make({ address_id: error5.address_id });
|
|
@@ -12748,41 +12865,41 @@ var list14 = Effect70.fn("AddressBook.list.call")(function* () {
|
|
|
12748
12865
|
});
|
|
12749
12866
|
|
|
12750
12867
|
// ../runtime/src/address/address-resolution-service.ts
|
|
12751
|
-
class AddressRouteNotFound extends
|
|
12868
|
+
class AddressRouteNotFound extends Schema65.TaggedErrorClass()("AddressRouteNotFound", {
|
|
12752
12869
|
address_id: exports_ids_schema.AddressId
|
|
12753
12870
|
}) {
|
|
12754
12871
|
}
|
|
12755
12872
|
|
|
12756
|
-
class AddressRouteKindMismatch extends
|
|
12873
|
+
class AddressRouteKindMismatch extends Schema65.TaggedErrorClass()("AddressRouteKindMismatch", {
|
|
12757
12874
|
address_id: exports_ids_schema.AddressId,
|
|
12758
|
-
expected:
|
|
12875
|
+
expected: Schema65.Literal("local-agent"),
|
|
12759
12876
|
actual: exports_address_schema.RouteKind,
|
|
12760
|
-
route_key:
|
|
12877
|
+
route_key: Schema65.String
|
|
12761
12878
|
}) {
|
|
12762
12879
|
}
|
|
12763
12880
|
|
|
12764
|
-
class AddressAgentDefinitionNotFound extends
|
|
12881
|
+
class AddressAgentDefinitionNotFound extends Schema65.TaggedErrorClass()("AddressAgentDefinitionNotFound", {
|
|
12765
12882
|
address_id: exports_ids_schema.AddressId,
|
|
12766
12883
|
agent_id: exports_ids_schema.AgentId
|
|
12767
12884
|
}) {
|
|
12768
12885
|
}
|
|
12769
12886
|
|
|
12770
|
-
class AddressResolutionError extends
|
|
12771
|
-
message:
|
|
12887
|
+
class AddressResolutionError extends Schema65.TaggedErrorClass()("AddressResolutionError", {
|
|
12888
|
+
message: Schema65.String
|
|
12772
12889
|
}) {
|
|
12773
12890
|
}
|
|
12774
|
-
var LocalAgentRoute =
|
|
12775
|
-
kind:
|
|
12891
|
+
var LocalAgentRoute = Schema65.Struct({
|
|
12892
|
+
kind: Schema65.Literal("local-agent"),
|
|
12776
12893
|
route_key: exports_shared_schema.NonEmptyString,
|
|
12777
|
-
metadata:
|
|
12894
|
+
metadata: Schema65.optionalKey(exports_shared_schema.Metadata)
|
|
12778
12895
|
}).annotate({ identifier: "Relay.AddressResolution.LocalAgentRoute" });
|
|
12779
|
-
var LocalAgentTarget =
|
|
12896
|
+
var LocalAgentTarget = Schema65.Struct({
|
|
12780
12897
|
address_id: exports_ids_schema.AddressId,
|
|
12781
12898
|
route: LocalAgentRoute,
|
|
12782
12899
|
agent_id: exports_ids_schema.AgentId,
|
|
12783
12900
|
agent_revision: exports_agent_schema.DefinitionRevision,
|
|
12784
12901
|
agent_snapshot: exports_agent_schema.Definition,
|
|
12785
|
-
tool_input_schema_digests:
|
|
12902
|
+
tool_input_schema_digests: Schema65.optionalKey(exports_agent_schema.ToolInputSchemaDigests)
|
|
12786
12903
|
}).annotate({ identifier: "Relay.AddressResolution.LocalAgentTarget" });
|
|
12787
12904
|
|
|
12788
12905
|
class Service53 extends Context53.Service()("@relayfx/runtime/address/address-resolution-service/Service") {
|
|
@@ -12815,7 +12932,7 @@ var layer44 = Layer58.effect(Service53, Effect71.gen(function* () {
|
|
|
12815
12932
|
return yield* AddressRouteNotFound.make({ address_id: addressId });
|
|
12816
12933
|
}
|
|
12817
12934
|
const route = yield* routeToLocalAgent(addressId, record2.route);
|
|
12818
|
-
const agentId = yield*
|
|
12935
|
+
const agentId = yield* Schema65.decodeUnknownEffect(exports_ids_schema.AgentId)(route.route_key).pipe(Effect71.mapError((error5) => AddressResolutionError.make({ message: String(error5) })));
|
|
12819
12936
|
const definition = yield* agentRegistry.get(agentId).pipe(Effect71.mapError(mapAgentRegistryError));
|
|
12820
12937
|
if (definition === undefined) {
|
|
12821
12938
|
return yield* AddressAgentDefinitionNotFound.make({
|
|
@@ -12844,13 +12961,13 @@ var resolveLocalAgent = Effect71.fn("AddressResolution.resolveLocalAgent.call")(
|
|
|
12844
12961
|
});
|
|
12845
12962
|
|
|
12846
12963
|
// ../runtime/src/agent/agent-loop-error.ts
|
|
12847
|
-
import { Schema as
|
|
12964
|
+
import { Schema as Schema66 } from "effect";
|
|
12848
12965
|
import { AiError as AiError2 } from "effect/unstable/ai";
|
|
12849
12966
|
|
|
12850
|
-
class AgentLoopError extends
|
|
12851
|
-
message:
|
|
12852
|
-
failure_classification:
|
|
12853
|
-
baton_failure:
|
|
12967
|
+
class AgentLoopError extends Schema66.TaggedErrorClass()("AgentLoopError", {
|
|
12968
|
+
message: Schema66.String,
|
|
12969
|
+
failure_classification: Schema66.optionalKey(Schema66.Literal("context-overflow")),
|
|
12970
|
+
baton_failure: Schema66.optionalKey(Schema66.Union([
|
|
12854
12971
|
exports_agent_event.AgentError,
|
|
12855
12972
|
exports_agent_event.ResumeMismatch,
|
|
12856
12973
|
exports_turn_policy.TurnPolicyError,
|
|
@@ -12858,31 +12975,31 @@ class AgentLoopError extends Schema65.TaggedErrorClass()("AgentLoopError", {
|
|
|
12858
12975
|
exports_agent_event.TurnLimitExceeded,
|
|
12859
12976
|
exports_agent_event.MiddlewareViolation,
|
|
12860
12977
|
exports_agent_event.DuplicateToolCallId,
|
|
12861
|
-
exports_agent_event.
|
|
12978
|
+
exports_agent_event.ProgressOverflow,
|
|
12862
12979
|
exports_agent_event.ToolNameCollision,
|
|
12863
12980
|
AiError2.AiError,
|
|
12864
12981
|
exports_model_registry.LanguageModelNotRegistered,
|
|
12865
12982
|
exports_tool_executor.FrameworkFailure
|
|
12866
12983
|
])),
|
|
12867
|
-
next_event_sequence:
|
|
12984
|
+
next_event_sequence: Schema66.optionalKey(exports_execution_schema.ExecutionEventSequence)
|
|
12868
12985
|
}) {
|
|
12869
12986
|
}
|
|
12870
12987
|
|
|
12871
|
-
class AgentLoopBudgetExceeded extends
|
|
12872
|
-
tokens_used:
|
|
12873
|
-
token_budget:
|
|
12988
|
+
class AgentLoopBudgetExceeded extends Schema66.TaggedErrorClass()("AgentLoopBudgetExceeded", {
|
|
12989
|
+
tokens_used: Schema66.Int,
|
|
12990
|
+
token_budget: Schema66.Int,
|
|
12874
12991
|
next_event_sequence: exports_execution_schema.ExecutionEventSequence
|
|
12875
12992
|
}) {
|
|
12876
12993
|
}
|
|
12877
|
-
var AgentTerminalFailure =
|
|
12994
|
+
var AgentTerminalFailure = Schema66.Union([AgentLoopError, AgentLoopBudgetExceeded]);
|
|
12878
12995
|
|
|
12879
12996
|
// ../runtime/src/child/parent-notifier-service.ts
|
|
12880
|
-
import { Context as Context54, Effect as Effect72, Layer as Layer59, Option as Option16, Ref as Ref16, Schema as
|
|
12881
|
-
class ParentNotifyError extends
|
|
12882
|
-
message:
|
|
12997
|
+
import { Context as Context54, Effect as Effect72, Layer as Layer59, Option as Option16, Ref as Ref16, Schema as Schema67 } from "effect";
|
|
12998
|
+
class ParentNotifyError extends Schema67.TaggedErrorClass()("ParentNotifyError", {
|
|
12999
|
+
message: Schema67.String
|
|
12883
13000
|
}) {
|
|
12884
13001
|
}
|
|
12885
|
-
var ChildTerminalStatus =
|
|
13002
|
+
var ChildTerminalStatus = Schema67.Literals(["completed", "failed", "cancelled"]).annotate({
|
|
12886
13003
|
identifier: "Relay.ParentNotifier.ChildTerminalStatus"
|
|
12887
13004
|
});
|
|
12888
13005
|
|
|
@@ -12963,15 +13080,15 @@ var notify = Effect72.fn("ParentNotifier.notify.call")(function* (input) {
|
|
|
12963
13080
|
});
|
|
12964
13081
|
|
|
12965
13082
|
// ../runtime/src/skill/skill-registry-service.ts
|
|
12966
|
-
import { Clock as Clock10, Context as Context55, Effect as Effect73, Layer as Layer60, Schema as
|
|
13083
|
+
import { Clock as Clock10, Context as Context55, Effect as Effect73, Layer as Layer60, Schema as Schema68 } from "effect";
|
|
12967
13084
|
|
|
12968
|
-
class SkillDefinitionInvalid extends
|
|
12969
|
-
message:
|
|
13085
|
+
class SkillDefinitionInvalid extends Schema68.TaggedErrorClass()("SkillDefinitionInvalid", {
|
|
13086
|
+
message: Schema68.String
|
|
12970
13087
|
}) {
|
|
12971
13088
|
}
|
|
12972
13089
|
|
|
12973
|
-
class SkillRegistryError extends
|
|
12974
|
-
message:
|
|
13090
|
+
class SkillRegistryError extends Schema68.TaggedErrorClass()("SkillRegistryError", {
|
|
13091
|
+
message: Schema68.String
|
|
12975
13092
|
}) {
|
|
12976
13093
|
}
|
|
12977
13094
|
|
|
@@ -13124,16 +13241,16 @@ var sourceForExecution = Effect73.fn("SkillRegistry.sourceForExecution.call")(fu
|
|
|
13124
13241
|
});
|
|
13125
13242
|
|
|
13126
13243
|
// ../runtime/src/execution/execution-service.ts
|
|
13127
|
-
import { Clock as Clock11, Context as Context56, Effect as Effect74, Layer as Layer61, Option as Option17, Schema as
|
|
13244
|
+
import { Clock as Clock11, Context as Context56, Effect as Effect74, Layer as Layer61, Option as Option17, Schema as Schema69, Stream as Stream12 } from "effect";
|
|
13128
13245
|
import { ShardingConfig } from "effect/unstable/cluster";
|
|
13129
13246
|
var ExecutionServiceErrorDetails = exports_shared_schema.JsonValue.annotate({
|
|
13130
13247
|
identifier: "Relay.ExecutionServiceErrorDetails"
|
|
13131
13248
|
});
|
|
13132
13249
|
|
|
13133
|
-
class ExecutionServiceError extends
|
|
13134
|
-
message:
|
|
13135
|
-
details:
|
|
13136
|
-
next_event_sequence:
|
|
13250
|
+
class ExecutionServiceError extends Schema69.TaggedErrorClass()("ExecutionServiceError", {
|
|
13251
|
+
message: Schema69.String,
|
|
13252
|
+
details: Schema69.optionalKey(ExecutionServiceErrorDetails),
|
|
13253
|
+
next_event_sequence: Schema69.optionalKey(exports_execution_schema.ExecutionEventSequence)
|
|
13137
13254
|
}) {
|
|
13138
13255
|
}
|
|
13139
13256
|
|
|
@@ -13268,6 +13385,37 @@ var failedEvent = (input, error5) => ({
|
|
|
13268
13385
|
created_at: input.completedAt
|
|
13269
13386
|
});
|
|
13270
13387
|
var terminalEvent2 = (events) => events.find((event) => event.type === "execution.completed" || event.type === "execution.failed");
|
|
13388
|
+
var terminalStatuses2 = new Set(["completed", "failed", "cancelled"]);
|
|
13389
|
+
var claimSessionWriter = Effect74.fn("ExecutionService.claimSessionWriter")(function* (sessions, repository, input) {
|
|
13390
|
+
if (input.sessionId === undefined)
|
|
13391
|
+
return;
|
|
13392
|
+
const sessionId = input.sessionId;
|
|
13393
|
+
const mapSessionError = (error5) => ExecutionServiceError.make({ message: error5.message });
|
|
13394
|
+
const claim = yield* sessions.claimWriter({ sessionId, executionId: input.executionId, now: input.createdAt }).pipe(Effect74.mapError(mapSessionError));
|
|
13395
|
+
if (claim._tag === "Claimed")
|
|
13396
|
+
return;
|
|
13397
|
+
const owner = yield* repository.get(claim.writer.executionId).pipe(Effect74.mapError(mapRepositoryError7));
|
|
13398
|
+
if (owner !== undefined && !terminalStatuses2.has(owner.status)) {
|
|
13399
|
+
return yield* ExecutionServiceError.make({
|
|
13400
|
+
message: `Session ${sessionId} is owned by execution ${claim.writer.executionId} at epoch ${claim.writer.epoch}`
|
|
13401
|
+
});
|
|
13402
|
+
}
|
|
13403
|
+
yield* sessions.releaseWriter({ sessionId, executionId: claim.writer.executionId, now: input.createdAt }).pipe(Effect74.mapError(mapSessionError));
|
|
13404
|
+
const seized = yield* sessions.claimWriter({ sessionId, executionId: input.executionId, now: input.createdAt }).pipe(Effect74.mapError(mapSessionError));
|
|
13405
|
+
if (seized._tag === "Busy") {
|
|
13406
|
+
return yield* ExecutionServiceError.make({
|
|
13407
|
+
message: `Session ${sessionId} is owned by execution ${seized.writer.executionId} at epoch ${seized.writer.epoch}`
|
|
13408
|
+
});
|
|
13409
|
+
}
|
|
13410
|
+
});
|
|
13411
|
+
var releaseSessionWriter = Effect74.fn("ExecutionService.releaseSessionWriter")(function* (sessions, execution, now) {
|
|
13412
|
+
if (Option17.isNone(sessions))
|
|
13413
|
+
return;
|
|
13414
|
+
const sessionId = execution.session_id;
|
|
13415
|
+
if (sessionId === undefined)
|
|
13416
|
+
return;
|
|
13417
|
+
yield* sessions.value.releaseWriter({ sessionId, executionId: execution.id, now }).pipe(Effect74.ignore);
|
|
13418
|
+
});
|
|
13271
13419
|
var existingTerminalExecution = Effect74.fn("ExecutionService.existingTerminalExecution")(function* (repository, eventLog, input) {
|
|
13272
13420
|
const events = yield* eventLog.replay({ executionId: input.executionId }).pipe(Effect74.mapError(mapEventLogError4));
|
|
13273
13421
|
const event = terminalEvent2(events);
|
|
@@ -13283,7 +13431,7 @@ var existingTerminalExecution = Effect74.fn("ExecutionService.existingTerminalEx
|
|
|
13283
13431
|
execution: undefined,
|
|
13284
13432
|
failure: ExecutionServiceError.make({
|
|
13285
13433
|
message: typeof metadata11.message === "string" ? metadata11.message : "Execution failed",
|
|
13286
|
-
...
|
|
13434
|
+
...Schema69.is(ExecutionServiceErrorDetails)(metadata11.details) ? { details: metadata11.details } : {},
|
|
13287
13435
|
next_event_sequence: event.sequence
|
|
13288
13436
|
})
|
|
13289
13437
|
};
|
|
@@ -13326,6 +13474,7 @@ var layer46 = Layer61.effect(Service56, Effect74.gen(function* () {
|
|
|
13326
13474
|
rootAddressId: input.rootAddressId,
|
|
13327
13475
|
now: input.createdAt
|
|
13328
13476
|
}).pipe(Effect74.mapError((error5) => ExecutionServiceError.make({ message: error5.message })));
|
|
13477
|
+
yield* claimSessionWriter(sessions.value, repository, input);
|
|
13329
13478
|
}
|
|
13330
13479
|
const record2 = yield* repository.create({
|
|
13331
13480
|
id: input.executionId,
|
|
@@ -13361,6 +13510,7 @@ var layer46 = Layer61.effect(Service56, Effect74.gen(function* () {
|
|
|
13361
13510
|
if (failedExecution.status !== "failed")
|
|
13362
13511
|
return failedExecution;
|
|
13363
13512
|
yield* appendIdempotentTo(eventLog, failedEvent(input, error5)).pipe(Effect74.mapError(mapEventLogError4));
|
|
13513
|
+
yield* releaseSessionWriter(sessions, failedExecution, input.completedAt);
|
|
13364
13514
|
yield* recordExecutionFinished("failed");
|
|
13365
13515
|
yield* recordExecutionDuration("failed", failedExecution.updated_at - failedExecution.created_at);
|
|
13366
13516
|
return yield* error5;
|
|
@@ -13376,6 +13526,7 @@ var layer46 = Layer61.effect(Service56, Effect74.gen(function* () {
|
|
|
13376
13526
|
if (execution.status !== "completed")
|
|
13377
13527
|
return execution;
|
|
13378
13528
|
yield* appendIdempotentTo(eventLog, completedEvent(input, resultMetadata, completedSequence)).pipe(Effect74.mapError(mapEventLogError4));
|
|
13529
|
+
yield* releaseSessionWriter(sessions, execution, input.completedAt);
|
|
13379
13530
|
yield* recordExecutionFinished("completed");
|
|
13380
13531
|
yield* recordExecutionDuration("completed", execution.updated_at - execution.created_at);
|
|
13381
13532
|
return execution;
|
|
@@ -13392,6 +13543,7 @@ var layer46 = Layer61.effect(Service56, Effect74.gen(function* () {
|
|
|
13392
13543
|
if (execution.status !== "cancelled")
|
|
13393
13544
|
return execution;
|
|
13394
13545
|
yield* appendIdempotentTo(eventLog, cancelledEvent(input)).pipe(Effect74.mapError(mapEventLogError4));
|
|
13546
|
+
yield* releaseSessionWriter(sessions, execution, input.cancelledAt);
|
|
13395
13547
|
yield* recordExecutionFinished("cancelled");
|
|
13396
13548
|
yield* recordExecutionDuration("cancelled", execution.updated_at - execution.created_at);
|
|
13397
13549
|
return execution;
|
|
@@ -13473,18 +13625,25 @@ var layer47 = Layer62.effect(Service57, Effect75.gen(function* () {
|
|
|
13473
13625
|
return Service57.of({
|
|
13474
13626
|
run: (executionId, effect) => Effect75.gen(function* () {
|
|
13475
13627
|
const signal = yield* Deferred2.make();
|
|
13476
|
-
|
|
13628
|
+
const done = yield* Deferred2.make();
|
|
13629
|
+
const entry = { signal, done };
|
|
13630
|
+
yield* Ref17.update(active, (entries) => new Map(entries).set(executionId, entry));
|
|
13477
13631
|
const interrupted = Deferred2.await(signal).pipe(Effect75.andThen(() => Effect75.interrupt));
|
|
13478
13632
|
return yield* Effect75.raceFirst(effect, interrupted).pipe(Effect75.ensuring(Ref17.update(active, (entries) => {
|
|
13479
13633
|
const next = new Map(entries);
|
|
13480
|
-
if (next.get(executionId) ===
|
|
13634
|
+
if (next.get(executionId) === entry)
|
|
13481
13635
|
next.delete(executionId);
|
|
13482
13636
|
return next;
|
|
13483
|
-
})));
|
|
13637
|
+
}).pipe(Effect75.andThen(Deferred2.succeed(done, undefined)))));
|
|
13484
13638
|
}),
|
|
13485
13639
|
interrupt: Effect75.fn("ActiveExecutionRegistry.interrupt")(function* (executionId) {
|
|
13486
|
-
const
|
|
13487
|
-
return
|
|
13640
|
+
const entry = yield* Ref17.get(active).pipe(Effect75.map((entries) => entries.get(executionId)));
|
|
13641
|
+
return entry === undefined ? false : yield* Deferred2.succeed(entry.signal, undefined);
|
|
13642
|
+
}),
|
|
13643
|
+
awaitQuiescent: Effect75.fn("ActiveExecutionRegistry.awaitQuiescent")(function* (executionId) {
|
|
13644
|
+
const entry = yield* Ref17.get(active).pipe(Effect75.map((entries) => entries.get(executionId)));
|
|
13645
|
+
if (entry !== undefined)
|
|
13646
|
+
yield* Deferred2.await(entry.done);
|
|
13488
13647
|
})
|
|
13489
13648
|
});
|
|
13490
13649
|
}));
|
|
@@ -13515,13 +13674,13 @@ var coordinate = Effect76.fn("ToolTransitionCoordinator.coordinate")(function* (
|
|
|
13515
13674
|
});
|
|
13516
13675
|
|
|
13517
13676
|
// ../runtime/src/workspace/workspace-planner-service.ts
|
|
13518
|
-
import { Context as Context60, Effect as Effect78, HashSet as HashSet6, Layer as Layer65, Option as Option18, Schema as
|
|
13677
|
+
import { Context as Context60, Effect as Effect78, HashSet as HashSet6, Layer as Layer65, Option as Option18, Schema as Schema71 } from "effect";
|
|
13519
13678
|
|
|
13520
13679
|
// ../runtime/src/workspace/workspace-runtime-service.ts
|
|
13521
|
-
import { Context as Context59, Effect as Effect77, Layer as Layer64, Schema as
|
|
13680
|
+
import { Context as Context59, Effect as Effect77, Layer as Layer64, Schema as Schema70 } from "effect";
|
|
13522
13681
|
|
|
13523
|
-
class WorkspaceRuntimeError extends
|
|
13524
|
-
message:
|
|
13682
|
+
class WorkspaceRuntimeError extends Schema70.TaggedErrorClass()("WorkspaceRuntimeError", {
|
|
13683
|
+
message: Schema70.String
|
|
13525
13684
|
}) {
|
|
13526
13685
|
}
|
|
13527
13686
|
|
|
@@ -13549,18 +13708,18 @@ var exec = Effect77.fn("WorkspaceRuntime.exec.call")(function* (input) {
|
|
|
13549
13708
|
});
|
|
13550
13709
|
|
|
13551
13710
|
// ../runtime/src/workspace/workspace-planner-service.ts
|
|
13552
|
-
class WorkspaceRuntimeMissing extends
|
|
13711
|
+
class WorkspaceRuntimeMissing extends Schema71.TaggedErrorClass()("WorkspaceRuntimeMissing", {
|
|
13553
13712
|
execution_id: exports_ids_schema.ExecutionId
|
|
13554
13713
|
}) {
|
|
13555
13714
|
}
|
|
13556
13715
|
|
|
13557
|
-
class WorkspaceLeaseMissingRef extends
|
|
13716
|
+
class WorkspaceLeaseMissingRef extends Schema71.TaggedErrorClass()("WorkspaceLeaseMissingRef", {
|
|
13558
13717
|
execution_id: exports_ids_schema.ExecutionId
|
|
13559
13718
|
}) {
|
|
13560
13719
|
}
|
|
13561
13720
|
|
|
13562
|
-
class WorkspacePlannerError extends
|
|
13563
|
-
message:
|
|
13721
|
+
class WorkspacePlannerError extends Schema71.TaggedErrorClass()("WorkspacePlannerError", {
|
|
13722
|
+
message: Schema71.String
|
|
13564
13723
|
}) {
|
|
13565
13724
|
}
|
|
13566
13725
|
|
|
@@ -13746,7 +13905,7 @@ var fail = Effect78.fn("WorkspacePlanner.fail.call")(function* (input) {
|
|
|
13746
13905
|
});
|
|
13747
13906
|
|
|
13748
13907
|
// ../runtime/src/workflow/execution-workflow-state.ts
|
|
13749
|
-
import { Option as Option19, Schema as
|
|
13908
|
+
import { Option as Option19, Schema as Schema72 } from "effect";
|
|
13750
13909
|
var toWaitSnapshot = (record2) => ({
|
|
13751
13910
|
id: record2.id,
|
|
13752
13911
|
execution_id: record2.executionId,
|
|
@@ -13814,7 +13973,7 @@ var waitIdFromExecution = (execution) => {
|
|
|
13814
13973
|
};
|
|
13815
13974
|
var pendingSuspensionFromExecution = (execution) => {
|
|
13816
13975
|
const pending = execution.metadata?.pending_agent_suspension;
|
|
13817
|
-
return
|
|
13976
|
+
return Schema72.decodeUnknownOption(exports_agent_event.AgentSuspended)(pending).pipe(Option19.getOrUndefined);
|
|
13818
13977
|
};
|
|
13819
13978
|
var ExecutionWorkflowState = {
|
|
13820
13979
|
agentDefinitionPinCount,
|
|
@@ -13855,74 +14014,74 @@ var {
|
|
|
13855
14014
|
workflowGenerationFromRecord: workflowGenerationFromRecord2
|
|
13856
14015
|
} = ExecutionWorkflowState;
|
|
13857
14016
|
|
|
13858
|
-
class ExecutionWorkflowFailed extends
|
|
13859
|
-
message:
|
|
13860
|
-
terminal_failure:
|
|
14017
|
+
class ExecutionWorkflowFailed extends Schema73.TaggedErrorClass()("ExecutionWorkflowFailed", {
|
|
14018
|
+
message: Schema73.String,
|
|
14019
|
+
terminal_failure: Schema73.optionalKey(AgentTerminalFailure)
|
|
13861
14020
|
}) {
|
|
13862
14021
|
}
|
|
13863
14022
|
|
|
13864
|
-
class AgentCheckpointCompatibilityError extends
|
|
13865
|
-
message:
|
|
14023
|
+
class AgentCheckpointCompatibilityError extends Schema73.TaggedErrorClass()("AgentCheckpointCompatibilityError", {
|
|
14024
|
+
message: Schema73.String
|
|
13866
14025
|
}) {
|
|
13867
14026
|
}
|
|
13868
|
-
var ExecutionWorkflowError =
|
|
13869
|
-
var StartInput =
|
|
14027
|
+
var ExecutionWorkflowError = Schema73.Union([ExecutionWorkflowFailed, AgentCheckpointCompatibilityError]);
|
|
14028
|
+
var StartInput = Schema73.Struct({
|
|
13870
14029
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13871
14030
|
root_address_id: exports_ids_schema.AddressId,
|
|
13872
|
-
session_id:
|
|
13873
|
-
input:
|
|
14031
|
+
session_id: Schema73.optionalKey(exports_ids_schema.SessionId),
|
|
14032
|
+
input: Schema73.optionalKey(Schema73.Array(exports_content_schema.Part)),
|
|
13874
14033
|
event_sequence: exports_execution_schema.ExecutionEventSequence,
|
|
13875
14034
|
started_at: exports_shared_schema.TimestampMillis,
|
|
13876
14035
|
completed_at: exports_shared_schema.TimestampMillis,
|
|
13877
|
-
agent_id:
|
|
13878
|
-
agent_revision:
|
|
13879
|
-
agent_snapshot:
|
|
13880
|
-
agent_tool_input_schema_digests:
|
|
13881
|
-
wait_id:
|
|
13882
|
-
resume_suspension:
|
|
13883
|
-
workflow_generation:
|
|
13884
|
-
metadata:
|
|
14036
|
+
agent_id: Schema73.optionalKey(exports_ids_schema.AgentId),
|
|
14037
|
+
agent_revision: Schema73.optionalKey(exports_agent_schema.DefinitionRevision),
|
|
14038
|
+
agent_snapshot: Schema73.optionalKey(exports_agent_schema.Definition),
|
|
14039
|
+
agent_tool_input_schema_digests: Schema73.optionalKey(exports_agent_schema.ToolInputSchemaDigests),
|
|
14040
|
+
wait_id: Schema73.optionalKey(exports_ids_schema.WaitId),
|
|
14041
|
+
resume_suspension: Schema73.optionalKey(exports_agent_event.AgentSuspended),
|
|
14042
|
+
workflow_generation: Schema73.optionalKey(Schema73.Int.check(Schema73.isGreaterThanOrEqualTo(0))),
|
|
14043
|
+
metadata: Schema73.optionalKey(exports_shared_schema.Metadata)
|
|
13885
14044
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.StartInput" });
|
|
13886
|
-
var WaitSignalState =
|
|
14045
|
+
var WaitSignalState = Schema73.Literals(["resolved", "timed_out", "cancelled"]).annotate({
|
|
13887
14046
|
identifier: "Relay.ExecutionWorkflow.WaitSignalState"
|
|
13888
14047
|
});
|
|
13889
|
-
var WaitSignal =
|
|
14048
|
+
var WaitSignal = Schema73.Struct({
|
|
13890
14049
|
wait_id: exports_ids_schema.WaitId,
|
|
13891
14050
|
state: WaitSignalState,
|
|
13892
14051
|
signaled_at: exports_shared_schema.TimestampMillis
|
|
13893
14052
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.WaitSignal" });
|
|
13894
|
-
var SignalWaitInput =
|
|
13895
|
-
workflow_execution_id:
|
|
14053
|
+
var SignalWaitInput = Schema73.Struct({
|
|
14054
|
+
workflow_execution_id: Schema73.String,
|
|
13896
14055
|
wait_id: exports_ids_schema.WaitId,
|
|
13897
14056
|
state: WaitSignalState,
|
|
13898
14057
|
signaled_at: exports_shared_schema.TimestampMillis
|
|
13899
14058
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.SignalWaitInput" });
|
|
13900
|
-
var CancelExecutionInput =
|
|
14059
|
+
var CancelExecutionInput = Schema73.Struct({
|
|
13901
14060
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13902
14061
|
cancelled_at: exports_shared_schema.TimestampMillis,
|
|
13903
|
-
reason:
|
|
14062
|
+
reason: Schema73.optionalKey(Schema73.String)
|
|
13904
14063
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.CancelExecutionInput" });
|
|
13905
|
-
var CancelExecutionResult =
|
|
14064
|
+
var CancelExecutionResult = Schema73.Struct({
|
|
13906
14065
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13907
14066
|
status: exports_execution_schema.ExecutionStatus
|
|
13908
14067
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.CancelExecutionResult" });
|
|
13909
|
-
var WaitSnapshot =
|
|
14068
|
+
var WaitSnapshot = Schema73.Struct({
|
|
13910
14069
|
id: exports_ids_schema.WaitId,
|
|
13911
14070
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13912
|
-
envelope_id:
|
|
14071
|
+
envelope_id: Schema73.optionalKey(exports_ids_schema.EnvelopeId),
|
|
13913
14072
|
mode: exports_envelope_schema.WaitMode,
|
|
13914
|
-
correlation_key:
|
|
13915
|
-
state:
|
|
14073
|
+
correlation_key: Schema73.optionalKey(Schema73.String),
|
|
14074
|
+
state: Schema73.Literals(["open", "resolved", "timed_out", "cancelled"]),
|
|
13916
14075
|
metadata: exports_shared_schema.Metadata,
|
|
13917
14076
|
created_at: exports_shared_schema.TimestampMillis,
|
|
13918
|
-
resolved_at:
|
|
14077
|
+
resolved_at: Schema73.optionalKey(exports_shared_schema.TimestampMillis)
|
|
13919
14078
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.WaitSnapshot" });
|
|
13920
|
-
var StartResult =
|
|
14079
|
+
var StartResult = Schema73.Struct({
|
|
13921
14080
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13922
14081
|
status: exports_execution_schema.ExecutionStatus,
|
|
13923
|
-
wait_id:
|
|
13924
|
-
wait_state:
|
|
13925
|
-
metadata:
|
|
14082
|
+
wait_id: Schema73.optionalKey(exports_ids_schema.WaitId),
|
|
14083
|
+
wait_state: Schema73.optionalKey(Schema73.Literals(["resolved", "timed_out", "cancelled"])),
|
|
14084
|
+
metadata: Schema73.optionalKey(exports_shared_schema.Metadata)
|
|
13926
14085
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.StartResult" });
|
|
13927
14086
|
var StartExecutionWorkflowName = "Relay/Execution/Start";
|
|
13928
14087
|
var ActivityNames = {
|
|
@@ -13970,12 +14129,12 @@ var StartExecutionWorkflow = Workflow2.make(StartExecutionWorkflowName, {
|
|
|
13970
14129
|
var mapExecutionError = (error5) => {
|
|
13971
14130
|
if (error5.details === undefined)
|
|
13972
14131
|
return ExecutionWorkflowFailed.make({ message: error5.message });
|
|
13973
|
-
const terminalFailure =
|
|
14132
|
+
const terminalFailure = Schema73.decodeUnknownOption(AgentTerminalFailure)(error5.details).pipe(Option20.getOrUndefined);
|
|
13974
14133
|
return terminalFailure === undefined ? ExecutionWorkflowFailed.make({ message: "Malformed durable agent failure details" }) : ExecutionWorkflowFailed.make({ message: error5.message, terminal_failure: terminalFailure });
|
|
13975
14134
|
};
|
|
13976
14135
|
var mapAgentLoopError = (error5) => ExecutionServiceError.make({
|
|
13977
14136
|
message: error5._tag === "AgentLoopBudgetExceeded" ? `AgentLoopBudgetExceeded: used ${error5.tokens_used} of ${error5.token_budget} tokens` : error5.message,
|
|
13978
|
-
details: error5.pipe(
|
|
14137
|
+
details: error5.pipe(Schema73.encodeSync(AgentTerminalFailure), Schema73.decodeUnknownSync(exports_shared_schema.JsonValue)),
|
|
13979
14138
|
...error5.next_event_sequence === undefined ? {} : { next_event_sequence: error5.next_event_sequence }
|
|
13980
14139
|
});
|
|
13981
14140
|
var mapWaitError2 = (error5) => ExecutionWorkflowFailed.make({
|
|
@@ -14124,7 +14283,7 @@ var prepareCancellation = Effect79.fn("ExecutionWorkflow.prepareCancellation")(f
|
|
|
14124
14283
|
signals,
|
|
14125
14284
|
terminalNoop: false
|
|
14126
14285
|
};
|
|
14127
|
-
})).pipe(Effect79.mapError((error5) =>
|
|
14286
|
+
})).pipe(Effect79.mapError((error5) => Schema73.is(ExecutionWorkflowFailed)(error5) ? error5 : ExecutionWorkflowFailed.make({ message: "Tool cancellation transaction failed" })));
|
|
14128
14287
|
});
|
|
14129
14288
|
var signalPreparedCancellation = Effect79.fn("ExecutionWorkflow.signalPreparedCancellation")(function* (prepared, signaledAt) {
|
|
14130
14289
|
for (const pending of prepared.signals) {
|
|
@@ -14149,23 +14308,39 @@ var cancelChildExecution = Effect79.fn("ExecutionWorkflow.cancelChildExecution")
|
|
|
14149
14308
|
reason: childCancelReason
|
|
14150
14309
|
});
|
|
14151
14310
|
yield* signalPreparedCancellation(prepared, cancelledAt);
|
|
14311
|
+
const activeExecutions = yield* Effect79.serviceOption(Service57);
|
|
14312
|
+
if (Option20.isSome(activeExecutions)) {
|
|
14313
|
+
yield* activeExecutions.value.interrupt(executionId);
|
|
14314
|
+
yield* activeExecutions.value.awaitQuiescent(executionId);
|
|
14315
|
+
}
|
|
14152
14316
|
});
|
|
14153
14317
|
var cancelOpenChildren = Effect79.fn("ExecutionWorkflow.cancelOpenChildren")(function* (executionId, cancelledAt) {
|
|
14154
|
-
const
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14160
|
-
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
|
|
14318
|
+
const pending = [executionId];
|
|
14319
|
+
const seen = new Set([executionId]);
|
|
14320
|
+
while (pending.length > 0) {
|
|
14321
|
+
const current2 = pending.shift();
|
|
14322
|
+
const children = yield* exports_child_execution_repository.listByExecution(current2).pipe(Effect79.mapError(mapChildExecutionRepositoryError));
|
|
14323
|
+
yield* Effect79.forEach(children.filter((child) => openChildStatuses.has(child.status)), (child) => Effect79.gen(function* () {
|
|
14324
|
+
yield* exports_child_execution_repository.updateStatus({
|
|
14325
|
+
id: child.id,
|
|
14326
|
+
status: "cancelled",
|
|
14327
|
+
updatedAt: cancelledAt,
|
|
14328
|
+
metadata: {
|
|
14329
|
+
...child.metadata,
|
|
14330
|
+
cancellation_requested: true,
|
|
14331
|
+
cancellation_reason: childCancelReason,
|
|
14332
|
+
cancellation_requested_at: cancelledAt
|
|
14333
|
+
}
|
|
14334
|
+
}).pipe(Effect79.mapError(mapChildExecutionRepositoryError));
|
|
14335
|
+
yield* cancelChildExecution(exports_ids_schema.ExecutionId.make(child.id), cancelledAt);
|
|
14336
|
+
}), { discard: true });
|
|
14337
|
+
for (const child of children) {
|
|
14338
|
+
if (seen.has(child.id))
|
|
14339
|
+
continue;
|
|
14340
|
+
seen.add(child.id);
|
|
14341
|
+
pending.push(exports_ids_schema.ExecutionId.make(child.id));
|
|
14342
|
+
}
|
|
14343
|
+
}
|
|
14169
14344
|
});
|
|
14170
14345
|
var cancelExecution = (input, turn, reason) => Activity.make({
|
|
14171
14346
|
name: ActivityNames.cancel(turn),
|
|
@@ -14185,7 +14360,7 @@ var cancelExecution = (input, turn, reason) => Activity.make({
|
|
|
14185
14360
|
});
|
|
14186
14361
|
var loadCancellationRequested = (input, turn) => Activity.make({
|
|
14187
14362
|
name: ActivityNames.checkCancel(turn),
|
|
14188
|
-
success:
|
|
14363
|
+
success: Schema73.Boolean,
|
|
14189
14364
|
error: ExecutionWorkflowFailed,
|
|
14190
14365
|
execute: Effect79.gen(function* () {
|
|
14191
14366
|
const repository = yield* exports_execution_repository.Service;
|
|
@@ -14195,7 +14370,7 @@ var loadCancellationRequested = (input, turn) => Activity.make({
|
|
|
14195
14370
|
});
|
|
14196
14371
|
var loadWait = (name, waitId2) => Activity.make({
|
|
14197
14372
|
name,
|
|
14198
|
-
success:
|
|
14373
|
+
success: Schema73.UndefinedOr(WaitSnapshot),
|
|
14199
14374
|
error: ExecutionWorkflowFailed,
|
|
14200
14375
|
execute: get11(waitId2).pipe(Effect79.map((record2) => record2 === undefined ? undefined : toWaitSnapshot2(record2)), Effect79.mapError(mapWaitError2))
|
|
14201
14376
|
});
|
|
@@ -14238,7 +14413,7 @@ var decodeOptionalNumberSetting = (value, key4, valid) => {
|
|
|
14238
14413
|
var optionalNumberForStart = (input, key4, valid) => decodeOptionalNumberSetting(metadataSetting2(input, key4), key4, valid).pipe(Effect79.map((value) => value === null ? undefined : value));
|
|
14239
14414
|
var continueAsNewAfterTurnsForStart = (input) => optionalNumberForStart(input, continueAsNewAfterTurnsMetadataKey2, (value) => Number.isInteger(value) && value > 0);
|
|
14240
14415
|
var toolOutputMaxBytesForStart = (input) => decodeOptionalNumberSetting(metadataSetting2(input, toolOutputMaxBytesMetadataKey2), toolOutputMaxBytesMetadataKey2, (value) => value >= 0);
|
|
14241
|
-
var decodeMemorySubject = (value) => typeof value === "string" ?
|
|
14416
|
+
var decodeMemorySubject = (value) => typeof value === "string" ? Schema73.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(value).pipe(Effect79.mapError(() => ExecutionWorkflowFailed.make({ message: `Invalid memory_subject_id metadata value: ${value}` }))) : Effect79.fail(ExecutionWorkflowFailed.make({ message: "memory_subject_id metadata value must be a string" }));
|
|
14242
14417
|
var memorySubjectForStart = Effect79.fn("ExecutionWorkflow.memorySubjectForStart")(function* (input) {
|
|
14243
14418
|
const executionSubject = memorySubjectFromMetadata2(input.metadata);
|
|
14244
14419
|
if (executionSubject !== undefined)
|
|
@@ -14249,7 +14424,7 @@ var memorySubjectForStart = Effect79.fn("ExecutionWorkflow.memorySubjectForStart
|
|
|
14249
14424
|
var nextEventSequence4 = (eventLog, executionId) => eventLog.maxSequence(executionId).pipe(Effect79.map((max) => max === undefined ? 0 : max + 1), Effect79.mapError(mapEventLogError6));
|
|
14250
14425
|
var ensureWorkspace = (input) => Activity.make({
|
|
14251
14426
|
name: ActivityNames.ensureWorkspace,
|
|
14252
|
-
success:
|
|
14427
|
+
success: Schema73.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14253
14428
|
error: ExecutionWorkflowFailed,
|
|
14254
14429
|
execute: Effect79.gen(function* () {
|
|
14255
14430
|
if (input.agent_snapshot === undefined)
|
|
@@ -14266,19 +14441,19 @@ var ensureWorkspace = (input) => Activity.make({
|
|
|
14266
14441
|
});
|
|
14267
14442
|
var suspendWorkspace = (input, key4) => Activity.make({
|
|
14268
14443
|
name: ActivityNames.suspendWorkspace(key4),
|
|
14269
|
-
success:
|
|
14444
|
+
success: Schema73.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14270
14445
|
error: ExecutionWorkflowFailed,
|
|
14271
14446
|
execute: suspend2({ executionId: input.execution_id, now: input.started_at }).pipe(Effect79.mapError(mapWorkspaceError))
|
|
14272
14447
|
});
|
|
14273
14448
|
var resumeWorkspace = (input, key4) => Activity.make({
|
|
14274
14449
|
name: ActivityNames.resumeWorkspace(key4),
|
|
14275
|
-
success:
|
|
14450
|
+
success: Schema73.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14276
14451
|
error: ExecutionWorkflowFailed,
|
|
14277
14452
|
execute: resume2({ executionId: input.execution_id, now: input.started_at }).pipe(Effect79.map((plan2) => plan2?.lease), Effect79.mapError(mapWorkspaceError))
|
|
14278
14453
|
});
|
|
14279
14454
|
var releaseWorkspace = (input) => Activity.make({
|
|
14280
14455
|
name: ActivityNames.releaseWorkspace,
|
|
14281
|
-
success:
|
|
14456
|
+
success: Schema73.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14282
14457
|
error: ExecutionWorkflowFailed,
|
|
14283
14458
|
execute: release2({ executionId: input.execution_id, now: input.completed_at }).pipe(Effect79.mapError(mapWorkspaceError))
|
|
14284
14459
|
});
|
|
@@ -14354,7 +14529,7 @@ var completeExecution = (input, waitId2, waitState, workspaceRuntimeLayer, turn,
|
|
|
14354
14529
|
...input.metadata,
|
|
14355
14530
|
wait_id: wait.wait_id,
|
|
14356
14531
|
wait_state: "open",
|
|
14357
|
-
pending_agent_suspension: wait.suspension.pipe(
|
|
14532
|
+
pending_agent_suspension: wait.suspension.pipe(Schema73.encodeSync(exports_agent_event.AgentSuspended), Schema73.decodeUnknownSync(exports_shared_schema.JsonValue)),
|
|
14358
14533
|
...generationMetadata2(workflowGenerationForStart2(input))
|
|
14359
14534
|
},
|
|
14360
14535
|
nextEventSequence: wait.next_event_sequence
|
|
@@ -14370,12 +14545,12 @@ var completeExecution = (input, waitId2, waitState, workspaceRuntimeLayer, turn,
|
|
|
14370
14545
|
});
|
|
14371
14546
|
var failIncompatibleCheckpoint = (input, error5) => Activity.make({
|
|
14372
14547
|
name: ActivityNames.failIncompatibleCheckpoint,
|
|
14373
|
-
success:
|
|
14548
|
+
success: Schema73.Void,
|
|
14374
14549
|
error: ExecutionWorkflowFailed,
|
|
14375
14550
|
execute: Effect79.gen(function* () {
|
|
14376
14551
|
const eventLog = yield* Service41;
|
|
14377
14552
|
const eventSequence = yield* nextEventSequence4(eventLog, input.execution_id);
|
|
14378
|
-
const details = yield* error5.pipe(
|
|
14553
|
+
const details = yield* error5.pipe(Schema73.encodeEffect(AgentCheckpointCompatibilityError), Effect79.flatMap(Schema73.decodeUnknownEffect(exports_shared_schema.JsonValue)), Effect79.mapError(() => ExecutionWorkflowFailed.make({ message: "Invalid checkpoint failure details" })));
|
|
14379
14554
|
yield* run4({
|
|
14380
14555
|
executionId: input.execution_id,
|
|
14381
14556
|
eventSequence,
|
|
@@ -14390,7 +14565,7 @@ var failIncompatibleCheckpoint = (input, error5) => Activity.make({
|
|
|
14390
14565
|
});
|
|
14391
14566
|
var loadChildCancellationRequested = (input) => Activity.make({
|
|
14392
14567
|
name: ActivityNames.checkQueuedChildCancellation,
|
|
14393
|
-
success:
|
|
14568
|
+
success: Schema73.Boolean,
|
|
14394
14569
|
error: ExecutionWorkflowFailed,
|
|
14395
14570
|
execute: Effect79.gen(function* () {
|
|
14396
14571
|
const context = childDispatchContext2(input);
|
|
@@ -14402,7 +14577,7 @@ var loadChildCancellationRequested = (input) => Activity.make({
|
|
|
14402
14577
|
});
|
|
14403
14578
|
var notifyParentActivity = (input, context, status, output) => Activity.make({
|
|
14404
14579
|
name: ActivityNames.notifyParent(status),
|
|
14405
|
-
success:
|
|
14580
|
+
success: Schema73.Void,
|
|
14406
14581
|
error: ExecutionWorkflowFailed,
|
|
14407
14582
|
execute: Effect79.gen(function* () {
|
|
14408
14583
|
const notifier = yield* Effect79.serviceOption(Service54);
|
|
@@ -14632,6 +14807,10 @@ var cancelRequest = Effect79.fn("ExecutionWorkflow.cancelRequest")(function* (in
|
|
|
14632
14807
|
return { execution_id: prepared.record.id, status: prepared.status };
|
|
14633
14808
|
}
|
|
14634
14809
|
yield* signalPreparedCancellation(prepared, input.cancelled_at);
|
|
14810
|
+
if (Option20.isSome(activeExecutions)) {
|
|
14811
|
+
yield* activeExecutions.value.interrupt(prepared.record.id);
|
|
14812
|
+
yield* activeExecutions.value.awaitQuiescent(prepared.record.id);
|
|
14813
|
+
}
|
|
14635
14814
|
yield* cancelOpenChildren(prepared.record.id, input.cancelled_at);
|
|
14636
14815
|
const eventLog = yield* Service41;
|
|
14637
14816
|
const eventSequence = yield* nextEventSequence4(eventLog, prepared.record.id);
|
|
@@ -14642,8 +14821,6 @@ var cancelRequest = Effect79.fn("ExecutionWorkflow.cancelRequest")(function* (in
|
|
|
14642
14821
|
...input.reason === undefined ? {} : { reason: input.reason },
|
|
14643
14822
|
metadata: prepared.record.metadata
|
|
14644
14823
|
}).pipe(Effect79.mapError(mapExecutionError));
|
|
14645
|
-
if (Option20.isSome(activeExecutions))
|
|
14646
|
-
yield* activeExecutions.value.interrupt(prepared.record.id);
|
|
14647
14824
|
return { execution_id: prepared.record.id, status: cancelled.status };
|
|
14648
14825
|
});
|
|
14649
14826
|
var workflowIdPlaceholderAddressId = exports_ids_schema.AddressId.make("address:workflow-id-placeholder");
|
|
@@ -14678,8 +14855,8 @@ var signalWait = Effect79.fn("ExecutionWorkflow.signalWait")(function* (input) {
|
|
|
14678
14855
|
});
|
|
14679
14856
|
|
|
14680
14857
|
// ../runtime/src/wait/wait-signal.ts
|
|
14681
|
-
class WaitSignalError extends
|
|
14682
|
-
message:
|
|
14858
|
+
class WaitSignalError extends Schema74.TaggedErrorClass()("WaitSignalError", {
|
|
14859
|
+
message: Schema74.String
|
|
14683
14860
|
}) {
|
|
14684
14861
|
}
|
|
14685
14862
|
var signalWorkflowWait = Effect80.fn("WaitSignal.signalWorkflowWait")(function* (input) {
|
|
@@ -14698,19 +14875,19 @@ var signalWorkflowWait = Effect80.fn("WaitSignal.signalWorkflowWait")(function*
|
|
|
14698
14875
|
});
|
|
14699
14876
|
|
|
14700
14877
|
// ../runtime/src/inbox/inbox-service.ts
|
|
14701
|
-
class InboxDeliveryError extends
|
|
14878
|
+
class InboxDeliveryError extends Schema75.TaggedErrorClass()("InboxDeliveryError", {
|
|
14702
14879
|
execution_id: exports_ids_schema.ExecutionId,
|
|
14703
|
-
message:
|
|
14880
|
+
message: Schema75.String
|
|
14704
14881
|
}) {
|
|
14705
14882
|
}
|
|
14706
14883
|
|
|
14707
|
-
class InboxReplyTokenInvalid extends
|
|
14708
|
-
reply_token:
|
|
14884
|
+
class InboxReplyTokenInvalid extends Schema75.TaggedErrorClass()("InboxReplyTokenInvalid", {
|
|
14885
|
+
reply_token: Schema75.String
|
|
14709
14886
|
}) {
|
|
14710
14887
|
}
|
|
14711
14888
|
|
|
14712
|
-
class InboxServiceError extends
|
|
14713
|
-
message:
|
|
14889
|
+
class InboxServiceError extends Schema75.TaggedErrorClass()("InboxServiceError", {
|
|
14890
|
+
message: Schema75.String
|
|
14714
14891
|
}) {
|
|
14715
14892
|
}
|
|
14716
14893
|
|
|
@@ -14818,9 +14995,9 @@ var layerWithSignal = (dependencies) => makeLayer2(dependencies);
|
|
|
14818
14995
|
var memoryLayer42 = layer50.pipe(Layer67.provide(exports_inbox_repository.memoryLayer), Layer67.provide(exports_envelope_repository.memoryLayer));
|
|
14819
14996
|
|
|
14820
14997
|
// ../runtime/src/topic/topic-service.ts
|
|
14821
|
-
import { Clock as Clock13, Context as Context62, Effect as Effect82, Layer as Layer68, Random as Random2, Schema as
|
|
14822
|
-
class TopicServiceError extends
|
|
14823
|
-
message:
|
|
14998
|
+
import { Clock as Clock13, Context as Context62, Effect as Effect82, Layer as Layer68, Random as Random2, Schema as Schema76 } from "effect";
|
|
14999
|
+
class TopicServiceError extends Schema76.TaggedErrorClass()("TopicServiceError", {
|
|
15000
|
+
message: Schema76.String
|
|
14824
15001
|
}) {
|
|
14825
15002
|
}
|
|
14826
15003
|
|
|
@@ -14896,17 +15073,17 @@ var layer51 = Layer68.effect(Service63, Effect82.gen(function* () {
|
|
|
14896
15073
|
var memoryLayer43 = layer51.pipe(Layer68.provide(exports_topic_repository.memoryLayer));
|
|
14897
15074
|
|
|
14898
15075
|
// ../runtime/src/topic/publish-to-topic-tool.ts
|
|
14899
|
-
import { Effect as Effect83, Schema as
|
|
15076
|
+
import { Effect as Effect83, Schema as Schema77 } from "effect";
|
|
14900
15077
|
var toolName3 = "publish_to_topic";
|
|
14901
15078
|
var permissionName3 = "relay.topic.publish";
|
|
14902
|
-
var ContentInput =
|
|
14903
|
-
var Input3 =
|
|
14904
|
-
topic:
|
|
15079
|
+
var ContentInput = Schema77.Union([Schema77.String, Schema77.Array(exports_content_schema.TextPart)]);
|
|
15080
|
+
var Input3 = Schema77.Struct({
|
|
15081
|
+
topic: Schema77.String,
|
|
14905
15082
|
content: ContentInput
|
|
14906
15083
|
}).annotate({ identifier: "Relay.PublishToTopicTool.Input" });
|
|
14907
|
-
var Output3 =
|
|
14908
|
-
envelope_id:
|
|
14909
|
-
subscriber_count:
|
|
15084
|
+
var Output3 = Schema77.Struct({
|
|
15085
|
+
envelope_id: Schema77.String,
|
|
15086
|
+
subscriber_count: Schema77.Int
|
|
14910
15087
|
}).annotate({ identifier: "Relay.PublishToTopicTool.Output" });
|
|
14911
15088
|
var registeredTool3 = (config) => tool(toolName3, {
|
|
14912
15089
|
description: "Publish a durable message to every subscriber of a topic.",
|
|
@@ -14928,23 +15105,23 @@ var registeredTool3 = (config) => tool(toolName3, {
|
|
|
14928
15105
|
});
|
|
14929
15106
|
|
|
14930
15107
|
// ../runtime/src/inbox/wait-for-messages-tool.ts
|
|
14931
|
-
import { Effect as Effect84, Schema as
|
|
15108
|
+
import { Effect as Effect84, Schema as Schema78 } from "effect";
|
|
14932
15109
|
var toolName4 = "wait_for_messages";
|
|
14933
15110
|
var permissionName4 = "relay.inbox.wait";
|
|
14934
|
-
var Input4 =
|
|
15111
|
+
var Input4 = Schema78.Struct({ timeout: Schema78.optionalKey(Schema78.String) }).annotate({
|
|
14935
15112
|
identifier: "Relay.WaitForMessagesTool.Input"
|
|
14936
15113
|
});
|
|
14937
|
-
var MessageView =
|
|
14938
|
-
sequence:
|
|
14939
|
-
from:
|
|
14940
|
-
content:
|
|
14941
|
-
reply_token:
|
|
14942
|
-
correlation_key:
|
|
14943
|
-
metadata:
|
|
15114
|
+
var MessageView = Schema78.Struct({
|
|
15115
|
+
sequence: Schema78.Int,
|
|
15116
|
+
from: Schema78.String,
|
|
15117
|
+
content: Schema78.Array(exports_content_schema.TextPart),
|
|
15118
|
+
reply_token: Schema78.optionalKey(Schema78.String),
|
|
15119
|
+
correlation_key: Schema78.optionalKey(Schema78.String),
|
|
15120
|
+
metadata: Schema78.optionalKey(exports_shared_schema.Metadata)
|
|
14944
15121
|
}).annotate({ identifier: "Relay.WaitForMessagesTool.MessageView" });
|
|
14945
|
-
var Output4 =
|
|
14946
|
-
status:
|
|
14947
|
-
messages:
|
|
15122
|
+
var Output4 = Schema78.Struct({
|
|
15123
|
+
status: Schema78.Literals(["messages", "timed_out"]),
|
|
15124
|
+
messages: Schema78.Array(MessageView)
|
|
14948
15125
|
}).annotate({ identifier: "Relay.WaitForMessagesTool.Output" });
|
|
14949
15126
|
var project = (message) => ({
|
|
14950
15127
|
sequence: message.sequence,
|
|
@@ -15001,18 +15178,18 @@ var registeredTool4 = (config) => tool(toolName4, {
|
|
|
15001
15178
|
});
|
|
15002
15179
|
|
|
15003
15180
|
// ../runtime/src/inbox/send-message-tool.ts
|
|
15004
|
-
import { Effect as Effect85, Schema as
|
|
15181
|
+
import { Effect as Effect85, Schema as Schema79 } from "effect";
|
|
15005
15182
|
var toolName5 = "send_message";
|
|
15006
15183
|
var permissionName5 = "relay.inbox.send";
|
|
15007
|
-
var ContentInput2 =
|
|
15008
|
-
var Input5 =
|
|
15009
|
-
to:
|
|
15184
|
+
var ContentInput2 = Schema79.Union([Schema79.String, Schema79.Array(exports_content_schema.TextPart)]);
|
|
15185
|
+
var Input5 = Schema79.Struct({
|
|
15186
|
+
to: Schema79.String,
|
|
15010
15187
|
content: ContentInput2,
|
|
15011
|
-
reply_token:
|
|
15188
|
+
reply_token: Schema79.optionalKey(Schema79.String)
|
|
15012
15189
|
}).annotate({ identifier: "Relay.SendMessageTool.Input" });
|
|
15013
|
-
var Output5 =
|
|
15014
|
-
envelope_id:
|
|
15015
|
-
delivered:
|
|
15190
|
+
var Output5 = Schema79.Struct({
|
|
15191
|
+
envelope_id: Schema79.String,
|
|
15192
|
+
delivered: Schema79.Literals(["inbox", "outbox", "reply"])
|
|
15016
15193
|
}).annotate({ identifier: "Relay.SendMessageTool.Output" });
|
|
15017
15194
|
var registeredTool5 = (config) => tool(toolName5, {
|
|
15018
15195
|
description: "Send a durable message to an address or reply to an inbox message.",
|
|
@@ -15050,26 +15227,26 @@ var registeredTool5 = (config) => tool(toolName5, {
|
|
|
15050
15227
|
});
|
|
15051
15228
|
|
|
15052
15229
|
// ../runtime/src/envelope/envelope-service.ts
|
|
15053
|
-
import { Context as Context63, Effect as Effect86, Layer as Layer69, Schema as
|
|
15054
|
-
class EnvelopeAddressNotFound extends
|
|
15230
|
+
import { Context as Context63, Effect as Effect86, Layer as Layer69, Schema as Schema80 } from "effect";
|
|
15231
|
+
class EnvelopeAddressNotFound extends Schema80.TaggedErrorClass()("EnvelopeAddressNotFound", {
|
|
15055
15232
|
address_id: exports_ids_schema.AddressId
|
|
15056
15233
|
}) {
|
|
15057
15234
|
}
|
|
15058
15235
|
|
|
15059
|
-
class EnvelopeRouteUnavailable extends
|
|
15236
|
+
class EnvelopeRouteUnavailable extends Schema80.TaggedErrorClass()("EnvelopeRouteUnavailable", {
|
|
15060
15237
|
address_id: exports_ids_schema.AddressId,
|
|
15061
|
-
route_key:
|
|
15238
|
+
route_key: Schema80.String
|
|
15062
15239
|
}) {
|
|
15063
15240
|
}
|
|
15064
15241
|
|
|
15065
|
-
class EnvelopeRouteDeferred extends
|
|
15242
|
+
class EnvelopeRouteDeferred extends Schema80.TaggedErrorClass()("EnvelopeRouteDeferred", {
|
|
15066
15243
|
address_id: exports_ids_schema.AddressId,
|
|
15067
|
-
route_key:
|
|
15244
|
+
route_key: Schema80.String
|
|
15068
15245
|
}) {
|
|
15069
15246
|
}
|
|
15070
15247
|
|
|
15071
|
-
class EnvelopeServiceError extends
|
|
15072
|
-
message:
|
|
15248
|
+
class EnvelopeServiceError extends Schema80.TaggedErrorClass()("EnvelopeServiceError", {
|
|
15249
|
+
message: Schema80.String
|
|
15073
15250
|
}) {
|
|
15074
15251
|
}
|
|
15075
15252
|
|
|
@@ -15250,7 +15427,7 @@ var send2 = Effect86.fn("EnvelopeService.send.call")(function* (input) {
|
|
|
15250
15427
|
});
|
|
15251
15428
|
|
|
15252
15429
|
// ../runtime/src/agent/relay-approvals.ts
|
|
15253
|
-
var layer53 = exports_approvals.
|
|
15430
|
+
var layer53 = exports_approvals.layerAutoApprove;
|
|
15254
15431
|
|
|
15255
15432
|
// ../runtime/src/agent/relay-compaction.ts
|
|
15256
15433
|
import { Clock as Clock14, Effect as Effect87, Layer as Layer70 } from "effect";
|
|
@@ -15301,11 +15478,11 @@ var make8 = (config) => exports_compaction.make(strategy(config), defaultOptions
|
|
|
15301
15478
|
var layerFromEpoch = (epoch) => exports_instructions.layer(epoch.baseline.length === 0 ? [] : [exports_instructions.staticSource("relay:context-epoch", epoch.baseline)]);
|
|
15302
15479
|
|
|
15303
15480
|
// ../runtime/src/agent/relay-permissions.ts
|
|
15304
|
-
import { Clock as Clock15, Effect as Effect88, Layer as Layer71, Option as Option21, Schema as
|
|
15305
|
-
var
|
|
15481
|
+
import { Clock as Clock15, Effect as Effect88, Layer as Layer71, Option as Option21, Schema as Schema81 } from "effect";
|
|
15482
|
+
var permissionTokenPrefix = "wait:permission:";
|
|
15483
|
+
var jsonValue3 = (value) => Schema81.decodeUnknownSync(exports_shared_schema.JsonValue)(value === undefined ? null : value);
|
|
15306
15484
|
var waitIdForToolCall = (executionId, toolCallId) => Identifiers.waitId("permission", executionId, toolCallId);
|
|
15307
|
-
var
|
|
15308
|
-
var tokenFor = (executionId, request) => waitIdForToolCall(executionId, request.toolCallId ?? fallbackToolCallId(request));
|
|
15485
|
+
var tokenFor = (executionId, request) => waitIdForToolCall(executionId, request.call.id);
|
|
15309
15486
|
var matchingRule = (rules, tool3, params) => {
|
|
15310
15487
|
let matched;
|
|
15311
15488
|
for (const rule of rules) {
|
|
@@ -15315,7 +15492,7 @@ var matchingRule = (rules, tool3, params) => {
|
|
|
15315
15492
|
return matched;
|
|
15316
15493
|
};
|
|
15317
15494
|
var staticDecision = (executionId, ruleset, request) => {
|
|
15318
|
-
const rule = matchingRule(ruleset.rules, request.
|
|
15495
|
+
const rule = matchingRule(ruleset.rules, request.call.name, request.call.params);
|
|
15319
15496
|
const level = rule?.level ?? ruleset.fallback ?? "ask";
|
|
15320
15497
|
switch (level) {
|
|
15321
15498
|
case "allow":
|
|
@@ -15329,25 +15506,8 @@ var staticDecision = (executionId, ruleset, request) => {
|
|
|
15329
15506
|
return { _tag: "Ask", token: tokenFor(executionId, request) };
|
|
15330
15507
|
}
|
|
15331
15508
|
};
|
|
15332
|
-
var evaluateDecision = Effect88.fn("RelayPermissions.evaluateDecision")(function* (config, request) {
|
|
15333
|
-
const remembered = yield* config.repository.list({ agent: config.agentName, scope: config.scope }).pipe(Effect88.mapError((error5) => permissionError(error5.message)));
|
|
15334
|
-
const rule = matchingRule(remembered.map((record2) => record2.rule), request.tool, request.params);
|
|
15335
|
-
if (rule !== undefined) {
|
|
15336
|
-
switch (rule.level) {
|
|
15337
|
-
case "allow":
|
|
15338
|
-
return { _tag: "Allow" };
|
|
15339
|
-
case "deny":
|
|
15340
|
-
return {
|
|
15341
|
-
_tag: "Deny",
|
|
15342
|
-
...rule.reason === undefined ? {} : { reason: rule.reason }
|
|
15343
|
-
};
|
|
15344
|
-
case "ask":
|
|
15345
|
-
return { _tag: "Ask", token: tokenFor(config.executionId, request) };
|
|
15346
|
-
}
|
|
15347
|
-
}
|
|
15348
|
-
return staticDecision(config.executionId, config.ruleset, request);
|
|
15349
|
-
});
|
|
15350
15509
|
var permissionError = (message) => exports_permissions.PermissionError.make({ message });
|
|
15510
|
+
var rememberedRules = (config) => config.repository.list({ agent: config.agentName, scope: config.scope }).pipe(Effect88.mapError((error5) => permissionError(error5.message)), Effect88.map((records) => records.map((record2) => record2.rule)));
|
|
15351
15511
|
var createdAtForSequence = (config, sequence) => config.startedAt + sequence - config.eventSequence;
|
|
15352
15512
|
var nextLoggedSequence = (eventLog, executionId, fallback) => eventLog.maxSequence(executionId).pipe(Effect88.mapError((error5) => permissionError(error5.message)), Effect88.map((max) => max === undefined ? fallback : Math.max(max + 1, fallback)));
|
|
15353
15513
|
var allocateEventSequence = Effect88.fn("RelayPermissions.allocateEventSequence")(function* (config) {
|
|
@@ -15357,19 +15517,19 @@ var allocateEventSequence = Effect88.fn("RelayPermissions.allocateEventSequence"
|
|
|
15357
15517
|
return sequence;
|
|
15358
15518
|
});
|
|
15359
15519
|
var resetAllocatorToLog = (config) => config.allocator.current.pipe(Effect88.flatMap((current2) => nextLoggedSequence(config.eventLog, config.executionId, current2)), Effect88.flatMap(config.allocator.resetTo));
|
|
15360
|
-
var permissionRequestedCursor = (config, pending
|
|
15361
|
-
var permissionResolvedCursor = (config, pending
|
|
15520
|
+
var permissionRequestedCursor = (config, pending) => `${config.executionId}:permission:${pending.call.id}:requested`;
|
|
15521
|
+
var permissionResolvedCursor = (config, pending) => `${config.executionId}:permission:${pending.call.id}:resolved`;
|
|
15362
15522
|
var permissionRequestedEvent = (config, pending, waitId2, sequence) => ({
|
|
15363
|
-
id: Identifiers.eventId(config.executionId, pending.
|
|
15523
|
+
id: Identifiers.eventId(config.executionId, pending.call.id, "permission-requested"),
|
|
15364
15524
|
execution_id: config.executionId,
|
|
15365
15525
|
type: "permission.ask.requested",
|
|
15366
15526
|
sequence,
|
|
15367
|
-
cursor: permissionRequestedCursor(config, pending
|
|
15527
|
+
cursor: permissionRequestedCursor(config, pending),
|
|
15368
15528
|
data: {
|
|
15369
|
-
tool_call_id: pending.
|
|
15370
|
-
tool_name: pending.
|
|
15529
|
+
tool_call_id: pending.call.id,
|
|
15530
|
+
tool_name: pending.call.name,
|
|
15371
15531
|
wait_id: waitId2,
|
|
15372
|
-
input: jsonValue3(pending.params),
|
|
15532
|
+
input: jsonValue3(pending.call.params),
|
|
15373
15533
|
agent_name: pending.agentName,
|
|
15374
15534
|
scope: config.scope
|
|
15375
15535
|
},
|
|
@@ -15394,15 +15554,28 @@ var answerForWait = (wait) => {
|
|
|
15394
15554
|
return { _tag: "Denied", reason: "Permission ask cancelled" };
|
|
15395
15555
|
return { _tag: "Denied", reason: "Permission denied" };
|
|
15396
15556
|
};
|
|
15557
|
+
var resolutionForAnswer = (pending, answer) => {
|
|
15558
|
+
switch (answer._tag) {
|
|
15559
|
+
case "Approved":
|
|
15560
|
+
return { _tag: "Approved" };
|
|
15561
|
+
case "Always":
|
|
15562
|
+
return { _tag: "Approved", remember: { pattern: pending.call.name, level: "allow" } };
|
|
15563
|
+
case "Denied":
|
|
15564
|
+
return {
|
|
15565
|
+
_tag: "Denied",
|
|
15566
|
+
...answer.reason === undefined ? {} : { reason: answer.reason }
|
|
15567
|
+
};
|
|
15568
|
+
}
|
|
15569
|
+
};
|
|
15397
15570
|
var permissionResolvedEvent = (config, pending, wait, answer, sequence) => ({
|
|
15398
|
-
id: Identifiers.eventId(config.executionId, pending.
|
|
15571
|
+
id: Identifiers.eventId(config.executionId, pending.call.id, "permission-resolved"),
|
|
15399
15572
|
execution_id: config.executionId,
|
|
15400
15573
|
type: "permission.ask.resolved",
|
|
15401
15574
|
sequence,
|
|
15402
|
-
cursor: permissionResolvedCursor(config, pending
|
|
15575
|
+
cursor: permissionResolvedCursor(config, pending),
|
|
15403
15576
|
data: {
|
|
15404
|
-
tool_call_id: pending.
|
|
15405
|
-
tool_name: pending.
|
|
15577
|
+
tool_call_id: pending.call.id,
|
|
15578
|
+
tool_name: pending.call.name,
|
|
15406
15579
|
wait_id: wait.id,
|
|
15407
15580
|
answer: answer._tag,
|
|
15408
15581
|
state: wait.state
|
|
@@ -15416,7 +15589,7 @@ var appendPermissionEvent = (config, event) => appendIdempotentTo(config.eventLo
|
|
|
15416
15589
|
onSome: (prior) => samePermissionEvent(prior, event) ? Effect88.succeed(prior) : Effect88.fail(permissionError(error5.message))
|
|
15417
15590
|
})))), Effect88.mapError((error5) => permissionError(error5.message)), Effect88.tap(() => resetAllocatorToLog(config)));
|
|
15418
15591
|
var ensurePermissionRequestedEvent = Effect88.fn("RelayPermissions.ensurePermissionRequestedEvent")(function* (config, pending, waitId2) {
|
|
15419
|
-
const cursor = permissionRequestedCursor(config, pending
|
|
15592
|
+
const cursor = permissionRequestedCursor(config, pending);
|
|
15420
15593
|
const existing = yield* findEventByCursor(config, cursor);
|
|
15421
15594
|
if (Option21.isSome(existing))
|
|
15422
15595
|
return;
|
|
@@ -15430,12 +15603,12 @@ var createAsk = Effect88.fn("RelayPermissions.createAsk")(function* (config, pen
|
|
|
15430
15603
|
waitId: waitId2,
|
|
15431
15604
|
executionId: config.executionId,
|
|
15432
15605
|
mode: "event",
|
|
15433
|
-
correlationKey: pending.
|
|
15606
|
+
correlationKey: pending.call.id,
|
|
15434
15607
|
metadata: {
|
|
15435
15608
|
kind: "tool-permission",
|
|
15436
|
-
tool_call_id: pending.
|
|
15437
|
-
tool_name: pending.
|
|
15438
|
-
input: jsonValue3(pending.params),
|
|
15609
|
+
tool_call_id: pending.call.id,
|
|
15610
|
+
tool_name: pending.call.name,
|
|
15611
|
+
input: jsonValue3(pending.call.params),
|
|
15439
15612
|
agent_name: pending.agentName,
|
|
15440
15613
|
scope: config.scope
|
|
15441
15614
|
},
|
|
@@ -15449,26 +15622,27 @@ var awaitAnswer = Effect88.fn("RelayPermissions.awaitAnswer")(function* (config,
|
|
|
15449
15622
|
const existing = yield* config.waits.get(waitId2).pipe(Effect88.mapError((error5) => permissionError(error5.message)));
|
|
15450
15623
|
if (existing === undefined) {
|
|
15451
15624
|
yield* createAsk(config, pending);
|
|
15452
|
-
return
|
|
15625
|
+
return pending;
|
|
15453
15626
|
}
|
|
15454
15627
|
if (existing.state === "open") {
|
|
15455
15628
|
yield* ensurePermissionRequestedEvent(config, pending, waitId2);
|
|
15456
|
-
return
|
|
15629
|
+
return pending;
|
|
15457
15630
|
}
|
|
15458
15631
|
const answer = answerForWait(existing);
|
|
15459
|
-
const resolvedCursor = permissionResolvedCursor(config, pending
|
|
15632
|
+
const resolvedCursor = permissionResolvedCursor(config, pending);
|
|
15460
15633
|
const resolved = yield* findEventByCursor(config, resolvedCursor);
|
|
15461
15634
|
if (Option21.isSome(resolved)) {
|
|
15462
15635
|
yield* resetAllocatorToLog(config);
|
|
15463
|
-
return
|
|
15636
|
+
return resolutionForAnswer(pending, answer);
|
|
15464
15637
|
}
|
|
15465
15638
|
const resolvedSequence = yield* allocateEventSequence(config);
|
|
15466
15639
|
yield* appendPermissionEvent(config, permissionResolvedEvent(config, pending, existing, answer, resolvedSequence));
|
|
15467
|
-
return
|
|
15640
|
+
return resolutionForAnswer(pending, answer);
|
|
15468
15641
|
});
|
|
15642
|
+
var resolve8 = (config, pending) => pending.token.startsWith(permissionTokenPrefix) ? awaitAnswer(config, pending).pipe(Effect88.orDie) : Effect88.succeed({ _tag: "Approved" });
|
|
15469
15643
|
var rememberRule = Effect88.fn("RelayPermissions.rememberRule")(function* (config, rule) {
|
|
15470
15644
|
const createdAt = yield* Clock15.currentTimeMillis;
|
|
15471
|
-
const decodedRule = yield*
|
|
15645
|
+
const decodedRule = yield* Schema81.decodeUnknownEffect(exports_agent_schema.PermissionRule)(rule).pipe(Effect88.mapError((error5) => permissionError(error5.message)));
|
|
15472
15646
|
yield* config.repository.remember({
|
|
15473
15647
|
agent: config.agentName,
|
|
15474
15648
|
scope: config.scope,
|
|
@@ -15477,16 +15651,18 @@ var rememberRule = Effect88.fn("RelayPermissions.rememberRule")(function* (confi
|
|
|
15477
15651
|
}).pipe(Effect88.mapError((error5) => permissionError(error5.message)));
|
|
15478
15652
|
});
|
|
15479
15653
|
var layer54 = (config) => Layer71.mergeAll(Layer71.succeed(exports_permissions.Permissions, exports_permissions.Permissions.of({
|
|
15480
|
-
evaluate: (request) =>
|
|
15481
|
-
await: (pending) => awaitAnswer(config, pending)
|
|
15654
|
+
evaluate: (request) => Effect88.succeed(staticDecision(config.executionId, config.ruleset, request))
|
|
15482
15655
|
})), Layer71.succeed(exports_permissions.RuleStore, exports_permissions.RuleStore.of({
|
|
15483
|
-
remember: (rule) => rememberRule(config, rule)
|
|
15656
|
+
remember: (rule) => rememberRule(config, rule),
|
|
15657
|
+
rules: rememberedRules(config)
|
|
15658
|
+
})), Layer71.succeed(exports_approvals.Approvals, exports_approvals.Approvals.of({
|
|
15659
|
+
resolve: (pending) => resolve8(config, pending)
|
|
15484
15660
|
})));
|
|
15485
15661
|
|
|
15486
15662
|
// ../runtime/src/agent/relay-steering.ts
|
|
15487
|
-
import { Clock as Clock16, Effect as Effect89, Layer as Layer72, Schema as
|
|
15663
|
+
import { Clock as Clock16, Effect as Effect89, Layer as Layer72, Schema as Schema82 } from "effect";
|
|
15488
15664
|
import { Prompt as Prompt5 } from "effect/unstable/ai";
|
|
15489
|
-
var jsonValue4 = (value) =>
|
|
15665
|
+
var jsonValue4 = (value) => Schema82.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
15490
15666
|
var stringifyJson2 = (value) => JSON.stringify(jsonValue4(value));
|
|
15491
15667
|
var createdAtForSequence2 = (config, sequence) => config.startedAt + sequence - config.eventSequence;
|
|
15492
15668
|
var drainId = (config, kind, sequence) => `drain:${config.executionId}:steering:${kind}:sequence:${sequence}`;
|
|
@@ -15519,7 +15695,7 @@ var contentFromMessage = (message) => {
|
|
|
15519
15695
|
const textParts = promptTextParts(prompt);
|
|
15520
15696
|
if (textParts.length > 0)
|
|
15521
15697
|
return textParts;
|
|
15522
|
-
return [exports_content_schema.text(prompt.pipe(
|
|
15698
|
+
return [exports_content_schema.text(prompt.pipe(Schema82.encodeSync(Prompt5.Prompt), stringifyJson2))];
|
|
15523
15699
|
};
|
|
15524
15700
|
var steeringDeliveredEvent = (config, kind, drain2, messages, sequence) => ({
|
|
15525
15701
|
id: exports_ids_schema.EventId.make(`event:${drain2.drainId}:delivered`),
|
|
@@ -15564,8 +15740,8 @@ var layer55 = (config) => Layer72.succeed(exports_steering.Steering, exports_ste
|
|
|
15564
15740
|
}));
|
|
15565
15741
|
|
|
15566
15742
|
// ../runtime/src/agent/relay-tool-executor.ts
|
|
15567
|
-
import { Deferred as Deferred3, Effect as Effect90, Layer as Layer73, Option as Option22, Schema as
|
|
15568
|
-
var jsonValue5 = (value) =>
|
|
15743
|
+
import { Deferred as Deferred3, Effect as Effect90, Layer as Layer73, Option as Option22, Schema as Schema83 } from "effect";
|
|
15744
|
+
var jsonValue5 = (value) => Schema83.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
15569
15745
|
var errorDetail = (error5) => {
|
|
15570
15746
|
switch (error5._tag) {
|
|
15571
15747
|
case "ToolNotRegistered":
|
|
@@ -15881,7 +16057,7 @@ var {
|
|
|
15881
16057
|
usageReportedEvent: usageReportedEvent2
|
|
15882
16058
|
} = AgentLoopEvents;
|
|
15883
16059
|
|
|
15884
|
-
class AgentLoopWaitRequested extends
|
|
16060
|
+
class AgentLoopWaitRequested extends Schema84.TaggedErrorClass()("AgentLoopWaitRequested", {
|
|
15885
16061
|
wait_id: exports_ids_schema.WaitId,
|
|
15886
16062
|
tool_call: exports_tool_schema.Call,
|
|
15887
16063
|
suspension: exports_agent_event.AgentSuspended,
|
|
@@ -15891,7 +16067,7 @@ class AgentLoopWaitRequested extends Schema83.TaggedErrorClass()("AgentLoopWaitR
|
|
|
15891
16067
|
|
|
15892
16068
|
class Service61 extends Context64.Service()("@relayfx/runtime/agent/agent-loop-service/Service") {
|
|
15893
16069
|
}
|
|
15894
|
-
var jsonValue6 = (value) =>
|
|
16070
|
+
var jsonValue6 = (value) => Schema84.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
15895
16071
|
var toolNames = (agent) => HashSet7.fromIterable(agent.tool_names);
|
|
15896
16072
|
var turnPolicyFromSnapshot = (snapshot2) => {
|
|
15897
16073
|
switch (snapshot2.kind) {
|
|
@@ -15983,7 +16159,7 @@ var runStructuredTurn = Effect93.fn("AgentLoop.runStructuredTurn")(function* (la
|
|
|
15983
16159
|
prompt: STRUCTURED_TURN_PROMPT,
|
|
15984
16160
|
schema: registration.schema,
|
|
15985
16161
|
objectName: "output"
|
|
15986
|
-
})).pipe(Effect93.mapError((error5) =>
|
|
16162
|
+
})).pipe(Effect93.mapError((error5) => Schema84.is(AgentLoopError)(error5) ? error5 : loopError(error5, sequence)));
|
|
15987
16163
|
return jsonValue6(response.value);
|
|
15988
16164
|
});
|
|
15989
16165
|
var loopError = (error5, nextEventSequence5) => AgentLoopError.make({
|
|
@@ -16017,8 +16193,8 @@ var appendCompactionCommittedEvent = Effect93.fn("AgentLoop.appendCompactionComm
|
|
|
16017
16193
|
});
|
|
16018
16194
|
var toolFromDefinition = (definition) => AiTool2.dynamic(definition.name, {
|
|
16019
16195
|
description: definition.description,
|
|
16020
|
-
parameters:
|
|
16021
|
-
success:
|
|
16196
|
+
parameters: Schema84.make(exports_tool_schema.parametersSchema(definition.input_schema).ast),
|
|
16197
|
+
success: Schema84.Unknown,
|
|
16022
16198
|
...definition.needs_approval === undefined ? {} : { needsApproval: definition.needs_approval }
|
|
16023
16199
|
});
|
|
16024
16200
|
var toolkitFromRegistered = (registered) => Toolkit2.make(...registered.map((tool3) => toolFromDefinition(tool3.definition)));
|
|
@@ -16048,7 +16224,7 @@ var restoreHistory = Effect93.fn("AgentLoop.restoreHistory")(function* (chats, i
|
|
|
16048
16224
|
}
|
|
16049
16225
|
return history;
|
|
16050
16226
|
});
|
|
16051
|
-
var promptEquivalence =
|
|
16227
|
+
var promptEquivalence = Schema84.toEquivalence(Prompt6.Prompt);
|
|
16052
16228
|
var reconcileCompactionCheckpoint = Effect93.fn("AgentLoop.reconcileCompactionCheckpoint")(function* (sessions, chats, input, restoredHistory, onCheckpointCommitted, failOnMismatch = false) {
|
|
16053
16229
|
if (input.sessionId === undefined)
|
|
16054
16230
|
return restoredHistory;
|
|
@@ -16140,7 +16316,7 @@ var restoreContextEpoch = Effect93.fn("AgentLoop.restoreContextEpoch")(function*
|
|
|
16140
16316
|
return { baseline: epoch.baseline, dynamicSourceIds: epoch.dynamicSourceIds };
|
|
16141
16317
|
});
|
|
16142
16318
|
var mapBatonRunError = (error5, current2) => {
|
|
16143
|
-
if (
|
|
16319
|
+
if (Schema84.is(exports_agent_event.AgentSuspended)(error5)) {
|
|
16144
16320
|
return AgentLoopWaitRequested.make({
|
|
16145
16321
|
wait_id: exports_ids_schema.WaitId.make(error5.token),
|
|
16146
16322
|
tool_call: {
|
|
@@ -16153,29 +16329,29 @@ var mapBatonRunError = (error5, current2) => {
|
|
|
16153
16329
|
});
|
|
16154
16330
|
}
|
|
16155
16331
|
let message;
|
|
16156
|
-
if (
|
|
16332
|
+
if (Schema84.is(exports_agent_event.AgentError)(error5))
|
|
16157
16333
|
message = error5.message;
|
|
16158
|
-
else if (
|
|
16334
|
+
else if (Schema84.is(exports_agent_event.ResumeMismatch)(error5))
|
|
16159
16335
|
message = `Resume mismatch: ${error5.reason}`;
|
|
16160
|
-
else if (
|
|
16336
|
+
else if (Schema84.is(exports_turn_policy.TurnPolicyError)(error5))
|
|
16161
16337
|
message = error5.message;
|
|
16162
|
-
else if (
|
|
16338
|
+
else if (Schema84.is(exports_agent_event.TurnPolicyStopped)(error5))
|
|
16163
16339
|
message = `Turn policy stopped at turn ${error5.turn}`;
|
|
16164
|
-
else if (
|
|
16340
|
+
else if (Schema84.is(exports_agent_event.TurnLimitExceeded)(error5))
|
|
16165
16341
|
message = "Tool call turn limit exceeded";
|
|
16166
|
-
else if (
|
|
16342
|
+
else if (Schema84.is(exports_agent_event.MiddlewareViolation)(error5))
|
|
16167
16343
|
message = `ModelMiddleware violation at turn ${error5.turn}: ${error5.detail}`;
|
|
16168
|
-
else if (
|
|
16344
|
+
else if (Schema84.is(exports_agent_event.DuplicateToolCallId)(error5))
|
|
16169
16345
|
message = `Duplicate tool call id: ${error5.id}`;
|
|
16170
|
-
else if (
|
|
16346
|
+
else if (Schema84.is(exports_agent_event.ProgressOverflow)(error5))
|
|
16171
16347
|
message = `Tool progress overflow: ${error5.toolCallId}`;
|
|
16172
|
-
else if (
|
|
16348
|
+
else if (Schema84.is(exports_agent_event.ToolNameCollision)(error5))
|
|
16173
16349
|
message = `Tool name collision: ${error5.name}`;
|
|
16174
|
-
else if (
|
|
16350
|
+
else if (Schema84.is(AiError3.AiError)(error5))
|
|
16175
16351
|
message = error5.message;
|
|
16176
|
-
else if (
|
|
16352
|
+
else if (Schema84.is(exports_model_registry.LanguageModelNotRegistered)(error5))
|
|
16177
16353
|
message = `Language model not registered: ${error5.provider}/${error5.model}`;
|
|
16178
|
-
else if (
|
|
16354
|
+
else if (Schema84.is(exports_tool_executor.FrameworkFailure)(error5))
|
|
16179
16355
|
message = error5.message;
|
|
16180
16356
|
else {
|
|
16181
16357
|
const exhaustive = error5;
|
|
@@ -16183,14 +16359,14 @@ var mapBatonRunError = (error5, current2) => {
|
|
|
16183
16359
|
}
|
|
16184
16360
|
return AgentLoopError.make({ message, baton_failure: error5, next_event_sequence: current2 });
|
|
16185
16361
|
};
|
|
16186
|
-
var isBatonRunError = (error5) =>
|
|
16362
|
+
var isBatonRunError = (error5) => Schema84.is(exports_agent_event.AgentSuspended)(error5) || Schema84.is(exports_agent_event.ResumeMismatch)(error5) || Schema84.is(exports_turn_policy.TurnPolicyError)(error5) || Schema84.is(exports_agent_event.TurnPolicyStopped)(error5) || Schema84.is(exports_agent_event.TurnLimitExceeded)(error5) || Schema84.is(exports_agent_event.MiddlewareViolation)(error5) || Schema84.is(exports_agent_event.DuplicateToolCallId)(error5) || Schema84.is(exports_agent_event.ProgressOverflow)(error5) || Schema84.is(exports_agent_event.ToolNameCollision)(error5) || Schema84.is(exports_agent_event.AgentError)(error5) || Schema84.is(AiError3.AiError)(error5) || Schema84.is(exports_model_registry.LanguageModelNotRegistered)(error5) || Schema84.is(exports_tool_executor.FrameworkFailure)(error5);
|
|
16187
16363
|
var mapBoundaryError = (errorOrCurrent, current2, failureClassification) => {
|
|
16188
16364
|
if (current2 === undefined) {
|
|
16189
16365
|
const sequence = errorOrCurrent;
|
|
16190
16366
|
return (error6) => mapBoundaryError(error6, sequence);
|
|
16191
16367
|
}
|
|
16192
16368
|
const error5 = errorOrCurrent;
|
|
16193
|
-
if (
|
|
16369
|
+
if (Schema84.is(AgentLoopError)(error5) || Schema84.is(AgentLoopWaitRequested)(error5) || Schema84.is(AgentLoopBudgetExceeded)(error5))
|
|
16194
16370
|
return error5;
|
|
16195
16371
|
const mapped = isBatonRunError(error5) ? mapBatonRunError(error5, current2) : loopError(error5, current2);
|
|
16196
16372
|
return mapped._tag === "AgentLoopError" && failureClassification === "context-overflow" ? AgentLoopError.make({
|
|
@@ -16336,6 +16512,7 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16336
16512
|
startedAt: input.startedAt,
|
|
16337
16513
|
eventSequence: input.eventSequence
|
|
16338
16514
|
});
|
|
16515
|
+
const approvalsLayer = input.agent.permission_rules === undefined ? layer53 : Layer75.empty;
|
|
16339
16516
|
const steeringLayer = input.steeringEnabled !== true ? Layer75.empty : Option24.isNone(steeringRepository) ? yield* AgentLoopError.make({
|
|
16340
16517
|
message: "Execution steering requires SteeringRepository in context",
|
|
16341
16518
|
next_event_sequence: input.eventSequence + 1
|
|
@@ -16351,6 +16528,8 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16351
16528
|
const memory = input.memorySubjectId === undefined ? undefined : { key: { agent: input.agent.name, subject: input.memorySubjectId } };
|
|
16352
16529
|
const restoredEpoch = durableHistory !== undefined && Option24.isSome(contextEpochs) ? yield* restoreContextEpoch(contextEpochs.value, input) : undefined;
|
|
16353
16530
|
const freshSessionHistory = durableHistory !== undefined || input.sessionId === undefined || Option24.isNone(sessionRepository) ? undefined : yield* sessionRepository.value.path({ sessionId: input.sessionId }).pipe(Effect93.mapError((error5) => loopError(error5, input.eventSequence + 1)), Effect93.map((path2) => path2.length === 0 ? undefined : exports_session.buildContext(path2)));
|
|
16531
|
+
const sessionWriter = input.sessionId === undefined || Option24.isNone(sessionRepository) ? undefined : yield* sessionRepository.value.get(input.sessionId).pipe(Effect93.mapError((error5) => loopError(error5, input.eventSequence + 1)), Effect93.map((record2) => record2?.writer === undefined ? undefined : { executionId: input.executionId, epoch: record2.writer.epoch }));
|
|
16532
|
+
const sessionOwnerToken = sessionWriter === undefined ? undefined : `${sessionWriter.executionId}#${sessionWriter.epoch}`;
|
|
16354
16533
|
const { options, instructionsLayer } = durableHistory === undefined ? yield* assembler.assemble({ agent: input.agent, tools: definitions2, input: input.input }).pipe(Effect93.mapError((error5) => loopError(error5, input.eventSequence + 1)), Effect93.flatMap((assembled) => Effect93.gen(function* () {
|
|
16355
16534
|
const epoch = { baseline: assembled.system, dynamicSourceIds: [] };
|
|
16356
16535
|
if (Option24.isSome(contextEpochs))
|
|
@@ -16360,6 +16539,7 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16360
16539
|
prompt: assembled.prompt,
|
|
16361
16540
|
...freshSessionHistory === undefined ? {} : { history: freshSessionHistory },
|
|
16362
16541
|
sessionId: input.sessionId ?? input.executionId,
|
|
16542
|
+
...sessionOwnerToken === undefined ? {} : { sessionOwnerToken },
|
|
16363
16543
|
...memory === undefined ? {} : { memory }
|
|
16364
16544
|
},
|
|
16365
16545
|
instructionsLayer: freshSessionHistory === undefined ? layerFromEpoch(epoch) : Layer75.empty
|
|
@@ -16370,7 +16550,8 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16370
16550
|
prompt: [],
|
|
16371
16551
|
...memory === undefined ? {} : { memory },
|
|
16372
16552
|
...resumeSuspension === undefined ? {} : { resume: { suspension: resumeSuspension } },
|
|
16373
|
-
sessionId: input.sessionId ?? input.executionId
|
|
16553
|
+
sessionId: input.sessionId ?? input.executionId,
|
|
16554
|
+
...sessionOwnerToken === undefined ? {} : { sessionOwnerToken }
|
|
16374
16555
|
},
|
|
16375
16556
|
instructionsLayer: restoredEpoch === undefined ? Layer75.empty : layerFromEpoch(restoredEpoch)
|
|
16376
16557
|
};
|
|
@@ -16516,9 +16697,10 @@ var make12 = (layerOptions) => Effect93.gen(function* () {
|
|
|
16516
16697
|
const runFold = Effect93.scoped(Effect93.gen(function* () {
|
|
16517
16698
|
const base = withToolCallDecodeResilience(yield* LanguageModel.LanguageModel, definitions2.map((definition) => definition.name), toolCallDecodeMaxRetries, (classification) => Ref19.set(lastModelFailureClassification, classification));
|
|
16518
16699
|
const sessionStore = input.sessionId !== undefined && Option24.isSome(sessionRepository) ? yield* make5(input.sessionId, input.sessionEntryScope ?? input.executionId, {
|
|
16519
|
-
onCheckpointCommitted: (result) => onCheckpointCommitted(result).pipe(Effect93.orDie)
|
|
16700
|
+
onCheckpointCommitted: (result) => onCheckpointCommitted(result).pipe(Effect93.orDie),
|
|
16701
|
+
...sessionWriter === undefined ? {} : { writer: sessionWriter }
|
|
16520
16702
|
}).pipe(Effect93.provideService(exports_session_repository.Service, sessionRepository.value)) : undefined;
|
|
16521
|
-
const foldContext = yield* Layer75.build(Layer75.mergeAll(executorLayer, handlerLayer,
|
|
16703
|
+
const foldContext = yield* Layer75.build(Layer75.mergeAll(executorLayer, handlerLayer, approvalsLayer, exports_model_middleware.layerIdentity, instructionsLayer, permissionsLayer, steeringLayer));
|
|
16522
16704
|
const folded = exports_agent.stream(agent, batonOptions).pipe(Stream13.runFoldEffect(() => ({
|
|
16523
16705
|
text: "",
|
|
16524
16706
|
transcript: undefined,
|
|
@@ -16570,7 +16752,7 @@ var run5 = Effect93.fn("AgentLoop.run.call")(function* (input) {
|
|
|
16570
16752
|
// ../runtime/src/cluster/execution-entity.ts
|
|
16571
16753
|
import { ClusterSchema, Entity } from "effect/unstable/cluster";
|
|
16572
16754
|
import { Rpc } from "effect/unstable/rpc";
|
|
16573
|
-
import { Schema as
|
|
16755
|
+
import { Schema as Schema85 } from "effect";
|
|
16574
16756
|
var Start = Rpc.make("start", {
|
|
16575
16757
|
payload: StartInput,
|
|
16576
16758
|
success: StartResult,
|
|
@@ -16578,12 +16760,12 @@ var Start = Rpc.make("start", {
|
|
|
16578
16760
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
16579
16761
|
var SignalWait = Rpc.make("signalWait", {
|
|
16580
16762
|
payload: SignalWaitInput,
|
|
16581
|
-
success:
|
|
16763
|
+
success: Schema85.Void,
|
|
16582
16764
|
error: ExecutionWorkflowFailed
|
|
16583
16765
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
16584
16766
|
var Dispatch = Rpc.make("dispatch", {
|
|
16585
16767
|
payload: StartInput,
|
|
16586
|
-
success:
|
|
16768
|
+
success: Schema85.Void,
|
|
16587
16769
|
error: ExecutionWorkflowError
|
|
16588
16770
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
16589
16771
|
var Cancel = Rpc.make("cancel", {
|
|
@@ -16606,10 +16788,10 @@ var layer59 = entity.toLayer(entity.of({
|
|
|
16606
16788
|
var client = entity.client;
|
|
16607
16789
|
|
|
16608
16790
|
// ../runtime/src/execution/execution-watch-service.ts
|
|
16609
|
-
import { Config as Config5, Context as Context65, Duration as Duration4, Effect as Effect94, Layer as Layer76, Ref as Ref20, Schema as
|
|
16791
|
+
import { Config as Config5, Context as Context65, Duration as Duration4, Effect as Effect94, Layer as Layer76, Ref as Ref20, Schema as Schema86, Stream as Stream14 } from "effect";
|
|
16610
16792
|
|
|
16611
|
-
class ExecutionWatchError extends
|
|
16612
|
-
message:
|
|
16793
|
+
class ExecutionWatchError extends Schema86.TaggedErrorClass()("ExecutionWatchError", {
|
|
16794
|
+
message: Schema86.String
|
|
16613
16795
|
}) {
|
|
16614
16796
|
}
|
|
16615
16797
|
|
|
@@ -16657,20 +16839,20 @@ var layerFromServices = Layer76.effect(Service65, Effect94.gen(function* () {
|
|
|
16657
16839
|
}));
|
|
16658
16840
|
|
|
16659
16841
|
// ../runtime/src/resident/resident-registry-service.ts
|
|
16660
|
-
import { Context as Context66, Effect as Effect95, Layer as Layer77, Schema as
|
|
16661
|
-
class ResidentKindNotFound extends
|
|
16842
|
+
import { Context as Context66, Effect as Effect95, Layer as Layer77, Schema as Schema87 } from "effect";
|
|
16843
|
+
class ResidentKindNotFound extends Schema87.TaggedErrorClass()("ResidentKindNotFound", {
|
|
16662
16844
|
kind: exports_ids_schema.ResidentKindName
|
|
16663
16845
|
}) {
|
|
16664
16846
|
}
|
|
16665
16847
|
|
|
16666
|
-
class ResidentKindInvalid extends
|
|
16848
|
+
class ResidentKindInvalid extends Schema87.TaggedErrorClass()("ResidentKindInvalid", {
|
|
16667
16849
|
kind: exports_ids_schema.ResidentKindName,
|
|
16668
|
-
message:
|
|
16850
|
+
message: Schema87.String
|
|
16669
16851
|
}) {
|
|
16670
16852
|
}
|
|
16671
16853
|
|
|
16672
|
-
class ResidentRegistryError extends
|
|
16673
|
-
message:
|
|
16854
|
+
class ResidentRegistryError extends Schema87.TaggedErrorClass()("ResidentRegistryError", {
|
|
16855
|
+
message: Schema87.String
|
|
16674
16856
|
}) {
|
|
16675
16857
|
}
|
|
16676
16858
|
|
|
@@ -16702,21 +16884,21 @@ var layer60 = Layer77.effect(Service66, Effect95.gen(function* () {
|
|
|
16702
16884
|
}));
|
|
16703
16885
|
|
|
16704
16886
|
// ../runtime/src/resident/resident-instance-service.ts
|
|
16705
|
-
import { Context as Context67, Effect as Effect96, Function as Function16, Layer as Layer78, Schema as
|
|
16706
|
-
class ResidentDestroyed extends
|
|
16887
|
+
import { Context as Context67, Effect as Effect96, Function as Function16, Layer as Layer78, Schema as Schema88 } from "effect";
|
|
16888
|
+
class ResidentDestroyed extends Schema88.TaggedErrorClass()("ResidentDestroyed", {
|
|
16707
16889
|
kind: exports_ids_schema.ResidentKindName,
|
|
16708
16890
|
key: exports_ids_schema.ResidentKey
|
|
16709
16891
|
}) {
|
|
16710
16892
|
}
|
|
16711
16893
|
|
|
16712
|
-
class ResidentNotFound2 extends
|
|
16894
|
+
class ResidentNotFound2 extends Schema88.TaggedErrorClass()("ResidentNotFound", {
|
|
16713
16895
|
kind: exports_ids_schema.ResidentKindName,
|
|
16714
16896
|
key: exports_ids_schema.ResidentKey
|
|
16715
16897
|
}) {
|
|
16716
16898
|
}
|
|
16717
16899
|
|
|
16718
|
-
class ResidentServiceError extends
|
|
16719
|
-
message:
|
|
16900
|
+
class ResidentServiceError extends Schema88.TaggedErrorClass()("ResidentServiceError", {
|
|
16901
|
+
message: Schema88.String
|
|
16720
16902
|
}) {
|
|
16721
16903
|
}
|
|
16722
16904
|
|
|
@@ -16819,9 +17001,9 @@ var layer61 = Layer78.effect(Service67, Effect96.gen(function* () {
|
|
|
16819
17001
|
}));
|
|
16820
17002
|
|
|
16821
17003
|
// ../runtime/src/execution/session-stream-service.ts
|
|
16822
|
-
import { Config as Config6, Context as Context68, Duration as Duration5, Effect as Effect97, HashSet as HashSet8, Layer as Layer79, Ref as Ref21, Schema as
|
|
16823
|
-
class SessionStreamError extends
|
|
16824
|
-
message:
|
|
17004
|
+
import { Config as Config6, Context as Context68, Duration as Duration5, Effect as Effect97, HashSet as HashSet8, Layer as Layer79, Ref as Ref21, Schema as Schema89, Stream as Stream15 } from "effect";
|
|
17005
|
+
class SessionStreamError extends Schema89.TaggedErrorClass()("SessionStreamError", {
|
|
17006
|
+
message: Schema89.String
|
|
16825
17007
|
}) {
|
|
16826
17008
|
}
|
|
16827
17009
|
|
|
@@ -16854,15 +17036,15 @@ var layerFromServices2 = Layer79.effect(Service68, Effect97.gen(function* () {
|
|
|
16854
17036
|
}));
|
|
16855
17037
|
|
|
16856
17038
|
// ../runtime/src/schedule/scheduler-service.ts
|
|
16857
|
-
import { Clock as Clock17, Config as Config7, Context as Context69, Cron, DateTime as DateTime2, Duration as Duration6, Effect as Effect98, Layer as Layer80, Option as Option25, Random as Random3, Result as Result3, Schema as
|
|
16858
|
-
class SchedulerError extends
|
|
16859
|
-
message:
|
|
17039
|
+
import { Clock as Clock17, Config as Config7, Context as Context69, Cron, DateTime as DateTime2, Duration as Duration6, Effect as Effect98, Layer as Layer80, Option as Option25, Random as Random3, Result as Result3, Schema as Schema90 } from "effect";
|
|
17040
|
+
class SchedulerError extends Schema90.TaggedErrorClass()("SchedulerError", {
|
|
17041
|
+
message: Schema90.String
|
|
16860
17042
|
}) {
|
|
16861
17043
|
}
|
|
16862
17044
|
|
|
16863
|
-
class ScheduleCronInvalid extends
|
|
16864
|
-
cron_expr:
|
|
16865
|
-
message:
|
|
17045
|
+
class ScheduleCronInvalid extends Schema90.TaggedErrorClass()("ScheduleCronInvalid", {
|
|
17046
|
+
cron_expr: Schema90.String,
|
|
17047
|
+
message: Schema90.String
|
|
16866
17048
|
}) {
|
|
16867
17049
|
}
|
|
16868
17050
|
|
|
@@ -17017,25 +17199,25 @@ var runOnce2 = Effect98.fn("SchedulerService.runOnce.call")(function* () {
|
|
|
17017
17199
|
});
|
|
17018
17200
|
|
|
17019
17201
|
// ../runtime/src/runner/runner-runtime-service.ts
|
|
17020
|
-
var DatabaseMode =
|
|
17202
|
+
var DatabaseMode = Schema91.Literals(["sql", "pg", "mysql", "sqlite", "memory"]).annotate({
|
|
17021
17203
|
identifier: "Relay.RunnerRuntime.DatabaseMode"
|
|
17022
17204
|
});
|
|
17023
|
-
var ReadinessStatus =
|
|
17205
|
+
var ReadinessStatus = Schema91.Struct({
|
|
17024
17206
|
database: DatabaseMode,
|
|
17025
|
-
cluster:
|
|
17026
|
-
workflow:
|
|
17027
|
-
executionEntity:
|
|
17207
|
+
cluster: Schema91.Literal("ready"),
|
|
17208
|
+
workflow: Schema91.Literals(["ready", "client"]),
|
|
17209
|
+
executionEntity: Schema91.Literals(["registered", "client"])
|
|
17028
17210
|
}).annotate({ identifier: "Relay.RunnerRuntime.ReadinessStatus" });
|
|
17029
17211
|
|
|
17030
|
-
class RunnerRuntimeError extends
|
|
17031
|
-
message:
|
|
17212
|
+
class RunnerRuntimeError extends Schema91.TaggedErrorClass()("RunnerRuntimeError", {
|
|
17213
|
+
message: Schema91.String
|
|
17032
17214
|
}) {
|
|
17033
17215
|
}
|
|
17034
17216
|
|
|
17035
|
-
class ClusterConfigMismatch extends
|
|
17036
|
-
field:
|
|
17037
|
-
expected:
|
|
17038
|
-
actual:
|
|
17217
|
+
class ClusterConfigMismatch extends Schema91.TaggedErrorClass()("ClusterConfigMismatch", {
|
|
17218
|
+
field: Schema91.String,
|
|
17219
|
+
expected: Schema91.String,
|
|
17220
|
+
actual: Schema91.String
|
|
17039
17221
|
}) {
|
|
17040
17222
|
}
|
|
17041
17223
|
|
|
@@ -17049,7 +17231,7 @@ var memoryClusterLayer = Sharding.layer.pipe(Layer81.provideMerge(Runners.layerN
|
|
|
17049
17231
|
var clusterHost = Config8.string("RELAY_CLUSTER_HOST").pipe(Config8.withDefault("localhost"));
|
|
17050
17232
|
var clusterPort = Config8.int("RELAY_CLUSTER_PORT").pipe(Config8.withDefault(34431));
|
|
17051
17233
|
var clusterShardsPerGroup = Config8.int("RELAY_CLUSTER_SHARDS_PER_GROUP").pipe(Config8.withDefault(300));
|
|
17052
|
-
var clusterShardGroups = Config8.schema(Config8.Array(
|
|
17234
|
+
var clusterShardGroups = Config8.schema(Config8.Array(Schema91.String), "RELAY_CLUSTER_SHARD_GROUPS").pipe(Config8.withDefault(["default", "execution"]));
|
|
17053
17235
|
var runnerAddressKey = (address) => `${address.host}:${address.port}`;
|
|
17054
17236
|
var runnerAddressEquals = (left, right) => left.host === right.host && left.port === right.port;
|
|
17055
17237
|
var shardingConfigFromEnv = Layer81.effect(ShardingConfig2.ShardingConfig, Effect99.gen(function* () {
|
|
@@ -17380,24 +17562,24 @@ var check = Effect99.fn("RunnerRuntime.check.call")(function* () {
|
|
|
17380
17562
|
});
|
|
17381
17563
|
|
|
17382
17564
|
// ../runtime/src/workflow/definition-runtime.ts
|
|
17383
|
-
import { Cause as Cause3, Clock as Clock18, Context as Context71, Effect as Effect100, Exit as Exit2, FiberMap as FiberMap2, Layer as Layer82, Option as Option27, Schema as
|
|
17565
|
+
import { Cause as Cause3, Clock as Clock18, Context as Context71, Effect as Effect100, Exit as Exit2, FiberMap as FiberMap2, Layer as Layer82, Option as Option27, Schema as Schema92 } from "effect";
|
|
17384
17566
|
import { dual as dual2 } from "effect/Function";
|
|
17385
17567
|
|
|
17386
|
-
class UnsupportedOperation extends
|
|
17568
|
+
class UnsupportedOperation extends Schema92.TaggedErrorClass()("UnsupportedWorkflowOperation", { operation_id: exports_ids_schema.WorkflowOperationId, kind: Schema92.String }) {
|
|
17387
17569
|
}
|
|
17388
17570
|
|
|
17389
|
-
class PinnedDefinitionNotFound extends
|
|
17571
|
+
class PinnedDefinitionNotFound extends Schema92.TaggedErrorClass()("PinnedWorkflowDefinitionNotFound", { execution_id: exports_ids_schema.ExecutionId }) {
|
|
17390
17572
|
}
|
|
17391
17573
|
|
|
17392
|
-
class PinnedDefinitionMismatch extends
|
|
17574
|
+
class PinnedDefinitionMismatch extends Schema92.TaggedErrorClass()("PinnedWorkflowDefinitionMismatch", { execution_id: exports_ids_schema.ExecutionId }) {
|
|
17393
17575
|
}
|
|
17394
17576
|
|
|
17395
|
-
class WorkflowRuntimeError extends
|
|
17396
|
-
message:
|
|
17577
|
+
class WorkflowRuntimeError extends Schema92.TaggedErrorClass()("WorkflowRuntimeError", {
|
|
17578
|
+
message: Schema92.String
|
|
17397
17579
|
}) {
|
|
17398
17580
|
}
|
|
17399
17581
|
|
|
17400
|
-
class WorkflowJoinPolicyNotSatisfied extends
|
|
17582
|
+
class WorkflowJoinPolicyNotSatisfied extends Schema92.TaggedErrorClass()("WorkflowJoinPolicyNotSatisfied", { policy: Schema92.String }) {
|
|
17401
17583
|
}
|
|
17402
17584
|
var runtimeError2 = (error5) => WorkflowRuntimeError.make({ message: String(error5) });
|
|
17403
17585
|
var mapRuntimeError2 = Effect100.mapError(runtimeError2);
|
|
@@ -17410,13 +17592,13 @@ class Service71 extends Context71.Service()("@relayfx/runtime/workflow/definitio
|
|
|
17410
17592
|
var fanOutIdFor = dual2(2, (executionId, fanOutKey) => exports_ids_schema.ChildFanOutId.make(`workflow:${executionId}:fan-out:${fanOutKey}`));
|
|
17411
17593
|
var childExecutionIdFor = (fanOutId, operationId2) => exports_ids_schema.ChildExecutionId.make(`${fanOutId}:member:${operationId2}`);
|
|
17412
17594
|
|
|
17413
|
-
class WorkflowCancelled extends
|
|
17595
|
+
class WorkflowCancelled extends Schema92.TaggedErrorClass()("WorkflowCancelled", {}) {
|
|
17414
17596
|
}
|
|
17415
17597
|
|
|
17416
|
-
class WorkflowBudgetExceeded extends
|
|
17598
|
+
class WorkflowBudgetExceeded extends Schema92.TaggedErrorClass()("WorkflowBudgetExceeded", { operation_id: exports_ids_schema.WorkflowOperationId }) {
|
|
17417
17599
|
}
|
|
17418
17600
|
|
|
17419
|
-
class WorkflowJoining extends
|
|
17601
|
+
class WorkflowJoining extends Schema92.TaggedErrorClass()("WorkflowJoining", {
|
|
17420
17602
|
fan_out_id: exports_ids_schema.ChildFanOutId
|
|
17421
17603
|
}) {
|
|
17422
17604
|
}
|
|
@@ -17671,7 +17853,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17671
17853
|
break;
|
|
17672
17854
|
}
|
|
17673
17855
|
case "cancellation":
|
|
17674
|
-
output2 = yield* execute(operation.operation).pipe(Effect100.catchIf(
|
|
17856
|
+
output2 = yield* execute(operation.operation).pipe(Effect100.catchIf(Schema92.is(WorkflowCancelled), () => operation.on_cancel === undefined ? Effect100.fail(WorkflowCancelled.make()) : execute(operation.on_cancel)));
|
|
17675
17857
|
break;
|
|
17676
17858
|
case "compensation":
|
|
17677
17859
|
output2 = yield* execute(operation.operation);
|
|
@@ -17718,7 +17900,7 @@ var run6 = Effect100.fn("WorkflowDefinitionRuntime.run")(function* (executionId)
|
|
|
17718
17900
|
const result = yield* Effect100.exit(execute(revision.definition.entry_operation_id));
|
|
17719
17901
|
if (Exit2.isFailure(result)) {
|
|
17720
17902
|
const failure2 = Cause3.findErrorOption(result.cause);
|
|
17721
|
-
if (Option27.isSome(failure2) &&
|
|
17903
|
+
if (Option27.isSome(failure2) && Schema92.is(WorkflowJoining)(failure2.value))
|
|
17722
17904
|
return yield* result;
|
|
17723
17905
|
const currentRun = yield* repository.inspect(executionId);
|
|
17724
17906
|
if (currentRun?.status === "cancelled") {
|
|
@@ -17789,12 +17971,12 @@ var layerFromRuntime2 = Layer82.effect(Service71, Effect100.gen(function* () {
|
|
|
17789
17971
|
}));
|
|
17790
17972
|
|
|
17791
17973
|
// src/runtime.ts
|
|
17792
|
-
import { Cause as Cause5, Context as Context74, Effect as Effect112, Layer as Layer86, Option as Option31, Schema as
|
|
17974
|
+
import { Cause as Cause5, Context as Context74, Effect as Effect112, Layer as Layer86, Option as Option31, Schema as Schema100 } from "effect";
|
|
17793
17975
|
import { SqlClient as SqlClient31 } from "effect/unstable/sql/SqlClient";
|
|
17794
17976
|
|
|
17795
17977
|
// src/runtime-acquisition-error.ts
|
|
17796
|
-
import { Cause as Cause4, Function as Function17, Schema as
|
|
17797
|
-
var RuntimeConfigurationCategory =
|
|
17978
|
+
import { Cause as Cause4, Function as Function17, Schema as Schema93 } from "effect";
|
|
17979
|
+
var RuntimeConfigurationCategory = Schema93.Literals([
|
|
17798
17980
|
"missing-http-client",
|
|
17799
17981
|
"provider-config",
|
|
17800
17982
|
"model-registration",
|
|
@@ -17802,31 +17984,31 @@ var RuntimeConfigurationCategory = Schema92.Literals([
|
|
|
17802
17984
|
"database-config",
|
|
17803
17985
|
"unknown-host-layer"
|
|
17804
17986
|
]);
|
|
17805
|
-
var RuntimeConfigurationScope =
|
|
17987
|
+
var RuntimeConfigurationScope = Schema93.Literals(["host-layer", "database-client"]);
|
|
17806
17988
|
|
|
17807
|
-
class RuntimeHostLayerFailure extends
|
|
17989
|
+
class RuntimeHostLayerFailure extends Schema93.TaggedErrorClass()("RuntimeHostLayerFailure", { category: RuntimeConfigurationCategory }) {
|
|
17808
17990
|
}
|
|
17809
|
-
var SafeCauseReason =
|
|
17991
|
+
var SafeCauseReason = Schema93.TaggedUnion({
|
|
17810
17992
|
Fail: {
|
|
17811
17993
|
category: RuntimeConfigurationCategory,
|
|
17812
|
-
errorTag:
|
|
17994
|
+
errorTag: Schema93.Literals(["RuntimeHostLayerFailure", "UnknownTypedFailure"])
|
|
17813
17995
|
},
|
|
17814
|
-
Die: { defectTag:
|
|
17996
|
+
Die: { defectTag: Schema93.Literal("UnknownDefect") },
|
|
17815
17997
|
Interrupt: {}
|
|
17816
17998
|
});
|
|
17817
|
-
var SafeCause =
|
|
17818
|
-
reasons:
|
|
17819
|
-
truncated:
|
|
17999
|
+
var SafeCause = Schema93.Struct({
|
|
18000
|
+
reasons: Schema93.Array(SafeCauseReason).check(Schema93.isMaxLength(16)),
|
|
18001
|
+
truncated: Schema93.Boolean
|
|
17820
18002
|
});
|
|
17821
18003
|
|
|
17822
|
-
class RuntimeConfigurationError extends
|
|
18004
|
+
class RuntimeConfigurationError extends Schema93.TaggedErrorClass()("RuntimeConfigurationError", {
|
|
17823
18005
|
category: RuntimeConfigurationCategory,
|
|
17824
18006
|
scope: RuntimeConfigurationScope,
|
|
17825
18007
|
cause: SafeCause
|
|
17826
18008
|
}) {
|
|
17827
18009
|
}
|
|
17828
18010
|
var typedFailure = (error5) => {
|
|
17829
|
-
if (
|
|
18011
|
+
if (Schema93.is(RuntimeHostLayerFailure)(error5)) {
|
|
17830
18012
|
return { _tag: "Fail", category: error5.category, errorTag: "RuntimeHostLayerFailure" };
|
|
17831
18013
|
}
|
|
17832
18014
|
return { _tag: "Fail", category: "unknown-host-layer", errorTag: "UnknownTypedFailure" };
|
|
@@ -17845,11 +18027,11 @@ var safeCause = (cause) => {
|
|
|
17845
18027
|
var normalizeAcquisitionCauseImpl = (cause, scope, preserve) => {
|
|
17846
18028
|
const summary = safeCause(cause);
|
|
17847
18029
|
return Cause4.map(cause, (error5) => {
|
|
17848
|
-
if (
|
|
18030
|
+
if (Schema93.is(RuntimeConfigurationError)(error5) || preserve !== undefined && preserve(error5))
|
|
17849
18031
|
return error5;
|
|
17850
18032
|
const reason = typedFailure(error5);
|
|
17851
18033
|
return RuntimeConfigurationError.make({
|
|
17852
|
-
category:
|
|
18034
|
+
category: Schema93.is(RuntimeHostLayerFailure)(error5) ? reason.category : scope === "database-client" ? "database-config" : "unknown-host-layer",
|
|
17853
18035
|
scope,
|
|
17854
18036
|
cause: summary
|
|
17855
18037
|
});
|
|
@@ -17871,16 +18053,16 @@ var renderConfigurationError = (error5) => {
|
|
|
17871
18053
|
return `Runtime configuration error [${error5.category}/${error5.scope}]: ${remediation}; causes=${reasons}${error5.cause.truncated ? ",truncated" : ""}`;
|
|
17872
18054
|
};
|
|
17873
18055
|
// src/internal-client.ts
|
|
17874
|
-
import { Clock as Clock19, Effect as Effect109, Layer as Layer84, Option as Option30, Random as Random4, Schema as
|
|
18056
|
+
import { Clock as Clock19, Effect as Effect109, Layer as Layer84, Option as Option30, Random as Random4, Schema as Schema99, Stream as Stream17 } from "effect";
|
|
17875
18057
|
import { EntityId, ShardId, Sharding as Sharding2, ShardingConfig as ShardingConfig3 } from "effect/unstable/cluster";
|
|
17876
18058
|
|
|
17877
18059
|
// src/runtime-capability-policy.ts
|
|
17878
|
-
import { Context as Context72, Effect as Effect101, Function as Function18, Layer as Layer83, Schema as
|
|
18060
|
+
import { Context as Context72, Effect as Effect101, Function as Function18, Layer as Layer83, Schema as Schema94 } from "effect";
|
|
17879
18061
|
|
|
17880
|
-
class RuntimeCapabilityUnavailable extends
|
|
17881
|
-
capability:
|
|
17882
|
-
role:
|
|
17883
|
-
nextAction:
|
|
18062
|
+
class RuntimeCapabilityUnavailable extends Schema94.TaggedErrorClass()("RuntimeCapabilityUnavailable", {
|
|
18063
|
+
capability: Schema94.Literals(["fan-out", "workflow-definition"]),
|
|
18064
|
+
role: Schema94.Literals(["embedded", "runner", "client"]),
|
|
18065
|
+
nextAction: Schema94.Literals(["enable-embedded-capability", "use-embedded-runtime"])
|
|
17884
18066
|
}) {
|
|
17885
18067
|
}
|
|
17886
18068
|
|
|
@@ -17898,7 +18080,7 @@ var layer64 = Function18.dual(2, (role, capabilities) => Layer83.succeed(Service
|
|
|
17898
18080
|
}));
|
|
17899
18081
|
|
|
17900
18082
|
// src/client-baton-agent.ts
|
|
17901
|
-
import { Effect as Effect102, Schema as
|
|
18083
|
+
import { Effect as Effect102, Schema as Schema95 } from "effect";
|
|
17902
18084
|
var isRegisterBatonAgentInput = (input) => ("agent" in input);
|
|
17903
18085
|
var toolRefsFromBatonAgent = (agent) => Object.values(agent.toolkit.tools).map((tool3) => ({ name: tool3.name }));
|
|
17904
18086
|
var modelSelectionFromBatonAgent = (selection) => ({
|
|
@@ -17906,9 +18088,9 @@ var modelSelectionFromBatonAgent = (selection) => ({
|
|
|
17906
18088
|
model: selection.model,
|
|
17907
18089
|
...selection.registrationKey === undefined ? {} : { registration_key: selection.registrationKey }
|
|
17908
18090
|
});
|
|
17909
|
-
var decodeBatonAgentName = (name) =>
|
|
17910
|
-
var decodeBatonAgentMetadata = (metadata11) => metadata11 === undefined ? Effect102.void :
|
|
17911
|
-
var decodeBatonMemorySubject = (subject) =>
|
|
18091
|
+
var decodeBatonAgentName = (name) => Schema95.decodeUnknownEffect(exports_shared_schema.NonEmptyString)(name).pipe(Effect102.mapError(() => ClientError.make({ message: "Baton agent name must not be blank" })));
|
|
18092
|
+
var decodeBatonAgentMetadata = (metadata11) => metadata11 === undefined ? Effect102.void : Schema95.decodeUnknownEffect(exports_shared_schema.Metadata)(metadata11).pipe(Effect102.mapError(() => ClientError.make({ message: "Baton agent metadata must be JSON metadata" })));
|
|
18093
|
+
var decodeBatonMemorySubject = (subject) => Schema95.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect102.mapError(() => ClientError.make({ message: "Baton agent memory subject must be a MemorySubjectId" })));
|
|
17912
18094
|
var metadataFromBatonAgent = Effect102.fn("Client.metadataFromBatonAgent")(function* (input) {
|
|
17913
18095
|
const agentMetadata = yield* decodeBatonAgentMetadata(input.agent.metadata);
|
|
17914
18096
|
const memorySubject = input.agent.memory === undefined ? undefined : yield* decodeBatonMemorySubject(input.agent.memory.subject);
|
|
@@ -18017,10 +18199,10 @@ import { Effect as Effect104, Option as Option29 } from "effect";
|
|
|
18017
18199
|
import { Effect as Effect103 } from "effect";
|
|
18018
18200
|
|
|
18019
18201
|
// src/client-error-mapping.ts
|
|
18020
|
-
import { Option as Option28, Schema as
|
|
18202
|
+
import { Option as Option28, Schema as Schema96 } from "effect";
|
|
18021
18203
|
var errorMessage2 = (error5) => error5 instanceof Error ? error5.message : String(error5);
|
|
18022
18204
|
var toClientError = (error5) => ClientError.make({ message: errorMessage2(error5) });
|
|
18023
|
-
var toStreamError = (error5) => Option28.match(
|
|
18205
|
+
var toStreamError = (error5) => Option28.match(Schema96.decodeUnknownOption(EventLogCursorNotFound)(error5), {
|
|
18024
18206
|
onNone: () => toClientError(error5),
|
|
18025
18207
|
onSome: (cursorError) => cursorError
|
|
18026
18208
|
});
|
|
@@ -18151,8 +18333,8 @@ var childStartInput = (input, accepted2, pin, definition, createdAt, parentWaitI
|
|
|
18151
18333
|
var childRunInternals = { childStartInput, internalSpawnChildRunInput };
|
|
18152
18334
|
|
|
18153
18335
|
// src/client-execution-payloads.ts
|
|
18154
|
-
import { Effect as Effect105, Schema as
|
|
18155
|
-
var encodeExecutionCursor = (cursor) =>
|
|
18336
|
+
import { Effect as Effect105, Schema as Schema97 } from "effect";
|
|
18337
|
+
var encodeExecutionCursor = (cursor) => Schema97.encodeEffect(exports_pagination_schema.ExecutionCursorCodec)({ id: cursor.id, at: cursor.updatedAt }).pipe(Effect105.mapError(toClientError));
|
|
18156
18338
|
var executionIdFromIdempotencyKey = (idempotencyKey) => exports_ids_schema.ExecutionId.make(`execution:${idempotencyKey}`);
|
|
18157
18339
|
var metadataWithIdempotencyKey = (metadata11, idempotencyKey) => ({
|
|
18158
18340
|
...metadata11,
|
|
@@ -18269,9 +18451,9 @@ var wakeRuntime = Effect107.fn("Client.waits.wakeRuntime")(function* (waits, eve
|
|
|
18269
18451
|
var runtimeWakeInternals = { wakeRuntime };
|
|
18270
18452
|
|
|
18271
18453
|
// src/client-tool-outcome.ts
|
|
18272
|
-
import { Effect as Effect108, Schema as
|
|
18454
|
+
import { Effect as Effect108, Schema as Schema98 } from "effect";
|
|
18273
18455
|
var toolWaitId = (executionId, callId) => Identifiers.waitId("tool", executionId, callId);
|
|
18274
|
-
var acceptedWaitOutcome = (wait) =>
|
|
18456
|
+
var acceptedWaitOutcome = (wait) => Schema98.decodeUnknownEffect(exports_tool_schema.ExternalOutcome)(wait.metadata.external_outcome).pipe(Effect108.mapError(toClientError));
|
|
18275
18457
|
var resolveToolOutcomeWait = Effect108.fn("Client.resolveToolOutcomeWait")(function* (waits, eventLog, call, outcome, completedAt) {
|
|
18276
18458
|
const waitId2 = call.waitId ?? toolWaitId(call.executionId, call.call.id);
|
|
18277
18459
|
const wait = yield* waits.get(waitId2).pipe(Effect108.mapError(toClientError));
|
|
@@ -18552,7 +18734,7 @@ var replyValueFrom = (content) => {
|
|
|
18552
18734
|
const text = content.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
18553
18735
|
if (text.length === 0)
|
|
18554
18736
|
return Option30.none();
|
|
18555
|
-
return
|
|
18737
|
+
return Schema99.decodeUnknownOption(Schema99.UnknownFromJsonString)(text);
|
|
18556
18738
|
};
|
|
18557
18739
|
var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
18558
18740
|
const makeExecutionClient = yield* client;
|
|
@@ -18632,7 +18814,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18632
18814
|
status: "queued",
|
|
18633
18815
|
metadata: { operation: "envelope-send" },
|
|
18634
18816
|
createdAt
|
|
18635
|
-
}).pipe(Effect109.catchIf(
|
|
18817
|
+
}).pipe(Effect109.catchIf(Schema99.is(exports_execution_repository.DuplicateExecution), () => Effect109.void), Effect109.mapError(toClientError));
|
|
18636
18818
|
}
|
|
18637
18819
|
const maxSequence3 = yield* eventLog.maxSequence(executionId).pipe(Effect109.mapError(toClientError));
|
|
18638
18820
|
return yield* envelopes.send({
|
|
@@ -18878,7 +19060,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18878
19060
|
return records.map(toWaitView);
|
|
18879
19061
|
}),
|
|
18880
19062
|
listExecutions: Effect109.fn("Client.runtime.listExecutions")(function* (input) {
|
|
18881
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19063
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema99.decodeEffect(exports_pagination_schema.ExecutionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })));
|
|
18882
19064
|
const result = yield* executionRepository.list({
|
|
18883
19065
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
18884
19066
|
...input.status === undefined ? {} : { status: input.status },
|
|
@@ -18928,13 +19110,13 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18928
19110
|
}).pipe(Effect109.mapError(toClientError));
|
|
18929
19111
|
}),
|
|
18930
19112
|
listSessions: Effect109.fn("Client.runtime.listSessions")(function* (input) {
|
|
18931
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19113
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema99.decodeEffect(exports_pagination_schema.SessionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })));
|
|
18932
19114
|
const result = yield* sessionRepository.list({
|
|
18933
19115
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
18934
19116
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
18935
19117
|
...cursor === undefined ? {} : { cursor }
|
|
18936
19118
|
});
|
|
18937
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
19119
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema99.encodeEffect(exports_pagination_schema.SessionCursorCodec)({
|
|
18938
19120
|
id: result.nextCursor.id,
|
|
18939
19121
|
at: result.nextCursor.updatedAt
|
|
18940
19122
|
});
|
|
@@ -18947,7 +19129,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
18947
19129
|
const session = yield* sessionRepository.get(input.session_id).pipe(Effect109.mapError(toClientError));
|
|
18948
19130
|
if (session === undefined)
|
|
18949
19131
|
return yield* ClientError.make({ message: `Session not found: ${input.session_id}` });
|
|
18950
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
19132
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema99.decodeEffect(exports_pagination_schema.ExecutionCursorCodec)(input.cursor).pipe(Effect109.map(({ id, at }) => ({ id, updatedAt: at })), Effect109.mapError(toClientError));
|
|
18951
19133
|
const result = yield* executionRepository.list({
|
|
18952
19134
|
sessionId: input.session_id,
|
|
18953
19135
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
@@ -19018,7 +19200,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19018
19200
|
if (instance === undefined || instance.status === "destroyed") {
|
|
19019
19201
|
return yield* ResidentNotFound.make({ kind: input.kind, key: input.key });
|
|
19020
19202
|
}
|
|
19021
|
-
const encoded = yield*
|
|
19203
|
+
const encoded = yield* Schema99.encodeUnknownEffect(input.command.input)(input.input).pipe(Effect109.mapError(toClientError));
|
|
19022
19204
|
const inputRef = inputSchemaRef(input.command.name);
|
|
19023
19205
|
const outputRef = outputSchemaRef(input.command.name);
|
|
19024
19206
|
if (Option30.isSome(schemaRegistry)) {
|
|
@@ -19065,7 +19247,7 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19065
19247
|
message: "reply carried no decodable content"
|
|
19066
19248
|
});
|
|
19067
19249
|
}
|
|
19068
|
-
return yield*
|
|
19250
|
+
return yield* Schema99.decodeUnknownEffect(input.command.output)(replyValue.value).pipe(Effect109.mapError((issue) => CommandReplyInvalid.make({
|
|
19069
19251
|
command: input.command.name,
|
|
19070
19252
|
wait_id: outcome.wait_id,
|
|
19071
19253
|
message: errorMessage2(issue)
|
|
@@ -19106,14 +19288,14 @@ var layerFromRuntime3 = Layer84.effect(Service, Effect109.gen(function* () {
|
|
|
19106
19288
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
19107
19289
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
19108
19290
|
updatedAt: input.updated_at
|
|
19109
|
-
}).pipe(Effect109.mapError((error5) =>
|
|
19291
|
+
}).pipe(Effect109.mapError((error5) => Schema99.is(StateVersionConflict3)(error5) ? StateVersionConflict.make(error5) : toClientError(error5)))),
|
|
19110
19292
|
deleteResidentState: Effect109.fn("Client.runtime.deleteResidentState")((input) => executionState.remove({
|
|
19111
19293
|
executionId: input.execution_id,
|
|
19112
19294
|
key: input.key,
|
|
19113
19295
|
...input.expected_version === undefined ? {} : { expectedVersion: input.expected_version },
|
|
19114
19296
|
...input.idempotency_key === undefined ? {} : { idempotencyKey: input.idempotency_key },
|
|
19115
19297
|
removedAt: input.removed_at
|
|
19116
|
-
}).pipe(Effect109.mapError((error5) =>
|
|
19298
|
+
}).pipe(Effect109.mapError((error5) => Schema99.is(StateVersionConflict3)(error5) ? StateVersionConflict.make(error5) : toClientError(error5)))),
|
|
19117
19299
|
listResidentState: Effect109.fn("Client.runtime.listResidentState")((input) => executionState.list({
|
|
19118
19300
|
executionId: input.execution_id,
|
|
19119
19301
|
...input.prefix === undefined ? {} : { prefix: input.prefix },
|
|
@@ -19372,77 +19554,77 @@ import { Effect as Effect111 } from "effect";
|
|
|
19372
19554
|
var recoverPersistedFanOut = (recover) => recover().pipe(Effect111.mapError((error5) => WorkflowRuntimeError.make({ message: error5._tag })), Effect111.asVoid);
|
|
19373
19555
|
|
|
19374
19556
|
// src/runtime.ts
|
|
19375
|
-
var Dialect2 =
|
|
19557
|
+
var Dialect2 = Schema100.Literals(["pg", "mysql", "sqlite"]);
|
|
19376
19558
|
|
|
19377
|
-
class NotificationFailure extends
|
|
19378
|
-
reason:
|
|
19559
|
+
class NotificationFailure extends Schema100.TaggedErrorClass()("NotificationFailure", {
|
|
19560
|
+
reason: Schema100.String
|
|
19379
19561
|
}) {
|
|
19380
19562
|
}
|
|
19381
19563
|
|
|
19382
|
-
class ClusterFailure extends
|
|
19383
|
-
reason:
|
|
19564
|
+
class ClusterFailure extends Schema100.TaggedErrorClass()("ClusterFailure", {
|
|
19565
|
+
reason: Schema100.String
|
|
19384
19566
|
}) {
|
|
19385
19567
|
}
|
|
19386
19568
|
|
|
19387
|
-
class SqlFailure extends
|
|
19388
|
-
category:
|
|
19389
|
-
operation:
|
|
19390
|
-
retryable:
|
|
19569
|
+
class SqlFailure extends Schema100.TaggedErrorClass()("SqlFailure", {
|
|
19570
|
+
category: Schema100.Literals(["connection", "statement", "unknown"]),
|
|
19571
|
+
operation: Schema100.Literals(["acquire", "migrate", "verify", "notify", "readiness"]),
|
|
19572
|
+
retryable: Schema100.Boolean
|
|
19391
19573
|
}) {
|
|
19392
19574
|
}
|
|
19393
|
-
var SqlDialect =
|
|
19575
|
+
var SqlDialect = Schema100.Literals(["sqlite", "pg", "mysql", "mssql", "clickhouse"]);
|
|
19394
19576
|
|
|
19395
|
-
class DatabaseDialectMismatch extends
|
|
19577
|
+
class DatabaseDialectMismatch extends Schema100.TaggedErrorClass()("DatabaseDialectMismatch", { expected: Dialect2, actual: SqlDialect }) {
|
|
19396
19578
|
}
|
|
19397
19579
|
|
|
19398
|
-
class DatabaseAlreadyOwned extends
|
|
19580
|
+
class DatabaseAlreadyOwned extends Schema100.TaggedErrorClass()("DatabaseAlreadyOwned", {
|
|
19399
19581
|
databaseIdentity: DatabaseIdentity
|
|
19400
19582
|
}) {
|
|
19401
19583
|
}
|
|
19402
19584
|
|
|
19403
|
-
class UnsupportedTopology extends
|
|
19404
|
-
reason:
|
|
19585
|
+
class UnsupportedTopology extends Schema100.TaggedErrorClass()("UnsupportedTopology", {
|
|
19586
|
+
reason: Schema100.String
|
|
19405
19587
|
}) {
|
|
19406
19588
|
}
|
|
19407
19589
|
|
|
19408
|
-
class MigratorError extends
|
|
19409
|
-
reason:
|
|
19590
|
+
class MigratorError extends Schema100.TaggedErrorClass()("MigratorError", {
|
|
19591
|
+
reason: Schema100.String
|
|
19410
19592
|
}) {
|
|
19411
19593
|
}
|
|
19412
19594
|
|
|
19413
|
-
class SchemaHeadMismatch extends
|
|
19414
|
-
expected:
|
|
19415
|
-
actual:
|
|
19595
|
+
class SchemaHeadMismatch extends Schema100.TaggedErrorClass()("SchemaHeadMismatch", {
|
|
19596
|
+
expected: Schema100.String,
|
|
19597
|
+
actual: Schema100.String
|
|
19416
19598
|
}) {
|
|
19417
19599
|
}
|
|
19418
19600
|
|
|
19419
|
-
class HostUnavailable extends
|
|
19420
|
-
host:
|
|
19421
|
-
reason:
|
|
19601
|
+
class HostUnavailable extends Schema100.TaggedErrorClass()("HostUnavailable", {
|
|
19602
|
+
host: Schema100.String,
|
|
19603
|
+
reason: Schema100.String
|
|
19422
19604
|
}) {
|
|
19423
19605
|
}
|
|
19424
|
-
var RuntimeTopologyCause =
|
|
19606
|
+
var RuntimeTopologyCause = Schema100.Union([
|
|
19425
19607
|
ClusterFailure,
|
|
19426
19608
|
DatabaseDialectMismatch,
|
|
19427
19609
|
DatabaseAlreadyOwned,
|
|
19428
19610
|
UnsupportedTopology
|
|
19429
19611
|
]);
|
|
19430
|
-
var RuntimeMigrationCause =
|
|
19612
|
+
var RuntimeMigrationCause = Schema100.Union([
|
|
19431
19613
|
SqlFailure,
|
|
19432
19614
|
MigratorError,
|
|
19433
19615
|
SchemaHeadMismatch
|
|
19434
19616
|
]);
|
|
19435
|
-
var RuntimeReadinessCause =
|
|
19617
|
+
var RuntimeReadinessCause = Schema100.Union([
|
|
19436
19618
|
SqlFailure,
|
|
19437
19619
|
NotificationFailure,
|
|
19438
19620
|
ClusterFailure,
|
|
19439
19621
|
HostUnavailable
|
|
19440
19622
|
]);
|
|
19441
19623
|
|
|
19442
|
-
class RuntimeTopologyError extends
|
|
19624
|
+
class RuntimeTopologyError extends Schema100.TaggedErrorClass()("RuntimeTopologyError", {
|
|
19443
19625
|
dialect: Dialect2,
|
|
19444
|
-
role:
|
|
19445
|
-
nextAction:
|
|
19626
|
+
role: Schema100.Literals(["embedded", "runner", "client"]),
|
|
19627
|
+
nextAction: Schema100.Literals([
|
|
19446
19628
|
"use-embedded",
|
|
19447
19629
|
"use-postgres-or-mysql",
|
|
19448
19630
|
"use-client-constructor",
|
|
@@ -19453,39 +19635,39 @@ class RuntimeTopologyError extends Schema99.TaggedErrorClass()("RuntimeTopologyE
|
|
|
19453
19635
|
}) {
|
|
19454
19636
|
}
|
|
19455
19637
|
|
|
19456
|
-
class RuntimeMigrationError extends
|
|
19638
|
+
class RuntimeMigrationError extends Schema100.TaggedErrorClass()("RuntimeMigrationError", {
|
|
19457
19639
|
dialect: Dialect2,
|
|
19458
|
-
phase:
|
|
19459
|
-
nextAction:
|
|
19640
|
+
phase: Schema100.Literals(["apply", "verify"]),
|
|
19641
|
+
nextAction: Schema100.Literals(["retry", "inspect-schema", "run-compatible-release"]),
|
|
19460
19642
|
cause: RuntimeMigrationCause
|
|
19461
19643
|
}) {
|
|
19462
19644
|
}
|
|
19463
19645
|
|
|
19464
|
-
class RuntimeReadinessError extends
|
|
19465
|
-
phase:
|
|
19646
|
+
class RuntimeReadinessError extends Schema100.TaggedErrorClass()("RuntimeReadinessError", {
|
|
19647
|
+
phase: Schema100.Literals(["database", "notification", "cluster", "hosts"]),
|
|
19466
19648
|
cause: RuntimeReadinessCause
|
|
19467
19649
|
}) {
|
|
19468
19650
|
}
|
|
19469
|
-
var RuntimeCapabilityStatus =
|
|
19470
|
-
|
|
19471
|
-
enabled:
|
|
19472
|
-
source:
|
|
19473
|
-
health:
|
|
19651
|
+
var RuntimeCapabilityStatus = Schema100.Union([
|
|
19652
|
+
Schema100.Struct({
|
|
19653
|
+
enabled: Schema100.Literal(false),
|
|
19654
|
+
source: Schema100.Literals(["local-host", "role-unavailable"]),
|
|
19655
|
+
health: Schema100.Literal("not-applicable")
|
|
19474
19656
|
}),
|
|
19475
|
-
|
|
19476
|
-
enabled:
|
|
19477
|
-
source:
|
|
19478
|
-
health:
|
|
19657
|
+
Schema100.Struct({
|
|
19658
|
+
enabled: Schema100.Literal(true),
|
|
19659
|
+
source: Schema100.Literal("local-host"),
|
|
19660
|
+
health: Schema100.Literals(["healthy", "unhealthy"])
|
|
19479
19661
|
})
|
|
19480
19662
|
]);
|
|
19481
|
-
var ReadinessStatus2 =
|
|
19482
|
-
ready:
|
|
19483
|
-
role:
|
|
19663
|
+
var ReadinessStatus2 = Schema100.Struct({
|
|
19664
|
+
ready: Schema100.Literal(true),
|
|
19665
|
+
role: Schema100.Literals(["embedded", "runner", "client"]),
|
|
19484
19666
|
dialect: Dialect2,
|
|
19485
19667
|
databaseIdentity: DatabaseIdentity,
|
|
19486
|
-
schemaHead:
|
|
19487
|
-
notification:
|
|
19488
|
-
capabilities:
|
|
19668
|
+
schemaHead: Schema100.String,
|
|
19669
|
+
notification: Schema100.Literals(["pg-listen-notify", "polling", "in-process"]),
|
|
19670
|
+
capabilities: Schema100.Struct({
|
|
19489
19671
|
fanOut: RuntimeCapabilityStatus,
|
|
19490
19672
|
workflowDefinition: RuntimeCapabilityStatus
|
|
19491
19673
|
})
|
|
@@ -19499,7 +19681,7 @@ var normalizeHost = (layer65, _role, _dialect) => layer65.pipe(Layer86.catchCaus
|
|
|
19499
19681
|
role: _role,
|
|
19500
19682
|
nextAction: _role === "embedded" ? "use-embedded" : "use-different-database",
|
|
19501
19683
|
cause: ClusterFailure.make({ reason: "cluster configuration is incompatible" })
|
|
19502
|
-
}) : error5), "host-layer", (error5) =>
|
|
19684
|
+
}) : error5), "host-layer", (error5) => Schema100.is(RuntimeConfigurationError)(error5) || Schema100.is(RuntimeTopologyError)(error5) || Schema100.is(RuntimeMigrationError)(error5))))));
|
|
19503
19685
|
var actualDialect = (sql) => sql.onDialectOrElse({
|
|
19504
19686
|
sqlite: () => "sqlite",
|
|
19505
19687
|
pg: () => "pg",
|