@cjhyy/code-shell-core 0.6.0-rc.8 → 0.7.0-beta.1

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 (177) 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 +2 -0
  7. package/dist/cc-orchestrator/agent-adapter.js +7 -1
  8. package/dist/cc-orchestrator/codex-session-history.js +1 -1
  9. package/dist/cc-orchestrator/cwd-normalize.d.ts +2 -0
  10. package/dist/cc-orchestrator/cwd-normalize.js +19 -0
  11. package/dist/cc-orchestrator/external-agent-bindings.d.ts +27 -0
  12. package/dist/cc-orchestrator/external-agent-bindings.js +150 -0
  13. package/dist/cc-orchestrator/external-agent-driver.d.ts +1 -0
  14. package/dist/cc-orchestrator/external-agent-driver.js +102 -51
  15. package/dist/cc-orchestrator/external-agent-session-store.d.ts +23 -0
  16. package/dist/cc-orchestrator/external-agent-session-store.js +146 -0
  17. package/dist/cc-orchestrator/session-history.js +2 -2
  18. package/dist/cli/agent-server-stdio.js +9 -2
  19. package/dist/context/compaction.d.ts +38 -1
  20. package/dist/context/compaction.js +138 -0
  21. package/dist/context/manager.d.ts +34 -2
  22. package/dist/context/manager.js +254 -58
  23. package/dist/context/token-counter.js +13 -0
  24. package/dist/credentials/access.d.ts +56 -0
  25. package/dist/credentials/access.js +183 -0
  26. package/dist/credentials/index.d.ts +1 -0
  27. package/dist/credentials/index.js +1 -0
  28. package/dist/credentials/inject-credential-tool.d.ts +3 -1
  29. package/dist/credentials/inject-credential-tool.js +30 -11
  30. package/dist/credentials/types.d.ts +2 -2
  31. package/dist/credentials/use-credential-tool.d.ts +9 -1
  32. package/dist/credentials/use-credential-tool.js +58 -45
  33. package/dist/engine/engine.d.ts +38 -12
  34. package/dist/engine/engine.js +477 -163
  35. package/dist/engine/image-policy.d.ts +6 -0
  36. package/dist/engine/image-policy.js +17 -6
  37. package/dist/engine/input-attachments.d.ts +13 -0
  38. package/dist/engine/input-attachments.js +255 -0
  39. package/dist/engine/model-facade.d.ts +5 -2
  40. package/dist/engine/model-facade.js +6 -16
  41. package/dist/engine/parse-task.d.ts +10 -0
  42. package/dist/engine/parse-task.js +5 -0
  43. package/dist/engine/query.js +2 -0
  44. package/dist/engine/session-usage.d.ts +12 -0
  45. package/dist/engine/session-usage.js +56 -0
  46. package/dist/engine/steer-queue.d.ts +2 -1
  47. package/dist/engine/steer-queue.js +2 -2
  48. package/dist/engine/streaming-tool-queue.d.ts +11 -7
  49. package/dist/engine/streaming-tool-queue.js +11 -7
  50. package/dist/engine/turn-loop.d.ts +34 -2
  51. package/dist/engine/turn-loop.js +269 -52
  52. package/dist/engine/types.d.ts +8 -0
  53. package/dist/git/worktree/crud.d.ts +69 -0
  54. package/dist/git/worktree/crud.js +206 -0
  55. package/dist/git/worktree/diff.d.ts +14 -0
  56. package/dist/git/worktree/diff.js +82 -0
  57. package/dist/git/worktree/git-exec.d.ts +7 -0
  58. package/dist/git/worktree/git-exec.js +51 -0
  59. package/dist/git/worktree/index.d.ts +5 -0
  60. package/dist/git/worktree/index.js +5 -0
  61. package/dist/git/worktree/query.d.ts +42 -0
  62. package/dist/git/worktree/query.js +121 -0
  63. package/dist/git/worktree/slug.d.ts +11 -0
  64. package/dist/git/worktree/slug.js +58 -0
  65. package/dist/git/worktree.d.ts +1 -84
  66. package/dist/git/worktree.js +5 -230
  67. package/dist/index.d.ts +31 -28
  68. package/dist/index.js +27 -25
  69. package/dist/logging/logger.js +6 -6
  70. package/dist/logging/sanitize-messages.d.ts +10 -2
  71. package/dist/logging/sanitize-messages.js +21 -6
  72. package/dist/plugins/installer/checkUpdate.d.ts +4 -1
  73. package/dist/plugins/installer/checkUpdate.js +4 -2
  74. package/dist/plugins/installer/install.js +2 -0
  75. package/dist/plugins/installer/installFromSource.js +9 -1
  76. package/dist/plugins/installer/parseSource.d.ts +4 -1
  77. package/dist/plugins/installer/parseSource.js +28 -10
  78. package/dist/plugins/installer/sourcePath.d.ts +9 -0
  79. package/dist/plugins/installer/sourcePath.js +50 -0
  80. package/dist/plugins/installer/update.d.ts +4 -1
  81. package/dist/plugins/installer/update.js +5 -3
  82. package/dist/plugins/parseMarketplaceInput.d.ts +4 -1
  83. package/dist/plugins/parseMarketplaceInput.js +4 -3
  84. package/dist/plugins/pluginInstaller.js +24 -22
  85. package/dist/preset/index.d.ts +1 -0
  86. package/dist/preset/index.js +16 -9
  87. package/dist/prompt/sections/base.md +1 -1
  88. package/dist/protocol/chat-session-manager.d.ts +2 -0
  89. package/dist/protocol/chat-session-manager.js +38 -2
  90. package/dist/protocol/chat-session.d.ts +5 -0
  91. package/dist/protocol/chat-session.js +2 -0
  92. package/dist/protocol/client.d.ts +13 -5
  93. package/dist/protocol/client.js +26 -3
  94. package/dist/protocol/server.d.ts +43 -12
  95. package/dist/protocol/server.js +326 -104
  96. package/dist/protocol/types.d.ts +51 -0
  97. package/dist/protocol/types.js +6 -0
  98. package/dist/run/FileRunStore.js +10 -1
  99. package/dist/run/Heartbeat.js +12 -0
  100. package/dist/run/RunApprovalBackend.d.ts +3 -0
  101. package/dist/run/RunApprovalBackend.js +41 -6
  102. package/dist/run/RunLock.js +2 -0
  103. package/dist/run/RunManager.d.ts +2 -0
  104. package/dist/run/RunManager.js +64 -24
  105. package/dist/run/ids.d.ts +2 -0
  106. package/dist/run/ids.js +23 -0
  107. package/dist/runtime/background-shell.d.ts +1 -0
  108. package/dist/runtime/background-shell.js +23 -13
  109. package/dist/runtime/safe-spawn.js +74 -11
  110. package/dist/runtime/spawn-common.js +10 -0
  111. package/dist/services/auto-dream.d.ts +15 -4
  112. package/dist/services/auto-dream.js +20 -20
  113. package/dist/services/dream-consolidation.d.ts +2 -3
  114. package/dist/services/dream-consolidation.js +65 -15
  115. package/dist/services/extract-memories.d.ts +14 -5
  116. package/dist/services/extract-memories.js +20 -3
  117. package/dist/services/global-dream-promotion.d.ts +23 -0
  118. package/dist/services/global-dream-promotion.js +112 -0
  119. package/dist/services/memory-orchestrator.js +347 -34
  120. package/dist/session/memory.d.ts +61 -18
  121. package/dist/session/memory.js +342 -79
  122. package/dist/session/session-manager.d.ts +35 -1
  123. package/dist/session/session-manager.js +197 -4
  124. package/dist/session/transcript.d.ts +5 -1
  125. package/dist/session/transcript.js +38 -5
  126. package/dist/settings/manager.d.ts +1 -0
  127. package/dist/settings/manager.js +87 -37
  128. package/dist/settings/schema-export.d.ts +2 -3
  129. package/dist/settings/schema-export.js +2 -3
  130. package/dist/settings/schema.d.ts +21 -0
  131. package/dist/settings/schema.js +12 -0
  132. package/dist/skills/scanner.d.ts +3 -2
  133. package/dist/skills/scanner.js +12 -9
  134. package/dist/tool-system/builtin/background-jobs.d.ts +10 -1
  135. package/dist/tool-system/builtin/background-jobs.js +12 -1
  136. package/dist/tool-system/builtin/background-work.d.ts +17 -18
  137. package/dist/tool-system/builtin/background-work.js +51 -5
  138. package/dist/tool-system/builtin/config.d.ts +2 -1
  139. package/dist/tool-system/builtin/config.js +16 -11
  140. package/dist/tool-system/builtin/drive-claude-code.d.ts +16 -2
  141. package/dist/tool-system/builtin/drive-claude-code.js +301 -47
  142. package/dist/tool-system/builtin/edit.js +5 -2
  143. package/dist/tool-system/builtin/generate-video.d.ts +1 -0
  144. package/dist/tool-system/builtin/generate-video.js +13 -4
  145. package/dist/tool-system/builtin/index.d.ts +8 -3
  146. package/dist/tool-system/builtin/index.js +37 -21
  147. package/dist/tool-system/builtin/lsp.d.ts +2 -1
  148. package/dist/tool-system/builtin/lsp.js +6 -3
  149. package/dist/tool-system/builtin/memory.js +40 -8
  150. package/dist/tool-system/builtin/notebook-edit.js +5 -2
  151. package/dist/tool-system/builtin/powershell.d.ts +5 -2
  152. package/dist/tool-system/builtin/powershell.js +11 -7
  153. package/dist/tool-system/builtin/read.js +118 -6
  154. package/dist/tool-system/builtin/view-image.d.ts +2 -2
  155. package/dist/tool-system/builtin/view-image.js +109 -19
  156. package/dist/tool-system/builtin/worktree.d.ts +4 -4
  157. package/dist/tool-system/builtin/worktree.js +297 -74
  158. package/dist/tool-system/builtin/write.js +5 -3
  159. package/dist/tool-system/context.d.ts +23 -1
  160. package/dist/tool-system/executor.d.ts +1 -5
  161. package/dist/tool-system/executor.js +94 -115
  162. package/dist/tool-system/mcp-manager.d.ts +18 -5
  163. package/dist/tool-system/mcp-manager.js +157 -74
  164. package/dist/tool-system/mcp-stdio-diagnostics.d.ts +9 -0
  165. package/dist/tool-system/mcp-stdio-diagnostics.js +93 -0
  166. package/dist/tool-system/path-policy.d.ts +2 -0
  167. package/dist/tool-system/path-policy.js +41 -12
  168. package/dist/tool-system/permission.d.ts +28 -7
  169. package/dist/tool-system/permission.js +130 -49
  170. package/dist/tool-system/registry.js +11 -4
  171. package/dist/tool-system/tool-result-redaction.d.ts +7 -0
  172. package/dist/tool-system/tool-result-redaction.js +48 -0
  173. package/dist/tool-system/workspace-bridge.d.ts +11 -0
  174. package/dist/tool-system/workspace-bridge.js +1 -0
  175. package/dist/types.d.ts +86 -5
  176. package/dist/utils/toolDisplay.js +1 -1
  177. package/package.json +4 -3
