@relayfx/sdk 0.4.2 → 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/http-server.js +1 -1
- package/dist/{index-4y9111jh.js → index-0jx86sx3.js} +1 -1
- package/dist/{index-y9ncz0zd.js → index-96b7htye.js} +893 -712
- package/dist/{index-x32kbvxv.js → index-c6jave5p.js} +989 -958
- package/dist/{index-3w6txjtg.js → index-fh2ftte9.js} +7 -2
- package/dist/index.js +254 -119
- package/dist/migrations/20260721120000_steering_delivered/migration.sql +3 -0
- package/dist/migrations/20260721170000_session_writer_ownership/migration.sql +5 -0
- package/dist/migrations/mysql/0013_steering_delivered.sql +3 -0
- package/dist/migrations/mysql/0014_session_writer_ownership.sql +5 -0
- package/dist/migrations/pg/20260721120000_steering_delivered/migration.sql +3 -0
- package/dist/migrations/pg/20260721170000_session_writer_ownership/migration.sql +5 -0
- package/dist/migrations/sqlite/0013_steering_delivered.sql +3 -0
- package/dist/migrations/sqlite/0014_session_writer_ownership.sql +5 -0
- package/dist/mysql.js +21 -5
- package/dist/postgres.js +10 -6
- package/dist/sqlite.js +21 -5
- package/dist/types/ai/language-model/language-model-registration.d.ts +23 -11
- package/dist/types/relay/client-public-executions.d.ts +2 -2
- 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/operation.d.ts +7 -4
- package/dist/types/relay/sqlite-migrations.d.ts +11 -1
- package/dist/types/relay/tool-worker.d.ts +1 -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/schema/execution-schema.d.ts +8 -3
- package/dist/types/schema/ids-schema.d.ts +4 -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
|
@@ -59,6 +59,7 @@ __export2(exports_ids_schema, {
|
|
|
59
59
|
ToolAttemptId: () => ToolAttemptId,
|
|
60
60
|
TenantId: () => TenantId,
|
|
61
61
|
SystemTenantId: () => SystemTenantId,
|
|
62
|
+
SteeringMessageId: () => SteeringMessageId,
|
|
62
63
|
SnapshotRef: () => SnapshotRef,
|
|
63
64
|
SkillDefinitionId: () => SkillDefinitionId,
|
|
64
65
|
SessionId: () => SessionId,
|
|
@@ -110,6 +111,7 @@ var ToolAttemptId = id("Relay.ToolAttemptId");
|
|
|
110
111
|
var WaitId = id("Relay.WaitId");
|
|
111
112
|
var ScheduleId = id("Relay.ScheduleId");
|
|
112
113
|
var EventId = id("Relay.EventId");
|
|
114
|
+
var SteeringMessageId = id("Relay.SteeringMessageId");
|
|
113
115
|
var exports_shared_schema = {};
|
|
114
116
|
__export2(exports_shared_schema, {
|
|
115
117
|
canonicalValue: () => canonicalValue,
|
|
@@ -517,6 +519,7 @@ __export2(exports_child_orchestration_schema, {
|
|
|
517
519
|
});
|
|
518
520
|
var exports_execution_schema = {};
|
|
519
521
|
__export2(exports_execution_schema, {
|
|
522
|
+
steeringMessageId: () => steeringMessageId,
|
|
520
523
|
childSessionId: () => childSessionId,
|
|
521
524
|
SpawnChildRunInput: () => SpawnChildRunInput,
|
|
522
525
|
ExecutionStatus: () => ExecutionStatus,
|
|
@@ -659,6 +662,7 @@ var ChildRunAccepted = Schema7.Struct({
|
|
|
659
662
|
execution_id: ExecutionId
|
|
660
663
|
}).annotate({ identifier: "Relay.ChildRunAccepted" });
|
|
661
664
|
var childSessionId = (childExecutionId) => SessionId.make(`session:child:${childExecutionId}`);
|
|
665
|
+
var steeringMessageId = (input) => SteeringMessageId.make(`steering:${input.execution_id}:${input.kind}:${input.sequence}`);
|
|
662
666
|
var ExecutionEventType = Schema7.Literals([
|
|
663
667
|
"execution.accepted",
|
|
664
668
|
"execution.started",
|
|
@@ -679,7 +683,7 @@ var ExecutionEventType = Schema7.Literals([
|
|
|
679
683
|
"tool.approval.resolved",
|
|
680
684
|
"permission.ask.requested",
|
|
681
685
|
"permission.ask.resolved",
|
|
682
|
-
"steering.
|
|
686
|
+
"steering.delivered",
|
|
683
687
|
"state.updated",
|
|
684
688
|
"state.deleted",
|
|
685
689
|
"inbox.enqueued",
|
|
@@ -1928,7 +1932,8 @@ var SteerInput = Schema22.Struct({
|
|
|
1928
1932
|
var SteerAccepted = Schema22.Struct({
|
|
1929
1933
|
execution_id: exports_ids_schema.ExecutionId,
|
|
1930
1934
|
kind: SteeringKind,
|
|
1931
|
-
sequence: Schema22.Int.check(Schema22.isGreaterThanOrEqualTo(0))
|
|
1935
|
+
sequence: Schema22.Int.check(Schema22.isGreaterThanOrEqualTo(0)),
|
|
1936
|
+
steering_message_id: exports_ids_schema.SteeringMessageId
|
|
1932
1937
|
}).annotate({ identifier: "Relay.Operation.SteerAccepted" });
|
|
1933
1938
|
var WakeInput = Schema22.Struct({
|
|
1934
1939
|
wait_id: exports_ids_schema.WaitId,
|
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,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
exports_wait_schema,
|
|
47
47
|
exports_workflow_schema,
|
|
48
48
|
followExecutionFrom
|
|
49
|
-
} from "./index-
|
|
49
|
+
} from "./index-fh2ftte9.js";
|
|
50
50
|
import {
|
|
51
51
|
__export
|
|
52
52
|
} from "./index-nb39b5ae.js";
|
|
@@ -144,55 +144,82 @@ var runOnce = Effect2.fn("ToolWorker.runOnce")(function* (options) {
|
|
|
144
144
|
});
|
|
145
145
|
var run = Effect2.fn("ToolWorker.run")(function* (options) {
|
|
146
146
|
const pollInterval = Duration.fromInputUnsafe(options.pollInterval ?? "1 second");
|
|
147
|
-
return yield* runOnce(options).pipe(Effect2.flatMap((worked) => worked ? Effect2.void : Effect2.sleep(pollInterval)), Effect2.forever);
|
|
147
|
+
return yield* runOnce(options).pipe(Effect2.catch((error) => Effect2.logWarning("relay tool worker poll failed", { message: error.message }).pipe(Effect2.as(false))), Effect2.flatMap((worked) => worked ? Effect2.void : Effect2.sleep(pollInterval)), Effect2.forever);
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
// src/language-model-registration.ts
|
|
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,14 +2,14 @@
|
|
|
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-
|
|
12
|
-
import"./index-
|
|
10
|
+
} from "./index-96b7htye.js";
|
|
11
|
+
import"./index-c6jave5p.js";
|
|
12
|
+
import"./index-fh2ftte9.js";
|
|
13
13
|
import"./index-nb39b5ae.js";
|
|
14
14
|
|
|
15
15
|
// src/mysql.ts
|
|
@@ -83,6 +83,20 @@ RENAME TABLE relay_entity_instances TO relay_resident_instances;
|
|
|
83
83
|
ALTER TABLE relay_resident_instances RENAME INDEX idx_relay_entity_instances_kind_status TO idx_relay_resident_instances_kind_status;
|
|
84
84
|
`;
|
|
85
85
|
|
|
86
|
+
// ../../migrations/mysql/0013_steering_delivered.sql
|
|
87
|
+
var _0013_steering_delivered_default = `UPDATE relay_execution_events
|
|
88
|
+
SET type = 'steering.delivered', id = replace(id, ':received', ':delivered')
|
|
89
|
+
WHERE type = 'steering.received';
|
|
90
|
+
`;
|
|
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
|
+
|
|
86
100
|
// src/mysql-migrations.ts
|
|
87
101
|
var migrations = [
|
|
88
102
|
[1, "baseline", _0001_baseline_default],
|
|
@@ -96,7 +110,9 @@ var migrations = [
|
|
|
96
110
|
[9, "workflow_definitions", _0009_workflow_definitions_default],
|
|
97
111
|
[10, "workflow_runtime", _0010_workflow_runtime_default],
|
|
98
112
|
[11, "execution_scoped_tool_calls", _0011_execution_scoped_tool_calls_default],
|
|
99
|
-
[12, "rename_entity_to_resident", _0012_rename_entity_to_resident_default]
|
|
113
|
+
[12, "rename_entity_to_resident", _0012_rename_entity_to_resident_default],
|
|
114
|
+
[13, "steering_delivered", _0013_steering_delivered_default],
|
|
115
|
+
[14, "session_writer_ownership", _0014_session_writer_ownership_default]
|
|
100
116
|
];
|
|
101
117
|
|
|
102
118
|
// src/mysql.ts
|