@relayfx/sdk 0.1.0 → 0.2.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.
- package/dist/ai.js +2 -2
- package/dist/{index-q0z11q9m.js → index-2xztzkfr.js} +5705 -3835
- package/dist/{index-sms8x6cq.js → index-bcbbm5wt.js} +1 -1
- package/dist/{index-vbf5hcw8.js → index-qgt9z94q.js} +320 -33
- package/dist/index.js +92 -3
- package/dist/migrations/20260712180000_child_fan_out/migration.sql +27 -0
- package/dist/migrations/20260712190000_workflow_definitions/migration.sql +3 -0
- package/dist/migrations/20260712200000_workflow_runtime/migration.sql +2 -0
- package/dist/migrations/mysql/0008_child_fan_out.sql +26 -0
- package/dist/migrations/mysql/0009_workflow_definitions.sql +3 -0
- package/dist/migrations/mysql/0010_workflow_runtime.sql +3 -0
- package/dist/migrations/pg/20260712180000_child_fan_out/migration.sql +27 -0
- package/dist/migrations/pg/20260712190000_workflow_definitions/migration.sql +3 -0
- package/dist/migrations/pg/20260712200000_workflow_runtime/migration.sql +2 -0
- package/dist/migrations/sqlite/0008_child_fan_out.sql +27 -0
- package/dist/migrations/sqlite/0009_workflow_definitions.sql +3 -0
- package/dist/migrations/sqlite/0010_workflow_runtime.sql +3 -0
- package/dist/sqlite.js +60 -11
- package/dist/types/relay/adapter-outbox.d.ts +3 -3
- package/dist/types/relay/client.d.ts +147 -17
- package/dist/types/relay/index.d.ts +2 -2
- package/dist/types/relay/operation.d.ts +559 -2
- package/dist/types/relay/sqlite-migrations.d.ts +16 -1
- package/dist/types/relay/sqlite-runtime.d.ts +8 -3
- package/dist/types/relay/sqlite.d.ts +3 -1
- package/dist/types/runtime/child/child-fan-out-admission-service.d.ts +30 -0
- package/dist/types/runtime/child/child-fan-out-runtime.d.ts +34 -0
- package/dist/types/runtime/child/child-fan-out-transition-service.d.ts +25 -0
- package/dist/types/runtime/cluster/execution-entity.d.ts +4 -2
- package/dist/types/runtime/execution/active-execution-registry.d.ts +12 -0
- package/dist/types/runtime/execution/execution-service.d.ts +1 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/runner/runner-runtime-service.d.ts +14 -14
- package/dist/types/runtime/workflow/definition-runtime.d.ts +78 -0
- package/dist/types/runtime/workflow/execution-workflow.d.ts +5 -5
- package/dist/types/schema/child-orchestration-schema.d.ts +393 -0
- package/dist/types/schema/execution-schema.d.ts +2 -2
- package/dist/types/schema/ids-schema.d.ts +12 -0
- package/dist/types/schema/index.d.ts +3 -0
- package/dist/types/schema/wait-schema.d.ts +98 -0
- package/dist/types/schema/workflow-schema.d.ts +2062 -0
- package/dist/types/store-sql/child/child-fan-out-repository.d.ts +53 -0
- package/dist/types/store-sql/index.d.ts +2 -0
- package/dist/types/store-sql/portable.d.ts +2 -0
- package/dist/types/store-sql/schema/relay-schema.d.ts +1266 -1
- package/dist/types/store-sql/workflow/workflow-definition-repository.d.ts +29 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
exports_language_model_registration
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-bcbbm5wt.js";
|
|
5
5
|
import {
|
|
6
6
|
Service,
|
|
7
7
|
exports_client,
|
|
8
8
|
exports_command,
|
|
9
9
|
exports_operation
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-qgt9z94q.js";
|
|
11
11
|
import {
|
|
12
12
|
Dialect,
|
|
13
13
|
__export,
|
|
@@ -24,8 +24,10 @@ import {
|
|
|
24
24
|
exports_agent_schema,
|
|
25
25
|
exports_artifact_store_service,
|
|
26
26
|
exports_blob_store_service,
|
|
27
|
+
exports_child_fan_out_runtime,
|
|
27
28
|
exports_child_run_service,
|
|
28
29
|
exports_content_schema,
|
|
30
|
+
exports_definition_runtime,
|
|
29
31
|
exports_entity_schema,
|
|
30
32
|
exports_envelope_schema,
|
|
31
33
|
exports_envelope_service,
|
|
@@ -51,11 +53,13 @@ import {
|
|
|
51
53
|
exports_skill_schema,
|
|
52
54
|
exports_tool_runtime_service,
|
|
53
55
|
exports_tool_schema,
|
|
56
|
+
exports_wait_schema,
|
|
54
57
|
exports_wait_service,
|
|
58
|
+
exports_workflow_schema,
|
|
55
59
|
fromDbTimestamp,
|
|
56
60
|
fromNullableDbTimestamp,
|
|
57
61
|
timestampParam
|
|
58
|
-
} from "./index-
|
|
62
|
+
} from "./index-2xztzkfr.js";
|
|
59
63
|
|
|
60
64
|
// src/adapter-outbox.ts
|
|
61
65
|
var exports_adapter_outbox = {};
|
|
@@ -172,6 +176,10 @@ var exports_relay_schema = {};
|
|
|
172
176
|
__export(exports_relay_schema, {
|
|
173
177
|
relayWorkspaceSnapshots: () => relayWorkspaceSnapshots,
|
|
174
178
|
relayWorkspaceLeases: () => relayWorkspaceLeases,
|
|
179
|
+
relayWorkflowRuns: () => relayWorkflowRuns,
|
|
180
|
+
relayWorkflowOperationStates: () => relayWorkflowOperationStates,
|
|
181
|
+
relayWorkflowLifecycleEvents: () => relayWorkflowLifecycleEvents,
|
|
182
|
+
relayWorkflowDefinitionRevisions: () => relayWorkflowDefinitionRevisions,
|
|
175
183
|
relayWaits: () => relayWaits,
|
|
176
184
|
relayTopicSubscriptions: () => relayTopicSubscriptions,
|
|
177
185
|
relayToolResults: () => relayToolResults,
|
|
@@ -201,6 +209,8 @@ __export(exports_relay_schema, {
|
|
|
201
209
|
relayEnvelopeReady: () => relayEnvelopeReady,
|
|
202
210
|
relayEntityKinds: () => relayEntityKinds,
|
|
203
211
|
relayEntityInstances: () => relayEntityInstances,
|
|
212
|
+
relayChildFanOuts: () => relayChildFanOuts,
|
|
213
|
+
relayChildFanOutMembers: () => relayChildFanOutMembers,
|
|
204
214
|
relayChildExecutions: () => relayChildExecutions,
|
|
205
215
|
relayAgentDefinitions: () => relayAgentDefinitions,
|
|
206
216
|
relayAgentDefinitionRevisions: () => relayAgentDefinitionRevisions,
|
|
@@ -222,6 +232,51 @@ import {
|
|
|
222
232
|
} from "drizzle-orm/pg-core";
|
|
223
233
|
import { sql as sql2 } from "drizzle-orm";
|
|
224
234
|
var tenantId = () => text("tenant_id").$type().notNull().default(exports_ids_schema.SystemTenantId);
|
|
235
|
+
var relayWorkflowDefinitionRevisions = pgTable("relay_workflow_definition_revisions", {
|
|
236
|
+
tenantId: tenantId(),
|
|
237
|
+
workflowDefinitionId: text("workflow_definition_id").$type().notNull(),
|
|
238
|
+
revision: integer("revision").$type().notNull(),
|
|
239
|
+
digest: text("digest").$type().notNull(),
|
|
240
|
+
definitionJson: jsonb("definition_json").$type().notNull(),
|
|
241
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
242
|
+
}, (table) => [
|
|
243
|
+
primaryKey({ columns: [table.tenantId, table.workflowDefinitionId, table.revision] }),
|
|
244
|
+
uniqueIndex("uq_relay_workflow_definition_digest").on(table.tenantId, table.workflowDefinitionId, table.digest)
|
|
245
|
+
]);
|
|
246
|
+
var relayWorkflowRuns = pgTable("relay_workflow_runs", {
|
|
247
|
+
tenantId: tenantId(),
|
|
248
|
+
executionId: text("execution_id").$type().notNull(),
|
|
249
|
+
workflowDefinitionId: text("workflow_definition_id").$type().notNull(),
|
|
250
|
+
workflowDefinitionRevision: integer("workflow_definition_revision").$type().notNull(),
|
|
251
|
+
workflowDefinitionDigest: text("workflow_definition_digest").$type().notNull(),
|
|
252
|
+
status: text("status").$type().notNull(),
|
|
253
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
254
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
255
|
+
}, (table) => [primaryKey({ columns: [table.tenantId, table.executionId] })]);
|
|
256
|
+
var relayWorkflowOperationStates = pgTable("relay_workflow_operation_states", {
|
|
257
|
+
tenantId: tenantId(),
|
|
258
|
+
executionId: text("execution_id").$type().notNull(),
|
|
259
|
+
operationId: text("operation_id").$type().notNull(),
|
|
260
|
+
status: text("status").notNull(),
|
|
261
|
+
fanOutId: text("fan_out_id"),
|
|
262
|
+
decision: boolean("decision"),
|
|
263
|
+
outputJson: jsonb("output_json"),
|
|
264
|
+
attempt: integer("attempt"),
|
|
265
|
+
backoffUntil: timestamp("backoff_until", { withTimezone: true }),
|
|
266
|
+
compensationOperationId: text("compensation_operation_id"),
|
|
267
|
+
startedAt: timestamp("started_at", { withTimezone: true }),
|
|
268
|
+
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
269
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
270
|
+
}, (table) => [primaryKey({ columns: [table.tenantId, table.executionId, table.operationId] })]);
|
|
271
|
+
var relayWorkflowLifecycleEvents = pgTable("relay_workflow_lifecycle_events", {
|
|
272
|
+
tenantId: tenantId(),
|
|
273
|
+
executionId: text("execution_id").$type().notNull(),
|
|
274
|
+
sequence: integer("sequence").notNull(),
|
|
275
|
+
eventType: text("event_type").notNull(),
|
|
276
|
+
operationId: text("operation_id"),
|
|
277
|
+
dataJson: jsonb("data_json"),
|
|
278
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull()
|
|
279
|
+
}, (table) => [primaryKey({ columns: [table.tenantId, table.executionId, table.sequence] })]);
|
|
225
280
|
var relayEntityKinds = pgTable("relay_entity_kinds", {
|
|
226
281
|
tenantId: tenantId(),
|
|
227
282
|
kind: text("kind").$type().notNull(),
|
|
@@ -544,6 +599,36 @@ var relayChildExecutions = pgTable("relay_child_executions", {
|
|
|
544
599
|
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_child_executions" }),
|
|
545
600
|
index("idx_relay_child_executions_parent").on(table.tenantId, table.executionId)
|
|
546
601
|
]);
|
|
602
|
+
var relayChildFanOuts = pgTable("relay_child_fan_outs", {
|
|
603
|
+
tenantId: tenantId(),
|
|
604
|
+
id: text("id").$type().notNull(),
|
|
605
|
+
parentExecutionId: text("parent_execution_id").$type().notNull(),
|
|
606
|
+
definitionJson: jsonb("definition_json").$type().notNull(),
|
|
607
|
+
state: text("state").$type().notNull().default("joining"),
|
|
608
|
+
satisfiedAt: timestamp("satisfied_at", { withTimezone: true }),
|
|
609
|
+
failedAt: timestamp("failed_at", { withTimezone: true }),
|
|
610
|
+
cancelledAt: timestamp("cancelled_at", { withTimezone: true }),
|
|
611
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
612
|
+
}, (table) => [
|
|
613
|
+
primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_child_fan_outs" }),
|
|
614
|
+
index("idx_relay_child_fan_outs_parent").on(table.tenantId, table.parentExecutionId)
|
|
615
|
+
]);
|
|
616
|
+
var relayChildFanOutMembers = pgTable("relay_child_fan_out_members", {
|
|
617
|
+
tenantId: tenantId(),
|
|
618
|
+
fanOutId: text("fan_out_id").$type().notNull(),
|
|
619
|
+
childExecutionId: text("child_execution_id").$type().notNull(),
|
|
620
|
+
ordinal: integer("ordinal").notNull(),
|
|
621
|
+
state: text("state").$type().notNull().default("queued"),
|
|
622
|
+
outputJson: jsonb("output_json").$type(),
|
|
623
|
+
error: text("error"),
|
|
624
|
+
completedAt: timestamp("completed_at", { withTimezone: true })
|
|
625
|
+
}, (table) => [
|
|
626
|
+
primaryKey({
|
|
627
|
+
columns: [table.tenantId, table.fanOutId, table.childExecutionId],
|
|
628
|
+
name: "pk_relay_child_fan_out_members"
|
|
629
|
+
}),
|
|
630
|
+
uniqueIndex("uq_relay_child_fan_out_member_ordinal").on(table.tenantId, table.fanOutId, table.ordinal)
|
|
631
|
+
]);
|
|
547
632
|
var relayEnvelopes = pgTable("relay_envelopes", {
|
|
548
633
|
tenantId: tenantId(),
|
|
549
634
|
id: text("id").$type().notNull(),
|
|
@@ -827,6 +912,9 @@ var run = Effect3.fn("ToolWorker.run")(function* (options) {
|
|
|
827
912
|
var relayPackage = "@relayfx/sdk";
|
|
828
913
|
export {
|
|
829
914
|
relayPackage,
|
|
915
|
+
exports_definition_runtime as WorkflowDefinitionRuntime,
|
|
916
|
+
exports_workflow_schema as Workflow,
|
|
917
|
+
exports_wait_schema as Waits,
|
|
830
918
|
exports_wait_service as WaitService,
|
|
831
919
|
exports_tool_worker as ToolWorker,
|
|
832
920
|
exports_tool_runtime_service as ToolRuntime,
|
|
@@ -862,6 +950,7 @@ export {
|
|
|
862
950
|
exports_command as Command,
|
|
863
951
|
exports_client as Client,
|
|
864
952
|
exports_child_run_service as ChildRunService,
|
|
953
|
+
exports_child_fan_out_runtime as ChildFanOutRuntime,
|
|
865
954
|
exports_blob_store_service as BlobStore,
|
|
866
955
|
exports_artifact_store_service as ArtifactStore,
|
|
867
956
|
exports_agent_registry_service as AgentRegistry,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
CREATE TABLE "relay_child_fan_out_members" (
|
|
2
|
+
"tenant_id" text DEFAULT 'system',
|
|
3
|
+
"fan_out_id" text,
|
|
4
|
+
"child_execution_id" text,
|
|
5
|
+
"ordinal" integer NOT NULL,
|
|
6
|
+
"state" text DEFAULT 'queued' NOT NULL,
|
|
7
|
+
"output_json" jsonb,
|
|
8
|
+
"error" text,
|
|
9
|
+
"completed_at" timestamp with time zone,
|
|
10
|
+
CONSTRAINT "pk_relay_child_fan_out_members" PRIMARY KEY("tenant_id","fan_out_id","child_execution_id")
|
|
11
|
+
);
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
CREATE TABLE "relay_child_fan_outs" (
|
|
14
|
+
"tenant_id" text DEFAULT 'system',
|
|
15
|
+
"id" text,
|
|
16
|
+
"parent_execution_id" text NOT NULL,
|
|
17
|
+
"definition_json" jsonb NOT NULL,
|
|
18
|
+
"state" text DEFAULT 'joining' NOT NULL,
|
|
19
|
+
"satisfied_at" timestamp with time zone,
|
|
20
|
+
"failed_at" timestamp with time zone,
|
|
21
|
+
"cancelled_at" timestamp with time zone,
|
|
22
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
23
|
+
CONSTRAINT "pk_relay_child_fan_outs" PRIMARY KEY("tenant_id","id")
|
|
24
|
+
);
|
|
25
|
+
--> statement-breakpoint
|
|
26
|
+
CREATE UNIQUE INDEX "uq_relay_child_fan_out_member_ordinal" ON "relay_child_fan_out_members" ("tenant_id","fan_out_id","ordinal");--> statement-breakpoint
|
|
27
|
+
CREATE INDEX "idx_relay_child_fan_outs_parent" ON "relay_child_fan_outs" ("tenant_id","parent_execution_id");
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS "relay_workflow_definition_revisions" ("tenant_id" text DEFAULT 'system' NOT NULL, "workflow_definition_id" text NOT NULL, "revision" integer NOT NULL, "digest" text NOT NULL, "definition_json" jsonb NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, PRIMARY KEY("tenant_id","workflow_definition_id","revision"));
|
|
2
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "uq_relay_workflow_definition_digest" ON "relay_workflow_definition_revisions" ("tenant_id","workflow_definition_id","digest");
|
|
3
|
+
CREATE TABLE IF NOT EXISTS "relay_workflow_runs" ("tenant_id" text DEFAULT 'system' NOT NULL, "execution_id" text NOT NULL, "workflow_definition_id" text NOT NULL, "workflow_definition_revision" integer NOT NULL, "workflow_definition_digest" text NOT NULL, "status" text NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL, PRIMARY KEY("tenant_id","execution_id"));
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS "relay_workflow_operation_states" ("tenant_id" text NOT NULL, "execution_id" text NOT NULL, "operation_id" text NOT NULL, "status" text NOT NULL, "fan_out_id" text, "decision" boolean, "output_json" jsonb, "attempt" integer, "backoff_until" timestamptz, "compensation_operation_id" text, "started_at" timestamptz, "completed_at" timestamptz, "updated_at" timestamptz NOT NULL, CONSTRAINT "relay_workflow_operation_states_pk" PRIMARY KEY("tenant_id", "execution_id", "operation_id"));
|
|
2
|
+
CREATE TABLE IF NOT EXISTS "relay_workflow_lifecycle_events" ("tenant_id" text NOT NULL, "execution_id" text NOT NULL, "sequence" integer NOT NULL, "event_type" text NOT NULL, "operation_id" text, "data_json" jsonb, "created_at" timestamptz NOT NULL, CONSTRAINT "relay_workflow_lifecycle_events_pk" PRIMARY KEY("tenant_id", "execution_id", "sequence"));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
CREATE TABLE `relay_child_fan_outs` (
|
|
2
|
+
`tenant_id` varchar(191) NOT NULL DEFAULT 'system',
|
|
3
|
+
`id` varchar(191) NOT NULL,
|
|
4
|
+
`parent_execution_id` varchar(191) NOT NULL,
|
|
5
|
+
`definition_json` json NOT NULL,
|
|
6
|
+
`state` varchar(32) NOT NULL DEFAULT 'joining',
|
|
7
|
+
`satisfied_at` datetime(3),
|
|
8
|
+
`failed_at` datetime(3),
|
|
9
|
+
`cancelled_at` datetime(3),
|
|
10
|
+
`created_at` datetime(3) NOT NULL,
|
|
11
|
+
PRIMARY KEY (`tenant_id`, `id`),
|
|
12
|
+
INDEX `idx_relay_child_fan_outs_parent` (`tenant_id`, `parent_execution_id`)
|
|
13
|
+
);
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
CREATE TABLE `relay_child_fan_out_members` (
|
|
16
|
+
`tenant_id` varchar(191) NOT NULL DEFAULT 'system',
|
|
17
|
+
`fan_out_id` varchar(191) NOT NULL,
|
|
18
|
+
`child_execution_id` varchar(191) NOT NULL,
|
|
19
|
+
`ordinal` integer NOT NULL,
|
|
20
|
+
`state` varchar(32) NOT NULL DEFAULT 'queued',
|
|
21
|
+
`output_json` json,
|
|
22
|
+
`error` text,
|
|
23
|
+
`completed_at` datetime(3),
|
|
24
|
+
PRIMARY KEY (`tenant_id`, `fan_out_id`, `child_execution_id`),
|
|
25
|
+
UNIQUE KEY `uq_relay_child_fan_out_member_ordinal` (`tenant_id`, `fan_out_id`, `ordinal`)
|
|
26
|
+
);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_definition_revisions (tenant_id VARCHAR(255) NOT NULL, workflow_definition_id VARCHAR(255) NOT NULL, revision INT NOT NULL, digest VARCHAR(255) NOT NULL, definition_json JSON NOT NULL, created_at DATETIME(3) NOT NULL, PRIMARY KEY (tenant_id, workflow_definition_id, revision), UNIQUE KEY uq_relay_workflow_definition_digest (tenant_id, workflow_definition_id, digest));
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_runs (tenant_id VARCHAR(255) NOT NULL, execution_id VARCHAR(255) NOT NULL, workflow_definition_id VARCHAR(255) NOT NULL, workflow_definition_revision INT NOT NULL, workflow_definition_digest VARCHAR(255) NOT NULL, status VARCHAR(32) NOT NULL, created_at DATETIME(3) NOT NULL, updated_at DATETIME(3) NOT NULL, PRIMARY KEY (tenant_id, execution_id));
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_operation_states (tenant_id VARCHAR(255) NOT NULL, execution_id VARCHAR(255) NOT NULL, operation_id VARCHAR(255) NOT NULL, status VARCHAR(32) NOT NULL, fan_out_id VARCHAR(255), decision BOOLEAN, output_json JSON, attempt INTEGER, backoff_until DATETIME(3), compensation_operation_id VARCHAR(255), started_at DATETIME(3), completed_at DATETIME(3), updated_at DATETIME(3) NOT NULL, PRIMARY KEY (tenant_id, execution_id, operation_id));
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_lifecycle_events (tenant_id VARCHAR(255) NOT NULL, execution_id VARCHAR(255) NOT NULL, sequence INT NOT NULL, event_type VARCHAR(64) NOT NULL, operation_id VARCHAR(255), data_json JSON, created_at DATETIME(3) NOT NULL, PRIMARY KEY (tenant_id, execution_id, sequence));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
CREATE TABLE "relay_child_fan_out_members" (
|
|
2
|
+
"tenant_id" text DEFAULT 'system',
|
|
3
|
+
"fan_out_id" text,
|
|
4
|
+
"child_execution_id" text,
|
|
5
|
+
"ordinal" integer NOT NULL,
|
|
6
|
+
"state" text DEFAULT 'queued' NOT NULL,
|
|
7
|
+
"output_json" jsonb,
|
|
8
|
+
"error" text,
|
|
9
|
+
"completed_at" timestamp with time zone,
|
|
10
|
+
CONSTRAINT "pk_relay_child_fan_out_members" PRIMARY KEY("tenant_id","fan_out_id","child_execution_id")
|
|
11
|
+
);
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
CREATE TABLE "relay_child_fan_outs" (
|
|
14
|
+
"tenant_id" text DEFAULT 'system',
|
|
15
|
+
"id" text,
|
|
16
|
+
"parent_execution_id" text NOT NULL,
|
|
17
|
+
"definition_json" jsonb NOT NULL,
|
|
18
|
+
"state" text DEFAULT 'joining' NOT NULL,
|
|
19
|
+
"satisfied_at" timestamp with time zone,
|
|
20
|
+
"failed_at" timestamp with time zone,
|
|
21
|
+
"cancelled_at" timestamp with time zone,
|
|
22
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
23
|
+
CONSTRAINT "pk_relay_child_fan_outs" PRIMARY KEY("tenant_id","id")
|
|
24
|
+
);
|
|
25
|
+
--> statement-breakpoint
|
|
26
|
+
CREATE UNIQUE INDEX "uq_relay_child_fan_out_member_ordinal" ON "relay_child_fan_out_members" ("tenant_id","fan_out_id","ordinal");--> statement-breakpoint
|
|
27
|
+
CREATE INDEX "idx_relay_child_fan_outs_parent" ON "relay_child_fan_outs" ("tenant_id","parent_execution_id");
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS "relay_workflow_definition_revisions" ("tenant_id" text DEFAULT 'system' NOT NULL, "workflow_definition_id" text NOT NULL, "revision" integer NOT NULL, "digest" text NOT NULL, "definition_json" jsonb NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, PRIMARY KEY("tenant_id","workflow_definition_id","revision"));
|
|
2
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "uq_relay_workflow_definition_digest" ON "relay_workflow_definition_revisions" ("tenant_id","workflow_definition_id","digest");
|
|
3
|
+
CREATE TABLE IF NOT EXISTS "relay_workflow_runs" ("tenant_id" text DEFAULT 'system' NOT NULL, "execution_id" text NOT NULL, "workflow_definition_id" text NOT NULL, "workflow_definition_revision" integer NOT NULL, "workflow_definition_digest" text NOT NULL, "status" text NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL, PRIMARY KEY("tenant_id","execution_id"));
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS "relay_workflow_operation_states" ("tenant_id" text NOT NULL, "execution_id" text NOT NULL, "operation_id" text NOT NULL, "status" text NOT NULL, "fan_out_id" text, "decision" boolean, "output_json" jsonb, "attempt" integer, "backoff_until" timestamptz, "compensation_operation_id" text, "started_at" timestamptz, "completed_at" timestamptz, "updated_at" timestamptz NOT NULL, CONSTRAINT "relay_workflow_operation_states_pk" PRIMARY KEY("tenant_id", "execution_id", "operation_id"));
|
|
2
|
+
CREATE TABLE IF NOT EXISTS "relay_workflow_lifecycle_events" ("tenant_id" text NOT NULL, "execution_id" text NOT NULL, "sequence" integer NOT NULL, "event_type" text NOT NULL, "operation_id" text, "data_json" jsonb, "created_at" timestamptz NOT NULL, CONSTRAINT "relay_workflow_lifecycle_events_pk" PRIMARY KEY("tenant_id", "execution_id", "sequence"));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
CREATE TABLE `relay_child_fan_outs` (
|
|
2
|
+
`tenant_id` text NOT NULL DEFAULT 'system',
|
|
3
|
+
`id` text NOT NULL,
|
|
4
|
+
`parent_execution_id` text NOT NULL,
|
|
5
|
+
`definition_json` text NOT NULL,
|
|
6
|
+
`state` text NOT NULL DEFAULT 'joining',
|
|
7
|
+
`satisfied_at` integer,
|
|
8
|
+
`failed_at` integer,
|
|
9
|
+
`cancelled_at` integer,
|
|
10
|
+
`created_at` integer NOT NULL,
|
|
11
|
+
PRIMARY KEY (`tenant_id`, `id`)
|
|
12
|
+
);
|
|
13
|
+
--> statement-breakpoint
|
|
14
|
+
CREATE INDEX `idx_relay_child_fan_outs_parent` ON `relay_child_fan_outs` (`tenant_id`, `parent_execution_id`);
|
|
15
|
+
--> statement-breakpoint
|
|
16
|
+
CREATE TABLE `relay_child_fan_out_members` (
|
|
17
|
+
`tenant_id` text NOT NULL DEFAULT 'system',
|
|
18
|
+
`fan_out_id` text NOT NULL,
|
|
19
|
+
`child_execution_id` text NOT NULL,
|
|
20
|
+
`ordinal` integer NOT NULL,
|
|
21
|
+
`state` text NOT NULL DEFAULT 'queued',
|
|
22
|
+
`output_json` text,
|
|
23
|
+
`error` text,
|
|
24
|
+
`completed_at` integer,
|
|
25
|
+
PRIMARY KEY (`tenant_id`, `fan_out_id`, `child_execution_id`),
|
|
26
|
+
UNIQUE (`tenant_id`, `fan_out_id`, `ordinal`)
|
|
27
|
+
);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_definition_revisions (tenant_id TEXT NOT NULL, workflow_definition_id TEXT NOT NULL, revision INTEGER NOT NULL, digest TEXT NOT NULL, definition_json TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY (tenant_id, workflow_definition_id, revision), UNIQUE (tenant_id, workflow_definition_id, digest));
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_runs (tenant_id TEXT NOT NULL, execution_id TEXT NOT NULL, workflow_definition_id TEXT NOT NULL, workflow_definition_revision INTEGER NOT NULL, workflow_definition_digest TEXT NOT NULL, status TEXT NOT NULL, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, PRIMARY KEY (tenant_id, execution_id));
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_operation_states (tenant_id TEXT NOT NULL, execution_id TEXT NOT NULL, operation_id TEXT NOT NULL, status TEXT NOT NULL, fan_out_id TEXT, decision INTEGER, output_json TEXT, attempt INTEGER, backoff_until INTEGER, compensation_operation_id TEXT, started_at INTEGER, completed_at INTEGER, updated_at INTEGER NOT NULL, PRIMARY KEY (tenant_id, execution_id, operation_id));
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_lifecycle_events (tenant_id TEXT NOT NULL, execution_id TEXT NOT NULL, sequence INTEGER NOT NULL, event_type TEXT NOT NULL, operation_id TEXT, data_json TEXT, created_at INTEGER NOT NULL, PRIMARY KEY (tenant_id, execution_id, sequence));
|
package/dist/sqlite.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
exports_client,
|
|
4
4
|
exports_operation
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-qgt9z94q.js";
|
|
6
6
|
import {
|
|
7
7
|
__export,
|
|
8
8
|
exports_activity_version_registry,
|
|
@@ -14,19 +14,25 @@ import {
|
|
|
14
14
|
exports_agent_schema,
|
|
15
15
|
exports_artifact_store_service,
|
|
16
16
|
exports_blob_store_service,
|
|
17
|
+
exports_child_fan_out_repository,
|
|
18
|
+
exports_child_fan_out_runtime,
|
|
19
|
+
exports_child_fan_out_transition_service,
|
|
17
20
|
exports_child_run_service,
|
|
18
21
|
exports_content_schema,
|
|
22
|
+
exports_definition_runtime,
|
|
19
23
|
exports_entity_schema,
|
|
20
24
|
exports_envelope_schema,
|
|
21
25
|
exports_envelope_service,
|
|
22
26
|
exports_event_log_service,
|
|
23
27
|
exports_execution_entity,
|
|
28
|
+
exports_execution_event_repository,
|
|
24
29
|
exports_execution_schema,
|
|
25
30
|
exports_execution_service,
|
|
26
31
|
exports_execution_workflow,
|
|
27
32
|
exports_ids_schema,
|
|
28
33
|
exports_language_model_service,
|
|
29
34
|
exports_model_call_policy,
|
|
35
|
+
exports_notification_bus,
|
|
30
36
|
exports_prompt_assembler_service,
|
|
31
37
|
exports_runner_runtime_service,
|
|
32
38
|
exports_schedule_schema,
|
|
@@ -37,18 +43,23 @@ import {
|
|
|
37
43
|
exports_skill_schema,
|
|
38
44
|
exports_tool_runtime_service,
|
|
39
45
|
exports_tool_schema,
|
|
40
|
-
exports_wait_service
|
|
41
|
-
|
|
46
|
+
exports_wait_service,
|
|
47
|
+
exports_workflow_definition_repository,
|
|
48
|
+
exports_workflow_schema
|
|
49
|
+
} from "./index-2xztzkfr.js";
|
|
42
50
|
// src/sqlite-runtime.ts
|
|
43
51
|
var exports_sqlite_runtime = {};
|
|
44
52
|
__export(exports_sqlite_runtime, {
|
|
53
|
+
workflowLayer: () => workflowLayer,
|
|
45
54
|
migrationsLayer: () => migrationsLayer,
|
|
46
55
|
layer: () => layer,
|
|
47
|
-
clientLayer: () => clientLayer
|
|
56
|
+
clientLayer: () => clientLayer,
|
|
57
|
+
childFanOutLayer: () => childFanOutLayer
|
|
48
58
|
});
|
|
49
59
|
import { layer as sqliteClientLayer } from "@effect/sql-sqlite-bun/SqliteClient";
|
|
50
|
-
import { layer as sqliteMigratorLayer } from "@effect/sql-sqlite-bun/SqliteMigrator";
|
|
51
|
-
import { Layer } from "effect";
|
|
60
|
+
import { layer as sqliteMigratorLayer, run as runSqliteMigrator } from "@effect/sql-sqlite-bun/SqliteMigrator";
|
|
61
|
+
import { Effect as Effect2, Layer } from "effect";
|
|
62
|
+
import { SqlClient as SqlClient2 } from "effect/unstable/sql/SqlClient";
|
|
52
63
|
|
|
53
64
|
// ../../migrations/sqlite/0001_baseline.sql
|
|
54
65
|
var _0001_baseline_default = `CREATE TABLE "relay_address_book_entries" (
|
|
@@ -613,10 +624,25 @@ var _0007_topic_subscriptions_default = `CREATE TABLE relay_topic_subscriptions
|
|
|
613
624
|
CREATE INDEX idx_relay_topic_subscriptions_subscriber ON relay_topic_subscriptions (tenant_id, subscriber_execution_id);
|
|
614
625
|
`;
|
|
615
626
|
|
|
627
|
+
// ../../migrations/sqlite/0008_child_fan_out.sql
|
|
628
|
+
var _0008_child_fan_out_default = "CREATE TABLE `relay_child_fan_outs` (\n `tenant_id` text NOT NULL DEFAULT 'system',\n `id` text NOT NULL,\n `parent_execution_id` text NOT NULL,\n `definition_json` text NOT NULL,\n `state` text NOT NULL DEFAULT 'joining',\n `satisfied_at` integer,\n `failed_at` integer,\n `cancelled_at` integer,\n `created_at` integer NOT NULL,\n PRIMARY KEY (`tenant_id`, `id`)\n);\n--> statement-breakpoint\nCREATE INDEX `idx_relay_child_fan_outs_parent` ON `relay_child_fan_outs` (`tenant_id`, `parent_execution_id`);\n--> statement-breakpoint\nCREATE TABLE `relay_child_fan_out_members` (\n `tenant_id` text NOT NULL DEFAULT 'system',\n `fan_out_id` text NOT NULL,\n `child_execution_id` text NOT NULL,\n `ordinal` integer NOT NULL,\n `state` text NOT NULL DEFAULT 'queued',\n `output_json` text,\n `error` text,\n `completed_at` integer,\n PRIMARY KEY (`tenant_id`, `fan_out_id`, `child_execution_id`),\n UNIQUE (`tenant_id`, `fan_out_id`, `ordinal`)\n);\n";
|
|
629
|
+
|
|
630
|
+
// ../../migrations/sqlite/0009_workflow_definitions.sql
|
|
631
|
+
var _0009_workflow_definitions_default = `CREATE TABLE IF NOT EXISTS relay_workflow_definition_revisions (tenant_id TEXT NOT NULL, workflow_definition_id TEXT NOT NULL, revision INTEGER NOT NULL, digest TEXT NOT NULL, definition_json TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY (tenant_id, workflow_definition_id, revision), UNIQUE (tenant_id, workflow_definition_id, digest));
|
|
632
|
+
--> statement-breakpoint
|
|
633
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_runs (tenant_id TEXT NOT NULL, execution_id TEXT NOT NULL, workflow_definition_id TEXT NOT NULL, workflow_definition_revision INTEGER NOT NULL, workflow_definition_digest TEXT NOT NULL, status TEXT NOT NULL, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, PRIMARY KEY (tenant_id, execution_id));
|
|
634
|
+
`;
|
|
635
|
+
|
|
636
|
+
// ../../migrations/sqlite/0010_workflow_runtime.sql
|
|
637
|
+
var _0010_workflow_runtime_default = `CREATE TABLE IF NOT EXISTS relay_workflow_operation_states (tenant_id TEXT NOT NULL, execution_id TEXT NOT NULL, operation_id TEXT NOT NULL, status TEXT NOT NULL, fan_out_id TEXT, decision INTEGER, output_json TEXT, attempt INTEGER, backoff_until INTEGER, compensation_operation_id TEXT, started_at INTEGER, completed_at INTEGER, updated_at INTEGER NOT NULL, PRIMARY KEY (tenant_id, execution_id, operation_id));
|
|
638
|
+
--> statement-breakpoint
|
|
639
|
+
CREATE TABLE IF NOT EXISTS relay_workflow_lifecycle_events (tenant_id TEXT NOT NULL, execution_id TEXT NOT NULL, sequence INTEGER NOT NULL, event_type TEXT NOT NULL, operation_id TEXT, data_json TEXT, created_at INTEGER NOT NULL, PRIMARY KEY (tenant_id, execution_id, sequence));
|
|
640
|
+
`;
|
|
641
|
+
|
|
616
642
|
// src/sqlite-migrations.ts
|
|
617
643
|
import { Effect } from "effect";
|
|
618
644
|
import { SqlClient } from "effect/unstable/sql/SqlClient";
|
|
619
|
-
var statements = (source) => source.split(
|
|
645
|
+
var statements = (source) => source.split(/--> statement-breakpoint|;/).map((statement) => statement.trim()).filter((statement) => statement.length > 0);
|
|
620
646
|
var execute = (source) => Effect.gen(function* () {
|
|
621
647
|
const sql = yield* SqlClient;
|
|
622
648
|
for (const statement of statements(source)) {
|
|
@@ -630,25 +656,47 @@ var migrations = [
|
|
|
630
656
|
{ id: 4, name: "execution_state", file: "0004_execution_state.sql", source: _0004_execution_state_default },
|
|
631
657
|
{ id: 5, name: "durable_entities", file: "0005_durable_entities.sql", source: _0005_durable_entities_default },
|
|
632
658
|
{ id: 6, name: "ephemeral_presence", file: "0006_ephemeral_presence.sql", source: _0006_ephemeral_presence_default },
|
|
633
|
-
{ id: 7, name: "topic_subscriptions", file: "0007_topic_subscriptions.sql", source: _0007_topic_subscriptions_default }
|
|
659
|
+
{ id: 7, name: "topic_subscriptions", file: "0007_topic_subscriptions.sql", source: _0007_topic_subscriptions_default },
|
|
660
|
+
{ id: 8, name: "child_fan_out", file: "0008_child_fan_out.sql", source: _0008_child_fan_out_default },
|
|
661
|
+
{ id: 9, name: "workflow_definitions", file: "0009_workflow_definitions.sql", source: _0009_workflow_definitions_default },
|
|
662
|
+
{ id: 10, name: "workflow_runtime", file: "0010_workflow_runtime.sql", source: _0010_workflow_runtime_default }
|
|
634
663
|
];
|
|
635
664
|
var loader = Effect.succeed(migrations.map(({ id, name, source }) => [id, name, Effect.succeed(execute(source))]));
|
|
636
665
|
|
|
637
666
|
// src/sqlite-runtime.ts
|
|
638
667
|
var clientLayer = (options) => sqliteClientLayer(options);
|
|
639
|
-
var
|
|
668
|
+
var migrationOptions = {
|
|
640
669
|
loader,
|
|
641
670
|
table: "relay_migrations"
|
|
642
|
-
}
|
|
671
|
+
};
|
|
672
|
+
var migrationsLayer = sqliteMigratorLayer(migrationOptions);
|
|
643
673
|
var layer = (options) => {
|
|
644
674
|
const client = clientLayer(options);
|
|
645
|
-
return Layer.
|
|
675
|
+
return Layer.effect(SqlClient2, Effect2.gen(function* () {
|
|
676
|
+
const sql = yield* SqlClient2;
|
|
677
|
+
yield* runSqliteMigrator(migrationOptions);
|
|
678
|
+
return sql;
|
|
679
|
+
})).pipe(Layer.provide(client));
|
|
680
|
+
};
|
|
681
|
+
var workflowLayer = (options, handlersLayer) => {
|
|
682
|
+
const sqlite = layer(options);
|
|
683
|
+
const repository = exports_workflow_definition_repository.layer.pipe(Layer.provideMerge(sqlite));
|
|
684
|
+
return exports_definition_runtime.layer.pipe(Layer.provideMerge(handlersLayer), Layer.provideMerge(repository));
|
|
685
|
+
};
|
|
686
|
+
var childFanOutLayer = (options, handlersLayer) => {
|
|
687
|
+
const sqlite = layer(options);
|
|
688
|
+
const repository = exports_child_fan_out_repository.layer.pipe(Layer.provideMerge(sqlite));
|
|
689
|
+
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));
|
|
690
|
+
const transitions = exports_child_fan_out_transition_service.layer.pipe(Layer.provide(repository), Layer.provide(events));
|
|
691
|
+
return exports_child_fan_out_runtime.layer.pipe(Layer.provide(handlersLayer), Layer.provide(repository), Layer.provide(transitions));
|
|
646
692
|
};
|
|
647
693
|
|
|
648
694
|
// src/sqlite.ts
|
|
649
695
|
var relaySqlitePackage = "@relayfx/sdk/sqlite";
|
|
650
696
|
export {
|
|
651
697
|
relaySqlitePackage,
|
|
698
|
+
exports_definition_runtime as WorkflowDefinitionRuntime,
|
|
699
|
+
exports_workflow_schema as Workflow,
|
|
652
700
|
exports_wait_service as WaitService,
|
|
653
701
|
exports_tool_runtime_service as ToolRuntime,
|
|
654
702
|
exports_tool_schema as Tool,
|
|
@@ -676,6 +724,7 @@ export {
|
|
|
676
724
|
exports_content_schema as Content,
|
|
677
725
|
exports_client as Client,
|
|
678
726
|
exports_child_run_service as ChildRunService,
|
|
727
|
+
exports_child_fan_out_runtime as ChildFanOutRuntime,
|
|
679
728
|
exports_blob_store_service as BlobStore,
|
|
680
729
|
exports_artifact_store_service as ArtifactStore,
|
|
681
730
|
exports_agent_registry_service as AgentRegistry,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from "effect";
|
|
2
|
-
import { ClientError, Service as ClientService } from "./client";
|
|
2
|
+
import { ClientError, Service as ClientService, WaitKindMismatch } from "./client";
|
|
3
3
|
import { AckEnvelopeReadyInput, ClaimEnvelopeReadyInput, EnvelopeReadyAcked, EnvelopeReadyLease, EnvelopeReadyReleased, ReleaseEnvelopeReadyInput, SubmitInboundEnvelopeAccepted, SubmitInboundEnvelopeInput } from "./operation";
|
|
4
4
|
export interface Interface {
|
|
5
5
|
readonly claim: (input: ClaimEnvelopeReadyInput) => Effect.Effect<EnvelopeReadyLease | null, ClientError>;
|
|
6
6
|
readonly ack: (input: AckEnvelopeReadyInput) => Effect.Effect<EnvelopeReadyAcked, ClientError>;
|
|
7
7
|
readonly release: (input: ReleaseEnvelopeReadyInput) => Effect.Effect<EnvelopeReadyReleased, ClientError>;
|
|
8
|
-
readonly submitInbound: (input: SubmitInboundEnvelopeInput) => Effect.Effect<SubmitInboundEnvelopeAccepted, ClientError>;
|
|
8
|
+
readonly submitInbound: (input: SubmitInboundEnvelopeInput) => Effect.Effect<SubmitInboundEnvelopeAccepted, WaitKindMismatch | ClientError>;
|
|
9
9
|
}
|
|
10
10
|
declare const Service_base: Context.ServiceClass<Service, "@relayfx/sdk/AdapterOutbox", Interface>;
|
|
11
11
|
export declare class Service extends Service_base {
|
|
@@ -15,5 +15,5 @@ export declare const testLayer: (implementation: Interface) => Layer.Layer<Servi
|
|
|
15
15
|
export declare const claim: (input: ClaimEnvelopeReadyInput) => Effect.Effect<EnvelopeReadyLease | null, ClientError, Service>;
|
|
16
16
|
export declare const ack: (input: AckEnvelopeReadyInput) => Effect.Effect<EnvelopeReadyAcked, ClientError, Service>;
|
|
17
17
|
export declare const release: (input: ReleaseEnvelopeReadyInput) => Effect.Effect<EnvelopeReadyReleased, ClientError, Service>;
|
|
18
|
-
export declare const submitInbound: (input: SubmitInboundEnvelopeInput) => Effect.Effect<SubmitInboundEnvelopeAccepted, ClientError, Service>;
|
|
18
|
+
export declare const submitInbound: (input: SubmitInboundEnvelopeInput) => Effect.Effect<SubmitInboundEnvelopeAccepted, ClientError | WaitKindMismatch, Service>;
|
|
19
19
|
export {};
|