@cursor/july 0.1.32 → 0.1.34
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/README.md +1 -1
- package/dist/artifacts.d.ts.map +1 -1
- package/dist/artifacts.js +0 -5
- package/dist/bin/agent-serve.d.ts +1 -0
- package/dist/bin/agent-serve.d.ts.map +1 -1
- package/dist/bin/agent-serve.js +32 -2
- package/dist/channels/github/types.d.ts +10 -7
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.C2aVczmo.js → app.FPupl4SP.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.WoYunhnT.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.DLEzetbD.js → VPLocalSearchBox.Cd182Cu0.js} +1 -1
- package/dist/docs/assets/chunks/{theme.BkOH1oMp.js → theme.BEM3Okcd.js} +2 -2
- package/dist/docs/assets/{example-agents_weather-agent.md.Dmrcphhl.js → example-agents_weather-agent.md.BADkPqxQ.js} +6 -4
- package/dist/docs/assets/example-agents_weather-agent.md.BADkPqxQ.lean.js +1 -0
- package/dist/docs/assets/guides_cloud-runtime.md.CDJGvVC4.js +9 -0
- package/dist/docs/assets/guides_cloud-runtime.md.CDJGvVC4.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 +10 -8
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +5 -5
- 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/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/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 +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/files-backends/agent-store-presigned-url.d.ts.map +1 -1
- package/dist/files-backends/agent-store-presigned-url.js +19 -810
- package/dist/files.d.ts +20 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +20 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/internal/artifacts-store.d.ts +14 -6
- package/dist/internal/artifacts-store.d.ts.map +1 -1
- package/dist/internal/artifacts-store.js +160 -16
- package/dist/internal/cli-convert-automation.d.ts +39 -0
- package/dist/internal/cli-convert-automation.d.ts.map +1 -0
- package/dist/internal/cli-convert-automation.js +280 -0
- package/dist/internal/cli-deploy.d.ts +2 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +1 -1
- package/dist/internal/cli-mcp-oauth.d.ts +23 -0
- package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
- package/dist/internal/cli-mcp-oauth.js +57 -33
- package/dist/internal/convert-automation/convert-workflow.d.ts +10 -0
- package/dist/internal/convert-automation/convert-workflow.d.ts.map +1 -0
- package/dist/internal/convert-automation/convert-workflow.js +998 -0
- package/dist/internal/convert-automation/index.d.ts +3 -0
- package/dist/internal/convert-automation/index.d.ts.map +1 -0
- package/dist/internal/convert-automation/index.js +1 -0
- package/dist/internal/convert-automation/slug.d.ts +11 -0
- package/dist/internal/convert-automation/slug.d.ts.map +1 -0
- package/dist/internal/convert-automation/slug.js +36 -0
- package/dist/internal/convert-automation/types.d.ts +191 -0
- package/dist/internal/convert-automation/types.d.ts.map +1 -0
- package/dist/internal/convert-automation/types.js +13 -0
- package/dist/internal/cursor-relay-core.d.ts +12 -0
- package/dist/internal/cursor-relay-core.d.ts.map +1 -1
- package/dist/internal/cursor-relay-core.js +42 -8
- package/dist/internal/deploy-client.d.ts +31 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +48 -0
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +3 -32
- package/dist/internal/init-project.d.ts +1 -0
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +1 -1
- package/dist/internal/mcp-endpoint.d.ts +6 -0
- package/dist/internal/mcp-endpoint.d.ts.map +1 -1
- package/dist/internal/mcp-endpoint.js +168 -0
- package/dist/internal/resolved-connections.d.ts +15 -0
- package/dist/internal/resolved-connections.d.ts.map +1 -1
- package/dist/internal/resolved-connections.js +12 -5
- package/dist/internal/review-comments.d.ts +9 -1
- package/dist/internal/review-comments.d.ts.map +1 -1
- package/dist/internal/review-comments.js +76 -0
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +83 -8
- package/dist/internal/session-engine.d.ts +56 -3
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +252 -83
- package/dist/internal/storage-coordinator.d.ts +0 -15
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +0 -52
- package/dist/internal/workspace.d.ts +10 -5
- package/dist/internal/workspace.d.ts.map +1 -1
- package/dist/internal/workspace.js +13 -0
- package/dist/memory.d.ts +22 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +100 -8
- package/dist/playground/assets/index-CDDWw0YX.js +85 -0
- package/dist/playground/assets/index-MVuNTd8v.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage.d.ts +0 -4
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +0 -4
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/example-agents/weather-agent.md +29 -11
- package/docs/guides/cloud-runtime.md +6 -4
- package/package.json +3 -22
- package/src/artifacts.ts +0 -6
- package/src/bin/agent-serve.ts +36 -2
- package/src/channels/github/types.ts +10 -7
- package/src/files-backends/agent-store-presigned-url.ts +7 -5
- package/src/files.ts +27 -0
- package/src/index.ts +6 -1
- package/src/internal/artifacts-store.ts +185 -22
- package/src/internal/cli-convert-automation.ts +352 -0
- package/src/internal/cli-deploy.ts +1 -1
- package/src/internal/cli-mcp-oauth.ts +69 -31
- package/src/internal/convert-automation/convert-workflow.ts +1422 -0
- package/src/internal/convert-automation/index.ts +10 -0
- package/src/internal/convert-automation/slug.ts +38 -0
- package/src/internal/convert-automation/types.ts +199 -0
- package/src/internal/cursor-relay-core.ts +62 -3
- package/src/internal/deploy-client.ts +78 -0
- package/src/internal/discovery.ts +3 -37
- package/src/internal/init-project.ts +1 -1
- package/src/internal/mcp-endpoint.ts +243 -0
- package/src/internal/resolved-connections.ts +32 -6
- package/src/internal/review-comments.ts +102 -2
- package/src/internal/server.ts +108 -2
- package/src/internal/session-engine.ts +329 -99
- package/src/internal/storage-coordinator.ts +0 -62
- package/src/internal/workspace.ts +19 -5
- package/src/memory.ts +126 -10
- package/src/storage.ts +0 -6
- package/src/types.ts +15 -0
- package/dist/channels/slack/post-update-delivery.d.ts +0 -85
- package/dist/channels/slack/post-update-delivery.d.ts.map +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.xgMnlUSO.js +0 -1
- package/dist/docs/assets/example-agents_weather-agent.md.Dmrcphhl.lean.js +0 -1
- package/dist/docs/assets/guides_cloud-runtime.md.BZ2GA7Es.js +0 -9
- package/dist/docs/assets/guides_cloud-runtime.md.BZ2GA7Es.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/persistence-coordinator.d.ts +0 -127
- package/dist/internal/persistence-coordinator.d.ts.map +0 -1
- package/dist/multi-tenant.d.ts +0 -80
- package/dist/multi-tenant.d.ts.map +0 -1
- package/dist/multi-tenant.js +0 -69
- package/dist/persistence.d.ts +0 -184
- package/dist/persistence.d.ts.map +0 -1
- package/dist/playground/assets/index-50PKeJlG.css +0 -1
- package/dist/playground/assets/index-C0f2Wl1q.js +0 -85
|
@@ -364,58 +364,6 @@ export class StorageCoordinator {
|
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
// ==========================================================================
|
|
367
|
-
// Artifacts (`ctx.artifacts`)
|
|
368
|
-
// ==========================================================================
|
|
369
|
-
/**
|
|
370
|
-
* Whether the sink can serve awaited artifact rows: `get` (upsert
|
|
371
|
-
* read-back), `list` (listing + eviction), and `delete` (`max` cap
|
|
372
|
-
* eviction) are all required — without `delete` the retention cap
|
|
373
|
-
* could never evict, so rows fall back to the filesystem store.
|
|
374
|
-
*/
|
|
375
|
-
get supportsArtifacts() {
|
|
376
|
-
return (this.definition.get !== undefined &&
|
|
377
|
-
this.definition.list !== undefined &&
|
|
378
|
-
this.definition.delete !== undefined);
|
|
379
|
-
}
|
|
380
|
-
/** Awaited artifact-row read. Errors propagate (read-after-write). */
|
|
381
|
-
artifactGet(id) {
|
|
382
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
383
|
-
const get = this.definition.get;
|
|
384
|
-
if (get === undefined) {
|
|
385
|
-
throw new Error("storage get is not configured");
|
|
386
|
-
}
|
|
387
|
-
const value = yield get(storageKeys.artifact(this.agentName, id), this.context("restore"));
|
|
388
|
-
return value !== null && value !== void 0 ? value : undefined;
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
/** Awaited artifact-row write (straight to the sink, like author KV). */
|
|
392
|
-
artifactPut(id, value) {
|
|
393
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
394
|
-
yield this.definition.put(storageKeys.artifact(this.agentName, id), value, this.context("policy"));
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
/** Awaited artifact-row delete. Errors propagate (cap eviction). */
|
|
398
|
-
artifactDelete(id) {
|
|
399
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
400
|
-
const del = this.definition.delete;
|
|
401
|
-
if (del === undefined) {
|
|
402
|
-
throw new Error("storage delete is not configured");
|
|
403
|
-
}
|
|
404
|
-
yield del(storageKeys.artifact(this.agentName, id), this.context("policy"));
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
/** All artifact-row values for this agent. Errors propagate. */
|
|
408
|
-
artifactList() {
|
|
409
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
410
|
-
const list = this.definition.list;
|
|
411
|
-
if (list === undefined) {
|
|
412
|
-
throw new Error("storage list is not configured");
|
|
413
|
-
}
|
|
414
|
-
const entries = yield list(storageKeys.artifactPrefix(this.agentName), this.context("restore"));
|
|
415
|
-
return Array.isArray(entries) ? entries.map((entry) => entry.value) : [];
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
// ==========================================================================
|
|
419
367
|
// Evals (dedicated `evals` table)
|
|
420
368
|
// ==========================================================================
|
|
421
369
|
/**
|
|
@@ -17,14 +17,19 @@ export interface MaterializeWorkspaceOptions {
|
|
|
17
17
|
seed: boolean;
|
|
18
18
|
/**
|
|
19
19
|
* Agent state root. `<stateRoot>/memory/` (the durable cross-session
|
|
20
|
-
* directory the memory hook journals into
|
|
21
|
-
* the
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* directory the memory hook journals into — on hosting a local mirror of
|
|
21
|
+
* the Agent Store journal) is created and symlinked into the workspace as
|
|
22
|
+
* `memory` so the agent reads it with plain file tools. Cloud VMs have no
|
|
23
|
+
* materialized workspace; they read the store mount directly (see
|
|
24
|
+
* {@link buildCloudMemorySection}).
|
|
25
25
|
*/
|
|
26
26
|
stateRoot: string;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* First-turn preamble section for cloud-runtime sessions on hosted
|
|
30
|
+
* deployments: cloud VMs read the memory journal from the store mount.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildCloudMemorySection(agentName: string): string;
|
|
28
33
|
/** Relative path of an agent-side tool script inside the session workspace. */
|
|
29
34
|
export declare function agentToolScriptPath(toolName: string): string;
|
|
30
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/internal/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/internal/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,aAAa,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;;;;;;OAOG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOjE;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,SAAS,CAapB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,GAAE;IAAE,cAAc,EAAE,OAAO,CAAA;CAA8B,GAC/D,MAAM,CA6CR;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE;IAAE,cAAc,EAAE,OAAO,CAAA;CAAE,GACnC,MAAM,CAUR;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAcrE;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CAkCf;AAqGD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAO3D;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
|
@@ -17,9 +17,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
17
17
|
};
|
|
18
18
|
import { chmod, copyFile, lstat, mkdir, readlink, rm, stat, symlink, writeFile, } from "node:fs/promises";
|
|
19
19
|
import { dirname, join, parse, relative, resolve, sep } from "node:path";
|
|
20
|
+
import { agentStoreKeys, DEPLOYMENT_STORE_MOUNT_PATH } from "../files.js";
|
|
20
21
|
import { MEMORY_DIR_NAME } from "../memory.js";
|
|
21
22
|
import { parseFrontmatter, serializeFrontmatter } from "./frontmatter.js";
|
|
22
23
|
import { buildIdentitySection } from "./prompt-context.js";
|
|
24
|
+
/**
|
|
25
|
+
* First-turn preamble section for cloud-runtime sessions on hosted
|
|
26
|
+
* deployments: cloud VMs read the memory journal from the store mount.
|
|
27
|
+
*/
|
|
28
|
+
export function buildCloudMemorySection(agentName) {
|
|
29
|
+
const dir = `${DEPLOYMENT_STORE_MOUNT_PATH}/${agentStoreKeys.memoryDir(agentName)}`;
|
|
30
|
+
return [
|
|
31
|
+
"## Shared session memory",
|
|
32
|
+
"",
|
|
33
|
+
`The cross-session memory journal (the \`memory/\` directory your instructions may reference) lives at \`${dir}\` on this machine — read \`${dir}/journal.jsonl\` with your normal file tools.`,
|
|
34
|
+
].join("\n");
|
|
35
|
+
}
|
|
23
36
|
/** Relative path of an agent-side tool script inside the session workspace. */
|
|
24
37
|
export function agentToolScriptPath(toolName) {
|
|
25
38
|
return `.agent-serve/tools/${toolName}.sh`;
|
package/dist/memory.d.ts
CHANGED
|
@@ -16,11 +16,13 @@
|
|
|
16
16
|
* path — typically a server tool under `agent/tools/`, which can resolve
|
|
17
17
|
* state via `ctx.stateRoot`.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* On Cursor-managed hosting the default is {@link agentStoreMemoryBackend}:
|
|
20
|
+
* the journal lives on the deployment's Agent Store (survives deploys,
|
|
21
|
+
* visible on cloud VMs under the store mount) and is mirrored to
|
|
22
|
+
* `<stateRoot>/memory/journal.jsonl` so the workspace symlink read path
|
|
23
|
+
* keeps working for local-runtime turns.
|
|
23
24
|
*/
|
|
25
|
+
import { type FileSink } from "./files.js";
|
|
24
26
|
import type { HookDefinition, TurnUsage } from "./types.js";
|
|
25
27
|
/** Name of the shared memory directory under the agent state root. */
|
|
26
28
|
export declare const MEMORY_DIR_NAME = "memory";
|
|
@@ -41,10 +43,11 @@ export type TurnMemoryRecord = {
|
|
|
41
43
|
result?: string;
|
|
42
44
|
usage?: TurnUsage;
|
|
43
45
|
};
|
|
44
|
-
/** Where turn records go. Receives the agent's state root per append. */
|
|
46
|
+
/** Where turn records go. Receives the agent's state root and name per append. */
|
|
45
47
|
export interface MemoryBackend {
|
|
46
48
|
appendTurn(record: TurnMemoryRecord, ctx: {
|
|
47
49
|
stateRoot: string;
|
|
50
|
+
agentName: string;
|
|
48
51
|
}): Promise<void>;
|
|
49
52
|
}
|
|
50
53
|
export interface FileMemoryBackendOptions {
|
|
@@ -55,11 +58,24 @@ export interface FileMemoryBackendOptions {
|
|
|
55
58
|
maxJournalBytes?: number;
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
|
-
*
|
|
61
|
+
* Local default backend: append-only JSONL at `<stateRoot>/memory/journal.jsonl`
|
|
59
62
|
* — the directory the framework symlinks into session workspaces. Rotated
|
|
60
63
|
* segments stay alongside as `journal-<epoch-ms>.jsonl`.
|
|
61
64
|
*/
|
|
62
65
|
export declare function fileMemoryBackend(options?: FileMemoryBackendOptions): MemoryBackend;
|
|
66
|
+
export interface AgentStoreMemoryBackendOptions {
|
|
67
|
+
/** Sink override (tests). Defaults to the deployment's Agent Store. */
|
|
68
|
+
sink?: FileSink;
|
|
69
|
+
/** Rotation threshold, same meaning as {@link FileMemoryBackendOptions}. */
|
|
70
|
+
maxJournalBytes?: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Journal on the deployment's Agent Store — durable across deploys, visible
|
|
74
|
+
* on cloud VMs under the store mount. Appends are read-modify-write with
|
|
75
|
+
* etag preconditions (retried on a lost race), then mirrored to
|
|
76
|
+
* `<stateRoot>/memory/journal.jsonl` for the workspace symlink read path.
|
|
77
|
+
*/
|
|
78
|
+
export declare function agentStoreMemoryBackend(options?: AgentStoreMemoryBackendOptions): MemoryBackend;
|
|
63
79
|
export interface MemoryHookOptions {
|
|
64
80
|
/** Where records go. Defaults to {@link fileMemoryBackend}. */
|
|
65
81
|
backend?: MemoryBackend;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAM9E,OAAO,KAAK,EAAe,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzE,sEAAsE;AACtE,eAAO,MAAM,eAAe,WAAW,CAAC;AAExC,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,kFAAkF;AAClF,MAAM,WAAW,aAAa;IAC5B,UAAU,CACR,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,wBAA6B,GACrC,aAAa,CAgCf;AAED,MAAM,WAAW,8BAA8B;IAC7C,uEAAuE;IACvE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,GAAE,8BAAmC,GAC3C,aAAa,CAsEf;AAqBD,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,yEAAyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAMD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,CA0F1E"}
|
package/dist/memory.js
CHANGED
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
* path — typically a server tool under `agent/tools/`, which can resolve
|
|
17
17
|
* state via `ctx.stateRoot`.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* On Cursor-managed hosting the default is {@link agentStoreMemoryBackend}:
|
|
20
|
+
* the journal lives on the deployment's Agent Store (survives deploys,
|
|
21
|
+
* visible on cloud VMs under the store mount) and is mirrored to
|
|
22
|
+
* `<stateRoot>/memory/journal.jsonl` so the workspace symlink read path
|
|
23
|
+
* keeps working for local-runtime turns.
|
|
23
24
|
*/
|
|
24
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
25
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -30,13 +31,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
30
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31
32
|
});
|
|
32
33
|
};
|
|
33
|
-
import {
|
|
34
|
+
import { randomUUID } from "node:crypto";
|
|
35
|
+
import { appendFile, mkdir, rename, stat, writeFile } from "node:fs/promises";
|
|
34
36
|
import { join } from "node:path";
|
|
37
|
+
import { agentStoreKeys, FileConflictError } from "./files.js";
|
|
38
|
+
import { cursorHostedFiles, isCursorHostedFilesAvailable, } from "./files-backends/cursor-hosted.js";
|
|
35
39
|
import { defineHook } from "./hooks.js";
|
|
36
40
|
/** Name of the shared memory directory under the agent state root. */
|
|
37
41
|
export const MEMORY_DIR_NAME = "memory";
|
|
38
42
|
/**
|
|
39
|
-
*
|
|
43
|
+
* Local default backend: append-only JSONL at `<stateRoot>/memory/journal.jsonl`
|
|
40
44
|
* — the directory the framework symlinks into session workspaces. Rotated
|
|
41
45
|
* segments stay alongside as `journal-<epoch-ms>.jsonl`.
|
|
42
46
|
*/
|
|
@@ -76,6 +80,91 @@ export function fileMemoryBackend(options = {}) {
|
|
|
76
80
|
},
|
|
77
81
|
};
|
|
78
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Journal on the deployment's Agent Store — durable across deploys, visible
|
|
85
|
+
* on cloud VMs under the store mount. Appends are read-modify-write with
|
|
86
|
+
* etag preconditions (retried on a lost race), then mirrored to
|
|
87
|
+
* `<stateRoot>/memory/journal.jsonl` for the workspace symlink read path.
|
|
88
|
+
*/
|
|
89
|
+
export function agentStoreMemoryBackend(options = {}) {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const sink = (_a = options.sink) !== null && _a !== void 0 ? _a : cursorHostedFiles();
|
|
92
|
+
const maxJournalBytes = (_b = options.maxJournalBytes) !== null && _b !== void 0 ? _b : 5 * 1024 * 1024;
|
|
93
|
+
// Appends are chained per journal key (same shape as fileMemoryBackend);
|
|
94
|
+
// a failed append must not poison the chain for later turns.
|
|
95
|
+
const appendChains = new Map();
|
|
96
|
+
const append = (record, ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const key = agentStoreKeys.memoryJournal(ctx.agentName);
|
|
98
|
+
const line = Buffer.from(`${JSON.stringify(record)}\n`, "utf8");
|
|
99
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
100
|
+
const current = yield sink.get(key);
|
|
101
|
+
const currentBody = current === undefined
|
|
102
|
+
? new Uint8Array(0)
|
|
103
|
+
: current instanceof Uint8Array
|
|
104
|
+
? current
|
|
105
|
+
: current.body;
|
|
106
|
+
const etag = current === undefined || current instanceof Uint8Array
|
|
107
|
+
? undefined
|
|
108
|
+
: current.etag;
|
|
109
|
+
let next;
|
|
110
|
+
let rotatedStamp;
|
|
111
|
+
if (currentBody.byteLength >= maxJournalBytes) {
|
|
112
|
+
rotatedStamp = `${Date.now()}-${randomUUID().slice(0, 8)}`;
|
|
113
|
+
yield sink.put(agentStoreKeys.memoryJournalRotated(ctx.agentName, rotatedStamp), currentBody, { ifMatch: null });
|
|
114
|
+
next = line;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
next = Buffer.concat([currentBody, line]);
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
yield sink.put(key, next, {
|
|
121
|
+
ifMatch: current === undefined ? null : etag,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
if (error instanceof FileConflictError && attempt < 2) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
yield mirrorJournalLocally(ctx.stateRoot, next);
|
|
131
|
+
if (rotatedStamp !== undefined) {
|
|
132
|
+
// Rotated segments sit beside the live journal locally too, so the
|
|
133
|
+
// workspace symlink read path keeps pre-rotation history.
|
|
134
|
+
yield writeFile(join(ctx.stateRoot, MEMORY_DIR_NAME, `journal-${rotatedStamp}.jsonl`), currentBody);
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
appendTurn(record, ctx) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
var _a;
|
|
143
|
+
const key = agentStoreKeys.memoryJournal(ctx.agentName);
|
|
144
|
+
const prior = (_a = appendChains.get(key)) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
145
|
+
const next = prior.catch(() => { }).then(() => append(record, ctx));
|
|
146
|
+
appendChains.set(key, next);
|
|
147
|
+
yield next;
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/** Atomic full rewrite of the local mirror; also hydrates a fresh pod after a deploy. */
|
|
153
|
+
function mirrorJournalLocally(stateRoot, contents) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const dir = join(stateRoot, MEMORY_DIR_NAME);
|
|
156
|
+
yield mkdir(dir, { recursive: true });
|
|
157
|
+
const tmp = join(dir, `.tmp-${randomUUID()}`);
|
|
158
|
+
yield writeFile(tmp, contents);
|
|
159
|
+
yield rename(tmp, join(dir, "journal.jsonl"));
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/** Hosted deployments journal to the Agent Store; local dev to plain files. */
|
|
163
|
+
function defaultMemoryBackend() {
|
|
164
|
+
return isCursorHostedFilesAvailable()
|
|
165
|
+
? agentStoreMemoryBackend()
|
|
166
|
+
: fileMemoryBackend();
|
|
167
|
+
}
|
|
79
168
|
function truncate(text, max) {
|
|
80
169
|
return text.length <= max ? text : `${text.slice(0, max)}…`;
|
|
81
170
|
}
|
|
@@ -90,7 +179,7 @@ function truncate(text, max) {
|
|
|
90
179
|
*/
|
|
91
180
|
export function memoryHook(options = {}) {
|
|
92
181
|
var _a, _b;
|
|
93
|
-
const backend = (_a = options.backend) !== null && _a !== void 0 ? _a :
|
|
182
|
+
const backend = (_a = options.backend) !== null && _a !== void 0 ? _a : defaultMemoryBackend();
|
|
94
183
|
const maxTextLength = (_b = options.maxTextLength) !== null && _b !== void 0 ? _b : 2000;
|
|
95
184
|
// Inbound message per turn (truncated at receipt so large pastes are not
|
|
96
185
|
// retained), keyed `<sessionId>/<turnId>` — `message.received` and the
|
|
@@ -123,7 +212,10 @@ export function memoryHook(options = {}) {
|
|
|
123
212
|
if (usage !== undefined) {
|
|
124
213
|
entry.usage = usage;
|
|
125
214
|
}
|
|
126
|
-
yield backend.appendTurn(entry, {
|
|
215
|
+
yield backend.appendTurn(entry, {
|
|
216
|
+
stateRoot: ctx.stateRoot,
|
|
217
|
+
agentName: ctx.agent.name,
|
|
218
|
+
});
|
|
127
219
|
});
|
|
128
220
|
const sweepSession = (ctx) => {
|
|
129
221
|
for (const key of pendingMessages.keys()) {
|