@relayfx/sdk 0.3.7 → 0.4.0

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.
Files changed (89) hide show
  1. package/dist/ai.js +1 -1
  2. package/dist/http-server.js +1 -1
  3. package/dist/{index-pw46cfne.js → index-3w6txjtg.js} +59 -426
  4. package/dist/{index-h8rx4xya.js → index-cs3be24t.js} +1 -1
  5. package/dist/{index-8awt651b.js → index-p43mg4kt.js} +5774 -5275
  6. package/dist/{index-t5bbk8cp.js → index-x32kbvxv.js} +935 -954
  7. package/dist/index.js +487 -22
  8. package/dist/migrations/20260719120000_rename_entity_to_resident/migration.sql +9 -0
  9. package/dist/migrations/mysql/0012_rename_entity_to_resident.sql +5 -0
  10. package/dist/migrations/pg/20260719120000_rename_entity_to_resident/migration.sql +9 -0
  11. package/dist/migrations/sqlite/0012_rename_entity_to_resident.sql +7 -0
  12. package/dist/mysql.js +18 -5
  13. package/dist/postgres.js +569 -550
  14. package/dist/sqlite.js +16 -5
  15. package/dist/types/relay/client-baton-agent.d.ts +30 -0
  16. package/dist/types/relay/client-child-runs.d.ts +35 -0
  17. package/dist/types/relay/client-error-mapping.d.ts +5 -0
  18. package/dist/types/relay/client-event-sequence.d.ts +3 -0
  19. package/dist/types/relay/client-execution-payloads.d.ts +12 -0
  20. package/dist/types/relay/client-public-agents.d.ts +15 -0
  21. package/dist/types/relay/client-public-child-runs.d.ts +9 -0
  22. package/dist/types/relay/client-public-envelope-ready.d.ts +6 -0
  23. package/dist/types/relay/client-public-executions.d.ts +247 -0
  24. package/dist/types/relay/client-public-messaging.d.ts +18 -0
  25. package/dist/types/relay/client-public-residents.d.ts +14 -0
  26. package/dist/types/relay/client-public-schedules.d.ts +6 -0
  27. package/dist/types/relay/client-public-tools.d.ts +12 -0
  28. package/dist/types/relay/client-public-workflows.d.ts +10 -0
  29. package/dist/types/relay/client-public.d.ts +133 -313
  30. package/dist/types/relay/client-runtime-wake.d.ts +10 -0
  31. package/dist/types/relay/client-tool-outcome.d.ts +16 -0
  32. package/dist/types/relay/client-view-mappers.d.ts +16 -0
  33. package/dist/types/relay/client-wait-signal.d.ts +5 -0
  34. package/dist/types/relay/client.d.ts +118 -1
  35. package/dist/types/relay/command.d.ts +6 -6
  36. package/dist/types/relay/http-server.d.ts +55 -37
  37. package/dist/types/relay/index.d.ts +3 -4
  38. package/dist/types/relay/internal-client.d.ts +5 -5
  39. package/dist/types/relay/mysql-migrations.d.ts +1 -1
  40. package/dist/types/relay/operation.d.ts +41 -41
  41. package/dist/types/relay/sqlite-migrations.d.ts +6 -1
  42. package/dist/types/runtime/agent/agent-loop-events.d.ts +24 -0
  43. package/dist/types/runtime/execution/event-log-memory.d.ts +7 -0
  44. package/dist/types/runtime/execution/event-log-repository.d.ts +8 -0
  45. package/dist/types/runtime/index.d.ts +2 -2
  46. package/dist/types/runtime/resident/resident-instance-service.d.ts +76 -0
  47. package/dist/types/runtime/resident/resident-registry-service.d.ts +35 -0
  48. package/dist/types/runtime/runner/runner-runtime-service.d.ts +14 -14
  49. package/dist/types/runtime/workflow/execution-workflow-state.d.ts +43 -0
  50. package/dist/types/schema/execution-schema.d.ts +2 -2
  51. package/dist/types/schema/ids-schema.d.ts +6 -6
  52. package/dist/types/schema/index.d.ts +1 -1
  53. package/dist/types/schema/{entity-schema.d.ts → resident-schema.d.ts} +6 -6
  54. package/dist/types/store-sql/envelope/envelope-ready-records.d.ts +51 -0
  55. package/dist/types/store-sql/envelope/envelope-records.d.ts +43 -0
  56. package/dist/types/store-sql/envelope/envelope-repository.d.ts +1 -2
  57. package/dist/types/store-sql/envelope/wait-records.d.ts +64 -0
  58. package/dist/types/store-sql/execution/execution-event-repository-memory.d.ts +8 -0
  59. package/dist/types/store-sql/execution/execution-event-repository-sql.d.ts +13 -0
  60. package/dist/types/store-sql/execution/execution-event-repository.d.ts +3 -4
  61. package/dist/types/store-sql/index.d.ts +1 -1
  62. package/dist/types/store-sql/portable.d.ts +1 -1
  63. package/dist/types/store-sql/resident/resident-repository.d.ts +36 -0
  64. package/dist/types/store-sql/schema/address-book-schema.d.ts +131 -0
  65. package/dist/types/store-sql/schema/agent-schema.d.ts +954 -0
  66. package/dist/types/store-sql/schema/communication-schema.d.ts +743 -0
  67. package/dist/types/store-sql/schema/envelope-schema.d.ts +701 -0
  68. package/dist/types/store-sql/schema/execution-schema.d.ts +1119 -0
  69. package/dist/types/store-sql/schema/idempotency-schema.d.ts +161 -0
  70. package/dist/types/store-sql/schema/presence-schema.d.ts +116 -0
  71. package/dist/types/store-sql/schema/relay-schema.d.ts +13 -6684
  72. package/dist/types/store-sql/schema/resident-schema.d.ts +294 -0
  73. package/dist/types/store-sql/schema/schedule-schema.d.ts +282 -0
  74. package/dist/types/store-sql/schema/schema-columns.d.ts +1 -0
  75. package/dist/types/store-sql/schema/session-schema.d.ts +228 -0
  76. package/dist/types/store-sql/schema/tool-schema.d.ts +627 -0
  77. package/dist/types/store-sql/schema/workflow-schema.d.ts +996 -0
  78. package/dist/types/store-sql/schema/workspace-schema.d.ts +338 -0
  79. package/dist/types/store-sql/session/session-entry-records.d.ts +52 -0
  80. package/dist/types/store-sql/session/session-records.d.ts +51 -0
  81. package/dist/types/store-sql/session/session-repository.d.ts +2 -3
  82. package/dist/types/store-sql/tool/tool-attempt-records.d.ts +52 -0
  83. package/dist/types/store-sql/tool/tool-call-records.d.ts +121 -0
  84. package/dist/types/store-sql/tool/tool-call-repository.d.ts +1 -2
  85. package/dist/types/store-sql/tool/tool-work-operations.d.ts +11 -0
  86. package/package.json +3 -3
  87. package/dist/types/runtime/entity/entity-instance-service.d.ts +0 -76
  88. package/dist/types/runtime/entity/entity-registry-service.d.ts +0 -35
  89. package/dist/types/store-sql/entity/entity-repository.d.ts +0 -36
