@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
package/dist/engine/engine.d.ts
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
import type { LLMConfig, StreamCallback } from "../types.js";
|
|
5
5
|
import { ToolRegistry } from "../tool-system/registry.js";
|
|
6
6
|
import { type BuiltinToolFn } from "../tool-system/builtin/index.js";
|
|
7
|
+
import { type ApprovalRouter } from "../tool-system/permission.js";
|
|
7
8
|
import { HookRegistry } from "../hooks/registry.js";
|
|
8
9
|
import { type GoalConfig, type GoalExtension } from "./goal.js";
|
|
9
10
|
import { type CompactStrategy } from "../context/manager.js";
|
|
10
|
-
import { SessionManager } from "../session/session-manager.js";
|
|
11
|
+
import { SessionManager, type ForkSessionOptions, type ForkSessionResult } from "../session/session-manager.js";
|
|
11
12
|
import type { AskUserFn } from "../tool-system/builtin/ask-user.js";
|
|
12
13
|
import type { CapabilityOverride } from "../settings/schema.js";
|
|
13
14
|
import { type FeatureFlagName } from "../settings/feature-flags.js";
|
|
@@ -34,6 +35,38 @@ export interface EnqueueSteerResult {
|
|
|
34
35
|
accepted: boolean;
|
|
35
36
|
id: string;
|
|
36
37
|
}
|
|
38
|
+
interface EngineRunOptions {
|
|
39
|
+
cwd?: string;
|
|
40
|
+
onStream?: StreamCallback;
|
|
41
|
+
signal?: AbortSignal;
|
|
42
|
+
sessionId?: string;
|
|
43
|
+
/** Immutable permission context for this run only. Omitted uses Engine config. */
|
|
44
|
+
permissionMode?: NonNullable<EngineConfig["permissionMode"]>;
|
|
45
|
+
/** Immutable plan context for this run only. Omitted follows permissionMode. */
|
|
46
|
+
planMode?: boolean;
|
|
47
|
+
/** Protocol connection's approval owner router for this run. */
|
|
48
|
+
approvalRouter?: ApprovalRouter;
|
|
49
|
+
/**
|
|
50
|
+
* Goal mode for this run: the engine registers a GoalStopHook so the
|
|
51
|
+
* turn loop runs until the session model judges this goal met. Falls
|
|
52
|
+
* back to config.goal. Orthogonal to permissionMode. Accepts a raw
|
|
53
|
+
* string or a full GoalConfig; normalized once at the run boundary.
|
|
54
|
+
*/
|
|
55
|
+
goal?: string | GoalConfig;
|
|
56
|
+
/**
|
|
57
|
+
* Marks this turn's task as a SYNTHETIC system-reminder injection (e.g. a
|
|
58
|
+
* background-job completion notification the server re-injects to wake an
|
|
59
|
+
* idle session) rather than the user's own input. The task is still sent
|
|
60
|
+
* to the model as a `role:"user"` message, but it is persisted with an
|
|
61
|
+
* `injected` flag so the disk reader skips rendering it as a user bubble
|
|
62
|
+
* on replay (matching the live UI, which shows only the assistant reply).
|
|
63
|
+
*/
|
|
64
|
+
injected?: boolean;
|
|
65
|
+
/** Stable id for this user-intent, used to make duplicate submits idempotent. */
|
|
66
|
+
clientMessageId?: string;
|
|
67
|
+
/** Structured input attachments. Legacy `<codeshell-image>` blocks remain supported. */
|
|
68
|
+
attachments?: InputAttachmentMeta[];
|
|
69
|
+
}
|
|
37
70
|
export { diskDefaultsFrom, type DiskDefaultPatch } from "../settings/disk-defaults.js";
|
|
38
71
|
/**
|
|
39
72
|
* Resolve the LLM config for a spawned child Engine.
|
|
@@ -122,6 +155,8 @@ export declare class Engine {
|
|
|
122
155
|
/** Shared resources supplied at construction (adapter pattern — null when self-constructed). */
|
|
123
156
|
readonly runtime: EngineRuntime | null;
|
|
124
157
|
private readonly sandboxCache;
|
|
158
|
+
private readonly interactiveBackends;
|
|
159
|
+
private activeApprovalRouter;
|
|
125
160
|
/** Active permission mode for this Engine instance. */
|
|
126
161
|
permissionMode: NonNullable<EngineConfig["permissionMode"]>;
|
|
127
162
|
/** True when permissionMode === "plan". */
|
|
@@ -154,6 +189,7 @@ export declare class Engine {
|
|
|
154
189
|
* LLM response arrives.
|
|
155
190
|
*/
|
|
156
191
|
private ctxOverheadBySid;
|
|
192
|
+
private lastCacheReadBySid;
|
|
157
193
|
/**
|
|
158
194
|
* Step-gap steering queue (per sessionId, in-memory). Host pushes user
|
|
159
195
|
* messages here via enqueueSteer while a run is in flight; the turn loop
|
|
@@ -187,6 +223,19 @@ export declare class Engine {
|
|
|
187
223
|
* Null when idle; set at run start, cleared in run's finally.
|
|
188
224
|
*/
|
|
189
225
|
private activeRunSession;
|
|
226
|
+
/**
|
|
227
|
+
* Same-instance run guard. Engine owns single-valued live controls and one
|
|
228
|
+
* HookRegistry, so a second run must not enter until the first has completed
|
|
229
|
+
* all state persistence and end hooks. This prevents handle contamination and
|
|
230
|
+
* whole-state saveState overlap only within this Engine instance. It does not
|
|
231
|
+
* coordinate different Engine instances sharing a sessionId, Workers, or
|
|
232
|
+
* processes; session-level locking/CAS for those cases is a separate finding.
|
|
233
|
+
*/
|
|
234
|
+
private runInProgress;
|
|
235
|
+
/** Permission update requested while runInProgress. Applied in run() finally. */
|
|
236
|
+
private pendingPermissionMode;
|
|
237
|
+
/** Plan update paired with pendingPermissionMode for one atomic boundary apply. */
|
|
238
|
+
private pendingPlanMode;
|
|
190
239
|
/** Public accessor so UI/clients can read the resolved per-model window. */
|
|
191
240
|
get maxContextTokens(): number;
|
|
192
241
|
private resolveMaxContextTokens;
|
|
@@ -278,7 +327,7 @@ export declare class Engine {
|
|
|
278
327
|
* the queued draft) and is the handle `unsteer` uses to revoke a still-pending
|
|
279
328
|
* entry. A blank id is tolerated but means the entry can't be revoked.
|
|
280
329
|
*/
|
|
281
|
-
enqueueSteer(sessionId: string, text: string, id?: string, clientMessageId?: string): EnqueueSteerResult;
|
|
330
|
+
enqueueSteer(sessionId: string, text: string, id?: string, clientMessageId?: string, attachments?: InputAttachmentMeta[]): EnqueueSteerResult;
|
|
282
331
|
/**
|
|
283
332
|
* Revoke a still-pending steer entry (the 撤回 path). Returns true if it was
|
|
284
333
|
* removed, false if it was already consumed by the turn loop (can't take it
|
|
@@ -287,6 +336,8 @@ export declare class Engine {
|
|
|
287
336
|
unsteer(sessionId: string, id: string): boolean;
|
|
288
337
|
/** Drain + clear the steer queue for a session (turn loop consumes per step). */
|
|
289
338
|
private consumeSteer;
|
|
339
|
+
/** Put failed steer preparation back ahead of messages queued while it was being prepared. */
|
|
340
|
+
private restoreSteer;
|
|
290
341
|
/** Wire the cookie→browser injection callback (InjectCredential tool). Same
|
|
291
342
|
* post-construction injection model as setBrowserBridge. */
|
|
292
343
|
setInjectCredential(fn: import("../tool-system/context.js").InjectCredentialFn | undefined): void;
|
|
@@ -303,35 +354,14 @@ export declare class Engine {
|
|
|
303
354
|
* against a blank session. A stat probe, not a load.
|
|
304
355
|
*/
|
|
305
356
|
sessionExistsOnDisk(sessionId: string): boolean;
|
|
357
|
+
forkSession(sourceSessionId: string, options?: ForkSessionOptions): ForkSessionResult;
|
|
306
358
|
/**
|
|
307
|
-
* Run a task from start to finish.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
sessionId?: string;
|
|
314
|
-
/**
|
|
315
|
-
* Goal mode for this run: the engine registers a GoalStopHook so the
|
|
316
|
-
* turn loop runs until the session model judges this goal met. Falls
|
|
317
|
-
* back to config.goal. Orthogonal to permissionMode. Accepts a raw
|
|
318
|
-
* string or a full GoalConfig; normalized once at the run boundary.
|
|
319
|
-
*/
|
|
320
|
-
goal?: string | GoalConfig;
|
|
321
|
-
/**
|
|
322
|
-
* Marks this turn's task as a SYNTHETIC system-reminder injection (e.g. a
|
|
323
|
-
* background-job completion notification the server re-injects to wake an
|
|
324
|
-
* idle session) rather than the user's own input. The task is still sent
|
|
325
|
-
* to the model as a `role:"user"` message, but it is persisted with an
|
|
326
|
-
* `injected` flag so the disk reader skips rendering it as a user bubble
|
|
327
|
-
* on replay (matching the live UI, which shows only the assistant reply).
|
|
328
|
-
*/
|
|
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[];
|
|
334
|
-
}): Promise<EngineResult>;
|
|
359
|
+
* Run a task from start to finish. Rejects immediately when this Engine
|
|
360
|
+
* instance already has a run in progress; hosts that want queueing own that
|
|
361
|
+
* policy (for example ChatSession's FIFO queue).
|
|
362
|
+
*/
|
|
363
|
+
run(task: string, options?: EngineRunOptions): Promise<EngineResult>;
|
|
364
|
+
private runExclusive;
|
|
335
365
|
/**
|
|
336
366
|
* Run the end-of-session memory pipeline as a fire-and-forget background
|
|
337
367
|
* task. Extracts durable memories from the transcript, saves a session
|
|
@@ -482,7 +512,8 @@ export declare class Engine {
|
|
|
482
512
|
after: number;
|
|
483
513
|
strategy: "none (no active session)" | "no compaction needed" | "compacted" | CompactStrategy;
|
|
484
514
|
}>;
|
|
485
|
-
private
|
|
515
|
+
private stripInjectedContextMessages;
|
|
516
|
+
private recordCacheReadDiagnostics;
|
|
486
517
|
private getSettingsManager;
|
|
487
518
|
/**
|
|
488
519
|
* Update a config setting at runtime.
|
|
@@ -495,12 +526,14 @@ export declare class Engine {
|
|
|
495
526
|
readSetting(key: string): unknown;
|
|
496
527
|
private buildPermissionConfig;
|
|
497
528
|
/**
|
|
498
|
-
* Switch permission mode at runtime.
|
|
499
|
-
*
|
|
500
|
-
* and
|
|
529
|
+
* Switch permission mode at runtime. Idle updates apply immediately; busy
|
|
530
|
+
* updates are committed atomically when the current run settles, so its
|
|
531
|
+
* classifier and ToolContext retain the immutable start-of-run snapshot.
|
|
501
532
|
* Session-only — does not persist to settings.
|
|
502
533
|
*/
|
|
503
534
|
setPermissionMode(mode: NonNullable<EngineConfig["permissionMode"]>): void;
|
|
535
|
+
private applyPermissionState;
|
|
536
|
+
private applyPendingPermissionState;
|
|
504
537
|
getPermissionMode(): NonNullable<EngineConfig["permissionMode"]>;
|
|
505
538
|
/**
|
|
506
539
|
* Extend the in-flight run's turn ceiling and/or goal budgets (TODO 3.1 —
|