@bastani/atomic 0.9.53-alpha.1 → 0.9.54-alpha.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/CHANGELOG.md +54 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +2 -1
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +2 -1
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +2 -1
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +17 -1
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +19 -0
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.js +2 -1
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
- package/dist/core/agent-session-summary.d.ts.map +1 -1
- package/dist/core/agent-session-summary.js +2 -1
- package/dist/core/agent-session-summary.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +2 -1
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/exec.d.ts +9 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +109 -74
- package/dist/core/exec.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +2 -2
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/model-resolver-patterns.d.ts.map +1 -1
- package/dist/core/model-resolver-patterns.js +15 -9
- package/dist/core/model-resolver-patterns.js.map +1 -1
- package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
- package/dist/core/package-manager-auto-resources.js +3 -2
- package/dist/core/package-manager-auto-resources.js.map +1 -1
- package/dist/core/package-manager-git.d.ts +1 -1
- package/dist/core/package-manager-git.d.ts.map +1 -1
- package/dist/core/package-manager-git.js +12 -1
- package/dist/core/package-manager-git.js.map +1 -1
- package/dist/core/package-manager-npm.d.ts +1 -1
- package/dist/core/package-manager-npm.d.ts.map +1 -1
- package/dist/core/package-manager-npm.js +8 -4
- package/dist/core/package-manager-npm.js.map +1 -1
- package/dist/core/package-manager-operations.d.ts.map +1 -1
- package/dist/core/package-manager-operations.js +33 -8
- package/dist/core/package-manager-operations.js.map +1 -1
- package/dist/core/package-manager-resolver.d.ts.map +1 -1
- package/dist/core/package-manager-resolver.js +22 -4
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/package-manager-resource-accumulator.d.ts.map +1 -1
- package/dist/core/package-manager-resource-accumulator.js +4 -4
- package/dist/core/package-manager-resource-accumulator.js.map +1 -1
- package/dist/core/package-manager-source.js +5 -5
- package/dist/core/package-manager-source.js.map +1 -1
- package/dist/core/package-manager-types.d.ts +5 -1
- package/dist/core/package-manager-types.d.ts.map +1 -1
- package/dist/core/package-manager-types.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +3 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +2 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-templates-async.d.ts.map +1 -1
- package/dist/core/prompt-templates-async.js +4 -9
- package/dist/core/prompt-templates-async.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +4 -12
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +8 -7
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-paths.js +5 -5
- package/dist/core/resource-loader-paths.js.map +1 -1
- package/dist/core/resource-loader-source-info.d.ts +0 -1
- package/dist/core/resource-loader-source-info.d.ts.map +1 -1
- package/dist/core/resource-loader-source-info.js +6 -17
- package/dist/core/resource-loader-source-info.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.js +2 -2
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.js +2 -2
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/skills-async.d.ts.map +1 -1
- package/dist/core/skills-async.js +5 -10
- package/dist/core/skills-async.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +5 -13
- package/dist/core/skills.js.map +1 -1
- package/dist/core/source-info.d.ts +2 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +5 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/tool-loadout.d.ts +4 -0
- package/dist/core/tool-loadout.d.ts.map +1 -1
- package/dist/core/tool-loadout.js +7 -1
- package/dist/core/tool-loadout.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +2 -7
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +15 -9
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +33 -8
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -3
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.js +2 -13
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +2 -2
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-tree.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-tree.js +4 -6
- package/dist/modes/interactive/components/session-selector-tree.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-utils.d.ts +2 -1
- package/dist/modes/interactive/components/session-selector-utils.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-utils.js +5 -13
- package/dist/modes/interactive/components/session-selector-utils.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +2 -6
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +4 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +15 -8
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts +1 -0
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +1 -1
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +3 -0
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +5 -2
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/git.d.ts +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +5 -3
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/paths.d.ts +14 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +39 -1
- package/dist/utils/paths.js.map +1 -1
- package/docs/extensions/api-reference.md +4 -2
- package/docs/packages.md +2 -0
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -3,7 +3,7 @@ import { dirname, join } from "node:path";
|
|
|
3
3
|
import lockfile from "proper-lockfile";
|
|
4
4
|
import { CONFIG_DIR_NAMES } from "../config.js";
|
|
5
5
|
import { parseJsonFileContent } from "../utils/json.js";
|
|
6
|
-
import { canonicalizePath, getHomeDir, resolvePath } from "../utils/paths.js";
|
|
6
|
+
import { canonicalizePath, getHomeDir, pathsEqual, resolvePath } from "../utils/paths.js";
|
|
7
7
|
export const TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES = [
|
|
8
8
|
"settings.json",
|
|
9
9
|
"extensions",
|
|
@@ -16,12 +16,18 @@ export const TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES = [
|
|
|
16
16
|
function normalizeCwd(cwd) {
|
|
17
17
|
return canonicalizePath(resolvePath(cwd));
|
|
18
18
|
}
|
|
19
|
+
/** Trust file keys naming `path`. Usually one; several on Windows when saved with different casing. */
|
|
20
|
+
function findTrustFileKeys(data, path) {
|
|
21
|
+
return Object.keys(data).filter((key) => pathsEqual(key, path));
|
|
22
|
+
}
|
|
19
23
|
function findNearestTrustEntry(data, cwd) {
|
|
20
24
|
let currentDir = normalizeCwd(cwd);
|
|
21
25
|
while (true) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
for (const key of findTrustFileKeys(data, currentDir)) {
|
|
27
|
+
const value = data[key];
|
|
28
|
+
if (value === true || value === false) {
|
|
29
|
+
return { path: key, decision: value };
|
|
30
|
+
}
|
|
25
31
|
}
|
|
26
32
|
const parentDir = dirname(currentDir);
|
|
27
33
|
if (parentDir === currentDir) {
|
|
@@ -168,7 +174,7 @@ export function hasTrustRequiringProjectResources(cwd) {
|
|
|
168
174
|
let currentDir = canonicalizePath(resolvePath(cwd));
|
|
169
175
|
while (true) {
|
|
170
176
|
const skillsDir = canonicalizePath(resolvePath(join(currentDir, ".agents", "skills")));
|
|
171
|
-
if (skillsDir
|
|
177
|
+
if (!pathsEqual(skillsDir, userGlobalSkillsDir) && existsSync(skillsDir)) {
|
|
172
178
|
return true;
|
|
173
179
|
}
|
|
174
180
|
const parentDir = dirname(currentDir);
|
|
@@ -192,7 +198,7 @@ export function hasProjectTrustInputs(cwd) {
|
|
|
192
198
|
}
|
|
193
199
|
}
|
|
194
200
|
const skillsDir = canonicalizePath(resolvePath(join(currentDir, ".agents", "skills")));
|
|
195
|
-
if (skillsDir
|
|
201
|
+
if (!pathsEqual(skillsDir, userGlobalSkillsDir) && existsSync(skillsDir)) {
|
|
196
202
|
return true;
|
|
197
203
|
}
|
|
198
204
|
const parentDir = dirname(currentDir);
|
|
@@ -224,10 +230,10 @@ export class ProjectTrustStore {
|
|
|
224
230
|
const data = readTrustFile(this.trustPath);
|
|
225
231
|
for (const { path, decision } of decisions) {
|
|
226
232
|
const key = normalizeCwd(path);
|
|
227
|
-
|
|
228
|
-
delete data[
|
|
233
|
+
for (const existingKey of findTrustFileKeys(data, key)) {
|
|
234
|
+
delete data[existingKey];
|
|
229
235
|
}
|
|
230
|
-
|
|
236
|
+
if (decision !== null) {
|
|
231
237
|
data[key] = decision;
|
|
232
238
|
}
|
|
233
239
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trust-manager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AAG,CAAC,GAAW;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,IAAI,IAAI,CAAC;IAC7C,CAAC;IAED,QAAQ,CAAC,GAAW;QACnB,OAAO,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YAC7C,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC3C,OAAO,qBAAqB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,QAA8B;QAC9C,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,SAA+B;QACtC,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YACtC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC3C,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,SAAS,EAAE,CAAC;gBAC5C,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;gBAC/B,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;oBACvB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,CAAC;qBAAM,CAAC;oBACP,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACtB,CAAC;YACF,CAAC;YACD,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport lockfile from \"proper-lockfile\";\nimport { CONFIG_DIR_NAMES } from \"../config.js\";\nimport { parseJsonFileContent } from \"../utils/json.ts\";\nimport { canonicalizePath, getHomeDir, resolvePath } from \"../utils/paths.ts\";\n\nexport type ProjectTrustDecision = boolean | null;\n\nexport interface ProjectTrustStoreEntry {\n\tpath: string;\n\tdecision: boolean;\n}\n\nexport interface ProjectTrustUpdate {\n\tpath: string;\n\tdecision: ProjectTrustDecision;\n}\n\nexport interface ProjectTrustOption {\n\tlabel: string;\n\ttrusted: boolean;\n\tupdates: ProjectTrustUpdate[];\n\tsavedPath?: string;\n}\n\ntype TrustFile = Record<string, boolean | null | undefined>;\nexport const TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES = [\n\t\"settings.json\",\n\t\"extensions\",\n\t\"skills\",\n\t\"prompts\",\n\t\"themes\",\n\t\"SYSTEM.md\",\n\t\"APPEND_SYSTEM.md\",\n] as const;\n\nfunction normalizeCwd(cwd: string): string {\n\treturn canonicalizePath(resolvePath(cwd));\n}\n\nfunction findNearestTrustEntry(data: TrustFile, cwd: string): ProjectTrustStoreEntry | null {\n\tlet currentDir = normalizeCwd(cwd);\n\twhile (true) {\n\t\tconst value = data[currentDir];\n\t\tif (value === true || value === false) {\n\t\t\treturn { path: currentDir, decision: value };\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn null;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport function getProjectTrustPath(cwd: string): string {\n\treturn normalizeCwd(cwd);\n}\n\nexport function getProjectTrustParentPath(cwd: string): string | undefined {\n\tconst trustPath = getProjectTrustPath(cwd);\n\tconst parentDir = dirname(trustPath);\n\treturn parentDir === trustPath ? undefined : parentDir;\n}\n\nexport function getProjectTrustOptions(cwd: string, options?: { includeSessionOnly?: boolean }): ProjectTrustOption[] {\n\tconst trustPath = getProjectTrustPath(cwd);\n\tconst trustOptions: ProjectTrustOption[] = [\n\t\t{ label: \"Trust\", trusted: true, updates: [{ path: trustPath, decision: true }], savedPath: trustPath },\n\t];\n\tconst parentPath = getProjectTrustParentPath(cwd);\n\tif (parentPath !== undefined) {\n\t\ttrustOptions.push({\n\t\t\tlabel: `Trust parent folder (${parentPath})`,\n\t\t\ttrusted: true,\n\t\t\tupdates: [\n\t\t\t\t{ path: parentPath, decision: true },\n\t\t\t\t{ path: trustPath, decision: null },\n\t\t\t],\n\t\t\tsavedPath: parentPath,\n\t\t});\n\t}\n\tif (options?.includeSessionOnly) {\n\t\ttrustOptions.push({ label: \"Trust (this session only)\", trusted: true, updates: [] });\n\t}\n\ttrustOptions.push({\n\t\tlabel: \"Do not trust\",\n\t\ttrusted: false,\n\t\tupdates: [{ path: trustPath, decision: false }],\n\t\tsavedPath: trustPath,\n\t});\n\tif (options?.includeSessionOnly) {\n\t\ttrustOptions.push({ label: \"Do not trust (this session only)\", trusted: false, updates: [] });\n\t}\n\treturn trustOptions;\n}\n\nfunction readTrustFile(path: string): TrustFile {\n\tif (!existsSync(path)) {\n\t\treturn {};\n\t}\n\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = parseJsonFileContent(readFileSync(path, \"utf-8\"));\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Failed to read trust store ${path}: ${message}`);\n\t}\n\n\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\tthrow new Error(`Invalid trust store ${path}: expected an object`);\n\t}\n\n\tconst data: TrustFile = {};\n\tfor (const [key, value] of Object.entries(parsed)) {\n\t\tif (value !== true && value !== false && value !== null) {\n\t\t\tthrow new Error(`Invalid trust store ${path}: value for ${JSON.stringify(key)} must be true, false, or null`);\n\t\t}\n\t\tdata[key] = value;\n\t}\n\treturn data;\n}\n\nfunction writeTrustFile(path: string, data: TrustFile): void {\n\tconst sorted: TrustFile = {};\n\tfor (const key of Object.keys(data).sort()) {\n\t\tconst value = data[key];\n\t\tif (value === true || value === false || value === null) {\n\t\t\tsorted[key] = value;\n\t\t}\n\t}\n\tmkdirSync(dirname(path), { recursive: true });\n\twriteFileSync(path, `${JSON.stringify(sorted, null, 2)}\\n`, \"utf-8\");\n}\n\nfunction acquireTrustLockSync(path: string): () => void {\n\tconst trustDir = dirname(path);\n\tmkdirSync(trustDir, { recursive: true });\n\tconst maxAttempts = 10;\n\tconst delayMs = 20;\n\tlet lastError: unknown;\n\n\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\ttry {\n\t\t\treturn lockfile.lockSync(trustDir, { realpath: false, lockfilePath: `${path}.lock` });\n\t\t} catch (error) {\n\t\t\tconst code =\n\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t: undefined;\n\t\t\tif (code !== \"ELOCKED\" || attempt === maxAttempts) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tlastError = error;\n\t\t\tconst start = Date.now();\n\t\t\twhile (Date.now() - start < delayMs) {\n\t\t\t\t// Sleep synchronously to avoid changing trust store callers to async.\n\t\t\t}\n\t\t}\n\t}\n\n\tif (lastError instanceof Error) {\n\t\tthrow lastError;\n\t}\n\tthrow new Error(\"Failed to acquire trust store lock\");\n}\n\nfunction withTrustFileLock<T>(path: string, fn: () => T): T {\n\tconst release = acquireTrustLockSync(path);\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\trelease();\n\t}\n}\n\nexport function hasProjectConfigDir(cwd: string): boolean {\n\tconst projectCwd = canonicalizePath(resolvePath(cwd));\n\treturn CONFIG_DIR_NAMES.some((configDirName) => existsSync(join(projectCwd, configDirName)));\n}\nfunction hasTrustRequiringConfigResources(cwd: string): boolean {\n\tconst projectCwd = canonicalizePath(resolvePath(cwd));\n\treturn CONFIG_DIR_NAMES.some((configDirName) => {\n\t\tconst configDir = join(projectCwd, configDirName);\n\t\treturn TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some((entry) => existsSync(join(configDir, entry)));\n\t});\n}\n\n/**\n * Returns true when cwd has project-local resources that must be gated by\n * project trust: trust-requiring entries under cwd/.atomic or cwd/.pi, or\n * .agents/skills in cwd or one of its ancestors. Returns false for inert\n * state-only config directories. The user-global ~/.agents/skills directory is\n * always treated as a trusted user resource and ignored, even when cwd is $HOME.\n */\nexport function hasTrustRequiringProjectResources(cwd: string): boolean {\n\tif (hasTrustRequiringConfigResources(cwd)) {\n\t\treturn true;\n\t}\n\n\tconst userGlobalSkillsDir = canonicalizePath(resolvePath(join(getHomeDir(), \".agents\", \"skills\")));\n\tlet currentDir = canonicalizePath(resolvePath(cwd));\n\twhile (true) {\n\t\tconst skillsDir = canonicalizePath(resolvePath(join(currentDir, \".agents\", \"skills\")));\n\t\tif (skillsDir !== userGlobalSkillsDir && existsSync(skillsDir)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport function hasProjectTrustInputs(cwd: string): boolean {\n\tlet currentDir = canonicalizePath(resolvePath(cwd));\n\tif (hasTrustRequiringConfigResources(currentDir)) {\n\t\treturn true;\n\t}\n\tconst userGlobalSkillsDir = canonicalizePath(resolvePath(join(getHomeDir(), \".agents\", \"skills\")));\n\tconst contextFileNames = [\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"];\n\n\twhile (true) {\n\t\tfor (const contextFileName of contextFileNames) {\n\t\t\tif (existsSync(join(currentDir, contextFileName))) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tconst skillsDir = canonicalizePath(resolvePath(join(currentDir, \".agents\", \"skills\")));\n\t\tif (skillsDir !== userGlobalSkillsDir && existsSync(skillsDir)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport class ProjectTrustStore {\n\tprivate trustPath: string;\n\n\tconstructor(agentDir: string) {\n\t\tthis.trustPath = join(resolvePath(agentDir), \"trust.json\");\n\t}\n\n\tget(cwd: string): ProjectTrustDecision {\n\t\treturn this.getEntry(cwd)?.decision ?? null;\n\t}\n\n\tgetEntry(cwd: string): ProjectTrustStoreEntry | null {\n\t\treturn withTrustFileLock(this.trustPath, () => {\n\t\t\tconst data = readTrustFile(this.trustPath);\n\t\t\treturn findNearestTrustEntry(data, cwd);\n\t\t});\n\t}\n\n\tset(cwd: string, decision: ProjectTrustDecision): void {\n\t\tthis.setMany([{ path: cwd, decision }]);\n\t}\n\n\tsetMany(decisions: ProjectTrustUpdate[]): void {\n\t\twithTrustFileLock(this.trustPath, () => {\n\t\t\tconst data = readTrustFile(this.trustPath);\n\t\t\tfor (const { path, decision } of decisions) {\n\t\t\t\tconst key = normalizeCwd(path);\n\t\t\t\tif (decision === null) {\n\t\t\t\t\tdelete data[key];\n\t\t\t\t} else {\n\t\t\t\t\tdata[key] = decision;\n\t\t\t\t}\n\t\t\t}\n\t\t\twriteTrustFile(this.trustPath, data);\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"trust-manager.js","sourceRoot":"","sources":["../../src/core/trust-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsB1F,MAAM,CAAC,MAAM,wCAAwC,GAAG;IACvD,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,QAAQ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AI,CAAC,SAAS,EAAE,GAAG,EAAE;YAC7C,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC3C,OAAO,qBAAqB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,QAA8B;QAC9C,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAC,SAA+B;QACtC,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YACtC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC3C,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,SAAS,EAAE,CAAC;gBAC5C,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;gBAC/B,KAAK,MAAM,WAAW,IAAI,iBAAiB,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;oBACxD,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC;gBAC1B,CAAC;gBACD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;oBACvB,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACtB,CAAC;YACF,CAAC;YACD,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport lockfile from \"proper-lockfile\";\nimport { CONFIG_DIR_NAMES } from \"../config.js\";\nimport { parseJsonFileContent } from \"../utils/json.ts\";\nimport { canonicalizePath, getHomeDir, pathsEqual, resolvePath } from \"../utils/paths.ts\";\n\nexport type ProjectTrustDecision = boolean | null;\n\nexport interface ProjectTrustStoreEntry {\n\tpath: string;\n\tdecision: boolean;\n}\n\nexport interface ProjectTrustUpdate {\n\tpath: string;\n\tdecision: ProjectTrustDecision;\n}\n\nexport interface ProjectTrustOption {\n\tlabel: string;\n\ttrusted: boolean;\n\tupdates: ProjectTrustUpdate[];\n\tsavedPath?: string;\n}\n\ntype TrustFile = Record<string, boolean | null | undefined>;\nexport const TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES = [\n\t\"settings.json\",\n\t\"extensions\",\n\t\"skills\",\n\t\"prompts\",\n\t\"themes\",\n\t\"SYSTEM.md\",\n\t\"APPEND_SYSTEM.md\",\n] as const;\n\nfunction normalizeCwd(cwd: string): string {\n\treturn canonicalizePath(resolvePath(cwd));\n}\n\n/** Trust file keys naming `path`. Usually one; several on Windows when saved with different casing. */\nfunction findTrustFileKeys(data: TrustFile, path: string): string[] {\n\treturn Object.keys(data).filter((key) => pathsEqual(key, path));\n}\n\nfunction findNearestTrustEntry(data: TrustFile, cwd: string): ProjectTrustStoreEntry | null {\n\tlet currentDir = normalizeCwd(cwd);\n\twhile (true) {\n\t\tfor (const key of findTrustFileKeys(data, currentDir)) {\n\t\t\tconst value = data[key];\n\t\t\tif (value === true || value === false) {\n\t\t\t\treturn { path: key, decision: value };\n\t\t\t}\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn null;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport function getProjectTrustPath(cwd: string): string {\n\treturn normalizeCwd(cwd);\n}\n\nexport function getProjectTrustParentPath(cwd: string): string | undefined {\n\tconst trustPath = getProjectTrustPath(cwd);\n\tconst parentDir = dirname(trustPath);\n\treturn parentDir === trustPath ? undefined : parentDir;\n}\n\nexport function getProjectTrustOptions(cwd: string, options?: { includeSessionOnly?: boolean }): ProjectTrustOption[] {\n\tconst trustPath = getProjectTrustPath(cwd);\n\tconst trustOptions: ProjectTrustOption[] = [\n\t\t{ label: \"Trust\", trusted: true, updates: [{ path: trustPath, decision: true }], savedPath: trustPath },\n\t];\n\tconst parentPath = getProjectTrustParentPath(cwd);\n\tif (parentPath !== undefined) {\n\t\ttrustOptions.push({\n\t\t\tlabel: `Trust parent folder (${parentPath})`,\n\t\t\ttrusted: true,\n\t\t\tupdates: [\n\t\t\t\t{ path: parentPath, decision: true },\n\t\t\t\t{ path: trustPath, decision: null },\n\t\t\t],\n\t\t\tsavedPath: parentPath,\n\t\t});\n\t}\n\tif (options?.includeSessionOnly) {\n\t\ttrustOptions.push({ label: \"Trust (this session only)\", trusted: true, updates: [] });\n\t}\n\ttrustOptions.push({\n\t\tlabel: \"Do not trust\",\n\t\ttrusted: false,\n\t\tupdates: [{ path: trustPath, decision: false }],\n\t\tsavedPath: trustPath,\n\t});\n\tif (options?.includeSessionOnly) {\n\t\ttrustOptions.push({ label: \"Do not trust (this session only)\", trusted: false, updates: [] });\n\t}\n\treturn trustOptions;\n}\n\nfunction readTrustFile(path: string): TrustFile {\n\tif (!existsSync(path)) {\n\t\treturn {};\n\t}\n\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = parseJsonFileContent(readFileSync(path, \"utf-8\"));\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Failed to read trust store ${path}: ${message}`);\n\t}\n\n\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\tthrow new Error(`Invalid trust store ${path}: expected an object`);\n\t}\n\n\tconst data: TrustFile = {};\n\tfor (const [key, value] of Object.entries(parsed)) {\n\t\tif (value !== true && value !== false && value !== null) {\n\t\t\tthrow new Error(`Invalid trust store ${path}: value for ${JSON.stringify(key)} must be true, false, or null`);\n\t\t}\n\t\tdata[key] = value;\n\t}\n\treturn data;\n}\n\nfunction writeTrustFile(path: string, data: TrustFile): void {\n\tconst sorted: TrustFile = {};\n\tfor (const key of Object.keys(data).sort()) {\n\t\tconst value = data[key];\n\t\tif (value === true || value === false || value === null) {\n\t\t\tsorted[key] = value;\n\t\t}\n\t}\n\tmkdirSync(dirname(path), { recursive: true });\n\twriteFileSync(path, `${JSON.stringify(sorted, null, 2)}\\n`, \"utf-8\");\n}\n\nfunction acquireTrustLockSync(path: string): () => void {\n\tconst trustDir = dirname(path);\n\tmkdirSync(trustDir, { recursive: true });\n\tconst maxAttempts = 10;\n\tconst delayMs = 20;\n\tlet lastError: unknown;\n\n\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\ttry {\n\t\t\treturn lockfile.lockSync(trustDir, { realpath: false, lockfilePath: `${path}.lock` });\n\t\t} catch (error) {\n\t\t\tconst code =\n\t\t\t\ttypeof error === \"object\" && error !== null && \"code\" in error\n\t\t\t\t\t? String((error as { code?: unknown }).code)\n\t\t\t\t\t: undefined;\n\t\t\tif (code !== \"ELOCKED\" || attempt === maxAttempts) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tlastError = error;\n\t\t\tconst start = Date.now();\n\t\t\twhile (Date.now() - start < delayMs) {\n\t\t\t\t// Sleep synchronously to avoid changing trust store callers to async.\n\t\t\t}\n\t\t}\n\t}\n\n\tif (lastError instanceof Error) {\n\t\tthrow lastError;\n\t}\n\tthrow new Error(\"Failed to acquire trust store lock\");\n}\n\nfunction withTrustFileLock<T>(path: string, fn: () => T): T {\n\tconst release = acquireTrustLockSync(path);\n\ttry {\n\t\treturn fn();\n\t} finally {\n\t\trelease();\n\t}\n}\n\nexport function hasProjectConfigDir(cwd: string): boolean {\n\tconst projectCwd = canonicalizePath(resolvePath(cwd));\n\treturn CONFIG_DIR_NAMES.some((configDirName) => existsSync(join(projectCwd, configDirName)));\n}\nfunction hasTrustRequiringConfigResources(cwd: string): boolean {\n\tconst projectCwd = canonicalizePath(resolvePath(cwd));\n\treturn CONFIG_DIR_NAMES.some((configDirName) => {\n\t\tconst configDir = join(projectCwd, configDirName);\n\t\treturn TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES.some((entry) => existsSync(join(configDir, entry)));\n\t});\n}\n\n/**\n * Returns true when cwd has project-local resources that must be gated by\n * project trust: trust-requiring entries under cwd/.atomic or cwd/.pi, or\n * .agents/skills in cwd or one of its ancestors. Returns false for inert\n * state-only config directories. The user-global ~/.agents/skills directory is\n * always treated as a trusted user resource and ignored, even when cwd is $HOME.\n */\nexport function hasTrustRequiringProjectResources(cwd: string): boolean {\n\tif (hasTrustRequiringConfigResources(cwd)) {\n\t\treturn true;\n\t}\n\n\tconst userGlobalSkillsDir = canonicalizePath(resolvePath(join(getHomeDir(), \".agents\", \"skills\")));\n\tlet currentDir = canonicalizePath(resolvePath(cwd));\n\twhile (true) {\n\t\tconst skillsDir = canonicalizePath(resolvePath(join(currentDir, \".agents\", \"skills\")));\n\t\tif (!pathsEqual(skillsDir, userGlobalSkillsDir) && existsSync(skillsDir)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport function hasProjectTrustInputs(cwd: string): boolean {\n\tlet currentDir = canonicalizePath(resolvePath(cwd));\n\tif (hasTrustRequiringConfigResources(currentDir)) {\n\t\treturn true;\n\t}\n\tconst userGlobalSkillsDir = canonicalizePath(resolvePath(join(getHomeDir(), \".agents\", \"skills\")));\n\tconst contextFileNames = [\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"];\n\n\twhile (true) {\n\t\tfor (const contextFileName of contextFileNames) {\n\t\t\tif (existsSync(join(currentDir, contextFileName))) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tconst skillsDir = canonicalizePath(resolvePath(join(currentDir, \".agents\", \"skills\")));\n\t\tif (!pathsEqual(skillsDir, userGlobalSkillsDir) && existsSync(skillsDir)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tconst parentDir = dirname(currentDir);\n\t\tif (parentDir === currentDir) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrentDir = parentDir;\n\t}\n}\n\nexport class ProjectTrustStore {\n\tprivate trustPath: string;\n\n\tconstructor(agentDir: string) {\n\t\tthis.trustPath = join(resolvePath(agentDir), \"trust.json\");\n\t}\n\n\tget(cwd: string): ProjectTrustDecision {\n\t\treturn this.getEntry(cwd)?.decision ?? null;\n\t}\n\n\tgetEntry(cwd: string): ProjectTrustStoreEntry | null {\n\t\treturn withTrustFileLock(this.trustPath, () => {\n\t\t\tconst data = readTrustFile(this.trustPath);\n\t\t\treturn findNearestTrustEntry(data, cwd);\n\t\t});\n\t}\n\n\tset(cwd: string, decision: ProjectTrustDecision): void {\n\t\tthis.setMany([{ path: cwd, decision }]);\n\t}\n\n\tsetMany(decisions: ProjectTrustUpdate[]): void {\n\t\twithTrustFileLock(this.trustPath, () => {\n\t\t\tconst data = readTrustFile(this.trustPath);\n\t\t\tfor (const { path, decision } of decisions) {\n\t\t\t\tconst key = normalizeCwd(path);\n\t\t\t\tfor (const existingKey of findTrustFileKeys(data, key)) {\n\t\t\t\t\tdelete data[existingKey];\n\t\t\t\t}\n\t\t\t\tif (decision !== null) {\n\t\t\t\t\tdata[key] = decision;\n\t\t\t\t}\n\t\t\t}\n\t\t\twriteTrustFile(this.trustPath, data);\n\t\t});\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/extensions/codemode/tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAsB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGpF,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAe,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC3G,OAAO,KAAK,EAAE,aAAa,EAAE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AAM,CAgER;AAoFD,wBAAgB,4BAA4B,CAC3C,OAAO,GAAE,mBAAwB,GAC/B,cAAc,CAAC,OAAO,cAAc,EAAE,mBAAmB,CAAC,CAgB5D;AACD,wBAAgB,kBAAkB,CACjC,KAAK,GAAE,SAAS,SAAS,EAAO,EAChC,OAAO,GAAE,mBAAwB,GAC/B,SAAS,CAAC,OAAO,cAAc,CAAC,CAKlC"}
|
|
@@ -104,8 +104,8 @@ export function createCodemodeDescription(tools, options = {}) {
|
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* The field names of an object schema, `{ output, exit_code, full_output_path? }`, with the fields of
|
|
107
|
-
* object-typed fields `depth` levels deep: `{ content, structuredContent?: { results } }
|
|
108
|
-
* for other schemas.
|
|
107
|
+
* object-typed fields `depth` levels deep: `{ content, structuredContent?: { results } }`, and the
|
|
108
|
+
* value of `const` fields: `{ action: "start", id }`. Undefined for other schemas.
|
|
109
109
|
*/
|
|
110
110
|
function describeFields(schema, depth) {
|
|
111
111
|
if (typeof schema !== "object" || schema === null)
|
|
@@ -115,24 +115,49 @@ function describeFields(schema, depth) {
|
|
|
115
115
|
return undefined;
|
|
116
116
|
const requiredNames = new Set(Array.isArray(required) ? required : []);
|
|
117
117
|
const fields = Object.entries(properties).map(([name, field]) => {
|
|
118
|
-
const
|
|
118
|
+
const constValue = field?.const;
|
|
119
|
+
const nested = constValue !== undefined
|
|
120
|
+
? JSON.stringify(constValue)
|
|
121
|
+
: depth > 0
|
|
122
|
+
? describeFields(field, depth - 1)
|
|
123
|
+
: undefined;
|
|
119
124
|
return `${name}${requiredNames.has(name) ? "" : "?"}${nested ? `: ${nested}` : ""}`;
|
|
120
125
|
});
|
|
121
126
|
return `{ ${fields.join(", ")} }`;
|
|
122
127
|
}
|
|
123
128
|
/**
|
|
124
129
|
* What a script call resolves to, in one line: `a string`, the field names of an object (see
|
|
125
|
-
* {@link describeFields}),
|
|
130
|
+
* {@link describeFields}), the field names of each object in a union, the rendered type when it
|
|
131
|
+
* fits on one line, or a pointer to `describeTool()` for anything longer. The full type of a large
|
|
132
|
+
* schema would otherwise be sent with every request (#11501).
|
|
126
133
|
*/
|
|
127
|
-
function describeOutput(schema) {
|
|
134
|
+
function describeOutput(name, schema) {
|
|
128
135
|
const type = renderToolOutputType(schema);
|
|
129
136
|
if (type === "string")
|
|
130
137
|
return "a string";
|
|
131
|
-
const fields = describeFields(schema, 1);
|
|
132
|
-
|
|
138
|
+
const fields = describeFields(schema, 1) ?? describeUnionFields(schema);
|
|
139
|
+
if (fields)
|
|
140
|
+
return `\`${fields}\``;
|
|
141
|
+
if (!type.includes("\n"))
|
|
142
|
+
return `\`${type}\``;
|
|
143
|
+
return `a value; \`await describeTool(${JSON.stringify(name)})\` shows its type`;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The field names of each variant of an `anyOf`/`oneOf` whose variants are all objects, joined by
|
|
147
|
+
* `|`.
|
|
148
|
+
*/
|
|
149
|
+
function describeUnionFields(schema) {
|
|
150
|
+
if (typeof schema !== "object" || schema === null)
|
|
151
|
+
return undefined;
|
|
152
|
+
const { anyOf, oneOf } = schema;
|
|
153
|
+
const variants = anyOf ?? oneOf;
|
|
154
|
+
if (!Array.isArray(variants) || variants.length === 0)
|
|
155
|
+
return undefined;
|
|
156
|
+
const described = variants.map((variant) => describeFields(variant, 0));
|
|
157
|
+
return described.every((fields) => fields !== undefined) ? described.join(" | ") : undefined;
|
|
133
158
|
}
|
|
134
159
|
function describeScriptCall(tool) {
|
|
135
|
-
return `${tool.description.trim()}\n\nCodemode: \`tools.${toCodemodeIdentifier(tool.name)}(args)\` resolves to ${describeOutput(toCodemodeDeclaration(tool).outputSchema)}.`;
|
|
160
|
+
return `${tool.description.trim()}\n\nCodemode: \`tools.${toCodemodeIdentifier(tool.name)}(args)\` resolves to ${describeOutput(tool.name, toCodemodeDeclaration(tool).outputSchema)}.`;
|
|
136
161
|
}
|
|
137
162
|
function prepareLoadout(loadout, options) {
|
|
138
163
|
const only = options.getMode?.() === "only";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/extensions/codemode/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACxH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,WAAW,EAAE,EAAE,aAAa,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;AAC1D,MAAM,CAAC,MAAM,8BAA8B,GAAW,iBAAiB,CAAC,QAAQ,CAAC,YAAY,CAAC;AAoB9F,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;QACjB,WAAW,EACV,0IAA0I;KAC3I,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,IAA2C;IACzE,OAAO,IAAI,CAAC,IAAI,KAAK,kBAAkB,IAAI,IAAI,CAAC,UAAU,KAAK,cAAc,CAAC;AAC/E,CAAC;AAcD,MAAM,UAAU,qBAAqB,CACpC,IAAe,EACf,UAAU,GAAsB,EAAE;IAElC,MAAM,OAAO,GAAG,UAAU,CA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E,CACjD,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;QACxF,GAAG,iBAAiB;KACpB,CAAC;AACH,CAAC;AACD,MAAM,UAAU,kBAAkB,CACjC,KAAK,GAAyB,EAAE,EAChC,OAAO,GAAwB,EAAE;IAEjC,OAAO;QACN,GAAG,kBAAkB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC5D,WAAW,EAAE,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC;KACtD,CAAC;AACH,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { CodemodeJsonSchema, CodemodeTool } from \"@earendil-works/pi-codemode\";\nimport { renderToolOutputType, renderToolSample, toCodemodeIdentifier } from \"@earendil-works/pi-codemode/declarations\";\nimport { CODEMODE_SOURCE_GRAMMAR } from \"@earendil-works/pi-codemode/source\";\nimport { type Static, Type } from \"typebox\";\nimport { getDocsPath } from \"../../config.js\";\nimport type { ToolDefinition, ToolInfo, ToolLoadout, ToolNamespace } from \"../../core/extensions/types.ts\";\nimport type { ModelRegistry } from \"../../core/model-registry.ts\";\nimport { SETTINGS_DEFAULTS } from \"../../core/settings-defaults.ts\";\nimport type { CodemodeMode } from \"../../core/settings-manager.ts\";\nimport { wrapToolDefinition } from \"../../core/tools/tool-definition-wrapper.ts\";\nimport { codemodeRenderers } from \"./renderer.js\";\n\nexport const CODEMODE_TOOL_NAME = \"codemode\";\nexport const CODEMODE_DOCS_PATH = join(getDocsPath(), \"codemode.md\");\nexport const CODEMODE_STORE_ENTRY_TYPE = \"codemode-store\";\nexport const DEFAULT_CODEMODE_INLINE_BUDGET: number = SETTINGS_DEFAULTS.codemode.inlineBudget;\nexport interface CodemodeStoreEntryData {\n\tset: Record<string, unknown>;\n\tdelete: string[];\n}\nexport type CodemodeModelRuntime = Pick<\n\tModelRegistry,\n\t\"getModelsOfType\" | \"getAvailableOfType\" | \"getModelOfType\" | \"classify\" | \"generateImages\"\n>;\nexport interface CodemodeToolOptions {\n\tgetToolNamespace?: (name: string) => ToolNamespace | undefined;\n\t/** Prompt guidelines shown with tool declarations in describeTool() and ALL_TOOLS. */\n\tgetToolGuidelines?: () => ReadonlyMap<string, readonly string[]>;\n\tmodels?: boolean;\n\tappendEntry?: (type: string, data: CodemodeStoreEntryData) => Promise<void>;\n\tgetMode?: () => CodemodeMode;\n\tgetInlineBudget?: () => number | undefined;\n\t/** Active model-only tools. Scripts cannot call them, so discovery answers an exact name with a hint. */\n\tgetModelOnlyTools?: () => readonly string[];\n}\nexport const codemodeSchema = Type.Object({\n\tcode: Type.String({\n\t\tdescription:\n\t\t\t'Raw JavaScript source with top-level await and return. Optional first line // @options: {\"max_output_tokens\": 1000, \"timeout_ms\": 60000}',\n\t}),\n});\nexport type CodemodeToolInput = Static<typeof codemodeSchema>;\nexport function isCodemodeTool(tool: Pick<ToolInfo, \"name\" | \"parameters\">): boolean {\n\treturn tool.name === CODEMODE_TOOL_NAME && tool.parameters === codemodeSchema;\n}\nexport interface CodemodeNestedCall {\n\tid: string;\n\tname: string;\n\targs: string;\n\tstatus: \"running\" | \"ok\" | \"error\" | \"cancelled\";\n\tdurationMs?: number;\n\terror?: string;\n\tcost?: number;\n}\nexport interface CodemodeToolDetails {\n\tcalls: CodemodeNestedCall[];\n\tfullOutputPath?: string;\n}\nexport function toCodemodeDeclaration(\n\ttool: AgentTool,\n\tguidelines: readonly string[] = [],\n): Omit<CodemodeTool, \"execute\"> {\n\tconst bullets = guidelines.flatMap((guideline) => (guideline.trim() ? [`- ${guideline.trim()}`] : []));\n\treturn {\n\t\tname: tool.name,\n\t\tdescription: bullets.length > 0 ? `${tool.description.trim()}\\n\\n${bullets.join(\"\\n\")}` : tool.description,\n\t\tinputSchema: tool.parameters as CodemodeJsonSchema,\n\t\toutputSchema: (tool.outputSchema as CodemodeJsonSchema | undefined) ?? { type: \"string\" },\n\t};\n}\nexport function getCodemodeCallableTools(tools: readonly AgentTool[]): AgentTool[] {\n\treturn tools.filter((tool) => tool.name !== CODEMODE_TOOL_NAME);\n}\nexport interface CodemodeDescriptionOptions {\n\tmodels?: boolean;\n\tnamespaces?: ReadonlyMap<string, ToolNamespace>;\n\tdeferred?: ReadonlySet<string>;\n\tguidelines?: ReadonlyMap<string, readonly string[]>;\n\tinlineBudget?: number;\n}\nconst INTRO = `Run JavaScript that composes tool calls in a fresh QuickJS worker sandbox.\nTop-level await and return work. Use tools.name(args), or tools[\"raw-name\"](args). Tool names normalize to JavaScript identifiers.\nNo Node, filesystem, network, timers, modules or credentials are available directly. Calls go through session validation and permission hooks. They have real side effects and are not undone after script failure.\nTools with output schemas resolve to structuredContent; others resolve to text. Failed or blocked calls throw, except that a tool with an output schema resolves with its structuredContent on failure too when it returned one; check its fields. Scripts have a 256 MB memory limit.\nGlobals: ALL_TOOLS, text(value), image(base64DataUrlOrImageContent), exit(), console.log(...), store(key, value), load(key), await searchTools(query, {limit?, namespace?}), await describeTool(name), await describeNamespace(name).\ntools, ALL_TOOLS and searchTools() matches cover only script-callable tools. Model-only tools such as subagent, workflow, intercom, and ask_user_question are excluded from them, but you can still call them directly. searchTools() and describeTool() answer the exact name of an active model-only tool with a hint to call it directly, not from a script.\nWith several text items, each starts with a ==> text N/M <== line. Console calls follow the other output in one <console_output> block, with one line per call.\nimage() also saves each image to a temp file and the result names its path before the image.\nSuccessful scripts persist store writes on the current session branch; failed scripts discard writes. Unawaited calls are cancelled when the script ends.\nOptional first line: // @options: {\"max_output_tokens\": 1000, \"timeout_ms\": 60000}. Output defaults to 10000 tokens; there is no default deadline.`;\n\nexport function createCodemodeDescription(\n\ttools: readonly AgentTool[],\n\toptions: CodemodeDescriptionOptions = {},\n): string {\n\tconst groups = new Map<\n\t\tstring,\n\t\t{ namespace?: ToolNamespace; entries: { name: string; section: string; cost: number }[] }\n\t>();\n\tfor (const tool of getCodemodeCallableTools(tools)) {\n\t\tif (options.deferred?.has(tool.name)) continue;\n\t\tconst namespace = options.namespaces?.get(tool.name);\n\t\tconst key = namespace?.name ?? \"\";\n\t\tlet group = groups.get(key);\n\t\tif (!group) {\n\t\t\tgroup = { namespace, entries: [] };\n\t\t\tgroups.set(key, group);\n\t\t}\n\t\tconst id = toCodemodeIdentifier(tool.name);\n\t\tconst section = `### \\`${id}\\`${id === tool.name ? \"\" : ` (\\`${tool.name}\\`)`}\\n${renderToolSample(toCodemodeDeclaration(tool, options.guidelines?.get(tool.name))).trim()}`;\n\t\tgroup.entries.push({\n\t\t\tname: tool.name,\n\t\t\tsection,\n\t\t\tcost: Math.ceil(section.length / 4),\n\t\t});\n\t}\n\tconst ordered = [...groups.values()].sort((a, b) =>\n\t\ta.namespace === undefined ? -1 : b.namespace === undefined ? 1 : a.namespace.name.localeCompare(b.namespace.name),\n\t);\n\tconst shown = new Set<string>();\n\tlet remaining = options.inlineBudget ?? Number.POSITIVE_INFINITY;\n\tlet queues = ordered\n\t\t.map((group) => [...group.entries].sort((a, b) => a.cost - b.cost))\n\t\t.filter((queue) => queue.length);\n\twhile (queues.length)\n\t\tqueues = queues.filter((queue) => {\n\t\t\tconst next = queue[0];\n\t\t\tif (next.cost > remaining) return false;\n\t\t\tremaining -= next.cost;\n\t\t\tshown.add(next.name);\n\t\t\tqueue.shift();\n\t\t\treturn queue.length > 0;\n\t\t});\n\tconst sections = [\n\t\tINTRO,\n\t\t\"Some nested tools may be omitted, including deferred tools. They remain available through tools and ALL_TOOLS. Use await searchTools(query), await describeTool(name), or await describeNamespace(name) to discover them.\",\n\t];\n\tif (options.models)\n\t\tsections.push(\n\t\t\t`Model API: \\`models\\` lists and runs classifier and image models with the session's credentials. Read ${CODEMODE_DOCS_PATH} before using it.`,\n\t\t);\n\tif (ordered.length === 0) return sections.join(\"\\n\\n\");\n\tsections.push(\"Nested tools:\");\n\tfor (const group of ordered) {\n\t\tif (group.namespace) {\n\t\t\tconst visible = group.entries.filter((entry) => shown.has(entry.name));\n\t\t\tconst listing =\n\t\t\t\tvisible.length === group.entries.length\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: visible.length === 0\n\t\t\t\t\t\t? \" (tools not listed)\"\n\t\t\t\t\t\t: \" (some tools not listed)\";\n\t\t\tconst description = group.namespace.description?.trim();\n\t\t\tsections.push(`## ${group.namespace.name}${listing}${description ? `\\n${description}` : \"\"}`);\n\t\t}\n\t\tfor (const entry of group.entries) if (shown.has(entry.name)) sections.push(entry.section);\n\t}\n\treturn sections.join(\"\\n\\n\");\n}\n/**\n * The field names of an object schema, `{ output, exit_code, full_output_path? }`, with the fields of\n * object-typed fields `depth` levels deep: `{ content, structuredContent?: { results } }`. Undefined\n * for other schemas.\n */\nfunction describeFields(schema: unknown, depth: number): string | undefined {\n\tif (typeof schema !== \"object\" || schema === null) return undefined;\n\tconst { type, properties, required } = schema as Record<string, unknown>;\n\tif (type !== \"object\" || typeof properties !== \"object\" || properties === null) return undefined;\n\tconst requiredNames = new Set(Array.isArray(required) ? required : []);\n\tconst fields = Object.entries(properties).map(([name, field]) => {\n\t\tconst nested = depth > 0 ? describeFields(field, depth - 1) : undefined;\n\t\treturn `${name}${requiredNames.has(name) ? \"\" : \"?\"}${nested ? `: ${nested}` : \"\"}`;\n\t});\n\treturn `{ ${fields.join(\", \")} }`;\n}\n/**\n * What a script call resolves to, in one line: `a string`, the field names of an object (see\n * {@link describeFields}), or the rendered type for anything else.\n */\nfunction describeOutput(schema: CodemodeJsonSchema | undefined): string {\n\tconst type = renderToolOutputType(schema);\n\tif (type === \"string\") return \"a string\";\n\tconst fields = describeFields(schema, 1);\n\treturn `\\`${fields ?? type.replace(/\\s+/g, \" \")}\\``;\n}\nfunction describeScriptCall(tool: AgentTool): string {\n\treturn `${tool.description.trim()}\\n\\nCodemode: \\`tools.${toCodemodeIdentifier(tool.name)}(args)\\` resolves to ${describeOutput(toCodemodeDeclaration(tool).outputSchema)}.`;\n}\nfunction prepareLoadout(loadout: ToolLoadout, options: CodemodeToolOptions) {\n\tconst only = options.getMode?.() === \"only\";\n\tconst callable = getCodemodeCallableTools(loadout.callable);\n\tconst descriptions: Record<string, string> = {};\n\tif (!only)\n\t\tfor (const tool of loadout.declared)\n\t\t\tif (callable.some((candidate) => candidate.name === tool.name))\n\t\t\t\tdescriptions[tool.name] = describeScriptCall(tool);\n\tconst listed = only ? callable : callable.filter((tool) => loadout.getExposure(tool.name) !== \"direct\");\n\tconst namespaces = new Map(\n\t\tlisted.flatMap((tool) => {\n\t\t\tconst namespace = loadout.getNamespace(tool.name);\n\t\t\treturn namespace ? [[tool.name, namespace] as const] : [];\n\t\t}),\n\t);\n\tconst guidelines = new Map(listed.map((tool) => [tool.name, loadout.getPromptGuidelines(tool.name)] as const));\n\tdescriptions[CODEMODE_TOOL_NAME] = createCodemodeDescription(listed, {\n\t\tmodels: options.models,\n\t\tnamespaces,\n\t\tguidelines,\n\t\tdeferred: new Set(\n\t\t\tlisted.filter((tool) => loadout.getExposure(tool.name) === \"deferred\").map((tool) => tool.name),\n\t\t),\n\t\tinlineBudget: options.getInlineBudget?.() ?? DEFAULT_CODEMODE_INLINE_BUDGET,\n\t});\n\treturn {\n\t\tdescriptions,\n\t\thiddenDeclarations: only\n\t\t\t? callable.filter((tool) => loadout.getExposure(tool.name) === \"direct\").map((tool) => tool.name)\n\t\t\t: [],\n\t};\n}\nexport function createCodemodeToolDefinition(\n\toptions: CodemodeToolOptions = {},\n): ToolDefinition<typeof codemodeSchema, CodemodeToolDetails> {\n\treturn {\n\t\tname: CODEMODE_TOOL_NAME,\n\t\tlabel: CODEMODE_TOOL_NAME,\n\t\tdescription: createCodemodeDescription([], options),\n\t\tparameters: codemodeSchema,\n\t\texposure: \"model-only\",\n\t\tconcurrency: \"exclusive\",\n\t\tdefaultActive: false,\n\t\tpromptSnippet: \"Run JavaScript that calls other tools, filters results, or batches independent calls\",\n\t\tprepareLoadout: (loadout) => prepareLoadout(loadout, options),\n\t\tconstrainedSampling: { type: \"grammar\", variants: { openai_lark: CODEMODE_SOURCE_GRAMMAR } },\n\t\texecute: async (id, input, signal, update, ctx) =>\n\t\t\t(await import(\"./execute.js\")).executeCodemode(id, input, signal, update, ctx, options),\n\t\t...codemodeRenderers,\n\t};\n}\nexport function createCodemodeTool(\n\ttools: readonly AgentTool[] = [],\n\toptions: CodemodeToolOptions = {},\n): AgentTool<typeof codemodeSchema> {\n\treturn {\n\t\t...wrapToolDefinition(createCodemodeToolDefinition(options)),\n\t\tdescription: createCodemodeDescription(tools, options),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/extensions/codemode/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACxH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,WAAW,EAAE,EAAE,aAAa,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;AAC1D,MAAM,CAAC,MAAM,8BAA8B,GAAW,iBAAiB,CAAC,QAAQ,CAAC,YAAY,CAAC;AAoB9F,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,I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,EAAE;QAC5F,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CACjD,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;QACxF,GAAG,iBAAiB;KACpB,CAAC;AACH,CAAC;AACD,MAAM,UAAU,kBAAkB,CACjC,KAAK,GAAyB,EAAE,EAChC,OAAO,GAAwB,EAAE;IAEjC,OAAO;QACN,GAAG,kBAAkB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;QAC5D,WAAW,EAAE,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC;KACtD,CAAC;AACH,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { CodemodeJsonSchema, CodemodeTool } from \"@earendil-works/pi-codemode\";\nimport { renderToolOutputType, renderToolSample, toCodemodeIdentifier } from \"@earendil-works/pi-codemode/declarations\";\nimport { CODEMODE_SOURCE_GRAMMAR } from \"@earendil-works/pi-codemode/source\";\nimport { type Static, Type } from \"typebox\";\nimport { getDocsPath } from \"../../config.js\";\nimport type { ToolDefinition, ToolInfo, ToolLoadout, ToolNamespace } from \"../../core/extensions/types.ts\";\nimport type { ModelRegistry } from \"../../core/model-registry.ts\";\nimport { SETTINGS_DEFAULTS } from \"../../core/settings-defaults.ts\";\nimport type { CodemodeMode } from \"../../core/settings-manager.ts\";\nimport { wrapToolDefinition } from \"../../core/tools/tool-definition-wrapper.ts\";\nimport { codemodeRenderers } from \"./renderer.js\";\n\nexport const CODEMODE_TOOL_NAME = \"codemode\";\nexport const CODEMODE_DOCS_PATH = join(getDocsPath(), \"codemode.md\");\nexport const CODEMODE_STORE_ENTRY_TYPE = \"codemode-store\";\nexport const DEFAULT_CODEMODE_INLINE_BUDGET: number = SETTINGS_DEFAULTS.codemode.inlineBudget;\nexport interface CodemodeStoreEntryData {\n\tset: Record<string, unknown>;\n\tdelete: string[];\n}\nexport type CodemodeModelRuntime = Pick<\n\tModelRegistry,\n\t\"getModelsOfType\" | \"getAvailableOfType\" | \"getModelOfType\" | \"classify\" | \"generateImages\"\n>;\nexport interface CodemodeToolOptions {\n\tgetToolNamespace?: (name: string) => ToolNamespace | undefined;\n\t/** Prompt guidelines shown with tool declarations in describeTool() and ALL_TOOLS. */\n\tgetToolGuidelines?: () => ReadonlyMap<string, readonly string[]>;\n\tmodels?: boolean;\n\tappendEntry?: (type: string, data: CodemodeStoreEntryData) => Promise<void>;\n\tgetMode?: () => CodemodeMode;\n\tgetInlineBudget?: () => number | undefined;\n\t/** Active model-only tools. Scripts cannot call them, so discovery answers an exact name with a hint. */\n\tgetModelOnlyTools?: () => readonly string[];\n}\nexport const codemodeSchema = Type.Object({\n\tcode: Type.String({\n\t\tdescription:\n\t\t\t'Raw JavaScript source with top-level await and return. Optional first line // @options: {\"max_output_tokens\": 1000, \"timeout_ms\": 60000}',\n\t}),\n});\nexport type CodemodeToolInput = Static<typeof codemodeSchema>;\nexport function isCodemodeTool(tool: Pick<ToolInfo, \"name\" | \"parameters\">): boolean {\n\treturn tool.name === CODEMODE_TOOL_NAME && tool.parameters === codemodeSchema;\n}\nexport interface CodemodeNestedCall {\n\tid: string;\n\tname: string;\n\targs: string;\n\tstatus: \"running\" | \"ok\" | \"error\" | \"cancelled\";\n\tdurationMs?: number;\n\terror?: string;\n\tcost?: number;\n}\nexport interface CodemodeToolDetails {\n\tcalls: CodemodeNestedCall[];\n\tfullOutputPath?: string;\n}\nexport function toCodemodeDeclaration(\n\ttool: AgentTool,\n\tguidelines: readonly string[] = [],\n): Omit<CodemodeTool, \"execute\"> {\n\tconst bullets = guidelines.flatMap((guideline) => (guideline.trim() ? [`- ${guideline.trim()}`] : []));\n\treturn {\n\t\tname: tool.name,\n\t\tdescription: bullets.length > 0 ? `${tool.description.trim()}\\n\\n${bullets.join(\"\\n\")}` : tool.description,\n\t\tinputSchema: tool.parameters as CodemodeJsonSchema,\n\t\toutputSchema: (tool.outputSchema as CodemodeJsonSchema | undefined) ?? { type: \"string\" },\n\t};\n}\nexport function getCodemodeCallableTools(tools: readonly AgentTool[]): AgentTool[] {\n\treturn tools.filter((tool) => tool.name !== CODEMODE_TOOL_NAME);\n}\nexport interface CodemodeDescriptionOptions {\n\tmodels?: boolean;\n\tnamespaces?: ReadonlyMap<string, ToolNamespace>;\n\tdeferred?: ReadonlySet<string>;\n\tguidelines?: ReadonlyMap<string, readonly string[]>;\n\tinlineBudget?: number;\n}\nconst INTRO = `Run JavaScript that composes tool calls in a fresh QuickJS worker sandbox.\nTop-level await and return work. Use tools.name(args), or tools[\"raw-name\"](args). Tool names normalize to JavaScript identifiers.\nNo Node, filesystem, network, timers, modules or credentials are available directly. Calls go through session validation and permission hooks. They have real side effects and are not undone after script failure.\nTools with output schemas resolve to structuredContent; others resolve to text. Failed or blocked calls throw, except that a tool with an output schema resolves with its structuredContent on failure too when it returned one; check its fields. Scripts have a 256 MB memory limit.\nGlobals: ALL_TOOLS, text(value), image(base64DataUrlOrImageContent), exit(), console.log(...), store(key, value), load(key), await searchTools(query, {limit?, namespace?}), await describeTool(name), await describeNamespace(name).\ntools, ALL_TOOLS and searchTools() matches cover only script-callable tools. Model-only tools such as subagent, workflow, intercom, and ask_user_question are excluded from them, but you can still call them directly. searchTools() and describeTool() answer the exact name of an active model-only tool with a hint to call it directly, not from a script.\nWith several text items, each starts with a ==> text N/M <== line. Console calls follow the other output in one <console_output> block, with one line per call.\nimage() also saves each image to a temp file and the result names its path before the image.\nSuccessful scripts persist store writes on the current session branch; failed scripts discard writes. Unawaited calls are cancelled when the script ends.\nOptional first line: // @options: {\"max_output_tokens\": 1000, \"timeout_ms\": 60000}. Output defaults to 10000 tokens; there is no default deadline.`;\n\nexport function createCodemodeDescription(\n\ttools: readonly AgentTool[],\n\toptions: CodemodeDescriptionOptions = {},\n): string {\n\tconst groups = new Map<\n\t\tstring,\n\t\t{ namespace?: ToolNamespace; entries: { name: string; section: string; cost: number }[] }\n\t>();\n\tfor (const tool of getCodemodeCallableTools(tools)) {\n\t\tif (options.deferred?.has(tool.name)) continue;\n\t\tconst namespace = options.namespaces?.get(tool.name);\n\t\tconst key = namespace?.name ?? \"\";\n\t\tlet group = groups.get(key);\n\t\tif (!group) {\n\t\t\tgroup = { namespace, entries: [] };\n\t\t\tgroups.set(key, group);\n\t\t}\n\t\tconst id = toCodemodeIdentifier(tool.name);\n\t\tconst section = `### \\`${id}\\`${id === tool.name ? \"\" : ` (\\`${tool.name}\\`)`}\\n${renderToolSample(toCodemodeDeclaration(tool, options.guidelines?.get(tool.name))).trim()}`;\n\t\tgroup.entries.push({\n\t\t\tname: tool.name,\n\t\t\tsection,\n\t\t\tcost: Math.ceil(section.length / 4),\n\t\t});\n\t}\n\tconst ordered = [...groups.values()].sort((a, b) =>\n\t\ta.namespace === undefined ? -1 : b.namespace === undefined ? 1 : a.namespace.name.localeCompare(b.namespace.name),\n\t);\n\tconst shown = new Set<string>();\n\tlet remaining = options.inlineBudget ?? Number.POSITIVE_INFINITY;\n\tlet queues = ordered\n\t\t.map((group) => [...group.entries].sort((a, b) => a.cost - b.cost))\n\t\t.filter((queue) => queue.length);\n\twhile (queues.length)\n\t\tqueues = queues.filter((queue) => {\n\t\t\tconst next = queue[0];\n\t\t\tif (next.cost > remaining) return false;\n\t\t\tremaining -= next.cost;\n\t\t\tshown.add(next.name);\n\t\t\tqueue.shift();\n\t\t\treturn queue.length > 0;\n\t\t});\n\tconst sections = [\n\t\tINTRO,\n\t\t\"Some nested tools may be omitted, including deferred tools. They remain available through tools and ALL_TOOLS. Use await searchTools(query), await describeTool(name), or await describeNamespace(name) to discover them.\",\n\t];\n\tif (options.models)\n\t\tsections.push(\n\t\t\t`Model API: \\`models\\` lists and runs classifier and image models with the session's credentials. Read ${CODEMODE_DOCS_PATH} before using it.`,\n\t\t);\n\tif (ordered.length === 0) return sections.join(\"\\n\\n\");\n\tsections.push(\"Nested tools:\");\n\tfor (const group of ordered) {\n\t\tif (group.namespace) {\n\t\t\tconst visible = group.entries.filter((entry) => shown.has(entry.name));\n\t\t\tconst listing =\n\t\t\t\tvisible.length === group.entries.length\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: visible.length === 0\n\t\t\t\t\t\t? \" (tools not listed)\"\n\t\t\t\t\t\t: \" (some tools not listed)\";\n\t\t\tconst description = group.namespace.description?.trim();\n\t\t\tsections.push(`## ${group.namespace.name}${listing}${description ? `\\n${description}` : \"\"}`);\n\t\t}\n\t\tfor (const entry of group.entries) if (shown.has(entry.name)) sections.push(entry.section);\n\t}\n\treturn sections.join(\"\\n\\n\");\n}\n/**\n * The field names of an object schema, `{ output, exit_code, full_output_path? }`, with the fields of\n * object-typed fields `depth` levels deep: `{ content, structuredContent?: { results } }`, and the\n * value of `const` fields: `{ action: \"start\", id }`. Undefined for other schemas.\n */\nfunction describeFields(schema: unknown, depth: number): string | undefined {\n\tif (typeof schema !== \"object\" || schema === null) return undefined;\n\tconst { type, properties, required } = schema as Record<string, unknown>;\n\tif (type !== \"object\" || typeof properties !== \"object\" || properties === null) return undefined;\n\tconst requiredNames = new Set(Array.isArray(required) ? required : []);\n\tconst fields = Object.entries(properties).map(([name, field]) => {\n\t\tconst constValue = (field as Record<string, unknown> | null)?.const;\n\t\tconst nested =\n\t\t\tconstValue !== undefined\n\t\t\t\t? JSON.stringify(constValue)\n\t\t\t\t: depth > 0\n\t\t\t\t\t? describeFields(field, depth - 1)\n\t\t\t\t\t: undefined;\n\t\treturn `${name}${requiredNames.has(name) ? \"\" : \"?\"}${nested ? `: ${nested}` : \"\"}`;\n\t});\n\treturn `{ ${fields.join(\", \")} }`;\n}\n/**\n * What a script call resolves to, in one line: `a string`, the field names of an object (see\n * {@link describeFields}), the field names of each object in a union, the rendered type when it\n * fits on one line, or a pointer to `describeTool()` for anything longer. The full type of a large\n * schema would otherwise be sent with every request (#11501).\n */\nfunction describeOutput(name: string, schema: CodemodeJsonSchema | undefined): string {\n\tconst type = renderToolOutputType(schema);\n\tif (type === \"string\") return \"a string\";\n\tconst fields = describeFields(schema, 1) ?? describeUnionFields(schema);\n\tif (fields) return `\\`${fields}\\``;\n\tif (!type.includes(\"\\n\")) return `\\`${type}\\``;\n\treturn `a value; \\`await describeTool(${JSON.stringify(name)})\\` shows its type`;\n}\n/**\n * The field names of each variant of an `anyOf`/`oneOf` whose variants are all objects, joined by\n * `|`.\n */\nfunction describeUnionFields(schema: unknown): string | undefined {\n\tif (typeof schema !== \"object\" || schema === null) return undefined;\n\tconst { anyOf, oneOf } = schema as Record<string, unknown>;\n\tconst variants = anyOf ?? oneOf;\n\tif (!Array.isArray(variants) || variants.length === 0) return undefined;\n\tconst described = variants.map((variant) => describeFields(variant, 0));\n\treturn described.every((fields) => fields !== undefined) ? described.join(\" | \") : undefined;\n}\nfunction describeScriptCall(tool: AgentTool): string {\n\treturn `${tool.description.trim()}\\n\\nCodemode: \\`tools.${toCodemodeIdentifier(tool.name)}(args)\\` resolves to ${describeOutput(tool.name, toCodemodeDeclaration(tool).outputSchema)}.`;\n}\nfunction prepareLoadout(loadout: ToolLoadout, options: CodemodeToolOptions) {\n\tconst only = options.getMode?.() === \"only\";\n\tconst callable = getCodemodeCallableTools(loadout.callable);\n\tconst descriptions: Record<string, string> = {};\n\tif (!only)\n\t\tfor (const tool of loadout.declared)\n\t\t\tif (callable.some((candidate) => candidate.name === tool.name))\n\t\t\t\tdescriptions[tool.name] = describeScriptCall(tool);\n\tconst listed = only ? callable : callable.filter((tool) => loadout.getExposure(tool.name) !== \"direct\");\n\tconst namespaces = new Map(\n\t\tlisted.flatMap((tool) => {\n\t\t\tconst namespace = loadout.getNamespace(tool.name);\n\t\t\treturn namespace ? [[tool.name, namespace] as const] : [];\n\t\t}),\n\t);\n\tconst guidelines = new Map(listed.map((tool) => [tool.name, loadout.getPromptGuidelines(tool.name)] as const));\n\tdescriptions[CODEMODE_TOOL_NAME] = createCodemodeDescription(listed, {\n\t\tmodels: options.models,\n\t\tnamespaces,\n\t\tguidelines,\n\t\tdeferred: new Set(\n\t\t\tlisted.filter((tool) => loadout.getExposure(tool.name) === \"deferred\").map((tool) => tool.name),\n\t\t),\n\t\tinlineBudget: options.getInlineBudget?.() ?? DEFAULT_CODEMODE_INLINE_BUDGET,\n\t});\n\treturn {\n\t\tdescriptions,\n\t\thiddenDeclarations: only\n\t\t\t? callable.filter((tool) => loadout.getExposure(tool.name) === \"direct\").map((tool) => tool.name)\n\t\t\t: [],\n\t};\n}\nexport function createCodemodeToolDefinition(\n\toptions: CodemodeToolOptions = {},\n): ToolDefinition<typeof codemodeSchema, CodemodeToolDetails> {\n\treturn {\n\t\tname: CODEMODE_TOOL_NAME,\n\t\tlabel: CODEMODE_TOOL_NAME,\n\t\tdescription: createCodemodeDescription([], options),\n\t\tparameters: codemodeSchema,\n\t\texposure: \"model-only\",\n\t\tconcurrency: \"exclusive\",\n\t\tdefaultActive: false,\n\t\tpromptSnippet: \"Run JavaScript that calls other tools, filters results, or batches independent calls\",\n\t\tprepareLoadout: (loadout) => prepareLoadout(loadout, options),\n\t\tconstrainedSampling: { type: \"grammar\", variants: { openai_lark: CODEMODE_SOURCE_GRAMMAR } },\n\t\texecute: async (id, input, signal, update, ctx) =>\n\t\t\t(await import(\"./execute.js\")).executeCodemode(id, input, signal, update, ctx, options),\n\t\t...codemodeRenderers,\n\t};\n}\nexport function createCodemodeTool(\n\ttools: readonly AgentTool[] = [],\n\toptions: CodemodeToolOptions = {},\n): AgentTool<typeof codemodeSchema> {\n\treturn {\n\t\t...wrapToolDefinition(createCodemodeToolDefinition(options)),\n\t\tdescription: createCodemodeDescription(tools, options),\n\t};\n}\n"]}
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAmHA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAmHA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAgBnD,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAoLnD,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,iBA+wB/D"}
|
package/dist/main.js
CHANGED
|
@@ -38,6 +38,7 @@ import { collectSettingsDiagnostics, drainProcessStdio, isTruthyEnvFlag, readPip
|
|
|
38
38
|
import { runMigrations, showDeprecationWarnings } from "./migrations.js";
|
|
39
39
|
import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index.js";
|
|
40
40
|
import { isUnknownModel } from "./modes/interactive/interactive-mode-helpers.js";
|
|
41
|
+
import { shouldUseFullscreenTui } from "./modes/interactive/interactive-tui.js";
|
|
41
42
|
import { initTheme, stopThemeWatcher } from "./modes/interactive/theme/theme.js";
|
|
42
43
|
import { createRuntimeForMode } from "./modes/interactive-engine/create-isolated-runtime.js";
|
|
43
44
|
import { startInteractiveEngineLiveness } from "./modes/interactive-engine/engine-child-liveness.js";
|
|
@@ -246,7 +247,17 @@ export async function main(argv, options) {
|
|
|
246
247
|
}
|
|
247
248
|
if (process.platform === "win32")
|
|
248
249
|
cleanupWindowsSelfUpdateQuarantine(getPackageDir());
|
|
249
|
-
|
|
250
|
+
let cwd;
|
|
251
|
+
try {
|
|
252
|
+
cwd = process.cwd();
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
if (error.code !== "ENOENT")
|
|
256
|
+
throw error;
|
|
257
|
+
console.error(chalk.red("Error: The current working directory no longer exists. Change to an existing directory and try again."));
|
|
258
|
+
process.exit(1);
|
|
259
|
+
}
|
|
260
|
+
const agentDir = getAgentDir();
|
|
250
261
|
const bootstrapSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: false });
|
|
251
262
|
applyHttpProxySettings(bootstrapSettingsManager.getGlobalSettings().httpProxy);
|
|
252
263
|
configureHttpDispatcher();
|
|
@@ -492,7 +503,7 @@ export async function main(argv, options) {
|
|
|
492
503
|
const prepareRuntime = async ({ cwd, agentDir, sessionManager, sessionStartEvent, projectTrustContext, }) => {
|
|
493
504
|
const cachedProjectTrust = projectTrustByCwd.get(cwd);
|
|
494
505
|
const hasTrustInputs = hasProjectTrustInputs(cwd);
|
|
495
|
-
const storedProjectTrust =
|
|
506
|
+
const storedProjectTrust = projectTrustStore.get(cwd);
|
|
496
507
|
const initialProjectTrusted = parsed.projectTrustOverride ?? cachedProjectTrust ?? storedProjectTrust ?? !hasTrustInputs;
|
|
497
508
|
const shouldResolveProjectTrust = !isolateInteractiveHost &&
|
|
498
509
|
parsed.projectTrustOverride === undefined &&
|
|
@@ -842,7 +853,12 @@ export async function main(argv, options) {
|
|
|
842
853
|
await runRpcMode(runtime, { deferInteractiveEngineResources: deferredExtensionLoad });
|
|
843
854
|
}
|
|
844
855
|
else if (appMode === "interactive") {
|
|
845
|
-
|
|
856
|
+
const modelScopeNotice = scopedModels.length > 0 && (parsed.verbose || settingsManager.getQuietStartup() === false)
|
|
857
|
+
? `Model scope: ${formatScopedModelList(scopedModels)} (ctrl+p cycle)`
|
|
858
|
+
: undefined;
|
|
859
|
+
// Fullscreen paints on the alternate screen, so a line printed here would stay in the shell after exit
|
|
860
|
+
// (upstream #11508); the interactive mode shows it in the header instead.
|
|
861
|
+
if (modelScopeNotice && !shouldUseFullscreenTui(options?.internalInteractiveHarness?.terminal !== undefined)) {
|
|
846
862
|
console.log(chalk.dim(`Model scope: ${formatScopedModelList(scopedModels)} ${chalk.gray("(ctrl+p cycle)")}`));
|
|
847
863
|
}
|
|
848
864
|
const interactiveMode = new InteractiveMode(runtime, {
|
|
@@ -861,6 +877,7 @@ export async function main(argv, options) {
|
|
|
861
877
|
initialImages,
|
|
862
878
|
initialMessages: parsed.messages,
|
|
863
879
|
verbose: parsed.verbose,
|
|
880
|
+
modelScopeNotice,
|
|
864
881
|
initialThemeSetting: parsed.useTheme,
|
|
865
882
|
deferredExtensionLoad,
|
|
866
883
|
startupInputCapture: startupEarlyInputCapture,
|