@relayfx/sdk 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.js +1 -1
- package/dist/{index-x32kbvxv.js → index-5vjhqzbk.js} +995 -958
- package/dist/{index-h1cf8za4.js → index-dm4yqr8f.js} +1 -1
- package/dist/{index-8asvg7x0.js → index-ftgf8py0.js} +888 -706
- package/dist/index.js +269 -117
- package/dist/migrations/20260721170000_session_writer_ownership/migration.sql +5 -0
- package/dist/migrations/mysql/0014_session_writer_ownership.sql +5 -0
- package/dist/migrations/pg/20260721170000_session_writer_ownership/migration.sql +5 -0
- package/dist/migrations/sqlite/0014_session_writer_ownership.sql +5 -0
- package/dist/mysql.js +13 -4
- package/dist/postgres.js +9 -5
- package/dist/sqlite.js +13 -4
- package/dist/types/ai/language-model/language-model-registration.d.ts +23 -11
- package/dist/types/relay/language-model-registration.d.ts +25 -11
- package/dist/types/relay/mysql-migrations.d.ts +1 -1
- package/dist/types/relay/sqlite-migrations.d.ts +6 -1
- package/dist/types/runtime/agent/agent-loop-error.d.ts +1 -1
- package/dist/types/runtime/agent/relay-permissions.d.ts +2 -2
- package/dist/types/runtime/execution/active-execution-registry.d.ts +1 -0
- package/dist/types/runtime/model/model-hub.d.ts +5 -5
- package/dist/types/runtime/runner/runner-runtime-service.d.ts +4 -4
- package/dist/types/runtime/session/session-store-service.d.ts +1 -0
- package/dist/types/store-sql/schema/session-schema.d.ts +45 -0
- package/dist/types/store-sql/session/session-records.d.ts +5 -47
- package/dist/types/store-sql/session/session-repository.d.ts +37 -1
- package/dist/types/store-sql/session/session-row.d.ts +60 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
exports_tool_runtime,
|
|
15
15
|
exports_workflow_definition_host,
|
|
16
16
|
makeDatabaseIdentity
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-ftgf8py0.js";
|
|
18
18
|
import {
|
|
19
19
|
exports_model_registry
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-5vjhqzbk.js";
|
|
21
21
|
import {
|
|
22
22
|
ClientError,
|
|
23
23
|
EventLogCursorNotFound,
|
|
@@ -151,48 +151,92 @@ var run = Effect2.fn("ToolWorker.run")(function* (options) {
|
|
|
151
151
|
var exports_language_model_registration = {};
|
|
152
152
|
__export(exports_language_model_registration, {
|
|
153
153
|
withOpenRouterFetch: () => withOpenRouterFetch,
|
|
154
|
-
withOpenRouter: () =>
|
|
155
|
-
withOpenAiOrDeterministicFetch: () => withOpenAiOrDeterministicFetch,
|
|
156
|
-
withOpenAiOrDeterministic: () => withOpenAiOrDeterministic,
|
|
154
|
+
withOpenRouter: () => layer6,
|
|
157
155
|
withOpenAiFetch: () => withOpenAiFetch,
|
|
158
156
|
withOpenAiCompatibleFetch: () => withOpenAiCompatibleFetch,
|
|
159
|
-
withOpenAiCompatible: () =>
|
|
157
|
+
withOpenAiCompatible: () => layer5,
|
|
160
158
|
withOpenAiAccountFetch: () => withOpenAiAccountFetch,
|
|
161
|
-
withOpenAiAccount: () =>
|
|
162
|
-
withOpenAi: () =>
|
|
163
|
-
withDeterministic: () => withDeterministic,
|
|
159
|
+
withOpenAiAccount: () => layerAccount,
|
|
160
|
+
withOpenAi: () => layer3,
|
|
164
161
|
withAnthropicFetch: () => withAnthropicFetch,
|
|
165
|
-
withAnthropic: () =>
|
|
166
|
-
openRouterClientLayerConfig: () =>
|
|
162
|
+
withAnthropic: () => layer2,
|
|
163
|
+
openRouterClientLayerConfig: () => layerConfig4,
|
|
167
164
|
openRouter: () => openRouter,
|
|
168
|
-
|
|
165
|
+
openAiOrDeterministicLayer: () => layerOpenAi,
|
|
166
|
+
openAiCompatibleClientLayerConfig: () => layerConfig3,
|
|
169
167
|
openAiCompatible: () => openAiCompatible,
|
|
170
|
-
openAiClientLayerConfig: () =>
|
|
171
|
-
openAiAccount: () => openAiAccount,
|
|
168
|
+
openAiClientLayerConfig: () => layerConfig2,
|
|
172
169
|
openAi: () => openAi,
|
|
173
|
-
deterministicModel: () =>
|
|
174
|
-
|
|
170
|
+
deterministicModel: () => deterministicModel,
|
|
171
|
+
deterministicLayer: () => layer4,
|
|
172
|
+
anthropicClientLayerConfig: () => layerConfig,
|
|
175
173
|
anthropic: () => anthropic,
|
|
176
174
|
OpenAiAccountCredentialError: () => OpenAiAccountCredentialError
|
|
177
175
|
});
|
|
176
|
+
import { AnthropicLanguageModel as AnthropicLanguageModel2 } from "@effect/ai-anthropic";
|
|
177
|
+
import { OpenAiLanguageModel as OpenAiLanguageModel4 } from "@effect/ai-openai";
|
|
178
|
+
import { OpenAiLanguageModel as OpenAiCompatibleLanguageModel } from "@effect/ai-openai-compat";
|
|
179
|
+
import { OpenRouterLanguageModel as OpenRouterLanguageModel2 } from "@effect/ai-openrouter";
|
|
178
180
|
|
|
179
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
180
|
-
import {
|
|
181
|
-
import { Config
|
|
182
|
-
import {
|
|
183
|
-
|
|
181
|
+
// ../../node_modules/.bun/@batonfx+providers@0.9.1/node_modules/@batonfx/providers/dist/anthropic.js
|
|
182
|
+
import { AnthropicClient, AnthropicLanguageModel } from "@effect/ai-anthropic";
|
|
183
|
+
import { Config, Layer as Layer2, Redacted } from "effect";
|
|
184
|
+
import { AiError } from "effect/unstable/ai";
|
|
185
|
+
var classifyFailure = (error) => {
|
|
186
|
+
if (!AiError.isAiError(error) || error.reason._tag !== "InvalidRequestError")
|
|
187
|
+
return "other";
|
|
188
|
+
const metadata = error.reason.metadata.anthropic;
|
|
189
|
+
return metadata?.errorType === "invalid_request_error" && /\bprompt is too long\b/i.test(error.reason.description ?? "") ? "context-overflow" : "other";
|
|
190
|
+
};
|
|
191
|
+
var layer2 = (input) => exports_model_registry.layer([
|
|
192
|
+
exports_model_registry.registration({
|
|
193
|
+
provider: "anthropic",
|
|
194
|
+
model: input.model,
|
|
195
|
+
layer: AnthropicLanguageModel.layer({
|
|
196
|
+
model: input.model,
|
|
197
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
198
|
+
}),
|
|
199
|
+
classifyFailure,
|
|
200
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
201
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
202
|
+
})
|
|
203
|
+
]).pipe(Layer2.provide(AnthropicClient.layerConfig({ ...input.clientConfig, apiKey: input.apiKey })));
|
|
204
|
+
var layerConfig = AnthropicClient.layerConfig;
|
|
205
|
+
|
|
206
|
+
// ../../node_modules/.bun/@batonfx+providers@0.9.1/node_modules/@batonfx/providers/dist/deterministic.js
|
|
207
|
+
import { OpenAiClient as OpenAiClient2, OpenAiLanguageModel as OpenAiLanguageModel2 } from "@effect/ai-openai";
|
|
208
|
+
import { Config as Config3, Effect as Effect4, Layer as Layer4, Option as Option2, Stream as Stream2 } from "effect";
|
|
209
|
+
import { LanguageModel, Response as Response2 } from "effect/unstable/ai";
|
|
210
|
+
import { HttpClient as HttpClient2 } from "effect/unstable/http";
|
|
184
211
|
|
|
185
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
212
|
+
// ../../node_modules/.bun/@batonfx+providers@0.9.1/node_modules/@batonfx/providers/dist/openai.js
|
|
186
213
|
import { OpenAiClient, OpenAiLanguageModel } from "@effect/ai-openai";
|
|
187
|
-
import { Config, Effect as Effect3, Layer as
|
|
188
|
-
import { AiError } from "effect/unstable/ai";
|
|
189
|
-
import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest } from "effect/unstable/http";
|
|
214
|
+
import { Config as Config2, Effect as Effect3, Function, Layer as Layer3, Option, Redacted as Redacted2, Schema, Stream } from "effect";
|
|
215
|
+
import { AiError as AiError2 } from "effect/unstable/ai";
|
|
216
|
+
import { FetchHttpClient, Headers, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse } from "effect/unstable/http";
|
|
190
217
|
var openAiAccountApiUrl = "https://chatgpt.com/backend-api/codex";
|
|
191
218
|
var openAiAccountResponsesUrl = `${openAiAccountApiUrl}/responses`;
|
|
192
219
|
var openAiAccountIdHeader = "ChatGPT-Account-ID";
|
|
193
220
|
var contextOverflowCodes = new Set(["context_length_exceeded", "context_window_exceeded", "input_too_long"]);
|
|
194
|
-
var
|
|
195
|
-
if (
|
|
221
|
+
var responseErrorCode = (error) => {
|
|
222
|
+
if (typeof error !== "object" || error === null || Array.isArray(error))
|
|
223
|
+
return;
|
|
224
|
+
const event = error;
|
|
225
|
+
if (event.type !== "error")
|
|
226
|
+
return;
|
|
227
|
+
if (typeof event.code === "string")
|
|
228
|
+
return event.code;
|
|
229
|
+
const details = event.error;
|
|
230
|
+
if (typeof details !== "object" || details === null || Array.isArray(details))
|
|
231
|
+
return;
|
|
232
|
+
const code = details.code;
|
|
233
|
+
return typeof code === "string" ? code : undefined;
|
|
234
|
+
};
|
|
235
|
+
var classifyFailure2 = (error) => {
|
|
236
|
+
const eventCode = responseErrorCode(error);
|
|
237
|
+
if (eventCode !== undefined && contextOverflowCodes.has(eventCode))
|
|
238
|
+
return "context-overflow";
|
|
239
|
+
if (!AiError2.isAiError(error))
|
|
196
240
|
return "other";
|
|
197
241
|
const reason = error.reason;
|
|
198
242
|
if (reason._tag !== "InvalidRequestError" && reason._tag !== "UnknownError")
|
|
@@ -205,25 +249,101 @@ var classifyFailure = (error) => {
|
|
|
205
249
|
}
|
|
206
250
|
return reason._tag === "InvalidRequestError" && /maximum context length|context length exceeded|input exceeds (?:the )?context window/i.test(reason.description ?? "") ? "context-overflow" : "other";
|
|
207
251
|
};
|
|
208
|
-
var
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
layer: OpenAiLanguageModel.layer({
|
|
252
|
+
var layer3 = (input) => exports_model_registry.layer([
|
|
253
|
+
exports_model_registry.registration({
|
|
254
|
+
provider: "openai",
|
|
212
255
|
model: input.model,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
256
|
+
layer: OpenAiLanguageModel.layer({
|
|
257
|
+
model: input.model,
|
|
258
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
259
|
+
}),
|
|
260
|
+
classifyFailure: classifyFailure2,
|
|
261
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
262
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
263
|
+
})
|
|
264
|
+
]).pipe(Layer3.provide(layerConfig2({ ...input.clientConfig, apiKey: input.apiKey })));
|
|
265
|
+
var stringifyJson = Schema.encodeSync(Schema.UnknownFromJsonString);
|
|
266
|
+
var parseJsonOption = Schema.decodeUnknownOption(Schema.UnknownFromJsonString);
|
|
267
|
+
var dataLinePrefix = /^data: ?/;
|
|
268
|
+
var frameSeparator = /(\r?\n\r?\n)/;
|
|
269
|
+
var lineSeparator = /(\r?\n)/;
|
|
270
|
+
var isResponsesUrl = (url) => url.split(/[?#]/)[0].replace(/\/+$/, "").endsWith("/responses");
|
|
271
|
+
var flattenErrorPayload = (payload) => {
|
|
272
|
+
const decoded = parseJsonOption(payload);
|
|
273
|
+
if (Option.isNone(decoded) || typeof decoded.value !== "object" || decoded.value === null)
|
|
274
|
+
return;
|
|
275
|
+
const record = decoded.value;
|
|
276
|
+
if (record.type !== "error" || record.message !== undefined)
|
|
277
|
+
return;
|
|
278
|
+
const details = record.error;
|
|
279
|
+
if (typeof details !== "object" || details === null || Array.isArray(details))
|
|
280
|
+
return;
|
|
281
|
+
const nested = details;
|
|
282
|
+
return stringifyJson({
|
|
283
|
+
type: "error",
|
|
284
|
+
code: typeof nested.code === "string" ? nested.code : null,
|
|
285
|
+
message: typeof nested.message === "string" ? nested.message : stringifyJson(nested),
|
|
286
|
+
param: typeof nested.param === "string" ? nested.param : null,
|
|
287
|
+
sequence_number: typeof record.sequence_number === "number" ? record.sequence_number : 0
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
var rewriteFrame = (frame) => {
|
|
291
|
+
const segments = frame.split(lineSeparator);
|
|
292
|
+
const dataIndexes = [];
|
|
293
|
+
for (let index = 0;index < segments.length; index += 2) {
|
|
294
|
+
if (dataLinePrefix.test(segments[index] ?? ""))
|
|
295
|
+
dataIndexes.push(index);
|
|
296
|
+
}
|
|
297
|
+
if (dataIndexes.length !== 1)
|
|
298
|
+
return frame;
|
|
299
|
+
const line = segments[dataIndexes[0]];
|
|
300
|
+
const prefix = line.match(dataLinePrefix)[0];
|
|
301
|
+
const flattened = flattenErrorPayload(line.slice(prefix.length));
|
|
302
|
+
if (flattened === undefined)
|
|
303
|
+
return frame;
|
|
304
|
+
segments[dataIndexes[0]] = `${prefix}${flattened}`;
|
|
305
|
+
return segments.join("");
|
|
306
|
+
};
|
|
307
|
+
var normalizeSseErrorFrames = (body) => body.pipe(Stream.decodeText(), Stream.mapAccum(() => "", (buffer, chunk) => {
|
|
308
|
+
const pieces = (buffer + chunk).split(frameSeparator);
|
|
309
|
+
const tail = pieces.length % 2 === 1 ? pieces.pop() : "";
|
|
310
|
+
const output = [];
|
|
311
|
+
for (let index = 0;index < pieces.length; index += 2) {
|
|
312
|
+
output.push(rewriteFrame(pieces[index]) + pieces[index + 1]);
|
|
313
|
+
}
|
|
314
|
+
return [tail, output];
|
|
315
|
+
}, { onHalt: (buffer) => buffer.length === 0 ? [] : [rewriteFrame(buffer)] }), Stream.encodeText);
|
|
316
|
+
var normalizeResponsesSse = (client) => HttpClient.transformResponse(client, (effect) => Effect3.map(effect, (response) => {
|
|
317
|
+
const contentType = String(response.headers["content-type"] ?? "");
|
|
318
|
+
if (!contentType.includes("text/event-stream") || !isResponsesUrl(response.request.url))
|
|
319
|
+
return response;
|
|
320
|
+
return HttpClientResponse.fromWeb(response.request, new Response(Stream.toReadableStream(normalizeSseErrorFrames(response.stream)), {
|
|
321
|
+
status: response.status,
|
|
322
|
+
headers: { "content-type": contentType }
|
|
323
|
+
}));
|
|
324
|
+
}));
|
|
325
|
+
var layerConfig2 = (options) => OpenAiClient.layerConfig({
|
|
326
|
+
...options,
|
|
327
|
+
transformClient: (client) => options?.transformClient === undefined ? normalizeResponsesSse(client) : client.pipe(normalizeResponsesSse, options.transformClient)
|
|
218
328
|
});
|
|
219
|
-
var openAiClientLayerConfig = OpenAiClient.layerConfig;
|
|
220
|
-
var withOpenAi = (options) => exports_model_registry.layerFromRegistrationEffects([openAi(options)]).pipe(Layer2.provide(OpenAiClient.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })));
|
|
221
|
-
var withOpenAiFetch = (options) => withOpenAi(options).pipe(Layer2.provide(FetchHttpClient.layer));
|
|
222
329
|
|
|
223
330
|
class OpenAiAccountCredentialError extends Schema.TaggedErrorClass()("@batonfx/providers/OpenAiAccountCredentialError", {
|
|
224
331
|
operation: Schema.Literals(["acquire", "refreshRejected"])
|
|
225
332
|
}) {
|
|
226
333
|
}
|
|
334
|
+
var credentialsFromAccountAuthImpl = (service, expectedFingerprint) => {
|
|
335
|
+
const mapCredential = (operation) => Effect3.mapError(() => OpenAiAccountCredentialError.make({ operation }));
|
|
336
|
+
const accountCredential = (operation) => Effect3.flatMap((credential) => credential.fingerprint === expectedFingerprint ? Effect3.succeed({
|
|
337
|
+
accessToken: credential.accessToken,
|
|
338
|
+
accountId: Redacted2.value(credential.accountId),
|
|
339
|
+
generation: credential.generation
|
|
340
|
+
}) : Effect3.fail(OpenAiAccountCredentialError.make({ operation })));
|
|
341
|
+
return {
|
|
342
|
+
acquire: service.acquire.pipe(accountCredential("acquire"), mapCredential("acquire")),
|
|
343
|
+
refreshRejected: (generation) => service.refreshRejected(generation).pipe(accountCredential("refreshRejected"), mapCredential("refreshRejected"))
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
var credentialsFromAccountAuth = Function.dual(2, credentialsFromAccountAuthImpl);
|
|
227
347
|
var credentialFailure = (request, error) => new HttpClientError.HttpClientError({
|
|
228
348
|
reason: new HttpClientError.TransportError({
|
|
229
349
|
request,
|
|
@@ -244,9 +364,9 @@ var accountClientTransform = (credentials) => (client) => HttpClient.transform(c
|
|
|
244
364
|
})))));
|
|
245
365
|
var withAccountHeaderRedaction = (effect) => effect.pipe(Effect3.updateService(Headers.CurrentRedactedNames, (names) => [...names, openAiAccountIdHeader]));
|
|
246
366
|
var withoutOpenAiSocket = (effect) => effect.pipe(Effect3.provideService(OpenAiClient.OpenAiSocket, null));
|
|
247
|
-
var openAiAccountClientLayer = (credentials) =>
|
|
367
|
+
var openAiAccountClientLayer = (credentials) => Layer3.effect(OpenAiClient.OpenAiClient, OpenAiClient.make({
|
|
248
368
|
apiUrl: openAiAccountApiUrl,
|
|
249
|
-
transformClient: accountClientTransform(credentials)
|
|
369
|
+
transformClient: (client) => client.pipe(normalizeResponsesSse, accountClientTransform(credentials))
|
|
250
370
|
}).pipe(Effect3.map((client) => OpenAiClient.OpenAiClient.of({
|
|
251
371
|
client: client.client,
|
|
252
372
|
createResponse: (options) => withAccountHeaderRedaction(client.createResponse(options)),
|
|
@@ -256,106 +376,87 @@ var openAiAccountClientLayer = (credentials) => Layer2.effect(OpenAiClient.OpenA
|
|
|
256
376
|
])),
|
|
257
377
|
createEmbedding: (options) => withAccountHeaderRedaction(client.createEmbedding(options))
|
|
258
378
|
}))));
|
|
259
|
-
var
|
|
379
|
+
var registrationAccount = (input) => exports_model_registry.registration({
|
|
260
380
|
provider: "openai",
|
|
261
381
|
model: input.model,
|
|
262
382
|
layer: OpenAiLanguageModel.layer({
|
|
263
383
|
model: input.model,
|
|
264
384
|
...input.config === undefined ? {} : { config: input.config }
|
|
265
|
-
}).pipe(
|
|
266
|
-
classifyFailure,
|
|
385
|
+
}).pipe(Layer3.provide(openAiAccountClientLayer(input.credentials))),
|
|
386
|
+
classifyFailure: classifyFailure2,
|
|
267
387
|
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
268
388
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
269
389
|
});
|
|
270
|
-
var
|
|
271
|
-
var withOpenAiAccountFetch = (input) => withOpenAiAccount(input).pipe(Layer2.provide(FetchHttpClient.layer));
|
|
390
|
+
var layerAccount = (input) => exports_model_registry.layer([registrationAccount(input)]);
|
|
272
391
|
|
|
273
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
274
|
-
var deterministicModelLayer =
|
|
392
|
+
// ../../node_modules/.bun/@batonfx+providers@0.9.1/node_modules/@batonfx/providers/dist/deterministic.js
|
|
393
|
+
var deterministicModelLayer = Layer4.effect(LanguageModel.LanguageModel, LanguageModel.make({
|
|
275
394
|
generateText: () => Effect4.succeed([{ type: "text", text: "deterministic response" }]),
|
|
276
|
-
streamText: () => Stream2.make(
|
|
395
|
+
streamText: () => Stream2.make(Response2.makePart("text-delta", { id: "text", delta: "deterministic response" }))
|
|
277
396
|
}));
|
|
278
|
-
var
|
|
397
|
+
var registration = (input = {}) => exports_model_registry.registration({
|
|
279
398
|
provider: input.provider ?? "deterministic",
|
|
280
399
|
model: input.model ?? "deterministic",
|
|
281
400
|
layer: deterministicModelLayer,
|
|
282
401
|
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
283
402
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
284
403
|
});
|
|
285
|
-
var
|
|
286
|
-
var
|
|
287
|
-
const deterministic = yield*
|
|
404
|
+
var layer4 = (input = {}) => exports_model_registry.layer([registration(input)]);
|
|
405
|
+
var layerOpenAi = (options) => Layer4.unwrap(Effect4.gen(function* () {
|
|
406
|
+
const deterministic = yield* registration({
|
|
288
407
|
provider: options.fallbackProvider ?? "deterministic",
|
|
289
408
|
model: options.fallbackModel
|
|
290
409
|
});
|
|
291
|
-
const configuredApiKey = yield*
|
|
292
|
-
const openAiRegistration = yield*
|
|
410
|
+
const configuredApiKey = yield* Config3.option(options.apiKey);
|
|
411
|
+
const openAiRegistration = yield* Option2.match(configuredApiKey, {
|
|
293
412
|
onNone: () => Effect4.succeedNone,
|
|
294
|
-
onSome: (apiKey) =>
|
|
413
|
+
onSome: (apiKey) => Layer4.build(OpenAiClient2.layerConfig({
|
|
295
414
|
...options.clientConfig,
|
|
296
|
-
apiKey:
|
|
297
|
-
})).pipe(Effect4.flatMap((context) =>
|
|
415
|
+
apiKey: Config3.succeed(apiKey)
|
|
416
|
+
})).pipe(Effect4.flatMap((context) => exports_model_registry.registration({
|
|
417
|
+
provider: "openai",
|
|
418
|
+
model: options.model,
|
|
419
|
+
layer: OpenAiLanguageModel2.layer({
|
|
420
|
+
model: options.model,
|
|
421
|
+
...options.config === undefined ? {} : { config: options.config }
|
|
422
|
+
}),
|
|
423
|
+
classifyFailure: classifyFailure2,
|
|
424
|
+
...options.registrationKey === undefined ? {} : { registrationKey: options.registrationKey },
|
|
425
|
+
...options.metadata === undefined ? {} : { metadata: options.metadata }
|
|
426
|
+
}).pipe(Effect4.provide(context))), Effect4.asSome)
|
|
298
427
|
});
|
|
299
428
|
return exports_model_registry.layer([
|
|
300
|
-
deterministic,
|
|
301
|
-
...
|
|
429
|
+
Effect4.succeed(deterministic),
|
|
430
|
+
...Option2.isSome(openAiRegistration) ? [Effect4.succeed(openAiRegistration.value)] : []
|
|
302
431
|
]);
|
|
303
432
|
}));
|
|
304
|
-
var withOpenAiOrDeterministicFetch = (options) => withOpenAiOrDeterministic(options).pipe(Layer3.provide(FetchHttpClient2.layer));
|
|
305
433
|
|
|
306
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
307
|
-
import {
|
|
308
|
-
import { Config as Config3, Layer as Layer4, Redacted as Redacted2 } from "effect";
|
|
309
|
-
import { AiError as AiError2 } from "effect/unstable/ai";
|
|
310
|
-
import { FetchHttpClient as FetchHttpClient3 } from "effect/unstable/http";
|
|
311
|
-
var classifyFailure2 = (error) => {
|
|
312
|
-
if (!AiError2.isAiError(error) || error.reason._tag !== "InvalidRequestError")
|
|
313
|
-
return "other";
|
|
314
|
-
const metadata = error.reason.metadata.anthropic;
|
|
315
|
-
return metadata?.errorType === "invalid_request_error" && /\bprompt is too long\b/i.test(error.reason.description ?? "") ? "context-overflow" : "other";
|
|
316
|
-
};
|
|
317
|
-
var anthropic = (input) => exports_model_registry.registrationFromLayer({
|
|
318
|
-
provider: "anthropic",
|
|
319
|
-
model: input.model,
|
|
320
|
-
layer: AnthropicLanguageModel.layer({
|
|
321
|
-
model: input.model,
|
|
322
|
-
...input.config === undefined ? {} : { config: input.config }
|
|
323
|
-
}),
|
|
324
|
-
classifyFailure: classifyFailure2,
|
|
325
|
-
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
326
|
-
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
327
|
-
});
|
|
328
|
-
var anthropicClientLayerConfig = AnthropicClient.layerConfig;
|
|
329
|
-
var withAnthropic = (options) => exports_model_registry.layerFromRegistrationEffects([anthropic(options)]).pipe(Layer4.provide(AnthropicClient.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })));
|
|
330
|
-
var withAnthropicFetch = (options) => withAnthropic(options).pipe(Layer4.provide(FetchHttpClient3.layer));
|
|
331
|
-
// ../../node_modules/.bun/@batonfx+providers@0.7.0/node_modules/@batonfx/providers/dist/openai-compat.js
|
|
332
|
-
import { OpenAiClient as OpenAiClient3, OpenAiLanguageModel as OpenAiLanguageModel2 } from "@effect/ai-openai-compat";
|
|
434
|
+
// ../../node_modules/.bun/@batonfx+providers@0.9.1/node_modules/@batonfx/providers/dist/openai-compat.js
|
|
435
|
+
import { OpenAiClient as OpenAiClient3, OpenAiLanguageModel as OpenAiLanguageModel3 } from "@effect/ai-openai-compat";
|
|
333
436
|
import { Config as Config4, Layer as Layer5, Redacted as Redacted3 } from "effect";
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
model: input.model,
|
|
338
|
-
layer: OpenAiLanguageModel2.layer({
|
|
437
|
+
var layer5 = (input) => exports_model_registry.layer([
|
|
438
|
+
exports_model_registry.registration({
|
|
439
|
+
provider: input.provider ?? "openai-compatible",
|
|
339
440
|
model: input.model,
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
...
|
|
350
|
-
...
|
|
351
|
-
})
|
|
352
|
-
|
|
353
|
-
var
|
|
354
|
-
|
|
441
|
+
layer: OpenAiLanguageModel3.layer({
|
|
442
|
+
model: input.model,
|
|
443
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
444
|
+
}),
|
|
445
|
+
...input.classifyFailure === undefined ? {} : { classifyFailure: input.classifyFailure },
|
|
446
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
447
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
448
|
+
})
|
|
449
|
+
]).pipe(Layer5.provide(OpenAiClient3.layerConfig({
|
|
450
|
+
...input.clientConfig,
|
|
451
|
+
...input.apiKey === undefined ? {} : { apiKey: input.apiKey },
|
|
452
|
+
...input.baseUrl === undefined ? {} : { apiUrl: Config4.succeed(input.baseUrl) }
|
|
453
|
+
})));
|
|
454
|
+
var layerConfig3 = OpenAiClient3.layerConfig;
|
|
455
|
+
|
|
456
|
+
// ../../node_modules/.bun/@batonfx+providers@0.9.1/node_modules/@batonfx/providers/dist/openrouter.js
|
|
355
457
|
import { OpenRouterClient, OpenRouterLanguageModel } from "@effect/ai-openrouter";
|
|
356
458
|
import { Config as Config5, Layer as Layer6, Redacted as Redacted4 } from "effect";
|
|
357
459
|
import { AiError as AiError3 } from "effect/unstable/ai";
|
|
358
|
-
import { FetchHttpClient as FetchHttpClient5 } from "effect/unstable/http";
|
|
359
460
|
var contextOverflowCodes2 = new Set(["context_length_exceeded", "context_window_exceeded", "input_too_long"]);
|
|
360
461
|
var classifyFailure3 = (error) => {
|
|
361
462
|
if (!AiError3.isAiError(error))
|
|
@@ -371,10 +472,51 @@ var classifyFailure3 = (error) => {
|
|
|
371
472
|
}
|
|
372
473
|
return reason._tag === "InvalidRequestError" && /maximum context length|context length exceeded|input exceeds (?:the )?context window|prompt is too long/i.test(reason.description ?? "") ? "context-overflow" : "other";
|
|
373
474
|
};
|
|
374
|
-
var
|
|
475
|
+
var layer6 = (input) => exports_model_registry.layer([
|
|
476
|
+
exports_model_registry.registration({
|
|
477
|
+
provider: "openrouter",
|
|
478
|
+
model: input.model,
|
|
479
|
+
layer: OpenRouterLanguageModel.layer({
|
|
480
|
+
model: input.model,
|
|
481
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
482
|
+
}),
|
|
483
|
+
classifyFailure: classifyFailure3,
|
|
484
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
485
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
486
|
+
})
|
|
487
|
+
]).pipe(Layer6.provide(OpenRouterClient.layerConfig({ ...input.clientConfig, apiKey: input.apiKey })));
|
|
488
|
+
var layerConfig4 = OpenRouterClient.layerConfig;
|
|
489
|
+
|
|
490
|
+
// src/language-model-registration.ts
|
|
491
|
+
import { Layer as Layer7 } from "effect";
|
|
492
|
+
import { FetchHttpClient as FetchHttpClient2 } from "effect/unstable/http";
|
|
493
|
+
var deterministicModel = (input) => registration(input);
|
|
494
|
+
var openAi = (input) => exports_model_registry.registration({
|
|
495
|
+
provider: "openai",
|
|
496
|
+
model: input.model,
|
|
497
|
+
layer: OpenAiLanguageModel4.layer({
|
|
498
|
+
model: input.model,
|
|
499
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
500
|
+
}),
|
|
501
|
+
classifyFailure: classifyFailure2,
|
|
502
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
503
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
504
|
+
});
|
|
505
|
+
var anthropic = (input) => exports_model_registry.registration({
|
|
506
|
+
provider: "anthropic",
|
|
507
|
+
model: input.model,
|
|
508
|
+
layer: AnthropicLanguageModel2.layer({
|
|
509
|
+
model: input.model,
|
|
510
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
511
|
+
}),
|
|
512
|
+
classifyFailure,
|
|
513
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
514
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
515
|
+
});
|
|
516
|
+
var openRouter = (input) => exports_model_registry.registration({
|
|
375
517
|
provider: "openrouter",
|
|
376
518
|
model: input.model,
|
|
377
|
-
layer:
|
|
519
|
+
layer: OpenRouterLanguageModel2.layer({
|
|
378
520
|
model: input.model,
|
|
379
521
|
...input.config === undefined ? {} : { config: input.config }
|
|
380
522
|
}),
|
|
@@ -382,12 +524,22 @@ var openRouter = (input) => exports_model_registry.registrationFromLayer({
|
|
|
382
524
|
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
383
525
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
384
526
|
});
|
|
385
|
-
var
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
527
|
+
var openAiCompatible = (input) => exports_model_registry.registration({
|
|
528
|
+
provider: input.provider ?? "openai-compatible",
|
|
529
|
+
model: input.model,
|
|
530
|
+
layer: OpenAiCompatibleLanguageModel.layer({
|
|
531
|
+
model: input.model,
|
|
532
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
533
|
+
}),
|
|
534
|
+
...input.classifyFailure === undefined ? {} : { classifyFailure: input.classifyFailure },
|
|
535
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
536
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
537
|
+
});
|
|
538
|
+
var withOpenAiFetch = (input) => layer3(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
539
|
+
var withAnthropicFetch = (input) => layer2(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
540
|
+
var withOpenRouterFetch = (input) => layer6(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
541
|
+
var withOpenAiCompatibleFetch = (input) => layer5(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
542
|
+
var withOpenAiAccountFetch = (input) => layerAccount(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
391
543
|
|
|
392
544
|
// src/client.ts
|
|
393
545
|
var exports_client = {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_execution_id" TEXT;
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_epoch" BIGINT NOT NULL DEFAULT 0;
|
|
4
|
+
--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_released" BOOLEAN NOT NULL DEFAULT TRUE;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE relay_sessions ADD COLUMN owner_execution_id TEXT NULL;
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE relay_sessions ADD COLUMN owner_epoch BIGINT NOT NULL DEFAULT 0;
|
|
4
|
+
--> statement-breakpoint
|
|
5
|
+
ALTER TABLE relay_sessions ADD COLUMN owner_released BOOLEAN NOT NULL DEFAULT TRUE;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_execution_id" TEXT;
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_epoch" BIGINT NOT NULL DEFAULT 0;
|
|
4
|
+
--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_released" BOOLEAN NOT NULL DEFAULT TRUE;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_execution_id" TEXT;
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_epoch" INTEGER NOT NULL DEFAULT 0;
|
|
4
|
+
--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_released" INTEGER NOT NULL DEFAULT 1;
|
package/dist/mysql.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
database,
|
|
4
4
|
normalizeMigrationCause
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-dm4yqr8f.js";
|
|
6
6
|
import {
|
|
7
7
|
MigratorError,
|
|
8
8
|
RuntimeMigrationError,
|
|
9
9
|
SqlFailure
|
|
10
|
-
} from "./index-
|
|
11
|
-
import"./index-
|
|
10
|
+
} from "./index-ftgf8py0.js";
|
|
11
|
+
import"./index-5vjhqzbk.js";
|
|
12
12
|
import"./index-fh2ftte9.js";
|
|
13
13
|
import"./index-nb39b5ae.js";
|
|
14
14
|
|
|
@@ -89,6 +89,14 @@ SET type = 'steering.delivered', id = replace(id, ':received', ':delivered')
|
|
|
89
89
|
WHERE type = 'steering.received';
|
|
90
90
|
`;
|
|
91
91
|
|
|
92
|
+
// ../../migrations/mysql/0014_session_writer_ownership.sql
|
|
93
|
+
var _0014_session_writer_ownership_default = `ALTER TABLE relay_sessions ADD COLUMN owner_execution_id TEXT NULL;
|
|
94
|
+
--> statement-breakpoint
|
|
95
|
+
ALTER TABLE relay_sessions ADD COLUMN owner_epoch BIGINT NOT NULL DEFAULT 0;
|
|
96
|
+
--> statement-breakpoint
|
|
97
|
+
ALTER TABLE relay_sessions ADD COLUMN owner_released BOOLEAN NOT NULL DEFAULT TRUE;
|
|
98
|
+
`;
|
|
99
|
+
|
|
92
100
|
// src/mysql-migrations.ts
|
|
93
101
|
var migrations = [
|
|
94
102
|
[1, "baseline", _0001_baseline_default],
|
|
@@ -103,7 +111,8 @@ var migrations = [
|
|
|
103
111
|
[10, "workflow_runtime", _0010_workflow_runtime_default],
|
|
104
112
|
[11, "execution_scoped_tool_calls", _0011_execution_scoped_tool_calls_default],
|
|
105
113
|
[12, "rename_entity_to_resident", _0012_rename_entity_to_resident_default],
|
|
106
|
-
[13, "steering_delivered", _0013_steering_delivered_default]
|
|
114
|
+
[13, "steering_delivered", _0013_steering_delivered_default],
|
|
115
|
+
[14, "session_writer_ownership", _0014_session_writer_ownership_default]
|
|
107
116
|
];
|
|
108
117
|
|
|
109
118
|
// src/mysql.ts
|
package/dist/postgres.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
database,
|
|
4
4
|
normalizeMigrationCause
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-dm4yqr8f.js";
|
|
6
6
|
import {
|
|
7
7
|
Dialect,
|
|
8
8
|
RuntimeMigrationError,
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
fromDbTimestamp,
|
|
15
15
|
fromNullableDbTimestamp,
|
|
16
16
|
timestampParam
|
|
17
|
-
} from "./index-
|
|
18
|
-
import"./index-
|
|
17
|
+
} from "./index-ftgf8py0.js";
|
|
18
|
+
import"./index-5vjhqzbk.js";
|
|
19
19
|
import {
|
|
20
20
|
exports_ids_schema
|
|
21
21
|
} from "./index-fh2ftte9.js";
|
|
@@ -487,12 +487,15 @@ var relayTopicSubscriptions = pgTable6("relay_topic_subscriptions", {
|
|
|
487
487
|
index4("idx_relay_topic_subscriptions_subscriber").on(table.tenantId, table.subscriberExecutionId)
|
|
488
488
|
]);
|
|
489
489
|
// ../store-sql/src/schema/session-schema.ts
|
|
490
|
-
import { index as index5, jsonb as jsonb7, pgTable as pgTable7, primaryKey as primaryKey7, text as text8, timestamp as timestamp7 } from "drizzle-orm/pg-core";
|
|
490
|
+
import { bigint, boolean as boolean3, index as index5, jsonb as jsonb7, pgTable as pgTable7, primaryKey as primaryKey7, text as text8, timestamp as timestamp7 } from "drizzle-orm/pg-core";
|
|
491
491
|
var relaySessions = pgTable7("relay_sessions", {
|
|
492
492
|
tenantId: tenantId(),
|
|
493
493
|
id: text8("id").$type().notNull(),
|
|
494
494
|
rootAddressId: text8("root_address_id").$type().notNull(),
|
|
495
495
|
leafEntryId: text8("leaf_entry_id").$type(),
|
|
496
|
+
ownerExecutionId: text8("owner_execution_id").$type(),
|
|
497
|
+
ownerEpoch: bigint("owner_epoch", { mode: "number" }).notNull().default(0),
|
|
498
|
+
ownerReleased: boolean3("owner_released").notNull().default(true),
|
|
496
499
|
metadataJson: jsonb7("metadata_json").$type().notNull().default({}),
|
|
497
500
|
createdAt: timestamp7("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
498
501
|
updatedAt: timestamp7("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
@@ -745,7 +748,7 @@ var relayIdempotencyKeys = pgTable13("relay_idempotency_keys", {
|
|
|
745
748
|
uniqueIndex9("uq_relay_idempotency_scope_operation_key").on(table.tenantId, table.scope, table.operation, table.key)
|
|
746
749
|
]);
|
|
747
750
|
// src/postgres.ts
|
|
748
|
-
var schemaHead = "
|
|
751
|
+
var schemaHead = "20260721170000_session_writer_ownership";
|
|
749
752
|
var migrationNames = [
|
|
750
753
|
"20260701002839_sour_cerebro",
|
|
751
754
|
"20260701041134_acoustic_hulk",
|
|
@@ -774,6 +777,7 @@ var migrationNames = [
|
|
|
774
777
|
"20260712200000_workflow_runtime",
|
|
775
778
|
"20260718140000_execution_scoped_tool_calls",
|
|
776
779
|
"20260719120000_rename_entity_to_resident",
|
|
780
|
+
"20260721120000_steering_delivered",
|
|
777
781
|
schemaHead
|
|
778
782
|
];
|
|
779
783
|
var migrationsFolderUrl = import.meta.url.endsWith("/src/postgres.ts") ? new URL("../../../migrations/pg", import.meta.url) : new URL("./migrations/pg", import.meta.url);
|