@@ -0,0 +1,43 @@
1
+ import { AgentEvent } from "@batonfx/core";
2
+ import { Content, Execution, Ids, Shared } from "../../schema/index";
3
+ import { EnvelopeRepository, ExecutionRepository } from "../../store-sql/portable";
4
+ import { Schema } from "effect";
5
+ import type { StartInput, WaitSignalState, WaitSnapshot } from "./execution-workflow";
6
+ declare const toWaitSnapshot: (record: EnvelopeRepository.WaitRecord) => WaitSnapshot;
7
+ declare const terminalWaitState: (wait: WaitSnapshot) => WaitSignalState | undefined;
8
+ declare const agentDefinitionPinCount: (input: StartInput) => number;
9
+ declare const waitIdFromRecord: (record: ExecutionRepository.ExecutionRecord) => (string & import("effect/Brand").Brand<"Relay.WaitId">) | undefined;
10
+ declare const workflowGenerationForStart: (input: StartInput) => number;
11
+ declare const workflowGenerationFromRecord: (record: ExecutionRepository.ExecutionRecord) => number;
12
+ declare const generationMetadata: (generation: number) => Shared.Metadata;
13
+ declare const memorySubjectFromMetadata: (metadata: Shared.Metadata | undefined) => Schema.Json | undefined;
14
+ declare const metadataSetting: (input: StartInput, key: string) => Shared.JsonValue | undefined;
15
+ declare const steeringEnabledForStart: (input: StartInput) => boolean;
16
+ export interface ChildDispatchContext {
17
+ readonly parentExecutionId: Ids.ExecutionId;
18
+ readonly childExecutionId: Ids.ChildExecutionId;
19
+ readonly parentWaitId?: Ids.WaitId;
20
+ }
21
+ declare const childDispatchContext: (input: StartInput) => ChildDispatchContext | undefined;
22
+ declare const terminalOutput: (execution: Execution.Execution) => ReadonlyArray<Content.Part>;
23
+ declare const waitIdFromExecution: (execution: Execution.Execution) => (string & import("effect/Brand").Brand<"Relay.WaitId">) | undefined;
24
+ declare const pendingSuspensionFromExecution: (execution: Execution.Execution) => AgentEvent.AgentSuspended | undefined;
25
+ export declare const ExecutionWorkflowState: {
26
+ agentDefinitionPinCount: typeof agentDefinitionPinCount;
27
+ childDispatchContext: typeof childDispatchContext;
28
+ continueAsNewAfterTurnsMetadataKey: string;
29
+ generationMetadata: typeof generationMetadata;
30
+ memorySubjectFromMetadata: typeof memorySubjectFromMetadata;
31
+ metadataSetting: typeof metadataSetting;
32
+ pendingSuspensionFromExecution: typeof pendingSuspensionFromExecution;
33
+ steeringEnabledForStart: typeof steeringEnabledForStart;
34
+ terminalOutput: typeof terminalOutput;
35
+ terminalWaitState: typeof terminalWaitState;
36
+ toolOutputMaxBytesMetadataKey: string;
37
+ toWaitSnapshot: typeof toWaitSnapshot;
38
+ waitIdFromExecution: typeof waitIdFromExecution;
39
+ waitIdFromRecord: typeof waitIdFromRecord;
40
+ workflowGenerationForStart: typeof workflowGenerationForStart;
41
+ workflowGenerationFromRecord: typeof workflowGenerationFromRecord;
42
+ };
43
+ export {};
@@ -385,7 +385,7 @@ export declare const ChildRunAccepted: Schema.Struct<{
385
385
  export interface ChildRunAccepted extends Schema.Schema.Type<typeof ChildRunAccepted> {
386
386
  }
387
387
  export declare const childSessionId: (childExecutionId: ChildExecutionId) => string & import("effect/Brand").Brand<"Relay.SessionId">;
388
- export declare const ExecutionEventType: 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", "agent.compaction.committed", "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"]>;
388
+ export declare const ExecutionEventType: 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", "agent.compaction.committed", "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", "resident.created", "resident.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"]>;
389
389
  export type ExecutionEventType = typeof ExecutionEventType.Type;
390
390
  export declare const CompactionCommittedEventData: Schema.Struct<{
391
391
  readonly checkpoint_id: Schema.brand<Schema.String, "Relay.SessionEntryId"> & {
@@ -408,7 +408,7 @@ export declare const ExecutionEvent: Schema.Struct<{
408
408
  readonly child_execution_id: Schema.optionalKey<Schema.brand<Schema.String, "Relay.ChildExecutionId"> & {
409
409
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ChildExecutionId">;
410
410
  }>;
411
- 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", "agent.compaction.committed", "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"]>;
411
+ 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", "agent.compaction.committed", "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", "resident.created", "resident.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"]>;
412
412
  readonly sequence: Schema.Int;
413
413
  readonly cursor: Schema.String;
414
414
  readonly content: Schema.optionalKey<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
@@ -24,14 +24,14 @@ export declare const WorkflowOperationId: Schema.brand<Schema.String, "Relay.Wor
24
24
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.WorkflowOperationId">;
25
25
  };
26
26
  export type WorkflowOperationId = typeof WorkflowOperationId.Type;
27
- export declare const EntityKindName: Schema.brand<Schema.String, "Relay.EntityKindName"> & {
28
- make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.EntityKindName">;
27
+ export declare const ResidentKindName: Schema.brand<Schema.String, "Relay.ResidentKindName"> & {
28
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ResidentKindName">;
29
29
  };
30
- export type EntityKindName = typeof EntityKindName.Type;
31
- export declare const EntityKey: Schema.brand<Schema.String, "Relay.EntityKey"> & {
32
- make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.EntityKey">;
30
+ export type ResidentKindName = typeof ResidentKindName.Type;
31
+ export declare const ResidentKey: Schema.brand<Schema.String, "Relay.ResidentKey"> & {
32
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ResidentKey">;
33
33
  };
34
- export type EntityKey = typeof EntityKey.Type;
34
+ export type ResidentKey = typeof ResidentKey.Type;
35
35
  export declare const SkillDefinitionId: Schema.brand<Schema.String, "Relay.SkillDefinitionId"> & {
36
36
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.SkillDefinitionId">;
37
37
  };
@@ -3,7 +3,7 @@ export * as Agent from "./agent-schema";
3
3
  export * as ChildOrchestration from "./child-orchestration-schema";
4
4
  export * as Content from "./content-schema";
5
5
  export * as Envelope from "./envelope-schema";
6
- export * as Entity from "./entity-schema";
6
+ export * as Resident from "./resident-schema";
7
7
  export * as Execution from "./execution-schema";
8
8
  export * as Ids from "./ids-schema";
9
9
  export * as Inbox from "./inbox-schema";
@@ -1,7 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  export declare const KindDefinition: Schema.Struct<{
3
- readonly kind: Schema.brand<Schema.String, "Relay.EntityKindName"> & {
4
- make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.EntityKindName">;
3
+ readonly kind: Schema.brand<Schema.String, "Relay.ResidentKindName"> & {
4
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ResidentKindName">;
5
5
  };
6
6
  readonly agent_id: Schema.brand<Schema.String, "Relay.AgentId"> & {
7
7
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.AgentId">;
@@ -19,11 +19,11 @@ export interface KindDefinition extends Schema.Schema.Type<typeof KindDefinition
19
19
  export declare const InstanceStatus: Schema.Literals<readonly ["active", "destroyed"]>;
20
20
  export type InstanceStatus = typeof InstanceStatus.Type;
21
21
  export declare const Instance: Schema.Struct<{
22
- readonly kind: Schema.brand<Schema.String, "Relay.EntityKindName"> & {
23
- make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.EntityKindName">;
22
+ readonly kind: Schema.brand<Schema.String, "Relay.ResidentKindName"> & {
23
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ResidentKindName">;
24
24
  };
25
- readonly key: Schema.brand<Schema.String, "Relay.EntityKey"> & {
26
- make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.EntityKey">;
25
+ readonly key: Schema.brand<Schema.String, "Relay.ResidentKey"> & {
26
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ResidentKey">;
27
27
  };
28
28
  readonly address_id: Schema.brand<Schema.String, "Relay.AddressId"> & {
29
29
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.AddressId">;
@@ -0,0 +1,51 @@
1
+ import { Ids } from "../../schema/index";
2
+ import { Effect, Schema } from "effect";
3
+ import type { SqlClient } from "effect/unstable/sql/SqlClient";
4
+ import type { AckReadyInput, ClaimReadyInput, EnvelopeReadyClaimMismatch, EnvelopeReadyNotFound, EnvelopeReadyRecord, EnvelopeRepositoryError, ReleaseReadyInput } from "./envelope-repository";
5
+ export declare const envelopeReadyRow: Schema.Struct<{
6
+ readonly id: Schema.String;
7
+ readonly envelope_id: Schema.String;
8
+ readonly route_type: Schema.String;
9
+ readonly route_key: Schema.String;
10
+ readonly state: Schema.String;
11
+ readonly available_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite]>;
12
+ readonly attempt: Schema.Finite;
13
+ readonly claim_owner: Schema.Union<readonly [Schema.String, Schema.Null]>;
14
+ readonly claim_expires_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite, Schema.Null]>;
15
+ readonly last_error: Schema.Union<readonly [Schema.String, Schema.Null]>;
16
+ readonly idempotency_key: Schema.Union<readonly [Schema.String, Schema.Null]>;
17
+ readonly metadata_json: Schema.Unknown;
18
+ readonly created_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite]>;
19
+ readonly updated_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite]>;
20
+ readonly claimed_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite, Schema.Null]>;
21
+ readonly acknowledged_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite, Schema.Null]>;
22
+ }>;
23
+ interface EnvelopeReadyRecordErrors {
24
+ readonly EnvelopeRepositoryError: {
25
+ readonly make: (input: {
26
+ readonly message: string;
27
+ }) => EnvelopeRepositoryError;
28
+ };
29
+ readonly EnvelopeReadyNotFound: {
30
+ readonly make: (input: {
31
+ readonly id: Ids.EnvelopeReadyId;
32
+ }) => EnvelopeReadyNotFound;
33
+ };
34
+ readonly EnvelopeReadyClaimMismatch: {
35
+ readonly make: (input: {
36
+ readonly id: Ids.EnvelopeReadyId;
37
+ readonly worker_id: string;
38
+ }) => EnvelopeReadyClaimMismatch;
39
+ };
40
+ }
41
+ interface MakeEnvelopeReadyRecordOperationsInput {
42
+ readonly sql: SqlClient;
43
+ readonly ts: (millis: number) => Date | number;
44
+ readonly errors: EnvelopeReadyRecordErrors;
45
+ }
46
+ export declare const makeEnvelopeReadyRecordOperations: ({ sql, ts, errors }: MakeEnvelopeReadyRecordOperationsInput) => {
47
+ claimReady: (input: ClaimReadyInput) => Effect.Effect<EnvelopeReadyRecord | undefined, EnvelopeRepositoryError, never>;
48
+ releaseReady: (input: ReleaseReadyInput) => Effect.Effect<EnvelopeReadyRecord, EnvelopeReadyClaimMismatch | EnvelopeReadyNotFound | EnvelopeRepositoryError, never>;
49
+ ackReady: (input: AckReadyInput) => Effect.Effect<EnvelopeReadyRecord, EnvelopeReadyClaimMismatch | EnvelopeReadyNotFound | EnvelopeRepositoryError, never>;
50
+ };
51
+ export {};
@@ -0,0 +1,43 @@
1
+ import { Envelope, Ids } from "../../schema/index";
2
+ import { Effect, Schema } from "effect";
3
+ import { SqlClient } from "effect/unstable/sql/SqlClient";
4
+ import { envelopeReadyRow } from "./envelope-ready-records";
5
+ import type { AcceptEnvelopeInput, EnvelopeReadyClaimMismatch, EnvelopeReadyNotFound, EnvelopeRepositoryError, Interface, WaitNotFound } from "./envelope-repository";
6
+ import { waitRow } from "./wait-records";
7
+ export declare const envelopeRow: Schema.Struct<{
8
+ readonly id: Schema.String;
9
+ readonly execution_id: Schema.String;
10
+ readonly from_address_id: Schema.String;
11
+ readonly to_address_id: Schema.String;
12
+ readonly content_json: Schema.Unknown;
13
+ readonly wait_json: Schema.Unknown;
14
+ readonly correlation_key: Schema.Union<readonly [Schema.String, Schema.Null]>;
15
+ readonly metadata_json: Schema.Unknown;
16
+ readonly created_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite]>;
17
+ }>;
18
+ export declare const accepted: (input: AcceptEnvelopeInput) => Envelope.EnvelopeAccepted;
19
+ interface EnvelopeRecordErrors {
20
+ readonly EnvelopeRepositoryError: {
21
+ readonly make: (input: {
22
+ readonly message: string;
23
+ }) => EnvelopeRepositoryError;
24
+ };
25
+ readonly EnvelopeReadyNotFound: {
26
+ readonly make: (input: {
27
+ readonly id: Ids.EnvelopeReadyId;
28
+ }) => EnvelopeReadyNotFound;
29
+ };
30
+ readonly EnvelopeReadyClaimMismatch: {
31
+ readonly make: (input: {
32
+ readonly id: Ids.EnvelopeReadyId;
33
+ readonly worker_id: string;
34
+ }) => EnvelopeReadyClaimMismatch;
35
+ };
36
+ readonly WaitNotFound: {
37
+ readonly make: (input: {
38
+ readonly id: Ids.WaitId;
39
+ }) => WaitNotFound;
40
+ };
41
+ }
42
+ export declare const makeEnvelopeRepository: (errors: EnvelopeRecordErrors) => Effect.Effect<Interface, never, SqlClient>;
43
+ export { envelopeReadyRow, waitRow };
@@ -1,6 +1,5 @@
1
1
  import { Address, Envelope, Ids, Shared } from "../../schema/index";
2
2
  import { Context, Effect, Layer, Schema } from "effect";
3
- import { SqlClient } from "effect/unstable/sql/SqlClient";
4
3
  export declare const WaitState: Schema.Literals<readonly ["open", "resolved", "timed_out", "cancelled"]>;
5
4
  export type WaitState = typeof WaitState.Type;
6
5
  export declare const EnvelopeReadyState: Schema.Literals<readonly ["ready", "claimed", "acknowledged"]>;
@@ -188,7 +187,7 @@ export declare const EnvelopeReadyRow: Schema.Struct<{
188
187
  readonly claimed_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite, Schema.Null]>;
189
188
  readonly acknowledged_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite, Schema.Null]>;
190
189
  }>;
191
- export declare const layer: Layer.Layer<Service, never, SqlClient>;
190
+ export declare const layer: Layer.Layer<Service, never, import("effect/unstable/sql/SqlClient").SqlClient>;
192
191
  export declare const memoryLayer: Layer.Layer<Service, never, never>;
193
192
  export declare const testLayer: (implementation: Interface) => Layer.Layer<Service, never, never>;
194
193
  export declare const acceptEnvelope: (input: AcceptEnvelopeInput) => Effect.Effect<Envelope.EnvelopeAccepted, EnvelopeRepositoryError, Service>;
@@ -0,0 +1,64 @@
1
+ import { Ids, Shared } from "../../schema/index";
2
+ import { Effect, Schema } from "effect";
3
+ import type { SqlClient } from "effect/unstable/sql/SqlClient";
4
+ import type { CompleteWaitInput, CreateWaitInput, EnvelopeRepositoryError, ListAllWaitsInput, ListWaitsInput, ResolveWaitInput, WaitNotFound, WaitRecord } from "./envelope-repository";
5
+ export declare const waitRow: Schema.Struct<{
6
+ readonly id: Schema.String;
7
+ readonly execution_id: Schema.String;
8
+ readonly envelope_id: Schema.Union<readonly [Schema.String, Schema.Null]>;
9
+ readonly mode: Schema.String;
10
+ readonly correlation_key: Schema.Union<readonly [Schema.String, Schema.Null]>;
11
+ readonly state: Schema.String;
12
+ readonly metadata_json: Schema.Unknown;
13
+ readonly created_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite]>;
14
+ readonly resolved_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite, Schema.Null]>;
15
+ }>;
16
+ export declare const metadata: (input: Shared.Metadata | undefined) => {
17
+ readonly [x: string]: Schema.Json;
18
+ };
19
+ export declare const listWaitsLimit: (input: ListWaitsInput) => number;
20
+ declare const compareWaitsDesc: (left: WaitRecord, right: WaitRecord) => number;
21
+ export declare const waitRecordOrdering: {
22
+ compareWaitsDesc: typeof compareWaitsDesc;
23
+ };
24
+ interface WaitRecordErrors {
25
+ readonly EnvelopeRepositoryError: {
26
+ readonly make: (input: {
27
+ readonly message: string;
28
+ }) => EnvelopeRepositoryError;
29
+ };
30
+ readonly WaitNotFound: {
31
+ readonly make: (input: {
32
+ readonly id: Ids.WaitId;
33
+ }) => WaitNotFound;
34
+ };
35
+ }
36
+ interface MakeWaitRecordOperationsInput {
37
+ readonly sql: SqlClient;
38
+ readonly ts: (millis: number) => Date | number;
39
+ readonly errors: WaitRecordErrors;
40
+ }
41
+ export declare const makeWaitRecordOperations: ({ sql, ts, errors }: MakeWaitRecordOperationsInput) => {
42
+ getWaitRow: (tenantId: Ids.TenantId, id: Ids.WaitId) => Effect.Effect<Schema.Struct.ReadonlySide<{
43
+ readonly id: Schema.String;
44
+ readonly execution_id: Schema.String;
45
+ readonly envelope_id: Schema.Union<readonly [Schema.String, Schema.Null]>;
46
+ readonly mode: Schema.String;
47
+ readonly correlation_key: Schema.Union<readonly [Schema.String, Schema.Null]>;
48
+ readonly state: Schema.String;
49
+ readonly metadata_json: Schema.Unknown;
50
+ readonly created_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite]>;
51
+ readonly resolved_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite, Schema.Null]>;
52
+ }, "Type"> | undefined, EnvelopeRepositoryError, never>;
53
+ getWait: (id: string & import("effect/Brand").Brand<"Relay.WaitId">) => Effect.Effect<WaitRecord | undefined, EnvelopeRepositoryError, never>;
54
+ createWait: (input: CreateWaitInput) => Effect.Effect<WaitRecord, EnvelopeRepositoryError, never>;
55
+ listWaits: (input: ListWaitsInput) => Effect.Effect<WaitRecord[], EnvelopeRepositoryError, never>;
56
+ findOpenByCorrelation: (executionId: string & import("effect/Brand").Brand<"Relay.ExecutionId">, correlationKey: string) => Effect.Effect<WaitRecord | undefined, EnvelopeRepositoryError, never>;
57
+ listAllWaits: (input: ListAllWaitsInput) => Effect.Effect<WaitRecord[], EnvelopeRepositoryError, never>;
58
+ completeWait: (input: CompleteWaitInput) => Effect.Effect<{
59
+ wait: WaitRecord;
60
+ transitioned: boolean;
61
+ }, EnvelopeRepositoryError | WaitNotFound, never>;
62
+ resolveWait: (input: ResolveWaitInput) => Effect.Effect<WaitRecord, EnvelopeRepositoryError | WaitNotFound, never>;
63
+ };
64
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Layer } from "effect";
2
+ import type { DuplicateExecutionEvent, ExecutionEventCursorNotFound, ExecutionEventOrderViolation, Service } from "./execution-event-repository";
3
+ export declare const makeMemoryLayer: (repository: {
4
+ readonly DuplicateExecutionEvent: typeof DuplicateExecutionEvent;
5
+ readonly ExecutionEventOrderViolation: typeof ExecutionEventOrderViolation;
6
+ readonly ExecutionEventCursorNotFound: typeof ExecutionEventCursorNotFound;
7
+ readonly Service: typeof Service;
8
+ }) => Layer.Layer<Service, never, never>;
@@ -0,0 +1,13 @@
1
+ import { Layer } from "effect";
2
+ import { SqlClient } from "effect/unstable/sql/SqlClient";
3
+ import { Service as NotificationBusService } from "../database/notification-bus";
4
+ import type { DuplicateExecutionEvent, ExecutionEventCursorNotFound, ExecutionEventOrderViolation, ExecutionEventRepositoryError, ExecutionEventRow, Service, executionEventsChannel } from "./execution-event-repository";
5
+ export declare const makeLayer: (repository: {
6
+ readonly DuplicateExecutionEvent: typeof DuplicateExecutionEvent;
7
+ readonly ExecutionEventOrderViolation: typeof ExecutionEventOrderViolation;
8
+ readonly ExecutionEventCursorNotFound: typeof ExecutionEventCursorNotFound;
9
+ readonly ExecutionEventRepositoryError: typeof ExecutionEventRepositoryError;
10
+ readonly ExecutionEventRow: typeof ExecutionEventRow;
11
+ readonly Service: typeof Service;
12
+ readonly executionEventsChannel: typeof executionEventsChannel;
13
+ }) => Layer.Layer<Service, never, NotificationBusService | SqlClient>;
@@ -1,7 +1,6 @@
1
1
  import { Execution, Ids } from "../../schema/index";