@@ -6,14 +6,17 @@ import { ToolRegistry } from "../tool-system/registry.js";
6
6
  import { type BuiltinToolFn } from "../tool-system/builtin/index.js";
7
7
  import { HookRegistry } from "../hooks/registry.js";
8
8
  import { type GoalConfig, type GoalExtension } from "./goal.js";
9
+ import { type CompactStrategy } from "../context/manager.js";
9
10
  import { SessionManager } from "../session/session-manager.js";
10
11
  import type { AskUserFn } from "../tool-system/builtin/ask-user.js";
11
12
  import type { CapabilityOverride } from "../settings/schema.js";
12
13
  import { type FeatureFlagName } from "../settings/feature-flags.js";
13
14
  import type { ToolContext } from "../tool-system/context.js";
15
+ import { type SandboxBackend } from "../tool-system/sandbox/index.js";
14
16
  import { ModelPool, type ModelEntry } from "../llm/model-pool.js";
15
17
  import { AgentDefinitionRegistry } from "../agent/agent-definition-registry.js";
16
18
  import { EngineRuntime } from "./runtime.js";
19
+ import type { InputAttachmentMeta } from "../protocol/types.js";
17
20
  /**
18
21
  * Build ScanOptions.compatFileNames from the user's instruction compat toggles.
19
22
  * Primary file name stays hard-wired to CODESHELL.md (not exposed). Turning a
@@ -27,6 +30,10 @@ export declare function compatFileNamesFrom(instructions?: {
27
30
  }): string[];
28
31
  export type { EngineConfig, EngineHookConfig, EngineResult } from "./types.js";
29
32
  import type { EngineConfig, EngineResult } from "./types.js";
33
+ export interface EnqueueSteerResult {
34
+ accepted: boolean;
35
+ id: string;
36
+ }
30
37
  export { diskDefaultsFrom, type DiskDefaultPatch } from "../settings/disk-defaults.js";
31
38
  /**
32
39
  * Resolve the LLM config for a spawned child Engine.
@@ -48,7 +55,7 @@ export declare function resolveChildLlm(modelKey: string | undefined, pool: Mode
48
55
  * Names in `disabledAgents` are filtered out so the LLM never sees them.
49
56
  */
