experimental-a2 0.18.0 → 0.19.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 +39 -0
- package/dist/{actor-Bjce9_5U.d.ts → actor-C7b-1arn.d.ts} +3 -3
- package/dist/{actor-Bjce9_5U.d.ts.map → actor-C7b-1arn.d.ts.map} +1 -1
- package/dist/actor-client.d.ts +1 -1
- package/dist/actor-react.d.ts +1 -1
- package/dist/actor-react.js +1 -1
- package/dist/actor.d.ts +1 -1
- package/dist/actor.js +2 -2
- package/dist/{ai-DrUaMyRt.d.ts → ai-Cz3hqVhk.d.ts} +34 -17
- package/dist/ai-Cz3hqVhk.d.ts.map +1 -0
- package/dist/ai-client.d.ts +1 -1
- package/dist/ai-client.js +2 -2
- package/dist/ai-control-CvLbW10B.js +46 -0
- package/dist/ai-control-CvLbW10B.js.map +1 -0
- package/dist/ai-fx.d.ts +1 -1
- package/dist/ai-fx.d.ts.map +1 -1
- package/dist/ai-fx.js +122 -44
- package/dist/ai-fx.js.map +1 -1
- package/dist/{ai-harness-BuLh_EYi.js → ai-harness-BuuC-gJ3.js} +79 -15
- package/dist/ai-harness-BuuC-gJ3.js.map +1 -0
- package/dist/{ai-harness-DvsPeJeB.d.ts → ai-harness-CV6rXbB3.d.ts} +2 -2
- package/dist/ai-harness-CV6rXbB3.d.ts.map +1 -0
- package/dist/{ai-BpOGm-zB.js → ai-mMiWul1T.js} +117 -78
- package/dist/ai-mMiWul1T.js.map +1 -0
- package/dist/ai-pi.d.ts +1 -1
- package/dist/ai-pi.d.ts.map +1 -1
- package/dist/ai-pi.js +114 -23
- package/dist/ai-pi.js.map +1 -1
- package/dist/ai-react.d.ts +1 -1
- package/dist/ai-react.js +2 -2
- package/dist/ai-server.d.ts +3 -3
- package/dist/ai-server.d.ts.map +1 -1
- package/dist/ai-server.js +127 -55
- package/dist/ai-server.js.map +1 -1
- package/dist/ai-tool-input-DmSqMUQi.js +40 -0
- package/dist/ai-tool-input-DmSqMUQi.js.map +1 -0
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +1 -1
- package/dist/{client-BReKqwZC.js → client-BhHLoNKF.js} +3 -3
- package/dist/{client-BReKqwZC.js.map → client-BhHLoNKF.js.map} +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/{internal-B2T3U4Rq.js → internal-CscSY7K_.js} +4 -2
- package/dist/{internal-B2T3U4Rq.js.map → internal-CscSY7K_.js.map} +1 -1
- package/dist/react.js +1 -1
- package/dist/scheduler-qstash.d.ts +2 -2
- package/dist/scheduler-qstash.js +3 -3
- package/dist/scheduler-qstash.js.map +1 -1
- package/dist/scheduler-vercel.d.ts +7 -7
- package/dist/scheduler-vercel.d.ts.map +1 -1
- package/dist/scheduler-vercel.js +10 -14
- package/dist/scheduler-vercel.js.map +1 -1
- package/dist/{server-Dw_k_7kO.js → server-D-Y4pqwu.js} +37 -11
- package/dist/server-D-Y4pqwu.js.map +1 -0
- package/dist/{server-En7cbi3v.d.ts → server-DYAATFuT.d.ts} +11 -5
- package/dist/server-DYAATFuT.d.ts.map +1 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/{session-clear-Bo-XTFEy.d.ts → session-clear-C-QwTXV1.d.ts} +2 -2
- package/dist/session-clear-C-QwTXV1.d.ts.map +1 -0
- package/dist/{store-Djdv0bnZ.d.ts → store-CyLUy86v.d.ts} +23 -4
- package/dist/store-CyLUy86v.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.js +25 -6
- package/dist/store-memory.js.map +1 -1
- package/dist/{store-polling-B5FcwJfo.js → store-polling-7WJV0YWP.js} +2 -2
- package/dist/{store-polling-B5FcwJfo.js.map → store-polling-7WJV0YWP.js.map} +1 -1
- package/dist/store-postgres.d.ts +1 -1
- package/dist/store-postgres.d.ts.map +1 -1
- package/dist/store-postgres.js +55 -25
- package/dist/store-postgres.js.map +1 -1
- package/dist/{store-presence-polling-BAwS8RWn.js → store-presence-polling-B1ixeqIS.js} +3 -3
- package/dist/{store-presence-polling-BAwS8RWn.js.map → store-presence-polling-B1ixeqIS.js.map} +1 -1
- package/dist/store-redis-http.d.ts +1 -1
- package/dist/store-redis-http.js +3 -3
- package/dist/{store-redis-notify-BRITti_o.js → store-redis-notify-CM0AfLY0.js} +88 -37
- package/dist/store-redis-notify-CM0AfLY0.js.map +1 -0
- package/dist/store-redis.d.ts +1 -1
- package/dist/store-redis.js +1 -1
- package/dist/store-sqlite.d.ts +1 -1
- package/dist/store-sqlite.js +35 -20
- package/dist/store-sqlite.js.map +1 -1
- package/dist/{wire-rSUglYo8.js → wire-BKxH1vbP.js} +2 -2
- package/dist/{wire-rSUglYo8.js.map → wire-BKxH1vbP.js.map} +1 -1
- package/docs/agents/03-conversations.mdx +27 -15
- package/docs/agents/04-harnesses.mdx +51 -5
- package/docs/contract/03-sessions.mdx +1 -1
- package/docs/index.mdx +3 -3
- package/docs/reference/02-server.mdx +12 -7
- package/docs/reference/04-ai.mdx +41 -23
- package/docs/reference/05-adapters.mdx +6 -6
- package/docs/server/01-handlers.mdx +1 -1
- package/docs/server/02-timers.mdx +1 -1
- package/docs/server/03-cancellation.mdx +3 -2
- package/docs/server/05-production.mdx +4 -3
- package/docs/server/06-guarantees.mdx +20 -11
- package/examples/playground/DEPLOY.md +11 -4
- package/examples/playground/app/a0/[appId]/page.tsx +2 -8
- package/examples/playground/app/a0/a0.css +244 -5
- package/examples/playground/app/a0/app-view.tsx +2 -1
- package/examples/playground/app/a0/attachments.ts +133 -0
- package/examples/playground/app/a0/chat.test.tsx +504 -0
- package/examples/playground/app/a0/chat.tsx +623 -63
- package/examples/playground/app/a0/context-menu.tsx +38 -11
- package/examples/playground/app/a0/devtools.tsx +2 -8
- package/examples/playground/app/a0/model.test.ts +28 -0
- package/examples/playground/app/a0/model.ts +30 -0
- package/examples/playground/app/a0/server.ts +13 -19
- package/examples/playground/app/a0/uploads/route.ts +29 -0
- package/examples/playground/app/agent/[agentId]/agent-client.tsx +2 -1
- package/examples/playground/app/agent/[agentId]/agent-queue.test.tsx +1 -0
- package/examples/playground/app/agent/model.test.ts +12 -3
- package/examples/playground/app/chat/[chatId]/agent-state.test.ts +1 -5
- package/examples/playground/next.config.ts +7 -4
- package/examples/playground/package.json +3 -1
- package/package.json +1 -1
- package/src/ai-agent.ts +14 -3
- package/src/ai-client-state.ts +21 -9
- package/src/ai-context-schema.ts +28 -4
- package/src/ai-context.ts +83 -3
- package/src/ai-control-server.ts +70 -43
- package/src/ai-control-state.ts +3 -4
- package/src/ai-control.ts +59 -10
- package/src/ai-coordinator.ts +7 -6
- package/src/ai-fx.ts +184 -67
- package/src/ai-harness.ts +153 -29
- package/src/ai-message-shape.ts +41 -0
- package/src/ai-pi.ts +161 -46
- package/src/ai-stored-state.ts +1 -3
- package/src/ai-tool-input.ts +45 -0
- package/src/ai.ts +116 -77
- package/src/internal.ts +6 -0
- package/src/libfx.d.ts +8 -1
- package/src/scheduler-qstash.ts +5 -5
- package/src/scheduler-vercel.ts +15 -27
- package/src/server.ts +58 -12
- package/src/store-memory.ts +50 -9
- package/src/store-postgres.ts +79 -28
- package/src/store-redis-core.ts +112 -31
- package/src/store-sqlite.ts +61 -28
- package/src/store.ts +22 -3
- package/dist/ai-BpOGm-zB.js.map +0 -1
- package/dist/ai-DrUaMyRt.d.ts.map +0 -1
- package/dist/ai-harness-BuLh_EYi.js.map +0 -1
- package/dist/ai-harness-DvsPeJeB.d.ts.map +0 -1
- package/dist/server-Dw_k_7kO.js.map +0 -1
- package/dist/server-En7cbi3v.d.ts.map +0 -1
- package/dist/session-clear-Bo-XTFEy.d.ts.map +0 -1
- package/dist/store-Djdv0bnZ.d.ts.map +0 -1
- package/dist/store-redis-notify-BRITti_o.js.map +0 -1
- package/examples/playground/app/a0/no-photon.cjs +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8f373b5: Under `fx()` and `pi()`, a user message's images now reach the model. A2 fetches each `image/*` file part from its `https:` or `data:` URL through the AI SDK's download, which refuses private addresses and checks redirects, up to 32 MiB of one message's files, and keeps what it fetched for the process. FX gets them as image prompt blocks and Pi as prompt and steering images. A file that isn't an image, an image A2 can't fetch, or a steer with files under FX fails the turn with an error that names the file. Every step sends the conversation so far with all its files, as under `{ type: 'ai-sdk' }`.
|
|
8
|
+
|
|
9
|
+
Before, both harnesses read only a message's text and dropped its files without a word.
|
|
10
|
+
|
|
11
|
+
- b83ba8b: `agent()` now throws a `TypeError` when a provider-defined tool (`type: 'provider'`, such as a provider's web search) is passed with `fx()` or `pi()`, as it does for a tool that sets `needsApproval`. Before, both harnesses dropped such a tool without a word, so the model never saw it.
|
|
12
|
+
- 88ee923: A2's AI log stores each message's content once, in the `ai.control.requested` command that brought it in. Before, a message sent with no turn running was stored three times, and a queued or steering one four: in its command, in `ai.control.committed`, and in `ai.message.created`.
|
|
13
|
+
|
|
14
|
+
- `ai.message.created` now records an admission as `{ messageId, role, generate? }`. `MessageCreatedPayload` is no longer generic. Only A2's control lane writes the event, after the command that brought its input in; `reduceAIState()` and `deriveUIMessages()` throw on one that no command explains.
|
|
15
|
+
- `ai.control.committed` never carries message content: queued inputs and `AIState.active.input` are the new `InputRef` type, `{ id, role, generate, afterStepOf? }`. `ActiveTurn` is no longer generic. `AIState.inbox.items` keep their `message`, now with `role`.
|
|
16
|
+
- `AIMessageOf` reads the message type from the contract's input command schema.
|
|
17
|
+
- The AI state, model context, and control reducers advance to `a2.ai.state.v27`, `a2.ai.context.v7`, and `a2.ai.control.v6`, so their checkpoints rebuild from the log. Logs written before this release don't fold.
|
|
18
|
+
|
|
19
|
+
Reading the log costs nothing more: the transcript's readers keep a queued input's content in their state from its command until its admission.
|
|
20
|
+
|
|
21
|
+
- da1e0e5: Steering hands off in the order it was sent, as one turn. `steer()` now queues new input right after the turn's earlier steering instead of ahead of it, and `queue.sendNow()` lands after that steering too. At the handoff, every input steering the turn enters together: the last one starts the new turn and the earlier ones enter as its context (`generate: false`), so the model answers them once. Under `fx()` and `pi()`, they reach the harness as one steering message. A turn paused with `pause({ when: 'now' })` keeps its steering until `resume()`, so every steer sent while it's paused targets it and they all enter on Resume.
|
|
22
|
+
|
|
23
|
+
Before, each steer jumped to the front, so several steers ran last-first, each as its own turn, and the first steer ended a paused turn at once, leaving later steers no turn to target.
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 9b80f3e: Under `pi()`, `speed: 'fast'` now asks AI Gateway for the model's fast tier on each of Pi's model calls, as it already did under `{ type: 'ai-sdk' }` and `fx()`. Before, `pi()` ignored `speed`, so every step ran at standard speed.
|
|
28
|
+
- b83ba8b: The interruption reason `'steered after step'` is reserved: A2 writes it when steering ends a response, and `fx()` and `pi()` replay the next response as that steering. A client interruption that carries it is now rejected. Before, one would make the harness replay a stopped response as steered, so the replay diverged and the session failed.
|
|
29
|
+
- c7afea6: `vercelQueues()` no longer refuses delays over six days itself. A task's delay goes to Vercel Queues as asked, with the seven-day retention it already set, and Vercel Queues refuses one longer than that.
|
|
30
|
+
|
|
31
|
+
## 0.18.1
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- 27f2d19: A handler that throws is held back before its retry: one second after the first failure, doubling up to 30 seconds. The store holds the failed event, so nothing retries it early, and the scheduler's next wake after the hold runs it. Before, a failed event was retried on every wake, every six to eight seconds whatever its failure count, and Vercel Queues also redelivered the failing message on a second 30-second chain. Custom `A2Store` implementations take a new `retryAfterMs` option on `failAttempt`: short of dead-lettering, keep the event unclaimable for that long by setting its claim expiry with no holder.
|
|
36
|
+
- 38e557b: An attempt that ends before it finishes, because its process timed out, crashed, or lost its claim, now counts toward the event's ten-attempt failure budget, the same as a handler that throws. The store counts it when the next claim takes the lapsed one over, and dead-letters the event in that same write once the count reaches ten, without running an eleventh attempt. A handler that never fits in its invocation dead-letters instead of retrying forever. A timeout costs every event it interrupts one attempt, so a session whose fan-out keeps outrunning its function can dead-letter work that was only waiting: bound the fan-out, or put work that contends for one resource in a lane. `lastError` keeps the last error a handler threw, or is null when every attempt lapsed. Custom `A2Store` implementations count the takeover of an expired claim whose holder is still recorded, and take a new `maxFailures` option on `claimAvailable` that dead-letters at the limit.
|
|
37
|
+
- 89c600a: Under `fx()`, a step no longer fails with "This operation was aborted" when the Gateway closes its response a moment after FX has read it. And a model stream that breaks while a step's progress is being written now fails that step, instead of leaving an unhandled rejection that ended the process.
|
|
38
|
+
- 7c5912f: Under `fx()`, a tool call's input goes through the tool's schema, as under `{ type: 'ai-sdk' }`. `execute` receives the schema's output, so defaults apply, and input the schema rejects goes back to the model as an error without running the tool. Before, `execute` received the model's raw JSON: an omitted field with a default arrived as `undefined`, and invalid input ran the tool. Responses recorded before this change replay unchanged.
|
|
39
|
+
- d28e1bf: Once a function's deadline passes, A2 claims nothing more in that invocation, so a timeout costs each in-flight event one attempt. Before, a drain past its deadline kept claiming the event it had just lost, with a 1ms window each time, until the platform ended the process: a single timeout could cost an event a dozen or more attempts, each one restarting its handler and writing to the store.
|
|
40
|
+
- 96c4968: Under `pi()`, a call to one of the agent's own tools goes through Pi's checks and then the tool's schema, as under `{ type: 'ai-sdk' }`. `execute` receives the schema's output of the arguments Pi accepts, so defaults apply and Pi's coercion carries through. Input either check rejects, and a call to a tool that does not exist, goes back to the model as an error without running the tool; so does input Pi rejects for its own tools, which no longer starts a tool execution. Before, `execute` received the model's raw arguments: an omitted field with a default arrived as `undefined`, a number sent as a string stayed a string, and a call Pi had rejected still ran while the model saw Pi's error. Pi's transcript keeps the model's own arguments, and responses recorded before this change replay unchanged.
|
|
41
|
+
|
|
3
42
|
## 0.18.0
|
|
4
43
|
|
|
5
44
|
### Minor Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as Contract, t as Reducer, u as EventDefs, v as StandardSchemaV1 } from "./reducer-CqA59Q6U.js";
|
|
2
|
-
import { t as A2Store } from "./store-
|
|
3
|
-
import { h as Session, n as A2Server, p as ScheduleTiming, t as A2Scheduler } from "./server-
|
|
2
|
+
import { t as A2Store } from "./store-CyLUy86v.js";
|
|
3
|
+
import { h as Session, n as A2Server, p as ScheduleTiming, t as A2Scheduler } from "./server-DYAATFuT.js";
|
|
4
4
|
import { i as A2Telemetry } from "./telemetry-Cyfqo6Qt.js";
|
|
5
5
|
//#region src/actor-shared.d.ts
|
|
6
6
|
/**
|
|
@@ -317,4 +317,4 @@ type ActorDefinition<D extends ActorProtocol> = {
|
|
|
317
317
|
declare function actor<D extends ActorProtocol>(options: ActorOptions<D>): ActorDefinition<D>;
|
|
318
318
|
//#endregion
|
|
319
319
|
export { ActorProtocol as _, ActorHandle as a, ActorScheduleSend as b, ActorOptions as c, concurrent as d, ActorConcurrentContext as f, ActorPresenceValues as g, ActorPresenceOf as h, ActorFetchOptions as i, ActorSendOptions as l, ActorPresenceMap as m, ActorCallResult as n, ActorHandler as o, ActorContext as p, ActorDefinition as r, ActorOperation as s, ActorCallOptions as t, actor as u, ActorRefusedError as v, ActorSend as x, ActorScheduleOptions as y };
|
|
320
|
-
//# sourceMappingURL=actor-
|
|
320
|
+
//# sourceMappingURL=actor-C7b-1arn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor-
|
|
1
|
+
{"version":3,"file":"actor-C7b-1arn.d.ts","names":[],"sources":["../src/actor-shared.ts","../src/actor.ts"],"mappings":";;;;;;;;;;;cAiCa,0BAA0B;;WAE5B;;WAEA;EACT,YAAY,eAAe,mBAAmB;;;;;;;;;KAepC;EACV;EACA;;;;;;;EAOA;;;KAIU,gBAAgB,UAAU,iBAAiB;EACrD,gBAAgB;IAEd;;KAIQ,oBAAoB,QAC7B,WAAW,cAAc,EAAE;;;;;;KAQ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AW,6BAA6B;;;;;;;;;;;;EAYrD,QAAQ,OAAO;;KAGL;;EAEV;;KAGU,mBAAmB;;EAE7B;;KAGU,gBAAgB;;EAE1B,OAAO;;EAEP;;;;;EAKA;;KAGG,WACH,UAAU,eACV,gBAAgB,0BACH,YAAY,MAErB,QAAQ,YAAY,IACpB,UAAU,qBACP,QAAQ,gBAAgB,gBAE3B,OAAO,YAAY,IACnB,UAAU,qBACP,QAAQ,gBAAgB;KAE5B,WACH,UAAU,eACV,gBAAgB,0BACH,YAAY,MAErB,QAAQ,YAAY,IACpB,UAAU,qBACP;EAAU;EAAY;MAEzB,OAAO,YAAY,IACnB,UAAU,qBACP;EAAU;EAAY;;;KAGnB,YAAY,UAAU;WACvB;;;;;;;;WAQA,kBAAkB,WAAW,cAAc,WAAW,GAAG;;WAEzD,kBAAkB,WAAW,cAAc,WAAW,GAAG;;WAEzD,aAAa,QAAQ,gBAAgB;;;;;;;;;;;WAWrC,QACP,SAAS,SACT,UAAU,kBAAkB,OACzB,QAAQ;;WAEJ,SAAS,QAAQ;;KAGhB,gBAAgB,UAAU;WAC3B;;;;;;WAMA,WAAW;;WAEX,UAAU,SAAS;;WAEnB,QAAQ,SAAS;;WAEjB,SAAS,QAAQ,qBAAqB,aAAa;EAC5D,MAAM,aAAa,YAAY;;;;;;;iBAsDjB,MAAM,UAAU,eAC9B,SAAS,aAAa,KACrB,gBAAgB"}
|
package/dist/actor-client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ActorCallResult, v as ActorRefusedError } from "./actor-
|
|
1
|
+
import { n as ActorCallResult, v as ActorRefusedError } from "./actor-C7b-1arn.js";
|
|
2
2
|
//#region src/actor-client.d.ts
|
|
3
3
|
declare class ActorRequestError extends Error {
|
|
4
4
|
readonly status: number | undefined;
|
package/dist/actor-react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as ContractEvent, u as EventDefs } from "./reducer-CqA59Q6U.js";
|
|
2
|
-
import { g as ActorPresenceValues, m as ActorPresenceMap } from "./actor-
|
|
2
|
+
import { g as ActorPresenceValues, m as ActorPresenceMap } from "./actor-C7b-1arn.js";
|
|
3
3
|
import { ActorClientCall, ActorStateOf, AnyActorDefinition } from "./actor-client.js";
|
|
4
4
|
import { a as Connection } from "./client-h_DKFAjj.js";
|
|
5
5
|
//#region src/actor-react.d.ts
|
package/dist/actor-react.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { n as isSessionCleared } from "./session-clear-DGI4jTQ5.js";
|
|
3
3
|
import { r as foldsClearMarkers } from "./reducer-BAXc8JyF.js";
|
|
4
4
|
import { n as internalContract } from "./contract-BYKASlCV.js";
|
|
5
|
-
import { t as createClient } from "./client-
|
|
5
|
+
import { t as createClient } from "./client-BhHLoNKF.js";
|
|
6
6
|
import { useSession } from "./react.js";
|
|
7
7
|
import { l as openPresenceDefs } from "./actor-shared-t7w8xIKP.js";
|
|
8
8
|
import { createActorClient } from "./actor-client.js";
|
package/dist/actor.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as ActorProtocol, a as ActorHandle, b as ActorScheduleSend, c as ActorOptions, d as concurrent, f as ActorConcurrentContext, g as ActorPresenceValues, h as ActorPresenceOf, i as ActorFetchOptions, l as ActorSendOptions, m as ActorPresenceMap, n as ActorCallResult, o as ActorHandler, p as ActorContext, r as ActorDefinition, s as ActorOperation, t as ActorCallOptions, u as actor, v as ActorRefusedError, x as ActorSend, y as ActorScheduleOptions } from "./actor-
|
|
1
|
+
import { _ as ActorProtocol, a as ActorHandle, b as ActorScheduleSend, c as ActorOptions, d as concurrent, f as ActorConcurrentContext, g as ActorPresenceValues, h as ActorPresenceOf, i as ActorFetchOptions, l as ActorSendOptions, m as ActorPresenceMap, n as ActorCallResult, o as ActorHandler, p as ActorContext, r as ActorDefinition, s as ActorOperation, t as ActorCallOptions, u as actor, v as ActorRefusedError, x as ActorSend, y as ActorScheduleOptions } from "./actor-C7b-1arn.js";
|
|
2
2
|
export { ActorCallOptions, ActorCallResult, type ActorConcurrentContext, type ActorContext, ActorDefinition, ActorFetchOptions, ActorHandle, ActorHandler, ActorOperation, ActorOptions, type ActorPresenceMap, type ActorPresenceOf, type ActorPresenceValues, type ActorProtocol, ActorRefusedError, type ActorScheduleOptions, type ActorScheduleSend, type ActorSend, ActorSendOptions, actor, concurrent };
|
package/dist/actor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as NonRetriableError, i as A2Error, n as isSessionCleared, r as sessionClearedError } from "./session-clear-DGI4jTQ5.js";
|
|
2
2
|
import { n as internalContract } from "./contract-BYKASlCV.js";
|
|
3
|
-
import { v as serverInternals } from "./internal-
|
|
4
|
-
import { c as parsePresenceSibling, o as setServerFetchHooks, s as sseResponse, t as createServer } from "./server-
|
|
3
|
+
import { v as serverInternals } from "./internal-CscSY7K_.js";
|
|
4
|
+
import { c as parsePresenceSibling, o as setServerFetchHooks, s as sseResponse, t as createServer } from "./server-D-Y4pqwu.js";
|
|
5
5
|
import { a as actorFailedSchema, c as isJsonTree, i as ActorRefusedError, l as openPresenceDefs, n as ACTOR_LANE, o as actorReducer, r as ACTOR_STATE_EVENT, s as actorStateSchema, t as ACTOR_FAILED_EVENT } from "./actor-shared-t7w8xIKP.js";
|
|
6
6
|
//#region src/actor.ts
|
|
7
7
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
2
|
+
import { c as HandlerContext } from "./server-DYAATFuT.js";
|
|
3
3
|
import { FinishReason, JSONValue as JSONValue$1, LanguageModelCallOptions, LanguageModelUsage, UIMessage, UIMessage as UIMessage$1, UIMessageChunk, UIMessageChunk as UIMessageChunk$1 } from "ai";
|
|
4
4
|
//#region src/ai-message-base.d.ts
|
|
5
5
|
type FieldUndo = {
|
|
@@ -22,12 +22,20 @@ type MessageBase = {
|
|
|
22
22
|
};
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/ai-control.d.ts
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* An input in the queue or the active turn. Its content stays in the
|
|
27
|
+
* `ai.control.requested` command that brought it, and in no other event.
|
|
28
|
+
*/
|
|
29
|
+
type InputRef = {
|
|
26
30
|
id: string;
|
|
27
|
-
|
|
31
|
+
role: UIMessage["role"];
|
|
28
32
|
generate: boolean;
|
|
29
33
|
afterStepOf?: string;
|
|
30
34
|
};
|
|
35
|
+
/** A queued input with its content, as `AIState` shows it. */
|
|
36
|
+
type InboxItem<M extends UIMessage = UIMessage> = InputRef & {
|
|
37
|
+
message: M;
|
|
38
|
+
};
|
|
31
39
|
type ControlCommand<M extends UIMessage = UIMessage> = {
|
|
32
40
|
action: "send";
|
|
33
41
|
message: M;
|
|
@@ -86,9 +94,9 @@ type ControlReceipt = {
|
|
|
86
94
|
outcome: "applied" | "rejected";
|
|
87
95
|
reason?: "not-pending" | "role-mismatch" | "stale-turn" | "not-found" | "closed" | "stale-work" | "not-user-input";
|
|
88
96
|
};
|
|
89
|
-
type ActiveTurn
|
|
97
|
+
type ActiveTurn = {
|
|
90
98
|
turnId: string;
|
|
91
|
-
input:
|
|
99
|
+
input: InputRef;
|
|
92
100
|
phase: "starting" | "generating" | "tools" | "waiting" | "failed" | "pausing" | "paused";
|
|
93
101
|
};
|
|
94
102
|
type WorkFact = {
|
|
@@ -216,10 +224,15 @@ type SessionCreatedPayload = {
|
|
|
216
224
|
type SessionClosedPayload = {
|
|
217
225
|
reason?: string;
|
|
218
226
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
227
|
+
/**
|
|
228
|
+
* A message entering the transcript. Its content is the command's that brought
|
|
229
|
+
* it in, which every reader of the transcript has already folded.
|
|
230
|
+
*/
|
|
231
|
+
type MessageCreatedPayload = {
|
|
232
|
+
messageId: string;
|
|
233
|
+
role: UIMessage$1["role"];
|
|
234
|
+
/** For user messages, false records passive context. Omission schedules. */
|
|
235
|
+
generate?: false;
|
|
223
236
|
};
|
|
224
237
|
type MessageCompletedPayload = {
|
|
225
238
|
messageId: string;
|
|
@@ -400,7 +413,7 @@ type AIEventDefs<M extends UIMessage$1 = UIMessage$1> = {
|
|
|
400
413
|
}>;
|
|
401
414
|
"ai.session.created": StandardSchemaV1<SessionCreatedPayload>;
|
|
402
415
|
"ai.session.closed": StandardSchemaV1<SessionClosedPayload>;
|
|
403
|
-
"ai.message.created": StandardSchemaV1<MessageCreatedPayload
|
|
416
|
+
"ai.message.created": StandardSchemaV1<MessageCreatedPayload>;
|
|
404
417
|
"ai.message.completed": StandardSchemaV1<MessageCompletedPayload>;
|
|
405
418
|
"ai.message.interrupted": StandardSchemaV1<MessageInterruptedPayload>;
|
|
406
419
|
"ai.generation.requested": StandardSchemaV1<GenerationRequestedPayload>;
|
|
@@ -491,7 +504,7 @@ type AIState<M extends UIMessage$1 = UIMessage$1> = {
|
|
|
491
504
|
items: InboxItem<M>[];
|
|
492
505
|
};
|
|
493
506
|
pendingQueueCommands?: PendingQueueCommand<M>[];
|
|
494
|
-
active: ActiveTurn
|
|
507
|
+
active: ActiveTurn | null;
|
|
495
508
|
starting: boolean;
|
|
496
509
|
receipt: ControlReceipt | null;
|
|
497
510
|
pausedGenerationIds?: Record<string, true>;
|
|
@@ -518,10 +531,14 @@ type AIState<M extends UIMessage$1 = UIMessage$1> = {
|
|
|
518
531
|
usage: GenerationUsage[];
|
|
519
532
|
error: string | null;
|
|
520
533
|
};
|
|
521
|
-
/** The `UIMessage` type a contract's
|
|
534
|
+
/** The `UIMessage` type a contract's input commands carry. */
|
|
522
535
|
type AIMessageOf<D> = D extends {
|
|
523
|
-
readonly "ai.
|
|
524
|
-
} ? StandardSchemaV1.InferOutput<S
|
|
536
|
+
readonly "ai.control.requested": infer S extends StandardSchemaV1;
|
|
537
|
+
} ? Extract<StandardSchemaV1.InferOutput<S>, {
|
|
538
|
+
action: "send";
|
|
539
|
+
}> extends {
|
|
540
|
+
message: infer M extends UIMessage$1;
|
|
541
|
+
} ? M : UIMessage$1 : UIMessage$1;
|
|
525
542
|
/** What `agentContract()` returns: the AI protocol, with `X` as application state. */
|
|
526
543
|
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>>;
|
|
527
544
|
type AgentToolEventDefs = EventDefs & Pick<AIEventDefs, "ai.tool.execution.requested">;
|
|
@@ -640,7 +657,7 @@ declare const inputs: AIInputs;
|
|
|
640
657
|
*/
|
|
641
658
|
declare function handlerContext<D extends AgentToolEventDefs = AIEventDefs>(contract?: Contract<D>): AgentToolContext<D>;
|
|
642
659
|
/** The built-in AI reducer's name, and so its checkpoint identity. */
|
|
643
|
-
declare const AI_STATE_REDUCER = "a2.ai.state.
|
|
660
|
+
declare const AI_STATE_REDUCER = "a2.ai.state.v27";
|
|
644
661
|
/**
|
|
645
662
|
* The built-in AI protocol plus application events, as a core contract whose
|
|
646
663
|
* reducer folds `AIState`. Isomorphic: share it when a client needs
|
|
@@ -649,5 +666,5 @@ declare const AI_STATE_REDUCER = "a2.ai.state.v26";
|
|
|
649
666
|
*/
|
|
650
667
|
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>;
|
|
651
668
|
//#endregion
|
|
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-
|
|
669
|
+
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, InputRef as pt, 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 };
|
|
670
|
+
//# sourceMappingURL=ai-Cz3hqVhk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-Cz3hqVhk.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;;;;;;;;KCQb;EACV;EACA,MAAM;EACN;EACA;;;KAIU,UAAU,UAAU,YAAY,aAAa;EACvD,SAAS;;KAGC,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;EACV;EACA,OAAO;EACP;;KA+BU;EAAa;EAAc;EAAY;;KACvC;EACV;EACA;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AmB,sBAEnB,SAAS,qBAAqB,GAAG,GAAG,KACnC,cAAc,GAAG,YAAY,KAAK,GAAG"}
|
package/dist/ai-client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
2
|
+
import { a as AI_STATE_REDUCER, i as AIState, r as AIMessageOf, t as AIEventDefs } from "./ai-Cz3hqVhk.js";
|
|
3
3
|
//#region src/ai-client.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The structural shape of `typeof` an `agent({ name })` server: one whose
|
package/dist/ai-client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as createClient } from "./client-
|
|
2
|
-
import { n as agentContract } from "./ai-
|
|
1
|
+
import { t as createClient } from "./client-BhHLoNKF.js";
|
|
2
|
+
import { n as agentContract } from "./ai-mMiWul1T.js";
|
|
3
3
|
//#region src/ai-client.ts
|
|
4
4
|
/**
|
|
5
5
|
* experimental-a2/ai/client — a client for an `agent()` route that needs no
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/ai-control.ts
|
|
2
|
+
/**
|
|
3
|
+
* The `ai.message.interrupted` reason A2 writes when steering ends a response
|
|
4
|
+
* after a step; a harness's replay continues the turn on it. Reserved, so a
|
|
5
|
+
* client's interruption can't carry it.
|
|
6
|
+
*/
|
|
7
|
+
const STEERED_REASON = "steered after step";
|
|
8
|
+
/**
|
|
9
|
+
* A fold met an admission no command explains. Only A2's control lane writes
|
|
10
|
+
* `ai.message.created`, after the command that brought its input in.
|
|
11
|
+
*/
|
|
12
|
+
const unexplainedAdmission = (messageId) => /* @__PURE__ */ new TypeError(`ai.message.created for ${messageId} follows no command that brought it in; only A2's control lane writes it`);
|
|
13
|
+
/**
|
|
14
|
+
* Where new steering for a turn goes in the inbox: right after the turn's
|
|
15
|
+
* earlier steering, or first, so it hands off in the order it was sent.
|
|
16
|
+
*/
|
|
17
|
+
const steeringEnd = (items, turnId) => items.findLastIndex((item) => item.afterStepOf === turnId) + 1;
|
|
18
|
+
/**
|
|
19
|
+
* Whether an input steering a turn enters as context for later steering: the
|
|
20
|
+
* run of inputs steering one turn is admitted together, and only its last
|
|
21
|
+
* generating input starts the next turn.
|
|
22
|
+
*/
|
|
23
|
+
const steersOn = (item, rest) => {
|
|
24
|
+
if (item.afterStepOf === void 0) return false;
|
|
25
|
+
for (const next of rest) {
|
|
26
|
+
if (next.afterStepOf !== item.afterStepOf) return false;
|
|
27
|
+
if (next.generate) return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
31
|
+
const initialControlState = () => ({
|
|
32
|
+
pendingStops: {},
|
|
33
|
+
inbox: {
|
|
34
|
+
paused: false,
|
|
35
|
+
items: []
|
|
36
|
+
},
|
|
37
|
+
active: null,
|
|
38
|
+
coordinator: {
|
|
39
|
+
closed: false,
|
|
40
|
+
queued: []
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
export { unexplainedAdmission as a, steersOn as i, initialControlState as n, steeringEnd as r, STEERED_REASON as t };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=ai-control-CvLbW10B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-control-CvLbW10B.js","names":[],"sources":["../src/ai-control.ts"],"sourcesContent":["import type { UIMessage } from 'ai'\nimport type { AICoordinatorState } from './ai-coordinator.ts'\nimport type {\n ApprovalRespondedPayload,\n GenerationStartedPayload,\n GenerationReason,\n InputRequestedPayload,\n InputRespondedPayload,\n MessageInterruptedPayload,\n RetryRequestedPayload,\n ToolCalledPayload,\n ToolResultPayload,\n} from './ai.ts'\n\n/**\n * An input in the queue or the active turn. Its content stays in the\n * `ai.control.requested` command that brought it, and in no other event.\n */\nexport type InputRef = {\n id: string\n role: UIMessage['role']\n generate: boolean\n afterStepOf?: string\n}\n\n/** A queued input with its content, as `AIState` shows it. */\nexport type InboxItem<M extends UIMessage = UIMessage> = InputRef & {\n message: M\n}\n\nexport type ControlCommand<M extends UIMessage = UIMessage> =\n | { action: 'send'; message: M; generate?: boolean }\n | { action: 'edit'; message: M }\n | { action: 'move'; inputId: string; beforeId: string | null }\n | { action: 'remove'; inputId: string }\n | {\n action: 'send-now'\n inputId: string\n turnId: string | null\n lastSeenIndex?: number\n }\n | { action: 'stop'; turnId: string; lastSeenIndex?: number }\n | { action: 'steer'; turnId: string; message: M; lastSeenIndex?: number }\n | { action: 'pause'; when: 'now' | 'after-turn' }\n | { action: 'resume' }\n | { action: 'tool-result'; result: ToolResultPayload }\n | { action: 'approval'; response: ApprovalRespondedPayload }\n | { action: 'input'; response: InputRespondedPayload }\n | { action: 'request-input'; request: InputRequestedPayload }\n | { action: 'retry'; request: RetryRequestedPayload }\n | { action: 'interrupt'; request: MessageInterruptedPayload }\n\nexport type ControlReceipt = {\n commandId: string\n work?: true\n outcome: 'applied' | 'rejected'\n reason?:\n | 'not-pending'\n | 'role-mismatch'\n | 'stale-turn'\n | 'not-found'\n | 'closed'\n | 'stale-work'\n | 'not-user-input'\n}\n\nexport type ActiveTurn = {\n turnId: string\n input: InputRef\n phase:\n | 'starting'\n | 'generating'\n | 'tools'\n | 'waiting'\n | 'failed'\n | 'pausing'\n | 'paused'\n}\n\nexport type ControlWork = {\n id: string\n version: number\n settled: boolean\n attempt?: number\n facts?: string[]\n}\n\nexport type AIControlState = {\n pendingStops: Record<string, string>\n inbox: { paused: boolean; items: InputRef[] }\n active:\n | (ActiveTurn & {\n version: number\n suspended: boolean\n model: ControlWork | null\n })\n | null\n coordinator: AICoordinatorState\n}\n\nexport type WorkFact = { type: string; id: string; payload: unknown }\nexport type WorkReport = {\n attempt: number\n workId: string\n turnId: string\n version: number\n kind: 'model' | 'tool'\n settled: boolean\n events: WorkFact[]\n}\n\nexport type ToolExecutionRequest = {\n turnId: string\n version: number\n call: ToolCalledPayload\n generation: GenerationStartedPayload\n}\n\n/**\n * The `ai.message.interrupted` reason A2 writes when steering ends a response\n * after a step; a harness's replay continues the turn on it. Reserved, so a\n * client's interruption can't carry it.\n */\nexport const STEERED_REASON = 'steered after step'\n\n/**\n * A fold met an admission no command explains. Only A2's control lane writes\n * `ai.message.created`, after the command that brought its input in.\n */\nexport const unexplainedAdmission = (messageId: string): TypeError =>\n new TypeError(\n `ai.message.created for ${messageId} follows no command that brought it in; only A2's control lane writes it`,\n )\n\n/**\n * Where new steering for a turn goes in the inbox: right after the turn's\n * earlier steering, or first, so it hands off in the order it was sent.\n */\nexport const steeringEnd = (\n items: readonly InputRef[],\n turnId: string,\n): number => items.findLastIndex((item) => item.afterStepOf === turnId) + 1\n\n/**\n * Whether an input steering a turn enters as context for later steering: the\n * run of inputs steering one turn is admitted together, and only its last\n * generating input starts the next turn.\n */\nexport const steersOn = (\n item: InputRef,\n rest: readonly InputRef[],\n): boolean => {\n if (item.afterStepOf === undefined) return false\n for (const next of rest) {\n if (next.afterStepOf !== item.afterStepOf) return false\n if (next.generate) return true\n }\n return false\n}\n\nexport const initialControlState = (): AIControlState => ({\n pendingStops: {},\n inbox: { paused: false, items: [] },\n active: null,\n coordinator: { closed: false, queued: [] },\n})\n\nexport type ControlChange = {\n path: (string | number)[]\n value?: unknown\n remove?: true\n splice?: { index: number; deleteCount: number; items: unknown[] }\n move?: { from: number; to: number }\n}\n\nexport type ControlCommit = {\n changes: ControlChange[]\n view: {\n turnId: string | null\n version: number | null\n phase: ActiveTurn['phase'] | null\n paused: boolean\n closed: boolean\n requestId: string | null\n requestReason: GenerationReason | null\n sourceGenerationId: string | null\n responseMessageId: string | null\n }\n}\n"],"mappings":";;;;;;AA2HA,MAAa,iBAAiB;;;;;AAM9B,MAAa,wBAAwB,8BACnC,IAAI,UACF,0BAA0B,UAAU,yEACtC;;;;;AAMF,MAAa,eACX,OACA,WACW,MAAM,eAAe,SAAS,KAAK,gBAAgB,MAAM,IAAI;;;;;;AAO1E,MAAa,YACX,MACA,SACY;CACZ,IAAI,KAAK,gBAAgB,KAAA,GAAW,OAAO;CAC3C,KAAK,MAAM,QAAQ,MAAM;EACvB,IAAI,KAAK,gBAAgB,KAAK,aAAa,OAAO;EAClD,IAAI,KAAK,UAAU,OAAO;CAC5B;CACA,OAAO;AACT;AAEA,MAAa,6BAA6C;CACxD,cAAc,CAAC;CACf,OAAO;EAAE,QAAQ;EAAO,OAAO,CAAC;CAAE;CAClC,QAAQ;CACR,aAAa;EAAE,QAAQ;EAAO,QAAQ,CAAC;CAAE;AAC3C"}
|
package/dist/ai-fx.d.ts
CHANGED
package/dist/ai-fx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-fx.d.ts","names":[],"sources":["../src/ai-fx.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"ai-fx.d.ts","names":[],"sources":["../src/ai-fx.ts"],"mappings":";;;;;;iBA2CgB,MAAM"}
|