@cursor/july 0.1.76 → 0.1.78

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.
Files changed (128) hide show
  1. package/dist/channels/origin/origin-webhook.d.ts +23 -2
  2. package/dist/channels/origin/origin-webhook.d.ts.map +1 -1
  3. package/dist/channels/origin/origin-webhook.js +82 -20
  4. package/dist/docs/404.html +2 -2
  5. package/dist/docs/ab.html +3 -3
  6. package/dist/docs/assets/{app.b8bhB2SV.js → app.BsA7t7rS.js} +1 -1
  7. package/dist/docs/assets/chunks/@localSearchIndexroot.Dcs6boxD.js +1 -0
  8. package/dist/docs/assets/chunks/{VPLocalSearchBox.lLSeIyWw.js → VPLocalSearchBox.B1hHhktM.js} +1 -1
  9. package/dist/docs/assets/chunks/{theme.C_owesa-.js → theme.DLpLSsQh.js} +2 -2
  10. package/dist/docs/assets/{storage.md.D8NQ389l.js → storage.md.ks1u64_R.js} +3 -3
  11. package/dist/docs/assets/storage.md.ks1u64_R.lean.js +1 -0
  12. package/dist/docs/building-with-agents.html +3 -3
  13. package/dist/docs/concepts.html +3 -3
  14. package/dist/docs/deployment.html +3 -3
  15. package/dist/docs/evals.html +3 -3
  16. package/dist/docs/example-agents/approval-buddy.html +3 -3
  17. package/dist/docs/example-agents/benny.html +3 -3
  18. package/dist/docs/example-agents/bugbot.html +3 -3
  19. package/dist/docs/example-agents/codebase-wiki.html +3 -3
  20. package/dist/docs/example-agents/codeowners-review.html +3 -3
  21. package/dist/docs/example-agents/concierge.html +3 -3
  22. package/dist/docs/example-agents/fsd.html +3 -3
  23. package/dist/docs/example-agents/index.html +3 -3
  24. package/dist/docs/example-agents/knowledge-base.html +3 -3
  25. package/dist/docs/example-agents/oncall.html +3 -3
  26. package/dist/docs/example-agents/security-reviewer.html +3 -3
  27. package/dist/docs/example-agents/slack-agent.html +3 -3
  28. package/dist/docs/example-agents/weather-agent.html +3 -3
  29. package/dist/docs/guides/agent-to-agent.html +3 -3
  30. package/dist/docs/guides/cloud-runtime.html +3 -3
  31. package/dist/docs/guides/convert-automation.html +3 -3
  32. package/dist/docs/guides/github.html +3 -3
  33. package/dist/docs/guides/human-in-the-loop.html +3 -3
  34. package/dist/docs/guides/mcp-oauth.html +3 -3
  35. package/dist/docs/guides/opentelemetry.html +3 -3
  36. package/dist/docs/guides/slack.html +3 -3
  37. package/dist/docs/guides/webhooks.html +3 -3
  38. package/dist/docs/hashmap.json +1 -1
  39. package/dist/docs/hillclimbing.html +3 -3
  40. package/dist/docs/index.html +3 -3
  41. package/dist/docs/quickstart.html +3 -3
  42. package/dist/docs/reference/agent-config.html +3 -3
  43. package/dist/docs/reference/artifacts.html +3 -3
  44. package/dist/docs/reference/channels.html +3 -3
  45. package/dist/docs/reference/cli.html +3 -3
  46. package/dist/docs/reference/connections.html +3 -3
  47. package/dist/docs/reference/hooks.html +3 -3
  48. package/dist/docs/reference/http-api.html +3 -3
  49. package/dist/docs/reference/instructions.html +3 -3
  50. package/dist/docs/reference/playground.html +3 -3
  51. package/dist/docs/reference/project-layout.html +3 -3
  52. package/dist/docs/reference/prompt.html +3 -3
  53. package/dist/docs/reference/schedules.html +3 -3
  54. package/dist/docs/reference/sessions.html +3 -3
  55. package/dist/docs/reference/skills.html +3 -3
  56. package/dist/docs/reference/subagents.html +3 -3
  57. package/dist/docs/reference/tools.html +3 -3
  58. package/dist/docs/scaffolding-agents.html +3 -3
  59. package/dist/docs/storage.html +7 -7
  60. package/dist/docs/templates/agentic-owners.html +3 -3
  61. package/dist/docs/templates/demo.html +3 -3
  62. package/dist/docs/templates/pr-autofixer.html +3 -3
  63. package/dist/docs/templates/security-reviewer.html +3 -3
  64. package/dist/docs/templates/triage.html +3 -3
  65. package/dist/docs/troubleshooting.html +3 -3
  66. package/dist/index.d.ts +0 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +0 -1
  69. package/dist/internal/discovery.d.ts.map +1 -1
  70. package/dist/internal/discovery.js +3 -21
  71. package/dist/internal/distribution.d.ts.map +1 -1
  72. package/dist/internal/distribution.js +0 -1
  73. package/dist/internal/session-engine.d.ts +1 -60
  74. package/dist/internal/session-engine.d.ts.map +1 -1
  75. package/dist/internal/session-engine.js +10 -109
  76. package/dist/kv/memory-kv.d.ts +1 -10
  77. package/dist/kv/memory-kv.d.ts.map +1 -1
  78. package/dist/kv/memory-kv.js +1 -10
  79. package/dist/kv.d.ts +2 -3
  80. package/dist/kv.d.ts.map +1 -1
  81. package/dist/kv.js +2 -3
  82. package/dist/playground/assets/{index-Bfwz2yLN.css → index-DJzcIeGt.css} +1 -1
  83. package/dist/playground/assets/{index-BWqjJcRo.js → index-K3Sxyx0I.js} +48 -45
  84. package/dist/playground/index.html +2 -2
  85. package/dist/storage-backends/cursor-hosted.js +3 -3
  86. package/dist/storage-protocol.d.ts +3 -8
  87. package/dist/storage-protocol.d.ts.map +1 -1
  88. package/dist/storage-protocol.js +4 -10
  89. package/dist/storage.d.ts +5 -11
  90. package/dist/storage.d.ts.map +1 -1
  91. package/dist/storage.js +3 -4
  92. package/dist/types.d.ts +5 -34
  93. package/dist/types.d.ts.map +1 -1
  94. package/docs/storage.md +11 -44
  95. package/package.json +1 -8
  96. package/src/channels/origin/origin-webhook.ts +111 -25
  97. package/src/index.ts +0 -6
  98. package/src/internal/discovery.ts +3 -27
  99. package/src/internal/distribution.ts +0 -1
  100. package/src/internal/session-engine.ts +1 -168
  101. package/src/kv/memory-kv.ts +1 -10
  102. package/src/kv.ts +2 -3
  103. package/src/storage-backends/cursor-hosted.ts +3 -3
  104. package/src/storage-protocol.ts +4 -10
  105. package/src/storage.ts +6 -12
  106. package/src/types.ts +5 -35
  107. package/dist/docs/assets/chunks/@localSearchIndexroot.DGZeXVqn.js +0 -1
  108. package/dist/docs/assets/storage.md.D8NQ389l.lean.js +0 -1
  109. package/dist/internal/durable-session-store.d.ts +0 -60
  110. package/dist/internal/durable-session-store.d.ts.map +0 -1
  111. package/dist/internal/durable-session-store.js +0 -131
  112. package/dist/internal/ledger-serving.d.ts +0 -169
  113. package/dist/internal/ledger-serving.d.ts.map +0 -1
  114. package/dist/internal/ledger-serving.js +0 -393
  115. package/dist/ledger/janitor.d.ts +0 -60
  116. package/dist/ledger/janitor.d.ts.map +0 -1
  117. package/dist/ledger/janitor.js +0 -137
  118. package/dist/ledger/session-ledger.d.ts +0 -293
  119. package/dist/ledger/session-ledger.d.ts.map +0 -1
  120. package/dist/ledger/session-ledger.js +0 -614
  121. package/dist/ledger.d.ts +0 -12
  122. package/dist/ledger.d.ts.map +0 -1
  123. package/dist/ledger.js +0 -9
  124. package/src/internal/durable-session-store.ts +0 -134
  125. package/src/internal/ledger-serving.ts +0 -531
  126. package/src/ledger/janitor.ts +0 -193
  127. package/src/ledger/session-ledger.ts +0 -839
  128. package/src/ledger.ts +0 -44
