agents 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -9
- package/dist/abortable-C1SpfVoi.js +21 -0
- package/dist/abortable-C1SpfVoi.js.map +1 -0
- package/dist/{agent-routing-0DR0Tk2v.d.ts → agent-routing-QDcchcQP.d.ts} +16 -16
- package/dist/agent-routing.d.ts +1 -1
- package/dist/agent-tool-types.d.ts +1 -1
- package/dist/{agent-tools-YrATZJu2.d.ts → agent-tools-DHL2XI7u.d.ts} +2 -2
- package/dist/agent-tools.d.ts +1 -1
- package/dist/ai-ahruGw7e.d.ts +239 -0
- package/dist/ai-sdk-Bdsf6mSA.js +2444 -0
- package/dist/ai-sdk-Bdsf6mSA.js.map +1 -0
- package/dist/apply-chunks-1FheRb9W.js +99 -0
- package/dist/apply-chunks-1FheRb9W.js.map +1 -0
- package/dist/broadcast-state-CEyI4uAK.js +69 -0
- package/dist/broadcast-state-CEyI4uAK.js.map +1 -0
- package/dist/browser/ai.d.ts +8 -227
- package/dist/browser/ai.js +259 -1
- package/dist/browser/ai.js.map +1 -0
- package/dist/browser/index.d.ts +56 -46
- package/dist/browser/index.js +4 -361
- package/dist/browser/{ai-sdk.d.ts → tools/ai-sdk.d.ts} +7 -7
- package/dist/browser/{ai-sdk.js → tools/ai-sdk.js} +6 -5
- package/dist/browser/tools/ai-sdk.js.map +1 -0
- package/dist/browser/tools/pi.d.ts +111 -0
- package/dist/browser/tools/pi.js +119 -0
- package/dist/browser/tools/pi.js.map +1 -0
- package/dist/browser/{tanstack-ai.d.ts → tools/tanstack-ai.d.ts} +39 -37
- package/dist/browser/{tanstack-ai.js → tools/tanstack-ai.js} +73 -59
- package/dist/browser/tools/tanstack-ai.js.map +1 -0
- package/dist/browser-CEdNlsaD.js +481 -0
- package/dist/browser-CEdNlsaD.js.map +1 -0
- package/dist/{browser-DE3d-RLk.d.ts → browser-D30VlpcA.d.ts} +63 -37
- package/dist/{browser-tool-CQ10e6Kj.js → browser-tool-4iomavs_.js} +198 -62
- package/dist/browser-tool-4iomavs_.js.map +1 -0
- package/dist/{browser-tool-DuNdlwZ9.d.ts → browser-tool-vtrPOV8e.d.ts} +25 -6
- package/dist/{capability-B4WbF81e.js → capability-DBAKc6UZ.js} +1 -3
- package/dist/capability-DBAKc6UZ.js.map +1 -0
- package/dist/{capability-runner-DBAnGr6L.d.ts → capability-runner-BiVUtjqC.d.ts} +9 -7
- package/dist/channel-Bak_6zDP.d.ts +333 -0
- package/dist/chat/index.d.ts +11 -9
- package/dist/chat/index.js +5 -194
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/react.d.ts +2 -4
- package/dist/chat/react.js +3 -1
- package/dist/chat/react.js.map +1 -1
- package/dist/chat-sdk/index.d.ts +1 -1
- package/dist/chat-sdk/index.js +1 -1
- package/dist/cli.js +144 -0
- package/dist/{client-je3koD9Z.d.ts → client-BGIQKJhX.d.ts} +2 -2
- package/dist/{client-fyQrLGkD.js → client-BnYbNT3z.js} +29 -5
- package/dist/client-BnYbNT3z.js.map +1 -0
- package/dist/client-tools-aIBO0Fk7.d.ts +53 -0
- package/dist/client.d.ts +1 -1
- package/dist/{connector-58XDGvc3.js → connector-CtZylXdk.js} +3 -603
- package/dist/connector-CtZylXdk.js.map +1 -0
- package/dist/{connector-Cl-VqPmA.d.ts → connector-DEXzVoaY.d.ts} +9 -374
- package/dist/conversations-FjHDRZyD.d.ts +192 -0
- package/dist/{current-agent-vAk_5JMt.d.ts → current-agent-CKgT5d1O.d.ts} +3 -5
- package/dist/current-agent-DhoDkSnH.js.map +1 -1
- package/dist/daemon-core-Buubj-y1.js +481 -0
- package/dist/daemon-core-Buubj-y1.js.map +1 -0
- package/dist/daemon-core-CbohVPAu.d.ts +132 -0
- package/dist/{do-oauth-client-provider-Tmf1vgKz.d.ts → do-oauth-client-provider-DfsUcpc3.d.ts} +7 -1
- package/dist/{durable-object-lifecycle-HhgOMWq9.d.ts → durable-object-lifecycle-DOI_bzCH.d.ts} +2 -2
- package/dist/{channels/email.d.ts → experimental/channels/email/index.d.ts} +25 -12
- package/dist/{channels/email.js → experimental/channels/email/index.js} +13 -35
- package/dist/experimental/channels/email/index.js.map +1 -0
- package/dist/experimental/channels/index.d.ts +270 -0
- package/dist/experimental/channels/index.js +1186 -0
- package/dist/experimental/channels/index.js.map +1 -0
- package/dist/{channels/slack.d.ts → experimental/channels/slack/index.d.ts} +19 -9
- package/dist/experimental/channels/slack/index.js +267 -0
- package/dist/experimental/channels/slack/index.js.map +1 -0
- package/dist/{channels/telegram.d.ts → experimental/channels/telegram/index.d.ts} +19 -9
- package/dist/experimental/channels/telegram/index.js +198 -0
- package/dist/experimental/channels/telegram/index.js.map +1 -0
- package/dist/experimental/channels/web/ai-sdk.d.ts +55 -0
- package/dist/experimental/channels/web/ai-sdk.js +266 -0
- package/dist/experimental/channels/web/ai-sdk.js.map +1 -0
- package/dist/experimental/channels/web/client.d.ts +97 -0
- package/dist/experimental/channels/web/client.js +349 -0
- package/dist/experimental/channels/web/client.js.map +1 -0
- package/dist/experimental/channels/web/index.d.ts +189 -0
- package/dist/experimental/channels/web/index.js +332 -0
- package/dist/experimental/channels/web/index.js.map +1 -0
- package/dist/gateway-BFO6vRDn.d.ts +100 -0
- package/dist/handle-zAzh0UW2.d.ts +460 -0
- package/dist/harness/ai-sdk/index.d.ts +175 -0
- package/dist/harness/ai-sdk/index.js +605 -0
- package/dist/harness/ai-sdk/index.js.map +1 -0
- package/dist/harness/container/daemon/index.d.ts +76 -0
- package/dist/harness/container/daemon/index.js +3 -0
- package/dist/harness/container/index.d.ts +740 -0
- package/dist/harness/container/index.js +2152 -0
- package/dist/harness/container/index.js.map +1 -0
- package/dist/harness/container/runtime/index.d.ts +144 -0
- package/dist/harness/container/runtime/index.js +1082 -0
- package/dist/harness/container/runtime/index.js.map +1 -0
- package/dist/harness/opencode/index.d.ts +369 -0
- package/dist/harness/opencode/index.js +1072 -0
- package/dist/harness/opencode/index.js.map +1 -0
- package/dist/harness/pi/index.d.ts +3 -2
- package/dist/harness/pi/index.js +3 -3
- package/dist/harness/store/index.d.ts +24 -0
- package/dist/harness/store/index.js +2 -0
- package/dist/harness/think/index.d.ts +821 -0
- package/dist/harness/think/index.js +2721 -0
- package/dist/harness/think/index.js.map +1 -0
- package/dist/harness-B6B9S3rb.d.ts +203 -0
- package/dist/{images-iiTDSyRu.js → images-Ce9SCu3X.js} +2 -248
- package/dist/images-Ce9SCu3X.js.map +1 -0
- package/dist/{index-BreL0YrQ.d.ts → index-BEL3ZV-s.d.ts} +2 -6
- package/dist/index-CBt8oRJt.d.ts +198 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/ingress-EFbrS547.js +9 -0
- package/dist/ingress-EFbrS547.js.map +1 -0
- package/dist/input-schema-BQykTEp_.js +20 -0
- package/dist/input-schema-BQykTEp_.js.map +1 -0
- package/dist/input-schema-D2QAtHZH.js +23 -0
- package/dist/input-schema-D2QAtHZH.js.map +1 -0
- package/dist/internal-kmw70xwR.js +46 -0
- package/dist/internal-kmw70xwR.js.map +1 -0
- package/dist/internal_context.d.ts +1 -1
- package/dist/lifecycle/index.d.ts +3 -3
- package/dist/lifecycle/index.js +2 -2
- package/dist/{lifecycle-CFu6OV03.js → lifecycle-DGorpAmA.js} +2 -4
- package/dist/lifecycle-DGorpAmA.js.map +1 -0
- package/dist/mcp/client/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/client/do-oauth-client-provider.js +9 -0
- package/dist/mcp/client/do-oauth-client-provider.js.map +1 -1
- package/dist/mcp/client/index.d.ts +1 -1
- package/dist/mcp/client/index.js +1 -1
- package/dist/mcp/client/x402.d.ts +35 -4
- package/dist/mcp/client/x402.js +24 -3
- package/dist/mcp/client/x402.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +2 -2
- package/dist/models/ai-sdk/index.d.ts +16 -14
- package/dist/models/ai-sdk/index.js +1 -2442
- package/dist/models/opencode/index.d.ts +65 -0
- package/dist/models/opencode/index.js +285 -0
- package/dist/models/opencode/index.js.map +1 -0
- package/dist/models/pi-ai/index.d.ts +9 -7
- package/dist/models/pi-ai/index.js +2 -1
- package/dist/models/pi-ai/index.js.map +1 -1
- package/dist/options-CiIsJHXR.d.ts +130 -0
- package/dist/protocol-BEgrJYC5.d.ts +331 -0
- package/dist/protocol-CukuI73M.d.ts +386 -0
- package/dist/protocol-cOklVBBD.js +227 -0
- package/dist/protocol-cOklVBBD.js.map +1 -0
- package/dist/{protocol-kHsr-f0X.js → protocol-eXeJxhgu.js} +2 -67
- package/dist/protocol-eXeJxhgu.js.map +1 -0
- package/dist/protocol-y2sSY584.js +148 -0
- package/dist/protocol-y2sSY584.js.map +1 -0
- package/dist/queue/index.d.ts +1 -1
- package/dist/queue/index.js +1 -1
- package/dist/{queue-BB-zfIYF.js → queue-CcIjVYTE.js} +2 -2
- package/dist/{queue-BB-zfIYF.js.map → queue-CcIjVYTE.js.map} +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/routing/index.d.ts +2 -2
- package/dist/routing/index.js +1 -1
- package/dist/{scheduler-RdACNXDP.d.ts → scheduler-BCLESHSC.d.ts} +2 -12
- package/dist/{scheduler-DZ3xQfeK.js → scheduler-FIHv2-kJ.js} +2 -4
- package/dist/scheduler-FIHv2-kJ.js.map +1 -0
- package/dist/schedules/index.d.ts +1 -1
- package/dist/schedules/index.js +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/session-store-Do4xkDcf.js +606 -0
- package/dist/session-store-Do4xkDcf.js.map +1 -0
- package/dist/session-store-DoPY12xM.d.ts +383 -0
- package/dist/sessions/index.d.ts +11 -434
- package/dist/sessions/index.js +1 -2271
- package/dist/sessions-_vN5BEZX.js +2272 -0
- package/dist/sessions-_vN5BEZX.js.map +1 -0
- package/dist/settings-C45hDliX.js +253 -0
- package/dist/settings-C45hDliX.js.map +1 -0
- package/dist/{transport-PfFnt-Ld.d.ts → settings-NgGwF7Qt.d.ts} +14 -208
- package/dist/{src-BZeu-SCD.js → src-CQxJFv4l.js} +8 -8
- package/dist/src-CQxJFv4l.js.map +1 -0
- package/dist/stall-watchdog-BpRF2uwG.js +195 -0
- package/dist/stall-watchdog-BpRF2uwG.js.map +1 -0
- package/dist/state/index.d.ts +1 -1
- package/dist/state/index.js +1 -3
- package/dist/state/index.js.map +1 -1
- package/dist/store-BKM4Xm9M.d.ts +332 -0
- package/dist/store-CslVzfN7.js +458 -0
- package/dist/store-CslVzfN7.js.map +1 -0
- package/dist/streams/index.d.ts +1 -1
- package/dist/streams/index.js +1 -1
- package/dist/{streams-DW-UCOUc.js → streams-lsHMJhRW.js} +17 -4
- package/dist/streams-lsHMJhRW.js.map +1 -0
- package/dist/{streams-Cmkj9QfW.d.ts → streams-vrCtbUIn.d.ts} +2 -2
- package/dist/sub-routing.d.ts +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/{tasks-68DESxf0.js → tasks-BN_5AWqI.js} +3 -2
- package/dist/tasks-BN_5AWqI.js.map +1 -0
- package/dist/{tasks-9YxYtByh.d.ts → tasks-E89KdwkS.d.ts} +2 -2
- package/dist/tool-CTp72Jb_.d.ts +278 -0
- package/dist/tool-CxKsvxjm.js +1126 -0
- package/dist/tool-CxKsvxjm.js.map +1 -0
- package/dist/tool-DoVberpN.d.ts +301 -0
- package/dist/tool-cQRkwSZZ.js +410 -0
- package/dist/tool-cQRkwSZZ.js.map +1 -0
- package/dist/tool-helpers-O5BDVEAY.js +58 -0
- package/dist/tool-helpers-O5BDVEAY.js.map +1 -0
- package/dist/transport-k2mFrtL8.d.ts +200 -0
- package/dist/turns-DCV3ycDl.js +317 -0
- package/dist/turns-DCV3ycDl.js.map +1 -0
- package/dist/voice/client.js +1 -1
- package/dist/voice/index.d.ts +2 -2
- package/dist/voice/index.js +1 -1
- package/dist/web/fetch/index.d.ts +89 -0
- package/dist/web/fetch/index.js +20 -0
- package/dist/web/fetch/index.js.map +1 -0
- package/dist/web/fetch/tools/ai-sdk.d.ts +80 -0
- package/dist/web/fetch/tools/ai-sdk.js +47 -0
- package/dist/web/fetch/tools/ai-sdk.js.map +1 -0
- package/dist/web/fetch/tools/pi.d.ts +84 -0
- package/dist/web/fetch/tools/pi.js +88 -0
- package/dist/web/fetch/tools/pi.js.map +1 -0
- package/dist/web/fetch/tools/tanstack-ai.d.ts +78 -0
- package/dist/web/fetch/tools/tanstack-ai.js +45 -0
- package/dist/web/fetch/tools/tanstack-ai.js.map +1 -0
- package/dist/web/search/index.d.ts +58 -0
- package/dist/web/search/index.js +2 -0
- package/dist/web/search/tools/ai-sdk.d.ts +77 -0
- package/dist/web/search/tools/ai-sdk.js +46 -0
- package/dist/web/search/tools/ai-sdk.js.map +1 -0
- package/dist/web/search/tools/pi.d.ts +82 -0
- package/dist/web/search/tools/pi.js +89 -0
- package/dist/web/search/tools/pi.js.map +1 -0
- package/dist/web/search/tools/tanstack-ai.d.ts +71 -0
- package/dist/web/search/tools/tanstack-ai.js +46 -0
- package/dist/web/search/tools/tanstack-ai.js.map +1 -0
- package/dist/websockets/index.d.ts +12 -296
- package/dist/websockets/index.js +1 -1
- package/dist/{websockets-Ci-LZFHH.js → websockets-C3zy8YR0.js} +20 -8
- package/dist/websockets-C3zy8YR0.js.map +1 -0
- package/dist/{wire-types-CrjKvDyi.d.ts → wire-types-Cv0iwjk5.d.ts} +3 -51
- package/dist/workflow-types.d.ts +1 -1
- package/dist/workflows.d.ts +1 -1
- package/dist/workflows.js +1 -1
- package/docs/browse-the-web.md +29 -1
- package/docs/fetch-the-web.md +276 -0
- package/docs/harnesses/pi.md +25 -0
- package/docs/harnesses/think.md +215 -0
- package/docs/index.md +99 -75
- package/docs/lifecycle.md +42 -3
- package/docs/queue.md +2 -3
- package/docs/scheduling.md +2 -6
- package/docs/search-the-web.md +135 -0
- package/package.json +148 -44
- package/dist/ai-fm7xx1BK.js +0 -312
- package/dist/ai-fm7xx1BK.js.map +0 -1
- package/dist/browser/ai-sdk.js.map +0 -1
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/tanstack-ai.js.map +0 -1
- package/dist/browser-tool-CQ10e6Kj.js.map +0 -1
- package/dist/capability-B4WbF81e.js.map +0 -1
- package/dist/channel-Bnm4S7T2.d.ts +0 -491
- package/dist/channels/ai-sdk.d.ts +0 -46
- package/dist/channels/ai-sdk.js +0 -120
- package/dist/channels/ai-sdk.js.map +0 -1
- package/dist/channels/email.js.map +0 -1
- package/dist/channels/index.d.ts +0 -233
- package/dist/channels/index.js +0 -608
- package/dist/channels/index.js.map +0 -1
- package/dist/channels/slack.js +0 -614
- package/dist/channels/slack.js.map +0 -1
- package/dist/channels/tanstack-ai.d.ts +0 -39
- package/dist/channels/tanstack-ai.js +0 -17
- package/dist/channels/tanstack-ai.js.map +0 -1
- package/dist/channels/telegram.js +0 -427
- package/dist/channels/telegram.js.map +0 -1
- package/dist/channels/voice.d.ts +0 -45
- package/dist/channels/voice.js +0 -122
- package/dist/channels/voice.js.map +0 -1
- package/dist/client-fyQrLGkD.js.map +0 -1
- package/dist/connector-58XDGvc3.js.map +0 -1
- package/dist/images-iiTDSyRu.js.map +0 -1
- package/dist/index-BB0kqhIz.d.ts +0 -101
- package/dist/ingress-BfetZbMO.js +0 -83
- package/dist/ingress-BfetZbMO.js.map +0 -1
- package/dist/internal-CYlgHl1l.js +0 -59
- package/dist/internal-CYlgHl1l.js.map +0 -1
- package/dist/lifecycle-CFu6OV03.js.map +0 -1
- package/dist/models/ai-sdk/index.js.map +0 -1
- package/dist/protocol-kHsr-f0X.js.map +0 -1
- package/dist/scheduler-DZ3xQfeK.js.map +0 -1
- package/dist/sessions/index.js.map +0 -1
- package/dist/src-BZeu-SCD.js.map +0 -1
- package/dist/streams-DW-UCOUc.js.map +0 -1
- package/dist/surface-bZZJqBka.js +0 -17
- package/dist/surface-bZZJqBka.js.map +0 -1
- package/dist/tasks-68DESxf0.js.map +0 -1
- package/dist/tool-schema-CBjGPrsQ.js +0 -31
- package/dist/tool-schema-CBjGPrsQ.js.map +0 -1
- package/dist/websockets-Ci-LZFHH.js.map +0 -1
- package/docs/channels.md +0 -323
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import {
|
|
2
|
+
_ as TranscriptMessage,
|
|
3
|
+
l as Json,
|
|
4
|
+
m as ResponseChunk
|
|
5
|
+
} from "./protocol-CukuI73M.js";
|
|
6
|
+
|
|
7
|
+
//#region src/experimental/channels/harness.d.ts
|
|
8
|
+
type SessionId = string;
|
|
9
|
+
/** One agent harness hosted in a Durable Object. */
|
|
10
|
+
interface AgentHarness {
|
|
11
|
+
readonly sessions: HarnessSessions;
|
|
12
|
+
/** A handle on one session. Without an id, the harness's default session. */
|
|
13
|
+
session(id?: SessionId): HarnessSession;
|
|
14
|
+
}
|
|
15
|
+
interface HarnessSessions {
|
|
16
|
+
create(): Promise<HarnessSession>;
|
|
17
|
+
/** A new session that sees `from`'s history so far. */
|
|
18
|
+
fork(from: SessionId): Promise<HarnessSession>;
|
|
19
|
+
list(): Promise<SessionInfo[]>;
|
|
20
|
+
}
|
|
21
|
+
type SessionInfo = {
|
|
22
|
+
readonly id: SessionId;
|
|
23
|
+
readonly parent?: SessionId;
|
|
24
|
+
readonly busy: boolean;
|
|
25
|
+
};
|
|
26
|
+
interface HarnessSession {
|
|
27
|
+
readonly id: SessionId;
|
|
28
|
+
/** A harness that takes no tool answers rejects them. */
|
|
29
|
+
submit(
|
|
30
|
+
input: (HarnessInput | ToolAnswer) & HarnessInputFrom,
|
|
31
|
+
options?: SubmitOptions
|
|
32
|
+
): Promise<Receipt>;
|
|
33
|
+
/** Stop one operation, or, without an id, everything in the session. */
|
|
34
|
+
abort(operationId?: string): Promise<boolean>;
|
|
35
|
+
wait(operationId: string, signal?: AbortSignal): Promise<OperationResult>;
|
|
36
|
+
/** Start a new context, optionally from a handoff note. */
|
|
37
|
+
reset(handoff?: string): Promise<void>;
|
|
38
|
+
/** The current state, then every change, in order. */
|
|
39
|
+
watch(): Promise<SessionWatch>;
|
|
40
|
+
}
|
|
41
|
+
type InputPart =
|
|
42
|
+
| {
|
|
43
|
+
readonly type: "text";
|
|
44
|
+
readonly text: string;
|
|
45
|
+
}
|
|
46
|
+
| {
|
|
47
|
+
readonly type: "file";
|
|
48
|
+
readonly mediaType: string;
|
|
49
|
+
readonly url: string;
|
|
50
|
+
readonly filename?: string;
|
|
51
|
+
};
|
|
52
|
+
type HarnessInput = {
|
|
53
|
+
readonly parts: readonly InputPart[];
|
|
54
|
+
/**
|
|
55
|
+
* The caller's id for the user message this places. Default: the
|
|
56
|
+
* operation id.
|
|
57
|
+
*/
|
|
58
|
+
readonly messageId?: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Who sent an input, once a conversation has several participants. (From the
|
|
62
|
+
* "later" draft, adopted early: a client tool's result is taken only from
|
|
63
|
+
* the participant whose client runs it.)
|
|
64
|
+
*/
|
|
65
|
+
type HarnessInputFrom = {
|
|
66
|
+
readonly from?: {
|
|
67
|
+
readonly participantId: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* A reply to something the agent asked for. Like a message, it makes the
|
|
72
|
+
* agent act, so it is submitted, queued, deduplicated and settled as an
|
|
73
|
+
* operation. (From the "later" draft, adopted early.)
|
|
74
|
+
*/
|
|
75
|
+
type ToolAnswer =
|
|
76
|
+
| {
|
|
77
|
+
readonly type: "approval";
|
|
78
|
+
readonly approvalId: string;
|
|
79
|
+
readonly approved: boolean;
|
|
80
|
+
readonly reason?: string;
|
|
81
|
+
}
|
|
82
|
+
| {
|
|
83
|
+
readonly type: "tool-result";
|
|
84
|
+
readonly toolCallId: string;
|
|
85
|
+
readonly result:
|
|
86
|
+
| {
|
|
87
|
+
readonly ok: true;
|
|
88
|
+
readonly output: Json;
|
|
89
|
+
}
|
|
90
|
+
| {
|
|
91
|
+
readonly ok: false;
|
|
92
|
+
readonly errorText?: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
type SubmitOptions = {
|
|
96
|
+
/** Idempotency key. Submitting the same id twice returns the same receipt. */ readonly operationId?: string;
|
|
97
|
+
readonly whenBusy?: "followUp" | "steer";
|
|
98
|
+
};
|
|
99
|
+
type Receipt = {
|
|
100
|
+
readonly operationId: string;
|
|
101
|
+
readonly session: SessionId /** False when this operation id was already submitted. */;
|
|
102
|
+
readonly accepted: boolean;
|
|
103
|
+
};
|
|
104
|
+
type OperationStatus =
|
|
105
|
+
| {
|
|
106
|
+
readonly operationId: string;
|
|
107
|
+
readonly status: "queued";
|
|
108
|
+
}
|
|
109
|
+
| {
|
|
110
|
+
readonly operationId: string;
|
|
111
|
+
readonly status: "placed";
|
|
112
|
+
}
|
|
113
|
+
| {
|
|
114
|
+
readonly operationId: string;
|
|
115
|
+
readonly status: "done";
|
|
116
|
+
readonly text?: string;
|
|
117
|
+
}
|
|
118
|
+
| {
|
|
119
|
+
readonly operationId: string;
|
|
120
|
+
readonly status: "unanswered";
|
|
121
|
+
readonly reason?: string;
|
|
122
|
+
};
|
|
123
|
+
type OperationResult = Extract<
|
|
124
|
+
OperationStatus,
|
|
125
|
+
| {
|
|
126
|
+
status: "done";
|
|
127
|
+
}
|
|
128
|
+
| {
|
|
129
|
+
status: "unanswered";
|
|
130
|
+
}
|
|
131
|
+
> & {
|
|
132
|
+
readonly session: SessionId;
|
|
133
|
+
};
|
|
134
|
+
type SessionWatch = {
|
|
135
|
+
readonly state: SessionState;
|
|
136
|
+
start(listener: (events: readonly SessionEvent[]) => Promise<void>): void;
|
|
137
|
+
stop(): Promise<void> /** Settles when the watch ends, stopped or not. */;
|
|
138
|
+
readonly closed: Promise<void>;
|
|
139
|
+
};
|
|
140
|
+
/** Resume is from state: no event log, no cursors. */
|
|
141
|
+
type SessionState = {
|
|
142
|
+
/** The active transcript, since the newest reset. */ readonly messages: readonly TranscriptMessage[] /** Operations not settled yet, oldest first. */;
|
|
143
|
+
readonly pending: readonly OperationStatus[] /** The run in progress, with its in-flight message. */;
|
|
144
|
+
readonly run?: {
|
|
145
|
+
readonly operations: readonly string[];
|
|
146
|
+
/**
|
|
147
|
+
* The in-flight message so far, as chunks, with parts still streaming
|
|
148
|
+
* left open. The watch's `chunk` events continue these parts. (The first
|
|
149
|
+
* draft had a `TranscriptMessage` here, which later chunks could not
|
|
150
|
+
* continue without showing the message twice.)
|
|
151
|
+
*/
|
|
152
|
+
readonly partial?: readonly ResponseChunk[];
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
type SessionEvent =
|
|
156
|
+
| {
|
|
157
|
+
readonly type: "operation";
|
|
158
|
+
readonly status: OperationStatus;
|
|
159
|
+
}
|
|
160
|
+
| {
|
|
161
|
+
readonly type: "run-start";
|
|
162
|
+
readonly operations: readonly string[];
|
|
163
|
+
}
|
|
164
|
+
| {
|
|
165
|
+
readonly type: "run-end";
|
|
166
|
+
readonly operations: readonly string[];
|
|
167
|
+
} /** A streamed delta of the in-flight message. Part ids are unique per run. */
|
|
168
|
+
| {
|
|
169
|
+
readonly type: "chunk";
|
|
170
|
+
readonly chunk: ResponseChunk;
|
|
171
|
+
} /** A message saved to the transcript; replaces any message with its id. */
|
|
172
|
+
| {
|
|
173
|
+
readonly type: "message";
|
|
174
|
+
readonly message: TranscriptMessage;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The context was reset. Not in the first draft: without it a watcher
|
|
178
|
+
* could not tell the active transcript restarted. Messages that follow
|
|
179
|
+
* belong to the new context.
|
|
180
|
+
*/
|
|
181
|
+
| {
|
|
182
|
+
readonly type: "reset";
|
|
183
|
+
};
|
|
184
|
+
//#endregion
|
|
185
|
+
export {
|
|
186
|
+
HarnessSessions as a,
|
|
187
|
+
OperationStatus as c,
|
|
188
|
+
SessionId as d,
|
|
189
|
+
SessionInfo as f,
|
|
190
|
+
ToolAnswer as g,
|
|
191
|
+
SubmitOptions as h,
|
|
192
|
+
HarnessSession as i,
|
|
193
|
+
Receipt as l,
|
|
194
|
+
SessionWatch as m,
|
|
195
|
+
HarnessInput as n,
|
|
196
|
+
InputPart as o,
|
|
197
|
+
SessionState as p,
|
|
198
|
+
HarnessInputFrom as r,
|
|
199
|
+
OperationResult as s,
|
|
200
|
+
AgentHarness as t,
|
|
201
|
+
SessionEvent as u
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=harness-B6B9S3rb.d.ts.map
|
|
@@ -125,252 +125,6 @@ function normalizeThrownError(error, context) {
|
|
|
125
125
|
url: context.url
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
/** Key that per-call options live under in a framework's per-call options bag. */
|
|
129
|
-
const PROVIDER_OPTIONS_KEY = "cloudflare";
|
|
130
|
-
/** The id legs of a fallback list; model objects are their module's business. */
|
|
131
|
-
function idLegs(fallback) {
|
|
132
|
-
return (fallback ?? []).filter((leg) => typeof leg === "string");
|
|
133
|
-
}
|
|
134
|
-
/** Strips `undefined` values so a later layer never blanks an earlier one. */
|
|
135
|
-
function defined(value) {
|
|
136
|
-
const result = {};
|
|
137
|
-
for (const [key, entry] of Object.entries(value)) if (entry !== void 0) result[key] = entry;
|
|
138
|
-
return result;
|
|
139
|
-
}
|
|
140
|
-
function normalizeGateway(gateway) {
|
|
141
|
-
if (gateway === void 0) return {};
|
|
142
|
-
return typeof gateway === "string" ? { id: gateway } : defined(gateway);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Folds one layer's flat gateway sugar into its `gateway` object. The flat key
|
|
146
|
-
* wins over the nested one, and an explicit `undefined` on either never blanks
|
|
147
|
-
* a lower layer.
|
|
148
|
-
*/
|
|
149
|
-
function layerGateway(options) {
|
|
150
|
-
if (options === void 0) return {};
|
|
151
|
-
return {
|
|
152
|
-
...normalizeGateway(options.gateway),
|
|
153
|
-
...defined({
|
|
154
|
-
cacheKey: options.cacheKey,
|
|
155
|
-
cacheTtl: options.cacheTtl,
|
|
156
|
-
collectLog: options.collectLog,
|
|
157
|
-
eventId: options.eventId,
|
|
158
|
-
id: options.id,
|
|
159
|
-
metadata: options.metadata,
|
|
160
|
-
requestTimeoutMs: options.requestTimeoutMs,
|
|
161
|
-
retries: options.retries,
|
|
162
|
-
skipCache: options.skipCache
|
|
163
|
-
})
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/** The flat gateway sugar {@link layerGateway} folds into `gateway`. */
|
|
167
|
-
const FLAT_GATEWAY_KEYS = [
|
|
168
|
-
"cacheKey",
|
|
169
|
-
"cacheTtl",
|
|
170
|
-
"collectLog",
|
|
171
|
-
"eventId",
|
|
172
|
-
"gateway",
|
|
173
|
-
"id",
|
|
174
|
-
"metadata",
|
|
175
|
-
"requestTimeoutMs",
|
|
176
|
-
"retries",
|
|
177
|
-
"skipCache"
|
|
178
|
-
];
|
|
179
|
-
/**
|
|
180
|
-
* One layer's gateway options as a single object, both spellings folded in.
|
|
181
|
-
* Exported so a module that collapses two option layers into one bag (a
|
|
182
|
-
* fallback leg inheriting a chain's gateway) can merge them field by field
|
|
183
|
-
* rather than replacing one object with the other.
|
|
184
|
-
*
|
|
185
|
-
* @experimental This surface is experimental and may change.
|
|
186
|
-
*/
|
|
187
|
-
function gatewayLayerOf(options) {
|
|
188
|
-
return layerGateway(options);
|
|
189
|
-
}
|
|
190
|
-
/** An option bag without the gateway keys, whichever spelling they used. */
|
|
191
|
-
function withoutGatewayKeys(options) {
|
|
192
|
-
const rest = { ...options };
|
|
193
|
-
for (const key of FLAT_GATEWAY_KEYS) delete rest[key];
|
|
194
|
-
return defined(rest);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Collapses two option layers into one bag, `override` winning field by field.
|
|
198
|
-
*
|
|
199
|
-
* The gateway keys of both are folded into a single `gateway` object, so
|
|
200
|
-
* neither layer's flat sugar can out-rank the other's nested spelling when the
|
|
201
|
-
* bag is resolved later, and `metadata` merges rather than replaces — the same
|
|
202
|
-
* rules {@link resolveOptions} applies across its three layers.
|
|
203
|
-
*
|
|
204
|
-
* @experimental This surface is experimental and may change.
|
|
205
|
-
*/
|
|
206
|
-
function mergeModelOptions(base, override) {
|
|
207
|
-
if (base === void 0) return override;
|
|
208
|
-
if (override === void 0) return base;
|
|
209
|
-
const layers = [layerGateway(base), layerGateway(override)];
|
|
210
|
-
const gateway = Object.assign({}, ...layers);
|
|
211
|
-
const metadata = Object.assign({}, ...layers.map((layer) => layer.metadata));
|
|
212
|
-
const retries = mergeRetries(layers);
|
|
213
|
-
const headers = {
|
|
214
|
-
...base.headers,
|
|
215
|
-
...override.headers
|
|
216
|
-
};
|
|
217
|
-
return {
|
|
218
|
-
...withoutGatewayKeys(base),
|
|
219
|
-
...withoutGatewayKeys(override),
|
|
220
|
-
...Object.keys(headers).length > 0 ? { headers } : {},
|
|
221
|
-
gateway: {
|
|
222
|
-
...gateway,
|
|
223
|
-
...Object.keys(metadata).length > 0 ? { metadata } : {},
|
|
224
|
-
...retries === void 0 ? {} : { retries }
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Merges the retry policies field by field, so a provider-wide `backoff` still
|
|
230
|
-
* applies when a call only sets `maxAttempts`. `undefined` on any layer means
|
|
231
|
-
* "not set" and never blanks a lower one.
|
|
232
|
-
*/
|
|
233
|
-
function mergeRetries(layers) {
|
|
234
|
-
const merged = layers.reduce((result, layer) => ({
|
|
235
|
-
...result,
|
|
236
|
-
...layer.retries === void 0 ? {} : defined(layer.retries)
|
|
237
|
-
}), {});
|
|
238
|
-
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Merges the option layers. Precedence is per-call
|
|
242
|
-
* (`providerOptions.cloudflare`) > per-model (`ai(id, options)`) >
|
|
243
|
-
* provider (`createAI({ ... })`).
|
|
244
|
-
*
|
|
245
|
-
* The provider layer takes the whole settings object as well as a bare
|
|
246
|
-
* `gateway` value, so `createAI({ binding, id: "prod", cacheTtl: 60 })` reads
|
|
247
|
-
* the same as `createAI({ binding, gateway: { id: "prod", cacheTtl: 60 } })`.
|
|
248
|
-
*
|
|
249
|
-
* @experimental This surface is experimental and may change.
|
|
250
|
-
*/
|
|
251
|
-
function resolveOptions(provider, model, call) {
|
|
252
|
-
const layers = typeof provider === "string" ? [
|
|
253
|
-
normalizeGateway(provider),
|
|
254
|
-
layerGateway(model),
|
|
255
|
-
layerGateway(call)
|
|
256
|
-
] : [
|
|
257
|
-
layerGateway(provider),
|
|
258
|
-
layerGateway(model),
|
|
259
|
-
layerGateway(call)
|
|
260
|
-
];
|
|
261
|
-
const gateway = Object.assign({}, ...layers);
|
|
262
|
-
const metadata = Object.assign({}, ...layers.map((layer) => layer.metadata));
|
|
263
|
-
const retries = mergeRetries(layers);
|
|
264
|
-
return {
|
|
265
|
-
chatTemplateKwargs: call?.chatTemplateKwargs ?? model?.chatTemplateKwargs,
|
|
266
|
-
fallback: idLegs(call?.fallback ?? model?.fallback),
|
|
267
|
-
gateway: {
|
|
268
|
-
...gateway,
|
|
269
|
-
id: gateway.id ?? "default",
|
|
270
|
-
...Object.keys(metadata).length > 0 ? { metadata } : {},
|
|
271
|
-
...retries === void 0 ? {} : { retries }
|
|
272
|
-
},
|
|
273
|
-
headers: {
|
|
274
|
-
...model?.headers,
|
|
275
|
-
...call?.headers
|
|
276
|
-
},
|
|
277
|
-
reasoningEffort: call?.reasoningEffort !== void 0 ? call.reasoningEffort : model?.reasoningEffort,
|
|
278
|
-
sessionAffinity: call?.sessionAffinity ?? model?.sessionAffinity
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
function asRecord(value) {
|
|
282
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
283
|
-
}
|
|
284
|
-
function asStringRecord(value) {
|
|
285
|
-
const record = asRecord(value);
|
|
286
|
-
if (record === void 0) return void 0;
|
|
287
|
-
const result = {};
|
|
288
|
-
for (const [key, entry] of Object.entries(record)) if (typeof entry === "string") result[key] = entry;
|
|
289
|
-
return result;
|
|
290
|
-
}
|
|
291
|
-
function asString(value) {
|
|
292
|
-
return typeof value === "string" ? value : void 0;
|
|
293
|
-
}
|
|
294
|
-
function asNumber(value) {
|
|
295
|
-
return typeof value === "number" ? value : void 0;
|
|
296
|
-
}
|
|
297
|
-
function asBoolean(value) {
|
|
298
|
-
return typeof value === "boolean" ? value : void 0;
|
|
299
|
-
}
|
|
300
|
-
function asReasoningEffort(value) {
|
|
301
|
-
if (value === null) return null;
|
|
302
|
-
if (value === "low" || value === "medium" || value === "high") return value;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Metadata values the gateway accepts are scalars only; a nested object or
|
|
306
|
-
* array would be rejected by the binding, so drop those rather than forward
|
|
307
|
-
* them.
|
|
308
|
-
*/
|
|
309
|
-
function asMetadata(value) {
|
|
310
|
-
const record = asRecord(value);
|
|
311
|
-
if (record === void 0) return void 0;
|
|
312
|
-
const result = {};
|
|
313
|
-
for (const [key, entry] of Object.entries(record)) if (entry === null || typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean") result[key] = entry;
|
|
314
|
-
return result;
|
|
315
|
-
}
|
|
316
|
-
const BACKOFFS = [
|
|
317
|
-
"constant",
|
|
318
|
-
"linear",
|
|
319
|
-
"exponential"
|
|
320
|
-
];
|
|
321
|
-
/** Reads the retry policy field by field; the binding validates it strictly. */
|
|
322
|
-
function asRetries(value) {
|
|
323
|
-
const record = asRecord(value);
|
|
324
|
-
if (record === void 0) return void 0;
|
|
325
|
-
const maxAttempts = asNumber(record.maxAttempts);
|
|
326
|
-
const backoff = asString(record.backoff);
|
|
327
|
-
const retries = defined({
|
|
328
|
-
backoff: BACKOFFS.find((entry) => entry === backoff),
|
|
329
|
-
maxAttempts: maxAttempts !== void 0 && Number.isInteger(maxAttempts) && maxAttempts >= 1 && maxAttempts <= 5 ? maxAttempts : void 0,
|
|
330
|
-
retryDelayMs: asNumber(record.retryDelayMs)
|
|
331
|
-
});
|
|
332
|
-
return Object.keys(retries).length > 0 ? retries : void 0;
|
|
333
|
-
}
|
|
334
|
-
/** Reads the shared gateway keys out of a loosely-typed record. */
|
|
335
|
-
function parseGatewayFields(raw) {
|
|
336
|
-
return defined({
|
|
337
|
-
cacheKey: asString(raw.cacheKey),
|
|
338
|
-
cacheTtl: asNumber(raw.cacheTtl),
|
|
339
|
-
collectLog: asBoolean(raw.collectLog),
|
|
340
|
-
eventId: asString(raw.eventId),
|
|
341
|
-
id: asString(raw.id),
|
|
342
|
-
metadata: asMetadata(raw.metadata),
|
|
343
|
-
requestTimeoutMs: asNumber(raw.requestTimeoutMs),
|
|
344
|
-
retries: asRetries(raw.retries),
|
|
345
|
-
skipCache: asBoolean(raw.skipCache)
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Reads per-call options out of a loosely-typed options bag (the value a
|
|
350
|
-
* framework keeps under {@link PROVIDER_OPTIONS_KEY}).
|
|
351
|
-
*
|
|
352
|
-
* The bag is plain JSON, so every field is read defensively: anything of an
|
|
353
|
-
* unexpected type is dropped rather than thrown, because a malformed
|
|
354
|
-
* observability hint should never fail a generation.
|
|
355
|
-
*
|
|
356
|
-
* @experimental This surface is experimental and may change.
|
|
357
|
-
*/
|
|
358
|
-
function parseModelOptions(value) {
|
|
359
|
-
const raw = asRecord(value);
|
|
360
|
-
if (raw === void 0) return void 0;
|
|
361
|
-
const nested = asRecord(raw.gateway);
|
|
362
|
-
const gateway = typeof raw.gateway === "string" ? raw.gateway : nested !== void 0 ? parseGatewayFields(nested) : void 0;
|
|
363
|
-
const fallback = Array.isArray(raw.fallback) ? raw.fallback.filter((entry) => typeof entry === "string") : void 0;
|
|
364
|
-
return defined({
|
|
365
|
-
...parseGatewayFields(raw),
|
|
366
|
-
chatTemplateKwargs: asRecord(raw.chatTemplateKwargs),
|
|
367
|
-
fallback,
|
|
368
|
-
gateway,
|
|
369
|
-
headers: asStringRecord(raw.headers),
|
|
370
|
-
reasoningEffort: asReasoningEffort(raw.reasoningEffort),
|
|
371
|
-
sessionAffinity: asString(raw.sessionAffinity)
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
128
|
//#endregion
|
|
375
129
|
//#region src/models/core/transport.ts
|
|
376
130
|
/** The reported `url` for a universal call made through the binding. */
|
|
@@ -1626,6 +1380,6 @@ function imageMediaTypeOf(base64) {
|
|
|
1626
1380
|
return "image/png";
|
|
1627
1381
|
}
|
|
1628
1382
|
//#endregion
|
|
1629
|
-
export {
|
|
1383
|
+
export { isRetryableStatus as S, isGatewayErrorEnvelope as _, normalizeChatCompletion as a, classifyStatus as b, gatewaySlugForBaseUrl as c, resolveGatewayProvider as d, createTransport as f, headersToObject as g, errorFromResponse as h, normalizeChatCompletionsStream as i, isGatewayShapedUrl as l, errorFromGatewayEnvelope as m, imageMediaTypeOf as n, prepareChatCompletionsRequest as o, definedHeaders as p, sseDataStream as r, GATEWAY_PROVIDER_NAMES as s, buildImageInput as t, requireGatewayProvider as u, unwrapEnvelope as v, isAbortError as x, CloudflareAIError as y };
|
|
1630
1384
|
|
|
1631
|
-
//# sourceMappingURL=images-
|
|
1385
|
+
//# sourceMappingURL=images-Ce9SCu3X.js.map
|