2
2
  import { Context, Effect, Layer, Option, Schema, Stream } from "effect";
3
- import { SqlClient } from "effect/unstable/sql/SqlClient";
4
- import { Service as NotificationBusService, type Transport } from "../database/notification-bus";
3
+ import { type Transport } from "../database/notification-bus";
5
4
  export declare const executionEventsChannel = "relay_execution_events";
6
5
  declare const DuplicateExecutionEvent_base: Schema.Class<DuplicateExecutionEvent, Schema.TaggedStruct<"DuplicateExecutionEvent", {
7
6
  readonly execution_id: Schema.brand<Schema.String, "Relay.ExecutionId"> & {
@@ -118,8 +117,8 @@ export declare const ExecutionEventRow: Schema.Struct<{
118
117
  readonly data_json: Schema.Unknown;
119
118
  readonly created_at: Schema.Union<readonly [Schema.Date, Schema.String, Schema.Finite]>;
120
119
  }>;
121
- export declare const layer: Layer.Layer<Service, never, NotificationBusService | SqlClient>;
122
- export declare const layerWithBus: Layer.Layer<Service, never, SqlClient>;
120
+ export declare const layer: Layer.Layer<Service, never, import("../database/notification-bus").Service | import("effect/unstable/sql/SqlClient").SqlClient>;
121
+ export declare const layerWithBus: Layer.Layer<Service, never, import("effect/unstable/sql/SqlClient").SqlClient>;
123
122
  export declare const memoryLayer: Layer.Layer<Service, never, never>;
124
123
  export type TestImplementation = Omit<Interface, "appendNext" | "page"> & Partial<Pick<Interface, "appendNext" | "page">>;
125
124
  export declare const testLayer: (implementation: TestImplementation) => Layer.Layer<Service, never, never>;
@@ -8,7 +8,7 @@ export * as CompactionRepository from "./compaction/compaction-repository";
8
8
  export * as Database from "./database/database-service";
9
9
  export * as SqlDialect from "./database/sql-dialect";
10
10
  export * as EnvelopeRepository from "./envelope/envelope-repository";
11
- export * as EntityRepository from "./entity/entity-repository";
11
+ export * as ResidentRepository from "./resident/resident-repository";
12
12
  export * as ExecutionEventRepository from "./execution/execution-event-repository";
13
13
  export * as ExecutionRepository from "./execution/execution-repository";
14
14
  export * as ExecutionStateRepository from "./state/execution-state-repository";
@@ -7,7 +7,7 @@ export * as ClusterRegistryRepository from "./cluster/cluster-registry-repositor
7
7
  export * as CompactionRepository from "./compaction/compaction-repository";
8
8
  export * as ContextEpochRepository from "./session/context-epoch-repository";
9
9
  export * as EnvelopeRepository from "./envelope/envelope-repository";
10
- export * as EntityRepository from "./entity/entity-repository";
10
+ export * as ResidentRepository from "./resident/resident-repository";
11
11
  export * as ExecutionEventRepository from "./execution/execution-event-repository";
12
12
  export * as ExecutionRepository from "./execution/execution-repository";
13
13
  export * as ExecutionStateRepository from "./state/execution-state-repository";
@@ -0,0 +1,36 @@
1
+ import { Ids, Resident } from "../../schema/index";
2
+ import { Context, Effect, Layer, Schema } from "effect";
3
+ import { SqlClient } from "effect/unstable/sql/SqlClient";
4
+ declare const ResidentRepositoryError_base: Schema.Class<ResidentRepositoryError, Schema.TaggedStruct<"ResidentRepositoryError", {
5
+ readonly message: Schema.String;
6
+ }>, import("effect/Cause").YieldableError>;
7
+ export declare class ResidentRepositoryError extends ResidentRepositoryError_base {
8
+ }
9
+ export interface CreateInstanceInput {
10
+ readonly kind: Ids.ResidentKindName;
11
+ readonly key: Ids.ResidentKey;
12
+ readonly addressId: Ids.AddressId;
13
+ readonly executionId: (generation: number) => Ids.ExecutionId;
14
+ readonly createdAt: number;
15
+ }
16
+ export interface Interface {
17
+ readonly putKind: (definition: Resident.KindDefinition) => Effect.Effect<Resident.KindDefinition, ResidentRepositoryError>;
18
+ readonly getKind: (kind: Ids.ResidentKindName) => Effect.Effect<Resident.KindDefinition | undefined, ResidentRepositoryError>;
19
+ readonly listKinds: (_?: never) => Effect.Effect<ReadonlyArray<Resident.KindDefinition>, ResidentRepositoryError>;
20
+ readonly spawn: (input: CreateInstanceInput) => Effect.Effect<Resident.Instance, ResidentRepositoryError>;
21
+ readonly get: (kind: Ids.ResidentKindName, key: Ids.ResidentKey) => Effect.Effect<Resident.Instance | undefined, ResidentRepositoryError>;
22
+ readonly destroy: (kind: Ids.ResidentKindName, key: Ids.ResidentKey, destroyedAt: number) => Effect.Effect<Resident.Instance | undefined, ResidentRepositoryError>;
23
+ readonly list: (input: {
24
+ readonly kind?: Ids.ResidentKindName;
25
+ readonly afterKind?: Ids.ResidentKindName;
26
+ readonly afterKey?: string;
27
+ readonly limit?: number;
28
+ }) => Effect.Effect<ReadonlyArray<Resident.Instance>, ResidentRepositoryError>;
29
+ }
30
+ declare const Service_base: Context.ServiceClass<Service, "@relayfx/store-sql/resident/resident-repository/Service", Interface>;
31
+ export declare class Service extends Service_base {
32
+ }
33
+ export declare const layer: Layer.Layer<Service, never, SqlClient>;
34
+ export declare const memoryLayer: Layer.Layer<Service, never, never>;
35
+ export declare const testLayer: (implementation: Interface) => Layer.Layer<Service, never, never>;
36
+ export {};
@@ -0,0 +1,131 @@
1
+ export declare const relayAddressBookEntries: import("drizzle-orm/pg-core").PgTableWithColumns<{
2
+ name: "relay_address_book_entries";
3
+ schema: undefined;
4
+ columns: {
5
+ tenantId: import("drizzle-orm/pg-core").PgBuildColumn<"relay_address_book_entries", import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").Set$Type<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>, string & import("effect/Brand").Brand<"Relay.TenantId">>>>, {
6
+ name: string;
7
+ tableName: "relay_address_book_entries";
8
+ dataType: "string";
9
+ data: string & import("effect/Brand").Brand<"Relay.TenantId">;
10
+ driverParam: string;
11
+ notNull: true;
12
+ hasDefault: true;
13
+ isPrimaryKey: false;
14
+ isAutoincrement: false;
15
+ hasRuntimeDefault: false;
16
+ enumValues: undefined;
17
+ identity: undefined;
18
+ generated: undefined;
19
+ }>;
20
+ id: import("drizzle-orm/pg-core").PgBuildColumn<"relay_address_book_entries", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").Set$Type<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>, string & import("effect/Brand").Brand<"Relay.AddressBookEntryId">>>, {
21
+ name: string;
22
+ tableName: "relay_address_book_entries";
23
+ dataType: "string";
24
+ data: string & import("effect/Brand").Brand<"Relay.AddressBookEntryId">;
25
+ driverParam: string;
26
+ notNull: true;
27
+ hasDefault: false;
28
+ isPrimaryKey: false;
29
+ isAutoincrement: false;
30
+ hasRuntimeDefault: false;
31
+ enumValues: undefined;
32
+ identity: undefined;
33
+ generated: undefined;
34
+ }>;
35
+ addressId: import("drizzle-orm/pg-core").PgBuildColumn<"relay_address_book_entries", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").Set$Type<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>, string & import("effect/Brand").Brand<"Relay.AddressId">>>, {
36
+ name: string;
37
+ tableName: "relay_address_book_entries";
38
+ dataType: "string";
39
+ data: string & import("effect/Brand").Brand<"Relay.AddressId">;
40
+ driverParam: string;
41
+ notNull: true;
42
+ hasDefault: false;
43
+ isPrimaryKey: false;
44
+ isAutoincrement: false;
45
+ hasRuntimeDefault: false;
46
+ enumValues: undefined;
47
+ identity: undefined;
48
+ generated: undefined;
49
+ }>;
50
+ routeKind: import("drizzle-orm/pg-core").PgBuildColumn<"relay_address_book_entries", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
51
+ name: string;
52
+ tableName: "relay_address_book_entries";
53
+ dataType: "string";
54
+ data: string;
55
+ driverParam: string;
56
+ notNull: true;
57
+ hasDefault: false;
58
+ isPrimaryKey: false;
59
+ isAutoincrement: false;
60
+ hasRuntimeDefault: false;
61
+ enumValues: undefined;
62
+ identity: undefined;
63
+ generated: undefined;
64
+ }>;
65
+ routeKey: import("drizzle-orm/pg-core").PgBuildColumn<"relay_address_book_entries", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
66
+ name: string;
67
+ tableName: "relay_address_book_entries";
68
+ dataType: "string";
69
+ data: string;
70
+ driverParam: string;
71
+ notNull: true;
72
+ hasDefault: false;
73
+ isPrimaryKey: false;
74
+ isAutoincrement: false;
75
+ hasRuntimeDefault: false;
76
+ enumValues: undefined;
77
+ identity: undefined;
78
+ generated: undefined;
79
+ }>;
80
+ metadataJson: import("drizzle-orm/pg-core").PgBuildColumn<"relay_address_book_entries", import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").Set$Type<import("drizzle-orm/pg-core").PgJsonbBuilder, {
81
+ readonly [x: string]: import("effect/Schema").Json;
82
+ }>>>, {
83
+ name: string;
84
+ tableName: "relay_address_book_entries";
85
+ dataType: "object json";
86
+ data: {
87
+ readonly [x: string]: import("effect/Schema").Json;
88
+ };
89
+ driverParam: unknown;
90
+ notNull: true;
91
+ hasDefault: true;
92
+ isPrimaryKey: false;
93
+ isAutoincrement: false;
94
+ hasRuntimeDefault: false;
95
+ enumValues: undefined;
96
+ identity: undefined;
97
+ generated: undefined;
98
+ }>;
99
+ createdAt: import("drizzle-orm/pg-core").PgBuildColumn<"relay_address_book_entries", import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTimestampBuilder>>, {
100
+ name: string;
101
+ tableName: "relay_address_book_entries";
102
+ dataType: "object date";
103
+ data: Date;
104
+ driverParam: string;
105
+ notNull: true;
106
+ hasDefault: true;
107
+ isPrimaryKey: false;
108
+ isAutoincrement: false;
109
+ hasRuntimeDefault: false;
110
+ enumValues: undefined;
111
+ identity: undefined;
112
+ generated: undefined;
113
+ }>;
114
+ updatedAt: import("drizzle-orm/pg-core").PgBuildColumn<"relay_address_book_entries", import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTimestampBuilder>>, {
115
+ name: string;
116
+ tableName: "relay_address_book_entries";
117
+ dataType: "object date";
118
+ data: Date;
119
+ driverParam: string;
120
+ notNull: true;
121
+ hasDefault: true;
122
+ isPrimaryKey: false;
123
+ isAutoincrement: false;
124
+ hasRuntimeDefault: false;
125
+ enumValues: undefined;
126
+ identity: undefined;
127
+ generated: undefined;
128
+ }>;
129
+ };
130
+ dialect: 'pg';
131
+ }>;