@relayfx/sdk 0.0.40 → 0.0.42
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 +15458 -0
- package/dist/index.js +942 -589
- 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.1/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
|
|
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 Schema46, 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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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,24 @@ 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.1/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
|
+
sandbox: () => sandbox,
|
|
9232
|
+
router: () => router,
|
|
9233
|
+
routeToolkit: () => routeToolkit,
|
|
9234
|
+
route: () => route,
|
|
9235
|
+
remote: () => remote,
|
|
9236
|
+
mcp: () => mcp,
|
|
9182
9237
|
fromToolkit: () => fromToolkit,
|
|
9183
9238
|
executeToolkit: () => executeToolkit,
|
|
9239
|
+
client: () => client,
|
|
9184
9240
|
ToolExecutor: () => ToolExecutor
|
|
9185
9241
|
});
|
|
9186
|
-
import { Cause as Cause2, Context as Context41, Effect as Effect43, Layer as Layer41, Option as Option14, Sink, Stream as
|
|
9242
|
+
import { Cause as Cause2, Context as Context41, Effect as Effect43, Layer as Layer41, Option as Option14, Schema as Schema45, Sink as Sink2, Stream as Stream6 } from "effect";
|
|
9187
9243
|
class ToolExecutor extends Context41.Service()("@batonfx/core/ToolExecutor") {
|
|
9188
9244
|
}
|
|
9189
9245
|
var failureMessage = (cause) => {
|
|
@@ -9203,11 +9259,29 @@ var resultMessage = (result) => {
|
|
|
9203
9259
|
return String(result);
|
|
9204
9260
|
}
|
|
9205
9261
|
};
|
|
9262
|
+
var schemaMessage = (error) => error instanceof Error ? error.message : typeof error === "string" ? error : resultMessage(error);
|
|
9263
|
+
var decodeSuccess = (tool2, result) => {
|
|
9264
|
+
const successSchema = tool2.successSchema;
|
|
9265
|
+
if (!Schema45.isSchema(successSchema)) {
|
|
9266
|
+
return Effect43.succeed({ _tag: "Success", result, encodedResult: result });
|
|
9267
|
+
}
|
|
9268
|
+
return Schema45.decodeUnknownEffect(successSchema)(result).pipe(Effect43.flatMap((decoded) => Schema45.encodeUnknownEffect(successSchema)(decoded).pipe(Effect43.map((encoded) => ({ _tag: "Success", result: decoded, encodedResult: encoded })))), Effect43.catchCause((cause) => Effect43.succeed(failureOutcome(`invalid client result: ${schemaMessage(Cause2.squash(cause))}`))));
|
|
9269
|
+
};
|
|
9270
|
+
var placementOutcome = (placement, tool2, response) => {
|
|
9271
|
+
switch (response._tag) {
|
|
9272
|
+
case "Failure":
|
|
9273
|
+
return Effect43.succeed(failureOutcome(response.message));
|
|
9274
|
+
case "Suspend":
|
|
9275
|
+
return Effect43.succeed({ _tag: "Suspend", token: response.token });
|
|
9276
|
+
case "Success":
|
|
9277
|
+
return decodeSuccess(tool2, response.result).pipe(Effect43.map((outcome) => outcome._tag === "Failure" ? failureOutcome(outcome.message.replace("invalid client result", `invalid ${placement} result`)) : outcome));
|
|
9278
|
+
}
|
|
9279
|
+
};
|
|
9206
9280
|
var executeWithToolkit = (toolkit, request) => {
|
|
9207
9281
|
if (toolkit.tools[request.call.name] === undefined) {
|
|
9208
9282
|
return Effect43.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
|
|
9209
9283
|
}
|
|
9210
|
-
return toolkit.handle(request.call.name, request.call.params).pipe(Effect43.flatMap((results) => results.pipe(
|
|
9284
|
+
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
9285
|
onNone: () => failureOutcome("Tool handler did not produce a final result"),
|
|
9212
9286
|
onSome: (result) => result.isFailure ? failureOutcome(resultMessage(result.result)) : {
|
|
9213
9287
|
_tag: "Success",
|
|
@@ -9232,9 +9306,51 @@ function fromToolkit(toolkit) {
|
|
|
9232
9306
|
execute: (request) => executeWithToolkit(handled, request)
|
|
9233
9307
|
}))));
|
|
9234
9308
|
}
|
|
9235
|
-
var
|
|
9309
|
+
var route = (options) => {
|
|
9310
|
+
const routedTools = options.tools ?? [];
|
|
9311
|
+
return {
|
|
9312
|
+
tools: routedTools,
|
|
9313
|
+
matches: (request) => routedTools.includes(request.call.name) || options.matches?.(request) === true,
|
|
9314
|
+
execute: options.execute
|
|
9315
|
+
};
|
|
9316
|
+
};
|
|
9317
|
+
var placementRoute = (placement, options) => {
|
|
9318
|
+
const routedTools = options.tools ?? Object.keys(options.toolkit.tools);
|
|
9319
|
+
return route({
|
|
9320
|
+
tools: routedTools,
|
|
9321
|
+
execute: (request) => {
|
|
9322
|
+
const tool2 = options.toolkit.tools[request.call.name];
|
|
9323
|
+
if (tool2 === undefined)
|
|
9324
|
+
return Effect43.succeed(failureOutcome(`Tool ${request.call.name} is not registered`));
|
|
9325
|
+
const effect = options.execute({ ...request, placement, tool: tool2 });
|
|
9326
|
+
const scheduled = "schedule" in options && options.schedule !== undefined ? Effect43.retry(effect, options.schedule) : effect;
|
|
9327
|
+
return scheduled.pipe(Effect43.flatMap((response) => placementOutcome(placement, tool2, response)), Effect43.catchCause((cause) => Cause2.hasInterrupts(cause) ? Effect43.interrupt : Effect43.succeed(failureOutcome(`${placement} tool infrastructure failed: ${failureMessage(cause)}`))));
|
|
9328
|
+
}
|
|
9329
|
+
});
|
|
9330
|
+
};
|
|
9331
|
+
var client = (options) => placementRoute("client", options);
|
|
9332
|
+
var remote = (options) => placementRoute("remote", options);
|
|
9333
|
+
var mcp = (options) => placementRoute("mcp", options);
|
|
9334
|
+
var sandbox = (options) => placementRoute("sandbox", options);
|
|
9335
|
+
function routeToolkit(toolkit) {
|
|
9336
|
+
const makeRoute = (handled) => route({
|
|
9337
|
+
tools: Object.keys(handled.tools),
|
|
9338
|
+
execute: (request) => executeWithToolkit(handled, request)
|
|
9339
|
+
});
|
|
9340
|
+
return "handle" in toolkit ? makeRoute(toolkit) : toolkit.pipe(Effect43.map(makeRoute));
|
|
9341
|
+
}
|
|
9342
|
+
var routeInputEffect = (input) => Effect43.isEffect(input) ? input : Effect43.succeed(input);
|
|
9343
|
+
function router(routes) {
|
|
9344
|
+
return Layer41.effect(ToolExecutor, Effect43.all(Array.from(routes, routeInputEffect)).pipe(Effect43.map((resolved) => ToolExecutor.of({
|
|
9345
|
+
execute: (request) => {
|
|
9346
|
+
const matched = resolved.find((candidate) => candidate.matches(request));
|
|
9347
|
+
return matched === undefined ? Effect43.succeed(failureOutcome(`Tool ${request.call.name} is not registered`)) : matched.execute(request);
|
|
9348
|
+
}
|
|
9349
|
+
}))));
|
|
9350
|
+
}
|
|
9351
|
+
var testLayer37 = (implementation) => Layer41.succeed(ToolExecutor, ToolExecutor.of(implementation));
|
|
9236
9352
|
|
|
9237
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
9353
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.1/node_modules/@batonfx/core/src/turn-policy.ts
|
|
9238
9354
|
var exports_turn_policy = {};
|
|
9239
9355
|
__export(exports_turn_policy, {
|
|
9240
9356
|
untilToolCall: () => untilToolCall,
|
|
@@ -9273,27 +9389,27 @@ var both = (first, second) => make4((info) => Effect44.gen(function* () {
|
|
|
9273
9389
|
}));
|
|
9274
9390
|
var defaultPolicy = recurs(8);
|
|
9275
9391
|
|
|
9276
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
9392
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.1/node_modules/@batonfx/core/src/agent.ts
|
|
9277
9393
|
function make5(nameOrOptions, options = {}) {
|
|
9278
9394
|
const resolved = typeof nameOrOptions === "string" ? { ...options, name: nameOrOptions } : nameOrOptions;
|
|
9279
9395
|
return {
|
|
9280
9396
|
name: resolved.name,
|
|
9281
9397
|
...resolved.instructions === undefined ? {} : { instructions: resolved.instructions },
|
|
9282
|
-
toolkit: resolved.toolkit ??
|
|
9398
|
+
toolkit: resolved.toolkit ?? Toolkit3.empty,
|
|
9283
9399
|
policy: resolved.policy ?? defaultPolicy
|
|
9284
9400
|
};
|
|
9285
9401
|
}
|
|
9286
9402
|
var defaultObjectPrompt = "Return the final structured output for the task above.";
|
|
9287
9403
|
var skillListingBudgetTokens = 2048;
|
|
9288
9404
|
var activateSkillToolName = "activate_skill";
|
|
9289
|
-
var activateSkillParameters =
|
|
9405
|
+
var activateSkillParameters = Schema46.Struct({ name: Schema46.String });
|
|
9290
9406
|
var activateSkillTool = Tool4.make(activateSkillToolName, {
|
|
9291
9407
|
description: "Load the full body for one listed Baton skill by name before applying that skill.",
|
|
9292
9408
|
parameters: activateSkillParameters,
|
|
9293
|
-
success:
|
|
9294
|
-
name:
|
|
9295
|
-
body:
|
|
9296
|
-
allowedTools:
|
|
9409
|
+
success: Schema46.Struct({
|
|
9410
|
+
name: Schema46.String,
|
|
9411
|
+
body: Schema46.String,
|
|
9412
|
+
allowedTools: Schema46.Array(Schema46.String)
|
|
9297
9413
|
})
|
|
9298
9414
|
});
|
|
9299
9415
|
var errorMessage = (error) => error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
@@ -9368,7 +9484,7 @@ var applyPartChain = (chain, part, context) => Effect45.gen(function* () {
|
|
|
9368
9484
|
}
|
|
9369
9485
|
return current2;
|
|
9370
9486
|
});
|
|
9371
|
-
var streamInternal = (agent, options, structured) =>
|
|
9487
|
+
var streamInternal = (agent, options, structured) => Stream7.unwrap(Effect45.gen(function* () {
|
|
9372
9488
|
const executor = yield* Effect45.serviceOption(ToolExecutor);
|
|
9373
9489
|
const approvals = yield* Effect45.serviceOption(Approvals);
|
|
9374
9490
|
const chain = yield* Effect45.serviceOption(ModelMiddleware).pipe(Effect45.map(Option15.match({ onNone: () => [], onSome: (service) => service })));
|
|
@@ -9435,7 +9551,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9435
9551
|
const freshChat = options.history !== undefined ? Chat.fromPrompt(options.history) : system !== undefined ? Chat.fromPrompt([Prompt4.makeMessage("system", { content: system })]) : Chat.empty;
|
|
9436
9552
|
const chat = persisted ?? (yield* freshChat);
|
|
9437
9553
|
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) =>
|
|
9554
|
+
const failSuspended = (call, token, reason) => Stream7.unwrap(savePersisted.pipe(Effect45.as(Stream7.fail(suspended(call, token, reason)))));
|
|
9439
9555
|
const state = {
|
|
9440
9556
|
text: "",
|
|
9441
9557
|
turn: 0,
|
|
@@ -9545,12 +9661,12 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9545
9661
|
case "Success":
|
|
9546
9662
|
return (isSkillActivationCall(call) ? Effect45.succeed(successResult(call, outcome)) : boundedSuccessResult(turn, call, outcome)).pipe(Effect45.map((result) => {
|
|
9547
9663
|
state.pending.push(result);
|
|
9548
|
-
return
|
|
9664
|
+
return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
|
|
9549
9665
|
}));
|
|
9550
9666
|
case "Failure": {
|
|
9551
9667
|
const result = failedResult(call, outcome.message);
|
|
9552
9668
|
state.pending.push(result);
|
|
9553
|
-
return Effect45.succeed(
|
|
9669
|
+
return Effect45.succeed(Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]));
|
|
9554
9670
|
}
|
|
9555
9671
|
case "Suspend":
|
|
9556
9672
|
return Effect45.succeed(failSuspended(call, outcome.token, "tool-wait"));
|
|
@@ -9561,9 +9677,9 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9561
9677
|
return executeToolkit(agent.toolkit, request);
|
|
9562
9678
|
}
|
|
9563
9679
|
const activated = activatedSkillTools.get(request.call.name);
|
|
9564
|
-
return activated === undefined ? Effect45.succeed({ _tag: "Failure", message: `Tool ${request.call.name} is not registered` }) : executeToolkit(
|
|
9680
|
+
return activated === undefined ? Effect45.succeed({ _tag: "Failure", message: `Tool ${request.call.name} is not registered` }) : executeToolkit(Toolkit3.make(activated), request);
|
|
9565
9681
|
};
|
|
9566
|
-
const executeApproved = (turn, call, request) =>
|
|
9682
|
+
const executeApproved = (turn, call, request) => Stream7.concat(Stream7.fromIterable([{ _tag: "ToolExecutionStarted", turn, call }]), Stream7.unwrap(Effect45.gen(function* () {
|
|
9567
9683
|
const progressQueue = yield* Queue2.unbounded();
|
|
9568
9684
|
const signal = yield* Effect45.abortSignal;
|
|
9569
9685
|
const context = ToolContext.of({
|
|
@@ -9585,18 +9701,18 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9585
9701
|
onSome: (service) => service.execute(request)
|
|
9586
9702
|
});
|
|
9587
9703
|
const fiber = yield* execution.pipe(Effect45.provideService(ToolContext, context), Effect45.ensuring(Queue2.end(progressQueue).pipe(Effect45.asVoid)), Effect45.forkScoped({ startImmediately: true }));
|
|
9588
|
-
return
|
|
9704
|
+
return Stream7.concat(Stream7.fromQueue(progressQueue), Stream7.fromEffect(Fiber.join(fiber)).pipe(Stream7.flatMap((outcome) => Stream7.unwrap(outcomeEvents(turn, call, outcome)))));
|
|
9589
9705
|
})));
|
|
9590
9706
|
const permissionError = (turn, error) => new AgentError({ message: error.message, turn, cause: error });
|
|
9591
9707
|
const permissionDeniedEvents = (turn, call, reason) => {
|
|
9592
9708
|
const result = failedResult(call, reason ?? "Permission denied");
|
|
9593
9709
|
state.pending.push(result);
|
|
9594
|
-
return
|
|
9710
|
+
return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
|
|
9595
9711
|
};
|
|
9596
9712
|
const activateSkillOutcome = (turn, call) => Effect45.gen(function* () {
|
|
9597
9713
|
if (skillRuntime === undefined)
|
|
9598
9714
|
return { _tag: "Failure", message: "SkillSource is not available" };
|
|
9599
|
-
const params =
|
|
9715
|
+
const params = Schema46.decodeUnknownOption(activateSkillParameters)(call.params);
|
|
9600
9716
|
if (Option15.isNone(params))
|
|
9601
9717
|
return { _tag: "Failure", message: "Skill activation requires a name" };
|
|
9602
9718
|
const skill = yield* skillRuntime.source.get(params.value.name).pipe(Effect45.mapError((error) => skillError(turn, error)));
|
|
@@ -9624,25 +9740,25 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9624
9740
|
onNone: () => Effect45.void,
|
|
9625
9741
|
onSome: (store) => store.remember({ pattern: call.name, level: "allow" }).pipe(Effect45.mapError((error) => permissionError(turn, error)))
|
|
9626
9742
|
})));
|
|
9627
|
-
const approvalEvents = (turn, call, messages, request, tool2) =>
|
|
9743
|
+
const approvalEvents = (turn, call, messages, request, tool2) => Stream7.unwrap(approvalRequired(tool2, call, messages).pipe(Effect45.map((isRequired) => {
|
|
9628
9744
|
if (!isRequired)
|
|
9629
9745
|
return executeApproved(turn, call, request);
|
|
9630
9746
|
if (Option15.isNone(approvals)) {
|
|
9631
9747
|
const result = failedResult(call, "Approvals service is required for approval-gated tools");
|
|
9632
9748
|
state.pending.push(result);
|
|
9633
|
-
return
|
|
9749
|
+
return Stream7.fromIterable([
|
|
9634
9750
|
{ _tag: "ApprovalRequested", turn, call },
|
|
9635
9751
|
{ _tag: "ToolExecutionCompleted", turn, call, result }
|
|
9636
9752
|
]);
|
|
9637
9753
|
}
|
|
9638
|
-
return
|
|
9754
|
+
return Stream7.concat(Stream7.fromIterable([{ _tag: "ApprovalRequested", turn, call }]), Stream7.unwrap(approvals.value.check(request).pipe(Effect45.map((decision2) => {
|
|
9639
9755
|
switch (decision2._tag) {
|
|
9640
9756
|
case "Approved":
|
|
9641
9757
|
return executeApproved(turn, call, request);
|
|
9642
9758
|
case "Denied": {
|
|
9643
9759
|
const result = failedResult(call, decision2.reason ?? "Tool call denied");
|
|
9644
9760
|
state.pending.push(result);
|
|
9645
|
-
return
|
|
9761
|
+
return Stream7.fromIterable([{ _tag: "ToolExecutionCompleted", turn, call, result }]);
|
|
9646
9762
|
}
|
|
9647
9763
|
case "Pending":
|
|
9648
9764
|
return failSuspended(call, decision2.token, "approval");
|
|
@@ -9656,7 +9772,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9656
9772
|
case "Denied":
|
|
9657
9773
|
return permissionDeniedEvents(turn, call, answer.reason);
|
|
9658
9774
|
case "Always":
|
|
9659
|
-
return
|
|
9775
|
+
return Stream7.unwrap(rememberAlways(turn, call).pipe(Effect45.as(executeApproved(turn, call, request))));
|
|
9660
9776
|
}
|
|
9661
9777
|
};
|
|
9662
9778
|
const permissionAskEvents = (turn, call, request, token) => {
|
|
@@ -9670,7 +9786,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9670
9786
|
};
|
|
9671
9787
|
if (Option15.isNone(permissionsService))
|
|
9672
9788
|
return failSuspended(call, token, "approval");
|
|
9673
|
-
return
|
|
9789
|
+
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
9790
|
onNone: () => failSuspended(call, token, "approval"),
|
|
9675
9791
|
onSome: (answer) => permissionAnsweredEvents(turn, call, request, answer)
|
|
9676
9792
|
})))));
|
|
@@ -9680,7 +9796,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9680
9796
|
const tool2 = currentToolkit().tools[call.name];
|
|
9681
9797
|
if (Option15.isNone(permissionsService))
|
|
9682
9798
|
return approvalEvents(turn, call, messages, request, tool2);
|
|
9683
|
-
return
|
|
9799
|
+
return Stream7.unwrap(permissionsService.value.evaluate({
|
|
9684
9800
|
tool: call.name,
|
|
9685
9801
|
params: call.params,
|
|
9686
9802
|
agentName: agent.name,
|
|
@@ -9728,57 +9844,57 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9728
9844
|
});
|
|
9729
9845
|
const partEvents = (turn, part, messages) => {
|
|
9730
9846
|
if (part.type === "error") {
|
|
9731
|
-
return
|
|
9847
|
+
return Stream7.fail(new AgentError({ message: errorMessage(part.error), turn, cause: part.error }));
|
|
9732
9848
|
}
|
|
9733
|
-
const modelPart =
|
|
9849
|
+
const modelPart = Stream7.fromIterable([{ _tag: "ModelPart", turn, part }]);
|
|
9734
9850
|
if (part.type === "tool-call") {
|
|
9735
9851
|
const call = part;
|
|
9736
|
-
return call.providerExecuted === true ? modelPart :
|
|
9852
|
+
return call.providerExecuted === true ? modelPart : Stream7.concat(modelPart, toolCallEvents(turn, call, messages));
|
|
9737
9853
|
}
|
|
9738
9854
|
if (part.type === "text-delta") {
|
|
9739
9855
|
state.text = `${state.text}${part.delta}`;
|
|
9740
9856
|
}
|
|
9741
9857
|
if (part.type === "finish") {
|
|
9742
|
-
return modelPart.pipe(
|
|
9858
|
+
return modelPart.pipe(Stream7.tap(() => captureFinishPart(part)));
|
|
9743
9859
|
}
|
|
9744
9860
|
return modelPart;
|
|
9745
9861
|
};
|
|
9746
|
-
const applyPartToEvents = (turn, part, messages) =>
|
|
9862
|
+
const applyPartToEvents = (turn, part, messages) => Stream7.unwrap(applyPartChain(chain, part, { agentName: agent.name, turn }).pipe(Effect45.map(Option15.match({
|
|
9747
9863
|
onSome: (transformed) => partEvents(turn, transformed, messages),
|
|
9748
|
-
onNone: () => part.type === "tool-call" ?
|
|
9864
|
+
onNone: () => part.type === "tool-call" ? Stream7.fail(new MiddlewareViolation({
|
|
9749
9865
|
turn,
|
|
9750
9866
|
detail: "ModelMiddleware dropped a tool-call part"
|
|
9751
|
-
})) :
|
|
9867
|
+
})) : Stream7.empty
|
|
9752
9868
|
}))));
|
|
9753
|
-
const currentToolkit = () =>
|
|
9754
|
-
const activeToolkit = (activeTools) =>
|
|
9869
|
+
const currentToolkit = () => Toolkit3.make(...Object.values(agent.toolkit.tools), ...hasActivatableSkills ? [activateSkillTool] : [], ...activatedSkillTools.values());
|
|
9870
|
+
const activeToolkit = (activeTools) => Toolkit3.make(...Object.values(currentToolkit().tools).filter((tool2) => activeTools.includes(tool2.name)));
|
|
9755
9871
|
const modelTurn = (turn, prompt, overrides) => {
|
|
9756
9872
|
const toolkit = overrides?.activeTools === undefined ? currentToolkit() : activeToolkit(overrides.activeTools);
|
|
9757
|
-
const attempt = (activePrompt, retryOverflow) =>
|
|
9873
|
+
const attempt = (activePrompt, retryOverflow) => Stream7.unwrap(Ref10.get(chat.history).pipe(Effect45.map((historyBeforeAttempt) => {
|
|
9758
9874
|
let emitted = false;
|
|
9759
9875
|
const messages = Prompt4.concat(historyBeforeAttempt, activePrompt).content;
|
|
9760
|
-
return chat.streamText({ prompt: activePrompt, toolkit, disableToolCallResolution: true }).pipe(
|
|
9876
|
+
return chat.streamText({ prompt: activePrompt, toolkit, disableToolCallResolution: true }).pipe(Stream7.map((part) => ({ part, messages })), Stream7.tap(() => Effect45.sync(() => {
|
|
9761
9877
|
emitted = true;
|
|
9762
|
-
})),
|
|
9878
|
+
})), Stream7.catchCause((cause) => {
|
|
9763
9879
|
if (Cause3.hasInterrupts(cause))
|
|
9764
|
-
return
|
|
9880
|
+
return Stream7.fromEffect(Effect45.interrupt);
|
|
9765
9881
|
const error = Cause3.squash(cause);
|
|
9766
9882
|
if (retryOverflow && !emitted && isContextOverflow(error) && Option15.isSome(compactionService)) {
|
|
9767
|
-
return
|
|
9883
|
+
return Stream7.unwrap(Effect45.gen(function* () {
|
|
9768
9884
|
yield* Ref10.set(chat.history, historyBeforeAttempt);
|
|
9769
9885
|
const compactedPrompt = yield* preparePrompt(turn, activePrompt, true);
|
|
9770
9886
|
return attempt(compactedPrompt, false);
|
|
9771
9887
|
}));
|
|
9772
9888
|
}
|
|
9773
|
-
return
|
|
9889
|
+
return Stream7.make({ part: Response3.makePart("error", { error }), messages });
|
|
9774
9890
|
}));
|
|
9775
9891
|
})));
|
|
9776
|
-
const parts =
|
|
9892
|
+
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
9893
|
const resilientParts = Option15.match(resilienceService, {
|
|
9778
9894
|
onNone: () => parts,
|
|
9779
|
-
onSome: (resilience) =>
|
|
9895
|
+
onSome: (resilience) => Stream7.unwrap(LanguageModel3.LanguageModel.pipe(Effect45.map((model) => parts.pipe(Stream7.provideService(LanguageModel3.LanguageModel, apply(model, resilience))))))
|
|
9780
9896
|
});
|
|
9781
|
-
return overrides?.model === undefined ? resilientParts : resilientParts.pipe(
|
|
9897
|
+
return overrides?.model === undefined ? resilientParts : resilientParts.pipe(Stream7.provide(overrides.model));
|
|
9782
9898
|
};
|
|
9783
9899
|
const turnCompletedEvent = (turn, transcript) => ({
|
|
9784
9900
|
_tag: "TurnCompleted",
|
|
@@ -9793,7 +9909,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9793
9909
|
transcript,
|
|
9794
9910
|
...state.usage === undefined ? {} : { usage: state.usage }
|
|
9795
9911
|
});
|
|
9796
|
-
const structuredFinalEvents = (turn, config) =>
|
|
9912
|
+
const structuredFinalEvents = (turn, config) => Stream7.fromEffect(Effect45.gen(function* () {
|
|
9797
9913
|
const structuredTurn = turn + 1;
|
|
9798
9914
|
const transformedPrompt = yield* applyPromptChain(chain, Prompt4.make(config.objectPrompt), {
|
|
9799
9915
|
agentName: agent.name,
|
|
@@ -9815,7 +9931,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9815
9931
|
content: response.content
|
|
9816
9932
|
};
|
|
9817
9933
|
return [structuredOutput, terminalCompletedEvent(structuredTurn, transcript)];
|
|
9818
|
-
})).pipe(
|
|
9934
|
+
})).pipe(Stream7.flatMap((events) => Stream7.fromIterable(events)));
|
|
9819
9935
|
const promptFromSteeringMessages = (messages) => messages.reduce((prompt, message) => Prompt4.concat(prompt, message.prompt), Prompt4.empty);
|
|
9820
9936
|
const takeSteering = () => Option15.match(steeringService, {
|
|
9821
9937
|
onNone: () => Effect45.succeed([]),
|
|
@@ -9835,18 +9951,18 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9835
9951
|
const followUp = yield* takeFollowUp();
|
|
9836
9952
|
if (followUp.length > 0) {
|
|
9837
9953
|
return {
|
|
9838
|
-
events:
|
|
9954
|
+
events: Stream7.fromIterable([completed]),
|
|
9839
9955
|
next: { prompt: promptFromSteeringMessages(followUp) }
|
|
9840
9956
|
};
|
|
9841
9957
|
}
|
|
9842
9958
|
if (structured !== undefined) {
|
|
9843
9959
|
return {
|
|
9844
|
-
events:
|
|
9960
|
+
events: Stream7.concat(Stream7.fromIterable([completed]), structuredFinalEvents(turn, structured))
|
|
9845
9961
|
};
|
|
9846
9962
|
}
|
|
9847
9963
|
yield* savePersisted;
|
|
9848
9964
|
return {
|
|
9849
|
-
events:
|
|
9965
|
+
events: Stream7.fromIterable([completed, terminalCompletedEvent(turn, transcript)])
|
|
9850
9966
|
};
|
|
9851
9967
|
}
|
|
9852
9968
|
const decision2 = yield* agent.policy.decide({
|
|
@@ -9856,7 +9972,7 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9856
9972
|
});
|
|
9857
9973
|
if (decision2._tag === "Stop") {
|
|
9858
9974
|
return {
|
|
9859
|
-
events:
|
|
9975
|
+
events: Stream7.concat(Stream7.fromIterable([completed]), Stream7.fail(new TurnLimitExceeded({
|
|
9860
9976
|
turn: turn + 1,
|
|
9861
9977
|
pending: pending.map((result) => ({
|
|
9862
9978
|
tool_call_id: result.id,
|
|
@@ -9871,21 +9987,21 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9871
9987
|
const basePrompt = steering.length === 0 ? toolPrompt : Prompt4.concat(promptFromSteeringMessages(steering), toolPrompt);
|
|
9872
9988
|
const prompt = decision2.overrides?.instructions === undefined ? basePrompt : withSystem(decision2.overrides.instructions, basePrompt);
|
|
9873
9989
|
return {
|
|
9874
|
-
events:
|
|
9990
|
+
events: Stream7.fromIterable([completed]),
|
|
9875
9991
|
next: { prompt, ...decision2.overrides === undefined ? {} : { overrides: decision2.overrides } }
|
|
9876
9992
|
};
|
|
9877
9993
|
});
|
|
9878
|
-
const resetTurnState = (turn) =>
|
|
9994
|
+
const resetTurnState = (turn) => Stream7.sync(() => {
|
|
9879
9995
|
state.turn = turn;
|
|
9880
9996
|
state.finish = undefined;
|
|
9881
|
-
}).pipe(
|
|
9997
|
+
}).pipe(Stream7.drain);
|
|
9882
9998
|
const runTurn = (turn, prompt, overrides) => {
|
|
9883
9999
|
let next;
|
|
9884
|
-
const currentTurn =
|
|
10000
|
+
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
10001
|
next = result.next;
|
|
9886
10002
|
return result.events;
|
|
9887
|
-
})))),
|
|
9888
|
-
return
|
|
10003
|
+
})))), Stream7.withSpan("Baton.Agent.turn", { attributes: { "baton.turn": turn } }));
|
|
10004
|
+
return Stream7.concat(currentTurn, Stream7.suspend(() => next === undefined ? Stream7.empty : runTurn(turn + 1, next.prompt, next.overrides)));
|
|
9889
10005
|
};
|
|
9890
10006
|
const resumeStream = (resume) => {
|
|
9891
10007
|
let next;
|
|
@@ -9895,36 +10011,36 @@ var streamInternal = (agent, options, structured) => Stream6.unwrap(Effect45.gen
|
|
|
9895
10011
|
params: resume.call.params,
|
|
9896
10012
|
providerExecuted: false
|
|
9897
10013
|
});
|
|
9898
|
-
const currentTurn = resetTurnState(0).pipe(
|
|
10014
|
+
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
10015
|
next = result.next;
|
|
9900
10016
|
return result.events;
|
|
9901
|
-
})))),
|
|
9902
|
-
return
|
|
10017
|
+
})))), Stream7.withSpan("Baton.Agent.turn", { attributes: { "baton.turn": 0 } }));
|
|
10018
|
+
return Stream7.concat(currentTurn, Stream7.suspend(() => next === undefined ? Stream7.empty : runTurn(1, next.prompt, next.overrides)));
|
|
9903
10019
|
};
|
|
9904
10020
|
const baseInitialPrompt = seedSystem === undefined ? Prompt4.make(options.prompt) : withSystem(seedSystem, Prompt4.make(options.prompt));
|
|
9905
10021
|
const initialPrompt = options.resume === undefined ? yield* recallInitialPrompt(baseInitialPrompt) : baseInitialPrompt;
|
|
9906
10022
|
const runStream = options.resume === undefined ? runTurn(0, initialPrompt) : resumeStream(options.resume);
|
|
9907
|
-
return runStream.pipe(
|
|
10023
|
+
return runStream.pipe(Stream7.catchCause((cause) => {
|
|
9908
10024
|
if (Cause3.hasInterrupts(cause))
|
|
9909
|
-
return
|
|
10025
|
+
return Stream7.fromEffect(Effect45.interrupt);
|
|
9910
10026
|
const error = Cause3.squash(cause);
|
|
9911
10027
|
if (error instanceof AgentSuspended) {
|
|
9912
|
-
return
|
|
10028
|
+
return Stream7.unwrap(Ref10.get(chat.history).pipe(Effect45.map((transcript) => Stream7.concat(Stream7.fromIterable([turnCompletedEvent(state.turn, transcript)]), Stream7.failCause(cause)))));
|
|
9913
10029
|
}
|
|
9914
|
-
return
|
|
10030
|
+
return Stream7.failCause(cause);
|
|
9915
10031
|
}));
|
|
9916
|
-
})).pipe(
|
|
10032
|
+
})).pipe(Stream7.withSpan("Baton.Agent.run", { attributes: { "baton.agent.name": agent.name } }));
|
|
9917
10033
|
var stream2 = (agent, options) => streamInternal(agent, options, undefined);
|
|
9918
10034
|
var streamObject = (agent, options) => streamInternal(agent, options, {
|
|
9919
10035
|
schema: options.schema,
|
|
9920
10036
|
objectName: options.objectName ?? "output",
|
|
9921
10037
|
objectPrompt: options.objectPrompt ?? defaultObjectPrompt
|
|
9922
10038
|
});
|
|
9923
|
-
var generate = (agent, options) =>
|
|
10039
|
+
var generate = (agent, options) => Stream7.runLast(stream2(agent, options)).pipe(Effect45.flatMap(Option15.match({
|
|
9924
10040
|
onNone: () => Effect45.fail(new AgentError({ message: "Agent run ended without a Completed event", turn: 0 })),
|
|
9925
10041
|
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
10042
|
})));
|
|
9927
|
-
var generateObject = (agent, options) =>
|
|
10043
|
+
var generateObject = (agent, options) => Stream7.runFold(streamObject(agent, options), () => ({
|
|
9928
10044
|
value: Option15.none(),
|
|
9929
10045
|
completed: Option15.none()
|
|
9930
10046
|
}), (acc, event) => {
|
|
@@ -9950,21 +10066,211 @@ var generateObject = (agent, options) => Stream6.runFold(streamObject(agent, opt
|
|
|
9950
10066
|
})
|
|
9951
10067
|
})
|
|
9952
10068
|
})));
|
|
9953
|
-
// ../../node_modules/.bun/@batonfx+core@0.
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
|
|
10069
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.1/node_modules/@batonfx/core/src/agent-tool.ts
|
|
10070
|
+
var exports_agent_tool = {};
|
|
10071
|
+
__export(exports_agent_tool, {
|
|
10072
|
+
asTool: () => asTool
|
|
10073
|
+
});
|
|
10074
|
+
import { Cause as Cause4, Effect as Effect46, Schema as Schema47 } from "effect";
|
|
10075
|
+
import { Tool as Tool5, Toolkit as Toolkit4 } from "effect/unstable/ai";
|
|
10076
|
+
var defaultParameters = Schema47.Struct({ prompt: Schema47.String });
|
|
10077
|
+
var errorMessage2 = (error) => {
|
|
10078
|
+
if (error instanceof AgentSuspended) {
|
|
10079
|
+
return `suspended on ${error.tool_name}: ${error.reason}`;
|
|
10080
|
+
}
|
|
10081
|
+
if (error instanceof AgentError) {
|
|
10082
|
+
return `failed on turn ${error.turn}: ${error.message}`;
|
|
10083
|
+
}
|
|
10084
|
+
if (error instanceof TurnLimitExceeded) {
|
|
10085
|
+
return `turn limit exceeded at turn ${error.turn}`;
|
|
10086
|
+
}
|
|
10087
|
+
if (error instanceof MiddlewareViolation) {
|
|
10088
|
+
return `middleware violation on turn ${error.turn}: ${error.detail}`;
|
|
10089
|
+
}
|
|
10090
|
+
return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
10091
|
+
};
|
|
10092
|
+
var causeMessage = (agentName, cause) => `sub-agent '${agentName}' could not complete: ${errorMessage2(Cause4.squash(cause))}`;
|
|
10093
|
+
var lazyHandled = (toolkit, name, handler) => ({
|
|
10094
|
+
tools: toolkit.tools,
|
|
10095
|
+
handle: (toolName, params) => toolkit.pipe(Effect46.provide(toolkit.toLayer({
|
|
10096
|
+
[name]: handler
|
|
10097
|
+
})), Effect46.flatMap((handled) => handled.handle(toolName, params)))
|
|
10098
|
+
});
|
|
10099
|
+
var asTool = (agent, options = {}) => {
|
|
10100
|
+
const name = options.name ?? agent.name;
|
|
10101
|
+
const parameters = options.parameters ?? defaultParameters;
|
|
10102
|
+
const success2 = options.success ?? Schema47.String;
|
|
10103
|
+
const toPrompt = options.toPrompt ?? ((params) => params.prompt);
|
|
10104
|
+
const fromResult = options.fromResult ?? ((result) => result.text);
|
|
10105
|
+
const tool2 = Tool5.make(name, {
|
|
10106
|
+
...options.description === undefined ? {} : { description: options.description },
|
|
10107
|
+
parameters,
|
|
10108
|
+
success: success2,
|
|
10109
|
+
failure: Schema47.String,
|
|
10110
|
+
failureMode: "return"
|
|
10111
|
+
});
|
|
10112
|
+
const toolkit = Toolkit4.make(tool2);
|
|
10113
|
+
const handler = (params) => Effect46.gen(function* () {
|
|
10114
|
+
const prompt = yield* Effect46.try({ try: () => toPrompt(params), catch: errorMessage2 });
|
|
10115
|
+
const result = yield* generate(agent, { prompt }).pipe(Effect46.catchCause((cause) => {
|
|
10116
|
+
if (Cause4.hasInterrupts(cause))
|
|
10117
|
+
return Effect46.interrupt;
|
|
10118
|
+
const error = Cause4.squash(cause);
|
|
10119
|
+
if (error instanceof AgentSuspended)
|
|
10120
|
+
return Effect46.die(error);
|
|
10121
|
+
return Effect46.fail(causeMessage(agent.name, cause));
|
|
10122
|
+
}));
|
|
10123
|
+
return yield* Effect46.try({ try: () => fromResult(result), catch: errorMessage2 });
|
|
10124
|
+
});
|
|
10125
|
+
return lazyHandled(toolkit, name, handler);
|
|
10126
|
+
};
|
|
10127
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.1/node_modules/@batonfx/core/src/guardrail.ts
|
|
10128
|
+
var exports_guardrail = {};
|
|
10129
|
+
__export(exports_guardrail, {
|
|
10130
|
+
validateInput: () => validateInput2,
|
|
10131
|
+
redactOutput: () => redactOutput,
|
|
10132
|
+
redactInput: () => redactInput,
|
|
10133
|
+
filterOutput: () => filterOutput
|
|
10134
|
+
});
|
|
9958
10135
|
import { Effect as Effect47, Option as Option16 } from "effect";
|
|
9959
10136
|
import { Prompt as Prompt6, Response as Response4 } from "effect/unstable/ai";
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
var
|
|
9964
|
-
|
|
10137
|
+
var replacement = (options) => options.replacement ?? "[redacted]";
|
|
10138
|
+
var redactText = (text3, options) => text3.replace(options.pattern, replacement(options));
|
|
10139
|
+
var redactUserPart = (part, options) => part.type === "text" ? Prompt6.makePart("text", { text: redactText(part.text, options), options: part.options }) : part;
|
|
10140
|
+
var redactAssistantPart = (part, options) => {
|
|
10141
|
+
switch (part.type) {
|
|
10142
|
+
case "text":
|
|
10143
|
+
return Prompt6.makePart("text", { text: redactText(part.text, options), options: part.options });
|
|
10144
|
+
case "reasoning":
|
|
10145
|
+
return Prompt6.makePart("reasoning", { text: redactText(part.text, options), options: part.options });
|
|
10146
|
+
default:
|
|
10147
|
+
return part;
|
|
10148
|
+
}
|
|
10149
|
+
};
|
|
10150
|
+
var redactToolPart = (part, options) => {
|
|
10151
|
+
if (part.type !== "tool-approval-response" || part.reason === undefined)
|
|
10152
|
+
return part;
|
|
10153
|
+
return Prompt6.makePart("tool-approval-response", {
|
|
10154
|
+
approvalId: part.approvalId,
|
|
10155
|
+
approved: part.approved,
|
|
10156
|
+
reason: redactText(part.reason, options),
|
|
10157
|
+
options: part.options
|
|
10158
|
+
});
|
|
10159
|
+
};
|
|
10160
|
+
var redactPromptText = (prompt, options) => Prompt6.fromMessages(prompt.content.map((message) => {
|
|
10161
|
+
switch (message.role) {
|
|
10162
|
+
case "system":
|
|
10163
|
+
return Prompt6.makeMessage("system", {
|
|
10164
|
+
content: redactText(message.content, options),
|
|
10165
|
+
options: message.options
|
|
10166
|
+
});
|
|
10167
|
+
case "user":
|
|
10168
|
+
return Prompt6.makeMessage("user", {
|
|
10169
|
+
content: message.content.map((part) => redactUserPart(part, options)),
|
|
10170
|
+
options: message.options
|
|
10171
|
+
});
|
|
10172
|
+
case "assistant":
|
|
10173
|
+
return Prompt6.makeMessage("assistant", {
|
|
10174
|
+
content: message.content.map((part) => redactAssistantPart(part, options)),
|
|
10175
|
+
options: message.options
|
|
10176
|
+
});
|
|
10177
|
+
case "tool":
|
|
10178
|
+
return Prompt6.makeMessage("tool", {
|
|
10179
|
+
content: message.content.map((part) => redactToolPart(part, options)),
|
|
10180
|
+
options: message.options
|
|
10181
|
+
});
|
|
10182
|
+
}
|
|
10183
|
+
}));
|
|
10184
|
+
var validateInput2 = (check2) => ({
|
|
10185
|
+
transformPrompt: (prompt, context) => check2(prompt, context).pipe(Effect47.flatMap(Option16.match({
|
|
10186
|
+
onNone: () => Effect47.succeed(prompt),
|
|
10187
|
+
onSome: (reason) => Effect47.fail(new AgentError({ message: `Input guardrail blocked: ${reason}`, turn: context.turn }))
|
|
10188
|
+
})))
|
|
10189
|
+
});
|
|
10190
|
+
var redactInput = (options) => ({
|
|
10191
|
+
transformPrompt: (prompt) => Effect47.succeed(redactPromptText(prompt, options))
|
|
10192
|
+
});
|
|
10193
|
+
var redactOutput = (options) => ({
|
|
10194
|
+
transformPart: (part) => {
|
|
10195
|
+
if (part.type !== "text-delta")
|
|
10196
|
+
return Effect47.succeed(Option16.some(part));
|
|
10197
|
+
return Effect47.succeed(Option16.some(Response4.makePart("text-delta", {
|
|
10198
|
+
id: part.id,
|
|
10199
|
+
delta: redactText(part.delta, options),
|
|
10200
|
+
metadata: part.metadata
|
|
10201
|
+
})));
|
|
10202
|
+
}
|
|
10203
|
+
});
|
|
10204
|
+
var filterOutput = (keep) => ({
|
|
10205
|
+
transformPart: (part, context) => Effect47.succeed(part.type === "tool-call" || keep(part, context) ? Option16.some(part) : Option16.none())
|
|
10206
|
+
});
|
|
10207
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.1/node_modules/@batonfx/core/src/handoff.ts
|
|
10208
|
+
var exports_handoff = {};
|
|
10209
|
+
__export(exports_handoff, {
|
|
10210
|
+
transferTool: () => transferTool,
|
|
10211
|
+
supervisor: () => supervisor,
|
|
10212
|
+
fanOut: () => fanOut
|
|
10213
|
+
});
|
|
10214
|
+
import { Effect as Effect48, Schema as Schema48 } from "effect";
|
|
10215
|
+
import { AiError as AiError2, Toolkit as Toolkit5 } from "effect/unstable/ai";
|
|
10216
|
+
var defaultTransferParameters = Schema48.Struct({ prompt: Schema48.String });
|
|
10217
|
+
var transferName = (agentName) => `transfer_to_${agentName}`;
|
|
10218
|
+
var positiveConcurrency = (value) => {
|
|
10219
|
+
const concurrency = value ?? 4;
|
|
10220
|
+
return Number.isInteger(concurrency) && concurrency > 0 ? Effect48.succeed(concurrency) : Effect48.fail(new AgentError({
|
|
10221
|
+
message: "Handoff.fanOut concurrency must be a positive integer",
|
|
10222
|
+
turn: 0
|
|
10223
|
+
}));
|
|
10224
|
+
};
|
|
10225
|
+
var mergeHandled = (toolkits) => {
|
|
10226
|
+
const tools = {};
|
|
10227
|
+
for (const toolkit of toolkits) {
|
|
10228
|
+
Object.assign(tools, toolkit.tools);
|
|
10229
|
+
}
|
|
10230
|
+
return {
|
|
10231
|
+
tools,
|
|
10232
|
+
handle: (name, params) => {
|
|
10233
|
+
const toolkit = toolkits.find((candidate) => candidate.tools[name] !== undefined);
|
|
10234
|
+
return toolkit === undefined ? Effect48.fail(AiError2.make({
|
|
10235
|
+
module: "Handoff",
|
|
10236
|
+
method: `${String(name)}.handle`,
|
|
10237
|
+
reason: new AiError2.ToolNotFoundError({
|
|
10238
|
+
toolName: String(name),
|
|
10239
|
+
availableTools: Object.keys(tools)
|
|
10240
|
+
})
|
|
10241
|
+
})) : toolkit.handle(name, params);
|
|
10242
|
+
}
|
|
10243
|
+
};
|
|
10244
|
+
};
|
|
10245
|
+
var toolkitFromHandled = (toolkit) => Toolkit5.make(...Object.values(toolkit.tools));
|
|
10246
|
+
var transferTool = (target, options = {}) => asTool(target, {
|
|
10247
|
+
name: options.nameOverride ?? transferName(target.name),
|
|
10248
|
+
description: options.description ?? `Transfer to ${target.name}`,
|
|
10249
|
+
...options.parameters === undefined ? {} : { parameters: options.parameters },
|
|
10250
|
+
...options.success === undefined ? {} : { success: options.success },
|
|
10251
|
+
...options.toPrompt === undefined ? {} : { toPrompt: options.toPrompt },
|
|
10252
|
+
...options.fromResult === undefined ? {} : { fromResult: options.fromResult }
|
|
10253
|
+
});
|
|
10254
|
+
var fanOut = (children, options = {}) => positiveConcurrency(options.concurrency).pipe(Effect48.flatMap((concurrency) => Effect48.forEach(children, (child) => generate(child.agent, { ...child.options, prompt: child.prompt }), {
|
|
10255
|
+
concurrency
|
|
10256
|
+
})));
|
|
10257
|
+
var supervisor = (options) => {
|
|
10258
|
+
const transferTools = options.specialists.map((specialist) => transferTool(specialist));
|
|
10259
|
+
const toolkit = mergeHandled(transferTools);
|
|
10260
|
+
return {
|
|
10261
|
+
agent: make5({
|
|
10262
|
+
name: options.name,
|
|
10263
|
+
...options.instructions === undefined ? {} : { instructions: options.instructions },
|
|
10264
|
+
toolkit: toolkitFromHandled(toolkit),
|
|
10265
|
+
...options.policy === undefined ? {} : { policy: options.policy }
|
|
10266
|
+
}),
|
|
10267
|
+
toolkit
|
|
10268
|
+
};
|
|
10269
|
+
};
|
|
10270
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.1/node_modules/@batonfx/core/src/model-registry.ts
|
|
9965
10271
|
var exports_model_registry = {};
|
|
9966
10272
|
__export(exports_model_registry, {
|
|
9967
|
-
testLayer: () =>
|
|
10273
|
+
testLayer: () => testLayer38,
|
|
9968
10274
|
registrations: () => registrations,
|
|
9969
10275
|
registrationFromLayer: () => registrationFromLayer,
|
|
9970
10276
|
register: () => register4,
|
|
@@ -9976,13 +10282,13 @@ __export(exports_model_registry, {
|
|
|
9976
10282
|
Service: () => Service29,
|
|
9977
10283
|
LanguageModelNotRegistered: () => LanguageModelNotRegistered
|
|
9978
10284
|
});
|
|
9979
|
-
import { Chunk as Chunk2, Context as Context42, Effect as Effect49, Layer as Layer43, Option as Option17, Ref as Ref11, Schema as
|
|
10285
|
+
import { Chunk as Chunk2, Context as Context42, Effect as Effect49, Layer as Layer43, Option as Option17, Ref as Ref11, Schema as Schema49, Semaphore as Semaphore3 } from "effect";
|
|
9980
10286
|
import { Model } from "effect/unstable/ai";
|
|
9981
10287
|
|
|
9982
|
-
class LanguageModelNotRegistered extends
|
|
9983
|
-
provider:
|
|
9984
|
-
model:
|
|
9985
|
-
registration_key:
|
|
10288
|
+
class LanguageModelNotRegistered extends Schema49.TaggedErrorClass()("LanguageModelNotRegistered", {
|
|
10289
|
+
provider: Schema49.String,
|
|
10290
|
+
model: Schema49.String,
|
|
10291
|
+
registration_key: Schema49.optionalKey(Schema49.String)
|
|
9986
10292
|
}) {
|
|
9987
10293
|
}
|
|
9988
10294
|
|
|
@@ -10036,7 +10342,7 @@ var layer31 = (initialRegistrations = [], options) => Layer43.effect(Service29,
|
|
|
10036
10342
|
var layerFromRegistrationEffects = (registrations, options) => Layer43.unwrap(Effect49.all(registrations).pipe(Effect49.map((items) => layer31(items, options))));
|
|
10037
10343
|
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
10344
|
var memoryLayer25 = layer31;
|
|
10039
|
-
var
|
|
10345
|
+
var testLayer38 = (implementation) => Layer43.succeed(Service29, Service29.of(implementation));
|
|
10040
10346
|
var register4 = Effect49.fn("ModelRegistry.register.call")(function* (input) {
|
|
10041
10347
|
const service = yield* Service29;
|
|
10042
10348
|
return yield* service.register(input);
|
|
@@ -10049,14 +10355,32 @@ var provide = (selection, effect) => Effect49.gen(function* () {
|
|
|
10049
10355
|
const service = yield* Service29;
|
|
10050
10356
|
return yield* service.provide(selection, effect);
|
|
10051
10357
|
});
|
|
10358
|
+
|
|
10359
|
+
// ../../node_modules/.bun/@batonfx+core@0.3.1/node_modules/@batonfx/core/src/index.ts
|
|
10360
|
+
import {
|
|
10361
|
+
AiError as AiError3,
|
|
10362
|
+
Chat as Chat2,
|
|
10363
|
+
EmbeddingModel,
|
|
10364
|
+
IdGenerator,
|
|
10365
|
+
LanguageModel as LanguageModel5,
|
|
10366
|
+
Model as Model2,
|
|
10367
|
+
Prompt as Prompt8,
|
|
10368
|
+
Response as Response5,
|
|
10369
|
+
ResponseIdTracker,
|
|
10370
|
+
Telemetry as Telemetry2,
|
|
10371
|
+
Tokenizer as Tokenizer3,
|
|
10372
|
+
Tool as Tool7,
|
|
10373
|
+
Toolkit as Toolkit6
|
|
10374
|
+
} from "effect/unstable/ai";
|
|
10375
|
+
|
|
10052
10376
|
// ../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
|
|
10054
|
-
import { Chat as
|
|
10377
|
+
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 Schema62, Stream as Stream8 } from "effect";
|
|
10378
|
+
import { Chat as Chat3, LanguageModel as LanguageModel6, Prompt as Prompt12, Tokenizer as Tokenizer4, Toolkit as Toolkit7 } from "effect/unstable/ai";
|
|
10055
10379
|
|
|
10056
10380
|
// ../runtime/src/child/child-run-service.ts
|
|
10057
10381
|
var exports_child_run_service = {};
|
|
10058
10382
|
__export(exports_child_run_service, {
|
|
10059
|
-
testLayer: () =>
|
|
10383
|
+
testLayer: () => testLayer39,
|
|
10060
10384
|
spawnStatic: () => spawnStatic,
|
|
10061
10385
|
spawnDynamic: () => spawnDynamic,
|
|
10062
10386
|
resolveForDispatch: () => resolveForDispatch,
|
|
@@ -10070,31 +10394,31 @@ __export(exports_child_run_service, {
|
|
|
10070
10394
|
ChildRunScopeBroadened: () => ChildRunScopeBroadened,
|
|
10071
10395
|
ChildRunModelMissing: () => ChildRunModelMissing
|
|
10072
10396
|
});
|
|
10073
|
-
import { Context as Context44, Effect as Effect51, HashSet as HashSet5, Layer as Layer45, Option as Option18, Result as Result2, Schema as
|
|
10397
|
+
import { Context as Context44, Effect as Effect51, HashSet as HashSet5, Layer as Layer45, Option as Option18, Result as Result2, Schema as Schema51 } from "effect";
|
|
10074
10398
|
|
|
10075
10399
|
// ../runtime/src/workspace/workspace-provider-service.ts
|
|
10076
|
-
import { Context as Context43, Effect as Effect50, Layer as Layer44, Ref as Ref12, Schema as
|
|
10400
|
+
import { Context as Context43, Effect as Effect50, Layer as Layer44, Ref as Ref12, Schema as Schema50 } from "effect";
|
|
10077
10401
|
|
|
10078
|
-
class WorkspaceNotFound extends
|
|
10402
|
+
class WorkspaceNotFound extends Schema50.TaggedErrorClass()("WorkspaceNotFound", {
|
|
10079
10403
|
sandbox_ref: exports_ids_schema.WorkspaceRef
|
|
10080
10404
|
}) {
|
|
10081
10405
|
}
|
|
10082
10406
|
|
|
10083
|
-
class WorkspaceUnavailable extends
|
|
10407
|
+
class WorkspaceUnavailable extends Schema50.TaggedErrorClass()("WorkspaceUnavailable", {
|
|
10084
10408
|
sandbox_ref: exports_ids_schema.WorkspaceRef,
|
|
10085
|
-
message:
|
|
10409
|
+
message: Schema50.String
|
|
10086
10410
|
}) {
|
|
10087
10411
|
}
|
|
10088
10412
|
|
|
10089
|
-
class WorkspaceCapabilityUnsupported extends
|
|
10090
|
-
capability:
|
|
10413
|
+
class WorkspaceCapabilityUnsupported extends Schema50.TaggedErrorClass()("WorkspaceCapabilityUnsupported", {
|
|
10414
|
+
capability: Schema50.Literals(["suspend", "snapshot", "fork"]),
|
|
10091
10415
|
provider_key: exports_workspace_schema.WorkspaceProviderKey
|
|
10092
10416
|
}) {
|
|
10093
10417
|
}
|
|
10094
10418
|
|
|
10095
|
-
class WorkspaceProviderError extends
|
|
10419
|
+
class WorkspaceProviderError extends Schema50.TaggedErrorClass()("WorkspaceProviderError", {
|
|
10096
10420
|
provider_key: exports_workspace_schema.WorkspaceProviderKey,
|
|
10097
|
-
message:
|
|
10421
|
+
message: Schema50.String
|
|
10098
10422
|
}) {
|
|
10099
10423
|
}
|
|
10100
10424
|
|
|
@@ -10126,28 +10450,28 @@ var destroy = Effect50.fn("WorkspaceProvider.destroy.call")(function* (ref) {
|
|
|
10126
10450
|
});
|
|
10127
10451
|
|
|
10128
10452
|
// ../runtime/src/child/child-run-service.ts
|
|
10129
|
-
class StaticChildRunPresetNotFound extends
|
|
10453
|
+
class StaticChildRunPresetNotFound extends Schema51.TaggedErrorClass()("StaticChildRunPresetNotFound", {
|
|
10130
10454
|
preset_name: exports_shared_schema.NonEmptyString
|
|
10131
10455
|
}) {
|
|
10132
10456
|
}
|
|
10133
10457
|
|
|
10134
|
-
class ChildRunScopeBroadened extends
|
|
10135
|
-
field:
|
|
10458
|
+
class ChildRunScopeBroadened extends Schema51.TaggedErrorClass()("ChildRunScopeBroadened", {
|
|
10459
|
+
field: Schema51.Literals(["tool_names", "permissions"]),
|
|
10136
10460
|
value: exports_shared_schema.NonEmptyString
|
|
10137
10461
|
}) {
|
|
10138
10462
|
}
|
|
10139
10463
|
|
|
10140
|
-
class ChildRunServiceError extends
|
|
10141
|
-
message:
|
|
10464
|
+
class ChildRunServiceError extends Schema51.TaggedErrorClass()("ChildRunServiceError", {
|
|
10465
|
+
message: Schema51.String
|
|
10142
10466
|
}) {
|
|
10143
10467
|
}
|
|
10144
10468
|
|
|
10145
|
-
class ChildRunWorkspaceUnavailable extends
|
|
10146
|
-
reason:
|
|
10469
|
+
class ChildRunWorkspaceUnavailable extends Schema51.TaggedErrorClass()("ChildRunWorkspaceUnavailable", {
|
|
10470
|
+
reason: Schema51.String
|
|
10147
10471
|
}) {
|
|
10148
10472
|
}
|
|
10149
10473
|
|
|
10150
|
-
class ChildRunModelMissing extends
|
|
10474
|
+
class ChildRunModelMissing extends Schema51.TaggedErrorClass()("ChildRunModelMissing", {}) {
|
|
10151
10475
|
}
|
|
10152
10476
|
|
|
10153
10477
|
class Service31 extends Context44.Service()("@relayfx/runtime/ChildRunService") {
|
|
@@ -10321,7 +10645,7 @@ var layer32 = Layer45.effect(Service31, Effect51.gen(function* () {
|
|
|
10321
10645
|
});
|
|
10322
10646
|
}));
|
|
10323
10647
|
var memoryLayer26 = layer32.pipe(Layer45.provide(exports_child_execution_repository.memoryLayer), Layer45.provide(memoryLayer21));
|
|
10324
|
-
var
|
|
10648
|
+
var testLayer39 = (implementation) => Layer45.succeed(Service31, Service31.of(implementation));
|
|
10325
10649
|
var agentContextFromSchema = (input) => ({
|
|
10326
10650
|
toolNames: input.tool_names,
|
|
10327
10651
|
permissions: input.permissions,
|
|
@@ -10375,26 +10699,26 @@ var spawnDynamic = Effect51.fn("ChildRunService.spawnDynamic.call")(function* (i
|
|
|
10375
10699
|
});
|
|
10376
10700
|
|
|
10377
10701
|
// ../runtime/src/child/spawn-child-run-tool.ts
|
|
10378
|
-
import { Effect as Effect52, Schema as
|
|
10702
|
+
import { Effect as Effect52, Schema as Schema52 } from "effect";
|
|
10379
10703
|
var toolName = "spawn_child_run";
|
|
10380
10704
|
var permissionName = "relay.child_run.spawn";
|
|
10381
|
-
var Input =
|
|
10382
|
-
preset_name:
|
|
10383
|
-
instructions:
|
|
10384
|
-
model:
|
|
10385
|
-
tool_names:
|
|
10386
|
-
permissions:
|
|
10387
|
-
output_schema_ref:
|
|
10388
|
-
metadata:
|
|
10389
|
-
input:
|
|
10705
|
+
var Input = Schema52.Struct({
|
|
10706
|
+
preset_name: Schema52.optionalKey(exports_shared_schema.NonEmptyString),
|
|
10707
|
+
instructions: Schema52.optionalKey(Schema52.String),
|
|
10708
|
+
model: Schema52.optionalKey(exports_agent_schema.ModelSelection),
|
|
10709
|
+
tool_names: Schema52.optionalKey(Schema52.Array(Schema52.String)),
|
|
10710
|
+
permissions: Schema52.optionalKey(Schema52.Array(Schema52.String)),
|
|
10711
|
+
output_schema_ref: Schema52.optionalKey(Schema52.String),
|
|
10712
|
+
metadata: Schema52.optionalKey(exports_shared_schema.Metadata),
|
|
10713
|
+
input: Schema52.optionalKey(Schema52.Array(exports_content_schema.Part))
|
|
10390
10714
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Input" });
|
|
10391
|
-
var Output =
|
|
10715
|
+
var Output = Schema52.Struct({
|
|
10392
10716
|
child_execution_id: exports_ids_schema.ChildExecutionId,
|
|
10393
|
-
status:
|
|
10394
|
-
output:
|
|
10717
|
+
status: Schema52.Literals(["completed", "failed", "cancelled"]),
|
|
10718
|
+
output: Schema52.Array(exports_content_schema.Part)
|
|
10395
10719
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.Output" });
|
|
10396
|
-
var TransferInput =
|
|
10397
|
-
input:
|
|
10720
|
+
var TransferInput = Schema52.Struct({
|
|
10721
|
+
input: Schema52.optionalKey(Schema52.Array(exports_content_schema.Part))
|
|
10398
10722
|
}).annotate({ identifier: "Relay.SpawnChildRunTool.TransferInput" });
|
|
10399
10723
|
var enabled = (agent) => agent.metadata?.multi_agent_enabled === true;
|
|
10400
10724
|
var parentContext = (agent) => ({
|
|
@@ -10581,17 +10905,17 @@ var transferTools = (config) => (config.agent.handoff_targets ?? []).map((target
|
|
|
10581
10905
|
});
|
|
10582
10906
|
|
|
10583
10907
|
// ../runtime/src/memory/memory-service.ts
|
|
10584
|
-
import { Clock as Clock3, Context as Context46, Effect as Effect54, Layer as Layer47, Schema as
|
|
10585
|
-
import { EmbeddingModel as
|
|
10908
|
+
import { Clock as Clock3, Context as Context46, Effect as Effect54, Layer as Layer47, Schema as Schema54 } from "effect";
|
|
10909
|
+
import { EmbeddingModel as EmbeddingModel3, Prompt as Prompt9 } from "effect/unstable/ai";
|
|
10586
10910
|
|
|
10587
10911
|
// ../runtime/src/model/embedding-model-service.ts
|
|
10588
|
-
import { Context as Context45, Effect as Effect53, Layer as Layer46, Ref as Ref13, Schema as
|
|
10589
|
-
import { EmbeddingModel, Model as
|
|
10912
|
+
import { Context as Context45, Effect as Effect53, Layer as Layer46, Ref as Ref13, Schema as Schema53 } from "effect";
|
|
10913
|
+
import { EmbeddingModel as EmbeddingModel2, Model as Model3 } from "effect/unstable/ai";
|
|
10590
10914
|
|
|
10591
|
-
class EmbeddingModelNotRegistered extends
|
|
10592
|
-
provider:
|
|
10593
|
-
model:
|
|
10594
|
-
registration_key:
|
|
10915
|
+
class EmbeddingModelNotRegistered extends Schema53.TaggedErrorClass()("EmbeddingModelNotRegistered", {
|
|
10916
|
+
provider: Schema53.String,
|
|
10917
|
+
model: Schema53.String,
|
|
10918
|
+
registration_key: Schema53.optionalKey(Schema53.String)
|
|
10595
10919
|
}) {
|
|
10596
10920
|
}
|
|
10597
10921
|
|
|
@@ -10625,7 +10949,7 @@ var resolveDefault = (registrations2, options) => {
|
|
|
10625
10949
|
}
|
|
10626
10950
|
return registrations2.length === 1 ? registrations2[0] : undefined;
|
|
10627
10951
|
};
|
|
10628
|
-
var registrationFromLayer2 = (input) =>
|
|
10952
|
+
var registrationFromLayer2 = (input) => Model3.make(input.provider, input.model, input.layer).captureRequirements.pipe(Effect53.map((layer33) => toRegistration({
|
|
10629
10953
|
provider: input.provider,
|
|
10630
10954
|
model: input.model,
|
|
10631
10955
|
...input.registrationKey === undefined ? {} : { registrationKey: input.registrationKey },
|
|
@@ -10683,12 +11007,12 @@ var deterministicVector = (input, dimensions) => {
|
|
|
10683
11007
|
};
|
|
10684
11008
|
var deterministicLayer = (options = {}) => {
|
|
10685
11009
|
const dimensions = options.dimensions ?? 64;
|
|
10686
|
-
return Layer46.mergeAll(Layer46.effect(
|
|
11010
|
+
return Layer46.mergeAll(Layer46.effect(EmbeddingModel2.EmbeddingModel, EmbeddingModel2.make({
|
|
10687
11011
|
embedMany: ({ inputs }) => Effect53.succeed({
|
|
10688
11012
|
results: inputs.map((input) => deterministicVector(input, dimensions)),
|
|
10689
11013
|
usage: { inputTokens: inputs.reduce((total, input) => total + words(input).length, 0) }
|
|
10690
11014
|
})
|
|
10691
|
-
})), Layer46.succeed(
|
|
11015
|
+
})), Layer46.succeed(EmbeddingModel2.Dimensions, dimensions));
|
|
10692
11016
|
};
|
|
10693
11017
|
var deterministicRegistration = (options = {}) => registrationFromLayer2({
|
|
10694
11018
|
provider: options.provider ?? "test",
|
|
@@ -10717,8 +11041,8 @@ var defaultTopK = 5;
|
|
|
10717
11041
|
var memoryError = (error) => new exports_memory.MemoryError({
|
|
10718
11042
|
message: error instanceof Error ? `${error.name}: ${error.message}` : String(error)
|
|
10719
11043
|
});
|
|
10720
|
-
var decodeSubject = (subject) =>
|
|
10721
|
-
var textPart = (text3) =>
|
|
11044
|
+
var decodeSubject = (subject) => Schema54.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(subject).pipe(Effect54.mapError(memoryError));
|
|
11045
|
+
var textPart = (text3) => Prompt9.makePart("text", { text: text3 });
|
|
10722
11046
|
var textFromParts = (parts) => parts.filter((part) => part.type === "text").map((part) => part.text).join(`
|
|
10723
11047
|
`).trim();
|
|
10724
11048
|
var latestUserText = (prompt) => {
|
|
@@ -10781,7 +11105,7 @@ var hashText = (input) => {
|
|
|
10781
11105
|
};
|
|
10782
11106
|
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
11107
|
var embed = (models, text3, options) => {
|
|
10784
|
-
const program =
|
|
11108
|
+
const program = EmbeddingModel3.EmbeddingModel.pipe(Effect54.flatMap((model) => model.embed(text3)));
|
|
10785
11109
|
return (options?.embeddingSelection === undefined ? models.provideDefault(program) : models.provide(options.embeddingSelection, program)).pipe(Effect54.mapError(memoryError));
|
|
10786
11110
|
};
|
|
10787
11111
|
var make6 = (options = {}) => Effect54.gen(function* () {
|
|
@@ -10848,7 +11172,7 @@ var remember2 = Effect54.fn("MemoryService.remember.call")(function* (input) {
|
|
|
10848
11172
|
// ../runtime/src/model/language-model-service.ts
|
|
10849
11173
|
var exports_language_model_service = {};
|
|
10850
11174
|
__export(exports_language_model_service, {
|
|
10851
|
-
testLayer: () =>
|
|
11175
|
+
testLayer: () => testLayer40,
|
|
10852
11176
|
registrations: () => registrations3,
|
|
10853
11177
|
registrationFromLayer: () => registrationFromLayer3,
|
|
10854
11178
|
register: () => register6,
|
|
@@ -10882,7 +11206,7 @@ var layer35 = (initialRegistrations = [], options) => Layer48.effect(Service34,
|
|
|
10882
11206
|
})).pipe(Layer48.provide(exports_model_registry.layer(initialRegistrations, options)));
|
|
10883
11207
|
var layerFromRegistrationEffects3 = (registrations3, options) => Layer48.unwrap(Effect55.all(registrations3).pipe(Effect55.map((items) => layer35(items, options))));
|
|
10884
11208
|
var memoryLayer28 = layer35;
|
|
10885
|
-
var
|
|
11209
|
+
var testLayer40 = (implementation) => Layer48.succeed(Service34, Service34.of(implementation));
|
|
10886
11210
|
var register6 = Effect55.fn("LanguageModelService.register.call")(function* (input) {
|
|
10887
11211
|
const service = yield* Service34;
|
|
10888
11212
|
return yield* service.register(input);
|
|
@@ -10903,7 +11227,7 @@ var provideForAgent = (agent, effect) => Effect55.gen(function* () {
|
|
|
10903
11227
|
// ../runtime/src/model/model-call-policy.ts
|
|
10904
11228
|
var exports_model_call_policy = {};
|
|
10905
11229
|
__export(exports_model_call_policy, {
|
|
10906
|
-
testLayer: () =>
|
|
11230
|
+
testLayer: () => testLayer41,
|
|
10907
11231
|
noRetryLayer: () => noRetryLayer,
|
|
10908
11232
|
make: () => make7,
|
|
10909
11233
|
layer: () => layer36,
|
|
@@ -10911,26 +11235,26 @@ __export(exports_model_call_policy, {
|
|
|
10911
11235
|
defaultClassify: () => defaultClassify2,
|
|
10912
11236
|
Service: () => Service35
|
|
10913
11237
|
});
|
|
10914
|
-
import { Context as Context48, Duration as Duration3, Layer as Layer49, Schedule as
|
|
10915
|
-
import { AiError as
|
|
11238
|
+
import { Context as Context48, Duration as Duration3, Layer as Layer49, Schedule as Schedule4 } from "effect";
|
|
11239
|
+
import { AiError as AiError4 } from "effect/unstable/ai";
|
|
10916
11240
|
|
|
10917
11241
|
class Service35 extends Context48.Service()("@relayfx/runtime/ModelCallPolicy") {
|
|
10918
11242
|
}
|
|
10919
|
-
var isOutputValidationError = (error) =>
|
|
11243
|
+
var isOutputValidationError = (error) => AiError4.isAiError(error) ? error.reason._tag === "InvalidOutputError" : AiError4.isAiErrorReason(error) && error._tag === "InvalidOutputError";
|
|
10920
11244
|
var defaultClassify2 = (error) => isOutputValidationError(error) ? "terminal" : exports_model_resilience.defaultClassify(error);
|
|
10921
|
-
var defaultSchedule =
|
|
11245
|
+
var defaultSchedule = Schedule4.exponential(Duration3.seconds(1)).pipe(Schedule4.jittered, Schedule4.both(Schedule4.recurs(4)));
|
|
10922
11246
|
var make7 = (input) => ({
|
|
10923
11247
|
classify: input?.classify ?? defaultClassify2,
|
|
10924
11248
|
retrySchedule: input?.retrySchedule ?? defaultSchedule
|
|
10925
11249
|
});
|
|
10926
11250
|
var layer36 = (input) => Layer49.succeed(Service35, Service35.of(make7(input)));
|
|
10927
|
-
var noRetryLayer = layer36({ retrySchedule:
|
|
10928
|
-
var
|
|
11251
|
+
var noRetryLayer = layer36({ retrySchedule: Schedule4.recurs(0) });
|
|
11252
|
+
var testLayer41 = (implementation) => Layer49.succeed(Service35, Service35.of(implementation));
|
|
10929
11253
|
|
|
10930
11254
|
// ../runtime/src/schema-registry/schema-registry-service.ts
|
|
10931
11255
|
var exports_schema_registry_service = {};
|
|
10932
11256
|
__export(exports_schema_registry_service, {
|
|
10933
|
-
testLayer: () =>
|
|
11257
|
+
testLayer: () => testLayer42,
|
|
10934
11258
|
resolve: () => resolve4,
|
|
10935
11259
|
registrations: () => registrations4,
|
|
10936
11260
|
register: () => register7,
|
|
@@ -10939,9 +11263,9 @@ __export(exports_schema_registry_service, {
|
|
|
10939
11263
|
Service: () => Service36,
|
|
10940
11264
|
SchemaRefNotRegistered: () => SchemaRefNotRegistered
|
|
10941
11265
|
});
|
|
10942
|
-
import { Context as Context49, Effect as Effect56, Layer as Layer50, Ref as Ref14, Schema as
|
|
11266
|
+
import { Context as Context49, Effect as Effect56, Layer as Layer50, Ref as Ref14, Schema as Schema55 } from "effect";
|
|
10943
11267
|
|
|
10944
|
-
class SchemaRefNotRegistered extends
|
|
11268
|
+
class SchemaRefNotRegistered extends Schema55.TaggedErrorClass()("SchemaRefNotRegistered", { schema_ref: exports_shared_schema.NonEmptyString }) {
|
|
10945
11269
|
}
|
|
10946
11270
|
|
|
10947
11271
|
class Service36 extends Context49.Service()("@relayfx/runtime/SchemaRegistry") {
|
|
@@ -10969,7 +11293,7 @@ var layer37 = (initialRegistrations = []) => Layer50.effect(Service36, Effect56.
|
|
|
10969
11293
|
return Service36.of({ register: register7, registrations: registrations4, resolve: resolve4 });
|
|
10970
11294
|
}));
|
|
10971
11295
|
var memoryLayer29 = layer37;
|
|
10972
|
-
var
|
|
11296
|
+
var testLayer42 = (implementation) => Layer50.succeed(Service36, Service36.of(implementation));
|
|
10973
11297
|
var register7 = Effect56.fn("SchemaRegistry.register.call")(function* (registration) {
|
|
10974
11298
|
const service = yield* Service36;
|
|
10975
11299
|
return yield* service.register(registration);
|
|
@@ -11065,7 +11389,7 @@ var make8 = Effect57.fn("RelaySessionStore.make")(function* (sessionId, entrySco
|
|
|
11065
11389
|
// ../runtime/src/content/blob-store-service.ts
|
|
11066
11390
|
var exports_blob_store_service = {};
|
|
11067
11391
|
__export(exports_blob_store_service, {
|
|
11068
|
-
testLayer: () =>
|
|
11392
|
+
testLayer: () => testLayer43,
|
|
11069
11393
|
resolve: () => resolve5,
|
|
11070
11394
|
put: () => put3,
|
|
11071
11395
|
passthroughLayer: () => passthroughLayer,
|
|
@@ -11074,16 +11398,16 @@ __export(exports_blob_store_service, {
|
|
|
11074
11398
|
BlobStoreError: () => BlobStoreError,
|
|
11075
11399
|
BlobNotResolvable: () => BlobNotResolvable
|
|
11076
11400
|
});
|
|
11077
|
-
import { Context as Context51, Effect as Effect58, Layer as Layer52, Ref as Ref16, Schema as
|
|
11401
|
+
import { Context as Context51, Effect as Effect58, Layer as Layer52, Ref as Ref16, Schema as Schema56 } from "effect";
|
|
11078
11402
|
|
|
11079
|
-
class BlobNotResolvable extends
|
|
11080
|
-
uri:
|
|
11081
|
-
reason:
|
|
11403
|
+
class BlobNotResolvable extends Schema56.TaggedErrorClass()("BlobNotResolvable", {
|
|
11404
|
+
uri: Schema56.String,
|
|
11405
|
+
reason: Schema56.String
|
|
11082
11406
|
}) {
|
|
11083
11407
|
}
|
|
11084
11408
|
|
|
11085
|
-
class BlobStoreError extends
|
|
11086
|
-
message:
|
|
11409
|
+
class BlobStoreError extends Schema56.TaggedErrorClass()("BlobStoreError", {
|
|
11410
|
+
message: Schema56.String
|
|
11087
11411
|
}) {
|
|
11088
11412
|
}
|
|
11089
11413
|
|
|
@@ -11134,7 +11458,7 @@ var memoryLayer30 = Layer52.effect(Service38, Effect58.gen(function* () {
|
|
|
11134
11458
|
})
|
|
11135
11459
|
});
|
|
11136
11460
|
}));
|
|
11137
|
-
var
|
|
11461
|
+
var testLayer43 = (implementation) => Layer52.succeed(Service38, Service38.of(implementation));
|
|
11138
11462
|
var resolve5 = Effect58.fn("BlobStore.resolve.call")(function* (part) {
|
|
11139
11463
|
const service = yield* Service38;
|
|
11140
11464
|
return yield* service.resolve(part);
|
|
@@ -11147,7 +11471,7 @@ var put3 = Effect58.fn("BlobStore.put.call")(function* (input) {
|
|
|
11147
11471
|
// ../runtime/src/agent/prompt-assembler-service.ts
|
|
11148
11472
|
var exports_prompt_assembler_service = {};
|
|
11149
11473
|
__export(exports_prompt_assembler_service, {
|
|
11150
|
-
testLayer: () =>
|
|
11474
|
+
testLayer: () => testLayer45,
|
|
11151
11475
|
layer: () => layer38,
|
|
11152
11476
|
defaultLayerWithStores: () => defaultLayerWithStores,
|
|
11153
11477
|
defaultLayer: () => defaultLayer,
|
|
@@ -11156,13 +11480,13 @@ __export(exports_prompt_assembler_service, {
|
|
|
11156
11480
|
Service: () => Service40,
|
|
11157
11481
|
PromptAssemblerError: () => PromptAssemblerError
|
|
11158
11482
|
});
|
|
11159
|
-
import { Context as Context53, Effect as Effect60, Layer as Layer54, Schema as
|
|
11160
|
-
import { Prompt as
|
|
11483
|
+
import { Context as Context53, Effect as Effect60, Layer as Layer54, Schema as Schema58 } from "effect";
|
|
11484
|
+
import { Prompt as Prompt10 } from "effect/unstable/ai";
|
|
11161
11485
|
|
|
11162
11486
|
// ../runtime/src/content/artifact-store-service.ts
|
|
11163
11487
|
var exports_artifact_store_service = {};
|
|
11164
11488
|
__export(exports_artifact_store_service, {
|
|
11165
|
-
testLayer: () =>
|
|
11489
|
+
testLayer: () => testLayer44,
|
|
11166
11490
|
resolve: () => resolve6,
|
|
11167
11491
|
register: () => register8,
|
|
11168
11492
|
passthroughLayer: () => passthroughLayer2,
|
|
@@ -11171,11 +11495,11 @@ __export(exports_artifact_store_service, {
|
|
|
11171
11495
|
Memory: () => Memory2,
|
|
11172
11496
|
ArtifactNotResolvable: () => ArtifactNotResolvable
|
|
11173
11497
|
});
|
|
11174
|
-
import { Context as Context52, Effect as Effect59, Layer as Layer53, Schema as
|
|
11498
|
+
import { Context as Context52, Effect as Effect59, Layer as Layer53, Schema as Schema57 } from "effect";
|
|
11175
11499
|
|
|
11176
|
-
class ArtifactNotResolvable extends
|
|
11177
|
-
artifact_id:
|
|
11178
|
-
reason:
|
|
11500
|
+
class ArtifactNotResolvable extends Schema57.TaggedErrorClass()("ArtifactNotResolvable", {
|
|
11501
|
+
artifact_id: Schema57.String,
|
|
11502
|
+
reason: Schema57.String
|
|
11179
11503
|
}) {
|
|
11180
11504
|
}
|
|
11181
11505
|
|
|
@@ -11206,7 +11530,7 @@ var memoryServiceLayer = Layer53.effect(Service39, Effect59.gen(function* () {
|
|
|
11206
11530
|
return Service39.of({ resolve: memory.resolve });
|
|
11207
11531
|
}));
|
|
11208
11532
|
var memoryLayer31 = memoryServiceLayer.pipe(Layer53.provideMerge(Layer53.effect(Memory2, makeMemory)));
|
|
11209
|
-
var
|
|
11533
|
+
var testLayer44 = (implementation) => Layer53.succeed(Service39, Service39.of(implementation));
|
|
11210
11534
|
var resolve6 = Effect59.fn("ArtifactStore.resolve.call")(function* (part) {
|
|
11211
11535
|
const service = yield* Service39;
|
|
11212
11536
|
return yield* service.resolve(part);
|
|
@@ -11217,32 +11541,32 @@ var register8 = Effect59.fn("ArtifactStore.register.call")(function* (artifact_i
|
|
|
11217
11541
|
});
|
|
11218
11542
|
|
|
11219
11543
|
// ../runtime/src/agent/prompt-assembler-service.ts
|
|
11220
|
-
class PromptAssemblerError extends
|
|
11221
|
-
message:
|
|
11544
|
+
class PromptAssemblerError extends Schema58.TaggedErrorClass()("PromptAssemblerError", {
|
|
11545
|
+
message: Schema58.String
|
|
11222
11546
|
}) {
|
|
11223
11547
|
}
|
|
11224
11548
|
|
|
11225
11549
|
class Service40 extends Context53.Service()("@relayfx/runtime/PromptAssembler") {
|
|
11226
11550
|
}
|
|
11227
|
-
var jsonValue2 = (value) =>
|
|
11551
|
+
var jsonValue2 = (value) => Schema58.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
11228
11552
|
var stringifyJson = (value) => JSON.stringify(jsonValue2(value));
|
|
11229
11553
|
var contentToPromptPart = (part) => {
|
|
11230
11554
|
const options = part.provider_options;
|
|
11231
11555
|
switch (part.type) {
|
|
11232
11556
|
case "text":
|
|
11233
|
-
return
|
|
11557
|
+
return Prompt10.makePart("text", { text: part.text, ...options === undefined ? {} : { options } });
|
|
11234
11558
|
case "structured":
|
|
11235
|
-
return
|
|
11559
|
+
return Prompt10.makePart("text", {
|
|
11236
11560
|
text: stringifyJson(part.value),
|
|
11237
11561
|
...options === undefined ? {} : { options }
|
|
11238
11562
|
});
|
|
11239
11563
|
case "tool-call":
|
|
11240
|
-
return
|
|
11564
|
+
return Prompt10.makePart("text", {
|
|
11241
11565
|
text: stringifyJson(part.call),
|
|
11242
11566
|
...options === undefined ? {} : { options }
|
|
11243
11567
|
});
|
|
11244
11568
|
case "tool-result":
|
|
11245
|
-
return
|
|
11569
|
+
return Prompt10.makePart("text", {
|
|
11246
11570
|
text: stringifyJson(part.result),
|
|
11247
11571
|
...options === undefined ? {} : { options }
|
|
11248
11572
|
});
|
|
@@ -11252,7 +11576,7 @@ var toAssemblerError = (error) => new PromptAssemblerError({
|
|
|
11252
11576
|
message: error.reason !== undefined ? `${error._tag}: ${error.reason}` : error.message !== undefined ? `${error._tag}: ${error.message}` : error._tag
|
|
11253
11577
|
});
|
|
11254
11578
|
var resolveBlobPart = (blobs, part) => blobs.resolve(part).pipe(Effect60.map((resolved) => [
|
|
11255
|
-
|
|
11579
|
+
Prompt10.makePart("file", {
|
|
11256
11580
|
mediaType: resolved.mediaType,
|
|
11257
11581
|
data: resolved._tag === "Bytes" ? resolved.bytes : resolved.url,
|
|
11258
11582
|
...resolved.fileName === undefined ? {} : { fileName: resolved.fileName },
|
|
@@ -11293,9 +11617,9 @@ var defaultSystem = (agent, tools) => [`Agent: ${agent.name}`, agent.instruction
|
|
|
11293
11617
|
`);
|
|
11294
11618
|
var defaultPrompt = (blobs, artifacts, input) => Effect60.forEach(input, (part) => resolveContentPart(blobs, artifacts, part), { concurrency: 1 }).pipe(Effect60.map((parts) => {
|
|
11295
11619
|
const flat = parts.flat();
|
|
11296
|
-
return
|
|
11297
|
-
|
|
11298
|
-
content: flat.length === 0 ? [
|
|
11620
|
+
return Prompt10.fromMessages([
|
|
11621
|
+
Prompt10.makeMessage("user", {
|
|
11622
|
+
content: flat.length === 0 ? [Prompt10.makePart("text", { text: "" })] : flat
|
|
11299
11623
|
})
|
|
11300
11624
|
]);
|
|
11301
11625
|
}));
|
|
@@ -11309,7 +11633,7 @@ var defaultLayerWithStores = Layer54.effect(Service40, Effect60.gen(function* ()
|
|
|
11309
11633
|
}));
|
|
11310
11634
|
var defaultLayer = defaultLayerWithStores.pipe(Layer54.provide(Layer54.mergeAll(passthroughLayer, passthroughLayer2)));
|
|
11311
11635
|
var layer38 = (implementation) => Layer54.succeed(Service40, Service40.of(implementation));
|
|
11312
|
-
var
|
|
11636
|
+
var testLayer45 = (implementation) => Layer54.succeed(Service40, Service40.of(implementation));
|
|
11313
11637
|
var assemble = Effect60.fn("PromptAssembler.assemble.call")(function* (input) {
|
|
11314
11638
|
const service = yield* Service40;
|
|
11315
11639
|
return yield* service.assemble(input);
|
|
@@ -11368,8 +11692,8 @@ var make9 = (config) => exports_compaction.make(strategy(config), defaultOptions
|
|
|
11368
11692
|
var layerFromEpoch = (epoch) => exports_instructions.layer(epoch.baseline.length === 0 ? [] : [exports_instructions.staticSource("relay:context-epoch", epoch.baseline)]);
|
|
11369
11693
|
|
|
11370
11694
|
// ../runtime/src/agent/relay-permissions.ts
|
|
11371
|
-
import { Clock as Clock6, Effect as Effect62, Equal as Equal2, Layer as Layer56, Option as Option19, Schema as
|
|
11372
|
-
var jsonValue3 = (value) =>
|
|
11695
|
+
import { Clock as Clock6, Effect as Effect62, Equal as Equal2, Layer as Layer56, Option as Option19, Schema as Schema59 } from "effect";
|
|
11696
|
+
var jsonValue3 = (value) => Schema59.decodeUnknownSync(exports_shared_schema.JsonValue)(value === undefined ? null : value);
|
|
11373
11697
|
var waitIdForToolCall = (toolCallId) => exports_ids_schema.WaitId.make(`wait:permission:${toolCallId}`);
|
|
11374
11698
|
var fallbackToolCallId = (request) => `${request.agentName}:${request.turn}:${request.tool}`;
|
|
11375
11699
|
var tokenFor2 = (request) => waitIdForToolCall(request.toolCallId ?? fallbackToolCallId(request));
|
|
@@ -11535,7 +11859,7 @@ var awaitAnswer = Effect62.fn("RelayPermissions.awaitAnswer")(function* (config,
|
|
|
11535
11859
|
});
|
|
11536
11860
|
var rememberRule = Effect62.fn("RelayPermissions.rememberRule")(function* (config, rule) {
|
|
11537
11861
|
const createdAt = yield* Clock6.currentTimeMillis;
|
|
11538
|
-
const decodedRule = yield*
|
|
11862
|
+
const decodedRule = yield* Schema59.decodeUnknownEffect(exports_agent_schema.PermissionRule)(rule).pipe(Effect62.mapError((error) => permissionError(error.message)));
|
|
11539
11863
|
yield* config.repository.remember({
|
|
11540
11864
|
agent: config.agentName,
|
|
11541
11865
|
scope: config.scope,
|
|
@@ -11551,9 +11875,9 @@ var layer40 = (config) => Layer56.mergeAll(Layer56.succeed(exports_permissions.P
|
|
|
11551
11875
|
})));
|
|
11552
11876
|
|
|
11553
11877
|
// ../runtime/src/agent/relay-steering.ts
|
|
11554
|
-
import { Clock as Clock7, Effect as Effect63, Layer as Layer57, Schema as
|
|
11555
|
-
import { Prompt as
|
|
11556
|
-
var jsonValue4 = (value) =>
|
|
11878
|
+
import { Clock as Clock7, Effect as Effect63, Layer as Layer57, Schema as Schema60 } from "effect";
|
|
11879
|
+
import { Prompt as Prompt11 } from "effect/unstable/ai";
|
|
11880
|
+
var jsonValue4 = (value) => Schema60.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
11557
11881
|
var stringifyJson2 = (value) => JSON.stringify(jsonValue4(value));
|
|
11558
11882
|
var createdAtForSequence2 = (config, sequence) => config.startedAt + sequence - config.eventSequence;
|
|
11559
11883
|
var drainId = (config, kind, sequence) => `drain:${config.executionId}:steering:${kind}:sequence:${sequence}`;
|
|
@@ -11571,22 +11895,22 @@ var purePromptPart = (part) => {
|
|
|
11571
11895
|
};
|
|
11572
11896
|
var contentToPromptPart2 = (part) => {
|
|
11573
11897
|
const pure = purePromptPart(part);
|
|
11574
|
-
return pure === undefined ?
|
|
11898
|
+
return pure === undefined ? Prompt11.makePart("text", { text: stringifyJson2(part) }) : contentToPromptPart(pure);
|
|
11575
11899
|
};
|
|
11576
|
-
var promptForContent = (content) =>
|
|
11577
|
-
|
|
11578
|
-
content: content.length === 0 ? [
|
|
11900
|
+
var promptForContent = (content) => Prompt11.fromMessages([
|
|
11901
|
+
Prompt11.makeMessage("user", {
|
|
11902
|
+
content: content.length === 0 ? [Prompt11.makePart("text", { text: "" })] : content.map((part) => contentToPromptPart2(part))
|
|
11579
11903
|
})
|
|
11580
11904
|
]);
|
|
11581
11905
|
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
11906
|
var contentFromMessage = (message) => {
|
|
11583
11907
|
if (typeof message.prompt === "string")
|
|
11584
11908
|
return [exports_content_schema.text(message.prompt)];
|
|
11585
|
-
const prompt =
|
|
11909
|
+
const prompt = Prompt11.make(message.prompt);
|
|
11586
11910
|
const textParts = promptTextParts(prompt);
|
|
11587
11911
|
if (textParts.length > 0)
|
|
11588
11912
|
return textParts;
|
|
11589
|
-
return [exports_content_schema.text(stringifyJson2(
|
|
11913
|
+
return [exports_content_schema.text(stringifyJson2(Schema60.encodeSync(Prompt11.Prompt)(prompt)))];
|
|
11590
11914
|
};
|
|
11591
11915
|
var steeringReceivedEvent = (config, kind, drain2, messages, sequence) => ({
|
|
11592
11916
|
id: exports_ids_schema.EventId.make(`event:${drain2.drainId}:received`),
|
|
@@ -11631,8 +11955,8 @@ var layer41 = (config) => Layer57.succeed(exports_steering.Steering, exports_ste
|
|
|
11631
11955
|
}));
|
|
11632
11956
|
|
|
11633
11957
|
// ../runtime/src/agent/relay-tool-executor.ts
|
|
11634
|
-
import { Effect as Effect64, Layer as Layer58, Option as Option20, Schema as
|
|
11635
|
-
var jsonValue5 = (value) =>
|
|
11958
|
+
import { Effect as Effect64, Layer as Layer58, Option as Option20, Schema as Schema61 } from "effect";
|
|
11959
|
+
var jsonValue5 = (value) => Schema61.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
11636
11960
|
var errorDetail = (error) => {
|
|
11637
11961
|
switch (error._tag) {
|
|
11638
11962
|
case "ToolNotRegistered":
|
|
@@ -11739,29 +12063,29 @@ var make12 = (first) => Ref17.make(first).pipe(Effect66.map((ref) => ({
|
|
|
11739
12063
|
})));
|
|
11740
12064
|
|
|
11741
12065
|
// ../runtime/src/agent/agent-loop-service.ts
|
|
11742
|
-
class AgentLoopError extends
|
|
11743
|
-
message:
|
|
11744
|
-
next_event_sequence:
|
|
12066
|
+
class AgentLoopError extends Schema62.TaggedErrorClass()("AgentLoopError", {
|
|
12067
|
+
message: Schema62.String,
|
|
12068
|
+
next_event_sequence: Schema62.optionalKey(exports_execution_schema.ExecutionEventSequence)
|
|
11745
12069
|
}) {
|
|
11746
12070
|
}
|
|
11747
12071
|
|
|
11748
|
-
class AgentLoopWaitRequested extends
|
|
12072
|
+
class AgentLoopWaitRequested extends Schema62.TaggedErrorClass()("AgentLoopWaitRequested", {
|
|
11749
12073
|
wait_id: exports_ids_schema.WaitId,
|
|
11750
12074
|
tool_call: exports_tool_schema.Call,
|
|
11751
12075
|
next_event_sequence: exports_execution_schema.ExecutionEventSequence
|
|
11752
12076
|
}) {
|
|
11753
12077
|
}
|
|
11754
12078
|
|
|
11755
|
-
class AgentLoopBudgetExceeded extends
|
|
11756
|
-
tokens_used:
|
|
11757
|
-
token_budget:
|
|
12079
|
+
class AgentLoopBudgetExceeded extends Schema62.TaggedErrorClass()("AgentLoopBudgetExceeded", {
|
|
12080
|
+
tokens_used: Schema62.Int,
|
|
12081
|
+
token_budget: Schema62.Int,
|
|
11758
12082
|
next_event_sequence: exports_execution_schema.ExecutionEventSequence
|
|
11759
12083
|
}) {
|
|
11760
12084
|
}
|
|
11761
12085
|
|
|
11762
12086
|
class Service41 extends Context54.Service()("@relayfx/runtime/AgentLoop") {
|
|
11763
12087
|
}
|
|
11764
|
-
var jsonValue6 = (value) =>
|
|
12088
|
+
var jsonValue6 = (value) => Schema62.decodeUnknownSync(exports_shared_schema.JsonValue)(value);
|
|
11765
12089
|
var toolNames = (agent) => HashSet6.fromIterable(agent.tool_names);
|
|
11766
12090
|
var availableRegisteredTools = (agent, registered) => {
|
|
11767
12091
|
const names = toolNames(agent);
|
|
@@ -11961,10 +12285,13 @@ var toolFromDefinition = (definition) => dynamicTool(definition.name, {
|
|
|
11961
12285
|
...definition.metadata === undefined ? {} : { metadata: definition.metadata },
|
|
11962
12286
|
run: () => Effect67.die("model-facing toolkit is not executed")
|
|
11963
12287
|
}).tool;
|
|
11964
|
-
var toolkitFromRegistered = (registered) =>
|
|
11965
|
-
var handlersForToolExecutor = (registered) => Object.fromEntries(registered.map((tool2) => [
|
|
12288
|
+
var toolkitFromRegistered = (registered) => Toolkit7.make(...registered.map(toolFromRegistered));
|
|
12289
|
+
var handlersForToolExecutor = (registered) => Object.fromEntries(registered.map((tool2) => [
|
|
12290
|
+
tool2.definition.name,
|
|
12291
|
+
() => Effect67.die(`Relay ToolExecutor must execute ${tool2.definition.name}`)
|
|
12292
|
+
]));
|
|
11966
12293
|
var persistTranscript = (chats, input, transcript) => Effect67.gen(function* () {
|
|
11967
|
-
const chat = yield*
|
|
12294
|
+
const chat = yield* Chat3.fromPrompt(transcript);
|
|
11968
12295
|
const exportData = yield* chat.export.pipe(Effect67.mapError((error) => loopError(error, input.eventSequence + 1)));
|
|
11969
12296
|
yield* chats.save({ executionId: input.executionId, exportData, updatedAt: input.completedAt }).pipe(Effect67.mapError((error) => loopError(error, input.eventSequence + 1)));
|
|
11970
12297
|
});
|
|
@@ -11976,7 +12303,7 @@ var restoreHistory = Effect67.fn("AgentLoop.restoreHistory")(function* (chats, i
|
|
|
11976
12303
|
next_event_sequence: input.eventSequence + 1
|
|
11977
12304
|
}));
|
|
11978
12305
|
}
|
|
11979
|
-
const chat = yield*
|
|
12306
|
+
const chat = yield* Chat3.fromExport(record2.exportData).pipe(Effect67.mapError((error) => loopError(error, input.eventSequence + 1)));
|
|
11980
12307
|
return yield* Ref18.get(chat.history);
|
|
11981
12308
|
});
|
|
11982
12309
|
var saveContextEpoch = Effect67.fn("AgentLoop.saveContextEpoch")(function* (epochs, input, epoch) {
|
|
@@ -12040,9 +12367,9 @@ var terminalMemoryTranscript = (prompt, text3) => {
|
|
|
12040
12367
|
return;
|
|
12041
12368
|
if (promptHasAssistantText(prompt, text3))
|
|
12042
12369
|
return prompt;
|
|
12043
|
-
return
|
|
12370
|
+
return Prompt12.fromMessages([
|
|
12044
12371
|
...prompt.content,
|
|
12045
|
-
|
|
12372
|
+
Prompt12.makeMessage("assistant", { content: [Prompt12.makePart("text", { text: text3 })] })
|
|
12046
12373
|
]);
|
|
12047
12374
|
};
|
|
12048
12375
|
var recallOnlyMemory = (memory) => exports_memory.Memory.of({
|
|
@@ -12089,7 +12416,7 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12089
12416
|
const permissionRules = yield* Effect67.serviceOption(exports_permission_rule_repository.Service);
|
|
12090
12417
|
const steeringRepository = yield* Effect67.serviceOption(exports_steering_repository.Service);
|
|
12091
12418
|
const waits = yield* Effect67.serviceOption(Service25);
|
|
12092
|
-
const tokenizer = yield* Effect67.serviceOption(
|
|
12419
|
+
const tokenizer = yield* Effect67.serviceOption(Tokenizer4.Tokenizer);
|
|
12093
12420
|
return Service41.of({
|
|
12094
12421
|
run: Effect67.fn("AgentLoop.run")(function* (input) {
|
|
12095
12422
|
const existing = yield* existingOutput(eventLog, input);
|
|
@@ -12106,7 +12433,7 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12106
12433
|
yield* appendEvent(eventLog, inputPreparedEvent(input, definitions2), input.eventSequence + 1);
|
|
12107
12434
|
const toolOutputMaxBytes = yield* effectiveToolOutputMaxBytes(input);
|
|
12108
12435
|
const compactionOptions = yield* effectiveCompactionOptions(input);
|
|
12109
|
-
const runTokenizer = yield* Effect67.serviceOption(
|
|
12436
|
+
const runTokenizer = yield* Effect67.serviceOption(Tokenizer4.Tokenizer);
|
|
12110
12437
|
const activeTokenizer = Option22.isSome(runTokenizer) ? runTokenizer : tokenizer;
|
|
12111
12438
|
const allocator = yield* make12(input.eventSequence + 1);
|
|
12112
12439
|
const toolkit = toolkitFromRegistered(registered);
|
|
@@ -12286,13 +12613,13 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12286
12613
|
}
|
|
12287
12614
|
});
|
|
12288
12615
|
const runFold = Effect67.gen(function* () {
|
|
12289
|
-
const base = yield*
|
|
12616
|
+
const base = yield* LanguageModel6.LanguageModel;
|
|
12290
12617
|
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(
|
|
12618
|
+
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
12619
|
const withToolOutput = toolOutputStore === undefined ? folded : folded.pipe(Effect67.provideService(exports_tool_output.ToolOutputStore, toolOutputStore));
|
|
12293
12620
|
const withCompaction = compactionService === undefined ? withToolOutput : withToolOutput.pipe(Effect67.provideService(exports_compaction.Compaction, compactionService));
|
|
12294
12621
|
const withSession = sessionStore === undefined ? withCompaction : withCompaction.pipe(Effect67.provideService(exports_session.SessionStore, sessionStore));
|
|
12295
|
-
const withTokenizer = Option22.isNone(activeTokenizer) ? withSession : withSession.pipe(Effect67.provideService(
|
|
12622
|
+
const withTokenizer = Option22.isNone(activeTokenizer) ? withSession : withSession.pipe(Effect67.provideService(Tokenizer4.Tokenizer, activeTokenizer.value));
|
|
12296
12623
|
return yield* memory !== undefined && Option22.isSome(durableMemory) ? withTokenizer.pipe(Effect67.provideService(exports_memory.Memory, recallOnlyMemory(durableMemory.value))) : withTokenizer;
|
|
12297
12624
|
});
|
|
12298
12625
|
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 +12631,7 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12304
12631
|
}
|
|
12305
12632
|
}
|
|
12306
12633
|
const schemaRef = input.agent.output_schema_ref;
|
|
12307
|
-
const structuredOutput = schemaRef === undefined || finalState.transcript === undefined ? undefined : yield*
|
|
12634
|
+
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
12635
|
const structuredPart = structuredOutput === undefined || schemaRef === undefined ? [] : [{ type: "structured", value: structuredOutput, schema_ref: schemaRef }];
|
|
12309
12636
|
yield* appendEvent(eventLog, outputCompletedEvent(input, [...completedContent(finalState.text), ...structuredPart], finalState.text, completedSequence, structuredOutput), completedSequence + 1);
|
|
12310
12637
|
return {
|
|
@@ -12317,7 +12644,7 @@ var layer44 = Layer60.effect(Service41, Effect67.gen(function* () {
|
|
|
12317
12644
|
})
|
|
12318
12645
|
});
|
|
12319
12646
|
}));
|
|
12320
|
-
var
|
|
12647
|
+
var testLayer46 = (implementation) => Layer60.succeed(Service41, Service41.of(implementation));
|
|
12321
12648
|
var run3 = Effect67.fn("AgentLoop.run.call")(function* (input) {
|
|
12322
12649
|
const service = yield* Service41;
|
|
12323
12650
|
return yield* service.run(input);
|
|
@@ -12327,14 +12654,14 @@ var exports_execution_entity = {};
|
|
|
12327
12654
|
__export(exports_execution_entity, {
|
|
12328
12655
|
layer: () => layer49,
|
|
12329
12656
|
entity: () => entity,
|
|
12330
|
-
client: () =>
|
|
12657
|
+
client: () => client2,
|
|
12331
12658
|
Start: () => Start,
|
|
12332
12659
|
SignalWait: () => SignalWait,
|
|
12333
12660
|
Cancel: () => Cancel
|
|
12334
12661
|
});
|
|
12335
12662
|
import { ClusterSchema, Entity } from "effect/unstable/cluster";
|
|
12336
12663
|
import { Rpc } from "effect/unstable/rpc";
|
|
12337
|
-
import { Schema as
|
|
12664
|
+
import { Schema as Schema69 } from "effect";
|
|
12338
12665
|
|
|
12339
12666
|
// ../runtime/src/workflow/execution-workflow.ts
|
|
12340
12667
|
var exports_execution_workflow = {};
|
|
@@ -12365,15 +12692,15 @@ __export(exports_execution_workflow, {
|
|
|
12365
12692
|
ActivityNameTemplates: () => ActivityNameTemplates
|
|
12366
12693
|
});
|
|
12367
12694
|
import { Activity, DurableDeferred, Workflow } from "effect/unstable/workflow";
|
|
12368
|
-
import { Effect as Effect73, Exit as Exit2, Option as Option26, Schema as
|
|
12695
|
+
import { Effect as Effect73, Exit as Exit2, Option as Option26, Schema as Schema68 } from "effect";
|
|
12369
12696
|
|
|
12370
12697
|
// ../runtime/src/child/parent-notifier-service.ts
|
|
12371
|
-
import { Context as Context55, Effect as Effect68, Layer as Layer61, Option as Option23, Ref as Ref19, Schema as
|
|
12372
|
-
class ParentNotifyError extends
|
|
12373
|
-
message:
|
|
12698
|
+
import { Context as Context55, Effect as Effect68, Layer as Layer61, Option as Option23, Ref as Ref19, Schema as Schema63 } from "effect";
|
|
12699
|
+
class ParentNotifyError extends Schema63.TaggedErrorClass()("ParentNotifyError", {
|
|
12700
|
+
message: Schema63.String
|
|
12374
12701
|
}) {
|
|
12375
12702
|
}
|
|
12376
|
-
var ChildTerminalStatus =
|
|
12703
|
+
var ChildTerminalStatus = Schema63.Literals(["completed", "failed", "cancelled"]).annotate({
|
|
12377
12704
|
identifier: "Relay.ParentNotifier.ChildTerminalStatus"
|
|
12378
12705
|
});
|
|
12379
12706
|
|
|
@@ -12456,7 +12783,7 @@ var notify = Effect68.fn("ParentNotifier.notify.call")(function* (input) {
|
|
|
12456
12783
|
// ../runtime/src/skill/skill-registry-service.ts
|
|
12457
12784
|
var exports_skill_registry_service = {};
|
|
12458
12785
|
__export(exports_skill_registry_service, {
|
|
12459
|
-
testLayer: () =>
|
|
12786
|
+
testLayer: () => testLayer47,
|
|
12460
12787
|
sourceLayerForExecution: () => sourceLayerForExecution,
|
|
12461
12788
|
sourceForExecution: () => sourceForExecution,
|
|
12462
12789
|
register: () => register9,
|
|
@@ -12472,15 +12799,15 @@ __export(exports_skill_registry_service, {
|
|
|
12472
12799
|
SkillDefinitionInvalid: () => SkillDefinitionInvalid,
|
|
12473
12800
|
Service: () => Service43
|
|
12474
12801
|
});
|
|
12475
|
-
import { Clock as Clock8, Context as Context56, Effect as Effect69, Layer as Layer62, Schema as
|
|
12802
|
+
import { Clock as Clock8, Context as Context56, Effect as Effect69, Layer as Layer62, Schema as Schema64 } from "effect";
|
|
12476
12803
|
|
|
12477
|
-
class SkillDefinitionInvalid extends
|
|
12478
|
-
message:
|
|
12804
|
+
class SkillDefinitionInvalid extends Schema64.TaggedErrorClass()("SkillDefinitionInvalid", {
|
|
12805
|
+
message: Schema64.String
|
|
12479
12806
|
}) {
|
|
12480
12807
|
}
|
|
12481
12808
|
|
|
12482
|
-
class SkillRegistryError extends
|
|
12483
|
-
message:
|
|
12809
|
+
class SkillRegistryError extends Schema64.TaggedErrorClass()("SkillRegistryError", {
|
|
12810
|
+
message: Schema64.String
|
|
12484
12811
|
}) {
|
|
12485
12812
|
}
|
|
12486
12813
|
|
|
@@ -12589,7 +12916,7 @@ var layer45 = Layer62.effect(Service43, Effect69.gen(function* () {
|
|
|
12589
12916
|
})
|
|
12590
12917
|
});
|
|
12591
12918
|
}));
|
|
12592
|
-
var
|
|
12919
|
+
var testLayer47 = (implementation) => Layer62.succeed(Service43, Service43.of(implementation));
|
|
12593
12920
|
var register9 = Effect69.fn("SkillRegistry.register.call")(function* (input) {
|
|
12594
12921
|
const service = yield* Service43;
|
|
12595
12922
|
return yield* service.register(input);
|
|
@@ -12637,7 +12964,7 @@ var sourceLayerForExecution = (executionId) => Layer62.effect(exports_skill_sour
|
|
|
12637
12964
|
// ../runtime/src/execution/execution-service.ts
|
|
12638
12965
|
var exports_execution_service = {};
|
|
12639
12966
|
__export(exports_execution_service, {
|
|
12640
|
-
testLayer: () =>
|
|
12967
|
+
testLayer: () => testLayer48,
|
|
12641
12968
|
stream: () => stream3,
|
|
12642
12969
|
spawnChildRun: () => spawnChildRun,
|
|
12643
12970
|
send: () => send,
|
|
@@ -12649,11 +12976,11 @@ __export(exports_execution_service, {
|
|
|
12649
12976
|
Service: () => Service44,
|
|
12650
12977
|
ExecutionServiceError: () => ExecutionServiceError
|
|
12651
12978
|
});
|
|
12652
|
-
import { Clock as Clock9, Context as Context57, Effect as Effect70, Layer as Layer63, Option as Option24, Schema as
|
|
12979
|
+
import { Clock as Clock9, Context as Context57, Effect as Effect70, Layer as Layer63, Option as Option24, Schema as Schema65, Stream as Stream9 } from "effect";
|
|
12653
12980
|
import { ShardingConfig } from "effect/unstable/cluster";
|
|
12654
|
-
class ExecutionServiceError extends
|
|
12655
|
-
message:
|
|
12656
|
-
next_event_sequence:
|
|
12981
|
+
class ExecutionServiceError extends Schema65.TaggedErrorClass()("ExecutionServiceError", {
|
|
12982
|
+
message: Schema65.String,
|
|
12983
|
+
next_event_sequence: Schema65.optionalKey(exports_execution_schema.ExecutionEventSequence)
|
|
12657
12984
|
}) {
|
|
12658
12985
|
}
|
|
12659
12986
|
|
|
@@ -12941,11 +13268,11 @@ var layer46 = Layer63.effect(Service44, Effect70.gen(function* () {
|
|
|
12941
13268
|
...override === undefined ? {} : { override }
|
|
12942
13269
|
}).pipe(Effect70.mapError(mapChildRunError2));
|
|
12943
13270
|
}),
|
|
12944
|
-
stream: (input) => eventLog.stream(input).pipe(
|
|
13271
|
+
stream: (input) => eventLog.stream(input).pipe(Stream9.take(input.limit ?? 1000), Stream9.mapError((error) => mapEventLogError4(error)))
|
|
12945
13272
|
});
|
|
12946
13273
|
}));
|
|
12947
13274
|
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
|
|
13275
|
+
var testLayer48 = (implementation) => Layer63.succeed(Service44, Service44.of(implementation));
|
|
12949
13276
|
var accept = Effect70.fn("ExecutionService.accept.call")(function* (input) {
|
|
12950
13277
|
const service = yield* Service44;
|
|
12951
13278
|
return yield* service.accept(input);
|
|
@@ -12966,16 +13293,16 @@ var spawnChildRun = Effect70.fn("ExecutionService.spawnChildRun.call")(function*
|
|
|
12966
13293
|
const service = yield* Service44;
|
|
12967
13294
|
return yield* service.spawnChildRun(input);
|
|
12968
13295
|
});
|
|
12969
|
-
var stream3 = (input) =>
|
|
13296
|
+
var stream3 = (input) => Stream9.unwrap(Service44.pipe(Effect70.map((service) => service.stream(input))));
|
|
12970
13297
|
|
|
12971
13298
|
// ../runtime/src/workspace/workspace-planner-service.ts
|
|
12972
|
-
import { Context as Context59, Effect as Effect72, HashSet as HashSet7, Layer as Layer65, Option as Option25, Schema as
|
|
13299
|
+
import { Context as Context59, Effect as Effect72, HashSet as HashSet7, Layer as Layer65, Option as Option25, Schema as Schema67 } from "effect";
|
|
12973
13300
|
|
|
12974
13301
|
// ../runtime/src/workspace/workspace-runtime-service.ts
|
|
12975
|
-
import { Context as Context58, Effect as Effect71, Layer as Layer64, Schema as
|
|
13302
|
+
import { Context as Context58, Effect as Effect71, Layer as Layer64, Schema as Schema66 } from "effect";
|
|
12976
13303
|
|
|
12977
|
-
class WorkspaceRuntimeError extends
|
|
12978
|
-
message:
|
|
13304
|
+
class WorkspaceRuntimeError extends Schema66.TaggedErrorClass()("WorkspaceRuntimeError", {
|
|
13305
|
+
message: Schema66.String
|
|
12979
13306
|
}) {
|
|
12980
13307
|
}
|
|
12981
13308
|
|
|
@@ -13003,18 +13330,18 @@ var exec = Effect71.fn("WorkspaceRuntime.exec.call")(function* (input) {
|
|
|
13003
13330
|
});
|
|
13004
13331
|
|
|
13005
13332
|
// ../runtime/src/workspace/workspace-planner-service.ts
|
|
13006
|
-
class WorkspaceRuntimeMissing extends
|
|
13333
|
+
class WorkspaceRuntimeMissing extends Schema67.TaggedErrorClass()("WorkspaceRuntimeMissing", {
|
|
13007
13334
|
execution_id: exports_ids_schema.ExecutionId
|
|
13008
13335
|
}) {
|
|
13009
13336
|
}
|
|
13010
13337
|
|
|
13011
|
-
class WorkspaceLeaseMissingRef extends
|
|
13338
|
+
class WorkspaceLeaseMissingRef extends Schema67.TaggedErrorClass()("WorkspaceLeaseMissingRef", {
|
|
13012
13339
|
execution_id: exports_ids_schema.ExecutionId
|
|
13013
13340
|
}) {
|
|
13014
13341
|
}
|
|
13015
13342
|
|
|
13016
|
-
class WorkspacePlannerError extends
|
|
13017
|
-
message:
|
|
13343
|
+
class WorkspacePlannerError extends Schema67.TaggedErrorClass()("WorkspacePlannerError", {
|
|
13344
|
+
message: Schema67.String
|
|
13018
13345
|
}) {
|
|
13019
13346
|
}
|
|
13020
13347
|
|
|
@@ -13200,67 +13527,67 @@ var fail = Effect72.fn("WorkspacePlanner.fail.call")(function* (input) {
|
|
|
13200
13527
|
});
|
|
13201
13528
|
|
|
13202
13529
|
// ../runtime/src/workflow/execution-workflow.ts
|
|
13203
|
-
class ExecutionWorkflowFailed extends
|
|
13204
|
-
message:
|
|
13530
|
+
class ExecutionWorkflowFailed extends Schema68.TaggedErrorClass()("ExecutionWorkflowFailed", {
|
|
13531
|
+
message: Schema68.String
|
|
13205
13532
|
}) {
|
|
13206
13533
|
}
|
|
13207
|
-
var StartInput =
|
|
13534
|
+
var StartInput = Schema68.Struct({
|
|
13208
13535
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13209
13536
|
root_address_id: exports_ids_schema.AddressId,
|
|
13210
|
-
session_id:
|
|
13211
|
-
input:
|
|
13537
|
+
session_id: Schema68.optionalKey(exports_ids_schema.SessionId),
|
|
13538
|
+
input: Schema68.optionalKey(Schema68.Array(exports_content_schema.Part)),
|
|
13212
13539
|
event_sequence: exports_execution_schema.ExecutionEventSequence,
|
|
13213
13540
|
started_at: exports_shared_schema.TimestampMillis,
|
|
13214
13541
|
completed_at: exports_shared_schema.TimestampMillis,
|
|
13215
|
-
agent_id:
|
|
13216
|
-
agent_revision:
|
|
13217
|
-
agent_snapshot:
|
|
13218
|
-
agent_tool_input_schema_digests:
|
|
13219
|
-
wait_id:
|
|
13220
|
-
resume_tool_call:
|
|
13221
|
-
workflow_generation:
|
|
13222
|
-
metadata:
|
|
13542
|
+
agent_id: Schema68.optionalKey(exports_ids_schema.AgentId),
|
|
13543
|
+
agent_revision: Schema68.optionalKey(exports_agent_schema.DefinitionRevision),
|
|
13544
|
+
agent_snapshot: Schema68.optionalKey(exports_agent_schema.Definition),
|
|
13545
|
+
agent_tool_input_schema_digests: Schema68.optionalKey(exports_agent_schema.ToolInputSchemaDigests),
|
|
13546
|
+
wait_id: Schema68.optionalKey(exports_ids_schema.WaitId),
|
|
13547
|
+
resume_tool_call: Schema68.optionalKey(exports_tool_schema.Call),
|
|
13548
|
+
workflow_generation: Schema68.optionalKey(Schema68.Int.check(Schema68.isGreaterThanOrEqualTo(0))),
|
|
13549
|
+
metadata: Schema68.optionalKey(exports_shared_schema.Metadata)
|
|
13223
13550
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.StartInput" });
|
|
13224
|
-
var WaitSignalState =
|
|
13551
|
+
var WaitSignalState = Schema68.Literals(["resolved", "timed_out", "cancelled"]).annotate({
|
|
13225
13552
|
identifier: "Relay.ExecutionWorkflow.WaitSignalState"
|
|
13226
13553
|
});
|
|
13227
|
-
var WaitSignal =
|
|
13554
|
+
var WaitSignal = Schema68.Struct({
|
|
13228
13555
|
wait_id: exports_ids_schema.WaitId,
|
|
13229
13556
|
state: WaitSignalState,
|
|
13230
13557
|
signaled_at: exports_shared_schema.TimestampMillis
|
|
13231
13558
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.WaitSignal" });
|
|
13232
|
-
var SignalWaitInput =
|
|
13233
|
-
workflow_execution_id:
|
|
13559
|
+
var SignalWaitInput = Schema68.Struct({
|
|
13560
|
+
workflow_execution_id: Schema68.String,
|
|
13234
13561
|
wait_id: exports_ids_schema.WaitId,
|
|
13235
13562
|
state: WaitSignalState,
|
|
13236
13563
|
signaled_at: exports_shared_schema.TimestampMillis
|
|
13237
13564
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.SignalWaitInput" });
|
|
13238
|
-
var CancelExecutionInput =
|
|
13565
|
+
var CancelExecutionInput = Schema68.Struct({
|
|
13239
13566
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13240
13567
|
cancelled_at: exports_shared_schema.TimestampMillis,
|
|
13241
|
-
reason:
|
|
13568
|
+
reason: Schema68.optionalKey(Schema68.String)
|
|
13242
13569
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.CancelExecutionInput" });
|
|
13243
|
-
var CancelExecutionResult =
|
|
13570
|
+
var CancelExecutionResult = Schema68.Struct({
|
|
13244
13571
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13245
13572
|
status: exports_execution_schema.ExecutionStatus
|
|
13246
13573
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.CancelExecutionResult" });
|
|
13247
|
-
var WaitSnapshot =
|
|
13574
|
+
var WaitSnapshot = Schema68.Struct({
|
|
13248
13575
|
id: exports_ids_schema.WaitId,
|
|
13249
13576
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13250
|
-
envelope_id:
|
|
13577
|
+
envelope_id: Schema68.optionalKey(exports_ids_schema.EnvelopeId),
|
|
13251
13578
|
mode: exports_envelope_schema.WaitMode,
|
|
13252
|
-
correlation_key:
|
|
13253
|
-
state:
|
|
13579
|
+
correlation_key: Schema68.optionalKey(Schema68.String),
|
|
13580
|
+
state: Schema68.Literals(["open", "resolved", "timed_out", "cancelled"]),
|
|
13254
13581
|
metadata: exports_shared_schema.Metadata,
|
|
13255
13582
|
created_at: exports_shared_schema.TimestampMillis,
|
|
13256
|
-
resolved_at:
|
|
13583
|
+
resolved_at: Schema68.optionalKey(exports_shared_schema.TimestampMillis)
|
|
13257
13584
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.WaitSnapshot" });
|
|
13258
|
-
var StartResult =
|
|
13585
|
+
var StartResult = Schema68.Struct({
|
|
13259
13586
|
execution_id: exports_ids_schema.ExecutionId,
|
|
13260
13587
|
status: exports_execution_schema.ExecutionStatus,
|
|
13261
|
-
wait_id:
|
|
13262
|
-
wait_state:
|
|
13263
|
-
metadata:
|
|
13588
|
+
wait_id: Schema68.optionalKey(exports_ids_schema.WaitId),
|
|
13589
|
+
wait_state: Schema68.optionalKey(Schema68.Literals(["resolved", "timed_out", "cancelled"])),
|
|
13590
|
+
metadata: Schema68.optionalKey(exports_shared_schema.Metadata)
|
|
13264
13591
|
}).annotate({ identifier: "Relay.ExecutionWorkflow.StartResult" });
|
|
13265
13592
|
var StartExecutionWorkflowName = "Relay/Execution/Start";
|
|
13266
13593
|
var ActivityNames = {
|
|
@@ -13470,7 +13797,7 @@ var cancelExecution = (input, turn, reason) => Activity.make({
|
|
|
13470
13797
|
});
|
|
13471
13798
|
var loadCancellationRequested = (input, turn) => Activity.make({
|
|
13472
13799
|
name: ActivityNames.checkCancel(turn),
|
|
13473
|
-
success:
|
|
13800
|
+
success: Schema68.Boolean,
|
|
13474
13801
|
error: ExecutionWorkflowFailed,
|
|
13475
13802
|
execute: Effect73.gen(function* () {
|
|
13476
13803
|
const repository = yield* exports_execution_repository.Service;
|
|
@@ -13480,7 +13807,7 @@ var loadCancellationRequested = (input, turn) => Activity.make({
|
|
|
13480
13807
|
});
|
|
13481
13808
|
var loadWait = (name, waitId) => Activity.make({
|
|
13482
13809
|
name,
|
|
13483
|
-
success:
|
|
13810
|
+
success: Schema68.UndefinedOr(WaitSnapshot),
|
|
13484
13811
|
error: ExecutionWorkflowFailed,
|
|
13485
13812
|
execute: get11(waitId).pipe(Effect73.map((record2) => record2 === undefined ? undefined : toWaitSnapshot(record2)), Effect73.mapError(mapWaitError2))
|
|
13486
13813
|
});
|
|
@@ -13571,7 +13898,7 @@ var compactionForStart = Effect73.fn("ExecutionWorkflow.compactionForStart")(fun
|
|
|
13571
13898
|
...keepRecentTokens === undefined ? {} : { keepRecentTokens }
|
|
13572
13899
|
};
|
|
13573
13900
|
});
|
|
13574
|
-
var decodeMemorySubject = (value) => typeof value === "string" ?
|
|
13901
|
+
var decodeMemorySubject = (value) => typeof value === "string" ? Schema68.decodeUnknownEffect(exports_ids_schema.MemorySubjectId)(value).pipe(Effect73.mapError(() => new ExecutionWorkflowFailed({ message: `Invalid memory_subject_id metadata value: ${value}` }))) : Effect73.fail(new ExecutionWorkflowFailed({ message: "memory_subject_id metadata value must be a string" }));
|
|
13575
13902
|
var memorySubjectForStart = Effect73.fn("ExecutionWorkflow.memorySubjectForStart")(function* (input) {
|
|
13576
13903
|
const executionSubject = memorySubjectFromMetadata(input.metadata);
|
|
13577
13904
|
if (executionSubject !== undefined)
|
|
@@ -13589,7 +13916,7 @@ var steeringEnabledForStart = (input) => {
|
|
|
13589
13916
|
var nextEventSequence4 = (eventLog, executionId) => eventLog.maxSequence(executionId).pipe(Effect73.map((max) => max === undefined ? 0 : max + 1), Effect73.mapError(mapEventLogError6));
|
|
13590
13917
|
var ensureWorkspace = (input) => Activity.make({
|
|
13591
13918
|
name: ActivityNames.ensureWorkspace,
|
|
13592
|
-
success:
|
|
13919
|
+
success: Schema68.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
13593
13920
|
error: ExecutionWorkflowFailed,
|
|
13594
13921
|
execute: Effect73.gen(function* () {
|
|
13595
13922
|
if (input.agent_snapshot === undefined)
|
|
@@ -13606,19 +13933,19 @@ var ensureWorkspace = (input) => Activity.make({
|
|
|
13606
13933
|
});
|
|
13607
13934
|
var suspendWorkspace = (input, key2) => Activity.make({
|
|
13608
13935
|
name: ActivityNames.suspendWorkspace(key2),
|
|
13609
|
-
success:
|
|
13936
|
+
success: Schema68.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
13610
13937
|
error: ExecutionWorkflowFailed,
|
|
13611
13938
|
execute: suspend2({ executionId: input.execution_id, now: input.started_at }).pipe(Effect73.mapError(mapWorkspaceError))
|
|
13612
13939
|
});
|
|
13613
13940
|
var resumeWorkspace = (input, key2) => Activity.make({
|
|
13614
13941
|
name: ActivityNames.resumeWorkspace(key2),
|
|
13615
|
-
success:
|
|
13942
|
+
success: Schema68.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
13616
13943
|
error: ExecutionWorkflowFailed,
|
|
13617
13944
|
execute: resume2({ executionId: input.execution_id, now: input.started_at }).pipe(Effect73.map((plan2) => plan2?.lease), Effect73.mapError(mapWorkspaceError))
|
|
13618
13945
|
});
|
|
13619
13946
|
var releaseWorkspace = (input) => Activity.make({
|
|
13620
13947
|
name: ActivityNames.releaseWorkspace,
|
|
13621
|
-
success:
|
|
13948
|
+
success: Schema68.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
13622
13949
|
error: ExecutionWorkflowFailed,
|
|
13623
13950
|
execute: release2({ executionId: input.execution_id, now: input.completed_at }).pipe(Effect73.mapError(mapWorkspaceError))
|
|
13624
13951
|
});
|
|
@@ -13719,7 +14046,7 @@ var childDispatchContext = (input) => {
|
|
|
13719
14046
|
};
|
|
13720
14047
|
var loadChildCancellationRequested = (input) => Activity.make({
|
|
13721
14048
|
name: ActivityNames.checkQueuedChildCancellation,
|
|
13722
|
-
success:
|
|
14049
|
+
success: Schema68.Boolean,
|
|
13723
14050
|
error: ExecutionWorkflowFailed,
|
|
13724
14051
|
execute: Effect73.gen(function* () {
|
|
13725
14052
|
const context = childDispatchContext(input);
|
|
@@ -13731,7 +14058,7 @@ var loadChildCancellationRequested = (input) => Activity.make({
|
|
|
13731
14058
|
});
|
|
13732
14059
|
var notifyParentActivity = (input, context, status, output) => Activity.make({
|
|
13733
14060
|
name: ActivityNames.notifyParent(status),
|
|
13734
|
-
success:
|
|
14061
|
+
success: Schema68.Void,
|
|
13735
14062
|
error: ExecutionWorkflowFailed,
|
|
13736
14063
|
execute: Effect73.gen(function* () {
|
|
13737
14064
|
const notifier = yield* Effect73.serviceOption(Service42);
|
|
@@ -13784,7 +14111,7 @@ var waitIdFromExecution = (execution) => {
|
|
|
13784
14111
|
};
|
|
13785
14112
|
var pendingToolCallFromExecution = (execution) => {
|
|
13786
14113
|
const pending = execution.metadata?.pending_tool_call;
|
|
13787
|
-
return
|
|
14114
|
+
return Schema68.decodeUnknownOption(exports_tool_schema.Call)(pending).pipe(Option26.getOrUndefined);
|
|
13788
14115
|
};
|
|
13789
14116
|
var finishCancelledWait = Effect73.fn("ExecutionWorkflow.finishCancelledWait")(function* (startInput, turn, waitId) {
|
|
13790
14117
|
const cancelled = yield* cancelExecution(startInput, turn, "wait cancelled");
|
|
@@ -13998,7 +14325,7 @@ var Start = Rpc.make("start", {
|
|
|
13998
14325
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
13999
14326
|
var SignalWait = Rpc.make("signalWait", {
|
|
14000
14327
|
payload: SignalWaitInput,
|
|
14001
|
-
success:
|
|
14328
|
+
success: Schema69.Void,
|
|
14002
14329
|
error: ExecutionWorkflowFailed
|
|
14003
14330
|
}).annotate(ClusterSchema.Persisted, true).annotate(ClusterSchema.Uninterruptible, "server");
|
|
14004
14331
|
var Cancel = Rpc.make("cancel", {
|
|
@@ -14012,11 +14339,11 @@ var layer49 = entity.toLayer(entity.of({
|
|
|
14012
14339
|
signalWait: (request) => signalWait(request.payload),
|
|
14013
14340
|
cancel: (request) => cancelRequest(request.payload)
|
|
14014
14341
|
}), { concurrency: "unbounded" });
|
|
14015
|
-
var
|
|
14342
|
+
var client2 = entity.client;
|
|
14016
14343
|
// ../runtime/src/envelope/envelope-service.ts
|
|
14017
14344
|
var exports_envelope_service = {};
|
|
14018
14345
|
__export(exports_envelope_service, {
|
|
14019
|
-
testLayer: () =>
|
|
14346
|
+
testLayer: () => testLayer49,
|
|
14020
14347
|
send: () => send2,
|
|
14021
14348
|
memoryLayer: () => memoryLayer33,
|
|
14022
14349
|
layer: () => layer50,
|
|
@@ -14026,26 +14353,26 @@ __export(exports_envelope_service, {
|
|
|
14026
14353
|
EnvelopeRouteDeferred: () => EnvelopeRouteDeferred,
|
|
14027
14354
|
EnvelopeAddressNotFound: () => EnvelopeAddressNotFound
|
|
14028
14355
|
});
|
|
14029
|
-
import { Context as Context60, Effect as Effect74, Layer as Layer67, Schema as
|
|
14030
|
-
class EnvelopeAddressNotFound extends
|
|
14356
|
+
import { Context as Context60, Effect as Effect74, Layer as Layer67, Schema as Schema70 } from "effect";
|
|
14357
|
+
class EnvelopeAddressNotFound extends Schema70.TaggedErrorClass()("EnvelopeAddressNotFound", {
|
|
14031
14358
|
address_id: exports_ids_schema.AddressId
|
|
14032
14359
|
}) {
|
|
14033
14360
|
}
|
|
14034
14361
|
|
|
14035
|
-
class EnvelopeRouteUnavailable extends
|
|
14362
|
+
class EnvelopeRouteUnavailable extends Schema70.TaggedErrorClass()("EnvelopeRouteUnavailable", {
|
|
14036
14363
|
address_id: exports_ids_schema.AddressId,
|
|
14037
|
-
route_key:
|
|
14364
|
+
route_key: Schema70.String
|
|
14038
14365
|
}) {
|
|
14039
14366
|
}
|
|
14040
14367
|
|
|
14041
|
-
class EnvelopeRouteDeferred extends
|
|
14368
|
+
class EnvelopeRouteDeferred extends Schema70.TaggedErrorClass()("EnvelopeRouteDeferred", {
|
|
14042
14369
|
address_id: exports_ids_schema.AddressId,
|
|
14043
|
-
route_key:
|
|
14370
|
+
route_key: Schema70.String
|
|
14044
14371
|
}) {
|
|
14045
14372
|
}
|
|
14046
14373
|
|
|
14047
|
-
class EnvelopeServiceError extends
|
|
14048
|
-
message:
|
|
14374
|
+
class EnvelopeServiceError extends Schema70.TaggedErrorClass()("EnvelopeServiceError", {
|
|
14375
|
+
message: Schema70.String
|
|
14049
14376
|
}) {
|
|
14050
14377
|
}
|
|
14051
14378
|
|
|
@@ -14080,16 +14407,16 @@ var waitIdFor = (input) => {
|
|
|
14080
14407
|
return;
|
|
14081
14408
|
return input.waitId ?? exports_ids_schema.WaitId.make(`wait:${input.envelopeId}`);
|
|
14082
14409
|
};
|
|
14083
|
-
var readyFor = (input,
|
|
14084
|
-
if (
|
|
14410
|
+
var readyFor = (input, route2) => {
|
|
14411
|
+
if (route2.kind === "local-agent")
|
|
14085
14412
|
return;
|
|
14086
14413
|
return {
|
|
14087
14414
|
id: exports_ids_schema.EnvelopeReadyId.make(`envelope-ready:${input.envelopeId}`),
|
|
14088
|
-
routeType:
|
|
14089
|
-
routeKey:
|
|
14415
|
+
routeType: route2.kind,
|
|
14416
|
+
routeKey: route2.route_key,
|
|
14090
14417
|
availableAt: input.createdAt,
|
|
14091
14418
|
...input.input.correlation_key === undefined ? {} : { idempotencyKey: input.input.correlation_key },
|
|
14092
|
-
...
|
|
14419
|
+
...route2.metadata === undefined ? {} : { metadata: route2.metadata }
|
|
14093
14420
|
};
|
|
14094
14421
|
};
|
|
14095
14422
|
var acceptedEvent2 = (input) => ({
|
|
@@ -14106,7 +14433,7 @@ var acceptedEvent2 = (input) => ({
|
|
|
14106
14433
|
},
|
|
14107
14434
|
created_at: input.createdAt
|
|
14108
14435
|
});
|
|
14109
|
-
var routedEvent = (input,
|
|
14436
|
+
var routedEvent = (input, route2) => ({
|
|
14110
14437
|
id: exports_ids_schema.EventId.make(`event:${input.envelopeId}:routed`),
|
|
14111
14438
|
execution_id: input.executionId,
|
|
14112
14439
|
type: "envelope.routed",
|
|
@@ -14114,8 +14441,8 @@ var routedEvent = (input, route) => ({
|
|
|
14114
14441
|
cursor: `${input.executionId}:envelope:${input.envelopeId}:routed`,
|
|
14115
14442
|
data: {
|
|
14116
14443
|
envelope_id: input.envelopeId,
|
|
14117
|
-
route_kind:
|
|
14118
|
-
route_key:
|
|
14444
|
+
route_kind: route2.kind,
|
|
14445
|
+
route_key: route2.route_key
|
|
14119
14446
|
},
|
|
14120
14447
|
created_at: input.createdAt + 1
|
|
14121
14448
|
});
|
|
@@ -14145,13 +14472,13 @@ var layer50 = Layer67.effect(Service47, Effect74.gen(function* () {
|
|
|
14145
14472
|
"relay.address.from": input.input.from,
|
|
14146
14473
|
"relay.address.to": input.input.to
|
|
14147
14474
|
});
|
|
14148
|
-
const
|
|
14475
|
+
const route2 = yield* addressBook.resolve(input.input.to).pipe(Effect74.mapError(mapAddressBookError2));
|
|
14149
14476
|
yield* Effect74.annotateCurrentSpan({
|
|
14150
|
-
"relay.route.kind":
|
|
14151
|
-
"relay.route.key":
|
|
14477
|
+
"relay.route.kind": route2.kind,
|
|
14478
|
+
"relay.route.key": route2.route_key
|
|
14152
14479
|
});
|
|
14153
14480
|
const envelope = envelopeFrom(input);
|
|
14154
|
-
const ready = readyFor(input,
|
|
14481
|
+
const ready = readyFor(input, route2);
|
|
14155
14482
|
const waitId = waitIdFor(input);
|
|
14156
14483
|
const accepted2 = yield* repository.acceptEnvelope({
|
|
14157
14484
|
envelope,
|
|
@@ -14159,17 +14486,17 @@ var layer50 = Layer67.effect(Service47, Effect74.gen(function* () {
|
|
|
14159
14486
|
...ready === undefined ? {} : { ready }
|
|
14160
14487
|
}).pipe(Effect74.mapError(mapRepositoryError12));
|
|
14161
14488
|
yield* eventLog.append(acceptedEvent2(input)).pipe(Effect74.mapError(mapEventLogError7));
|
|
14162
|
-
yield* eventLog.append(routedEvent(input,
|
|
14489
|
+
yield* eventLog.append(routedEvent(input, route2)).pipe(Effect74.mapError(mapEventLogError7));
|
|
14163
14490
|
if (ready !== undefined) {
|
|
14164
14491
|
yield* eventLog.append(readyEvent(input, ready)).pipe(Effect74.mapError(mapEventLogError7));
|
|
14165
14492
|
}
|
|
14166
|
-
yield* recordEnvelopeSent(
|
|
14493
|
+
yield* recordEnvelopeSent(route2.kind);
|
|
14167
14494
|
return accepted2;
|
|
14168
14495
|
})
|
|
14169
14496
|
});
|
|
14170
14497
|
}));
|
|
14171
14498
|
var memoryLayer33 = (routes = []) => layer50.pipe(Layer67.provide(memoryLayer20(routes)), Layer67.provide(exports_envelope_repository.memoryLayer), Layer67.provide(memoryLayer21));
|
|
14172
|
-
var
|
|
14499
|
+
var testLayer49 = (implementation) => Layer67.succeed(Service47, Service47.of(implementation));
|
|
14173
14500
|
var send2 = Effect74.fn("EnvelopeService.send.call")(function* (input) {
|
|
14174
14501
|
const service = yield* Service47;
|
|
14175
14502
|
return yield* service.send(input);
|
|
@@ -14180,7 +14507,7 @@ __export(exports_runner_runtime_service, {
|
|
|
14180
14507
|
testLayerWithServices: () => testLayerWithServices,
|
|
14181
14508
|
testLayerWithLanguageModelService: () => testLayerWithLanguageModelService,
|
|
14182
14509
|
testLayerWithDatabaseCheck: () => testLayerWithDatabaseCheck,
|
|
14183
|
-
testLayer: () =>
|
|
14510
|
+
testLayer: () => testLayer51,
|
|
14184
14511
|
testClientLayerWithDatabaseCheck: () => testClientLayerWithDatabaseCheck,
|
|
14185
14512
|
testClientLayer: () => testClientLayer,
|
|
14186
14513
|
shardingConfigFromEnv: () => shardingConfigFromEnv,
|
|
@@ -14203,7 +14530,7 @@ __export(exports_runner_runtime_service, {
|
|
|
14203
14530
|
DatabaseMode: () => DatabaseMode,
|
|
14204
14531
|
ClusterConfigMismatch: () => ClusterConfigMismatch
|
|
14205
14532
|
});
|
|
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
|
|
14533
|
+
import { Config as Config5, Context as Context62, Crypto as Crypto4, Duration as Duration5, Effect as Effect77, Layer as Layer69, Option as Option27, Schema as Schema72, Stream as Stream10 } from "effect";
|
|
14207
14534
|
import {
|
|
14208
14535
|
ClusterWorkflowEngine,
|
|
14209
14536
|
HttpRunner,
|
|
@@ -14221,13 +14548,13 @@ import { FetchHttpClient } from "effect/unstable/http";
|
|
|
14221
14548
|
import { SqlClient as SqlClient22 } from "effect/unstable/sql/SqlClient";
|
|
14222
14549
|
import { RpcSerialization } from "effect/unstable/rpc";
|
|
14223
14550
|
import { WorkflowEngine } from "effect/unstable/workflow";
|
|
14224
|
-
import { LanguageModel as
|
|
14551
|
+
import { LanguageModel as LanguageModel7 } from "effect/unstable/ai";
|
|
14225
14552
|
|
|
14226
14553
|
// ../runtime/src/schedule/scheduler-service.ts
|
|
14227
14554
|
var exports_scheduler_service = {};
|
|
14228
14555
|
__export(exports_scheduler_service, {
|
|
14229
14556
|
workerIdConfig: () => workerIdConfig,
|
|
14230
|
-
testLayer: () =>
|
|
14557
|
+
testLayer: () => testLayer50,
|
|
14231
14558
|
startIdempotencyKey: () => startIdempotencyKey,
|
|
14232
14559
|
runOnce: () => runOnce2,
|
|
14233
14560
|
pollIntervalMillisConfig: () => pollIntervalMillisConfig,
|
|
@@ -14241,7 +14568,7 @@ __export(exports_scheduler_service, {
|
|
|
14241
14568
|
SchedulerError: () => SchedulerError,
|
|
14242
14569
|
ScheduleCronInvalid: () => ScheduleCronInvalid
|
|
14243
14570
|
});
|
|
14244
|
-
import { Clock as Clock10, Config as Config4, Context as Context61, Cron, Duration as Duration4, Effect as Effect76, Layer as Layer68, Random, Result as Result3, Schema as
|
|
14571
|
+
import { Clock as Clock10, Config as Config4, Context as Context61, Cron, Duration as Duration4, Effect as Effect76, Layer as Layer68, Random, Result as Result3, Schema as Schema71 } from "effect";
|
|
14245
14572
|
|
|
14246
14573
|
// ../runtime/src/wait/wait-signal.ts
|
|
14247
14574
|
var exports_wait_signal = {};
|
|
@@ -14251,8 +14578,8 @@ __export(exports_wait_signal, {
|
|
|
14251
14578
|
import { Effect as Effect75 } from "effect";
|
|
14252
14579
|
var signalWorkflowWait = Effect75.fn("WaitSignal.signalWorkflowWait")(function* (input) {
|
|
14253
14580
|
const workflowExecutionId2 = yield* activeWorkflowExecutionIdForExecution(input.executionId);
|
|
14254
|
-
const
|
|
14255
|
-
yield*
|
|
14581
|
+
const client3 = input.makeExecutionClient(input.executionId);
|
|
14582
|
+
yield* client3.signalWait({
|
|
14256
14583
|
workflow_execution_id: workflowExecutionId2,
|
|
14257
14584
|
wait_id: input.waitId,
|
|
14258
14585
|
state: input.state,
|
|
@@ -14261,14 +14588,14 @@ var signalWorkflowWait = Effect75.fn("WaitSignal.signalWorkflowWait")(function*
|
|
|
14261
14588
|
});
|
|
14262
14589
|
|
|
14263
14590
|
// ../runtime/src/schedule/scheduler-service.ts
|
|
14264
|
-
class SchedulerError extends
|
|
14265
|
-
message:
|
|
14591
|
+
class SchedulerError extends Schema71.TaggedErrorClass()("SchedulerError", {
|
|
14592
|
+
message: Schema71.String
|
|
14266
14593
|
}) {
|
|
14267
14594
|
}
|
|
14268
14595
|
|
|
14269
|
-
class ScheduleCronInvalid extends
|
|
14270
|
-
cron_expr:
|
|
14271
|
-
message:
|
|
14596
|
+
class ScheduleCronInvalid extends Schema71.TaggedErrorClass()("ScheduleCronInvalid", {
|
|
14597
|
+
cron_expr: Schema71.String,
|
|
14598
|
+
message: Schema71.String
|
|
14272
14599
|
}) {
|
|
14273
14600
|
}
|
|
14274
14601
|
|
|
@@ -14284,7 +14611,7 @@ var parseCron = (cronExpr) => {
|
|
|
14284
14611
|
return Result3.isFailure(parsed) ? Effect76.fail(new ScheduleCronInvalid({ cron_expr: cronExpr, message: String(parsed.failure) })) : Effect76.succeed(parsed.success);
|
|
14285
14612
|
};
|
|
14286
14613
|
var startIdempotencyKey = (schedule) => `schedule:${schedule.id}:${schedule.next_run_at}`;
|
|
14287
|
-
var
|
|
14614
|
+
var errorMessage3 = (error) => {
|
|
14288
14615
|
if (error instanceof Error)
|
|
14289
14616
|
return error.message;
|
|
14290
14617
|
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
@@ -14292,7 +14619,7 @@ var errorMessage2 = (error) => {
|
|
|
14292
14619
|
}
|
|
14293
14620
|
return String(error);
|
|
14294
14621
|
};
|
|
14295
|
-
var toSchedulerError = (error) => new SchedulerError({ message:
|
|
14622
|
+
var toSchedulerError = (error) => new SchedulerError({ message: errorMessage3(error) });
|
|
14296
14623
|
var dispatchMetadata = (schedule) => ({
|
|
14297
14624
|
source: "schedule",
|
|
14298
14625
|
schedule_id: schedule.id
|
|
@@ -14306,7 +14633,7 @@ var make14 = Effect76.gen(function* () {
|
|
|
14306
14633
|
const waits = yield* Service25;
|
|
14307
14634
|
const eventLog = yield* Service24;
|
|
14308
14635
|
const executionRepository = yield* exports_execution_repository.Service;
|
|
14309
|
-
const makeExecutionClient = yield*
|
|
14636
|
+
const makeExecutionClient = yield* client2;
|
|
14310
14637
|
const workerId = yield* workerIdConfig;
|
|
14311
14638
|
const claimTtlMillis = yield* claimTtlMillisConfig;
|
|
14312
14639
|
const pollIntervalMillis = yield* pollIntervalMillisConfig;
|
|
@@ -14412,32 +14739,32 @@ var layer51 = Layer68.effect(Service48, Effect76.gen(function* () {
|
|
|
14412
14739
|
return service;
|
|
14413
14740
|
}));
|
|
14414
14741
|
var memoryLayer34 = Layer68.effect(Service48, make14);
|
|
14415
|
-
var
|
|
14742
|
+
var testLayer50 = (implementation) => Layer68.succeed(Service48, Service48.of(implementation));
|
|
14416
14743
|
var runOnce2 = Effect76.fn("SchedulerService.runOnce.call")(function* () {
|
|
14417
14744
|
const service = yield* Service48;
|
|
14418
14745
|
return yield* service.runOnce;
|
|
14419
14746
|
});
|
|
14420
14747
|
|
|
14421
14748
|
// ../runtime/src/runner/runner-runtime-service.ts
|
|
14422
|
-
var DatabaseMode =
|
|
14749
|
+
var DatabaseMode = Schema72.Literals(["sql", "pg", "mysql", "sqlite", "memory"]).annotate({
|
|
14423
14750
|
identifier: "Relay.RunnerRuntime.DatabaseMode"
|
|
14424
14751
|
});
|
|
14425
|
-
var ReadinessStatus =
|
|
14752
|
+
var ReadinessStatus = Schema72.Struct({
|
|
14426
14753
|
database: DatabaseMode,
|
|
14427
|
-
cluster:
|
|
14428
|
-
workflow:
|
|
14429
|
-
executionEntity:
|
|
14754
|
+
cluster: Schema72.Literal("ready"),
|
|
14755
|
+
workflow: Schema72.Literals(["ready", "client"]),
|
|
14756
|
+
executionEntity: Schema72.Literals(["registered", "client"])
|
|
14430
14757
|
}).annotate({ identifier: "Relay.RunnerRuntime.ReadinessStatus" });
|
|
14431
14758
|
|
|
14432
|
-
class RunnerRuntimeError extends
|
|
14433
|
-
message:
|
|
14759
|
+
class RunnerRuntimeError extends Schema72.TaggedErrorClass()("RunnerRuntimeError", {
|
|
14760
|
+
message: Schema72.String
|
|
14434
14761
|
}) {
|
|
14435
14762
|
}
|
|
14436
14763
|
|
|
14437
|
-
class ClusterConfigMismatch extends
|
|
14438
|
-
field:
|
|
14439
|
-
expected:
|
|
14440
|
-
actual:
|
|
14764
|
+
class ClusterConfigMismatch extends Schema72.TaggedErrorClass()("ClusterConfigMismatch", {
|
|
14765
|
+
field: Schema72.String,
|
|
14766
|
+
expected: Schema72.String,
|
|
14767
|
+
actual: Schema72.String
|
|
14441
14768
|
}) {
|
|
14442
14769
|
}
|
|
14443
14770
|
|
|
@@ -14451,7 +14778,7 @@ var memoryClusterLayer = Sharding.layer.pipe(Layer69.provideMerge(Runners.layerN
|
|
|
14451
14778
|
var clusterHost = Config5.string("RELAY_CLUSTER_HOST").pipe(Config5.withDefault("localhost"));
|
|
14452
14779
|
var clusterPort = Config5.int("RELAY_CLUSTER_PORT").pipe(Config5.withDefault(34431));
|
|
14453
14780
|
var clusterShardsPerGroup = Config5.int("RELAY_CLUSTER_SHARDS_PER_GROUP").pipe(Config5.withDefault(300));
|
|
14454
|
-
var clusterShardGroups = Config5.schema(Config5.Array(
|
|
14781
|
+
var clusterShardGroups = Config5.schema(Config5.Array(Schema72.String), "RELAY_CLUSTER_SHARD_GROUPS").pipe(Config5.withDefault(["default", "execution"]));
|
|
14455
14782
|
var runnerAddressKey = (address) => `${address.host}:${address.port}`;
|
|
14456
14783
|
var runnerAddressEquals = (left, right) => left.host === right.host && left.port === right.port;
|
|
14457
14784
|
var shardingConfigFromEnv = () => Layer69.effect(ShardingConfig2.ShardingConfig, Effect77.gen(function* () {
|
|
@@ -14552,7 +14879,7 @@ var testCryptoLayer = Layer69.succeed(Crypto4.Crypto, Crypto4.make({
|
|
|
14552
14879
|
var executionServiceLayer = layer46.pipe(Layer69.provideMerge(layer32));
|
|
14553
14880
|
var addressResolutionLayerWith = (toolRuntimeLayer) => layer25.pipe(Layer69.provideMerge(layerFromRepository), Layer69.provideMerge(layer24.pipe(Layer69.provideMerge(toolRuntimeLayer))));
|
|
14554
14881
|
var parentNotifierLayer = Layer69.effect(Service42, Effect77.gen(function* () {
|
|
14555
|
-
const makeExecutionClient = yield*
|
|
14882
|
+
const makeExecutionClient = yield* client2;
|
|
14556
14883
|
const executionRepository = yield* exports_execution_repository.Service;
|
|
14557
14884
|
return yield* make13({
|
|
14558
14885
|
signalWait: (input) => signalWorkflowWait({
|
|
@@ -14568,10 +14895,10 @@ var agentLoopLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistry
|
|
|
14568
14895
|
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
14896
|
var workflowLayerWith = (toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer) => layer48.pipe(Layer69.provideMerge(runtimeServicesLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer)));
|
|
14570
14897
|
var workflowAndEntityLayerWith = (toolRuntimeLayer, schedulerLayer, promptAssemblerLayer, schemaRegistryLayer) => Layer69.mergeAll(layer49, schedulerLayer).pipe(Layer69.provideMerge(workflowLayerWith(toolRuntimeLayer, promptAssemblerLayer, schemaRegistryLayer)));
|
|
14571
|
-
var
|
|
14898
|
+
var makeService2 = (database, checkDatabase) => Effect77.gen(function* () {
|
|
14572
14899
|
const sharding = yield* Sharding.Sharding;
|
|
14573
14900
|
const workflow = yield* WorkflowEngine.WorkflowEngine;
|
|
14574
|
-
const makeClient = yield*
|
|
14901
|
+
const makeClient = yield* client2;
|
|
14575
14902
|
return Service49.of({
|
|
14576
14903
|
check: Effect77.fn("RunnerRuntime.check")(function* () {
|
|
14577
14904
|
yield* Effect77.annotateCurrentSpan("relay.database.mode", database);
|
|
@@ -14589,7 +14916,7 @@ var makeService = (database, checkDatabase) => Effect77.gen(function* () {
|
|
|
14589
14916
|
})
|
|
14590
14917
|
});
|
|
14591
14918
|
});
|
|
14592
|
-
var checkLayer = (database, checkDatabase) => Layer69.effect(Service49,
|
|
14919
|
+
var checkLayer = (database, checkDatabase) => Layer69.effect(Service49, makeService2(database, checkDatabase));
|
|
14593
14920
|
var memoryCheckLayer = checkLayer("memory", Effect77.void);
|
|
14594
14921
|
var detectDialect = Effect77.serviceOption(SqlClient22).pipe(Effect77.map(Option27.match({
|
|
14595
14922
|
onNone: () => "sql",
|
|
@@ -14614,11 +14941,11 @@ var databaseHealthCheck = Effect77.gen(function* () {
|
|
|
14614
14941
|
var sqlCheckLayer = Layer69.effect(Service49, Effect77.gen(function* () {
|
|
14615
14942
|
const dialect2 = yield* detectDialect;
|
|
14616
14943
|
const checkDatabase = yield* databaseHealthCheck;
|
|
14617
|
-
return yield*
|
|
14944
|
+
return yield* makeService2(dialect2, checkDatabase);
|
|
14618
14945
|
}));
|
|
14619
14946
|
var makeClientService = (database, checkDatabase) => Effect77.gen(function* () {
|
|
14620
14947
|
const sharding = yield* Sharding.Sharding;
|
|
14621
|
-
const makeClient = yield*
|
|
14948
|
+
const makeClient = yield* client2;
|
|
14622
14949
|
return Service49.of({
|
|
14623
14950
|
check: Effect77.fn("RunnerRuntime.check")(function* () {
|
|
14624
14951
|
yield* Effect77.annotateCurrentSpan("relay.database.mode", database);
|
|
@@ -14647,9 +14974,9 @@ var sqlClientCheckLayer = Layer69.effect(Service49, Effect77.gen(function* () {
|
|
|
14647
14974
|
const checkDatabase = yield* databaseHealthCheck;
|
|
14648
14975
|
return yield* makeClientService(dialect2, checkDatabase);
|
|
14649
14976
|
}));
|
|
14650
|
-
var deterministicTestModelLayer = Layer69.effect(
|
|
14977
|
+
var deterministicTestModelLayer = Layer69.effect(LanguageModel7.LanguageModel, LanguageModel7.make({
|
|
14651
14978
|
generateText: () => Effect77.succeed([{ type: "text", text: "deterministic test response" }]),
|
|
14652
|
-
streamText: () =>
|
|
14979
|
+
streamText: () => Stream10.make({ type: "text-delta", id: "text", delta: "deterministic test response" })
|
|
14653
14980
|
}));
|
|
14654
14981
|
var testLanguageModelLayer = layerFromRegistrationEffects3([
|
|
14655
14982
|
registrationFromLayer3({
|
|
@@ -14735,7 +15062,7 @@ var testLayerWithServices = (options) => layerWith({
|
|
|
14735
15062
|
schedulerLayer: memoryLayer34
|
|
14736
15063
|
}).pipe(Layer69.provideMerge(testCryptoLayer));
|
|
14737
15064
|
var testLayerWithLanguageModelService = (languageModelLayer) => testLayerWithServices({ languageModelLayer, toolRuntimeLayer: layer23() });
|
|
14738
|
-
var
|
|
15065
|
+
var testLayer51 = testLayerWithServices({
|
|
14739
15066
|
languageModelLayer: testLanguageModelLayer,
|
|
14740
15067
|
toolRuntimeLayer: layer23()
|
|
14741
15068
|
});
|
|
@@ -14781,51 +15108,51 @@ __export(exports_activity_version_registry, {
|
|
|
14781
15108
|
ActivityManifestChange: () => ActivityManifestChange,
|
|
14782
15109
|
ActivityManifest: () => ActivityManifest
|
|
14783
15110
|
});
|
|
14784
|
-
import { Crypto as Crypto5, Effect as Effect78, Schema as
|
|
15111
|
+
import { Crypto as Crypto5, Effect as Effect78, Schema as Schema73 } from "effect";
|
|
14785
15112
|
var generatedFrom = "@relayfx/runtime/ExecutionWorkflow";
|
|
14786
|
-
var ActivityManifestEntry =
|
|
14787
|
-
name:
|
|
14788
|
-
signature_hash:
|
|
15113
|
+
var ActivityManifestEntry = Schema73.Struct({
|
|
15114
|
+
name: Schema73.String,
|
|
15115
|
+
signature_hash: Schema73.String
|
|
14789
15116
|
}).annotate({ identifier: "Relay.ActivityManifestEntry" });
|
|
14790
|
-
var ActivityManifest =
|
|
14791
|
-
version:
|
|
14792
|
-
generated_from:
|
|
14793
|
-
hash_algorithm:
|
|
14794
|
-
activities:
|
|
15117
|
+
var ActivityManifest = Schema73.Struct({
|
|
15118
|
+
version: Schema73.Literal(1),
|
|
15119
|
+
generated_from: Schema73.String,
|
|
15120
|
+
hash_algorithm: Schema73.Literal("sha256-json-schema-v1"),
|
|
15121
|
+
activities: Schema73.Array(ActivityManifestEntry)
|
|
14795
15122
|
}).annotate({ identifier: "Relay.ActivityManifest" });
|
|
14796
|
-
var ActivityManifestChange =
|
|
14797
|
-
type:
|
|
14798
|
-
name:
|
|
14799
|
-
baseline_hash:
|
|
14800
|
-
current_hash:
|
|
15123
|
+
var ActivityManifestChange = Schema73.Struct({
|
|
15124
|
+
type: Schema73.Literals(["removed", "changed", "added"]),
|
|
15125
|
+
name: Schema73.String,
|
|
15126
|
+
baseline_hash: Schema73.optionalKey(Schema73.String),
|
|
15127
|
+
current_hash: Schema73.optionalKey(Schema73.String)
|
|
14801
15128
|
}).annotate({ identifier: "Relay.ActivityManifestChange" });
|
|
14802
|
-
var ActivityManifestGuardResult =
|
|
14803
|
-
status:
|
|
14804
|
-
waiting_executions:
|
|
14805
|
-
breaking_changes:
|
|
14806
|
-
additive_changes:
|
|
15129
|
+
var ActivityManifestGuardResult = Schema73.Struct({
|
|
15130
|
+
status: Schema73.Literals(["pass", "fail"]),
|
|
15131
|
+
waiting_executions: Schema73.Int.check(Schema73.isGreaterThanOrEqualTo(0)),
|
|
15132
|
+
breaking_changes: Schema73.Array(ActivityManifestChange),
|
|
15133
|
+
additive_changes: Schema73.Array(ActivityManifestChange)
|
|
14807
15134
|
}).annotate({ identifier: "Relay.ActivityManifestGuardResult" });
|
|
14808
15135
|
|
|
14809
|
-
class ActivityManifestGuardFailed extends
|
|
14810
|
-
message:
|
|
15136
|
+
class ActivityManifestGuardFailed extends Schema73.TaggedErrorClass()("ActivityManifestGuardFailed", {
|
|
15137
|
+
message: Schema73.String,
|
|
14811
15138
|
result: ActivityManifestGuardResult
|
|
14812
15139
|
}) {
|
|
14813
15140
|
}
|
|
14814
|
-
var TurnInput =
|
|
15141
|
+
var TurnInput = Schema73.Struct({
|
|
14815
15142
|
start: StartInput,
|
|
14816
|
-
turn:
|
|
15143
|
+
turn: Schema73.Int.check(Schema73.isGreaterThanOrEqualTo(0))
|
|
14817
15144
|
});
|
|
14818
|
-
var WaitIdInput =
|
|
15145
|
+
var WaitIdInput = Schema73.Struct({
|
|
14819
15146
|
wait_id: exports_ids_schema.WaitId
|
|
14820
15147
|
});
|
|
14821
|
-
var WorkspaceKeyInput =
|
|
15148
|
+
var WorkspaceKeyInput = Schema73.Struct({
|
|
14822
15149
|
start: StartInput,
|
|
14823
|
-
key:
|
|
15150
|
+
key: Schema73.String
|
|
14824
15151
|
});
|
|
14825
15152
|
var contracts = [
|
|
14826
15153
|
{
|
|
14827
15154
|
name: ActivityNameTemplates.resolveLocalAgent,
|
|
14828
|
-
input:
|
|
15155
|
+
input: Schema73.Struct({ address_id: exports_ids_schema.AddressId }),
|
|
14829
15156
|
success: LocalAgentTarget,
|
|
14830
15157
|
error: ExecutionWorkflowFailed
|
|
14831
15158
|
},
|
|
@@ -14837,66 +15164,66 @@ var contracts = [
|
|
|
14837
15164
|
},
|
|
14838
15165
|
{
|
|
14839
15166
|
name: ActivityNameTemplates.cancel,
|
|
14840
|
-
input:
|
|
15167
|
+
input: Schema73.Struct({ start: StartInput, turn: Schema73.Int, reason: Schema73.String }),
|
|
14841
15168
|
success: exports_execution_schema.Execution,
|
|
14842
15169
|
error: ExecutionWorkflowFailed
|
|
14843
15170
|
},
|
|
14844
15171
|
{
|
|
14845
15172
|
name: ActivityNameTemplates.checkCancel,
|
|
14846
15173
|
input: TurnInput,
|
|
14847
|
-
success:
|
|
15174
|
+
success: Schema73.Boolean,
|
|
14848
15175
|
error: ExecutionWorkflowFailed
|
|
14849
15176
|
},
|
|
14850
15177
|
{
|
|
14851
15178
|
name: ActivityNameTemplates.loadWaitBeforeSleep,
|
|
14852
15179
|
input: WaitIdInput,
|
|
14853
|
-
success:
|
|
15180
|
+
success: Schema73.UndefinedOr(WaitSnapshot),
|
|
14854
15181
|
error: ExecutionWorkflowFailed
|
|
14855
15182
|
},
|
|
14856
15183
|
{
|
|
14857
15184
|
name: ActivityNameTemplates.loadWaitAfterWake,
|
|
14858
15185
|
input: WaitIdInput,
|
|
14859
|
-
success:
|
|
15186
|
+
success: Schema73.UndefinedOr(WaitSnapshot),
|
|
14860
15187
|
error: ExecutionWorkflowFailed
|
|
14861
15188
|
},
|
|
14862
15189
|
{
|
|
14863
15190
|
name: ActivityNameTemplates.markWaiting,
|
|
14864
|
-
input:
|
|
15191
|
+
input: Schema73.Struct({ start: StartInput, wait: WaitSnapshot }),
|
|
14865
15192
|
success: exports_execution_schema.Execution,
|
|
14866
15193
|
error: ExecutionWorkflowFailed
|
|
14867
15194
|
},
|
|
14868
15195
|
{
|
|
14869
15196
|
name: ActivityNameTemplates.ensureWorkspace,
|
|
14870
15197
|
input: StartInput,
|
|
14871
|
-
success:
|
|
15198
|
+
success: Schema73.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14872
15199
|
error: ExecutionWorkflowFailed
|
|
14873
15200
|
},
|
|
14874
15201
|
{
|
|
14875
15202
|
name: ActivityNameTemplates.suspendWorkspace,
|
|
14876
15203
|
input: WorkspaceKeyInput,
|
|
14877
|
-
success:
|
|
15204
|
+
success: Schema73.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14878
15205
|
error: ExecutionWorkflowFailed
|
|
14879
15206
|
},
|
|
14880
15207
|
{
|
|
14881
15208
|
name: ActivityNameTemplates.resumeWorkspace,
|
|
14882
15209
|
input: WorkspaceKeyInput,
|
|
14883
|
-
success:
|
|
15210
|
+
success: Schema73.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14884
15211
|
error: ExecutionWorkflowFailed
|
|
14885
15212
|
},
|
|
14886
15213
|
{
|
|
14887
15214
|
name: ActivityNameTemplates.releaseWorkspace,
|
|
14888
15215
|
input: StartInput,
|
|
14889
|
-
success:
|
|
15216
|
+
success: Schema73.UndefinedOr(exports_workspace_schema.WorkspaceLeaseRecord),
|
|
14890
15217
|
error: ExecutionWorkflowFailed
|
|
14891
15218
|
},
|
|
14892
15219
|
{
|
|
14893
15220
|
name: ActivityNameTemplates.complete,
|
|
14894
|
-
input:
|
|
15221
|
+
input: Schema73.Struct({
|
|
14895
15222
|
start: StartInput,
|
|
14896
|
-
turn:
|
|
14897
|
-
wait_id:
|
|
14898
|
-
wait_state:
|
|
14899
|
-
pending_tool_call:
|
|
15223
|
+
turn: Schema73.Int.check(Schema73.isGreaterThanOrEqualTo(0)),
|
|
15224
|
+
wait_id: Schema73.optionalKey(exports_ids_schema.WaitId),
|
|
15225
|
+
wait_state: Schema73.optionalKey(WaitSignalState),
|
|
15226
|
+
pending_tool_call: Schema73.optionalKey(exports_tool_schema.Call)
|
|
14900
15227
|
}),
|
|
14901
15228
|
success: exports_execution_schema.Execution,
|
|
14902
15229
|
error: ExecutionWorkflowFailed
|
|
@@ -14904,24 +15231,24 @@ var contracts = [
|
|
|
14904
15231
|
{
|
|
14905
15232
|
name: ActivityNameTemplates.checkQueuedChildCancellation,
|
|
14906
15233
|
input: StartInput,
|
|
14907
|
-
success:
|
|
15234
|
+
success: Schema73.Boolean,
|
|
14908
15235
|
error: ExecutionWorkflowFailed
|
|
14909
15236
|
},
|
|
14910
15237
|
{
|
|
14911
15238
|
name: ActivityNameTemplates.notifyParent,
|
|
14912
|
-
input:
|
|
15239
|
+
input: Schema73.Struct({
|
|
14913
15240
|
start: StartInput,
|
|
14914
15241
|
status: ChildTerminalStatus,
|
|
14915
|
-
output:
|
|
15242
|
+
output: Schema73.Array(exports_content_schema.Part)
|
|
14916
15243
|
}),
|
|
14917
|
-
success:
|
|
15244
|
+
success: Schema73.Void,
|
|
14918
15245
|
error: ExecutionWorkflowFailed
|
|
14919
15246
|
},
|
|
14920
15247
|
{
|
|
14921
15248
|
name: ActivityNameTemplates.continueAsNew,
|
|
14922
|
-
input:
|
|
15249
|
+
input: Schema73.Struct({
|
|
14923
15250
|
start: StartInput,
|
|
14924
|
-
turn:
|
|
15251
|
+
turn: Schema73.Int.check(Schema73.isGreaterThanOrEqualTo(0)),
|
|
14925
15252
|
wait_id: exports_ids_schema.WaitId,
|
|
14926
15253
|
pending_tool_call: exports_tool_schema.Call
|
|
14927
15254
|
}),
|
|
@@ -14929,7 +15256,7 @@ var contracts = [
|
|
|
14929
15256
|
error: ExecutionWorkflowFailed
|
|
14930
15257
|
}
|
|
14931
15258
|
];
|
|
14932
|
-
var schemaJson = (schema) =>
|
|
15259
|
+
var schemaJson = (schema) => Schema73.decodeUnknownSync(exports_shared_schema.JsonValue)(Schema73.toJsonSchemaDocument(schema));
|
|
14933
15260
|
var canonical = (value) => {
|
|
14934
15261
|
if (value === null || typeof value !== "object")
|
|
14935
15262
|
return value;
|
|
@@ -15020,17 +15347,17 @@ var guard = Effect78.fn("ActivityVersionRegistry.guard")(function* (input) {
|
|
|
15020
15347
|
}));
|
|
15021
15348
|
});
|
|
15022
15349
|
// src/client.ts
|
|
15023
|
-
import { Clock as Clock11, Context as Context63, Effect as Effect79, Layer as Layer70, Option as Option28, Schema as
|
|
15350
|
+
import { Clock as Clock11, Context as Context63, Effect as Effect79, Layer as Layer70, Option as Option28, Schema as Schema74, SchemaGetter, SchemaIssue, Stream as Stream11 } from "effect";
|
|
15024
15351
|
import { EntityId, ShardId, Sharding as Sharding2, ShardingConfig as ShardingConfig3 } from "effect/unstable/cluster";
|
|
15025
15352
|
|
|
15026
|
-
class ClientError extends
|
|
15027
|
-
message:
|
|
15353
|
+
class ClientError extends Schema74.TaggedErrorClass()("ClientError", {
|
|
15354
|
+
message: Schema74.String
|
|
15028
15355
|
}) {
|
|
15029
15356
|
}
|
|
15030
15357
|
|
|
15031
15358
|
class Service50 extends Context63.Service()("@relayfx/sdk/Client") {
|
|
15032
15359
|
}
|
|
15033
|
-
var
|
|
15360
|
+
var errorMessage4 = (error) => {
|
|
15034
15361
|
if (error instanceof Error)
|
|
15035
15362
|
return error.message;
|
|
15036
15363
|
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
@@ -15041,7 +15368,7 @@ var errorMessage3 = (error) => {
|
|
|
15041
15368
|
}
|
|
15042
15369
|
return String(error);
|
|
15043
15370
|
};
|
|
15044
|
-
var toClientError = (error) => new ClientError({ message:
|
|
15371
|
+
var toClientError = (error) => new ClientError({ message: errorMessage4(error) });
|
|
15045
15372
|
var malformedCursor = (wire) => new SchemaIssue.InvalidValue(Option28.some(wire), { message: "Malformed pagination cursor" });
|
|
15046
15373
|
var decodeCursorFields = (wire) => Effect79.gen(function* () {
|
|
15047
15374
|
const decoded = yield* Effect79.try({
|
|
@@ -15056,11 +15383,11 @@ var decodeCursorFields = (wire) => Effect79.gen(function* () {
|
|
|
15056
15383
|
return yield* Effect79.fail(malformedCursor(wire));
|
|
15057
15384
|
return { updatedAt, id: decoded.slice(separator + 1) };
|
|
15058
15385
|
});
|
|
15059
|
-
var ExecutionCursorFromString = exports_shared_schema.NonEmptyString.pipe(
|
|
15386
|
+
var ExecutionCursorFromString = exports_shared_schema.NonEmptyString.pipe(Schema74.decodeTo(Schema74.Struct({ updatedAt: Schema74.Int, id: exports_ids_schema.ExecutionId }), {
|
|
15060
15387
|
decode: SchemaGetter.transformOrFail((wire) => decodeCursorFields(wire)),
|
|
15061
15388
|
encode: SchemaGetter.transform((cursor) => globalThis.btoa(`${cursor.updatedAt}:${cursor.id}`))
|
|
15062
15389
|
})).annotate({ identifier: "Relay.Client.ExecutionCursor" });
|
|
15063
|
-
var SessionCursorFromString = exports_shared_schema.NonEmptyString.pipe(
|
|
15390
|
+
var SessionCursorFromString = exports_shared_schema.NonEmptyString.pipe(Schema74.decodeTo(Schema74.Struct({ updatedAt: Schema74.Int, id: exports_ids_schema.SessionId }), {
|
|
15064
15391
|
decode: SchemaGetter.transformOrFail((wire) => decodeCursorFields(wire)),
|
|
15065
15392
|
encode: SchemaGetter.transform((cursor) => globalThis.btoa(`${cursor.updatedAt}:${cursor.id}`))
|
|
15066
15393
|
})).annotate({ identifier: "Relay.Client.SessionCursor" });
|
|
@@ -15138,6 +15465,32 @@ var startExecutionByAgentDefinitionPayload = (input, definition) => ({
|
|
|
15138
15465
|
...input.wait_id === undefined ? {} : { wait_id: input.wait_id },
|
|
15139
15466
|
metadata: metadataWithIdempotencyKey(input.metadata, input.idempotency_key)
|
|
15140
15467
|
});
|
|
15468
|
+
var isRegisterBatonAgentInput = (input) => ("agent" in input);
|
|
15469
|
+
var toolRefsFromBatonAgent = (agent) => {
|
|
15470
|
+
const tools = agent.toolkit.tools;
|
|
15471
|
+
return Object.values(tools).map((tool2) => ({ name: tool2.name }));
|
|
15472
|
+
};
|
|
15473
|
+
var registerAgentPayload = (input) => {
|
|
15474
|
+
if (!isRegisterBatonAgentInput(input))
|
|
15475
|
+
return exports_agent_schema.define(input);
|
|
15476
|
+
return exports_agent_schema.define({
|
|
15477
|
+
id: input.id,
|
|
15478
|
+
name: Schema74.decodeUnknownSync(exports_shared_schema.NonEmptyString)(input.agent.name),
|
|
15479
|
+
...input.agent.instructions === undefined ? {} : { instructions: input.agent.instructions },
|
|
15480
|
+
model: input.model,
|
|
15481
|
+
tools: toolRefsFromBatonAgent(input.agent),
|
|
15482
|
+
permissions: input.permissions ?? [],
|
|
15483
|
+
...input.skill_definition_ids === undefined ? {} : { skill_definition_ids: input.skill_definition_ids },
|
|
15484
|
+
...input.permission_rules === undefined ? {} : { permission_rules: input.permission_rules },
|
|
15485
|
+
...input.max_tool_turns === undefined ? {} : { max_tool_turns: input.max_tool_turns },
|
|
15486
|
+
...input.max_wait_turns === undefined ? {} : { max_wait_turns: input.max_wait_turns },
|
|
15487
|
+
...input.token_budget === undefined ? {} : { token_budget: input.token_budget },
|
|
15488
|
+
...input.child_run_presets === undefined ? {} : { child_run_presets: input.child_run_presets },
|
|
15489
|
+
...input.handoff_targets === undefined ? {} : { handoff_targets: input.handoff_targets },
|
|
15490
|
+
...input.output_schema_ref === undefined ? {} : { output_schema_ref: input.output_schema_ref },
|
|
15491
|
+
...input.metadata === undefined ? {} : { metadata: input.metadata }
|
|
15492
|
+
});
|
|
15493
|
+
};
|
|
15141
15494
|
var agentDefinitionNotFound = (id2) => new ClientError({ message: `Agent not found: ${id2}` });
|
|
15142
15495
|
var wakeMetadata = (input) => ({
|
|
15143
15496
|
...input.metadata,
|
|
@@ -15275,7 +15628,7 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15275
15628
|
const skillRegistry = yield* exports_skill_registry_service.Service;
|
|
15276
15629
|
return Service50.of({
|
|
15277
15630
|
registerAgent: Effect79.fn("Client.runtime.registerAgent")(function* (input) {
|
|
15278
|
-
const payload =
|
|
15631
|
+
const payload = registerAgentPayload(input);
|
|
15279
15632
|
const registered = yield* agentRegistry.register(payload).pipe(Effect79.mapError(toClientError));
|
|
15280
15633
|
if (input.address !== undefined) {
|
|
15281
15634
|
yield* addressBook.register(input.address, { kind: "local-agent", route_key: payload.id }).pipe(Effect79.mapError(toClientError));
|
|
@@ -15313,25 +15666,25 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15313
15666
|
return yield* addressBook.list().pipe(Effect79.mapError(toClientError));
|
|
15314
15667
|
}),
|
|
15315
15668
|
startExecution: Effect79.fn("Client.runtime.startExecution")(function* (input) {
|
|
15316
|
-
const
|
|
15317
|
-
return yield*
|
|
15669
|
+
const client3 = makeExecutionClient(input.execution_id);
|
|
15670
|
+
return yield* client3.start(input).pipe(Effect79.mapError(toClientError));
|
|
15318
15671
|
}),
|
|
15319
15672
|
startExecutionByAddress: Effect79.fn("Client.runtime.startExecutionByAddress")(function* (input) {
|
|
15320
15673
|
const payload = startExecutionByAddressPayload(input);
|
|
15321
|
-
const
|
|
15322
|
-
return yield*
|
|
15674
|
+
const client3 = makeExecutionClient(payload.execution_id);
|
|
15675
|
+
return yield* client3.start(payload).pipe(Effect79.mapError(toClientError));
|
|
15323
15676
|
}),
|
|
15324
15677
|
startExecutionByAgentDefinition: Effect79.fn("Client.runtime.startExecutionByAgentDefinition")(function* (input) {
|
|
15325
15678
|
const definition = yield* agentRegistry.get(input.agent_id).pipe(Effect79.mapError(toClientError));
|
|
15326
15679
|
if (definition === undefined)
|
|
15327
15680
|
return yield* Effect79.fail(agentDefinitionNotFound(input.agent_id));
|
|
15328
15681
|
const payload = startExecutionByAgentDefinitionPayload(input, definition);
|
|
15329
|
-
const
|
|
15330
|
-
return yield*
|
|
15682
|
+
const client3 = makeExecutionClient(payload.execution_id);
|
|
15683
|
+
return yield* client3.start(payload).pipe(Effect79.mapError(toClientError));
|
|
15331
15684
|
}),
|
|
15332
15685
|
cancelExecution: Effect79.fn("Client.runtime.cancelExecution")(function* (input) {
|
|
15333
|
-
const
|
|
15334
|
-
return yield*
|
|
15686
|
+
const client3 = makeExecutionClient(input.execution_id);
|
|
15687
|
+
return yield* client3.cancel({
|
|
15335
15688
|
execution_id: input.execution_id,
|
|
15336
15689
|
cancelled_at: input.cancelled_at,
|
|
15337
15690
|
...input.reason === undefined ? {} : { reason: input.reason }
|
|
@@ -15366,27 +15719,27 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15366
15719
|
return records.map(toWaitView);
|
|
15367
15720
|
}),
|
|
15368
15721
|
listExecutions: Effect79.fn("Client.runtime.listExecutions")(function* (input) {
|
|
15369
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
15722
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema74.decodeEffect(ExecutionCursorFromString)(input.cursor).pipe(Effect79.mapError(toClientError));
|
|
15370
15723
|
const result = yield* executionRepository.list({
|
|
15371
15724
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
15372
15725
|
...input.status === undefined ? {} : { status: input.status },
|
|
15373
15726
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
15374
15727
|
...cursor === undefined ? {} : { cursor }
|
|
15375
15728
|
}).pipe(Effect79.mapError(toClientError));
|
|
15376
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
15729
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema74.encodeEffect(ExecutionCursorFromString)(result.nextCursor).pipe(Effect79.mapError(toClientError));
|
|
15377
15730
|
return {
|
|
15378
15731
|
records: result.records.map(toConversationSummary),
|
|
15379
15732
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
15380
15733
|
};
|
|
15381
15734
|
}),
|
|
15382
15735
|
listSessions: Effect79.fn("Client.runtime.listSessions")(function* (input) {
|
|
15383
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
15736
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema74.decodeEffect(SessionCursorFromString)(input.cursor).pipe(Effect79.mapError(toClientError));
|
|
15384
15737
|
const result = yield* sessionRepository.list({
|
|
15385
15738
|
...input.root_address_id === undefined ? {} : { rootAddressId: input.root_address_id },
|
|
15386
15739
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
15387
15740
|
...cursor === undefined ? {} : { cursor }
|
|
15388
15741
|
}).pipe(Effect79.mapError(toClientError));
|
|
15389
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
15742
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema74.encodeEffect(SessionCursorFromString)(result.nextCursor).pipe(Effect79.mapError(toClientError));
|
|
15390
15743
|
return {
|
|
15391
15744
|
records: result.records.map(toSessionSummary),
|
|
15392
15745
|
...nextCursor === undefined ? {} : { next_cursor: nextCursor }
|
|
@@ -15396,13 +15749,13 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15396
15749
|
const session = yield* sessionRepository.get(input.session_id).pipe(Effect79.mapError(toClientError));
|
|
15397
15750
|
if (session === undefined)
|
|
15398
15751
|
return yield* new ClientError({ message: `Session not found: ${input.session_id}` });
|
|
15399
|
-
const cursor = input.cursor === undefined ? undefined : yield*
|
|
15752
|
+
const cursor = input.cursor === undefined ? undefined : yield* Schema74.decodeEffect(ExecutionCursorFromString)(input.cursor).pipe(Effect79.mapError(toClientError));
|
|
15400
15753
|
const result = yield* executionRepository.list({
|
|
15401
15754
|
sessionId: input.session_id,
|
|
15402
15755
|
...input.limit === undefined ? {} : { limit: input.limit },
|
|
15403
15756
|
...cursor === undefined ? {} : { cursor }
|
|
15404
15757
|
}).pipe(Effect79.mapError(toClientError));
|
|
15405
|
-
const nextCursor = result.nextCursor === undefined ? undefined : yield*
|
|
15758
|
+
const nextCursor = result.nextCursor === undefined ? undefined : yield* Schema74.encodeEffect(ExecutionCursorFromString)(result.nextCursor).pipe(Effect79.mapError(toClientError));
|
|
15406
15759
|
return {
|
|
15407
15760
|
session: toSessionSummary(session),
|
|
15408
15761
|
executions: result.records.map(toConversationSummary),
|
|
@@ -15448,7 +15801,7 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15448
15801
|
executionId: input.execution_id,
|
|
15449
15802
|
...input.after_cursor === undefined ? {} : { afterCursor: input.after_cursor },
|
|
15450
15803
|
...input.limit === undefined ? {} : { limit: input.limit }
|
|
15451
|
-
}).pipe(
|
|
15804
|
+
}).pipe(Stream11.mapError(toClientError)),
|
|
15452
15805
|
wake: Effect79.fn("Client.runtime.wake")(function* (input) {
|
|
15453
15806
|
return yield* wakeRuntime(waits, eventLog, executionRepository, makeExecutionClient, input);
|
|
15454
15807
|
}),
|
|
@@ -15491,8 +15844,8 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15491
15844
|
const createdAt = input.created_at ?? (yield* Clock11.currentTimeMillis);
|
|
15492
15845
|
const parentWaitId = input.wait === true ? yield* createChildJoinWait(waits, eventLog, input, accepted2, createdAt) : undefined;
|
|
15493
15846
|
const startPayload = childStartInput(input, accepted2, pin, definition, createdAt, parentWaitId);
|
|
15494
|
-
const
|
|
15495
|
-
yield*
|
|
15847
|
+
const client3 = makeExecutionClient(startPayload.execution_id);
|
|
15848
|
+
yield* client3.start(startPayload).pipe(Effect79.catchCause(() => Effect79.void), Effect79.forkDetach);
|
|
15496
15849
|
return accepted2;
|
|
15497
15850
|
}),
|
|
15498
15851
|
claimEnvelopeReady: Effect79.fn("Client.runtime.claimEnvelopeReady")(function* (input) {
|
|
@@ -15557,7 +15910,7 @@ var layerFromRuntime = Layer70.effect(Service50, Effect79.gen(function* () {
|
|
|
15557
15910
|
})
|
|
15558
15911
|
});
|
|
15559
15912
|
}));
|
|
15560
|
-
var
|
|
15913
|
+
var testLayer52 = (implementation) => Layer70.succeed(Service50, Service50.of(implementation));
|
|
15561
15914
|
var registerAgentDefinition = Effect79.fn("Client.registerAgentDefinition.call")(function* (input) {
|
|
15562
15915
|
const service = yield* Service50;
|
|
15563
15916
|
return yield* service.registerAgentDefinition(input);
|
|
@@ -15658,7 +16011,7 @@ var send3 = Effect79.fn("Client.send.call")(function* (input) {
|
|
|
15658
16011
|
const service = yield* Service50;
|
|
15659
16012
|
return yield* service.send(input);
|
|
15660
16013
|
});
|
|
15661
|
-
var streamExecution = (input) =>
|
|
16014
|
+
var streamExecution = (input) => Stream11.unwrap(Service50.pipe(Effect79.map((service) => service.streamExecution(input))));
|
|
15662
16015
|
var wake2 = Effect79.fn("Client.wake.call")(function* (input) {
|
|
15663
16016
|
const service = yield* Service50;
|
|
15664
16017
|
return yield* service.wake(input);
|
|
@@ -15712,23 +16065,23 @@ var listSchedules = Effect79.fn("Client.listSchedules.call")(function* (input) {
|
|
|
15712
16065
|
class Service51 extends Context64.Service()("@relayfx/sdk/AdapterOutbox") {
|
|
15713
16066
|
}
|
|
15714
16067
|
var layer53 = Layer71.effect(Service51, Effect80.gen(function* () {
|
|
15715
|
-
const
|
|
16068
|
+
const client3 = yield* Service50;
|
|
15716
16069
|
return Service51.of({
|
|
15717
16070
|
claim: Effect80.fn("AdapterOutbox.claim")(function* (input) {
|
|
15718
|
-
return yield*
|
|
16071
|
+
return yield* client3.claimEnvelopeReady(input);
|
|
15719
16072
|
}),
|
|
15720
16073
|
ack: Effect80.fn("AdapterOutbox.ack")(function* (input) {
|
|
15721
|
-
return yield*
|
|
16074
|
+
return yield* client3.ackEnvelopeReady(input);
|
|
15722
16075
|
}),
|
|
15723
16076
|
release: Effect80.fn("AdapterOutbox.release")(function* (input) {
|
|
15724
|
-
return yield*
|
|
16077
|
+
return yield* client3.releaseEnvelopeReady(input);
|
|
15725
16078
|
}),
|
|
15726
16079
|
submitInbound: Effect80.fn("AdapterOutbox.submitInbound")(function* (input) {
|
|
15727
|
-
return yield*
|
|
16080
|
+
return yield* client3.submitInboundEnvelope(input);
|
|
15728
16081
|
})
|
|
15729
16082
|
});
|
|
15730
16083
|
}));
|
|
15731
|
-
var
|
|
16084
|
+
var testLayer53 = (implementation) => Layer71.succeed(Service51, Service51.of(implementation));
|
|
15732
16085
|
var claim = Effect80.fn("AdapterOutbox.claim.call")(function* (input) {
|
|
15733
16086
|
const service = yield* Service51;
|
|
15734
16087
|
return yield* service.claim(input);
|
|
@@ -15748,7 +16101,7 @@ var submitInbound = Effect80.fn("AdapterOutbox.submitInbound.call")(function* (i
|
|
|
15748
16101
|
// src/database.ts
|
|
15749
16102
|
var exports_database = {};
|
|
15750
16103
|
__export(exports_database, {
|
|
15751
|
-
testLayer: () =>
|
|
16104
|
+
testLayer: () => testLayer54,
|
|
15752
16105
|
pgTypeParsers: () => pgTypeParsers2,
|
|
15753
16106
|
layerFromPgClient: () => layerFromPgClient2,
|
|
15754
16107
|
dialect: () => dialect2,
|
|
@@ -15758,7 +16111,7 @@ __export(exports_database, {
|
|
|
15758
16111
|
});
|
|
15759
16112
|
var Service52 = exports_database_service.Service;
|
|
15760
16113
|
var layerFromPgClient2 = exports_database_service.layerFromPgClient;
|
|
15761
|
-
var
|
|
16114
|
+
var testLayer54 = exports_database_service.testLayer;
|
|
15762
16115
|
var check3 = exports_database_service.check;
|
|
15763
16116
|
var pgTypeParsers2 = exports_database_service.pgTypeParsers;
|
|
15764
16117
|
var Dialect2 = exports_database_service.Dialect;
|
|
@@ -15815,92 +16168,92 @@ __export(exports_operation, {
|
|
|
15815
16168
|
CancelExecutionAccepted: () => CancelExecutionAccepted,
|
|
15816
16169
|
AckEnvelopeReadyInput: () => AckEnvelopeReadyInput
|
|
15817
16170
|
});
|
|
15818
|
-
import { Schema as
|
|
15819
|
-
var StartExecutionInput =
|
|
16171
|
+
import { Schema as Schema75 } from "effect";
|
|
16172
|
+
var StartExecutionInput = Schema75.Struct({
|
|
15820
16173
|
execution_id: exports_ids_schema.ExecutionId,
|
|
15821
16174
|
root_address_id: exports_ids_schema.AddressId,
|
|
15822
|
-
session_id:
|
|
15823
|
-
input:
|
|
16175
|
+
session_id: Schema75.optionalKey(exports_ids_schema.SessionId),
|
|
16176
|
+
input: Schema75.optionalKey(Schema75.Array(exports_content_schema.Part)),
|
|
15824
16177
|
event_sequence: exports_execution_schema.ExecutionEventSequence,
|
|
15825
16178
|
started_at: exports_shared_schema.TimestampMillis,
|
|
15826
16179
|
completed_at: exports_shared_schema.TimestampMillis,
|
|
15827
|
-
agent_id:
|
|
15828
|
-
agent_revision:
|
|
15829
|
-
agent_snapshot:
|
|
15830
|
-
agent_tool_input_schema_digests:
|
|
15831
|
-
wait_id:
|
|
15832
|
-
metadata:
|
|
16180
|
+
agent_id: Schema75.optionalKey(exports_ids_schema.AgentId),
|
|
16181
|
+
agent_revision: Schema75.optionalKey(exports_agent_schema.DefinitionRevision),
|
|
16182
|
+
agent_snapshot: Schema75.optionalKey(exports_agent_schema.Definition),
|
|
16183
|
+
agent_tool_input_schema_digests: Schema75.optionalKey(exports_agent_schema.ToolInputSchemaDigests),
|
|
16184
|
+
wait_id: Schema75.optionalKey(exports_ids_schema.WaitId),
|
|
16185
|
+
metadata: Schema75.optionalKey(exports_shared_schema.Metadata)
|
|
15833
16186
|
}).annotate({ identifier: "Relay.Operation.StartExecutionInput" });
|
|
15834
|
-
var StartExecutionResult =
|
|
16187
|
+
var StartExecutionResult = Schema75.Struct({
|
|
15835
16188
|
execution_id: exports_ids_schema.ExecutionId,
|
|
15836
16189
|
status: exports_execution_schema.ExecutionStatus,
|
|
15837
|
-
metadata:
|
|
16190
|
+
metadata: Schema75.optionalKey(exports_shared_schema.Metadata)
|
|
15838
16191
|
}).annotate({ identifier: "Relay.Operation.StartExecutionResult" });
|
|
15839
|
-
var StreamExecutionInput =
|
|
16192
|
+
var StreamExecutionInput = Schema75.Struct({
|
|
15840
16193
|
execution_id: exports_execution_schema.Execution.fields.id,
|
|
15841
|
-
after_cursor:
|
|
15842
|
-
limit:
|
|
16194
|
+
after_cursor: Schema75.optionalKey(exports_shared_schema.NonEmptyString),
|
|
16195
|
+
limit: Schema75.optionalKey(Schema75.Int.check(Schema75.isGreaterThan(0)))
|
|
15843
16196
|
}).annotate({ identifier: "Relay.Operation.StreamExecutionInput" });
|
|
15844
|
-
var WaitTerminalState =
|
|
16197
|
+
var WaitTerminalState = Schema75.Literals(["resolved", "timed_out", "cancelled"]).annotate({
|
|
15845
16198
|
identifier: "Relay.Operation.WaitTerminalState"
|
|
15846
16199
|
});
|
|
15847
|
-
var CancelExecutionInput2 =
|
|
16200
|
+
var CancelExecutionInput2 = Schema75.Struct({
|
|
15848
16201
|
execution_id: exports_ids_schema.ExecutionId,
|
|
15849
16202
|
cancelled_at: exports_shared_schema.TimestampMillis,
|
|
15850
|
-
reason:
|
|
16203
|
+
reason: Schema75.optionalKey(Schema75.String)
|
|
15851
16204
|
}).annotate({ identifier: "Relay.Operation.CancelExecutionInput" });
|
|
15852
|
-
var CancelExecutionAccepted =
|
|
16205
|
+
var CancelExecutionAccepted = Schema75.Struct({
|
|
15853
16206
|
execution_id: exports_ids_schema.ExecutionId,
|
|
15854
16207
|
status: exports_execution_schema.ExecutionStatus
|
|
15855
16208
|
}).annotate({ identifier: "Relay.Operation.CancelExecutionAccepted" });
|
|
15856
|
-
var SteeringKind =
|
|
16209
|
+
var SteeringKind = Schema75.Literals(["steering", "follow_up"]).annotate({
|
|
15857
16210
|
identifier: "Relay.Operation.SteeringKind"
|
|
15858
16211
|
});
|
|
15859
|
-
var SteerInput =
|
|
16212
|
+
var SteerInput = Schema75.Struct({
|
|
15860
16213
|
execution_id: exports_ids_schema.ExecutionId,
|
|
15861
16214
|
kind: SteeringKind,
|
|
15862
|
-
content:
|
|
16215
|
+
content: Schema75.Array(exports_content_schema.Part),
|
|
15863
16216
|
created_at: exports_shared_schema.TimestampMillis
|
|
15864
16217
|
}).annotate({ identifier: "Relay.Operation.SteerInput" });
|
|
15865
|
-
var SteerAccepted =
|
|
16218
|
+
var SteerAccepted = Schema75.Struct({
|
|
15866
16219
|
execution_id: exports_ids_schema.ExecutionId,
|
|
15867
16220
|
kind: SteeringKind,
|
|
15868
|
-
sequence:
|
|
16221
|
+
sequence: Schema75.Int.check(Schema75.isGreaterThanOrEqualTo(0))
|
|
15869
16222
|
}).annotate({ identifier: "Relay.Operation.SteerAccepted" });
|
|
15870
|
-
var WakeInput =
|
|
16223
|
+
var WakeInput = Schema75.Struct({
|
|
15871
16224
|
wait_id: exports_ids_schema.WaitId,
|
|
15872
16225
|
state: WaitTerminalState,
|
|
15873
16226
|
signaled_at: exports_shared_schema.TimestampMillis,
|
|
15874
|
-
from:
|
|
15875
|
-
content:
|
|
15876
|
-
correlation_key:
|
|
15877
|
-
metadata:
|
|
16227
|
+
from: Schema75.optionalKey(exports_ids_schema.AddressId),
|
|
16228
|
+
content: Schema75.optionalKey(Schema75.Array(exports_content_schema.Part)),
|
|
16229
|
+
correlation_key: Schema75.optionalKey(Schema75.String),
|
|
16230
|
+
metadata: Schema75.optionalKey(exports_shared_schema.Metadata)
|
|
15878
16231
|
}).annotate({ identifier: "Relay.Operation.WakeInput" });
|
|
15879
|
-
var WakeAccepted =
|
|
16232
|
+
var WakeAccepted = Schema75.Struct({
|
|
15880
16233
|
wait_id: exports_ids_schema.WaitId,
|
|
15881
16234
|
state: WaitTerminalState,
|
|
15882
16235
|
signaled_at: exports_shared_schema.TimestampMillis
|
|
15883
16236
|
}).annotate({ identifier: "Relay.Operation.WakeAccepted" });
|
|
15884
|
-
var WaitState2 =
|
|
16237
|
+
var WaitState2 = Schema75.Literals(["open", "resolved", "timed_out", "cancelled"]).annotate({
|
|
15885
16238
|
identifier: "Relay.Operation.WaitState"
|
|
15886
16239
|
});
|
|
15887
|
-
var ListWaitsInput =
|
|
15888
|
-
state:
|
|
15889
|
-
execution_id:
|
|
15890
|
-
limit:
|
|
16240
|
+
var ListWaitsInput = Schema75.Struct({
|
|
16241
|
+
state: Schema75.optionalKey(WaitState2),
|
|
16242
|
+
execution_id: Schema75.optionalKey(exports_ids_schema.ExecutionId),
|
|
16243
|
+
limit: Schema75.optionalKey(Schema75.Int.check(Schema75.isGreaterThan(0)))
|
|
15891
16244
|
}).annotate({ identifier: "Relay.Operation.ListWaitsInput" });
|
|
15892
|
-
var WaitView =
|
|
16245
|
+
var WaitView = Schema75.Struct({
|
|
15893
16246
|
wait_id: exports_ids_schema.WaitId,
|
|
15894
16247
|
execution_id: exports_ids_schema.ExecutionId,
|
|
15895
|
-
envelope_id:
|
|
16248
|
+
envelope_id: Schema75.optionalKey(exports_ids_schema.EnvelopeId),
|
|
15896
16249
|
mode: exports_envelope_schema.WaitMode,
|
|
15897
|
-
correlation_key:
|
|
16250
|
+
correlation_key: Schema75.optionalKey(Schema75.String),
|
|
15898
16251
|
state: WaitState2,
|
|
15899
16252
|
metadata: exports_shared_schema.Metadata,
|
|
15900
16253
|
created_at: exports_shared_schema.TimestampMillis,
|
|
15901
|
-
resolved_at:
|
|
16254
|
+
resolved_at: Schema75.optionalKey(exports_shared_schema.TimestampMillis)
|
|
15902
16255
|
}).annotate({ identifier: "Relay.Operation.WaitView" });
|
|
15903
|
-
var PendingToolApproval =
|
|
16256
|
+
var PendingToolApproval = Schema75.Struct({
|
|
15904
16257
|
wait_id: exports_ids_schema.WaitId,
|
|
15905
16258
|
execution_id: exports_ids_schema.ExecutionId,
|
|
15906
16259
|
tool_call_id: exports_ids_schema.ToolCallId,
|
|
@@ -15908,169 +16261,169 @@ var PendingToolApproval = Schema74.Struct({
|
|
|
15908
16261
|
input: exports_shared_schema.JsonValue,
|
|
15909
16262
|
requested_at: exports_shared_schema.TimestampMillis
|
|
15910
16263
|
}).annotate({ identifier: "Relay.Operation.PendingToolApproval" });
|
|
15911
|
-
var ListPendingApprovalsInput =
|
|
16264
|
+
var ListPendingApprovalsInput = Schema75.Struct({
|
|
15912
16265
|
execution_id: exports_ids_schema.ExecutionId
|
|
15913
16266
|
}).annotate({ identifier: "Relay.Operation.ListPendingApprovalsInput" });
|
|
15914
|
-
var PendingToolApprovalList =
|
|
15915
|
-
approvals:
|
|
16267
|
+
var PendingToolApprovalList = Schema75.Struct({
|
|
16268
|
+
approvals: Schema75.Array(PendingToolApproval)
|
|
15916
16269
|
}).annotate({ identifier: "Relay.Operation.PendingToolApprovalList" });
|
|
15917
|
-
var ResolveToolApprovalInput =
|
|
16270
|
+
var ResolveToolApprovalInput = Schema75.Struct({
|
|
15918
16271
|
wait_id: exports_ids_schema.WaitId,
|
|
15919
|
-
approved:
|
|
15920
|
-
comment:
|
|
16272
|
+
approved: Schema75.Boolean,
|
|
16273
|
+
comment: Schema75.optionalKey(Schema75.String),
|
|
15921
16274
|
resolved_at: exports_shared_schema.TimestampMillis
|
|
15922
16275
|
}).annotate({ identifier: "Relay.Operation.ResolveToolApprovalInput" });
|
|
15923
|
-
var PermissionAnswer =
|
|
16276
|
+
var PermissionAnswer = Schema75.Literals(["Approved", "Denied", "Always"]).annotate({
|
|
15924
16277
|
identifier: "Relay.Operation.PermissionAnswer"
|
|
15925
16278
|
});
|
|
15926
|
-
var ResolvePermissionInput =
|
|
16279
|
+
var ResolvePermissionInput = Schema75.Struct({
|
|
15927
16280
|
wait_id: exports_ids_schema.WaitId,
|
|
15928
16281
|
answer: PermissionAnswer,
|
|
15929
|
-
reason:
|
|
16282
|
+
reason: Schema75.optionalKey(Schema75.String),
|
|
15930
16283
|
resolved_at: exports_shared_schema.TimestampMillis
|
|
15931
16284
|
}).annotate({ identifier: "Relay.Operation.ResolvePermissionInput" });
|
|
15932
|
-
var SubmitInboundEnvelopeInput =
|
|
16285
|
+
var SubmitInboundEnvelopeInput = Schema75.Struct({
|
|
15933
16286
|
envelope: exports_envelope_schema.SendInput,
|
|
15934
16287
|
wake: WakeInput
|
|
15935
16288
|
}).annotate({ identifier: "Relay.Operation.SubmitInboundEnvelopeInput" });
|
|
15936
|
-
var SubmitInboundEnvelopeAccepted =
|
|
16289
|
+
var SubmitInboundEnvelopeAccepted = Schema75.Struct({
|
|
15937
16290
|
envelope: exports_envelope_schema.EnvelopeAccepted,
|
|
15938
16291
|
wake: WakeAccepted
|
|
15939
16292
|
}).annotate({ identifier: "Relay.Operation.SubmitInboundEnvelopeAccepted" });
|
|
15940
|
-
var ClaimEnvelopeReadyInput =
|
|
16293
|
+
var ClaimEnvelopeReadyInput = Schema75.Struct({
|
|
15941
16294
|
route_type: exports_address_schema.RouteKind,
|
|
15942
|
-
route_key:
|
|
16295
|
+
route_key: Schema75.optionalKey(Schema75.String),
|
|
15943
16296
|
worker_id: exports_shared_schema.NonEmptyString,
|
|
15944
16297
|
now: exports_shared_schema.TimestampMillis,
|
|
15945
16298
|
claim_expires_at: exports_shared_schema.TimestampMillis
|
|
15946
16299
|
}).annotate({ identifier: "Relay.Operation.ClaimEnvelopeReadyInput" });
|
|
15947
|
-
var EnvelopeReadyLease =
|
|
16300
|
+
var EnvelopeReadyLease = Schema75.Struct({
|
|
15948
16301
|
ready: exports_envelope_schema.EnvelopeReady,
|
|
15949
16302
|
worker_id: exports_shared_schema.NonEmptyString,
|
|
15950
16303
|
claim_expires_at: exports_shared_schema.TimestampMillis
|
|
15951
16304
|
}).annotate({ identifier: "Relay.Operation.EnvelopeReadyLease" });
|
|
15952
|
-
var AckEnvelopeReadyInput =
|
|
16305
|
+
var AckEnvelopeReadyInput = Schema75.Struct({
|
|
15953
16306
|
envelope_ready_id: exports_ids_schema.EnvelopeReadyId,
|
|
15954
16307
|
worker_id: exports_shared_schema.NonEmptyString,
|
|
15955
16308
|
acknowledged_at: exports_shared_schema.TimestampMillis
|
|
15956
16309
|
}).annotate({ identifier: "Relay.Operation.AckEnvelopeReadyInput" });
|
|
15957
|
-
var EnvelopeReadyAcked =
|
|
16310
|
+
var EnvelopeReadyAcked = Schema75.Struct({
|
|
15958
16311
|
envelope_ready_id: exports_ids_schema.EnvelopeReadyId,
|
|
15959
|
-
state:
|
|
16312
|
+
state: Schema75.Literal("acknowledged"),
|
|
15960
16313
|
acknowledged_at: exports_shared_schema.TimestampMillis
|
|
15961
16314
|
}).annotate({ identifier: "Relay.Operation.EnvelopeReadyAcked" });
|
|
15962
|
-
var ReleaseEnvelopeReadyInput =
|
|
16315
|
+
var ReleaseEnvelopeReadyInput = Schema75.Struct({
|
|
15963
16316
|
envelope_ready_id: exports_ids_schema.EnvelopeReadyId,
|
|
15964
16317
|
worker_id: exports_shared_schema.NonEmptyString,
|
|
15965
16318
|
next_available_at: exports_shared_schema.TimestampMillis,
|
|
15966
|
-
error:
|
|
16319
|
+
error: Schema75.optionalKey(Schema75.String)
|
|
15967
16320
|
}).annotate({ identifier: "Relay.Operation.ReleaseEnvelopeReadyInput" });
|
|
15968
|
-
var EnvelopeReadyReleased =
|
|
16321
|
+
var EnvelopeReadyReleased = Schema75.Struct({
|
|
15969
16322
|
envelope_ready_id: exports_ids_schema.EnvelopeReadyId,
|
|
15970
|
-
state:
|
|
16323
|
+
state: Schema75.Literal("ready"),
|
|
15971
16324
|
next_available_at: exports_shared_schema.TimestampMillis
|
|
15972
16325
|
}).annotate({ identifier: "Relay.Operation.EnvelopeReadyReleased" });
|
|
15973
|
-
var CreateScheduleInput =
|
|
16326
|
+
var CreateScheduleInput = Schema75.Struct({
|
|
15974
16327
|
schedule_id: exports_ids_schema.ScheduleId,
|
|
15975
16328
|
kind: exports_schedule_schema.ScheduleKind,
|
|
15976
16329
|
target_kind: exports_schedule_schema.ScheduleTargetKind,
|
|
15977
|
-
address_id:
|
|
15978
|
-
wait_id:
|
|
15979
|
-
cron_expr:
|
|
15980
|
-
input:
|
|
16330
|
+
address_id: Schema75.optionalKey(exports_ids_schema.AddressId),
|
|
16331
|
+
wait_id: Schema75.optionalKey(exports_ids_schema.WaitId),
|
|
16332
|
+
cron_expr: Schema75.optionalKey(exports_shared_schema.NonEmptyString),
|
|
16333
|
+
input: Schema75.optionalKey(Schema75.Array(exports_content_schema.Part)),
|
|
15981
16334
|
next_run_at: exports_shared_schema.TimestampMillis,
|
|
15982
|
-
idempotency_key:
|
|
15983
|
-
metadata:
|
|
16335
|
+
idempotency_key: Schema75.optionalKey(exports_shared_schema.NonEmptyString),
|
|
16336
|
+
metadata: Schema75.optionalKey(exports_shared_schema.Metadata)
|
|
15984
16337
|
}).annotate({ identifier: "Relay.Operation.CreateScheduleInput" });
|
|
15985
|
-
var CreateScheduleResult =
|
|
16338
|
+
var CreateScheduleResult = Schema75.Struct({
|
|
15986
16339
|
schedule: exports_schedule_schema.ScheduleRecord
|
|
15987
16340
|
}).annotate({ identifier: "Relay.Operation.CreateScheduleResult" });
|
|
15988
|
-
var CancelScheduleInput =
|
|
16341
|
+
var CancelScheduleInput = Schema75.Struct({
|
|
15989
16342
|
schedule_id: exports_ids_schema.ScheduleId,
|
|
15990
16343
|
cancelled_at: exports_shared_schema.TimestampMillis
|
|
15991
16344
|
}).annotate({ identifier: "Relay.Operation.CancelScheduleInput" });
|
|
15992
|
-
var CancelScheduleResult =
|
|
16345
|
+
var CancelScheduleResult = Schema75.Struct({
|
|
15993
16346
|
schedule: exports_schedule_schema.ScheduleRecord
|
|
15994
16347
|
}).annotate({ identifier: "Relay.Operation.CancelScheduleResult" });
|
|
15995
|
-
var ListSchedulesInput =
|
|
15996
|
-
state:
|
|
16348
|
+
var ListSchedulesInput = Schema75.Struct({
|
|
16349
|
+
state: Schema75.optionalKey(exports_schedule_schema.ScheduleState)
|
|
15997
16350
|
}).annotate({ identifier: "Relay.Operation.ListSchedulesInput" });
|
|
15998
|
-
var ListSchedulesResult =
|
|
15999
|
-
schedules:
|
|
16351
|
+
var ListSchedulesResult = Schema75.Struct({
|
|
16352
|
+
schedules: Schema75.Array(exports_schedule_schema.ScheduleRecord)
|
|
16000
16353
|
}).annotate({ identifier: "Relay.Operation.ListSchedulesResult" });
|
|
16001
|
-
var ListExecutionsInput =
|
|
16002
|
-
root_address_id:
|
|
16003
|
-
status:
|
|
16004
|
-
limit:
|
|
16005
|
-
cursor:
|
|
16354
|
+
var ListExecutionsInput = Schema75.Struct({
|
|
16355
|
+
root_address_id: Schema75.optionalKey(exports_ids_schema.AddressId),
|
|
16356
|
+
status: Schema75.optionalKey(exports_execution_schema.ExecutionStatus),
|
|
16357
|
+
limit: Schema75.optionalKey(Schema75.Int.check(Schema75.isGreaterThan(0))),
|
|
16358
|
+
cursor: Schema75.optionalKey(exports_shared_schema.NonEmptyString)
|
|
16006
16359
|
}).annotate({ identifier: "Relay.Operation.ListExecutionsInput" });
|
|
16007
|
-
var ConversationKind =
|
|
16360
|
+
var ConversationKind = Schema75.Literals(["user-agent", "agent-agent"]).annotate({
|
|
16008
16361
|
identifier: "Relay.Operation.ConversationKind"
|
|
16009
16362
|
});
|
|
16010
|
-
var ConversationSummary =
|
|
16363
|
+
var ConversationSummary = Schema75.Struct({
|
|
16011
16364
|
execution_id: exports_ids_schema.ExecutionId,
|
|
16012
16365
|
root_address_id: exports_ids_schema.AddressId,
|
|
16013
|
-
session_id:
|
|
16366
|
+
session_id: Schema75.optionalKey(exports_ids_schema.SessionId),
|
|
16014
16367
|
status: exports_execution_schema.ExecutionStatus,
|
|
16015
16368
|
kind: ConversationKind,
|
|
16016
|
-
agent_id:
|
|
16369
|
+
agent_id: Schema75.optionalKey(exports_ids_schema.AgentId),
|
|
16017
16370
|
metadata: exports_shared_schema.Metadata,
|
|
16018
16371
|
created_at: exports_shared_schema.TimestampMillis,
|
|
16019
16372
|
updated_at: exports_shared_schema.TimestampMillis
|
|
16020
16373
|
}).annotate({ identifier: "Relay.Operation.ConversationSummary" });
|
|
16021
|
-
var ListExecutionsResult =
|
|
16022
|
-
records:
|
|
16023
|
-
next_cursor:
|
|
16374
|
+
var ListExecutionsResult = Schema75.Struct({
|
|
16375
|
+
records: Schema75.Array(ConversationSummary),
|
|
16376
|
+
next_cursor: Schema75.optionalKey(exports_shared_schema.NonEmptyString)
|
|
16024
16377
|
}).annotate({ identifier: "Relay.Operation.ListExecutionsResult" });
|
|
16025
|
-
var ListSessionsInput =
|
|
16026
|
-
root_address_id:
|
|
16027
|
-
limit:
|
|
16028
|
-
cursor:
|
|
16378
|
+
var ListSessionsInput = Schema75.Struct({
|
|
16379
|
+
root_address_id: Schema75.optionalKey(exports_ids_schema.AddressId),
|
|
16380
|
+
limit: Schema75.optionalKey(Schema75.Int.check(Schema75.isGreaterThan(0))),
|
|
16381
|
+
cursor: Schema75.optionalKey(exports_shared_schema.NonEmptyString)
|
|
16029
16382
|
}).annotate({ identifier: "Relay.Operation.ListSessionsInput" });
|
|
16030
|
-
var SessionSummary =
|
|
16383
|
+
var SessionSummary = Schema75.Struct({
|
|
16031
16384
|
session_id: exports_ids_schema.SessionId,
|
|
16032
16385
|
root_address_id: exports_ids_schema.AddressId,
|
|
16033
16386
|
metadata: exports_shared_schema.Metadata,
|
|
16034
16387
|
created_at: exports_shared_schema.TimestampMillis,
|
|
16035
16388
|
updated_at: exports_shared_schema.TimestampMillis
|
|
16036
16389
|
}).annotate({ identifier: "Relay.Operation.SessionSummary" });
|
|
16037
|
-
var ListSessionsResult =
|
|
16038
|
-
records:
|
|
16039
|
-
next_cursor:
|
|
16390
|
+
var ListSessionsResult = Schema75.Struct({
|
|
16391
|
+
records: Schema75.Array(SessionSummary),
|
|
16392
|
+
next_cursor: Schema75.optionalKey(exports_shared_schema.NonEmptyString)
|
|
16040
16393
|
}).annotate({ identifier: "Relay.Operation.ListSessionsResult" });
|
|
16041
|
-
var GetSessionInput =
|
|
16394
|
+
var GetSessionInput = Schema75.Struct({
|
|
16042
16395
|
session_id: exports_ids_schema.SessionId,
|
|
16043
|
-
limit:
|
|
16044
|
-
cursor:
|
|
16396
|
+
limit: Schema75.optionalKey(Schema75.Int.check(Schema75.isGreaterThan(0))),
|
|
16397
|
+
cursor: Schema75.optionalKey(exports_shared_schema.NonEmptyString)
|
|
16045
16398
|
}).annotate({ identifier: "Relay.Operation.GetSessionInput" });
|
|
16046
|
-
var GetSessionResult =
|
|
16399
|
+
var GetSessionResult = Schema75.Struct({
|
|
16047
16400
|
session: SessionSummary,
|
|
16048
|
-
executions:
|
|
16049
|
-
next_cursor:
|
|
16401
|
+
executions: Schema75.Array(ConversationSummary),
|
|
16402
|
+
next_cursor: Schema75.optionalKey(exports_shared_schema.NonEmptyString)
|
|
16050
16403
|
}).annotate({ identifier: "Relay.Operation.GetSessionResult" });
|
|
16051
|
-
var ReplayExecutionInput =
|
|
16404
|
+
var ReplayExecutionInput = Schema75.Struct({
|
|
16052
16405
|
execution_id: exports_ids_schema.ExecutionId,
|
|
16053
|
-
after_cursor:
|
|
16054
|
-
limit:
|
|
16406
|
+
after_cursor: Schema75.optionalKey(exports_shared_schema.NonEmptyString),
|
|
16407
|
+
limit: Schema75.optionalKey(Schema75.Int.check(Schema75.isGreaterThan(0)))
|
|
16055
16408
|
}).annotate({ identifier: "Relay.Operation.ReplayExecutionInput" });
|
|
16056
|
-
var ReplayExecutionResult =
|
|
16057
|
-
events:
|
|
16409
|
+
var ReplayExecutionResult = Schema75.Struct({
|
|
16410
|
+
events: Schema75.Array(exports_execution_schema.ExecutionEvent)
|
|
16058
16411
|
}).annotate({ identifier: "Relay.Operation.ReplayExecutionResult" });
|
|
16059
|
-
var RunnerSummary =
|
|
16060
|
-
address:
|
|
16061
|
-
healthy:
|
|
16412
|
+
var RunnerSummary = Schema75.Struct({
|
|
16413
|
+
address: Schema75.String,
|
|
16414
|
+
healthy: Schema75.Boolean,
|
|
16062
16415
|
last_heartbeat: exports_shared_schema.TimestampMillis,
|
|
16063
|
-
owned_shards:
|
|
16416
|
+
owned_shards: Schema75.Int
|
|
16064
16417
|
}).annotate({ identifier: "Relay.Operation.RunnerSummary" });
|
|
16065
|
-
var ListRunnersResult =
|
|
16066
|
-
runners:
|
|
16067
|
-
total_shards:
|
|
16418
|
+
var ListRunnersResult = Schema75.Struct({
|
|
16419
|
+
runners: Schema75.Array(RunnerSummary),
|
|
16420
|
+
total_shards: Schema75.Int
|
|
16068
16421
|
}).annotate({ identifier: "Relay.Operation.ListRunnersResult" });
|
|
16069
|
-
var RouteExecutionResult =
|
|
16422
|
+
var RouteExecutionResult = Schema75.Struct({
|
|
16070
16423
|
execution_id: exports_ids_schema.ExecutionId,
|
|
16071
|
-
shard:
|
|
16072
|
-
runner_address:
|
|
16073
|
-
owned:
|
|
16424
|
+
shard: Schema75.String,
|
|
16425
|
+
runner_address: Schema75.NullOr(Schema75.String),
|
|
16426
|
+
owned: Schema75.Boolean
|
|
16074
16427
|
}).annotate({ identifier: "Relay.Operation.RouteExecutionResult" });
|
|
16075
16428
|
// ../ai/src/embedding-model/embedding-model-registration.ts
|
|
16076
16429
|
import { OpenAiClient, OpenAiEmbeddingModel } from "@effect/ai-openai";
|
|
@@ -16102,7 +16455,7 @@ __export(exports_language_model_registration, {
|
|
|
16102
16455
|
anthropic: () => anthropic
|
|
16103
16456
|
});
|
|
16104
16457
|
|
|
16105
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16458
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.1/node_modules/@batonfx/providers/src/anthropic.ts
|
|
16106
16459
|
import { AnthropicClient, AnthropicLanguageModel } from "@effect/ai-anthropic";
|
|
16107
16460
|
import { Layer as Layer72 } from "effect";
|
|
16108
16461
|
import { FetchHttpClient as FetchHttpClient2 } from "effect/unstable/http";
|
|
@@ -16118,13 +16471,13 @@ var anthropic = (input) => exports_model_registry.registrationFromLayer({
|
|
|
16118
16471
|
});
|
|
16119
16472
|
var anthropicClientLayerConfig = AnthropicClient.layerConfig;
|
|
16120
16473
|
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.
|
|
16474
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.1/node_modules/@batonfx/providers/src/deterministic.ts
|
|
16122
16475
|
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
|
|
16476
|
+
import { Effect as Effect81, Layer as Layer74, Option as Option29, Stream as Stream12 } from "effect";
|
|
16477
|
+
import { LanguageModel as LanguageModel8, Response as Response7 } from "effect/unstable/ai";
|
|
16125
16478
|
import { FetchHttpClient as FetchHttpClient4 } from "effect/unstable/http";
|
|
16126
16479
|
|
|
16127
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16480
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.1/node_modules/@batonfx/providers/src/openai.ts
|
|
16128
16481
|
import { OpenAiClient as OpenAiClient2, OpenAiLanguageModel } from "@effect/ai-openai";
|
|
16129
16482
|
import { Layer as Layer73 } from "effect";
|
|
16130
16483
|
import { FetchHttpClient as FetchHttpClient3 } from "effect/unstable/http";
|
|
@@ -16141,10 +16494,10 @@ var openAi = (input) => exports_model_registry.registrationFromLayer({
|
|
|
16141
16494
|
var openAiClientLayerConfig2 = OpenAiClient2.layerConfig;
|
|
16142
16495
|
var withOpenAi = (options) => exports_model_registry.layerFromRegistrationEffects([openAi(options)]).pipe(Layer73.provide(OpenAiClient2.layerConfig({ ...options.clientConfig, apiKey: options.apiKey })), Layer73.provide(FetchHttpClient3.layer));
|
|
16143
16496
|
|
|
16144
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16145
|
-
var deterministicModelLayer = Layer74.effect(
|
|
16497
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.1/node_modules/@batonfx/providers/src/deterministic.ts
|
|
16498
|
+
var deterministicModelLayer = Layer74.effect(LanguageModel8.LanguageModel, LanguageModel8.make({
|
|
16146
16499
|
generateText: () => Effect81.succeed([{ type: "text", text: "deterministic response" }]),
|
|
16147
|
-
streamText: () =>
|
|
16500
|
+
streamText: () => Stream12.make(Response7.makePart("text-delta", { id: "text", delta: "deterministic response" }))
|
|
16148
16501
|
}));
|
|
16149
16502
|
var deterministicModel = (input = {}) => exports_model_registry.registrationFromLayer({
|
|
16150
16503
|
provider: input.provider ?? "deterministic",
|
|
@@ -16165,7 +16518,7 @@ var withOpenAiOrDeterministic = (options) => Layer74.unwrap(Effect81.gen(functio
|
|
|
16165
16518
|
...Option29.isSome(openAiRegistration) ? [openAiRegistration.value] : []
|
|
16166
16519
|
]);
|
|
16167
16520
|
}));
|
|
16168
|
-
// ../../node_modules/.bun/@batonfx+providers@0.
|
|
16521
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.1/node_modules/@batonfx/providers/src/openai-compat.ts
|
|
16169
16522
|
import { OpenAiClient as OpenAiClient4, OpenAiLanguageModel as OpenAiLanguageModel2 } from "@effect/ai-openai-compat";
|
|
16170
16523
|
import { Config as Config8, Layer as Layer75 } from "effect";
|
|
16171
16524
|
import { FetchHttpClient as FetchHttpClient5 } from "effect/unstable/http";
|
|
@@ -16186,7 +16539,7 @@ var clientLayerConfig = (options) => OpenAiClient4.layerConfig({
|
|
|
16186
16539
|
...options.baseUrl === undefined ? {} : { apiUrl: Config8.succeed(options.baseUrl) }
|
|
16187
16540
|
});
|
|
16188
16541
|
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.
|
|
16542
|
+
// ../../node_modules/.bun/@batonfx+providers@0.3.1/node_modules/@batonfx/providers/src/openrouter.ts
|
|
16190
16543
|
import { OpenRouterClient, OpenRouterLanguageModel } from "@effect/ai-openrouter";
|
|
16191
16544
|
import { Layer as Layer76 } from "effect";
|
|
16192
16545
|
import { FetchHttpClient as FetchHttpClient6 } from "effect/unstable/http";
|