@cursor/july 0.1.33 → 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.
Files changed (164) hide show
  1. package/README.md +1 -1
  2. package/dist/artifacts.d.ts.map +1 -1
  3. package/dist/artifacts.js +0 -5
  4. package/dist/bin/agent-serve.d.ts +1 -0
  5. package/dist/bin/agent-serve.d.ts.map +1 -1
  6. package/dist/bin/agent-serve.js +32 -2
  7. package/dist/channels/github/types.d.ts +10 -7
  8. package/dist/channels/github/types.d.ts.map +1 -1
  9. package/dist/docs/404.html +2 -2
  10. package/dist/docs/ab.html +3 -3
  11. package/dist/docs/assets/{app.CgZqLyWL.js → app.FPupl4SP.js} +1 -1
  12. package/dist/docs/assets/chunks/@localSearchIndexroot.WoYunhnT.js +1 -0
  13. package/dist/docs/assets/chunks/{VPLocalSearchBox.C4KigoQn.js → VPLocalSearchBox.Cd182Cu0.js} +1 -1
  14. package/dist/docs/assets/chunks/{theme.C_Ty4yT7.js → theme.BEM3Okcd.js} +2 -2
  15. package/dist/docs/assets/{example-agents_weather-agent.md.Dmrcphhl.js → example-agents_weather-agent.md.BADkPqxQ.js} +6 -4
  16. package/dist/docs/assets/example-agents_weather-agent.md.BADkPqxQ.lean.js +1 -0
  17. package/dist/docs/assets/guides_cloud-runtime.md.CDJGvVC4.js +9 -0
  18. package/dist/docs/assets/guides_cloud-runtime.md.CDJGvVC4.lean.js +1 -0
  19. package/dist/docs/building-with-agents.html +3 -3
  20. package/dist/docs/concepts.html +3 -3
  21. package/dist/docs/deployment.html +3 -3
  22. package/dist/docs/evals.html +3 -3
  23. package/dist/docs/example-agents/approval-buddy.html +3 -3
  24. package/dist/docs/example-agents/benny.html +3 -3
  25. package/dist/docs/example-agents/bugbot.html +3 -3
  26. package/dist/docs/example-agents/codebase-wiki.html +3 -3
  27. package/dist/docs/example-agents/codeowners-review.html +3 -3
  28. package/dist/docs/example-agents/concierge.html +3 -3
  29. package/dist/docs/example-agents/fsd.html +3 -3
  30. package/dist/docs/example-agents/index.html +3 -3
  31. package/dist/docs/example-agents/knowledge-base.html +3 -3
  32. package/dist/docs/example-agents/oncall.html +3 -3
  33. package/dist/docs/example-agents/security-reviewer.html +3 -3
  34. package/dist/docs/example-agents/slack-agent.html +3 -3
  35. package/dist/docs/example-agents/weather-agent.html +10 -8
  36. package/dist/docs/guides/agent-to-agent.html +3 -3
  37. package/dist/docs/guides/cloud-runtime.html +5 -5
  38. package/dist/docs/guides/github.html +3 -3
  39. package/dist/docs/guides/human-in-the-loop.html +3 -3
  40. package/dist/docs/guides/mcp-oauth.html +3 -3
  41. package/dist/docs/guides/slack.html +3 -3
  42. package/dist/docs/guides/webhooks.html +3 -3
  43. package/dist/docs/hashmap.json +1 -1
  44. package/dist/docs/hillclimbing.html +3 -3
  45. package/dist/docs/index.html +3 -3
  46. package/dist/docs/quickstart.html +3 -3
  47. package/dist/docs/reference/agent-config.html +3 -3
  48. package/dist/docs/reference/channels.html +3 -3
  49. package/dist/docs/reference/cli.html +3 -3
  50. package/dist/docs/reference/connections.html +3 -3
  51. package/dist/docs/reference/hooks.html +3 -3
  52. package/dist/docs/reference/http-api.html +3 -3
  53. package/dist/docs/reference/instructions.html +3 -3
  54. package/dist/docs/reference/playground.html +3 -3
  55. package/dist/docs/reference/project-layout.html +3 -3
  56. package/dist/docs/reference/prompt.html +3 -3
  57. package/dist/docs/reference/schedules.html +3 -3
  58. package/dist/docs/reference/sessions.html +3 -3
  59. package/dist/docs/reference/skills.html +3 -3
  60. package/dist/docs/reference/subagents.html +3 -3
  61. package/dist/docs/reference/tools.html +3 -3
  62. package/dist/docs/scaffolding-agents.html +3 -3
  63. package/dist/docs/storage.html +3 -3
  64. package/dist/docs/troubleshooting.html +3 -3
  65. package/dist/files-backends/agent-store-presigned-url.d.ts +3 -11
  66. package/dist/files.d.ts +20 -0
  67. package/dist/files.d.ts.map +1 -1
  68. package/dist/files.js +20 -0
  69. package/dist/index.d.ts +2 -2
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +2 -2
  72. package/dist/internal/artifacts-store.d.ts +14 -6
  73. package/dist/internal/artifacts-store.d.ts.map +1 -1
  74. package/dist/internal/artifacts-store.js +160 -16
  75. package/dist/internal/cli-convert-automation.d.ts +39 -0
  76. package/dist/internal/cli-convert-automation.d.ts.map +1 -0
  77. package/dist/internal/cli-convert-automation.js +280 -0
  78. package/dist/internal/cli-deploy.d.ts +2 -0
  79. package/dist/internal/cli-deploy.d.ts.map +1 -1
  80. package/dist/internal/cli-deploy.js +1 -1
  81. package/dist/internal/cli-mcp-oauth.d.ts +23 -0
  82. package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
  83. package/dist/internal/cli-mcp-oauth.js +57 -33
  84. package/dist/internal/convert-automation/convert-workflow.d.ts +10 -0
  85. package/dist/internal/convert-automation/convert-workflow.d.ts.map +1 -0
  86. package/dist/internal/convert-automation/convert-workflow.js +998 -0
  87. package/dist/internal/convert-automation/index.d.ts +3 -0
  88. package/dist/internal/convert-automation/index.d.ts.map +1 -0
  89. package/dist/internal/convert-automation/index.js +1 -0
  90. package/dist/internal/convert-automation/slug.d.ts +11 -0
  91. package/dist/internal/convert-automation/slug.d.ts.map +1 -0
  92. package/dist/internal/convert-automation/slug.js +36 -0
  93. package/dist/internal/convert-automation/types.d.ts +191 -0
  94. package/dist/internal/convert-automation/types.d.ts.map +1 -0
  95. package/dist/internal/convert-automation/types.js +13 -0
  96. package/dist/internal/deploy-client.d.ts +31 -0
  97. package/dist/internal/deploy-client.d.ts.map +1 -1
  98. package/dist/internal/deploy-client.js +48 -0
  99. package/dist/internal/discovery.d.ts.map +1 -1
  100. package/dist/internal/discovery.js +3 -32
  101. package/dist/internal/init-project.d.ts +1 -0
  102. package/dist/internal/init-project.d.ts.map +1 -1
  103. package/dist/internal/init-project.js +1 -1
  104. package/dist/internal/mcp-endpoint.d.ts +6 -0
  105. package/dist/internal/mcp-endpoint.d.ts.map +1 -1
  106. package/dist/internal/mcp-endpoint.js +168 -0
  107. package/dist/internal/resolved-connections.d.ts +15 -0
  108. package/dist/internal/resolved-connections.d.ts.map +1 -1
  109. package/dist/internal/resolved-connections.js +12 -5
  110. package/dist/internal/server.d.ts.map +1 -1
  111. package/dist/internal/server.js +75 -7
  112. package/dist/internal/session-engine.d.ts +56 -3
  113. package/dist/internal/session-engine.d.ts.map +1 -1
  114. package/dist/internal/session-engine.js +252 -83
  115. package/dist/internal/storage-coordinator.d.ts +0 -15
  116. package/dist/internal/storage-coordinator.d.ts.map +1 -1
  117. package/dist/internal/storage-coordinator.js +0 -52
  118. package/dist/internal/workspace.d.ts +10 -5
  119. package/dist/internal/workspace.d.ts.map +1 -1
  120. package/dist/internal/workspace.js +13 -0
  121. package/dist/memory.d.ts +22 -6
  122. package/dist/memory.d.ts.map +1 -1
  123. package/dist/memory.js +100 -8
  124. package/dist/playground/assets/{index-CVlCAcUx.js → index-CDDWw0YX.js} +46 -46
  125. package/dist/playground/assets/index-MVuNTd8v.css +1 -0
  126. package/dist/playground/index.html +2 -2
  127. package/dist/storage.d.ts +0 -4
  128. package/dist/storage.d.ts.map +1 -1
  129. package/dist/storage.js +0 -4
  130. package/dist/types.d.ts +18 -0
  131. package/dist/types.d.ts.map +1 -1
  132. package/docs/example-agents/weather-agent.md +29 -11
  133. package/docs/guides/cloud-runtime.md +6 -4
  134. package/package.json +3 -1
  135. package/src/artifacts.ts +0 -6
  136. package/src/bin/agent-serve.ts +36 -2
  137. package/src/channels/github/types.ts +10 -7
  138. package/src/files.ts +27 -0
  139. package/src/index.ts +6 -1
  140. package/src/internal/artifacts-store.ts +185 -22
  141. package/src/internal/cli-convert-automation.ts +352 -0
  142. package/src/internal/cli-deploy.ts +1 -1
  143. package/src/internal/cli-mcp-oauth.ts +69 -31
  144. package/src/internal/convert-automation/convert-workflow.ts +1422 -0
  145. package/src/internal/convert-automation/index.ts +10 -0
  146. package/src/internal/convert-automation/slug.ts +38 -0
  147. package/src/internal/convert-automation/types.ts +199 -0
  148. package/src/internal/deploy-client.ts +78 -0
  149. package/src/internal/discovery.ts +3 -37
  150. package/src/internal/init-project.ts +1 -1
  151. package/src/internal/mcp-endpoint.ts +243 -0
  152. package/src/internal/resolved-connections.ts +32 -6
  153. package/src/internal/server.ts +99 -1
  154. package/src/internal/session-engine.ts +329 -99
  155. package/src/internal/storage-coordinator.ts +0 -62
  156. package/src/internal/workspace.ts +19 -5
  157. package/src/memory.ts +126 -10
  158. package/src/storage.ts +0 -6
  159. package/src/types.ts +15 -0
  160. package/dist/docs/assets/chunks/@localSearchIndexroot.B1uHGxBZ.js +0 -1
  161. package/dist/docs/assets/example-agents_weather-agent.md.Dmrcphhl.lean.js +0 -1
  162. package/dist/docs/assets/guides_cloud-runtime.md.BZ2GA7Es.js +0 -9
  163. package/dist/docs/assets/guides_cloud-runtime.md.BZ2GA7Es.lean.js +0 -1
  164. package/dist/playground/assets/index-BRhBbnd4.css +0 -1
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
- * TODO(agent-store): once agent-serve can mount the agent's AgentStore
20
- * (durable S3-backed filesystem shared across serve hosts and cloud VMs),
21
- * ship an AgentStore-backed backend and make it the default. The journal
22
- * format is designed to survive that move unchanged.
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
- * Default backend: append-only JSONL at `<stateRoot>/memory/journal.jsonl`
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;
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,KAAK,EAAe,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzE,sEAAsE;AACtE,eAAO,MAAM,eAAe,WAAW,CAAC;AAExC,gDAAgD;AAChD,MA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QG;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
- * TODO(agent-store): once agent-serve can mount the agent's AgentStore
20
- * (durable S3-backed filesystem shared across serve hosts and cloud VMs),
21
- * ship an AgentStore-backed backend and make it the default. The journal
22
- * format is designed to survive that move unchanged.
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 { appendFile, mkdir, rename, stat } from "node:fs/promises";
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
- * Default backend: append-only JSONL at `<stateRoot>/memory/journal.jsonl`
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 : fileMemoryBackend();
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, { stateRoot: ctx.stateRoot });
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()) {