@yielded/agent 0.1.0-beta.173 → 0.1.0-beta.174
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/{Admin-BX9ns28E.d.mts → Admin-BHmp2V9p.d.mts} +25 -16
- package/dist/{Agent-9aBoIi74.d.mts → Agent-B39jRnFv.d.mts} +2 -2
- package/dist/{Agent-0WvBWWbM.mjs → Agent-BiRbr73L.mjs} +7 -6
- package/dist/Agent-BiRbr73L.mjs.map +1 -0
- package/dist/{AgentRuntime-CQ-qcETl.mjs → AgentRuntime-B6qZlD3f.mjs} +199 -191
- package/dist/AgentRuntime-B6qZlD3f.mjs.map +1 -0
- package/dist/{AgentRuntime-BfP14534.d.mts → AgentRuntime-BD3ZHAMq.d.mts} +10 -10
- package/dist/{Digest-DCuPlhNk.mjs → Digest-EpeqWEdv.mjs} +41 -14
- package/dist/Digest-EpeqWEdv.mjs.map +1 -0
- package/dist/{DurableAgentRuntime-BAmSkWYr.mjs → DurableAgentRuntime-CBBjRNJN.mjs} +1447 -1424
- package/dist/DurableAgentRuntime-CBBjRNJN.mjs.map +1 -0
- package/dist/{EventSource-BwliwQz9.d.mts → EventSource-C9aaJaXT.d.mts} +2 -2
- package/dist/{MessageDelivery-B943ebI_.d.mts → MessageDelivery-BGDm-c46.d.mts} +42 -42
- package/dist/{Messaging-C_6OOg_s.d.mts → Messaging-SVu6rWV8.d.mts} +12 -6
- package/dist/{MessagingHost-B8oKM7AC.d.mts → MessagingHost-C6SOAcoG.d.mts} +2 -2
- package/dist/{Output-Dsx6k52t.d.mts → Output-CRamN1Fy.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-CxSJSiTl.d.mts → PreparedInputAdmission-BvDqlgiP.d.mts} +3 -3
- package/dist/{RunContinuation-DHYNAQFi.mjs → RunContinuation-4ZATcVLB.mjs} +113 -56
- package/dist/RunContinuation-4ZATcVLB.mjs.map +1 -0
- package/dist/{RunContinuation-FHM7XPjq.d.mts → RunContinuation-CTJ1jGrO.d.mts} +6 -6
- package/dist/{RunJournal-kfKVxJj7.mjs → RunJournal-CNZqA3Ge.mjs} +33 -5
- package/dist/RunJournal-CNZqA3Ge.mjs.map +1 -0
- package/dist/{RunOptions-D8zxFIrZ.d.mts → RunOptions-Be77lKVZ.d.mts} +2 -2
- package/dist/{RunStorage-uqPxps09.mjs → RunStorage-BHjuuERI.mjs} +9 -6
- package/dist/RunStorage-BHjuuERI.mjs.map +1 -0
- package/dist/{Scheduling-CVyfXlBR.mjs → Scheduling-NG8slKdI.mjs} +11 -11
- package/dist/Scheduling-NG8slKdI.mjs.map +1 -0
- package/dist/{Subagent-vpffemql.mjs → Subagent-CTIpnzlB.mjs} +53 -40
- package/dist/Subagent-CTIpnzlB.mjs.map +1 -0
- package/dist/{Subagent-E6tvd7-k.d.mts → Subagent-DKhZA72u.d.mts} +19 -8
- package/dist/{SubagentHost-B6w2m-SI.d.mts → SubagentHost-D1xBgn9g.d.mts} +2 -2
- package/dist/{Subscription-DONig54Q.d.mts → Subscription-BNg9VCRl.d.mts} +2 -2
- package/dist/{SubscriptionInput-mJIRxWJM.d.mts → SubscriptionInput-BUoXv-_K.d.mts} +2 -2
- package/dist/{ThreadImport-DpHxjBrA.d.mts → ThreadImport-CMgzttvr.d.mts} +5 -5
- package/dist/{ThreadImport-DckUMEqJ.mjs → ThreadImport-CodYoJoa.mjs} +7 -7
- package/dist/ThreadImport-CodYoJoa.mjs.map +1 -0
- package/dist/{ThreadStore-CEekRa80.mjs → ThreadStore-59uDGXul.mjs} +163 -84
- package/dist/ThreadStore-59uDGXul.mjs.map +1 -0
- package/dist/{ThreadTransfer-B4gTQLIl.mjs → ThreadTransfer-3jigUl3g.mjs} +3 -3
- package/dist/{ThreadTransfer-B4gTQLIl.mjs.map → ThreadTransfer-3jigUl3g.mjs.map} +1 -1
- package/dist/{WorkerAdmission-DFVbbVh2.mjs → WorkerAdmission-DDYJdOsU.mjs} +4 -4
- package/dist/{WorkerAdmission-DFVbbVh2.mjs.map → WorkerAdmission-DDYJdOsU.mjs.map} +1 -1
- package/dist/{agent-registration-ByMZ_cK5.mjs → agent-registration-DRbyhAu-.mjs} +69 -56
- package/dist/agent-registration-DRbyhAu-.mjs.map +1 -0
- package/dist/capabilities/Approval.mjs +2 -2
- package/dist/capabilities/Approval.mjs.map +1 -1
- package/dist/capabilities/BrowserUse.d.mts +102 -1867
- package/dist/capabilities/BrowserUse.mjs +74 -798
- package/dist/capabilities/BrowserUse.mjs.map +1 -1
- package/dist/capabilities/Budget.mjs +3 -1
- package/dist/capabilities/Budget.mjs.map +1 -1
- package/dist/capabilities/CodeMode.d.mts +1 -1
- package/dist/capabilities/CodeMode.mjs +16 -9
- package/dist/capabilities/CodeMode.mjs.map +1 -1
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/McpClient.mjs +1 -1
- package/dist/capabilities/McpClient.mjs.map +1 -1
- package/dist/capabilities/Messaging.d.mts +1 -1
- package/dist/capabilities/Messaging.mjs +4 -4
- package/dist/capabilities/Messaging.mjs.map +1 -1
- package/dist/capabilities/ModelContext.mjs +7 -5
- package/dist/capabilities/ModelContext.mjs.map +1 -1
- package/dist/capabilities/Redaction.mjs +49 -19
- package/dist/capabilities/Redaction.mjs.map +1 -1
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/RunHooks.mjs +1 -1
- package/dist/capabilities/RunHooks.mjs.map +1 -1
- package/dist/capabilities/Subagent.d.mts +1 -1
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/capabilities/SubagentReservations.mjs +3 -1
- package/dist/capabilities/SubagentReservations.mjs.map +1 -1
- package/dist/capabilities/WebCapture.mjs.map +1 -1
- package/dist/capabilities/WebSearch.mjs +7 -7
- package/dist/capabilities/WebSearch.mjs.map +1 -1
- package/dist/core/Agent.d.mts +1 -1
- package/dist/core/Agent.mjs +1 -1
- package/dist/core/AgentUpdates.mjs +8 -8
- package/dist/core/AgentUpdates.mjs.map +1 -1
- package/dist/core/Thread.mjs +1 -1
- package/dist/core/Thread.mjs.map +1 -1
- package/dist/core/Usage.mjs +2 -2
- package/dist/core/Usage.mjs.map +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/AgentRegistration.d.mts +1 -1
- package/dist/durable/AgentRegistration.mjs +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +1 -1
- package/dist/durable/CommittedActivity.mjs +2 -2
- package/dist/durable/Digest.mjs +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +2 -2
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/EventSource.mjs +6 -6
- package/dist/durable/EventSource.mjs.map +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/LifecyclePublication.d.mts +1 -1
- package/dist/durable/LifecyclePublication.mjs +1 -1
- package/dist/durable/MessageDelivery.d.mts +1 -1
- package/dist/durable/MessageDelivery.mjs +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +2 -2
- package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
- package/dist/durable/PersistentHistory.d.mts +1 -1
- package/dist/durable/PersistentHistory.mjs +3 -3
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/RecordFormat.mjs +2 -2
- package/dist/durable/RecordFormat.mjs.map +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/RunContinuation.d.mts +2 -2
- package/dist/durable/RunContinuation.mjs +2 -2
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/RunJournal.mjs +1 -1
- package/dist/durable/RunStorage.d.mts +1 -1
- package/dist/durable/RunStorage.mjs +1 -1
- package/dist/durable/Scheduling.d.mts +1 -1
- package/dist/durable/Scheduling.mjs +1 -1
- package/dist/durable/SettlementPublisher.d.mts +1 -1
- package/dist/durable/SettlementPublisher.mjs +2 -2
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +5 -1
- package/dist/durable/SubmissionLedger.mjs.map +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +4 -4
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +3 -3
- package/dist/durable/SubscriptionInput.mjs.map +1 -1
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.mjs +2 -2
- package/dist/durable/SubscriptionStoreConformance.mjs.map +1 -1
- package/dist/durable/SubscriptionTools.d.mts +2 -2
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/Subscriptions.mjs +2 -2
- package/dist/durable/Subscriptions.mjs.map +1 -1
- package/dist/durable/ThreadArchiveRange.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.mjs +1 -1
- package/dist/durable/ThreadImport.d.mts +1 -1
- package/dist/durable/ThreadImport.mjs +1 -1
- package/dist/durable/ThreadInvariants.d.mts +3 -3
- package/dist/durable/ThreadInvariants.mjs +4 -4
- package/dist/durable/ThreadInvariants.mjs.map +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadReader.d.mts +1 -1
- package/dist/durable/ThreadReader.mjs +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStore.mjs +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +3 -3
- package/dist/durable/ThreadTransfer.d.mts +1 -1
- package/dist/durable/ThreadTransfer.mjs +1 -1
- package/dist/durable/ThreadWork.d.mts +1 -1
- package/dist/durable/ThreadWork.mjs +4 -4
- package/dist/durable/ThreadWork.mjs.map +1 -1
- package/dist/durable/WorkerAdmission.d.mts +1 -1
- package/dist/durable/WorkerAdmission.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +2 -2
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/MessagingHost.d.mts +1 -1
- package/dist/engine/Output.d.mts +1 -1
- package/dist/engine/RunOptions.d.mts +1 -1
- package/dist/engine/SubagentHost.d.mts +1 -1
- package/dist/index.d.mts +19 -19
- package/dist/index.mjs +14 -14
- package/dist/{run-context-reader-OcsZr4bk.d.mts → run-context-reader-CC7ZD95F.d.mts} +2 -2
- package/package.json +1 -1
- package/src/capabilities/Approval.ts +58 -60
- package/src/capabilities/BrowserUse.ts +89 -944
- package/src/capabilities/Budget.ts +8 -1
- package/src/capabilities/CodeMode.ts +57 -33
- package/src/capabilities/McpClient.ts +2 -2
- package/src/capabilities/Messaging.ts +51 -55
- package/src/capabilities/ModelContext.ts +5 -2
- package/src/capabilities/Redaction.ts +64 -34
- package/src/capabilities/RunHooks.ts +52 -55
- package/src/capabilities/Subagent.ts +33 -33
- package/src/capabilities/SubagentReservations.ts +9 -1
- package/src/capabilities/WebCapture.ts +6 -0
- package/src/capabilities/WebSearch.ts +10 -7
- package/src/capabilities/internal/subagent-background.ts +202 -158
- package/src/core/Agent.ts +11 -6
- package/src/core/AgentUpdates.ts +8 -8
- package/src/core/Thread.ts +9 -10
- package/src/core/Usage.ts +7 -8
- package/src/core/internal/agent-updates.ts +1 -0
- package/src/durable/DurableAgentRuntime.ts +645 -625
- package/src/durable/EventSource.ts +15 -9
- package/src/durable/RecordFormat.ts +5 -3
- package/src/durable/RunContinuation.ts +233 -81
- package/src/durable/RunJournal.ts +10 -9
- package/src/durable/RunStorage.ts +122 -124
- package/src/durable/Scheduling.ts +639 -651
- package/src/durable/SubmissionLedger.ts +4 -0
- package/src/durable/SubscriptionInput.ts +5 -3
- package/src/durable/SubscriptionStoreConformance.ts +23 -23
- package/src/durable/Subscriptions.ts +18 -19
- package/src/durable/ThreadImport.ts +18 -19
- package/src/durable/ThreadInvariants.ts +2 -1
- package/src/durable/ThreadStore.ts +215 -111
- package/src/durable/ThreadWork.ts +1 -2
- package/src/durable/internal/StorageOwner.ts +10 -4
- package/src/durable/internal/agent-registration.ts +96 -89
- package/src/durable/internal/canonical-json.ts +61 -20
- package/src/durable/internal/prompt-history-cache.ts +13 -4
- package/src/durable/internal/record-encoding.ts +120 -64
- package/src/durable/internal/schedule-time.ts +6 -6
- package/src/durable/internal/usage-totals.ts +38 -0
- package/src/durable/internal/worker-host.ts +69 -74
- package/src/engine/internal/agent-runtime.ts +1067 -1018
- package/src/engine/internal/provisional-text.ts +12 -10
- package/src/engine/internal/tool-exposure.ts +22 -18
- package/src/engine/internal/tool-telemetry.ts +12 -7
- package/dist/Agent-0WvBWWbM.mjs.map +0 -1
- package/dist/AgentRuntime-CQ-qcETl.mjs.map +0 -1
- package/dist/Digest-DCuPlhNk.mjs.map +0 -1
- package/dist/DurableAgentRuntime-BAmSkWYr.mjs.map +0 -1
- package/dist/RunContinuation-DHYNAQFi.mjs.map +0 -1
- package/dist/RunJournal-kfKVxJj7.mjs.map +0 -1
- package/dist/RunStorage-uqPxps09.mjs.map +0 -1
- package/dist/Scheduling-CVyfXlBR.mjs.map +0 -1
- package/dist/Subagent-vpffemql.mjs.map +0 -1
- package/dist/ThreadImport-DckUMEqJ.mjs.map +0 -1
- package/dist/ThreadStore-CEekRa80.mjs.map +0 -1
- package/dist/agent-registration-ByMZ_cK5.mjs.map +0 -1
|
@@ -30,9 +30,8 @@ const makeAttempt = Effect.fnUntraced(function* (
|
|
|
30
30
|
): Effect.fn.Return<Attempt> {
|
|
31
31
|
const publisher = yield* ProvisionalText.Publisher;
|
|
32
32
|
const identity = { threadId, submissionId, attemptId };
|
|
33
|
-
const active = new Set<ModelHandle>();
|
|
34
33
|
let closed = false;
|
|
35
|
-
let
|
|
34
|
+
let nextGeneration = 0;
|
|
36
35
|
|
|
37
36
|
const offerUnsafe = (event: ProvisionalText.Event): boolean => {
|
|
38
37
|
try {
|
|
@@ -47,7 +46,7 @@ const makeAttempt = Effect.fnUntraced(function* (
|
|
|
47
46
|
openModel: (runId, turnId) => {
|
|
48
47
|
if (closed) return undefined;
|
|
49
48
|
|
|
50
|
-
const
|
|
49
|
+
const generation = ++nextGeneration;
|
|
51
50
|
let open = true;
|
|
52
51
|
|
|
53
52
|
const handle: ModelHandle = {
|
|
@@ -61,28 +60,31 @@ const makeAttempt = Effect.fnUntraced(function* (
|
|
|
61
60
|
? Response.makePart("text-delta", { id: part.id, delta: part.delta })
|
|
62
61
|
: Response.makePart(part.type, { id: part.id });
|
|
63
62
|
|
|
64
|
-
return offerUnsafe({
|
|
63
|
+
return offerUnsafe({
|
|
64
|
+
_tag: "Text",
|
|
65
|
+
...identity,
|
|
66
|
+
runId,
|
|
67
|
+
turnId,
|
|
68
|
+
generation,
|
|
69
|
+
part: detached,
|
|
70
|
+
});
|
|
65
71
|
},
|
|
66
72
|
discard: () => {
|
|
67
|
-
if (!open) return;
|
|
73
|
+
if (!open || closed) return;
|
|
68
74
|
handle.close();
|
|
69
|
-
offerUnsafe({ _tag: "Discard", ...
|
|
75
|
+
offerUnsafe({ _tag: "Discard", ...identity, runId, turnId, generation });
|
|
70
76
|
},
|
|
71
77
|
close: () => {
|
|
72
78
|
if (!open) return;
|
|
73
79
|
open = false;
|
|
74
|
-
active.delete(handle);
|
|
75
80
|
},
|
|
76
81
|
};
|
|
77
82
|
|
|
78
|
-
active.add(handle);
|
|
79
|
-
|
|
80
83
|
return handle;
|
|
81
84
|
},
|
|
82
85
|
close: () => {
|
|
83
86
|
if (closed) return;
|
|
84
87
|
closed = true;
|
|
85
|
-
for (const handle of active) handle.close();
|
|
86
88
|
offerUnsafe({ _tag: "AttemptEnded", ...identity });
|
|
87
89
|
},
|
|
88
90
|
};
|
|
@@ -194,25 +194,29 @@ export const exposureSnapshot = Effect.fnUntraced(function* (
|
|
|
194
194
|
if (names.length > limits.maxTools)
|
|
195
195
|
return yield* invalid("Tool exposure exceeds the configured Tool count bound");
|
|
196
196
|
|
|
197
|
+
const declarations: Array<unknown> = [];
|
|
198
|
+
|
|
199
|
+
for (const name of names) {
|
|
200
|
+
const tool = definition.toolkit.tools[name];
|
|
201
|
+
|
|
202
|
+
if (tool === undefined) return yield* invalid("A selected Tool schema cannot be rendered");
|
|
203
|
+
declarations.push(
|
|
204
|
+
yield* Effect.try({
|
|
205
|
+
try: () =>
|
|
206
|
+
Tool.isProviderDefined(tool)
|
|
207
|
+
? { type: tool.providerName, args: tool.args }
|
|
208
|
+
: {
|
|
209
|
+
name,
|
|
210
|
+
description: Tool.getDescription(tool),
|
|
211
|
+
parameters: Tool.getJsonSchema(tool, { transformer }),
|
|
212
|
+
},
|
|
213
|
+
catch: () => invalid("A selected Tool schema cannot be rendered"),
|
|
214
|
+
}),
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
197
218
|
const bytes = yield* Effect.try({
|
|
198
|
-
try: () =>
|
|
199
|
-
utf8ByteLength(
|
|
200
|
-
JSON.stringify(
|
|
201
|
-
names.map((name) => {
|
|
202
|
-
const tool = definition.toolkit.tools[name];
|
|
203
|
-
|
|
204
|
-
if (tool === undefined) throw new Error("Selected Tool is unavailable");
|
|
205
|
-
|
|
206
|
-
return Tool.isProviderDefined(tool)
|
|
207
|
-
? { type: tool.providerName, args: tool.args }
|
|
208
|
-
: {
|
|
209
|
-
name,
|
|
210
|
-
description: Tool.getDescription(tool),
|
|
211
|
-
parameters: Tool.getJsonSchema(tool, { transformer }),
|
|
212
|
-
};
|
|
213
|
-
}),
|
|
214
|
-
),
|
|
215
|
-
),
|
|
219
|
+
try: () => utf8ByteLength(JSON.stringify(declarations)),
|
|
216
220
|
catch: () => invalid("A selected Tool schema cannot be rendered"),
|
|
217
221
|
});
|
|
218
222
|
|
|
@@ -8,6 +8,7 @@ import * as ErrorReporter from "effect/ErrorReporter";
|
|
|
8
8
|
import * as Exit from "effect/Exit";
|
|
9
9
|
import * as Layer from "effect/Layer";
|
|
10
10
|
import * as Option from "effect/Option";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
11
12
|
import * as Stream from "effect/Stream";
|
|
12
13
|
import * as Tracer from "effect/Tracer";
|
|
13
14
|
|
|
@@ -112,12 +113,12 @@ export const restoreToolSpanFailureCause = <E, Original>(
|
|
|
112
113
|
const MAX_REPORTED_SPAN_LIFECYCLE_DEFECTS = 16;
|
|
113
114
|
|
|
114
115
|
/** Content-free marker used only to close a delegate that cannot be wrapped safely. */
|
|
115
|
-
class ToolSpanLifecycleFailure extends
|
|
116
|
+
class ToolSpanLifecycleFailure extends Schema.TaggedError<ToolSpanLifecycleFailure>()(
|
|
117
|
+
"ToolSpanLifecycleFailure",
|
|
118
|
+
{},
|
|
119
|
+
) {
|
|
116
120
|
override readonly name = "ToolSpanLifecycleFailure";
|
|
117
|
-
|
|
118
|
-
constructor() {
|
|
119
|
-
super("Tool span lifecycle failed");
|
|
120
|
-
}
|
|
121
|
+
override readonly message = "Tool span lifecycle failed";
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
/**
|
|
@@ -173,7 +174,7 @@ class IsolatedToolSpan implements Tracer.Span {
|
|
|
173
174
|
// attempt even if downstream cancellation or telemetry interruption determines the channel Exit.
|
|
174
175
|
const exportedExit =
|
|
175
176
|
this.#terminalOutcome === "failure"
|
|
176
|
-
? Exit.fail(this.#terminalFailure ??
|
|
177
|
+
? Exit.fail(this.#terminalFailure ?? ToolSpanLifecycleFailure.make({}))
|
|
177
178
|
: this.#terminalOutcome === "success"
|
|
178
179
|
? Exit.succeed(undefined)
|
|
179
180
|
: exit;
|
|
@@ -302,6 +303,7 @@ export const makeIsolatedToolTracer = (delegate: Tracer.Tracer): IsolatedToolTra
|
|
|
302
303
|
case "Succeeded":
|
|
303
304
|
return evaluation.value;
|
|
304
305
|
case "Failed":
|
|
306
|
+
// oxlint-disable-next-line effect/no-untyped-throw -- The synchronous foreign tracer hook must rethrow the original primitive failure for the Effect evaluator.
|
|
305
307
|
throw evaluation.error;
|
|
306
308
|
case "Pending": {
|
|
307
309
|
try {
|
|
@@ -312,6 +314,7 @@ export const makeIsolatedToolTracer = (delegate: Tracer.Tracer): IsolatedToolTra
|
|
|
312
314
|
return value;
|
|
313
315
|
} catch (error) {
|
|
314
316
|
evaluation = { _tag: "Failed", error };
|
|
317
|
+
// oxlint-disable-next-line effect/no-untyped-throw -- The synchronous foreign tracer hook must rethrow the original primitive failure for the Effect evaluator.
|
|
315
318
|
throw error;
|
|
316
319
|
}
|
|
317
320
|
}
|
|
@@ -329,6 +332,7 @@ export const makeIsolatedToolTracer = (delegate: Tracer.Tracer): IsolatedToolTra
|
|
|
329
332
|
|
|
330
333
|
switch (observed._tag) {
|
|
331
334
|
case "Failed":
|
|
335
|
+
// oxlint-disable-next-line effect/no-untyped-throw -- The synchronous foreign tracer hook must rethrow the original primitive failure for the Effect evaluator.
|
|
332
336
|
throw observed.error;
|
|
333
337
|
case "Succeeded":
|
|
334
338
|
recordDefect(defect);
|
|
@@ -344,6 +348,7 @@ export const makeIsolatedToolTracer = (delegate: Tracer.Tracer): IsolatedToolTra
|
|
|
344
348
|
|
|
345
349
|
switch (observed._tag) {
|
|
346
350
|
case "Failed":
|
|
351
|
+
// oxlint-disable-next-line effect/no-untyped-throw -- The synchronous foreign tracer hook must rethrow the original primitive failure for the Effect evaluator.
|
|
347
352
|
throw observed.error;
|
|
348
353
|
case "Succeeded":
|
|
349
354
|
return observed.value;
|
|
@@ -373,7 +378,7 @@ export const makeIsolatedToolTracer = (delegate: Tracer.Tracer): IsolatedToolTra
|
|
|
373
378
|
try {
|
|
374
379
|
// Allocation succeeded, so best-effort close the host span without attaching the raw
|
|
375
380
|
// wrapper defect. The start time gives this abandoned measurement a bounded duration.
|
|
376
|
-
delegateSpan.end(options.startTime, Exit.fail(
|
|
381
|
+
delegateSpan.end(options.startTime, Exit.fail(ToolSpanLifecycleFailure.make({})));
|
|
377
382
|
} catch (closeDefect) {
|
|
378
383
|
recordDefect(closeDefect);
|
|
379
384
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Agent-0WvBWWbM.mjs","names":["S"],"sources":["../src/core/internal/agent-updates.ts","../src/core/Agent.ts"],"sourcesContent":["import * as Tool from \"effect/ai/Tool\";\nimport * as Toolkit from \"effect/ai/Toolkit\";\nimport * as Schema from \"effect/Schema\";\n\nimport { Emitter, UpdateError } from \"../AgentUpdates.ts\";\n\n/** Definition-owned native Tool. Runtime supplies its handler under the same identity. */\nexport const updateTool = <S extends Schema.Top>(schema: S) =>\n Tool.make(\"emit_update\", {\n description:\n \"Emit a structured intermediate update. Success acknowledges acceptance by this Run; \" +\n \"parent delivery and processing are separate. This does not complete the task.\",\n parameters: Schema.Struct({ value: schema }),\n success: Schema.Struct({ emitted: Schema.Literal(true) }),\n failure: UpdateError,\n failureMode: \"return\",\n }).addDependency(Emitter);\n\nexport type UpdateToolkit<\n T extends Toolkit.Any,\n S extends Schema.Top | undefined,\n> = S extends Schema.Top\n ? Toolkit.Toolkit<T[\"tools\"] & { readonly emit_update: ReturnType<typeof updateTool<S>> }>\n : T;\n\nexport const withUpdateTool = (\n toolkit: Toolkit.Any,\n schema: Schema.Top | undefined,\n): Toolkit.Any => {\n if (schema === undefined) return toolkit;\n if (Object.hasOwn(toolkit.tools, \"emit_update\"))\n throw new TypeError(\"emit_update is reserved for Agent updates\");\n\n return Toolkit.make(...Object.values(toolkit.tools), updateTool(schema));\n};\n","import type { Effect, Layer, Option, Schema } from \"effect\";\nimport type { AiError, LanguageModel, Model, Prompt } from \"effect/ai\";\nimport * as Tool from \"effect/ai/Tool\";\nimport * as Toolkit from \"effect/ai/Toolkit\";\nimport * as S from \"effect/Schema\";\n\nimport type {\n AgentInputDecodeError,\n AgentInputError,\n AgentOutputError,\n AgentRunDispositionError,\n} from \"./AgentError.ts\";\nimport { AgentPolicy, type AgentPolicyInput } from \"./AgentPolicy.ts\";\nimport { AgentId } from \"./Identifiers.ts\";\nimport { type UpdateToolkit, withUpdateTool } from \"./internal/agent-updates.ts\";\nimport type { Configuration } from \"./ToolExposure.ts\";\n\n/** Prompt input produced directly or by an Effect that preserves its failure and requirements. */\nexport type InstructionResult<E = never, R = never> =\n | Prompt.RawInput\n | Effect.Effect<Prompt.RawInput, E, R>;\n\n/** Static prompt input or an input-dependent source evaluated once while preparing a run. */\nexport type InstructionSource<Input, E = never, R = never> =\n | Prompt.RawInput\n | ((input: Input) => InstructionResult<E, R>);\n\n/** Definition-owned projection from decoded Agent input to model-visible prompt content. */\nexport type InputPromptSource<Input, E = never, R = never> = (\n input: Input,\n) => InstructionResult<E, R>;\n\n/** Native services needed to execute and identify model calls. */\nexport type ModelServices = LanguageModel.LanguageModel | Model.ProviderName | Model.ModelName;\n\n/**\n * An optional capability on a provided LanguageModel service. The runtime supplies\n * only model-visible task context and eligible Tool descriptions after validating input.\n * The resolver owns retaining one choice per Thread, including across Runs and\n * recovery; it captures client requirements and returns a closed native Layer\n * that the interpreter acquires for the Run. Context hooks may prepare prompts\n * but cannot replace this model through a per-Turn modelCall.\n * Selection failures remain AiError values and all selector/client services stay in R.\n */\nexport interface ModelResolver extends LanguageModel.LanguageModel {\n readonly resolve: (request: {\n readonly threadId: string;\n readonly state: Schema.JsonObject;\n }) => Effect.Effect<Layer.Layer<ModelServices>, AiError.AiError>;\n}\n\n/** Detect the deferred resolver capability on a trusted, host-provided model service. */\nexport const isModelResolver = (model: LanguageModel.LanguageModel): model is ModelResolver =>\n \"resolve\" in model && typeof model.resolve === \"function\";\n\n/** Accepts native model Layers that provide generation and model identity. */\nexport type NativeModel<ModelValue> =\n ModelValue extends Layer.Layer<infer Provides, never, infer _Requires>\n ? ModelServices extends Provides\n ? ModelValue\n : never\n : never;\n\n/** Definition-owned boundary for selecting and validating an application run disposition. */\nexport interface RunDispositionDeclaration<Output, DispositionSchema extends Schema.Top> {\n /**\n * Opt background workers into one retained assignment. The encoded disposition must be\n * Worker.AssignmentDisposition: completed seals the worker, waiting leaves it steerable.\n * Failures and exhausted Runs seal as failed; aborting an active Run seals as cancelled.\n * The worker origin retains this choice. Omission preserves reusable workers.\n */\n readonly workerLifecycle?: \"assignment\" | undefined;\n /** Canonical Schema used to validate and encode the selected disposition. */\n readonly schema: DispositionSchema;\n /** Pure selection from decoded output. `undefined` declares none, except for assignments. */\n readonly fromOutput: (output: Output) => unknown;\n}\n\n/** Values available to a Definition-owned completion Tool projector after canonical decoding. */\nexport interface CompletionProjectionInput<Parameters = unknown, Result = unknown> {\n readonly parameters: Parameters;\n readonly result: Result;\n}\n\n/**\n * One application Tool whose successful result can complete its owning Agent when it is the\n * only application call. Provider-executed calls may accompany it only with terminal results.\n * Mixed, wholly unexecuted application batches are rejected with failed Tool results so the\n * model can correct them within ordinary Run budgets; completed provider results are retained.\n * Missing provider results and invalid pending resumed batches fail closed. The completion\n * designation never permits side-effect replay.\n */\nexport interface CompletionToolDeclaration<\n Parameters = unknown,\n Result = unknown,\n Output = unknown,\n> {\n readonly tool: string;\n /** Require native Tool use on every model Turn and this Tool for final completion. */\n readonly required?: boolean | undefined;\n /**\n * Pure, deterministic projection: recovery may reevaluate a recorded Tool result before\n * RunCompleted commits. Once committed, that stored output wins across later code changes.\n */\n readonly project: (input: CompletionProjectionInput<Parameters, Result>) => Output;\n}\n\ntype CompletionToolFor<ToolkitValue extends Toolkit.Any, Output> = {\n readonly [Name in keyof ToolkitValue[\"tools\"] & string]: CompletionToolDeclaration<\n Tool.Parameters<ToolkitValue[\"tools\"][Name]>,\n Tool.Success<ToolkitValue[\"tools\"][Name]>,\n Output\n > & { readonly tool: Name };\n}[keyof ToolkitValue[\"tools\"] & string];\n\n/**\n * An ordinary action Tool whose canonical success may satisfy the whole request.\n * Projectors must be pure and deterministic: recovery re-evaluates them. None preserves\n * ordinary continuation; Some is validated as the Agent output. These Tools must be the sole\n * application call; terminal provider results may accompany them. They never receive the\n * required completion Tool's exhaustion allowance.\n */\nexport interface CompletionFromToolDeclaration<\n Parameters = unknown,\n Result = unknown,\n Output = unknown,\n> {\n readonly tool: string;\n readonly project: (input: CompletionProjectionInput<Parameters, Result>) => Option.Option<Output>;\n}\n\ntype CompletionFromToolFor<ToolkitValue extends Toolkit.Any, Output> = {\n readonly [Name in keyof ToolkitValue[\"tools\"] & string]: CompletionFromToolDeclaration<\n Tool.Parameters<ToolkitValue[\"tools\"][Name]>,\n Tool.Success<ToolkitValue[\"tools\"][Name]>,\n Output\n > & { readonly tool: Name };\n}[keyof ToolkitValue[\"tools\"] & string];\n\n/** Immutable, model-agnostic schemas, behavior, tools, and bounds for an agent. */\nexport interface Definition<\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions,\n ToolkitValue extends Toolkit.Any,\n RunDispositionValue = undefined,\n InputPromptValue = undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n> {\n /** Stable agent identity; changing it creates a distinct definition identity. */\n readonly id: AgentId;\n /** Canonical Schema for intermediate updates emitted by this Agent. */\n readonly updates?: UpdatesSchema;\n /** Canonical schema used to decode and encode run input. */\n readonly input: InputSchema;\n /** Canonical schema used to decode the final model output. */\n readonly output: OutputSchema;\n /**\n * Evaluated once while preparing each Run. OpenAI, xAI and native adapters advertising support\n * preserve chronological system messages, omitting exact repeats only when no distinct system\n * instruction intervenes. The actual selected model determines support on each call. Other\n * adapters group systems first and keep the last exact repeat, including provider options;\n * Anthropic requires an upstream adapter with mid-conversation system-message support.\n * Stored history is unchanged.\n */\n readonly instructions: Instructions;\n /**\n * Optional projection from decoded input to model-visible native Effect AI prompt content.\n * This controls disclosure only: durable admission retains the complete input and Tool\n * authorization receives it. A projection failure never falls back to sending full input.\n */\n readonly inputPrompt?: InputPromptValue | undefined;\n /** Native Effect AI toolkit whose failures and requirements remain visible. */\n readonly toolkit: ToolkitValue;\n readonly toolExposure?: Configuration | undefined;\n /** Finite execution bounds enforced by the runtime. */\n readonly policy: AgentPolicy;\n /** Explicit policy fields, retained so delegated runs can inherit omitted fields. */\n readonly policyOverrides?: Partial<AgentPolicyInput> | undefined;\n /** Optional successful Tool result that projects directly to the Agent output and settles. */\n readonly completion?: CompletionToolDeclaration | undefined;\n readonly completionFromTools?: ReadonlyArray<CompletionFromToolDeclaration> | undefined;\n readonly runDisposition?: RunDispositionValue | undefined;\n readonly description?: string | undefined;\n readonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\n/** Options for a model-agnostic agent definition. */\nexport interface DefinitionOptions<\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n RunDispositionValue extends\n | RunDispositionDeclaration<OutputSchema[\"Type\"], Schema.Top>\n | undefined = undefined,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined =\n undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n> {\n readonly updates?: UpdatesSchema;\n readonly input: InputSchema;\n readonly output: OutputSchema;\n readonly instructions: Instructions;\n readonly inputPrompt?: InputPromptValue | undefined;\n readonly toolkit: ToolkitValue;\n readonly toolExposure?: Configuration | undefined;\n readonly policy?: Partial<AgentPolicyInput> | undefined;\n readonly completion?: CompletionToolFor<ToolkitValue, OutputSchema[\"Type\"]> | undefined;\n readonly completionFromTools?:\n | ReadonlyArray<CompletionFromToolFor<ToolkitValue, OutputSchema[\"Type\"]>>\n | undefined;\n readonly runDisposition?: RunDispositionValue | undefined;\n readonly description?: string | undefined;\n readonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\ntype AnyDefinitionShape = Definition<\n Schema.Top,\n Schema.Top,\n unknown,\n Toolkit.Any,\n RunDispositionDeclaration<never, Schema.Top> | undefined,\n unknown,\n Schema.Top | undefined\n>;\n\n/** Immutable pairing of an agent definition with a native model Layer or thread resolver. */\nexport interface Binding<DefinitionValue extends AnyDefinitionShape, ModelValue> {\n readonly definition: DefinitionValue;\n readonly model: NativeModel<ModelValue>;\n}\n\ntype InstructionEffect<Instructions, Input> = Instructions extends (input: Input) => infer Result\n ? Result\n : Instructions;\n\ntype InputPromptEffect<InputPrompt, Input> = InputPrompt extends (input: Input) => infer Result\n ? Result\n : never;\n\ntype EffectError<Value> =\n Value extends Effect.Effect<infer _Success, infer Error, infer _Services> ? Error : never;\n\ntype EffectServices<Value> =\n Value extends Effect.Effect<infer _Success, infer _Error, infer Services> ? Services : never;\n\ntype ModelRequirements<Value> =\n Value extends Layer.Layer<infer _Provides, infer _Error, infer Services> ? Services : never;\n\n/** Constructors and type projections for definitions and runnable model bindings. */\n\n/** Type-erased definition used at generic framework boundaries. */\nexport type AnyDefinition = AnyDefinitionShape;\n\n/** Read-only interpreter program or binding used at inspection and projection boundaries. */\nexport interface Any {\n readonly definition: AnyDefinition;\n readonly model?: unknown;\n}\n\n/** Native Tool configuration for inspection; it does not predict an invocation's outcome. */\nexport const ToolInspection = S.Struct({\n name: S.String,\n failureMode: S.Literals([\"error\", \"return\"]),\n /** False for provider-executed Tools, whose results do not pass through local handlers. */\n requiresHandler: S.Boolean,\n});\n\nexport type ToolInspection = typeof ToolInspection.Type;\n\n/**\n * Inspect registered native Tools in declaration order without acquiring handlers or a Model.\n * This is the full Definition toolkit, before run-specific visibility or exposure filtering.\n * `failureMode` is Effect AI's configured mode, including its `\"error\"` default. Handler-level\n * recovery, programmatic invocation and Subagent containment can change where failures go;\n * consult execution diagnostics for the actual route. No arguments, results or services are read.\n */\nexport const inspectTools = (agent: AnyDefinition | Any): ReadonlyArray<ToolInspection> => {\n const definition = \"definition\" in agent ? agent.definition : agent;\n\n return Object.values(definition.toolkit.tools).map((tool) =>\n ToolInspection.make({\n name: tool.name,\n failureMode: tool.failureMode,\n requiresHandler: !Tool.isProviderDefined(tool) || tool.requiresHandler,\n }),\n );\n};\n\ntype DefinitionOf<AgentValue extends AnyDefinition | Any> = AgentValue extends {\n readonly definition: infer DefinitionValue extends AnyDefinition;\n}\n ? DefinitionValue\n : AgentValue;\n\ntype RunDispositionSchemaOf<DefinitionValue extends AnyDefinition> = [\n Exclude<DefinitionValue[\"runDisposition\"], undefined>,\n] extends [never]\n ? never\n : Exclude<DefinitionValue[\"runDisposition\"], undefined> extends RunDispositionDeclaration<\n never,\n infer DispositionSchema\n >\n ? DispositionSchema\n : never;\n\n/** Literal Agent ID, retained by Agent.make. */\nexport type Name<A extends AnyDefinition | Any> = DefinitionOf<A>[\"id\"] extends AgentId &\n (infer N extends string)\n ? N\n : string;\n\n/** Declared update Schema, or never for Agents without updates. */\nexport type UpdatesSchema<A extends AnyDefinition | Any> = Exclude<\n DefinitionOf<A>[\"updates\"],\n undefined\n>;\n\n/** Decoded intermediate update value. */\nexport type Update<A extends AnyDefinition | Any> = UpdatesSchema<A>[\"Type\"];\n\n/** Decoded input type of a definition or binding. */\nexport type Input<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"input\"][\"Type\"];\n\n/** Encoded input accepted by the primary execution operations. */\nexport type EncodedInput<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"input\"][\"Encoded\"];\n\n/** Decoded output type of a definition or binding. */\nexport type Output<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"output\"][\"Type\"];\n\n/** Input Schema carried by a definition or binding. */\nexport type InputSchema<AgentValue extends AnyDefinition | Any> = DefinitionOf<AgentValue>[\"input\"];\n\n/** Output Schema carried by a definition or binding. */\nexport type OutputSchema<AgentValue extends AnyDefinition | Any> =\n DefinitionOf<AgentValue>[\"output\"];\n\n/** Application run-disposition Schema carried by a definition or binding, or `never`. */\nexport type RunDispositionSchema<AgentValue extends AnyDefinition | Any> = RunDispositionSchemaOf<\n DefinitionOf<AgentValue>\n>;\n\n/** Decoded application run disposition declared by a definition or binding. */\nexport type RunDisposition<AgentValue extends AnyDefinition | Any> = [\n RunDispositionSchema<AgentValue>,\n] extends [never]\n ? never\n : RunDispositionSchema<AgentValue>[\"Type\"];\n\n/** Validation failure admitted only by definitions that declare a run disposition. */\nexport type RunDispositionFailure<AgentValue extends AnyDefinition | Any> = [\n RunDispositionSchemaOf<DefinitionOf<AgentValue>>,\n] extends [never]\n ? never\n : AgentRunDispositionError;\n\n/** Effect AI tool map carried by a definition or binding. */\nexport type Tools<AgentValue extends AnyDefinition | Any> = Toolkit.Tools<\n DefinitionOf<AgentValue>[\"toolkit\"]\n>;\n\ntype ApplicationTools<A extends AnyDefinition> = [UpdatesSchema<A>] extends [never]\n ? Tools<A>\n : Omit<Tools<A>, \"emit_update\">;\n\ntype ToolMapValues<ToolMap extends Record<string, Tool.Any>> = ToolMap extends unknown\n ? ToolMap[keyof ToolMap]\n : never;\n\n/** All possible tools, including keys present in only one definition or binding branch. */\nexport type ToolUnion<AgentValue extends AnyDefinition | Any> = ToolMapValues<Tools<AgentValue>>;\n\n/** Instruction, tool-handler, and Schema services required before a Model is bound. */\nexport type DefinitionRequirements<DefinitionValue extends AnyDefinition> =\n DefinitionValue extends unknown\n ?\n | EffectServices<InstructionEffect<DefinitionValue[\"instructions\"], Input<DefinitionValue>>>\n | EffectServices<InputPromptEffect<DefinitionValue[\"inputPrompt\"], Input<DefinitionValue>>>\n | Tool.HandlersFor<ApplicationTools<DefinitionValue>>\n | Tool.HandlerServices<ToolMapValues<ApplicationTools<DefinitionValue>>>\n // The interpreter canonically re-encodes decoded Tool parameters before recording them.\n | Tool.ParametersSchema<ToolUnion<DefinitionValue>>[\"EncodingServices\"]\n | Tool.SuccessSchema<ToolUnion<DefinitionValue>>[\"DecodingServices\"]\n | DefinitionValue[\"input\"][\"DecodingServices\"]\n | DefinitionValue[\"input\"][\"EncodingServices\"]\n | DefinitionValue[\"output\"][\"DecodingServices\"]\n | DefinitionValue[\"output\"][\"EncodingServices\"]\n | UpdatesSchema<DefinitionValue>[\"DecodingServices\"]\n | UpdatesSchema<DefinitionValue>[\"EncodingServices\"]\n | RunDispositionSchemaOf<DefinitionValue>[\"DecodingServices\"]\n | RunDispositionSchemaOf<DefinitionValue>[\"EncodingServices\"]\n : never;\n\n/** Definition services plus native model services, or a binding's model Layer requirements. */\nexport type Requirements<AgentValue extends AnyDefinition | Any> =\n | DefinitionRequirements<DefinitionOf<AgentValue>>\n | (AgentValue extends { readonly model: infer ModelValue }\n ? ModelRequirements<ModelValue>\n : ModelServices);\n\n// Distribute after unwrapping bindings too: withModel may itself contain a definition union.\ntype DefinitionFailure<DefinitionValue extends AnyDefinition> = DefinitionValue extends unknown\n ?\n | EffectError<InstructionEffect<DefinitionValue[\"instructions\"], Input<DefinitionValue>>>\n | EffectError<InputPromptEffect<DefinitionValue[\"inputPrompt\"], Input<DefinitionValue>>>\n | Tool.HandlerError<ToolUnion<DefinitionValue>>\n : never;\n\n/** Failures from every possible definition, preserving each branch's instruction input type. */\nexport type Failure<AgentValue extends AnyDefinition | Any> =\n | DefinitionFailure<DefinitionOf<AgentValue>>\n | AiError.AiError\n | AgentInputDecodeError\n | AgentInputError\n | AgentOutputError\n | RunDispositionFailure<AgentValue>;\n\n/** Validate an agent ID and return a shallowly frozen, model-agnostic definition. */\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n DispositionSchema extends Schema.Top,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n InputPromptValue,\n UpdatesSchema\n > & {\n readonly runDisposition: RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>;\n readonly inputPrompt: InputPromptValue;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n InputPromptValue,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n DispositionSchema extends Schema.Top,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n undefined,\n UpdatesSchema\n > & {\n readonly runDisposition: RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>;\n readonly inputPrompt?: undefined;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n RunDispositionDeclaration<OutputSchema[\"Type\"], DispositionSchema>,\n undefined,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n InputPromptValue extends InputPromptSource<InputSchema[\"Type\"], unknown, unknown> | undefined,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n undefined,\n InputPromptValue,\n UpdatesSchema\n > & {\n readonly inputPrompt: InputPromptValue;\n readonly runDisposition?: undefined;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n undefined,\n InputPromptValue,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make<\n const Name extends string,\n InputSchema extends Schema.Top,\n OutputSchema extends Schema.Top,\n Instructions extends InstructionSource<InputSchema[\"Type\"], unknown, unknown>,\n ToolkitValue extends Toolkit.Any,\n UpdatesSchema extends Schema.Top | undefined = undefined,\n>(\n id: Name,\n options: DefinitionOptions<\n InputSchema,\n OutputSchema,\n Instructions,\n ToolkitValue,\n undefined,\n undefined,\n UpdatesSchema\n > & {\n readonly inputPrompt?: undefined;\n readonly runDisposition?: undefined;\n },\n): Definition<\n InputSchema,\n OutputSchema,\n Instructions,\n UpdateToolkit<ToolkitValue, NoInfer<UpdatesSchema>>,\n undefined,\n undefined,\n NoInfer<UpdatesSchema>\n> & { readonly id: AgentId & Name };\n\nexport function make(\n id: string,\n options: {\n readonly updates?: Schema.Top | undefined;\n readonly input: Schema.Top;\n readonly output: Schema.Top;\n readonly instructions: unknown;\n readonly inputPrompt?: unknown;\n readonly toolkit: Toolkit.Any;\n readonly toolExposure?: Configuration | undefined;\n readonly policy?: Partial<AgentPolicyInput> | undefined;\n readonly completion?: CompletionToolDeclaration | undefined;\n readonly completionFromTools?: ReadonlyArray<CompletionFromToolDeclaration> | undefined;\n readonly runDisposition?: RunDispositionDeclaration<never, Schema.Top> | undefined;\n readonly description?: string | undefined;\n readonly metadata?: Readonly<Record<string, string>> | undefined;\n },\n): AnyDefinition {\n const completionNames = new Set<string>();\n\n for (const declaration of options.completionFromTools ?? []) {\n if (declaration.tool === options.completion?.tool || completionNames.has(declaration.tool)) {\n throw new Error(`Tool ${declaration.tool} has more than one completion declaration`);\n }\n if (!Object.hasOwn(options.toolkit.tools, declaration.tool)) {\n throw new Error(`Unknown completion Tool ${declaration.tool}`);\n }\n completionNames.add(declaration.tool);\n }\n\n const tools = Object.values(options.toolkit.tools);\n\n const readonlyTools = tools.map((tool) =>\n Tool.isProviderDefined(tool) &&\n !tool.requiresHandler &&\n [\"web_search\", \"web_search_preview\", \"file_search\"].includes(tool.providerName)\n ? tool.annotate(Tool.Readonly, true)\n : tool,\n );\n\n const toolkit = readonlyTools.some((tool, index) => tool !== tools[index])\n ? Toolkit.make(...readonlyTools)\n : options.toolkit;\n\n return Object.freeze({\n ...options,\n toolkit: withUpdateTool(toolkit, options.updates),\n policy: AgentPolicy.resolve(options.policy),\n policyOverrides: Object.freeze({ ...options.policy }),\n toolExposure:\n options.toolExposure === undefined\n ? undefined\n : Object.freeze({\n ...options.toolExposure,\n initialToolNames: Object.freeze([...(options.toolExposure.initialToolNames ?? [])]),\n }),\n id: S.decodeSync(AgentId)(id),\n metadata: options.metadata === undefined ? undefined : Object.freeze({ ...options.metadata }),\n completion:\n options.completion === undefined ? undefined : Object.freeze({ ...options.completion }),\n completionFromTools:\n options.completionFromTools === undefined\n ? undefined\n : Object.freeze(\n options.completionFromTools.map((declaration) => Object.freeze({ ...declaration })),\n ),\n runDisposition:\n options.runDisposition === undefined\n ? undefined\n : Object.freeze({ ...options.runDisposition }),\n });\n}\n\n/** Bind a native model or thread resolver without acquiring or hiding its requirements. */\nexport const withModel = <DefinitionValue extends AnyDefinition, ModelValue>(\n definition: DefinitionValue,\n model: NativeModel<ModelValue>,\n): Binding<DefinitionValue, ModelValue> =>\n Object.freeze({\n definition,\n model,\n });\n"],"mappings":"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"}
|