strands-darwin 0.0.34 → 0.0.36

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 (273) hide show
  1. package/README.md +22 -3
  2. package/README.zh-CN.md +22 -3
  3. package/dist/patches/@strands-agents+sdk+1.16.0.patch +29 -15
  4. package/dist/patches/ink+7.1.1.patch +58 -0
  5. package/dist/src/agent/background-delegation.d.ts +3 -3
  6. package/dist/src/agent/background-delegation.js +2 -2
  7. package/dist/src/agent/background-delegation.js.map +1 -1
  8. package/dist/src/agent/context-breakdown.d.ts +2 -1
  9. package/dist/src/agent/context-breakdown.js +2 -1
  10. package/dist/src/agent/context-breakdown.js.map +1 -1
  11. package/dist/src/agent/instructions.d.ts +22 -3
  12. package/dist/src/agent/instructions.js +67 -34
  13. package/dist/src/agent/instructions.js.map +1 -1
  14. package/dist/src/agent/prompt-cache.js +15 -2
  15. package/dist/src/agent/prompt-cache.js.map +1 -1
  16. package/dist/src/agent/refusal.d.ts +44 -7
  17. package/dist/src/agent/refusal.js +54 -8
  18. package/dist/src/agent/refusal.js.map +1 -1
  19. package/dist/src/agent/rewind.d.ts +2 -0
  20. package/dist/src/agent/rewind.js +4 -1
  21. package/dist/src/agent/rewind.js.map +1 -1
  22. package/dist/src/agent/runtime.d.ts +86 -13
  23. package/dist/src/agent/runtime.js +250 -43
  24. package/dist/src/agent/runtime.js.map +1 -1
  25. package/dist/src/agent/session.d.ts +96 -4
  26. package/dist/src/agent/session.js +249 -9
  27. package/dist/src/agent/session.js.map +1 -1
  28. package/dist/src/agent/stream-idle.d.ts +16 -0
  29. package/dist/src/agent/stream-idle.js +127 -0
  30. package/dist/src/agent/stream-idle.js.map +1 -0
  31. package/dist/src/agent/stream-resumption.d.ts +5 -2
  32. package/dist/src/agent/stream-resumption.js +5 -2
  33. package/dist/src/agent/stream-resumption.js.map +1 -1
  34. package/dist/src/agent/system-prompt.d.ts +1 -1
  35. package/dist/src/agent/system-prompt.js +4 -1
  36. package/dist/src/agent/system-prompt.js.map +1 -1
  37. package/dist/src/agent/thinking.js +4 -2
  38. package/dist/src/agent/thinking.js.map +1 -1
  39. package/dist/src/agent/working-context.d.ts +21 -1
  40. package/dist/src/agent/working-context.js +28 -1
  41. package/dist/src/agent/working-context.js.map +1 -1
  42. package/dist/src/agent/workspace-trust.d.ts +112 -0
  43. package/dist/src/agent/workspace-trust.js +207 -0
  44. package/dist/src/agent/workspace-trust.js.map +1 -0
  45. package/dist/src/agentcore/auto-policy.d.ts +7 -0
  46. package/dist/src/agentcore/auto-policy.js +50 -0
  47. package/dist/src/agentcore/auto-policy.js.map +1 -0
  48. package/dist/src/agentcore/auto-state.d.ts +43 -0
  49. package/dist/src/agentcore/auto-state.js +73 -0
  50. package/dist/src/agentcore/auto-state.js.map +1 -0
  51. package/dist/src/agentcore/cli.d.ts +2 -0
  52. package/dist/src/agentcore/cli.js +38 -0
  53. package/dist/src/agentcore/cli.js.map +1 -0
  54. package/dist/src/agentcore/config.d.ts +48 -0
  55. package/dist/src/agentcore/config.js +44 -0
  56. package/dist/src/agentcore/config.js.map +1 -0
  57. package/dist/src/agentcore/controller.d.ts +105 -0
  58. package/dist/src/agentcore/controller.js +979 -0
  59. package/dist/src/agentcore/controller.js.map +1 -0
  60. package/dist/src/agentcore/projection.d.ts +2 -0
  61. package/dist/src/agentcore/projection.js +8 -0
  62. package/dist/src/agentcore/projection.js.map +1 -0
  63. package/dist/src/agentcore/records.d.ts +41 -0
  64. package/dist/src/agentcore/records.js +149 -0
  65. package/dist/src/agentcore/records.js.map +1 -0
  66. package/dist/src/agentcore/state.d.ts +16 -0
  67. package/dist/src/agentcore/state.js +149 -0
  68. package/dist/src/agentcore/state.js.map +1 -0
  69. package/dist/src/agentcore/tools.d.ts +3 -0
  70. package/dist/src/agentcore/tools.js +11 -0
  71. package/dist/src/agentcore/tools.js.map +1 -0
  72. package/dist/src/agentcore/transport.d.ts +37 -0
  73. package/dist/src/agentcore/transport.js +242 -0
  74. package/dist/src/agentcore/transport.js.map +1 -0
  75. package/dist/src/agentcore/upload-projection.d.ts +208 -0
  76. package/dist/src/agentcore/upload-projection.js +823 -0
  77. package/dist/src/agentcore/upload-projection.js.map +1 -0
  78. package/dist/src/agents/child-recipe.js +4 -1
  79. package/dist/src/agents/child-recipe.js.map +1 -1
  80. package/dist/src/agents/loader.d.ts +12 -0
  81. package/dist/src/agents/loader.js +15 -1
  82. package/dist/src/agents/loader.js.map +1 -1
  83. package/dist/src/agents/subagent-tool.js +6 -7
  84. package/dist/src/agents/subagent-tool.js.map +1 -1
  85. package/dist/src/agents/workflow-tool.js +4 -6
  86. package/dist/src/agents/workflow-tool.js.map +1 -1
  87. package/dist/src/cli-doctor.js +14 -5
  88. package/dist/src/cli-doctor.js.map +1 -1
  89. package/dist/src/cli-import.d.ts +1 -0
  90. package/dist/src/cli-import.js +26 -0
  91. package/dist/src/cli-import.js.map +1 -0
  92. package/dist/src/cli-main.js +60 -10
  93. package/dist/src/cli-main.js.map +1 -1
  94. package/dist/src/cli-permissions.d.ts +2 -0
  95. package/dist/src/cli-permissions.js +20 -0
  96. package/dist/src/cli-permissions.js.map +1 -0
  97. package/dist/src/cli-sessions.js +6 -2
  98. package/dist/src/cli-sessions.js.map +1 -1
  99. package/dist/src/cli-usage.d.ts +9 -1
  100. package/dist/src/cli-usage.js +13 -0
  101. package/dist/src/cli-usage.js.map +1 -1
  102. package/dist/src/cli.js +19 -2
  103. package/dist/src/cli.js.map +1 -1
  104. package/dist/src/commands/custom-commands.d.ts +1 -1
  105. package/dist/src/commands/custom-commands.js +20 -6
  106. package/dist/src/commands/custom-commands.js.map +1 -1
  107. package/dist/src/commands/init-command.d.ts +47 -0
  108. package/dist/src/commands/init-command.js +110 -0
  109. package/dist/src/commands/init-command.js.map +1 -0
  110. package/dist/src/commands/review-command.d.ts +10 -0
  111. package/dist/src/commands/review-command.js +28 -0
  112. package/dist/src/commands/review-command.js.map +1 -0
  113. package/dist/src/config-file.d.ts +9 -0
  114. package/dist/src/config-file.js +82 -0
  115. package/dist/src/config-file.js.map +1 -0
  116. package/dist/src/config.d.ts +100 -7
  117. package/dist/src/config.js +253 -46
  118. package/dist/src/config.js.map +1 -1
  119. package/dist/src/dev-repl.js +33 -2
  120. package/dist/src/dev-repl.js.map +1 -1
  121. package/dist/src/headless-protocol.d.ts +24 -1
  122. package/dist/src/headless-protocol.js +24 -5
  123. package/dist/src/headless-protocol.js.map +1 -1
  124. package/dist/src/headless-runner.d.ts +8 -0
  125. package/dist/src/headless-runner.js +42 -2
  126. package/dist/src/headless-runner.js.map +1 -1
  127. package/dist/src/headless.d.ts +11 -0
  128. package/dist/src/headless.js +33 -7
  129. package/dist/src/headless.js.map +1 -1
  130. package/dist/src/hooks/hook-process.js +7 -2
  131. package/dist/src/hooks/hook-process.js.map +1 -1
  132. package/dist/src/hooks/lifecycle-hooks.js +3 -1
  133. package/dist/src/hooks/lifecycle-hooks.js.map +1 -1
  134. package/dist/src/hooks/tool-hooks.js +3 -1
  135. package/dist/src/hooks/tool-hooks.js.map +1 -1
  136. package/dist/src/import-claude-files.d.ts +28 -0
  137. package/dist/src/import-claude-files.js +227 -0
  138. package/dist/src/import-claude-files.js.map +1 -0
  139. package/dist/src/import-claude-snippets.d.ts +2 -0
  140. package/dist/src/import-claude-snippets.js +105 -0
  141. package/dist/src/import-claude-snippets.js.map +1 -0
  142. package/dist/src/import-claude.d.ts +13 -0
  143. package/dist/src/import-claude.js +287 -0
  144. package/dist/src/import-claude.js.map +1 -0
  145. package/dist/src/mcp/registry.d.ts +57 -1
  146. package/dist/src/mcp/registry.js +78 -6
  147. package/dist/src/mcp/registry.js.map +1 -1
  148. package/dist/src/memory/command.d.ts +1 -1
  149. package/dist/src/memory/command.js +89 -4
  150. package/dist/src/memory/command.js.map +1 -1
  151. package/dist/src/memory/controller.d.ts +32 -0
  152. package/dist/src/memory/controller.js +39 -3
  153. package/dist/src/memory/controller.js.map +1 -1
  154. package/dist/src/memory/state.d.ts +6 -0
  155. package/dist/src/memory/state.js +6 -1
  156. package/dist/src/memory/state.js.map +1 -1
  157. package/dist/src/memory/store.d.ts +13 -0
  158. package/dist/src/memory/store.js +38 -2
  159. package/dist/src/memory/store.js.map +1 -1
  160. package/dist/src/memory/tools.d.ts +7 -0
  161. package/dist/src/memory/tools.js +12 -1
  162. package/dist/src/memory/tools.js.map +1 -1
  163. package/dist/src/paths.js +3 -0
  164. package/dist/src/paths.js.map +1 -1
  165. package/dist/src/permissions-test.d.ts +18 -0
  166. package/dist/src/permissions-test.js +207 -0
  167. package/dist/src/permissions-test.js.map +1 -0
  168. package/dist/src/pricing/model-prices.d.ts +11 -6
  169. package/dist/src/pricing/model-prices.js +37 -16
  170. package/dist/src/pricing/model-prices.js.map +1 -1
  171. package/dist/src/project-identity.d.ts +3 -0
  172. package/dist/src/project-identity.js +8 -0
  173. package/dist/src/project-identity.js.map +1 -0
  174. package/dist/src/project-overrides.d.ts +57 -0
  175. package/dist/src/project-overrides.js +79 -0
  176. package/dist/src/project-overrides.js.map +1 -0
  177. package/dist/src/skills/builtin/setup-agentcore-memory/SKILL.md +158 -0
  178. package/dist/src/skills/loader.d.ts +1 -1
  179. package/dist/src/skills/loader.js +4 -1
  180. package/dist/src/skills/loader.js.map +1 -1
  181. package/dist/src/tools/background-bash.d.ts +21 -3
  182. package/dist/src/tools/background-bash.js +44 -8
  183. package/dist/src/tools/background-bash.js.map +1 -1
  184. package/dist/src/tools/file-editor-serial.d.ts +14 -0
  185. package/dist/src/tools/file-editor-serial.js +15 -0
  186. package/dist/src/tools/file-editor-serial.js.map +1 -1
  187. package/dist/src/tools/shell-env.d.ts +101 -0
  188. package/dist/src/tools/shell-env.js +173 -0
  189. package/dist/src/tools/shell-env.js.map +1 -0
  190. package/dist/src/trajectory/reader.d.ts +1 -1
  191. package/dist/src/trajectory/reader.js +23 -3
  192. package/dist/src/trajectory/reader.js.map +1 -1
  193. package/dist/src/trajectory/replay.js +23 -0
  194. package/dist/src/trajectory/replay.js.map +1 -1
  195. package/dist/src/trajectory/resume-recap.d.ts +11 -1
  196. package/dist/src/trajectory/resume-recap.js +10 -1
  197. package/dist/src/trajectory/resume-recap.js.map +1 -1
  198. package/dist/src/trajectory/rewind-history.d.ts +8 -0
  199. package/dist/src/trajectory/rewind-history.js +81 -0
  200. package/dist/src/trajectory/rewind-history.js.map +1 -0
  201. package/dist/src/trajectory/writer.d.ts +44 -3
  202. package/dist/src/trajectory/writer.js +80 -14
  203. package/dist/src/trajectory/writer.js.map +1 -1
  204. package/dist/src/tui/App.d.ts +8 -1
  205. package/dist/src/tui/App.js +453 -75
  206. package/dist/src/tui/App.js.map +1 -1
  207. package/dist/src/tui/InputBox.d.ts +1 -1
  208. package/dist/src/tui/InputBox.js +1 -1
  209. package/dist/src/tui/MessageList.js +1 -1
  210. package/dist/src/tui/MessageList.js.map +1 -1
  211. package/dist/src/tui/PermissionPrompt.js +5 -3
  212. package/dist/src/tui/PermissionPrompt.js.map +1 -1
  213. package/dist/src/tui/QueuedMessages.js +14 -8
  214. package/dist/src/tui/QueuedMessages.js.map +1 -1
  215. package/dist/src/tui/ToolCallPanel.js +2 -2
  216. package/dist/src/tui/ToolCallPanel.js.map +1 -1
  217. package/dist/src/tui/WorkspaceTrustPrompt.d.ts +8 -0
  218. package/dist/src/tui/WorkspaceTrustPrompt.js +37 -0
  219. package/dist/src/tui/WorkspaceTrustPrompt.js.map +1 -0
  220. package/dist/src/tui/draft-stash.d.ts +25 -0
  221. package/dist/src/tui/draft-stash.js +49 -0
  222. package/dist/src/tui/draft-stash.js.map +1 -0
  223. package/dist/src/tui/frame-budget.d.ts +2 -2
  224. package/dist/src/tui/frame-budget.js +3 -3
  225. package/dist/src/tui/frame-budget.js.map +1 -1
  226. package/dist/src/tui/help-format.d.ts +2 -2
  227. package/dist/src/tui/help-format.js +3 -3
  228. package/dist/src/tui/help-format.js.map +1 -1
  229. package/dist/src/tui/instructions-format.d.ts +14 -0
  230. package/dist/src/tui/instructions-format.js +24 -0
  231. package/dist/src/tui/instructions-format.js.map +1 -0
  232. package/dist/src/tui/mcp-format.d.ts +9 -0
  233. package/dist/src/tui/mcp-format.js +5 -3
  234. package/dist/src/tui/mcp-format.js.map +1 -1
  235. package/dist/src/tui/permission-rule-preview.d.ts +23 -0
  236. package/dist/src/tui/permission-rule-preview.js +38 -0
  237. package/dist/src/tui/permission-rule-preview.js.map +1 -0
  238. package/dist/src/tui/prompt-editor.d.ts +12 -0
  239. package/dist/src/tui/prompt-editor.js +38 -28
  240. package/dist/src/tui/prompt-editor.js.map +1 -1
  241. package/dist/src/tui/prompt-history-search.js +3 -2
  242. package/dist/src/tui/prompt-history-search.js.map +1 -1
  243. package/dist/src/tui/prompt-queue.d.ts +4 -2
  244. package/dist/src/tui/prompt-queue.js +22 -5
  245. package/dist/src/tui/prompt-queue.js.map +1 -1
  246. package/dist/src/tui/rewind-search.js +4 -3
  247. package/dist/src/tui/rewind-search.js.map +1 -1
  248. package/dist/src/tui/search-preview.d.ts +2 -0
  249. package/dist/src/tui/search-preview.js +9 -0
  250. package/dist/src/tui/search-preview.js.map +1 -0
  251. package/dist/src/tui/shell-command.js +4 -1
  252. package/dist/src/tui/shell-command.js.map +1 -1
  253. package/dist/src/tui/spinner.d.ts +1 -0
  254. package/dist/src/tui/spinner.js +6 -0
  255. package/dist/src/tui/spinner.js.map +1 -0
  256. package/dist/src/tui/status-format.d.ts +24 -0
  257. package/dist/src/tui/status-format.js +62 -2
  258. package/dist/src/tui/status-format.js.map +1 -1
  259. package/dist/src/tui/subagent-format.js +6 -0
  260. package/dist/src/tui/subagent-format.js.map +1 -1
  261. package/dist/src/tui/tangent.d.ts +122 -0
  262. package/dist/src/tui/tangent.js +153 -0
  263. package/dist/src/tui/tangent.js.map +1 -0
  264. package/dist/src/tui/task-format.d.ts +5 -0
  265. package/dist/src/tui/task-format.js +15 -0
  266. package/dist/src/tui/task-format.js.map +1 -1
  267. package/dist/src/tui/trust-format.d.ts +31 -0
  268. package/dist/src/tui/trust-format.js +102 -0
  269. package/dist/src/tui/trust-format.js.map +1 -0
  270. package/dist/src/tui/turn-state.d.ts +13 -1
  271. package/dist/src/tui/turn-state.js +13 -0
  272. package/dist/src/tui/turn-state.js.map +1 -1
  273. package/package.json +4 -3
