@relayfx/sdk 0.2.16 → 0.3.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./index-per7tyzq.js";
2
+ import"./index-d3dme13d.js";
3
3
  import {
4
4
  AiError,
5
5
  Chat,
@@ -34,7 +34,7 @@ import {
34
34
  exports_tool_executor,
35
35
  exports_tool_output,
36
36
  exports_turn_policy
37
- } from "./index-5x686v8w.js";
37
+ } from "./index-c2skef55.js";
38
38
 
39
39
  // src/ai.ts
40
40
  var relayAiPackage = "@relayfx/sdk/ai";
@@ -7,7 +7,7 @@ import {
7
7
  RuntimeMigrationError,
8
8
  SqlFailure,
9
9
  exports_runtime_database
10
- } from "./index-a6vwwhcp.js";
10
+ } from "./index-9k4k3wq1.js";
11
11
 
12
12
  // src/migration-errors.ts
13
13
  import { Cause, Effect, Function } from "effect";
@@ -52,7 +52,7 @@ import {
52
52
  exports_wait_service,
53
53
  exports_wait_signal,
54
54
  exports_workflow_definition_repository
55
- } from "./index-5x686v8w.js";
55
+ } from "./index-c2skef55.js";
56
56
 
57
57
  // src/operation.ts
58
58
  var exports_operation = {};
