@relayfx/sdk 0.5.0 → 0.6.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 +1 -1
- package/dist/{index-h1cf8za4.js → index-0jx86sx3.js} +1 -1
- package/dist/{index-8asvg7x0.js → index-96b7htye.js} +878 -706
- package/dist/{index-x32kbvxv.js → index-c6jave5p.js} +989 -958
- package/dist/index.js +252 -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 +7 -4
- 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 +35 -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-96b7htye.js";
|
|
18
18
|
import {
|
|
19
19
|
exports_model_registry
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-c6jave5p.js";
|
|
21
21
|
import {
|
|
22
22
|
ClientError,
|
|
23
23
|
EventLogCursorNotFound,
|
|
@@ -151,48 +151,75 @@ 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.0/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.0/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.0/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 classifyFailure2 = (error) => {
|
|
222
|
+
if (!AiError2.isAiError(error))
|
|
196
223
|
return "other";
|
|
197
224
|
const reason = error.reason;
|
|
198
225
|
if (reason._tag !== "InvalidRequestError" && reason._tag !== "UnknownError")
|
|
@@ -205,25 +232,101 @@ var classifyFailure = (error) => {
|
|
|
205
232
|
}
|
|
206
233
|
return reason._tag === "InvalidRequestError" && /maximum context length|context length exceeded|input exceeds (?:the )?context window/i.test(reason.description ?? "") ? "context-overflow" : "other";
|
|
207
234
|
};
|
|
208
|
-
var
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
layer: OpenAiLanguageModel.layer({
|
|
235
|
+
var layer3 = (input) => exports_model_registry.layer([
|
|
236
|
+
exports_model_registry.registration({
|
|
237
|
+
provider: "openai",
|
|
212
238
|
model: input.model,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
239
|
+
layer: OpenAiLanguageModel.layer({
|
|
240
|
+
model: input.model,
|
|
241
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
242
|
+
}),
|
|
243
|
+
classifyFailure: classifyFailure2,
|
|
244
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
245
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
246
|
+
})
|
|
247
|
+
]).pipe(Layer3.provide(layerConfig2({ ...input.clientConfig, apiKey: input.apiKey })));
|
|
248
|
+
var stringifyJson = Schema.encodeSync(Schema.UnknownFromJsonString);
|
|
249
|
+
var parseJsonOption = Schema.decodeUnknownOption(Schema.UnknownFromJsonString);
|
|
250
|
+
var dataLinePrefix = /^data: ?/;
|
|
251
|
+
var frameSeparator = /(\r?\n\r?\n)/;
|
|
252
|
+
var lineSeparator = /(\r?\n)/;
|
|
253
|
+
var isResponsesUrl = (url) => url.split(/[?#]/)[0].replace(/\/+$/, "").endsWith("/responses");
|
|
254
|
+
var flattenErrorPayload = (payload) => {
|
|
255
|
+
const decoded = parseJsonOption(payload);
|
|
256
|
+
if (Option.isNone(decoded) || typeof decoded.value !== "object" || decoded.value === null)
|
|
257
|
+
return;
|
|
258
|
+
const record = decoded.value;
|
|
259
|
+
if (record.type !== "error" || record.message !== undefined)
|
|
260
|
+
return;
|
|
261
|
+
const details = record.error;
|
|
262
|
+
if (typeof details !== "object" || details === null || Array.isArray(details))
|
|
263
|
+
return;
|
|
264
|
+
const nested = details;
|
|
265
|
+
return stringifyJson({
|
|
266
|
+
type: "error",
|
|
267
|
+
code: typeof nested.code === "string" ? nested.code : null,
|
|
268
|
+
message: typeof nested.message === "string" ? nested.message : stringifyJson(nested),
|
|
269
|
+
param: typeof nested.param === "string" ? nested.param : null,
|
|
270
|
+
sequence_number: typeof record.sequence_number === "number" ? record.sequence_number : 0
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
var rewriteFrame = (frame) => {
|
|
274
|
+
const segments = frame.split(lineSeparator);
|
|
275
|
+
const dataIndexes = [];
|
|
276
|
+
for (let index = 0;index < segments.length; index += 2) {
|
|
277
|
+
if (dataLinePrefix.test(segments[index] ?? ""))
|
|
278
|
+
dataIndexes.push(index);
|
|
279
|
+
}
|
|
280
|
+
if (dataIndexes.length !== 1)
|
|
281
|
+
return frame;
|
|
282
|
+
const line = segments[dataIndexes[0]];
|
|
283
|
+
const prefix = line.match(dataLinePrefix)[0];
|
|
284
|
+
const flattened = flattenErrorPayload(line.slice(prefix.length));
|
|
285
|
+
if (flattened === undefined)
|
|
286
|
+
return frame;
|
|
287
|
+
segments[dataIndexes[0]] = `${prefix}${flattened}`;
|
|
288
|
+
return segments.join("");
|
|
289
|
+
};
|
|
290
|
+
var normalizeSseErrorFrames = (body) => body.pipe(Stream.decodeText(), Stream.mapAccum(() => "", (buffer, chunk) => {
|
|
291
|
+
const pieces = (buffer + chunk).split(frameSeparator);
|
|
292
|
+
const tail = pieces.length % 2 === 1 ? pieces.pop() : "";
|
|
293
|
+
const output = [];
|
|
294
|
+
for (let index = 0;index < pieces.length; index += 2) {
|
|
295
|
+
output.push(rewriteFrame(pieces[index]) + pieces[index + 1]);
|
|
296
|
+
}
|
|
297
|
+
return [tail, output];
|
|
298
|
+
}, { onHalt: (buffer) => buffer.length === 0 ? [] : [rewriteFrame(buffer)] }), Stream.encodeText);
|
|
299
|
+
var normalizeResponsesSse = (client) => HttpClient.transformResponse(client, (effect) => Effect3.map(effect, (response) => {
|
|
300
|
+
const contentType = String(response.headers["content-type"] ?? "");
|
|
301
|
+
if (!contentType.includes("text/event-stream") || !isResponsesUrl(response.request.url))
|
|
302
|
+
return response;
|
|
303
|
+
return HttpClientResponse.fromWeb(response.request, new Response(Stream.toReadableStream(normalizeSseErrorFrames(response.stream)), {
|
|
304
|
+
status: response.status,
|
|
305
|
+
headers: { "content-type": contentType }
|
|
306
|
+
}));
|
|
307
|
+
}));
|
|
308
|
+
var layerConfig2 = (options) => OpenAiClient.layerConfig({
|
|
309
|
+
...options,
|
|
310
|
+
transformClient: (client) => options?.transformClient === undefined ? normalizeResponsesSse(client) : client.pipe(normalizeResponsesSse, options.transformClient)
|
|
218
311
|
});
|
|
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
312
|
|
|
223
313
|
class OpenAiAccountCredentialError extends Schema.TaggedErrorClass()("@batonfx/providers/OpenAiAccountCredentialError", {
|
|
224
314
|
operation: Schema.Literals(["acquire", "refreshRejected"])
|
|
225
315
|
}) {
|
|
226
316
|
}
|
|
317
|
+
var credentialsFromAccountAuthImpl = (service, expectedFingerprint) => {
|
|
318
|
+
const mapCredential = (operation) => Effect3.mapError(() => OpenAiAccountCredentialError.make({ operation }));
|
|
319
|
+
const accountCredential = (operation) => Effect3.flatMap((credential) => credential.fingerprint === expectedFingerprint ? Effect3.succeed({
|
|
320
|
+
accessToken: credential.accessToken,
|
|
321
|
+
accountId: Redacted2.value(credential.accountId),
|
|
322
|
+
generation: credential.generation
|
|
323
|
+
}) : Effect3.fail(OpenAiAccountCredentialError.make({ operation })));
|
|
324
|
+
return {
|
|
325
|
+
acquire: service.acquire.pipe(accountCredential("acquire"), mapCredential("acquire")),
|
|
326
|
+
refreshRejected: (generation) => service.refreshRejected(generation).pipe(accountCredential("refreshRejected"), mapCredential("refreshRejected"))
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
var credentialsFromAccountAuth = Function.dual(2, credentialsFromAccountAuthImpl);
|
|
227
330
|
var credentialFailure = (request, error) => new HttpClientError.HttpClientError({
|
|
228
331
|
reason: new HttpClientError.TransportError({
|
|
229
332
|
request,
|
|
@@ -244,9 +347,9 @@ var accountClientTransform = (credentials) => (client) => HttpClient.transform(c
|
|
|
244
347
|
})))));
|
|
245
348
|
var withAccountHeaderRedaction = (effect) => effect.pipe(Effect3.updateService(Headers.CurrentRedactedNames, (names) => [...names, openAiAccountIdHeader]));
|
|
246
349
|
var withoutOpenAiSocket = (effect) => effect.pipe(Effect3.provideService(OpenAiClient.OpenAiSocket, null));
|
|
247
|
-
var openAiAccountClientLayer = (credentials) =>
|
|
350
|
+
var openAiAccountClientLayer = (credentials) => Layer3.effect(OpenAiClient.OpenAiClient, OpenAiClient.make({
|
|
248
351
|
apiUrl: openAiAccountApiUrl,
|
|
249
|
-
transformClient: accountClientTransform(credentials)
|
|
352
|
+
transformClient: (client) => client.pipe(normalizeResponsesSse, accountClientTransform(credentials))
|
|
250
353
|
}).pipe(Effect3.map((client) => OpenAiClient.OpenAiClient.of({
|
|
251
354
|
client: client.client,
|
|
252
355
|
createResponse: (options) => withAccountHeaderRedaction(client.createResponse(options)),
|
|
@@ -256,106 +359,87 @@ var openAiAccountClientLayer = (credentials) => Layer2.effect(OpenAiClient.OpenA
|
|
|
256
359
|
])),
|
|
257
360
|
createEmbedding: (options) => withAccountHeaderRedaction(client.createEmbedding(options))
|
|
258
361
|
}))));
|
|
259
|
-
var
|
|
362
|
+
var registrationAccount = (input) => exports_model_registry.registration({
|
|
260
363
|
provider: "openai",
|
|
261
364
|
model: input.model,
|
|
262
365
|
layer: OpenAiLanguageModel.layer({
|
|
263
366
|
model: input.model,
|
|
264
367
|
...input.config === undefined ? {} : { config: input.config }
|
|
265
|
-
}).pipe(
|
|
266
|
-
classifyFailure,
|
|
368
|
+
}).pipe(Layer3.provide(openAiAccountClientLayer(input.credentials))),
|
|
369
|
+
classifyFailure: classifyFailure2,
|
|
267
370
|
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
268
371
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
269
372
|
});
|
|
270
|
-
var
|
|
271
|
-
var withOpenAiAccountFetch = (input) => withOpenAiAccount(input).pipe(Layer2.provide(FetchHttpClient.layer));
|
|
373
|
+
var layerAccount = (input) => exports_model_registry.layer([registrationAccount(input)]);
|
|
272
374
|
|
|
273
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
274
|
-
var deterministicModelLayer =
|
|
375
|
+
// ../../node_modules/.bun/@batonfx+providers@0.9.0/node_modules/@batonfx/providers/dist/deterministic.js
|
|
376
|
+
var deterministicModelLayer = Layer4.effect(LanguageModel.LanguageModel, LanguageModel.make({
|
|
275
377
|
generateText: () => Effect4.succeed([{ type: "text", text: "deterministic response" }]),
|
|
276
|
-
streamText: () => Stream2.make(
|
|
378
|
+
streamText: () => Stream2.make(Response2.makePart("text-delta", { id: "text", delta: "deterministic response" }))
|
|
277
379
|
}));
|
|
278
|
-
var
|
|
380
|
+
var registration = (input = {}) => exports_model_registry.registration({
|
|
279
381
|
provider: input.provider ?? "deterministic",
|
|
280
382
|
model: input.model ?? "deterministic",
|
|
281
383
|
layer: deterministicModelLayer,
|
|
282
384
|
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
283
385
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
284
386
|
});
|
|
285
|
-
var
|
|
286
|
-
var
|
|
287
|
-
const deterministic = yield*
|
|
387
|
+
var layer4 = (input = {}) => exports_model_registry.layer([registration(input)]);
|
|
388
|
+
var layerOpenAi = (options) => Layer4.unwrap(Effect4.gen(function* () {
|
|
389
|
+
const deterministic = yield* registration({
|
|
288
390
|
provider: options.fallbackProvider ?? "deterministic",
|
|
289
391
|
model: options.fallbackModel
|
|
290
392
|
});
|
|
291
|
-
const configuredApiKey = yield*
|
|
292
|
-
const openAiRegistration = yield*
|
|
393
|
+
const configuredApiKey = yield* Config3.option(options.apiKey);
|
|
394
|
+
const openAiRegistration = yield* Option2.match(configuredApiKey, {
|
|
293
395
|
onNone: () => Effect4.succeedNone,
|
|
294
|
-
onSome: (apiKey) =>
|
|
396
|
+
onSome: (apiKey) => Layer4.build(OpenAiClient2.layerConfig({
|
|
295
397
|
...options.clientConfig,
|
|
296
|
-
apiKey:
|
|
297
|
-
})).pipe(Effect4.flatMap((context) =>
|
|
398
|
+
apiKey: Config3.succeed(apiKey)
|
|
399
|
+
})).pipe(Effect4.flatMap((context) => exports_model_registry.registration({
|
|
400
|
+
provider: "openai",
|
|
401
|
+
model: options.model,
|
|
402
|
+
layer: OpenAiLanguageModel2.layer({
|
|
403
|
+
model: options.model,
|
|
404
|
+
...options.config === undefined ? {} : { config: options.config }
|
|
405
|
+
}),
|
|
406
|
+
classifyFailure: classifyFailure2,
|
|
407
|
+
...options.registrationKey === undefined ? {} : { registrationKey: options.registrationKey },
|
|
408
|
+
...options.metadata === undefined ? {} : { metadata: options.metadata }
|
|
409
|
+
}).pipe(Effect4.provide(context))), Effect4.asSome)
|
|
298
410
|
});
|
|
299
411
|
return exports_model_registry.layer([
|
|
300
|
-
deterministic,
|
|
301
|
-
...
|
|
412
|
+
Effect4.succeed(deterministic),
|
|
413
|
+
...Option2.isSome(openAiRegistration) ? [Effect4.succeed(openAiRegistration.value)] : []
|
|
302
414
|
]);
|
|
303
415
|
}));
|
|
304
|
-
var withOpenAiOrDeterministicFetch = (options) => withOpenAiOrDeterministic(options).pipe(Layer3.provide(FetchHttpClient2.layer));
|
|
305
416
|
|
|
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";
|
|
417
|
+
// ../../node_modules/.bun/@batonfx+providers@0.9.0/node_modules/@batonfx/providers/dist/openai-compat.js
|
|
418
|
+
import { OpenAiClient as OpenAiClient3, OpenAiLanguageModel as OpenAiLanguageModel3 } from "@effect/ai-openai-compat";
|
|
333
419
|
import { Config as Config4, Layer as Layer5, Redacted as Redacted3 } from "effect";
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
model: input.model,
|
|
338
|
-
layer: OpenAiLanguageModel2.layer({
|
|
420
|
+
var layer5 = (input) => exports_model_registry.layer([
|
|
421
|
+
exports_model_registry.registration({
|
|
422
|
+
provider: input.provider ?? "openai-compatible",
|
|
339
423
|
model: input.model,
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
...
|
|
350
|
-
...
|
|
351
|
-
})
|
|
352
|
-
|
|
353
|
-
var
|
|
354
|
-
|
|
424
|
+
layer: OpenAiLanguageModel3.layer({
|
|
425
|
+
model: input.model,
|
|
426
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
427
|
+
}),
|
|
428
|
+
...input.classifyFailure === undefined ? {} : { classifyFailure: input.classifyFailure },
|
|
429
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
430
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
431
|
+
})
|
|
432
|
+
]).pipe(Layer5.provide(OpenAiClient3.layerConfig({
|
|
433
|
+
...input.clientConfig,
|
|
434
|
+
...input.apiKey === undefined ? {} : { apiKey: input.apiKey },
|
|
435
|
+
...input.baseUrl === undefined ? {} : { apiUrl: Config4.succeed(input.baseUrl) }
|
|
436
|
+
})));
|
|
437
|
+
var layerConfig3 = OpenAiClient3.layerConfig;
|
|
438
|
+
|
|
439
|
+
// ../../node_modules/.bun/@batonfx+providers@0.9.0/node_modules/@batonfx/providers/dist/openrouter.js
|
|
355
440
|
import { OpenRouterClient, OpenRouterLanguageModel } from "@effect/ai-openrouter";
|
|
356
441
|
import { Config as Config5, Layer as Layer6, Redacted as Redacted4 } from "effect";
|
|
357
442
|
import { AiError as AiError3 } from "effect/unstable/ai";
|
|
358
|
-
import { FetchHttpClient as FetchHttpClient5 } from "effect/unstable/http";
|
|
359
443
|
var contextOverflowCodes2 = new Set(["context_length_exceeded", "context_window_exceeded", "input_too_long"]);
|
|
360
444
|
var classifyFailure3 = (error) => {
|
|
361
445
|
if (!AiError3.isAiError(error))
|
|
@@ -371,10 +455,51 @@ var classifyFailure3 = (error) => {
|
|
|
371
455
|
}
|
|
372
456
|
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
457
|
};
|
|
374
|
-
var
|
|
458
|
+
var layer6 = (input) => exports_model_registry.layer([
|
|
459
|
+
exports_model_registry.registration({
|
|
460
|
+
provider: "openrouter",
|
|
461
|
+
model: input.model,
|
|
462
|
+
layer: OpenRouterLanguageModel.layer({
|
|
463
|
+
model: input.model,
|
|
464
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
465
|
+
}),
|
|
466
|
+
classifyFailure: classifyFailure3,
|
|
467
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
468
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
469
|
+
})
|
|
470
|
+
]).pipe(Layer6.provide(OpenRouterClient.layerConfig({ ...input.clientConfig, apiKey: input.apiKey })));
|
|
471
|
+
var layerConfig4 = OpenRouterClient.layerConfig;
|
|
472
|
+
|
|
473
|
+
// src/language-model-registration.ts
|
|
474
|
+
import { Layer as Layer7 } from "effect";
|
|
475
|
+
import { FetchHttpClient as FetchHttpClient2 } from "effect/unstable/http";
|
|
476
|
+
var deterministicModel = (input) => registration(input);
|
|
477
|
+
var openAi = (input) => exports_model_registry.registration({
|
|
478
|
+
provider: "openai",
|
|
479
|
+
model: input.model,
|
|
480
|
+
layer: OpenAiLanguageModel4.layer({
|
|
481
|
+
model: input.model,
|
|
482
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
483
|
+
}),
|
|
484
|
+
classifyFailure: classifyFailure2,
|
|
485
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
486
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
487
|
+
});
|
|
488
|
+
var anthropic = (input) => exports_model_registry.registration({
|
|
489
|
+
provider: "anthropic",
|
|
490
|
+
model: input.model,
|
|
491
|
+
layer: AnthropicLanguageModel2.layer({
|
|
492
|
+
model: input.model,
|
|
493
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
494
|
+
}),
|
|
495
|
+
classifyFailure,
|
|
496
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
497
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
498
|
+
});
|
|
499
|
+
var openRouter = (input) => exports_model_registry.registration({
|
|
375
500
|
provider: "openrouter",
|
|
376
501
|
model: input.model,
|
|
377
|
-
layer:
|
|
502
|
+
layer: OpenRouterLanguageModel2.layer({
|
|
378
503
|
model: input.model,
|
|
379
504
|
...input.config === undefined ? {} : { config: input.config }
|
|
380
505
|
}),
|
|
@@ -382,12 +507,22 @@ var openRouter = (input) => exports_model_registry.registrationFromLayer({
|
|
|
382
507
|
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
383
508
|
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
384
509
|
});
|
|
385
|
-
var
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
510
|
+
var openAiCompatible = (input) => exports_model_registry.registration({
|
|
511
|
+
provider: input.provider ?? "openai-compatible",
|
|
512
|
+
model: input.model,
|
|
513
|
+
layer: OpenAiCompatibleLanguageModel.layer({
|
|
514
|
+
model: input.model,
|
|
515
|
+
...input.config === undefined ? {} : { config: input.config }
|
|
516
|
+
}),
|
|
517
|
+
...input.classifyFailure === undefined ? {} : { classifyFailure: input.classifyFailure },
|
|
518
|
+
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
519
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
520
|
+
});
|
|
521
|
+
var withOpenAiFetch = (input) => layer3(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
522
|
+
var withAnthropicFetch = (input) => layer2(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
523
|
+
var withOpenRouterFetch = (input) => layer6(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
524
|
+
var withOpenAiCompatibleFetch = (input) => layer5(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
525
|
+
var withOpenAiAccountFetch = (input) => layerAccount(input).pipe(Layer7.provide(FetchHttpClient2.layer));
|
|
391
526
|
|
|
392
527
|
// src/client.ts
|
|
393
528
|
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-0jx86sx3.js";
|
|
6
6
|
import {
|
|
7
7
|
MigratorError,
|
|
8
8
|
RuntimeMigrationError,
|
|
9
9
|
SqlFailure
|
|
10
|
-
} from "./index-
|
|
11
|
-
import"./index-
|
|
10
|
+
} from "./index-96b7htye.js";
|
|
11
|
+
import"./index-c6jave5p.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-0jx86sx3.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-96b7htye.js";
|
|
18
|
+
import"./index-c6jave5p.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()
|
package/dist/sqlite.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
database,
|
|
4
4
|
normalizeMigrationCause
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-0jx86sx3.js";
|
|
6
6
|
import {
|
|
7
7
|
DatabaseAlreadyOwned,
|
|
8
8
|
RuntimeConfigurationError,
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
make,
|
|
13
13
|
makeDatabaseIdentity,
|
|
14
14
|
runtimeLayer
|
|
15
|
-
} from "./index-
|
|
16
|
-
import"./index-
|
|
15
|
+
} from "./index-96b7htye.js";
|
|
16
|
+
import"./index-c6jave5p.js";
|
|
17
17
|
import"./index-fh2ftte9.js";
|
|
18
18
|
import"./index-nb39b5ae.js";
|
|
19
19
|
|
|
@@ -674,6 +674,14 @@ SET type = 'steering.delivered', id = replace(id, ':received', ':delivered')
|
|
|
674
674
|
WHERE type = 'steering.received';
|
|
675
675
|
`;
|
|
676
676
|
|
|
677
|
+
// ../../migrations/sqlite/0014_session_writer_ownership.sql
|
|
678
|
+
var _0014_session_writer_ownership_default = `ALTER TABLE "relay_sessions" ADD COLUMN "owner_execution_id" TEXT;
|
|
679
|
+
--> statement-breakpoint
|
|
680
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_epoch" INTEGER NOT NULL DEFAULT 0;
|
|
681
|
+
--> statement-breakpoint
|
|
682
|
+
ALTER TABLE "relay_sessions" ADD COLUMN "owner_released" INTEGER NOT NULL DEFAULT 1;
|
|
683
|
+
`;
|
|
684
|
+
|
|
677
685
|
// src/sqlite-migrations.ts
|
|
678
686
|
import { Effect } from "effect";
|
|
679
687
|
import { SqlClient } from "effect/unstable/sql/SqlClient";
|
|
@@ -697,7 +705,8 @@ var migrations = [
|
|
|
697
705
|
{ id: 10, name: "workflow_runtime", file: "0010_workflow_runtime.sql", source: _0010_workflow_runtime_default },
|
|
698
706
|
{ id: 11, name: "execution_scoped_tool_calls", file: "0011_execution_scoped_tool_calls.sql", source: _0011_execution_scoped_tool_calls_default },
|
|
699
707
|
{ id: 12, name: "rename_entity_to_resident", file: "0012_rename_entity_to_resident.sql", source: _0012_rename_entity_to_resident_default },
|
|
700
|
-
{ id: 13, name: "steering_delivered", file: "0013_steering_delivered.sql", source: _0013_steering_delivered_default }
|
|
708
|
+
{ id: 13, name: "steering_delivered", file: "0013_steering_delivered.sql", source: _0013_steering_delivered_default },
|
|
709
|
+
{ id: 14, name: "session_writer_ownership", file: "0014_session_writer_ownership.sql", source: _0014_session_writer_ownership_default }
|
|
701
710
|
];
|
|
702
711
|
var loader = Effect.succeed(migrations.map(({ id, name, source }) => [id, name, Effect.succeed(execute(source))]));
|
|
703
712
|
|