@@ -1,14 +1,29 @@
1
1
  /**
2
- * Project instructions preloaded from AGENTS.md.
2
+ * Project instructions preloaded from AGENTS.md — or, when there is none, CLAUDE.md.
3
3
  *
4
- * Only the run directory's own `AGENTS.md` is read: no walking up to parent
5
- * directories and no merging of several files, so what reaches the model is
6
- * exactly the file sitting next to the repository the user is working in.
4
+ * Only the run directory's own file is read: no walking up to parent directories
5
+ * and no merging of several files, so what reaches the model is exactly one file
6
+ * sitting next to the repository the user is working in. There is exactly one
7
+ * fallback name and it is fixed: `CLAUDE.md` (Claude Code's convention) is tried
8
+ * only when `AGENTS.md` does not exist at all. An `AGENTS.md` that is present but
9
+ * unusable decides the outcome by itself; when both files exist, `CLAUDE.md` is
10
+ * never opened.
7
11
  */
8
12
  import { readFile } from 'node:fs/promises';
9
13
  import path from 'node:path';
10
14
  import { StringDecoder } from 'node:string_decoder';
11
15
  export const AGENTS_FILENAME = 'AGENTS.md';
16
+ /** Read only when {@link AGENTS_FILENAME} does not exist. */
17
+ export const CLAUDE_FILENAME = 'CLAUDE.md';
18
+ /** Lookup order — the first file that exists decides, whether or not it can be read. */
19
+ const INSTRUCTIONS_FILENAMES = [AGENTS_FILENAME, CLAUDE_FILENAME];
20
+ /**
21
+ * One fixed line for the CLAUDE.md case only. Claude Code expands `@path` lines
22
+ * into the referenced files; darwin does not, so without this the model would
23
+ * take an import line for content it has already been given.
24
+ */
25
+ export const CLAUDE_IMPORT_NOTICE = `(Loaded from ${CLAUDE_FILENAME} because there is no ${AGENTS_FILENAME}. ` +
26
+ '`@path` import lines are not expanded by darwin: they are literal text here, not loaded content.)';
12
27
  /**
13
28
  * Instructions past this size are truncated rather than sent whole.
14
29
  *
@@ -18,7 +33,8 @@ export const AGENTS_FILENAME = 'AGENTS.md';
18
33
  */
