@norman-else/dsh-claude 0.1.39 → 0.1.41
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/README.md +4 -2
- package/lib/bin.mjs +1 -1
- package/lib/client.d.ts +33 -0
- package/lib/client.js +1692 -655
- package/lib/client.js.map +1 -1
- package/lib/{events-OhBoFNKO.mjs → events-B-FPMzI7.mjs} +7 -2
- package/lib/events-B-FPMzI7.mjs.map +1 -0
- package/lib/index.d.mts +55 -3
- package/lib/index.mjs +815 -167
- package/lib/index.mjs.map +1 -1
- package/lib/{presenters-BBoM1Ju1.mjs → presenters-BV42EKkB.mjs} +21 -2
- package/lib/{presenters-BBoM1Ju1.mjs.map → presenters-BV42EKkB.mjs.map} +1 -1
- package/lib/{preset-installer-loenwnLS.mjs → preset-installer-yRGfkGjd.mjs} +2 -2
- package/lib/{preset-installer-loenwnLS.mjs.map → preset-installer-yRGfkGjd.mjs.map} +1 -1
- package/lib/preset-route.mjs +2 -2
- package/package.json +1 -1
- package/lib/events-OhBoFNKO.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as redactText } from "./events-
|
|
1
|
+
import { l as redactText } from "./events-B-FPMzI7.mjs";
|
|
2
2
|
//#region src/command-bridge.ts
|
|
3
3
|
const COMMAND_NAME = /^[a-z][a-z0-9_-]*$/u;
|
|
4
4
|
const MAX_DESCRIPTION_CHARS = 300;
|
|
@@ -216,6 +216,24 @@ function fetchCallView(args) {
|
|
|
216
216
|
rawInput: args
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
+
/** ExitPlanMode: the plan itself, as prose rather than as tool arguments.
|
|
220
|
+
*
|
|
221
|
+
* This is the one built-in tool whose whole payload is written for the user
|
|
222
|
+
* to read: Claude asks to leave plan mode and the approval that follows is
|
|
223
|
+
* the user agreeing to the plan. Rendering it as `Input: {"plan":"..."}`
|
|
224
|
+
* buries the only thing worth reading, so the plan becomes the card body. */
|
|
225
|
+
function planCallView(args) {
|
|
226
|
+
const plan = str(record(args)?.plan);
|
|
227
|
+
return plan === void 0 ? void 0 : {
|
|
228
|
+
card: "generic",
|
|
229
|
+
kind: "other",
|
|
230
|
+
title: "Plan ready for review",
|
|
231
|
+
content: [{
|
|
232
|
+
type: "text",
|
|
233
|
+
text: plan
|
|
234
|
+
}]
|
|
235
|
+
};
|
|
236
|
+
}
|
|
219
237
|
/** Task: a subagent card titled by Claude's task description. */
|
|
220
238
|
function taskCallView(args) {
|
|
221
239
|
const arguments_ = record(args);
|
|
@@ -289,6 +307,7 @@ function claudePresenterDefinitions() {
|
|
|
289
307
|
presenterDefinition("WebSearch", PRESENTATION_NOTE, searchCallView),
|
|
290
308
|
presenterDefinition("WebFetch", PRESENTATION_NOTE, fetchCallView),
|
|
291
309
|
presenterDefinition("Task", PRESENTATION_NOTE, taskCallView),
|
|
310
|
+
presenterDefinition("ExitPlanMode", PRESENTATION_NOTE, planCallView),
|
|
292
311
|
presenterDefinition("TodoWrite", PRESENTATION_NOTE, () => genericTitle("Update todos"))
|
|
293
312
|
];
|
|
294
313
|
}
|
|
@@ -297,4 +316,4 @@ const CLAUDE_PRESENTER_NAMES = new Set(claudePresenterDefinitions().map((definit
|
|
|
297
316
|
//#endregion
|
|
298
317
|
export { projectClaudeCommands as a, CLAUDE_COMMANDS_SERVICE as i, claudePresenterDefinitions as n, dynamicPresenterDefinition as r, CLAUDE_PRESENTER_NAMES as t };
|
|
299
318
|
|
|
300
|
-
//# sourceMappingURL=presenters-
|
|
319
|
+
//# sourceMappingURL=presenters-BV42EKkB.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenters-BBoM1Ju1.mjs","names":[],"sources":["../src/command-bridge.ts","../src/presenters.ts"],"sourcesContent":["import type { SlashCommand } from '@anthropic-ai/claude-agent-sdk'\nimport type { CommandDescriptor } from '@deepseek-ai/dsh-commands'\nimport { redactText } from './events.ts'\n\nconst COMMAND_NAME = /^[a-z][a-z0-9_-]*$/u\nconst MAX_DESCRIPTION_CHARS = 300\nconst MAX_HINT_CHARS = 120\n\n/** DSH registry names reject `:`, but plugin-qualified Claude skills carry it\n * (e.g. `awesome-skills:ci-deploy`). Derive a registry-safe public name while\n * forwarding keeps the exact Claude-side name. */\nfunction registryName(claudeName: string): string | undefined {\n if (COMMAND_NAME.test(claudeName)) return claudeName\n const short = claudeName.includes(':') ? claudeName.slice(claudeName.lastIndexOf(':') + 1) : undefined\n if (short !== undefined && COMMAND_NAME.test(short)) return short\n const sanitized = claudeName.replaceAll(':', '-').toLowerCase()\n return COMMAND_NAME.test(sanitized) ? sanitized : undefined\n}\n\n/**\n * Names registered as CLIENT-side commandUi contributions (not host\n * commands). The DSH web command palette fails its whole command group when\n * a host command name equals a contribution name\n * (\"contribution /model collides with a host command\"), so these can never\n * be registered by this bridge. Keep in sync with the client bundles:\n * dsh-client-ui-model-selection registers \"model\".\n */\nconst CLIENT_CONTRIBUTION_NAMES: ReadonlySet<string> = new Set(['model'])\n\nexport interface ClaudeCommandTarget {\n list(): readonly Pick<CommandDescriptor, 'name'>[]\n}\n\n/**\n * Agent-scope command-directory contract. The commands service is unreachable\n * from the host plugin's view of `agent.ctx` (\"without inject\"), but the\n * preset route plugin runs inside the agent's preset composition with\n * `commands` injected. The Host reads only the exact agent's effective names\n * for collision checks; Claude catalog entries are never registered there.\n */\nexport interface ClaudeAgentCommandService {\n list(agent: unknown): readonly Pick<CommandDescriptor, 'name'>[]\n}\n\n/**\n * Cordis service name the preset route provides (behind an entry-local\n * isolate realm, so each session gets its own instance) and the host reads\n * back with dsh-agent-presets' official `serviceForAgent(ctx, agent, name)`\n * — the supported cross-scope read for callers that already hold the agent.\n */\nexport const CLAUDE_COMMANDS_SERVICE = 'claudeCommands'\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n claudeCommands?: ClaudeAgentCommandService\n }\n}\n\nexport interface ClaudeCommandView {\n publicName: string\n claudeName: string\n description: string\n hint?: string\n prefixed: boolean\n}\n\nfunction bounded(value: string, maxChars: number): string {\n return redactText(value, maxChars)\n}\n\nexport function projectClaudeCommands(\n catalog: readonly SlashCommand[],\n target: ClaudeCommandTarget,\n): readonly ClaudeCommandView[] {\n const reservedNames = new Set(target.list().map(command => command.name))\n // Client contributions are absent from the Host directory but share the\n // same slash menu, so reserve their public names explicitly.\n for (const name of CLIENT_CONTRIBUTION_NAMES) reservedNames.add(name)\n const assigned = new Set<string>()\n const views: ClaudeCommandView[] = []\n for (const command of catalog) {\n const names = [command.name, ...(command.aliases ?? [])]\n const commandBases = new Set<string>()\n for (const claudeName of names) {\n const base = registryName(claudeName)\n if (base === undefined || commandBases.has(base)) continue\n commandBases.add(base)\n let publicName = base\n let prefixed = false\n if (reservedNames.has(publicName) || assigned.has(publicName)) {\n publicName = `claude-${base}`\n prefixed = true\n }\n if (!COMMAND_NAME.test(publicName) || reservedNames.has(publicName) || assigned.has(publicName)) continue\n const description = bounded(command.description || `Claude Code /${command.name}`, MAX_DESCRIPTION_CHARS)\n const hint = bounded(command.argumentHint ?? '', MAX_HINT_CHARS)\n views.push({\n publicName,\n claudeName,\n description,\n ...(hint.length === 0 ? {} : { hint }),\n prefixed,\n })\n assigned.add(publicName)\n }\n }\n return views\n}\n","/**\n * Presentation-only tool definitions for the Claude Code preset. Claude Code\n * owns tool execution; these definitions exist solely so the host's tool\n * presentation pipeline (`viewFor` → `presentCall`/`presentResult`) can\n * compute native render intents for the mirrored `tool/call`/`tool/result`\n * events, giving Claude tool rows the same cards DSH-executed tools get.\n */\nimport type { ToolDefinition, ToolResult } from '@deepseek-ai/dsh-tools'\nimport type { ToolCallView, ToolResultView } from '@deepseek-ai/dsh-tools/presentation'\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : undefined\n}\n\nfunction str(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nfunction resultText(result: ToolResult): string {\n return result.content\n .filter((block): block is Extract<typeof block, { type: 'text' }> => block.type === 'text')\n .map(block => block.text)\n .join('\\n')\n}\n\n/** Bash: a terminal card headed by the command, described above by Claude's own summary. */\nexport function bashCallView(args: unknown): ToolCallView | undefined {\n const command = str(record(args)?.command)\n if (command === undefined) return undefined\n const description = str(record(args)?.description)\n return { card: 'terminal', title: command, ...(description === undefined ? {} : { description }) }\n}\n\nexport function terminalResultView(_args: unknown, result: ToolResult): ToolResultView | undefined {\n const output = resultText(result)\n return output.length === 0 ? undefined : { card: 'terminal', output }\n}\n\n/** Read: a generic read card that follow-alongs the file window. */\nexport function readCallView(args: unknown): ToolCallView | undefined {\n const arguments_ = record(args)\n const path = str(arguments_?.file_path)\n if (path === undefined) return undefined\n const offset = typeof arguments_?.offset === 'number' ? arguments_.offset : undefined\n return {\n card: 'generic',\n kind: 'read',\n title: `Read ${path}`,\n locations: [{ path, ...(offset === undefined ? {} : { line: offset }) }],\n }\n}\n\nfunction fileDiffs(args: unknown): { path: string; oldText: string | null; newText: string }[] | undefined {\n const arguments_ = record(args)\n const path = str(arguments_?.file_path)\n if (path === undefined) return undefined\n if (Array.isArray(arguments_?.edits)) {\n const diffs: { path: string; oldText: string | null; newText: string }[] = []\n for (const edit of arguments_.edits) {\n const item = record(edit)\n const oldText = str(item?.old_string)\n const newText = str(item?.new_string)\n if (newText === undefined) continue\n diffs.push({ path, oldText: oldText ?? null, newText })\n }\n return diffs.length > 0 ? diffs : undefined\n }\n const newText = str(arguments_?.new_string) ?? arguments_?.content\n if (typeof newText !== 'string' || newText.length === 0) return undefined\n const oldText = str(arguments_?.old_string)\n return [{ path, oldText: oldText ?? null, newText }]\n}\n\n/** Edit / MultiEdit / Write: inline diff cards derived from the call arguments. */\nexport function diffCallView(args: unknown): ToolCallView | undefined {\n const arguments_ = record(args)\n const path = str(arguments_?.file_path)\n const diffs = fileDiffs(args)\n if (path === undefined || diffs === undefined) return undefined\n const verb = typeof arguments_?.new_string === 'string' || Array.isArray(arguments_?.edits) ? 'Edit' : 'Write'\n return { card: 'diff', title: `${verb} ${path}`, diffs, locations: [{ path }] }\n}\n\n/** Edit / MultiEdit / Write results: the same diff, again.\n *\n * A completed card replaces the pending one, so a mutation that returns no\n * result view loses its diff to the raw result text. The plugin transcript\n * drops the diff on failure and shows the error instead; mirror that. */\nexport function diffResultView(args: unknown, result: ToolResult): ToolResultView | undefined {\n if (result.isError) return undefined\n const diffs = fileDiffs(args)\n return diffs === undefined ? undefined : { card: 'diff', diffs }\n}\n\nfunction parsedResult(result: ToolResult): unknown {\n const text = resultText(result)\n if (text.length === 0) return undefined\n try {\n return JSON.parse(text) as unknown\n } catch {\n return text\n }\n}\n\n/** Grep / Glob results: the discovered paths as a search card.\n *\n * Only the structured `filenames` shape is projected. A text result (Grep's\n * content mode) carries its own formatting, so it falls through to the raw\n * result content rather than being re-parsed into fake match groups. */\nexport function searchResultView(_args: unknown, result: ToolResult): ToolResultView | undefined {\n if (result.isError) return undefined\n const output = record(parsedResult(result))\n if (!Array.isArray(output?.filenames)) return undefined\n const paths = output.filenames.filter((item): item is string => typeof item === 'string')\n const reported = output.numFiles\n const total = typeof reported === 'number' && Number.isInteger(reported) && reported >= paths.length ? reported : paths.length\n return { card: 'search', shape: 'paths', paths, truncated: total > paths.length, total }\n}\n\n/** Grep / Glob / WebSearch: search-category cards titled by the query. */\nexport function searchCallView(args: unknown): ToolCallView | undefined {\n const arguments_ = record(args)\n const query = str(arguments_?.pattern) ?? str(arguments_?.query)\n if (query === undefined) return undefined\n const scope = str(arguments_?.path)\n return {\n card: 'generic',\n kind: 'search',\n title: scope === undefined ? query : `${query} · ${scope}`,\n rawInput: args,\n }\n}\n\n/** WebFetch: a fetch-category card titled by the URL. */\nexport function fetchCallView(args: unknown): ToolCallView | undefined {\n const url = str(record(args)?.url)\n if (url === undefined) return undefined\n return { card: 'generic', kind: 'fetch', title: url, rawInput: args }\n}\n\n/** Task: a subagent card titled by Claude's task description. */\nexport function taskCallView(args: unknown): ToolCallView | undefined {\n const arguments_ = record(args)\n const title = str(arguments_?.description) ?? str(arguments_?.subagent_type) ?? 'Subagent'\n return { card: 'generic', kind: 'other', title, rawInput: args }\n}\n\nfunction genericTitle(title: string): ToolCallView {\n return { card: 'generic', kind: 'other', title }\n}\n\nfunction presenterDefinition(\n name: string,\n description: string,\n presentCall?: (args: unknown) => ToolCallView | undefined,\n presentResult?: (args: unknown, result: ToolResult) => ToolResultView | undefined,\n): ToolDefinition {\n return {\n name,\n description,\n parameters: { type: 'object', properties: {} },\n output: {\n schema: { type: 'object', properties: {} } as ToolDefinition['output']['schema'],\n render: () => [],\n },\n execute: async () => {\n throw new Error(`dsh-claude: Claude Code owns execution of ${name}`)\n },\n ...(presentCall === undefined ? {} : { presentCall }),\n ...(presentResult === undefined ? {} : { presentResult }),\n }\n}\n\nconst PRESENTATION_NOTE = 'Presentation mirror of the Claude Code tool; execution is owned by Claude Code.'\n\n/** Generic call view for dynamically observed tools (MCP tools, new built-ins). */\nexport function genericCallView(toolName: string): (args: unknown) => ToolCallView | undefined {\n return (args: unknown) => {\n const description = str(record(args)?.description)\n return { card: 'generic', kind: 'other', title: description ?? toolName, rawInput: args }\n }\n}\n\n/** One presenter-only mirror for a tool name discovered at runtime. */\nexport function dynamicPresenterDefinition(name: string): ToolDefinition {\n return presenterDefinition(name, PRESENTATION_NOTE, genericCallView(name))\n}\n\n/** The presentation-only registry contributed to the Claude Code preset scope. */\nexport function claudePresenterDefinitions(): ToolDefinition[] {\n return [\n presenterDefinition('Bash', PRESENTATION_NOTE, bashCallView, terminalResultView),\n // The plugin transcript gives PowerShell the same terminal treatment as\n // Bash; without its own mirror the native card would fall back to generic.\n presenterDefinition('PowerShell', PRESENTATION_NOTE, bashCallView, terminalResultView),\n presenterDefinition('Read', PRESENTATION_NOTE, readCallView),\n presenterDefinition('Edit', PRESENTATION_NOTE, diffCallView, diffResultView),\n presenterDefinition('MultiEdit', PRESENTATION_NOTE, diffCallView, diffResultView),\n presenterDefinition('Write', PRESENTATION_NOTE, diffCallView, diffResultView),\n presenterDefinition('NotebookEdit', PRESENTATION_NOTE, args => {\n const path = str(record(args)?.notebook_path)\n return path === undefined ? undefined : genericTitle(`NotebookEdit ${path}`)\n }),\n presenterDefinition('Grep', PRESENTATION_NOTE, searchCallView, searchResultView),\n presenterDefinition('Glob', PRESENTATION_NOTE, searchCallView, searchResultView),\n presenterDefinition('WebSearch', PRESENTATION_NOTE, searchCallView),\n presenterDefinition('WebFetch', PRESENTATION_NOTE, fetchCallView),\n presenterDefinition('Task', PRESENTATION_NOTE, taskCallView),\n presenterDefinition('TodoWrite', PRESENTATION_NOTE, () => genericTitle('Update todos')),\n ]\n}\n\n/** Names covered by the static preset-scope registry; dynamic mirrors skip them. */\nexport const CLAUDE_PRESENTER_NAMES: ReadonlySet<string> = new Set(claudePresenterDefinitions().map(definition => definition.name))\n"],"mappings":";;AAIA,MAAM,eAAe;AACrB,MAAM,wBAAwB;AAC9B,MAAM,iBAAiB;;;;AAKvB,SAAS,aAAa,YAAwC;CAC5D,IAAI,aAAa,KAAK,UAAU,GAAG,OAAO;CAC1C,MAAM,QAAQ,WAAW,SAAS,GAAG,IAAI,WAAW,MAAM,WAAW,YAAY,GAAG,IAAI,CAAC,IAAI,KAAA;CAC7F,IAAI,UAAU,KAAA,KAAa,aAAa,KAAK,KAAK,GAAG,OAAO;CAC5D,MAAM,YAAY,WAAW,WAAW,KAAK,GAAG,CAAC,CAAC,YAAY;CAC9D,OAAO,aAAa,KAAK,SAAS,IAAI,YAAY,KAAA;AACpD;;;;;;;;;AAUA,MAAM,4CAAiD,IAAI,IAAI,CAAC,OAAO,CAAC;;;;;;;AAuBxE,MAAa,0BAA0B;AAgBvC,SAAS,QAAQ,OAAe,UAA0B;CACxD,OAAO,WAAW,OAAO,QAAQ;AACnC;AAEA,SAAgB,sBACd,SACA,QAC8B;CAC9B,MAAM,gBAAgB,IAAI,IAAI,OAAO,KAAK,CAAC,CAAC,KAAI,YAAW,QAAQ,IAAI,CAA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mjs","names":[],"sources":["../src/command-bridge.ts","../src/presenters.ts"],"sourcesContent":["import type { SlashCommand } from '@anthropic-ai/claude-agent-sdk'\nimport type { CommandDescriptor } from '@deepseek-ai/dsh-commands'\nimport { redactText } from './events.ts'\n\nconst COMMAND_NAME = /^[a-z][a-z0-9_-]*$/u\nconst MAX_DESCRIPTION_CHARS = 300\nconst MAX_HINT_CHARS = 120\n\n/** DSH registry names reject `:`, but plugin-qualified Claude skills carry it\n * (e.g. `awesome-skills:ci-deploy`). Derive a registry-safe public name while\n * forwarding keeps the exact Claude-side name. */\nfunction registryName(claudeName: string): string | undefined {\n if (COMMAND_NAME.test(claudeName)) return claudeName\n const short = claudeName.includes(':') ? claudeName.slice(claudeName.lastIndexOf(':') + 1) : undefined\n if (short !== undefined && COMMAND_NAME.test(short)) return short\n const sanitized = claudeName.replaceAll(':', '-').toLowerCase()\n return COMMAND_NAME.test(sanitized) ? sanitized : undefined\n}\n\n/**\n * Names registered as CLIENT-side commandUi contributions (not host\n * commands). The DSH web command palette fails its whole command group when\n * a host command name equals a contribution name\n * (\"contribution /model collides with a host command\"), so these can never\n * be registered by this bridge. Keep in sync with the client bundles:\n * dsh-client-ui-model-selection registers \"model\".\n */\nconst CLIENT_CONTRIBUTION_NAMES: ReadonlySet<string> = new Set(['model'])\n\nexport interface ClaudeCommandTarget {\n list(): readonly Pick<CommandDescriptor, 'name'>[]\n}\n\n/**\n * Agent-scope command-directory contract. The commands service is unreachable\n * from the host plugin's view of `agent.ctx` (\"without inject\"), but the\n * preset route plugin runs inside the agent's preset composition with\n * `commands` injected. The Host reads only the exact agent's effective names\n * for collision checks; Claude catalog entries are never registered there.\n */\nexport interface ClaudeAgentCommandService {\n list(agent: unknown): readonly Pick<CommandDescriptor, 'name'>[]\n}\n\n/**\n * Cordis service name the preset route provides (behind an entry-local\n * isolate realm, so each session gets its own instance) and the host reads\n * back with dsh-agent-presets' official `serviceForAgent(ctx, agent, name)`\n * — the supported cross-scope read for callers that already hold the agent.\n */\nexport const CLAUDE_COMMANDS_SERVICE = 'claudeCommands'\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n claudeCommands?: ClaudeAgentCommandService\n }\n}\n\nexport interface ClaudeCommandView {\n publicName: string\n claudeName: string\n description: string\n hint?: string\n prefixed: boolean\n}\n\nfunction bounded(value: string, maxChars: number): string {\n return redactText(value, maxChars)\n}\n\nexport function projectClaudeCommands(\n catalog: readonly SlashCommand[],\n target: ClaudeCommandTarget,\n): readonly ClaudeCommandView[] {\n const reservedNames = new Set(target.list().map(command => command.name))\n // Client contributions are absent from the Host directory but share the\n // same slash menu, so reserve their public names explicitly.\n for (const name of CLIENT_CONTRIBUTION_NAMES) reservedNames.add(name)\n const assigned = new Set<string>()\n const views: ClaudeCommandView[] = []\n for (const command of catalog) {\n const names = [command.name, ...(command.aliases ?? [])]\n const commandBases = new Set<string>()\n for (const claudeName of names) {\n const base = registryName(claudeName)\n if (base === undefined || commandBases.has(base)) continue\n commandBases.add(base)\n let publicName = base\n let prefixed = false\n if (reservedNames.has(publicName) || assigned.has(publicName)) {\n publicName = `claude-${base}`\n prefixed = true\n }\n if (!COMMAND_NAME.test(publicName) || reservedNames.has(publicName) || assigned.has(publicName)) continue\n const description = bounded(command.description || `Claude Code /${command.name}`, MAX_DESCRIPTION_CHARS)\n const hint = bounded(command.argumentHint ?? '', MAX_HINT_CHARS)\n views.push({\n publicName,\n claudeName,\n description,\n ...(hint.length === 0 ? {} : { hint }),\n prefixed,\n })\n assigned.add(publicName)\n }\n }\n return views\n}\n","/**\n * Presentation-only tool definitions for the Claude Code preset. Claude Code\n * owns tool execution; these definitions exist solely so the host's tool\n * presentation pipeline (`viewFor` → `presentCall`/`presentResult`) can\n * compute native render intents for the mirrored `tool/call`/`tool/result`\n * events, giving Claude tool rows the same cards DSH-executed tools get.\n */\nimport type { ToolDefinition, ToolResult } from '@deepseek-ai/dsh-tools'\nimport type { ToolCallView, ToolResultView } from '@deepseek-ai/dsh-tools/presentation'\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : undefined\n}\n\nfunction str(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nfunction resultText(result: ToolResult): string {\n return result.content\n .filter((block): block is Extract<typeof block, { type: 'text' }> => block.type === 'text')\n .map(block => block.text)\n .join('\\n')\n}\n\n/** Bash: a terminal card headed by the command, described above by Claude's own summary. */\nexport function bashCallView(args: unknown): ToolCallView | undefined {\n const command = str(record(args)?.command)\n if (command === undefined) return undefined\n const description = str(record(args)?.description)\n return { card: 'terminal', title: command, ...(description === undefined ? {} : { description }) }\n}\n\nexport function terminalResultView(_args: unknown, result: ToolResult): ToolResultView | undefined {\n const output = resultText(result)\n return output.length === 0 ? undefined : { card: 'terminal', output }\n}\n\n/** Read: a generic read card that follow-alongs the file window. */\nexport function readCallView(args: unknown): ToolCallView | undefined {\n const arguments_ = record(args)\n const path = str(arguments_?.file_path)\n if (path === undefined) return undefined\n const offset = typeof arguments_?.offset === 'number' ? arguments_.offset : undefined\n return {\n card: 'generic',\n kind: 'read',\n title: `Read ${path}`,\n locations: [{ path, ...(offset === undefined ? {} : { line: offset }) }],\n }\n}\n\nfunction fileDiffs(args: unknown): { path: string; oldText: string | null; newText: string }[] | undefined {\n const arguments_ = record(args)\n const path = str(arguments_?.file_path)\n if (path === undefined) return undefined\n if (Array.isArray(arguments_?.edits)) {\n const diffs: { path: string; oldText: string | null; newText: string }[] = []\n for (const edit of arguments_.edits) {\n const item = record(edit)\n const oldText = str(item?.old_string)\n const newText = str(item?.new_string)\n if (newText === undefined) continue\n diffs.push({ path, oldText: oldText ?? null, newText })\n }\n return diffs.length > 0 ? diffs : undefined\n }\n const newText = str(arguments_?.new_string) ?? arguments_?.content\n if (typeof newText !== 'string' || newText.length === 0) return undefined\n const oldText = str(arguments_?.old_string)\n return [{ path, oldText: oldText ?? null, newText }]\n}\n\n/** Edit / MultiEdit / Write: inline diff cards derived from the call arguments. */\nexport function diffCallView(args: unknown): ToolCallView | undefined {\n const arguments_ = record(args)\n const path = str(arguments_?.file_path)\n const diffs = fileDiffs(args)\n if (path === undefined || diffs === undefined) return undefined\n const verb = typeof arguments_?.new_string === 'string' || Array.isArray(arguments_?.edits) ? 'Edit' : 'Write'\n return { card: 'diff', title: `${verb} ${path}`, diffs, locations: [{ path }] }\n}\n\n/** Edit / MultiEdit / Write results: the same diff, again.\n *\n * A completed card replaces the pending one, so a mutation that returns no\n * result view loses its diff to the raw result text. The plugin transcript\n * drops the diff on failure and shows the error instead; mirror that. */\nexport function diffResultView(args: unknown, result: ToolResult): ToolResultView | undefined {\n if (result.isError) return undefined\n const diffs = fileDiffs(args)\n return diffs === undefined ? undefined : { card: 'diff', diffs }\n}\n\nfunction parsedResult(result: ToolResult): unknown {\n const text = resultText(result)\n if (text.length === 0) return undefined\n try {\n return JSON.parse(text) as unknown\n } catch {\n return text\n }\n}\n\n/** Grep / Glob results: the discovered paths as a search card.\n *\n * Only the structured `filenames` shape is projected. A text result (Grep's\n * content mode) carries its own formatting, so it falls through to the raw\n * result content rather than being re-parsed into fake match groups. */\nexport function searchResultView(_args: unknown, result: ToolResult): ToolResultView | undefined {\n if (result.isError) return undefined\n const output = record(parsedResult(result))\n if (!Array.isArray(output?.filenames)) return undefined\n const paths = output.filenames.filter((item): item is string => typeof item === 'string')\n const reported = output.numFiles\n const total = typeof reported === 'number' && Number.isInteger(reported) && reported >= paths.length ? reported : paths.length\n return { card: 'search', shape: 'paths', paths, truncated: total > paths.length, total }\n}\n\n/** Grep / Glob / WebSearch: search-category cards titled by the query. */\nexport function searchCallView(args: unknown): ToolCallView | undefined {\n const arguments_ = record(args)\n const query = str(arguments_?.pattern) ?? str(arguments_?.query)\n if (query === undefined) return undefined\n const scope = str(arguments_?.path)\n return {\n card: 'generic',\n kind: 'search',\n title: scope === undefined ? query : `${query} · ${scope}`,\n rawInput: args,\n }\n}\n\n/** WebFetch: a fetch-category card titled by the URL. */\nexport function fetchCallView(args: unknown): ToolCallView | undefined {\n const url = str(record(args)?.url)\n if (url === undefined) return undefined\n return { card: 'generic', kind: 'fetch', title: url, rawInput: args }\n}\n\n/** ExitPlanMode: the plan itself, as prose rather than as tool arguments.\n *\n * This is the one built-in tool whose whole payload is written for the user\n * to read: Claude asks to leave plan mode and the approval that follows is\n * the user agreeing to the plan. Rendering it as `Input: {\"plan\":\"...\"}`\n * buries the only thing worth reading, so the plan becomes the card body. */\nexport function planCallView(args: unknown): ToolCallView | undefined {\n const plan = str(record(args)?.plan)\n return plan === undefined ? undefined : {\n card: 'generic',\n kind: 'other',\n title: 'Plan ready for review',\n content: [{ type: 'text', text: plan }],\n }\n}\n\n/** Task: a subagent card titled by Claude's task description. */\nexport function taskCallView(args: unknown): ToolCallView | undefined {\n const arguments_ = record(args)\n const title = str(arguments_?.description) ?? str(arguments_?.subagent_type) ?? 'Subagent'\n return { card: 'generic', kind: 'other', title, rawInput: args }\n}\n\nfunction genericTitle(title: string): ToolCallView {\n return { card: 'generic', kind: 'other', title }\n}\n\nfunction presenterDefinition(\n name: string,\n description: string,\n presentCall?: (args: unknown) => ToolCallView | undefined,\n presentResult?: (args: unknown, result: ToolResult) => ToolResultView | undefined,\n): ToolDefinition {\n return {\n name,\n description,\n parameters: { type: 'object', properties: {} },\n output: {\n schema: { type: 'object', properties: {} } as ToolDefinition['output']['schema'],\n render: () => [],\n },\n execute: async () => {\n throw new Error(`dsh-claude: Claude Code owns execution of ${name}`)\n },\n ...(presentCall === undefined ? {} : { presentCall }),\n ...(presentResult === undefined ? {} : { presentResult }),\n }\n}\n\nconst PRESENTATION_NOTE = 'Presentation mirror of the Claude Code tool; execution is owned by Claude Code.'\n\n/** Generic call view for dynamically observed tools (MCP tools, new built-ins). */\nexport function genericCallView(toolName: string): (args: unknown) => ToolCallView | undefined {\n return (args: unknown) => {\n const description = str(record(args)?.description)\n return { card: 'generic', kind: 'other', title: description ?? toolName, rawInput: args }\n }\n}\n\n/** One presenter-only mirror for a tool name discovered at runtime. */\nexport function dynamicPresenterDefinition(name: string): ToolDefinition {\n return presenterDefinition(name, PRESENTATION_NOTE, genericCallView(name))\n}\n\n/** The presentation-only registry contributed to the Claude Code preset scope. */\nexport function claudePresenterDefinitions(): ToolDefinition[] {\n return [\n presenterDefinition('Bash', PRESENTATION_NOTE, bashCallView, terminalResultView),\n // The plugin transcript gives PowerShell the same terminal treatment as\n // Bash; without its own mirror the native card would fall back to generic.\n presenterDefinition('PowerShell', PRESENTATION_NOTE, bashCallView, terminalResultView),\n presenterDefinition('Read', PRESENTATION_NOTE, readCallView),\n presenterDefinition('Edit', PRESENTATION_NOTE, diffCallView, diffResultView),\n presenterDefinition('MultiEdit', PRESENTATION_NOTE, diffCallView, diffResultView),\n presenterDefinition('Write', PRESENTATION_NOTE, diffCallView, diffResultView),\n presenterDefinition('NotebookEdit', PRESENTATION_NOTE, args => {\n const path = str(record(args)?.notebook_path)\n return path === undefined ? undefined : genericTitle(`NotebookEdit ${path}`)\n }),\n presenterDefinition('Grep', PRESENTATION_NOTE, searchCallView, searchResultView),\n presenterDefinition('Glob', PRESENTATION_NOTE, searchCallView, searchResultView),\n presenterDefinition('WebSearch', PRESENTATION_NOTE, searchCallView),\n presenterDefinition('WebFetch', PRESENTATION_NOTE, fetchCallView),\n presenterDefinition('Task', PRESENTATION_NOTE, taskCallView),\n presenterDefinition('ExitPlanMode', PRESENTATION_NOTE, planCallView),\n presenterDefinition('TodoWrite', PRESENTATION_NOTE, () => genericTitle('Update todos')),\n ]\n}\n\n/** Names covered by the static preset-scope registry; dynamic mirrors skip them. */\nexport const CLAUDE_PRESENTER_NAMES: ReadonlySet<string> = new Set(claudePresenterDefinitions().map(definition => definition.name))\n"],"mappings":";;AAIA,MAAM,eAAe;AACrB,MAAM,wBAAwB;AAC9B,MAAM,iBAAiB;;;;AAKvB,SAAS,aAAa,YAAwC;CAC5D,IAAI,aAAa,KAAK,UAAU,GAAG,OAAO;CAC1C,M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AAc,kBAAkB;EAG/E,oBAAoB,cAAc,mBAAmB,cAAc,kBAAkB;EACrF,oBAAoB,QAAQ,mBAAmB,YAAY;EAC3D,oBAAoB,QAAQ,mBAAmB,cAAc,cAAc;EAC3E,oBAAoB,aAAa,mBAAmB,cAAc,cAAc;EAChF,oBAAoB,SAAS,mBAAmB,cAAc,cAAc;EAC5E,oBAAoB,gBAAgB,oBAAmB,SAAQ;GAC7D,MAAM,OAAO,IAAI,OAAO,IAAI,CAAC,EAAE,aAAa;GAC5C,OAAO,SAAS,KAAA,IAAY,KAAA,IAAY,aAAa,gBAAgB,MAAM;EAC7E,CAAC;EACD,oBAAoB,QAAQ,mBAAmB,gBAAgB,gBAAgB;EAC/E,oBAAoB,QAAQ,mBAAmB,gBAAgB,gBAAgB;EAC/E,oBAAoB,aAAa,mBAAmB,cAAc;EAClE,oBAAoB,YAAY,mBAAmB,aAAa;EAChE,oBAAoB,QAAQ,mBAAmB,YAAY;EAC3D,oBAAoB,gBAAgB,mBAAmB,YAAY;EACnE,oBAAoB,aAAa,yBAAyB,aAAa,cAAc,CAAC;CACxF;AACF;;AAGA,MAAa,yBAA8C,IAAI,IAAI,2BAA2B,CAAC,CAAC,KAAI,eAAc,WAAW,IAAI,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as CLAUDE_CODE_PRESET_ID, l as redactText } from "./events-B-FPMzI7.mjs";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { access, link, lstat, mkdir, readFile, readdir, rm, rmdir, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, isAbsolute, join, win32 } from "node:path";
|
|
@@ -304,4 +304,4 @@ async function removeManagedPreset(paths = defaultManagedPresetPaths()) {
|
|
|
304
304
|
//#endregion
|
|
305
305
|
export { resolveClaudeExecutable as a, parseClaudeVersion as i, ensureManagedPreset as n, runClaudeDoctor as o, removeManagedPreset as r, ManagedPresetConflictError as t };
|
|
306
306
|
|
|
307
|
-
//# sourceMappingURL=preset-installer-
|
|
307
|
+
//# sourceMappingURL=preset-installer-yRGfkGjd.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset-installer-loenwnLS.mjs","names":[],"sources":["../src/executable.ts","../src/preset-installer.ts"],"sourcesContent":["import { constants } from 'node:fs'\nimport { access } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { isAbsolute, join, win32 } from 'node:path'\nimport type { SubprocessHandle, SubprocessRuntime } from '@deepseek-ai/dsh-subprocess'\nimport { redactText } from './events.ts'\n\nconst VERSION_PATTERN = /(?:Claude Code\\s+)?v?(\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?)/i\nconst MAX_PROBE_STDOUT = 64 * 1024\nconst MAX_PROBE_STDERR = 8 * 1024\n\nexport type ExecutableRuntime = Pick<SubprocessRuntime, 'resolveExecutable' | 'spawn'>\n\nexport class ClaudeExecutableNotFoundError extends Error {\n readonly searched: readonly string[]\n\n constructor(searched: readonly string[], options?: ErrorOptions) {\n super(`Claude Code executable not found. Searched: ${searched.join(', ')}`, options)\n this.name = 'ClaudeExecutableNotFoundError'\n this.searched = [...searched]\n }\n}\n\nexport interface ClaudeExecutableResolution {\n path: string\n searched: readonly string[]\n}\n\nexport interface ClaudeDoctorReport {\n executable: {\n status: 'found' | 'missing'\n path?: string\n searched: readonly string[]\n }\n version: {\n status: 'ok' | 'error' | 'not-run'\n value?: string\n message?: string\n }\n authentication: {\n status: 'signed-in' | 'signed-out' | 'unknown' | 'not-run'\n method?: string\n provider?: string\n subscription?: string\n message?: string\n }\n handshake: 'not-run' | 'ok' | 'error'\n}\n\nfunction fallbackCandidates(): string[] {\n if (process.platform !== 'darwin') return []\n return [\n join(homedir(), '.local', 'bin', 'claude'),\n '/opt/homebrew/bin/claude',\n '/usr/local/bin/claude',\n ]\n}\n\nfunction abortError(error: unknown): boolean {\n return error instanceof Error && (error.name === 'AbortError' || error.name === 'TimeoutError')\n}\n\n/**\n * Prefer the package's own native binary over a Windows npm shim.\n *\n * A PATH lookup on Windows answers `claude.CMD`, and since the fix for\n * CVE-2024-27980 Node refuses to spawn `.cmd` and `.bat` without\n * `shell: true` — every probe and every session then fails with\n * `spawn EINVAL`, reported to the user as an executable and authentication\n * error with nothing pointing at the file extension. Auto-resolution\n * therefore cannot work on Windows at all, and the user has to discover\n * `executablePath` to get anywhere.\n *\n * npm installs the package beside the shim it writes, and\n * `@anthropic-ai/claude-code` ships a native executable (its own manifest\n * declares `\"bin\": { \"claude\": \"bin/claude.exe\" }`), which carries no such\n * restriction. Falling back to the shim keeps a layout that does not match\n * this assumption working exactly as before.\n *\n * @param path - the resolved candidate, possibly a Windows shim.\n * @returns the native executable when one sits beside the shim, else `path`.\n */\nasync function preferNativeWindowsBinary(path: string): Promise<string> {\n if (process.platform !== 'win32') return path\n if (!/\\.(?:cmd|bat)$/iu.test(path)) return path\n const native = win32.join(\n win32.dirname(path),\n 'node_modules',\n '@anthropic-ai',\n 'claude-code',\n 'bin',\n 'claude.exe',\n )\n try {\n await access(native, constants.X_OK)\n return native\n } catch {\n return path\n }\n}\n\nexport async function resolveClaudeExecutable(\n runtime: ExecutableRuntime,\n configuredPath?: string,\n signal?: AbortSignal,\n): Promise<ClaudeExecutableResolution> {\n const searched: string[] = []\n const candidates = configuredPath === undefined\n ? ['claude', ...fallbackCandidates()]\n : [configuredPath]\n if (configuredPath !== undefined && !isAbsolute(configuredPath) && !win32.isAbsolute(configuredPath)) {\n throw new Error(`Claude Code executable path must be absolute: ${configuredPath}`)\n }\n\n let lastError: unknown\n for (const candidate of candidates) {\n if (searched.includes(candidate)) continue\n searched.push(candidate)\n try {\n const resolved = await runtime.resolveExecutable(candidate, undefined, signal)\n return { path: await preferNativeWindowsBinary(resolved), searched }\n } catch (error) {\n if (abortError(error) || signal?.aborted === true) throw error\n lastError = error\n }\n }\n throw new ClaudeExecutableNotFoundError(searched, lastError === undefined ? undefined : { cause: lastError })\n}\n\ninterface CollectedCommand {\n exitCode: number | null\n signal: NodeJS.Signals | null\n stdout: string\n stderr: string\n}\n\nasync function collect(handle: SubprocessHandle): Promise<CollectedCommand> {\n const outcome = await handle.done\n const stdout = handle.collected.stdout?.readFrom(0).text ?? ''\n const stderr = handle.collected.stderr?.readFrom(0).text ?? ''\n return { ...outcome, stdout, stderr }\n}\n\nasync function runProbe(\n runtime: ExecutableRuntime,\n executable: string,\n args: readonly string[],\n cwd: string,\n signal?: AbortSignal,\n): Promise<CollectedCommand> {\n return collect(runtime.spawn({\n argv: [executable, ...args],\n cwd,\n stdio: {\n stdin: 'ignore',\n stdout: { maxBytes: MAX_PROBE_STDOUT },\n stderr: { maxBytes: MAX_PROBE_STDERR },\n },\n graceMs: 2_000,\n ...(signal === undefined ? {} : { signal }),\n env: {},\n }))\n}\n\nexport function parseClaudeVersion(output: string): string | undefined {\n return VERSION_PATTERN.exec(output)?.[1]\n}\n\nexport async function probeClaudeVersion(\n runtime: ExecutableRuntime,\n executable: string,\n cwd: string,\n signal?: AbortSignal,\n): Promise<string> {\n const result = await runProbe(runtime, executable, ['--version'], cwd, signal)\n const version = parseClaudeVersion(`${result.stdout}\\n${result.stderr}`)\n if (result.exitCode !== 0 || version === undefined) {\n throw new Error(`Claude Code version probe failed (${result.exitCode ?? result.signal ?? 'unknown exit'})`)\n }\n return version\n}\n\nexport async function probeClaudeAuthentication(\n runtime: ExecutableRuntime,\n executable: string,\n cwd: string,\n signal?: AbortSignal,\n): Promise<ClaudeDoctorReport['authentication']> {\n const result = await runProbe(runtime, executable, ['auth', 'status', '--json'], cwd, signal)\n if (result.exitCode !== 0) {\n return { status: 'unknown', message: 'Claude authentication status command failed' }\n }\n try {\n const value = JSON.parse(result.stdout) as Record<string, unknown>\n const report: ClaudeDoctorReport['authentication'] = {\n status: value.loggedIn === true ? 'signed-in' : value.loggedIn === false ? 'signed-out' : 'unknown',\n }\n if (typeof value.authMethod === 'string') report.method = redactText(value.authMethod, 100)\n if (typeof value.apiProvider === 'string') report.provider = redactText(value.apiProvider, 100)\n if (typeof value.subscriptionType === 'string') report.subscription = redactText(value.subscriptionType, 100)\n return report\n } catch {\n return { status: 'unknown', message: 'Claude authentication status was not valid JSON' }\n }\n}\n\nexport async function runClaudeDoctor(\n runtime: ExecutableRuntime,\n options: { configuredPath?: string; cwd: string; signal?: AbortSignal },\n): Promise<ClaudeDoctorReport> {\n let resolution: ClaudeExecutableResolution\n try {\n resolution = await resolveClaudeExecutable(runtime, options.configuredPath, options.signal)\n } catch (error) {\n if (error instanceof ClaudeExecutableNotFoundError) {\n return {\n executable: { status: 'missing', searched: error.searched },\n version: { status: 'not-run' },\n authentication: { status: 'not-run' },\n handshake: 'not-run',\n }\n }\n throw error\n }\n\n const report: ClaudeDoctorReport = {\n executable: { status: 'found', path: resolution.path, searched: resolution.searched },\n version: { status: 'not-run' },\n authentication: { status: 'not-run' },\n handshake: 'not-run',\n }\n try {\n report.version = {\n status: 'ok',\n value: await probeClaudeVersion(runtime, resolution.path, options.cwd, options.signal),\n }\n } catch (error) {\n report.version = {\n status: 'error',\n message: error instanceof Error ? error.message : 'Version probe failed',\n }\n }\n try {\n report.authentication = await probeClaudeAuthentication(runtime, resolution.path, options.cwd, options.signal)\n } catch (error) {\n report.authentication = {\n status: 'unknown',\n message: error instanceof Error ? error.message : 'Authentication probe failed',\n }\n }\n return report\n}\n","import { randomUUID } from 'node:crypto'\nimport { link, lstat, mkdir, readFile, readdir, rm, rmdir, writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { dshHomePath } from '@deepseek-ai/dsh-home-paths'\nimport { CLAUDE_CODE_PRESET_ID } from './constants.ts'\n\nexport const MANAGED_PRESET_FILES = ['agent.cordis.yml', 'preset.yml'] as const\n\n/** Package specifier kept in the installed template. DSH Desktop 2.0.4 resolves\n * it through the active profile package factory, so the preset route and client\n * module share one Loader source. An absolute built entry would register a\n * second source and make the Desktop renderer reject the plugin graph. */\nconst PRESET_ROUTE_PACKAGE_SPECIFIER = '@norman-else/dsh-claude/preset-route'\n\nexport class ManagedPresetConflictError extends Error {\n readonly path: string\n\n constructor(path: string) {\n super(`dsh-claude: refusing to overwrite user-modified preset file ${path}`)\n this.name = 'ManagedPresetConflictError'\n this.path = path\n }\n}\n\nexport interface ManagedPresetPaths {\n sourceDir: string\n targetDir: string\n}\n\nexport function defaultManagedPresetPaths(dshHome?: string): ManagedPresetPaths {\n const packageRoot = fileURLToPath(new URL('../', import.meta.url))\n return {\n sourceDir: join(packageRoot, 'legacy-preset'),\n targetDir: dshHome === undefined\n ? dshHomePath('.agent-presets', CLAUDE_CODE_PRESET_ID)\n : join(dshHome, '.agent-presets', CLAUDE_CODE_PRESET_ID),\n }\n}\n\ninterface ManagedContent {\n file: string\n /** Content this installer version writes. */\n content: string\n /** Older installer-written contents that may be silently upgraded/removed. */\n legacy: readonly string[]\n /** Legacy detection for contents that predate the current template. */\n isLegacy(current: string): boolean\n}\n\nasync function managedContents(paths: ManagedPresetPaths): Promise<ManagedContent[]> {\n return await Promise.all(MANAGED_PRESET_FILES.map(async (file): Promise<ManagedContent> => {\n const source = await readFile(join(paths.sourceDir, file), 'utf8')\n const nameRow = `name: '${PRESET_ROUTE_PACKAGE_SPECIFIER}'`\n const legacyNameRow = `name: ${PRESET_ROUTE_PACKAGE_SPECIFIER}`\n if (file !== 'agent.cordis.yml' || !source.includes(nameRow)) {\n return { file, content: source, legacy: [], isLegacy: () => false }\n }\n return {\n file,\n content: source,\n legacy: [],\n // Earlier installers wrote either an unquoted specifier or an absolute\n // built-module path. Both are installer-owned and safe to converge to the\n // single profile package source used by Desktop 2.0.4.\n isLegacy: current =>\n current.includes('id: claude-code-route')\n && (current.includes(legacyNameRow)\n || current.includes('lib/preset-route.mjs')),\n }\n }))\n}\n\nasync function readIfPresent(path: string): Promise<string | undefined> {\n try {\n return await readFile(path, 'utf8')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined\n throw error\n }\n}\n\nasync function atomicWrite(path: string, content: string): Promise<boolean> {\n await mkdir(dirname(path), { recursive: true })\n const temporary = `${path}.${randomUUID()}.tmp`\n try {\n await writeFile(temporary, content, { encoding: 'utf8', mode: 0o600, flag: 'wx' })\n try {\n await link(temporary, path)\n return true\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error\n if (await readIfPresent(path) === content) return false\n throw new ManagedPresetConflictError(path)\n }\n } finally {\n await rm(temporary, { force: true })\n }\n}\n\nexport async function ensureManagedPreset(paths = defaultManagedPresetPaths()): Promise<'installed' | 'unchanged'> {\n await assertSafeTargetDirectory(paths.targetDir)\n const expected = await managedContents(paths)\n let changed = false\n for (const { file, content, legacy, isLegacy } of expected) {\n const target = join(paths.targetDir, file)\n const current = await readIfPresent(target)\n if (current === content) continue\n if (current !== undefined) {\n // Upgrade installer-written legacy content in place; never touch user edits.\n if (!legacy.includes(current) && !isLegacy(current)) throw new ManagedPresetConflictError(target)\n await rm(target)\n }\n changed = await atomicWrite(target, content) || changed\n }\n return changed ? 'installed' : 'unchanged'\n}\n\n/** Reject a target directory that is a symlink (or occupies the path as a file)\n * so the managed preset never writes through an attacker-controlled link. */\nasync function assertSafeTargetDirectory(targetDir: string): Promise<void> {\n try {\n const stat = await lstat(targetDir)\n if (!stat.isDirectory() || stat.isSymbolicLink()) {\n throw new ManagedPresetConflictError(targetDir)\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return\n throw error\n }\n}\n\nexport async function removeManagedPreset(paths = defaultManagedPresetPaths()): Promise<'removed' | 'absent'> {\n await assertSafeTargetDirectory(paths.targetDir)\n const expected = await managedContents(paths)\n const managedTargets: string[] = []\n for (const { file, content, legacy, isLegacy } of expected) {\n const target = join(paths.targetDir, file)\n const current = await readIfPresent(target)\n if (current === undefined) continue\n if (current !== content && !legacy.includes(current) && !isLegacy(current)) throw new ManagedPresetConflictError(target)\n managedTargets.push(target)\n }\n for (const target of managedTargets) await rm(target)\n try {\n if ((await readdir(paths.targetDir)).length === 0) await rmdir(paths.targetDir)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n }\n return managedTargets.length > 0 ? 'removed' : 'absent'\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AAIzB,IAAa,gCAAb,cAAmD,MAAM;CACvD;CAEA,YAAY,UAA6B,SAAwB;EAC/D,MAAM,+CAA+C,SAAS,KAAK,IAAI,KAAK,OAAO;EACnF,KAAK,OAAO;EACZ,KAAK,WAAW,CAAC,GAAG,QAAQ;CAC9B;AACF;AA4BA,SAAS,qBAA+B;CACtC,IAAI,QAAQ,aAAa,UAAU,OAAO,CAAC;CAC3C,OAAO;EACL,KAAK,QAAQ,GAAG,UAAU,OAAO,QAAQ;EACzC;EACA;CACF;AACF;AAEA,SAAS,WAAW,OAAyB;CAC3C,OAAO,iBAAiB,UAAU,MAAM,SAAS,gBAAgB,MAAM,SAAS;AAClF;;;;;;;;;;;;;;;;;;;;;AAsBA,eAAe,0BAA0B,MAA+B;CACtE,IAAI,QAAQ,aAAa,SAAS,OAAO;CACzC,IAAI,CAAC,mBAAmB,KAAK,IAAI,GAAG,OAAO;CAC3C,MAAM,SAAS,MAAM,KACnB,MAAM,QAAQ,IAAI,GAClB,gBACA,iBACA,eACA,OACA,YACF;CACA,IAAI;EACF,MAAM,OAAO,QAAQ,UAAU,IAAI;EACnC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAsB,wBACpB,SACA,gBACA,QACqC;CACrC,MAAM,WAAqB,CAAC;CAC5B,MAAM,aAAa,mBAAmB,KAAA,IAClC,CAAC,UAAU,GAAG,mBAAmB,CAAC,IAClC,CAAC,cAAc;CACnB,IAAI,mBAAmB,KAAA,KAAa,CAAC,WAAW,cAAc,KAAK,CAAC,MAAM,WAAW,cAAc,GACjG,MAAM,IAAI,MAAM,iDAAiD,gBAAgB;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AM,GAAG,MAAM;EACjB;EACA,UAAU,MAAM,YAAY,QAAQ,OAAO,KAAK;CAClD;CACA,OAAO,UAAU,cAAc;AACjC;;;AAIA,eAAe,0BAA0B,WAAkC;CACzE,IAAI;EACF,MAAM,OAAO,MAAM,MAAM,SAAS;EAClC,IAAI,CAAC,KAAK,YAAY,KAAK,KAAK,eAAe,GAC7C,MAAM,IAAI,2BAA2B,SAAS;CAElD,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU;EACxD,MAAM;CACR;AACF;AAEA,eAAsB,oBAAoB,QAAQ,0BAA0B,GAAkC;CAC5G,MAAM,0BAA0B,MAAM,SAAS;CAC/C,MAAM,WAAW,MAAM,gBAAgB,KAAK;CAC5C,MAAM,iBAA2B,CAAC;CAClC,KAAK,MAAM,EAAE,MAAM,SAAS,QAAQ,cAAc,UAAU;EAC1D,MAAM,SAAS,KAAK,MAAM,WAAW,IAAI;EACzC,MAAM,UAAU,MAAM,cAAc,MAAM;EAC1C,IAAI,YAAY,KAAA,GAAW;EAC3B,IAAI,YAAY,WAAW,CAAC,OAAO,SAAS,OAAO,KAAK,CAAC,SAAS,OAAO,GAAG,MAAM,IAAI,2BAA2B,MAAM;EACvH,eAAe,KAAK,MAAM;CAC5B;CACA,KAAK,MAAM,UAAU,gBAAgB,MAAM,GAAG,MAAM;CACpD,IAAI;EACF,KAAK,MAAM,QAAQ,MAAM,SAAS,EAAA,CAAG,WAAW,GAAG,MAAM,MAAM,MAAM,SAAS;CAChF,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,MAAM;CAChE;CACA,OAAO,eAAe,SAAS,IAAI,YAAY;AACjD"}
|
|
1
|
+
{"version":3,"file":"preset-installer-yRGfkGjd.mjs","names":[],"sources":["../src/executable.ts","../src/preset-installer.ts"],"sourcesContent":["import { constants } from 'node:fs'\nimport { access } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { isAbsolute, join, win32 } from 'node:path'\nimport type { SubprocessHandle, SubprocessRuntime } from '@deepseek-ai/dsh-subprocess'\nimport { redactText } from './events.ts'\n\nconst VERSION_PATTERN = /(?:Claude Code\\s+)?v?(\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?)/i\nconst MAX_PROBE_STDOUT = 64 * 1024\nconst MAX_PROBE_STDERR = 8 * 1024\n\nexport type ExecutableRuntime = Pick<SubprocessRuntime, 'resolveExecutable' | 'spawn'>\n\nexport class ClaudeExecutableNotFoundError extends Error {\n readonly searched: readonly string[]\n\n constructor(searched: readonly string[], options?: ErrorOptions) {\n super(`Claude Code executable not found. Searched: ${searched.join(', ')}`, options)\n this.name = 'ClaudeExecutableNotFoundError'\n this.searched = [...searched]\n }\n}\n\nexport interface ClaudeExecutableResolution {\n path: string\n searched: readonly string[]\n}\n\nexport interface ClaudeDoctorReport {\n executable: {\n status: 'found' | 'missing'\n path?: string\n searched: readonly string[]\n }\n version: {\n status: 'ok' | 'error' | 'not-run'\n value?: string\n message?: string\n }\n authentication: {\n status: 'signed-in' | 'signed-out' | 'unknown' | 'not-run'\n method?: string\n provider?: string\n subscription?: string\n message?: string\n }\n handshake: 'not-run' | 'ok' | 'error'\n}\n\nfunction fallbackCandidates(): string[] {\n if (process.platform !== 'darwin') return []\n return [\n join(homedir(), '.local', 'bin', 'claude'),\n '/opt/homebrew/bin/claude',\n '/usr/local/bin/claude',\n ]\n}\n\nfunction abortError(error: unknown): boolean {\n return error instanceof Error && (error.name === 'AbortError' || error.name === 'TimeoutError')\n}\n\n/**\n * Prefer the package's own native binary over a Windows npm shim.\n *\n * A PATH lookup on Windows answers `claude.CMD`, and since the fix for\n * CVE-2024-27980 Node refuses to spawn `.cmd` and `.bat` without\n * `shell: true` — every probe and every session then fails with\n * `spawn EINVAL`, reported to the user as an executable and authentication\n * error with nothing pointing at the file extension. Auto-resolution\n * therefore cannot work on Windows at all, and the user has to discover\n * `executablePath` to get anywhere.\n *\n * npm installs the package beside the shim it writes, and\n * `@anthropic-ai/claude-code` ships a native executable (its own manifest\n * declares `\"bin\": { \"claude\": \"bin/claude.exe\" }`), which carries no such\n * restriction. Falling back to the shim keeps a layout that does not match\n * this assumption working exactly as before.\n *\n * @param path - the resolved candidate, possibly a Windows shim.\n * @returns the native executable when one sits beside the shim, else `path`.\n */\nasync function preferNativeWindowsBinary(path: string): Promise<string> {\n if (process.platform !== 'win32') return path\n if (!/\\.(?:cmd|bat)$/iu.test(path)) return path\n const native = win32.join(\n win32.dirname(path),\n 'node_modules',\n '@anthropic-ai',\n 'claude-code',\n 'bin',\n 'claude.exe',\n )\n try {\n await access(native, constants.X_OK)\n return native\n } catch {\n return path\n }\n}\n\nexport async function resolveClaudeExecutable(\n runtime: ExecutableRuntime,\n configuredPath?: string,\n signal?: AbortSignal,\n): Promise<ClaudeExecutableResolution> {\n const searched: string[] = []\n const candidates = configuredPath === undefined\n ? ['claude', ...fallbackCandidates()]\n : [configuredPath]\n if (configuredPath !== undefined && !isAbsolute(configuredPath) && !win32.isAbsolute(configuredPath)) {\n throw new Error(`Claude Code executable path must be absolute: ${configuredPath}`)\n }\n\n let lastError: unknown\n for (const candidate of candidates) {\n if (searched.includes(candidate)) continue\n searched.push(candidate)\n try {\n const resolved = await runtime.resolveExecutable(candidate, undefined, signal)\n return { path: await preferNativeWindowsBinary(resolved), searched }\n } catch (error) {\n if (abortError(error) || signal?.aborted === true) throw error\n lastError = error\n }\n }\n throw new ClaudeExecutableNotFoundError(searched, lastError === undefined ? undefined : { cause: lastError })\n}\n\ninterface CollectedCommand {\n exitCode: number | null\n signal: NodeJS.Signals | null\n stdout: string\n stderr: string\n}\n\nasync function collect(handle: SubprocessHandle): Promise<CollectedCommand> {\n const outcome = await handle.done\n const stdout = handle.collected.stdout?.readFrom(0).text ?? ''\n const stderr = handle.collected.stderr?.readFrom(0).text ?? ''\n return { ...outcome, stdout, stderr }\n}\n\nasync function runProbe(\n runtime: ExecutableRuntime,\n executable: string,\n args: readonly string[],\n cwd: string,\n signal?: AbortSignal,\n): Promise<CollectedCommand> {\n return collect(runtime.spawn({\n argv: [executable, ...args],\n cwd,\n stdio: {\n stdin: 'ignore',\n stdout: { maxBytes: MAX_PROBE_STDOUT },\n stderr: { maxBytes: MAX_PROBE_STDERR },\n },\n graceMs: 2_000,\n ...(signal === undefined ? {} : { signal }),\n env: {},\n }))\n}\n\nexport function parseClaudeVersion(output: string): string | undefined {\n return VERSION_PATTERN.exec(output)?.[1]\n}\n\nexport async function probeClaudeVersion(\n runtime: ExecutableRuntime,\n executable: string,\n cwd: string,\n signal?: AbortSignal,\n): Promise<string> {\n const result = await runProbe(runtime, executable, ['--version'], cwd, signal)\n const version = parseClaudeVersion(`${result.stdout}\\n${result.stderr}`)\n if (result.exitCode !== 0 || version === undefined) {\n throw new Error(`Claude Code version probe failed (${result.exitCode ?? result.signal ?? 'unknown exit'})`)\n }\n return version\n}\n\nexport async function probeClaudeAuthentication(\n runtime: ExecutableRuntime,\n executable: string,\n cwd: string,\n signal?: AbortSignal,\n): Promise<ClaudeDoctorReport['authentication']> {\n const result = await runProbe(runtime, executable, ['auth', 'status', '--json'], cwd, signal)\n if (result.exitCode !== 0) {\n return { status: 'unknown', message: 'Claude authentication status command failed' }\n }\n try {\n const value = JSON.parse(result.stdout) as Record<string, unknown>\n const report: ClaudeDoctorReport['authentication'] = {\n status: value.loggedIn === true ? 'signed-in' : value.loggedIn === false ? 'signed-out' : 'unknown',\n }\n if (typeof value.authMethod === 'string') report.method = redactText(value.authMethod, 100)\n if (typeof value.apiProvider === 'string') report.provider = redactText(value.apiProvider, 100)\n if (typeof value.subscriptionType === 'string') report.subscription = redactText(value.subscriptionType, 100)\n return report\n } catch {\n return { status: 'unknown', message: 'Claude authentication status was not valid JSON' }\n }\n}\n\nexport async function runClaudeDoctor(\n runtime: ExecutableRuntime,\n options: { configuredPath?: string; cwd: string; signal?: AbortSignal },\n): Promise<ClaudeDoctorReport> {\n let resolution: ClaudeExecutableResolution\n try {\n resolution = await resolveClaudeExecutable(runtime, options.configuredPath, options.signal)\n } catch (error) {\n if (error instanceof ClaudeExecutableNotFoundError) {\n return {\n executable: { status: 'missing', searched: error.searched },\n version: { status: 'not-run' },\n authentication: { status: 'not-run' },\n handshake: 'not-run',\n }\n }\n throw error\n }\n\n const report: ClaudeDoctorReport = {\n executable: { status: 'found', path: resolution.path, searched: resolution.searched },\n version: { status: 'not-run' },\n authentication: { status: 'not-run' },\n handshake: 'not-run',\n }\n try {\n report.version = {\n status: 'ok',\n value: await probeClaudeVersion(runtime, resolution.path, options.cwd, options.signal),\n }\n } catch (error) {\n report.version = {\n status: 'error',\n message: error instanceof Error ? error.message : 'Version probe failed',\n }\n }\n try {\n report.authentication = await probeClaudeAuthentication(runtime, resolution.path, options.cwd, options.signal)\n } catch (error) {\n report.authentication = {\n status: 'unknown',\n message: error instanceof Error ? error.message : 'Authentication probe failed',\n }\n }\n return report\n}\n","import { randomUUID } from 'node:crypto'\nimport { link, lstat, mkdir, readFile, readdir, rm, rmdir, writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { dshHomePath } from '@deepseek-ai/dsh-home-paths'\nimport { CLAUDE_CODE_PRESET_ID } from './constants.ts'\n\nexport const MANAGED_PRESET_FILES = ['agent.cordis.yml', 'preset.yml'] as const\n\n/** Package specifier kept in the installed template. DSH Desktop 2.0.4 resolves\n * it through the active profile package factory, so the preset route and client\n * module share one Loader source. An absolute built entry would register a\n * second source and make the Desktop renderer reject the plugin graph. */\nconst PRESET_ROUTE_PACKAGE_SPECIFIER = '@norman-else/dsh-claude/preset-route'\n\nexport class ManagedPresetConflictError extends Error {\n readonly path: string\n\n constructor(path: string) {\n super(`dsh-claude: refusing to overwrite user-modified preset file ${path}`)\n this.name = 'ManagedPresetConflictError'\n this.path = path\n }\n}\n\nexport interface ManagedPresetPaths {\n sourceDir: string\n targetDir: string\n}\n\nexport function defaultManagedPresetPaths(dshHome?: string): ManagedPresetPaths {\n const packageRoot = fileURLToPath(new URL('../', import.meta.url))\n return {\n sourceDir: join(packageRoot, 'legacy-preset'),\n targetDir: dshHome === undefined\n ? dshHomePath('.agent-presets', CLAUDE_CODE_PRESET_ID)\n : join(dshHome, '.agent-presets', CLAUDE_CODE_PRESET_ID),\n }\n}\n\ninterface ManagedContent {\n file: string\n /** Content this installer version writes. */\n content: string\n /** Older installer-written contents that may be silently upgraded/removed. */\n legacy: readonly string[]\n /** Legacy detection for contents that predate the current template. */\n isLegacy(current: string): boolean\n}\n\nasync function managedContents(paths: ManagedPresetPaths): Promise<ManagedContent[]> {\n return await Promise.all(MANAGED_PRESET_FILES.map(async (file): Promise<ManagedContent> => {\n const source = await readFile(join(paths.sourceDir, file), 'utf8')\n const nameRow = `name: '${PRESET_ROUTE_PACKAGE_SPECIFIER}'`\n const legacyNameRow = `name: ${PRESET_ROUTE_PACKAGE_SPECIFIER}`\n if (file !== 'agent.cordis.yml' || !source.includes(nameRow)) {\n return { file, content: source, legacy: [], isLegacy: () => false }\n }\n return {\n file,\n content: source,\n legacy: [],\n // Earlier installers wrote either an unquoted specifier or an absolute\n // built-module path. Both are installer-owned and safe to converge to the\n // single profile package source used by Desktop 2.0.4.\n isLegacy: current =>\n current.includes('id: claude-code-route')\n && (current.includes(legacyNameRow)\n || current.includes('lib/preset-route.mjs')),\n }\n }))\n}\n\nasync function readIfPresent(path: string): Promise<string | undefined> {\n try {\n return await readFile(path, 'utf8')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined\n throw error\n }\n}\n\nasync function atomicWrite(path: string, content: string): Promise<boolean> {\n await mkdir(dirname(path), { recursive: true })\n const temporary = `${path}.${randomUUID()}.tmp`\n try {\n await writeFile(temporary, content, { encoding: 'utf8', mode: 0o600, flag: 'wx' })\n try {\n await link(temporary, path)\n return true\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error\n if (await readIfPresent(path) === content) return false\n throw new ManagedPresetConflictError(path)\n }\n } finally {\n await rm(temporary, { force: true })\n }\n}\n\nexport async function ensureManagedPreset(paths = defaultManagedPresetPaths()): Promise<'installed' | 'unchanged'> {\n await assertSafeTargetDirectory(paths.targetDir)\n const expected = await managedContents(paths)\n let changed = false\n for (const { file, content, legacy, isLegacy } of expected) {\n const target = join(paths.targetDir, file)\n const current = await readIfPresent(target)\n if (current === content) continue\n if (current !== undefined) {\n // Upgrade installer-written legacy content in place; never touch user edits.\n if (!legacy.includes(current) && !isLegacy(current)) throw new ManagedPresetConflictError(target)\n await rm(target)\n }\n changed = await atomicWrite(target, content) || changed\n }\n return changed ? 'installed' : 'unchanged'\n}\n\n/** Reject a target directory that is a symlink (or occupies the path as a file)\n * so the managed preset never writes through an attacker-controlled link. */\nasync function assertSafeTargetDirectory(targetDir: string): Promise<void> {\n try {\n const stat = await lstat(targetDir)\n if (!stat.isDirectory() || stat.isSymbolicLink()) {\n throw new ManagedPresetConflictError(targetDir)\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return\n throw error\n }\n}\n\nexport async function removeManagedPreset(paths = defaultManagedPresetPaths()): Promise<'removed' | 'absent'> {\n await assertSafeTargetDirectory(paths.targetDir)\n const expected = await managedContents(paths)\n const managedTargets: string[] = []\n for (const { file, content, legacy, isLegacy } of expected) {\n const target = join(paths.targetDir, file)\n const current = await readIfPresent(target)\n if (current === undefined) continue\n if (current !== content && !legacy.includes(current) && !isLegacy(current)) throw new ManagedPresetConflictError(target)\n managedTargets.push(target)\n }\n for (const target of managedTargets) await rm(target)\n try {\n if ((await readdir(paths.targetDir)).length === 0) await rmdir(paths.targetDir)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n }\n return managedTargets.length > 0 ? 'removed' : 'absent'\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AAIzB,IAAa,gCAAb,cAAmD,MAAM;CACvD;CAEA,YAAY,UAA6B,SAAwB;EAC/D,MAAM,+CAA+C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,MAAM;CACR;AACF;AAEA,eAAsB,oBAAoB,QAAQ,0BAA0B,GAAkC;CAC5G,MAAM,0BAA0B,MAAM,SAAS;CAC/C,MAAM,WAAW,MAAM,gBAAgB,KAAK;CAC5C,MAAM,iBAA2B,CAAC;CAClC,KAAK,MAAM,EAAE,MAAM,SAAS,QAAQ,cAAc,UAAU;EAC1D,MAAM,SAAS,KAAK,MAAM,WAAW,IAAI;EACzC,MAAM,UAAU,MAAM,cAAc,MAAM;EAC1C,IAAI,YAAY,KAAA,GAAW;EAC3B,IAAI,YAAY,WAAW,CAAC,OAAO,SAAS,OAAO,KAAK,CAAC,SAAS,OAAO,GAAG,MAAM,IAAI,2BAA2B,MAAM;EACvH,eAAe,KAAK,MAAM;CAC5B;CACA,KAAK,MAAM,UAAU,gBAAgB,MAAM,GAAG,MAAM;CACpD,IAAI;EACF,KAAK,MAAM,QAAQ,MAAM,SAAS,EAAA,CAAG,WAAW,GAAG,MAAM,MAAM,MAAM,SAAS;CAChF,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,MAAM;CAChE;CACA,OAAO,eAAe,SAAS,IAAI,YAAY;AACjD"}
|
package/lib/preset-route.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as CLAUDE_COMMANDS_SERVICE, n as claudePresenterDefinitions } from "./presenters-
|
|
1
|
+
import { g as CLAUDE_CODE_PROVIDER } from "./events-B-FPMzI7.mjs";
|
|
2
|
+
import { i as CLAUDE_COMMANDS_SERVICE, n as claudePresenterDefinitions } from "./presenters-BV42EKkB.mjs";
|
|
3
3
|
//#region src/preset-route.ts
|
|
4
4
|
const name = "claude-code-preset-route";
|
|
5
5
|
const inject = ["tools", "commands"];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@norman-else/dsh-claude",
|
|
3
3
|
"description": "Run the local Claude Code CLI as a first-class main conversation inside DeepSeek Harness",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.41",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.mjs",
|
|
7
7
|
"types": "lib/index.d.mts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events-OhBoFNKO.mjs","names":[],"sources":["../src/constants.ts","../src/events.ts"],"sourcesContent":["export const CLAUDE_CODE_PROVIDER = 'claude'\nexport const CLAUDE_CODE_PRESET_ID = 'claude'\nexport const CLAUDE_CODE_PROVIDER_IDS = [CLAUDE_CODE_PROVIDER] as const\nexport const CLAUDE_SESSION_BOUND_EVENT = 'claude-code/session-bound'\nexport const CLAUDE_ACTIVITY_EVENT = 'claude-code/activity'\nexport const CLAUDE_CONTEXT_USAGE_EVENT = 'claude-code/context-usage'\nexport const CLAUDE_TASKS_EVENT = 'claude-code/tasks'\n/** Claude's subagent dispatch tools; rendered as plugin-owned group cards\n * gathering subagent activity instead of native tool cards. */\nexport const TASK_TOOL_NAMES: ReadonlySet<string> = new Set(['Task', 'Agent'])\nexport const SDK_VERSION = '0.3.247'\nexport const CLAUDE_DOCTOR_PATH = '/plugins/dsh-claude/doctor'\nexport const CLAUDE_CLIENT_DIAGNOSTICS_PATH = '/plugins/dsh-claude/client-diagnostics'\nexport const CLAUDE_UPDATE_CHECK_PATH = '/plugins/dsh-claude/update/check'\nexport const CLAUDE_USAGE_PATH = '/plugins/dsh-claude/usage'\nexport const CLAUDE_UPDATE_PATH = '/plugins/dsh-claude/update'\nexport const CLAUDE_PROJECTION_PATH = '/plugins/dsh-claude/projection'\nexport const CLAUDE_GLOBAL_SETTINGS_PATH = '/plugins/dsh-claude/settings/global'\nexport const CLAUDE_REPOSITORY_SETUP_PATH = '/plugins/dsh-claude/repository/setup'\nexport const CLAUDE_REPOSITORY_ACTION_PATH = '/plugins/dsh-claude/repository/action'\nexport const CLAUDE_REVIEW_COMMENT_PATH = '/plugins/dsh-claude/review-comments'\nexport const CLAUDE_REPOSITORY_FEEDBACK_PATH = '/plugins/dsh-claude/repository/feedback'\nexport const CLAUDE_REPOSITORY_STATUS_PATH = '/plugins/dsh-claude/repository/status'\nexport const CLAUDE_REPOSITORY_FILE_PATH = '/plugins/dsh-claude/repository/file'\nexport const CLAUDE_JIRA_PATH = '/plugins/dsh-claude/jira'\nexport const CLAUDE_ASK_PATH = '/plugins/dsh-claude/ask'\nexport const CLAUDE_EDITOR_OPEN_PATH = '/plugins/dsh-claude/editor/open'\nexport const CLAUDE_REWIND_PATH = '/plugins/dsh-claude/rewind'\n\n/** Which renderer draws Claude's visible output.\n *\n * 'plugin' keeps the sidecar-backed transcript this package owns (interleaved\n * prose, grouped tool cards, activity rows). 'native' hands the same turn to\n * DSH's own conversation renderer: prose streams as ordinary assistant text\n * blocks, thinking as reasoning blocks, and root Claude tools are mirrored\n * into the durable `tool/call`/`tool/result` channel so the Host's tool\n * presentation pipeline draws them exactly like DSH-executed calls. */\nexport type ClaudeRenderMode = 'plugin' | 'native'\nexport const CLAUDE_RENDER_MODES = ['plugin', 'native'] as const\nexport const DEFAULT_CLAUDE_RENDER_MODE: ClaudeRenderMode = 'plugin'\n\nexport function isClaudeRenderMode(value: unknown): value is ClaudeRenderMode {\n return value === 'plugin' || value === 'native'\n}\n\n/** How this package paints the PROSE of a Claude answer.\n *\n * 'plain' is Claude's own presentation: body text in the Host's text colour,\n * colour reserved for code. 'enhanced' gives headings, emphasis, list markers,\n * quotes and links their own hues and darkens the code surface — the way a\n * Markdown-highlighting editor shows a document rather than the way Claude\n * desktop shows an answer. It is opt-in because it deliberately breaks the\n * parity the rest of `markdown-theme.ts` exists to hold.\n *\n * Only meaningful under {@link ClaudeRenderMode} 'plugin': the stylesheet is\n * scoped to markup this package renders, and 'native' turns are drawn by the\n * Host, where it has no reach. */\nexport type ClaudeProseMode = 'plain' | 'enhanced'\nexport const CLAUDE_PROSE_MODES = ['plain', 'enhanced'] as const\nexport const DEFAULT_CLAUDE_PROSE_MODE: ClaudeProseMode = 'plain'\n\nexport function isClaudeProseMode(value: unknown): value is ClaudeProseMode {\n return value === 'plain' || value === 'enhanced'\n}\n","import type { SessionEvent } from '@deepseek-ai/dsh-session'\nimport {\n CLAUDE_ACTIVITY_EVENT,\n CLAUDE_CONTEXT_USAGE_EVENT,\n CLAUDE_SESSION_BOUND_EVENT,\n CLAUDE_TASKS_EVENT,\n isClaudeRenderMode,\n type ClaudeRenderMode,\n} from './constants.ts'\n\nexport type ClaudeActivityKind =\n | 'text'\n | 'status'\n /** Context compaction boundary; the transcript draws it as a divider. */\n | 'compaction'\n | 'thinking'\n | 'tool-call'\n | 'tool-result'\n | 'permission'\n | 'question'\n | 'subagent'\n | 'usage'\n | 'warning'\n | 'error'\n\nexport type ClaudeActivityPhase =\n | 'started'\n | 'updated'\n | 'completed'\n | 'denied'\n | 'failed'\n\nexport interface ClaudeUsage {\n inputTokens?: number\n outputTokens?: number\n cacheReadTokens?: number\n cacheCreationTokens?: number\n cumulativeCostUsd?: number\n /** Wall time from the turn being admitted to it settling. Measured here\n * rather than derived on the client: activities carry no timestamps. */\n durationMs?: number\n /** Wall time to the first visible token of the turn. */\n ttftMs?: number\n}\n\nexport interface ClaudeSessionBoundEvent {\n claudeSessionId: string\n cliVersion?: string\n sdkVersion: string\n cwd: string\n}\n\nexport interface ClaudeActivityEvent {\n turn: number\n step: number\n ordinal: number\n kind: ClaudeActivityKind\n phase?: ClaudeActivityPhase\n /** Claude task-board identity for lifecycle activity; never a transcript path. */\n taskId?: string\n toolUseId?: string\n /** Enclosing Claude tool call for subagent-nested activity. */\n parentToolUseId?: string\n toolName?: string\n title?: string\n summary?: string\n detail?: string\n /** Redacted visible Claude prose used by the plugin-owned interleaved transcript. */\n text?: string\n isError?: boolean\n usage?: ClaudeUsage\n /** Which renderer this record was produced for. Stamped only when the Host\n * drew the step natively, so a record written before the setting existed —\n * and every record written under the plugin renderer — reads as 'plugin'.\n * It travels with the data so a step always renders the way it was\n * recorded, whatever the setting says now. */\n renderer?: ClaudeRenderMode\n}\n\nexport interface ClaudeContextUsageCategory {\n name: string\n tokens: number\n color: string\n isDeferred?: boolean\n}\n\nexport interface ClaudeContextUsageEvent {\n model: string\n totalTokens: number\n maxTokens: number\n percentage: number\n categories: readonly ClaudeContextUsageCategory[]\n}\n\nexport interface ClaudeContextUsageInput {\n model: unknown\n totalTokens: unknown\n maxTokens: unknown\n percentage: unknown\n categories: readonly {\n name?: unknown\n tokens?: unknown\n color?: unknown\n isDeferred?: unknown\n }[]\n}\n\ndeclare module '@deepseek-ai/dsh-session/types' {\n interface SessionEventMap {\n 'claude-code/session-bound': ClaudeSessionBoundEvent\n 'claude-code/activity': ClaudeActivityEvent\n 'claude-code/context-usage': ClaudeContextUsageEvent\n 'claude-code/tasks': ClaudeTasksEvent\n }\n}\n\nconst SECRET_KEY = /(?:^|[_-])(password|passwd|secret|token|api[_-]?key|authorization|credential|private[_-]?key|session[_-]?key|env|environ|environment)(?:$|[_-])/i\nconst MAX_SUMMARY_CHARS = 1_000\nconst MAX_DETAIL_CHARS = 4_000\nconst MAX_TRANSCRIPT_TEXT_CHARS = 64_000\nconst MAX_DEPTH = 6\nconst MAX_ARRAY_ITEMS = 40\nconst MAX_OBJECT_KEYS = 60\nconst REDACTED = '[REDACTED]'\nconst TRUNCATED = '…[truncated]'\nconst SECRET_ASSIGNMENT = /((?:password|passwd|secret|token|api[_-]?key|authorization|credential|private[_-]?key|session[_-]?key)\\s*(?:=|:)\\s*)(?:\"[^\"]*\"|'[^']*'|[^\\s,;&]+)/giu\nconst BEARER_TOKEN = /(\\bbearer\\s+)[A-Za-z0-9._~+/=-]+/giu\nconst PREFIXED_TOKEN = /\\b(?:sk-(?:ant-|proj-)?|xox[baprs]-|ghp_|github_pat_)[A-Za-z0-9_-]{8,}/giu\nconst JWT_TOKEN = /\\beyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b/gu\nconst URL_USERINFO = /([a-z][a-z0-9+.-]*:\\/\\/[^:\\s/@]+:)[^@\\s/]+@/giu\nconst URL_SECRET_PARAM = /([?&](?:password|secret|token|api[_-]?key|access[_-]?token|refresh[_-]?token)=)[^&#\\s]+/giu\n\nexport function boundText(value: string, maxChars: number): string {\n if (value.length <= maxChars) return value\n return `${value.slice(0, Math.max(0, maxChars - TRUNCATED.length))}${TRUNCATED}`\n}\n\nexport function redactText(value: string, maxChars = MAX_DETAIL_CHARS): string {\n return boundText(\n value\n .replace(JWT_TOKEN, REDACTED)\n .replace(PREFIXED_TOKEN, REDACTED)\n .replace(BEARER_TOKEN, `$1${REDACTED}`)\n .replace(URL_USERINFO, `$1${REDACTED}@`)\n .replace(URL_SECRET_PARAM, `$1${REDACTED}`)\n .replace(SECRET_ASSIGNMENT, `$1${REDACTED}`),\n maxChars,\n )\n}\n\nexport function redactValue(value: unknown, depth = 0, seen = new WeakSet<object>()): unknown {\n if (depth > MAX_DEPTH) return '[max-depth]'\n if (value === null || typeof value === 'boolean' || typeof value === 'number') return value\n if (typeof value === 'string') return redactText(value)\n if (typeof value === 'bigint') return value.toString()\n if (typeof value === 'undefined') return null\n if (typeof value === 'function' || typeof value === 'symbol') return `[${typeof value}]`\n if (value instanceof Error) {\n return { name: value.name, message: redactText(value.message, MAX_SUMMARY_CHARS) }\n }\n if (typeof value !== 'object') return String(value)\n if (seen.has(value)) return '[circular]'\n seen.add(value)\n try {\n if (Array.isArray(value)) {\n const items = value.slice(0, MAX_ARRAY_ITEMS).map(item => redactValue(item, depth + 1, seen))\n if (value.length > MAX_ARRAY_ITEMS) items.push(`[${value.length - MAX_ARRAY_ITEMS} more items]`)\n return items\n }\n const result: Record<string, unknown> = {}\n const entries = Object.entries(value as Record<string, unknown>)\n for (const [key, item] of entries.slice(0, MAX_OBJECT_KEYS)) {\n result[key] = SECRET_KEY.test(key) ? REDACTED : redactValue(item, depth + 1, seen)\n }\n if (entries.length > MAX_OBJECT_KEYS) result.__truncatedKeys = entries.length - MAX_OBJECT_KEYS\n return result\n } finally {\n seen.delete(value)\n }\n}\n\nexport function safeDetail(value: unknown): string | undefined {\n if (value === undefined) return undefined\n const redacted = redactValue(value)\n const text = typeof redacted === 'string' ? redacted : JSON.stringify(redacted)\n return boundText(text, MAX_DETAIL_CHARS)\n}\n\nexport function normalizeActivity(\n activity: Omit<ClaudeActivityEvent, 'summary' | 'detail'> & {\n summary?: unknown\n detail?: unknown\n },\n): ClaudeActivityEvent {\n const normalized: ClaudeActivityEvent = {\n turn: activity.turn,\n step: activity.step,\n ordinal: activity.ordinal,\n kind: activity.kind,\n }\n if (activity.phase !== undefined) normalized.phase = activity.phase\n if (activity.taskId !== undefined) normalized.taskId = redactText(activity.taskId, 128)\n if (activity.toolUseId !== undefined) normalized.toolUseId = redactText(activity.toolUseId, 256)\n if (activity.parentToolUseId !== undefined) normalized.parentToolUseId = redactText(activity.parentToolUseId, 256)\n if (activity.toolName !== undefined) normalized.toolName = redactText(activity.toolName, 256)\n if (activity.title !== undefined) normalized.title = redactText(activity.title, MAX_SUMMARY_CHARS)\n if (activity.summary !== undefined) {\n normalized.summary = redactText(\n typeof activity.summary === 'string' ? activity.summary : safeDetail(activity.summary) ?? '',\n MAX_SUMMARY_CHARS,\n )\n }\n const detail = safeDetail(activity.detail)\n if (detail !== undefined) normalized.detail = detail\n if (activity.text !== undefined) normalized.text = redactText(activity.text, MAX_TRANSCRIPT_TEXT_CHARS)\n if (activity.isError !== undefined) normalized.isError = activity.isError\n if (activity.usage !== undefined) normalized.usage = { ...activity.usage }\n if (isClaudeRenderMode(activity.renderer)) normalized.renderer = activity.renderer\n return normalized\n}\n\nconst MAX_CONTEXT_CATEGORIES = 24\nconst FALLBACK_CONTEXT_COLOR = '#8b95a5'\nconst SAFE_CONTEXT_COLOR = /^#[0-9a-f]{3,8}$/iu\n\nfunction nonNegativeInteger(value: unknown): number {\n return typeof value === 'number' && Number.isFinite(value)\n ? Math.max(0, Math.floor(value))\n : 0\n}\n\nexport function normalizeContextUsage(input: ClaudeContextUsageInput): ClaudeContextUsageEvent {\n return {\n model: redactText(typeof input.model === 'string' ? input.model : 'unknown', 128),\n totalTokens: nonNegativeInteger(input.totalTokens),\n maxTokens: nonNegativeInteger(input.maxTokens),\n percentage: Math.min(100, nonNegativeInteger(input.percentage)),\n categories: input.categories.slice(0, MAX_CONTEXT_CATEGORIES).map(category => ({\n name: redactText(typeof category.name === 'string' ? category.name : 'Unknown', 128),\n tokens: nonNegativeInteger(category.tokens),\n color: typeof category.color === 'string' && SAFE_CONTEXT_COLOR.test(category.color)\n ? category.color\n : FALLBACK_CONTEXT_COLOR,\n ...(category.isDeferred === true ? { isDeferred: true } : {}),\n })),\n }\n}\n\nexport function latestClaudeContextUsage(\n events: readonly SessionEvent[],\n): ClaudeContextUsageEvent | undefined {\n for (let index = events.length - 1; index >= 0; index -= 1) {\n const event = events[index]\n if (event?.type === CLAUDE_CONTEXT_USAGE_EVENT) return event.data as ClaudeContextUsageEvent\n }\n return undefined\n}\n\nexport type ClaudeTaskStatus = 'running' | 'completed' | 'failed' | 'stopped' | 'killed'\n\nexport interface ClaudeTaskUsage {\n totalTokens?: number\n toolUses?: number\n durationMs?: number\n}\n\nexport interface ClaudeTaskInfo {\n taskId: string\n description: string\n status: ClaudeTaskStatus\n /** DSH turn during which this task was first observed, when known. */\n originTurn?: number\n subagentType?: string\n taskType?: string\n lastToolName?: string\n summary?: string\n usage?: ClaudeTaskUsage\n /** True while the task runs detached (background command/subagent). */\n backgrounded?: boolean\n}\n\n/** Level snapshot of one session's Claude task board, REPLACE semantics. */\nexport interface ClaudeTasksEvent {\n tasks: readonly ClaudeTaskInfo[]\n}\n\nconst MAX_TASKS_PER_SNAPSHOT = 50\nconst MAX_TASK_TEXT_CHARS = 300\n\nconst TASK_STATUSES: ReadonlySet<string> = new Set(['running', 'completed', 'failed', 'stopped', 'killed'])\n\nfunction normalizeTaskUsage(input: ClaudeTaskUsage | undefined): ClaudeTaskUsage | undefined {\n if (input === undefined) return undefined\n const usage: ClaudeTaskUsage = {}\n if (input.totalTokens !== undefined) usage.totalTokens = nonNegativeInteger(input.totalTokens)\n if (input.toolUses !== undefined) usage.toolUses = nonNegativeInteger(input.toolUses)\n if (input.durationMs !== undefined) usage.durationMs = nonNegativeInteger(input.durationMs)\n return Object.keys(usage).length === 0 ? undefined : usage\n}\n\nexport function normalizeTasksEvent(tasks: readonly ClaudeTaskInfo[]): ClaudeTasksEvent {\n return {\n tasks: tasks.slice(0, MAX_TASKS_PER_SNAPSHOT).map(task => {\n const usage = normalizeTaskUsage(task.usage)\n return {\n taskId: redactText(String(task.taskId), 128),\n description: redactText(String(task.description), MAX_TASK_TEXT_CHARS),\n status: TASK_STATUSES.has(task.status) ? task.status : 'running',\n ...(task.originTurn === undefined ? {} : { originTurn: nonNegativeInteger(task.originTurn) }),\n ...(task.subagentType === undefined ? {} : { subagentType: redactText(task.subagentType, 64) }),\n ...(task.taskType === undefined ? {} : { taskType: redactText(task.taskType, 64) }),\n ...(task.lastToolName === undefined ? {} : { lastToolName: redactText(task.lastToolName, 64) }),\n ...(task.summary === undefined ? {} : { summary: redactText(task.summary, MAX_TASK_TEXT_CHARS) }),\n ...(usage === undefined ? {} : { usage }),\n ...(task.backgrounded === true ? { backgrounded: true } : {}),\n }\n }),\n }\n}\n\nexport function latestClaudeTasks(\n events: readonly SessionEvent[],\n): ClaudeTasksEvent | undefined {\n for (let index = events.length - 1; index >= 0; index -= 1) {\n const event = events[index]\n if (event?.type === CLAUDE_TASKS_EVENT) return event.data as ClaudeTasksEvent\n }\n return undefined\n}\n\nexport type ClaudeActivityInput = Omit<\n ClaudeActivityEvent,\n 'turn' | 'step' | 'ordinal' | 'summary' | 'detail'\n> & {\n summary?: unknown\n detail?: unknown\n}\n\nexport interface ClaudeActivityCursor {\n turn: number\n step: number\n nextOrdinal: number\n}\n\n/** Derive the current DSH turn/step; activity ordinals are completed from the sidecar. */\nexport function currentClaudeActivityCursor(events: readonly SessionEvent[]): ClaudeActivityCursor {\n let turn = 0\n let step = 0\n for (const event of events) {\n if (event.type !== 'step/start') continue\n const data = event.data as { turn: number; step: number }\n turn = data.turn\n step = data.step\n }\n if (turn < 1 || step < 1) {\n throw new Error('dsh-claude: Claude activity requires an open DSH step')\n }\n return { turn, step, nextOrdinal: 0 }\n}\n\nexport function latestClaudeSessionBinding(\n events: readonly SessionEvent[],\n): ClaudeSessionBoundEvent | undefined {\n for (let index = events.length - 1; index >= 0; index -= 1) {\n const event = events[index]\n if (event?.type === CLAUDE_SESSION_BOUND_EVENT) {\n return event.data as ClaudeSessionBoundEvent\n }\n }\n return undefined\n}\n"],"mappings":";AAAA,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;AACrC,MAAa,2BAA2B,CAAC,oBAAoB;AAE7D,MAAa,wBAAwB;;;AAKrC,MAAa,kCAAuC,IAAI,IAAI,CAAC,QAAQ,OAAO,CAAC;AAC7E,MAAa,cAAc;AAC3B,MAAa,qBAAqB;AAClC,MAAa,iCAAiC;AAC9C,MAAa,2BAA2B;AACxC,MAAa,oBAAoB;AACjC,MAAa,qBAAqB;AAClC,MAAa,yBAAyB;AACtC,MAAa,8BAA8B;AAC3C,MAAa,+BAA+B;AAC5C,MAAa,gCAAgC;AAC7C,MAAa,6BAA6B;AAC1C,MAAa,kCAAkC;AAC/C,MAAa,gCAAgC;AAC7C,MAAa,8BAA8B;AAC3C,MAAa,mBAAmB;AAChC,MAAa,kBAAkB;AAC/B,MAAa,0BAA0B;AACvC,MAAa,qBAAqB;AAWlC,MAAa,sBAAsB,CAAC,UAAU,QAAQ;AACtD,MAAa,6BAA+C;AAE5D,SAAgB,mBAAmB,OAA2C;CAC5E,OAAO,UAAU,YAAY,UAAU;AACzC;AAeA,MAAa,qBAAqB,CAAC,SAAS,UAAU;AACtD,MAAa,4BAA6C;AAE1D,SAAgB,kBAAkB,OAA0C;CAC1E,OAAO,UAAU,WAAW,UAAU;AACxC;;;ACqDA,MAAM,aAAa;AACnB,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,4BAA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