50
57
  /**
51
- * Resolve the working directory for a run. Precedence:
58
+ * Resolve the working directory for a run. Precedence for legacy sessions:
52
59
  * options.cwd > resumed session's state.cwd > config.cwd > process.cwd()
53
60
  *
54
61
  * The session-cwd tier is what stops a project-bound session from being
@@ -256,20 +263,22 @@ export declare class Engine {
256
263
  * clear "no browser panel" error.
257
264
  */
258
265
  setBrowserBridge(bridge: import("../tool-system/browser-bridge.js").BrowserBridge | undefined): void;
266
+ /** Inject the host-backed workspace bridge after construction. */
267
+ setWorkspaceBridge(bridge: import("../tool-system/workspace-bridge.js").WorkspaceBridge | undefined): void;
259
268
  /**
260
269
  * Queue a user message to be spliced into the in-flight run for `sessionId`
261
270
  * at the next turn-loop step boundary — the 不打断 steering path (vs cancel +
262
271
  * resend). General-purpose: any host path (UI 引导, future agent coordination,
263
- * external triggers) can call it. If no run is active for the session the
264
- * message simply waits in the queue and is consumed when that session next
265
- * runs (rare race; host normally only steers while busy). No-op on blank text.
272
+ * external triggers) can call it. If no run is active for this session, reject
273
+ * without queueing so the host can downgrade to a normal run immediately.
274
+ * No-op on blank text.
266
275
  *
267
276
  * `id` is the host's stable queue-entry id. It rides through to the
268
277
  * `steer_injected` event (so the host can match the injected bubble back to
269
278
  * the queued draft) and is the handle `unsteer` uses to revoke a still-pending
270
279
  * entry. A blank id is tolerated but means the entry can't be revoked.
271
280
  */
