@cjhyy/code-shell-core 0.6.0-rc.9 → 0.7.0

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 (193) hide show
  1. package/THIRD_PARTY_NOTICES.md +206 -0
  2. package/dist/automation/scheduler.d.ts +13 -7
  3. package/dist/automation/scheduler.js +116 -37
  4. package/dist/capability-control/service.d.ts +2 -0
  5. package/dist/capability-control/service.js +4 -2
  6. package/dist/cc-orchestrator/agent-adapter.d.ts +4 -0
  7. package/dist/cc-orchestrator/agent-adapter.js +11 -1
  8. package/dist/cc-orchestrator/codex-session-history.d.ts +14 -1
  9. package/dist/cc-orchestrator/codex-session-history.js +65 -5
  10. package/dist/cc-orchestrator/cwd-normalize.d.ts +2 -0
  11. package/dist/cc-orchestrator/cwd-normalize.js +19 -0
  12. package/dist/cc-orchestrator/external-agent-bindings.d.ts +27 -0
  13. package/dist/cc-orchestrator/external-agent-bindings.js +150 -0
  14. package/dist/cc-orchestrator/external-agent-changes.js +22 -5
  15. package/dist/cc-orchestrator/external-agent-driver.d.ts +1 -0
  16. package/dist/cc-orchestrator/external-agent-driver.js +265 -50
  17. package/dist/cc-orchestrator/external-agent-session-store.d.ts +23 -0
  18. package/dist/cc-orchestrator/external-agent-session-store.js +146 -0
  19. package/dist/cc-orchestrator/session-history.d.ts +35 -0
  20. package/dist/cc-orchestrator/session-history.js +98 -15
  21. package/dist/cli/agent-server-stdio.js +9 -2
  22. package/dist/context/compaction.d.ts +8 -1
  23. package/dist/context/compaction.js +49 -4
  24. package/dist/context/manager.d.ts +16 -2
  25. package/dist/context/manager.js +103 -19
  26. package/dist/credentials/access.d.ts +57 -0
  27. package/dist/credentials/access.js +185 -0
  28. package/dist/credentials/index.d.ts +3 -1
  29. package/dist/credentials/index.js +2 -0
  30. package/dist/credentials/inject-credential-tool.d.ts +3 -1
  31. package/dist/credentials/inject-credential-tool.js +30 -11
  32. package/dist/credentials/oauth.d.ts +20 -0
  33. package/dist/credentials/oauth.js +114 -0
  34. package/dist/credentials/store.d.ts +1 -0
  35. package/dist/credentials/store.js +3 -1
  36. package/dist/credentials/types.d.ts +49 -3
  37. package/dist/credentials/use-credential-tool.d.ts +9 -1
  38. package/dist/credentials/use-credential-tool.js +58 -45
  39. package/dist/engine/engine.d.ts +23 -3
  40. package/dist/engine/engine.js +380 -255
  41. package/dist/engine/goal.d.ts +17 -0
  42. package/dist/engine/goal.js +16 -6
  43. package/dist/engine/image-policy.d.ts +6 -0
  44. package/dist/engine/image-policy.js +17 -6
  45. package/dist/engine/input-attachments.d.ts +13 -0
  46. package/dist/engine/input-attachments.js +398 -0
  47. package/dist/engine/model-facade.d.ts +5 -2
  48. package/dist/engine/model-facade.js +4 -4
  49. package/dist/engine/parse-task.d.ts +10 -0
  50. package/dist/engine/parse-task.js +5 -0
  51. package/dist/engine/run-image-input.d.ts +22 -0
  52. package/dist/engine/run-image-input.js +195 -0
  53. package/dist/engine/steer-queue.d.ts +3 -1
  54. package/dist/engine/steer-queue.js +10 -2
  55. package/dist/engine/streaming-tool-queue.d.ts +11 -7
  56. package/dist/engine/streaming-tool-queue.js +11 -7
  57. package/dist/engine/turn-loop.d.ts +37 -2
  58. package/dist/engine/turn-loop.js +228 -43
  59. package/dist/engine/types.d.ts +8 -0
  60. package/dist/git/worktree/crud.d.ts +69 -0
  61. package/dist/git/worktree/crud.js +206 -0
  62. package/dist/git/worktree/diff.d.ts +14 -0
  63. package/dist/git/worktree/diff.js +82 -0
  64. package/dist/git/worktree/git-exec.d.ts +7 -0
  65. package/dist/git/worktree/git-exec.js +51 -0
  66. package/dist/git/worktree/index.d.ts +5 -0
  67. package/dist/git/worktree/index.js +5 -0
  68. package/dist/git/worktree/query.d.ts +42 -0
  69. package/dist/git/worktree/query.js +121 -0
  70. package/dist/git/worktree/slug.d.ts +11 -0
  71. package/dist/git/worktree/slug.js +58 -0
  72. package/dist/git/worktree.d.ts +1 -84
  73. package/dist/git/worktree.js +5 -230
  74. package/dist/hooks/goal-stop-hook.d.ts +33 -1
  75. package/dist/hooks/goal-stop-hook.js +202 -34
  76. package/dist/index.d.ts +31 -28
  77. package/dist/index.js +27 -25
  78. package/dist/logging/logger.js +6 -6
  79. package/dist/logging/sanitize-messages.d.ts +10 -2
  80. package/dist/logging/sanitize-messages.js +21 -6
  81. package/dist/plugins/installer/checkUpdate.d.ts +4 -1
  82. package/dist/plugins/installer/checkUpdate.js +4 -2
  83. package/dist/plugins/installer/install.js +2 -0
  84. package/dist/plugins/installer/installFromSource.js +9 -1
  85. package/dist/plugins/installer/parseSource.d.ts +4 -1
  86. package/dist/plugins/installer/parseSource.js +28 -10
  87. package/dist/plugins/installer/sourcePath.d.ts +9 -0
  88. package/dist/plugins/installer/sourcePath.js +50 -0
  89. package/dist/plugins/installer/update.d.ts +4 -1
  90. package/dist/plugins/installer/update.js +5 -3
  91. package/dist/plugins/parseMarketplaceInput.d.ts +4 -1
  92. package/dist/plugins/parseMarketplaceInput.js +4 -3
  93. package/dist/plugins/pluginInstaller.js +24 -22
  94. package/dist/preset/index.d.ts +1 -0
  95. package/dist/preset/index.js +30 -13
  96. package/dist/prompt/sections/base.md +1 -1
  97. package/dist/protocol/chat-session-manager.d.ts +2 -0
  98. package/dist/protocol/chat-session-manager.js +38 -2
  99. package/dist/protocol/chat-session.d.ts +3 -0
  100. package/dist/protocol/chat-session.js +1 -0
  101. package/dist/protocol/client.d.ts +9 -4
  102. package/dist/protocol/client.js +18 -1
  103. package/dist/protocol/server.d.ts +30 -0
  104. package/dist/protocol/server.js +247 -47
  105. package/dist/protocol/types.d.ts +49 -0
  106. package/dist/protocol/types.js +6 -0
  107. package/dist/run/FileRunStore.js +10 -1
  108. package/dist/run/Heartbeat.js +12 -0
  109. package/dist/run/RunApprovalBackend.d.ts +3 -0
  110. package/dist/run/RunApprovalBackend.js +41 -6
  111. package/dist/run/RunLock.js +2 -0
  112. package/dist/run/RunManager.d.ts +2 -0
  113. package/dist/run/RunManager.js +64 -24
  114. package/dist/run/ids.d.ts +2 -0
  115. package/dist/run/ids.js +23 -0
  116. package/dist/runtime/background-shell.d.ts +1 -0
  117. package/dist/runtime/background-shell.js +23 -13
  118. package/dist/runtime/spawn-common.js +10 -0
  119. package/dist/services/auto-dream.d.ts +15 -4
  120. package/dist/services/auto-dream.js +20 -20
  121. package/dist/services/dream-consolidation.d.ts +2 -3
  122. package/dist/services/dream-consolidation.js +65 -15
  123. package/dist/services/extract-memories.d.ts +14 -5
  124. package/dist/services/extract-memories.js +20 -3
  125. package/dist/services/global-dream-promotion.d.ts +23 -0
  126. package/dist/services/global-dream-promotion.js +112 -0
  127. package/dist/services/memory-orchestrator.js +347 -34
  128. package/dist/session/memory.d.ts +61 -18
  129. package/dist/session/memory.js +342 -79
  130. package/dist/session/session-manager.d.ts +35 -1
  131. package/dist/session/session-manager.js +224 -4
  132. package/dist/session/transcript.d.ts +1 -1
  133. package/dist/session/transcript.js +17 -5
  134. package/dist/settings/manager.d.ts +1 -0
  135. package/dist/settings/manager.js +87 -37
  136. package/dist/settings/schema-export.d.ts +2 -3
  137. package/dist/settings/schema-export.js +2 -3
  138. package/dist/settings/schema.d.ts +21 -0
  139. package/dist/settings/schema.js +12 -0
  140. package/dist/skills/scanner.d.ts +3 -2
  141. package/dist/skills/scanner.js +12 -9
  142. package/dist/tool-system/builtin/agent-notifications.d.ts +11 -4
  143. package/dist/tool-system/builtin/agent-notifications.js +19 -7
  144. package/dist/tool-system/builtin/background-jobs.d.ts +35 -6
  145. package/dist/tool-system/builtin/background-jobs.js +116 -7
  146. package/dist/tool-system/builtin/background-work.d.ts +17 -18
  147. package/dist/tool-system/builtin/background-work.js +51 -5
  148. package/dist/tool-system/builtin/config.d.ts +2 -1
  149. package/dist/tool-system/builtin/config.js +16 -11
  150. package/dist/tool-system/builtin/cron-list.definition.d.ts +3 -0
  151. package/dist/tool-system/builtin/cron-list.definition.js +6 -0
  152. package/dist/tool-system/builtin/cron.d.ts +1 -2
  153. package/dist/tool-system/builtin/cron.js +9 -7
  154. package/dist/tool-system/builtin/drive-claude-code.d.ts +23 -2
  155. package/dist/tool-system/builtin/drive-claude-code.js +589 -48
  156. package/dist/tool-system/builtin/edit.js +5 -2
  157. package/dist/tool-system/builtin/generate-video.d.ts +1 -0
  158. package/dist/tool-system/builtin/generate-video.js +13 -4
  159. package/dist/tool-system/builtin/index.d.ts +8 -3
  160. package/dist/tool-system/builtin/index.js +50 -22
  161. package/dist/tool-system/builtin/lsp.d.ts +2 -1
  162. package/dist/tool-system/builtin/lsp.js +6 -3
  163. package/dist/tool-system/builtin/memory.js +40 -8
  164. package/dist/tool-system/builtin/notebook-edit.js +5 -2
  165. package/dist/tool-system/builtin/powershell.d.ts +5 -2
  166. package/dist/tool-system/builtin/powershell.js +11 -7
  167. package/dist/tool-system/builtin/read.js +118 -6
  168. package/dist/tool-system/builtin/sleep.d.ts +1 -2
  169. package/dist/tool-system/builtin/sleep.definition.d.ts +8 -0
  170. package/dist/tool-system/builtin/sleep.definition.js +28 -0
  171. package/dist/tool-system/builtin/sleep.js +1 -22
  172. package/dist/tool-system/builtin/view-image.d.ts +2 -2
  173. package/dist/tool-system/builtin/view-image.js +109 -19
  174. package/dist/tool-system/builtin/worktree.d.ts +4 -4
  175. package/dist/tool-system/builtin/worktree.js +297 -74
  176. package/dist/tool-system/builtin/write.js +5 -3
  177. package/dist/tool-system/context.d.ts +41 -1
  178. package/dist/tool-system/executor.d.ts +1 -5
  179. package/dist/tool-system/executor.js +94 -115
  180. package/dist/tool-system/mcp-manager.d.ts +31 -6
  181. package/dist/tool-system/mcp-manager.js +193 -78
  182. package/dist/tool-system/path-policy.d.ts +2 -0
  183. package/dist/tool-system/path-policy.js +41 -12
  184. package/dist/tool-system/permission.d.ts +28 -7
  185. package/dist/tool-system/permission.js +130 -49
  186. package/dist/tool-system/registry.js +11 -4
  187. package/dist/tool-system/tool-result-redaction.d.ts +7 -0
  188. package/dist/tool-system/tool-result-redaction.js +48 -0
  189. package/dist/tool-system/workspace-bridge.d.ts +11 -0
  190. package/dist/tool-system/workspace-bridge.js +1 -0
  191. package/dist/types.d.ts +78 -11
  192. package/dist/utils/toolDisplay.js +1 -1
  193. package/package.json +4 -3
