experimental-a2 0.11.0 → 0.12.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 523988e: Add `handler` to `experimental-a2/server` to normalize function and object handler entries into the object shape for composition while preserving event and presence types.
8
+
3
9
  ## 0.11.0
4
10
 
5
11
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  import { h as StandardSchemaV1, i as Contract, s as EventDefs, t as Reducer } from "./reducer-DJKWm3cp.js";
2
2
  import { t as A2Store } from "./store-DtDOWLSn.js";
3
- import { f as ScheduleTiming, m as Session, n as A2Server, t as A2Scheduler } from "./server-DwPrMqHB.js";
3
+ import { f as ScheduleTiming, m as Session, n as A2Server, t as A2Scheduler } from "./server-DjZZa1wr.js";
4
4
  import { i as A2Telemetry } from "./telemetry-CpeclqB2.js";
5
5
  //#region src/actor-shared.d.ts
6
6
  /**
@@ -307,4 +307,4 @@ type ActorDefinition<D extends ActorProtocol> = {
307
307
  declare function actor<D extends ActorProtocol>(options: ActorOptions<D>): ActorDefinition<D>;
308
308
  //#endregion
309
309
  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 };
310
- //# sourceMappingURL=actor-D_54lz_1.d.ts.map
310
+ //# sourceMappingURL=actor-DJi3RsNu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actor-D_54lz_1.d.ts","names":[],"sources":["../src/actor-shared.ts","../src/actor.ts"],"mappings":";;;;;;;;;;;c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AGA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA;WACA,QAAQ,SAAS;;KAGpB,kBAAkB,UAAU;;EAEtC,aAAa,WAAW,6BAA6B;;;;;;;;;;;;EAYrD,QAAQ,OAAO;;KAGL;;EAEV;;KAGU,mBAAmB;;EAE7B;;KAGU,gBAAgB;;EAE1B,OAAO;;EAEP;;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;;;;;;WAMA,kBAAkB,WAAW,cAAc,WAAW,GAAG;;WAEzD,kBAAkB,WAAW,cAAc,WAAW,GAAG;;WAEzD,aAAa,QAAQ,gBAAgB;;;;;;;;;;WAUrC,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"}
@@ -1,4 +1,4 @@
1
- import { n as ActorCallResult, v as ActorRefusedError } from "./actor-D_54lz_1.js";
1
+ import { n as ActorCallResult, v as ActorRefusedError } from "./actor-DJi3RsNu.js";
2
2
  //#region src/actor-client.d.ts
3
3
  declare class ActorRequestError extends Error {
4
4
  readonly status: number | undefined;
@@ -1,5 +1,5 @@
1
1
  import { a as ContractEvent, s as EventDefs } from "./reducer-DJKWm3cp.js";
2
- import { g as ActorPresenceValues, m as ActorPresenceMap } from "./actor-D_54lz_1.js";
2
+ import { g as ActorPresenceValues, m as ActorPresenceMap } from "./actor-DJi3RsNu.js";
3
3
  import { ActorClientCall, ActorStateOf, AnyActorDefinition } from "./actor-client.js";
4
4
  import { a as Connection } from "./client-P_NNNRM-.js";
5
5
  //#region src/actor-react.d.ts
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-D_54lz_1.js";
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-DJi3RsNu.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,6 +1,6 @@
1
1
  import { t as contract } from "./contract-48bUMgcL.js";
2
2
  import { n as NonRetriableError, t as A2Error } from "./errors-DCk6ch5n.js";
3
- import { a as parsePresenceSibling, i as sseResponse, r as setServerFetchHooks, t as createServer } from "./server-Dkz2a84E.js";
3
+ import { a as sseResponse, i as setServerFetchHooks, o as parsePresenceSibling, t as createServer } from "./server-BeNADlCI.js";
4
4
  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-DI7J5upy.js";
5
5
  //#region src/actor.ts
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import { a as ContractEvent, s as EventDefs } from "./reducer-DJKWm3cp.js";
2
- import { n as A2Server, p as ServerOptions } from "./server-DwPrMqHB.js";
2
+ import { n as A2Server, p as ServerOptions } from "./server-DjZZa1wr.js";
3
3
  import { AIEventDefs, AIState, AgentDefinition, AgentToolContext, AgentToolEventDefs } from "./ai.js";
4
4
  import { Instructions, LanguageModel, TextStreamPart, ToolSet, ToolSet as ToolSet$1, UIMessage, UIMessageChunk, streamText } from "ai";
5
5
  //#region src/ai-sdk-step.d.ts
package/dist/ai-server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as A2Error } from "./errors-DCk6ch5n.js";
2
2
  import { f as consumeSchedulerSendFailure, p as installAmbientToolScopeStorage } from "./internal-Dq2qYxou.js";
3
- import { r as setServerFetchHooks, t as createServer } from "./server-Dkz2a84E.js";
3
+ import { i as setServerFetchHooks, t as createServer } from "./server-BeNADlCI.js";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
  import { convertToModelMessages, stepCountIs, streamText, toUIMessageStream } from "ai";
6
6
  //#region src/ai-sdk-step.ts
package/dist/ai.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { h as StandardSchemaV1, i as Contract, r as AppendInput, s as EventDefs, t as Reducer } from "./reducer-DJKWm3cp.js";
2
- import { s as HandlerContext } from "./server-DwPrMqHB.js";
2
+ import { s as HandlerContext } from "./server-DjZZa1wr.js";
3
3
  import { FinishReason, JSONValue, LanguageModelUsage, UIMessage, UIMessageChunk } from "ai";
4
4
  //#region src/ai.d.ts
5
5
  type AgentStatus = "idle" | "generating" | "waiting" | "failed" | "closed";
@@ -1,5 +1,5 @@
1
1
  import { r as Clock } from "./store-DtDOWLSn.js";
2
- import { T as SchedulerTask, t as A2Scheduler } from "./server-DwPrMqHB.js";
2
+ import { E as SchedulerTask, t as A2Scheduler } from "./server-DjZZa1wr.js";
3
3
  //#region src/scheduler-qstash.d.ts
4
4
  type QStashStoreOutage = {
5
5
  version: 1;
@@ -1,7 +1,7 @@
1
1
  import { t as A2Error } from "./errors-DCk6ch5n.js";
2
2
  import { d as classifySchedulerSendFailure, g as serverInternals, t as DRAIN_TIMINGS, u as assertSchedulerTargets } from "./internal-Dq2qYxou.js";
3
3
  import { n as platformVercelOidcToken } from "./platform-B4TnJtWu.js";
4
- import { n as deliverSchedulerAppend } from "./server-Dkz2a84E.js";
4
+ import { n as deliverSchedulerAppend } from "./server-BeNADlCI.js";
5
5
  import { t as retryableLazy } from "./retryable-lazy-DZWmHpii.js";
6
6
  import { n as SYSTEM_CLOCK } from "./store-N8PXxDAS.js";
7
7
  import { t as normalizeSchedulerTask } from "./scheduler-task-BpzhPnRS.js";
@@ -1,5 +1,5 @@
1
1
  import { r as Clock } from "./store-DtDOWLSn.js";
2
- import { T as SchedulerTask, t as A2Scheduler } from "./server-DwPrMqHB.js";
2
+ import { E as SchedulerTask, t as A2Scheduler } from "./server-DjZZa1wr.js";
3
3
  //#region src/scheduler-vercel.d.ts
4
4
  /**
5
5
  * The "not settled yet" signal for a stalled handler — an expected state,
@@ -1,5 +1,5 @@
1
1
  import { d as classifySchedulerSendFailure, g as serverInternals, t as DRAIN_TIMINGS, u as assertSchedulerTargets } from "./internal-Dq2qYxou.js";
2
- import { n as deliverSchedulerAppend } from "./server-Dkz2a84E.js";
2
+ import { n as deliverSchedulerAppend } from "./server-BeNADlCI.js";
3
3
  import { t as retryableLazy } from "./retryable-lazy-DZWmHpii.js";
4
4
  import { n as SYSTEM_CLOCK } from "./store-N8PXxDAS.js";
5
5
  import { t as normalizeSchedulerTask } from "./scheduler-task-BpzhPnRS.js";
@@ -816,6 +816,9 @@ async function deliverSchedulerAppend(server, task) {
816
816
  if (!internals) throw new TypeError(`a2 scheduler: server for contract '${task.contract}' cannot receive scheduled appends`);
817
817
  await internals.schedulerAppend(task.sessionId, task.events);
818
818
  }
819
+ function handler(entry) {
820
+ return typeof entry === "function" ? { handler: entry } : entry;
821
+ }
819
822
  const MAX_FAILURES = 10;
820
823
  /** Default: how long a presence value survives without a refreshing set. */
