@cursor/july 0.1.5 → 0.1.7
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/ab.d.ts +8 -95
- package/dist/ab.d.ts.map +1 -1
- package/dist/ab.js +9 -150
- package/dist/bin/agent-serve.js +41 -8
- package/dist/channels/slack/post-update-delivery.d.ts +85 -0
- package/dist/channels/slack/post-update-delivery.d.ts.map +1 -0
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +4 -4
- package/dist/docs/assets/{app.DabPG-io.js → app.COTN7wgo.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.B7UcKvIn.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.jmyr0bU0.js → VPLocalSearchBox.BW3TBdT0.js} +1 -1
- package/dist/docs/assets/chunks/{theme.DysN9-VN.js → theme.BEJW0vE7.js} +2 -2
- package/dist/docs/assets/deployment.md.BtfEsc9S.js +55 -0
- package/dist/docs/assets/deployment.md.BtfEsc9S.lean.js +1 -0
- package/dist/docs/assets/example-agents_approval-buddy.md.8R5phXb5.js +10 -0
- package/dist/docs/assets/example-agents_approval-buddy.md.8R5phXb5.lean.js +1 -0
- package/dist/docs/assets/example-agents_benny.md.B0gjhI-p.js +7 -0
- package/dist/docs/assets/example-agents_benny.md.B0gjhI-p.lean.js +1 -0
- package/dist/docs/assets/example-agents_bugbot.md.DelIdhxB.js +11 -0
- package/dist/docs/assets/example-agents_bugbot.md.DelIdhxB.lean.js +1 -0
- package/dist/docs/assets/example-agents_codebase-wiki.md.DC6sgwn0.js +8 -0
- package/dist/docs/assets/example-agents_codebase-wiki.md.DC6sgwn0.lean.js +1 -0
- package/dist/docs/assets/example-agents_codeowners-review.md.Ku_tG2RY.js +8 -0
- package/dist/docs/assets/example-agents_codeowners-review.md.Ku_tG2RY.lean.js +1 -0
- package/dist/docs/assets/example-agents_concierge.md.4rQTSMXt.js +23 -0
- package/dist/docs/assets/example-agents_concierge.md.4rQTSMXt.lean.js +1 -0
- package/dist/docs/assets/example-agents_fsd.md.CzgUrDfi.js +15 -0
- package/dist/docs/assets/example-agents_fsd.md.CzgUrDfi.lean.js +1 -0
- package/dist/docs/assets/example-agents_index.md.CRqJlnIf.js +2 -0
- package/dist/docs/assets/example-agents_index.md.CRqJlnIf.lean.js +1 -0
- package/dist/docs/assets/example-agents_knowledge-base.md.BPJiVueF.js +11 -0
- package/dist/docs/assets/example-agents_knowledge-base.md.BPJiVueF.lean.js +1 -0
- package/dist/docs/assets/example-agents_security-reviewer.md.D2rtwDTO.js +19 -0
- package/dist/docs/assets/example-agents_security-reviewer.md.D2rtwDTO.lean.js +1 -0
- package/dist/docs/assets/example-agents_slack-agent.md.buLbgvBf.js +5 -0
- package/dist/docs/assets/example-agents_slack-agent.md.buLbgvBf.lean.js +1 -0
- package/dist/docs/assets/example-agents_weather-agent.md.C9Qv-W0o.js +24 -0
- package/dist/docs/assets/example-agents_weather-agent.md.C9Qv-W0o.lean.js +1 -0
- package/dist/docs/assets/index.md.COiu-1jL.js +20 -0
- package/dist/docs/assets/{index.md.Cylk70gg.lean.js → index.md.COiu-1jL.lean.js} +1 -1
- package/dist/docs/assets/reference_cli.md.D189RBCH.js +60 -0
- package/dist/docs/assets/reference_cli.md.D189RBCH.lean.js +1 -0
- package/dist/docs/building-with-agents.html +4 -4
- package/dist/docs/concepts.html +4 -4
- package/dist/docs/deployment.html +58 -17
- package/dist/docs/evals.html +4 -4
- package/dist/docs/example-agents/approval-buddy.html +34 -0
- package/dist/docs/example-agents/benny.html +31 -0
- package/dist/docs/example-agents/bugbot.html +35 -0
- package/dist/docs/example-agents/codebase-wiki.html +32 -0
- package/dist/docs/example-agents/codeowners-review.html +32 -0
- package/dist/docs/example-agents/concierge.html +47 -0
- package/dist/docs/example-agents/fsd.html +39 -0
- package/dist/docs/example-agents/index.html +26 -0
- package/dist/docs/example-agents/knowledge-base.html +35 -0
- package/dist/docs/example-agents/security-reviewer.html +43 -0
- package/dist/docs/example-agents/slack-agent.html +29 -0
- package/dist/docs/example-agents/weather-agent.html +48 -0
- package/dist/docs/guides/agent-to-agent.html +4 -4
- package/dist/docs/guides/cloud-runtime.html +5 -5
- package/dist/docs/guides/github.html +4 -4
- package/dist/docs/guides/human-in-the-loop.html +4 -4
- package/dist/docs/guides/slack.html +4 -4
- package/dist/docs/guides/webhooks.html +4 -4
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +4 -4
- package/dist/docs/index.html +7 -7
- package/dist/docs/quickstart.html +4 -4
- package/dist/docs/reference/agent-config.html +4 -4
- package/dist/docs/reference/channels.html +4 -4
- package/dist/docs/reference/cli.html +52 -30
- package/dist/docs/reference/connections.html +4 -4
- package/dist/docs/reference/hooks.html +4 -4
- package/dist/docs/reference/http-api.html +4 -4
- package/dist/docs/reference/instructions.html +4 -4
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +4 -4
- package/dist/docs/reference/schedules.html +4 -4
- package/dist/docs/reference/sessions.html +4 -4
- package/dist/docs/reference/skills.html +4 -4
- package/dist/docs/reference/subagents.html +4 -4
- package/dist/docs/reference/tools.html +4 -4
- package/dist/docs/scaffolding-agents.html +4 -4
- package/dist/docs/storage.html +4 -4
- package/dist/docs/troubleshooting.html +4 -4
- package/dist/evals.d.ts +5 -62
- package/dist/evals.d.ts.map +1 -1
- package/dist/evals.js +3 -66
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/ab-collector.d.ts +7 -5
- package/dist/internal/ab-collector.d.ts.map +1 -1
- package/dist/internal/ab-collector.js +3 -14
- package/dist/internal/ab-snapshot.d.ts +2 -4
- package/dist/internal/ab-snapshot.d.ts.map +1 -1
- package/dist/internal/cli-ax.d.ts +33 -5
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +428 -87
- package/dist/internal/cli-deploy.js +1 -1
- package/dist/internal/discovery.js +3 -3
- package/dist/internal/eval-run-store.d.ts +35 -30
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +88 -100
- package/dist/internal/evals-client.d.ts +96 -0
- package/dist/internal/evals-client.d.ts.map +1 -0
- package/dist/internal/evals-client.js +262 -0
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +1 -0
- package/dist/internal/persistence-coordinator.d.ts +127 -0
- package/dist/internal/persistence-coordinator.d.ts.map +1 -0
- package/dist/internal/playground-proxy.d.ts +5 -5
- package/dist/internal/playground-proxy.js +3 -3
- package/dist/internal/resolve-prod-target.d.ts +30 -0
- package/dist/internal/resolve-prod-target.d.ts.map +1 -1
- package/dist/internal/resolve-prod-target.js +74 -2
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +16 -5
- package/dist/internal/session-engine.d.ts +1 -2
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +14 -31
- package/dist/internal/storage-coordinator.d.ts +16 -15
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +73 -80
- package/dist/persistence.d.ts +184 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/playground/assets/cursor-icons-16-CQ50JpfO.woff2 +0 -0
- package/dist/playground/assets/index-72vCOBWO.js +86 -0
- package/dist/playground/assets/index-BjnMwYoR.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage.d.ts +51 -10
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +27 -10
- package/docs/README.md +34 -5
- package/docs/deployment.md +352 -149
- package/docs/example-agents/approval-buddy.md +270 -0
- package/docs/example-agents/benny.md +186 -0
- package/docs/example-agents/bugbot.md +231 -0
- package/docs/example-agents/codebase-wiki.md +174 -0
- package/docs/example-agents/codeowners-review.md +195 -0
- package/docs/example-agents/concierge.md +205 -0
- package/docs/example-agents/fsd.md +330 -0
- package/docs/example-agents/index.md +102 -0
- package/docs/example-agents/knowledge-base.md +171 -0
- package/docs/example-agents/security-reviewer.md +296 -0
- package/docs/example-agents/slack-agent.md +146 -0
- package/docs/example-agents/weather-agent.md +302 -0
- package/docs/reference/cli.md +546 -147
- package/package.json +1 -1
- package/src/ab.ts +9 -261
- package/src/bin/agent-serve.ts +46 -7
- package/src/evals.ts +5 -119
- package/src/index.ts +2 -0
- package/src/internal/ab-collector.ts +12 -22
- package/src/internal/ab-snapshot.ts +2 -4
- package/src/internal/cli-ax.ts +551 -104
- package/src/internal/cli-deploy.ts +1 -1
- package/src/internal/discovery.ts +2 -2
- package/src/internal/eval-run-store.ts +91 -100
- package/src/internal/evals-client.ts +431 -0
- package/src/internal/init-project.ts +1 -0
- package/src/internal/playground-proxy.ts +5 -5
- package/src/internal/resolve-prod-target.ts +101 -3
- package/src/internal/server.ts +17 -3
- package/src/internal/session-engine.ts +9 -29
- package/src/internal/storage-coordinator.ts +109 -101
- package/src/storage.ts +79 -14
- package/dist/docs/assets/chunks/@localSearchIndexroot.QwK5BtEH.js +0 -1
- package/dist/docs/assets/deployment.md.DTKwE15Z.js +0 -14
- package/dist/docs/assets/deployment.md.DTKwE15Z.lean.js +0 -1
- package/dist/docs/assets/index.md.Cylk70gg.js +0 -20
- package/dist/docs/assets/reference_cli.md.Bv6pOxcF.js +0 -38
- package/dist/docs/assets/reference_cli.md.Bv6pOxcF.lean.js +0 -1
- package/dist/internal/json-dir-store.js +0 -100
- package/dist/playground/assets/cursor-icons-outline-BxTT_FVJ.woff2 +0 -0
- package/dist/playground/assets/index-BEauYlII.css +0 -1
- package/dist/playground/assets/index-BtM0wEGg.js +0 -319
- package/src/internal/json-dir-store.ts +0 -109
package/dist/internal/server.js
CHANGED
|
@@ -223,9 +223,8 @@ export function startServer(mounts_1) {
|
|
|
223
223
|
const scheduleRunner = new ScheduleRunner(engine, project, logger);
|
|
224
224
|
const reminderRunner = new ReminderRunner(engine, logger);
|
|
225
225
|
const evalRuns = new EvalRunStore(project.rootDir, logger,
|
|
226
|
-
//
|
|
227
|
-
|
|
228
|
-
(_b = engine.storage) === null || _b === void 0 ? void 0 : _b.asEvalRunPersistence());
|
|
226
|
+
// Playground eval history mirrors onto the defineStorage evals table.
|
|
227
|
+
(_b = engine.storage) === null || _b === void 0 ? void 0 : _b.evalRuns());
|
|
229
228
|
// Eval history restores with the same startup step as sessions (reads
|
|
230
229
|
// also hydrate lazily, but doing it here surfaces store problems at
|
|
231
230
|
// boot and makes /v1/dev/evals complete from the first request).
|
|
@@ -561,6 +560,9 @@ export function startServer(mounts_1) {
|
|
|
561
560
|
for (const runtime of runtimes) {
|
|
562
561
|
runtime.scheduleRunner.stop();
|
|
563
562
|
runtime.reminderRunner.stop();
|
|
563
|
+
// Before the engines close their storage coordinators, so the
|
|
564
|
+
// interrupted-batch write can still reach the sink.
|
|
565
|
+
runtime.evalRuns.close();
|
|
564
566
|
}
|
|
565
567
|
for (const stop of channelStopHooks) {
|
|
566
568
|
try {
|
|
@@ -844,14 +846,16 @@ function mountAgentRoutes(router, runtime, args) {
|
|
|
844
846
|
const body = yield readJsonObject(request);
|
|
845
847
|
const filterIds = asStringArray(body === null || body === void 0 ? void 0 : body.filterIds);
|
|
846
848
|
const tags = asStringArray(body === null || body === void 0 ? void 0 : body.tags);
|
|
849
|
+
const timeoutMs = asPositiveInt(body === null || body === void 0 ? void 0 : body.timeoutMs);
|
|
850
|
+
const verbose = (body === null || body === void 0 ? void 0 : body.verbose) === true;
|
|
847
851
|
const authHeader = request.headers.get("authorization");
|
|
848
852
|
const bearerToken = (authHeader === null || authHeader === void 0 ? void 0 : authHeader.toLowerCase().startsWith("bearer "))
|
|
849
853
|
? authHeader.slice("bearer ".length).trim()
|
|
850
854
|
: undefined;
|
|
851
855
|
try {
|
|
852
|
-
const snap = yield runtime.evalRuns.start(Object.assign(Object.assign(Object.assign({}, (filterIds === undefined ? {} : { filterIds })), (tags === undefined ? {} : { tags })), (bearerToken === undefined || bearerToken === ""
|
|
856
|
+
const snap = yield runtime.evalRuns.start(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (filterIds === undefined ? {} : { filterIds })), (tags === undefined ? {} : { tags })), (bearerToken === undefined || bearerToken === ""
|
|
853
857
|
? {}
|
|
854
|
-
: { bearerToken })));
|
|
858
|
+
: { bearerToken })), (timeoutMs === undefined ? {} : { timeoutMs })), (verbose ? { verbose: true } : {})));
|
|
855
859
|
return jsonResponse(snap, { status: 202 });
|
|
856
860
|
}
|
|
857
861
|
catch (error) {
|
|
@@ -1486,6 +1490,13 @@ function asStringArray(value) {
|
|
|
1486
1490
|
}
|
|
1487
1491
|
return out.length === 0 ? undefined : out;
|
|
1488
1492
|
}
|
|
1493
|
+
function asPositiveInt(value) {
|
|
1494
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1495
|
+
return undefined;
|
|
1496
|
+
}
|
|
1497
|
+
const n = Math.floor(value);
|
|
1498
|
+
return n > 0 ? n : undefined;
|
|
1499
|
+
}
|
|
1489
1500
|
function assertReminderReadable(input) {
|
|
1490
1501
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1491
1502
|
const existing = yield input.engine.sessions.findByContinuation(input.reminder.channelId, input.reminder.continuationToken);
|
|
@@ -87,8 +87,7 @@ export declare class SessionEngine {
|
|
|
87
87
|
* Runtime for `agent/storage.ts` (`defineStorage`), when
|
|
88
88
|
* authored. All durable state changes funnel through it (session
|
|
89
89
|
* records, event chunks, A/B samples/snapshots); the eval run store
|
|
90
|
-
* attaches via {@link StorageCoordinator.
|
|
91
|
-
* serve start.
|
|
90
|
+
* attaches via {@link StorageCoordinator.evalRuns} at serve start.
|
|
92
91
|
*/
|
|
93
92
|
readonly storage: StorageCoordinator | undefined;
|
|
94
93
|
/** In-flight lazy restores, deduped per channel + continuation key. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-engine.d.ts","sourceRoot":"","sources":["../../src/internal/session-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBA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AAO,CAAC,IAAI,CAAC,CAoCzE;IAED,kEAAkE;IAC5D,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,SAAI,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAG3E;IAEK,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GAAG,IAAI,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf;IAED,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAIxC;IAED,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,WAAW,CAc9C;IAED,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,gBAAgB;IAwBxB,OAAO,CAAC,mBAAmB;IAc3B,sEAAsE;IACtE,OAAO,CAAC,YAAY;IA6BpB;;;;;;;;;;;OAWG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAc3C;YAEa,cAAc;IA4F5B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,4BAA4B;YAqBtB,gCAAgC;IAyB9C;;;;;OAKG;YACW,kBAAkB;IAYhC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAO/C;IAED,yEAAyE;IACnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3B;CACF"}
|
|
@@ -110,7 +110,6 @@ export class ApprovalInterruptedError extends Error {
|
|
|
110
110
|
export class SessionEngine {
|
|
111
111
|
constructor(options) {
|
|
112
112
|
var _a, _b;
|
|
113
|
-
var _c, _d, _e;
|
|
114
113
|
/** In-flight lazy restores, deduped per channel + continuation key. */
|
|
115
114
|
this.restoreInFlight = new Map();
|
|
116
115
|
this.channelsById = new Map();
|
|
@@ -131,7 +130,7 @@ export class SessionEngine {
|
|
|
131
130
|
this.project = options.project;
|
|
132
131
|
this.stateRoot = options.stateRoot;
|
|
133
132
|
this.runner = options.runner;
|
|
134
|
-
this.logger = (
|
|
133
|
+
this.logger = (_a = options.logger) !== null && _a !== void 0 ? _a : (() => { });
|
|
135
134
|
this.sessions = new SessionStore(join(options.stateRoot, "sessions"));
|
|
136
135
|
this.logs = new EventLogStore((sessionId) => this.sessions.eventFilePath(sessionId), (sessionId, error) => this.logger(`[agentkit] failed to persist events for ${sessionId}: ${describeError(error)}`));
|
|
137
136
|
this.storage =
|
|
@@ -143,17 +142,14 @@ export class SessionEngine {
|
|
|
143
142
|
projectRoot: options.project.rootDir,
|
|
144
143
|
logger: this.logger,
|
|
145
144
|
});
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
projectRoot: options.project.rootDir,
|
|
150
|
-
persistSamples,
|
|
151
|
-
});
|
|
145
|
+
this.abCollector = new ABCollector(options.project.abs, this.logger, (sessionId) => __awaiter(this, void 0, void 0, function* () { return (yield this.logs.get(sessionId)).snapshot(0); }),
|
|
146
|
+
// Samples flow to the defineStorage `abs` table (no-op without one).
|
|
147
|
+
{ persistSample: (sample) => { var _a; return (_a = this.storage) === null || _a === void 0 ? void 0 : _a.abSample(sample); } });
|
|
152
148
|
// Peer and Cursor-account transports are symbolic until the serve host
|
|
153
149
|
// resolves them; the host-side MCP registry starts with the concrete
|
|
154
150
|
// connections and gains the rest via setResolvedConnections.
|
|
155
151
|
this.mcpHost = new McpHost(options.project.agent.connections.filter((connection) => !isSymbolicConnectionTransport(connection.transport)));
|
|
156
|
-
this.platforms = (
|
|
152
|
+
this.platforms = (_b = options.platforms) !== null && _b !== void 0 ? _b : createHostPlatforms();
|
|
157
153
|
for (const channel of options.project.channels) {
|
|
158
154
|
this.channelsById.set(channel.id, channel.definition);
|
|
159
155
|
}
|
|
@@ -1175,8 +1171,8 @@ export class SessionEngine {
|
|
|
1175
1171
|
*/
|
|
1176
1172
|
abSnapshot(caller, options) {
|
|
1177
1173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1178
|
-
var _a;
|
|
1179
|
-
var
|
|
1174
|
+
var _a, _b;
|
|
1175
|
+
var _c;
|
|
1180
1176
|
const sessions = yield this.listSessions(caller, options);
|
|
1181
1177
|
const abConfig = this.project.abConfig;
|
|
1182
1178
|
const maxPlaygroundSessions = resolveABMaxPlaygroundSessions(abConfig === null || abConfig === void 0 ? void 0 : abConfig.maxPlaygroundSessions);
|
|
@@ -1192,12 +1188,13 @@ export class SessionEngine {
|
|
|
1192
1188
|
if (foldedSessions.length === 0 &&
|
|
1193
1189
|
this.storage !== undefined &&
|
|
1194
1190
|
(yield this.sessions.list()).length === 0) {
|
|
1195
|
-
(
|
|
1191
|
+
(_c = this.restoredAbSnapshot) !== null && _c !== void 0 ? _c : (this.restoredAbSnapshot = this.storage.getLatestAbSnapshot());
|
|
1196
1192
|
const restoredSnapshot = yield this.restoredAbSnapshot;
|
|
1197
1193
|
if (restoredSnapshot !== undefined) {
|
|
1198
1194
|
return restoredSnapshot;
|
|
1199
1195
|
}
|
|
1200
1196
|
}
|
|
1197
|
+
const abTable = (_a = this.project.storage) === null || _a === void 0 ? void 0 : _a.abs;
|
|
1201
1198
|
const snapshot = yield buildABSnapshot({
|
|
1202
1199
|
experiments: this.project.abs,
|
|
1203
1200
|
agentName: this.project.name,
|
|
@@ -1208,27 +1205,13 @@ export class SessionEngine {
|
|
|
1208
1205
|
logger: this.logger,
|
|
1209
1206
|
config: {
|
|
1210
1207
|
maxPlaygroundSessions,
|
|
1211
|
-
durableSamples:
|
|
1212
|
-
durableSnapshots: (
|
|
1208
|
+
durableSamples: abTable !== undefined,
|
|
1209
|
+
durableSnapshots: (abTable === null || abTable === void 0 ? void 0 : abTable.putSnapshot) !== undefined,
|
|
1213
1210
|
},
|
|
1214
1211
|
});
|
|
1215
|
-
// Side effect on the read path: playground polls GET /v1/abs ~every 4s
|
|
1216
|
-
//
|
|
1217
|
-
|
|
1218
|
-
if (persistSnapshots !== undefined) {
|
|
1219
|
-
try {
|
|
1220
|
-
yield persistSnapshots.save(snapshot, {
|
|
1221
|
-
projectRoot: this.project.rootDir,
|
|
1222
|
-
});
|
|
1223
|
-
}
|
|
1224
|
-
catch (error) {
|
|
1225
|
-
this.logger(`[agentkit] ab persistSnapshots.save threw: ${describeError(error)}`);
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
else {
|
|
1229
|
-
// defineStorage fallback (throttled inside the coordinator).
|
|
1230
|
-
(_a = this.storage) === null || _a === void 0 ? void 0 : _a.abSnapshot(snapshot);
|
|
1231
|
-
}
|
|
1212
|
+
// Side effect on the read path: playground polls GET /v1/abs ~every 4s;
|
|
1213
|
+
// the coordinator throttles the actual table write.
|
|
1214
|
+
(_b = this.storage) === null || _b === void 0 ? void 0 : _b.abSnapshot(snapshot);
|
|
1232
1215
|
return snapshot;
|
|
1233
1216
|
});
|
|
1234
1217
|
}
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
* failures — a throwing sink is logged and its write dropped; storage
|
|
11
11
|
* must never stall or fail a turn.
|
|
12
12
|
*
|
|
13
|
-
* Scaling shape: sessions
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Scaling shape: sessions and reminders reduce to keyed puts on the KV
|
|
14
|
+
* sink; eval runs and A/B metrics go to their dedicated tables
|
|
15
|
+
* (`evals` / `abs`). Everything shares one bounded, serialized queue.
|
|
16
16
|
*/
|
|
17
|
-
import type {
|
|
18
|
-
import type { EvalRunPersistence } from "../evals.js";
|
|
17
|
+
import type { ABMetricSample } from "../ab.js";
|
|
19
18
|
import { type ResolvedStoragePolicy, type StorageContext, type StorageDefinition } from "../storage.js";
|
|
20
19
|
import type { SessionEvent, SessionRecord } from "../types.js";
|
|
21
20
|
import type { ABSnapshot } from "./ab-snapshot.js";
|
|
21
|
+
import type { EvalRunStorage } from "./eval-run-store.js";
|
|
22
22
|
import { type ReminderRecord } from "./reminder-store.js";
|
|
23
23
|
export interface StorageCoordinatorOptions {
|
|
24
24
|
definition: StorageDefinition;
|
|
@@ -67,6 +67,10 @@ export declare class StorageCoordinator {
|
|
|
67
67
|
* put the current token, delete the previous one when it changed.
|
|
68
68
|
*/
|
|
69
69
|
private continuationOps;
|
|
70
|
+
/** KV upsert op on the sink's `put`. */
|
|
71
|
+
private putOp;
|
|
72
|
+
/** KV delete op on the sink's `delete` (skipped when the hook is absent). */
|
|
73
|
+
private deleteOp;
|
|
70
74
|
/** Whether the sink can serve the startup bulk restore (`list`). */
|
|
71
75
|
get canBulkRestore(): boolean;
|
|
72
76
|
/**
|
|
@@ -103,20 +107,17 @@ export declare class StorageCoordinator {
|
|
|
103
107
|
*/
|
|
104
108
|
listReminders(): Promise<ReminderRecord[]>;
|
|
105
109
|
/**
|
|
106
|
-
* Adapter
|
|
107
|
-
*
|
|
108
|
-
*
|
|
110
|
+
* Adapter over the sink's dedicated `evals` table for the playground
|
|
111
|
+
* eval-run store. Undefined when the table is not configured — eval
|
|
112
|
+
* history then stays in process memory.
|
|
109
113
|
*/
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
* back to this sink when `ab.config.ts` sets no `persistSamples`.
|
|
114
|
-
*/
|
|
115
|
-
asABSamplePersistence(): ABSamplePersistence;
|
|
114
|
+
evalRuns(): EvalRunStorage | undefined;
|
|
115
|
+
/** Append one metric sample to the `abs` table (no-op without it). */
|
|
116
|
+
abSample(sample: ABMetricSample): void;
|
|
116
117
|
/**
|
|
117
118
|
* Refresh the persisted aggregate A/B snapshot, throttled to once per
|
|
118
119
|
* {@link AB_SNAPSHOT_MIN_INTERVAL_MS} (the playground recomputes the
|
|
119
|
-
* fold on every `GET /v1/abs` poll).
|
|
120
|
+
* fold on every `GET /v1/abs` poll). No-op without `abs.putSnapshot`.
|
|
120
121
|
*/
|
|
121
122
|
abSnapshot(snapshot: ABSnapshot): void;
|
|
122
123
|
/** Latest persisted aggregate A/B snapshot; errors read as absent. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-coordinator.d.ts","sourceRoot":"","sources":["../../src/internal/storage-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OA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ChE,mBAAmB,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAc3D;IAMD;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAqB3B;IAED,wEAAwE;IACxE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAExB;IAED,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,WAAW;IAgBnB,2EAA2E;YAC7D,OAAO;IAkBrB,OAAO,CAAC,OAAO;IA8Bf,OAAO,CAAC,OAAO;CAGhB"}
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* failures — a throwing sink is logged and its write dropped; storage
|
|
11
11
|
* must never stall or fail a turn.
|
|
12
12
|
*
|
|
13
|
-
* Scaling shape: sessions
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Scaling shape: sessions and reminders reduce to keyed puts on the KV
|
|
14
|
+
* sink; eval runs and A/B metrics go to their dedicated tables
|
|
15
|
+
* (`evals` / `abs`). Everything shares one bounded, serialized queue.
|
|
16
16
|
*/
|
|
17
17
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -139,18 +139,10 @@ export class StorageCoordinator {
|
|
|
139
139
|
const ops = [];
|
|
140
140
|
const first = buffer.events[0];
|
|
141
141
|
if (first !== undefined) {
|
|
142
|
-
ops.push(
|
|
143
|
-
op: "put",
|
|
144
|
-
key: storageKeys.sessionEvents(this.agentName, sessionId, first.index),
|
|
145
|
-
value: buffer.events,
|
|
146
|
-
});
|
|
142
|
+
ops.push(this.putOp(storageKeys.sessionEvents(this.agentName, sessionId, first.index), buffer.events));
|
|
147
143
|
}
|
|
148
144
|
if (buffer.record !== undefined) {
|
|
149
|
-
ops.push(
|
|
150
|
-
op: "put",
|
|
151
|
-
key: storageKeys.session(this.agentName, sessionId),
|
|
152
|
-
value: buffer.record,
|
|
153
|
-
});
|
|
145
|
+
ops.push(this.putOp(storageKeys.session(this.agentName, sessionId), buffer.record));
|
|
154
146
|
ops.push(...this.continuationOps(buffer.record));
|
|
155
147
|
}
|
|
156
148
|
if (ops.length > 0) {
|
|
@@ -170,20 +162,27 @@ export class StorageCoordinator {
|
|
|
170
162
|
this.continuationIndex.set(record.sessionId, next);
|
|
171
163
|
const ops = [];
|
|
172
164
|
if (previous != null) {
|
|
173
|
-
ops.push(
|
|
174
|
-
op: "delete",
|
|
175
|
-
key: storageKeys.continuation(this.agentName, record.channelId, previous),
|
|
176
|
-
});
|
|
165
|
+
ops.push(this.deleteOp(storageKeys.continuation(this.agentName, record.channelId, previous)));
|
|
177
166
|
}
|
|
178
167
|
if (next != null) {
|
|
179
|
-
ops.push({
|
|
180
|
-
op: "put",
|
|
181
|
-
key: storageKeys.continuation(this.agentName, record.channelId, next),
|
|
182
|
-
value: { sessionId: record.sessionId },
|
|
183
|
-
});
|
|
168
|
+
ops.push(this.putOp(storageKeys.continuation(this.agentName, record.channelId, next), { sessionId: record.sessionId }));
|
|
184
169
|
}
|
|
185
170
|
return ops;
|
|
186
171
|
}
|
|
172
|
+
/** KV upsert op on the sink's `put`. */
|
|
173
|
+
putOp(key, value) {
|
|
174
|
+
return {
|
|
175
|
+
label: `put(${key})`,
|
|
176
|
+
run: (ctx) => this.definition.put(key, value, ctx),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/** KV delete op on the sink's `delete` (skipped when the hook is absent). */
|
|
180
|
+
deleteOp(key) {
|
|
181
|
+
return {
|
|
182
|
+
label: `delete(${key})`,
|
|
183
|
+
run: (ctx) => { var _a, _b; return (_b = (_a = this.definition).delete) === null || _b === void 0 ? void 0 : _b.call(_a, key, ctx); },
|
|
184
|
+
};
|
|
185
|
+
}
|
|
187
186
|
// ==========================================================================
|
|
188
187
|
// Sessions (reads / restore)
|
|
189
188
|
// ==========================================================================
|
|
@@ -279,11 +278,7 @@ export class StorageCoordinator {
|
|
|
279
278
|
return;
|
|
280
279
|
}
|
|
281
280
|
this.enqueue([
|
|
282
|
-
|
|
283
|
-
op: "put",
|
|
284
|
-
key: storageKeys.reminder(this.agentName, record.id),
|
|
285
|
-
value: record,
|
|
286
|
-
},
|
|
281
|
+
this.putOp(storageKeys.reminder(this.agentName, record.id), record),
|
|
287
282
|
], "policy");
|
|
288
283
|
}
|
|
289
284
|
/**
|
|
@@ -297,93 +292,97 @@ export class StorageCoordinator {
|
|
|
297
292
|
});
|
|
298
293
|
}
|
|
299
294
|
// ==========================================================================
|
|
300
|
-
// Evals
|
|
295
|
+
// Evals (dedicated `evals` table)
|
|
301
296
|
// ==========================================================================
|
|
302
297
|
/**
|
|
303
|
-
* Adapter
|
|
304
|
-
*
|
|
305
|
-
*
|
|
298
|
+
* Adapter over the sink's dedicated `evals` table for the playground
|
|
299
|
+
* eval-run store. Undefined when the table is not configured — eval
|
|
300
|
+
* history then stays in process memory.
|
|
306
301
|
*/
|
|
307
|
-
|
|
302
|
+
evalRuns() {
|
|
303
|
+
const table = this.definition.evals;
|
|
304
|
+
if (table === undefined) {
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
308
307
|
return {
|
|
309
|
-
load: () => __awaiter(this, void 0, void 0, function* () {
|
|
310
|
-
const entries = yield this.tryList(storageKeys.evalRunPrefix(this.agentName));
|
|
311
|
-
return entries
|
|
312
|
-
.map((entry) => entry.value)
|
|
313
|
-
.filter((run) => run != null);
|
|
314
|
-
}),
|
|
315
308
|
save: (run) => {
|
|
309
|
+
// Clone at enqueue time: the store mutates snapshots in place as
|
|
310
|
+
// cases finish, and delivery is async.
|
|
311
|
+
const snapshot = structuredClone(run);
|
|
316
312
|
this.enqueue([
|
|
317
313
|
{
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
value: run,
|
|
314
|
+
label: `evals.put(${run.runId})`,
|
|
315
|
+
run: (ctx) => table.put(snapshot, ctx),
|
|
321
316
|
},
|
|
322
317
|
], "policy");
|
|
323
318
|
},
|
|
324
319
|
delete: (runId) => {
|
|
325
320
|
this.enqueue([
|
|
326
321
|
{
|
|
327
|
-
|
|
328
|
-
|
|
322
|
+
label: `evals.delete(${runId})`,
|
|
323
|
+
run: (ctx) => table.delete(runId, ctx),
|
|
329
324
|
},
|
|
330
325
|
], "policy");
|
|
331
326
|
},
|
|
327
|
+
list: () => __awaiter(this, void 0, void 0, function* () {
|
|
328
|
+
try {
|
|
329
|
+
const runs = yield table.list(this.context("restore"));
|
|
330
|
+
return Array.isArray(runs) ? runs : [];
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
this.logger(`[agentkit] storage evals.list() failed: ${describeError(error)}`);
|
|
334
|
+
return [];
|
|
335
|
+
}
|
|
336
|
+
}),
|
|
332
337
|
};
|
|
333
338
|
}
|
|
334
339
|
// ==========================================================================
|
|
335
|
-
// A/Bs
|
|
340
|
+
// A/Bs (dedicated `abs` table)
|
|
336
341
|
// ==========================================================================
|
|
337
|
-
/**
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
key: storageKeys.abSample(this.agentName, sample.sessionId, sample.at),
|
|
348
|
-
value: sample,
|
|
349
|
-
},
|
|
350
|
-
], "policy");
|
|
342
|
+
/** Append one metric sample to the `abs` table (no-op without it). */
|
|
343
|
+
abSample(sample) {
|
|
344
|
+
const table = this.definition.abs;
|
|
345
|
+
if (this.closed || table === undefined) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
this.enqueue([
|
|
349
|
+
{
|
|
350
|
+
label: `abs.putSample(${sample.sessionId})`,
|
|
351
|
+
run: (ctx) => table.putSample(sample, ctx),
|
|
351
352
|
},
|
|
352
|
-
|
|
353
|
+
], "policy");
|
|
353
354
|
}
|
|
354
355
|
/**
|
|
355
356
|
* Refresh the persisted aggregate A/B snapshot, throttled to once per
|
|
356
357
|
* {@link AB_SNAPSHOT_MIN_INTERVAL_MS} (the playground recomputes the
|
|
357
|
-
* fold on every `GET /v1/abs` poll).
|
|
358
|
+
* fold on every `GET /v1/abs` poll). No-op without `abs.putSnapshot`.
|
|
358
359
|
*/
|
|
359
360
|
abSnapshot(snapshot) {
|
|
361
|
+
var _a;
|
|
362
|
+
const putSnapshot = (_a = this.definition.abs) === null || _a === void 0 ? void 0 : _a.putSnapshot;
|
|
360
363
|
const now = Date.now();
|
|
361
364
|
if (this.closed ||
|
|
365
|
+
putSnapshot === undefined ||
|
|
362
366
|
now - this.lastAbSnapshotAt < AB_SNAPSHOT_MIN_INTERVAL_MS) {
|
|
363
367
|
return;
|
|
364
368
|
}
|
|
365
369
|
this.lastAbSnapshotAt = now;
|
|
366
|
-
this.enqueue([
|
|
367
|
-
{
|
|
368
|
-
op: "put",
|
|
369
|
-
key: storageKeys.abSnapshot(this.agentName),
|
|
370
|
-
value: snapshot,
|
|
371
|
-
},
|
|
372
|
-
], "policy");
|
|
370
|
+
this.enqueue([{ label: "abs.putSnapshot", run: (ctx) => putSnapshot(snapshot, ctx) }], "policy");
|
|
373
371
|
}
|
|
374
372
|
/** Latest persisted aggregate A/B snapshot; errors read as absent. */
|
|
375
373
|
getLatestAbSnapshot() {
|
|
376
374
|
return __awaiter(this, void 0, void 0, function* () {
|
|
377
|
-
|
|
378
|
-
|
|
375
|
+
var _a;
|
|
376
|
+
const getSnapshot = (_a = this.definition.abs) === null || _a === void 0 ? void 0 : _a.getSnapshot;
|
|
377
|
+
if (getSnapshot === undefined) {
|
|
379
378
|
return undefined;
|
|
380
379
|
}
|
|
381
380
|
try {
|
|
382
|
-
const value = yield
|
|
383
|
-
return value
|
|
381
|
+
const value = yield getSnapshot(this.context("restore"));
|
|
382
|
+
return value !== null && value !== void 0 ? value : undefined;
|
|
384
383
|
}
|
|
385
384
|
catch (error) {
|
|
386
|
-
this.logger(`[agentkit] storage
|
|
385
|
+
this.logger(`[agentkit] storage abs.getSnapshot() failed: ${describeError(error)}`);
|
|
387
386
|
return undefined;
|
|
388
387
|
}
|
|
389
388
|
});
|
|
@@ -474,18 +473,12 @@ export class StorageCoordinator {
|
|
|
474
473
|
this.pending += ops.length;
|
|
475
474
|
const ctx = this.context(reason);
|
|
476
475
|
this.queue = this.queue.then(() => __awaiter(this, void 0, void 0, function* () {
|
|
477
|
-
var _a, _b;
|
|
478
476
|
for (const op of ops) {
|
|
479
477
|
try {
|
|
480
|
-
|
|
481
|
-
yield this.definition.put(op.key, op.value, ctx);
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
yield (_b = (_a = this.definition).delete) === null || _b === void 0 ? void 0 : _b.call(_a, op.key, ctx);
|
|
485
|
-
}
|
|
478
|
+
yield op.run(ctx);
|
|
486
479
|
}
|
|
487
480
|
catch (error) {
|
|
488
|
-
this.logger(`[agentkit] storage ${op.
|
|
481
|
+
this.logger(`[agentkit] storage ${op.label} failed: ${describeError(error)}`);
|
|
489
482
|
}
|
|
490
483
|
finally {
|
|
491
484
|
this.pending -= 1;
|