experimental-a2 0.18.0 → 0.18.1
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 +11 -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-BMLlI2Ff.d.ts} +2 -2
- package/dist/{ai-DrUaMyRt.d.ts.map → ai-BMLlI2Ff.d.ts.map} +1 -1
- package/dist/{ai-BpOGm-zB.js → ai-D6mGlO8j.js} +2 -2
- package/dist/{ai-BpOGm-zB.js.map → ai-D6mGlO8j.js.map} +1 -1
- package/dist/ai-client.d.ts +1 -1
- package/dist/ai-client.js +2 -2
- package/dist/ai-fx.d.ts +1 -1
- package/dist/ai-fx.d.ts.map +1 -1
- package/dist/ai-fx.js +92 -34
- package/dist/ai-fx.js.map +1 -1
- package/dist/{ai-harness-DvsPeJeB.d.ts → ai-harness-B2suP2Qh.d.ts} +2 -2
- package/dist/{ai-harness-DvsPeJeB.d.ts.map → ai-harness-B2suP2Qh.d.ts.map} +1 -1
- package/dist/ai-pi.d.ts +1 -1
- package/dist/ai-pi.d.ts.map +1 -1
- package/dist/ai-pi.js +59 -13
- 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 +10 -6
- 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 +1 -1
- 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 +9 -10
- 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 +2 -2
- package/docs/index.mdx +3 -3
- package/docs/reference/02-server.mdx +12 -7
- package/docs/reference/04-ai.mdx +16 -7
- package/docs/reference/05-adapters.mdx +4 -4
- package/docs/server/01-handlers.mdx +1 -1
- package/docs/server/03-cancellation.mdx +3 -2
- package/docs/server/05-production.mdx +2 -1
- package/docs/server/06-guarantees.mdx +20 -11
- package/examples/playground/DEPLOY.md +2 -4
- package/examples/playground/app/a0/[appId]/page.tsx +2 -8
- package/examples/playground/app/a0/devtools.tsx +2 -8
- package/examples/playground/app/a0/server.ts +8 -19
- package/examples/playground/package.json +1 -1
- package/package.json +1 -1
- package/src/ai-agent.ts +10 -3
- package/src/ai-fx.ts +126 -47
- package/src/ai-pi.ts +74 -15
- package/src/ai-tool-input.ts +45 -0
- package/src/internal.ts +6 -0
- package/src/scheduler-qstash.ts +5 -5
- package/src/scheduler-vercel.ts +14 -15
- 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/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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { a as NonRetriableError, i as A2Error, n as isSessionCleared, o as asStoreUnavailable, r as sessionClearedError } from "./session-clear-DGI4jTQ5.js";
|
|
2
2
|
import { n as foldEvent, s as validateSync, t as cloneInitial } from "./reducer-BAXc8JyF.js";
|
|
3
3
|
import { n as encodeState, t as decodeState } from "./reducer-runtime-DQwz_J59.js";
|
|
4
|
-
import { _ as nullProtoRecord, c as STATE_CACHE, g as markSchedulerSendFailure, i as POLL_TIMINGS, l as STREAM_TIMINGS, m as failedPreviousAttempt, o as RESERVED_PARTICIPANT_IDS, s as SOCKET_TIMINGS, t as DRAIN_TIMINGS, v as serverInternals, y as stateTailReaders } from "./internal-
|
|
4
|
+
import { _ as nullProtoRecord, c as STATE_CACHE, g as markSchedulerSendFailure, i as POLL_TIMINGS, l as STREAM_TIMINGS, m as failedPreviousAttempt, o as RESERVED_PARTICIPANT_IDS, s as SOCKET_TIMINGS, t as DRAIN_TIMINGS, v as serverInternals, y as stateTailReaders } from "./internal-CscSY7K_.js";
|
|
5
5
|
import { t as boundedCache } from "./bounded-cache-CPHWF-8h.js";
|
|
6
|
-
import { i as streamActivities, r as createStreamActivity, t as defaultSleep } from "./store-polling-
|
|
6
|
+
import { i as streamActivities, r as createStreamActivity, t as defaultSleep } from "./store-polling-7WJV0YWP.js";
|
|
7
7
|
import { i as takeBuffered, n as isSerializedEvent, r as parseSerializedEvent, t as bufferedEvents } from "./stream-buffer-Cx7AAPGq.js";
|
|
8
8
|
import { r as platformWaitUntil, t as invocationDeadlineMs } from "./platform-B4TnJtWu.js";
|
|
9
|
-
import { A as stateSnapshotToWire, C as serializedEventToWireJson, D as socketFrameFor, E as socketEventsFor, O as socketSubscribedFor, S as presenceSnapshotToWire, T as socketErrorAckFor, b as presencePatchToWire, d as heldEventBatch, i as compactEventJson, j as wireVersion, k as socketUnsubscribedFor, m as isStreamEvent, n as SOCKET_PING_FRAME, o as errorStatus, r as asA2Error, s as errorToWire, t as EVENT_WRITE_CHARS, u as eventToWire, w as socketAckFor } from "./wire-
|
|
9
|
+
import { A as stateSnapshotToWire, C as serializedEventToWireJson, D as socketFrameFor, E as socketEventsFor, O as socketSubscribedFor, S as presenceSnapshotToWire, T as socketErrorAckFor, b as presencePatchToWire, d as heldEventBatch, i as compactEventJson, j as wireVersion, k as socketUnsubscribedFor, m as isStreamEvent, n as SOCKET_PING_FRAME, o as errorStatus, r as asA2Error, s as errorToWire, t as EVENT_WRITE_CHARS, u as eventToWire, w as socketAckFor } from "./wire-BKxH1vbP.js";
|
|
10
10
|
import { t as retryableLazy } from "./retryable-lazy-DZWmHpii.js";
|
|
11
11
|
//#region src/push-envelope.ts
|
|
12
12
|
/**
|
|
@@ -1105,6 +1105,8 @@ function handler(entry) {
|
|
|
1105
1105
|
return typeof entry === "function" ? { handler: entry } : entry;
|
|
1106
1106
|
}
|
|
1107
1107
|
const MAX_FAILURES = 10;
|
|
1108
|
+
/** How long an event waits after its `failureCount`th failed attempt. */
|
|
1109
|
+
const failureRetryDelayMs = (failureCount) => Math.min(DRAIN_TIMINGS.failureRetryBaseMs * 2 ** Math.max(failureCount - 1, 0), DRAIN_TIMINGS.failureRetryMaxMs);
|
|
1108
1110
|
/** Abort a lost attempt's handler and release its drain slot. */
|
|
1109
1111
|
function endSuperseded(entry, message) {
|
|
1110
1112
|
entry.supersede.abort(new A2Error("SUPERSEDED_ATTEMPT", message));
|
|
@@ -1165,9 +1167,11 @@ function pruneAbortHub(hub) {
|
|
|
1165
1167
|
for (const [index, event] of hub.seen) if (index <= minimum || !types.has(event.type)) hub.seen.delete(index);
|
|
1166
1168
|
}
|
|
1167
1169
|
/**
|
|
1168
|
-
* Deadlines tighten the claim/watchdog window
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1170
|
+
* Deadlines tighten the claim/watchdog window, and a passed deadline ends
|
|
1171
|
+
* claiming: a claim then could not run, only lapse and be claimed again until
|
|
1172
|
+
* the platform ends the process. A platform timeout otherwise follows the
|
|
1173
|
+
* same path as any other process death: the in-flight event remains pending
|
|
1174
|
+
* and a fresh invocation retries it.
|
|
1171
1175
|
*/
|
|
1172
1176
|
function nextClaimWindow() {
|
|
1173
1177
|
const nowMs = Date.now();
|
|
@@ -1180,7 +1184,8 @@ function nextClaimWindow() {
|
|
|
1180
1184
|
ttlMs,
|
|
1181
1185
|
expiresAtMs,
|
|
1182
1186
|
watchdogAtMs: expiresAtMs + DRAIN_TIMINGS.watchdogGraceMs,
|
|
1183
|
-
deadlineCapped
|
|
1187
|
+
deadlineCapped,
|
|
1188
|
+
pastDeadline: deadlineMs !== null && deadlineTtlMs <= 0
|
|
1184
1189
|
};
|
|
1185
1190
|
}
|
|
1186
1191
|
function schedulerSlot(dueAt) {
|
|
@@ -2639,6 +2644,19 @@ function createServer(options) {
|
|
|
2639
2644
|
renewal = tracked;
|
|
2640
2645
|
return tracked;
|
|
2641
2646
|
};
|
|
2647
|
+
/** Records an event the store dead-lettered on takeover; it never runs. */
|
|
2648
|
+
const reportExhausted = (event) => telemetry.span("a2.event", {
|
|
2649
|
+
"a2.contract": name,
|
|
2650
|
+
"a2.session_id": sessionId,
|
|
2651
|
+
"a2.event.type": event.type,
|
|
2652
|
+
"a2.event.index": event.index,
|
|
2653
|
+
"a2.event.id": event.id,
|
|
2654
|
+
"a2.event.attempt": event.attemptCount,
|
|
2655
|
+
"a2.event.handled": handlers.has(event.type),
|
|
2656
|
+
...event.lane === null ? {} : { "a2.event.lane": event.lane }
|
|
2657
|
+
}, async (eventSpan) => {
|
|
2658
|
+
eventSpan.setAttribute("a2.event.outcome", "dead_lettered");
|
|
2659
|
+
});
|
|
2642
2660
|
const runEvent = async (event, supersedeSignal, endAttempt) => {
|
|
2643
2661
|
const registration = handlers.get(event.type);
|
|
2644
2662
|
return telemetry.span("a2.event", {
|
|
@@ -2688,7 +2706,8 @@ function createServer(options) {
|
|
|
2688
2706
|
index: event.index,
|
|
2689
2707
|
attempt: event.attemptCount,
|
|
2690
2708
|
error: describeError(err),
|
|
2691
|
-
maxFailures: err instanceof NonRetriableError ? 1 : MAX_FAILURES
|
|
2709
|
+
maxFailures: err instanceof NonRetriableError ? 1 : MAX_FAILURES,
|
|
2710
|
+
retryAfterMs: failureRetryDelayMs(event.failureCount + 1)
|
|
2692
2711
|
});
|
|
2693
2712
|
commitSpan.setAttribute("a2.commit.outcome", result.outcome);
|
|
2694
2713
|
return result;
|
|
@@ -2780,6 +2799,10 @@ function createServer(options) {
|
|
|
2780
2799
|
let claim;
|
|
2781
2800
|
if (shouldClaim) {
|
|
2782
2801
|
const window = nextClaimWindow();
|
|
2802
|
+
if (window.pastDeadline) {
|
|
2803
|
+
outcome = "busy";
|
|
2804
|
+
break;
|
|
2805
|
+
}
|
|
2783
2806
|
claim = await telemetry.span("a2.claim", {
|
|
2784
2807
|
"a2.contract": name,
|
|
2785
2808
|
"a2.session_id": sessionId
|
|
@@ -2788,6 +2811,7 @@ function createServer(options) {
|
|
|
2788
2811
|
sessionId: ns,
|
|
2789
2812
|
holder,
|
|
2790
2813
|
ttlMs: window.ttlMs,
|
|
2814
|
+
maxFailures: MAX_FAILURES,
|
|
2791
2815
|
...window.deadlineCapped ? { expiresAtMs: window.expiresAtMs } : {},
|
|
2792
2816
|
...excluded.size === 0 ? {} : { excludeIndexes: [...excluded] }
|
|
2793
2817
|
});
|
|
@@ -2796,9 +2820,11 @@ function createServer(options) {
|
|
|
2796
2820
|
return result;
|
|
2797
2821
|
});
|
|
2798
2822
|
if (claim.outcome === "claimed") {
|
|
2799
|
-
|
|
2823
|
+
const runnable = claim.events.filter((event) => event.failedAt === null);
|
|
2824
|
+
for (const event of claim.events) if (event.failedAt !== null) await reportExhausted(event);
|
|
2825
|
+
if (runnable.length > 0) requestWatchdog(window.watchdogAtMs);
|
|
2800
2826
|
if (window.deadlineCapped) stopRenewing = true;
|
|
2801
|
-
for (const event of
|
|
2827
|
+
for (const event of runnable) start(event, window.expiresAtMs);
|
|
2802
2828
|
shouldClaim = false;
|
|
2803
2829
|
}
|
|
2804
2830
|
}
|
|
@@ -3023,4 +3049,4 @@ const stateCacheKey = (sessionId, reducerName) => `${sessionId}\u0000${reducerNa
|
|
|
3023
3049
|
//#endregion
|
|
3024
3050
|
export { CONSOLE_TELEMETRY as a, parsePresenceSibling as c, handler as i, deliverSchedulerAppend as n, setServerFetchHooks as o, deliverSchedulerClear as r, sseResponse as s, createServer as t };
|
|
3025
3051
|
|
|
3026
|
-
//# sourceMappingURL=server-
|
|
3052
|
+
//# sourceMappingURL=server-D-Y4pqwu.js.map
|