272
- enqueueSteer(sessionId: string, text: string, id?: string): void;
281
+ enqueueSteer(sessionId: string, text: string, id?: string, clientMessageId?: string): EnqueueSteerResult;
273
282
  /**
274
283
  * Revoke a still-pending steer entry (the 撤回 path). Returns true if it was
275
284
  * removed, false if it was already consumed by the turn loop (can't take it
@@ -318,6 +327,10 @@ export declare class Engine {
318
327
  * on replay (matching the live UI, which shows only the assistant reply).
319
328
  */
320
329
  injected?: boolean;
330
+ /** Stable id for this user-intent, used to make duplicate submits idempotent. */
331
+ clientMessageId?: string;
332
+ /** Structured input attachments. Legacy `<codeshell-image>` blocks remain supported. */
333
+ attachments?: InputAttachmentMeta[];
321
334
  }): Promise<EngineResult>;
322
335
  /**
323
336
  * Run the end-of-session memory pipeline as a fire-and-forget background
@@ -332,6 +345,11 @@ export declare class Engine {
332
345
  * active run's client) when unset, unknown, or on any build failure — aux
333
346
  * work is best-effort and must never break a run.
334
347
  */
348
+ /**
349
+ * Build the SummarizeFn used for context compaction. Extracted so both the
350
+ * run path and forceCompact share one definition of the summarization call.
351
+ */
352
+ private buildSummarizeFn;
335
353
  private resolveAuxClient;
