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
package/package.json
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"durable objects"
|
|
10
10
|
],
|
|
11
11
|
"type": "module",
|
|
12
|
-
"
|
|
12
|
+
"bin": {
|
|
13
|
+
"agents": "./dist/cli.js"
|
|
14
|
+
},
|
|
15
|
+
"version": "0.28.0",
|
|
13
16
|
"license": "MIT",
|
|
14
17
|
"repository": {
|
|
15
18
|
"directory": "packages/agents",
|
|
@@ -42,10 +45,13 @@
|
|
|
42
45
|
"@cloudflare/codemode": "^0.5.3",
|
|
43
46
|
"@earendil-works/pi-ai": "^1.0.0",
|
|
44
47
|
"@earendil-works/pi-durable": "^1.0.0",
|
|
48
|
+
"@earendil-works/pi-tui": "1.0.0",
|
|
45
49
|
"@modelcontextprotocol/client": "2.0.0",
|
|
46
50
|
"@modelcontextprotocol/conformance-v2": "npm:@modelcontextprotocol/conformance@0.2.0-alpha.10",
|
|
47
51
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
48
52
|
"@modelcontextprotocol/server": "2.0.0",
|
|
53
|
+
"@opencode/plugin": "2.0.24",
|
|
54
|
+
"@opencode/sdk": "2.0.24",
|
|
49
55
|
"@tanstack/ai": "0.38.0",
|
|
50
56
|
"@types/react": "^19.2.17",
|
|
51
57
|
"@valibot/to-json-schema": "1.3.0",
|
|
@@ -54,6 +60,7 @@
|
|
|
54
60
|
"ai": "^7.0.0",
|
|
55
61
|
"chat": "^4.31.0",
|
|
56
62
|
"glob": "^13.0.6",
|
|
63
|
+
"highlight.js": "11.12.0",
|
|
57
64
|
"just-bash": "^3.0.2",
|
|
58
65
|
"react": "^19.2.7",
|
|
59
66
|
"teleproto": "^1.228.5",
|
|
@@ -69,6 +76,8 @@
|
|
|
69
76
|
"@modelcontextprotocol/client": "2.0.0",
|
|
70
77
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
71
78
|
"@modelcontextprotocol/server": "2.0.0",
|
|
79
|
+
"@opencode/plugin": "^2.0.24",
|
|
80
|
+
"@opencode/sdk": "^2.0.24",
|
|
72
81
|
"@tanstack/ai": ">=0.10.2 <1.0.0",
|
|
73
82
|
"@x402/core": "^2.0.0",
|
|
74
83
|
"@x402/evm": "^2.0.0",
|
|
@@ -95,6 +104,12 @@
|
|
|
95
104
|
"@earendil-works/pi-durable": {
|
|
96
105
|
"optional": true
|
|
97
106
|
},
|
|
107
|
+
"@opencode/plugin": {
|
|
108
|
+
"optional": true
|
|
109
|
+
},
|
|
110
|
+
"@opencode/sdk": {
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
98
113
|
"@tanstack/ai": {
|
|
99
114
|
"optional": true
|
|
100
115
|
},
|
|
@@ -167,11 +182,46 @@
|
|
|
167
182
|
"import": "./dist/lifecycle/index.js",
|
|
168
183
|
"require": "./dist/lifecycle/index.js"
|
|
169
184
|
},
|
|
185
|
+
"./harness/ai-sdk": {
|
|
186
|
+
"types": "./dist/harness/ai-sdk/index.d.ts",
|
|
187
|
+
"import": "./dist/harness/ai-sdk/index.js",
|
|
188
|
+
"require": "./dist/harness/ai-sdk/index.js"
|
|
189
|
+
},
|
|
190
|
+
"./harness/opencode": {
|
|
191
|
+
"types": "./dist/harness/opencode/index.d.ts",
|
|
192
|
+
"import": "./dist/harness/opencode/index.js",
|
|
193
|
+
"require": "./dist/harness/opencode/index.js"
|
|
194
|
+
},
|
|
170
195
|
"./harness/pi": {
|
|
171
196
|
"types": "./dist/harness/pi/index.d.ts",
|
|
172
197
|
"import": "./dist/harness/pi/index.js",
|
|
173
198
|
"require": "./dist/harness/pi/index.js"
|
|
174
199
|
},
|
|
200
|
+
"./harness/think": {
|
|
201
|
+
"types": "./dist/harness/think/index.d.ts",
|
|
202
|
+
"import": "./dist/harness/think/index.js",
|
|
203
|
+
"require": "./dist/harness/think/index.js"
|
|
204
|
+
},
|
|
205
|
+
"./harness/container": {
|
|
206
|
+
"types": "./dist/harness/container/index.d.ts",
|
|
207
|
+
"import": "./dist/harness/container/index.js",
|
|
208
|
+
"require": "./dist/harness/container/index.js"
|
|
209
|
+
},
|
|
210
|
+
"./harness/container/daemon": {
|
|
211
|
+
"types": "./dist/harness/container/daemon/index.d.ts",
|
|
212
|
+
"import": "./dist/harness/container/daemon/index.js",
|
|
213
|
+
"require": "./dist/harness/container/daemon/index.js"
|
|
214
|
+
},
|
|
215
|
+
"./harness/container/runtime": {
|
|
216
|
+
"types": "./dist/harness/container/runtime/index.d.ts",
|
|
217
|
+
"import": "./dist/harness/container/runtime/index.js",
|
|
218
|
+
"require": "./dist/harness/container/runtime/index.js"
|
|
219
|
+
},
|
|
220
|
+
"./harness/store": {
|
|
221
|
+
"types": "./dist/harness/store/index.d.ts",
|
|
222
|
+
"import": "./dist/harness/store/index.js",
|
|
223
|
+
"require": "./dist/harness/store/index.js"
|
|
224
|
+
},
|
|
175
225
|
"./agent-tools": {
|
|
176
226
|
"types": "./dist/agent-tools.d.ts",
|
|
177
227
|
"import": "./dist/agent-tools.js",
|
|
@@ -212,6 +262,11 @@
|
|
|
212
262
|
"import": "./dist/models/ai-sdk/index.js",
|
|
213
263
|
"require": "./dist/models/ai-sdk/index.js"
|
|
214
264
|
},
|
|
265
|
+
"./models/opencode": {
|
|
266
|
+
"types": "./dist/models/opencode/index.d.ts",
|
|
267
|
+
"import": "./dist/models/opencode/index.js",
|
|
268
|
+
"require": "./dist/models/opencode/index.js"
|
|
269
|
+
},
|
|
215
270
|
"./models/pi-ai": {
|
|
216
271
|
"types": "./dist/models/pi-ai/index.d.ts",
|
|
217
272
|
"import": "./dist/models/pi-ai/index.js",
|
|
@@ -328,14 +383,59 @@
|
|
|
328
383
|
"require": "./dist/browser/ai.js"
|
|
329
384
|
},
|
|
330
385
|
"./browser/ai-sdk": {
|
|
331
|
-
"types": "./dist/browser/ai-sdk.d.ts",
|
|
332
|
-
"import": "./dist/browser/ai-sdk.js",
|
|
333
|
-
"require": "./dist/browser/ai-sdk.js"
|
|
386
|
+
"types": "./dist/browser/tools/ai-sdk.d.ts",
|
|
387
|
+
"import": "./dist/browser/tools/ai-sdk.js",
|
|
388
|
+
"require": "./dist/browser/tools/ai-sdk.js"
|
|
334
389
|
},
|
|
335
390
|
"./browser/tanstack-ai": {
|
|
336
|
-
"types": "./dist/browser/tanstack-ai.d.ts",
|
|
337
|
-
"import": "./dist/browser/tanstack-ai.js",
|
|
338
|
-
"require": "./dist/browser/tanstack-ai.js"
|
|
391
|
+
"types": "./dist/browser/tools/tanstack-ai.d.ts",
|
|
392
|
+
"import": "./dist/browser/tools/tanstack-ai.js",
|
|
393
|
+
"require": "./dist/browser/tools/tanstack-ai.js"
|
|
394
|
+
},
|
|
395
|
+
"./websearch": {
|
|
396
|
+
"types": "./dist/web/search/index.d.ts",
|
|
397
|
+
"import": "./dist/web/search/index.js",
|
|
398
|
+
"require": "./dist/web/search/index.js"
|
|
399
|
+
},
|
|
400
|
+
"./websearch/pi": {
|
|
401
|
+
"types": "./dist/web/search/tools/pi.d.ts",
|
|
402
|
+
"import": "./dist/web/search/tools/pi.js",
|
|
403
|
+
"require": "./dist/web/search/tools/pi.js"
|
|
404
|
+
},
|
|
405
|
+
"./websearch/ai-sdk": {
|
|
406
|
+
"types": "./dist/web/search/tools/ai-sdk.d.ts",
|
|
407
|
+
"import": "./dist/web/search/tools/ai-sdk.js",
|
|
408
|
+
"require": "./dist/web/search/tools/ai-sdk.js"
|
|
409
|
+
},
|
|
410
|
+
"./websearch/tanstack-ai": {
|
|
411
|
+
"types": "./dist/web/search/tools/tanstack-ai.d.ts",
|
|
412
|
+
"import": "./dist/web/search/tools/tanstack-ai.js",
|
|
413
|
+
"require": "./dist/web/search/tools/tanstack-ai.js"
|
|
414
|
+
},
|
|
415
|
+
"./browser/pi": {
|
|
416
|
+
"types": "./dist/browser/tools/pi.d.ts",
|
|
417
|
+
"import": "./dist/browser/tools/pi.js",
|
|
418
|
+
"require": "./dist/browser/tools/pi.js"
|
|
419
|
+
},
|
|
420
|
+
"./webfetch": {
|
|
421
|
+
"types": "./dist/web/fetch/index.d.ts",
|
|
422
|
+
"import": "./dist/web/fetch/index.js",
|
|
423
|
+
"require": "./dist/web/fetch/index.js"
|
|
424
|
+
},
|
|
425
|
+
"./webfetch/pi": {
|
|
426
|
+
"types": "./dist/web/fetch/tools/pi.d.ts",
|
|
427
|
+
"import": "./dist/web/fetch/tools/pi.js",
|
|
428
|
+
"require": "./dist/web/fetch/tools/pi.js"
|
|
429
|
+
},
|
|
430
|
+
"./webfetch/ai-sdk": {
|
|
431
|
+
"types": "./dist/web/fetch/tools/ai-sdk.d.ts",
|
|
432
|
+
"import": "./dist/web/fetch/tools/ai-sdk.js",
|
|
433
|
+
"require": "./dist/web/fetch/tools/ai-sdk.js"
|
|
434
|
+
},
|
|
435
|
+
"./webfetch/tanstack-ai": {
|
|
436
|
+
"types": "./dist/web/fetch/tools/tanstack-ai.d.ts",
|
|
437
|
+
"import": "./dist/web/fetch/tools/tanstack-ai.js",
|
|
438
|
+
"require": "./dist/web/fetch/tools/tanstack-ai.js"
|
|
339
439
|
},
|
|
340
440
|
"./voice": {
|
|
341
441
|
"types": "./dist/voice/index.d.ts",
|
|
@@ -377,40 +477,40 @@
|
|
|
377
477
|
"import": "./dist/voice/text.js",
|
|
378
478
|
"require": "./dist/voice/text.js"
|
|
379
479
|
},
|
|
380
|
-
"./channels": {
|
|
381
|
-
"types": "./dist/channels/index.d.ts",
|
|
382
|
-
"import": "./dist/channels/index.js",
|
|
383
|
-
"require": "./dist/channels/index.js"
|
|
384
|
-
},
|
|
385
|
-
"./channels/email": {
|
|
386
|
-
"types": "./dist/channels/email.d.ts",
|
|
387
|
-
"import": "./dist/channels/email.js",
|
|
388
|
-
"require": "./dist/channels/email.js"
|
|
389
|
-
},
|
|
390
|
-
"./channels/slack": {
|
|
391
|
-
"types": "./dist/channels/slack.d.ts",
|
|
392
|
-
"import": "./dist/channels/slack.js",
|
|
393
|
-
"require": "./dist/channels/slack.js"
|
|
394
|
-
},
|
|
395
|
-
"./channels/telegram": {
|
|
396
|
-
"types": "./dist/channels/telegram.d.ts",
|
|
397
|
-
"import": "./dist/channels/telegram.js",
|
|
398
|
-
"require": "./dist/channels/telegram.js"
|
|
399
|
-
},
|
|
400
|
-
"./channels/
|
|
401
|
-
"types": "./dist/channels/
|
|
402
|
-
"import": "./dist/channels/
|
|
403
|
-
"require": "./dist/channels/
|
|
404
|
-
},
|
|
405
|
-
"./channels/
|
|
406
|
-
"types": "./dist/channels/
|
|
407
|
-
"import": "./dist/channels/
|
|
408
|
-
"require": "./dist/channels/
|
|
409
|
-
},
|
|
410
|
-
"./channels/
|
|
411
|
-
"types": "./dist/channels/
|
|
412
|
-
"import": "./dist/channels/
|
|
413
|
-
"require": "./dist/channels/
|
|
480
|
+
"./experimental/channels": {
|
|
481
|
+
"types": "./dist/experimental/channels/index.d.ts",
|
|
482
|
+
"import": "./dist/experimental/channels/index.js",
|
|
483
|
+
"require": "./dist/experimental/channels/index.js"
|
|
484
|
+
},
|
|
485
|
+
"./experimental/channels/email": {
|
|
486
|
+
"types": "./dist/experimental/channels/email/index.d.ts",
|
|
487
|
+
"import": "./dist/experimental/channels/email/index.js",
|
|
488
|
+
"require": "./dist/experimental/channels/email/index.js"
|
|
489
|
+
},
|
|
490
|
+
"./experimental/channels/slack": {
|
|
491
|
+
"types": "./dist/experimental/channels/slack/index.d.ts",
|
|
492
|
+
"import": "./dist/experimental/channels/slack/index.js",
|
|
493
|
+
"require": "./dist/experimental/channels/slack/index.js"
|
|
494
|
+
},
|
|
495
|
+
"./experimental/channels/telegram": {
|
|
496
|
+
"types": "./dist/experimental/channels/telegram/index.d.ts",
|
|
497
|
+
"import": "./dist/experimental/channels/telegram/index.js",
|
|
498
|
+
"require": "./dist/experimental/channels/telegram/index.js"
|
|
499
|
+
},
|
|
500
|
+
"./experimental/channels/web": {
|
|
501
|
+
"types": "./dist/experimental/channels/web/index.d.ts",
|
|
502
|
+
"import": "./dist/experimental/channels/web/index.js",
|
|
503
|
+
"require": "./dist/experimental/channels/web/index.js"
|
|
504
|
+
},
|
|
505
|
+
"./experimental/channels/web/client": {
|
|
506
|
+
"types": "./dist/experimental/channels/web/client.d.ts",
|
|
507
|
+
"import": "./dist/experimental/channels/web/client.js",
|
|
508
|
+
"require": "./dist/experimental/channels/web/client.js"
|
|
509
|
+
},
|
|
510
|
+
"./experimental/channels/web/ai-sdk": {
|
|
511
|
+
"types": "./dist/experimental/channels/web/ai-sdk.d.ts",
|
|
512
|
+
"import": "./dist/experimental/channels/web/ai-sdk.js",
|
|
513
|
+
"require": "./dist/experimental/channels/web/ai-sdk.js"
|
|
414
514
|
},
|
|
415
515
|
"./tsconfig": "./agents.tsconfig.json",
|
|
416
516
|
"./vite": {
|
|
@@ -453,7 +553,8 @@
|
|
|
453
553
|
],
|
|
454
554
|
"outputs": [
|
|
455
555
|
"{projectRoot}/dist",
|
|
456
|
-
"{projectRoot}/docs"
|
|
556
|
+
"{projectRoot}/docs",
|
|
557
|
+
"{projectRoot}/src/harness/container/daemon-source.generated.ts"
|
|
457
558
|
]
|
|
458
559
|
}
|
|
459
560
|
}
|
|
@@ -467,11 +568,12 @@
|
|
|
467
568
|
"test:voice:workers": "vitest --project voice-workers",
|
|
468
569
|
"test:voice:react": "vitest --project voice-react",
|
|
469
570
|
"test:channels": "vitest --project channels",
|
|
470
|
-
"test:channels:live": "vitest --run -c src/channels/vitest.live.config.ts",
|
|
471
571
|
"test:browser": "vitest run --config src/browser-tests/vitest.config.ts",
|
|
472
572
|
"test:workers": "vitest --project workers",
|
|
473
573
|
"test:chat": "vitest --project chat",
|
|
574
|
+
"test:harness:opencode": "vitest --project harness-opencode",
|
|
474
575
|
"test:harness:pi": "vitest --project harness-pi",
|
|
576
|
+
"test:harness:container": "vitest --project harness-container --project harness-container-runtime",
|
|
475
577
|
"test:webmcp": "vitest --project webmcp",
|
|
476
578
|
"test:x402": "vitest --project x402",
|
|
477
579
|
"test:e2e": "vitest --run -c src/e2e-tests/vitest.config.ts",
|
|
@@ -485,6 +587,8 @@
|
|
|
485
587
|
"test:conformance:server:mcp-agent": "bash conformance/run.sh server-mcp-agent",
|
|
486
588
|
"test:conformance:server:handler": "bash conformance/run.sh server-handler",
|
|
487
589
|
"test:conformance:server:handler:legacy-compat": "bash conformance/run.sh server-handler-legacy-compat",
|
|
488
|
-
"test:conformance:server:handler:legacy": "bash conformance/run.sh server-handler-legacy"
|
|
590
|
+
"test:conformance:server:handler:legacy": "bash conformance/run.sh server-handler-legacy",
|
|
591
|
+
"test:harness:think": "vitest --project harness-think",
|
|
592
|
+
"build:daemon": "tsx ./scripts/build-daemon.ts"
|
|
489
593
|
}
|
|
490
594
|
}
|
package/dist/ai-fm7xx1BK.js
DELETED
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
import { t as __DO_NOT_USE_WILL_BREAK__agentContext } from "./current-agent-DhoDkSnH.js";
|
|
2
|
-
import "./internal_context.js";
|
|
3
|
-
import { c as browserExtract, f as browserScrape, i as DurableBrowserSessionStore, l as browserLinks, s as browserContent, t as BrowserConnector, u as browserMarkdown } from "./connector-58XDGvc3.js";
|
|
4
|
-
import { t as redactBase64Payloads } from "./base64-redaction-C1Uu29t5.js";
|
|
5
|
-
import { tool } from "ai";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { DynamicWorkerExecutor, createCodemodeRuntime, truncateResult } from "@cloudflare/codemode";
|
|
8
|
-
//#region src/browser/tool-helpers.ts
|
|
9
|
-
function browserScreenshotOutput(value) {
|
|
10
|
-
const outer = typeof value === "object" && value !== null ? value : null;
|
|
11
|
-
const result = outer && typeof outer.result === "object" && outer.result !== null ? outer.result : outer;
|
|
12
|
-
if (result?.type !== "browser_screenshot" || typeof result.mediaType !== "string" || typeof result.data !== "string") return null;
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
|
-
function transformBrowserResult(value) {
|
|
16
|
-
return browserScreenshotOutput(value) ? value : truncateResult(redactBase64Payloads(value));
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @param notes Sentences appended when a screenshot collapses the output to
|
|
20
|
-
* text, so notices on the output aren't lost with it.
|
|
21
|
-
*/
|
|
22
|
-
function browserExecuteModelOutput(output, notes = []) {
|
|
23
|
-
const screenshot = browserScreenshotOutput(output);
|
|
24
|
-
if (screenshot) {
|
|
25
|
-
const approximateBytes = Math.floor(screenshot.data.length * 3 / 4);
|
|
26
|
-
return {
|
|
27
|
-
type: "text",
|
|
28
|
-
value: [`Screenshot captured successfully (${screenshot.mediaType}, approximately ${approximateBytes.toLocaleString()} bytes); the image is kept for the UI and omitted here.`, ...notes].join(" ")
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const redacted = redactBase64Payloads(typeof output === "object" && output !== null && !Array.isArray(output) ? (({ calls: _calls, ...rest }) => ({
|
|
32
|
-
...rest,
|
|
33
|
-
...Array.isArray(rest.logs) ? { logs: truncateResult(rest.logs) } : {}
|
|
34
|
-
}))(output) : output);
|
|
35
|
-
try {
|
|
36
|
-
const serialized = JSON.stringify(redacted);
|
|
37
|
-
return {
|
|
38
|
-
type: "json",
|
|
39
|
-
value: serialized === void 0 ? null : JSON.parse(serialized)
|
|
40
|
-
};
|
|
41
|
-
} catch {
|
|
42
|
-
return {
|
|
43
|
-
type: "text",
|
|
44
|
-
value: "Browser execution completed, but its result could not be serialized for model context."
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* The Durable Object state to build the runtime in: the explicit `ctx` if
|
|
50
|
-
* given, otherwise the current Agent's `ctx` (via `getCurrentAgent()`), so
|
|
51
|
-
* `createBrowserRuntime` can be called from an Agent method without threading
|
|
52
|
-
* `this.ctx` through.
|
|
53
|
-
*/
|
|
54
|
-
function resolveCtx(options) {
|
|
55
|
-
if (options.ctx) return options.ctx;
|
|
56
|
-
return (__DO_NOT_USE_WILL_BREAK__agentContext.getStore()?.agent)?.ctx;
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/browser/ai.ts
|
|
60
|
-
let didWarnExperimental = false;
|
|
61
|
-
let didDebugQuickActionSkip = false;
|
|
62
|
-
function connectorOptions(options, ctx) {
|
|
63
|
-
if (options.cdpUrl) return {
|
|
64
|
-
cdpUrl: options.cdpUrl,
|
|
65
|
-
cdpHeaders: options.cdpHeaders,
|
|
66
|
-
timeout: options.timeout
|
|
67
|
-
};
|
|
68
|
-
if (!options.browser) throw new Error("Either 'browser' (Fetcher binding) or 'cdpUrl' must be provided");
|
|
69
|
-
return {
|
|
70
|
-
browser: options.browser,
|
|
71
|
-
store: options.store ?? new DurableBrowserSessionStore(ctx.storage),
|
|
72
|
-
session: options.session,
|
|
73
|
-
timeout: options.timeout
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Create the browser codemode runtime: the `browser_execute` tool plus the
|
|
78
|
-
* runtime handle and connector for host-side wiring (approvals, session info,
|
|
79
|
-
* sweeps).
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```ts
|
|
83
|
-
* export class MyAgent extends Agent<Env> {
|
|
84
|
-
* get browser() {
|
|
85
|
-
* return createBrowserRuntime({
|
|
86
|
-
* ctx: this.ctx,
|
|
87
|
-
* browser: this.env.BROWSER,
|
|
88
|
-
* loader: this.env.LOADER,
|
|
89
|
-
* session: { mode: "dynamic" }
|
|
90
|
-
* });
|
|
91
|
-
* }
|
|
92
|
-
*
|
|
93
|
-
* @callable()
|
|
94
|
-
* async closeBrowserSession() {
|
|
95
|
-
* await this.browser.connector.closeSession();
|
|
96
|
-
* }
|
|
97
|
-
* }
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
function createBrowserRuntime(options) {
|
|
101
|
-
if (!didWarnExperimental) {
|
|
102
|
-
didWarnExperimental = true;
|
|
103
|
-
console.warn("[agents/browser] Browser tools are experimental and may change in a future release.");
|
|
104
|
-
}
|
|
105
|
-
const ctx = resolveCtx(options);
|
|
106
|
-
if (!ctx) throw new Error("createBrowserRuntime requires a Durable Object 'ctx' — pass it explicitly, or call from within an Agent so it can be resolved via getCurrentAgent()");
|
|
107
|
-
const connector = new BrowserConnector(ctx, connectorOptions(options, ctx));
|
|
108
|
-
const runtime = createCodemodeRuntime({
|
|
109
|
-
ctx,
|
|
110
|
-
executor: new DynamicWorkerExecutor({
|
|
111
|
-
loader: options.loader,
|
|
112
|
-
timeout: options.timeout
|
|
113
|
-
}),
|
|
114
|
-
connectors: [connector],
|
|
115
|
-
name: options.name ?? "browser",
|
|
116
|
-
transformResult: transformBrowserResult
|
|
117
|
-
});
|
|
118
|
-
const isKitesurf = !options.cdpUrl && options.session?.browser === "kitesurf";
|
|
119
|
-
const tools = { browser_execute: {
|
|
120
|
-
...runtime.tool({ connectorHints: { cdp: isKitesurf ? "Kitesurf one-shot Browser CDP. Call codemode.describe(\"cdp\") for connector types and Kitesurf execution rules. codemode.search indexes connector methods and snippets, not underlying CDP commands. Complete the task in one execution and do not pause. Return screenshots as { type: \"browser_screenshot\", mediaType: \"image/png\", data: screenshot.data }." : "Browser CDP. Return screenshots as { type: 'browser_screenshot', mediaType: 'image/png', data: screenshot.data }; the UI keeps the image while the model receives a compact summary." } }),
|
|
121
|
-
toModelOutput: ({ output }) => browserExecuteModelOutput(output)
|
|
122
|
-
} };
|
|
123
|
-
if (options.quickActions !== false && (!isKitesurf || options.quickActions !== void 0)) {
|
|
124
|
-
const qa = typeof options.quickActions === "object" ? options.quickActions : {};
|
|
125
|
-
const quickActionBrowser = qa.browser ?? options.browser;
|
|
126
|
-
if (quickActionBrowser) Object.assign(tools, createQuickActionTools({
|
|
127
|
-
browser: quickActionBrowser,
|
|
128
|
-
actions: qa.actions,
|
|
129
|
-
maxChars: qa.maxChars,
|
|
130
|
-
options: qa.options
|
|
131
|
-
}));
|
|
132
|
-
else if (options.quickActions) throw new Error("quickActions requires a Browser Run binding — set 'browser' (env.BROWSER) or 'quickActions.browser'");
|
|
133
|
-
else if (!didDebugQuickActionSkip) {
|
|
134
|
-
didDebugQuickActionSkip = true;
|
|
135
|
-
console.debug("[agents/browser] Quick Action tools skipped — no Browser Run binding (only 'cdpUrl' is set). Pass 'browser' or 'quickActions.browser' to enable them.");
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
runtime,
|
|
140
|
-
connector,
|
|
141
|
-
tools
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Create AI SDK tools for browser automation via CDP code mode.
|
|
146
|
-
*
|
|
147
|
-
* Returns a `ToolSet` with a single durable `browser_execute` tool backed by
|
|
148
|
-
* a codemode runtime: the model writes TypeScript against the `cdp` connector
|
|
149
|
-
* (`cdp.send`, `cdp.attachToTarget`, `cdp.spec`, …), executions are recorded
|
|
150
|
-
* for abort-and-replay, and browser sessions survive pauses.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```ts
|
|
154
|
-
* import { createBrowserTools } from "agents/browser/ai";
|
|
155
|
-
* import { generateText } from "ai";
|
|
156
|
-
*
|
|
157
|
-
* // inside a Durable Object / Agent:
|
|
158
|
-
* const browserTools = createBrowserTools({
|
|
159
|
-
* ctx: this.ctx,
|
|
160
|
-
* browser: this.env.BROWSER,
|
|
161
|
-
* loader: this.env.LOADER,
|
|
162
|
-
* });
|
|
163
|
-
*
|
|
164
|
-
* const result = await generateText({
|
|
165
|
-
* model,
|
|
166
|
-
* tools: { ...browserTools, ...otherTools },
|
|
167
|
-
* messages,
|
|
168
|
-
* });
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
function createBrowserTools(options) {
|
|
172
|
-
return createBrowserRuntime(options).tools;
|
|
173
|
-
}
|
|
174
|
-
const DEFAULT_QUICK_ACTION_TOOLS = [
|
|
175
|
-
"markdown",
|
|
176
|
-
"extract",
|
|
177
|
-
"links",
|
|
178
|
-
"scrape"
|
|
179
|
-
];
|
|
180
|
-
const DEFAULT_QUICK_ACTION_MAX_CHARS = 5e4;
|
|
181
|
-
const pageInputSchema = z.object({
|
|
182
|
-
url: z.string().url().optional().describe("URL of the page to load"),
|
|
183
|
-
html: z.string().optional().describe("Raw HTML to render instead of loading a URL")
|
|
184
|
-
}).refine((value) => Boolean(value.url) || Boolean(value.html), { message: "Provide either 'url' or 'html'" });
|
|
185
|
-
function toPage(input, options) {
|
|
186
|
-
const page = input.url ? { url: input.url } : { html: input.html };
|
|
187
|
-
return {
|
|
188
|
-
...options,
|
|
189
|
-
...page
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function truncate(text, maxChars) {
|
|
193
|
-
if (maxChars <= 0 || text.length <= maxChars) return text;
|
|
194
|
-
return `${text.slice(0, maxChars)}\n\n[truncated ${text.length - maxChars} characters]`;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Keep a tool result within a rough character budget so a single browse cannot
|
|
198
|
-
* blow the model's context window — while preserving the result's shape so the
|
|
199
|
-
* model sees a consistent type across calls:
|
|
200
|
-
*
|
|
201
|
-
* - strings (markdown/content) are truncated to a string;
|
|
202
|
-
* - arrays (links/scrape) are trimmed from the end but stay arrays;
|
|
203
|
-
* - only an opaque oversized object (e.g. a sprawling `extract`) degrades to a
|
|
204
|
-
* `{ truncated, note, preview }` summary, since it cannot be trimmed safely.
|
|
205
|
-
*/
|
|
206
|
-
function boundResult(value, maxChars) {
|
|
207
|
-
if (maxChars <= 0) return value;
|
|
208
|
-
if (typeof value === "string") return truncate(value, maxChars);
|
|
209
|
-
let json;
|
|
210
|
-
try {
|
|
211
|
-
json = JSON.stringify(value);
|
|
212
|
-
} catch {
|
|
213
|
-
return value;
|
|
214
|
-
}
|
|
215
|
-
if (json.length <= maxChars) return value;
|
|
216
|
-
if (Array.isArray(value)) {
|
|
217
|
-
const trimmed = boundArray(value, maxChars);
|
|
218
|
-
if (trimmed.length > 0) return trimmed;
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
truncated: true,
|
|
222
|
-
note: `Result is too large (${json.length} characters); narrow the request.`,
|
|
223
|
-
preview: `${json.slice(0, maxChars)}…`
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Take as many leading items as fit within `maxChars` (measured against their
|
|
228
|
-
* JSON length), returning a trimmed array of the same element type. Silent by
|
|
229
|
-
* design: the model gets fewer, valid items rather than a reshaped result.
|
|
230
|
-
*/
|
|
231
|
-
function boundArray(value, maxChars) {
|
|
232
|
-
const out = [];
|
|
233
|
-
let size = 2;
|
|
234
|
-
for (const item of value) {
|
|
235
|
-
const itemSize = JSON.stringify(item).length + 1;
|
|
236
|
-
if (size + itemSize > maxChars) break;
|
|
237
|
-
out.push(item);
|
|
238
|
-
size += itemSize;
|
|
239
|
-
}
|
|
240
|
-
return out;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Create AI SDK tools for Browser Run [Quick Actions](https://developers.cloudflare.com/browser-run/quick-actions/):
|
|
244
|
-
* stateless one-shot browsing (read a page as Markdown, extract structured
|
|
245
|
-
* data with AI, list links, scrape elements). Unlike `createBrowserTools`,
|
|
246
|
-
* these need only the `browser` binding — no Durable Object, loader, or
|
|
247
|
-
* sandbox — so they work from any Worker.
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* ```ts
|
|
251
|
-
* import { createQuickActionTools } from "agents/browser/ai";
|
|
252
|
-
*
|
|
253
|
-
* const tools = createQuickActionTools({ browser: this.env.BROWSER });
|
|
254
|
-
* const result = await generateText({ model, tools, messages });
|
|
255
|
-
* ```
|
|
256
|
-
*/
|
|
257
|
-
function createQuickActionTools(options) {
|
|
258
|
-
const { browser } = options;
|
|
259
|
-
const requestOptions = options.options;
|
|
260
|
-
const enabled = new Set(options.actions ?? DEFAULT_QUICK_ACTION_TOOLS);
|
|
261
|
-
const maxChars = options.maxChars ?? DEFAULT_QUICK_ACTION_MAX_CHARS;
|
|
262
|
-
const tools = {};
|
|
263
|
-
if (enabled.has("markdown")) tools.browser_markdown = tool({
|
|
264
|
-
description: "Load a web page (or render raw HTML) and return its content as Markdown. Best for reading articles, docs, or any page as text.",
|
|
265
|
-
inputSchema: pageInputSchema,
|
|
266
|
-
execute: async (input) => boundResult(await browserMarkdown(browser, toPage(input, requestOptions)), maxChars)
|
|
267
|
-
});
|
|
268
|
-
if (enabled.has("extract")) tools.browser_extract = tool({
|
|
269
|
-
description: "Extract structured data from a web page using AI. Describe what you want in 'prompt'. Passing a JSON Schema in 'schema' is strongly recommended — without one the extractor often fails to produce JSON.",
|
|
270
|
-
inputSchema: z.object({
|
|
271
|
-
url: z.string().url().optional().describe("URL of the page to load"),
|
|
272
|
-
html: z.string().optional().describe("Raw HTML to render instead of loading a URL"),
|
|
273
|
-
prompt: z.string().optional().describe("What to extract, in natural language"),
|
|
274
|
-
schema: z.record(z.string(), z.unknown(), { error: "Schema must be a JSON object" }).optional().describe("Optional JSON Schema describing the desired output")
|
|
275
|
-
}).refine((value) => Boolean(value.url) || Boolean(value.html), { message: "Provide either 'url' or 'html'" }).refine((value) => Boolean(value.prompt) || Boolean(value.schema), { message: "Provide either 'prompt' or 'schema'" }),
|
|
276
|
-
execute: async (input) => boundResult(await browserExtract(browser, {
|
|
277
|
-
...toPage(input, requestOptions),
|
|
278
|
-
prompt: input.prompt,
|
|
279
|
-
response_format: input.schema ? {
|
|
280
|
-
type: "json_schema",
|
|
281
|
-
json_schema: input.schema
|
|
282
|
-
} : void 0
|
|
283
|
-
}), maxChars)
|
|
284
|
-
});
|
|
285
|
-
if (enabled.has("links")) tools.browser_links = tool({
|
|
286
|
-
description: "Return every link found on a web page (including ones not visible). Useful for discovering pages to follow.",
|
|
287
|
-
inputSchema: pageInputSchema,
|
|
288
|
-
execute: async (input) => boundResult(await browserLinks(browser, toPage(input, requestOptions)), maxChars)
|
|
289
|
-
});
|
|
290
|
-
if (enabled.has("scrape")) tools.browser_scrape = tool({
|
|
291
|
-
description: "Scrape specific elements from a web page by CSS selector. Returns the matched elements' text, HTML, and attributes.",
|
|
292
|
-
inputSchema: z.object({
|
|
293
|
-
url: z.string().url().optional().describe("URL of the page to load"),
|
|
294
|
-
html: z.string().optional().describe("Raw HTML to render instead of loading a URL"),
|
|
295
|
-
selectors: z.array(z.string()).min(1).describe("CSS selectors to extract")
|
|
296
|
-
}).refine((value) => Boolean(value.url) || Boolean(value.html), { message: "Provide either 'url' or 'html'" }),
|
|
297
|
-
execute: async (input) => boundResult(await browserScrape(browser, {
|
|
298
|
-
...toPage(input, requestOptions),
|
|
299
|
-
elements: input.selectors.map((selector) => ({ selector }))
|
|
300
|
-
}), maxChars)
|
|
301
|
-
});
|
|
302
|
-
if (enabled.has("content")) tools.browser_content = tool({
|
|
303
|
-
description: "Load a web page and return its fully rendered HTML (after JavaScript runs). Prefer 'browser_markdown' unless you need the raw HTML.",
|
|
304
|
-
inputSchema: pageInputSchema,
|
|
305
|
-
execute: async (input) => boundResult(await browserContent(browser, toPage(input, requestOptions)), maxChars)
|
|
306
|
-
});
|
|
307
|
-
return tools;
|
|
308
|
-
}
|
|
309
|
-
//#endregion
|
|
310
|
-
export { browserScreenshotOutput as a, browserExecuteModelOutput as i, createBrowserTools as n, resolveCtx as o, createQuickActionTools as r, transformBrowserResult as s, createBrowserRuntime as t };
|
|
311
|
-
|
|
312
|
-
//# sourceMappingURL=ai-fm7xx1BK.js.map
|