@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.
- package/dist/channels/origin/origin-webhook.d.ts +23 -2
- package/dist/channels/origin/origin-webhook.d.ts.map +1 -1
- package/dist/channels/origin/origin-webhook.js +82 -20
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.b8bhB2SV.js → app.BsA7t7rS.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.Dcs6boxD.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.lLSeIyWw.js → VPLocalSearchBox.B1hHhktM.js} +1 -1
- package/dist/docs/assets/chunks/{theme.C_owesa-.js → theme.DLpLSsQh.js} +2 -2
- package/dist/docs/assets/{storage.md.D8NQ389l.js → storage.md.ks1u64_R.js} +3 -3
- package/dist/docs/assets/storage.md.ks1u64_R.lean.js +1 -0
- package/dist/docs/building-with-agents.html +3 -3
- package/dist/docs/concepts.html +3 -3
- package/dist/docs/deployment.html +3 -3
- package/dist/docs/evals.html +3 -3
- package/dist/docs/example-agents/approval-buddy.html +3 -3
- package/dist/docs/example-agents/benny.html +3 -3
- package/dist/docs/example-agents/bugbot.html +3 -3
- package/dist/docs/example-agents/codebase-wiki.html +3 -3
- package/dist/docs/example-agents/codeowners-review.html +3 -3
- package/dist/docs/example-agents/concierge.html +3 -3
- package/dist/docs/example-agents/fsd.html +3 -3
- package/dist/docs/example-agents/index.html +3 -3
- package/dist/docs/example-agents/knowledge-base.html +3 -3
- package/dist/docs/example-agents/oncall.html +3 -3
- package/dist/docs/example-agents/security-reviewer.html +3 -3
- package/dist/docs/example-agents/slack-agent.html +3 -3
- package/dist/docs/example-agents/weather-agent.html +3 -3
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +3 -3
- package/dist/docs/guides/convert-automation.html +3 -3
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/mcp-oauth.html +3 -3
- package/dist/docs/guides/opentelemetry.html +3 -3
- package/dist/docs/guides/slack.html +3 -3
- package/dist/docs/guides/webhooks.html +3 -3
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +3 -3
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/artifacts.html +3 -3
- package/dist/docs/reference/channels.html +3 -3
- package/dist/docs/reference/cli.html +3 -3
- package/dist/docs/reference/connections.html +3 -3
- package/dist/docs/reference/hooks.html +3 -3
- package/dist/docs/reference/http-api.html +3 -3
- package/dist/docs/reference/instructions.html +3 -3
- package/dist/docs/reference/playground.html +3 -3
- package/dist/docs/reference/project-layout.html +3 -3
- package/dist/docs/reference/prompt.html +3 -3
- package/dist/docs/reference/schedules.html +3 -3
- package/dist/docs/reference/sessions.html +3 -3
- package/dist/docs/reference/skills.html +3 -3
- package/dist/docs/reference/subagents.html +3 -3
- package/dist/docs/reference/tools.html +3 -3
- package/dist/docs/scaffolding-agents.html +3 -3
- package/dist/docs/storage.html +7 -7
- package/dist/docs/templates/agentic-owners.html +3 -3
- package/dist/docs/templates/demo.html +3 -3
- package/dist/docs/templates/pr-autofixer.html +3 -3
- package/dist/docs/templates/security-reviewer.html +3 -3
- package/dist/docs/templates/triage.html +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +3 -21
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +0 -1
- package/dist/internal/session-engine.d.ts +1 -60
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +10 -109
- package/dist/kv/memory-kv.d.ts +1 -10
- package/dist/kv/memory-kv.d.ts.map +1 -1
- package/dist/kv/memory-kv.js +1 -10
- package/dist/kv.d.ts +2 -3
- package/dist/kv.d.ts.map +1 -1
- package/dist/kv.js +2 -3
- package/dist/playground/assets/{index-Bfwz2yLN.css → index-DJzcIeGt.css} +1 -1
- package/dist/playground/assets/{index-BWqjJcRo.js → index-K3Sxyx0I.js} +48 -45
- package/dist/playground/index.html +2 -2
- package/dist/storage-backends/cursor-hosted.js +3 -3
- package/dist/storage-protocol.d.ts +3 -8
- package/dist/storage-protocol.d.ts.map +1 -1
- package/dist/storage-protocol.js +4 -10
- package/dist/storage.d.ts +5 -11
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +3 -4
- package/dist/types.d.ts +5 -34
- package/dist/types.d.ts.map +1 -1
- package/docs/storage.md +11 -44
- package/package.json +1 -8
- package/src/channels/origin/origin-webhook.ts +111 -25
- package/src/index.ts +0 -6
- package/src/internal/discovery.ts +3 -27
- package/src/internal/distribution.ts +0 -1
- package/src/internal/session-engine.ts +1 -168
- package/src/kv/memory-kv.ts +1 -10
- package/src/kv.ts +2 -3
- package/src/storage-backends/cursor-hosted.ts +3 -3
- package/src/storage-protocol.ts +4 -10
- package/src/storage.ts +6 -12
- package/src/types.ts +5 -35
- package/dist/docs/assets/chunks/@localSearchIndexroot.DGZeXVqn.js +0 -1
- package/dist/docs/assets/storage.md.D8NQ389l.lean.js +0 -1
- package/dist/internal/durable-session-store.d.ts +0 -60
- package/dist/internal/durable-session-store.d.ts.map +0 -1
- package/dist/internal/durable-session-store.js +0 -131
- package/dist/internal/ledger-serving.d.ts +0 -169
- package/dist/internal/ledger-serving.d.ts.map +0 -1
- package/dist/internal/ledger-serving.js +0 -393
- package/dist/ledger/janitor.d.ts +0 -60
- package/dist/ledger/janitor.d.ts.map +0 -1
- package/dist/ledger/janitor.js +0 -137
- package/dist/ledger/session-ledger.d.ts +0 -293
- package/dist/ledger/session-ledger.d.ts.map +0 -1
- package/dist/ledger/session-ledger.js +0 -614
- package/dist/ledger.d.ts +0 -12
- package/dist/ledger.d.ts.map +0 -1
- package/dist/ledger.js +0 -9
- package/src/internal/durable-session-store.ts +0 -134
- package/src/internal/ledger-serving.ts +0 -531
- package/src/ledger/janitor.ts +0 -193
- package/src/ledger/session-ledger.ts +0 -839
- package/src/ledger.ts +0 -44
package/src/ledger/janitor.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The ledger janitor: lazy crash recovery has a hole — a session with
|
|
3
|
-
* pending events and no future events would wait forever — so serving runs
|
|
4
|
-
* this loop. It scans `ledger/` by prefix, finds pending-with-expired-lease
|
|
5
|
-
* sessions, claims them, and hands each claim to the execution callback.
|
|
6
|
-
* Self-host runs the same loop; it is part of the library, not the control
|
|
7
|
-
* plane.
|
|
8
|
-
*
|
|
9
|
-
* Nothing starts on construction: call `start()` for the interval loop or
|
|
10
|
-
* `runOnce()` for an explicit pass (what unit tests use).
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type {
|
|
14
|
-
ClaimResult,
|
|
15
|
-
LedgerLease,
|
|
16
|
-
SessionLedger,
|
|
17
|
-
} from "./session-ledger.js";
|
|
18
|
-
|
|
19
|
-
export const DEFAULT_JANITOR_INTERVAL_MS = 15_000;
|
|
20
|
-
|
|
21
|
-
export interface JanitorClaimedSession {
|
|
22
|
-
sessionId: string;
|
|
23
|
-
lease: LedgerLease;
|
|
24
|
-
head: number;
|
|
25
|
-
pending: string[];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface JanitorRunResult {
|
|
29
|
-
/** Ledgers scanned this pass. */
|
|
30
|
-
scanned: number;
|
|
31
|
-
/** Sessions this pass claimed and handed to the callback. */
|
|
32
|
-
claimed: JanitorClaimedSession[];
|
|
33
|
-
/** Orphan blob ids deleted (only when the sweep is enabled). */
|
|
34
|
-
orphansDeleted: string[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface LedgerJanitorOptions {
|
|
38
|
-
ledger: SessionLedger;
|
|
39
|
-
/**
|
|
40
|
-
* Executes a recovered session: drain, run the turn, commit. Awaited so
|
|
41
|
-
* one pass never claims more sessions than it can serve.
|
|
42
|
-
*/
|
|
43
|
-
onSession: (session: JanitorClaimedSession) => Promise<void> | void;
|
|
44
|
-
/** Scan cadence for `start()` (default {@link DEFAULT_JANITOR_INTERVAL_MS}). */
|
|
45
|
-
intervalMs?: number;
|
|
46
|
-
/**
|
|
47
|
-
* Also sweep unreferenced mailbox blobs each pass. Off by default —
|
|
48
|
-
* enable with `{ olderThanMs }` (see `SessionLedger.sweepOrphans`).
|
|
49
|
-
*/
|
|
50
|
-
orphanSweep?: { olderThanMs?: number };
|
|
51
|
-
/** Called with per-session or sweep failures; the pass continues. */
|
|
52
|
-
onError?: (error: unknown, sessionId?: string) => void;
|
|
53
|
-
/** Time source for lease-expiry checks (default `Date.now`). */
|
|
54
|
-
clock?: () => number;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface LedgerJanitor {
|
|
58
|
-
start(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Clear the interval AND await any in-flight pass: a running pass can
|
|
61
|
-
* claim a session and spawn a turn, so shutdown must not proceed while
|
|
62
|
-
* one is mid-scan.
|
|
63
|
-
*/
|
|
64
|
-
stop(): Promise<void>;
|
|
65
|
-
runOnce(): Promise<JanitorRunResult>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function createLedgerJanitor(
|
|
69
|
-
options: LedgerJanitorOptions
|
|
70
|
-
): LedgerJanitor {
|
|
71
|
-
const intervalMs = options.intervalMs ?? DEFAULT_JANITOR_INTERVAL_MS;
|
|
72
|
-
const clock = options.clock ?? Date.now;
|
|
73
|
-
const reportError =
|
|
74
|
-
options.onError ??
|
|
75
|
-
((): void => {
|
|
76
|
-
// Recovery is best-effort per pass; an unobserved failure is retried
|
|
77
|
-
// on the next scan.
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
let timer: ReturnType<typeof setInterval> | undefined;
|
|
81
|
-
let running = false;
|
|
82
|
-
/** The settled-shape promise of the pass currently scanning, if any. */
|
|
83
|
-
let inFlight: Promise<void> | undefined;
|
|
84
|
-
|
|
85
|
-
const runPass = async (): Promise<JanitorRunResult> => {
|
|
86
|
-
// An unparseable ledger record is reported and skipped: it degrades
|
|
87
|
-
// that one session's recovery, never the whole agent's pass.
|
|
88
|
-
const ledgers = await options.ledger.listLedgers((key, error) => {
|
|
89
|
-
reportError(
|
|
90
|
-
new Error(
|
|
91
|
-
`janitor scan: skipping unparseable ledger record at ${key}: ${String(
|
|
92
|
-
error instanceof Error ? error.message : error
|
|
93
|
-
)}`
|
|
94
|
-
)
|
|
95
|
-
);
|
|
96
|
-
});
|
|
97
|
-
const claimed: JanitorClaimedSession[] = [];
|
|
98
|
-
for (const snapshot of ledgers) {
|
|
99
|
-
if (snapshot.pending.length === 0) {
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (snapshot.lease !== null && snapshot.lease.expiresAt > clock()) {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
let claim: ClaimResult;
|
|
106
|
-
try {
|
|
107
|
-
claim = await options.ledger.claim(snapshot.sessionId);
|
|
108
|
-
} catch (error) {
|
|
109
|
-
reportError(error, snapshot.sessionId);
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (!claim.claimed) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const session: JanitorClaimedSession = {
|
|
116
|
-
sessionId: snapshot.sessionId,
|
|
117
|
-
lease: claim.lease,
|
|
118
|
-
head: claim.head,
|
|
119
|
-
pending: claim.pending,
|
|
120
|
-
};
|
|
121
|
-
claimed.push(session);
|
|
122
|
-
try {
|
|
123
|
-
await options.onSession(session);
|
|
124
|
-
} catch (error) {
|
|
125
|
-
reportError(error, snapshot.sessionId);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
let orphansDeleted: string[] = [];
|
|
130
|
-
if (options.orphanSweep !== undefined) {
|
|
131
|
-
try {
|
|
132
|
-
const swept = await options.ledger.sweepOrphans({
|
|
133
|
-
olderThanMs: options.orphanSweep.olderThanMs,
|
|
134
|
-
});
|
|
135
|
-
orphansDeleted = swept.deleted;
|
|
136
|
-
} catch (error) {
|
|
137
|
-
reportError(error);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return { scanned: ledgers.length, claimed, orphansDeleted };
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const runOnce = (): Promise<JanitorRunResult> => {
|
|
144
|
-
const pass = runPass();
|
|
145
|
-
const settled = pass.then(
|
|
146
|
-
() => undefined,
|
|
147
|
-
() => undefined
|
|
148
|
-
);
|
|
149
|
-
inFlight = settled;
|
|
150
|
-
void settled.finally(() => {
|
|
151
|
-
if (inFlight === settled) {
|
|
152
|
-
inFlight = undefined;
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
return pass;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const tick = async (): Promise<void> => {
|
|
159
|
-
// Skip a tick rather than overlap passes when a scan outlasts the
|
|
160
|
-
// cadence — overlapping claims would just fence each other.
|
|
161
|
-
if (running) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
running = true;
|
|
165
|
-
try {
|
|
166
|
-
await runOnce();
|
|
167
|
-
} catch (error) {
|
|
168
|
-
reportError(error);
|
|
169
|
-
} finally {
|
|
170
|
-
running = false;
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
start(): void {
|
|
176
|
-
if (timer !== undefined) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
timer = setInterval(() => {
|
|
180
|
-
void tick();
|
|
181
|
-
}, intervalMs);
|
|
182
|
-
timer.unref?.();
|
|
183
|
-
},
|
|
184
|
-
async stop(): Promise<void> {
|
|
185
|
-
if (timer !== undefined) {
|
|
186
|
-
clearInterval(timer);
|
|
187
|
-
timer = undefined;
|
|
188
|
-
}
|
|
189
|
-
await inFlight;
|
|
190
|
-
},
|
|
191
|
-
runOnce,
|
|
192
|
-
};
|
|
193
|
-
}
|