336
354
  private runMemoryPipeline;
337
355
  /**
@@ -363,10 +381,8 @@ export declare class Engine {
363
381
  */
364
382
  switchModel(key: string): ModelEntry;
365
383
  /**
366
- * Zero a session's cumulative token/cache usage on disk. Called on a model
367
- * switch: a different model has its own prompt cache, so the accumulated
368
- * cache-hit stats from the prior model are no longer meaningful. The next
369
- * run's baseline (snapshotted from state.tokenUsage) then starts from zero.
384
+ * Zero the legacy/model-scoped token/cache usage window on disk. The
385
+ * whole-session cumulative counters are intentionally left alone.
370
386
  */
371
387
  resetSessionUsage(sessionId: string): void;
372
388
  /**
@@ -450,16 +466,22 @@ export declare class Engine {
450
466
  * session with no active goal is a no-op returning false.
451
467
  */
452
468
  clearGoal(sessionId: string): boolean;
469
+ /**
470
+ * Reset a session's workspace pointer back to its main root. If the session is
471
+ * actively running, mutate that live SessionBundle first so the run's next
472
+ * saveState cannot resurrect a stale worktree pointer.
473
+ */
474
+ releaseSessionWorkspace(sessionId: string): import("../types.js").SessionWorkspace | null;
453
475
  injectContext(sessionId: string, content: string): void;
454
476
  /**
455
477
  * Force context compaction on a session.
456
478
  * Returns token stats before/after.
457
479
  */
458
- forceCompact(sessionId?: string): {
480
+ forceCompact(sessionId?: string): Promise<{
459
481
  before: number;
460
482
  after: number;
461
- strategy: string;
462
- };
483
+ strategy: "none (no active session)" | "no compaction needed" | "compacted" | CompactStrategy;
484
+ }>;
463
485
  private stripUserContextMessage;
464
486
  private getSettingsManager;
465
487
  /**
@@ -560,6 +582,7 @@ export declare class Engine {
560
582
  * by tests that want a ToolContext without a full run() cycle.
561
583
  */
562
584
  private resolveSandboxWithoutRuntime;
585
+ private resolveSandboxConfigForCwd;
563
586
  /**
564
587
  * Build the shell env layered onto the Bash tool / background shells (see
565
588
  * mergeShellEnv). Three user-configured sources, merged lowest → highest:
@@ -612,6 +635,9 @@ export declare class Engine {
612
635
  linux?: string;
613
636
  windows?: string;
614
637
  } | undefined;
638
+ readWorktreeBranchPrefix(cwd?: string): string | undefined;
639
+ resolveWorktreeSetupSandbox(cwd: string): Promise<SandboxBackend | undefined>;
640
+ readWorktreeSetupShellEnv(cwd?: string): Record<string, string> | undefined;
615
641
  buildToolContext(): ToolContext;
616
642
  /**
617
643
  * Read settings.disabledSkills + settings.disabledPlugins in a single