@cursor/july 0.1.104 → 0.1.105

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 (161) hide show
  1. package/dist/channels/deployments/deployments-channel.d.ts.map +1 -1
  2. package/dist/channels/deployments/deployments-channel.js +1 -0
  3. package/dist/channels/deployments/types.d.ts +2 -0
  4. package/dist/channels/deployments/types.d.ts.map +1 -1
  5. package/dist/docs/404.html +2 -2
  6. package/dist/docs/ab.html +4 -4
  7. package/dist/docs/assets/{app.DbMWUyGb.js → app.BVwaffdK.js} +1 -1
  8. package/dist/docs/assets/chunks/@localSearchIndexroot.CJxMklAy.js +1 -0
  9. package/dist/docs/assets/chunks/{VPLocalSearchBox.DcNeTh9o.js → VPLocalSearchBox.WuWTZ1x8.js} +1 -1
  10. package/dist/docs/assets/chunks/{theme.DMjhY3gl.js → theme.BYdI_6sF.js} +2 -2
  11. package/dist/docs/assets/guides_grokbot-agents.md.DVqdhBKb.js +9 -0
  12. package/dist/docs/assets/guides_grokbot-agents.md.DVqdhBKb.lean.js +1 -0
  13. package/dist/docs/assets/index.md.BW_6tOgR.js +5 -0
  14. package/dist/docs/assets/index.md.BW_6tOgR.lean.js +1 -0
  15. package/dist/docs/assets/{reference_cli.md.CJNc_xYK.js → reference_cli.md.C6Lo8SEd.js} +2 -1
  16. package/dist/docs/assets/{reference_extensions.md.DykHW3qL.js → reference_extensions.md.CGmMLblt.js} +1 -1
  17. package/dist/docs/assets/templates_grokbot-agents.md.c1s6Flp9.js +3 -0
  18. package/dist/docs/assets/templates_grokbot-agents.md.c1s6Flp9.lean.js +1 -0
  19. package/dist/docs/building-with-agents.html +4 -4
  20. package/dist/docs/concepts.html +4 -4
  21. package/dist/docs/deployment.html +4 -4
  22. package/dist/docs/evals.html +4 -4
  23. package/dist/docs/guides/agent-to-agent.html +4 -4
  24. package/dist/docs/guides/cloud-agents.html +5 -5
  25. package/dist/docs/guides/convert-automation.html +4 -4
  26. package/dist/docs/guides/github.html +4 -4
  27. package/dist/docs/guides/grokbot-agents.html +35 -0
  28. package/dist/docs/guides/grokbot-agents.md +88 -0
  29. package/dist/docs/guides/human-in-the-loop.html +4 -4
  30. package/dist/docs/guides/mcp-oauth.html +4 -4
  31. package/dist/docs/guides/opentelemetry.html +5 -5
  32. package/dist/docs/guides/slack.html +4 -4
  33. package/dist/docs/guides/webhooks.html +4 -4
  34. package/dist/docs/hashmap.json +1 -1
  35. package/dist/docs/hillclimbing.html +4 -4
  36. package/dist/docs/index.html +6 -6
  37. package/dist/docs/index.md +6 -1
  38. package/dist/docs/llms-full.txt +156 -2
  39. package/dist/docs/llms.txt +2 -0
  40. package/dist/docs/quickstart.html +4 -4
  41. package/dist/docs/reference/agent-config.html +4 -4
  42. package/dist/docs/reference/artifacts.html +4 -4
  43. package/dist/docs/reference/channels.html +4 -4
  44. package/dist/docs/reference/cli.html +7 -6
  45. package/dist/docs/reference/cli.md +2 -1
  46. package/dist/docs/reference/connections.html +4 -4
  47. package/dist/docs/reference/extensions.html +6 -6
  48. package/dist/docs/reference/extensions.md +2 -0
  49. package/dist/docs/reference/hooks.html +4 -4
  50. package/dist/docs/reference/http-api.html +4 -4
  51. package/dist/docs/reference/instructions.html +4 -4
  52. package/dist/docs/reference/playground.html +4 -4
  53. package/dist/docs/reference/project-layout.html +4 -4
  54. package/dist/docs/reference/prompt.html +4 -4
  55. package/dist/docs/reference/result.html +4 -4
  56. package/dist/docs/reference/schedules.html +4 -4
  57. package/dist/docs/reference/sessions.html +4 -4
  58. package/dist/docs/reference/skills.html +4 -4
  59. package/dist/docs/reference/subagents.html +4 -4
  60. package/dist/docs/reference/tools.html +4 -4
  61. package/dist/docs/scaffolding-agents.html +4 -4
  62. package/dist/docs/skills/ab.html +4 -4
  63. package/dist/docs/skills/create-agent.html +4 -4
  64. package/dist/docs/skills/debug.html +4 -4
  65. package/dist/docs/skills/evals.html +4 -4
  66. package/dist/docs/skills/framework-map.html +4 -4
  67. package/dist/docs/skills/github.html +4 -4
  68. package/dist/docs/skills/hillclimb.html +4 -4
  69. package/dist/docs/skills/index.html +4 -4
  70. package/dist/docs/skills/mcp-auth.html +4 -4
  71. package/dist/docs/skills/otel.html +4 -4
  72. package/dist/docs/skills/setup-slack.html +4 -4
  73. package/dist/docs/storage.html +4 -4
  74. package/dist/docs/templates/agentic-owners.html +4 -4
  75. package/dist/docs/templates/agents-md.html +4 -4
  76. package/dist/docs/templates/code-wiki.html +5 -5
  77. package/dist/docs/templates/demo.html +5 -5
  78. package/dist/docs/templates/grokbot-agents.html +29 -0
  79. package/dist/docs/templates/grokbot-agents.md +48 -0
  80. package/dist/docs/templates/pr-autofixer.html +4 -4
  81. package/dist/docs/templates/security-help.html +4 -4
  82. package/dist/docs/templates/security-reviewer.html +4 -4
  83. package/dist/docs/templates/triage.html +4 -4
  84. package/dist/docs/troubleshooting.html +4 -4
  85. package/dist/files.d.ts +7 -2
  86. package/dist/files.d.ts.map +1 -1
  87. package/dist/files.js +7 -2
  88. package/dist/internal/cursor-agent-template.d.ts +1 -1
  89. package/dist/internal/cursor-agent-template.d.ts.map +1 -1
  90. package/dist/internal/cursor-agent-template.js +1 -0
  91. package/dist/internal/framework-file-storage.d.ts +3 -1
  92. package/dist/internal/framework-file-storage.d.ts.map +1 -1
  93. package/dist/internal/framework-file-storage.js +3 -1
  94. package/dist/internal/hosted-delivery.d.ts +7 -0
  95. package/dist/internal/hosted-delivery.d.ts.map +1 -1
  96. package/dist/internal/hosted-delivery.js +29 -1
  97. package/dist/internal/hosted-managed-automation.d.ts.map +1 -1
  98. package/dist/internal/hosted-managed-automation.js +27 -2
  99. package/dist/internal/init-project.d.ts.map +1 -1
  100. package/dist/internal/init-project.js +4 -1
  101. package/dist/internal/sdk-runner.d.ts +12 -0
  102. package/dist/internal/sdk-runner.d.ts.map +1 -1
  103. package/dist/internal/sdk-runner.js +18 -0
  104. package/dist/internal/server.d.ts.map +1 -1
  105. package/dist/internal/server.js +11 -3
  106. package/dist/internal/session-engine.d.ts +8 -0
  107. package/dist/internal/session-engine.d.ts.map +1 -1
  108. package/dist/internal/session-engine.js +132 -52
  109. package/dist/internal/store-mirror.d.ts +2 -2
  110. package/dist/internal/store-mirror.js +2 -2
  111. package/dist/internal/tenant-slack/relay.d.ts +2 -0
  112. package/dist/internal/tenant-slack/relay.d.ts.map +1 -1
  113. package/dist/internal/tenant-slack/relay.js +18 -8
  114. package/dist/internal/workspace-sync.d.ts +31 -6
  115. package/dist/internal/workspace-sync.d.ts.map +1 -1
  116. package/dist/internal/workspace-sync.js +67 -12
  117. package/dist/internal/workspace.d.ts +9 -0
  118. package/dist/internal/workspace.d.ts.map +1 -1
  119. package/dist/internal/workspace.js +16 -0
  120. package/dist/playground/assets/{index-8YiozU89.js → index-BaQzjaNK.js} +36 -36
  121. package/dist/playground/assets/index-CceqnLTX.css +1 -0
  122. package/dist/playground/index.html +2 -2
  123. package/dist/types.d.ts +9 -8
  124. package/dist/types.d.ts.map +1 -1
  125. package/docs/README.md +6 -1
  126. package/docs/guides/grokbot-agents.md +93 -0
  127. package/docs/reference/cli.md +2 -1
  128. package/docs/reference/extensions.md +2 -0
  129. package/docs/templates/grokbot-agents.md +53 -0
  130. package/package.json +10 -1
  131. package/src/channels/deployments/deployments-channel.ts +1 -0
  132. package/src/channels/deployments/types.ts +2 -0
  133. package/src/files.ts +9 -2
  134. package/src/internal/cursor-agent-template.ts +1 -0
  135. package/src/internal/framework-file-storage.ts +3 -1
  136. package/src/internal/hosted-delivery.ts +53 -1
  137. package/src/internal/hosted-managed-automation.ts +49 -5
  138. package/src/internal/init-project.ts +4 -1
  139. package/src/internal/sdk-runner.ts +19 -0
  140. package/src/internal/server.ts +16 -0
  141. package/src/internal/session-engine.ts +168 -56
  142. package/src/internal/store-mirror.ts +2 -2
  143. package/src/internal/tenant-slack/relay.ts +28 -4
  144. package/src/internal/workspace-sync.ts +84 -12
  145. package/src/internal/workspace.ts +20 -0
  146. package/src/types.ts +9 -8
  147. package/templates/grokbot-agents/README.md +26 -0
  148. package/templates/grokbot-agents/agent/agent.ts +6 -0
  149. package/templates/grokbot-agents/agent/extensions/grokbot.ts +5 -0
  150. package/templates/grokbot-agents/agent/instructions.md +7 -0
  151. package/templates/grokbot-agents/evals/evals.config.ts +5 -0
  152. package/templates/grokbot-agents/evals/grokbot-agents.eval.ts +18 -0
  153. package/templates/grokbot-agents/init.json +18 -0
  154. package/templates/grokbot-agents/package.json +17 -0
  155. package/templates/grokbot-agents/tsconfig.json +12 -0
  156. package/dist/docs/assets/chunks/@localSearchIndexroot.Bqsulb9K.js +0 -1
  157. package/dist/docs/assets/index.md.D75GWhPl.js +0 -5
  158. package/dist/docs/assets/index.md.D75GWhPl.lean.js +0 -1
  159. package/dist/playground/assets/index-MbMxXg-y.css +0 -1
  160. /package/dist/docs/assets/{reference_cli.md.CJNc_xYK.lean.js → reference_cli.md.C6Lo8SEd.lean.js} +0 -0
  161. /package/dist/docs/assets/{reference_extensions.md.DykHW3qL.lean.js → reference_extensions.md.CGmMLblt.lean.js} +0 -0
