@cjhyy/code-shell-core 0.9.3 → 0.9.5
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/engine/engine.d.ts +8 -0
- package/dist/engine/engine.js +16 -12
- package/dist/engine/model-facade.d.ts +3 -0
- package/dist/engine/model-facade.js +2 -0
- package/dist/engine/run-tooling.js +8 -8
- package/dist/engine/streaming-tool-queue.d.ts +4 -1
- package/dist/engine/streaming-tool-queue.js +17 -2
- package/dist/engine/turn-loop.d.ts +14 -5
- package/dist/engine/turn-loop.js +92 -37
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/llm/prompt-cache.d.ts +48 -0
- package/dist/llm/prompt-cache.js +100 -0
- package/dist/llm/providers/anthropic.d.ts +3 -0
- package/dist/llm/providers/anthropic.js +77 -53
- package/dist/llm/providers/openai.d.ts +7 -27
- package/dist/llm/providers/openai.js +120 -68
- package/dist/llm/types.d.ts +3 -0
- package/dist/panel-apps/manifest.d.ts +12 -12
- package/dist/profile/types.d.ts +26 -26
- package/dist/session/session-manager.js +30 -1
- package/dist/tool-system/context.d.ts +9 -4
- package/dist/tool-system/external-tool-exposure.js +11 -10
- package/package.json +2 -1
|
@@ -57,37 +57,37 @@ export declare const PanelAppAgentContribution: z.ZodEffects<z.ZodObject<{
|
|
|
57
57
|
}>, "many">>;
|
|
58
58
|
skills: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
59
59
|
}, "strict", z.ZodTypeAny, {
|
|
60
|
-
skills: string[];
|
|
61
60
|
tools: {
|
|
62
61
|
name: string;
|
|
63
62
|
description: string;
|
|
64
63
|
inputSchema: Record<string, unknown>;
|
|
65
64
|
readOnly: boolean;
|
|
66
65
|
}[];
|
|
66
|
+
skills: string[];
|
|
67
67
|
}, {
|
|
68
|
-
skills?: string[] | undefined;
|
|
69
68
|
tools?: {
|
|
70
69
|
name: string;
|
|
71
70
|
description: string;
|
|
72
71
|
inputSchema: Record<string, unknown>;
|
|
73
72
|
readOnly?: boolean | undefined;
|
|
74
73
|
}[] | undefined;
|
|
74
|
+
skills?: string[] | undefined;
|
|
75
75
|
}>, {
|
|
76
|
-
skills: string[];
|
|
77
76
|
tools: {
|
|
78
77
|
name: string;
|
|
79
78
|
description: string;
|
|
80
79
|
inputSchema: Record<string, unknown>;
|
|
81
80
|
readOnly: boolean;
|
|
82
81
|
}[];
|
|
82
|
+
skills: string[];
|
|
83
83
|
}, {
|
|
84
|
-
skills?: string[] | undefined;
|
|
85
84
|
tools?: {
|
|
86
85
|
name: string;
|
|
87
86
|
description: string;
|
|
88
87
|
inputSchema: Record<string, unknown>;
|
|
89
88
|
readOnly?: boolean | undefined;
|
|
90
89
|
}[] | undefined;
|
|
90
|
+
skills?: string[] | undefined;
|
|
91
91
|
}>;
|
|
92
92
|
/**
|
|
93
93
|
* Schema v2 keeps one installable Panel App identity while allowing it to
|
|
@@ -178,37 +178,37 @@ export declare const PanelAppManifest: z.ZodEffects<z.ZodDiscriminatedUnion<"sch
|
|
|
178
178
|
}>, "many">>;
|
|
179
179
|
skills: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
180
180
|
}, "strict", z.ZodTypeAny, {
|
|
181
|
-
skills: string[];
|
|
182
181
|
tools: {
|
|
183
182
|
name: string;
|
|
184
183
|
description: string;
|
|
185
184
|
inputSchema: Record<string, unknown>;
|
|
186
185
|
readOnly: boolean;
|
|
187
186
|
}[];
|
|
187
|
+
skills: string[];
|
|
188
188
|
}, {
|
|
189
|
-
skills?: string[] | undefined;
|
|
190
189
|
tools?: {
|
|
191
190
|
name: string;
|
|
192
191
|
description: string;
|
|
193
192
|
inputSchema: Record<string, unknown>;
|
|
194
193
|
readOnly?: boolean | undefined;
|
|
195
194
|
}[] | undefined;
|
|
195
|
+
skills?: string[] | undefined;
|
|
196
196
|
}>, {
|
|
197
|
-
skills: string[];
|
|
198
197
|
tools: {
|
|
199
198
|
name: string;
|
|
200
199
|
description: string;
|
|
201
200
|
inputSchema: Record<string, unknown>;
|
|
202
201
|
readOnly: boolean;
|
|
203
202
|
}[];
|
|
203
|
+
skills: string[];
|
|
204
204
|
}, {
|
|
205
|
-
skills?: string[] | undefined;
|
|
206
205
|
tools?: {
|
|
207
206
|
name: string;
|
|
208
207
|
description: string;
|
|
209
208
|
inputSchema: Record<string, unknown>;
|
|
210
209
|
readOnly?: boolean | undefined;
|
|
211
210
|
}[] | undefined;
|
|
211
|
+
skills?: string[] | undefined;
|
|
212
212
|
}>>;
|
|
213
213
|
id: z.ZodString;
|
|
214
214
|
version: z.ZodString;
|
|
@@ -247,13 +247,13 @@ export declare const PanelAppManifest: z.ZodEffects<z.ZodDiscriminatedUnion<"sch
|
|
|
247
247
|
placement: "right-dock";
|
|
248
248
|
singleton: boolean;
|
|
249
249
|
agent?: {
|
|
250
|
-
skills: string[];
|
|
251
250
|
tools: {
|
|
252
251
|
name: string;
|
|
253
252
|
description: string;
|
|
254
253
|
inputSchema: Record<string, unknown>;
|
|
255
254
|
readOnly: boolean;
|
|
256
255
|
}[];
|
|
256
|
+
skills: string[];
|
|
257
257
|
} | undefined;
|
|
258
258
|
description?: string | undefined;
|
|
259
259
|
}, {
|
|
@@ -267,13 +267,13 @@ export declare const PanelAppManifest: z.ZodEffects<z.ZodDiscriminatedUnion<"sch
|
|
|
267
267
|
};
|
|
268
268
|
schemaVersion: 2;
|
|
269
269
|
agent?: {
|
|
270
|
-
skills?: string[] | undefined;
|
|
271
270
|
tools?: {
|
|
272
271
|
name: string;
|
|
273
272
|
description: string;
|
|
274
273
|
inputSchema: Record<string, unknown>;
|
|
275
274
|
readOnly?: boolean | undefined;
|
|
276
275
|
}[] | undefined;
|
|
276
|
+
skills?: string[] | undefined;
|
|
277
277
|
} | undefined;
|
|
278
278
|
description?: string | undefined;
|
|
279
279
|
permissions?: ("context.session" | "context.workspace" | "storage" | "external.open" | "agent.submitPrompt" | "agent.task" | "workspace.info" | "workspace.read" | "workspace.write" | "notifications.send" | "audio.transcribe" | "credentials.cookies" | "automations.manage" | "process")[] | undefined;
|
|
@@ -310,13 +310,13 @@ export declare const PanelAppManifest: z.ZodEffects<z.ZodDiscriminatedUnion<"sch
|
|
|
310
310
|
placement: "right-dock";
|
|
311
311
|
singleton: boolean;
|
|
312
312
|
agent?: {
|
|
313
|
-
skills: string[];
|
|
314
313
|
tools: {
|
|
315
314
|
name: string;
|
|
316
315
|
description: string;
|
|
317
316
|
inputSchema: Record<string, unknown>;
|
|
318
317
|
readOnly: boolean;
|
|
319
318
|
}[];
|
|
319
|
+
skills: string[];
|
|
320
320
|
} | undefined;
|
|
321
321
|
description?: string | undefined;
|
|
322
322
|
}, {
|
|
@@ -345,13 +345,13 @@ export declare const PanelAppManifest: z.ZodEffects<z.ZodDiscriminatedUnion<"sch
|
|
|
345
345
|
};
|
|
346
346
|
schemaVersion: 2;
|
|
347
347
|
agent?: {
|
|
348
|
-
skills?: string[] | undefined;
|
|
349
348
|
tools?: {
|
|
350
349
|
name: string;
|
|
351
350
|
description: string;
|
|
352
351
|
inputSchema: Record<string, unknown>;
|
|
353
352
|
readOnly?: boolean | undefined;
|
|
354
353
|
}[] | undefined;
|
|
354
|
+
skills?: string[] | undefined;
|
|
355
355
|
} | undefined;
|
|
356
356
|
description?: string | undefined;
|
|
357
357
|
permissions?: ("context.session" | "context.workspace" | "storage" | "external.open" | "agent.submitPrompt" | "agent.task" | "workspace.info" | "workspace.read" | "workspace.write" | "notifications.send" | "audio.transcribe" | "credentials.cookies" | "automations.manage" | "process")[] | undefined;
|
package/dist/profile/types.d.ts
CHANGED
|
@@ -125,6 +125,11 @@ export declare const WorkspaceProfileRequirementsSchema: z.ZodObject<{
|
|
|
125
125
|
hint?: string | undefined;
|
|
126
126
|
}>, "many">>;
|
|
127
127
|
}, "strip", z.ZodTypeAny, {
|
|
128
|
+
tools: {
|
|
129
|
+
bin: string;
|
|
130
|
+
minVersion?: string | undefined;
|
|
131
|
+
hint?: string | undefined;
|
|
132
|
+
}[];
|
|
128
133
|
skills: {
|
|
129
134
|
source: "github";
|
|
130
135
|
scope: "project";
|
|
@@ -132,12 +137,12 @@ export declare const WorkspaceProfileRequirementsSchema: z.ZodObject<{
|
|
|
132
137
|
fullDepth: boolean;
|
|
133
138
|
skills?: string[] | undefined;
|
|
134
139
|
}[];
|
|
135
|
-
|
|
140
|
+
}, {
|
|
141
|
+
tools?: {
|
|
136
142
|
bin: string;
|
|
137
143
|
minVersion?: string | undefined;
|
|
138
144
|
hint?: string | undefined;
|
|
139
|
-
}[];
|
|
140
|
-
}, {
|
|
145
|
+
}[] | undefined;
|
|
141
146
|
skills?: {
|
|
142
147
|
source: "github";
|
|
143
148
|
repo: string;
|
|
@@ -145,11 +150,6 @@ export declare const WorkspaceProfileRequirementsSchema: z.ZodObject<{
|
|
|
145
150
|
skills?: string[] | undefined;
|
|
146
151
|
fullDepth?: boolean | undefined;
|
|
147
152
|
}[] | undefined;
|
|
148
|
-
tools?: {
|
|
149
|
-
bin: string;
|
|
150
|
-
minVersion?: string | undefined;
|
|
151
|
-
hint?: string | undefined;
|
|
152
|
-
}[] | undefined;
|
|
153
153
|
}>;
|
|
154
154
|
export type SkillRequirement = z.infer<typeof skillRequirementSchema>;
|
|
155
155
|
export type ToolRequirement = z.infer<typeof toolRequirementSchema>;
|
|
@@ -206,6 +206,11 @@ export declare const WorkspaceProfileSchema: z.ZodObject<{
|
|
|
206
206
|
hint?: string | undefined;
|
|
207
207
|
}>, "many">>;
|
|
208
208
|
}, "strip", z.ZodTypeAny, {
|
|
209
|
+
tools: {
|
|
210
|
+
bin: string;
|
|
211
|
+
minVersion?: string | undefined;
|
|
212
|
+
hint?: string | undefined;
|
|
213
|
+
}[];
|
|
209
214
|
skills: {
|
|
210
215
|
source: "github";
|
|
211
216
|
scope: "project";
|
|
@@ -213,12 +218,12 @@ export declare const WorkspaceProfileSchema: z.ZodObject<{
|
|
|
213
218
|
fullDepth: boolean;
|
|
214
219
|
skills?: string[] | undefined;
|
|
215
220
|
}[];
|
|
216
|
-
|
|
221
|
+
}, {
|
|
222
|
+
tools?: {
|
|
217
223
|
bin: string;
|
|
218
224
|
minVersion?: string | undefined;
|
|
219
225
|
hint?: string | undefined;
|
|
220
|
-
}[];
|
|
221
|
-
}, {
|
|
226
|
+
}[] | undefined;
|
|
222
227
|
skills?: {
|
|
223
228
|
source: "github";
|
|
224
229
|
repo: string;
|
|
@@ -226,11 +231,6 @@ export declare const WorkspaceProfileSchema: z.ZodObject<{
|
|
|
226
231
|
skills?: string[] | undefined;
|
|
227
232
|
fullDepth?: boolean | undefined;
|
|
228
233
|
}[] | undefined;
|
|
229
|
-
tools?: {
|
|
230
|
-
bin: string;
|
|
231
|
-
minVersion?: string | undefined;
|
|
232
|
-
hint?: string | undefined;
|
|
233
|
-
}[] | undefined;
|
|
234
234
|
}>>;
|
|
235
235
|
/**
|
|
236
236
|
* true → 独占工作面:激活时把**未声明**的 skill/plugin/mcp/agent 显式关掉,
|
|
@@ -264,6 +264,11 @@ export declare const WorkspaceProfileSchema: z.ZodObject<{
|
|
|
264
264
|
version?: string | undefined;
|
|
265
265
|
description?: string | undefined;
|
|
266
266
|
requires?: {
|
|
267
|
+
tools: {
|
|
268
|
+
bin: string;
|
|
269
|
+
minVersion?: string | undefined;
|
|
270
|
+
hint?: string | undefined;
|
|
271
|
+
}[];
|
|
267
272
|
skills: {
|
|
268
273
|
source: "github";
|
|
269
274
|
scope: "project";
|
|
@@ -271,11 +276,6 @@ export declare const WorkspaceProfileSchema: z.ZodObject<{
|
|
|
271
276
|
fullDepth: boolean;
|
|
272
277
|
skills?: string[] | undefined;
|
|
273
278
|
}[];
|
|
274
|
-
tools: {
|
|
275
|
-
bin: string;
|
|
276
|
-
minVersion?: string | undefined;
|
|
277
|
-
hint?: string | undefined;
|
|
278
|
-
}[];
|
|
279
279
|
} | undefined;
|
|
280
280
|
mainInstruction?: string | undefined;
|
|
281
281
|
}, {
|
|
@@ -289,6 +289,11 @@ export declare const WorkspaceProfileSchema: z.ZodObject<{
|
|
|
289
289
|
plugins?: string[] | undefined;
|
|
290
290
|
agents?: string[] | undefined;
|
|
291
291
|
requires?: {
|
|
292
|
+
tools?: {
|
|
293
|
+
bin: string;
|
|
294
|
+
minVersion?: string | undefined;
|
|
295
|
+
hint?: string | undefined;
|
|
296
|
+
}[] | undefined;
|
|
292
297
|
skills?: {
|
|
293
298
|
source: "github";
|
|
294
299
|
repo: string;
|
|
@@ -296,11 +301,6 @@ export declare const WorkspaceProfileSchema: z.ZodObject<{
|
|
|
296
301
|
skills?: string[] | undefined;
|
|
297
302
|
fullDepth?: boolean | undefined;
|
|
298
303
|
}[] | undefined;
|
|
299
|
-
tools?: {
|
|
300
|
-
bin: string;
|
|
301
|
-
minVersion?: string | undefined;
|
|
302
|
-
hint?: string | undefined;
|
|
303
|
-
}[] | undefined;
|
|
304
304
|
} | undefined;
|
|
305
305
|
exclusiveCapabilities?: boolean | undefined;
|
|
306
306
|
mainInstruction?: string | undefined;
|
|
@@ -237,13 +237,42 @@ function normalizedSessionKind(kind) {
|
|
|
237
237
|
export function codeShellHome() {
|
|
238
238
|
return process.env.CODE_SHELL_HOME || join(homedir(), ".code-shell");
|
|
239
239
|
}
|
|
240
|
+
/** True when this process is a test runner. `bun test` sets NODE_ENV itself. */
|
|
241
|
+
function isTestRunner() {
|
|
242
|
+
return process.env.NODE_ENV === "test" || process.env.BUN_TEST === "1";
|
|
243
|
+
}
|
|
244
|
+
/** The real per-user home, ignoring any CODE_SHELL_HOME override. */
|
|
245
|
+
function defaultHome() {
|
|
246
|
+
return join(homedir(), ".code-shell");
|
|
247
|
+
}
|
|
240
248
|
/**
|
|
241
249
|
* Canonical root for every persisted CodeShell session. An explicit `home`
|
|
242
250
|
* (a `~/.code-shell`-equivalent data root) overrides the default resolution;
|
|
243
251
|
* absent → `codeShellHome()` exactly as before.
|
|
244
252
|
*/
|
|
245
253
|
export function sessionsRoot(home) {
|
|
246
|
-
|
|
254
|
+
const resolvedHome = home ?? codeShellHome();
|
|
255
|
+
// Fail closed rather than write fixture sessions into the developer's real
|
|
256
|
+
// store. The bunfig preload only applies when Bun resolves a bunfig.toml:
|
|
257
|
+
// `bun test <file>` from a subdirectory, or an IDE/CI runner with its own
|
|
258
|
+
// cwd, finds none and silently fell through to ~/.code-shell — which is how
|
|
259
|
+
// ~700 `test-model` sessions ended up in the real store and the sidebar.
|
|
260
|
+
//
|
|
261
|
+
// Guarded here rather than in codeShellHome() because the home is also the
|
|
262
|
+
// legitimate root for settings/projects/trust that many tests read by
|
|
263
|
+
// design; only the SESSIONS root is the one tests corrupt.
|
|
264
|
+
if (isTestRunner() && resolvedHome === defaultHome()) {
|
|
265
|
+
// Prefer the preload's sandbox. Many test files delete CODE_SHELL_HOME in
|
|
266
|
+
// cleanup, and bun shares one process across files, so isolation would
|
|
267
|
+
// otherwise vanish for every later suite.
|
|
268
|
+
const sandbox = process.env.CODE_SHELL_TEST_HOME;
|
|
269
|
+
if (sandbox)
|
|
270
|
+
return join(sandbox, "sessions");
|
|
271
|
+
throw new SessionError("Refusing to use the real ~/.code-shell/sessions from a test. Set CODE_SHELL_HOME " +
|
|
272
|
+
"to a temp dir (packages/core/test-setup.ts does this via the bunfig preload) " +
|
|
273
|
+
"or pass an explicit storageDir.");
|
|
274
|
+
}
|
|
275
|
+
return join(resolvedHome, "sessions");
|
|
247
276
|
}
|
|
248
277
|
function isSessionWorkspace(value) {
|
|
249
278
|
if (!value || typeof value !== "object")
|
|
@@ -215,13 +215,18 @@ export interface ExternalFileChangesRecord {
|
|
|
215
215
|
changedFiles: string[];
|
|
216
216
|
originClientMessageId?: string;
|
|
217
217
|
}
|
|
218
|
-
export type ToolRunYieldReason = "background_notification";
|
|
219
|
-
/**
|
|
218
|
+
export type ToolRunYieldReason = "background_notification" | "reply_committed";
|
|
219
|
+
/**
|
|
220
|
+
* Run-scoped handoff from a trusted tool to the owning turn loop. Distinct
|
|
221
|
+
* reasons accumulate independently: one batch may both commit a host reply
|
|
222
|
+
* and launch background work, and the loop decides boundary precedence.
|
|
223
|
+
*/
|
|
220
224
|
export interface ToolRunYieldController {
|
|
221
225
|
request(reason: ToolRunYieldReason): void;
|
|
222
226
|
/** Inspect without clearing so the loop can prioritize an accepted steer. */
|
|
223
|
-
peek
|
|
224
|
-
|
|
227
|
+
peek(reason: ToolRunYieldReason): boolean;
|
|
228
|
+
/** Clear one pending reason; true if it was pending. */
|
|
229
|
+
consume(reason: ToolRunYieldReason): boolean;
|
|
225
230
|
}
|
|
226
231
|
export interface ToolContext {
|
|
227
232
|
/** Active working directory for this Engine. */
|
|
@@ -62,8 +62,9 @@ export const FIRST_PHASE_EXPOSURE_RATIONALE = [
|
|
|
62
62
|
},
|
|
63
63
|
// ── Delegation and state-machine exceptions ──────────────────────
|
|
64
64
|
// Agent and the two plan-state tools remain structurally excluded. DriveAgent
|
|
65
|
-
// is the reviewed exception because the
|
|
66
|
-
//
|
|
65
|
+
// is the reviewed exception because the child does not inherit the host
|
|
66
|
+
// bridge and background work is allowed only when the host guarantees an
|
|
67
|
+
// observable completion handoff.
|
|
67
68
|
{
|
|
68
69
|
tool: "Agent",
|
|
69
70
|
kind: "self-contained",
|
|
@@ -78,19 +79,19 @@ export const FIRST_PHASE_EXPOSURE_RATIONALE = [
|
|
|
78
79
|
kind: "self-contained",
|
|
79
80
|
status: "exposed",
|
|
80
81
|
reason: "Delegates one bounded task to an installed Codex/Claude CLI. External " +
|
|
81
|
-
"sessions
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"bridge, which bounds nesting at one level; the outer call
|
|
85
|
-
"the normal DriveAgent approval.",
|
|
82
|
+
"sessions may detach it only when the Desktop host promises to drain the " +
|
|
83
|
+
"completion queue and inject a continuation into the same Session; other " +
|
|
84
|
+
"hosts fail closed and require foreground execution. The child CLI does not " +
|
|
85
|
+
"inherit this host bridge, which bounds nesting at one level; the outer call " +
|
|
86
|
+
"still requires the normal DriveAgent approval.",
|
|
86
87
|
},
|
|
87
88
|
{
|
|
88
89
|
tool: "DriveAgentJobs",
|
|
89
90
|
kind: "self-contained",
|
|
90
91
|
status: "exposed",
|
|
91
|
-
reason: "Lets the runtime inspect or cancel retained DriveAgent jobs
|
|
92
|
-
"
|
|
93
|
-
"
|
|
92
|
+
reason: "Lets the runtime inspect or cancel retained DriveAgent jobs, including " +
|
|
93
|
+
"Desktop-backed background delegations whose completion is delivered through " +
|
|
94
|
+
"the owning Session.",
|
|
94
95
|
},
|
|
95
96
|
{
|
|
96
97
|
tool: "EnterPlanMode",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cjhyy/code-shell-core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Core engine for code-shell — agent orchestration, tool execution, hooks, protocol. UI-agnostic.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "bun run clean && tsc -p tsconfig.json && bun run copy-assets",
|
|
41
|
+
"test": "bun test --timeout 30000 src",
|
|
41
42
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
42
43
|
"copy-assets": "node ../../scripts/copy-assets.mjs dist/prompt/sections src/prompt/sections/*.md && node ../../scripts/copy-assets.mjs dist/data src/data/*.json",
|
|
43
44
|
"dev": "bun run copy-assets && tsc -p tsconfig.json --watch --preserveWatchOutput",
|