19
34
  export const MAX_INSTRUCTIONS_BYTES = 32 * 1024;
20
35
  /**
21
- * Reads `<projectRoot>/AGENTS.md`.
36
+ * Reads `<projectRoot>/AGENTS.md`, or `<projectRoot>/CLAUDE.md` when the former
37
+ * does not exist.
22
38
  *
23
39
  * A broken file never blocks startup — the agent works without project
24
40
  * instructions — but the two ways of ending up without them are not the same. No
@@ -27,34 +43,46 @@ export const MAX_INSTRUCTIONS_BYTES = 32 * 1024;
27
43
  * user has rules they believe are in effect and nothing on screen contradicts
28
44
  * that. Same isolation rule as a broken skill directory: skip it, say why.
29
45
  *
46
+ * Only a truly missing `AGENTS.md` moves on to `CLAUDE.md`: an unreadable one is
47
+ * reported as such and never falls through, because the file the user wrote
48
+ * rules into is the one that must decide. Whichever file is found first is the
49
+ * only one opened.
50
+ *
30
51
  * An empty or whitespace-only file is silently skipped: injecting the delimiters
31
52
  * with nothing between them would only point the model at emptiness.
32
53
  */
33
54
  export async function loadProjectInstructions(projectRoot) {
34
- const filePath = path.join(projectRoot, AGENTS_FILENAME);
35
- let raw;
36
- try {
37
- raw = await readFile(filePath);
38
- }
39
- catch (error) {
40
- return { instructions: undefined, problem: isMissingFile(error) ? undefined : describe(error) };
55
+ for (const filename of INSTRUCTIONS_FILENAMES) {
56
+ const filePath = path.join(projectRoot, filename);
57
+ let raw;
58
+ try {
59
+ raw = await readFile(filePath);
60
+ }
61
+ catch (error) {
62
+ if (isMissingFile(error))
63
+ continue;
64
+ return { instructions: undefined, problem: describe(error), problemFile: filename };
65
+ }
66
+ const bytes = raw.byteLength;
67
+ const truncated = bytes > MAX_INSTRUCTIONS_BYTES;
68
+ const text = truncated
69
+ ? clipToLastLine(raw.subarray(0, MAX_INSTRUCTIONS_BYTES))
70
+ : raw.toString('utf8');
71
+ if (text.trim() === '')
72
+ return { instructions: undefined, problem: undefined, problemFile: undefined };
73
+ return {
74
+ instructions: {
75
+ filename,
76
+ path: filePath,
77
+ bytes,
78
+ truncated,
79
+ fragment: renderFragment(text.trimEnd(), truncated, filename),
80
+ },
81
+ problem: undefined,
82
+ problemFile: undefined,
83
+ };
41
84
  }
42
- const bytes = raw.byteLength;
43
- const truncated = bytes > MAX_INSTRUCTIONS_BYTES;
44
- const text = truncated
45
- ? clipToLastLine(raw.subarray(0, MAX_INSTRUCTIONS_BYTES))
46
- : raw.toString('utf8');
47
- if (text.trim() === '')
48
- return { instructions: undefined, problem: undefined };
49
- return {
50
- instructions: {
51
- path: filePath,
52
- bytes,
53
- truncated,
54
- fragment: renderFragment(text.trimEnd(), truncated),
55
- },
56
- problem: undefined,
57
- };
85
+ return { instructions: undefined, problem: undefined, problemFile: undefined };
58
86
  }
59
87
  /**
60
88
  * Places project instructions directly after the base prompt.
@@ -71,10 +99,11 @@ export function composeSystemPrompt(basePrompt, instructions) {
71
99
  return `${basePrompt}\n\n${instructions.fragment}`;
72
100
  }
73
101
  /**
74
- * True when the file is simply not there.
102
+ * True when the file is simply not there — the only case that moves on to the
103
+ * fallback name.
75
104
  *
76
105
  * `ENOTDIR` counts: a path component that is a file rather than a directory means
77
- * there is no AGENTS.md at that location either.
106
+ * there is no such file at that location either.
78
107
  */
79
108
  function isMissingFile(error) {
80
109
  const code = typeof error === 'object' && error !== null ? error.code : undefined;
@@ -100,14 +129,18 @@ function clipToLastLine(slice) {
100
129
  /**
101
130
  * Wraps the text in a labelled block. The source attribute matters: the model has
102
131
  * to be able to tell these instructions came from the project's own file rather
103
- * than from darwin itself, since only one of the two is something the user can edit.
132
+ * than from darwin itself, since only one of the two is something the user can edit
133
+ * — and which file, since a CLAUDE.md may lean on Claude Code features (its
134
+ * `@path` imports) that darwin does not provide; {@link CLAUDE_IMPORT_NOTICE} says
135
+ * so once, in that case only.
104
136
  */
105
- function renderFragment(text, truncated) {
137
+ function renderFragment(text, truncated, filename) {
106
138
  const attributes = truncated
107
- ? `source="${AGENTS_FILENAME}" truncated="true"`
108
- : `source="${AGENTS_FILENAME}"`;
139
+ ? `source="${filename}" truncated="true"`
140
+ : `source="${filename}"`;
109
141
  return [
110
142
  `<project-instructions ${attributes}>`,
143
+ ...(filename === CLAUDE_FILENAME ? [CLAUDE_IMPORT_NOTICE] : []),
111
144
  text,
112
145
  ...(truncated
113
146
  ? [`(This file is larger than ${MAX_INSTRUCTIONS_BYTES / 1024} KB and was cut off here.)`]
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../src/agent/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,CAAC;AA0BhD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,WAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAEzD,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IAClG,CAAC;IAED,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC;IAC7B,MAAM,SAAS,GAAG,KAAK,GAAG,sBAAsB,CAAC;IACjD,MAAM,IAAI,GAAG,SAAS;QACpB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,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yBAAyB,UAAU,GAAG;QACtC,GAAG,CAAC,QAAQ,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,IAAI;QACJ,GAAG,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,6BAA6B,sBAAsB,GAAG,IAAI,4BAA4B,CAAC;YAC1F,CAAC,CAAC,EAAE,CAAC;QACP,yBAAyB;KAC1B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -107,8 +107,21 @@ export function bedrockCacheConfig(plan) {
107
107
  return {
108
108
  strategy: 'auto',
109
109
  // One TTL everywhere: Bedrock requires TTLs to be non-increasing across
110
- // tools → system → messages, and equal values satisfy that trivially.
111
- ...(plan.ttl !== undefined && { toolsTTL: plan.ttl, messagesTTL: plan.ttl }),
110
+ // tools → system → messages, and equal values satisfy that trivially. The
111
+ // shared `ttl` matters as much as the per-section values: whenever a request
112
+ // carries a *string* system prompt — the SDK summarizer behind `/compact`,
113
+ // recipe children — the SDK auto-injects a system cache point of its own and
114
+ // fills its TTL from `systemPromptTTL`/`ttl`. Without these, that point stays
115
+ // at Bedrock's `5m` default between a `1h` tools point and a `1h` messages
116
+ // point, and Bedrock rejects the request (`a ttl='1h' cache_control block
117
+ // must not come after a ttl='5m' cache_control block`). Darwin's hand-placed
118
+ // system point already carries the TTL, so it is left as written.
119
+ ...(plan.ttl !== undefined && {
120
+ ttl: plan.ttl,
121
+ toolsTTL: plan.ttl,
122
+ systemPromptTTL: plan.ttl,
123
+ messagesTTL: plan.ttl,
124
+ }),
112
125
  };
113
126
  }
114
127
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-cache.js","sourceRoot":"","sources":["../../../src/agent/prompt-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAMjE;;;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AC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,GAAG,OAAO,0DAA0D,CAAC;AAC9E,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `stopReason: 'refusal'` — the model's safety classifiers declined the request.
2
+ * Refusal-class stop reasons — the provider or its classifiers declined the request.
3
3
  *
4
4
  * Claude Fable 5.1 (and the Mythos line) end such a turn *successfully* from the
5
5
  * SDK's point of view: the agent loop sees a non-`toolUse` stop and returns an
@@ -8,13 +8,50 @@
8
8
  * reported as `succeeded`. The drivers and delegation tools ask here and state the
9
9
  * outcome; the loop itself is never touched (the SDK owns the stop, darwin only
10
10
  * names it).
11
+ *
12
+ * The stop-reason vocabulary differs per provider, so the class is a fixed set of
13
+ * exactly three SDK words, not one provider's string (SRF-029 — a Bedrock session
14
+ * lost three turns to `contentFiltered` while only `refusal` was recognised):
15
+ *
16
+ * - `refusal` — the direct Anthropic provider (`models/anthropic.js`) passes the
17
+ * API's `stop_reason: "refusal"` through unchanged: the model's own classifiers
18
+ * blocked the response.
19
+ * - `contentFiltered` — the Bedrock provider's `STOP_REASON_MAP` (`models/bedrock.js`)
20
+ * for Converse's `content_filtered`: the same classifier block, reached through
21
+ * Bedrock, which spells it differently.
22
+ * - `guardrailIntervened` — the same map's `guardrail_intervened`: a configured
23
+ * Bedrock Guardrail, not the model, stopped the turn. Kept distinguishable from the
24
+ * classifier block because the remedy differs (the guardrail is the account's).
25
+ *
26
+ * Nothing else qualifies. `maxTokens`, `stopSequence`, `endTurn` and `toolUse` are
27
+ * the model finishing on its own terms; `cancelled`, `interrupt` and `checkpoint`
28
+ * are darwin's or the SDK's own stops. Every user-facing string names the reason
29
+ * actually received, so a reader can tell the three apart.
11
30
  */
12
- /** The SDK's stop reason for a model-side refusal, on every provider. */
13
- export declare const REFUSAL_STOP_REASON = "refusal";
31
+ /** The SDK stop reasons that mean "the provider or its classifiers declined". */
32
+ export declare const REFUSAL_STOP_REASONS: readonly ["refusal", "contentFiltered", "guardrailIntervened"];
33
+ export type RefusalStopReason = (typeof REFUSAL_STOP_REASONS)[number];
34
+ export declare function isRefusalStop(stopReason: string): stopReason is RefusalStopReason;
14
35
  /** One bounded user-facing line for the transcript or stderr. */
15
- export declare const REFUSAL_NOTICE = "model declined this request (stop_reason: refusal) \u2014 rephrase it or start a new turn";
36
+ export declare function refusalNotice(stopReason: string): string;
37
+ /**
38
+ * The TUI's variant of {@link refusalNotice}: the same line plus the remedy only the
39
+ * TUI can offer (SRF-030). A refused turn still appended the prompt and the declined
40
+ * reply to the SDK conversation, and `AgentRuntime.send` now catalogues its pre-prompt
41
+ * checkpoint, so `/rewind` to that prompt is the one user-chosen way to cut the
42
+ * exchange out before rephrasing — darwin never removes it on its own. Headless
43
+ * drivers have no `/rewind` and keep printing the base line.
44
+ */
45
+ export declare function refusalNoticeWithRewind(stopReason: string): string;
16
46
  /** The error a headless run ends with when a refusal left no reply at all. */
17
- export declare const REFUSAL_EMPTY_REPLY_ERROR = "The model declined this request (stop_reason: refusal) and produced no reply.";
47
+ export declare function refusalEmptyReplyError(stopReason: string): string;
18
48
  /** The fixed note a refused child's failure carries back to the parent. */
19
- export declare const CHILD_REFUSAL_ERROR = "child model declined the delegated task (stop_reason: refusal)";
20
- export declare function isRefusalStop(stopReason: string): boolean;
49
+ export declare function childRefusalError(stopReason: string): string;
50
+ /**
51
+ * The one line replay (and therefore `/export` and the resume recap) prints in the
52
+ * answer slot of a refusal-class turn, after whatever partial text it streamed. The
53
+ * live session showed {@link refusalNotice} instead — its remedy is advice for the
54
+ * moment, meaningless in a transcript read later — so the transcript states only
55
+ * the fact and the reason, parenthesised because it is not the model's text.
56
+ */
57
+ export declare function refusalTranscriptLine(stopReason: string): string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `stopReason: 'refusal'` — the model's safety classifiers declined the request.
2
+ * Refusal-class stop reasons — the provider or its classifiers declined the request.
3
3
  *
4
4
  * Claude Fable 5.1 (and the Mythos line) end such a turn *successfully* from the
5
5
  * SDK's point of view: the agent loop sees a non-`toolUse` stop and returns an
@@ -8,16 +8,62 @@
8
8
  * reported as `succeeded`. The drivers and delegation tools ask here and state the
9
9
  * outcome; the loop itself is never touched (the SDK owns the stop, darwin only
10
10
  * names it).
11
+ *
12
+ * The stop-reason vocabulary differs per provider, so the class is a fixed set of
13
+ * exactly three SDK words, not one provider's string (SRF-029 — a Bedrock session
14
+ * lost three turns to `contentFiltered` while only `refusal` was recognised):
15
+ *
16
+ * - `refusal` — the direct Anthropic provider (`models/anthropic.js`) passes the
17
+ * API's `stop_reason: "refusal"` through unchanged: the model's own classifiers
18
+ * blocked the response.
19
+ * - `contentFiltered` — the Bedrock provider's `STOP_REASON_MAP` (`models/bedrock.js`)
20
+ * for Converse's `content_filtered`: the same classifier block, reached through
21
+ * Bedrock, which spells it differently.
22
+ * - `guardrailIntervened` — the same map's `guardrail_intervened`: a configured
23
+ * Bedrock Guardrail, not the model, stopped the turn. Kept distinguishable from the
24
+ * classifier block because the remedy differs (the guardrail is the account's).
25
+ *
26
+ * Nothing else qualifies. `maxTokens`, `stopSequence`, `endTurn` and `toolUse` are
27
+ * the model finishing on its own terms; `cancelled`, `interrupt` and `checkpoint`
28
+ * are darwin's or the SDK's own stops. Every user-facing string names the reason
29
+ * actually received, so a reader can tell the three apart.
11
30
  */
12
- /** The SDK's stop reason for a model-side refusal, on every provider. */
13
- export const REFUSAL_STOP_REASON = 'refusal';
31
+ /** The SDK stop reasons that mean "the provider or its classifiers declined". */
32
+ export const REFUSAL_STOP_REASONS = Object.freeze(['refusal', 'contentFiltered', 'guardrailIntervened']);
33
+ export function isRefusalStop(stopReason) {
34
+ return REFUSAL_STOP_REASONS.includes(stopReason);
35
+ }
14
36
  /** One bounded user-facing line for the transcript or stderr. */
15
- export const REFUSAL_NOTICE = 'model declined this request (stop_reason: refusal) — rephrase it or start a new turn';
37
+ export function refusalNotice(stopReason) {
38
+ return `model declined this request (stop_reason: ${stopReason}) — rephrase it or start a new turn`;
39
+ }
40
+ /**
41
+ * The TUI's variant of {@link refusalNotice}: the same line plus the remedy only the
42
+ * TUI can offer (SRF-030). A refused turn still appended the prompt and the declined
43
+ * reply to the SDK conversation, and `AgentRuntime.send` now catalogues its pre-prompt
44
+ * checkpoint, so `/rewind` to that prompt is the one user-chosen way to cut the
45
+ * exchange out before rephrasing — darwin never removes it on its own. Headless
46
+ * drivers have no `/rewind` and keep printing the base line.
47
+ */
48
+ export function refusalNoticeWithRewind(stopReason) {
49
+ return `${refusalNotice(stopReason)} — the declined reply stays in the conversation; /rewind to this prompt removes it before you rephrase`;
50
+ }
16
51
  /** The error a headless run ends with when a refusal left no reply at all. */
17
- export const REFUSAL_EMPTY_REPLY_ERROR = 'The model declined this request (stop_reason: refusal) and produced no reply.';
52
+ export function refusalEmptyReplyError(stopReason) {
53
+ return `The model declined this request (stop_reason: ${stopReason}) and produced no reply.`;
54
+ }
18
55
  /** The fixed note a refused child's failure carries back to the parent. */
19
- export const CHILD_REFUSAL_ERROR = 'child model declined the delegated task (stop_reason: refusal)';
20
- export function isRefusalStop(stopReason) {
21
- return stopReason === REFUSAL_STOP_REASON;
56
+ export function childRefusalError(stopReason) {
57
+ return `child model declined the delegated task (stop_reason: ${stopReason})`;
58
+ }
59
+ /**
60
+ * The one line replay (and therefore `/export` and the resume recap) prints in the
61
+ * answer slot of a refusal-class turn, after whatever partial text it streamed. The
62
+ * live session showed {@link refusalNotice} instead — its remedy is advice for the
63
+ * moment, meaningless in a transcript read later — so the transcript states only
64
+ * the fact and the reason, parenthesised because it is not the model's text.
65
+ */
66
+ export function refusalTranscriptLine(stopReason) {
67
+ return `(model declined this request — stop_reason: ${stopReason})`;
22
68
  }
23
69
  //# sourceMappingURL=refusal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"refusal.js","sourceRoot":"","sources":["../../../src/agent/refusal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,yEAAyE;AACzE,MAAM,CAAC,MA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;AACtE,CAAC"}
@@ -6,6 +6,8 @@ export interface RewindCheckpoint {
6
6
  readonly snapshotId: string;
7
7
  readonly prompt: string;
8
8
  readonly completedAt: string;
9
+ /** Optional display-only trajectory boundary; the SDK snapshot remains authoritative. */
10
+ readonly trajectoryTurn?: number;
9
11
  }
10
12
  export interface RewindCatalogue {
11
13
  readonly checkpoints: readonly RewindCheckpoint[];
@@ -53,7 +53,9 @@ export async function readRewindCatalogue(projectRoot, sessionId) {
53
53
  if (!isRecord(value) || typeof value.snapshotId !== 'string' || typeof value.prompt !== 'string' ||
54
54
  typeof value.completedAt !== 'string' || [...value.snapshotId].length === 0 ||
55
55
  [...value.snapshotId].length > MAX_SNAPSHOT_ID_CODE_POINTS || !rewindPromptEligible(value.prompt) ||
56
- !Number.isFinite(Date.parse(value.completedAt)) || ids.has(value.snapshotId)) {
56
+ !Number.isFinite(Date.parse(value.completedAt)) || ids.has(value.snapshotId) ||
57
+ (value.trajectoryTurn !== undefined &&
58
+ (!Number.isSafeInteger(value.trajectoryTurn) || value.trajectoryTurn < 1))) {
57
59
  return { checkpoints: [], capped: false, problem: 'rewind checkpoint catalogue has an invalid entry' };
58
60
  }
59
61
  ids.add(value.snapshotId);
@@ -61,6 +63,7 @@ export async function readRewindCatalogue(projectRoot, sessionId) {
61
63
  snapshotId: value.snapshotId,
62
64
  prompt: value.prompt,
63
65
  completedAt: value.completedAt,
66
+ ...(value.trajectoryTurn === undefined ? {} : { trajectoryTurn: value.trajectoryTurn }),
64
67
  });
65
68
  }
66
69
  return { checkpoints, capped: checkpoints.length >= MAX_REWIND_CHECKPOINTS };
@@ -1 +1 @@
1
- {"version":3,"file":"rewind.js","sourceRoot":"","sources":["../../../src/agent/rewind.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,IAAI,MAAM,WAAW,CA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AAK,CAAC,EAAE,EAAE,CAAC;IAC/H,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,sBAAsB,EAAE,CAAC;AAC/E,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,uBAAuB,CAAC,SAA0B;IAChE,OAAO,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AACpD,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -13,16 +13,18 @@ import { type McpLoadResult, type McpServerStatus } from '../mcp/registry.js';
13
13
  import { type ExpandedSkillCommand } from '../skills/plugin.js';
14
14
  import { type MemoryCommandResult } from '../memory/command.js';
15
15
  import { MemoryToolController } from '../memory/controller.js';
16
+ import { CloudMemory } from '../agentcore/controller.js';
16
17
  import type { MemoryStatus } from '../memory/store.js';
17
18
  import type { ContextCompactedEntry, TaskNotificationFields } from '../trajectory/record.js';
18
19
  import { type RecorderOptions, type TrajectoryStatus } from '../trajectory/writer.js';
19
20
  import { type ContextBreakdown } from './context-breakdown.js';
20
- import { type ProjectInstructionsSummary } from './instructions.js';
21
+ import { type InstructionsFilename, type ProjectInstructionsSummary } from './instructions.js';
21
22
  import { type AllowRuleEntry, type ApprovalMode, type PermissionBridge, type PermissionModeChange } from './permission.js';
22
23
  import { type PromptCachePlan } from './prompt-cache.js';
23
24
  import { type SessionSelector } from './session.js';
24
25
  import { type SystemPromptSource } from './system-prompt.js';
25
26
  import { type ThinkingEffort, type ThinkingPlan } from './thinking.js';
27
+ import { type WorkspaceTrust, type WorkspaceTrustReport } from './workspace-trust.js';
26
28
  import { type RewindCatalogue, type RewindCheckpoint } from './rewind.js';
27
29
  import { type UsageTotals } from './usage.js';
28
30
  import { type SessionCallStats } from './call-stats.js';
@@ -62,6 +64,18 @@ export interface RuntimeOptions {
62
64
  backgroundCompletionWakes?: boolean;
63
65
  /** Refuses the next parent-Agent SDK model call after this many in the process. */
64
66
  maxModelCalls?: number;
67
+ /**
68
+ * The workspace-trust decision the driver resolved *before* asking for a runtime
69
+ * (SER-090, `workspace-trust.ts`). Anything but `trusted` holds the repository-
70
+ * supplied layers back: `loadProjectPolicy` skips the project hook roots and the
71
+ * legacy `.darwin/config.json` rule fallback, `loadMcpClients` leaves the project MCP
72
+ * file unread — skipped, never an error — and the held items are reported on
73
+ * `info.workspaceTrust`. Absent means the caller vouches for the checkout (the
74
+ * pre-trust behaviour; programmatic embedding and the spike fixtures). The three
75
+ * drivers always pass it, and a `/clear` or `/rewind` successor inherits it with the
76
+ * rest of these options.
77
+ */
78
+ workspaceTrust?: WorkspaceTrust;
65
79
  /**
66
80
  * One driver-owned section appended to the base prompt, before project instructions.
67
81
  * Headless runs pass `HEADLESS_AUTONOMY_SECTION` (system-prompt.ts); the interactive TUI passes
@@ -147,6 +161,12 @@ export type ExpandedSlashCommand = ({
147
161
  } & ExpandedCustomCommand) | {
148
162
  kind: 'workflow';
149
163
  message: string;
164
+ } | {
165
+ kind: 'init';
166
+ message: string;
167
+ } | {
168
+ kind: 'review';
169
+ message: string;
150
170
  };
151
171
  /** Estimated size of the next request's context, plus the model's window. */
152
172
  export interface ContextEstimate {
@@ -181,6 +201,14 @@ export interface RuntimeInfo {
181
201
  permissionMode: ApprovalMode;
182
202
  sessionId: string;
183
203
  resumed: boolean;
204
+ /**
205
+ * SER-091: one bounded sentence about this session's lease when the acquisition was
206
+ * not the ordinary uncontested one — a stale lease taken over, or a bare `--resume`
207
+ * that found its session open in another live process and started fresh. Absent
208
+ * otherwise; the drivers state it once in the transcript/stderr and nothing else
209
+ * reads it.
210
+ */
211
+ leaseNotice?: string;
184
212
  /** Names of skills discovered under `.darwin/skills/`. */
185
213
  skillNames: string[];
186
214
  /** Skill directories that were skipped, with the reason. */
@@ -202,10 +230,12 @@ export interface RuntimeInfo {
202
230
  file: string;
203
231
  reason: string;
204
232
  }[];
205
- /** AGENTS.md preloaded from the run directory, or undefined when there is none. */
233
+ /** AGENTS.md (or the CLAUDE.md fallback) preloaded from the run directory, or undefined when there is none. */
206
234
  projectInstructions: ProjectInstructionsSummary | undefined;
207
- /** Why a present AGENTS.md was skipped; undefined when there is no such file. */
235
+ /** Why a present instructions file was skipped; undefined when there is no such file. */
208
236
  projectInstructionsProblem: string | undefined;
237
+ /** Which file `projectInstructionsProblem` is about; undefined exactly when it is. */
238
+ projectInstructionsProblemFile: InstructionsFilename | undefined;
209
239
  /** Where the base system prompt came from: built-in, config, or override file. */
210
240
  systemPromptSource: SystemPromptSource;
211
241
  /** Path of the system prompt override file, when one is in effect. */
@@ -253,6 +283,24 @@ export interface RuntimeInfo {
253
283
  directory: string;
254
284
  shadowed: string[];
255
285
  }[];
286
+ /**
287
+ * What model-spawned shells were denied at startup (SER-082): the sorted names
288
+ * withheld from the persistent shell and background jobs, plus the configured
289
+ * passthrough entries. Names only — no value is ever stored or shown. Read by the
290
+ * startup notice and `/status`; the map itself lives in the bash tools.
291
+ */
292
+ shellEnv: {
293
+ withheld: string[];
294
+ passthrough: string[];
295
+ };
296
+ /**
297
+ * The workspace-trust decision this runtime applied (SER-090) and exactly what it
298
+ * held back when the project is not trusted: hook files never loaded, MCP servers
299
+ * never spawned, the legacy rule fallback never granted. Empty held lists for a
300
+ * trusted project or an empty inventory. Read by the transcript notice, `/status`,
301
+ * `/mcp` and the headless `trust:` line / `run.started.trust`.
302
+ */
303
+ workspaceTrust: WorkspaceTrustReport;
256
304
  mcpIgnoredConfigPath: string | undefined;
257
305
  /** Number of MCP servers configured (some may have failed to connect). */
258
306
  mcpServerCount: number;
@@ -303,6 +351,13 @@ export declare class AgentRuntime {
303
351
  private readonly diagnosticsLog;
304
352
  /** Undefined only when effective config disables derived project context. */
305
353
  private readonly memoryController;
354
+ private readonly cloudMemory;
355
+ /**
356
+ * This process's hold on `info.sessionId` (SER-091). Released by {@link shutdown}
357
+ * and by {@link retire} — the `/clear` and `/rewind` successor takes its own lease
358
+ * on its own id through `create()` — and only while the file still names this pid.
359
+ */
360
+ private readonly lease;
306
361
  readonly info: RuntimeInfo;
307
362
  /**
308
363
  * What this runtime was created with, so {@link startNewSession} can assemble its
@@ -391,7 +446,7 @@ export declare class AgentRuntime {
391
446
  * Releases startup-owned observers and external clients when construction fails.
392
447
  * Successful creation transfers the same resources to `shutdown()` instead.
393
448
  */
394
- static unwindCreate(diagnosticsLog: DiagnosticsLog | undefined, mcpClients?: readonly McpClient[], backgroundBash?: BackgroundBashManager, memoryController?: MemoryToolController, lifecycleHooks?: LifecycleHookRunner, codexHooks?: CodexHookRunner): Promise<void>;
449
+ static unwindCreate(diagnosticsLog: DiagnosticsLog | undefined, mcpClients?: readonly McpClient[], backgroundBash?: BackgroundBashManager, memoryController?: MemoryToolController, lifecycleHooks?: LifecycleHookRunner, codexHooks?: CodexHookRunner, cloudMemory?: CloudMemory): Promise<void>;
395
450
  static create(options: RuntimeOptions): Promise<AgentRuntime>;
396
451
  /**
397
452
  * Runs one turn, yielding SDK stream events untouched so callers can render
@@ -486,10 +541,13 @@ export declare class AgentRuntime {
486
541
  get diagnosticsStatus(): DiagnosticsStatus | undefined;
487
542
  /** Best-effort status of enabled derived project memory. */
488
543
  get memoryStatus(): MemoryStatus | undefined;
489
- /**
490
- * Runs the user-only local `/memory` command and refreshes the verified Darwin-owned
491
- * prompt block before a successful mutation returns. No Agent invocation is made.
492
- */
544
+ /** Cloud status is a projection, never an implicit retrieval. */
545
+ get cloudMemoryStatus(): string;
546
+ private checkCloudPreparation;
547
+ refreshCloudPolicy(): Promise<void>;
548
+ private prepareCloudPreferences;
549
+ manageCloudMemory(input: string): Promise<string>;
550
+ private applyCloudPreferences;
493
551
  manageMemory(input: string): Promise<MemoryCommandResult>;
494
552
  /**
495
553
  * Replaces old conversation history with rolling summaries, keeping the recent
@@ -554,6 +612,13 @@ export declare class AgentRuntime {
554
612
  * of swallowing: the caller reports it to the user.
555
613
  */
556
614
  saveAllowRule(rule: string): Promise<void>;
615
+ /**
616
+ * The `loadProjectPolicy` layer option this runtime was created with (SER-090), so
617
+ * the two rule writers below promote legacy rules only from a layer that was in
618
+ * force — an untrusted project's committed `.darwin/config.json` never reaches the
619
+ * user-owned file through an "always allow" answer.
620
+ */
621
+ private projectLayerOptions;
557
622
  /**
558
623
  * The live allow-rules with their provenance — config-loaded vs granted this
559
624
  * session — for the `/permissions` report. Read live from the gate, like
@@ -787,6 +852,9 @@ export declare class AgentRuntime {
787
852
  get sessionUsage(): UsageTotals;
788
853
  /** Current-process background tasks, without creating an agent tool call. */
789
854
  listBackgroundTasks(): Promise<BackgroundTaskStatus[]>;
855
+ /** Live in-memory activity for the TUI; no log reads or tool invocation. */
856
+ get runningBackgroundTaskCount(): number;
857
+ subscribeToBackgroundTaskActivity(listener: () => void): () => void;
790
858
  /** Publishes future terminal task snapshots until the returned closure is called. */
791
859
  subscribeToBackgroundTasks(listener: BackgroundTaskListener): () => void;
792
860
  /**
@@ -884,8 +952,8 @@ export declare class AgentRuntime {
884
952
  * the user the conversation they just set aside. The successor claims the pointer on
885
953
  * its first finished turn, through the ordinary path.
886
954
  *
887
- * If assembling the successor fails, this runtime stays fully usable: nothing it owns
888
- * has been released yet, and the diagnostics tap it installed at startup is put back
955
+ * If assembling the successor fails, conversation/tools stay usable; predecessor auto
956
+ * uploads remain conservatively stopped (cloud status states it). The diagnostics tap is put back
889
957
  * (the failed successor's unwind clears the process-global sink).
890
958
  *
891
959
  * Refused while a background delegation is tracked (SER-070): `retire()` would cancel
@@ -919,10 +987,15 @@ export declare class AgentRuntime {
919
987
  private captureRewindCheckpoint;
920
988
  /**
921
989
  * Expands a built-in prompt command, a skill, or a project command into the
922
- * prompt sent to the model. `/workflow` is checked first: built-in
990
+ * prompt sent to the model. `/workflow`, `/init` and `/review` come first: built-in
923
991
  * reservation precedes skills and custom commands, so no extension can
924
- * shadow it. Its bare form returns null — the drivers own that local usage
925
- * notice, and the runtime never fabricates a turn. Skills are checked before
992
+ * shadow them. Bare `/workflow` returns null — the drivers own that local usage
993
+ * notice, and the runtime never fabricates a turn — while bare `/init` is the
994
+ * trigger itself, as is bare `/review`. `/review` is guidance only, with no mode
995
+ * change or executor. `/init` decides create-versus-improve from the instructions
996
+ * summary this runtime captured at startup (the header's own data), never from
997
+ * a fresh filesystem read, so TUI, dev-repl and both headless drivers get the
998
+ * same branch through this one seam. Skills are checked before
926
999
  * custom commands as a defensive backstop to the loader's collision
927
1000
  * filtering. Unknown slash input remains ordinary user input.
928
1001
  */