@@ -76,13 +76,16 @@ function describeError(error) {
76
76
  */
77
77
  export function postRelaySlackMessage(args) {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
- var _a, _b, _c;
79
+ var _a, _b, _c, _d, _e;
80
80
  const channel = args.channel.trim();
81
+ const log = (_a = args.log) !== null && _a !== void 0 ? _a : ((line) => console.info(line));
81
82
  if (channel === "") {
83
+ log(`[agent-sdk-slack-relay-client] refusing post automationUuid=${args.automationUuid}: empty channel`);
82
84
  return { ok: false, channel, status: 0, error: "empty channel" };
83
85
  }
84
- const target = ((_a = args.resolve) !== null && _a !== void 0 ? _a : resolveRelaySlackTarget)();
86
+ const target = ((_b = args.resolve) !== null && _b !== void 0 ? _b : resolveRelaySlackTarget)();
85
87
  if (target === undefined) {
88
+ log(`[agent-sdk-slack-relay-client] refusing post automationUuid=${args.automationUuid} channel=${channel}: no Cursor credential resolved (CURSOR_API_KEY / pod credential absent)`);
86
89
  return {
87
90
  ok: false,
88
91
  channel,
@@ -90,11 +93,14 @@ export function postRelaySlackMessage(args) {
90
93
  error: "no Cursor credential for the Slack relay",
91
94
  };
92
95
  }
93
- const fetchImpl = (_b = args.fetchImpl) !== null && _b !== void 0 ? _b : fetch;
96
+ const fetchImpl = (_c = args.fetchImpl) !== null && _c !== void 0 ? _c : fetch;
94
97
  const url = relaySlackPostUrl({
95
98
  baseUrl: target.relayBaseUrl,
96
99
  automationUuid: args.automationUuid,
97
100
  });
101
+ const messageChars = args.message.length;
102
+ log(`[agent-sdk-slack-relay-client] POST ${url} channel=${channel} messageChars=${String(messageChars)} truncated=${String(messageChars > AGENT_SDK_SLACK_RELAY_MAX_MESSAGE_CHARS)} threaded=${String(args.threadTs !== undefined)} timeoutMs=${String((_d = args.timeoutMs) !== null && _d !== void 0 ? _d : DEFAULT_TIMEOUT_MS)}`);
103
+ const startedAt = Date.now();
98
104
  let response;
99
105
  try {
100
106
  response = yield fetchImpl(url, {
@@ -105,32 +111,36 @@ export function postRelaySlackMessage(args) {
105
111
  accept: "application/json",
106
112
  },
107
113
  body: JSON.stringify(Object.assign({ channel, message: truncateMessage(args.message) }, (args.threadTs === undefined ? {} : { threadTs: args.threadTs }))),
108
- signal: AbortSignal.timeout((_c = args.timeoutMs) !== null && _c !== void 0 ? _c : DEFAULT_TIMEOUT_MS),
114
+ signal: AbortSignal.timeout((_e = args.timeoutMs) !== null && _e !== void 0 ? _e : DEFAULT_TIMEOUT_MS),
109
115
  });
110
116
  }
111
117
  catch (error) {
118
+ log(`[agent-sdk-slack-relay-client] request failed before a response channel=${channel} automationUuid=${args.automationUuid} elapsedMs=${String(Date.now() - startedAt)}: ${describeError(error)}`);
112
119
  return { ok: false, channel, status: 0, error: describeError(error) };
113
120
  }
114
121
  let body;
115
122
  try {
116
123
  body = yield response.json();
117
124
  }
118
- catch (_d) {
125
+ catch (_f) {
119
126
  body = undefined;
120
127
  }
121
128
  const record = typeof body === "object" && body !== null && !Array.isArray(body)
122
129
  ? body
123
130
  : {};
124
131
  if (!response.ok || record.ok !== true) {
132
+ const error = typeof record.error === "string" && record.error !== ""
133
+ ? record.error
134
+ : `relay responded ${response.status}`;
135
+ log(`[agent-sdk-slack-relay-client] relay denied channel=${channel} automationUuid=${args.automationUuid} status=${String(response.status)} bodyOk=${String(record.ok)} elapsedMs=${String(Date.now() - startedAt)}: ${error}`);
125
136
  return {
126
137
  ok: false,
127
138
  channel,
128
139
  status: response.status,
129
- error: typeof record.error === "string" && record.error !== ""
130
- ? record.error
131
- : `relay responded ${response.status}`,
140
+ error,
132
141
  };
133
142
  }
143
+ log(`[agent-sdk-slack-relay-client] relay posted channel=${typeof record.channel === "string" ? record.channel : channel} automationUuid=${args.automationUuid} status=${String(response.status)} ts=${typeof record.ts === "string" ? record.ts : "<none>"} elapsedMs=${String(Date.now() - startedAt)}`);
134
144
  return Object.assign(Object.assign({ ok: true, channel: typeof record.channel === "string" ? record.channel : channel }, (typeof record.ts === "string" ? { ts: record.ts } : {})), (typeof record.permalink === "string"
135
145
  ? { permalink: record.permalink }
136
146
  : {}));
@@ -1,13 +1,22 @@
1
1
  /**
2
- * Sync `agent/sandbox/workspace/**` seed files onto an Agent Store so
3
- * cloud-runtime turns read them from the store mount (the first cloud prompt
4
- * names the directory; see `buildCloudWorkspaceSection`). Hosted deployments
5
- * write store-root `workspace/<path>`. Local `serve`/`run` with
6
- * `runtime: "cloud"` writes `agent-serve/<agent>/workspace/<path>` on the
7
- * USER store.
2
+ * Sync workspace trees onto an Agent Store so cloud-runtime turns read
3
+ * them from the store mount. Authored `agent/sandbox/workspace/**` seeds
4
+ * land at store-root `workspace/<path>` (see `buildCloudWorkspaceSection`).
5
+ * Per-turn `workspaceFiles` land at `sessions/<sessionId>/workspace/<path>`
6
+ * (see `buildCloudSessionWorkspaceSection`). Personal-key local+cloud
7
+ * nests both under `agent-serve/<agent>/`.
8
8
  */
9
9
  import { type FileSink } from "../files.js";
10
10
  import type { SeedFile } from "../types.js";
11
+ export type WorkspaceFileBody = string | {
12
+ encoding: "base64";
13
+ data: string;
14
+ mimeType?: string;
15
+ };
16
+ /** Path or encoding that can never land. Distinct from a store outage. */
17
+ export declare class WorkspaceFileRefusal extends Error {
18
+ readonly name = "WorkspaceFileRefusal";
19
+ }
11
20
  /**
12
21
  * Mirror the seed tree onto the store at its authored relative paths and
13
22
  * delete keys no seed claims so redeploys drop removed files. Every seed
@@ -19,4 +28,20 @@ export declare function syncWorkspaceToStore(args: {
19
28
  /** Store-root directory that holds the seed tree. Defaults to `workspace/`. */
20
29
  workspacePrefix?: string;
21
30
  }): Promise<void>;
31
+ /**
32
+ * Replace the session workspace prefix with this turn's `workspaceFiles`.
33
+ * Keys the map does not claim are deleted so a later send cannot leave a
34
+ * stale `pr.json`. Every path validates before the store is touched.
35
+ * Returns the relative paths that landed, in send order.
36
+ */
37
+ export declare function syncSessionWorkspaceFiles(args: {
38
+ sink: FileSink;
39
+ files: Record<string, WorkspaceFileBody>;
40
+ workspacePrefix: string;
41
+ }): Promise<string[]>;
42
+ /** Delete every key under the session workspace prefix. */
43
+ export declare function wipeSessionWorkspace(args: {
44
+ sink: FileSink;
45
+ workspacePrefix: string;
46
+ }): Promise<void>;
22
47
  //# sourceMappingURL=workspace-sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-sync.d.ts","sourceRoot":"","sources":["../../src/internal/workspace-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC/B,+EAA+E;IAC/E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CAchB"}
1
+ {"version":3,"file":"workspace-sync.d.ts","sourceRoot":"","sources":["../../src/internal/workspace-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,0EAA0E;AAC1E,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAkB,IAAI,0BAA0B;CACjD;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC/B,+EAA+E;IAC/E,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CAchB;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACzC,eAAe,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBpB;AAED,2DAA2D;AAC3D,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhB"}
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Sync `agent/sandbox/workspace/**` seed files onto an Agent Store so
3
- * cloud-runtime turns read them from the store mount (the first cloud prompt
4
- * names the directory; see `buildCloudWorkspaceSection`). Hosted deployments
5
- * write store-root `workspace/<path>`. Local `serve`/`run` with
6
- * `runtime: "cloud"` writes `agent-serve/<agent>/workspace/<path>` on the
7
- * USER store.
2
+ * Sync workspace trees onto an Agent Store so cloud-runtime turns read
3
+ * them from the store mount. Authored `agent/sandbox/workspace/**` seeds
4
+ * land at store-root `workspace/<path>` (see `buildCloudWorkspaceSection`).
5
+ * Per-turn `workspaceFiles` land at `sessions/<sessionId>/workspace/<path>`
6
+ * (see `buildCloudSessionWorkspaceSection`). Personal-key local+cloud
7
+ * nests both under `agent-serve/<agent>/`.
8
8
  */
9
9
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
10
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -19,6 +19,13 @@ import { readFile } from "node:fs/promises";
19
19
  import { agentStoreKeys } from "../files.js";
20
20
  import { MEMORY_DIR_NAME } from "../memory.js";
21
21
  import { mirrorToStore, storeRelPath } from "./store-mirror.js";
22
+ /** Path or encoding that can never land. Distinct from a store outage. */
23
+ export class WorkspaceFileRefusal extends Error {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.name = "WorkspaceFileRefusal";
27
+ }
28
+ }
22
29
  /**
23
30
  * Mirror the seed tree onto the store at its authored relative paths and
24
31
  * delete keys no seed claims so redeploys drop removed files. Every seed
@@ -30,20 +37,68 @@ export function syncWorkspaceToStore(args) {
30
37
  const workspacePrefix = (_a = args.workspacePrefix) !== null && _a !== void 0 ? _a : agentStoreKeys.workspacePrefix();
31
38
  const desired = new Map();
32
39
  for (const seed of args.seedFiles) {
33
- desired.set(agentStoreKeys.workspaceFile(seedRelPath(seed.relativePath), workspacePrefix), yield readFile(seed.sourcePath));
40
+ desired.set(agentStoreKeys.workspaceFile(workspaceRelPath(seed.relativePath), workspacePrefix), yield readFile(seed.sourcePath));
34
41
  }
35
42
  yield mirrorToStore({ sink: args.sink, prefix: workspacePrefix, desired });
36
43
  });
37
44
  }
45
+ /**
46
+ * Replace the session workspace prefix with this turn's `workspaceFiles`.
47
+ * Keys the map does not claim are deleted so a later send cannot leave a
48
+ * stale `pr.json`. Every path validates before the store is touched.
49
+ * Returns the relative paths that landed, in send order.
50
+ */
51
+ export function syncSessionWorkspaceFiles(args) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ const desired = new Map();
54
+ const relPaths = [];
55
+ for (const [relativePath, contents] of Object.entries(args.files)) {
56
+ const rel = workspaceRelPath(relativePath);
57
+ desired.set(agentStoreKeys.workspaceFile(rel, args.workspacePrefix), workspaceFileBytes(relativePath, contents));
58
+ relPaths.push(rel);
59
+ }
60
+ yield mirrorToStore({
61
+ sink: args.sink,
62
+ prefix: args.workspacePrefix,
63
+ desired,
64
+ });
65
+ return relPaths;
66
+ });
67
+ }
68
+ /** Delete every key under the session workspace prefix. */
69
+ export function wipeSessionWorkspace(args) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ yield mirrorToStore({
72
+ sink: args.sink,
73
+ prefix: args.workspacePrefix,
74
+ desired: new Map(),
75
+ });
76
+ });
77
+ }
38
78
  /**
39
79
  * Same reservation as local materialization's `resolveWorkspaceWritePath`:
40
- * `memory/` is the shared cross-session journal, so a seed under it fails
41
- * the sync exactly as it fails a local first turn.
80
+ * `memory/` is the shared cross-session journal, so a seed or send under it
81
+ * fails the sync exactly as it fails a local first turn.
42
82
  */