@@ -7,22 +7,17 @@
7
7
  * - token/link → `{ kind: "value", value }`
8
8
  * - cookie → 就地写临时 cookies.txt(0600),返回 `{ kind: "cookie", cookiesFile, count }`
9
9
  *
10
- * 取值全部 core 直读 CredentialStore(cookie 值第二期已进库),无跨进程。
10
+ * desktop 下通过 host credential access IPC 按需解析 secret;headless/SDK
11
+ * 仍可使用本地 CredentialStore。
11
12
  * 集中在 core/src/credentials/ 下,只经 ToolDefinition 注册 + ToolContext.askUser 耦合 core,
12
13
  * 满足设计稿 §1「可整块外移」约束。
13
14
  */
14
- import { writeFileSync, existsSync, readdirSync, statSync, rmSync } from "node:fs";
15
- import { join } from "node:path";
16
- import { tmpdir } from "node:os";
17
- import { randomUUID } from "node:crypto";
18
- import { CredentialStore } from "./store.js";
19
- import { formatNetscapeCookies, parseCookieJar } from "./cookie-jar.js";
15
+ import { SENSITIVE_TOOL_RESULT_PLACEHOLDER } from "../tool-system/tool-result-redaction.js";
20
16
  import { credentialUseGate, } from "./use-gate.js";
