@relayfx/sdk 0.3.4 → 0.3.6

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.
@@ -1114,42 +1114,46 @@ var Classification = Schema17.Union([
1114
1114
  TimerWait,
1115
1115
  ExternalWait
1116
1116
  ]).annotate({ identifier: "Relay.WaitClassification" });
1117
- var suffixAfter = (waitId, namespace) => waitId.slice(namespace.length);
1117
+ var scopedToolCallId = (waitId, namespace) => {
1118
+ const scope = waitId.slice(namespace.length);
1119
+ const separator = scope.indexOf(":");
1120
+ return ToolCallId.make(decodeURIComponent(scope.slice(separator + 1)));
1121
+ };
1118
1122
  var classify = (input) => {
1119
1123
  const waitId = input.wait_id;
1120
1124
  if (waitId.startsWith("wait:permission:")) {
1121
1125
  return {
1122
1126
  kind: "permission",
1123
1127
  wait_id: waitId,
1124
- tool_call_id: ToolCallId.make(suffixAfter(waitId, "wait:permission:"))
1128
+ tool_call_id: scopedToolCallId(waitId, "wait:permission:")
1125
1129
  };
1126
1130
  }
1127
1131
  if (waitId.startsWith("wait:approval:")) {
1128
1132
  return {
1129
1133
  kind: "tool_approval",
1130
1134
  wait_id: waitId,
1131
- tool_call_id: ToolCallId.make(suffixAfter(waitId, "wait:approval:"))
1135
+ tool_call_id: scopedToolCallId(waitId, "wait:approval:")
1132
1136
  };
1133
1137
  }
1134
1138
  if (waitId.startsWith("wait:child:")) {
1135
1139
  return {
1136
1140
  kind: "child_join",
1137
1141
  wait_id: waitId,
1138
- child_execution_id: ChildExecutionId.make(suffixAfter(waitId, "wait:child:"))
1142
+ child_execution_id: ChildExecutionId.make(waitId.slice("wait:child:".length))
1139
1143
  };
1140
1144
  }
1141
1145
  if (waitId.startsWith("wait:inbox:")) {
1142
1146
  return {
1143
1147
  kind: "inbox",
1144
1148
  wait_id: waitId,
1145
- tool_call_id: ToolCallId.make(suffixAfter(waitId, "wait:inbox:"))
1149
+ tool_call_id: ToolCallId.make(waitId.slice("wait:inbox:".length))
1146
1150
  };
1147
1151
  }
1148
1152
  if (waitId.startsWith("wait:tool:")) {
1149
1153
  return {
1150
1154
  kind: "tool_placement",
1151
1155
  wait_id: waitId,
1152
- tool_call_id: ToolCallId.make(suffixAfter(waitId, "wait:tool:"))
1156
+ tool_call_id: scopedToolCallId(waitId, "wait:tool:")
1153
1157
  };
1154
1158
  }
1155
1159
  if (waitId.startsWith("wait:reply:") || input.envelope_id !== undefined && input.mode === "reply") {
@@ -2019,6 +2023,7 @@ var ClaimToolWorkInput = Schema22.Struct({
2019
2023
  claim_expires_at: exports_shared_schema.TimestampMillis
2020
2024
  }).annotate({ identifier: "Relay.Operation.ClaimToolWorkInput" });
2021
2025
  var CompleteToolWorkInput = Schema22.Struct({
2026
+ execution_id: exports_ids_schema.ExecutionId,
2022
2027
  tool_call_id: exports_ids_schema.ToolCallId,
2023
2028
  attempt_id: exports_ids_schema.ToolAttemptId,
2024
2029
  worker_id: exports_tool_schema.WorkerId,
@@ -2026,6 +2031,7 @@ var CompleteToolWorkInput = Schema22.Struct({
2026
2031
  completed_at: exports_shared_schema.TimestampMillis
2027
2032
  }).annotate({ identifier: "Relay.Operation.CompleteToolWorkInput" });
2028
2033
  var ReleaseToolWorkInput = Schema22.Struct({
2034
+ execution_id: exports_ids_schema.ExecutionId,
2029
2035
  tool_call_id: exports_ids_schema.ToolCallId,
2030
2036
  attempt_id: exports_ids_schema.ToolAttemptId,
2031
2037
  worker_id: exports_tool_schema.WorkerId,
@@ -2034,6 +2040,7 @@ var ReleaseToolWorkInput = Schema22.Struct({
2034
2040
  error: Schema22.optionalKey(Schema22.String)
2035
2041
  }).annotate({ identifier: "Relay.Operation.ReleaseToolWorkInput" });
2036
2042
  var ListToolAttemptsInput = Schema22.Struct({
2043
+ execution_id: exports_ids_schema.ExecutionId,
2037
2044
  tool_call_id: exports_ids_schema.ToolCallId
2038
2045
  }).annotate({ identifier: "Relay.Operation.ListToolAttemptsInput" });
2039
2046
  var ToolAttempt = Schema22.Struct({
package/dist/index.js CHANGED
@@ -13,10 +13,10 @@ import {
13
13
  exports_tool_runtime,
14
14
  exports_workflow_definition_host,
15
15
  makeDatabaseIdentity
16
- } from "./index-01rpd00m.js";
16
+ } from "./index-e02krw55.js";
17
17
  import {
18
18
  exports_model_registry
19
- } from "./index-25gwk9tj.js";
19
+ } from "./index-8fpd6kvj.js";
20
20
  import {
21
21
  Service,
22
22
  exports_address_schema,
@@ -40,7 +40,7 @@ import {
40
40
  exports_tool_schema,
41
41
  exports_wait_schema,
42
42
  exports_workflow_schema
43
- } from "./index-cphmds30.js";
43
+ } from "./index-mtvz1bjn.js";
44
44
  import {
45
45
  __export
46
46
  } from "./index-nb39b5ae.js";
@@ -127,6 +127,7 @@ var runOnce = Effect2.fn("ToolWorker.runOnce")(function* (options) {
127
127
  const outcome = yield* handlerOutcome(options, lease);
128
128
  const completedAt = yield* Clock.currentTimeMillis;
129
129
  yield* client.completeToolWork({
130
+ execution_id: lease.execution_id,
130
131
  tool_call_id: lease.call.id,
131
132
  attempt_id: lease.attempt.attempt_id,
132
133
  worker_id: options.workerId,
@@ -169,13 +170,13 @@ __export(exports_language_model_registration, {
169
170
  OpenAiAccountCredentialError: () => OpenAiAccountCredentialError
170
171
  });
171
172
 
172
- // ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/deterministic.js
173
+ // ../../node_modules/.bun/@batonfx+providers@0.6.2/node_modules/@batonfx/providers/dist/deterministic.js
173
174
  import { OpenAiClient as OpenAiClient2 } from "@effect/ai-openai";
174
175
  import { Config as Config2, Effect as Effect4, Layer as Layer3, Option, Stream as Stream2 } from "effect";
175
176
  import { LanguageModel, Response } from "effect/unstable/ai";
176
177
  import { FetchHttpClient as FetchHttpClient2 } from "effect/unstable/http";
177
178
 
178
- // ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/openai.js
179
+ // ../../node_modules/.bun/@batonfx+providers@0.6.2/node_modules/@batonfx/providers/dist/openai.js
179
180
  import { OpenAiClient, OpenAiLanguageModel } from "@effect/ai-openai";
180
181
  import { Config, Effect as Effect3, Layer as Layer2, Redacted, Schema, Stream } from "effect";
181
182
  import { AiError } from "effect/unstable/ai";
@@ -263,7 +264,7 @@ var openAiAccount = (input) => exports_model_registry.registrationFromLayer({
263
264
  var withOpenAiAccount = (input) => exports_model_registry.layerFromRegistrationEffects([openAiAccount(input)]);
264
265
  var withOpenAiAccountFetch = (input) => withOpenAiAccount(input).pipe(Layer2.provide(FetchHttpClient.layer));
265
266
 
266
- // ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/deterministic.js
267
+ // ../../node_modules/.bun/@batonfx+providers@0.6.2/node_modules/@batonfx/providers/dist/deterministic.js
267
268
  var deterministicModelLayer = Layer3.effect(LanguageModel.LanguageModel, LanguageModel.make({
268
269
  generateText: () => Effect4.succeed([{ type: "text", text: "deterministic response" }]),
269
270
  streamText: () => Stream2.make(Response.makePart("text-delta", { id: "text", delta: "deterministic response" }))
@@ -296,7 +297,7 @@ var withOpenAiOrDeterministic = (options) => Layer3.unwrap(Effect4.gen(function*
296
297
  }));
297
298
  var withOpenAiOrDeterministicFetch = (options) => withOpenAiOrDeterministic(options).pipe(Layer3.provide(FetchHttpClient2.layer));
298
299
 
299
- // ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/anthropic.js
300
+ // ../../node_modules/.bun/@batonfx+providers@0.6.2/node_modules/@batonfx/providers/dist/anthropic.js
300
301
  import { AnthropicClient, AnthropicLanguageModel } from "@effect/ai-anthropic";
301
302
  import { Config as Config3, Layer as Layer4, Redacted as Redacted2 } from "effect";
302
303
  import { AiError as AiError2 } from "effect/unstable/ai";
@@ -321,7 +322,7 @@ var anthropic = (input) => exports_model_registry.registrationFromLayer({
321
322
  var anthropicClientLayerConfig = AnthropicClient.layerConfig;
322
323
  var withAnthropic = (options) => exports_model_registry.layerFromRegistrationEffects([anthropic(options)]).pipe(Layer4.provide(AnthropicClient.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })));
323
324
  var withAnthropicFetch = (options) => withAnthropic(options).pipe(Layer4.provide(FetchHttpClient3.layer));
324
- // ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/openai-compat.js
325
+ // ../../node_modules/.bun/@batonfx+providers@0.6.2/node_modules/@batonfx/providers/dist/openai-compat.js
325
326
  import { OpenAiClient as OpenAiClient3, OpenAiLanguageModel as OpenAiLanguageModel2 } from "@effect/ai-openai-compat";
326
327
  import { Config as Config4, Layer as Layer5, Redacted as Redacted3 } from "effect";
327
328
  import { FetchHttpClient as FetchHttpClient4 } from "effect/unstable/http";
@@ -344,7 +345,7 @@ var clientLayerConfig = (options) => OpenAiClient3.layerConfig({
344
345
  });
345
346
  var withOpenAiCompatible = (options) => exports_model_registry.layerFromRegistrationEffects([openAiCompatible(options)]).pipe(Layer5.provide(clientLayerConfig(options)));
346
347
  var withOpenAiCompatibleFetch = (options) => withOpenAiCompatible(options).pipe(Layer5.provide(FetchHttpClient4.layer));
347
- // ../../node_modules/.bun/@batonfx+providers@0.6.1/node_modules/@batonfx/providers/dist/openrouter.js
348
+ // ../../node_modules/.bun/@batonfx+providers@0.6.2/node_modules/@batonfx/providers/dist/openrouter.js
348
349
  import { OpenRouterClient, OpenRouterLanguageModel } from "@effect/ai-openrouter";
349
350
  import { Config as Config5, Layer as Layer6, Redacted as Redacted4 } from "effect";
350
351
  import { AiError as AiError3 } from "effect/unstable/ai";
@@ -0,0 +1,35 @@
1
+ ALTER TABLE "relay_tool_results" ADD COLUMN "execution_id" text;
2
+ --> statement-breakpoint
3
+ UPDATE "relay_tool_results" result SET "execution_id" = call."execution_id"
4
+ FROM "relay_tool_calls" call
5
+ WHERE result."tenant_id" = call."tenant_id" AND result."tool_call_id" = call."id";
6
+ --> statement-breakpoint
7
+ ALTER TABLE "relay_tool_results" ALTER COLUMN "execution_id" SET NOT NULL;
8
+ --> statement-breakpoint
9
+ ALTER TABLE "relay_tool_attempts" ADD COLUMN "execution_id" text;
10
+ --> statement-breakpoint
11
+ UPDATE "relay_tool_attempts" attempt SET "execution_id" = call."execution_id"
12
+ FROM "relay_tool_calls" call
13
+ WHERE attempt."tenant_id" = call."tenant_id" AND attempt."tool_call_id" = call."id";
14
+ --> statement-breakpoint
15
+ ALTER TABLE "relay_tool_attempts" ALTER COLUMN "execution_id" SET NOT NULL;
16
+ --> statement-breakpoint
17
+ ALTER TABLE "relay_tool_calls" DROP CONSTRAINT "pk_relay_tool_calls";
18
+ --> statement-breakpoint
19
+ ALTER TABLE "relay_tool_calls" ADD CONSTRAINT "pk_relay_tool_calls" PRIMARY KEY ("tenant_id", "execution_id", "id");
20
+ --> statement-breakpoint
21
+ ALTER TABLE "relay_tool_results" DROP CONSTRAINT "pk_relay_tool_results";
22
+ --> statement-breakpoint
23
+ ALTER TABLE "relay_tool_results" ADD CONSTRAINT "pk_relay_tool_results" PRIMARY KEY ("tenant_id", "execution_id", "tool_call_id");
24
+ --> statement-breakpoint
25
+ ALTER TABLE "relay_tool_attempts" DROP CONSTRAINT "pk_relay_tool_attempts";
26
+ --> statement-breakpoint
27
+ DROP INDEX "uq_relay_tool_attempts_number";
28
+ --> statement-breakpoint
29
+ DROP INDEX "idx_relay_tool_attempts_call";
30
+ --> statement-breakpoint
31
+ ALTER TABLE "relay_tool_attempts" ADD CONSTRAINT "pk_relay_tool_attempts" PRIMARY KEY ("tenant_id", "execution_id", "tool_call_id", "id");
32
+ --> statement-breakpoint
33
+ CREATE UNIQUE INDEX "uq_relay_tool_attempts_number" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "attempt_number");
34
+ --> statement-breakpoint
35
+ CREATE INDEX "idx_relay_tool_attempts_call" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "attempt_number");
@@ -0,0 +1,29 @@
1
+ ALTER TABLE `relay_tool_results` ADD COLUMN `execution_id` VARCHAR(191) NULL;
2
+ --> statement-breakpoint
3
+ UPDATE `relay_tool_results` result JOIN `relay_tool_calls` tool_call
4
+ ON result.`tenant_id` = tool_call.`tenant_id` AND result.`tool_call_id` = tool_call.`id`
5
+ SET result.`execution_id` = tool_call.`execution_id`;
6
+ --> statement-breakpoint
7
+ ALTER TABLE `relay_tool_results` MODIFY COLUMN `execution_id` VARCHAR(191) NOT NULL;
8
+ --> statement-breakpoint
9
+ ALTER TABLE `relay_tool_attempts` ADD COLUMN `execution_id` VARCHAR(191);
10
+ --> statement-breakpoint
11
+ UPDATE `relay_tool_attempts` attempt JOIN `relay_tool_calls` tool_call
12
+ ON attempt.`tenant_id` = tool_call.`tenant_id` AND attempt.`tool_call_id` = tool_call.`id`
13
+ SET attempt.`execution_id` = tool_call.`execution_id`;
14
+ --> statement-breakpoint
15
+ ALTER TABLE `relay_tool_attempts` MODIFY COLUMN `execution_id` VARCHAR(191) NOT NULL;
16
+ --> statement-breakpoint
17
+ ALTER TABLE `relay_tool_calls` DROP PRIMARY KEY, ADD CONSTRAINT `pk_relay_tool_calls` PRIMARY KEY (`tenant_id`, `execution_id`, `id`);
18
+ --> statement-breakpoint
19
+ ALTER TABLE `relay_tool_results` DROP PRIMARY KEY, ADD CONSTRAINT `pk_relay_tool_results` PRIMARY KEY (`tenant_id`, `execution_id`, `tool_call_id`);
20
+ --> statement-breakpoint
21
+ DROP INDEX `uq_relay_tool_attempts_number` ON `relay_tool_attempts`;
22
+ --> statement-breakpoint
23
+ DROP INDEX `idx_relay_tool_attempts_call` ON `relay_tool_attempts`;
24
+ --> statement-breakpoint
25
+ ALTER TABLE `relay_tool_attempts` DROP PRIMARY KEY, ADD CONSTRAINT `pk_relay_tool_attempts` PRIMARY KEY (`tenant_id`, `execution_id`, `tool_call_id`, `id`);
26
+ --> statement-breakpoint
27
+ CREATE UNIQUE INDEX `uq_relay_tool_attempts_number` ON `relay_tool_attempts` (`tenant_id`, `execution_id`, `tool_call_id`, `attempt_number`);
28
+ --> statement-breakpoint
29
+ CREATE INDEX `idx_relay_tool_attempts_call` ON `relay_tool_attempts` (`tenant_id`, `execution_id`, `tool_call_id`, `attempt_number`);
@@ -0,0 +1,35 @@
1
+ ALTER TABLE "relay_tool_results" ADD COLUMN "execution_id" text;
2
+ --> statement-breakpoint
3
+ UPDATE "relay_tool_results" result SET "execution_id" = call."execution_id"
4
+ FROM "relay_tool_calls" call
5
+ WHERE result."tenant_id" = call."tenant_id" AND result."tool_call_id" = call."id";
6
+ --> statement-breakpoint
7
+ ALTER TABLE "relay_tool_results" ALTER COLUMN "execution_id" SET NOT NULL;
8
+ --> statement-breakpoint
9
+ ALTER TABLE "relay_tool_attempts" ADD COLUMN "execution_id" text;
10
+ --> statement-breakpoint
11
+ UPDATE "relay_tool_attempts" attempt SET "execution_id" = call."execution_id"
12
+ FROM "relay_tool_calls" call
13
+ WHERE attempt."tenant_id" = call."tenant_id" AND attempt."tool_call_id" = call."id";
14
+ --> statement-breakpoint
15
+ ALTER TABLE "relay_tool_attempts" ALTER COLUMN "execution_id" SET NOT NULL;
16
+ --> statement-breakpoint
17
+ ALTER TABLE "relay_tool_calls" DROP CONSTRAINT "pk_relay_tool_calls";
18
+ --> statement-breakpoint
19
+ ALTER TABLE "relay_tool_calls" ADD CONSTRAINT "pk_relay_tool_calls" PRIMARY KEY ("tenant_id", "execution_id", "id");
20
+ --> statement-breakpoint
21
+ ALTER TABLE "relay_tool_results" DROP CONSTRAINT "pk_relay_tool_results";
22
+ --> statement-breakpoint
23
+ ALTER TABLE "relay_tool_results" ADD CONSTRAINT "pk_relay_tool_results" PRIMARY KEY ("tenant_id", "execution_id", "tool_call_id");
24
+ --> statement-breakpoint
25
+ ALTER TABLE "relay_tool_attempts" DROP CONSTRAINT "pk_relay_tool_attempts";
26
+ --> statement-breakpoint
27
+ DROP INDEX "uq_relay_tool_attempts_number";
28
+ --> statement-breakpoint
29
+ DROP INDEX "idx_relay_tool_attempts_call";
30
+ --> statement-breakpoint
31
+ ALTER TABLE "relay_tool_attempts" ADD CONSTRAINT "pk_relay_tool_attempts" PRIMARY KEY ("tenant_id", "execution_id", "tool_call_id", "id");
32
+ --> statement-breakpoint
33
+ CREATE UNIQUE INDEX "uq_relay_tool_attempts_number" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "attempt_number");
34
+ --> statement-breakpoint
35
+ CREATE INDEX "idx_relay_tool_attempts_call" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "attempt_number");
@@ -0,0 +1,53 @@
1
+ ALTER TABLE "relay_tool_results" ADD COLUMN "execution_id" TEXT NULL;
2
+ --> statement-breakpoint
3
+ UPDATE "relay_tool_results" SET "execution_id" = (
4
+ SELECT call."execution_id" FROM "relay_tool_calls" call
5
+ WHERE call."tenant_id" = "relay_tool_results"."tenant_id" AND call."id" = "relay_tool_results"."tool_call_id"
6
+ );
7
+ --> statement-breakpoint
8
+ ALTER TABLE "relay_tool_attempts" ADD COLUMN "execution_id" TEXT;
9
+ --> statement-breakpoint
10
+ UPDATE "relay_tool_attempts" SET "execution_id" = (
11
+ SELECT call."execution_id" FROM "relay_tool_calls" call
12
+ WHERE call."tenant_id" = "relay_tool_attempts"."tenant_id" AND call."id" = "relay_tool_attempts"."tool_call_id"
13
+ );
14
+ --> statement-breakpoint
15
+ CREATE TABLE "relay_tool_calls_next" AS SELECT * FROM "relay_tool_calls";
16
+ --> statement-breakpoint
17
+ DROP TABLE "relay_tool_calls";
18
+ --> statement-breakpoint
19
+ ALTER TABLE "relay_tool_calls_next" RENAME TO "relay_tool_calls";
20
+ --> statement-breakpoint
21
+ CREATE UNIQUE INDEX "pk_relay_tool_calls" ON "relay_tool_calls" ("tenant_id", "execution_id", "id");
22
+ --> statement-breakpoint
23
+ CREATE INDEX "idx_relay_tool_calls_execution" ON "relay_tool_calls" ("tenant_id", "execution_id", "created_at");
24
+ --> statement-breakpoint
25
+ CREATE INDEX "idx_relay_tool_calls_remote_claim" ON "relay_tool_calls" ("tenant_id", "placement_kind", "placement_key", "state", "available_at", "created_at", "id");
26
+ --> statement-breakpoint
27
+ CREATE INDEX "idx_relay_tool_calls_stale_claim" ON "relay_tool_calls" ("tenant_id", "state", "claim_expires_at");
28
+ --> statement-breakpoint
29
+ CREATE INDEX "idx_relay_tool_calls_client_pending" ON "relay_tool_calls" ("tenant_id", "placement_kind", "state", "created_at", "id");
30
+ --> statement-breakpoint
31
+ CREATE TABLE "relay_tool_results_next" AS SELECT * FROM "relay_tool_results";
32
+ --> statement-breakpoint
33
+ DROP TABLE "relay_tool_results";
34
+ --> statement-breakpoint
35
+ ALTER TABLE "relay_tool_results_next" RENAME TO "relay_tool_results";
36
+ --> statement-breakpoint
37
+ CREATE UNIQUE INDEX "pk_relay_tool_results" ON "relay_tool_results" ("tenant_id", "execution_id", "tool_call_id");
38
+ --> statement-breakpoint
39
+ DROP INDEX "uq_relay_tool_attempts_number";
40
+ --> statement-breakpoint
41
+ DROP INDEX "idx_relay_tool_attempts_call";
42
+ --> statement-breakpoint
43
+ CREATE TABLE "relay_tool_attempts_next" AS SELECT * FROM "relay_tool_attempts";
44
+ --> statement-breakpoint
45
+ DROP TABLE "relay_tool_attempts";
46
+ --> statement-breakpoint
47
+ ALTER TABLE "relay_tool_attempts_next" RENAME TO "relay_tool_attempts";
48
+ --> statement-breakpoint
49
+ CREATE UNIQUE INDEX "pk_relay_tool_attempts" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "id");
50
+ --> statement-breakpoint
51
+ CREATE UNIQUE INDEX "uq_relay_tool_attempts_number" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "attempt_number");
52
+ --> statement-breakpoint
53
+ CREATE INDEX "idx_relay_tool_attempts_call" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "attempt_number");
package/dist/mysql.js CHANGED
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  database,
4
4
  normalizeMigrationCause
5
- } from "./index-pr9133xv.js";
5
+ } from "./index-2vsf6dks.js";
6
6
  import {
7
7
  MigratorError,
8
8
  RuntimeMigrationError,
9
9
  SqlFailure
10
- } from "./index-01rpd00m.js";
11
- import"./index-25gwk9tj.js";
12
- import"./index-cphmds30.js";
10
+ } from "./index-e02krw55.js";
11
+ import"./index-8fpd6kvj.js";
12
+ import"./index-mtvz1bjn.js";
13
13
  import"./index-nb39b5ae.js";
14
14
 
15
15
  // src/mysql.ts
package/dist/postgres.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  database,
4
4
  normalizeMigrationCause
5
- } from "./index-pr9133xv.js";
5
+ } from "./index-2vsf6dks.js";
6
6
  import {
7
7
  Dialect,
8
8
  RuntimeMigrationError,
@@ -14,11 +14,11 @@ import {
14
14
  fromDbTimestamp,
15
15
  fromNullableDbTimestamp,
16
16
  timestampParam
17
- } from "./index-01rpd00m.js";
18
- import"./index-25gwk9tj.js";
17
+ } from "./index-e02krw55.js";
18
+ import"./index-8fpd6kvj.js";
19
19
  import {
20
20
  exports_ids_schema
21
- } from "./index-cphmds30.js";
21
+ } from "./index-mtvz1bjn.js";
22
22
  import {
23
23
  __export
24
24
  } from "./index-nb39b5ae.js";
@@ -659,7 +659,7 @@ var relayToolCalls = pgTable("relay_tool_calls", {
659
659
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
660
660
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
661
661
  }, (table) => [
662
- primaryKey({ columns: [table.tenantId, table.id], name: "pk_relay_tool_calls" }),
662
+ primaryKey({ columns: [table.tenantId, table.executionId, table.id], name: "pk_relay_tool_calls" }),
663
663
  index("idx_relay_tool_calls_execution").on(table.tenantId, table.executionId, table.createdAt),
664
664
  index("idx_relay_tool_calls_remote_claim").on(table.tenantId, table.placementKind, table.placementKey, table.state, table.availableAt, table.createdAt, table.id),
665
665
  index("idx_relay_tool_calls_stale_claim").on(table.tenantId, table.state, table.claimExpiresAt),
@@ -667,6 +667,7 @@ var relayToolCalls = pgTable("relay_tool_calls", {
667
667
  ]);
668
668
  var relayToolAttempts = pgTable("relay_tool_attempts", {
669
669
  tenantId: tenantId(),
670
+ executionId: text("execution_id").$type().notNull(),
670
671
  id: text("id").$type().notNull(),
671
672
  toolCallId: text("tool_call_id").$type().notNull(),
672
673
  attemptNumber: integer("attempt_number").notNull(),
@@ -677,18 +678,27 @@ var relayToolAttempts = pgTable("relay_tool_attempts", {
677
678
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
678
679
  completedAt: timestamp("completed_at", { withTimezone: true })
679
680
  }, (table) => [
680
- primaryKey({ columns: [table.tenantId, table.toolCallId, table.id], name: "pk_relay_tool_attempts" }),
681
- uniqueIndex("uq_relay_tool_attempts_number").on(table.tenantId, table.toolCallId, table.attemptNumber),
682
- index("idx_relay_tool_attempts_call").on(table.tenantId, table.toolCallId, table.attemptNumber)
681
+ primaryKey({
682
+ columns: [table.tenantId, table.executionId, table.toolCallId, table.id],
683
+ name: "pk_relay_tool_attempts"
684
+ }),
685
+ uniqueIndex("uq_relay_tool_attempts_number").on(table.tenantId, table.executionId, table.toolCallId, table.attemptNumber),
686
+ index("idx_relay_tool_attempts_call").on(table.tenantId, table.executionId, table.toolCallId, table.attemptNumber)
683
687
  ]);
684
688
  var relayToolResults = pgTable("relay_tool_results", {
685
689
  tenantId: tenantId(),
690
+ executionId: text("execution_id").$type().notNull(),
686
691
  toolCallId: text("tool_call_id").$type().notNull(),
687
692
  outputJson: jsonb("output_json").notNull(),
688
693
  error: text("error"),
689
694
  metadataJson: jsonb("metadata_json").$type().notNull().default({}),
690
695
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
691
- }, (table) => [primaryKey({ columns: [table.tenantId, table.toolCallId], name: "pk_relay_tool_results" })]);
696
+ }, (table) => [
697
+ primaryKey({
698
+ columns: [table.tenantId, table.executionId, table.toolCallId],
699
+ name: "pk_relay_tool_results"
700
+ })
701
+ ]);
692
702
  var relayRouteAttempts = pgTable("relay_route_attempts", {
693
703
  tenantId: tenantId(),
694
704
  id: text("id").notNull(),
@@ -717,7 +727,7 @@ var relayIdempotencyKeys = pgTable("relay_idempotency_keys", {
717
727
  uniqueIndex("uq_relay_idempotency_scope_operation_key").on(table.tenantId, table.scope, table.operation, table.key)
718
728
  ]);
719
729
  // src/postgres.ts
720
- var schemaHead = "20260712200000_workflow_runtime";
730
+ var schemaHead = "20260718140000_execution_scoped_tool_calls";
721
731
  var migrationNames = [
722
732
  "20260701002839_sour_cerebro",
723
733
  "20260701041134_acoustic_hulk",
@@ -743,6 +753,7 @@ var migrationNames = [
743
753
  "20260712170000_topic_subscriptions",
744
754
  "20260712180000_child_fan_out",
745
755
  "20260712190000_workflow_definitions",
756
+ "20260712200000_workflow_runtime",
746
757
  schemaHead
747
758
  ];
748
759
  var migrationsFolderUrl = import.meta.url.endsWith("/src/postgres.ts") ? new URL("../../../migrations/pg", import.meta.url) : new URL("./migrations/pg", import.meta.url);
package/dist/sqlite.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  database,
4
4
  normalizeMigrationCause
5
- } from "./index-pr9133xv.js";
5
+ } from "./index-2vsf6dks.js";
6
6
  import {
7
7
  DatabaseAlreadyOwned,
8
8
  RuntimeConfigurationError,
@@ -12,9 +12,9 @@ import {
12
12
  make,
13
13
  makeDatabaseIdentity,
14
14
  runtimeLayer
15
- } from "./index-01rpd00m.js";
16
- import"./index-25gwk9tj.js";
17
- import"./index-cphmds30.js";
15
+ } from "./index-e02krw55.js";
16
+ import"./index-8fpd6kvj.js";
17
+ import"./index-mtvz1bjn.js";
18
18
  import"./index-nb39b5ae.js";
19
19
 
20
20
  // src/sqlite-runtime.ts
@@ -602,6 +602,62 @@ var _0010_workflow_runtime_default = `CREATE TABLE IF NOT EXISTS relay_workflow_
602
602
  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));
603
603
  `;
604
604
 
605
+ // ../../migrations/sqlite/0011_execution_scoped_tool_calls.sql
606
+ var _0011_execution_scoped_tool_calls_default = `ALTER TABLE "relay_tool_results" ADD COLUMN "execution_id" TEXT NULL;
607
+ --> statement-breakpoint
608
+ UPDATE "relay_tool_results" SET "execution_id" = (
609
+ SELECT call."execution_id" FROM "relay_tool_calls" call
610
+ WHERE call."tenant_id" = "relay_tool_results"."tenant_id" AND call."id" = "relay_tool_results"."tool_call_id"
611
+ );
612
+ --> statement-breakpoint
613
+ ALTER TABLE "relay_tool_attempts" ADD COLUMN "execution_id" TEXT;
614
+ --> statement-breakpoint
615
+ UPDATE "relay_tool_attempts" SET "execution_id" = (
616
+ SELECT call."execution_id" FROM "relay_tool_calls" call
617
+ WHERE call."tenant_id" = "relay_tool_attempts"."tenant_id" AND call."id" = "relay_tool_attempts"."tool_call_id"
618
+ );
619
+ --> statement-breakpoint
620
+ CREATE TABLE "relay_tool_calls_next" AS SELECT * FROM "relay_tool_calls";
621
+ --> statement-breakpoint
622
+ DROP TABLE "relay_tool_calls";
623
+ --> statement-breakpoint
624
+ ALTER TABLE "relay_tool_calls_next" RENAME TO "relay_tool_calls";
625
+ --> statement-breakpoint
626
+ CREATE UNIQUE INDEX "pk_relay_tool_calls" ON "relay_tool_calls" ("tenant_id", "execution_id", "id");
627
+ --> statement-breakpoint
628
+ CREATE INDEX "idx_relay_tool_calls_execution" ON "relay_tool_calls" ("tenant_id", "execution_id", "created_at");
629
+ --> statement-breakpoint
630
+ CREATE INDEX "idx_relay_tool_calls_remote_claim" ON "relay_tool_calls" ("tenant_id", "placement_kind", "placement_key", "state", "available_at", "created_at", "id");
631
+ --> statement-breakpoint
632
+ CREATE INDEX "idx_relay_tool_calls_stale_claim" ON "relay_tool_calls" ("tenant_id", "state", "claim_expires_at");
633
+ --> statement-breakpoint
634
+ CREATE INDEX "idx_relay_tool_calls_client_pending" ON "relay_tool_calls" ("tenant_id", "placement_kind", "state", "created_at", "id");
635
+ --> statement-breakpoint
636
+ CREATE TABLE "relay_tool_results_next" AS SELECT * FROM "relay_tool_results";
637
+ --> statement-breakpoint
638
+ DROP TABLE "relay_tool_results";
639
+ --> statement-breakpoint
640
+ ALTER TABLE "relay_tool_results_next" RENAME TO "relay_tool_results";
641
+ --> statement-breakpoint
642
+ CREATE UNIQUE INDEX "pk_relay_tool_results" ON "relay_tool_results" ("tenant_id", "execution_id", "tool_call_id");
643
+ --> statement-breakpoint
644
+ DROP INDEX "uq_relay_tool_attempts_number";
645
+ --> statement-breakpoint
646
+ DROP INDEX "idx_relay_tool_attempts_call";
647
+ --> statement-breakpoint
648
+ CREATE TABLE "relay_tool_attempts_next" AS SELECT * FROM "relay_tool_attempts";
649
+ --> statement-breakpoint
650
+ DROP TABLE "relay_tool_attempts";
651
+ --> statement-breakpoint
652
+ ALTER TABLE "relay_tool_attempts_next" RENAME TO "relay_tool_attempts";
653
+ --> statement-breakpoint
654
+ CREATE UNIQUE INDEX "pk_relay_tool_attempts" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "id");
655
+ --> statement-breakpoint
656
+ CREATE UNIQUE INDEX "uq_relay_tool_attempts_number" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "attempt_number");
657
+ --> statement-breakpoint
658
+ CREATE INDEX "idx_relay_tool_attempts_call" ON "relay_tool_attempts" ("tenant_id", "execution_id", "tool_call_id", "attempt_number");
659
+ `;
660
+
605
661
  // src/sqlite-migrations.ts
606
662
  import { Effect } from "effect";
607
663
  import { SqlClient } from "effect/unstable/sql/SqlClient";
@@ -622,7 +678,8 @@ var migrations = [
622
678
  { id: 7, name: "topic_subscriptions", file: "0007_topic_subscriptions.sql", source: _0007_topic_subscriptions_default },
623
679
  { id: 8, name: "child_fan_out", file: "0008_child_fan_out.sql", source: _0008_child_fan_out_default },
624
680
  { id: 9, name: "workflow_definitions", file: "0009_workflow_definitions.sql", source: _0009_workflow_definitions_default },
625
- { id: 10, name: "workflow_runtime", file: "0010_workflow_runtime.sql", source: _0010_workflow_runtime_default }
681
+ { id: 10, name: "workflow_runtime", file: "0010_workflow_runtime.sql", source: _0010_workflow_runtime_default },
682
+ { id: 11, name: "execution_scoped_tool_calls", file: "0011_execution_scoped_tool_calls.sql", source: _0011_execution_scoped_tool_calls_default }
626
683
  ];
627
684
  var loader = Effect.succeed(migrations.map(({ id, name, source }) => [id, name, Effect.succeed(execute(source))]));
628
685
 
@@ -918,6 +918,9 @@ export declare const ClaimToolWorkInput: Schema.Struct<{
918
918
  export interface ClaimToolWorkInput extends Schema.Schema.Type<typeof ClaimToolWorkInput> {
919
919
  }
920
920
  export declare const CompleteToolWorkInput: Schema.Struct<{
921
+ readonly execution_id: Schema.brand<Schema.String, "Relay.ExecutionId"> & {
922
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ExecutionId">;
923
+ };
921
924
  readonly tool_call_id: Schema.brand<Schema.String, "Relay.ToolCallId"> & {
922
925
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ToolCallId">;
923
926
  };
@@ -937,6 +940,9 @@ export declare const CompleteToolWorkInput: Schema.Struct<{
937
940
  export interface CompleteToolWorkInput extends Schema.Schema.Type<typeof CompleteToolWorkInput> {
938
941
  }
939
942
  export declare const ReleaseToolWorkInput: Schema.Struct<{
943
+ readonly execution_id: Schema.brand<Schema.String, "Relay.ExecutionId"> & {
944
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ExecutionId">;
945
+ };
940
946
  readonly tool_call_id: Schema.brand<Schema.String, "Relay.ToolCallId"> & {
941
947
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ToolCallId">;
942
948
  };
@@ -951,6 +957,9 @@ export declare const ReleaseToolWorkInput: Schema.Struct<{
951
957
  export interface ReleaseToolWorkInput extends Schema.Schema.Type<typeof ReleaseToolWorkInput> {
952
958
  }
953
959
  export declare const ListToolAttemptsInput: Schema.Struct<{
960
+ readonly execution_id: Schema.brand<Schema.String, "Relay.ExecutionId"> & {
961
+ make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ExecutionId">;
962
+ };
954
963
  readonly tool_call_id: Schema.brand<Schema.String, "Relay.ToolCallId"> & {
955
964
  make: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => string & import("effect/Brand").Brand<"Relay.ToolCallId">;
956
965
  };
@@ -50,5 +50,10 @@ export declare const migrations: readonly [{
50
50
  readonly name: "workflow_runtime";
51
51
  readonly file: "0010_workflow_runtime.sql";
52
52
  readonly source: string;
53
+ }, {
54
+ readonly id: 11;
55
+ readonly name: "execution_scoped_tool_calls";
56
+ readonly file: "0011_execution_scoped_tool_calls.sql";
57
+ readonly source: string;
53
58
  }];
54
- export declare const loader: Effect.Effect<(readonly [1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10, "baseline" | "child_fan_out" | "durable_entities" | "durable_inbox" | "durable_tool_placement" | "ephemeral_presence" | "execution_state" | "topic_subscriptions" | "workflow_definitions" | "workflow_runtime", Effect.Effect<Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, SqlClient>, never, never>])[], never, never>;
59
+ export declare const loader: Effect.Effect<(readonly [1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11, "baseline" | "child_fan_out" | "durable_entities" | "durable_inbox" | "durable_tool_placement" | "ephemeral_presence" | "execution_scoped_tool_calls" | "execution_state" | "topic_subscriptions" | "workflow_definitions" | "workflow_runtime", Effect.Effect<Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, SqlClient>, never, never>])[], never, never>;
@@ -21,5 +21,4 @@ export interface Config {
21
21
  readonly startedAt: number;
22
22
  readonly eventSequence: Execution.ExecutionEventSequence;
23
23
  }
24
- export declare const waitIdForToolCall: (toolCallId: string) => string & import("effect/Brand").Brand<"Relay.WaitId">;
25
24
  export declare const layer: (config: Config) => Layer.Layer<Permissions.Permissions | Permissions.RuleStore, never, never>;
@@ -0,0 +1,9 @@
1
+ import { Ids } from "../../schema/index";
2
+ export type ToolWaitKind = "approval" | "permission" | "tool";
3
+ declare const eventId: (executionId: Ids.ExecutionId, toolCallId: Ids.ToolCallId | string, kind: "tool-requested" | "tool-result" | "approval-requested" | "approval-resolved" | "permission-requested" | "permission-resolved") => string & import("effect/Brand").Brand<"Relay.EventId">;
4
+ declare const waitId: (kind: ToolWaitKind, executionId: Ids.ExecutionId, toolCallId: Ids.ToolCallId | string) => string & import("effect/Brand").Brand<"Relay.WaitId">;
5
+ export declare const Identifiers: {
6
+ eventId: typeof eventId;
7
+ waitId: typeof waitId;
8
+ };
9
+ export {};
@@ -6,6 +6,7 @@ import { Service as EventLogService } from "../execution/event-log-service";
6
6
  import { Service as WaitServiceService } from "../wait/wait-service";
7
7
  export * from "./tool-runtime-contract";
8
8
  import { Service } from "./tool-runtime-contract";
9
+ export { Identifiers } from "./tool-runtime-identifiers";
9
10
  import type { DynamicToolOptions, PlacedToolOptions, RegisteredTool, RunInput, ToolkitRegistrationOptions, ToolOptions } from "./tool-runtime-contract";
10
11
  export declare const toolFromRegistered: (tool: RegisteredTool) => AiTool.Any;
11
12
  export declare const toolsFromToolkit: {
@@ -6140,6 +6140,21 @@ export declare const relayToolAttempts: import("drizzle-orm/pg-core").PgTableWit
6140
6140
  identity: undefined;
6141
6141
  generated: undefined;
6142
6142
  }>;
6143
+ executionId: import("drizzle-orm/pg-core").PgBuildColumn<"relay_tool_attempts", 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.ExecutionId">>>, {
6144
+ name: string;
6145
+ tableName: "relay_tool_attempts";
6146
+ dataType: "string";
6147
+ data: string & import("effect/Brand").Brand<"Relay.ExecutionId">;
6148
+ driverParam: string;
6149
+ notNull: true;
6150
+ hasDefault: false;
6151
+ isPrimaryKey: false;
6152
+ isAutoincrement: false;
6153
+ hasRuntimeDefault: false;
6154
+ enumValues: undefined;
6155
+ identity: undefined;
6156
+ generated: undefined;
6157
+ }>;
6143
6158
  id: import("drizzle-orm/pg-core").PgBuildColumn<"relay_tool_attempts", 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.ToolAttemptId">>>, {
6144
6159
  name: string;
6145
6160
  tableName: "relay_tool_attempts";
@@ -6297,6 +6312,21 @@ export declare const relayToolResults: import("drizzle-orm/pg-core").PgTableWith
6297
6312
  identity: undefined;
6298
6313
  generated: undefined;
6299
6314
  }>;
6315
+ executionId: import("drizzle-orm/pg-core").PgBuildColumn<"relay_tool_results", 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.ExecutionId">>>, {
6316
+ name: string;
6317
+ tableName: "relay_tool_results";
6318
+ dataType: "string";
6319
+ data: string & import("effect/Brand").Brand<"Relay.ExecutionId">;
6320
+ driverParam: string;
6321
+ notNull: true;
6322
+ hasDefault: false;
6323
+ isPrimaryKey: false;
6324
+ isAutoincrement: false;
6325
+ hasRuntimeDefault: false;
6326
+ enumValues: undefined;
6327
+ identity: undefined;
6328
+ generated: undefined;
6329
+ }>;
6300
6330
  toolCallId: import("drizzle-orm/pg-core").PgBuildColumn<"relay_tool_results", 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.ToolCallId">>>, {
6301
6331
  name: string;
6302
6332
  tableName: "relay_tool_results";