43
- function seedRelPath(relPath) {
44
- const rel = storeRelPath(relPath, "workspace file");
83
+ function workspaceRelPath(relPath) {
84
+ let rel;
85
+ try {
86
+ rel = storeRelPath(relPath, "workspace file");
87
+ }
88
+ catch (error) {
89
+ throw new WorkspaceFileRefusal(error instanceof Error ? error.message : String(error));
90
+ }
45
91
  if (rel.split("/", 1)[0] === MEMORY_DIR_NAME) {
46
- throw new Error(`"${MEMORY_DIR_NAME}" is reserved for shared session memory; refusing to sync ${relPath}`);
92
+ throw new WorkspaceFileRefusal(`"${MEMORY_DIR_NAME}" is reserved for shared session memory; refusing to sync ${relPath}`);
47
93
  }
48
94
  return rel;
49
95
  }
96
+ function workspaceFileBytes(relativePath, contents) {
97
+ if (typeof contents === "string") {
98
+ return new TextEncoder().encode(contents);
99
+ }
100
+ if (contents.encoding === "base64") {
101
+ return new Uint8Array(Buffer.from(contents.data, "base64"));
102
+ }
103
+ throw new WorkspaceFileRefusal(`Unsupported workspace file encoding for ${relativePath}`);
104
+ }
@@ -37,6 +37,15 @@ export declare function buildCloudMemorySection(agentName: string): string;
37
37
  * `syncWorkspaceToStore`), so the model has to be told where they are.