@@ -1 +0,0 @@
1
- import{_ as s,c as t,o as a,ag as i}from"./chunks/framework.CAZyNGu9.js";const k=JSON.parse(`{"title":"Storage","description":"Point the Agent SDK's durable storage at a backend you own with defineStorage.","frontmatter":{"title":"Storage","description":"Point the Agent SDK's durable storage at a backend you own with defineStorage."},"headers":[],"relativePath":"storage.md","filePath":"storage.md"}`),n={name:"storage.md"};function o(r,e,d,l,h,p){return a(),t("div",null,[...e[0]||(e[0]=[i("",41)])])}const g=s(n,[["render",o]]);export{k as __pageData,g as default};
@@ -1,60 +0,0 @@
1
- /**
2
- * Durable-session store resolution.
3
- *
4
- * Two APIs, one backend: `defineStorage` is the **storage API** (agent
5
- * state — session records, event chunks, author KV), and the session
6
- * ledger is the **durable session API** (session identity, mailboxes,
7
- * leases, fenced commits). The ledger consumes {@link SessionLedgerKv} —
8
- * the full CAS-capable KV surface, since the inbox reads/sweeps mailbox
9
- * payload blobs (`get`/`put`/`delete`) and scans by prefix (`listKeys`)
10
- * on top of the CAS trio; this module adapts a storage backend's methods
11
- * into that interface, so a deployment's one authored backend serves
12
- * both APIs by default.
13
- *
14
- * Calls go straight at the config's methods — NOT through the
15
- * StorageCoordinator: the coordinator's queue is bounded, serialized, and
16
- * at-most-once (mirror semantics), while ledger CAS calls are the
17
- * correctness path and must observe their own results synchronously.
18
- */
19
- import type { SessionLedgerKv } from "../ledger/session-ledger.js";
20
- import { type StorageConfig } from "../storage.js";
21
- export interface StorageCasKvArgs {
22
- agentName: string;
23
- projectRoot: string;
24
- }
25
- /**
26
- * The one place the ledger's physical namespace is minted: the per-agent
27
- * prefix for ledger state, following the {@link storageKeys} convention
28
- * (`<root>/<agent>/<family>/…`) so a store shared by several ledger-mode
29
- * agents (one fileKv dir, one hosted deployment) never mixes their
30
- * sessions, leases, or mailboxes — and so each agent's janitor
31
- * prefix-scan only ever sees its own ledgers. The extra
32
- * `durable-session` segment keeps the ledger's `session/` family out of
33
- * `storageKeys.sessionPrefix` scans (storage restore lists
34
- * `<root>/<agent>/session/`). The ledger itself never sees this string:
35
- * it speaks bare `session/…` / `ledger/…` / `mailbox/…` keys against a
36
- * handle that {@link namespacedKv} has already scoped.
37
- */
38
- export declare function ledgerKeyPrefix(agentName: string): string;
39
- /**
40
- * Adapt a storage backend into the ledger's KV interface. Throws when
41
- * the backend does not implement the `cas` group, or omits `get` /
42
- * `delete` (optional for resident-only sinks, but the ledger reads and
43
- * sweeps mailbox payload blobs through the same store) — the caller
44
- * turns that into the fail-fast startup error for `serving: "ledger"`.
45
- * Every call carries a `reason: "coordination"` {@link StorageContext}.
46
- */
47
- export declare function storageCasKv(config: StorageConfig, args: StorageCasKvArgs): SessionLedgerKv;
48
- /**
49
- * Scope a raw store handle under a namespace: every key going in gets it
50
- * prepended, and `listKeys` results come back with it **stripped**, so a
51
- * caller that lists and then reads/deletes the returned keys stays fully
52
- * prefix-free (the janitor scan and the orphan sweep do exactly that).
53
- * Applied exactly once, where the engine constructs the ledger's store
54
- * handle — the same conceptual boundary where `host.kv` gets its agent
55
- * scoping. Internal: not part of the public kv interface, and callers
56
- * (including the explicit `durableSessionStore` override) always supply
57
- * the raw store — they never write prefixes.
58
- */
59
- export declare function namespacedKv(store: SessionLedgerKv, namespace: string): SessionLedgerKv;
60
- //# sourceMappingURL=durable-session-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"durable-session-store.d.ts","sourceRoot":"","sources":["../../src/internal/durable-session-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,gBAAgB,GACrB,eAAe,CA0CjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,EACtB,SAAS,EAAE,MAAM,GAChB,eAAe,CAcjB"}
@@ -1,131 +0,0 @@
1
- /**
2
- * Durable-session store resolution.
3
- *
4
- * Two APIs, one backend: `defineStorage` is the **storage API** (agent
5
- * state — session records, event chunks, author KV), and the session
6
- * ledger is the **durable session API** (session identity, mailboxes,
7
- * leases, fenced commits). The ledger consumes {@link SessionLedgerKv} —
8
- * the full CAS-capable KV surface, since the inbox reads/sweeps mailbox
9
- * payload blobs (`get`/`put`/`delete`) and scans by prefix (`listKeys`)
10
- * on top of the CAS trio; this module adapts a storage backend's methods
11
- * into that interface, so a deployment's one authored backend serves
12
- * both APIs by default.
13
- *
14
- * Calls go straight at the config's methods — NOT through the
15
- * StorageCoordinator: the coordinator's queue is bounded, serialized, and
16
- * at-most-once (mirror semantics), while ledger CAS calls are the
17
- * correctness path and must observe their own results synchronously.
18
- */
19
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
20
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21
- return new (P || (P = Promise))(function (resolve, reject) {
22
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
25
- step((generator = generator.apply(thisArg, _arguments || [])).next());
26
- });
27
- };
28
- import { keySegment, STORAGE_KEY_ROOT, } from "../storage.js";
29
- /**
30
- * The one place the ledger's physical namespace is minted: the per-agent
31
- * prefix for ledger state, following the {@link storageKeys} convention
32
- * (`<root>/<agent>/<family>/…`) so a store shared by several ledger-mode
33
- * agents (one fileKv dir, one hosted deployment) never mixes their
34
- * sessions, leases, or mailboxes — and so each agent's janitor
35
- * prefix-scan only ever sees its own ledgers. The extra
36
- * `durable-session` segment keeps the ledger's `session/` family out of
37
- * `storageKeys.sessionPrefix` scans (storage restore lists
38
- * `<root>/<agent>/session/`). The ledger itself never sees this string:
39
- * it speaks bare `session/…` / `ledger/…` / `mailbox/…` keys against a
40
- * handle that {@link namespacedKv} has already scoped.
41
- */
42
- export function ledgerKeyPrefix(agentName) {
43
- return `${STORAGE_KEY_ROOT}/${keySegment(agentName)}/durable-session/`;
44
- }
45
- /**
46
- * Adapt a storage backend into the ledger's KV interface. Throws when
47
- * the backend does not implement the `cas` group, or omits `get` /
48
- * `delete` (optional for resident-only sinks, but the ledger reads and
49
- * sweeps mailbox payload blobs through the same store) — the caller
50
- * turns that into the fail-fast startup error for `serving: "ledger"`.
51
- * Every call carries a `reason: "coordination"` {@link StorageContext}.
52
- */
53
- export function storageCasKv(config, args) {
54
- const ctx = {
55
- agentName: args.agentName,
56
- projectRoot: args.projectRoot,
57
- reason: "coordination",
58
- };
59
- const { cas } = config;
60
- if (cas === undefined) {
61
- throw new Error("storageCasKv: the storage backend does not implement the cas group (conditional writes)");
62
- }
63
- const get = config.get;
64
- const remove = config.delete;
65
- if (get === undefined || remove === undefined) {
66
- throw new Error("storageCasKv: the storage backend must implement get and delete (the session ledger reads and sweeps payload blobs through the same store)");
67
- }
68
- return {
69
- get(key) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- var _a;
72
- return (_a = (yield get(key, ctx))) !== null && _a !== void 0 ? _a : undefined;
73
- });
74
- },
75
- put(key, value) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- yield config.put(key, value, ctx);
78
- });
79
- },
80
- delete(key) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- yield remove(key, ctx);
83
- });
84
- },
85
- getWithVersion(key) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- return yield cas.getWithVersion(key, ctx);
88
- });
89
- },
90
- putIfAbsent(key, value) {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- return yield cas.putIfAbsent(key, value, ctx);
93
- });
94
- },
95
- putIfVersion(key, value, expectedVersion) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- return yield cas.putIfVersion(key, value, expectedVersion, ctx);
98
- });
99
- },
100
- listKeys(prefix) {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- return yield cas.listKeys(prefix, ctx);
103
- });
104
- },
105
- };
106
- }
107
- /**
108
- * Scope a raw store handle under a namespace: every key going in gets it
109
- * prepended, and `listKeys` results come back with it **stripped**, so a
110
- * caller that lists and then reads/deletes the returned keys stays fully
111
- * prefix-free (the janitor scan and the orphan sweep do exactly that).
112
- * Applied exactly once, where the engine constructs the ledger's store
113
- * handle — the same conceptual boundary where `host.kv` gets its agent
114
- * scoping. Internal: not part of the public kv interface, and callers
115
- * (including the explicit `durableSessionStore` override) always supply
116
- * the raw store — they never write prefixes.
117
- */
118
- export function namespacedKv(store, namespace) {
119
- return {
120
- get: (key) => store.get(namespace + key),
121
- put: (key, value) => store.put(namespace + key, value),
122
- delete: (key) => store.delete(namespace + key),
123
- getWithVersion: (key) => store.getWithVersion(namespace + key),
124
- putIfAbsent: (key, value) => store.putIfAbsent(namespace + key, value),
125
- putIfVersion: (key, value, expectedVersion) => store.putIfVersion(namespace + key, value, expectedVersion),
126
- listKeys: (prefix) => __awaiter(this, void 0, void 0, function* () {
127
- const keys = yield store.listKeys(namespace + prefix);
128
- return keys.map((key) => key.slice(namespace.length));
129
- }),
130
- };
131
- }
@@ -1,169 +0,0 @@
1
- /**
2
- * Ledger-mode serving seam (`serving: "ledger"` on `defineAgent`): an event
3
- * pump that routes every engine `send` through the KV session ledger
4
- * instead of starting turns directly.
5
- *
6
- * Delivery: ensureSession (continuation key, as today) → principal gate
7
- * (an existing session rejects a sender that is not its principal BEFORE
8
- * anything is parked; mirrors the resident `samePrincipal` check) →
9
- * appendEvent (payload + CAS — the source ack point moves after this) →
10
- * claim → drain → run the drained turns through the resident engine path →
11
- * commit (heartbeats while turns run) → repeat while the commit reports
12
- * pending. A deliver that finds the lease held walks away (the holder's
13
- * commit sees the append); the janitor recovers sessions whose holder
14
- * died. A foreign-principal envelope that reaches the mailbox anyway is
15
- * consumed and committed away at drain (warn log), never replayed.
16
- *
17
- * v1 scope: the mailbox envelope carries `message`, `auth`, `title`,
18
- * `state`, `mode`, `purpose`, and the isolation-relevant per-send
19
- * overrides `workspaceDir` and `cloud` — the two options
20
- * `resolveSessionRuntime` and harness-cwd selection read. Dropping
21
- * those is a sandbox escape, not a feature gap: without them a drained
22
- * GitHub/Slack turn falls back to the local runtime with the default
23
- * harness cwd, so untrusted channel content drives tools on the serve
24
- * host instead of the cloud VM / channel worktree. `coalesceSourceTs`
25
- * (when present) is used as the drain-ordering `sourceTs`. Deferred
26
- * (documented, not silently faked — deliver logs a warning naming what
27
- * it dropped): `workspaceFiles` and per-turn `images` (content
28
- * injection, and their base64 payloads can blow the mailbox blob past
29
- * hosted KV value caps), `sdkAgentId` seeding, and `admission`
30
- * semantics (both `"preempt"` and Slack `"coalesce"` nudge bookkeeping
31
- * — ledger draining already serializes turns, but nothing is
32
- * interrupted or coalesced through the mailbox).
33
- */
34
- import type { SessionLedger } from "../ledger/session-ledger.js";
35
- import type { AgentCloudOptions, AuthContext, ChannelSession, JsonValue, SendMessageOptions, SessionPurpose } from "../types.js";
36
- /** The JSON payload stored in `mailbox/<sessionId>/<eventId>`. */
37
- export interface LedgerDeliveryEnvelope {
38
- channelId: string;
39
- continuationToken: string;
40
- message: string;
41
- auth: AuthContext | null;
42
- title?: string;
43
- state?: JsonValue;
44
- mode?: "chat" | "task";
45
- purpose?: SessionPurpose;
46
- /**
47
- * Isolation-relevant per-send overrides, reapplied on the resident
48
- * send at drain. Absent on envelopes parked by earlier builds — the
49
- * drain then behaves as those builds did (agent-default runtime/cwd).
50
- */
51
- workspaceDir?: string;
52
- cloud?: AgentCloudOptions;
53
- }
54
- /** The `send` options the envelope can carry through the mailbox. */
55
- export type LedgerDeliverOptions = SendMessageOptions & {
56
- mode?: "chat" | "task";
57
- };
58
- export interface LedgerServingOptions {
59
- ledger: SessionLedger;
60
- /**
61
- * Run one drained event as a resident-path turn (the engine's `send`
62
- * with the internal `fromLedgerPump` flag). Must resolve once the turn
63
- * is admitted; the pump awaits `waitForCompletion` itself.
64
- */
65
- deliverTurn: (envelope: LedgerDeliveryEnvelope) => Promise<ChannelSession>;
66
- /** Engine continuation lookup (local index + lazy storage restore). */
67
- findSession: (channelId: string, continuationToken: string) => Promise<ChannelSession | undefined>;
68
- logger?: (line: string) => void;
69
- /** Lease heartbeat cadence while turns run (default 10s). */
70
- heartbeatIntervalMs?: number;
71
- /** Janitor scan cadence (default `DEFAULT_JANITOR_INTERVAL_MS`). */
72
- janitorIntervalMs?: number;
73
- clock?: () => number;
74
- }
75
- export declare class LedgerServing {
76
- private readonly ledger;
77
- private readonly deliverTurn;
78
- private readonly findSession;
79
- private readonly logger;
80
- private readonly heartbeatIntervalMs;
81
- private readonly clock;
82
- private readonly janitor;
83
- /** One pump per ledger session — the in-process face of the lease. */
84
- private readonly pumps;
85
- /** Fire-and-forget re-pump checks, awaited on close. */
86
- private readonly background;
87
- constructor(options: LedgerServingOptions);
88
- /** Start the janitor loop (recovers expired-lease sessions). */
89
- start(): void;
90
- /** Stop the janitor and settle in-flight pumps and re-pump checks. */
91
- close(): Promise<void>;
92
- /**
93
- * Ledger-mode `send`: append the message to the session mailbox, then
94
- * serve pending events (or walk away if another holder is already
95
- * serving them). Resolves with the engine session handle once one
96
- * exists — the ack point is the durable append, not turn completion —
97
- * so HTTP create/follow-up can return a session id while the holder is
98
- * still in flight. When this process wins the claim, the pump keeps
99
- * draining in the background; callers that need the turn to finish use
100
- * `waitForCompletion` (and the lease releases on the pump's commit).
101
- * When another holder is serving the session and no engine session
102
- * exists on this pod, the delivery is still a success — the event is
103
- * durably parked and the holder's commit (or the janitor) drains it —
104
- * so the resolved handle is a parked stand-in carrying the durable
105
- * session identity.
106
- */
107
- deliver(channelId: string, message: string, options: LedgerDeliverOptions): Promise<ChannelSession>;
108
- /**
109
- * The stand-in handle for a delivery whose event is parked while
110
- * another holder serves the session: real durable identity, no local
111
- * turn. `waitForCompletion` resolves immediately — the parked event's
112
- * turn runs on the holder, so there is nothing local to await (the
113
- * same contract as a coalesced send, whose outcome is not its own
114
- * message's turn). The event stream and re-keying live wherever the
115
- * turn runs, so both fail loudly here.
116
- */
117
- private parkedSession;
118
- /**
119
- * Return a handle as soon as the engine session exists, without waiting
120
- * for the pump to commit. If the pump settles without creating a
121
- * session (walk-away, or a throw before admit), surface that: rethrow
122
- * a failed claimant turn, otherwise the parked stand-in.
123
- */
124
- private resolveDeliverHandle;
125
- /**
126
- * Drain ordering: prefer the real source time over this pod's receipt
127
- * time. `coalesceSourceTs` is a Slack-style seconds string
128
- * (`"1712345678.000100"`); normalize sub-epoch-ms values to ms so they
129
- * stay comparable with the `Date.now()` fallback.
130
- */
131
- private resolveSourceTs;
132
- /**
133
- * One warning per delivery naming the send options the mailbox does not
134
- * replay — better a loud line than an author silently losing images or
135
- * admission semantics on a ledger-mode agent.
136
- */
137
- private warnOnDroppedOptions;
138
- /**
139
- * Serve a session's pending events. When a pump is already running the
140
- * caller walks away (the holder's commit re-reads pending) — except
141
- * that the holder's *final* commit may have released before this
142
- * append landed, so a re-check is chained behind it. Deliver never
143
- * awaits this promise for its full lifetime: awaiting a new pump would
144
- * block HTTP until the turn committed, and awaiting a running pump
145
- * would deadlock a send issued from inside one of its turns.
146
- */
147
- private servePending;
148
- /** Claim-or-defer entry used after an append and after a pump settles. */
149
- private runPump;
150
- /** Janitor hand-off: the claim already happened, just run the turns. */
151
- private serveClaimed;
152
- /**
153
- * Re-pump after the previous holder settled, covering the release window
154
- * where an append landed after that holder's final commit.
155
- */
156
- private repumpIfPending;
157
- /** Register a pump in the per-session map for its lifetime. */
158
- private track;
159
- /**
160
- * The drain → turn → commit loop for a held lease. Heartbeats extend the
161
- * lease while turns run; a fenced heartbeat (or fenced commit) means a
162
- * new holder took over — discard without committing; the new holder
163
- * re-drains (at-least-once actuation, exactly-once ledger apply).
164
- */
165
- private runClaimedTurns;
166
- }
167
- /** Mint the lease holder id for this process. */
168
- export declare function newLedgerPodId(): string;
169
- //# sourceMappingURL=ledger-serving.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ledger-serving.d.ts","sourceRoot":"","sources":["../../src/internal/ledger-serving.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAQH,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK9E,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,cAAc,EACf,MAAM,aAAa,CAAC;AAKrB,kEAAkE;AAClE,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IAC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