@relayfx/sdk 0.0.40 → 0.0.41
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 +15416 -0
- package/dist/index.js +526 -215
- package/dist/types/ai/index.d.ts +1 -0
- package/dist/types/relay/ai.d.ts +2 -0
- package/dist/types/relay/client.d.ts +20 -2
- package/dist/types/runtime/tool/tool-runtime-service.d.ts +15 -9
- package/package.json +8 -4
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __require = import.meta.require;
|
|
|
18
18
|
// src/adapter-outbox.ts
|
|
19
19
|
var exports_adapter_outbox = {};
|
|
20
20
|
__export(exports_adapter_outbox, {
|
|
21
|
-
testLayer: () =>
|
|
21
|
+
testLayer: () => testLayer53,
|
|
22
22
|
submitInbound: () => submitInbound,
|
|
23
23
|
release: () => release3,
|
|
24
24
|
layer: () => layer53,
|
|
@@ -32,7 +32,7 @@ import { Context as Context64, Effect as Effect80, Layer as Layer71 } from "effe
|
|
|
32
32
|
var exports_client = {};
|
|
33
33
|
__export(exports_client, {
|
|
34
34
|
wake: () => wake2,
|
|
35
|
-
testLayer: () =>
|
|
35
|
+
testLayer: () => testLayer52,
|
|
36
36
|
submitInboundEnvelope: () => submitInboundEnvelope,
|
|
37
37
|
streamExecution: () => streamExecution,
|
|
38
38
|
steer: () => steer,
|
|
@@ -7223,13 +7223,16 @@ var digestDefinitions = Effect25.fn("ToolInputSchemaDigest.digestDefinitions")(f
|
|
|
7223
7223
|
// ../runtime/src/tool/tool-runtime-service.ts
|
|
7224
7224
|
var exports_tool_runtime_service = {};
|
|
7225
7225
|
__export(exports_tool_runtime_service, {
|
|
7226
|
+
toolsFromToolkit: () => toolsFromToolkit,
|
|
7226
7227
|
toolFromRegistered: () => toolFromRegistered,
|
|
7227
7228
|
tool: () => tool,
|
|
7228
7229
|
testLayer: () => testLayer23,
|
|
7229
7230
|
run: () => run,
|
|
7230
7231
|
registeredTools: () => registeredTools,
|
|
7231
7232
|
register: () => register2,
|
|
7233
|
+
memoryLayerFromToolkit: () => memoryLayerFromToolkit,
|
|
7232
7234
|
memoryLayer: () => memoryLayer23,
|
|
7235
|
+
layerFromToolkit: () => layerFromToolkit,
|
|
7233
7236
|
layer: () => layer23,
|
|
7234
7237
|
dynamicTool: () => dynamicTool,
|
|
7235
7238
|
definitions: () => definitions,
|
|
@@ -7243,7 +7246,7 @@ __export(exports_tool_runtime_service, {
|
|
|
7243
7246
|
Service: () => Service26
|
|
7244
7247
|
});
|
|
7245
7248
|
import { Tool as AiTool } from "effect/unstable/ai";
|
|
7246
|
-
import { Chunk, Context as Context26, Effect as Effect28, HashSet as HashSet3, Layer as Layer26, Option as Option6, Ref as Ref6, Schema as Schema35 } from "effect";
|
|
7249
|
+
import { Chunk, Context as Context26, Effect as Effect28, HashSet as HashSet3, Layer as Layer26, Option as Option6, Ref as Ref6, Schema as Schema35, Sink, Stream as Stream4 } from "effect";
|
|
7247
7250
|
|
|
7248
7251
|
// ../runtime/src/execution/event-log-service.ts
|
|
7249
7252
|
var exports_event_log_service = {};
|
|
@@ -7860,6 +7863,27 @@ var parametersForInputSchema = (inputSchema) => {
|
|
|
7860
7863
|
};
|
|
7861
7864
|
var attachJsonSchema = (tool, jsonSchema) => jsonSchema === undefined ? tool : Object.assign(tool, { jsonSchema });
|
|
7862
7865
|
var toolFromRegistered = (tool) => tool.tool;
|
|
7866
|
+
var isStructFieldMap = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((field) => Schema35.isSchema(field));
|
|
7867
|
+
var parametersSchemaFromEffectTool = (tool) => {
|
|
7868
|
+
const parameters = tool.parametersSchema;
|
|
7869
|
+
if (Schema35.isSchema(parameters))
|
|
7870
|
+
return parameters;
|
|
7871
|
+
if (isStructFieldMap(parameters))
|
|
7872
|
+
return Schema35.Struct(parameters);
|
|
7873
|
+
return Schema35.Unknown;
|
|
7874
|
+
};
|
|
7875
|
+
var jsonSchemaFromEffectToolParameters = (tool) => {
|
|
7876
|
+
const parameters = tool.parametersSchema;
|
|
7877
|
+
if (Schema35.isSchema(parameters))
|
|
7878
|
+
return AiTool.getJsonSchema(tool);
|
|
7879
|
+
if (isStructFieldMap(parameters))
|
|
7880
|
+
return AiTool.getJsonSchemaFromSchema(Schema35.Struct(parameters));
|
|
7881
|
+
return AiTool.getJsonSchema(tool);
|
|
7882
|
+
};
|
|
7883
|
+
var runHandledToolkitTool = (toolkit, name, input) => toolkit.handle(name, input).pipe(Effect28.flatMap((results) => results.pipe(Stream4.filter((item) => item.preliminary === false), Stream4.run(Sink.last()))), Effect28.flatMap(Option6.match({
|
|
7884
|
+
onNone: () => Effect28.fail("Tool handler did not produce a final result"),
|
|
7885
|
+
onSome: (result) => result.isFailure ? Effect28.fail(result.result) : Effect28.succeed(jsonValue(result.encodedResult))
|
|
7886
|
+
})));
|
|
7863
7887
|
var finalToolResult = (tool, input) => Effect28.gen(function* () {
|
|
7864
7888
|
const context = {
|
|
7865
7889
|
executionId: input.executionId,
|
|
@@ -7947,16 +7971,30 @@ var recordRequested = (repository, eventLog, input) => repository.getCall(input.
|
|
|
7947
7971
|
}));
|
|
7948
7972
|
var recordReceived = (repository, eventLog, input, result) => repository.recordResult({ result, createdAt: input.createdAt + 1 }).pipe(Effect28.catchTag("DuplicateToolResult", () => repository.getResult(result.call_id).pipe(Effect28.mapError(mapRepositoryError4), Effect28.flatMap((existing) => existing === undefined ? Effect28.fail(new ToolRuntimeError({ message: "DuplicateToolResult" })) : Effect28.succeed(existing)))), Effect28.mapError(preserveRecordResultError), Effect28.flatMap((record2) => appendIdempotentTo(eventLog, resultEvent(input, record2.result)).pipe(Effect28.mapError(mapEventLogError2), Effect28.as(record2.result))));
|
|
7949
7973
|
var nonEmptyName = (name) => Schema35.decodeUnknownSync(exports_shared_schema.NonEmptyString)(name);
|
|
7974
|
+
var needsApprovalFromEffectTool = (tool) => tool.needsApproval === undefined ? undefined : typeof tool.needsApproval === "boolean" ? tool.needsApproval : true;
|
|
7950
7975
|
var definitionFromEffectTool = (modelTool, options) => ({
|
|
7951
7976
|
name: modelTool.name,
|
|
7952
7977
|
description: AiTool.getDescription(modelTool) ?? "",
|
|
7953
|
-
input_schema: jsonValue(
|
|
7978
|
+
input_schema: jsonValue(jsonSchemaFromEffectToolParameters(modelTool)),
|
|
7954
7979
|
output_schema: jsonValue(AiTool.getJsonSchemaFromSchema(modelTool.successSchema)),
|
|
7955
7980
|
permissions: options.permissions ?? [],
|
|
7956
7981
|
...options.requirements === undefined ? {} : { requirements: options.requirements },
|
|
7957
7982
|
...options.needsApproval === undefined ? {} : { needs_approval: options.needsApproval },
|
|
7958
7983
|
...options.metadata === undefined ? {} : { metadata: options.metadata }
|
|
7959
7984
|
});
|
|
7985
|
+
var toolkitOptionsFor = (tool, options = {}) => typeof options === "function" ? options(tool) : options;
|
|
7986
|
+
var registeredToolFromToolkit = (toolkit, modelTool, options = {}) => {
|
|
7987
|
+
const toolOptions = toolkitOptionsFor(modelTool, options);
|
|
7988
|
+
const needsApproval = toolOptions.needsApproval ?? needsApprovalFromEffectTool(modelTool);
|
|
7989
|
+
return {
|
|
7990
|
+
definition: definitionFromEffectTool(modelTool, { ...toolOptions, needsApproval }),
|
|
7991
|
+
tool: modelTool,
|
|
7992
|
+
...toolOptions.requiredPermissions === undefined ? {} : { requiredPermissions: toolOptions.requiredPermissions },
|
|
7993
|
+
validateInput: (input) => Schema35.decodeUnknownEffect(parametersSchemaFromEffectTool(modelTool))(input).pipe(Effect28.mapError((error) => new ToolInputInvalid({ tool_name: modelTool.name, message: error.message })), Effect28.asVoid),
|
|
7994
|
+
run: (input) => runHandledToolkitTool(toolkit, modelTool.name, input)
|
|
7995
|
+
};
|
|
7996
|
+
};
|
|
7997
|
+
var toolsFromToolkit = (toolkit, options = {}) => Object.values(toolkit.tools).map((modelTool) => registeredToolFromToolkit(toolkit, modelTool, options));
|
|
7960
7998
|
var tool = (name, options) => {
|
|
7961
7999
|
const effectTool = AiTool.make(name, {
|
|
7962
8000
|
description: options.description,
|
|
@@ -7967,7 +8005,6 @@ var tool = (name, options) => {
|
|
|
7967
8005
|
});
|
|
7968
8006
|
const definition = definitionFromEffectTool(effectTool, options);
|
|
7969
8007
|
return {
|
|
7970
|
-
name: nonEmptyName(name),
|
|
7971
8008
|
definition,
|
|
7972
8009
|
tool: effectTool,
|
|
7973
8010
|
...options.requiredPermissions === undefined ? {} : { requiredPermissions: options.requiredPermissions },
|
|
@@ -7984,7 +8021,6 @@ var dynamicTool = (name, options) => {
|
|
|
7984
8021
|
needsApproval: options.needsApproval
|
|
7985
8022
|
}), parameters.jsonSchema);
|
|
7986
8023
|
return {
|
|
7987
|
-
name: nonEmptyName(name),
|
|
7988
8024
|
definition: {
|
|
7989
8025
|
name: nonEmptyName(name),
|
|
7990
8026
|
description: options.description,
|
|
@@ -8000,7 +8036,7 @@ var dynamicTool = (name, options) => {
|
|
|
8000
8036
|
run: options.run
|
|
8001
8037
|
};
|
|
8002
8038
|
};
|
|
8003
|
-
var
|
|
8039
|
+
var makeService = (initialTools) => Effect28.gen(function* () {
|
|
8004
8040
|
const repository = yield* exports_tool_call_repository.Service;
|
|
8005
8041
|
const eventLog = yield* Service24;
|
|
8006
8042
|
const waits = yield* Service25;
|
|
@@ -8048,8 +8084,14 @@ var layer23 = (initialTools = []) => Layer26.effect(Service26, Effect28.gen(func
|
|
|
8048
8084
|
}).pipe(Effect28.tapError((error) => recordToolCall(input.call.name, error._tag === "ToolExecutionWaitRequested" ? "wait" : error._tag === "ToolPermissionDenied" ? "denied" : "failure")));
|
|
8049
8085
|
})
|
|
8050
8086
|
});
|
|
8087
|
+
});
|
|
8088
|
+
var layer23 = (initialTools = []) => Layer26.effect(Service26, makeService(initialTools));
|
|
8089
|
+
var layerFromToolkit = (toolkit, options = {}) => Layer26.effect(Service26, Effect28.gen(function* () {
|
|
8090
|
+
const handled = yield* toolkit;
|
|
8091
|
+
return yield* makeService(toolsFromToolkit(handled, options));
|
|
8051
8092
|
}));
|
|
8052
8093
|
var memoryLayer23 = (tools = []) => layer23(tools).pipe(Layer26.provide(layer22), Layer26.provide(exports_tool_call_repository.memoryLayer), Layer26.provide(exports_envelope_repository.memoryLayer), Layer26.provide(exports_schedule_repository.memoryLayer), Layer26.provide(memoryLayer21));
|
|
8094
|
+
var memoryLayerFromToolkit = (toolkit, options = {}) => layerFromToolkit(toolkit, options).pipe(Layer26.provide(layer22), Layer26.provide(exports_tool_call_repository.memoryLayer), Layer26.provide(exports_envelope_repository.memoryLayer), Layer26.provide(exports_schedule_repository.memoryLayer), Layer26.provide(memoryLayer21));
|
|
8053
8095
|
var testLayer23 = (implementation) => Layer26.succeed(Service26, Service26.of(implementation));
|
|
8054
8096
|
var register2 = Effect28.fn("ToolRuntime.register.call")(function* (registeredTool) {
|
|
8055
8097
|
const service = yield* Service26;
|
|
@@ -8318,7 +8360,7 @@ var resolveLocalAgent = Effect30.fn("AddressResolution.resolveLocalAgent.call")(
|
|
|
8318
8360
|
var exports_agent_loop_service = {};
|
|
8319
8361
|
__export(exports_agent_loop_service, {
|
|
8320
8362
|
toolFromDefinition: () => toolFromDefinition,
|
|
8321
|
-
testLayer: () =>
|
|
8363
|
+
testLayer: () => testLayer46,
|
|
8322
8364
|
run: () => run3,
|
|
8323
8365
|
mapBoundaryError: () => mapBoundaryError,
|
|
8324
8366
|
layer: () => layer44,
|
|
@@ -8329,7 +8371,7 @@ __export(exports_agent_loop_service, {
|
|
|
8329
8371
|
AgentLoopBudgetExceeded: () => AgentLoopBudgetExceeded
|
|
8330
8372
|
});
|
|
8331
8373
|
|
|
8332
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8374
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/agent.ts
|
|
8333
8375
|
var exports_agent = {};
|
|
8334
8376
|
__export(exports_agent, {
|
|
8335
8377
|
streamObject: () => streamObject,
|
|
@@ -8339,10 +8381,10 @@ __export(exports_agent, {
|
|
|
8339
8381
|
generate: () => generate,
|
|
8340
8382
|
defaultObjectPrompt: () => defaultObjectPrompt
|
|
8341
8383
|
});
|
|
8342
|
-
import { Cause as Cause3, Effect as Effect45, Fiber, Option as Option15, Queue as Queue2, Ref as Ref10, Schema as Schema45, Stream as
|
|
8343
|
-
import { Chat, LanguageModel as LanguageModel3, Prompt as Prompt4, Response as Response3, Telemetry, Tokenizer as Tokenizer2, Tool as Tool4, Toolkit as
|
|
8384
|
+
import { Cause as Cause3, Effect as Effect45, Fiber, Option as Option15, Queue as Queue2, Ref as Ref10, Schema as Schema45, Stream as Stream7 } from "effect";
|
|
8385
|
+
import { Chat, LanguageModel as LanguageModel3, Prompt as Prompt4, Response as Response3, Telemetry, Tokenizer as Tokenizer2, Tool as Tool4, Toolkit as Toolkit3 } from "effect/unstable/ai";
|
|
8344
8386
|
|
|
8345
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8387
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/agent-event.ts
|
|
8346
8388
|
var exports_agent_event = {};
|
|
8347
8389
|
__export(exports_agent_event, {
|
|
8348
8390
|
addUsage: () => addUsage,
|
|
@@ -8399,7 +8441,7 @@ class AgentSuspended extends Schema38.TaggedErrorClass()("@batonfx/core/AgentSus
|
|
|
8399
8441
|
}) {
|
|
8400
8442
|
}
|
|
8401
8443
|
|
|
8402
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8444
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/approvals.ts
|
|
8403
8445
|
var exports_approvals = {};
|
|
8404
8446
|
__export(exports_approvals, {
|
|
8405
8447
|
testLayer: () => testLayer26,
|
|
@@ -8415,7 +8457,7 @@ var autoApprove = Layer29.succeed(Approvals, Approvals.of({ check: () => Effect3
|
|
|
8415
8457
|
var denyAll = Layer29.succeed(Approvals, Approvals.of({ check: () => Effect31.succeed({ _tag: "Denied" }) }));
|
|
8416
8458
|
var testLayer26 = (implementation) => Layer29.succeed(Approvals, Approvals.of(implementation));
|
|
8417
8459
|
|
|
8418
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8460
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/compaction.ts
|
|
8419
8461
|
var exports_compaction = {};
|
|
8420
8462
|
__export(exports_compaction, {
|
|
8421
8463
|
truncate: () => truncate,
|
|
@@ -8431,9 +8473,9 @@ __export(exports_compaction, {
|
|
|
8431
8473
|
Compaction: () => Compaction
|
|
8432
8474
|
});
|
|
8433
8475
|
import { Context as Context32, Effect as Effect34, Layer as Layer32, Option as Option10, Schema as Schema41 } from "effect";
|
|
8434
|
-
import { LanguageModel, Prompt as Prompt3, Tokenizer, Toolkit } from "effect/unstable/ai";
|
|
8476
|
+
import { LanguageModel, Prompt as Prompt3, Tokenizer, Toolkit as Toolkit2 } from "effect/unstable/ai";
|
|
8435
8477
|
|
|
8436
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8478
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/session.ts
|
|
8437
8479
|
var exports_session = {};
|
|
8438
8480
|
__export(exports_session, {
|
|
8439
8481
|
testLayer: () => testLayer27,
|
|
@@ -8565,7 +8607,7 @@ var memoryLayer24 = Layer30.effect(SessionStore, Ref7.make(initialState).pipe(Ef
|
|
|
8565
8607
|
}))));
|
|
8566
8608
|
var testLayer27 = (implementation) => Layer30.succeed(SessionStore, SessionStore.of(implementation));
|
|
8567
8609
|
|
|
8568
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8610
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/tool-output.ts
|
|
8569
8611
|
var exports_tool_output = {};
|
|
8570
8612
|
__export(exports_tool_output, {
|
|
8571
8613
|
testLayer: () => testLayer28,
|
|
@@ -8625,7 +8667,7 @@ var bound = (result, options) => Effect33.gen(function* () {
|
|
|
8625
8667
|
return { _tag: "Success", result: output, encodedResult: output };
|
|
8626
8668
|
});
|
|
8627
8669
|
|
|
8628
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8670
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/compaction.ts
|
|
8629
8671
|
var DEFAULT_RESERVE_TOKENS = 16384;
|
|
8630
8672
|
var DEFAULT_KEEP_RECENT_TOKENS = 20000;
|
|
8631
8673
|
var SUMMARY_TEMPLATE = `Summarize the conversation so another agent can continue seamlessly.
|
|
@@ -8755,7 +8797,7 @@ var defaultStrategy = (options = {}) => ({
|
|
|
8755
8797
|
const [compactedHead] = request.toolOutputMaxBytes === undefined ? [head, false] : yield* microcompactPrompt(head, request.toolOutputMaxBytes);
|
|
8756
8798
|
const prompt = summaryPrompt(options.summaryPrompt ?? SUMMARY_TEMPLATE, compactedHead);
|
|
8757
8799
|
const model = yield* LanguageModel.LanguageModel;
|
|
8758
|
-
return yield* model.generateText({ prompt, toolkit:
|
|
8800
|
+
return yield* model.generateText({ prompt, toolkit: Toolkit2.empty, toolChoice: "none" }).pipe(Effect34.map((response) => response.text), Effect34.mapError((error) => new CompactionError({ message: String(error), cause: error })));
|
|
8759
8801
|
});
|
|
8760
8802
|
return options.summaryModel === undefined ? effect : effect.pipe(Effect34.provide(options.summaryModel));
|
|
8761
8803
|
}
|
|
@@ -8808,7 +8850,7 @@ var truncate = (maxTokens) => ({
|
|
|
8808
8850
|
var testLayer29 = (implementation) => Layer32.succeed(Compaction, Compaction.of(implementation));
|
|
8809
8851
|
var isContextOverflow = (error) => /context|token|prompt/i.test(error instanceof Error ? `${error.name}: ${error.message}` : String(error)) && /overflow|exceed|exceeded|maximum|too large|too long|length/i.test(error instanceof Error ? `${error.name}: ${error.message}` : String(error));
|
|
8810
8852
|
|
|
8811
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8853
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/instructions.ts
|
|
8812
8854
|
var exports_instructions = {};
|
|
8813
8855
|
__export(exports_instructions, {
|
|
8814
8856
|
testLayer: () => testLayer30,
|
|
@@ -8857,7 +8899,7 @@ var renderUpdate = (epoch, context) => Effect35.gen(function* () {
|
|
|
8857
8899
|
var layer27 = (sources) => Layer33.succeed(Instructions, Instructions.of({ sources: [...sources] }));
|
|
8858
8900
|
var testLayer30 = (implementation) => Layer33.succeed(Instructions, Instructions.of(implementation));
|
|
8859
8901
|
|
|
8860
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8902
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/memory.ts
|
|
8861
8903
|
var exports_memory = {};
|
|
8862
8904
|
__export(exports_memory, {
|
|
8863
8905
|
testLayer: () => testLayer31,
|
|
@@ -8886,7 +8928,7 @@ var merge = (first, second) => ({
|
|
|
8886
8928
|
var noopLayer = Layer34.succeed(Memory, Memory.of(noop));
|
|
8887
8929
|
var testLayer31 = (implementation) => Layer34.succeed(Memory, Memory.of(implementation));
|
|
8888
8930
|
|
|
8889
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8931
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/model-middleware.ts
|
|
8890
8932
|
var exports_model_middleware = {};
|
|
8891
8933
|
__export(exports_model_middleware, {
|
|
8892
8934
|
layer: () => layer28,
|
|
@@ -8900,7 +8942,7 @@ class ModelMiddleware extends Context35.Service()("@batonfx/core/ModelMiddleware
|
|
|
8900
8942
|
var identityLayer = Layer35.succeed(ModelMiddleware, []);
|
|
8901
8943
|
var layer28 = (middleware) => Layer35.succeed(ModelMiddleware, middleware);
|
|
8902
8944
|
|
|
8903
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8945
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/model-resilience.ts
|
|
8904
8946
|
var exports_model_resilience = {};
|
|
8905
8947
|
__export(exports_model_resilience, {
|
|
8906
8948
|
testLayer: () => testLayer32,
|
|
@@ -8911,7 +8953,7 @@ __export(exports_model_resilience, {
|
|
|
8911
8953
|
apply: () => apply,
|
|
8912
8954
|
ModelResilience: () => ModelResilience
|
|
8913
8955
|
});
|
|
8914
|
-
import { Cause, Context as Context36, Effect as Effect38, Layer as Layer36, Schedule as Schedule2, Stream as
|
|
8956
|
+
import { Cause, Context as Context36, Effect as Effect38, Layer as Layer36, Schedule as Schedule2, Stream as Stream5 } from "effect";
|
|
8915
8957
|
import { AiError, Response as Response2 } from "effect/unstable/ai";
|
|
8916
8958
|
|
|
8917
8959
|
class ModelResilience extends Context36.Service()("@batonfx/core/ModelResilience") {
|
|
@@ -8933,20 +8975,20 @@ var apply = (model, resilience) => ({
|
|
|
8933
8975
|
...model,
|
|
8934
8976
|
generateText: (options) => retryEffect(() => model.generateText(options), resilience),
|
|
8935
8977
|
generateObject: (options) => retryEffect(() => model.generateObject(options), resilience),
|
|
8936
|
-
streamText: (options) =>
|
|
8978
|
+
streamText: (options) => Stream5.suspend(() => {
|
|
8937
8979
|
let emitted = false;
|
|
8938
|
-
return model.streamText(options).pipe(
|
|
8980
|
+
return model.streamText(options).pipe(Stream5.tap(() => Effect38.sync(() => {
|
|
8939
8981
|
emitted = true;
|
|
8940
|
-
})),
|
|
8982
|
+
})), Stream5.catchCause((cause) => {
|
|
8941
8983
|
if (Cause.hasInterrupts(cause))
|
|
8942
|
-
return
|
|
8984
|
+
return Stream5.failCause(cause);
|
|
8943
8985
|
const error = Cause.squash(cause);
|
|
8944
|
-
return emitted ?
|
|
8986
|
+
return emitted ? Stream5.make(Response2.makePart("error", { error })) : Stream5.failCause(cause);
|
|
8945
8987
|
}));
|
|
8946
|
-
}).pipe(
|
|
8988
|
+
}).pipe(Stream5.retry(retryStreamSchedule(resilience)))
|
|
8947
8989
|
});
|
|
8948
8990
|
|
|
8949
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
8991
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/permissions.ts
|
|
8950
8992
|
var exports_permissions = {};
|
|
8951
8993
|
__export(exports_permissions, {
|
|
8952
8994
|
testLayer: () => testLayer33,
|
|
@@ -9076,7 +9118,7 @@ var ruleStoreMemory = (initialRules = []) => Layer37.effect(RuleStore, Ref9.make
|
|
|
9076
9118
|
var ruleStoreTestLayer = (implementation) => Layer37.succeed(RuleStore, RuleStore.of(implementation));
|
|
9077
9119
|
var testLayer33 = (implementation) => Layer37.succeed(Permissions, Permissions.of(implementation));
|
|
9078
9120
|
|
|
9079
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
9121
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/skill-source.ts
|
|
9080
9122
|
var exports_skill_source = {};
|
|
9081
9123
|
__export(exports_skill_source, {
|
|
9082
9124
|
testLayer: () => testLayer34,
|
|
@@ -9134,7 +9176,7 @@ var selectListings = (skills, budgetTokens, recentlyUsed) => {
|
|
|
9134
9176
|
return selected;
|
|
9135
9177
|
};
|
|
9136
9178
|
|
|
9137
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
9179
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/steering.ts
|
|
9138
9180
|
var exports_steering = {};
|
|
9139
9181
|
__export(exports_steering, {
|
|
9140
9182
|
testLayer: () => testLayer35,
|
|
@@ -9164,7 +9206,13 @@ var layer30 = (options = {}) => Layer39.effect(Steering, Effect41.gen(function*
|
|
|
9164
9206
|
}));
|
|
9165
9207
|
var testLayer35 = (implementation) => Layer39.succeed(Steering, Steering.of(implementation));
|
|
9166
9208
|
|
|
9167
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
9209
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/tool-context.ts
|
|
9210
|
+
var exports_tool_context = {};
|
|
9211
|
+
__export(exports_tool_context, {
|
|
9212
|
+
testLayer: () => testLayer36,
|
|
9213
|
+
layerDefault: () => layerDefault,
|
|
9214
|
+
ToolContext: () => ToolContext
|
|
9215
|
+
});
|
|
9168
9216
|
import { Context as Context40, Effect as Effect42, Layer as Layer40 } from "effect";
|
|
9169
9217
|
|
|
9170
9218
|
class ToolContext extends Context40.Service()("@batonfx/core/ToolContext") {
|
|
@@ -9174,16 +9222,20 @@ var layerDefault = Layer40.sync(ToolContext, () => ToolContext.of({
|
|
|
9174
9222
|
emit: () => Effect42.void,
|
|
9175
9223
|
sessionId: "local"
|
|
9176
9224
|
}));
|
|
9225
|
+
var testLayer36 = (implementation) => Layer40.succeed(ToolContext, ToolContext.of(implementation));
|
|
9177
9226
|
|
|
9178
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
9227
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/tool-executor.ts
|
|
9179
9228
|
var exports_tool_executor = {};
|
|
9180
9229
|
__export(exports_tool_executor, {
|
|
9181
|
-
testLayer: () =>
|
|
9230
|
+
testLayer: () => testLayer37,
|
|
9231
|
+
router: () => router,
|
|
9232
|
+
routeToolkit: () => routeToolkit,
|
|
9233
|
+
route: () => route,
|
|
9182
9234
|
fromToolkit: () => fromToolkit,
|
|
9183
9235
|
executeToolkit: () => executeToolkit,
|
|
9184
9236
|
ToolExecutor: () => ToolExecutor
|
|
9185
9237
|
});
|
|
9186
|
-
import { Cause as Cause2, Context as Context41, Effect as Effect43, Layer as Layer41, Option as Option14, Sink, Stream as
|
|
9238
|
+
import { Cause as Cause2, Context as Context41, Effect as Effect43, Layer as Layer41, Option as Option14, Sink as Sink2, Stream as Stream6 } from "effect";
|
|
9187
9239
|
class ToolExecutor extends Context41.Service()("@batonfx/core/ToolExecutor") {
|
|
9188
9240
|
}
|
|
9189
9241
|
var failureMessage = (cause) => {
|
|
@@ -9207,7 +9259,7 @@ var executeWithToolkit = (toolkit, request) => {
|
|
|
9207
9259
|
if (toolkit.tools[request.call.name] === undefined) {
|
|
9208
9260
|
return Effect43.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
|
|
9209
9261
|
}
|
|
9210
|
-
return toolkit.handle(request.call.name, request.call.params).pipe(Effect43.flatMap((results) => results.pipe(
|
|
9262
|
+
return toolkit.handle(request.call.name, request.call.params).pipe(Effect43.flatMap((results) => results.pipe(Stream6.filter((item) => item.preliminary === false), Stream6.run(Sink2.last()))), Effect43.map(Option14.match({
|
|
9211
9263
|
onNone: () => failureOutcome("Tool handler did not produce a final result"),
|
|
9212
9264
|
onSome: (result) => result.isFailure ? failureOutcome(resultMessage(result.result)) : {
|
|
9213
9265
|
_tag: "Success",
|
|
@@ -9232,9 +9284,31 @@ function fromToolkit(toolkit) {
|
|
|
9232
9284
|
execute: (request) => executeWithToolkit(handled, request)
|
|
9233
9285
|
}))));
|
|
9234
9286
|
}
|
|
9235
|
-
var
|
|
9287
|
+
var route = (options) => {
|
|
9288
|
+
const routedTools = options.tools ?? [];
|
|
9289
|
+
return {
|
|
9290
|
+
tools: routedTools,
|
|
9291
|
+
matches: (request) => routedTools.includes(request.call.name) || options.matches?.(request) === true,
|
|
9292
|
+
execute: options.execute
|
|
9293
|
+
};
|
|
9294
|
+
};
|
|
9295
|
+
function routeToolkit(toolkit) {
|
|
9296
|
+
const makeRoute = (handled) => route({
|
|
9297
|
+
tools: Object.keys(handled.tools),
|
|
9298
|
+
execute: (request) => executeWithToolkit(handled, request)
|
|
9299
|
+
});
|
|
9300
|
+
return "handle" in toolkit ? makeRoute(toolkit) : toolkit.pipe(Effect43.map(makeRoute));
|
|
9301
|
+
}
|
|
9302
|
+
var routeInputEffect = (input) => Effect43.isEffect(input) ? input : Effect43.succeed(input);
|
|
9303
|
+
var router = (routes) => Layer41.effect(ToolExecutor, Effect43.all(Array.from(routes, routeInputEffect)).pipe(Effect43.map((resolved) => ToolExecutor.of({
|
|
9304
|
+
execute: (request) => {
|
|
9305
|
+
const matched = resolved.find((candidate) => candidate.matches(request));
|
|
9306
|
+
return matched === undefined ? Effect43.succeed(failureOutcome(`Tool ${request.call.name} is not registered`)) : matched.execute(request);
|
|
9307
|
+
}
|
|
9308
|
+
}))));
|
|
9309
|
+
var testLayer37 = (implementation) => Layer41.succeed(ToolExecutor, ToolExecutor.of(implementation));
|
|
9236
9310
|
|
|
9237
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
9311
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/turn-policy.ts
|
|
9238
9312
|
var exports_turn_policy = {};
|
|
9239
9313
|
__export(exports_turn_policy, {
|
|
9240
9314
|
untilToolCall: () => untilToolCall,
|
|
@@ -9273,13 +9347,13 @@ var both = (first, second) => make4((info) => Effect44.gen(function* () {
|
|
|
9273
9347
|
}));
|
|
9274
9348
|
var defaultPolicy = recurs(8);
|
|
9275
9349
|
|
|
9276
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
9350
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/agent.ts
|
|
9277
9351
|
function make5(nameOrOptions, options = {}) {
|
|
9278
9352
|
const resolved = typeof nameOrOptions === "string" ? { ...options, name: nameOrOptions } : nameOrOptions;
|
|
9279
9353
|
return {
|
|
9280
9354
|
name: resolved.name,
|
|
9281
9355
|
...resolved.instructions === undefined ? {} : { instructions: resolved.instructions },
|
|
9282
|
-
toolkit: resolved.toolkit ??
|
|
9356
|
+
toolkit: resolved.toolkit ?? Toolkit3.empty,
|
|
9283
9357
|
policy: resolved.policy ?? defaultPolicy
|
|
9284
9358
|
};
|
|
9285
9359
|
}
|
|
@@ -9368,7 +9442,7 @@ var applyPartChain = (chain, part, context) => Effect45.gen(function* () {
|
|
|
9368
9442
|
}
|
|
9369
9443
|
return current2;
|
|
9370
9444
|
});
|
|
9371
|
-
var streamInternal = (agent, options, structured) =>
|
|
9445
|
+
var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen(function* () {
|
|
9372
9446
|
const executor = yield* Effect45.serviceOption(ToolExecutor);
|
|
9373
9447
|
const approvals = yield* Effect45.serviceOption(Approvals);
|
|
9374
9448
|
const chain = yield* Effect45.serviceOption(ModelMiddleware).pipe(Effect45.map(Option15.match({ onNone: () => [], onSome: (service) => service })));
|
|
@@ -9435,7 +9509,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9435
9509
|
const freshChat = options.history !== undefined ? Chat.fromPrompt(options.history) : system !== undefined ? Chat.fromPrompt([Prompt4.makeMessage("system", { content: system })]) : Chat.empty;
|
|
9436
9510
|
const chat = persisted ?? (yield* freshChat);
|
|
9437
9511
|
const savePersisted = persisted === undefined ? Effect45.void : persisted.save.pipe(Effect45.mapError((error) => new AgentError({ message: errorMessage(error), turn: 0, cause: error })));
|
|
9438
|
-
const failSuspended = (call, token, reason) =>
|
|
9512
|
+
const failSuspended = (call, token, reason) => Stream7.unwrap(savePersisted.pipe(Effect45.as(Stream7.fail(suspended(call, token, reason)))));
|
|
9439
9513
|
const state = {
|
|
9440
9514
|
text: "",
|
|
9441
9515
|
turn: 0,
|
|
@@ -9545,12 +9619,12 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9545
9619
|
case "Success":
|
|
9546
9620
|
return (isSkillActivationCall(call) ? Effect45.succeed(successResult(call, outcome)) : boundedSuccessResult(turn, call, outcome)).pipe(Effect45.map((result) => {
|
|
9547
9621
|
state.pending.push(result);
|
|
9548
|
-
return
|
|
9622
|
+
return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
|
|
9549
9623
|
}));
|
|
9550
9624
|
case "Failure": {
|
|
9551
9625
|
const result = failedResult(call, outcome.message);
|
|
9552
9626
|
state.pending.push(result);
|
|
9553
|
-
return Effect45.succeed(
|
|
9627
|
+
return Effect45.succeed(Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]));
|
|
9554
9628
|
}
|
|
9555
9629
|
case "Suspend":
|
|
9556
9630
|
return Effect45.succeed(failSuspended(call, outcome.token, "tool-wait"));
|
|
@@ -9561,9 +9635,9 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9561
9635
|
return executeToolkit(agent.toolkit, request);
|
|
9562
9636
|
}
|
|
9563
9637
|
const activated = activatedSkillTools.get(request.call.name);
|
|
9564
|
-
return activated === undefined ? Effect45.succeed({ _tag: "Failure", message: `Tool ${request.call.name} is not registered` }) : executeToolkit(
|
|
9638
|
+
return activated === undefined ? Effect45.succeed({ _tag: "Failure", message: `Tool ${request.call.name} is not registered` }) : executeToolkit(Toolkit3.make(activated), request);
|
|
9565
9639
|
};
|
|
9566
|
-
const executeApproved = (turn, call, request) =>
|
|
9640
|
+
const executeApproved = (turn, call, request) => Stream7.concat(Stream7.fromIterable([{ _tag: "ToolExecutionStarted", turn, call }]), Stream7.unwrap(Effect45.gen(function* () {
|
|
9567
9641
|
const progressQueue = yield* Queue2.unbounded();
|
|
9568
9642
|
const signal = yield* Effect45.abortSignal;
|
|
9569
9643
|
const context = ToolContext.of({
|
|
@@ -9585,13 +9659,13 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9585
9659
|
onSome: (service) => service.execute(request)
|
|
9586
9660
|
});
|
|
9587
9661
|
const fiber = yield* execution.pipe(Effect45.provideService(ToolContext, context), Effect45.ensuring(Queue2.end(progressQueue).pipe(Effect45.asVoid)), Effect45.forkScoped({ startImmediately: true }));
|
|
9588
|
-
return
|
|
9662
|
+
return Stream7.concat(Stream7.fromQueue(progressQueue), Stream7.fromEffect(Fiber.join(fiber)).pipe(Stream7.flatMap((outcome) => Stream7.unwrap(outcomeEvents(turn, call, outcome)))));
|
|
9589
9663
|
})));
|
|
9590
9664
|
const permissionError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
|
|
9591
9665
|
const permissionDeniedEvents = (turn, call, reason) => {
|
|
9592
9666
|
const result = failedResult(call, reason ?? "Permission denied");
|
|
9593
9667
|
state.pending.push(result);
|
|
9594
|
-
return
|
|
9668
|
+
return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
|
|
9595
9669
|
};
|
|
9596
9670
|
const activateSkillOutcome = (turn, call) => Effect45.gen(function* () {
|
|
9597
9671
|
if (skillRuntime === undefined)
|
|
@@ -9624,25 +9698,25 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9624
9698
|
onNone: () => Effect45.void,
|
|
9625
9699
|
onSome: (store) => store.remember({ pattern: call.name, level: "allow" }).pipe(Effect45.mapError((error) => permissionError(turn, error)))
|
|
9626
9700
|
})));
|
|
9627
|
-
const approvalEvents = (turn, call, messages, request, tool2) =>
|
|
9701
|
+
const approvalEvents = (turn, call, messages, request, tool2) => Stream7.unwrap(approvalRequired(tool2, call, messages).pipe(Effect45.map((isRequired) => {
|
|
9628
9702
|
if (!isRequired)
|
|
9629
9703
|
return executeApproved(turn, call, request);
|
|
9630
9704
|
if (Option15.isNone(approvals)) {
|
|
9631
9705
|
const result = failedResult(call, "Approvals service is required for approval-gated tools");
|
|
9632
9706
|
state.pending.push(result);
|
|
9633
|
-
return
|
|
9707
|
+
return Stream7.fromIterable([
|
|
9634
9708
|
{ _tag: "ApprovalRequested", turn, call },
|
|
9635
9709
|
{ _tag: "ToolExecutionCompleted", turn, call, result }
|
|
9636
9710
|
]);
|
|
9637
9711
|
}
|
|
9638
|
-
return
|
|
9712
|
+
return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(approvals.value.check(request).pipe(Effect45.map((decision2) => {
|
|
9639
9713
|
switch (decision2._tag) {
|
|
9640
9714
|
case "Approved":
|
|
9641
9715
|
return executeApproved(turn, call, request);
|
|
9642
9716
|
case "Denied": {
|
|
9643
9717
|
const result = failedResult(call, decision2.reason ?? "Tool call denied");
|
|
9644
9718
|
state.pending.push(result);
|
|
9645
|
-
return
|
|
9719
|
+
return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
|
|
9646
9720
|
}
|
|
9647
9721
|
case "Pending":
|
|
9648
9722
|
return failSuspended(call, decision2.token, "approval");
|
|
@@ -9656,7 +9730,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9656
9730
|
case "Denied":
|
|
9657
9731
|
return permissionDeniedEvents(turn, call, answer.reason);
|
|
9658
9732
|
case "Always":
|
|
9659
|
-
return
|
|
9733
|
+
return Stream7.unwrap(rememberAlways(turn, call).pipe(Effect45.as(executeApproved(turn, call, request))));
|
|
9660
9734
|
}
|
|
9661
9735
|
};
|
|
9662
9736
|
const permissionAskEvents = (turn, call, request, token) => {
|
|
@@ -9670,7 +9744,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9670
9744
|
};
|
|
9671
9745
|
if (Option15.isNone(permissionsService))
|
|
9672
9746
|
return failSuspended(call, token, "approval");
|
|
9673
|
-
return
|
|
9747
|
+
return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(permissionsService.value.await(pending).pipe(Effect45.mapError((error) => permissionError(turn, error)), Effect45.map(Option15.match({
|
|
9674
9748
|
onNone: () => failSuspended(call, token, "approval"),
|
|
9675
9749
|
onSome: (answer) => permissionAnsweredEvents(turn, call, request, answer)
|
|
9676
9750
|
})))));
|
|
@@ -9680,7 +9754,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9680
9754
|
const tool2 = currentToolkit().tools[call.name];
|
|
9681
9755
|
if (Option15.isNone(permissionsService))
|
|
9682
9756
|
return approvalEvents(turn, call, messages, request, tool2);
|
|
9683
|
-
return
|
|
9757
|
+
return Stream7.unwrap(permissionsService.value.evaluate({
|
|
9684
9758
|
tool: call.name,
|
|
9685
9759
|
params: call.params,
|
|
9686
9760
|
agentName: agent.name,
|
|
@@ -9728,57 +9802,57 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9728
9802
|
});
|
|
9729
9803
|
const partEvents = (turn, part, messages) => {
|
|
9730
9804
|
if (part.type === "error") {
|
|
9731
|
-
return
|
|
9805
|
+
return Stream7.fail(new AgentError({ message: errorMessage(part.error), turn, cause: part.error }));
|
|
9732
9806
|
}
|
|
9733
|
-
const modelPart =
|
|
9807
|
+
const modelPart = Stream7.fromIterable([{ _tag: "ModelPart", turn, part }]);
|
|
9734
9808
|
if (part.type === "tool-call") {
|
|
9735
9809
|
const call = part;
|
|
9736
|
-
return call.providerExecuted === true ? modelPart :
|
|
9810
|
+
return call.providerExecuted === true ? modelPart : Stream7.concat(modelPart, toolCallEvents(turn, call, messages));
|
|
9737
9811
|
}
|
|
9738
9812
|
if (part.type === "text-delta") {
|
|
9739
9813
|
state.text = `${state.text}${part.delta}`;
|
|
9740
9814
|
}
|
|
9741
9815
|
if (part.type === "finish") {
|
|
9742
|
-
return modelPart.pipe(
|
|
9816
|
+
return modelPart.pipe(Stream7.tap(() => captureFinishPart(part)));
|
|
9743
9817
|
}
|
|
9744
9818
|
return modelPart;
|
|
9745
9819
|
};
|
|
9746
|
-
const applyPartToEvents = (turn, part, messages) =>
|
|
9820
|
+
const applyPartToEvents = (turn, part, messages) => Stream7.unwrap(applyPartChain(chain, part, { agentName: agent.name, turn }).pipe(Effect45.map(Option15.match({
|
|
9747
9821
|
onSome: (transformed) => partEvents(turn, transformed, messages),
|
|
9748
|
-
onNone: () => part.type === "tool-call" ?
|
|
9822
|
+
onNone: () => part.type === "tool-call" ? Stream7.fail(new MiddlewareViolation({
|
|
9749
9823
|
turn,
|
|
9750
9824
|
detail: "ModelMiddleware dropped a tool-call part"
|
|
9751
|
-
})) :
|
|
9825
|
+
})) : Stream7.empty
|
|
9752
9826
|
}))));
|
|
9753
|
-
const currentToolkit = () =>
|
|
9754
|
-
const activeToolkit = (activeTools) =>
|
|
9827
|
+
const currentToolkit = () => Toolkit3.make(...Object.values(agent.toolkit.tools), ...hasActivatableSkills ? [activateSkillTool] : [], ...activatedSkillTools.values());
|
|
9828
|
+
const activeToolkit = (activeTools) => Toolkit3.make(...Object.values(currentToolkit().tools).filter((tool2) => activeTools.includes(tool2.name)));
|
|
9755
9829
|
const modelTurn = (turn, prompt, overrides) => {
|
|
9756
9830
|
const toolkit = overrides?.activeTools === undefined ? currentToolkit() : activeToolkit(overrides.activeTools);
|
|
9757
|
-
const attempt = (activePrompt, retryOverflow) =>
|
|
9831
|
+
const attempt = (activePrompt, retryOverflow) => Stream7.unwrap(Ref10.get(chat.history).pipe(Effect45.map((historyBeforeAttempt) => {
|
|
9758
9832
|
let emitted = false;
|
|
9759
9833
|
const messages = Prompt4.concat(historyBeforeAttempt, activePrompt).content;
|
|
9760
|
-
return chat.streamText({ prompt: activePrompt, toolkit, disableToolCallResolution: true }).pipe(
|
|
9834
|
+
return chat.streamText({ prompt: activePrompt, toolkit, disableToolCallResolution: true }).pipe(Stream7.map((part) => ({ part, messages })), Stream7.tap(() => Effect45.sync(() => {
|
|
9761
9835
|
emitted = true;
|
|
9762
|
-
})),
|
|
9836
|
+
})), Stream7.catchCause((cause) => {
|
|
9763
9837
|
if (Cause3.hasInterrupts(cause))
|
|
9764
|
-
return
|
|
9838
|
+
return Stream7.fromEffect(Effect45.interrupt);
|
|
9765
9839
|
const error = Cause3.squash(cause);
|
|
9766
9840
|
if (retryOverflow && !emitted && isContextOverflow(error) && Option15.isSome(compactionService)) {
|
|
9767
|
-
return
|
|
9841
|
+
return Stream7.unwrap(Effect45.gen(function* () {
|
|
9768
9842
|
yield* Ref10.set(chat.history, historyBeforeAttempt);
|
|
9769
9843
|
const compactedPrompt = yield* preparePrompt(turn, activePrompt, true);
|
|
9770
9844
|
return attempt(compactedPrompt, false);
|
|
9771
9845
|
}));
|
|
9772
9846
|
}
|
|
9773
|
-
return
|
|
9847
|
+
return Stream7.make({ part: Response3.makePart("error", { error }), messages });
|
|
9774
9848
|
}));
|
|
9775
9849
|
})));
|
|
9776
|
-
const parts =
|
|
9850
|
+
const parts = Stream7.unwrap(applyPromptChain(chain, Prompt4.make(prompt), { agentName: agent.name, turn }).pipe(Effect45.flatMap((transformedPrompt) => preparePrompt(turn, transformedPrompt, false)), Effect45.map((preparedPrompt) => attempt(preparedPrompt, true).pipe(Stream7.flatMap(({ part, messages }) => applyPartToEvents(turn, part, messages))))));
|
|
9777
9851
|
const resilientParts = Option15.match(resilienceService, {
|
|
9778
9852
|
onNone: () => parts,
|
|
9779
|
-
onSome: (resilience) =>
|
|
9853
|
+
onSome: (resilience) => Stream7.unwrap(LanguageModel3.LanguageModel.pipe(Effect45.map((model) => parts.pipe(Stream7.provideService(LanguageModel3.LanguageModel, apply(model, resilience))))))
|
|
9780
9854
|
});
|
|
9781
|
-
return overrides?.model === undefined ? resilientParts : resilientParts.pipe(
|
|
9855
|
+
return overrides?.model === undefined ? resilientParts : resilientParts.pipe(Stream7.provide(overrides.model));
|
|
9782
9856
|
};
|
|
9783
9857
|
const turnCompletedEvent = (turn, transcript) => ({
|
|
9784
9858
|
_tag: "TurnCompleted",
|
|
@@ -9793,7 +9867,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9793
9867
|
transcript,
|
|
9794
9868
|
...state.usage === undefined ? {} : { usage: state.usage }
|
|
9795
9869
|
});
|
|
9796
|
-
const structuredFinalEvents = (turn, config) =>
|
|
9870
|
+
const structuredFinalEvents = (turn, config) => Stream7.fromEffect(Effect45.gen(function* () {
|
|
9797
9871
|
const structuredTurn = turn + 1;
|
|
9798
9872
|
const transformedPrompt = yield* applyPromptChain(chain, Prompt4.make(config.objectPrompt), {
|
|
9799
9873
|
agentName: agent.name,
|
|
@@ -9815,7 +9889,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9815
9889
|
content: response.content
|
|
9816
9890
|
};
|
|
9817
9891
|
return [structuredOutput, terminalCompletedEvent(structuredTurn, transcript)];
|
|
9818
|
-
})).pipe(
|
|
9892
|
+
})).pipe(Stream7.flatMap((events) => Stream7.fromIterable(events)));
|
|
9819
9893
|
const promptFromSteeringMessages = (messages) => messages.reduce((prompt, message) => Prompt4.concat(prompt, message.prompt), Prompt4.empty);
|
|
9820
9894
|
const takeSteering = () => Option15.match(steeringService, {
|
|
9821
9895
|
onNone: () => Effect45.succeed([]),
|
|
@@ -9835,18 +9909,18 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9835
9909
|
const followUp = yield* takeFollowUp();
|
|
9836
9910
|
if (followUp.length > 0) {
|
|
9837
9911
|
return {
|
|
9838
|
-
events:
|
|
9912
|
+
events: Stream7.fromIterable([completed]),
|
|
9839
9913
|
next: { prompt: promptFromSteeringMessages(followUp) }
|
|
9840
9914
|
};
|
|
9841
9915
|
}
|
|
9842
9916
|
if (structured !== undefined) {
|
|
9843
9917
|
return {
|
|
9844
|
-
events:
|
|
9918
|
+
events: Stream7.concat(Stream7.fromIterable([completed]), structuredFinalEvents(turn, structured))
|
|
9845
9919
|
};
|
|
9846
9920
|
}
|
|
9847
9921
|
yield* savePersisted;
|
|
9848
9922
|
return {
|
|
9849
|
-
events:
|
|
9923
|
+
events: Stream7.fromIterable([completed, terminalCompletedEvent(turn, transcript)])
|
|
9850
9924
|
};
|
|
9851
9925
|
}
|
|
9852
9926
|
const decision2 = yield* agent.policy.decide({
|
|
@@ -9856,7 +9930,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9856
9930
|
});
|
|
9857
9931
|
if (decision2._tag === "Stop") {
|
|
9858
9932
|
return {
|
|
9859
|
-
events:
|
|
9933
|
+
events: Stream7.concat(Stream7.fromIterable([completed]), Stream7.fail(new TurnLimitExceeded({
|
|
9860
9934
|
turn: turn + 1,
|
|
9861
9935
|
pending: pending.map((result) => ({
|
|
9862
9936
|
tool_call_id: result.id,
|
|
@@ -9871,21 +9945,21 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9871
9945
|
const basePrompt = steering.length === 0 ? toolPrompt : Prompt4.concat(promptFromSteeringMessages(steering), toolPrompt);
|
|
9872
9946
|
const prompt = decision2.overrides?.instructions === undefined ? basePrompt : withSystem(decision2.overrides.instructions, basePrompt);
|
|
9873
9947
|
return {
|
|
9874
|
-
events:
|
|
9948
|
+
events: Stream7.fromIterable([completed]),
|
|
9875
9949
|
next: { prompt, ...decision2.overrides === undefined ? {} : { overrides: decision2.overrides } }
|
|
9876
9950
|
};
|
|
9877
9951
|
});
|
|
9878
|
-
const resetTurnState = (turn) =>
|
|
9952
|
+
const resetTurnState = (turn) => Stream7.sync(() => {
|
|
9879
9953
|
state.turn = turn;
|
|
9880
9954
|
state.finish = undefined;
|
|
9881
|
-
}).pipe(
|
|
9955
|
+
}).pipe(Stream7.drain);
|
|
9882
9956
|
const runTurn = (turn, prompt, overrides) => {
|
|
9883
9957
|
let next;
|
|
9884
|
-
const currentTurn =
|
|
9958
|
+
const currentTurn = Stream7.fromIterable([{ _tag: "TurnStarted", turn }]).pipe(Stream7.concat(resetTurnState(turn)), Stream7.concat(modelTurn(turn, prompt, overrides)), Stream7.concat(Stream7.unwrap(afterTurn(turn).pipe(Effect45.map((result) => {
|
|
9885
9959
|
next = result.next;
|
|
9886
9960
|
return result.events;
|
|
9887
|
-
})))),
|
|
9888
|
-
return
|
|
9961
|
+
})))), Stream7.withSpan("Baton.Agent.turn", { attributes: { "baton.turn": turn } }));
|
|
9962
|
+
return Stream7.concat(currentTurn, Stream7.suspend(() => next === undefined ? Stream7.empty : runTurn(turn + 1, next.prompt, next.overrides)));
|
|
9889
9963
|
};
|
|
9890
9964
|
const resumeStream = (resume) => {
|
|
9891
9965
|
let next;
|
|
@@ -9895,36 +9969,36 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9895
9969
|
params: resume.call.params,
|
|
9896
9970
|
providerExecuted: false
|
|
9897
9971
|
});
|
|
9898
|
-
const currentTurn = resetTurnState(0).pipe(
|
|
9972
|
+
const currentTurn = resetTurnState(0).pipe(Stream7.concat(Stream7.unwrap(Ref10.get(chat.history).pipe(Effect45.map((history) => toolCallEvents(0, call, history.content))))), Stream7.concat(Stream7.unwrap(afterTurn(0).pipe(Effect45.map((result) => {
|
|
9899
9973
|
next = result.next;
|
|
9900
9974
|
return result.events;
|
|
9901
|
-
})))),
|
|
9902
|
-
return
|
|
9975
|
+
})))), Stream7.withSpan("Baton.Agent.turn", { attributes: { "baton.turn": 0 } }));
|
|
9976
|
+
return Stream7.concat(currentTurn, Stream7.suspend(() => next === undefined ? Stream7.empty : runTurn(1, next.prompt, next.overrides)));
|
|
9903
9977
|
};
|
|
9904
9978
|
const baseInitialPrompt = seedSystem === undefined ? Prompt4.make(options.prompt) : withSystem(seedSystem, Prompt4.make(options.prompt));
|
|
9905
9979
|
const initialPrompt = options.resume === undefined ? yield* recallInitialPrompt(baseInitialPrompt) : baseInitialPrompt;
|
|
9906
9980
|
const runStream = options.resume === undefined ? runTurn(0, initialPrompt) : resumeStream(options.resume);
|
|
9907
|
-
return runStream.pipe(
|
|
9981
|
+
return runStream.pipe(Stream7.catchCause((cause) => {
|
|
9908
9982
|
if (Cause3.hasInterrupts(cause))
|
|
9909
|
-
return
|
|
9983
|
+
return Stream7.fromEffect(Effect45.interrupt);
|
|
9910
9984
|
const error = Cause3.squash(cause);
|
|
9911
9985
|
if (error instanceof AgentSuspended) {
|
|
9912
|
-
return
|
|
9986
|
+
return Stream7.unwrap(Ref10.get(chat.history).pipe(Effect45.map((transcript) => Stream7.concat(Stream7.fromIterable([turnCompletedEvent(state.turn, transcript)]), Stream7.failCause(cause)))));
|
|
9913
9987
|
}
|
|
9914
|
-
return
|
|
9988
|
+
return Stream7.failCause(cause);
|
|
9915
9989
|
}));
|
|
9916
|
-
})).pipe(
|
|
9990
|
+
})).pipe(Stream7.withSpan("Baton.Agent.run", { attributes: { "baton.agent.name": agent.name } }));
|
|
9917
9991
|
var stream2 = (agent, options) => streamInternal(agent, options, undefined);
|
|
9918
9992
|
var streamObject = (agent, options) => streamInternal(agent, options, {
|
|
9919
9993
|
schema: options.schema,
|
|
9920
9994
|
objectName: options.objectName ?? "output",
|
|
9921
9995
|
objectPrompt: options.objectPrompt ?? defaultObjectPrompt
|
|
9922
9996
|
});
|
|
9923
|
-
var generate = (agent, options) =>
|
|
9997
|
+
var generate = (agent, options) => Stream7.runLast(stream2(agent, options)).pipe(Effect45.flatMap(Option15.match({
|
|
9924
9998
|
onNone: () => Effect45.fail(new AgentError({ message: "Agent run ended without a Completed event", turn: 0 })),
|
|
9925
9999
|
onSome: (event) => event._tag === "Completed" ? Effect45.succeed({ text: event.text, turns: event.turns, transcript: event.transcript }) : Effect45.fail(new AgentError({ message: "Agent run ended without a Completed event", turn: 0 }))
|
|
9926
10000
|
})));
|
|
9927
|
-
var generateObject = (agent, options) =>
|
|
10001
|
+
var generateObject = (agent, options) => Stream7.runFold(streamObject(agent, options), () => ({
|
|
9928
10002
|
value: Option15.none(),
|
|
9929
10003
|
completed: Option15.none()
|
|
9930
10004
|
}), (acc, event) => {
|
|
@@ -9950,21 +10024,211 @@ var generateObject = (agent, options) => Stream6.runFold(streamObject(agent, opt
|
|
|
9950
10024
|
})
|
|
9951
10025
|
})
|
|
9952
10026
|
})));
|
|
9953
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
10027
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/agent-tool.ts
|
|
10028
|
+
var exports_agent_tool = {};
|
|
10029
|
+
__export(exports_agent_tool, {
|
|
10030
|
+
asTool: () => asTool
|
|
10031
|
+
});
|
|
9954
10032
|
import { Cause as Cause4, Effect as Effect46, Schema as Schema46 } from "effect";
|
|
9955
|
-
import { Tool as Tool5, Toolkit as
|
|
10033
|
+
import { Tool as Tool5, Toolkit as Toolkit4 } from "effect/unstable/ai";
|
|
9956
10034
|
var defaultParameters = Schema46.Struct({ prompt: Schema46.String });
|
|
9957
|
-
|
|
10035
|
+
var errorMessage2 = (error) => {
|
|
10036
|
+
if (error instanceof AgentSuspended) {
|
|
10037
|
+
return `suspended on ${error.tool_name}: ${error.reason}`;
|
|
10038
|
+
}
|
|
10039
|
+
if (error instanceof AgentError) {
|
|
10040
|
+
return `failed on turn ${error.turn}: ${error.message}`;
|
|
10041
|
+
}
|
|
10042
|
+
if (error instanceof TurnLimitExceeded) {
|
|
10043
|
+
return `turn limit exceeded at turn ${error.turn}`;
|
|
10044
|
+
}
|
|
10045
|
+
if (error instanceof MiddlewareViolation) {
|
|
10046
|
+
return `middleware violation on turn ${error.turn}: ${error.detail}`;
|
|
10047
|
+
}
|
|
10048
|
+
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
10049
|
+
};
|
|
10050
|
+
var causeMessage = (agentName, cause) => `sub-agent '${agentName}' could not complete: ${errorMessage2(Cause4.squash(cause))}`;
|
|
10051
|
+
var lazyHandled = (toolkit, name, handler) => ({
|
|
10052
|
+
tools: toolkit.tools,
|
|
10053
|
+
handle: (toolName, params) => toolkit.pipe(Effect46.provide(toolkit.toLayer({
|
|
10054
|
+
[name]: handler
|
|
10055
|
+
})), Effect46.flatMap((handled) => handled.handle(toolName, params)))
|
|
10056
|
+
});
|
|
10057
|
+
var asTool = (agent, options = {}) => {
|
|
10058
|
+
const name = options.name ?? agent.name;
|
|
10059
|
+
const parameters = options.parameters ?? defaultParameters;
|
|
10060
|
+
const success2 = options.success ?? Schema46.String;
|
|
10061
|
+
const toPrompt = options.toPrompt ?? ((params) => params.prompt);
|
|
10062
|
+
const fromResult = options.fromResult ?? ((result) => result.text);
|
|
10063
|
+
const tool2 = Tool5.make(name, {
|
|
10064
|
+
...options.description === undefined ? {} : { description: options.description },
|
|
10065
|
+
parameters,
|
|
10066
|
+
success: success2,
|
|
10067
|
+
failure: Schema46.String,
|
|
10068
|
+
failureMode: "return"
|
|
10069
|
+
});
|
|
10070
|
+
const toolkit = Toolkit4.make(tool2);
|
|
10071
|
+
const handler = (params) => Effect46.gen(function* () {
|
|
10072
|
+
const prompt = yield* Effect46.try({ try: () => toPrompt(params), catch: errorMessage2 });
|
|
10073
|
+
const result = yield* generate(agent, { prompt }).pipe(Effect46.catchCause((cause) => {
|
|
10074
|
+
if (Cause4.hasInterrupts(cause))
|
|
10075
|
+
return Effect46.interrupt;
|
|
10076
|
+
const error = Cause4.squash(cause);
|
|
10077
|
+
if (error instanceof AgentSuspended)
|
|
10078
|
+
return Effect46.die(error);
|
|
10079
|
+
return Effect46.fail(causeMessage(agent.name, cause));
|
|
10080
|
+
}));
|
|
10081
|
+
return yield* Effect46.try({ try: () => fromResult(result), catch: errorMessage2 });
|
|
10082
|
+
});
|
|
10083
|
+
return lazyHandled(toolkit, name, handler);
|
|
10084
|
+
};
|
|
10085
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/guardrail.ts
|
|
10086
|
+
var exports_guardrail = {};
|
|
10087
|
+
__export(exports_guardrail, {
|
|
10088
|
+
validateInput: () => validateInput2,
|
|
10089
|
+
redactOutput: () => redactOutput,
|
|
10090
|
+
redactInput: () => redactInput,
|
|
10091
|
+
filterOutput: () => filterOutput
|
|
10092
|
+
});
|
|
9958
10093
|
import { Effect as Effect47, Option as Option16 } from "effect";
|
|
9959
10094
|
import { Prompt as Prompt6, Response as Response4 } from "effect/unstable/ai";
|
|
9960
|
-
|
|
10095
|
+
var replacement = (options) => options.replacement ?? "[redacted]";
|
|
10096
|
+
var redactText = (text3, options) => text3.replace(options.pattern, replacement(options));
|
|
10097
|
+
var redactUserPart = (part, options) => part.type === "text" ? Prompt6.makePart("text", { text: redactText(part.text, options), options: part.options }) : part;
|
|
10098
|
+
var redactAssistantPart = (part, options) => {
|
|
10099
|
+
switch (part.type) {
|
|
10100
|
+
case "text":
|
|
10101
|
+
return Prompt6.makePart("text", { text: redactText(part.text, options), options: part.options });
|
|
10102
|
+
case "reasoning":
|
|
10103
|
+
return Prompt6.makePart("reasoning", { text: redactText(part.text, options), options: part.options });
|
|
10104
|
+
default:
|
|
10105
|
+
return part;
|
|
10106
|
+
}
|
|
10107
|
+
};
|
|
10108
|
+
var redactToolPart = (part, options) => {
|
|
10109
|
+
if (part.type !== "tool-approval-response" || part.reason === undefined)
|
|
10110
|
+
return part;
|
|
10111
|
+
return Prompt6.makePart("tool-approval-response", {
|
|
10112
|
+
approvalId: part.approvalId,
|
|
10113
|
+
approved: part.approved,
|
|
10114
|
+
reason: redactText(part.reason, options),
|
|
10115
|
+
options: part.options
|
|
10116
|
+
});
|
|
10117
|
+
};
|
|
10118
|
+
var redactPromptText = (prompt, options) => Prompt6.fromMessages(prompt.content.map((message) => {
|
|
10119
|
+
switch (message.role) {
|
|
10120
|
+
case "system":
|
|
10121
|
+
return Prompt6.makeMessage("system", {
|
|
10122
|
+
content: redactText(message.content, options),
|
|
10123
|
+
options: message.options
|
|
10124
|
+
});
|
|
10125
|
+
case "user":
|
|
10126
|
+
return Prompt6.makeMessage("user", {
|
|
10127
|
+
content: message.content.map((part) => redactUserPart(part, options)),
|
|
10128
|
+
options: message.options
|
|
10129
|
+
});
|
|
10130
|
+
case "assistant":
|
|
10131
|
+
return Prompt6.makeMessage("assistant", {
|
|
10132
|
+
content: message.content.map((part) => redactAssistantPart(part, options)),
|
|
10133
|
+
options: message.options
|
|
10134
|
+
});
|
|
10135
|
+
case "tool":
|
|
10136
|
+
return Prompt6.makeMessage("tool", {
|
|
10137
|
+
content: message.content.map((part) => redactToolPart(part, options)),
|
|
10138
|
+
options: message.options
|
|
10139
|
+
});
|
|
10140
|
+
}
|
|
10141
|
+
}));
|
|
10142
|
+
var validateInput2 = (check2) => ({
|
|
10143
|
+
transformPrompt: (prompt, context) => check2(prompt, context).pipe(Effect47.flatMap(Option16.match({
|
|
10144
|
+
onNone: () => Effect47.succeed(prompt),
|
|
10145
|
+
onSome: (reason) => Effect47.fail(new AgentError({ message: `Input guardrail blocked: ${reason}`, turn: context.turn }))
|
|
10146
|
+
})))
|
|
10147
|
+
});
|
|
10148
|
+
var redactInput = (options) => ({
|
|
10149
|
+
transformPrompt: (prompt) => Effect47.succeed(redactPromptText(prompt, options))
|
|
10150
|
+
});
|
|
10151
|
+
var redactOutput = (options) => ({
|
|
10152
|
+
transformPart: (part) => {
|
|
10153
|
+
if (part.type !== "text-delta")
|
|
10154
|
+
return Effect47.succeed(Option16.some(part));
|
|
10155
|
+
return Effect47.succeed(Option16.some(Response4.makePart("text-delta", {
|
|
10156
|
+
id: part.id,
|
|
10157
|
+
delta: redactText(part.delta, options),
|
|
10158
|
+
metadata: part.metadata
|
|
10159
|
+
})));
|
|
10160
|
+
}
|
|
10161
|
+
});
|
|
10162
|
+
var filterOutput = (keep) => ({
|
|
10163
|
+
transformPart: (part, context) => Effect47.succeed(part.type === "tool-call" || keep(part, context) ? Option16.some(part) : Option16.none())
|
|
10164
|
+
});
|
|
10165
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/handoff.ts
|
|
10166
|
+
var exports_handoff = {};
|
|
10167
|
+
__export(exports_handoff, {
|
|
10168
|
+
transferTool: () => transferTool,
|
|
10169
|
+
supervisor: () => supervisor,
|
|
10170
|
+
fanOut: () => fanOut
|
|
10171
|
+
});
|
|
9961
10172
|
import { Effect as Effect48, Schema as Schema47 } from "effect";
|
|
9962
|
-
import { AiError as AiError2, Toolkit as
|
|
10173
|
+
import { AiError as AiError2, Toolkit as Toolkit5 } from "effect/unstable/ai";
|
|
9963
10174
|
var defaultTransferParameters = Schema47.Struct({ prompt: Schema47.String });
|
|
9964
|
-
|
|
10175
|
+
var transferName = (agentName) => `transfer_to_${agentName}`;
|
|
10176
|
+
var positiveConcurrency = (value) => {
|
|
10177
|
+
const concurrency = value ?? 4;
|
|
10178
|
+
return Number.isInteger(concurrency) && concurrency > 0 ? Effect48.succeed(concurrency) : Effect48.fail(new AgentError({
|
|
10179
|
+
message: "Handoff.fanOut concurrency must be a positive integer",
|
|
10180
|
+
turn: 0
|
|
10181
|
+
}));
|
|
10182
|
+
};
|
|
10183
|
+
var mergeHandled = (toolkits) => {
|
|
10184
|
+
const tools = {};
|
|
10185
|
+
for (const toolkit of toolkits) {
|
|
10186
|
+
Object.assign(tools, toolkit.tools);
|
|
10187
|
+
}
|
|
10188
|
+
return {
|
|
10189
|
+
tools,
|
|
10190
|
+
handle: (name, params) => {
|
|
10191
|
+
const toolkit = toolkits.find((candidate) => candidate.tools[name] !== undefined);
|
|
10192
|
+
return toolkit === undefined ? Effect48.fail(AiError2.make({
|
|
10193
|
+
module: "Handoff",
|
|
10194
|
+
method: `${String(name)}.handle`,
|
|
10195
|
+
reason: new AiError2.ToolNotFoundError({
|
|
10196
|
+
toolName: String(name),
|
|
10197
|
+
availableTools: Object.keys(tools)
|
|
10198
|
+
})
|
|
10199
|
+
})) : toolkit.handle(name, params);
|
|
10200
|
+
}
|
|
10201
|
+
};
|
|
10202
|
+
};
|
|
10203
|
+
var toolkitFromHandled = (toolkit) => Toolkit5.make(...Object.values(toolkit.tools));
|
|
10204
|
+
var transferTool = (target, options = {}) => asTool(target, {
|
|
10205
|
+
name: options.nameOverride ?? transferName(target.name),
|
|
10206
|
+
description: options.description ?? `Transfer to ${target.name}`,
|
|
10207
|
+
...options.parameters === undefined ? {} : { parameters: options.parameters },
|
|
10208
|
+
...options.success === undefined ? {} : { success: options.success },
|
|
10209
|
+
...options.toPrompt === undefined ? {} : { toPrompt: options.toPrompt },
|
|
10210
|
+
...options.fromResult === undefined ? {} : { fromResult: options.fromResult }
|
|
10211
|
+
});
|
|
10212
|
+
var fanOut = (children, options = {}) => positiveConcurrency(options.concurrency).pipe(Effect48.flatMap((concurrency) => Effect48.forEach(children, (child) => generate(child.agent, { ...child.options, prompt: child.prompt }), {
|
|
10213
|
+
concurrency
|
|
10214
|
+
})));
|
|
10215
|
+
var supervisor = (options) => {
|
|
10216
|
+
const transferTools = options.specialists.map((specialist) => transferTool(specialist));
|
|
10217
|
+
const toolkit = mergeHandled(transferTools);
|
|
10218
|
+
return {
|
|
10219
|
+
agent: make5({
|
|
10220
|
+
name: options.name,
|
|
10221
|
+
...options.instructions === undefined ? {} : { instructions: options.instructions },
|
|
10222
|
+
toolkit: toolkitFromHandled(toolkit),
|
|
10223
|
+
...options.policy === undefined ? {} : { policy: options.policy }
|
|
10224
|
+
}),
|
|
10225
|
+
toolkit
|
|
10226
|
+
};
|
|
10227
|
+
};
|
|
10228
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/model-registry.ts
|
|
9965
10229
|
var exports_model_registry = {};
|
|
9966
10230
|
__export(exports_model_registry, {
|
|
9967
|
-
testLayer: () =>
|
|
10231
|
+
testLayer: () => testLayer38,
|
|
9968
10232
|
registrations: () => registrations,
|
|
9969
10233
|
registrationFromLayer: () => registrationFromLayer,
|
|
9970
10234
|
register: () => register4,
|
|
@@ -10036,7 +10300,7 @@ var layer31 = (initialRegistrations = [], options) => Layer43.effect(Service29,
|
|
|
10036
10300
|
var layerFromRegistrationEffects = (registrations, options) => Layer43.unwrap(Effect49.all(registrations).pipe(Effect49.map((items) => layer31(items, options))));
|
|
10037
10301
|
var combine = (registries, options) => Layer43.unwrap(Effect49.forEach(registries, (registry) => Layer43.build(registry).pipe(Effect49.flatMap((context) => Context42.get(context, Service29).registrations))).pipe(Effect49.map((groups) => layer31(groups.flat(), options))));
|
|
10038
10302
|
var memoryLayer25 = layer31;
|
|
10039
|
-
var
|
|
10303
|
+
var testLayer38 = (implementation) => Layer43.succeed(Service29, Service29.of(implementation));
|
|
10040
10304
|
var register4 = Effect49.fn("ModelRegistry.register.call")(function* (input) {
|
|
10041
10305
|
const service = yield* Service29;
|
|
10042
10306
|
return yield* service.register(input);
|
|
@@ -10049,14 +10313,32 @@ var provide = (selection, effect) => Effect49.gen(function* () {
|
|
|
10049
10313
|
const service = yield* Service29;
|
|
10050
10314
|
return yield* service.provide(selection, effect);
|
|
10051
10315
|
});
|
|
10316
|
+
|
|
10317
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.0/node_modules/@batonfx/core/src/index.ts
|
|
10318
|
+
import {
|
|
10319
|
+
AiError as AiError3,
|
|
10320
|
+
Chat as Chat2,
|
|
10321
|
+
EmbeddingModel,
|
|
10322
|
+
IdGenerator,
|
|
10323
|
+
LanguageModel as LanguageModel5,
|
|
10324
|
+
Model as Model2,
|
|
10325
|
+
Prompt as Prompt8,
|
|
10326
|
+
Response as Response5,
|
|
10327
|
+
ResponseIdTracker,
|
|
10328
|
+
Telemetry as Telemetry2,
|
|
10329
|
+
Tokenizer as Tokenizer3,
|
|
10330
|
+
Tool as Tool7,
|
|
10331
|
+
Toolkit as Toolkit6
|
|
10332
|
+
} from "effect/unstable/ai";
|
|
10333
|
+
|
|
10052
10334
|
// ../runtime/src/agent/agent-loop-service.ts
|
|
10053
|
-
import { Config as Config3, Context as Context54, Crypto as Crypto3, Effect as Effect67, HashSet as HashSet6, Layer as Layer60, Option as Option22, Ref as Ref18, Schema as Schema61, Stream as
|
|
10054
|
-
import { Chat as
|
|
10335
|
+
import { Config as Config3, Context as Context54, Crypto as Crypto3, Effect as Effect67, HashSet as HashSet6, Layer as Layer60, Option as Option22, Ref as Ref18, Schema as Schema61, Stream as Stream8 } from "effect";
|
|
10336
|
+
import { Chat as Chat3, LanguageModel as LanguageModel6, Prompt as Prompt12, Tokenizer as Tokenizer4, Toolkit as Toolkit7 } from "effect/unstable/ai";
|
|
10055
10337
|
|
|
10056
10338
|
// ../runtime/src/child/child-run-service.ts
|
|
10057
10339
|
var exports_child_run_service = {};
|
|
10058
10340
|
__export(exports_child_run_service, {
|
|
10059
|
-
testLayer: () =>
|
|
10341
|
+
testLayer: () => testLayer39,
|
|
10060
10342
|
spawnStatic: () => spawnStatic,
|
|
10061
10343
|
spawnDynamic: () => spawnDynamic,
|
|
10062
10344
|
resolveForDispatch: () => resolveForDispatch,
|
|
@@ -10321,7 +10603,7 @@ var layer32 = Layer45.effect(Service31, Effect51.gen(function* () {
|
|
|
10321
10603
|
});
|
|
10322
10604
|
}));
|
|
10323
10605
|
var memoryLayer26 = layer32.pipe(Layer45.provide(exports_child_execution_repository.memoryLayer), Layer45.provide(memoryLayer21));
|
|
10324
|
-
var
|
|
10606
|
+
var testLayer39 = (implementation) => Layer45.succeed(Service31, Service31.of(implementation));
|
|
10325
10607
|
var agentContextFromSchema = (input) => ({
|
|
10326
10608
|
toolNames: input.tool_names,
|
|
10327
10609
|
permissions: input.permissions,
|
|
@@ -10582,11 +10864,11 @@ var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target
|
|
|
10582
10864
|
|
|
10583
10865
|
// ../runtime/src/memory/memory-service.ts
|
|
10584
10866
|
import { Clock as Clock3, Context as Context46, Effect as Effect54, Layer as Layer47, Schema as Schema53 } from "effect";
|
|
10585
|
-
import { EmbeddingModel as
|
|
10867
|
+
import { EmbeddingModel as EmbeddingModel3, Prompt as Prompt9 } from "effect/unstable/ai";
|
|
10586
10868
|
|
|
10587
10869
|
// ../runtime/src/model/embedding-model-service.ts
|
|
10588
10870
|
import { Context as Context45, Effect as Effect53, Layer as Layer46, Ref as Ref13, Schema as Schema52 } from "effect";
|
|
10589
|
-
import { EmbeddingModel, Model as
|
|
10871
|
+
import { EmbeddingModel as EmbeddingModel2, Model as Model3 } from "effect/unstable/ai";
|
|
10590
10872
|
|
|
10591
10873
|
class EmbeddingModelNotRegistered extends Schema52.TaggedErrorClass()("EmbeddingModelNotRegistered", {
|
|
10592
10874
|
provider: Schema52.String,
|
|
@@ -10625,7 +10907,7 @@ var resolveDefault = (registrations2, options) => {
|
|
|
10625
10907
|
}
|
|
10626
10908
|
return registrations2.length === 1 ? registrations2[0] : undefined;
|
|
10627
10909
|
};
|
|
10628
|
-
var registrationFromLayer2 = (input) =>
|
|
10910
|
+
var registrationFromLayer2 = (input) => Model3.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect53.map((layer33) => toRegistration({
|
|
10629
10911
|
provider: input.provider,
|
|
10630
10912
|
model: input.model,
|
|
10631
10913
|
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
@@ -10683,12 +10965,12 @@ var deterministicVector = (input, dimensions) => {
|
|
|
10683
10965
|
};
|
|
10684
10966
|
var deterministicLayer = (options = {}) => {
|
|
10685
10967
|
const dimensions = options.dimensions ?? 64;
|
|
10686
|
-
return Layer46.mergeAll(Layer46.effect(
|
|
10968
|
+
return Layer46.mergeAll(Layer46.effect(EmbeddingModel2.EmbeddingModel, EmbeddingModel2.make({
|
|
10687
10969
|
embedMany: ({ inputs }) => Effect53.succeed({
|
|
10688
10970
|
results: inputs.map((input) => deterministicVector(input, dimensions)),
|
|
10689
10971
|
usage: { inputTokens: inputs.reduce((total, input) => total + words(input).length, 0) }
|
|
10690
10972
|
})
|
|
10691
|
-
})), Layer46.succeed(
|
|
10973
|
+
})), Layer46.succeed(EmbeddingModel2.Dimensions, dimensions));
|
|
10692
10974
|
};
|
|
10693
10975
|
var deterministicRegistration = (options = {}) => registrationFromLayer2({
|
|
10694
10976
|
provider: options.provider ?? "test",
|
|
@@ -10718,7 +11000,7 @@ var memoryError = (error) => new exports_memory.MemoryError({
|
|
|
10718
11000
|
message: error instanceof Error ? `${error.name}: ${error.message}` : String(error)
|
|
10719
11001
|
});
|
|
10720
11002
|
var decodeSubject = (subject) => Schema53.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect54.mapError(memoryError));
|
|
10721
|
-
var textPart = (text3) =>
|
|
11003
|
+
var textPart = (text3) => Prompt9.makePart("text", { text: text3 });
|
|
10722
11004
|
var textFromParts = (parts) => parts.filter((part) => part.type === "text").map((part) => part.text).join(`
|
|
10723
11005
|
`).trim();
|
|
10724
11006
|
var latestUserText = (prompt) => {
|
|
@@ -10781,7 +11063,7 @@ var hashText = (input) => {
|
|
|
10781
11063
|
};
|
|
10782
11064
|
var memoryId = (input, text3) => `memory:${input.key.agent}:${input.key.subject}:${input.turn}:${hashText(`${input.key.agent}\x00${input.key.subject}\x00${input.turn}\x00${text3}`)}`;
|
|
10783
11065
|
var embed = (models, text3, options) => {
|
|
10784
|
-
const program =
|
|
11066
|
+
const program = EmbeddingModel3.EmbeddingModel.pipe(Effect54.flatMap((model) => model.embed(text3)));
|
|
10785
11067
|
return (options?.embeddingSelection === undefined ? models.provideDefault(program) : models.provide(options.embeddingSelection, program)).pipe(Effect54.mapError(memoryError));
|
|
10786
11068
|
};
|
|
10787
11069
|
var make6 = (options = {}) => Effect54.gen(function* () {
|
|
@@ -10848,7 +11130,7 @@ var remember2 = Effect54.fn("MemoryService.remember.call")(function* (input) {
|
|
|
10848
11130
|
// ../runtime/src/model/language-model-service.ts
|
|
10849
11131
|
var exports_language_model_service = {};
|
|
10850
11132
|
__export(exports_language_model_service, {
|
|
10851
|
-
testLayer: () =>
|
|
11133
|
+
testLayer: () => testLayer40,
|
|
10852
11134
|
registrations: () => registrations3,
|
|
10853
11135
|
registrationFromLayer: () => registrationFromLayer3,
|
|
10854
11136
|
register: () => register6,
|
|
@@ -10882,7 +11164,7 @@ var layer35 = (initialRegistrations = [], options) => Layer48.effect(Service34,
|
|
|
10882
11164
|
})).pipe(Layer48.provide(exports_model_registry.layer(initialRegistrations, options)));
|
|
10883
11165
|
var layerFromRegistrationEffects3 = (registrations3, options) => Layer48.unwrap(Effect55.all(registrations3).pipe(Effect55.map((items) => layer35(items, options))));
|
|
10884
11166
|
var memoryLayer28 = layer35;
|
|
10885
|
-
var
|
|
11167
|
+
var testLayer40 = (implementation) => Layer48.succeed(Service34, Service34.of(implementation));
|
|
10886
11168
|
var register6 = Effect55.fn("LanguageModelService.register.call")(function* (input) {
|
|
10887
11169
|
const service = yield* Service34;
|
|
10888
11170
|
return yield* service.register(input);
|
|
@@ -10903,7 +11185,7 @@ var provideForAgent = (agent, effect) => Effect55.gen(function* () {
|
|
|
10903
11185
|
// ../runtime/src/model/model-call-policy.ts
|
|
10904
11186
|
var exports_model_call_policy = {};
|
|
10905
11187
|
__export(exports_model_call_policy, {
|
|
10906
|
-
testLayer: () =>
|
|
11188
|
+
testLayer: () => testLayer41,
|
|
10907
11189
|
noRetryLayer: () => noRetryLayer,
|
|
10908
11190
|
make: () => make7,
|
|
10909
11191
|
layer: () => layer36,
|
|
@@ -10912,11 +11194,11 @@ __export(exports_model_call_policy, {
|
|
|
10912
11194
|
Service: () => Service35
|
|
10913
11195
|
});
|
|
10914
11196
|
import { Context as Context48, Duration as Duration3, Layer as Layer49, Schedule as Schedule3 } from "effect";
|
|
10915
|
-
import { AiError as
|
|
11197
|
+
import { AiError as AiError4 } from "effect/unstable/ai";
|
|
10916
11198
|
|
|
10917
11199
|
class Service35 extends Context48.Service()("@relayfx/runtime/ModelCallPolicy") {
|
|
10918
11200
|
}
|
|
10919
|
-
var isOutputValidationError = (error) =>
|
|
11201
|
+
var isOutputValidationError = (error) => AiError4.isAiError(error) ? error.reason._tag === "InvalidOutputError" : AiError4.isAiErrorReason(error) && error._tag === "InvalidOutputError";
|
|
10920
11202
|
var defaultClassify2 = (error) => isOutputValidationError(error) ? "terminal" : exports_model_resilience.defaultClassify(error);
|
|
10921
11203
|
var defaultSchedule = Schedule3.exponential(Duration3.seconds(1)).pipe(Schedule3.jittered, Schedule3.both(Schedule3.recurs(4)));
|
|
10922
11204
|
var make7 = (input) => ({
|
|
@@ -10925,12 +11207,12 @@ var make7 = (input) => ({
|
|
|
10925
11207
|
});
|
|
10926
11208
|
var layer36 = (input) => Layer49.succeed(Service35, Service35.of(make7(input)));
|
|
10927
11209
|
var noRetryLayer = layer36({ retrySchedule: Schedule3.recurs(0) });
|
|
10928
|
-
var
|
|
11210
|
+
var testLayer41 = (implementation) => Layer49.succeed(Service35, Service35.of(implementation));
|
|
10929
11211
|
|
|
10930
11212
|
// ../runtime/src/schema-registry/schema-registry-service.ts
|
|
10931
11213
|
var exports_schema_registry_service = {};
|
|
10932
11214
|
__export(exports_schema_registry_service, {
|
|
10933
|
-
testLayer: () =>
|
|
11215
|
+
testLayer: () => testLayer42,
|
|
10934
11216
|
resolve: () => resolve4,
|
|
10935
11217
|
registrations: () => registrations4,
|
|
10936
11218
|
register: () => register7,
|
|
@@ -10969,7 +11251,7 @@ var layer37 = (initialRegistrations = []) => Layer50.effect(Service36, Effect56.
|
|
|
10969
11251
|
return Service36.of({ register: register7, registrations: registrations4, resolve: resolve4 });
|
|
10970
11252
|
}));
|
|
10971
11253
|
var memoryLayer29 = layer37;
|
|
10972
|
-
var
|
|
11254
|
+
var testLayer42 = (implementation) => Layer50.succeed(Service36, Service36.of(implementation));
|
|
10973
11255
|
var register7 = Effect56.fn("SchemaRegistry.register.call")(function* (registration) {
|
|
10974
11256
|
const service = yield* Service36;
|
|
10975
11257
|
return yield* service.register(registration);
|
|
@@ -11065,7 +11347,7 @@ var make8 = Effect57.fn("RelaySessionStore.make")(function* (sessionId, entrySco
|
|
|
11065
11347
|
// ../runtime/src/content/blob-store-service.ts
|
|
11066
11348
|
var exports_blob_store_service = {};
|
|
11067
11349
|
__export(exports_blob_store_service, {
|
|
11068
|
-
testLayer: () =>
|
|
11350
|
+
testLayer: () => testLayer43,
|
|
11069
11351
|
resolve: () => resolve5,
|
|
11070
11352
|
put: () => put3,
|
|
11071
11353
|
passthroughLayer: () => passthroughLayer,
|
|
@@ -11134,7 +11416,7 @@ var memoryLayer30 = Layer52.effect(Service38, Effect58.gen(function* () {
|
|
|
11134
11416
|
})
|
|
11135
11417
|
});
|
|
11136
11418
|
}));
|
|
11137
|
-
var
|
|
11419
|
+
var testLayer43 = (implementation) => Layer52.succeed(Service38, Service38.of(implementation));
|
|
11138
11420
|
var resolve5 = Effect58.fn("BlobStore.resolve.call")(function* (part) {
|
|
11139
11421
|
const service = yield* Service38;
|
|
11140
11422
|
return yield* service.resolve(part);
|
|
@@ -11147,7 +11429,7 @@ var put3 = Effect58.fn("BlobStore.put.call")(function* (input) {
|
|
|
11147
11429
|
// ../runtime/src/agent/prompt-assembler-service.ts
|
|
11148
11430
|
var exports_prompt_assembler_service = {};
|
|
11149
11431
|
__export(exports_prompt_assembler_service, {
|
|
11150
|
-
testLayer: () =>
|
|
11432
|
+
testLayer: () => testLayer45,
|
|
11151
11433
|
layer: () => layer38,
|
|
11152
11434
|
defaultLayerWithStores: () => defaultLayerWithStores,
|
|
11153
11435
|
defaultLayer: () => defaultLayer,
|
|
@@ -11157,12 +11439,12 @@ __export(exports_prompt_assembler_service, {
|
|
|
11157
11439
|
PromptAssemblerError: () => PromptAssemblerError
|
|
11158
11440
|
});
|
|
11159
11441
|
import { Context as Context53, Effect as Effect60, Layer as Layer54, Schema as Schema57 } from "effect";
|
|
11160
|
-
import { Prompt as
|
|
11442
|
+
import { Prompt as Prompt10 } from "effect/unstable/ai";
|
|
11161
11443
|
|
|
11162
11444
|
// ../runtime/src/content/artifact-store-service.ts
|
|
11163
11445
|
var exports_artifact_store_service = {};
|
|
11164
11446
|
__export(exports_artifact_store_service, {
|
|
11165
|
-
testLayer: () =>
|
|
11447
|
+
testLayer: () => testLayer44,
|
|
11166
11448
|
resolve: () => resolve6,
|
|
11167
11449
|
register: () => register8,
|
|
11168
11450
|
passthroughLayer: () => passthroughLayer2,
|
|
@@ -11206,7 +11488,7 @@ var memoryServiceLayer = Layer53.effect(Service39, Effect59.gen(function* () {
|
|
|
11206
11488
|
return Service39.of({ resolve: memory.resolve });
|
|
11207
11489
|
}));
|
|
11208
11490
|
var memoryLayer31 = memoryServiceLayer.pipe(Layer53.provideMerge(Layer53.effect(Memory2, makeMemory)));
|
|
11209
|
-
var
|
|
11491
|
+
var testLayer44 = (implementation) => Layer53.succeed(Service39, Service39.of(implementation));
|
|
11210
11492
|
var resolve6 = Effect59.fn("ArtifactStore.resolve.call")(function* (part) {
|
|
11211
11493
|
const service = yield* Service39;
|
|
11212
11494
|
return yield* service.resolve(part);
|
|
@@ -11230,19 +11512,19 @@ var contentToPromptPart = (part) => {
|
|
|
11230
11512
|
const options = part.provider_options;
|
|
11231
11513
|
switch (part.type) {
|
|
11232
11514
|
case "text":
|
|
11233
|
-
return
|
|
11515
|
+
return Prompt10.makePart("text", { text: part.text, ...options === undefined ? {} : { options } });
|
|
11234
11516
|
case "structured":
|
|
11235
|
-
return
|
|
11517
|
+
return Prompt10.makePart("text", {
|
|
11236
11518
|
text: stringifyJson(part.value),
|
|
11237
11519
|
...options === undefined ? {} : { options }
|
|
11238
11520
|
});
|
|
11239
11521
|
case "tool-call":
|
|
11240
|
-
return
|
|
11522
|
+
return Prompt10.makePart("text", {
|
|
11241
11523
|
text: stringifyJson(part.call),
|
|
11242
11524
|
...options === undefined ? {} : { options }
|
|
11243
11525
|
});
|
|
11244
11526
|
case "tool-result":
|
|
11245
|
-
return
|
|
11527
|
+
return Prompt10.makePart("text", {
|
|
11246
11528
|
text: stringifyJson(part.result),
|
|
11247
11529
|
...options === undefined ? {} : { options }
|
|
11248
11530
|
});
|
|
@@ -11252,7 +11534,7 @@ var toAssemblerError = (error) => new PromptAssemblerError({
|
|
|
11252
11534
|
message: error.reason !== undefined ? `${error._tag}: ${error.reason}` : error.message !== undefined ? `${error._tag}: ${error.message}` : error._tag
|
|
11253
11535
|
});
|
|
11254
11536
|
var resolveBlobPart = (blobs, part) => blobs.resolve(part).pipe(Effect60.map((resolved) => [
|
|
11255
|
-
|
|
11537
|
+
Prompt10.makePart("file", {
|
|
11256
11538
|
mediaType: resolved.mediaType,
|
|
11257
11539
|
data: resolved._tag === "Bytes" ? resolved.bytes : resolved.url,
|
|
11258
11540
|
...resolved.fileName === undefined ? {} : { fileName: resolved.fileName },
|
|
@@ -11293,9 +11575,9 @@ var defaultSystem = (agent, tools) => [`Agent: ${agent.name}`, agent.instruction
|
|
|
11293
11575
|
`);
|
|
11294
11576
|
var defaultPrompt = (blobs, artifacts, input) => Effect60.forEach(input, (part) => resolveContentPart(blobs, artifacts, part), { concurrency: 1 }).pipe(Effect60.map((parts) => {
|
|
11295
11577
|
const flat = parts.flat();
|
|
11296
|
-
return
|
|
11297
|
-
|
|
11298
|
-
content: flat.length === 0 ? [
|
|
11578
|
+
return Prompt10.fromMessages([
|
|
11579
|
+
Prompt10.makeMessage("user", {
|
|
11580
|
+
content: flat.length === 0 ? [Prompt10.makePart("text", { text: "" })] : flat
|
|
11299
11581
|
})
|
|
11300
11582
|
]);
|
|
11301
11583
|
}));
|
|
@@ -11309,7 +11591,7 @@ var defaultLayerWithStores = Layer54.effect(Service40, Effect60.gen(function* ()
|
|
|
11309
11591
|
}));
|
|
11310
11592
|
var defaultLayer = defaultLayerWithStores.pipe(Layer54.provide(Layer54.mergeAll(passthroughLayer, passthroughLayer2)));
|
|
11311
11593
|
var layer38 = (implementation) => Layer54.succeed(Service40, Service40.of(implementation));
|
|
11312
|
-
var
|
|
11594
|
+
var testLayer45 = (implementation) => Layer54.succeed(Service40, Service40.of(implementation));
|
|
11313
11595
|
var assemble = Effect60.fn("PromptAssembler.assemble.call")(function* (input) {
|
|
11314
11596
|
const service = yield* Service40;
|
|
11315
11597
|
return yield* service.assemble(input);
|
|
@@ -11552,7 +11834,7 @@ var layer40 = (config) => Layer56.mergeAll(Layer56.succeed(exports_permissions.P
|
|
|
11552
11834
|
|
|
11553
11835
|
// ../runtime/src/agent/relay-steering.ts
|
|
11554
11836
|
import { Clock as Clock7, Effect as Effect63, Layer as Layer57, Schema as Schema59 } from "effect";
|
|
11555
|
-
import { Prompt as
|
|
11837
|
+
import { Prompt as Prompt11 } from "effect/unstable/ai";
|
|
11556
11838
|
var jsonValue4 = (value) => Schema59.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
11557
11839
|
var stringifyJson2 = (value) => JSON.stringify(jsonValue4(value));
|
|
11558
11840
|
var createdAtForSequence2 = (config, sequence) => config.startedAt + sequence - config.eventSequence;
|
|
@@ -11571,22 +11853,22 @@ var purePromptPart = (part) => {
|
|
|
11571
11853
|
};
|
|
11572
11854
|
var contentToPromptPart2 = (part) => {
|
|
11573
11855
|
const pure = purePromptPart(part);
|
|
11574
|
-
return pure === undefined ?
|
|
11856
|
+
return pure === undefined ? Prompt11.makePart("text", { text: stringifyJson2(part) }) : contentToPromptPart(pure);
|
|
11575
11857
|
};
|
|
11576
|
-
var promptForContent = (content) =>
|
|
11577
|
-
|
|
11578
|
-
content: content.length === 0 ? [
|
|
11858
|
+
var promptForContent = (content) => Prompt11.fromMessages([
|
|
11859
|
+
Prompt11.makeMessage("user", {
|
|
11860
|
+
content: content.length === 0 ? [Prompt11.makePart("text", { text: "" })] : content.map((part) => contentToPromptPart2(part))
|
|
11579
11861
|
})
|
|
11580
11862
|
]);
|
|
11581
11863
|
var promptTextParts = (prompt) => prompt.content.flatMap((message) => typeof message.content === "string" ? [exports_content_schema.text(message.content)] : message.content.flatMap((part) => part.type === "text" ? [exports_content_schema.text(part.text)] : []));
|
|
11582
11864
|
var contentFromMessage = (message) => {
|
|
11583
11865
|
if (typeof message.prompt === "string")
|
|
11584
11866
|
return [exports_content_schema.text(message.prompt)];
|
|
11585
|
-
const prompt =
|
|
11867
|
+
const prompt = Prompt11.make(message.prompt);
|
|
11586
11868
|
const textParts = promptTextParts(prompt);
|
|
11587
11869
|
if (textParts.length > 0)
|
|
11588
11870
|
return textParts;
|
|
11589
|
-
return [exports_content_schema.text(stringifyJson2(Schema59.encodeSync(
|
|
11871
|
+
return [exports_content_schema.text(stringifyJson2(Schema59.encodeSync(Prompt11.Prompt)(prompt)))];
|
|
11590
11872
|
};
|
|
11591
11873
|
var steeringReceivedEvent = (config, kind, drain2, messages, sequence) => ({
|
|
11592
11874
|
id: exports_ids_schema.EventId.make(`event:${drain2.drainId}:received`),
|
|
@@ -11961,10 +12243,13 @@ var toolFromDefinition = (definition) => dynamicTool(definition.name, {
|
|
|
11961
12243
|
...definition.metadata === undefined ? {} : { metadata: definition.metadata },
|
|
11962
12244
|
run: () => Effect67.die("model-facing toolkit is not executed")
|
|
11963
12245
|
}).tool;
|
|
11964
|
-
var toolkitFromRegistered = (registered) =>
|
|
11965
|
-
var handlersForToolExecutor = (registered) => Object.fromEntries(registered.map((tool2) => [
|
|
12246
|
+
var toolkitFromRegistered = (registered) => Toolkit7.make(...registered.map(toolFromRegistered));
|
|
12247
|
+
var handlersForToolExecutor = (registered) => Object.fromEntries(registered.map((tool2) => [
|
|
12248
|
+
tool2.definition.name,
|
|
12249
|
+
() => Effect67.die(`Relay ToolExecutor must execute ${tool2.definition.name}`)
|
|
12250
|
+
]));
|
|
11966
12251
|
var persistTranscript = (chats, input, transcript) => Effect67.gen(function* () {
|
|
11967
|
-
const chat = yield*
|
|
12252
|
+
const chat = yield* Chat3.fromPrompt(transcript);
|
|
11968
12253
|
const exportData = yield* chat.export.pipe(Effect67.mapError((error) => loopError(error, input.eventSequence + 1)));
|
|
11969
12254
|
yield* chats.save({ executionId: input.executionId, exportData, updatedAt: input.completedAt }).pipe(Effect67.mapError((error) => loopError(error, input.eventSequence + 1)));
|
|
11970
12255
|
});
|
|
@@ -11976,7 +12261,7 @@ var restoreHistory = Effect67.fn("AgentLoop.restoreHistory")(function* (chats, i
|
|
|
11976
12261
|
next_event_sequence: input.eventSequence + 1
|
|
11977
12262
|
}));
|
|
11978
12263
|
}
|
|
11979
|
-
const chat = yield*
|
|
12264
|
+
const chat = yield* Chat3.fromExport(record2.exportData).pipe(Effect67.mapError((error) => loopError(error, input.eventSequence + 1)));
|
|
11980
12265
|
return yield* Ref18.get(chat.history);
|
|
11981
12266
|
});
|
|
11982
12267
|
var saveContextEpoch = Effect67.fn("AgentLoop.saveContextEpoch")(function* (epochs, input, epoch) {
|
|
@@ -12040,9 +12325,9 @@ var terminalMemoryTranscript = (prompt, text3) => {
|
|
|
12040
12325
|
return;
|
|
12041
12326
|
if (promptHasAssistantText(prompt, text3))
|
|
12042
12327
|
return prompt;
|
|
12043
|
-
return
|
|
12328
|
+
return Prompt12.fromMessages([
|
|
12044
12329
|
...prompt.content,
|
|
12045
|
-
|
|
12330
|
+
Prompt12.makeMessage("assistant", { content: [Prompt12.makePart("text", { text: text3 })] })
|
|
12046
12331
|
]);
|
|
12047
12332
|
};
|
|
12048
12333
|
var recallOnlyMemory = (memory) => exports_memory.Memory.of({
|
|
@@ -12089,7 +12374,7 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12089
12374
|
const permissionRules = yield* Effect67.serviceOption(exports_permission_rule_repository.Service);
|
|
12090
12375
|
const steeringRepository = yield* Effect67.serviceOption(exports_steering_repository.Service);
|
|
12091
12376
|
const waits = yield* Effect67.serviceOption(Service25);
|
|
12092
|
-
const tokenizer = yield* Effect67.serviceOption(
|
|
12377
|
+
const tokenizer = yield* Effect67.serviceOption(Tokenizer4.Tokenizer);
|
|
12093
12378
|
return Service41.of({
|
|
12094
12379
|
run: Effect67.fn("AgentLoop.run")(function* (input) {
|
|
12095
12380
|
const existing = yield* existingOutput(eventLog, input);
|
|
@@ -12106,7 +12391,7 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12106
12391
|
yield* appendEvent(eventLog, inputPreparedEvent(input, definitions2), input.eventSequence + 1);
|
|
12107
12392
|
const toolOutputMaxBytes = yield* effectiveToolOutputMaxBytes(input);
|
|
12108
12393
|
const compactionOptions = yield* effectiveCompactionOptions(input);
|
|
12109
|
-
const runTokenizer = yield* Effect67.serviceOption(
|
|
12394
|
+
const runTokenizer = yield* Effect67.serviceOption(Tokenizer4.Tokenizer);
|
|
12110
12395
|
const activeTokenizer = Option22.isSome(runTokenizer) ? runTokenizer : tokenizer;
|
|
12111
12396
|
const allocator = yield* make12(input.eventSequence + 1);
|
|
12112
12397
|
const toolkit = toolkitFromRegistered(registered);
|
|
@@ -12286,13 +12571,13 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12286
12571
|
}
|
|
12287
12572
|
});
|
|
12288
12573
|
const runFold = Effect67.gen(function* () {
|
|
12289
|
-
const base = yield*
|
|
12574
|
+
const base = yield* LanguageModel6.LanguageModel;
|
|
12290
12575
|
const sessionStore = input.sessionId !== undefined && Option22.isSome(sessionRepository) ? yield* make8(input.sessionId, input.sessionEntryScope ?? input.executionId).pipe(Effect67.provideService(exports_session_repository.Service, sessionRepository.value)) : undefined;
|
|
12291
|
-
const folded = exports_agent.stream(agent, batonOptions).pipe(
|
|
12576
|
+
const folded = exports_agent.stream(agent, batonOptions).pipe(Stream8.runFoldEffect(() => ({ text: "", transcript: undefined, turn: undefined, tokensUsed: seededTokens }), foldEvent), Effect67.provideService(LanguageModel6.LanguageModel, base), Effect67.provideService(exports_model_resilience.ModelResilience, policy), Effect67.provide(executorLayer), Effect67.provide(handlerLayer), Effect67.provide(layer39), Effect67.provide(exports_model_middleware.identityLayer), Effect67.provide(instructionsLayer), Effect67.provide(permissionsLayer), Effect67.provide(steeringLayer));
|
|
12292
12577
|
const withToolOutput = toolOutputStore === undefined ? folded : folded.pipe(Effect67.provideService(exports_tool_output.ToolOutputStore, toolOutputStore));
|
|
12293
12578
|
const withCompaction = compactionService === undefined ? withToolOutput : withToolOutput.pipe(Effect67.provideService(exports_compaction.Compaction, compactionService));
|
|
12294
12579
|
const withSession = sessionStore === undefined ? withCompaction : withCompaction.pipe(Effect67.provideService(exports_session.SessionStore, sessionStore));
|
|
12295
|
-
const withTokenizer = Option22.isNone(activeTokenizer) ? withSession : withSession.pipe(Effect67.provideService(
|
|
12580
|
+
const withTokenizer = Option22.isNone(activeTokenizer) ? withSession : withSession.pipe(Effect67.provideService(Tokenizer4.Tokenizer, activeTokenizer.value));
|
|
12296
12581
|
return yield* memory !== undefined && Option22.isSome(durableMemory) ? withTokenizer.pipe(Effect67.provideService(exports_memory.Memory, recallOnlyMemory(durableMemory.value))) : withTokenizer;
|
|
12297
12582
|
});
|
|
12298
12583
|
const finalState = yield* languageModels.provideForAgent(input.agent, runFold).pipe(Effect67.catch((error) => allocator.current.pipe(Effect67.flatMap((current2) => Effect67.fail(mapBoundaryError(error, current2))))));
|
|
@@ -12304,7 +12589,7 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12304
12589
|
}
|
|
12305
12590
|
}
|
|
12306
12591
|
const schemaRef = input.agent.output_schema_ref;
|
|
12307
|
-
const structuredOutput = schemaRef === undefined || finalState.transcript === undefined ? undefined : yield*
|
|
12592
|
+
const structuredOutput = schemaRef === undefined || finalState.transcript === undefined ? undefined : yield* Chat3.fromPrompt(finalState.transcript).pipe(Effect67.flatMap((chat) => runStructuredTurn(languageModels, schemas, chat, input, schemaRef, completedSequence + 1)));
|
|
12308
12593
|
const structuredPart = structuredOutput === undefined || schemaRef === undefined ? [] : [{ type: "structured", value: structuredOutput, schema_ref: schemaRef }];
|
|
12309
12594
|
yield* appendEvent(eventLog, outputCompletedEvent(input, [...completedContent(finalState.text), ...structuredPart], finalState.text, completedSequence, structuredOutput), completedSequence + 1);
|
|
12310
12595
|
return {
|
|
@@ -12317,7 +12602,7 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12317
12602
|
})
|
|
12318
12603
|
});
|
|
12319
12604
|
}));
|
|
12320
|
-
var
|
|
12605
|
+
var testLayer46 = (implementation) => Layer60.succeed(Service41, Service41.of(implementation));
|
|
12321
12606
|
var run3 = Effect67.fn("AgentLoop.run.call")(function* (input) {
|
|
12322
12607
|
const service = yield* Service41;
|
|
12323
12608
|
return yield* service.run(input);
|
|
@@ -12456,7 +12741,7 @@ var notify = Effect68.fn("ParentNotifier.notify.call")(function* (input) {
|
|
|
12456
12741
|
// ../runtime/src/skill/skill-registry-service.ts
|
|
12457
12742
|
var exports_skill_registry_service = {};
|
|
12458
12743
|
__export(exports_skill_registry_service, {
|
|
12459
|
-
testLayer: () =>
|
|
12744
|
+
testLayer: () => testLayer47,
|
|
12460
12745
|
sourceLayerForExecution: () => sourceLayerForExecution,
|
|
12461
12746
|
sourceForExecution: () => sourceForExecution,
|
|
12462
12747
|
register: () => register9,
|
|
@@ -12589,7 +12874,7 @@ var layer45 = Layer62.effect(Service43, Effect69.gen(function* () {
|
|
|
12589
12874
|
})
|
|
12590
12875
|
});
|
|
12591
12876
|
}));
|
|
12592
|
-
var
|
|
12877
|
+
var testLayer47 = (implementation) => Layer62.succeed(Service43, Service43.of(implementation));
|
|
12593
12878
|
var register9 = Effect69.fn("SkillRegistry.register.call")(function* (input) {
|
|
12594
12879
|
const service = yield* Service43;
|
|
12595
12880
|
return yield* service.register(input);
|
|
@@ -12637,7 +12922,7 @@ var sourceLayerForExecution = (executionId) => Layer62.effect(exports_skill_sour
|
|
|
12637
12922
|
// ../runtime/src/execution/execution-service.ts
|
|
12638
12923
|
var exports_execution_service = {};
|
|
12639
12924
|
__export(exports_execution_service, {
|
|
12640
|
-
testLayer: () =>
|
|
12925
|
+
testLayer: () => testLayer48,
|
|
12641
12926
|
stream: () => stream3,
|
|
12642
12927
|
spawnChildRun: () => spawnChildRun,
|
|
12643
12928
|
send: () => send,
|
|
@@ -12649,7 +12934,7 @@ __export(exports_execution_service, {
|
|
|
12649
12934
|
Service: () => Service44,
|
|
12650
12935
|
ExecutionServiceError: () => ExecutionServiceError
|
|
12651
12936
|
});
|
|
12652
|
-
import { Clock as Clock9, Context as Context57, Effect as Effect70, Layer as Layer63, Option as Option24, Schema as Schema64, Stream as
|
|
12937
|
+
import { Clock as Clock9, Context as Context57, Effect as Effect70, Layer as Layer63, Option as Option24, Schema as Schema64, Stream as Stream9 } from "effect";
|
|
12653
12938
|
import { ShardingConfig } from "effect/unstable/cluster";
|
|
12654
12939
|
class ExecutionServiceError extends Schema64.TaggedErrorClass()("ExecutionServiceError", {
|
|
12655
12940
|
message: Schema64.String,
|
|
@@ -12941,11 +13226,11 @@ var layer46 = Layer63.effect(Service44, Effect70.gen(function* () {
|
|
|
12941
13226
|
...override === undefined ? {} : { override }
|
|
12942
13227
|
}).pipe(Effect70.mapError(mapChildRunError2));
|
|
12943
13228
|
}),
|
|
12944
|
-
stream: (input) => eventLog.stream(input).pipe(
|
|
13229
|
+
stream: (input) => eventLog.stream(input).pipe(Stream9.take(input.limit ?? 1000), Stream9.mapError((error) => mapEventLogError4(error)))
|
|
12945
13230
|
});
|
|
12946
13231
|
}));
|
|
12947
13232
|
var memoryLayer32 = layer46.pipe(Layer63.provide(layer32), Layer63.provide(exports_execution_repository.memoryLayer), Layer63.provide(exports_session_repository.memoryLayer), Layer63.provide(exports_child_execution_repository.memoryLayer), Layer63.provide(memoryLayer21), Layer63.provide(ShardingConfig.layer({ runnerAddress: Option24.none() })));
|
|
12948
|
-
var
|
|
13233
|
+
var testLayer48 = (implementation) => Layer63.succeed(Service44, Service44.of(implementation));
|
|
12949
13234
|
var accept = Effect70.fn("ExecutionService.accept.call")(function* (input) {
|
|
12950
13235
|
const service = yield* Service44;
|
|
12951
13236
|
return yield* service.accept(input);
|
|
@@ -12966,7 +13251,7 @@ var spawnChildRun = Effect70.fn("ExecutionService.spawnChildRun.call")(function*
|
|
|
12966
13251
|
const service = yield* Service44;
|
|
12967
13252
|
return yield* service.spawnChildRun(input);
|
|
12968
13253
|
});
|
|
12969
|
-
var stream3 = (input) =>
|
|
13254
|
+
var stream3 = (input) => Stream9.unwrap(Service44.pipe(Effect70.map((service) => service.stream(input))));
|
|
12970
13255
|
|
|
12971
13256
|
// ../runtime/src/workspace/workspace-planner-service.ts
|
|
12972
13257
|
import { Context as Context59, Effect as Effect72, HashSet as HashSet7, Layer as Layer65, Option as Option25, Schema as Schema66 } from "effect";
|
|
@@ -14016,7 +14301,7 @@ var client = entity.client;
|
|
|
14016
14301
|
// ../runtime/src/envelope/envelope-service.ts
|
|
14017
14302
|
var exports_envelope_service = {};
|
|
14018
14303
|
__export(exports_envelope_service, {
|
|
14019
|
-
testLayer: () =>
|
|
14304
|
+
testLayer: () => testLayer49,
|
|
14020
14305
|
send: () => send2,
|
|
14021
14306
|
memoryLayer: () => memoryLayer33,
|
|
14022
14307
|
layer: () => layer50,
|
|
@@ -14080,16 +14365,16 @@ var waitIdFor = (input) => {
|
|
|
14080
14365
|
return;
|
|
14081
14366
|
return input.waitId ?? exports_ids_schema.WaitId.make(`wait:${input.envelopeId}`);
|
|
14082
14367
|
};
|
|
14083
|
-
var readyFor = (input,
|
|
14084
|
-
if (
|
|
14368
|
+
var readyFor = (input, route2) => {
|
|
14369
|
+
if (route2.kind === "local-agent")
|
|
14085
14370
|
return;
|
|
14086
14371
|
return {
|
|
14087
14372
|
id: exports_ids_schema.EnvelopeReadyId.make(`envelope-ready:${input.envelopeId}`),
|
|
14088
|
-
routeType:
|
|
14089
|
-
routeKey:
|
|
14373
|
+
routeType: route2.kind,
|
|
14374
|
+
routeKey: route2.route_key,
|
|
14090
14375
|
availableAt: input.createdAt,
|
|
14091
14376
|
...input.input.correlation_key === undefined ? {} : { idempotencyKey: input.input.correlation_key },
|
|
14092
|
-
...
|
|
14377
|
+
...route2.metadata === undefined ? {} : { metadata: route2.metadata }
|
|
14093
14378
|
};
|
|
14094
14379
|
};
|
|
14095
14380
|
var acceptedEvent2 = (input) => ({
|
|
@@ -14106,7 +14391,7 @@ var acceptedEvent2 = (input) => ({
|
|
|
14106
14391
|
},
|
|
14107
14392
|
created_at: input.createdAt
|
|
14108
14393
|
});
|
|
14109
|
-
var routedEvent = (input,
|
|
14394
|
+
var routedEvent = (input, route2) => ({
|
|
14110
14395
|
id: exports_ids_schema.EventId.make(`event:${input.envelopeId}:routed`),
|
|
14111
14396
|
execution_id: input.executionId,
|
|
14112
14397
|
type: "envelope.routed",
|
|
@@ -14114,8 +14399,8 @@ var routedEvent = (input, route) => ({
|
|
|
14114
14399
|
cursor: `${input.executionId}:envelope:${input.envelopeId}:routed`,
|
|
14115
14400
|
data: {
|
|
14116
14401
|
envelope_id: input.envelopeId,
|
|
14117
|
-
route_kind:
|
|
14118
|
-
route_key:
|
|
14402
|
+
route_kind: route2.kind,
|
|
14403
|
+
route_key: route2.route_key
|
|
14119
14404
|
},
|
|
14120
14405
|
created_at: input.createdAt + 1
|
|
14121
14406
|
});
|
|
@@ -14145,13 +14430,13 @@ var layer50 = Layer67.effect(Service47, Effect74.gen(function* () {
|
|
|
14145
14430
|
"relay.address.from": input.input.from,
|
|
14146
14431
|
"relay.address.to": input.input.to
|
|
14147
14432
|
});
|
|
14148
|
-
const
|
|
14433
|
+
const route2 = yield* addressBook.resolve(input.input.to).pipe(Effect74.mapError(mapAddressBookError2));
|
|
14149
14434
|
yield* Effect74.annotateCurrentSpan({
|
|
14150
|
-
"relay.route.kind":
|
|
14151
|
-
"relay.route.key":
|
|
14435
|
+
"relay.route.kind": route2.kind,
|
|
14436
|
+
"relay.route.key": route2.route_key
|
|
14152
14437
|
});
|
|
14153
14438
|
const envelope = envelopeFrom(input);
|
|
14154
|
-
const ready = readyFor(input,
|
|
14439
|
+
const ready = readyFor(input, route2);
|
|
14155
14440
|
const waitId = waitIdFor(input);
|
|
14156
14441
|
const accepted2 = yield* repository.acceptEnvelope({
|
|
14157
14442
|
envelope,
|
|
@@ -14159,17 +14444,17 @@ var layer50 = Layer67.effect(Service47, Effect74.gen(function* () {
|
|
|
14159
14444
|
...ready === undefined ? {} : { ready }
|
|
14160
14445
|
}).pipe(Effect74.mapError(mapRepositoryError12));
|
|
14161
14446
|
yield* eventLog.append(acceptedEvent2(input)).pipe(Effect74.mapError(mapEventLogError7));
|
|
14162
|
-
yield* eventLog.append(routedEvent(input,
|
|
14447
|
+
yield* eventLog.append(routedEvent(input, route2)).pipe(Effect74.mapError(mapEventLogError7));
|
|
14163
14448
|
if (ready !== undefined) {
|
|
14164
14449
|
yield* eventLog.append(readyEvent(input, ready)).pipe(Effect74.mapError(mapEventLogError7));
|
|
14165
14450
|
}
|
|
14166
|
-
yield* recordEnvelopeSent(
|
|
14451
|
+
yield* recordEnvelopeSent(route2.kind);
|
|
14167
14452
|
return accepted2;
|
|
14168
14453
|
})
|
|
14169
14454
|
});
|
|
14170
14455
|
}));
|
|
14171
14456
|
var memoryLayer33 = (routes = []) => layer50.pipe(Layer67.provide(memoryLayer20(routes)), Layer67.provide(exports_envelope_repository.memoryLayer), Layer67.provide(memoryLayer21));
|
|
14172
|
-
var
|
|
14457
|
+
var testLayer49 = (implementation) => Layer67.succeed(Service47, Service47.of(implementation));
|
|
14173
14458
|
var send2 = Effect74.fn("EnvelopeService.send.call")(function* (input) {
|
|
14174
14459
|
const service = yield* Service47;
|
|
14175
14460
|
return yield* service.send(input);
|
|
@@ -14180,7 +14465,7 @@ __export(exports_runner_runtime_service, {
|
|
|
14180
14465
|
testLayerWithServices: () => testLayerWithServices,
|
|
14181
14466
|
testLayerWithLanguageModelService: () => testLayerWithLanguageModelService,
|
|
14182
14467
|
testLayerWithDatabaseCheck: () => testLayerWithDatabaseCheck,
|
|
14183
|
-
testLayer: () =>
|
|
14468
|
+
testLayer: () => testLayer51,
|
|
14184
14469
|
testClientLayerWithDatabaseCheck: () => testClientLayerWithDatabaseCheck,
|
|
14185
14470
|
testClientLayer: () => testClientLayer,
|
|
14186
14471
|
shardingConfigFromEnv: () => shardingConfigFromEnv,
|
|
@@ -14203,7 +14488,7 @@ __export(exports_runner_runtime_service, {
|
|
|
14203
14488
|
DatabaseMode: () => DatabaseMode,
|
|
14204
14489
|
ClusterConfigMismatch: () => ClusterConfigMismatch
|
|
14205
14490
|
});
|
|
14206
|
-
import { Config as Config5, Context as Context62, Crypto as Crypto4, Duration as Duration5, Effect as Effect77, Layer as Layer69, Option as Option27, Schema as Schema71, Stream as
|
|
14491
|
+
import { Config as Config5, Context as Context62, Crypto as Crypto4, Duration as Duration5, Effect as Effect77, Layer as Layer69, Option as Option27, Schema as Schema71, Stream as Stream10 } from "effect";
|
|
14207
14492
|
import {
|
|
14208
14493
|
ClusterWorkflowEngine,
|
|
14209
14494
|
HttpRunner,
|
|
@@ -14221,13 +14506,13 @@ import { FetchHttpClient } from "effect/unstable/http";
|
|
|
14221
14506
|
import { SqlClient as SqlClient22 } from "effect/unstable/sql/SqlClient";
|
|
14222
14507
|
import { RpcSerialization } from "effect/unstable/rpc";
|
|
14223
14508
|
import { WorkflowEngine } from "effect/unstable/workflow";
|
|
14224
|
-
import { LanguageModel as
|
|
14509
|
+
import { LanguageModel as LanguageModel7 } from "effect/unstable/ai";
|
|
14225
14510
|
|
|
14226
14511
|
// ../runtime/src/schedule/scheduler-service.ts
|
|
14227
14512
|
var exports_scheduler_service = {};
|
|
14228
14513
|
__export(exports_scheduler_service, {
|
|
14229
14514
|
workerIdConfig: () => workerIdConfig,
|
|
14230
|
-
testLayer: () =>
|
|
14515
|
+
testLayer: () => testLayer50,
|
|
14231
14516
|
startIdempotencyKey: () => startIdempotencyKey,
|
|
14232
14517
|
runOnce: () => runOnce2,
|
|
14233
14518
|
pollIntervalMillisConfig: () => pollIntervalMillisConfig,
|
|
@@ -14284,7 +14569,7 @@ var parseCron = (cronExpr) => {
|
|
|
14284
14569
|
return Result3.isFailure(parsed) ? Effect76.fail(new ScheduleCronInvalid({ cron_expr: cronExpr, message: String(parsed.failure) })) : Effect76.succeed(parsed.success);
|
|
14285
14570
|
};
|
|
14286
14571
|
var startIdempotencyKey = (schedule) => `schedule:${schedule.id}:${schedule.next_run_at}`;
|
|
14287
|
-
var
|
|
14572
|
+
var errorMessage3 = (error) => {
|
|
14288
14573
|
if (error instanceof Error)
|
|
14289
14574
|
return error.message;
|
|
14290
14575
|
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
@@ -14292,7 +14577,7 @@ var errorMessage2 = (error) => {
|
|
|
14292
14577
|
}
|
|
14293
14578
|
return String(error);
|
|
14294
14579
|
};
|
|
14295
|
-
var toSchedulerError = (error) => new SchedulerError({ message:
|
|
14580
|
+
var toSchedulerError = (error) => new SchedulerError({ message: errorMessage3(error) });
|
|
14296
14581
|
var dispatchMetadata = (schedule) => ({
|
|
14297
14582
|
source: "schedule",
|
|
14298
14583
|
schedule_id: schedule.id
|
|
@@ -14412,7 +14697,7 @@ var layer51 = Layer68.effect(Service48, Effect76.gen(function* () {
|
|
|
14412
14697
|
return service;
|
|
14413
14698
|
}));
|
|
14414
14699
|
var memoryLayer34 = Layer68.effect(Service48, make14);
|
|
14415
|
-
var
|
|
14700
|
+
var testLayer50 = (implementation) => Layer68.succeed(Service48, Service48.of(implementation));
|
|
14416
14701
|
var runOnce2 = Effect76.fn("SchedulerService.runOnce.call")(function* () {
|
|
14417
14702
|
const service = yield* Service48;
|
|
14418
14703
|
return yield* service.runOnce;
|
|
@@ -14568,7 +14853,7 @@ var agentLoopLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistry
|
|
|
14568
14853
|
var runtimeServicesLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer) => Layer69.mergeAll(addressResolutionLayerWith(toolRuntimeLayer), layer45, executionServiceLayer, agentLoopLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer), layer47, parentNotifierLayer).pipe(Layer69.provideMerge(layer22), Layer69.provideMerge(layerFromRepository2));
|
|
14569
14854
|
var workflowLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer) => layer48.pipe(Layer69.provideMerge(runtimeServicesLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer)));
|
|
14570
14855
|
var workflowAndEntityLayerWith = (toolRuntimeLayer, schedulerLayer, promptAssemblerLayer, schemaRegistryLayer) => Layer69.mergeAll(layer49, schedulerLayer).pipe(Layer69.provideMerge(workflowLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer)));
|
|
14571
|
-
var
|
|
14856
|
+
var makeService2 = (database, checkDatabase) => Effect77.gen(function* () {
|
|
14572
14857
|
const sharding = yield* Sharding.Sharding;
|
|
14573
14858
|
const workflow = yield* WorkflowEngine.WorkflowEngine;
|
|
14574
14859
|
const makeClient = yield* client;
|
|
@@ -14589,7 +14874,7 @@ var makeService = (database, checkDatabase) => Effect77.gen(function* () {
|
|
|
14589
14874
|
})
|
|
14590
14875
|
});
|
|
14591
14876
|
});
|
|
14592
|
-
var checkLayer = (database, checkDatabase) => Layer69.effect(Service49,
|
|
14877
|
+
var checkLayer = (database, checkDatabase) => Layer69.effect(Service49, makeService2(database, checkDatabase));
|
|
14593
14878
|
var memoryCheckLayer = checkLayer("memory", Effect77.void);
|
|
14594
14879
|
var detectDialect = Effect77.serviceOption(SqlClient22).pipe(Effect77.map(Option27.match({
|
|
14595
14880
|
onNone: () => "sql",
|
|
@@ -14614,7 +14899,7 @@ var databaseHealthCheck = Effect77.gen(function* () {
|
|
|
14614
14899
|
var sqlCheckLayer = Layer69.effect(Service49, Effect77.gen(function* () {
|
|
14615
14900
|
const dialect2 = yield* detectDialect;
|
|
14616
14901
|
const checkDatabase = yield* databaseHealthCheck;
|
|
14617
|
-
return yield*
|
|
14902
|
+
return yield* makeService2(dialect2, checkDatabase);
|
|
14618
14903
|
}));
|
|
14619
14904
|
var makeClientService = (database, checkDatabase) => Effect77.gen(function* () {
|
|
14620
14905
|
const sharding = yield* Sharding.Sharding;
|
|
@@ -14647,9 +14932,9 @@ var sqlClientCheckLayer = Layer69.effect(Service49, Effect77.gen(function* () {
|
|
|
14647
14932
|
const checkDatabase = yield* databaseHealthCheck;
|
|
14648
14933
|
return yield* makeClientService(dialect2, checkDatabase);
|
|
14649
14934
|
}));
|
|
14650
|
-
var deterministicTestModelLayer = Layer69.effect(
|
|
14935
|
+
var deterministicTestModelLayer = Layer69.effect(LanguageModel7.LanguageModel, LanguageModel7.make({
|
|
14651
14936
|
generateText: () => Effect77.succeed([{ type: "text", text: "deterministic test response" }]),
|
|
14652
|
-
streamText: () =>
|
|
14937
|
+
streamText: () => Stream10.make({ type: "text-delta", id: "text", delta: "deterministic test response" })
|
|
14653
14938
|
}));
|
|
14654
14939
|
var testLanguageModelLayer = layerFromRegistrationEffects3([
|
|
14655
14940
|
registrationFromLayer3({
|
|
@@ -14735,7 +15020,7 @@ var testLayerWithServices = (options) => layerWith({
|
|
|
14735
15020
|
schedulerLayer: memoryLayer34
|
|
14736
15021
|
}).pipe(Layer69.provideMerge(testCryptoLayer));
|
|
14737
15022
|
var testLayerWithLanguageModelService = (languageModelLayer) => testLayerWithServices({ languageModelLayer, toolRuntimeLayer: layer23() });
|
|
14738
|
-
var
|
|
15023
|
+
var testLayer51 = testLayerWithServices({
|
|
14739
15024
|
languageModelLayer: testLanguageModelLayer,
|
|
14740
15025
|
toolRuntimeLayer: layer23()
|
|
14741
15026
|
});
|
|
@@ -15020,7 +15305,7 @@ var guard = Effect78.fn("ActivityVersionRegistry.guard")(function* (input) {
|
|
|
15020
15305
|
}));
|
|
15021
15306
|
});
|
|
15022
15307
|
// src/client.ts
|
|
15023
|
-
import { Clock as Clock11, Context as Context63, Effect as Effect79, Layer as Layer70, Option as Option28, Schema as Schema73, SchemaGetter, SchemaIssue, Stream as
|
|
15308
|
+
import { Clock as Clock11, Context as Context63, Effect as Effect79, Layer as Layer70, Option as Option28, Schema as Schema73, SchemaGetter, SchemaIssue, Stream as Stream11 } from "effect";
|
|
15024
15309
|
import { EntityId, ShardId, Sharding as Sharding2, ShardingConfig as ShardingConfig3 } from "effect/unstable/cluster";
|
|
15025
15310
|
|
|
15026
15311
|
class ClientError extends Schema73.TaggedErrorClass()("ClientError", {
|
|
@@ -15030,7 +15315,7 @@ class ClientError extends Schema73.TaggedErrorClass()("ClientError", {
|
|
|
15030
15315
|
|
|
15031
15316
|
class Service50 extends Context63.Service()("@relayfx/sdk/Client") {
|
|
15032
15317
|
}
|
|
15033
|
-
var
|
|
15318
|
+
var errorMessage4 = (error) => {
|
|
15034
15319
|
if (error instanceof Error)
|
|
15035
15320
|
return error.message;
|
|
15036
15321
|
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
@@ -15041,7 +15326,7 @@ var errorMessage3 = (error) => {
|
|
|
15041
15326
|
}
|
|
15042
15327
|
return String(error);
|
|
15043
15328
|
};
|
|
15044
|
-
var toClientError = (error) => new ClientError({ message:
|
|
15329
|
+
var toClientError = (error) => new ClientError({ message: errorMessage4(error) });
|
|
15045
15330
|
var malformedCursor = (wire) => new SchemaIssue.InvalidValue(Option28.some(wire), { message: "Malformed pagination cursor" });
|
|
15046
15331
|
var decodeCursorFields = (wire) => Effect79.gen(function* () {
|
|
15047
15332
|
const decoded = yield* Effect79.try({
|
|
@@ -15138,6 +15423,32 @@ var startExecutionByAgentDefinitionPayload = (input, definition) => ({
|
|
|
15138
15423
|
...input.wait_id === undefined ? {} : { wait_id: input.wait_id },
|
|
15139
15424
|
metadata: metadataWithIdempotencyKey(input.metadata, input.idempotency_key)
|
|
15140
15425
|
});
|
|
15426
|
+
var isRegisterBatonAgentInput = (input) => ("agent" in input);
|
|
15427
|
+
var toolRefsFromBatonAgent = (agent) => {
|
|
15428
|
+
const tools = agent.toolkit.tools;
|
|
15429
|
+
return Object.values(tools).map((tool2) => ({ name: tool2.name }));
|
|
15430
|
+
};
|
|
15431
|
+
var registerAgentPayload = (input) => {
|
|
15432
|
+
if (!isRegisterBatonAgentInput(input))
|
|
15433
|
+
return exports_agent_schema.define(input);
|
|
15434
|
+
return exports_agent_schema.define({
|
|
15435
|
+
id: input.id,
|
|
15436
|
+
name: Schema73.decodeUnknownSync(exports_shared_schema.NonEmptyString)(input.agent.name),
|
|
15437
|
+
...input.agent.instructions === undefined ? {} : { instructions: input.agent.instructions },
|
|
15438
|
+
model: input.model,
|
|
15439
|
+
tools: toolRefsFromBatonAgent(input.agent),
|
|
15440
|
+
permissions: input.permissions ?? [],
|
|
15441
|
+
...input.skill_definition_ids === undefined ? {} : { skill_definition_ids: input.skill_definition_ids },
|
|
15442
|
+
...input.permission_rules === undefined ? {} : { permission_rules: input.permission_rules },
|
|
15443
|
+
...input.max_tool_turns === undefined ? {} : { max_tool_turns: input.max_tool_turns },
|
|
15444
|
+
...input.max_wait_turns === undefined ? {} : { max_wait_turns: input.max_wait_turns },
|
|
15445
|
+
...input.token_budget === undefined ? {} : { token_budget: input.token_budget },
|
|
15446
|
+
...input.child_run_presets === undefined ? {} : { child_run_presets: input.child_run_presets },
|
|
15447
|
+
...input.handoff_targets === undefined ? {} : { handoff_targets: input.handoff_targets },
|
|
15448
|
+
...input.output_schema_ref === undefined ? {} : { output_schema_ref: input.output_schema_ref },
|
|
15449
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
15450
|
+
});
|
|
15451
|
+
};
|
|
15141
15452
|
var agentDefinitionNotFound = (id2) => new ClientError({ message: `Agent not found: ${id2}` });
|
|
15142
15453
|
var wakeMetadata = (input) => ({
|
|
15143
15454
|
...input.metadata,
|
|
@@ -15275,7 +15586,7 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15275
15586
|
const skillRegistry = yield* exports_skill_registry_service.Service;
|
|
15276
15587
|
return Service50.of({
|
|
15277
15588
|
registerAgent: Effect79.fn("Client.runtime.registerAgent")(function* (input) {
|
|
15278
|
-
const payload =
|
|
15589
|
+
const payload = registerAgentPayload(input);
|
|
15279
15590
|
const registered = yield* agentRegistry.register(payload).pipe(Effect79.mapError(toClientError));
|
|
15280
15591
|
if (input.address !== undefined) {
|
|
15281
15592
|
yield* addressBook.register(input.address, { kind: "local-agent", route_key: payload.id }).pipe(Effect79.mapError(toClientError));
|
|
@@ -15448,7 +15759,7 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15448
15759
|
executionId: input.execution_id,
|
|
15449
15760
|
...input.after_cursor === undefined ? {} : { afterCursor: input.after_cursor },
|
|
15450
15761
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
15451
|
-
}).pipe(
|
|
15762
|
+
}).pipe(Stream11.mapError(toClientError)),
|
|
15452
15763
|
wake: Effect79.fn("Client.runtime.wake")(function* (input) {
|
|
15453
15764
|
return yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, input);
|
|
15454
15765
|
}),
|
|
@@ -15557,7 +15868,7 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15557
15868
|
})
|
|
15558
15869
|
});
|
|
15559
15870
|
}));
|
|
15560
|
-
var
|
|
15871
|
+
var testLayer52 = (implementation) => Layer70.succeed(Service50, Service50.of(implementation));
|
|
15561
15872
|
var registerAgentDefinition = Effect79.fn("Client.registerAgentDefinition.call")(function* (input) {
|
|
15562
15873
|
const service = yield* Service50;
|
|
15563
15874
|
return yield* service.registerAgentDefinition(input);
|
|
@@ -15658,7 +15969,7 @@ var send3 = Effect79.fn("Client.send.call")(function* (input) {
|
|
|
15658
15969
|
const service = yield* Service50;
|
|
15659
15970
|
return yield* service.send(input);
|
|
15660
15971
|
});
|
|
15661
|
-
var streamExecution = (input) =>
|
|
15972
|
+
var streamExecution = (input) => Stream11.unwrap(Service50.pipe(Effect79.map((service) => service.streamExecution(input))));
|
|
15662
15973
|
var wake2 = Effect79.fn("Client.wake.call")(function* (input) {
|
|
15663
15974
|
const service = yield* Service50;
|
|
15664
15975
|
return yield* service.wake(input);
|
|
@@ -15728,7 +16039,7 @@ var layer53 = Layer71.effect(Service51, Effect80.gen(function* () {
|
|
|
15728
16039
|
})
|
|
15729
16040
|
});
|
|
15730
16041
|
}));
|
|
15731
|
-
var
|
|
16042
|
+
var testLayer53 = (implementation) => Layer71.succeed(Service51, Service51.of(implementation));
|
|
15732
16043
|
var claim = Effect80.fn("AdapterOutbox.claim.call")(function* (input) {
|
|
15733
16044
|
const service = yield* Service51;
|
|
15734
16045
|
return yield* service.claim(input);
|
|
@@ -15748,7 +16059,7 @@ var submitInbound = Effect80.fn("AdapterOutbox.submitInbound.call")(function* (i
|
|
|
15748
16059
|
// src/database.ts
|
|
15749
16060
|
var exports_database = {};
|
|
15750
16061
|
__export(exports_database, {
|
|
15751
|
-
testLayer: () =>
|
|
16062
|
+
testLayer: () => testLayer54,
|
|
15752
16063
|
pgTypeParsers: () => pgTypeParsers2,
|
|
15753
16064
|
layerFromPgClient: () => layerFromPgClient2,
|
|
15754
16065
|
dialect: () => dialect2,
|
|
@@ -15758,7 +16069,7 @@ __export(exports_database, {
|
|
|
15758
16069
|
});
|
|
15759
16070
|
var Service52 = exports_database_service.Service;
|
|
15760
16071
|
var layerFromPgClient2 = exports_database_service.layerFromPgClient;
|
|
15761
|
-
var
|
|
16072
|
+
var testLayer54 = exports_database_service.testLayer;
|
|
15762
16073
|
var check3 = exports_database_service.check;
|
|
15763
16074
|
var pgTypeParsers2 = exports_database_service.pgTypeParsers;
|
|
15764
16075
|
var Dialect2 = exports_database_service.Dialect;
|
|
@@ -16102,7 +16413,7 @@ __export(exports_language_model_registration, {
|
|
|
16102
16413
|
anthropic: () => anthropic
|
|
16103
16414
|
});
|
|
16104
16415
|
|
|
16105
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16416
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.0/node_modules/@batonfx/providers/src/anthropic.ts
|
|
16106
16417
|
import { AnthropicClient, AnthropicLanguageModel } from "@effect/ai-anthropic";
|
|
16107
16418
|
import { Layer as Layer72 } from "effect";
|
|
16108
16419
|
import { FetchHttpClient as FetchHttpClient2 } from "effect/unstable/http";
|
|
@@ -16118,13 +16429,13 @@ var anthropic = (input) => exports_model_registry.registrationFromLayer({
|
|
|
16118
16429
|
});
|
|
16119
16430
|
var anthropicClientLayerConfig = AnthropicClient.layerConfig;
|
|
16120
16431
|
var withAnthropic = (options) => exports_model_registry.layerFromRegistrationEffects([anthropic(options)]).pipe(Layer72.provide(AnthropicClient.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })), Layer72.provide(FetchHttpClient2.layer));
|
|
16121
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16432
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.0/node_modules/@batonfx/providers/src/deterministic.ts
|
|
16122
16433
|
import { OpenAiClient as OpenAiClient3 } from "@effect/ai-openai";
|
|
16123
|
-
import { Effect as Effect81, Layer as Layer74, Option as Option29, Stream as
|
|
16124
|
-
import { LanguageModel as
|
|
16434
|
+
import { Effect as Effect81, Layer as Layer74, Option as Option29, Stream as Stream12 } from "effect";
|
|
16435
|
+
import { LanguageModel as LanguageModel8, Response as Response7 } from "effect/unstable/ai";
|
|
16125
16436
|
import { FetchHttpClient as FetchHttpClient4 } from "effect/unstable/http";
|
|
16126
16437
|
|
|
16127
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16438
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.0/node_modules/@batonfx/providers/src/openai.ts
|
|
16128
16439
|
import { OpenAiClient as OpenAiClient2, OpenAiLanguageModel } from "@effect/ai-openai";
|
|
16129
16440
|
import { Layer as Layer73 } from "effect";
|
|
16130
16441
|
import { FetchHttpClient as FetchHttpClient3 } from "effect/unstable/http";
|
|
@@ -16141,10 +16452,10 @@ var openAi = (input) => exports_model_registry.registrationFromLayer({
|
|
|
16141
16452
|
var openAiClientLayerConfig2 = OpenAiClient2.layerConfig;
|
|
16142
16453
|
var withOpenAi = (options) => exports_model_registry.layerFromRegistrationEffects([openAi(options)]).pipe(Layer73.provide(OpenAiClient2.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })), Layer73.provide(FetchHttpClient3.layer));
|
|
16143
16454
|
|
|
16144
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16145
|
-
var deterministicModelLayer = Layer74.effect(
|
|
16455
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.0/node_modules/@batonfx/providers/src/deterministic.ts
|
|
16456
|
+
var deterministicModelLayer = Layer74.effect(LanguageModel8.LanguageModel, LanguageModel8.make({
|
|
16146
16457
|
generateText: () => Effect81.succeed([{ type: "text", text: "deterministic response" }]),
|
|
16147
|
-
streamText: () =>
|
|
16458
|
+
streamText: () => Stream12.make(Response7.makePart("text-delta", { id: "text", delta: "deterministic response" }))
|
|
16148
16459
|
}));
|
|
16149
16460
|
var deterministicModel = (input = {}) => exports_model_registry.registrationFromLayer({
|
|
16150
16461
|
provider: input.provider ?? "deterministic",
|
|
@@ -16165,7 +16476,7 @@ var withOpenAiOrDeterministic = (options) => Layer74.unwrap(Effect81.gen(functio
|
|
|
16165
16476
|
...Option29.isSome(openAiRegistration) ? [openAiRegistration.value] : []
|
|
16166
16477
|
]);
|
|
16167
16478
|
}));
|
|
16168
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16479
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.0/node_modules/@batonfx/providers/src/openai-compat.ts
|
|
16169
16480
|
import { OpenAiClient as OpenAiClient4, OpenAiLanguageModel as OpenAiLanguageModel2 } from "@effect/ai-openai-compat";
|
|
16170
16481
|
import { Config as Config8, Layer as Layer75 } from "effect";
|
|
16171
16482
|
import { FetchHttpClient as FetchHttpClient5 } from "effect/unstable/http";
|
|
@@ -16186,7 +16497,7 @@ var clientLayerConfig = (options) => OpenAiClient4.layerConfig({
|
|
|
16186
16497
|
...options.baseUrl === undefined ? {} : { apiUrl: Config8.succeed(options.baseUrl) }
|
|
16187
16498
|
});
|
|
16188
16499
|
var withOpenAiCompatible = (options) => exports_model_registry.layerFromRegistrationEffects([openAiCompatible(options)]).pipe(Layer75.provide(clientLayerConfig(options)), Layer75.provide(FetchHttpClient5.layer));
|
|
16189
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16500
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.0/node_modules/@batonfx/providers/src/openrouter.ts
|
|
16190
16501
|
import { OpenRouterClient, OpenRouterLanguageModel } from "@effect/ai-openrouter";
|
|
16191
16502
|
import { Layer as Layer76 } from "effect";
|
|
16192
16503
|
import { FetchHttpClient as FetchHttpClient6 } from "effect/unstable/http";
|