21
17
  import { SettingsManager } from "../settings/manager.js";
22
18
  import { logger } from "../logging/logger.js";
19
+ import { credentialAccessScope, getCredentialAccess, materializeCookieSecret, sweepStaleCredentialCookieFiles, } from "./access.js";
23
20
  const TOOL_NAME = "UseCredential";
24
- const COOKIE_FILE_PREFIX = "codeshell-cred-cookie-";
25
- const COOKIE_FILE_MAX_AGE_MS = 30 * 60 * 1000; // 30min 启动 sweep 上限
26
21
  const BASE_DESCRIPTION = "Use a stored credential (token / API key / login cookie) to run a command. " +
27
22
  "Call with NO arguments first to list available credentials (id + label + type); " +
28
23
  "then call again with `id` to fetch one. Token/link credentials return their secret " +
@@ -52,7 +47,7 @@ export const useCredentialToolDef = {
52
47
  */
53
48
  export function useCredentialToolDefFor(cwd) {
54
49
  try {
55
- const list = new CredentialStore(cwd).listMasked();
50
+ const list = getCredentialAccess().listMasked(cwd, "full");
56
51
  if (list.length === 0)
57
52
  return useCredentialToolDef;
58
53
  const names = list.map((c) => `${c.id} (${c.type})`).join(", ");
@@ -70,26 +65,7 @@ export function useCredentialToolDefFor(cwd) {
70
65
  * 不引入 lease 对象/定时器 —— 文件用完靠进程退出 + 这个轻量 sweep。
71
66
  */
72
67
  export function sweepStaleCredentialCookies(now = Date.now()) {
73
- const dir = tmpdir();
74
- try {
75
- if (!existsSync(dir))
76
- return;
77
- for (const f of readdirSync(dir)) {
78
- if (!f.startsWith(COOKIE_FILE_PREFIX))
79
- continue;
80
- const p = join(dir, f);
81
- try {
82
- if (now - statSync(p).mtimeMs > COOKIE_FILE_MAX_AGE_MS)
83
- rmSync(p, { force: true });
84
- }
85
- catch {
86
- /* skip */
87
- }
88
- }
89
- }
90
- catch {
91
- /* best-effort */
92
- }
68
+ sweepStaleCredentialCookieFiles(now);
93
69
  }
94
70
  /** 内存会话 allow 集:每个 Engine 一份(从 ctx.sessionId 键)。纯内存,关进程即忘。 */
95
71
  const sessionAllowByEngine = new Map();
@@ -112,7 +88,7 @@ function sessionAllowFor(ctx) {
112
88
  // (project-only). An "isolated" engine is at least as restrictive as project,
113
89
  // so it maps to "project" — it must never read the host user's ~/.code-shell.
114
90
  function credentialScope(scope) {
115
- return scope === "full" || scope === undefined ? "full" : "project";
91
+ return credentialAccessScope(scope);
116
92
  }
117
93
  function readAutoApprove(cwd, scope) {
118
94
  try {
@@ -128,19 +104,19 @@ function readAutoApprove(cwd, scope) {
128
104
  }
129
105
  export async function useCredentialTool(args, ctx) {
130
106
  const cwd = ctx?.cwd ?? process.cwd();
131
- const store = new CredentialStore(cwd);
107
+ const access = getCredentialAccess();
132
108
  const scope = credentialScope(ctx?.settingsScope);
133
109
  const id = typeof args.id === "string" ? args.id.trim() : "";
134
110
  const purpose = typeof args.purpose === "string" ? args.purpose : undefined;
135
111
  // 无 id → 清单(脱敏,权威实时源)。按 engine scope 过滤:project/isolated
136
112
  // 引擎不得列出宿主 user 层凭证。
137
113
  if (!id) {
138
- const credentials = store
139
- .listMasked(scope)
114
+ const credentials = access
115
+ .listMasked(cwd, scope)
140
116
  .map((c) => ({ id: c.id, label: c.label, type: c.type }));
141
117
  return json({ kind: "list", credentials });
142
118
  }
143
- const cred = store.resolve(id, scope);
119
+ const cred = access.resolveMeta(cwd, id, scope);
144
120
  if (!cred) {
145
121
  return json({ kind: "error", error: `凭证不存在: "${id}"。调用本工具(无参)可列出可用凭证。` });
146
122
  }
@@ -162,14 +138,20 @@ export async function useCredentialTool(args, ctx) {
162
138
  }
163
139
  // token/link → 直接返回值
164
140
  if (cred.type === "token" || cred.type === "link") {
165
- if (!cred.secret)
141
+ if (!cred.hasSecret || !access.resolveValue) {
142
+ return json({ kind: "error", error: `凭证「${cred.label}」没有可用的值。` });
143
+ }
144
+ try {
145
+ const value = await access.resolveValue({ cwd, id: cred.id, scope, purpose: "use" });
146
+ return json({ kind: "value", value });
147
+ }
148
+ catch {
166
149
  return json({ kind: "error", error: `凭证「${cred.label}」没有可用的值。` });
167
- return json({ kind: "value", value: cred.secret });
150
+ }
168
151
  }
169
152
  // cookie → 就地写临时 cookies.txt
170
153
  if (cred.type === "cookie") {
171
- const jar = parseCookieJar(cred.secret);
172
- if (jar.length === 0) {
154
+ if (!cred.hasSecret) {
173
155
  return json({
174
156
  kind: "error",
175
157
  error: `凭证「${cred.label}」的 cookie 为空或已失效,请在凭证页对该账号点「重拓」(重新登录后重新拓取)。`,
@@ -180,26 +162,57 @@ export async function useCredentialTool(args, ctx) {
180
162
  // same process — the second write would clobber the first and a caller could
181
163
  // read another account's cookies. A random component makes each file distinct.
182
164
  // Prefix is unchanged so the 30-min startup sweep still matches & cleans them.
183
- const file = join(tmpdir(), `${COOKIE_FILE_PREFIX}${safe(cred.id)}-${process.pid}-${randomUUID()}.txt`);
184
165
  try {
185
- writeFileSync(file, formatNetscapeCookies(jar), { mode: 0o600 });
166
+ const materialized = access.materializeCookie
167
+ ? await access.materializeCookie({ cwd, id: cred.id, scope })
168
+ : materializeCookieSecret(cred.id, await access.resolveValue({ cwd, id: cred.id, scope, purpose: "use" }));
169
+ return json({
170
+ kind: "cookie",
171
+ cookiesFile: materialized.cookiesFile,
172
+ count: materialized.count,
173
+ });
186
174
  }
187
175
  catch (e) {
176
+ if (String(e).includes("cookie jar is empty or invalid")) {
177
+ return json({
178
+ kind: "error",
179
+ error: `凭证「${cred.label}」的 cookie 为空或已失效,请在凭证页对该账号点「重拓」(重新登录后重新拓取)。`,
180
+ });
181
+ }
188
182
  logger.warn(`UseCredential: failed to write cookies.txt: ${String(e)}`);
189
183
  return json({ kind: "error", error: `写临时 cookie 文件失败: ${String(e)}` });
190
184
  }
191
- return json({ kind: "cookie", cookiesFile: file, count: jar.length });
192
185
  }
193
186
  return json({ kind: "error", error: `未知凭证类型: ${cred.type}` });
194
187
  }
195
- /** 文件名安全化(凭证 id 用了 `__`,这里只挡路径分隔符/控制字符) */
196
- function safe(s) {
197
- return s.replace(/[^a-zA-Z0-9_.-]/g, "_");
188
+ export async function useCredentialBuiltinTool(args, ctx) {
189
+ const result = await useCredentialTool(args, ctx);
190
+ if (!isValueResult(result))
191
+ return result;
192
+ const redacted = json({ kind: "value", value: SENSITIVE_TOOL_RESULT_PLACEHOLDER });
193
+ return {
194
+ result,
195
+ sensitive: true,
196
+ displayResult: redacted,
197
+ transcriptResult: redacted,
198
+ };
198
199
  }
199
200
  function json(r) {
200
201
  return JSON.stringify(r);
201
202
  }
203
+ function isValueResult(result) {
204
+ try {
205
+ const parsed = JSON.parse(result);
206
+ return parsed.kind === "value" && typeof parsed.value === "string";
207
+ }
208
+ catch {
209
+ return false;
210
+ }
211
+ }
202
212
  /** 测试钩子:清空会话 allow 集(避免跨用例污染)。 */
203
213
  export function __resetCredentialSessionAllowForTests() {
204
214
  sessionAllowByEngine.clear();
205
215
  }
216
+ export function clearCredentialSessionAllow(sessionId) {
217
+ sessionAllowByEngine.delete(sessionId);
218
+ }
@@ -12,9 +12,11 @@ import type { AskUserFn } from "../tool-system/builtin/ask-user.js";
12
12
  import type { CapabilityOverride } from "../settings/schema.js";
13
13
  import { type FeatureFlagName } from "../settings/feature-flags.js";
14
14
  import type { ToolContext } from "../tool-system/context.js";
15
+ import { type SandboxBackend } from "../tool-system/sandbox/index.js";
15
16
  import { ModelPool, type ModelEntry } from "../llm/model-pool.js";
16
17
  import { AgentDefinitionRegistry } from "../agent/agent-definition-registry.js";
17
18
  import { EngineRuntime } from "./runtime.js";
19
+ import type { InputAttachmentMeta } from "../protocol/types.js";
18
20
  /**
19
21
  * Build ScanOptions.compatFileNames from the user's instruction compat toggles.
20
22
  * Primary file name stays hard-wired to CODESHELL.md (not exposed). Turning a
@@ -53,7 +55,7 @@ export declare function resolveChildLlm(modelKey: string | undefined, pool: Mode
53
55
  * Names in `disabledAgents` are filtered out so the LLM never sees them.
54
56
  */
55
57
  /**
56
- * Resolve the working directory for a run. Precedence:
58
+ * Resolve the working directory for a run. Precedence for legacy sessions:
57
59
  * options.cwd > resumed session's state.cwd > config.cwd > process.cwd()
58
60
  *
59
61
  * The session-cwd tier is what stops a project-bound session from being
@@ -152,6 +154,7 @@ export declare class Engine {
152
154
  * LLM response arrives.
153
155
  */
154
156
  private ctxOverheadBySid;
157
+ private lastCacheReadBySid;
155
158
  /**
156
159
  * Step-gap steering queue (per sessionId, in-memory). Host pushes user
157
160
  * messages here via enqueueSteer while a run is in flight; the turn loop
@@ -261,6 +264,8 @@ export declare class Engine {
261
264
  * clear "no browser panel" error.
262
265
  */
263
266
  setBrowserBridge(bridge: import("../tool-system/browser-bridge.js").BrowserBridge | undefined): void;
267
+ /** Inject the host-backed workspace bridge after construction. */
268
+ setWorkspaceBridge(bridge: import("../tool-system/workspace-bridge.js").WorkspaceBridge | undefined): void;
264
269
  /**
265
270
  * Queue a user message to be spliced into the in-flight run for `sessionId`
266
271
  * at the next turn-loop step boundary — the 不打断 steering path (vs cancel +
@@ -274,7 +279,7 @@ export declare class Engine {
274
279
  * the queued draft) and is the handle `unsteer` uses to revoke a still-pending
275
280
  * entry. A blank id is tolerated but means the entry can't be revoked.
276
281
  */
277
- enqueueSteer(sessionId: string, text: string, id?: string, clientMessageId?: string): EnqueueSteerResult;
282
+ enqueueSteer(sessionId: string, text: string, id?: string, clientMessageId?: string, attachments?: InputAttachmentMeta[]): EnqueueSteerResult;
278
283
  /**
279
284
  * Revoke a still-pending steer entry (the 撤回 path). Returns true if it was
280
285
  * removed, false if it was already consumed by the turn loop (can't take it
@@ -283,6 +288,8 @@ export declare class Engine {
283
288
  unsteer(sessionId: string, id: string): boolean;
284
289
  /** Drain + clear the steer queue for a session (turn loop consumes per step). */
285
290
  private consumeSteer;
291
+ /** Put failed steer preparation back ahead of messages queued while it was being prepared. */
292
+ private restoreSteer;
286
293
  /** Wire the cookie→browser injection callback (InjectCredential tool). Same
287
294
  * post-construction injection model as setBrowserBridge. */
288
295
  setInjectCredential(fn: import("../tool-system/context.js").InjectCredentialFn | undefined): void;
@@ -325,6 +332,8 @@ export declare class Engine {
325
332
  injected?: boolean;
326
333
  /** Stable id for this user-intent, used to make duplicate submits idempotent. */
327
334
  clientMessageId?: string;
335
+ /** Structured input attachments. Legacy `<codeshell-image>` blocks remain supported. */
336
+ attachments?: InputAttachmentMeta[];
328
337
  }): Promise<EngineResult>;
329
338
  /**
330
339
  * Run the end-of-session memory pipeline as a fire-and-forget background
@@ -460,6 +469,12 @@ export declare class Engine {
460
469
  * session with no active goal is a no-op returning false.
461
470
  */
462
471
  clearGoal(sessionId: string): boolean;
472
+ /**
473
+ * Reset a session's workspace pointer back to its main root. If the session is
474
+ * actively running, mutate that live SessionBundle first so the run's next
475
+ * saveState cannot resurrect a stale worktree pointer.
476
+ */
477
+ releaseSessionWorkspace(sessionId: string): import("../types.js").SessionWorkspace | null;
463
478
  injectContext(sessionId: string, content: string): void;
464
479
  /**
465
480
  * Force context compaction on a session.
@@ -470,7 +485,8 @@ export declare class Engine {
470
485
  after: number;
471
486
  strategy: "none (no active session)" | "no compaction needed" | "compacted" | CompactStrategy;
472
487
  }>;
473
- private stripUserContextMessage;
488
+ private stripInjectedContextMessages;
489
+ private recordCacheReadDiagnostics;
474
490
  private getSettingsManager;
475
491
  /**
476
492
  * Update a config setting at runtime.
@@ -570,6 +586,7 @@ export declare class Engine {
570
586
  * by tests that want a ToolContext without a full run() cycle.
571
587
  */
572
588
  private resolveSandboxWithoutRuntime;
589
+ private resolveSandboxConfigForCwd;
573
590
  /**
574
591
  * Build the shell env layered onto the Bash tool / background shells (see
575
592
  * mergeShellEnv). Three user-configured sources, merged lowest → highest:
@@ -622,6 +639,9 @@ export declare class Engine {
622
639
  linux?: string;
623
640
  windows?: string;
624
641
  } | undefined;
642
+ readWorktreeBranchPrefix(cwd?: string): string | undefined;
643
+ resolveWorktreeSetupSandbox(cwd: string): Promise<SandboxBackend | undefined>;
644
+ readWorktreeSetupShellEnv(cwd?: string): Record<string, string> | undefined;
625
645
  buildToolContext(): ToolContext;
626
646
  /**
627
647
  * Read settings.disabledSkills + settings.disabledPlugins in a single