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,192 @@
|
|
|
1
|
+
import { s as LifecycleCapability } from "./capability-runner-BiVUtjqC.js";
|
|
2
|
+
import { n as Streams } from "./streams-vrCtbUIn.js";
|
|
3
|
+
import {
|
|
4
|
+
_ as TranscriptMessage,
|
|
5
|
+
a as DispatchResult,
|
|
6
|
+
b as ChannelMessageSurface,
|
|
7
|
+
c as InboundEvent,
|
|
8
|
+
i as ConversationSnapshot,
|
|
9
|
+
m as ResponseChunk,
|
|
10
|
+
n as ConversationInfo,
|
|
11
|
+
o as EventOrigin,
|
|
12
|
+
r as ConversationOperation,
|
|
13
|
+
s as GatewayOrigin,
|
|
14
|
+
y as TurnStatus
|
|
15
|
+
} from "./protocol-CukuI73M.js";
|
|
16
|
+
import { i as WebSockets } from "./index-CBt8oRJt.js";
|
|
17
|
+
import { t as AgentHarness } from "./harness-B6B9S3rb.js";
|
|
18
|
+
|
|
19
|
+
//#region src/experimental/channels/conversations.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* An inbound event as the gateway sends it. An approval response from a
|
|
22
|
+
* webhook names no turn; Channels finds it from the conversation snapshot.
|
|
23
|
+
*/
|
|
24
|
+
type GatewayEvent =
|
|
25
|
+
| InboundEvent
|
|
26
|
+
| Omit<
|
|
27
|
+
Extract<
|
|
28
|
+
InboundEvent,
|
|
29
|
+
{
|
|
30
|
+
type: "approval-response";
|
|
31
|
+
}
|
|
32
|
+
>,
|
|
33
|
+
"turnId"
|
|
34
|
+
>;
|
|
35
|
+
/** How a response finished, as a reader sees it. */
|
|
36
|
+
type ResponseEnding = "ended" | "interrupted" | "not-found";
|
|
37
|
+
/** A change Channels pushes to every channel showing a conversation. */
|
|
38
|
+
type ConversationUpdate =
|
|
39
|
+
| {
|
|
40
|
+
type: "turn";
|
|
41
|
+
turn: TurnStatus;
|
|
42
|
+
}
|
|
43
|
+
| {
|
|
44
|
+
type: "messages";
|
|
45
|
+
messages: TranscriptMessage[] /** Set when the messages arrived as an inbound event. */;
|
|
46
|
+
origin?: EventOrigin /** The inbound event's id, set with `origin`. */;
|
|
47
|
+
eventId?: string;
|
|
48
|
+
}
|
|
49
|
+
| {
|
|
50
|
+
type: "reset";
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
type: "response-end";
|
|
54
|
+
responseId: string;
|
|
55
|
+
ending: ResponseEnding;
|
|
56
|
+
};
|
|
57
|
+
type ResponseReadOptions = {
|
|
58
|
+
from?: number;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
onChunks(
|
|
61
|
+
from: number,
|
|
62
|
+
chunks: ResponseChunk[]
|
|
63
|
+
): void /** Everything recorded so far has been read; what follows is live. */;
|
|
64
|
+
onCaughtUp(cursor: number): void;
|
|
65
|
+
};
|
|
66
|
+
/** Durable state a channel keeps in the agent, private to that channel. */
|
|
67
|
+
type ChannelState = {
|
|
68
|
+
get<T>(key: string): T | undefined;
|
|
69
|
+
put(key: string, value: unknown): void;
|
|
70
|
+
delete(key: string): void;
|
|
71
|
+
};
|
|
72
|
+
/** What Channels gives a mounted channel. */
|
|
73
|
+
type ChannelsHost = {
|
|
74
|
+
readonly channelKey: string;
|
|
75
|
+
/**
|
|
76
|
+
* The WebSockets this Channels' channels share: the instance Channels was
|
|
77
|
+
* given, or else the one the first channel to ask creates. Install it with
|
|
78
|
+
* `Lifecycle.use(channels.websockets)`.
|
|
79
|
+
*/
|
|
80
|
+
websockets(
|
|
81
|
+
create: () => WebSockets
|
|
82
|
+
): WebSockets /** This channel's surfaces that have joined the conversation. */;
|
|
83
|
+
surfaces(conversationId: string): Promise<ChannelMessageSurface[]>;
|
|
84
|
+
readonly state: ChannelState;
|
|
85
|
+
snapshot(
|
|
86
|
+
conversationId: string
|
|
87
|
+
): Promise<ConversationSnapshot> /** The conversation a surface joins when it names none. */;
|
|
88
|
+
defaultConversation(): string /** The conversation operations the agent supports. */;
|
|
89
|
+
readonly operations: readonly ConversationOperation[] /** The agent's conversations. */;
|
|
90
|
+
listConversations(): Promise<ConversationInfo[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Deliver an event to the agent. Resolves once the agent accepted it and
|
|
93
|
+
* rejects if the agent threw.
|
|
94
|
+
*/
|
|
95
|
+
dispatch(event: InboundEvent, origin: EventOrigin): Promise<DispatchResult>;
|
|
96
|
+
readResponse(
|
|
97
|
+
conversationId: string,
|
|
98
|
+
responseId: string,
|
|
99
|
+
options: ResponseReadOptions
|
|
100
|
+
): Promise<ResponseEnding>;
|
|
101
|
+
};
|
|
102
|
+
/** An interface that shows conversations, such as the Web Channel. */
|
|
103
|
+
interface ConversationChannel {
|
|
104
|
+
/** Called once, when Channels is constructed. Take shared dependencies here. */
|
|
105
|
+
mount(host: ChannelsHost): void;
|
|
106
|
+
publish(
|
|
107
|
+
conversationId: string,
|
|
108
|
+
update: ConversationUpdate
|
|
109
|
+
): void | Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
type ChannelsOptions = {
|
|
112
|
+
/**
|
|
113
|
+
* The agent: its sessions are served as conversations, a conversation's
|
|
114
|
+
* id being its session's id.
|
|
115
|
+
*/
|
|
116
|
+
harness: AgentHarness /** Install it before Channels. */;
|
|
117
|
+
streams: Streams /** Shared with channels that serve WebSockets, such as the Web Channel. */;
|
|
118
|
+
websockets?: WebSockets;
|
|
119
|
+
channels: Record<string, ConversationChannel>;
|
|
120
|
+
};
|
|
121
|
+
type ForHarnessOptions = {
|
|
122
|
+
channels: Record<
|
|
123
|
+
string,
|
|
124
|
+
ConversationChannel
|
|
125
|
+
> /** Default: a new Streams, exposed as `channels.streams`. */;
|
|
126
|
+
streams?: Streams /** Default: one the Web Channel creates, exposed as `channels.websockets`. */;
|
|
127
|
+
websockets?: WebSockets;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Serves an agent harness's sessions as conversations: carries inbound
|
|
131
|
+
* events to the harness, and responses, turn statuses and transcript
|
|
132
|
+
* updates back to every channel showing the conversation.
|
|
133
|
+
*/
|
|
134
|
+
declare class Channels extends LifecycleCapability {
|
|
135
|
+
#private;
|
|
136
|
+
/**
|
|
137
|
+
* Channels for any shared-interface harness, with their own Streams and
|
|
138
|
+
* (when a channel needs them) WebSockets. Lifecycle does not install one
|
|
139
|
+
* capability from another yet, so install them alongside:
|
|
140
|
+
*
|
|
141
|
+
* ```ts
|
|
142
|
+
* readonly channels = Channels.forHarness(harness, {
|
|
143
|
+
* channels: { web: new WebChannel() }
|
|
144
|
+
* });
|
|
145
|
+
* readonly lifecycle = Lifecycle.install(this)
|
|
146
|
+
* .use(this.harness)
|
|
147
|
+
* .use(this.channels.streams)
|
|
148
|
+
* .use(this.channels)
|
|
149
|
+
* .use(this.channels.websockets);
|
|
150
|
+
*
|
|
151
|
+
* receive(event: GatewayEvent, origin: GatewayOrigin) {
|
|
152
|
+
* return this.channels.receive(event, origin);
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
static forHarness(
|
|
157
|
+
harness: AgentHarness,
|
|
158
|
+
options: ForHarnessOptions
|
|
159
|
+
): Channels;
|
|
160
|
+
/** The responses' Streams. Install it before Channels. */
|
|
161
|
+
readonly streams: Streams;
|
|
162
|
+
constructor(options: ChannelsOptions);
|
|
163
|
+
/**
|
|
164
|
+
* The WebSockets the channels share. Install it with Lifecycle. Throws
|
|
165
|
+
* when no channel uses WebSockets.
|
|
166
|
+
*/
|
|
167
|
+
get websockets(): WebSockets;
|
|
168
|
+
/** Mark responses left streaming by an earlier instance as interrupted. */
|
|
169
|
+
onStart(): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Deliver an inbound event from the gateway, through the same path as
|
|
172
|
+
* the agent's own channels. The agent calls this from its RPC method.
|
|
173
|
+
*/
|
|
174
|
+
receive(
|
|
175
|
+
event: GatewayEvent,
|
|
176
|
+
from: GatewayOrigin | EventOrigin
|
|
177
|
+
): Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export {
|
|
181
|
+
ConversationChannel as a,
|
|
182
|
+
GatewayEvent as c,
|
|
183
|
+
ChannelsOptions as i,
|
|
184
|
+
ResponseEnding as l,
|
|
185
|
+
Channels as n,
|
|
186
|
+
ConversationUpdate as o,
|
|
187
|
+
ChannelsHost as r,
|
|
188
|
+
ForHarnessOptions as s,
|
|
189
|
+
ChannelState as t,
|
|
190
|
+
ResponseReadOptions as u
|
|
191
|
+
};
|
|
192
|
+
//# sourceMappingURL=conversations-FjHDRZyD.d.ts.map
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
o as MemoryLimitContext,
|
|
4
4
|
v as LifecycleJobOutcome,
|
|
5
5
|
x as Connection
|
|
6
|
-
} from "./capability-runner-
|
|
7
|
-
import { t as Lifecycle } from "./durable-object-lifecycle-
|
|
6
|
+
} from "./capability-runner-BiVUtjqC.js";
|
|
7
|
+
import { t as Lifecycle } from "./durable-object-lifecycle-DOI_bzCH.js";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
9
|
import { DurableObject } from "cloudflare:workers";
|
|
10
10
|
|
|
@@ -14,8 +14,6 @@ import { DurableObject } from "cloudflare:workers";
|
|
|
14
14
|
*
|
|
15
15
|
* Pass a more specific Lifecycle Object type to {@link getCurrentAgent} when
|
|
16
16
|
* shared host code needs APIs implemented by a particular object.
|
|
17
|
-
*
|
|
18
|
-
* @experimental The API surface may change before stabilizing.
|
|
19
17
|
*/
|
|
20
18
|
interface LifecycleObject<
|
|
21
19
|
Env extends object = Cloudflare.Env,
|
|
@@ -90,4 +88,4 @@ export {
|
|
|
90
88
|
LifecycleObject as r,
|
|
91
89
|
AgentContextStore as t
|
|
92
90
|
};
|
|
93
|
-
//# sourceMappingURL=current-agent-
|
|
91
|
+
//# sourceMappingURL=current-agent-CKgT5d1O.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current-agent-DhoDkSnH.js","names":[],"sources":["../src/lifecycle/current-agent.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { DurableObject } from \"cloudflare:workers\";\n\nimport type { MemoryLimitContext } from \"./capability-runner\";\nimport type { Lifecycle } from \"./durable-object-lifecycle\";\nimport type { Connection } from \"./types\";\nimport type { LifecycleJobContext, LifecycleJobOutcome } from \"./job-queue\";\n\n/**\n * A Durable Object that has installed the Agents SDK Lifecycle.\n *\n * Pass a more specific Lifecycle Object type to {@link getCurrentAgent} when\n * shared host code needs APIs implemented by a particular object.\n
|
|
1
|
+
{"version":3,"file":"current-agent-DhoDkSnH.js","names":[],"sources":["../src/lifecycle/current-agent.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { DurableObject } from \"cloudflare:workers\";\n\nimport type { MemoryLimitContext } from \"./capability-runner\";\nimport type { Lifecycle } from \"./durable-object-lifecycle\";\nimport type { Connection } from \"./types\";\nimport type { LifecycleJobContext, LifecycleJobOutcome } from \"./job-queue\";\n\n/**\n * A Durable Object that has installed the Agents SDK Lifecycle.\n *\n * Pass a more specific Lifecycle Object type to {@link getCurrentAgent} when\n * shared host code needs APIs implemented by a particular object.\n */\nexport interface LifecycleObject<\n Env extends object = Cloudflare.Env,\n Props extends object = object\n> extends DurableObject<Env> {\n readonly lifecycle: Lifecycle<Env, Props>;\n onStart?(props?: Props): void | Promise<void>;\n onRequest?(request: Request): Response | Promise<Response>;\n onAlarm?(): void | Promise<void>;\n onJob?(\n context: LifecycleJobContext\n ): LifecycleJobOutcome | void | Promise<LifecycleJobOutcome | void>;\n /**\n * Host domain policy applied when the alarm memory-limit circuit breaker\n * records a strike (#1825), after every capability's `onMemoryLimit` hook.\n *\n * Lifecycle dispatches host hooks structurally through its internal host\n * cast, so TS visibility is the host's to choose: a framework host whose\n * implementation is internal machinery declares the hook `protected` (the\n * pattern — see `AIChatAgent`/`Think`) and keeps the real work in a\n * `private _cf_`-prefixed method, without falling out of this contract at\n * runtime.\n */\n onAlarmMemoryLimit?(context: MemoryLimitContext): void | Promise<void>;\n}\n\n/** Values associated with the currently executing Lifecycle host. */\nexport type AgentContextStore = {\n /** Lifecycle host selected for this invocation. */\n agent: unknown;\n /** WebSocket connection selected for this invocation, when applicable. */\n connection: Connection | undefined;\n /** HTTP request selected for this invocation, when applicable. */\n request: Request | undefined;\n /** Extension-owned value selected for this invocation, when applicable. */\n email: unknown;\n};\n\n/** Values returned by {@link getCurrentAgent}. */\nexport type CurrentAgentContext<\n Host extends DurableObject = LifecycleObject,\n Email = unknown\n> = {\n agent: Host | undefined;\n connection: Connection | undefined;\n request: Request | undefined;\n email: Email | undefined;\n};\n\n/**\n * Shared invocation context for Lifecycle, Agent, AIChatAgent, and Think.\n *\n * @internal Importing or relying on this symbol will break your code in a\n * future release. Use {@link getCurrentAgent} to read the public context.\n */\nexport const __DO_NOT_USE_WILL_BREAK__agentContext =\n new AsyncLocalStorage<AgentContextStore>();\n\n/**\n * Return the current Agent or Lifecycle Object and invocation-specific values.\n *\n * Lifecycle host startup and alarm hooks receive the current object with no\n * request. Request hooks additionally receive the request being handled.\n * Lifecycle-managed WebSocket hooks receive their connection and, during\n * connect, its upgrade request. Agent extensions may also establish context\n * for email, chat turns, callable methods, and detached work. Capability hooks\n * do not run in this ambient context.\n */\nexport function getCurrentAgent<\n Host extends DurableObject = LifecycleObject\n>(): CurrentAgentContext<Host> {\n const store = __DO_NOT_USE_WILL_BREAK__agentContext.getStore();\n if (!store) {\n return {\n agent: undefined,\n connection: undefined,\n request: undefined,\n email: undefined\n };\n }\n\n return {\n agent: store.agent as Host,\n connection: store.connection,\n request: store.request,\n email: store.email\n };\n}\n\ntype LifecycleHostContext<Env extends object, Props extends object> = {\n readonly host: LifecycleObject<Env, Props>;\n readonly connection?: Connection;\n readonly request?: Request;\n};\n\n/** Run one host hook in the context of its Lifecycle Object. */\nexport function runInLifecycleHostContext<\n Env extends object,\n Props extends object,\n T\n>(context: LifecycleHostContext<Env, Props>, operation: () => T): T {\n return __DO_NOT_USE_WILL_BREAK__agentContext.run(\n {\n agent: context.host,\n connection: context.connection,\n request: context.request,\n email: undefined\n },\n operation\n );\n}\n\n/** Run a capability hook without inheriting a current Agent or host context. */\nexport function runWithoutCurrentAgent<T>(operation: () => T): T {\n return __DO_NOT_USE_WILL_BREAK__agentContext.exit(operation);\n}\n"],"mappings":";;;;;;;;AAoEA,MAAa,wCACX,IAAI,kBAAqC;;;;;;;;;;;AAY3C,SAAgB,kBAEe;CAC7B,MAAM,QAAQ,sCAAsC,SAAS;CAC7D,IAAI,CAAC,OACH,OAAO;EACL,OAAO,KAAA;EACP,YAAY,KAAA;EACZ,SAAS,KAAA;EACT,OAAO,KAAA;CACT;CAGF,OAAO;EACL,OAAO,MAAM;EACb,YAAY,MAAM;EAClB,SAAS,MAAM;EACf,OAAO,MAAM;CACf;AACF;;AASA,SAAgB,0BAId,SAA2C,WAAuB;CAClE,OAAO,sCAAsC,IAC3C;EACE,OAAO,QAAQ;EACf,YAAY,QAAQ;EACpB,SAAS,QAAQ;EACjB,OAAO,KAAA;CACT,GACA,SACF;AACF;;AAGA,SAAgB,uBAA0B,WAAuB;CAC/D,OAAO,sCAAsC,KAAK,SAAS;AAC7D"}
|