@cjhyy/code-shell-core 0.7.0-beta.1 → 0.7.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/dist/arena/arena.d.ts +2 -0
- package/dist/arena/arena.js +30 -1
- package/dist/arena/phases/adjudication.d.ts +2 -1
- package/dist/arena/phases/adjudication.js +2 -1
- package/dist/arena/phases/build-consensus.d.ts +2 -1
- package/dist/arena/phases/build-consensus.js +3 -1
- package/dist/arena/phases/cross-review.d.ts +3 -1
- package/dist/arena/phases/cross-review.js +8 -2
- package/dist/arena/phases/debate-rounds.d.ts +2 -1
- package/dist/arena/phases/debate-rounds.js +4 -2
- package/dist/arena/phases/participant-research.d.ts +2 -1
- package/dist/arena/phases/participant-research.js +3 -1
- package/dist/arena/phases/planning-detail-expansion.d.ts +2 -1
- package/dist/arena/phases/planning-detail-expansion.js +2 -1
- package/dist/arena/planner.d.ts +2 -1
- package/dist/arena/planner.js +2 -1
- package/dist/arena/types.d.ts +5 -1
- package/dist/cc-orchestrator/agent-adapter.d.ts +2 -0
- package/dist/cc-orchestrator/agent-adapter.js +4 -0
- package/dist/cc-orchestrator/codex-session-history.d.ts +14 -1
- package/dist/cc-orchestrator/codex-session-history.js +64 -4
- package/dist/cc-orchestrator/external-agent-changes.js +22 -5
- package/dist/cc-orchestrator/external-agent-driver.d.ts +1 -1
- package/dist/cc-orchestrator/external-agent-driver.js +202 -38
- package/dist/cc-orchestrator/session-history.d.ts +35 -0
- package/dist/cc-orchestrator/session-history.js +96 -13
- package/dist/cli/agent-server-tcp.js +13 -2
- package/dist/context/manager.d.ts +3 -3
- package/dist/context/manager.js +6 -6
- package/dist/context/token-counter.js +5 -3
- package/dist/context/tool-result-storage.d.ts +6 -0
- package/dist/context/tool-result-storage.js +25 -4
- package/dist/credentials/access.d.ts +11 -1
- package/dist/credentials/access.js +77 -1
- package/dist/credentials/index.d.ts +3 -1
- package/dist/credentials/index.js +2 -0
- package/dist/credentials/oauth.d.ts +25 -0
- package/dist/credentials/oauth.js +179 -0
- package/dist/credentials/store.d.ts +2 -1
- package/dist/credentials/store.js +19 -8
- package/dist/credentials/types.d.ts +84 -1
- package/dist/credentials/types.js +16 -1
- package/dist/engine/engine.d.ts +67 -34
- package/dist/engine/engine.js +448 -247
- package/dist/engine/goal.d.ts +19 -0
- package/dist/engine/goal.js +16 -6
- package/dist/engine/input-attachments.js +156 -13
- package/dist/engine/run-image-input.d.ts +22 -0
- package/dist/engine/run-image-input.js +195 -0
- package/dist/engine/session-title.d.ts +2 -1
- package/dist/engine/session-title.js +4 -1
- package/dist/engine/steer-queue.d.ts +3 -1
- package/dist/engine/steer-queue.js +10 -2
- package/dist/engine/turn-loop.d.ts +48 -1
- package/dist/engine/turn-loop.js +307 -37
- package/dist/engine/types.d.ts +6 -2
- package/dist/git/worktree/crud.d.ts +3 -0
- package/dist/git/worktree/crud.js +32 -3
- package/dist/git/worktree/git-exec.d.ts +2 -2
- package/dist/git/worktree/git-exec.js +47 -11
- package/dist/git/worktree/query.d.ts +8 -7
- package/dist/git/worktree/query.js +27 -20
- package/dist/hooks/events.d.ts +3 -0
- package/dist/hooks/events.js +0 -3
- package/dist/hooks/goal-stop-hook.d.ts +44 -2
- package/dist/hooks/goal-stop-hook.js +775 -52
- package/dist/hooks/registry.js +3 -0
- package/dist/hooks/shell-runner.d.ts +12 -1
- package/dist/hooks/shell-runner.js +160 -9
- package/dist/index.d.ts +7 -6
- package/dist/index.js +6 -5
- package/dist/llm/client-base.js +12 -10
- package/dist/llm/types.d.ts +12 -5
- package/dist/plugins/pluginCommandHook.d.ts +4 -4
- package/dist/plugins/pluginCommandHook.js +111 -13
- package/dist/preset/index.js +14 -4
- package/dist/protocol/chat-session-manager.d.ts +13 -2
- package/dist/protocol/chat-session-manager.js +90 -18
- package/dist/protocol/chat-session.d.ts +12 -0
- package/dist/protocol/chat-session.js +30 -5
- package/dist/protocol/client.d.ts +5 -2
- package/dist/protocol/client.js +22 -1
- package/dist/protocol/server.d.ts +25 -11
- package/dist/protocol/server.js +291 -73
- package/dist/protocol/types.d.ts +36 -2
- package/dist/protocol/types.js +2 -0
- package/dist/services/dream-consolidation.d.ts +3 -0
- package/dist/services/dream-consolidation.js +4 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/oauth.d.ts +34 -10
- package/dist/services/oauth.js +233 -98
- package/dist/session/session-manager.d.ts +35 -6
- package/dist/session/session-manager.js +396 -27
- package/dist/session/transcript.d.ts +30 -1
- package/dist/session/transcript.js +119 -4
- package/dist/tool-system/builtin/agent-notifications.d.ts +11 -4
- package/dist/tool-system/builtin/agent-notifications.js +19 -7
- package/dist/tool-system/builtin/agent.js +5 -1
- package/dist/tool-system/builtin/arena.js +1 -0
- package/dist/tool-system/builtin/background-jobs.d.ts +28 -5
- package/dist/tool-system/builtin/background-jobs.js +109 -7
- package/dist/tool-system/builtin/background-work.d.ts +6 -1
- package/dist/tool-system/builtin/background-work.js +5 -1
- package/dist/tool-system/builtin/bash.d.ts +3 -5
- package/dist/tool-system/builtin/bash.js +10 -5
- package/dist/tool-system/builtin/browser-tools.d.ts +2 -2
- package/dist/tool-system/builtin/cron-list.definition.d.ts +3 -0
- package/dist/tool-system/builtin/cron-list.definition.js +6 -0
- package/dist/tool-system/builtin/cron.d.ts +1 -2
- package/dist/tool-system/builtin/cron.js +9 -7
- package/dist/tool-system/builtin/drive-claude-code.d.ts +7 -0
- package/dist/tool-system/builtin/drive-claude-code.js +307 -20
- package/dist/tool-system/builtin/edit.d.ts +2 -1
- package/dist/tool-system/builtin/edit.js +12 -4
- package/dist/tool-system/builtin/generate-video.d.ts +4 -0
- package/dist/tool-system/builtin/generate-video.js +138 -21
- package/dist/tool-system/builtin/glob.d.ts +2 -1
- package/dist/tool-system/builtin/glob.js +28 -3
- package/dist/tool-system/builtin/grep.d.ts +1 -0
- package/dist/tool-system/builtin/grep.js +82 -17
- package/dist/tool-system/builtin/index.d.ts +25 -11
- package/dist/tool-system/builtin/index.js +60 -5
- package/dist/tool-system/builtin/sleep.d.ts +1 -2
- package/dist/tool-system/builtin/sleep.definition.d.ts +8 -0
- package/dist/tool-system/builtin/sleep.definition.js +28 -0
- package/dist/tool-system/builtin/sleep.js +1 -22
- package/dist/tool-system/builtin/video-providers.d.ts +12 -15
- package/dist/tool-system/builtin/video-providers.js +1 -0
- package/dist/tool-system/builtin/view-image.d.ts +2 -2
- package/dist/tool-system/builtin/web-fetch.js +44 -3
- package/dist/tool-system/builtin/worktree.js +25 -7
- package/dist/tool-system/builtin/write.d.ts +2 -1
- package/dist/tool-system/builtin/write.js +14 -4
- package/dist/tool-system/context.d.ts +35 -5
- package/dist/tool-system/executor.js +24 -8
- package/dist/tool-system/mcp-manager.d.ts +20 -2
- package/dist/tool-system/mcp-manager.js +111 -12
- package/dist/tool-system/path-policy.d.ts +19 -0
- package/dist/tool-system/path-policy.js +62 -1
- package/dist/tool-system/permission.d.ts +43 -3
- package/dist/tool-system/permission.js +383 -30
- package/dist/tool-system/registry.d.ts +3 -2
- package/dist/tool-system/registry.js +52 -34
- package/dist/types.d.ts +38 -7
- package/package.json +1 -1
|
@@ -10,9 +10,10 @@ 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
|
+
import { type GoalJudgeRuntimeContext } from "../hooks/goal-stop-hook.js";
|
|
13
14
|
import { Transcript } from "../session/transcript.js";
|
|
14
15
|
import { type CumulativeUsageCounters } from "./session-usage.js";
|
|
15
|
-
import { type GoalConfig, type GoalExtension } from "./goal.js";
|
|
16
|
+
import { type GoalConfig, type GoalExtension, type GoalTerminationReason } from "./goal.js";
|
|
16
17
|
export interface TurnLoopConfig {
|
|
17
18
|
maxTurns: number;
|
|
18
19
|
maxToolCallsPerTurn: number;
|
|
@@ -25,6 +26,11 @@ export interface TurnLoopConfig {
|
|
|
25
26
|
* response, then downgrades them to placeholders in the working history.
|
|
26
27
|
*/
|
|
27
28
|
freshImageMessages?: Iterable<Message>;
|
|
29
|
+
/**
|
|
30
|
+
* Per-run injected context that must be visible to the model but must not be
|
|
31
|
+
* summarized into durable history. Engine uses this for dynamicContext.
|
|
32
|
+
*/
|
|
33
|
+
volatileContextMessages?: Iterable<Message>;
|
|
28
34
|
/**
|
|
29
35
|
* Fired after each turn boundary is recorded. Lets the engine flush an
|
|
30
36
|
* up-to-date snapshot to state.json mid-run, so a long run doesn't leave
|
|
@@ -88,6 +94,11 @@ export interface TurnLoopDeps {
|
|
|
88
94
|
* Returns the updated counters so usage_update can carry both metric scopes.
|
|
89
95
|
*/
|
|
90
96
|
recordCumulativeUsage?: (usage: TokenUsage) => CumulativeUsageCounters;
|
|
97
|
+
/**
|
|
98
|
+
* Lightweight per-session prompt-cache diagnostic, owned by Engine because it
|
|
99
|
+
* needs memory across TurnLoop instances.
|
|
100
|
+
*/
|
|
101
|
+
recordCacheReadDiagnostics?: (usage: TokenUsage) => void;
|
|
91
102
|
/** Persist the latest context-estimation anchor derived from provider usage. */
|
|
92
103
|
recordContextUsageAnchor?: (anchor: ContextUsageAnchor) => void;
|
|
93
104
|
/**
|
|
@@ -99,12 +110,20 @@ export interface TurnLoopDeps {
|
|
|
99
110
|
* tests (turn loop tolerates undefined).
|
|
100
111
|
*/
|
|
101
112
|
consumeSteer?: (source?: "normal_step" | "finalize_backfill") => SteerItem[];
|
|
113
|
+
/** Restore steer items whose model-facing content could not be prepared. */
|
|
114
|
+
restoreSteer?: (items: SteerItem[]) => void;
|
|
115
|
+
/** Build model-facing content for a queued steer item, including attachments. */
|
|
116
|
+
buildSteerUserMessageContent?: (item: SteerItem) => string | ContentBlock[] | Promise<string | ContentBlock[]>;
|
|
102
117
|
/**
|
|
103
118
|
* Execution-level idempotency guard for host-supplied user/steer intents.
|
|
104
119
|
* Returns false only when a present clientMessageId has already entered this
|
|
105
120
|
* run or the persisted transcript. Messages without an id bypass this guard.
|
|
106
121
|
*/
|
|
107
122
|
claimClientMessageId?: (clientMessageId: string, source: "steer") => boolean;
|
|
123
|
+
/** Release a steer id reservation when preparation fails before persistence. */
|
|
124
|
+
releaseClientMessageId?: (clientMessageId: string) => void;
|
|
125
|
+
/** Make tools launched after an injected steer attribute side effects to that steer. */
|
|
126
|
+
setOriginClientMessageId?: (clientMessageId: string | undefined) => void;
|
|
108
127
|
/**
|
|
109
128
|
* Clear this session's PERSISTED goal (state.activeGoal) and drop the
|
|
110
129
|
* in-flight goal-stop hook, so a user-initiated cancel_goal both stops the
|
|
@@ -114,11 +133,18 @@ export interface TurnLoopDeps {
|
|
|
114
133
|
* goalTracker short-circuit still stops the run).
|
|
115
134
|
*/
|
|
116
135
|
clearPersistedGoal?: () => void;
|
|
136
|
+
/**
|
|
137
|
+
* Private Goal-judge evidence seam. Engine stores this snapshot in the
|
|
138
|
+
* built-in judge closure; it is never added to the public on_stop context.
|
|
139
|
+
*/
|
|
140
|
+
updateGoalJudgeContext?: (context: GoalJudgeRuntimeContext) => void;
|
|
117
141
|
}
|
|
118
142
|
export interface TurnLoopResult {
|
|
119
143
|
text: string;
|
|
120
144
|
reason: TerminalReason;
|
|
121
145
|
messages: Message[];
|
|
146
|
+
/** Goal-specific forced terminal outcome; public TerminalReason stays stable. */
|
|
147
|
+
goalTermination?: GoalTerminationReason;
|
|
122
148
|
}
|
|
123
149
|
/**
|
|
124
150
|
* 把一个 ToolResult 映射成发给 LLM 的 tool_result ContentBlock。
|
|
@@ -145,6 +171,11 @@ export declare class TurnLoop {
|
|
|
145
171
|
private currentCumulativeUsage;
|
|
146
172
|
private readonly sensitiveToolResultRedactions;
|
|
147
173
|
private readonly pendingImageMessages;
|
|
174
|
+
private readonly volatileContextMessages;
|
|
175
|
+
/** Last outer-loop turn for which the model returned a complete response. */
|
|
176
|
+
private lastCompletedModelTurn;
|
|
177
|
+
/** Last model turn whose transcript/persistence boundary was finalized. */
|
|
178
|
+
private lastFinalizedTurn;
|
|
148
179
|
/**
|
|
149
180
|
* Consecutive on_stop blocks (Goal mode kept the agent going). Reset to 0
|
|
150
181
|
* on any unblocked completion. When it reaches config.maxStopBlocks the
|
|
@@ -177,6 +208,13 @@ export declare class TurnLoop {
|
|
|
177
208
|
timeBudgetMs?: number;
|
|
178
209
|
maxStopBlocks: number;
|
|
179
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Private Goal-judge accounting seam. Judge calls bypass ModelFacade, so the
|
|
213
|
+
* Engine forwards their provider usage here while the run-scoped tracker is
|
|
214
|
+
* live. The returned reason lets the hook suppress verdict side effects when
|
|
215
|
+
* this very request crossed a hard token/time budget.
|
|
216
|
+
*/
|
|
217
|
+
recordGoalJudgeUsage(usage: TokenUsage | undefined): Extract<GoalTerminationReason, "token_budget_exhausted" | "time_budget_exhausted"> | undefined;
|
|
180
218
|
/**
|
|
181
219
|
* Goal mode only: if the run is nearing EITHER stop ceiling (maxTurns or
|
|
182
220
|
* maxStopBlocks) and we haven't announced it yet, emit one approaching_limit
|
|
@@ -202,7 +240,16 @@ export declare class TurnLoop {
|
|
|
202
240
|
* for one Stop still writes a single marker.
|
|
203
241
|
*/
|
|
204
242
|
private markStopped;
|
|
243
|
+
/**
|
|
244
|
+
* Close one completed model turn exactly once. The transcript boundary must
|
|
245
|
+
* be durable before the Engine flushes usage, heartbeat, and turnCount via
|
|
246
|
+
* onTurnBoundary, so crash recovery never folds two assistant responses into
|
|
247
|
+
* the same transcript turn or observes state ahead of the transcript.
|
|
248
|
+
*/
|
|
249
|
+
private finalizeModelTurn;
|
|
205
250
|
private prepareMessagesForModel;
|
|
251
|
+
private stripVolatileContextMessages;
|
|
252
|
+
private appendVolatileContextMessages;
|
|
206
253
|
private markPendingImagesConsumed;
|
|
207
254
|
private redactConsumedSensitiveToolResults;
|
|
208
255
|
private modelCallRecordingOptions;
|