38
38
  */
39
39
  export declare function buildCloudWorkspaceSection(dir: string): string;
40
+ /**
41
+ * Per-turn preamble for cloud `workspaceFiles` after they land on the
42
+ * session store prefix (see `syncSessionWorkspaceFiles`). Omitted when
43
+ * the sync did not land.
44
+ *
45
+ * Same shared Agent Store mount as authored seeds — the session path is
46
+ * replace-per-send / task-end wipe lifetime, not a separate mount ACL.
47
+ */
48
+ export declare function buildCloudSessionWorkspaceSection(dir: string, relPaths: readonly string[]): string;
40
49
  /** Relative path of an agent-side tool script inside the session workspace. */
41
50
  export declare function agentToolScriptPath(toolName: string): string;
42
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/internal/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AAMrB,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;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM9D;AAED,+EAA+E;AAC/E,wBAAg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dir) {
50
50
  `The agent's authored workspace files live at \`${dir}\` on this machine. Relative paths in your instructions that name these files resolve under that directory rather than your working directory. Read them with your normal file tools. The directory is shared across sessions, so copy a file into your working directory before editing it.`,
51
51
  ].join("\n");
52
52
  }
53
+ /**
54
+ * Per-turn preamble for cloud `workspaceFiles` after they land on the
55
+ * session store prefix (see `syncSessionWorkspaceFiles`). Omitted when
56
+ * the sync did not land.
57
+ *
58
+ * Same shared Agent Store mount as authored seeds — the session path is
59
+ * replace-per-send / task-end wipe lifetime, not a separate mount ACL.
60
+ */
61
+ export function buildCloudSessionWorkspaceSection(dir, relPaths) {
62
+ const listed = relPaths.map((path) => `\`${path}\``).join(", ");
63
+ return [
64
+ "## Session workspace files",
65
+ "",
66
+ `This turn's workspace files live at \`${dir}\` on this machine (${listed}). Read them with your normal file tools. They sit on the same shared Agent Store mount as authored workspace seeds; the session directory is replaced on the next send for this session, and task sessions remove it when they finish.`,
67
+ ].join("\n");
68
+ }
53
69
  /** Relative path of an agent-side tool script inside the session workspace. */
54
70
  export function agentToolScriptPath(toolName) {
55
71
  return `.agent-serve/tools/${toolName}.sh`;