experimental-a2 0.16.1 → 0.18.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/CHANGELOG.md +373 -0
- package/README.md +1 -1
- package/dist/{actor-ohPC-81x.d.ts → actor-Bjce9_5U.d.ts} +21 -11
- package/dist/actor-Bjce9_5U.d.ts.map +1 -0
- package/dist/actor-client.d.ts +2 -5
- package/dist/actor-client.d.ts.map +1 -1
- package/dist/actor-client.js +13 -4
- package/dist/actor-client.js.map +1 -1
- package/dist/actor-react.d.ts +5 -3
- package/dist/actor-react.d.ts.map +1 -1
- package/dist/actor-react.js +20 -10
- package/dist/actor-react.js.map +1 -1
- package/dist/{actor-shared-B5tJfzt-.js → actor-shared-t7w8xIKP.js} +12 -7
- package/dist/actor-shared-t7w8xIKP.js.map +1 -0
- package/dist/actor.d.ts +1 -1
- package/dist/actor.js +42 -23
- package/dist/actor.js.map +1 -1
- package/dist/{ai-DgOBltJ_.js → ai-BpOGm-zB.js} +621 -216
- package/dist/ai-BpOGm-zB.js.map +1 -0
- package/dist/{ai-CrEf6p_W.d.ts → ai-DrUaMyRt.d.ts} +114 -100
- package/dist/ai-DrUaMyRt.d.ts.map +1 -0
- package/dist/ai-client.d.ts +27 -0
- package/dist/ai-client.d.ts.map +1 -0
- package/dist/ai-client.js +29 -0
- package/dist/ai-client.js.map +1 -0
- package/dist/ai-fx.browser.d.ts +1 -0
- package/dist/ai-fx.browser.js +6 -0
- package/dist/ai-fx.browser.js.map +1 -0
- package/dist/ai-fx.d.ts +10 -0
- package/dist/ai-fx.d.ts.map +1 -0
- package/dist/ai-fx.js +634 -0
- package/dist/ai-fx.js.map +1 -0
- package/dist/ai-harness-BuLh_EYi.js +273 -0
- package/dist/ai-harness-BuLh_EYi.js.map +1 -0
- package/dist/ai-harness-DvsPeJeB.d.ts +26 -0
- package/dist/ai-harness-DvsPeJeB.d.ts.map +1 -0
- package/dist/ai-pi.browser.d.ts +1 -0
- package/dist/ai-pi.browser.js +6 -0
- package/dist/ai-pi.browser.js.map +1 -0
- package/dist/ai-pi.d.ts +17 -0
- package/dist/ai-pi.d.ts.map +1 -0
- package/dist/ai-pi.js +904 -0
- package/dist/ai-pi.js.map +1 -0
- package/dist/ai-react.d.ts +96 -0
- package/dist/ai-react.d.ts.map +1 -0
- package/dist/ai-react.js +142 -0
- package/dist/ai-react.js.map +1 -0
- package/dist/ai-server.browser.js +2 -2
- package/dist/ai-server.browser.js.map +1 -1
- package/dist/ai-server.d.ts +109 -43
- package/dist/ai-server.d.ts.map +1 -1
- package/dist/ai-server.js +526 -283
- package/dist/ai-server.js.map +1 -1
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +2 -2
- package/dist/bounded-cache-CPHWF-8h.js +41 -0
- package/dist/bounded-cache-CPHWF-8h.js.map +1 -0
- package/dist/{client-BYzHjkwU.js → client-BReKqwZC.js} +447 -80
- package/dist/client-BReKqwZC.js.map +1 -0
- package/dist/{client-CzyacQpJ.d.ts → client-h_DKFAjj.d.ts} +14 -13
- package/dist/client-h_DKFAjj.d.ts.map +1 -0
- package/dist/client.d.ts +4 -2
- package/dist/client.js +1 -1
- package/dist/{contract-CKRg_E4q.js → contract-BYKASlCV.js} +12 -21
- package/dist/contract-BYKASlCV.js.map +1 -0
- package/dist/{idempotent-replay-DVOlyYbx.js → idempotent-replay-JdgMQRRm.js} +2 -2
- package/dist/{idempotent-replay-DVOlyYbx.js.map → idempotent-replay-JdgMQRRm.js.map} +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/{errors-DvhSXnxk.d.ts → initial-snapshot-Bx-c0pDP.d.ts} +7 -3
- package/dist/initial-snapshot-Bx-c0pDP.d.ts.map +1 -0
- package/dist/{internal-Dq2qYxou.js → internal-B2T3U4Rq.js} +29 -2
- package/dist/internal-B2T3U4Rq.js.map +1 -0
- package/dist/otel.d.ts +1 -1
- package/dist/react-BBXgHWFc.d.ts +86 -0
- package/dist/react-BBXgHWFc.d.ts.map +1 -0
- package/dist/react.d.ts +2 -122
- package/dist/react.js +107 -100
- package/dist/react.js.map +1 -1
- package/dist/reducer-BAXc8JyF.js +87 -0
- package/dist/reducer-BAXc8JyF.js.map +1 -0
- package/dist/{reducer-otzHjuJj.d.ts → reducer-CqA59Q6U.d.ts} +46 -30
- package/dist/reducer-CqA59Q6U.d.ts.map +1 -0
- package/dist/reducer-runtime-DQwz_J59.js +28 -0
- package/dist/reducer-runtime-DQwz_J59.js.map +1 -0
- package/dist/scheduler-qstash.d.ts +3 -3
- package/dist/scheduler-qstash.d.ts.map +1 -1
- package/dist/scheduler-qstash.js +33 -10
- package/dist/scheduler-qstash.js.map +1 -1
- package/dist/{scheduler-task-BpzhPnRS.js → scheduler-task-X1SToDjP.js} +18 -3
- package/dist/scheduler-task-X1SToDjP.js.map +1 -0
- package/dist/scheduler-vercel.d.ts +4 -9
- package/dist/scheduler-vercel.d.ts.map +1 -1
- package/dist/scheduler-vercel.js +25 -44
- package/dist/scheduler-vercel.js.map +1 -1
- package/dist/{server-BD5ckxZb.js → server-Dw_k_7kO.js} +904 -219
- package/dist/server-Dw_k_7kO.js.map +1 -0
- package/dist/{server-DbD7IJVK.d.ts → server-En7cbi3v.d.ts} +116 -26
- package/dist/server-En7cbi3v.d.ts.map +1 -0
- package/dist/server.d.ts +4 -4
- package/dist/server.js +2 -2
- package/dist/session-clear-Bo-XTFEy.d.ts +12 -0
- package/dist/session-clear-Bo-XTFEy.d.ts.map +1 -0
- package/dist/{errors-DCk6ch5n.js → session-clear-DGI4jTQ5.js} +17 -2
- package/dist/session-clear-DGI4jTQ5.js.map +1 -0
- package/dist/{store-DyZM6fS5.d.ts → store-Djdv0bnZ.d.ts} +73 -3
- package/dist/store-Djdv0bnZ.d.ts.map +1 -0
- package/dist/store-N8PXxDAS.js.map +1 -1
- package/dist/store-memory.d.ts +1 -1
- package/dist/store-memory.d.ts.map +1 -1
- package/dist/store-memory.js +205 -66
- package/dist/store-memory.js.map +1 -1
- package/dist/{store-polling-CmxUbV93.js → store-polling-B5FcwJfo.js} +21 -4
- package/dist/store-polling-B5FcwJfo.js.map +1 -0
- package/dist/store-postgres.d.ts +1 -1
- package/dist/store-postgres.d.ts.map +1 -1
- package/dist/store-postgres.js +450 -108
- package/dist/store-postgres.js.map +1 -1
- package/dist/{store-presence-polling-C7-XZyW9.js → store-presence-polling-BAwS8RWn.js} +3 -3
- package/dist/{store-presence-polling-C7-XZyW9.js.map → store-presence-polling-BAwS8RWn.js.map} +1 -1
- package/dist/store-redis-http.d.ts +1 -1
- package/dist/store-redis-http.d.ts.map +1 -1
- package/dist/store-redis-http.js +293 -11
- package/dist/store-redis-http.js.map +1 -1
- package/dist/store-redis-notify-BRITti_o.js +2493 -0
- package/dist/store-redis-notify-BRITti_o.js.map +1 -0
- package/dist/store-redis.d.ts +1 -1
- package/dist/store-redis.d.ts.map +1 -1
- package/dist/store-redis.js +11 -11
- package/dist/store-redis.js.map +1 -1
- package/dist/store-sqlite.d.ts +1 -1
- package/dist/store-sqlite.d.ts.map +1 -1
- package/dist/store-sqlite.js +197 -33
- package/dist/store-sqlite.js.map +1 -1
- package/dist/stream-buffer-Cx7AAPGq.js +23 -0
- package/dist/stream-buffer-Cx7AAPGq.js.map +1 -0
- package/dist/{telemetry-B5jzpy6y.d.ts → telemetry-Cyfqo6Qt.d.ts} +2 -2
- package/dist/telemetry-Cyfqo6Qt.d.ts.map +1 -0
- package/dist/{wire-BO5wWCb1.js → wire-rSUglYo8.js} +132 -10
- package/dist/wire-rSUglYo8.js.map +1 -0
- package/docs/01-quickstart.mdx +50 -84
- package/docs/{guides/07-examples.mdx → 02-examples.mdx} +10 -20
- package/docs/actors/01-introduction.mdx +48 -82
- package/docs/actors/02-concurrency.mdx +43 -70
- package/docs/actors/03-timers.mdx +28 -42
- package/docs/actors/04-routes.mdx +110 -137
- package/docs/actors/meta.ts +1 -1
- package/docs/agents/01-introduction.mdx +257 -0
- package/docs/agents/02-tools.mdx +247 -0
- package/docs/agents/03-conversations.mdx +538 -0
- package/docs/agents/04-harnesses.mdx +136 -0
- package/docs/agents/meta.ts +1 -0
- package/docs/client/01-react.mdx +294 -0
- package/docs/client/02-transports.mdx +86 -0
- package/docs/client/03-presence.mdx +224 -0
- package/docs/client/meta.ts +1 -0
- package/docs/contract/01-events.mdx +57 -0
- package/docs/contract/02-state.mdx +142 -0
- package/docs/contract/03-sessions.mdx +175 -0
- package/docs/index.mdx +112 -156
- package/docs/reference/01-core.mdx +139 -0
- package/docs/reference/02-server.mdx +855 -0
- package/docs/reference/03-client.mdx +301 -0
- package/docs/reference/04-ai.mdx +722 -0
- package/docs/reference/05-adapters.mdx +351 -0
- package/docs/reference/06-errors.mdx +138 -0
- package/docs/reference/meta.ts +1 -1
- package/docs/server/01-handlers.mdx +200 -0
- package/docs/server/02-timers.mdx +130 -0
- package/docs/server/03-cancellation.mdx +141 -0
- package/docs/server/04-routes.mdx +243 -0
- package/docs/server/05-production.mdx +322 -0
- package/docs/server/06-guarantees.mdx +123 -0
- package/examples/playground/DEPLOY.md +53 -7
- package/examples/playground/app/a0/[appId]/loading.tsx +16 -0
- package/examples/playground/app/a0/[appId]/page.tsx +53 -0
- package/examples/playground/app/a0/a0.css +818 -0
- package/examples/playground/app/a0/app-list.tsx +218 -0
- package/examples/playground/app/a0/app-view.tsx +63 -0
- package/examples/playground/app/a0/apps/[appId]/preview/route.ts +27 -0
- package/examples/playground/app/a0/apps/[appId]/route.ts +28 -0
- package/examples/playground/app/a0/apps.test.ts +128 -0
- package/examples/playground/app/a0/apps.ts +102 -0
- package/examples/playground/app/a0/chat.tsx +410 -0
- package/examples/playground/app/a0/columns.tsx +109 -0
- package/examples/playground/app/a0/context-menu.tsx +116 -0
- package/examples/playground/app/a0/cookies.ts +46 -0
- package/examples/playground/app/a0/crash-on-request.ts +72 -0
- package/examples/playground/app/a0/crashes/route.ts +3 -0
- package/examples/playground/app/a0/crashes.test.ts +33 -0
- package/examples/playground/app/a0/crashes.ts +28 -0
- package/examples/playground/app/a0/devtools.tsx +164 -0
- package/examples/playground/app/a0/events/route.ts +6 -0
- package/examples/playground/app/a0/flags.ts +30 -0
- package/examples/playground/app/a0/fx/events/route.ts +9 -0
- package/examples/playground/app/a0/fx/scheduler/route.ts +7 -0
- package/examples/playground/app/a0/fx/short/events/route.ts +11 -0
- package/examples/playground/app/a0/layout.tsx +38 -0
- package/examples/playground/app/a0/list/route.ts +10 -0
- package/examples/playground/app/a0/model.test.ts +73 -0
- package/examples/playground/app/a0/model.ts +95 -0
- package/examples/playground/app/a0/no-photon.cjs +4 -0
- package/examples/playground/app/a0/no-quickjs.cjs +3 -0
- package/examples/playground/app/a0/page.tsx +14 -0
- package/examples/playground/app/a0/pi/events/route.ts +9 -0
- package/examples/playground/app/a0/pi/scheduler/route.ts +7 -0
- package/examples/playground/app/a0/pi/short/events/route.ts +11 -0
- package/examples/playground/app/a0/preview-pane.tsx +145 -0
- package/examples/playground/app/a0/preview.test.ts +53 -0
- package/examples/playground/app/a0/preview.ts +26 -0
- package/examples/playground/app/a0/sandbox-log.ts +75 -0
- package/examples/playground/app/a0/sandbox-session.ts +152 -0
- package/examples/playground/app/a0/sandbox.ts +191 -0
- package/examples/playground/app/a0/sandboxes/scheduler/route.ts +6 -0
- package/examples/playground/app/a0/scheduler/route.ts +7 -0
- package/examples/playground/app/a0/server.ts +213 -0
- package/examples/playground/app/a0/session.ts +59 -0
- package/examples/playground/app/a0/shell.tsx +158 -0
- package/examples/playground/app/a0/short/events/route.ts +9 -0
- package/examples/playground/app/a0/splitter.tsx +120 -0
- package/examples/playground/app/agent/[agentId]/agent-client.tsx +144 -174
- package/examples/playground/app/agent/[agentId]/command-receipt.test.tsx +65 -0
- package/examples/playground/app/agent/[agentId]/command-receipt.tsx +27 -0
- package/examples/playground/app/agent/[agentId]/compaction-event.tsx +25 -24
- package/examples/playground/app/agent/[agentId]/compaction-panel.test.tsx +119 -0
- package/examples/playground/app/agent/[agentId]/compaction-panel.tsx +208 -165
- package/examples/playground/app/agent/[agentId]/page.tsx +2 -16
- package/examples/playground/app/agent/events/route.ts +5 -2
- package/examples/playground/app/agent/ingress.test.ts +101 -0
- package/examples/playground/app/agent/model-input.test.tsx +58 -0
- package/examples/playground/app/agent/model-input.tsx +115 -0
- package/examples/playground/app/agent/model.test.ts +73 -0
- package/examples/playground/app/agent/model.ts +58 -26
- package/examples/playground/app/agent/new-agent-session.tsx +37 -19
- package/examples/playground/app/agent/page.tsx +4 -4
- package/examples/playground/app/agent/server.ts +19 -15
- package/examples/playground/app/agent/session.ts +5 -6
- package/examples/playground/app/agent/telemetry.test.ts +189 -0
- package/examples/playground/app/agent/telemetry.ts +30 -0
- package/examples/playground/app/agent/trace.test.ts +23 -0
- package/examples/playground/app/agent/trace.ts +18 -0
- package/examples/playground/app/canvas/[canvasId]/canvas-client.tsx +12 -12
- package/examples/playground/app/canvas/[canvasId]/page.tsx +1 -2
- package/examples/playground/app/canvas/[canvasId]/session.ts +2 -2
- package/examples/playground/app/canvas/model.ts +53 -53
- package/examples/playground/app/chat/[chatId]/agent-state.test.ts +176 -0
- package/examples/playground/app/chat/[chatId]/agent-stream-drawer.tsx +16 -1
- package/examples/playground/app/chat/[chatId]/chat-client.tsx +55 -77
- package/examples/playground/app/chat/[chatId]/chat-view.ts +37 -3
- package/examples/playground/app/chat/[chatId]/page.tsx +7 -15
- package/examples/playground/app/chat/[chatId]/session.ts +2 -19
- package/examples/playground/app/chat/agent/route.ts +9 -0
- package/examples/playground/app/chat/model.test.ts +46 -119
- package/examples/playground/app/chat/model.ts +82 -128
- package/examples/playground/app/chat/scheduler/route.ts +2 -2
- package/examples/playground/app/chat/server.test.ts +112 -0
- package/examples/playground/app/chat/server.ts +113 -117
- package/examples/playground/app/components/activity-feed.tsx +30 -1
- package/examples/playground/app/components/activity-history.test.tsx +35 -0
- package/examples/playground/app/components/demo-icons.tsx +89 -0
- package/examples/playground/app/components/demos.tsx +33 -0
- package/examples/playground/app/components/fast-link.test.tsx +58 -0
- package/examples/playground/app/components/fast-link.tsx +55 -0
- package/examples/playground/app/components/site-header.tsx +96 -0
- package/examples/playground/app/counter/counter-client.tsx +3 -3
- package/examples/playground/app/counter/model.test.ts +3 -3
- package/examples/playground/app/counter/model.ts +11 -21
- package/examples/playground/app/counter/page.tsx +2 -15
- package/examples/playground/app/counter/session.ts +2 -2
- package/examples/playground/app/documents/[documentId]/code-editor.tsx +12 -1
- package/examples/playground/app/documents/[documentId]/document-client.tsx +10 -11
- package/examples/playground/app/documents/[documentId]/page.tsx +1 -2
- package/examples/playground/app/documents/[documentId]/session.ts +2 -2
- package/examples/playground/app/documents/model.ts +27 -27
- package/examples/playground/app/globals.css +420 -207
- package/examples/playground/app/initial-state.test.tsx +54 -0
- package/examples/playground/app/layout.tsx +7 -23
- package/examples/playground/app/orders/[orderId]/page.tsx +1 -2
- package/examples/playground/app/orders/[orderId]/session.ts +2 -2
- package/examples/playground/app/orders/model.ts +49 -49
- package/examples/playground/app/page.tsx +13 -102
- package/examples/playground/app/recovery/[recoveryId]/page.tsx +1 -2
- package/examples/playground/app/recovery/[recoveryId]/session.ts +2 -2
- package/examples/playground/app/recovery/model.ts +30 -30
- package/examples/playground/instrumentation.ts +5 -0
- package/examples/playground/next.config.ts +17 -5
- package/examples/playground/package.json +13 -2
- package/examples/playground/scripts/a0-template.ts +77 -0
- package/examples/playground/vercel.json +36 -0
- package/package.json +29 -3
- package/src/actor-client.ts +16 -4
- package/src/actor-react.ts +25 -11
- package/src/actor-shared.ts +21 -6
- package/src/actor.ts +76 -31
- package/src/ai-agent-actions.ts +219 -0
- package/src/ai-agent.ts +2517 -0
- package/src/ai-app-state.ts +91 -0
- package/src/ai-client-state.ts +6 -3
- package/src/ai-client.ts +62 -0
- package/src/ai-context-schema.ts +25 -5
- package/src/ai-context.ts +90 -40
- package/src/ai-control-server.ts +92 -72
- package/src/ai-coordinator.ts +23 -22
- package/src/ai-fx.browser.ts +5 -0
- package/src/ai-fx.ts +833 -0
- package/src/ai-harness.ts +518 -0
- package/src/ai-message-base.ts +209 -0
- package/src/ai-message-projection.ts +262 -64
- package/src/ai-model-metadata.ts +11 -6
- package/src/ai-pi.browser.ts +5 -0
- package/src/ai-pi.ts +1263 -0
- package/src/ai-progress-batches.ts +26 -0
- package/src/ai-projector.ts +95 -14
- package/src/ai-react.ts +146 -0
- package/src/ai-sdk-step.ts +2 -2
- package/src/ai-server.browser.ts +2 -2
- package/src/ai-server.ts +23 -1965
- package/src/ai-stored-state.ts +48 -163
- package/src/ai.ts +339 -155
- package/src/bootstrap-stream.ts +72 -0
- package/src/bounded-cache.ts +55 -0
- package/src/client-render-session.ts +49 -0
- package/src/client.ts +688 -151
- package/src/contract.ts +92 -42
- package/src/deterministic-id.ts +37 -0
- package/src/equal-json.ts +32 -0
- package/src/errors.ts +13 -1
- package/src/index.ts +5 -1
- package/src/initial-snapshot.ts +39 -0
- package/src/internal.ts +52 -0
- package/src/libfx.d.ts +34 -0
- package/src/postgres-notification-scope.ts +14 -3
- package/src/react.ts +171 -206
- package/src/redis-http-reply.ts +256 -0
- package/src/redis-http-stream.ts +73 -0
- package/src/redis-http-subscriptions.ts +13 -5
- package/src/reducer-runtime.ts +52 -0
- package/src/reducer.ts +93 -11
- package/src/scheduler-qstash.ts +49 -20
- package/src/scheduler-task.ts +34 -2
- package/src/scheduler-vercel.ts +32 -84
- package/src/server-fetch.ts +139 -35
- package/src/server.ts +1133 -255
- package/src/session-clear.ts +23 -0
- package/src/session-socket.ts +154 -49
- package/src/sse.ts +71 -4
- package/src/store-memory.ts +252 -75
- package/src/store-polling.ts +18 -4
- package/src/store-postgres.ts +541 -114
- package/src/store-redis-core.ts +1450 -493
- package/src/store-redis-http.ts +18 -2
- package/src/store-redis-notify.ts +262 -85
- package/src/store-redis.ts +19 -9
- package/src/store-sqlite.ts +319 -45
- package/src/store.ts +79 -1
- package/src/stream-buffer.ts +43 -0
- package/src/telemetry.ts +14 -1
- package/src/wire.ts +241 -13
- package/dist/actor-ohPC-81x.d.ts.map +0 -1
- package/dist/actor-shared-B5tJfzt-.js.map +0 -1
- package/dist/ai-CrEf6p_W.d.ts.map +0 -1
- package/dist/ai-DgOBltJ_.js.map +0 -1
- package/dist/client-BYzHjkwU.js.map +0 -1
- package/dist/client-CzyacQpJ.d.ts.map +0 -1
- package/dist/contract-CKRg_E4q.js.map +0 -1
- package/dist/errors-DCk6ch5n.js.map +0 -1
- package/dist/errors-DvhSXnxk.d.ts.map +0 -1
- package/dist/internal-Dq2qYxou.js.map +0 -1
- package/dist/react.d.ts.map +0 -1
- package/dist/reducer-DEMjEY_O.js +0 -29
- package/dist/reducer-DEMjEY_O.js.map +0 -1
- package/dist/reducer-otzHjuJj.d.ts.map +0 -1
- package/dist/scheduler-task-BpzhPnRS.js.map +0 -1
- package/dist/server-BD5ckxZb.js.map +0 -1
- package/dist/server-DbD7IJVK.d.ts.map +0 -1
- package/dist/store-DyZM6fS5.d.ts.map +0 -1
- package/dist/store-polling-CmxUbV93.js.map +0 -1
- package/dist/store-redis-notify-BVLUfI3j.js +0 -1583
- package/dist/store-redis-notify-BVLUfI3j.js.map +0 -1
- package/dist/telemetry-B5jzpy6y.d.ts.map +0 -1
- package/dist/validate-XKT4FSNn.js +0 -30
- package/dist/validate-XKT4FSNn.js.map +0 -1
- package/dist/wire-BO5wWCb1.js.map +0 -1
- package/docs/concepts/01-contracts.mdx +0 -142
- package/docs/concepts/02-handlers.mdx +0 -284
- package/docs/concepts/03-durability.mdx +0 -314
- package/docs/concepts/04-state.mdx +0 -209
- package/docs/guides/01-timers.mdx +0 -185
- package/docs/guides/02-cancellation.mdx +0 -161
- package/docs/guides/03-react.mdx +0 -384
- package/docs/guides/04-local-first.mdx +0 -88
- package/docs/guides/05-production.mdx +0 -521
- package/docs/guides/06-ai-agents.mdx +0 -1318
- package/docs/guides/08-application-data.mdx +0 -113
- package/docs/guides/09-presence.mdx +0 -266
- package/docs/guides/10-transports.mdx +0 -221
- package/docs/reference/01-api.mdx +0 -1896
- package/docs/reference/02-errors.mdx +0 -149
- package/examples/playground/app/agent/[agentId]/compaction/route.ts +0 -14
- package/examples/playground/app/agent/compaction-settings.test.ts +0 -144
- package/examples/playground/app/agent/compaction-settings.ts +0 -49
- package/examples/playground/app/agent/compaction-timeline.test.ts +0 -377
- package/examples/playground/app/agent/compaction-timeline.ts +0 -208
- /package/docs/{concepts → contract}/meta.ts +0 -0
- /package/docs/{guides → server}/meta.ts +0 -0
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { FinishReason, JSONValue, LanguageModelUsage, UIMessage, UIMessage as UIMessage$1, UIMessageChunk, UIMessageChunk as UIMessageChunk$1 } from "ai";
|
|
1
|
+
import { c as ContractEvent, s as Contract, t as Reducer, u as EventDefs, v as StandardSchemaV1 } from "./reducer-CqA59Q6U.js";
|
|
2
|
+
import { c as HandlerContext } from "./server-En7cbi3v.js";
|
|
3
|
+
import { FinishReason, JSONValue as JSONValue$1, LanguageModelCallOptions, LanguageModelUsage, UIMessage, UIMessage as UIMessage$1, UIMessageChunk, UIMessageChunk as UIMessageChunk$1 } from "ai";
|
|
4
|
+
//#region src/ai-message-base.d.ts
|
|
5
|
+
type FieldUndo = {
|
|
6
|
+
value?: unknown;
|
|
7
|
+
} | {
|
|
8
|
+
remove: true;
|
|
9
|
+
} | {
|
|
10
|
+
length: number;
|
|
11
|
+
};
|
|
12
|
+
type FieldsUndo = Record<string, FieldUndo>;
|
|
13
|
+
type PartUndo = {
|
|
14
|
+
value: UIMessage["parts"][number];
|
|
15
|
+
} | {
|
|
16
|
+
fields: FieldsUndo;
|
|
17
|
+
};
|
|
18
|
+
type MessageBase = {
|
|
19
|
+
partCount: number;
|
|
20
|
+
fields?: FieldsUndo;
|
|
21
|
+
parts?: Record<string, PartUndo>;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
4
24
|
//#region src/ai-control.d.ts
|
|
5
25
|
type InboxItem<M extends UIMessage = UIMessage> = {
|
|
6
26
|
id: string;
|
|
@@ -161,56 +181,37 @@ type ProgressBatches = {
|
|
|
161
181
|
};
|
|
162
182
|
//#endregion
|
|
163
183
|
//#region src/ai-message-projection.d.ts
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
type Value = null | boolean | number | string | Value[] | {
|
|
168
|
-
[key: string]: Value;
|
|
169
|
-
};
|
|
170
|
-
type Payload = {
|
|
171
|
-
value?: unknown;
|
|
172
|
-
};
|
|
173
|
-
type Undo = {
|
|
174
|
-
value: Value;
|
|
175
|
-
} | {
|
|
176
|
-
length: number;
|
|
177
|
-
items: Record<string, Undo>;
|
|
178
|
-
} | {
|
|
179
|
-
fields: Record<string, Undo>;
|
|
180
|
-
remove: string[];
|
|
181
|
-
};
|
|
182
|
-
type Projection = {
|
|
183
|
-
fields: Value;
|
|
184
|
-
hasMessage: boolean;
|
|
185
|
-
message?: Undo;
|
|
186
|
-
tools?: Undo;
|
|
187
|
-
};
|
|
188
|
-
type AIStoredState = {
|
|
189
|
-
version: 2;
|
|
190
|
-
fields: Value;
|
|
191
|
-
projection: Projection | null;
|
|
192
|
-
values: Payload[];
|
|
193
|
-
};
|
|
194
|
-
type AIStoredView = {
|
|
195
|
-
messages: UIMessage[];
|
|
196
|
-
activeProjection: (MessageProjection<UIMessage> & {
|
|
197
|
-
baseTools?: AIState["tools"];
|
|
198
|
-
}) | null;
|
|
199
|
-
tools?: AIState["tools"];
|
|
200
|
-
usage?: AIState["usage"];
|
|
201
|
-
};
|
|
202
|
-
declare const aiStateReducer: unique symbol;
|
|
203
|
-
type AIStoredReducer<D extends EventDefs, S extends AIStoredView> = Reducer<D, AIStoredState, Record<never, never>, S> & {
|
|
204
|
-
readonly [aiStateReducer]: Reducer<D, S>;
|
|
205
|
-
view(state: AIStoredState): S;
|
|
206
|
-
fromView(state: S): AIStoredState;
|
|
207
|
-
};
|
|
184
|
+
declare const isCompactionPart: (part: {
|
|
185
|
+
type: string;
|
|
186
|
+
}) => part is CompactionPart;
|
|
208
187
|
//#endregion
|
|
209
188
|
//#region src/ai.d.ts
|
|
210
189
|
type AgentStatus = "idle" | "generating" | "waiting" | "failed" | "closed" | "paused";
|
|
211
190
|
type GenerationReason = "message" | "tool" | "input" | "retry" | "resume";
|
|
191
|
+
type ReasoningLevel = NonNullable<LanguageModelCallOptions["reasoning"]>;
|
|
192
|
+
declare const reasoningLevels: readonly ReasoningLevel[];
|
|
193
|
+
type CompactionPartData = {
|
|
194
|
+
status: "running" | "completed" | "failed" | "interrupted";
|
|
195
|
+
inputTokens?: number;
|
|
196
|
+
thresholdTokens?: number;
|
|
197
|
+
summary?: string;
|
|
198
|
+
usage?: LanguageModelUsage;
|
|
199
|
+
};
|
|
200
|
+
/** The transcript part A2 adds to a response where its context was compacted. */
|
|
201
|
+
type CompactionPart = {
|
|
202
|
+
type: "data-a2-compaction";
|
|
203
|
+
id: string;
|
|
204
|
+
data: CompactionPartData;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* A transcript message: `M` plus the compaction part A2 adds, so
|
|
208
|
+
* `isCompactionPart` narrows even when `M` declares its own data parts.
|
|
209
|
+
*/
|
|
210
|
+
type TranscriptMessage<M extends UIMessage$1> = Omit<M, "parts"> & {
|
|
211
|
+
parts: Array<M["parts"][number] | CompactionPart>;
|
|
212
|
+
};
|
|
212
213
|
type SessionCreatedPayload = {
|
|
213
|
-
metadata?: JSONValue;
|
|
214
|
+
metadata?: JSONValue$1;
|
|
214
215
|
};
|
|
215
216
|
type SessionClosedPayload = {
|
|
216
217
|
reason?: string;
|
|
@@ -258,15 +259,13 @@ type GenerationStartedPayload = {
|
|
|
258
259
|
generationId: string;
|
|
259
260
|
responseMessageId: string;
|
|
260
261
|
attempt: number;
|
|
261
|
-
model
|
|
262
|
+
/** Absent when the attempt failed before its model resolved. */
|
|
263
|
+
model?: string;
|
|
262
264
|
promptThroughIndex?: number;
|
|
263
265
|
};
|
|
264
266
|
type GenerationProgressPayload = {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
generationId: string;
|
|
268
|
-
responseMessageId: string;
|
|
269
|
-
sequence: number;
|
|
267
|
+
/** Log index of the generation's `ai.generation.started`. */
|
|
268
|
+
startIndex: number;
|
|
270
269
|
chunks: UIMessageChunk$1[];
|
|
271
270
|
};
|
|
272
271
|
type GenerationCompletedPayload = {
|
|
@@ -343,7 +342,7 @@ type InputRequestedPayload = {
|
|
|
343
342
|
generationId: string;
|
|
344
343
|
inputId: string;
|
|
345
344
|
name: string;
|
|
346
|
-
question?: JSONValue;
|
|
345
|
+
question?: JSONValue$1;
|
|
347
346
|
};
|
|
348
347
|
type InputRespondedPayload = {
|
|
349
348
|
requestId: string;
|
|
@@ -351,7 +350,7 @@ type InputRespondedPayload = {
|
|
|
351
350
|
generationId: string;
|
|
352
351
|
inputId: string;
|
|
353
352
|
name: string;
|
|
354
|
-
value: JSONValue;
|
|
353
|
+
value: JSONValue$1;
|
|
355
354
|
};
|
|
356
355
|
type ModelLimits = {
|
|
357
356
|
contextWindow: number;
|
|
@@ -421,19 +420,22 @@ type AIEventDefs<M extends UIMessage$1 = UIMessage$1> = {
|
|
|
421
420
|
"ai.model.metadata.requested": StandardSchemaV1<ModelMetadataRequestedPayload>;
|
|
422
421
|
"ai.model.metadata.resolved": StandardSchemaV1<ModelMetadataResolvedPayload>;
|
|
423
422
|
};
|
|
424
|
-
type ActiveGeneration = GenerationStartedPayload
|
|
425
|
-
|
|
423
|
+
type ActiveGeneration = GenerationStartedPayload & {
|
|
424
|
+
/** Log index of this generation's `ai.generation.started`. */
|
|
425
|
+
startIndex: number;
|
|
426
|
+
};
|
|
427
|
+
type ActiveGenerationProjection = {
|
|
426
428
|
generationId: string;
|
|
427
429
|
responseMessageId: string;
|
|
428
430
|
/** Log index of the completed model step while its response remains interruptible. */
|
|
429
431
|
completionIndex?: number;
|
|
430
|
-
|
|
432
|
+
base?: MessageBase;
|
|
431
433
|
promptThroughIndex?: number;
|
|
432
434
|
cursor?: {
|
|
433
435
|
throughIndex: number;
|
|
434
436
|
stream: UIMessageCursor;
|
|
435
437
|
} | null;
|
|
436
|
-
baseCompaction?: CompactionState
|
|
438
|
+
baseCompaction?: CompactionState | null;
|
|
437
439
|
batches: ProgressBatches;
|
|
438
440
|
baseTools: ToolActivity[];
|
|
439
441
|
toolEvents: Array<{
|
|
@@ -463,27 +465,19 @@ type ToolActivity = {
|
|
|
463
465
|
generationId: string;
|
|
464
466
|
toolCallId: string;
|
|
465
467
|
toolName?: string;
|
|
466
|
-
input?: unknown;
|
|
467
|
-
rawInput?: unknown;
|
|
468
|
-
output?: unknown;
|
|
469
468
|
error?: string;
|
|
470
469
|
preliminary?: boolean;
|
|
471
470
|
phase?: "input" | "execution";
|
|
472
471
|
dynamic?: boolean;
|
|
473
472
|
providerExecuted?: boolean;
|
|
474
|
-
callProviderMetadata?: unknown;
|
|
475
|
-
resultProviderMetadata?: unknown;
|
|
476
|
-
toolMetadata?: unknown;
|
|
477
473
|
title?: string;
|
|
478
474
|
status: "running" | "completed" | "failed" | "denied";
|
|
479
475
|
};
|
|
480
|
-
type CompactionState
|
|
476
|
+
type CompactionState = {
|
|
481
477
|
status: "running" | "completed";
|
|
482
478
|
generationId: string;
|
|
483
479
|
throughMessageId: string;
|
|
484
480
|
throughIndex?: number;
|
|
485
|
-
messages?: M[];
|
|
486
|
-
retainedMessageIds?: string[];
|
|
487
481
|
summary?: string;
|
|
488
482
|
usage?: LanguageModelUsage;
|
|
489
483
|
};
|
|
@@ -503,43 +497,68 @@ type AIState<M extends UIMessage$1 = UIMessage$1> = {
|
|
|
503
497
|
pausedGenerationIds?: Record<string, true>;
|
|
504
498
|
session: {
|
|
505
499
|
created: boolean;
|
|
506
|
-
metadata?: JSONValue;
|
|
500
|
+
metadata?: JSONValue$1;
|
|
507
501
|
};
|
|
508
|
-
messages: M[];
|
|
502
|
+
messages: TranscriptMessage<M>[];
|
|
509
503
|
status: AgentStatus;
|
|
510
504
|
activeGeneration: ActiveGeneration | null;
|
|
511
505
|
activeRequestId: string | null;
|
|
512
506
|
activeRequestReason: GenerationReason | null;
|
|
513
507
|
activeRequestSourceGenerationId: string | null;
|
|
514
508
|
activeResponseMessageId: string | null;
|
|
515
|
-
activeProjection: ActiveGenerationProjection
|
|
509
|
+
activeProjection: ActiveGenerationProjection | null;
|
|
516
510
|
responseOwners: Record<string, Pick<GenerationStartedPayload, "generationId" | "requestId" | "attempt">>;
|
|
517
511
|
terminalRequestIds?: Record<string, true>;
|
|
518
512
|
terminalGenerations?: Record<string, "completed" | "failed" | "interrupted" | "superseded">;
|
|
519
513
|
pendingApprovals: PendingApproval[];
|
|
520
514
|
pendingInputs: PendingInput[];
|
|
521
515
|
tools: ToolActivity[];
|
|
522
|
-
compaction: CompactionState
|
|
516
|
+
compaction: CompactionState | null;
|
|
523
517
|
modelMetadata: Record<string, ModelMetadataState>;
|
|
524
518
|
usage: GenerationUsage[];
|
|
525
519
|
error: string | null;
|
|
526
520
|
};
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
readonly
|
|
530
|
-
};
|
|
521
|
+
/** The `UIMessage` type a contract's `ai.message.created` schema carries. */
|
|
522
|
+
type AIMessageOf<D> = D extends {
|
|
523
|
+
readonly "ai.message.created": infer S extends StandardSchemaV1;
|
|
524
|
+
} ? StandardSchemaV1.InferOutput<S> extends MessageCreatedPayload<infer M extends UIMessage$1> ? M : UIMessage$1 : UIMessage$1;
|
|
525
|
+
/** What `agentContract()` returns: the AI protocol, with `X` as application state. */
|
|
526
|
+
type AgentContract<M extends UIMessage$1 = UIMessage$1, D extends EventDefs = AIEventDefs<M>, X extends object = Record<never, never>> = Contract<D, Record<never, never>, AgentReducer<M, D, X>>;
|
|
531
527
|
type AgentToolEventDefs = EventDefs & Pick<AIEventDefs, "ai.tool.execution.requested">;
|
|
532
528
|
/** The durable handler context supplied when A2 executes a local AI tool. */
|
|
533
529
|
type AgentToolContext<D extends AgentToolEventDefs> = HandlerContext<D, "ai.tool.execution.requested">;
|
|
534
|
-
|
|
530
|
+
/** Application state folded after the AI protocol, on the server and in clients. */
|
|
531
|
+
/** Rejects application state keys that would shadow `AIState`'s. */
|
|
532
|
+
type OwnKeys<X> = { [K in Extract<keyof X, keyof AIState>]: never; };
|
|
533
|
+
/** Rejects a stateless application reducer, whose name would not be built in. */
|
|
534
|
+
type NonEmpty<X> = keyof X extends never ? never : unknown;
|
|
535
|
+
/**
|
|
536
|
+
* The reducer `agentContract()` builds. Without application state it carries
|
|
537
|
+
* the built-in name, which is what lets the contract-free client fold it.
|
|
538
|
+
* `~appState` is type-only, absent at runtime: it carries the application
|
|
539
|
+
* state's type to `agent()`, and marks the reducer as `agentContract()`'s.
|
|
540
|
+
*/
|
|
541
|
+
type AgentReducer<M extends UIMessage$1, D extends EventDefs, X extends object> = (keyof X extends never ? Reducer<D, AIState<M>> & {
|
|
542
|
+
readonly name: typeof AI_STATE_REDUCER;
|
|
543
|
+
} : Reducer<D, AIState<M> & X>) & {
|
|
544
|
+
readonly "~appState": X;
|
|
545
|
+
};
|
|
546
|
+
type AgentContractOptions<M extends UIMessage$1, E extends EventDefs, X extends object> = {
|
|
535
547
|
name: string;
|
|
536
548
|
events?: E;
|
|
537
549
|
/** Optional stricter schema for custom UIMessage metadata/data/tool types. */
|
|
538
550
|
messageSchema?: StandardSchemaV1<M>;
|
|
539
|
-
/**
|
|
540
|
-
|
|
551
|
+
/**
|
|
552
|
+
* Application state, folded from events beside `AIState` and merged into
|
|
553
|
+
* it. `fold` sees only this state, never the transcript.
|
|
554
|
+
*/
|
|
555
|
+
reducer?: {
|
|
556
|
+
/** Snapshot identity of the application state. Rename it when `fold` changes. */
|
|
557
|
+
name: string;
|
|
558
|
+
initialState: X & OwnKeys<X> & NonEmpty<X>;
|
|
559
|
+
fold: (state: NoInfer<X>, event: ContractEvent<AIEventDefs<M> & NoInfer<E>>) => NoInfer<X>;
|
|
560
|
+
};
|
|
541
561
|
};
|
|
542
|
-
type AIMessageFrom<D extends EventDefs> = D extends Record<"ai.message.created", infer S extends StandardSchemaV1> ? StandardSchemaV1.InferOutput<S> extends MessageCreatedPayload<infer M extends UIMessage$1> ? M : UIMessage$1 : UIMessage$1;
|
|
543
562
|
declare function createEvents<M extends UIMessage$1 = UIMessage$1>(options?: {
|
|
544
563
|
messageSchema?: StandardSchemaV1<M>;
|
|
545
564
|
}): AIEventDefs<M>;
|
|
@@ -556,14 +575,7 @@ declare function deriveUIMessages<M extends UIMessage$1 = UIMessage$1>(history:
|
|
|
556
575
|
type: string;
|
|
557
576
|
payload: unknown;
|
|
558
577
|
index: number;
|
|
559
|
-
}[]): M[];
|
|
560
|
-
/** Build the standard AI state projection for any contract containing the protocol. */
|
|
561
|
-
declare function createReducer<D extends EventDefs>(options: {
|
|
562
|
-
contract: Contract<D>;
|
|
563
|
-
name?: string;
|
|
564
|
-
fold?: Reducer<D, AIState<AIMessageFrom<D>>>["fold"];
|
|
565
|
-
stateSchema?: StandardSchemaV1<unknown, AIState<AIMessageFrom<D>>>;
|
|
566
|
-
}): AIStoredReducer<D, AIState<AIMessageFrom<D>>>;
|
|
578
|
+
}[]): TranscriptMessage<M>[];
|
|
567
579
|
type CommandInput<C> = {
|
|
568
580
|
type: "ai.control.requested";
|
|
569
581
|
payload: C;
|
|
@@ -622,18 +634,20 @@ declare const inputs: AIInputs;
|
|
|
622
634
|
* Read the durable handler context ambient to the current AI tool
|
|
623
635
|
* execution. A2 runs each local tool's `execute` inside this scope, so
|
|
624
636
|
* plain AI SDK `tool()` definitions reach their `event`, `attempt`,
|
|
625
|
-
* `session`, and `signal` without an A2-specific wrapper.
|
|
626
|
-
* contract
|
|
627
|
-
* the executing
|
|
637
|
+
* `session`, and `signal` without an A2-specific wrapper. Pass the
|
|
638
|
+
* agent's contract to type application events; it is verified against
|
|
639
|
+
* the executing agent.
|
|
628
640
|
*/
|
|
629
|
-
declare function handlerContext<D extends AgentToolEventDefs>(
|
|
630
|
-
|
|
631
|
-
|
|
641
|
+
declare function handlerContext<D extends AgentToolEventDefs = AIEventDefs>(contract?: Contract<D>): AgentToolContext<D>;
|
|
642
|
+
/** The built-in AI reducer's name, and so its checkpoint identity. */
|
|
643
|
+
declare const AI_STATE_REDUCER = "a2.ai.state.v26";
|
|
632
644
|
/**
|
|
633
|
-
*
|
|
634
|
-
* reducer
|
|
645
|
+
* The built-in AI protocol plus application events, as a core contract whose
|
|
646
|
+
* reducer folds `AIState`. Isomorphic: share it when a client needs
|
|
647
|
+
* application events or extended state; otherwise `agent({ name })` on the
|
|
648
|
+
* server builds one and clients use the built-in protocol.
|
|
635
649
|
*/
|
|
636
|
-
declare function
|
|
650
|
+
declare function agentContract<M extends UIMessage$1 = UIMessage$1, E extends EventDefs = Record<never, never>, X extends object = Record<never, never>>(options: AgentContractOptions<M, E, X>): AgentContract<M, AIEventDefs<M> & E, X>;
|
|
637
651
|
//#endregion
|
|
638
|
-
export {
|
|
639
|
-
//# sourceMappingURL=ai-
|
|
652
|
+
export { agentContract as $, InputRespondedPayload as A, PendingApproval as B, GenerationFailedPayload as C, GenerationStartedPayload as D, GenerationRequestedPayload as E, MessageInterruptedPayload as F, SessionClosedPayload as G, ReasoningLevel as H, ModelLimits as I, ToolCalledPayload as J, SessionCreatedPayload as K, ModelMetadataRequestedPayload as L, LanguageModelUsage as M, MessageCompletedPayload as N, GenerationUsage as O, MessageCreatedPayload as P, UIMessageChunk$1 as Q, ModelMetadataResolvedPayload as R, GenerationCompletedPayload as S, GenerationReason as T, RetryGenerationOptions as U, PendingInput as V, RetryRequestedPayload as W, TranscriptMessage as X, ToolResultPayload as Y, UIMessage$1 as Z, CompactionPart as _, AI_STATE_REDUCER as a, reasoningLevels as at, CompactionState as b, AgentContract as c, PendingQueueCommand as ct, AgentStatus as d, ControlReceipt as dt, createEvents as et, AgentToolContext as f, InboxItem as ft, CompactionCompletedPayload as g, ApprovalRespondedPayload as h, AIState as i, inputs as it, JSONValue$1 as j, InputRequestedPayload as k, AgentContractOptions as l, ActiveTurn as lt, ApprovalRequestedPayload as m, AIInputs as n, events as nt, ActiveGeneration as o, reduceAIState as ot, AgentToolEventDefs as p, ToolActivity as q, AIMessageOf as r, handlerContext as rt, ActiveGenerationProjection as s, isCompactionPart as st, AIEventDefs as t, deriveUIMessages as tt, AgentReducer as u, ControlCommand as ut, CompactionPartData as v, GenerationProgressPayload as w, FinishReason as x, CompactionRequestedPayload as y, ModelMetadataState as z };
|
|
653
|
+
//# sourceMappingURL=ai-DrUaMyRt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-DrUaMyRt.d.ts","names":[],"sources":["../src/ai-message-base.ts","../src/ai-control.ts","../src/ai-client-state.ts","../src/ai-projector.ts","../src/ai-progress-batches.ts","../src/ai-message-projection.ts","../src/ai.ts"],"mappings":";;;;KAGK;EAAc;;EAAsB;;EAAmB;;KACvD,aAAa,eAAe;KAC5B;EAAa,OAAO;;EAAiC,QAAQ;;KAEtD;EACV;EACA,SAAS;EACT,QAAQ,eAAe;;;;KCIb,UAAU,UAAU,YAAY;EAC1C;EACA,SAAS;EACT;EACA;;KAGU,eAAe,UAAU,YAAY;EAC3C;EAAgB,SAAS;EAAG;;EAC5B;EAAgB,SAAS;;EACzB;EAAgB;EAAiB;;EACjC;EAAkB;;EAElB;EACA;EACA;EACA;;EAEA;EAAgB;EAAgB;;EAChC;EAAiB;EAAgB,SAAS;EAAG;;EAC7C;EAAiB;;EACjB;;EACA;EAAuB,QAAQ;;EAC/B;EAAoB,UAAU;;EAC9B;EAAiB,UAAU;;EAC3B;EAAyB,SAAS;;EAClC;EAAiB,SAAS;;EAC1B;EAAqB,SAAS;;KAExB;EACV;EACA;EACA;EACA;;KAUU,WAAW,UAAU,YAAY;EAC3C;EACA,OAAO,UAAU;EACjB;;KA+BU;EAAa;EAAc;EAAY;;KACvC;EACV;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ;;KAGE;EACV;EACA;EACA,MAAM;EACN,YAAY;;KAYF;EACV;EACA;EACA;E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 -0,0 +1,27 @@
|
|
|
1
|
+
import { s as CreateClientOptions, t as A2Client } from "./client-h_DKFAjj.js";
|
|
2
|
+
import { a as AI_STATE_REDUCER, i as AIState, r as AIMessageOf, t as AIEventDefs } from "./ai-DrUaMyRt.js";
|
|
3
|
+
//#region src/ai-client.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The structural shape of `typeof` an `agent({ name })` server: one whose
|
|
6
|
+
* state the built-in reducer folds. Agents built from an extended contract
|
|
7
|
+
* use `createClient({ contract })` instead.
|
|
8
|
+
*/
|
|
9
|
+
type AnyAgent = {
|
|
10
|
+
readonly contract: {
|
|
11
|
+
readonly events: object;
|
|
12
|
+
readonly reducer: {
|
|
13
|
+
readonly name: typeof AI_STATE_REDUCER;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
type AgentMessage<A extends AnyAgent> = AIMessageOf<A["contract"]["events"]>;
|
|
18
|
+
type AgentClient<A extends AnyAgent = AnyAgent> = A2Client<AIEventDefs<AgentMessage<A>>, AIState<AgentMessage<A>>>;
|
|
19
|
+
type CreateAgentClientOptions = Omit<CreateClientOptions<AIEventDefs, AIState>, "contract">;
|
|
20
|
+
/**
|
|
21
|
+
* A client for the built-in AI protocol. Agents built from a shared
|
|
22
|
+
* `agentContract()` use `createClient({ contract })` instead.
|
|
23
|
+
*/
|
|
24
|
+
declare function createAgentClient<A extends AnyAgent = AnyAgent>(options: CreateAgentClientOptions): AgentClient<A>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AgentClient, AgentMessage, AnyAgent, CreateAgentClientOptions, createAgentClient };
|
|
27
|
+
//# sourceMappingURL=ai-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-client.d.ts","names":[],"sources":["../src/ai-client.ts"],"mappings":";;;;;;;;KA8BY;WACD;aACE;aACA;eAAoB,aAAa;;;;KAIlC,aAAa,UAAU,YAAY,YAC7C;KAGU,YAAY,UAAU,WAAW,YAAY,SACvD,YAAY,aAAa,KACzB,QAAQ,aAAa;KAGX,2BAA2B,KACrC,oBAAoB,aAAa;;;;;iBAUnB,kBAAkB,UAAU,WAAW,UACrD,SAAS,2BACR,YAAY"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { t as createClient } from "./client-BReKqwZC.js";
|
|
2
|
+
import { n as agentContract } from "./ai-BpOGm-zB.js";
|
|
3
|
+
//#region src/ai-client.ts
|
|
4
|
+
/**
|
|
5
|
+
* experimental-a2/ai/client — a client for an `agent()` route that needs no
|
|
6
|
+
* contract: the AI protocol and its `AIState` reducer are library code, and
|
|
7
|
+
* the agent's types arrive through a type-only `typeof` import.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import type { assistant } from '@/server/assistant' // erased at build
|
|
11
|
+
* const client = createAgentClient<typeof assistant>({ api: '/api/agent' })
|
|
12
|
+
* await client.session(id).push(...inputs.message(message))
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
const protocol = agentContract({ name: "a2.ai" });
|
|
16
|
+
/**
|
|
17
|
+
* A client for the built-in AI protocol. Agents built from a shared
|
|
18
|
+
* `agentContract()` use `createClient({ contract })` instead.
|
|
19
|
+
*/
|
|
20
|
+
function createAgentClient(options) {
|
|
21
|
+
return createClient({
|
|
22
|
+
...options,
|
|
23
|
+
contract: protocol
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { createAgentClient };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=ai-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-client.js","names":[],"sources":["../src/ai-client.ts"],"sourcesContent":["/**\n * experimental-a2/ai/client — a client for an `agent()` route that needs no\n * contract: the AI protocol and its `AIState` reducer are library code, and\n * the agent's types arrive through a type-only `typeof` import.\n *\n * ```ts\n * import type { assistant } from '@/server/assistant' // erased at build\n * const client = createAgentClient<typeof assistant>({ api: '/api/agent' })\n * await client.session(id).push(...inputs.message(message))\n * ```\n */\n\nimport {\n agentContract,\n type AI_STATE_REDUCER,\n type AIEventDefs,\n type AIMessageOf,\n type AIState,\n} from './ai.ts'\nimport {\n createClient,\n type A2Client,\n type CreateClientOptions,\n} from './client.ts'\n\n/**\n * The structural shape of `typeof` an `agent({ name })` server: one whose\n * state the built-in reducer folds. Agents built from an extended contract\n * use `createClient({ contract })` instead.\n */\nexport type AnyAgent = {\n readonly contract: {\n readonly events: object\n readonly reducer: { readonly name: typeof AI_STATE_REDUCER }\n }\n}\n\nexport type AgentMessage<A extends AnyAgent> = AIMessageOf<\n A['contract']['events']\n>\n\nexport type AgentClient<A extends AnyAgent = AnyAgent> = A2Client<\n AIEventDefs<AgentMessage<A>>,\n AIState<AgentMessage<A>>\n>\n\nexport type CreateAgentClientOptions = Omit<\n CreateClientOptions<AIEventDefs, AIState>,\n 'contract'\n>\n\nconst protocol = agentContract({ name: 'a2.ai' })\n\n/**\n * A client for the built-in AI protocol. Agents built from a shared\n * `agentContract()` use `createClient({ contract })` instead.\n */\nexport function createAgentClient<A extends AnyAgent = AnyAgent>(\n options: CreateAgentClientOptions,\n): AgentClient<A> {\n return createClient({ ...options, contract: protocol }) as AgentClient<A>\n}\n"],"mappings":";;;;;;;;;;;;;;AAmDA,MAAM,WAAW,cAAc,EAAE,MAAM,QAAQ,CAAC;;;;;AAMhD,SAAgB,kBACd,SACgB;CAChB,OAAO,aAAa;EAAE,GAAG;EAAS,UAAU;CAAS,CAAC;AACxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/ai-fx.browser.ts
|
|
2
|
+
/** experimental-a2/ai/fx is server-only; browsers reach an agent through its route. */
|
|
3
|
+
throw new Error("experimental-a2/ai/fx is server-only — a client bundle imported it. Keep agent({ harness: fx() }) in server code.");
|
|
4
|
+
//#endregion
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=ai-fx.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-fx.browser.js","names":[],"sources":["../src/ai-fx.browser.ts"],"sourcesContent":["/** experimental-a2/ai/fx is server-only; browsers reach an agent through its route. */\nthrow new Error(\n 'experimental-a2/ai/fx is server-only — a client bundle imported it. Keep agent({ harness: fx() }) in server code.',\n)\nexport {}\n"],"mappings":";;AACA,MAAM,IAAI,MACR,mHACF"}
|
package/dist/ai-fx.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as Harness } from "./ai-harness-DvsPeJeB.js";
|
|
2
|
+
//#region src/ai-fx.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The FX harness. Every model call FX makes is one durable step; A2 rebuilds
|
|
5
|
+
* the kernel for each step from its latest checkpoint and the log since.
|
|
6
|
+
*/
|
|
7
|
+
declare function fx(): Harness<"fx", never>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { type Harness, fx };
|
|
10
|
+
//# sourceMappingURL=ai-fx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-fx.d.ts","names":[],"sources":["../src/ai-fx.ts"],"mappings":";;;;;;iBAwCgB,MAAM"}
|