821
824
  const PRESENCE_TTL_MS = 6e4;
@@ -967,8 +970,8 @@ function createServer(options) {
967
970
  for (const [type, entry] of Object.entries(options.handlers ?? {})) {
968
971
  if (entry === void 0) continue;
969
972
  if (!Object.hasOwn(defs, type)) throw new TypeError(`contract '${name}' has no event type '${type}' — cannot register a handler for it`);
970
- const handler = typeof entry === "function" ? entry : entry?.handler;
971
- if (typeof handler !== "function") throw new TypeError(`handler for '${type}' must be a function`);
973
+ const callback = typeof entry === "function" ? entry : entry?.handler;
974
+ if (typeof callback !== "function") throw new TypeError(`handler for '${type}' must be a function`);
972
975
  let abortOn = null;
973
976
  const spec = typeof entry === "function" ? void 0 : entry.abortOn;
974
977
  if (spec !== void 0) {
@@ -984,7 +987,7 @@ function createServer(options) {
984
987
  const lane = typeof entry === "function" ? null : entry.lane ?? null;
985
988
  if (lane !== null && typeof lane !== "function" && (typeof lane !== "string" || lane.length === 0)) throw new TypeError(`lane for '${type}' must be a non-empty string or a function`);
986
989
  handlers.set(type, {
987
- handler,
990
+ handler: callback,
988
991
  abortOn,
989
992
  lane
990
993
  });
@@ -2319,6 +2322,6 @@ function cloneInitial(initial) {
2319
2322
  }
2320
2323
  }
2321
2324
  //#endregion
2322
- export { parsePresenceSibling as a, sseResponse as i, deliverSchedulerAppend as n, setServerFetchHooks as r, createServer as t };
2325
+ export { sseResponse as a, setServerFetchHooks as i, deliverSchedulerAppend as n, parsePresenceSibling as o, handler as r, createServer as t };
2323
2326
 
2324
- //# sourceMappingURL=server-Dkz2a84E.js.map
2327
+ //# sourceMappingURL=server-BeNADlCI.js.map