@relayfx/sdk 0.0.48 → 0.0.50
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 +2054 -576
- package/dist/index.js +2884 -860
- package/dist/migrations/20260709214238_faithful_black_widow/migration.sql +53 -0
- package/dist/migrations/20260709214238_faithful_black_widow/snapshot.json +5426 -0
- package/dist/migrations/20260709220016_fearless_aaron_stack/migration.sql +2 -0
- package/dist/migrations/20260709220016_fearless_aaron_stack/snapshot.json +5426 -0
- package/dist/migrations/mysql/0002_durable_tool_placement.sql +75 -0
- package/dist/migrations/pg/20260709214238_faithful_black_widow/migration.sql +53 -0
- package/dist/migrations/pg/20260709214238_faithful_black_widow/snapshot.json +5426 -0
- package/dist/migrations/pg/20260709220016_fearless_aaron_stack/migration.sql +2 -0
- package/dist/migrations/pg/20260709220016_fearless_aaron_stack/snapshot.json +5426 -0
- package/dist/migrations/sqlite/0002_durable_tool_placement.sql +71 -0
- package/dist/types/relay/client.d.ts +27 -6
- package/dist/types/relay/index.d.ts +1 -0
- package/dist/types/relay/operation.d.ts +525 -53
- package/dist/types/relay/tool-worker.d.ts +19 -0
- package/dist/types/runtime/address/address-resolution-service.d.ts +69 -54
- package/dist/types/runtime/agent/relay-compaction.d.ts +1 -0
- package/dist/types/runtime/cluster/execution-entity.d.ts +10 -477
- package/dist/types/runtime/execution/event-log-service.d.ts +6 -0
- package/dist/types/runtime/index.d.ts +1 -0
- package/dist/types/runtime/runner/runner-runtime-service.d.ts +18 -15
- package/dist/types/runtime/tool/tool-runtime-service.d.ts +17 -1
- package/dist/types/runtime/tool/tool-transition-coordinator.d.ts +13 -0
- package/dist/types/runtime/workflow/execution-workflow.d.ts +146 -114
- package/dist/types/schema/agent-schema.d.ts +431 -320
- package/dist/types/schema/execution-schema.d.ts +69 -53
- package/dist/types/schema/ids-schema.d.ts +4 -0
- package/dist/types/schema/tool-schema.d.ts +29 -0
- package/dist/types/store-sql/envelope/envelope-repository.d.ts +6 -0
- package/dist/types/store-sql/execution/execution-event-repository.d.ts +6 -0
- package/dist/types/store-sql/schema/relay-schema.d.ts +386 -7
- package/dist/types/store-sql/tool/tool-call-repository.d.ts +160 -1
- package/package.json +3 -3
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
CREATE TABLE `relay_tool_attempts` (
|
|
2
|
+
`tenant_id` VARCHAR(191) NOT NULL DEFAULT 'system',
|
|
3
|
+
`id` VARCHAR(191) NOT NULL,
|
|
4
|
+
`tool_call_id` VARCHAR(191) NOT NULL,
|
|
5
|
+
`attempt_number` INT NOT NULL,
|
|
6
|
+
`state` VARCHAR(32) NOT NULL,
|
|
7
|
+
`worker_id` VARCHAR(191),
|
|
8
|
+
`claim_expires_at` DATETIME(3),
|
|
9
|
+
`error` TEXT,
|
|
10
|
+
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
11
|
+
`completed_at` DATETIME(3),
|
|
12
|
+
CONSTRAINT `pk_relay_tool_attempts` PRIMARY KEY (`tenant_id`, `tool_call_id`, `id`)
|
|
13
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `definition_json` JSON;
|
|
16
|
+
--> statement-breakpoint
|
|
17
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `placement_kind` VARCHAR(32) NOT NULL DEFAULT 'local';
|
|
18
|
+
--> statement-breakpoint
|
|
19
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `placement_key` VARCHAR(191);
|
|
20
|
+
--> statement-breakpoint
|
|
21
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `state` VARCHAR(32) NOT NULL DEFAULT 'requested';
|
|
22
|
+
--> statement-breakpoint
|
|
23
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `wait_id` VARCHAR(191);
|
|
24
|
+
--> statement-breakpoint
|
|
25
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `idempotency_key` TEXT;
|
|
26
|
+
--> statement-breakpoint
|
|
27
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `available_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3);
|
|
28
|
+
--> statement-breakpoint
|
|
29
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `active_attempt_id` VARCHAR(191);
|
|
30
|
+
--> statement-breakpoint
|
|
31
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `claim_owner` VARCHAR(191);
|
|
32
|
+
--> statement-breakpoint
|
|
33
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `claimed_at` DATETIME(3);
|
|
34
|
+
--> statement-breakpoint
|
|
35
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `claim_expires_at` DATETIME(3);
|
|
36
|
+
--> statement-breakpoint
|
|
37
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `external_outcome_json` JSON;
|
|
38
|
+
--> statement-breakpoint
|
|
39
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `external_outcome_at` DATETIME(3);
|
|
40
|
+
--> statement-breakpoint
|
|
41
|
+
ALTER TABLE `relay_tool_calls` ADD COLUMN `updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3);
|
|
42
|
+
--> statement-breakpoint
|
|
43
|
+
UPDATE `relay_tool_calls`
|
|
44
|
+
SET `idempotency_key` = CONCAT(
|
|
45
|
+
'tool:', CHAR_LENGTH(`tenant_id`), ':', `tenant_id`, ':',
|
|
46
|
+
CHAR_LENGTH(`execution_id`), ':', `execution_id`, ':', CHAR_LENGTH(`id`), ':', `id`
|
|
47
|
+
),
|
|
48
|
+
`available_at` = `created_at`,
|
|
49
|
+
`updated_at` = `created_at`,
|
|
50
|
+
`state` = CASE
|
|
51
|
+
WHEN EXISTS (
|
|
52
|
+
SELECT 1 FROM `relay_tool_results` result
|
|
53
|
+
WHERE result.`tenant_id` = `relay_tool_calls`.`tenant_id`
|
|
54
|
+
AND result.`tool_call_id` = `relay_tool_calls`.`id`
|
|
55
|
+
AND result.`error` IS NULL
|
|
56
|
+
) THEN 'completed'
|
|
57
|
+
WHEN EXISTS (
|
|
58
|
+
SELECT 1 FROM `relay_tool_results` result
|
|
59
|
+
WHERE result.`tenant_id` = `relay_tool_calls`.`tenant_id`
|
|
60
|
+
AND result.`tool_call_id` = `relay_tool_calls`.`id`
|
|
61
|
+
) THEN 'failed'
|
|
62
|
+
ELSE 'requested'
|
|
63
|
+
END;
|
|
64
|
+
--> statement-breakpoint
|
|
65
|
+
ALTER TABLE `relay_tool_calls` MODIFY COLUMN `idempotency_key` TEXT NOT NULL;
|
|
66
|
+
--> statement-breakpoint
|
|
67
|
+
CREATE UNIQUE INDEX `uq_relay_tool_attempts_number` ON `relay_tool_attempts` (`tenant_id`, `tool_call_id`, `attempt_number`);
|
|
68
|
+
--> statement-breakpoint
|
|
69
|
+
CREATE INDEX `idx_relay_tool_attempts_call` ON `relay_tool_attempts` (`tenant_id`, `tool_call_id`, `attempt_number`);
|
|
70
|
+
--> statement-breakpoint
|
|
71
|
+
CREATE INDEX `idx_relay_tool_calls_remote_claim` ON `relay_tool_calls` (`tenant_id`, `placement_kind`, `placement_key`, `state`, `available_at`, `created_at`, `id`);
|
|
72
|
+
--> statement-breakpoint
|
|
73
|
+
CREATE INDEX `idx_relay_tool_calls_stale_claim` ON `relay_tool_calls` (`tenant_id`, `state`, `claim_expires_at`);
|
|
74
|
+
--> statement-breakpoint
|
|
75
|
+
CREATE INDEX `idx_relay_tool_calls_client_pending` ON `relay_tool_calls` (`tenant_id`, `placement_kind`, `state`, `created_at`, `id`);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
CREATE TABLE "relay_tool_attempts" (
|
|
2
|
+
"tenant_id" text DEFAULT 'system',
|
|
3
|
+
"id" text,
|
|
4
|
+
"tool_call_id" text NOT NULL,
|
|
5
|
+
"attempt_number" integer NOT NULL,
|
|
6
|
+
"state" text NOT NULL,
|
|
7
|
+
"worker_id" text,
|
|
8
|
+
"claim_expires_at" timestamp with time zone,
|
|
9
|
+
"error" text,
|
|
10
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
11
|
+
"completed_at" timestamp with time zone,
|
|
12
|
+
CONSTRAINT "pk_relay_tool_attempts" PRIMARY KEY("tenant_id","id")
|
|
13
|
+
);
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "definition_json" jsonb;--> statement-breakpoint
|
|
16
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "placement_kind" text DEFAULT 'local' NOT NULL;--> statement-breakpoint
|
|
17
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "placement_key" text;--> statement-breakpoint
|
|
18
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "state" text DEFAULT 'requested' NOT NULL;--> statement-breakpoint
|
|
19
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "wait_id" text;--> statement-breakpoint
|
|
20
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "idempotency_key" text;--> statement-breakpoint
|
|
21
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "available_at" timestamp with time zone DEFAULT now() NOT NULL;--> statement-breakpoint
|
|
22
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "active_attempt_id" text;--> statement-breakpoint
|
|
23
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "claim_owner" text;--> statement-breakpoint
|
|
24
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "claimed_at" timestamp with time zone;--> statement-breakpoint
|
|
25
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "claim_expires_at" timestamp with time zone;--> statement-breakpoint
|
|
26
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "external_outcome_json" jsonb;--> statement-breakpoint
|
|
27
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "external_outcome_at" timestamp with time zone;--> statement-breakpoint
|
|
28
|
+
ALTER TABLE "relay_tool_calls" ADD COLUMN "updated_at" timestamp with time zone DEFAULT now() NOT NULL;--> statement-breakpoint
|
|
29
|
+
UPDATE "relay_tool_calls"
|
|
30
|
+
SET "idempotency_key" = 'tool:' || char_length("tenant_id") || ':' || "tenant_id" || ':' ||
|
|
31
|
+
char_length("execution_id") || ':' || "execution_id" || ':' || char_length("id") || ':' || "id",
|
|
32
|
+
"available_at" = "created_at",
|
|
33
|
+
"updated_at" = "created_at",
|
|
34
|
+
"state" = CASE
|
|
35
|
+
WHEN EXISTS (
|
|
36
|
+
SELECT 1 FROM "relay_tool_results" result
|
|
37
|
+
WHERE result."tenant_id" = "relay_tool_calls"."tenant_id"
|
|
38
|
+
AND result."tool_call_id" = "relay_tool_calls"."id"
|
|
39
|
+
AND result."error" IS NULL
|
|
40
|
+
) THEN 'completed'
|
|
41
|
+
WHEN EXISTS (
|
|
42
|
+
SELECT 1 FROM "relay_tool_results" result
|
|
43
|
+
WHERE result."tenant_id" = "relay_tool_calls"."tenant_id"
|
|
44
|
+
AND result."tool_call_id" = "relay_tool_calls"."id"
|
|
45
|
+
) THEN 'failed'
|
|
46
|
+
ELSE 'requested'
|
|
47
|
+
END;--> statement-breakpoint
|
|
48
|
+
ALTER TABLE "relay_tool_calls" ALTER COLUMN "idempotency_key" SET NOT NULL;--> statement-breakpoint
|
|
49
|
+
CREATE UNIQUE INDEX "uq_relay_tool_attempts_number" ON "relay_tool_attempts" ("tenant_id","tool_call_id","attempt_number");--> statement-breakpoint
|
|
50
|
+
CREATE INDEX "idx_relay_tool_attempts_call" ON "relay_tool_attempts" ("tenant_id","tool_call_id","attempt_number");--> statement-breakpoint
|
|
51
|
+
CREATE INDEX "idx_relay_tool_calls_remote_claim" ON "relay_tool_calls" ("tenant_id","placement_kind","placement_key","state","available_at","created_at","id");--> statement-breakpoint
|
|
52
|
+
CREATE INDEX "idx_relay_tool_calls_stale_claim" ON "relay_tool_calls" ("tenant_id","state","claim_expires_at");--> statement-breakpoint
|
|
53
|
+
CREATE INDEX "idx_relay_tool_calls_client_pending" ON "relay_tool_calls" ("tenant_id","placement_kind","state","created_at","id");
|