@cursor/july 0.1.5 → 0.1.6
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 +14 -6
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +4 -4
- package/dist/docs/assets/{app.DabPG-io.js → app.DMboGKUD.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.O6eP7QZr.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.jmyr0bU0.js → VPLocalSearchBox.DkEqEnJU.js} +1 -1
- package/dist/docs/assets/chunks/{theme.DysN9-VN.js → theme.ASugdMNm.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 +4 -61
- 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 +18 -3
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +80 -42
- package/dist/internal/cli-deploy.js +1 -1
- package/dist/internal/discovery.js +3 -3
- package/dist/internal/eval-run-store.d.ts +33 -30
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +84 -96
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +3 -2
- 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 +5 -3
- 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/playground/assets/cursor-icons-16-CQ50JpfO.woff2 +0 -0
- package/dist/playground/assets/index-7GJIUFQj.css +1 -0
- package/dist/playground/assets/index-mux9aj5P.js +319 -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 +14 -6
- package/src/evals.ts +4 -118
- 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 +101 -45
- package/src/internal/cli-deploy.ts +1 -1
- package/src/internal/discovery.ts +2 -2
- package/src/internal/eval-run-store.ts +86 -100
- package/src/internal/init-project.ts +3 -2
- package/src/internal/playground-proxy.ts +5 -5
- package/src/internal/resolve-prod-target.ts +101 -3
- package/src/internal/server.ts +5 -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.d.ts +0 -32
- package/dist/internal/json-dir-store.d.ts.map +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/src/storage.ts
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* Author `agent/storage.ts` with {@link defineStorage} to mirror the
|
|
5
5
|
* framework's durable state into storage you own (a database, S3, a data
|
|
6
6
|
* pipeline, …). Without it, state lives under `--state-root` on local disk
|
|
7
|
-
* only
|
|
8
|
-
* `persistSamples` / `persistSnapshots` hooks).
|
|
7
|
+
* only, and eval/A/B history stays in process memory.
|
|
9
8
|
*
|
|
10
|
-
* The sink is a plain key-value store — four functions, no schema
|
|
9
|
+
* The sink is a plain key-value store — four functions, no schema — plus
|
|
10
|
+
* two optional dedicated tables ({@link StorageConfig.evals} and
|
|
11
|
+
* {@link StorageConfig.abs}) for eval-run and A/B history:
|
|
11
12
|
*
|
|
12
13
|
* ```ts
|
|
13
14
|
* import { defineStorage } from "@anysphere/agent-serve/storage";
|
|
@@ -17,6 +18,8 @@
|
|
|
17
18
|
* get: (key) => db.get(key),
|
|
18
19
|
* delete: (key) => db.delete(key),
|
|
19
20
|
* list: (prefix) => db.listByPrefix(prefix), // [{ key, value }] in key order
|
|
21
|
+
* evals: { put: ..., delete: ..., list: ... }, // eval-runs table
|
|
22
|
+
* abs: { putSample: ... }, // A/B table
|
|
20
23
|
* });
|
|
21
24
|
* ```
|
|
22
25
|
*
|
|
@@ -41,6 +44,9 @@
|
|
|
41
44
|
*/
|
|
42
45
|
|
|
43
46
|
import { createHash } from "node:crypto";
|
|
47
|
+
import type { ABMetricSample } from "./ab.js";
|
|
48
|
+
import type { EvalRunSnapshot } from "./evals.js";
|
|
49
|
+
import type { ABSnapshot } from "./internal/ab-snapshot.js";
|
|
44
50
|
import { brandDefinition } from "./internal/brand.js";
|
|
45
51
|
import type { JsonValue } from "./types.js";
|
|
46
52
|
|
|
@@ -110,11 +116,54 @@ export interface StorageRestorePolicy {
|
|
|
110
116
|
maxTotalBytes?: number;
|
|
111
117
|
}
|
|
112
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Dedicated table for playground eval batches, keyed by `runId`. The
|
|
121
|
+
* framework saves a full {@link EvalRunSnapshot} as a batch starts,
|
|
122
|
+
* progresses, and finishes; prunes runs past the playground history
|
|
123
|
+
* window; and lists everything back at serve start.
|
|
124
|
+
*/
|
|
125
|
+
export interface StorageEvalsTable {
|
|
126
|
+
/** Upsert one run snapshot under `run.runId` (last write wins). */
|
|
127
|
+
put(run: EvalRunSnapshot, ctx: StorageContext): void | Promise<void>;
|
|
128
|
+
/** Remove a run pruned out of the playground history window. */
|
|
129
|
+
delete(runId: string, ctx: StorageContext): void | Promise<void>;
|
|
130
|
+
/** All saved runs (any order). Called once when the serve process hydrates. */
|
|
131
|
+
list(ctx: StorageContext): EvalRunSnapshot[] | Promise<EvalRunSnapshot[]>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Dedicated table for live A/B metrics: one row per cumulative metric
|
|
136
|
+
* sample (unique per `experiment` + `sessionId` + `at` — one boundary
|
|
137
|
+
* event emits a sample per enrolled experiment), plus — optionally — the latest
|
|
138
|
+
* aggregate snapshot so a replacement host with no local sessions can
|
|
139
|
+
* still serve the A/Bs surface.
|
|
140
|
+
*/
|
|
141
|
+
export interface StorageABTable {
|
|
142
|
+
/** Append one cumulative metric sample (turn complete/fail). */
|
|
143
|
+
putSample(sample: ABMetricSample, ctx: StorageContext): void | Promise<void>;
|
|
144
|
+
/** Upsert the latest aggregate snapshot (framework-throttled). Optional. */
|
|
145
|
+
putSnapshot?(snapshot: ABSnapshot, ctx: StorageContext): void | Promise<void>;
|
|
146
|
+
/** Latest saved aggregate snapshot (replacement-host backfill). Optional. */
|
|
147
|
+
getSnapshot?(
|
|
148
|
+
ctx: StorageContext
|
|
149
|
+
): ABSnapshot | undefined | null | Promise<ABSnapshot | undefined | null>;
|
|
150
|
+
}
|
|
151
|
+
|
|
113
152
|
export interface StorageConfig {
|
|
114
153
|
/** Optional label surfaced on `GET /v1/info` diagnostics. */
|
|
115
154
|
name?: string;
|
|
116
155
|
/** Timing knobs; see {@link StoragePolicy}. */
|
|
117
156
|
policy?: StoragePolicy;
|
|
157
|
+
/**
|
|
158
|
+
* Dedicated eval-runs table. Omit it and playground eval history stays
|
|
159
|
+
* in process memory (lost on restart).
|
|
160
|
+
*/
|
|
161
|
+
evals?: StorageEvalsTable;
|
|
162
|
+
/**
|
|
163
|
+
* Dedicated A/B table. Omit it and metric samples are not exported
|
|
164
|
+
* (session event logs remain the assignment/fold source of truth).
|
|
165
|
+
*/
|
|
166
|
+
abs?: StorageABTable;
|
|
118
167
|
/**
|
|
119
168
|
* Store one value under a key (upsert, last-write-wins). Called on the
|
|
120
169
|
* framework's schedule — never concurrently, always in order. Keep it
|
|
@@ -168,6 +217,30 @@ export function defineStorage(config: StorageConfig): StorageDefinition {
|
|
|
168
217
|
);
|
|
169
218
|
}
|
|
170
219
|
}
|
|
220
|
+
if (config.evals !== undefined) {
|
|
221
|
+
for (const hook of ["put", "delete", "list"] as const) {
|
|
222
|
+
if (typeof config.evals[hook] !== "function") {
|
|
223
|
+
throw new Error(
|
|
224
|
+
`defineStorage: evals.${hook} must be a function when the evals table is set`
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (config.abs !== undefined) {
|
|
230
|
+
if (typeof config.abs.putSample !== "function") {
|
|
231
|
+
throw new Error(
|
|
232
|
+
"defineStorage: abs.putSample must be a function when the abs table is set"
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
for (const hook of ["putSnapshot", "getSnapshot"] as const) {
|
|
236
|
+
const value = config.abs[hook];
|
|
237
|
+
if (value !== undefined && typeof value !== "function") {
|
|
238
|
+
throw new Error(
|
|
239
|
+
`defineStorage: abs.${hook} must be a function when set`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
171
244
|
// Validate eagerly so a bad policy fails at discovery, not first flush.
|
|
172
245
|
resolveStoragePolicy(config.policy);
|
|
173
246
|
return brandDefinition("storage", config);
|
|
@@ -201,9 +274,9 @@ export const STORAGE_KEY_ROOT = "agentkit/v1" as const;
|
|
|
201
274
|
* | `agentkit/v1/{agent}/session-events/{sessionId}/{index}` | `SessionEvent[]` chunk (index = first event's index, zero-padded) |
|
|
202
275
|
* | `agentkit/v1/{agent}/continuation/{channelId}/{token}` | `{ sessionId }` |
|
|
203
276
|
* | `agentkit/v1/{agent}/reminder/{reminderId}` | `ReminderRecord` |
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
277
|
+
*
|
|
278
|
+
* Eval-run and A/B history do not flow through this KV scheme — they have
|
|
279
|
+
* dedicated tables ({@link StorageConfig.evals} / {@link StorageConfig.abs}).
|
|
207
280
|
*/
|
|
208
281
|
export const storageKeys = {
|
|
209
282
|
session: (agent: string, sessionId: string): string =>
|
|
@@ -228,14 +301,6 @@ export const storageKeys = {
|
|
|
228
301
|
`${STORAGE_KEY_ROOT}/${agent}/reminder/${reminderId}`,
|
|
229
302
|
reminderPrefix: (agent: string): string =>
|
|
230
303
|
`${STORAGE_KEY_ROOT}/${agent}/reminder/`,
|
|
231
|
-
evalRun: (agent: string, runId: string): string =>
|
|
232
|
-
`${STORAGE_KEY_ROOT}/${agent}/eval-run/${runId}`,
|
|
233
|
-
evalRunPrefix: (agent: string): string =>
|
|
234
|
-
`${STORAGE_KEY_ROOT}/${agent}/eval-run/`,
|
|
235
|
-
abSample: (agent: string, sessionId: string, at: string): string =>
|
|
236
|
-
`${STORAGE_KEY_ROOT}/${agent}/ab-sample/${sessionId}/${at}`,
|
|
237
|
-
abSnapshot: (agent: string): string =>
|
|
238
|
-
`${STORAGE_KEY_ROOT}/${agent}/ab-snapshot`,
|
|
239
304
|
} as const;
|
|
240
305
|
|
|
241
306
|
/**
|