@@ -101,6 +101,8 @@ __export(exports_operation, {
101
101
  PendingToolCall: () => PendingToolCall,
102
102
  PendingToolApprovalList: () => PendingToolApprovalList,
103
103
  PendingToolApproval: () => PendingToolApproval,
104
+ PageExecutionEventsResult: () => PageExecutionEventsResult,
105
+ PageExecutionEventsInput: () => PageExecutionEventsInput,
104
106
  ListWaitsInput: () => ListWaitsInput,
105
107
  ListTopicSubscriptionsInput: () => ListTopicSubscriptionsInput,
106
108
  ListToolAttemptsInput: () => ListToolAttemptsInput,
@@ -129,6 +131,7 @@ __export(exports_operation, {
129
131
  FollowExecutionInput: () => FollowExecutionInput,
130
132
  ExecutionListChange: () => ExecutionListChange,
131
133
  ExecutionInspection: () => ExecutionInspection,
134
+ ExecutionEventPageDirection: () => ExecutionEventPageDirection,
132
135
  ExecutionCursor: () => ExecutionCursor,
133
136
  EventLogCursorNotFound: () => EventLogCursorNotFound,
134
137
  EnvelopeReadyReleased: () => EnvelopeReadyReleased,
@@ -675,6 +678,27 @@ var ReplayExecutionInput = Schema.Struct({
675
678
  var ReplayExecutionResult = Schema.Struct({
676
679
  events: Schema.Array(exports_execution_schema.ExecutionEvent)
677
680
  }).annotate({ identifier: "Relay.Operation.ReplayExecutionResult" });
681
+ var ExecutionEventPageDirection = Schema.Literals(["forward", "backward"]).annotate({
682
+ identifier: "Relay.Operation.ExecutionEventPageDirection"
683
+ });
684
+ var PageExecutionEventsInput = Schema.Struct({
685
+ execution_id: exports_ids_schema.ExecutionId,
686
+ direction: ExecutionEventPageDirection,
687
+ after_cursor: Schema.optionalKey(exports_shared_schema.NonEmptyString),
688
+ before_cursor: Schema.optionalKey(exports_shared_schema.NonEmptyString),
689
+ limit: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(1000)))
690
+ }).check(Schema.makeFilter((input) => {
691
+ if (input.direction === "forward") {
692
+ return input.before_cursor === undefined ? undefined : { path: ["before_cursor"], issue: "forward pages accept only after_cursor" };
693
+ }
694
+ return input.after_cursor === undefined ? undefined : { path: ["after_cursor"], issue: "backward pages accept only before_cursor" };
695
+ })).annotate({ identifier: "Relay.Operation.PageExecutionEventsInput" });
696
+ var PageExecutionEventsResult = Schema.Struct({
697
+ events: Schema.Array(exports_execution_schema.ExecutionEvent),
698
+ has_more: Schema.Boolean,
699
+ oldest_cursor: Schema.optionalKey(exports_shared_schema.NonEmptyString),
700
+ newest_cursor: Schema.optionalKey(exports_shared_schema.NonEmptyString)
701
+ }).annotate({ identifier: "Relay.Operation.PageExecutionEventsResult" });
678
702
  var RunnerSummary = Schema.Struct({
679
703
  address: Schema.String,
680
704
  healthy: Schema.Boolean,
@@ -756,6 +780,7 @@ __export(exports_client, {
756
780
  registerAgent: () => registerAgent,
757
781
  registerAddressBookRoute: () => registerAddressBookRoute,
758
782
  publishTopic: () => publishTopic,
783
+ pageExecutionEvents: () => pageExecutionEvents,
759
784
  listWaits: () => listWaits,
760
785
  listTopicSubscriptions: () => listTopicSubscriptions,
761
786
  listToolAttempts: () => listToolAttempts,
@@ -1873,6 +1898,26 @@ var layerFromRuntime = Layer2.effect(Service2, Effect2.gen(function* () {
1873
1898
  }).pipe(Effect2.mapError(toClientError));
1874
1899
  return { events };
1875
1900
  }),
1901
+ pageExecutionEvents: Effect2.fn("Client.runtime.pageExecutionEvents")(function* (input) {
1902
+ const pageInput = input.direction === "forward" ? {
1903
+ executionId: input.execution_id,
1904
+ direction: "forward",
1905
+ ...input.after_cursor === undefined ? {} : { afterCursor: input.after_cursor },
1906
+ ...input.limit === undefined ? {} : { limit: input.limit }
1907
+ } : {
1908
+ executionId: input.execution_id,
1909
+ direction: "backward",
1910
+ ...input.before_cursor === undefined ? {} : { beforeCursor: input.before_cursor },
1911
+ ...input.limit === undefined ? {} : { limit: input.limit }
1912
+ };
1913
+ const result = yield* eventLog.page(pageInput).pipe(Effect2.mapError(toStreamError));
1914
+ return {
1915
+ events: result.events,
1916
+ has_more: result.hasMore,
1917
+ ...result.oldestCursor === undefined ? {} : { oldest_cursor: result.oldestCursor },
1918
+ ...result.newestCursor === undefined ? {} : { newest_cursor: result.newestCursor }
1919
+ };
1920
+ }),
1876
1921
  listRunners: Effect2.fn("Client.runtime.listRunners")(function* (_) {
1877
1922
  const runners = yield* clusterRegistry.listRunners().pipe(Effect2.mapError(toClientError));
1878
1923
  return {
@@ -2230,6 +2275,7 @@ var testLayer = (implementation) => Layer2.succeed(Service2, Service2.of({
2230
2275
  getEntity: implementation.getEntity ?? (() => Effect2.void.pipe(Effect2.as(undefined))),
2231
2276
  destroyEntity: implementation.destroyEntity ?? (() => Effect2.fail(ClientError.make({ message: "Entity service unavailable" }))),
2232
2277
  listEntities: implementation.listEntities ?? (() => Effect2.succeed([])),
2278
+ pageExecutionEvents: implementation.pageExecutionEvents ?? (() => Effect2.fail(ClientError.make({ message: "Execution event paging unavailable" }))),
2233
2279
  streamSession: implementation.streamSession ?? (() => Stream.empty),
2234
2280
  watchExecutions: implementation.watchExecutions ?? (() => Stream.empty),
2235
2281
  getPresence: implementation.getPresence ?? ((scope) => Effect2.succeed({ scope, entries: [], observed_at: 0 })),
@@ -2350,6 +2396,10 @@ var replayExecution = Effect2.fn("Client.replayExecution.call")(function* (input
2350
2396
  const service = yield* Service2;
2351
2397
  return yield* service.replayExecution(input);
2352
2398
  });
2399
+ var pageExecutionEvents = Effect2.fn("Client.pageExecutionEvents.call")(function* (input) {
2400
+ const service = yield* Service2;
2401
+ return yield* service.pageExecutionEvents(input);
2402
+ });
2353
2403
  var listRunners = Effect2.fn("Client.listRunners.call")(function* () {
2354
2404
  const service = yield* Service2;
2355
2405
  return yield* service.listRunners();
@@ -2807,4 +2857,4 @@ var layerClient = (options) => {
2807
2857
  return normalizeHost(publicGraph(runner, options.databaseLayer, "client"), "client", options.databaseLayer[DatabaseDialect]);
2808
2858
  };
2809
2859
 
2810
- export { exports_operation, exports_command, Service2 as Service, exports_client, exports_runtime_database, makeDatabaseIdentity, DatabaseDialect, ConfigFailure, SqlFailure, DatabaseAlreadyOwned, MigratorError, SchemaHeadMismatch, RuntimeConfigurationError, RuntimeTopologyError, RuntimeMigrationError, exports_runtime };
2860
+ export { exports_operation, exports_command, Service2 as Service, exports_client, exports_runtime_database, makeDatabaseIdentity, DatabaseDialect, HostLayerError, ConfigFailure, SqlFailure, DatabaseAlreadyOwned, MigratorError, SchemaHeadMismatch, RuntimeConfigurationError, RuntimeTopologyError, RuntimeMigrationError, exports_runtime };
@@ -4549,6 +4549,7 @@ var exports_execution_event_repository = {};
4549
4549
  __export(exports_execution_event_repository, {
4550
4550
  testLayer: () => testLayer13,
4551
4551
  sumUsage: () => sumUsage,
4552
+ page: () => page,
4552
4553
  notifyAppended: () => notifyAppended,
4553
4554
  memoryLayer: () => memoryLayer13,
4554
4555
  maxSequence: () => maxSequence,
@@ -4651,7 +4652,20 @@ var ExecutionEventRow = Schema31.Struct({
4651
4652
  created_at: Schema31.Union([Schema31.Date, Schema31.String, Schema31.Finite])
4652
4653
  }).annotate({ identifier: "Relay.ExecutionEvent.Row" });
4653
4654
  var maxListLimit = 1000;
4655
+ var defaultPageLimit = 256;
4654
4656
  var listLimit = (input) => input.limit ?? maxListLimit;
4657
+ var pageLimit = (input) => Math.max(1, Math.min(maxListLimit, Math.trunc(input.limit ?? defaultPageLimit)));
4658
+ var pageResult = (events, limit, direction) => {
4659
+ const hasMore = events.length > limit;
4660
+ const retained = events.slice(0, limit);
4661
+ const ordered = direction === "backward" ? retained.toReversed() : retained;
4662
+ return {
4663
+ events: ordered,
4664
+ hasMore,
4665
+ ...ordered[0] === undefined ? {} : { oldestCursor: ordered[0].cursor },
4666
+ ...ordered.at(-1) === undefined ? {} : { newestCursor: ordered.at(-1).cursor }
4667
+ };
4668
+ };
4655
4669
  var usageReportedEventType = "model.usage.reported";
4656
4670
  var eventUsageTokens = (event) => {
4657
4671
  if (event.type !== usageReportedEventType)
@@ -4943,6 +4957,42 @@ var layer13 = Layer14.effect(Service14, Effect15.gen(function* () {
4943
4957
  const rows = yield* selectAfterSequence(tenantId, input).pipe(Effect15.mapError(toRepositoryError9));
4944
4958
  return yield* decodeEvents(rows);
4945
4959
  });
4960
+ const page = Effect15.fn("ExecutionEventRepository.page")(function* (input) {
4961
+ const tenantId = yield* current();
4962
+ const cursor = input.direction === "forward" ? input.afterCursor : input.beforeCursor;
4963
+ const cursorRows = cursor === undefined ? [] : yield* sql`
4964
+ SELECT ${columns}
4965
+ FROM relay_execution_events
4966
+ WHERE tenant_id = ${tenantId} AND execution_id = ${input.executionId}
4967
+ AND ${sql.literal(cursorColumn)} = ${cursor}
4968
+ LIMIT 1
4969
+ `.pipe(Effect15.mapError(toRepositoryError9));
4970
+ const cursorRow = cursorRows[0];
4971
+ if (cursor !== undefined && cursorRow === undefined) {
4972
+ return yield* ExecutionEventCursorNotFound.make({
4973
+ execution_id: input.executionId,
4974
+ cursor
4975
+ });
4976
+ }
4977
+ const boundary = cursorRow === undefined ? undefined : toEvent(yield* decodeRow8(cursorRow)).sequence;
4978
+ const limit = pageLimit(input);
4979
+ const rows = input.direction === "forward" ? yield* sql`
4980
+ SELECT ${columns}
4981
+ FROM relay_execution_events
4982
+ WHERE tenant_id = ${tenantId} AND execution_id = ${input.executionId}
4983
+ ${boundary === undefined ? sql`` : sql`AND sequence > ${boundary}`}
4984
+ ORDER BY sequence ASC
4985
+ LIMIT ${sql.literal(String(limit + 1))}
4986
+ `.pipe(Effect15.mapError(toRepositoryError9)) : yield* sql`
4987
+ SELECT ${columns}
4988
+ FROM relay_execution_events
4989
+ WHERE tenant_id = ${tenantId} AND execution_id = ${input.executionId}
4990
+ ${boundary === undefined ? sql`` : sql`AND sequence < ${boundary}`}
4991
+ ORDER BY sequence DESC
4992
+ LIMIT ${sql.literal(String(limit + 1))}
4993
+ `.pipe(Effect15.mapError(toRepositoryError9));
4994
+ return pageResult(yield* decodeEvents(rows), limit, input.direction);
4995
+ });
4946
4996
  return Service14.of({
4947
4997
  signalTransport: bus.transport,
4948
4998
  append,
@@ -4955,7 +5005,8 @@ var layer13 = Layer14.effect(Service14, Effect15.gen(function* () {
4955
5005
  sumUsage,
4956
5006
  notifyAppended,
4957
5007
  appendedSignals,
4958
- listAfterSequence
5008
+ listAfterSequence,
5009
+ page
4959
5010
  });
4960
5011
  }));
4961
5012
  var layerWithBus = layer13.pipe(Layer14.provide(layerFromDialect));
@@ -5017,10 +5068,24 @@ var memoryLayer13 = Layer14.effect(Service14, Effect15.gen(function* () {
5017
5068
  listAfterSequence: Effect15.fn("ExecutionEventRepository.memory.listAfterSequence")((input) => {
5018
5069
  const executionEvents = events.get(input.executionId) ?? [];
5019
5070
  return Effect15.succeed(executionEvents.filter((event) => input.afterSequence === undefined || event.sequence > input.afterSequence).toSorted((left, right) => left.sequence - right.sequence).slice(0, input.limit));
5071
+ }),
5072
+ page: Effect15.fn("ExecutionEventRepository.memory.page")(function* (input) {
5073
+ const executionEvents = (events.get(input.executionId) ?? []).toSorted((left, right) => left.sequence - right.sequence);
5074
+ const cursor = input.direction === "forward" ? input.afterCursor : input.beforeCursor;
5075
+ const boundary = cursor === undefined ? undefined : executionEvents.findIndex((event) => event.cursor === cursor);
5076
+ if (cursor !== undefined && boundary !== undefined && boundary < 0) {
5077
+ return yield* ExecutionEventCursorNotFound.make({ execution_id: input.executionId, cursor });
5078
+ }
5079
+ const limit = pageLimit(input);
5080
+ const candidates = input.direction === "forward" ? executionEvents.slice(boundary === undefined ? 0 : boundary + 1, (boundary ?? -1) + limit + 2) : executionEvents.slice(0, boundary ?? executionEvents.length).toReversed().slice(0, limit + 1);
5081
+ return pageResult(candidates, limit, input.direction);
5020
5082
  })
5021
5083
  });
5022
5084
  }));
5023
- var testLayer13 = (implementation) => Layer14.succeed(Service14, Service14.of(implementation));
5085
+ var testLayer13 = (implementation) => Layer14.succeed(Service14, Service14.of({
5086
+ ...implementation,
5087
+ page: implementation.page ?? (() => Effect15.succeed({ events: [], hasMore: false }))
5088
+ }));
5024
5089
  var append = Effect15.fn("ExecutionEventRepository.append.call")(function* (input) {
5025
5090
  const repository = yield* Service14;
5026
5091
  return yield* repository.append(input);
@@ -5029,6 +5094,10 @@ var list5 = Effect15.fn("ExecutionEventRepository.list.call")(function* (input)
5029
5094
  const repository = yield* Service14;
5030
5095
  return yield* repository.list(input);
5031
5096
  });
5097
+ var page = Effect15.fn("ExecutionEventRepository.page.call")(function* (input) {
5098
+ const repository = yield* Service14;
5099
+ return yield* repository.page(input);
5100
+ });
5032
5101
  var findBySequenceOrCursor = Effect15.fn("ExecutionEventRepository.findBySequenceOrCursor.call")(function* (input) {
5033
5102
  const repository = yield* Service14;
5034
5103
  return yield* repository.findBySequenceOrCursor(input);
@@ -5322,10 +5391,10 @@ var layerWithoutBus = Layer15.effect(Service15, Effect16.gen(function* () {
5322
5391
  ${cursor === undefined ? sql`` : sql`AND (updated_at > ${timestampParam(sql, cursor.updatedAt)} OR (updated_at = ${timestampParam(sql, cursor.updatedAt)} AND id > ${cursor.id}))`}
5323
5392
  ORDER BY updated_at ASC, id ASC LIMIT ${sql.literal(String(pageSize))}
5324
5393
  `.pipe(Effect16.mapError(toRepositoryError10));
5325
- const page = (yield* Effect16.forEach(rows, decodeRow9)).map(toRecord7);
5326
- records.push(...page);
5327
- const last = page.at(-1);
5328
- if (last === undefined || page.length < pageSize)
5394
+ const page2 = (yield* Effect16.forEach(rows, decodeRow9)).map(toRecord7);
5395
+ records.push(...page2);
5396
+ const last = page2.at(-1);
5397
+ if (last === undefined || page2.length < pageSize)
5329
5398
  break;
5330
5399
  cursor = { updatedAt: last.updatedAt, id: last.id };
5331
5400
  }
@@ -5369,9 +5438,9 @@ var memoryLayer14 = Layer15.sync(Service15, () => {
5369
5438
  return yield* Effect16.sync(() => {
5370
5439
  const limit = listLimit2(input);
5371
5440
  const matched = Array.from(records.values()).filter((record2) => input.rootAddressId === undefined || record2.rootAddressId === input.rootAddressId).filter((record2) => input.sessionId === undefined || record2.sessionId === input.sessionId).filter((record2) => input.status === undefined || record2.status === input.status).toSorted(compareDesc).filter((record2) => afterCursor(record2, input.cursor));
5372
- const page = matched.slice(0, limit).map(cloneRecord5);
5373
- const nextCursor = nextCursorOf(page, matched.length, limit);
5374
- return nextCursor === undefined ? { records: page } : { records: page, nextCursor };
5441
+ const page2 = matched.slice(0, limit).map(cloneRecord5);
5442
+ const nextCursor = nextCursorOf(page2, matched.length, limit);
5443
+ return nextCursor === undefined ? { records: page2 } : { records: page2, nextCursor };
5375
5444
  });
5376
5445
  }),
5377
5446
  transition: Effect16.fn("ExecutionRepository.memory.transition")(function* (input) {
@@ -7741,9 +7810,9 @@ var memoryLayer23 = Layer24.sync(Service24, () => {
7741
7810
  list: Effect25.fn("SessionRepository.memory.list")((input) => Effect25.sync(() => {
7742
7811
  const limit = listLimit3(input);
7743
7812
  const matched = Array.from(sessions.values()).filter((record2) => input.rootAddressId === undefined || record2.rootAddressId === input.rootAddressId).toSorted(compareDesc2).filter((record2) => afterCursor2(record2, input.cursor));
7744
- const page = matched.slice(0, limit).map(cloneSession);
7745
- const nextCursor = nextCursorOf2(page, matched.length, limit);
7746
- return nextCursor === undefined ? { records: page } : { records: page, nextCursor };
7813
+ const page2 = matched.slice(0, limit).map(cloneSession);
7814
+ const nextCursor = nextCursorOf2(page2, matched.length, limit);
7815
+ return nextCursor === undefined ? { records: page2 } : { records: page2, nextCursor };
7747
7816
  })),
7748
7817
  touch: Effect25.fn("SessionRepository.memory.touch")(function* (input) {
7749
7818
  const current2 = sessions.get(input.id);
@@ -10324,6 +10393,7 @@ __export(exports_event_log_service, {
10324
10393
  sumUsage: () => sumUsage2,
10325
10394
  stream: () => stream,
10326
10395
  replay: () => replay,
10396
+ page: () => page2,
10327
10397
  memoryLayer: () => memoryLayer29,
10328
10398
  maxSequence: () => maxSequence2,
10329
10399
  layerFromRepository: () => layerFromRepository2,
@@ -10372,7 +10442,27 @@ class EventLogError extends Schema47.TaggedErrorClass()("EventLogError", {
10372
10442
  class Service30 extends Context30.Service()("@relayfx/runtime/execution/event-log-service/Service") {
10373
10443
  }
10374
10444
  var defaultReplayLimit = 1000;
10445
+ var defaultPageLimit2 = 256;
10375
10446
  var limitOf = (input) => input.limit ?? defaultReplayLimit;
10447
+ var pageLimitOf = (input) => Math.max(1, Math.min(defaultReplayLimit, Math.trunc(input.limit ?? defaultPageLimit2)));
10448
+ var pageEvents = (events, input) => {
10449
+ const cursor = input.direction === "forward" ? input.afterCursor : input.beforeCursor;
10450
+ const boundary = cursor === undefined ? undefined : events.findIndex((event) => event.cursor === cursor);
10451
+ if (cursor !== undefined && boundary !== undefined && boundary < 0) {
10452
+ return Effect32.fail(EventLogCursorNotFound.make({ execution_id: input.executionId, cursor }));
10453
+ }
10454
+ const limit = pageLimitOf(input);
10455
+ const candidates = input.direction === "forward" ? events.slice(boundary === undefined ? 0 : boundary + 1, (boundary ?? -1) + limit + 2) : events.slice(0, boundary ?? events.length).toReversed().slice(0, limit + 1);
10456
+ const hasMore = candidates.length > limit;
10457
+ const retained = candidates.slice(0, limit);
10458
+ const ordered = input.direction === "backward" ? retained.toReversed() : retained;
10459
+ return Effect32.succeed({
10460
+ events: ordered,
10461
+ hasMore,
10462
+ ...ordered[0] === undefined ? {} : { oldestCursor: ordered[0].cursor },
10463
+ ...ordered.at(-1) === undefined ? {} : { newestCursor: ordered.at(-1).cursor }
10464
+ });
10465
+ };
10376
10466
  var eventUsageTokens2 = (event) => {
10377
10467
  if (event.type !== "model.usage.reported")
10378
10468
  return 0;
@@ -10520,6 +10610,7 @@ var layerFromRepository2 = Layer30.effect(Service30, Effect32.gen(function* () {
10520
10610
  yield* recordEventReplayed("repository", replay.history.length);
10521
10611
  return replay.history;
10522
10612
  }),
10613
+ page: Effect32.fn("EventLog.repository.page")((input) => repository.page(input).pipe(Effect32.mapError(mapRepositoryListError))),
10523
10614
  stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect32.map(({ history, sequence }) => {
10524
10615
  const replay = Stream5.fromIterable(history);
10525
10616
  return history.some(isTerminal) ? replay : replay.pipe(Stream5.concat(liveTail(repository, hubs, input, history.at(-1)?.sequence ?? sequence).pipe(Stream5.takeUntil(isTerminal))));
@@ -10575,6 +10666,10 @@ var memoryLayer29 = Layer30.effect(Service30, Effect32.gen(function* () {
10575
10666
  yield* recordEventReplayed("memory", replay.history.length);
10576
10667
  return replay.history;
10577
10668
  }),
10669
+ page: Effect32.fn("EventLog.memory.page")(function* (input) {
10670
+ const executionEvents = yield* allEvents(input.executionId);
10671
+ return yield* pageEvents(executionEvents, input);
10672
+ }),
10578
10673
  stream: (input) => Stream5.unwrap(loadReplay(input).pipe(Effect32.map(({ history, sequence }) => {
10579
10674
  const replay = Stream5.fromIterable(history);
10580
10675
  return history.some(isTerminal) ? replay : replay.pipe(Stream5.concat(liveEvents(pubsub, input, history, sequence)));
@@ -10609,7 +10704,10 @@ var memoryLayer29 = Layer30.effect(Service30, Effect32.gen(function* () {
10609
10704
  })
10610
10705
  });
10611
10706
  }));
10612
- var testLayer27 = (implementation) => Layer30.succeed(Service30, Service30.of(implementation));
10707
+ var testLayer27 = (implementation) => Layer30.succeed(Service30, Service30.of({
10708
+ ...implementation,
10709
+ page: implementation.page ?? (() => Effect32.succeed({ events: [], hasMore: false }))
10710
+ }));
10613
10711
  var appendIdempotentTo = Function3.dual(2, (eventLog, input) => eventLog.append(input).pipe(Effect32.catchTag("EventLogError", (error5) => eventLog.findBySequenceOrCursor({
10614
10712
  executionId: input.execution_id,
10615
10713
  sequence: input.sequence,
@@ -10630,6 +10728,10 @@ var replay = Effect32.fn("EventLog.replay.call")(function* (input) {
10630
10728
  const service = yield* Service30;
10631
10729
  return yield* service.replay(input);
10632
10730
  });
10731
+ var page2 = Effect32.fn("EventLog.page.call")(function* (input) {
10732
+ const service = yield* Service30;
10733
+ return yield* service.page(input);
10734
+ });
10633
10735
  var findBySequenceOrCursor2 = Effect32.fn("EventLog.findBySequenceOrCursor.call")(function* (input) {
10634
10736
  const service = yield* Service30;
10635
10737
  return yield* service.findBySequenceOrCursor(input);
@@ -19893,7 +19995,7 @@ var layerFromServices2 = Layer86.effect(Service66, Effect100.gen(function* () {
19893
19995
  return Service66.of({
19894
19996
  stream: (input) => Stream14.unwrap(Effect100.gen(function* () {
19895
19997
  const seen = yield* Ref25.make(HashSet8.empty());
19896
- const listAll = (cursor) => repository.list({ sessionId: input.sessionId, limit: 100, ...cursor === undefined ? {} : { cursor } }).pipe(Effect100.flatMap((page) => page.nextCursor === undefined ? Effect100.succeed(page.records) : listAll(page.nextCursor).pipe(Effect100.map((rest) => [...page.records, ...rest]))));
19998
+ const listAll = (cursor) => repository.list({ sessionId: input.sessionId, limit: 100, ...cursor === undefined ? {} : { cursor } }).pipe(Effect100.flatMap((page3) => page3.nextCursor === undefined ? Effect100.succeed(page3.records) : listAll(page3.nextCursor).pipe(Effect100.map((rest) => [...page3.records, ...rest]))));
19897
19999
  const discover = listAll().pipe(Effect100.flatMap((records) => Ref25.modify(seen, (known) => {
19898
20000
  const fresh = records.filter((record2) => !HashSet8.has(known, record2.id));
19899
20001
  return [fresh, fresh.reduce((set, record2) => HashSet8.add(set, record2.id), known)];
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  __export,
4
4
  exports_model_registry
5
- } from "./index-5x686v8w.js";
5
+ } from "./index-c2skef55.js";
6
6
 
7
7
  // ../ai/src/language-model/language-model-registration.ts
8
8
  var exports_language_model_registration = {};
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  exports_language_model_registration
4
- } from "./index-per7tyzq.js";
4
+ } from "./index-d3dme13d.js";
5
5
  import {
6
6
  Service,
7
7
  exports_client,
@@ -9,7 +9,7 @@ import {
9
9
  exports_operation,
10
10
  exports_runtime,
11
11
  makeDatabaseIdentity
12
- } from "./index-a6vwwhcp.js";
12
+ } from "./index-9k4k3wq1.js";
13
13
  import {
14
14
  Dialect,
15
15
  __export,
@@ -62,7 +62,7 @@ import {
62
62
  fromDbTimestamp,
63
63
  fromNullableDbTimestamp,
64
64
  timestampParam
65
- } from "./index-5x686v8w.js";
65
+ } from "./index-c2skef55.js";
66
66
 
67
67
  // src/adapter-outbox.ts
68
68
  var exports_adapter_outbox = {};
package/dist/mysql.js CHANGED
@@ -3,13 +3,13 @@ import {
3
3
  normalizeClientLayer,
4
4
  normalizeMigrationCause,
5
5
  runtimeDatabaseLayer
6
- } from "./index-6dv1dqq1.js";
6
+ } from "./index-3sv8mmz5.js";
7
7
  import {
8
8
  MigratorError,
9
9
  RuntimeMigrationError,
10
10
  SqlFailure
11
- } from "./index-a6vwwhcp.js";
12
- import"./index-5x686v8w.js";
11
+ } from "./index-9k4k3wq1.js";
12
+ import"./index-c2skef55.js";
13
13
 
14
14
  // src/mysql.ts
15
15
  import { Effect, Layer } from "effect";
package/dist/postgres.js CHANGED
@@ -3,12 +3,12 @@ import {
3
3
  normalizeClientLayer,
4
4
  normalizeMigrationCause,
5
5
  runtimeDatabaseLayer
6
- } from "./index-6dv1dqq1.js";
6
+ } from "./index-3sv8mmz5.js";
7
7
  import {
8
8
  RuntimeMigrationError,
9
9
  SqlFailure
10
- } from "./index-a6vwwhcp.js";
11
- import"./index-5x686v8w.js";
10
+ } from "./index-9k4k3wq1.js";
11
+ import"./index-c2skef55.js";
12
12
 
13
13
  // src/postgres.ts
14
14
  import { PgClient } from "@effect/sql-pg/PgClient";
package/dist/sqlite.js CHANGED
@@ -2,10 +2,11 @@
2
2
  import {
3
3
  normalizeMigrationCause,
4
4
  runtimeDatabaseLayer
5
- } from "./index-6dv1dqq1.js";
5
+ } from "./index-3sv8mmz5.js";
6
6
  import {
7
7
  DatabaseAlreadyOwned,
8
8
  DatabaseDialect,
9
+ HostLayerError,
9
10
  RuntimeConfigurationError,
10
11
  RuntimeMigrationError,
11
12
  RuntimeTopologyError,
@@ -14,7 +15,7 @@ import {
14
15
  exports_operation,
15
16
  exports_runtime,
16
17
  makeDatabaseIdentity
17
- } from "./index-a6vwwhcp.js";
18
+ } from "./index-9k4k3wq1.js";
18
19
  import {
19
20
  __export,
20
21
  exports_activity_version_registry,
@@ -59,7 +60,7 @@ import {
59
60
  exports_wait_service,
60
61
  exports_workflow_definition_repository,
61
62
  exports_workflow_schema
62
- } from "./index-5x686v8w.js";
63
+ } from "./index-c2skef55.js";
63
64
  // src/sqlite-runtime.ts
64
65
  var exports_sqlite_runtime = {};
65
66
  __export(exports_sqlite_runtime, {
@@ -73,7 +74,7 @@ __export(exports_sqlite_runtime, {
73
74
  import { layer as sqliteClientLayer } from "@effect/sql-sqlite-bun/SqliteClient";
74
75
  import { layer as sqliteMigratorLayer, run as runSqliteMigrator } from "@effect/sql-sqlite-bun/SqliteMigrator";
75
76
  import { layer as bunServicesLayer } from "@effect/platform-bun/BunServices";
76
- import { Effect as Effect2, FileSystem, Function, Layer, Path } from "effect";
77
+ import { Cause, Effect as Effect2, FileSystem, Function, Layer, Path } from "effect";
77
78
  import { SqlClient as SqlClient2 } from "effect/unstable/sql/SqlClient";
78
79
 
79
80
  // ../../migrations/sqlite/0001_baseline.sql
@@ -754,17 +755,37 @@ var layer = (options) => {
754
755
  return sql;
755
756
  })).pipe(Layer.provide(client));
756
757
  };
758
+ var isAcquisitionError = (error) => typeof error === "object" && error !== null && ("_tag" in error) && (error._tag === "RuntimeConfigurationError" || error._tag === "RuntimeTopologyError" || error._tag === "RuntimeMigrationError");
759
+ var normalizeHostError = (error) => {
760
+ if (isAcquisitionError(error))
761
+ return error;
762
+ const hostFailure = HostLayerError.make({
763
+ service: "SQLite compatibility host graph",
764
+ reason: "host layer acquisition failed"
765
+ });
766
+ Object.defineProperty(hostFailure, "originalCause", { value: error, enumerable: false });
767
+ return RuntimeConfigurationError.make({
768
+ setting: "host layers",
769
+ nextAction: "provide-host-layer",
770
+ cause: hostFailure
771
+ });
772
+ };
773
+ var normalizeHostLayer = (source) => source.pipe(Layer.catchCause((cause) => {
774
+ if (Cause.hasInterrupts(cause))
775
+ return Layer.unwrap(Effect2.failCause(Cause.map(cause, normalizeHostError)));
776
+ return Layer.unwrap(Effect2.fail(normalizeHostError(Cause.squash(cause))));
777
+ }));
757
778
  var workflowLayer = Function.dual(2, (options, handlersLayer) => {
758
779
  const sqlite = layer(options);
759
780
  const repository = exports_workflow_definition_repository.layer.pipe(Layer.provideMerge(sqlite));
760
- return exports_definition_runtime.layer.pipe(Layer.provideMerge(handlersLayer), Layer.provideMerge(repository));
781
+ return normalizeHostLayer(exports_definition_runtime.layer.pipe(Layer.provideMerge(handlersLayer), Layer.provideMerge(repository)));
761
782
  });
762
783
  var childFanOutLayer = Function.dual(2, (options, handlersLayer) => {
763
784
  const sqlite = layer(options);
764
785
  const repository = exports_child_fan_out_repository.layer.pipe(Layer.provideMerge(sqlite));
765
786
  const events = exports_event_log_service.layerFromRepository.pipe(Layer.provide(exports_execution_event_repository.layer.pipe(Layer.provide(exports_notification_bus.inProcessLayer))), Layer.provideMerge(sqlite));
766
787
  const transitions = exports_child_fan_out_transition_service.layer.pipe(Layer.provide(repository), Layer.provide(events));
767
- return exports_child_fan_out_runtime.layer.pipe(Layer.provide(handlersLayer), Layer.provide(repository), Layer.provide(transitions));
788
+ return normalizeHostLayer(exports_child_fan_out_runtime.layer.pipe(Layer.provide(handlersLayer), Layer.provide(repository), Layer.provide(transitions)));
768
789
  });
769
790
 
770
791
  // src/sqlite.ts
@@ -4,7 +4,7 @@ import { Address, Agent, ChildOrchestration, Content, Entity, Envelope, Executio
4
4
  import { ChildExecutionRepository, ChildFanOutRepository, ClusterRegistryRepository, EnvelopeRepository, ExecutionRepository, InboxRepository, ScheduleRepository, SessionRepository, SteeringRepository, ToolCallRepository, WorkflowDefinitionRepository } from "../store-sql/portable";
5
5
  import { Context, Effect, Layer, Schema, Stream } from "effect";
6
6
  import { Sharding, ShardingConfig } from "effect/unstable/cluster";
7
- import type { AckEnvelopeReadyInput, CancelExecutionAccepted, CancelExecutionInput, CancelScheduleInput, CancelScheduleResult, ClaimEnvelopeReadyInput, CreateScheduleInput, CreateScheduleResult, EnvelopeReadyAcked, EnvelopeReadyLease, EnvelopeReadyReleased, ExecutionInspection, ExecutionListChange, GetSessionInput, GetSessionResult, GetEntityStateInput, PutEntityStateInput, DeleteEntityStateInput, ListEntityStateInput, GetOrCreateEntityInput, GetEntityInput, DestroyEntityInput, ListEntitiesInput, ListExecutionsInput, ListExecutionsResult, ListInboxMessagesInput, ListTopicSubscriptionsInput, PublishTopicInput, SubscribeTopicInput, TopicPublishAccepted, TopicSubscription, UnsubscribeTopicInput, ListPendingApprovalsInput, SessionStreamItem, StreamSessionInput, WatchExecutionsInput, ListRunnersResult, ListSchedulesInput, ListSchedulesResult, ListSessionsInput, ListSessionsResult, ListWaitsInput, PendingToolApprovalList, PendingToolCallList, ListPendingToolCallsInput, FulfillToolCallInput, ClaimToolWorkInput, CompleteToolWorkInput, ReleaseToolWorkInput, ListToolAttemptsInput, ToolAttemptList, ToolOutcomeAccepted, ToolWorkLease, ToolWorkReleased, ReleaseEnvelopeReadyInput, ReplayExecutionInput, ReplayExecutionResult, ResolvePermissionInput, ResolveToolApprovalInput, RouteExecutionResult, StartExecutionInput, StartExecutionResult, SpawnChildRunInput, CancelChildFanOutInput, CancelChildFanOutResult, CreateChildFanOutInput, InspectChildFanOutInput, InspectChildFanOutResult, SteerAccepted, SteerInput, StreamExecutionInput, SubmitInboundEnvelopeAccepted, SubmitInboundEnvelopeInput, WaitView, WakeAccepted, WakeInput } from "./operation";
7
+ import type { AckEnvelopeReadyInput, CancelExecutionAccepted, CancelExecutionInput, CancelScheduleInput, CancelScheduleResult, ClaimEnvelopeReadyInput, CreateScheduleInput, CreateScheduleResult, EnvelopeReadyAcked, EnvelopeReadyLease, EnvelopeReadyReleased, ExecutionInspection, ExecutionListChange, GetSessionInput, GetSessionResult, GetEntityStateInput, PutEntityStateInput, DeleteEntityStateInput, ListEntityStateInput, GetOrCreateEntityInput, GetEntityInput, DestroyEntityInput, ListEntitiesInput, ListExecutionsInput, ListExecutionsResult, ListInboxMessagesInput, ListTopicSubscriptionsInput, PublishTopicInput, SubscribeTopicInput, TopicPublishAccepted, TopicSubscription, UnsubscribeTopicInput, ListPendingApprovalsInput, SessionStreamItem, StreamSessionInput, WatchExecutionsInput, ListRunnersResult, ListSchedulesInput, ListSchedulesResult, ListSessionsInput, ListSessionsResult, ListWaitsInput, PendingToolApprovalList, PendingToolCallList, ListPendingToolCallsInput, FulfillToolCallInput, ClaimToolWorkInput, CompleteToolWorkInput, ReleaseToolWorkInput, ListToolAttemptsInput, ToolAttemptList, ToolOutcomeAccepted, ToolWorkLease, ToolWorkReleased, ReleaseEnvelopeReadyInput, PageExecutionEventsInput, PageExecutionEventsResult, ReplayExecutionInput, ReplayExecutionResult, ResolvePermissionInput, ResolveToolApprovalInput, RouteExecutionResult, StartExecutionInput, StartExecutionResult, SpawnChildRunInput, CancelChildFanOutInput, CancelChildFanOutResult, CreateChildFanOutInput, InspectChildFanOutInput, InspectChildFanOutResult, SteerAccepted, SteerInput, StreamExecutionInput, SubmitInboundEnvelopeAccepted, SubmitInboundEnvelopeInput, WaitView, WakeAccepted, WakeInput } from "./operation";
8
8
  import { EventLogCursorNotFound } from "./operation";
9
9
  export { EventLogCursorNotFound } from "./operation";
10
10
  import { AwaitWaitInput, WaitOutcome } from "./operation";
@@ -137,6 +137,7 @@ export interface Interface {
137
137
  readonly getSession: (input: GetSessionInput) => Effect.Effect<GetSessionResult, ClientError>;
138
138
  readonly listWaits: (input: ListWaitsInput) => Effect.Effect<ReadonlyArray<WaitView>, ClientError>;
139
139
  readonly replayExecution: (input: ReplayExecutionInput) => Effect.Effect<ReplayExecutionResult, ClientError>;
140
+ readonly pageExecutionEvents: (input: PageExecutionEventsInput) => Effect.Effect<PageExecutionEventsResult, EventLogCursorNotFound | ClientError>;
140
141
  readonly listRunners: (_?: void) => Effect.Effect<ListRunnersResult, ClientError>;
141
142
  readonly routeExecution: (executionId: Ids.ExecutionId) => Effect.Effect<RouteExecutionResult, ClientError>;
142
143
  readonly send: (input: Envelope.SendInput) => Effect.Effect<Envelope.EnvelopeAccepted, ClientError>;
@@ -185,7 +186,7 @@ export interface FollowExecutionDependencies {
185
186
  export declare const followExecutionFrom: (dependencies: FollowExecutionDependencies) => (input: FollowExecutionInput) => Stream.Stream<FollowExecutionItem, EventLogCursorNotFound | ClientError>;
186
187
  export type RuntimeRequirements = AgentRegistry.Service | EntityRegistry.Service | EntityInstanceService.Service | AddressBook.Service | ExecutionService.Service | EnvelopeService.Service | WaitService.Service | EventLog.Service | SessionStream.Service | ExecutionWatch.Service | ExecutionState.Service | PresenceService.Service | EnvelopeRepository.Service | ExecutionRepository.Service | InboxRepository.Service | TopicService.Service | ToolCallRepository.Service | ChildExecutionRepository.Service | ChildFanOutRepository.Service | SessionRepository.Service | SteeringRepository.Service | ClusterRegistryRepository.Service | ScheduleRepository.Service | SkillRegistry.Service | ToolTransitionCoordinator.Service | WorkflowDefinitionRepository.Service | Sharding.Sharding | ShardingConfig.ShardingConfig;
187
188
  export declare const layerFromRuntime: Layer.Layer<Service, never, RuntimeRequirements>;
188
- export declare const testLayer: (implementation: Omit<Interface, "registerWorkflowDefinition" | "getWorkflowDefinitionRevision" | "listWorkflowDefinitionRevisions" | "startWorkflowRun" | "inspectWorkflowRun" | "replayWorkflowRun" | "cancelWorkflowRun" | "streamSession" | "watchExecutions" | "getPresence" | "watchPresence" | "registerEntityKind" | "getOrCreateEntity" | "getEntity" | "destroyEntity" | "listEntities" | "followExecution"> & Partial<Interface>) => Layer.Layer<Service, never, never>;
189
+ export declare const testLayer: (implementation: Omit<Interface, "registerWorkflowDefinition" | "getWorkflowDefinitionRevision" | "listWorkflowDefinitionRevisions" | "startWorkflowRun" | "inspectWorkflowRun" | "replayWorkflowRun" | "cancelWorkflowRun" | "streamSession" | "watchExecutions" | "getPresence" | "watchPresence" | "registerEntityKind" | "getOrCreateEntity" | "getEntity" | "destroyEntity" | "listEntities" | "followExecution" | "pageExecutionEvents"> & Partial<Interface>) => Layer.Layer<Service, never, never>;
189
190
  export declare const registerAgentDefinition: (input: Agent.RegisterDefinitionPayload) => Effect.Effect<Agent.DefinitionRegistered, ClientError, Service>;
190
191
  export declare const registerEntityKind: (input: Entity.KindDefinition) => Effect.Effect<Entity.KindDefinition, ClientError, Service>;
191
192
  export declare const getOrCreateEntity: (input: GetOrCreateEntityInput) => Effect.Effect<Entity.Instance, ClientError, Service>;
@@ -213,6 +214,7 @@ export declare const listSessions: (input: ListSessionsInput) => Effect.Effect<L
213
214
  export declare const getSession: (input: GetSessionInput) => Effect.Effect<GetSessionResult, ClientError, Service>;
214
215
  export declare const listWaits: (input: ListWaitsInput) => Effect.Effect<readonly WaitView[], ClientError, Service>;
215
216
  export declare const replayExecution: (input: ReplayExecutionInput) => Effect.Effect<ReplayExecutionResult, ClientError, Service>;
217
+ export declare const pageExecutionEvents: (input: PageExecutionEventsInput) => Effect.Effect<PageExecutionEventsResult, ClientError | EventLogCursorNotFound, Service>;
216
218
  export declare const listRunners: () => Effect.Effect<ListRunnersResult, ClientError, Service>;
217
219
  export declare const routeExecution: (executionId: string & import("effect/Brand").Brand<"Relay.ExecutionId">) => Effect.Effect<RouteExecutionResult, ClientError, Service>;
218
220
  export declare const subscribeTopic: (input: SubscribeTopicInput) => Effect.Effect<TopicSubscription, ClientError, Service>;
@@ -2761,6 +2761,91 @@ export declare const ReplayExecutionResult: Schema.Struct<{
2761
2761
  }>;
2762
2762
  export interface ReplayExecutionResult extends Schema.Schema.Type<typeof ReplayExecutionResult> {
2763
2763
  }
2764
+ export declare const ExecutionEventPageDirection: Schema.Literals<readonly ["forward", "backward"]>;
2765
+ export type ExecutionEventPageDirection = typeof ExecutionEventPageDirection.Type;
2766
+ export declare const PageExecutionEventsInput: Schema.Struct<{
2767
+ readonly execution_id: Schema.brand<Schema.String, "Relay.ExecutionId"> & {
2768
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ExecutionId">;
2769
+ };
2770
+ readonly direction: Schema.Literals<readonly ["forward", "backward"]>;
2771
+ readonly after_cursor: Schema.optionalKey<Schema.String>;
2772
+ readonly before_cursor: Schema.optionalKey<Schema.String>;
2773
+ readonly limit: Schema.optionalKey<Schema.Int>;
2774
+ }>;
2775
+ export interface PageExecutionEventsInput extends Schema.Schema.Type<typeof PageExecutionEventsInput> {
2776
+ }
2777
+ export declare const PageExecutionEventsResult: Schema.Struct<{
2778
+ readonly events: Schema.$Array<Schema.Struct<{
2779
+ readonly id: Schema.brand<Schema.String, "Relay.EventId"> & {
2780
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.EventId">;
2781
+ };
2782
+ readonly execution_id: Schema.brand<Schema.String, "Relay.ExecutionId"> & {
2783
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ExecutionId">;
2784
+ };
2785
+ readonly child_execution_id: Schema.optionalKey<Schema.brand<Schema.String, "Relay.ChildExecutionId"> & {
2786
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ChildExecutionId">;
2787
+ }>;
2788
+ readonly type: Schema.Literals<readonly ["execution.accepted", "execution.started", "execution.completed", "execution.failed", "execution.cancelled", "model.input.prepared", "model.output.delta", "model.reasoning.delta", "model.toolcall.delta", "model.output.completed", "model.usage.reported", "budget.exceeded", "tool.call.requested", "tool.result.received", "tool.approval.requested", "tool.approval.resolved", "permission.ask.requested", "permission.ask.resolved", "steering.received", "state.updated", "state.deleted", "inbox.enqueued", "inbox.drained", "entity.created", "entity.destroyed", "envelope.accepted", "envelope.routed", "envelope.ready", "delivery.attempt", "wait.created", "wait.woken", "wait.timed_out", "wait.cancelled", "child_run.spawned", "child_run.event", "child_fan_out.created", "child_fan_out.member.admitted", "child_fan_out.member.terminal", "child_fan_out.terminal", "workspace.lease.planned", "workspace.lease.acquired", "workspace.suspended", "workspace.resumed", "workspace.snapshot.created", "workspace.lease.released", "workspace.lease.failed"]>;
2789
+ readonly sequence: Schema.Int;
2790
+ readonly cursor: Schema.String;
2791
+ readonly content: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
2792
+ readonly type: Schema.Literal<"text">;
2793
+ readonly text: Schema.String;
2794
+ readonly provider_options: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2795
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2796
+ }>, Schema.Struct<{
2797
+ readonly type: Schema.Literal<"structured">;
2798
+ readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
2799
+ readonly schema_ref: Schema.optionalKey<Schema.String>;
2800
+ readonly provider_options: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2801
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2802
+ }>, Schema.Struct<{
2803
+ readonly type: Schema.Literal<"blob-reference">;
2804
+ readonly uri: Schema.String;
2805
+ readonly media_type: Schema.String;
2806
+ readonly filename: Schema.optionalKey<Schema.String>;
2807
+ readonly provider_options: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2808
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2809
+ }>, Schema.Struct<{
2810
+ readonly type: Schema.Literal<"artifact-reference">;
2811
+ readonly artifact_id: Schema.String;
2812
+ readonly media_type: Schema.optionalKey<Schema.String>;
2813
+ readonly provider_options: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2814
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2815
+ }>, Schema.Struct<{
2816
+ readonly type: Schema.Literal<"tool-call">;
2817
+ readonly call: Schema.Struct<{
2818
+ readonly id: Schema.brand<Schema.String, "Relay.ToolCallId"> & {
2819
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ToolCallId">;
2820
+ };
2821
+ readonly name: Schema.String;
2822
+ readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
2823
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2824
+ }>;
2825
+ readonly provider_options: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2826
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2827
+ }>, Schema.Struct<{
2828
+ readonly type: Schema.Literal<"tool-result">;
2829
+ readonly result: Schema.Struct<{
2830
+ readonly call_id: Schema.brand<Schema.String, "Relay.ToolCallId"> & {
2831
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ToolCallId">;
2832
+ };
2833
+ readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
2834
+ readonly error: Schema.optionalKey<Schema.String>;
2835
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2836
+ }>;
2837
+ readonly provider_options: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2838
+ readonly metadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2839
+ }>]>>>;
2840
+ readonly data: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
2841
+ readonly created_at: Schema.Int;
2842
+ }>>;
2843
+ readonly has_more: Schema.Boolean;
2844
+ readonly oldest_cursor: Schema.optionalKey<Schema.String>;
2845
+ readonly newest_cursor: Schema.optionalKey<Schema.String>;
2846
+ }>;
2847
+ export interface PageExecutionEventsResult extends Schema.Schema.Type<typeof PageExecutionEventsResult> {
2848
+ }
2764
2849
  export declare const RunnerSummary: Schema.Struct<{
2765
2850
  readonly address: Schema.String;
2766
2851
  readonly healthy: Schema.Boolean;
@@ -2,7 +2,7 @@ import { type SqliteClientConfig } from "@effect/sql-sqlite-bun/SqliteClient";
2
2
  import { ChildFanOutRuntime, WorkflowDefinitionRuntime } from "../runtime/index";
3
3
  import { Layer } from "effect";
4
4
  import { SqlClient } from "effect/unstable/sql/SqlClient";
5
- import { RuntimeConfigurationError, RuntimeMigrationError, RuntimeTopologyError, type DatabaseLayer } from "./runtime";
5
+ import { type AcquisitionError, RuntimeConfigurationError, RuntimeMigrationError, RuntimeTopologyError, type DatabaseLayer } from "./runtime";
6
6
  export declare const clientLayer: (options: SqliteClientConfig) => Layer.Layer<SqlClient | import("@effect/sql-sqlite-bun/SqliteClient").SqliteClient, never, never>;
7
7
  export interface SQLiteRuntimeDatabaseOptions {
8
8
  readonly filename: string;
@@ -15,10 +15,10 @@ export declare const runtimeDatabaseLayer: (options: SQLiteRuntimeDatabaseOption
15
15
  export declare const migrationsLayer: Layer.Layer<never, import("@effect/sql-sqlite-bun/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError, SqlClient>;
16
16
  export declare const layer: (options: SqliteClientConfig) => Layer.Layer<SqlClient, import("@effect/sql-sqlite-bun/SqliteMigrator").MigrationError | import("effect/unstable/sql/SqlError").SqlError, never>;
17
17
  export declare const workflowLayer: {
18
- <E, R>(handlersLayer: Layer.Layer<WorkflowDefinitionRuntime.HandlerService, E, R>): (options: SqliteClientConfig) => ReturnType<typeof workflowLayer<E, R>>;
19
- <E, R>(options: SqliteClientConfig, handlersLayer: Layer.Layer<WorkflowDefinitionRuntime.HandlerService, E, R>): Layer.Layer<WorkflowDefinitionRuntime.Service, unknown, R>;
18
+ <E, R>(handlersLayer: Layer.Layer<WorkflowDefinitionRuntime.HandlerService, E, R>): (options: SqliteClientConfig) => Layer.Layer<WorkflowDefinitionRuntime.Service, AcquisitionError, R>;
19
+ <E, R>(options: SqliteClientConfig, handlersLayer: Layer.Layer<WorkflowDefinitionRuntime.HandlerService, E, R>): Layer.Layer<WorkflowDefinitionRuntime.Service, AcquisitionError, R>;
20
20
  };
21
21
  export declare const childFanOutLayer: {
22
- <E, R>(handlersLayer: Layer.Layer<ChildFanOutRuntime.HandlerService, E, R>): (options: SqliteClientConfig) => Layer.Layer<ChildFanOutRuntime.Service, unknown, R>;
23
- <E, R>(options: SqliteClientConfig, handlersLayer: Layer.Layer<ChildFanOutRuntime.HandlerService, E, R>): Layer.Layer<ChildFanOutRuntime.Service, unknown, R>;
22
+ <E, R>(handlersLayer: Layer.Layer<ChildFanOutRuntime.HandlerService, E, R>): (options: SqliteClientConfig) => Layer.Layer<ChildFanOutRuntime.Service, AcquisitionError, R>;
23
+ <E, R>(options: SqliteClientConfig, handlersLayer: Layer.Layer<ChildFanOutRuntime.HandlerService, E, R>): Layer.Layer<ChildFanOutRuntime.Service, AcquisitionError, R>;
24
24
  };
@@ -19,6 +19,25 @@ export interface ReplayInput {
19
19
  readonly afterCursor?: string;
20
20
  readonly limit?: number;
21
21
  }
22
+ export type PageInput = {
23
+ readonly executionId: Ids.ExecutionId;
24
+ readonly direction: "forward";
25
+ readonly afterCursor?: string;
26
+ readonly beforeCursor?: never;
27
+ readonly limit?: number;
28
+ } | {
29
+ readonly executionId: Ids.ExecutionId;
30
+ readonly direction: "backward";
31
+ readonly afterCursor?: never;
32
+ readonly beforeCursor?: string;
33
+ readonly limit?: number;
34
+ };
35
+ export interface PageResult {
36
+ readonly events: ReadonlyArray<Execution.ExecutionEvent>;
37
+ readonly hasMore: boolean;
38
+ readonly oldestCursor?: string;
39
+ readonly newestCursor?: string;
40
+ }
22
41
  export interface FindBySequenceOrCursorInput {
23
42
  readonly executionId: Ids.ExecutionId;
24
43
  readonly sequence: Execution.ExecutionEventSequence;
@@ -41,6 +60,7 @@ export interface Interface {
41
60
  readonly append: (input: Execution.ExecutionEvent) => Effect.Effect<Execution.ExecutionEvent, EventLogError>;
42
61
  readonly replay: (input: ReplayInput) => Effect.Effect<ReadonlyArray<Execution.ExecutionEvent>, EventLogCursorNotFound | EventLogError>;
43
62
  readonly stream: (input: ReplayInput) => Stream.Stream<Execution.ExecutionEvent, EventLogCursorNotFound | EventLogError>;
63
+ readonly page: (input: PageInput) => Effect.Effect<PageResult, EventLogCursorNotFound | EventLogError>;
44
64
  readonly findBySequenceOrCursor: (input: FindBySequenceOrCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, EventLogError>;
45
65
  readonly findByCursor: (input: FindByCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, EventLogError>;
46
66
  readonly findBySequence: (input: FindBySequenceInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, EventLogError>;
@@ -53,7 +73,8 @@ export declare class Service extends Service_base {
53
73
  }
54
74
  export declare const layerFromRepository: Layer.Layer<Service, never, ExecutionEventRepository.Service>;
55
75
  export declare const memoryLayer: Layer.Layer<Service, never, never>;
56
- export declare const testLayer: (implementation: Interface) => Layer.Layer<Service, never, never>;
76
+ type TestImplementation = Omit<Interface, "page"> & Partial<Pick<Interface, "page">>;
77
+ export declare const testLayer: (implementation: TestImplementation) => Layer.Layer<Service, never, never>;
57
78
  export declare const appendIdempotentTo: {
58
79
  (eventLog: Interface, input: Execution.ExecutionEvent): Effect.Effect<Execution.ExecutionEvent, EventLogError>;
59
80
  (input: Execution.ExecutionEvent): (eventLog: Interface) => Effect.Effect<Execution.ExecutionEvent, EventLogError>;
@@ -61,6 +82,7 @@ export declare const appendIdempotentTo: {
61
82
  export declare const append: (input: Execution.ExecutionEvent) => Effect.Effect<Execution.ExecutionEvent, EventLogError, Service>;
62
83
  export declare const appendIdempotent: (input: Execution.ExecutionEvent) => Effect.Effect<Execution.ExecutionEvent, EventLogError, Service>;
63
84
  export declare const replay: (input: ReplayInput) => Effect.Effect<readonly Execution.ExecutionEvent[], EventLogCursorNotFound | EventLogError, Service>;
85
+ export declare const page: (input: PageInput) => Effect.Effect<PageResult, EventLogCursorNotFound | EventLogError, Service>;
64
86
  export declare const findBySequenceOrCursor: (input: FindBySequenceOrCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, EventLogError, Service>;
65
87
  export declare const findByCursor: (input: FindByCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, EventLogError, Service>;
66
88
  export declare const findBySequence: (input: FindBySequenceInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, EventLogError, Service>;
@@ -62,6 +62,25 @@ export interface ListAfterSequenceInput {
62
62
  readonly afterSequence: Execution.ExecutionEventSequence | undefined;
63
63
  readonly limit: number;
64
64
  }
65
+ export type PageInput = {
66
+ readonly executionId: Ids.ExecutionId;
67
+ readonly direction: "forward";
68
+ readonly afterCursor?: string;
69
+ readonly beforeCursor?: never;
70
+ readonly limit?: number;
71
+ } | {
72
+ readonly executionId: Ids.ExecutionId;
73
+ readonly direction: "backward";
74
+ readonly afterCursor?: never;
75
+ readonly beforeCursor?: string;
76
+ readonly limit?: number;
77
+ };
78
+ export interface PageResult {
79
+ readonly events: ReadonlyArray<Execution.ExecutionEvent>;
80
+ readonly hasMore: boolean;
81
+ readonly oldestCursor?: string;
82
+ readonly newestCursor?: string;
83
+ }
65
84
  export interface Interface {
66
85
  readonly signalTransport: Transport;
67
86
  readonly append: (input: Execution.ExecutionEvent) => Effect.Effect<Execution.ExecutionEvent, DuplicateExecutionEvent | ExecutionEventOrderViolation | ExecutionEventRepositoryError>;
@@ -75,6 +94,7 @@ export interface Interface {
75
94
  readonly notifyAppended: (event: Execution.ExecutionEvent) => Effect.Effect<void, ExecutionEventRepositoryError>;
76
95
  readonly appendedSignals: (executionId: Ids.ExecutionId) => Stream.Stream<Execution.ExecutionEventSequence, ExecutionEventRepositoryError>;
77
96
  readonly listAfterSequence: (input: ListAfterSequenceInput) => Effect.Effect<ReadonlyArray<Execution.ExecutionEvent>, ExecutionEventRepositoryError>;
97
+ readonly page: (input: PageInput) => Effect.Effect<PageResult, ExecutionEventCursorNotFound | ExecutionEventRepositoryError>;
78
98
  }
79
99
  declare const Service_base: Context.ServiceClass<Service, "@relayfx/store-sql/execution/execution-event-repository/Service", Interface>;
80
100
  export declare class Service extends Service_base {
@@ -93,9 +113,11 @@ export declare const ExecutionEventRow: Schema.Struct<{
93
113
  export declare const layer: Layer.Layer<Service, never, NotificationBusService | SqlClient>;
94
114
  export declare const layerWithBus: Layer.Layer<Service, never, SqlClient>;
95
115
  export declare const memoryLayer: Layer.Layer<Service, never, never>;
96
- export declare const testLayer: (implementation: Interface) => Layer.Layer<Service, never, never>;
116
+ type TestImplementation = Omit<Interface, "page"> & Partial<Pick<Interface, "page">>;
117
+ export declare const testLayer: (implementation: TestImplementation) => Layer.Layer<Service, never, never>;
97
118
  export declare const append: (input: Execution.ExecutionEvent) => Effect.Effect<Execution.ExecutionEvent, DuplicateExecutionEvent | ExecutionEventOrderViolation | ExecutionEventRepositoryError, Service>;
98
119
  export declare const list: (input: ListInput) => Effect.Effect<readonly Execution.ExecutionEvent[], ExecutionEventCursorNotFound | ExecutionEventRepositoryError, Service>;
120
+ export declare const page: (input: PageInput) => Effect.Effect<PageResult, ExecutionEventCursorNotFound | ExecutionEventRepositoryError, Service>;
99
121
  export declare const findBySequenceOrCursor: (input: FindBySequenceOrCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError, Service>;
100
122
  export declare const findByCursor: (input: FindByCursorInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError, Service>;
101
123
  export declare const findBySequence: (input: FindBySequenceInput) => Effect.Effect<Option.Option<Execution.ExecutionEvent>, ExecutionEventRepositoryError, Service>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@relayfx/sdk",
4
- "version": "0.2.16",
4
+ "version": "0.3.1",
5
5
  "description": "Effect-native durable execution SDK for addressable agents and tools",
6
6
  "type": "module",
7
7
  "exports": {