@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.
- package/THIRD_PARTY_NOTICES.md +206 -0
- package/dist/automation/scheduler.d.ts +13 -7
- package/dist/automation/scheduler.js +116 -37
- package/dist/capability-control/service.d.ts +2 -0
- package/dist/capability-control/service.js +4 -2
- package/dist/cc-orchestrator/agent-adapter.d.ts +2 -0
- package/dist/cc-orchestrator/agent-adapter.js +7 -1
- package/dist/cc-orchestrator/codex-session-history.js +1 -1
- package/dist/cc-orchestrator/cwd-normalize.d.ts +2 -0
- package/dist/cc-orchestrator/cwd-normalize.js +19 -0
- package/dist/cc-orchestrator/external-agent-bindings.d.ts +27 -0
- package/dist/cc-orchestrator/external-agent-bindings.js +150 -0
- package/dist/cc-orchestrator/external-agent-driver.d.ts +1 -0
- package/dist/cc-orchestrator/external-agent-driver.js +102 -51
- package/dist/cc-orchestrator/external-agent-session-store.d.ts +23 -0
- package/dist/cc-orchestrator/external-agent-session-store.js +146 -0
- package/dist/cc-orchestrator/session-history.js +2 -2
- package/dist/cli/agent-server-stdio.js +9 -2
- package/dist/context/compaction.d.ts +38 -1
- package/dist/context/compaction.js +138 -0
- package/dist/context/manager.d.ts +34 -2
- package/dist/context/manager.js +254 -58
- package/dist/context/token-counter.js +13 -0
- package/dist/credentials/access.d.ts +56 -0
- package/dist/credentials/access.js +183 -0
- package/dist/credentials/index.d.ts +1 -0
- package/dist/credentials/index.js +1 -0
- package/dist/credentials/inject-credential-tool.d.ts +3 -1
- package/dist/credentials/inject-credential-tool.js +30 -11
- package/dist/credentials/types.d.ts +2 -2
- package/dist/credentials/use-credential-tool.d.ts +9 -1
- package/dist/credentials/use-credential-tool.js +58 -45
- package/dist/engine/engine.d.ts +38 -12
- package/dist/engine/engine.js +477 -163
- package/dist/engine/image-policy.d.ts +6 -0
- package/dist/engine/image-policy.js +17 -6
- package/dist/engine/input-attachments.d.ts +13 -0
- package/dist/engine/input-attachments.js +255 -0
- package/dist/engine/model-facade.d.ts +5 -2
- package/dist/engine/model-facade.js +6 -16
- package/dist/engine/parse-task.d.ts +10 -0
- package/dist/engine/parse-task.js +5 -0
- package/dist/engine/query.js +2 -0
- package/dist/engine/session-usage.d.ts +12 -0
- package/dist/engine/session-usage.js +56 -0
- package/dist/engine/steer-queue.d.ts +2 -1
- package/dist/engine/steer-queue.js +2 -2
- package/dist/engine/streaming-tool-queue.d.ts +11 -7
- package/dist/engine/streaming-tool-queue.js +11 -7
- package/dist/engine/turn-loop.d.ts +34 -2
- package/dist/engine/turn-loop.js +269 -52
- package/dist/engine/types.d.ts +8 -0
- package/dist/git/worktree/crud.d.ts +69 -0
- package/dist/git/worktree/crud.js +206 -0
- package/dist/git/worktree/diff.d.ts +14 -0
- package/dist/git/worktree/diff.js +82 -0
- package/dist/git/worktree/git-exec.d.ts +7 -0
- package/dist/git/worktree/git-exec.js +51 -0
- package/dist/git/worktree/index.d.ts +5 -0
- package/dist/git/worktree/index.js +5 -0
- package/dist/git/worktree/query.d.ts +42 -0
- package/dist/git/worktree/query.js +121 -0
- package/dist/git/worktree/slug.d.ts +11 -0
- package/dist/git/worktree/slug.js +58 -0
- package/dist/git/worktree.d.ts +1 -84
- package/dist/git/worktree.js +5 -230
- package/dist/index.d.ts +31 -28
- package/dist/index.js +27 -25
- package/dist/logging/logger.js +6 -6
- package/dist/logging/sanitize-messages.d.ts +10 -2
- package/dist/logging/sanitize-messages.js +21 -6
- package/dist/plugins/installer/checkUpdate.d.ts +4 -1
- package/dist/plugins/installer/checkUpdate.js +4 -2
- package/dist/plugins/installer/install.js +2 -0
- package/dist/plugins/installer/installFromSource.js +9 -1
- package/dist/plugins/installer/parseSource.d.ts +4 -1
- package/dist/plugins/installer/parseSource.js +28 -10
- package/dist/plugins/installer/sourcePath.d.ts +9 -0
- package/dist/plugins/installer/sourcePath.js +50 -0
- package/dist/plugins/installer/update.d.ts +4 -1
- package/dist/plugins/installer/update.js +5 -3
- package/dist/plugins/parseMarketplaceInput.d.ts +4 -1
- package/dist/plugins/parseMarketplaceInput.js +4 -3
- package/dist/plugins/pluginInstaller.js +24 -22
- package/dist/preset/index.d.ts +1 -0
- package/dist/preset/index.js +16 -9
- package/dist/prompt/sections/base.md +1 -1
- package/dist/protocol/chat-session-manager.d.ts +2 -0
- package/dist/protocol/chat-session-manager.js +38 -2
- package/dist/protocol/chat-session.d.ts +5 -0
- package/dist/protocol/chat-session.js +2 -0
- package/dist/protocol/client.d.ts +13 -5
- package/dist/protocol/client.js +26 -3
- package/dist/protocol/server.d.ts +43 -12
- package/dist/protocol/server.js +326 -104
- package/dist/protocol/types.d.ts +51 -0
- package/dist/protocol/types.js +6 -0
- package/dist/run/FileRunStore.js +10 -1
- package/dist/run/Heartbeat.js +12 -0
- package/dist/run/RunApprovalBackend.d.ts +3 -0
- package/dist/run/RunApprovalBackend.js +41 -6
- package/dist/run/RunLock.js +2 -0
- package/dist/run/RunManager.d.ts +2 -0
- package/dist/run/RunManager.js +64 -24
- package/dist/run/ids.d.ts +2 -0
- package/dist/run/ids.js +23 -0
- package/dist/runtime/background-shell.d.ts +1 -0
- package/dist/runtime/background-shell.js +23 -13
- package/dist/runtime/safe-spawn.js +74 -11
- package/dist/runtime/spawn-common.js +10 -0
- package/dist/services/auto-dream.d.ts +15 -4
- package/dist/services/auto-dream.js +20 -20
- package/dist/services/dream-consolidation.d.ts +2 -3
- package/dist/services/dream-consolidation.js +65 -15
- package/dist/services/extract-memories.d.ts +14 -5
- package/dist/services/extract-memories.js +20 -3
- package/dist/services/global-dream-promotion.d.ts +23 -0
- package/dist/services/global-dream-promotion.js +112 -0
- package/dist/services/memory-orchestrator.js +347 -34
- package/dist/session/memory.d.ts +61 -18
- package/dist/session/memory.js +342 -79
- package/dist/session/session-manager.d.ts +35 -1
- package/dist/session/session-manager.js +197 -4
- package/dist/session/transcript.d.ts +5 -1
- package/dist/session/transcript.js +38 -5
- package/dist/settings/manager.d.ts +1 -0
- package/dist/settings/manager.js +87 -37
- package/dist/settings/schema-export.d.ts +2 -3
- package/dist/settings/schema-export.js +2 -3
- package/dist/settings/schema.d.ts +21 -0
- package/dist/settings/schema.js +12 -0
- package/dist/skills/scanner.d.ts +3 -2
- package/dist/skills/scanner.js +12 -9
- package/dist/tool-system/builtin/background-jobs.d.ts +10 -1
- package/dist/tool-system/builtin/background-jobs.js +12 -1
- package/dist/tool-system/builtin/background-work.d.ts +17 -18
- package/dist/tool-system/builtin/background-work.js +51 -5
- package/dist/tool-system/builtin/config.d.ts +2 -1
- package/dist/tool-system/builtin/config.js +16 -11
- package/dist/tool-system/builtin/drive-claude-code.d.ts +16 -2
- package/dist/tool-system/builtin/drive-claude-code.js +301 -47
- package/dist/tool-system/builtin/edit.js +5 -2
- package/dist/tool-system/builtin/generate-video.d.ts +1 -0
- package/dist/tool-system/builtin/generate-video.js +13 -4
- package/dist/tool-system/builtin/index.d.ts +8 -3
- package/dist/tool-system/builtin/index.js +37 -21
- package/dist/tool-system/builtin/lsp.d.ts +2 -1
- package/dist/tool-system/builtin/lsp.js +6 -3
- package/dist/tool-system/builtin/memory.js +40 -8
- package/dist/tool-system/builtin/notebook-edit.js +5 -2
- package/dist/tool-system/builtin/powershell.d.ts +5 -2
- package/dist/tool-system/builtin/powershell.js +11 -7
- package/dist/tool-system/builtin/read.js +118 -6
- package/dist/tool-system/builtin/view-image.d.ts +2 -2
- package/dist/tool-system/builtin/view-image.js +109 -19
- package/dist/tool-system/builtin/worktree.d.ts +4 -4
- package/dist/tool-system/builtin/worktree.js +297 -74
- package/dist/tool-system/builtin/write.js +5 -3
- package/dist/tool-system/context.d.ts +23 -1
- package/dist/tool-system/executor.d.ts +1 -5
- package/dist/tool-system/executor.js +94 -115
- package/dist/tool-system/mcp-manager.d.ts +18 -5
- package/dist/tool-system/mcp-manager.js +157 -74
- package/dist/tool-system/mcp-stdio-diagnostics.d.ts +9 -0
- package/dist/tool-system/mcp-stdio-diagnostics.js +93 -0
- package/dist/tool-system/path-policy.d.ts +2 -0
- package/dist/tool-system/path-policy.js +41 -12
- package/dist/tool-system/permission.d.ts +28 -7
- package/dist/tool-system/permission.js +130 -49
- package/dist/tool-system/registry.js +11 -4
- package/dist/tool-system/tool-result-redaction.d.ts +7 -0
- package/dist/tool-system/tool-result-redaction.js +48 -0
- package/dist/tool-system/workspace-bridge.d.ts +11 -0
- package/dist/tool-system/workspace-bridge.js +1 -0
- package/dist/types.d.ts +86 -5
- package/dist/utils/toolDisplay.js +1 -1
- package/package.json +4 -3
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* Following Claude Code's po_() pattern:
|
|
5
5
|
* pre_check → model_call → post_check → tool_exec → context_mgmt → hook_notify → next turn
|
|
6
6
|
*/
|
|
7
|
-
import type { Message, StreamCallback, TerminalReason, ContentBlock, ToolResult } from "../types.js";
|
|
7
|
+
import type { Message, StreamCallback, TerminalReason, ContentBlock, ToolResult, TokenUsage, ContextUsageAnchor } from "../types.js";
|
|
8
8
|
import type { SteerItem } from "./steer-queue.js";
|
|
9
9
|
import { ModelFacade } from "./model-facade.js";
|
|
10
10
|
import { ToolExecutor } from "../tool-system/executor.js";
|
|
11
11
|
import { ContextManager } from "../context/manager.js";
|
|
12
12
|
import { HookRegistry } from "../hooks/registry.js";
|
|
13
13
|
import { Transcript } from "../session/transcript.js";
|
|
14
|
+
import { type CumulativeUsageCounters } from "./session-usage.js";
|
|
14
15
|
import { type GoalConfig, type GoalExtension } from "./goal.js";
|
|
15
16
|
export interface TurnLoopConfig {
|
|
16
17
|
maxTurns: number;
|
|
@@ -18,6 +19,12 @@ export interface TurnLoopConfig {
|
|
|
18
19
|
tokenBudget?: number;
|
|
19
20
|
onStream?: StreamCallback;
|
|
20
21
|
signal?: AbortSignal;
|
|
22
|
+
/**
|
|
23
|
+
* Image-bearing messages added for the current request and not yet consumed
|
|
24
|
+
* by the model. TurnLoop preserves their base64 for one successful model
|
|
25
|
+
* response, then downgrades them to placeholders in the working history.
|
|
26
|
+
*/
|
|
27
|
+
freshImageMessages?: Iterable<Message>;
|
|
21
28
|
/**
|
|
22
29
|
* Fired after each turn boundary is recorded. Lets the engine flush an
|
|
23
30
|
* up-to-date snapshot to state.json mid-run, so a long run doesn't leave
|
|
@@ -76,6 +83,13 @@ export interface TurnLoopDeps {
|
|
|
76
83
|
before: number;
|
|
77
84
|
after: number;
|
|
78
85
|
} | null;
|
|
86
|
+
/**
|
|
87
|
+
* Records one LLM response into the session-monotonic cumulative counters.
|
|
88
|
+
* Returns the updated counters so usage_update can carry both metric scopes.
|
|
89
|
+
*/
|
|
90
|
+
recordCumulativeUsage?: (usage: TokenUsage) => CumulativeUsageCounters;
|
|
91
|
+
/** Persist the latest context-estimation anchor derived from provider usage. */
|
|
92
|
+
recordContextUsageAnchor?: (anchor: ContextUsageAnchor) => void;
|
|
79
93
|
/**
|
|
80
94
|
* Reads/clears any user messages queued for THIS session via the steering
|
|
81
95
|
* channel (Engine.enqueueSteer) while a run is in flight. Consumed at the top
|
|
@@ -84,7 +98,13 @@ export interface TurnLoopDeps {
|
|
|
84
98
|
* Returns [] when nothing is queued. Wired by Engine; absent in standalone
|
|
85
99
|
* tests (turn loop tolerates undefined).
|
|
86
100
|
*/
|
|
87
|
-
consumeSteer?: () => SteerItem[];
|
|
101
|
+
consumeSteer?: (source?: "normal_step" | "finalize_backfill") => SteerItem[];
|
|
102
|
+
/**
|
|
103
|
+
* Execution-level idempotency guard for host-supplied user/steer intents.
|
|
104
|
+
* Returns false only when a present clientMessageId has already entered this
|
|
105
|
+
* run or the persisted transcript. Messages without an id bypass this guard.
|
|
106
|
+
*/
|
|
107
|
+
claimClientMessageId?: (clientMessageId: string, source: "steer") => boolean;
|
|
88
108
|
/**
|
|
89
109
|
* Clear this session's PERSISTED goal (state.activeGoal) and drop the
|
|
90
110
|
* in-flight goal-stop hook, so a user-initiated cancel_goal both stops the
|
|
@@ -121,6 +141,10 @@ export declare class TurnLoop {
|
|
|
121
141
|
private currentTurnLog;
|
|
122
142
|
/** Last emitted ctx token estimate; used to skip no-op usage_update events. */
|
|
123
143
|
private lastCtxEmit;
|
|
144
|
+
private currentTurnUsage;
|
|
145
|
+
private currentCumulativeUsage;
|
|
146
|
+
private readonly sensitiveToolResultRedactions;
|
|
147
|
+
private readonly pendingImageMessages;
|
|
124
148
|
/**
|
|
125
149
|
* Consecutive on_stop blocks (Goal mode kept the agent going). Reset to 0
|
|
126
150
|
* on any unblocked completion. When it reaches config.maxStopBlocks the
|
|
@@ -178,6 +202,11 @@ export declare class TurnLoop {
|
|
|
178
202
|
* for one Stop still writes a single marker.
|
|
179
203
|
*/
|
|
180
204
|
private markStopped;
|
|
205
|
+
private prepareMessagesForModel;
|
|
206
|
+
private markPendingImagesConsumed;
|
|
207
|
+
private redactConsumedSensitiveToolResults;
|
|
208
|
+
private modelCallRecordingOptions;
|
|
209
|
+
private trackFreshImageMessage;
|
|
181
210
|
private emitHook;
|
|
182
211
|
/**
|
|
183
212
|
* Emit a usage_update so the UI ctx bar reflects current message-array
|
|
@@ -187,17 +216,20 @@ export declare class TurnLoop {
|
|
|
187
216
|
* promptTokens to override our estimate).
|
|
188
217
|
*/
|
|
189
218
|
private emitCtxFromMessages;
|
|
219
|
+
private recordResponseUsage;
|
|
190
220
|
private emitCtxFromUsage;
|
|
191
221
|
/**
|
|
192
222
|
* Run the multi-turn agent loop until completion.
|
|
193
223
|
*/
|
|
194
224
|
run(initialMessages: Message[]): Promise<TurnLoopResult>;
|
|
225
|
+
private runUnredacted;
|
|
195
226
|
/**
|
|
196
227
|
* Call model with streaming fallback.
|
|
197
228
|
* If streaming fails, emit tombstone and retry non-streaming.
|
|
198
229
|
*/
|
|
199
230
|
private callModelWithFallback;
|
|
200
231
|
get currentTurn(): number;
|
|
232
|
+
private consumeQueuedSteer;
|
|
201
233
|
/**
|
|
202
234
|
* Generate synthetic error tool_results for any dangling tool_use blocks
|
|
203
235
|
* that never received results (e.g. because the API call failed).
|