@astralyn/pi 0.84.7 → 0.84.8
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 +19 -0
- package/dist/core/compaction/compaction.d.ts +2 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +7 -7
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/extensions/background/index.d.ts.map +1 -1
- package/dist/extensions/background/index.js +48 -72
- package/dist/extensions/background/index.js.map +1 -1
- package/dist/extensions/background/manager.d.ts.map +1 -1
- package/dist/extensions/background/manager.js +5 -3
- package/dist/extensions/background/manager.js.map +1 -1
- package/dist/extensions/background/registry.d.ts +11 -13
- package/dist/extensions/background/registry.d.ts.map +1 -1
- package/dist/extensions/background/registry.js +71 -80
- package/dist/extensions/background/registry.js.map +1 -1
- package/dist/extensions/background/render.d.ts.map +1 -1
- package/dist/extensions/background/render.js +8 -3
- package/dist/extensions/background/render.js.map +1 -1
- package/dist/extensions/deepwiki/constants.d.ts +2 -2
- package/dist/extensions/deepwiki/constants.d.ts.map +1 -1
- package/dist/extensions/deepwiki/constants.js +5 -5
- package/dist/extensions/deepwiki/constants.js.map +1 -1
- package/dist/extensions/deepwiki/schema.js +1 -1
- package/dist/extensions/deepwiki/schema.js.map +1 -1
- package/dist/extensions/question/constants.d.ts +2 -2
- package/dist/extensions/question/constants.d.ts.map +1 -1
- package/dist/extensions/question/constants.js +5 -2
- package/dist/extensions/question/constants.js.map +1 -1
- package/dist/extensions/subagent/activity.d.ts +9 -0
- package/dist/extensions/subagent/activity.d.ts.map +1 -1
- package/dist/extensions/subagent/activity.js +21 -0
- package/dist/extensions/subagent/activity.js.map +1 -1
- package/dist/extensions/subagent/agents.d.ts.map +1 -1
- package/dist/extensions/subagent/agents.js +7 -3
- package/dist/extensions/subagent/agents.js.map +1 -1
- package/dist/extensions/subagent/constants.d.ts +1 -0
- package/dist/extensions/subagent/constants.d.ts.map +1 -1
- package/dist/extensions/subagent/constants.js +4 -0
- package/dist/extensions/subagent/constants.js.map +1 -1
- package/dist/extensions/subagent/index.js +2 -2
- package/dist/extensions/subagent/index.js.map +1 -1
- package/dist/extensions/subagent/render.d.ts.map +1 -1
- package/dist/extensions/subagent/render.js +1 -7
- package/dist/extensions/subagent/render.js.map +1 -1
- package/dist/extensions/subagent/sdk-runner.d.ts.map +1 -1
- package/dist/extensions/subagent/sdk-runner.js +19 -0
- package/dist/extensions/subagent/sdk-runner.js.map +1 -1
- package/dist/extensions/subagent/state.d.ts +9 -0
- package/dist/extensions/subagent/state.d.ts.map +1 -1
- package/dist/extensions/subagent/state.js +33 -2
- package/dist/extensions/subagent/state.js.map +1 -1
- package/dist/extensions/todo/constants.d.ts +1 -1
- package/dist/extensions/todo/constants.d.ts.map +1 -1
- package/dist/extensions/todo/constants.js +10 -27
- package/dist/extensions/todo/constants.js.map +1 -1
- package/dist/extensions/todo/state.d.ts.map +1 -1
- package/dist/extensions/todo/state.js +27 -16
- package/dist/extensions/todo/state.js.map +1 -1
- package/dist/extensions/todo/view.d.ts.map +1 -1
- package/dist/extensions/todo/view.js +16 -5
- package/dist/extensions/todo/view.js.map +1 -1
- package/docs/bundled/extensions/background.md +3 -3
- package/docs/bundled/extensions/todo.md +2 -2
- package/docs/compaction.md +2 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/extensions/background/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAkB,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQxF,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAc,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EACN,kBAAkB,EAClB,cAAc,EACd,cAAc,EAEd,gBAAgB,EAChB,cAAc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CACP,SAAS,EACT,6GAA6G,CAC7G,EACD,CAAC,EACD,CAAC,CACD,CACD,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Transcript rendering for the background extension: the single bg tool's\n * call/result rows (dispatched on action) and the completion-notification\n * message. Style follows the built-in bash presentation: a `$` prompt row\n * with an `&` marker for the background call.\n */\n\nimport { type Component, Container, Text, TruncatedText } from \"@earendil-works/pi-tui\";\nimport type {\n\tAgentToolResult,\n\tMessageRenderOptions,\n\tToolRenderContext,\n\tToolRenderResultOptions,\n} from \"../../core/extensions/types.ts\";\nimport type { CustomMessage } from \"../../core/messages.ts\";\nimport { formatSize } from \"../../core/tools/truncate.ts\";\nimport { highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { BgCreateInput, BgDetails, BgInput, BgNotificationDetails } from \"./index.ts\";\nimport {\n\tBG_WAIT_DEFAULT_MS,\n\tBG_WAIT_MAX_MS,\n\tBG_WAIT_MIN_MS,\n\ttype BgTaskStatus,\n\tfirstCommandLine,\n\tformatDuration,\n} from \"./registry.ts\";\n\nconst COMMAND_PREVIEW_LIMIT = 120;\nconst NOTIFY_TAIL_LIMIT = 4000;\n/** Cap for expanded transcript views of tool-result text (already bounded at the source). */\nconst RESULT_EXPAND_LIMIT = 4000;\n/** Live pending-wait line refresh cadence; the first settled render clears the timer. */\nconst WAIT_REFRESH_MS = 1000;\n\n/** Live peek at a waited-on task, fed from the registry by the call renderer. */\nexport interface BgTaskLive {\n\tstatus: BgTaskStatus;\n\toutputBytes: number;\n}\n\nexport type WaitLiveProbe = (taskId: string) => BgTaskLive | undefined;\n\n/** Per-call live-refresh state owned by the shell's render context. */\nexport interface BgRenderState {\n\trefreshTimer?: ReturnType<typeof setTimeout>;\n\t/** First pending render of a wait call; anchors the elapsed display. */\n\twaitStartedAt?: number;\n\t/** outputBytes snapshot at wait start; anchors the \"+new output\" display. */\n\twaitBaselineBytes?: number;\n}\n\n/**\n * Arm a one-shot 1s refresh while a wait call is pending, clear it once\n * settled. The timer fires → context.invalidate() → renderCall re-runs →\n * re-arms, so at most one armed timer exists per tool row. Unref'd: it can\n * never hold the process open.\n */\nexport function scheduleWaitRefresh(context: ToolRenderContext<BgRenderState>, pending: boolean): void {\n\tconst state = context.state;\n\tif (state === undefined) return; // Standalone render without shell state: nothing to schedule.\n\tif (pending) {\n\t\tif (state.refreshTimer === undefined) {\n\t\t\tstate.refreshTimer = setTimeout(() => {\n\t\t\t\tstate.refreshTimer = undefined;\n\t\t\t\tcontext.invalidate();\n\t\t\t}, WAIT_REFRESH_MS);\n\t\t\tstate.refreshTimer.unref?.();\n\t\t}\n\t\treturn;\n\t}\n\tif (state.refreshTimer !== undefined) {\n\t\tclearTimeout(state.refreshTimer);\n\t\tstate.refreshTimer = undefined;\n\t}\n\tstate.waitStartedAt = undefined;\n\tstate.waitBaselineBytes = undefined;\n}\n\n/** Basename of a path, slash-normalized — compact display of output files. */\nexport function fileNameOf(path: string): string {\n\treturn path.replace(/\\\\/g, \"/\").split(\"/\").at(-1) ?? path;\n}\n\nfunction bgPrompt(theme: Theme): string {\n\treturn theme.fg(\"toolTitle\", theme.bold(\"$ \"));\n}\n\nfunction timeoutSuffix(timeout: number | undefined, theme: Theme): string {\n\treturn timeout ? theme.fg(\"muted\", ` (timeout ${timeout}s)`) : \"\";\n}\n\n/** Keep the END of oversized text — that is where the outcome lives. */\nfunction capForTranscript(text: string, limit: number): string {\n\treturn text.length > limit ? `…${text.slice(-limit)}` : text;\n}\n\nexport function statusGlyph(status: BgTaskStatus, stalled?: boolean): string {\n\tif (stalled) return \"…\";\n\tswitch (status) {\n\t\tcase \"completed\":\n\t\t\treturn \"✓\";\n\t\tcase \"failed\":\n\t\tcase \"timeout\":\n\t\t\treturn \"✗\";\n\t\tcase \"killed\":\n\t\t\treturn \"○\";\n\t\tdefault:\n\t\t\treturn \"●\";\n\t}\n}\n\nexport function statusColor(status: BgTaskStatus, stalled?: boolean): \"success\" | \"error\" | \"warning\" | \"accent\" {\n\tif (stalled) return \"warning\";\n\tswitch (status) {\n\t\tcase \"completed\":\n\t\t\treturn \"success\";\n\t\tcase \"failed\":\n\t\t\treturn \"error\";\n\t\tcase \"timeout\":\n\t\tcase \"killed\":\n\t\t\treturn \"warning\";\n\t\tdefault:\n\t\t\treturn \"accent\";\n\t}\n}\n\n/** First command line truncated to a visible-character budget with an ellipsis. */\nexport function commandLabel(command: string, width: number): string {\n\tconst characters = [...firstCommandLine(command)];\n\treturn characters.length <= width ? characters.join(\"\") : `${characters.slice(0, Math.max(0, width - 1)).join(\"\")}…`;\n}\n\n// ── tool call ─────────────────────────────────────────────────────────────\n\nexport function renderBgCall(\n\targs: BgInput,\n\ttheme: Theme,\n\tcontext: ToolRenderContext<BgRenderState>,\n\tgetTaskLive?: WaitLiveProbe,\n): Component {\n\tswitch (args.action) {\n\t\tcase \"create\":\n\t\t\treturn typeof args.command === \"string\"\n\t\t\t\t? renderCreateCall(args as BgCreateInput, theme, context)\n\t\t\t\t: new Text(theme.fg(\"toolTitle\", theme.bold(\"bg create\")), 0, 0);\n\t\tcase \"read\": {\n\t\t\tconst mode = args.mode ?? \"tail\";\n\t\t\tconst size = args.bytes !== undefined ? ` ${formatSize(args.bytes)}` : \"\";\n\t\t\treturn new Text(\n\t\t\t\t`${theme.fg(\"toolTitle\", theme.bold(\"bg read \"))}${theme.fg(\"accent\", args.taskId ?? \"\")}${theme.fg(\"muted\", ` ${mode}${size}`)}`,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t);\n\t\t}\n\t\tcase \"wait\":\n\t\t\treturn renderWaitCall(args, theme, context, getTaskLive);\n\t\tcase \"kill\":\n\t\t\treturn new Text(\n\t\t\t\t`${theme.fg(\"toolTitle\", theme.bold(\"bg kill \"))}${theme.fg(\"accent\", args.taskId ?? \"\")}`,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t);\n\t\tcase \"list\":\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(\"bg list\")), 0, 0);\n\t\tdefault: {\n\t\t\t// Tool arguments arrive incrementally while the model is still emitting\n\t\t\t// JSON. Keep the call row renderable until `action` becomes valid.\n\t\t\tconst action = typeof args.action === \"string\" ? ` ${theme.fg(\"dim\", args.action)}` : \"\";\n\t\t\treturn new Text(`${theme.fg(\"toolTitle\", theme.bold(\"bg\"))}${action}`, 0, 0);\n\t\t}\n\t}\n}\n\n/** Mirror the execution-side clamp so the shown window matches the real one. */\nexport function clampWaitMs(waitMs: number | undefined): number {\n\treturn Math.min(BG_WAIT_MAX_MS, Math.max(BG_WAIT_MIN_MS, Math.floor(waitMs ?? BG_WAIT_DEFAULT_MS)));\n}\n\n/**\n * Pending wait call: elapsed/wait-window and the new-output delta since the\n * wait began, refreshed once per second by scheduleWaitRefresh until the\n * result settles and takes over the row.\n */\nfunction renderWaitCall(\n\targs: BgInput,\n\ttheme: Theme,\n\tcontext: ToolRenderContext<BgRenderState>,\n\tgetTaskLive: WaitLiveProbe | undefined,\n): Component {\n\tconst taskId = typeof args.taskId === \"string\" ? args.taskId.trim() : \"\";\n\tconst live = getTaskLive !== undefined && taskId ? getTaskLive(taskId) : undefined;\n\t// The live display needs shell-owned state; without it (standalone renders)\n\t// fall back to the static line.\n\tconst pending = context.isPartial === true && context.state !== undefined && taskId.length > 0;\n\tscheduleWaitRefresh(context, pending);\n\tif (!pending) {\n\t\tconst ms = args.waitMs !== undefined ? ` ${formatDuration(clampWaitMs(args.waitMs))}` : \"\";\n\t\treturn new Text(\n\t\t\t`${theme.fg(\"toolTitle\", theme.bold(\"bg wait \"))}${theme.fg(\"accent\", args.taskId ?? \"\")}${theme.fg(\"muted\", ms)}`,\n\t\t\t0,\n\t\t\t0,\n\t\t);\n\t}\n\tconst state = context.state;\n\tif (state.waitStartedAt === undefined) state.waitStartedAt = Date.now();\n\tconst startedAt = state.waitStartedAt;\n\tlet liveBase: number | undefined;\n\tif (live) {\n\t\tif (state.waitBaselineBytes === undefined) state.waitBaselineBytes = live.outputBytes;\n\t\tliveBase = state.waitBaselineBytes;\n\t}\n\tconst parts = [`waiting ${formatDuration(Date.now() - startedAt)}/${formatDuration(clampWaitMs(args.waitMs))}`];\n\tif (live && live.status === \"running\" && liveBase !== undefined && live.outputBytes > liveBase) {\n\t\tparts.push(`+${formatSize(live.outputBytes - liveBase)} new output`);\n\t}\n\treturn new Text(\n\t\t`${theme.fg(\"toolTitle\", theme.bold(\"bg wait \"))}${theme.fg(\"accent\", taskId)} ${theme.fg(\"muted\", parts.join(\" · \"))}`,\n\t\t0,\n\t\t0,\n\t);\n}\n\nfunction renderCreateCall(args: BgCreateInput, theme: Theme, context: ToolRenderContext): Component {\n\tconst lines = args.command.split(/\\r?\\n/).filter((line) => line.trim().length > 0);\n\tconst label = args.description ? theme.fg(\"muted\", ` · ${args.description}`) : \"\";\n\tconst suffix = theme.fg(\"muted\", \" &\") + timeoutSuffix(args.timeout, theme) + label;\n\tif (context.expanded && lines.length > 1) {\n\t\tconst body = highlightCode(args.command, \"bash\").join(\"\\n\");\n\t\treturn new Text(`${bgPrompt(theme)}${body}${suffix}`, 0, 0);\n\t}\n\tconst body = highlightCode(firstCommandLine(args.command), \"bash\").join(\"\\n\");\n\tif (lines.length > 1) {\n\t\tconst hidden = lines.length - 1;\n\t\tconst more = theme.fg(\"muted\", ` (+${hidden} line${hidden === 1 ? \"\" : \"s\"})`);\n\t\treturn new Text(`${bgPrompt(theme)}${body}${suffix}${more}`, 0, 0);\n\t}\n\treturn new Text(`${bgPrompt(theme)}${body}${suffix}`, 0, 0);\n}\n\n// ── tool result ───────────────────────────────────────────────────────────\n\nexport function renderBgResult(\n\tresult: AgentToolResult<BgDetails | undefined>,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcontext: ToolRenderContext<BgRenderState>,\n): Component {\n\t// bg results are always settled today; clear defensively so no live-refresh\n\t// timer can outlive its row if a host ever streams partial results.\n\tif (context.args?.action === \"wait\" && !options.isPartial) scheduleWaitRefresh(context, false);\n\tconst details = result.details;\n\tif (context.isError || !details) {\n\t\tconst text = result.content.find((part) => part.type === \"text\")?.text ?? \"\";\n\t\treturn new Text(theme.fg(\"toolOutput\", text.trimEnd()), 0, 0);\n\t}\n\n\tconst container = new Container();\n\tcontainer.addChild(new TruncatedText(resultSummaryLine(details, theme), 1, 0));\n\tif (options.expanded) {\n\t\tconst text = result.content.find((part) => part.type === \"text\")?.text ?? \"\";\n\t\tcontainer.addChild(new Text(\"\", 0, 0));\n\t\tcontainer.addChild(new Text(theme.fg(\"toolOutput\", capForTranscript(text, RESULT_EXPAND_LIMIT).trimEnd()), 1, 0));\n\t}\n\treturn container;\n}\n\nfunction resultSummaryLine(details: BgDetails, theme: Theme): string {\n\tswitch (details.action) {\n\t\tcase \"create\": {\n\t\t\tconst label = details.description ? ` (${details.description})` : \"\";\n\t\t\treturn `${theme.fg(\"muted\", \"→ task \")}${theme.fg(\"accent\", `${details.taskId}${label}`)}${theme.fg(\"muted\", ` started · ${details.outputPath}`)}`;\n\t\t}\n\t\tcase \"read\": {\n\t\t\tconst size =\n\t\t\t\tdetails.sliceBytes !== details.totalBytes\n\t\t\t\t\t? `${details.mode} ${formatSize(details.sliceBytes)} of ${formatSize(details.totalBytes)}`\n\t\t\t\t\t: formatSize(details.totalBytes);\n\t\t\treturn `${theme.fg(\"muted\", \"→ \")}${theme.fg(\"accent\", details.taskId)}${theme.fg(\"muted\", ` ${size} · ${details.outputPath}`)}`;\n\t\t}\n\t\tcase \"wait\": {\n\t\t\tif (details.timedOut) {\n\t\t\t\treturn `${theme.fg(statusColor(details.status), statusGlyph(details.status))} ${theme.fg(\"accent\", details.taskId)}${theme.fg(\"muted\", ` still running · waited ${formatDuration(details.waitedMs)} · ${formatSize(details.totalBytes)}`)}`;\n\t\t\t}\n\t\t\tconst exit = details.exitCode !== undefined && details.exitCode !== null ? `, exit ${details.exitCode}` : \"\";\n\t\t\treturn `${theme.fg(statusColor(details.status), statusGlyph(details.status))} ${theme.fg(\"accent\", details.taskId)}${theme.fg(\"muted\", ` ${details.status}${exit} · waited ${formatDuration(details.waitedMs)} · +${formatSize(details.deltaBytes)}`)}`;\n\t\t}\n\t\tcase \"kill\":\n\t\t\treturn `${theme.fg(statusColor(\"killed\"), statusGlyph(\"killed\"))} ${theme.fg(\"accent\", details.taskId)}${theme.fg(\"muted\", \" stopped\")}`;\n\t\tcase \"list\": {\n\t\t\tconst hidden = details.hidden > 0 ? ` · ${details.hidden} more finished` : \"\";\n\t\t\treturn theme.fg(\"muted\", `${details.running} running · ${details.finished} finished${hidden}`);\n\t\t}\n\t}\n}\n\n// ── completion notification ───────────────────────────────────────────────\n\n/** One-line summary of a finished task, shared by the notification renderer. */\nfunction taskSummaryLine(details: BgNotificationDetails, theme: Theme): string {\n\tconst runtime = formatDuration(details.runtimeMs);\n\tconst exit = details.exitCode !== undefined && details.exitCode !== null ? `, exit ${details.exitCode}` : \"\";\n\tif (details.stalled) {\n\t\tconst glyph = theme.fg(\"warning\", \"…\");\n\t\tconst label = details.description\n\t\t\t? `${details.description} (${commandLabel(details.command, 40)})`\n\t\t\t: commandLabel(details.command, COMMAND_PREVIEW_LIMIT);\n\t\treturn `${glyph} ${theme.fg(\"accent\", details.taskId)} ${label} ${theme.fg(\"muted\", `— waiting for input (${runtime})`)}`;\n\t}\n\tconst outcome = theme.fg(statusColor(details.status), `${details.status}${exit} in ${runtime}`);\n\tconst glyph = theme.fg(statusColor(details.status), statusGlyph(details.status));\n\tconst label = details.description\n\t\t? `${details.description} (${commandLabel(details.command, 40)})`\n\t\t: commandLabel(details.command, COMMAND_PREVIEW_LIMIT);\n\treturn `${glyph} ${theme.fg(\"accent\", details.taskId)} ${label} ${theme.fg(\"muted\", `— ${outcome}`)}`;\n}\n\n/**\n * Collapsed: status glyph, task id, label, and outcome on one line, output\n * path below. Expanded adds the embedded output tail. Returns undefined for\n * malformed details so the default custom-message rendering takes over.\n */\nexport function renderBackgroundNotification(\n\tmessage: CustomMessage<BgNotificationDetails>,\n\toptions: MessageRenderOptions,\n\ttheme: Theme,\n): Component | undefined {\n\tconst details = message.details;\n\tif (!details || typeof details.taskId !== \"string\") return undefined;\n\n\tconst container = new Container();\n\tcontainer.addChild(new TruncatedText(taskSummaryLine(details, theme), 1, 0));\n\t// Collapsed keeps the row compact with the file name; the full path\n\t// (model-relevant, human-rarely) shows when expanded.\n\tconst shownPath = options.expanded ? details.outputPath : fileNameOf(details.outputPath);\n\tcontainer.addChild(new Text(theme.fg(\"muted\", shownPath), 1, 0));\n\n\tif (details.tailError) {\n\t\tcontainer.addChild(new Text(theme.fg(\"error\", `Output unavailable: ${details.tailError}`), 1, 0));\n\t} else if (options.expanded && details.tailText) {\n\t\tcontainer.addChild(new Text(\"\", 0, 0));\n\t\tconst tail = capForTranscript(details.tailText, NOTIFY_TAIL_LIMIT);\n\t\tconst truncatedNote = details.tailTruncated\n\t\t\t? `\\n[showing tail of ${formatSize(details.totalBytes)} bytes; full output: ${details.outputPath}]`\n\t\t\t: \"\";\n\t\tcontainer.addChild(\n\t\t\tnew Text(`${theme.fg(\"toolOutput\", tail.trimEnd())}${theme.fg(\"muted\", truncatedNote)}`, 1, 0),\n\t\t);\n\t}\n\tif (details.stalled && options.expanded) {\n\t\tcontainer.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"warning\",\n\t\t\t\t\t\"Blocked on interactive input — kill (bg action kill) and re-run with piped input or a non-interactive flag.\",\n\t\t\t\t),\n\t\t\t\t1,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t}\n\treturn container;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/extensions/background/render.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAkB,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQxF,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,aAAa,EA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,CAAC,CAAC,CAC9F,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzC,SAAS,CAAC,QAAQ,CACjB,IAAI,IAAI,CACP,KAAK,CAAC,EAAE,CACP,SAAS,EACT,6GAA6G,CAC7G,EACD,CAAC,EACD,CAAC,CACD,CACD,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Transcript rendering for the background extension: the single bg tool's\n * call/result rows (dispatched on action) and the completion-notification\n * message. Style follows the built-in bash presentation: a `$` prompt row\n * with an `&` marker for the background call.\n */\n\nimport { type Component, Container, Text, TruncatedText } from \"@earendil-works/pi-tui\";\nimport type {\n\tAgentToolResult,\n\tMessageRenderOptions,\n\tToolRenderContext,\n\tToolRenderResultOptions,\n} from \"../../core/extensions/types.ts\";\nimport type { CustomMessage } from \"../../core/messages.ts\";\nimport { formatSize } from \"../../core/tools/truncate.ts\";\nimport { highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport type { BgCreateInput, BgDetails, BgInput, BgNotificationDetails } from \"./index.ts\";\nimport {\n\tBG_WAIT_DEFAULT_MS,\n\tBG_WAIT_MAX_MS,\n\tBG_WAIT_MIN_MS,\n\ttype BgTaskStatus,\n\tfirstCommandLine,\n\tformatDuration,\n} from \"./registry.ts\";\n\nconst COMMAND_PREVIEW_LIMIT = 120;\nconst NOTIFY_TAIL_LIMIT = 4000;\n/** Cap for expanded transcript views of tool-result text (already bounded at the source). */\nconst RESULT_EXPAND_LIMIT = 4000;\n/** Live pending-wait line refresh cadence; the first settled render clears the timer. */\nconst WAIT_REFRESH_MS = 1000;\n\n/** Live peek at a waited-on task, fed from the registry by the call renderer. */\nexport interface BgTaskLive {\n\tstatus: BgTaskStatus;\n\toutputBytes: number;\n}\n\nexport type WaitLiveProbe = (taskId: string) => BgTaskLive | undefined;\n\n/** Per-call live-refresh state owned by the shell's render context. */\nexport interface BgRenderState {\n\trefreshTimer?: ReturnType<typeof setTimeout>;\n\t/** First pending render of a wait call; anchors the elapsed display. */\n\twaitStartedAt?: number;\n\t/** outputBytes snapshot at wait start; anchors the \"+new output\" display. */\n\twaitBaselineBytes?: number;\n}\n\n/**\n * Arm a one-shot 1s refresh while a wait call is pending, clear it once\n * settled. The timer fires → context.invalidate() → renderCall re-runs →\n * re-arms, so at most one armed timer exists per tool row. Unref'd: it can\n * never hold the process open.\n */\nexport function scheduleWaitRefresh(context: ToolRenderContext<BgRenderState>, pending: boolean): void {\n\tconst state = context.state;\n\tif (state === undefined) return; // Standalone render without shell state: nothing to schedule.\n\tif (pending) {\n\t\tif (state.refreshTimer === undefined) {\n\t\t\tstate.refreshTimer = setTimeout(() => {\n\t\t\t\tstate.refreshTimer = undefined;\n\t\t\t\tcontext.invalidate();\n\t\t\t}, WAIT_REFRESH_MS);\n\t\t\tstate.refreshTimer.unref?.();\n\t\t}\n\t\treturn;\n\t}\n\tif (state.refreshTimer !== undefined) {\n\t\tclearTimeout(state.refreshTimer);\n\t\tstate.refreshTimer = undefined;\n\t}\n\tstate.waitStartedAt = undefined;\n\tstate.waitBaselineBytes = undefined;\n}\n\n/** Basename of a path, slash-normalized — compact display of output files. */\nexport function fileNameOf(path: string): string {\n\treturn path.replace(/\\\\/g, \"/\").split(\"/\").at(-1) ?? path;\n}\n\nfunction bgPrompt(theme: Theme): string {\n\treturn theme.fg(\"toolTitle\", theme.bold(\"$ \"));\n}\n\nfunction timeoutSuffix(timeout: number | undefined, theme: Theme): string {\n\treturn timeout ? theme.fg(\"muted\", ` (timeout ${timeout}s)`) : \"\";\n}\n\n/** Keep the END of oversized text — that is where the outcome lives. */\nfunction capForTranscript(text: string, limit: number): string {\n\treturn text.length > limit ? `…${text.slice(-limit)}` : text;\n}\n\nexport function statusGlyph(status: BgTaskStatus, stalled?: boolean): string {\n\tif (stalled) return \"…\";\n\tswitch (status) {\n\t\tcase \"completed\":\n\t\t\treturn \"✓\";\n\t\tcase \"failed\":\n\t\tcase \"timeout\":\n\t\t\treturn \"✗\";\n\t\tcase \"killed\":\n\t\t\treturn \"○\";\n\t\tdefault:\n\t\t\treturn \"●\";\n\t}\n}\n\nexport function statusColor(status: BgTaskStatus, stalled?: boolean): \"success\" | \"error\" | \"warning\" | \"accent\" {\n\tif (stalled) return \"warning\";\n\tswitch (status) {\n\t\tcase \"completed\":\n\t\t\treturn \"success\";\n\t\tcase \"failed\":\n\t\t\treturn \"error\";\n\t\tcase \"timeout\":\n\t\tcase \"killed\":\n\t\t\treturn \"warning\";\n\t\tdefault:\n\t\t\treturn \"accent\";\n\t}\n}\n\n/** First command line truncated to a visible-character budget with an ellipsis. */\nexport function commandLabel(command: string, width: number): string {\n\tconst characters = [...firstCommandLine(command)];\n\treturn characters.length <= width ? characters.join(\"\") : `${characters.slice(0, Math.max(0, width - 1)).join(\"\")}…`;\n}\n\n// ── tool call ─────────────────────────────────────────────────────────────\n\nexport function renderBgCall(\n\targs: BgInput,\n\ttheme: Theme,\n\tcontext: ToolRenderContext<BgRenderState>,\n\tgetTaskLive?: WaitLiveProbe,\n): Component {\n\tswitch (args.action) {\n\t\tcase \"create\":\n\t\t\treturn typeof args.command === \"string\"\n\t\t\t\t? renderCreateCall(args as BgCreateInput, theme, context)\n\t\t\t\t: new Text(theme.fg(\"toolTitle\", theme.bold(\"bg create\")), 0, 0);\n\t\tcase \"read\": {\n\t\t\tconst mode = args.mode ?? \"tail\";\n\t\t\tconst size = args.bytes !== undefined ? ` ${formatSize(args.bytes)}` : \"\";\n\t\t\treturn new Text(\n\t\t\t\t`${theme.fg(\"toolTitle\", theme.bold(\"bg read \"))}${theme.fg(\"accent\", args.taskId ?? \"\")}${theme.fg(\"muted\", ` ${mode}${size}`)}`,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t);\n\t\t}\n\t\tcase \"wait\":\n\t\t\treturn renderWaitCall(args, theme, context, getTaskLive);\n\t\tcase \"kill\":\n\t\t\treturn new Text(\n\t\t\t\t`${theme.fg(\"toolTitle\", theme.bold(\"bg kill \"))}${theme.fg(\"accent\", args.taskId ?? \"\")}`,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t);\n\t\tcase \"list\":\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(\"bg list\")), 0, 0);\n\t\tdefault: {\n\t\t\t// Tool arguments arrive incrementally while the model is still emitting\n\t\t\t// JSON. Keep the call row renderable until `action` becomes valid.\n\t\t\tconst action = typeof args.action === \"string\" ? ` ${theme.fg(\"dim\", args.action)}` : \"\";\n\t\t\treturn new Text(`${theme.fg(\"toolTitle\", theme.bold(\"bg\"))}${action}`, 0, 0);\n\t\t}\n\t}\n}\n\n/** Mirror the execution-side clamp so the shown window matches the real one. */\nexport function clampWaitMs(waitMs: number | undefined): number {\n\treturn Math.min(BG_WAIT_MAX_MS, Math.max(BG_WAIT_MIN_MS, Math.floor(waitMs ?? BG_WAIT_DEFAULT_MS)));\n}\n\n/**\n * Pending wait call: elapsed/wait-window and the new-output delta since the\n * wait began, refreshed once per second by scheduleWaitRefresh until the\n * result settles and takes over the row.\n */\nfunction renderWaitCall(\n\targs: BgInput,\n\ttheme: Theme,\n\tcontext: ToolRenderContext<BgRenderState>,\n\tgetTaskLive: WaitLiveProbe | undefined,\n): Component {\n\tconst taskId = typeof args.taskId === \"string\" ? args.taskId.trim() : \"\";\n\tconst live = getTaskLive !== undefined && taskId ? getTaskLive(taskId) : undefined;\n\t// isPartial alone means \"not settled\", which also covers argument streaming\n\t// and replayed history rows that never settle; executionStarted narrows it to\n\t// a call that is actually running. The live display also needs shell-owned\n\t// state; without it (standalone renders) fall back to the static line.\n\tconst pending =\n\t\tcontext.executionStarted === true &&\n\t\tcontext.isPartial === true &&\n\t\tcontext.state !== undefined &&\n\t\ttaskId.length > 0;\n\tscheduleWaitRefresh(context, pending);\n\tif (!pending) {\n\t\tconst ms = args.waitMs !== undefined ? ` ${formatDuration(clampWaitMs(args.waitMs))}` : \"\";\n\t\treturn new Text(\n\t\t\t`${theme.fg(\"toolTitle\", theme.bold(\"bg wait \"))}${theme.fg(\"accent\", args.taskId ?? \"\")}${theme.fg(\"muted\", ms)}`,\n\t\t\t0,\n\t\t\t0,\n\t\t);\n\t}\n\tconst state = context.state;\n\tif (state.waitStartedAt === undefined) state.waitStartedAt = Date.now();\n\tconst startedAt = state.waitStartedAt;\n\tlet liveBase: number | undefined;\n\tif (live) {\n\t\tif (state.waitBaselineBytes === undefined) state.waitBaselineBytes = live.outputBytes;\n\t\tliveBase = state.waitBaselineBytes;\n\t}\n\tconst parts = [`waiting ${formatDuration(Date.now() - startedAt)}/${formatDuration(clampWaitMs(args.waitMs))}`];\n\tif (live && live.status === \"running\" && liveBase !== undefined && live.outputBytes > liveBase) {\n\t\tparts.push(`+${formatSize(live.outputBytes - liveBase)} new output`);\n\t}\n\treturn new Text(\n\t\t`${theme.fg(\"toolTitle\", theme.bold(\"bg wait \"))}${theme.fg(\"accent\", taskId)} ${theme.fg(\"muted\", parts.join(\" · \"))}`,\n\t\t0,\n\t\t0,\n\t);\n}\n\nfunction renderCreateCall(args: BgCreateInput, theme: Theme, context: ToolRenderContext): Component {\n\tconst lines = args.command.split(/\\r?\\n/).filter((line) => line.trim().length > 0);\n\tconst label = args.description ? theme.fg(\"muted\", ` · ${args.description}`) : \"\";\n\tconst suffix = theme.fg(\"muted\", \" &\") + timeoutSuffix(args.timeout, theme) + label;\n\tif (context.expanded && lines.length > 1) {\n\t\tconst body = highlightCode(args.command, \"bash\").join(\"\\n\");\n\t\treturn new Text(`${bgPrompt(theme)}${body}${suffix}`, 0, 0);\n\t}\n\tconst body = highlightCode(firstCommandLine(args.command), \"bash\").join(\"\\n\");\n\tif (lines.length > 1) {\n\t\tconst hidden = lines.length - 1;\n\t\tconst more = theme.fg(\"muted\", ` (+${hidden} line${hidden === 1 ? \"\" : \"s\"})`);\n\t\treturn new Text(`${bgPrompt(theme)}${body}${suffix}${more}`, 0, 0);\n\t}\n\treturn new Text(`${bgPrompt(theme)}${body}${suffix}`, 0, 0);\n}\n\n// ── tool result ───────────────────────────────────────────────────────────\n\nexport function renderBgResult(\n\tresult: AgentToolResult<BgDetails | undefined>,\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tcontext: ToolRenderContext<BgRenderState>,\n): Component {\n\t// bg results are always settled today; clear defensively so no live-refresh\n\t// timer can outlive its row if a host ever streams partial results.\n\tif (context.args?.action === \"wait\" && !options.isPartial) scheduleWaitRefresh(context, false);\n\tconst details = result.details;\n\tif (context.isError || !details) {\n\t\tconst text = result.content.find((part) => part.type === \"text\")?.text ?? \"\";\n\t\treturn new Text(theme.fg(\"toolOutput\", text.trimEnd()), 0, 0);\n\t}\n\n\tconst container = new Container();\n\tcontainer.addChild(new TruncatedText(resultSummaryLine(details, theme), 1, 0));\n\tif (options.expanded) {\n\t\tconst text = result.content.find((part) => part.type === \"text\")?.text ?? \"\";\n\t\tcontainer.addChild(new Text(\"\", 0, 0));\n\t\tcontainer.addChild(new Text(theme.fg(\"toolOutput\", capForTranscript(text, RESULT_EXPAND_LIMIT).trimEnd()), 1, 0));\n\t}\n\treturn container;\n}\n\nfunction resultSummaryLine(details: BgDetails, theme: Theme): string {\n\tswitch (details.action) {\n\t\tcase \"create\": {\n\t\t\tconst label = details.description ? ` (${details.description})` : \"\";\n\t\t\treturn `${theme.fg(\"muted\", \"→ task \")}${theme.fg(\"accent\", `${details.taskId}${label}`)}${theme.fg(\"muted\", ` started · ${details.outputPath}`)}`;\n\t\t}\n\t\tcase \"read\": {\n\t\t\tconst size =\n\t\t\t\tdetails.sliceBytes !== details.totalBytes\n\t\t\t\t\t? `${details.mode} ${formatSize(details.sliceBytes)} of ${formatSize(details.totalBytes)}`\n\t\t\t\t\t: formatSize(details.totalBytes);\n\t\t\treturn `${theme.fg(\"muted\", \"→ \")}${theme.fg(\"accent\", details.taskId)}${theme.fg(\"muted\", ` ${size} · ${details.outputPath}`)}`;\n\t\t}\n\t\tcase \"wait\": {\n\t\t\tif (details.timedOut) {\n\t\t\t\treturn `${theme.fg(statusColor(details.status), statusGlyph(details.status))} ${theme.fg(\"accent\", details.taskId)}${theme.fg(\"muted\", ` still running · waited ${formatDuration(details.waitedMs)} · ${formatSize(details.totalBytes)}`)}`;\n\t\t\t}\n\t\t\tconst exit = details.exitCode !== undefined && details.exitCode !== null ? `, exit ${details.exitCode}` : \"\";\n\t\t\treturn `${theme.fg(statusColor(details.status), statusGlyph(details.status))} ${theme.fg(\"accent\", details.taskId)}${theme.fg(\"muted\", ` ${details.status}${exit} · waited ${formatDuration(details.waitedMs)} · +${formatSize(details.deltaBytes)}`)}`;\n\t\t}\n\t\tcase \"kill\":\n\t\t\treturn `${theme.fg(statusColor(\"killed\"), statusGlyph(\"killed\"))} ${theme.fg(\"accent\", details.taskId)}${theme.fg(\"muted\", \" stopped\")}`;\n\t\tcase \"list\": {\n\t\t\tconst hidden = details.hidden > 0 ? ` · ${details.hidden} more finished` : \"\";\n\t\t\treturn theme.fg(\"muted\", `${details.running} running · ${details.finished} finished${hidden}`);\n\t\t}\n\t}\n}\n\n// ── completion notification ───────────────────────────────────────────────\n\n/** One-line summary of a finished task, shared by the notification renderer. */\nfunction taskSummaryLine(details: BgNotificationDetails, theme: Theme): string {\n\tconst runtime = formatDuration(details.runtimeMs);\n\tconst exit = details.exitCode !== undefined && details.exitCode !== null ? `, exit ${details.exitCode}` : \"\";\n\tif (details.stalled) {\n\t\tconst glyph = theme.fg(\"warning\", \"…\");\n\t\tconst label = details.description\n\t\t\t? `${details.description} (${commandLabel(details.command, 40)})`\n\t\t\t: commandLabel(details.command, COMMAND_PREVIEW_LIMIT);\n\t\treturn `${glyph} ${theme.fg(\"accent\", details.taskId)} ${label} ${theme.fg(\"muted\", `— waiting for input (${runtime})`)}`;\n\t}\n\tconst outcome = theme.fg(statusColor(details.status), `${details.status}${exit} in ${runtime}`);\n\tconst glyph = theme.fg(statusColor(details.status), statusGlyph(details.status));\n\tconst label = details.description\n\t\t? `${details.description} (${commandLabel(details.command, 40)})`\n\t\t: commandLabel(details.command, COMMAND_PREVIEW_LIMIT);\n\treturn `${glyph} ${theme.fg(\"accent\", details.taskId)} ${label} ${theme.fg(\"muted\", `— ${outcome}`)}`;\n}\n\n/**\n * Collapsed: status glyph, task id, label, and outcome on one line, output\n * path below. Expanded adds the embedded output tail. Returns undefined for\n * malformed details so the default custom-message rendering takes over.\n */\nexport function renderBackgroundNotification(\n\tmessage: CustomMessage<BgNotificationDetails>,\n\toptions: MessageRenderOptions,\n\ttheme: Theme,\n): Component | undefined {\n\tconst details = message.details;\n\tif (!details || typeof details.taskId !== \"string\") return undefined;\n\n\tconst container = new Container();\n\tcontainer.addChild(new TruncatedText(taskSummaryLine(details, theme), 1, 0));\n\t// Collapsed keeps the row compact with the file name; the full path\n\t// (model-relevant, human-rarely) shows when expanded.\n\tconst shownPath = options.expanded ? details.outputPath : fileNameOf(details.outputPath);\n\tcontainer.addChild(new Text(theme.fg(\"muted\", shownPath), 1, 0));\n\n\tif (details.tailError) {\n\t\tcontainer.addChild(new Text(theme.fg(\"error\", `Output unavailable: ${details.tailError}`), 1, 0));\n\t} else if (options.expanded && details.tailText) {\n\t\tcontainer.addChild(new Text(\"\", 0, 0));\n\t\tconst tail = capForTranscript(details.tailText, NOTIFY_TAIL_LIMIT);\n\t\tconst truncatedNote = details.tailTruncated\n\t\t\t? `\\n[showing tail of ${formatSize(details.totalBytes)} bytes; full output: ${details.outputPath}]`\n\t\t\t: \"\";\n\t\tcontainer.addChild(\n\t\t\tnew Text(`${theme.fg(\"toolOutput\", tail.trimEnd())}${theme.fg(\"muted\", truncatedNote)}`, 1, 0),\n\t\t);\n\t}\n\tif (details.stalled && options.expanded) {\n\t\tcontainer.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\n\t\t\t\t\t\"warning\",\n\t\t\t\t\t\"Blocked on interactive input — kill (bg action kill) and re-run with piped input or a non-interactive flag.\",\n\t\t\t\t),\n\t\t\t\t1,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t}\n\treturn container;\n}\n"]}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const DEEPWIKI_TOOL_NAME = "deepwiki";
|
|
9
9
|
export declare const DEEPWIKI_LABEL = "DeepWiki";
|
|
10
|
-
export declare const DEEPWIKI_DESCRIPTION = "Query DeepWiki's AI-generated documentation for indexed public GitHub repositories.
|
|
11
|
-
export declare const DEEPWIKI_PROMPT_SNIPPET = "Query AI-generated docs for public GitHub repos: architecture, APIs, implementation patterns
|
|
10
|
+
export declare const DEEPWIKI_DESCRIPTION = "Query DeepWiki's AI-generated documentation for indexed public GitHub repositories. structure lists a repo's wiki pages; contents reads one page, or the whole wiki truncated past ~120k chars when page is omitted; question answers a focused query about one repo, or across up to 10 repos for a comparison. Results are indexed public snapshots and may cite sources. A repository that is not indexed fails every action with a repository-not-found error.";
|
|
11
|
+
export declare const DEEPWIKI_PROMPT_SNIPPET = "Query AI-generated docs for public GitHub repos: architecture, APIs, implementation patterns";
|
|
12
12
|
export declare const DEEPWIKI_PROMPT_GUIDELINES: string[];
|
|
13
13
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/extensions/deepwiki/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/extensions/deepwiki/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,eAAO,MAAM,oBAAoB,ucACoa,CAAC;AAEtc,eAAO,MAAM,uBAAuB,iGAC2D,CAAC;AAIhG,eAAO,MAAM,0BAA0B,UAGtC,CAAC"}
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export const DEEPWIKI_TOOL_NAME = "deepwiki";
|
|
9
9
|
export const DEEPWIKI_LABEL = "DeepWiki";
|
|
10
|
-
export const DEEPWIKI_DESCRIPTION = "Query DeepWiki's AI-generated documentation for indexed public GitHub repositories.
|
|
11
|
-
export const DEEPWIKI_PROMPT_SNIPPET = "Query AI-generated docs for public GitHub repos: architecture, APIs, implementation patterns
|
|
10
|
+
export const DEEPWIKI_DESCRIPTION = "Query DeepWiki's AI-generated documentation for indexed public GitHub repositories. structure lists a repo's wiki pages; contents reads one page, or the whole wiki truncated past ~120k chars when page is omitted; question answers a focused query about one repo, or across up to 10 repos for a comparison. Results are indexed public snapshots and may cite sources. A repository that is not indexed fails every action with a repository-not-found error.";
|
|
11
|
+
export const DEEPWIKI_PROMPT_SNIPPET = "Query AI-generated docs for public GitHub repos: architecture, APIs, implementation patterns";
|
|
12
|
+
// Routing only: how to pick and reject `deepwiki`. Per-parameter syntax stays in
|
|
13
|
+
// DeepWikiParamsSchema, which the model receives in the same request.
|
|
12
14
|
export const DEEPWIKI_PROMPT_GUIDELINES = [
|
|
13
|
-
"
|
|
14
|
-
"After structure, use `contents` with `page` set to a 1-based index or an exact page title from the structure list (titles are plain names like `Extension System`, not numbered outline lines like `4.4 Extension System`). Avoid `contents` without `page` unless the wiki is small.",
|
|
15
|
-
"Use `deepwiki` action `question` for a focused answer without reading pages, or when structure/contents do not cover the topic. Single repo: `repoName` as a string. Compare 2-10 repos: `repoName` as an array of owner/repo strings (or comma-separated string).",
|
|
15
|
+
"Run `deepwiki` action `structure` first for a repo; a repository-not-found error means it is not indexed, so do not retry that repo with `contents` or `question`.",
|
|
16
16
|
"Do not use `deepwiki` for local workspace files, private repos, exact current HEAD, or freshness-sensitive facts (releases, pricing, advisories); use local tools or current primary sources instead.",
|
|
17
17
|
];
|
|
18
18
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/deepwiki/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAChC,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/deepwiki/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAChC,ocAAoc,CAAC;AAEtc,MAAM,CAAC,MAAM,uBAAuB,GACnC,8FAA8F,CAAC;AAEhG,iFAAiF;AACjF,sEAAsE;AACtE,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACzC,oKAAoK;IACpK,uMAAuM;CACvM,CAAC","sourcesContent":["/**\n * constants.ts — deepwiki tool identity + prompt copy.\n *\n * Name/label/description/promptSnippet/promptGuidelines live here so\n * `index.ts` only assembles the tool. Prompt copy is the model-facing\n * contract; keep it stable.\n */\n\nexport const DEEPWIKI_TOOL_NAME = \"deepwiki\";\nexport const DEEPWIKI_LABEL = \"DeepWiki\";\n\nexport const DEEPWIKI_DESCRIPTION =\n\t\"Query DeepWiki's AI-generated documentation for indexed public GitHub repositories. structure lists a repo's wiki pages; contents reads one page, or the whole wiki truncated past ~120k chars when page is omitted; question answers a focused query about one repo, or across up to 10 repos for a comparison. Results are indexed public snapshots and may cite sources. A repository that is not indexed fails every action with a repository-not-found error.\";\n\nexport const DEEPWIKI_PROMPT_SNIPPET =\n\t\"Query AI-generated docs for public GitHub repos: architecture, APIs, implementation patterns\";\n\n// Routing only: how to pick and reject `deepwiki`. Per-parameter syntax stays in\n// DeepWikiParamsSchema, which the model receives in the same request.\nexport const DEEPWIKI_PROMPT_GUIDELINES = [\n\t\"Run `deepwiki` action `structure` first for a repo; a repository-not-found error means it is not indexed, so do not retry that repo with `contents` or `question`.\",\n\t\"Do not use `deepwiki` for local workspace files, private repos, exact current HEAD, or freshness-sensitive facts (releases, pricing, advisories); use local tools or current primary sources instead.\",\n];\n"]}
|
|
@@ -4,7 +4,7 @@ import { normalizePageRef } from "./contents.js";
|
|
|
4
4
|
export const DEEPWIKI_ACTIONS = ["structure", "contents", "question"];
|
|
5
5
|
const MAX_QUESTION_REPOS = 10;
|
|
6
6
|
const DeepWikiActionSchema = StringEnum(DEEPWIKI_ACTIONS, {
|
|
7
|
-
description: "DeepWiki operation: structure lists generated wiki pages
|
|
7
|
+
description: "DeepWiki operation: structure lists a repo's generated wiki pages, contents reads one page of that wiki (or all of it when page is omitted), and question answers focused repo/reference/comparison questions across up to 10 repos.",
|
|
8
8
|
});
|
|
9
9
|
export const DeepWikiParamsSchema = Type.Object({
|
|
10
10
|
action: DeepWikiActionSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/extensions/deepwiki/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAU,CAAC;AAC/E,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,MAAM,oBAAoB,GAAG,UAAU,CAAC,gBAAgB,EAAE;IACzD,WAAW,EACV,qNAAqN;CACtN,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/C,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AK,UAAU,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC;AACH,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\n\nimport { normalizePageRef } from \"./contents.ts\";\n\nexport const DEEPWIKI_ACTIONS = [\"structure\", \"contents\", \"question\"] as const;\nconst MAX_QUESTION_REPOS = 10;\n\nconst DeepWikiActionSchema = StringEnum(DEEPWIKI_ACTIONS, {\n\tdescription:\n\t\t\"DeepWiki operation: structure lists generated wiki pages for one repo, contents reads the full generated wiki for one repo, and question answers focused repo/reference/comparison questions across up to 10 repos.\",\n});\n\nexport const DeepWikiParamsSchema = Type.Object({\n\taction: DeepWikiActionSchema,\n\trepoName: Type.Union([\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription:\n\t\t\t\t'One public GitHub repo as \"owner/repo\" (preferred), or a GitHub/DeepWiki URL. Required for structure and contents; for question with a single repo use this string form — not a one-element array.',\n\t\t}),\n\t\tType.Array(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tdescription: 'Public GitHub repo in \"owner/repo\" format.',\n\t\t\t}),\n\t\t\t{\n\t\t\t\tminItems: 1,\n\t\t\t\tmaxItems: MAX_QUESTION_REPOS,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Only for action question when comparing 2-10 repos. Each entry is owner/repo. For one repo use a string repoName instead.\",\n\t\t\t},\n\t\t),\n\t]),\n\tquestion: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription:\n\t\t\t\t\"Required for action question. Ask a focused question about architecture, APIs, implementation patterns, extension points, onboarding, or cross-repo comparison.\",\n\t\t}),\n\t),\n\tpage: Type.Optional(\n\t\tType.Union([Type.String({ minLength: 1 }), Type.Number()], {\n\t\t\tdescription:\n\t\t\t\t'Only for action contents: one page by 1-based index or by title from structure (e.g. \"Extension System\") — titles do not include outline numbers like \"4.4\". Run structure first if unsure. Prefer page reads over omitting page.',\n\t\t}),\n\t),\n});\n\nexport type DeepWikiAction = (typeof DEEPWIKI_ACTIONS)[number];\nexport type DeepWikiParams = Static<typeof DeepWikiParamsSchema>;\n\nconst ACTION_ALIASES: Record<string, DeepWikiAction> = {\n\task: \"question\",\n\task_question: \"question\",\n\tcontents: \"contents\",\n\tcontent: \"contents\",\n\tfull: \"contents\",\n\tmap: \"structure\",\n\tpages: \"structure\",\n\tquestion: \"question\",\n\tquery: \"question\",\n\tread_wiki_contents: \"contents\",\n\tread_wiki_structure: \"structure\",\n\tstructure: \"structure\",\n\ttopics: \"structure\",\n\twiki: \"contents\",\n};\n\nconst GITHUB_OWNER_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38}[A-Za-z0-9])?$/;\nconst GITHUB_REPO_RE = /^[A-Za-z0-9._-]{1,100}$/;\n\nfunction readString(record: Record<string, unknown>, keys: string[]): string | undefined {\n\tfor (const key of keys) {\n\t\tconst value = record[key];\n\t\tif (typeof value === \"string\" && value.trim()) return value.trim();\n\t}\n\treturn undefined;\n}\n\nfunction readPageRef(record: Record<string, unknown>): string | number | undefined {\n\tfor (const key of [\"page\", \"pageName\", \"pageTitle\"]) {\n\t\tconst value = record[key];\n\t\tif (typeof value === \"number\" && Number.isFinite(value)) return value;\n\t\tif (typeof value === \"string\" && value.trim()) return normalizePageRef(value.trim());\n\t}\n\treturn undefined;\n}\n\nfunction coerceRepoNameInput(value: unknown): unknown {\n\tif (Array.isArray(value)) return value;\n\tif (typeof value !== \"string\") return value;\n\tconst trimmed = value.trim();\n\tif (!trimmed.startsWith(\"[\")) return value;\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(trimmed);\n\t\tif (Array.isArray(parsed)) return parsed;\n\t} catch {\n\t\t/* keep original string */\n\t}\n\treturn value;\n}\n\nfunction normalizeAction(\n\taction: unknown,\n\tquestion: string | undefined,\n\tpage: string | number | undefined,\n): DeepWikiAction {\n\tif (typeof action === \"string\") {\n\t\tconst key = action\n\t\t\t.trim()\n\t\t\t.toLowerCase()\n\t\t\t.replace(/[\\s-]+/g, \"_\");\n\t\tif (!key) return inferAction(question, page);\n\t\tconst normalized = ACTION_ALIASES[key];\n\t\tif (normalized) return normalized;\n\t\tthrow new Error(`unsupported deepwiki action: ${action}`);\n\t}\n\tif (action !== undefined && action !== null) {\n\t\tthrow new Error(\"deepwiki action must be a string\");\n\t}\n\treturn inferAction(question, page);\n}\n\nfunction inferAction(question: string | undefined, page: string | number | undefined): DeepWikiAction {\n\tif (question) return \"question\";\n\tif (page !== undefined) return \"contents\";\n\treturn \"structure\";\n}\n\nexport function normalizeRepoName(value: unknown): string {\n\tif (typeof value !== \"string\") throw new Error(\"repoName is required\");\n\n\tconst input = value.trim().replace(/^\\/+|\\/+$/g, \"\");\n\tif (!input) throw new Error(\"repoName is required\");\n\n\tlet owner: string | undefined;\n\tlet repo: string | undefined;\n\n\tconst sshMatch = input.match(/^git@github\\.com:([^/\\s]+)\\/([^/\\s]+?)(?:\\.git)?$/i);\n\tif (sshMatch) {\n\t\towner = sshMatch[1];\n\t\trepo = sshMatch[2];\n\t} else if (/^(?:https?:\\/\\/)?(?:www\\.)?(?:github\\.com|deepwiki\\.com)\\//i.test(input)) {\n\t\tconst urlInput = /^[a-z][a-z0-9+.-]*:\\/\\//i.test(input) ? input : `https://${input}`;\n\t\ttry {\n\t\t\tconst url = new URL(urlInput);\n\t\t\tconst [urlOwner, urlRepo] = url.pathname.replace(/^\\/+|\\/+$/g, \"\").split(\"/\");\n\t\t\towner = urlOwner;\n\t\t\trepo = urlRepo?.replace(/\\.git$/i, \"\");\n\t\t} catch {\n\t\t\tthrow new Error('repoName must use \"owner/repo\" format');\n\t\t}\n\t} else {\n\t\tconst parts = input.replace(/\\.git$/i, \"\").split(\"/\");\n\t\tif (parts.length === 2) {\n\t\t\t[owner, repo] = parts;\n\t\t}\n\t}\n\n\tif (!owner || !repo || !GITHUB_OWNER_RE.test(owner) || !GITHUB_REPO_RE.test(repo)) {\n\t\tthrow new Error('repoName must use a public GitHub \"owner/repo\" identifier');\n\t}\n\treturn `${owner}/${repo}`;\n}\n\nfunction normalizeRepoNames(value: unknown): string[] {\n\tvalue = coerceRepoNameInput(value);\n\tconst values =\n\t\ttypeof value === \"string\" && value.includes(\",\")\n\t\t\t? value\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((repo) => repo.trim())\n\t\t\t\t\t.filter(Boolean)\n\t\t\t: Array.isArray(value)\n\t\t\t\t? value\n\t\t\t\t: [value];\n\tconst repos = values.map((item) => normalizeRepoName(item));\n\tconst seen = new Set<string>();\n\tconst unique: string[] = [];\n\tfor (const repo of repos) {\n\t\tconst key = repo.toLowerCase();\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tunique.push(repo);\n\t}\n\tif (unique.length > MAX_QUESTION_REPOS) {\n\t\tthrow new Error(`question action supports at most ${MAX_QUESTION_REPOS} repositories`);\n\t}\n\treturn unique;\n}\n\nexport function normalizeDeepWikiParams(input: unknown): DeepWikiParams {\n\tif (!input || typeof input !== \"object\") {\n\t\tthrow new Error(\"deepwiki arguments must be an object\");\n\t}\n\n\tconst record = input as Record<string, unknown>;\n\tconst question = readString(record, [\"question\", \"query\", \"prompt\"]);\n\tconst page = readPageRef(record);\n\tconst action = normalizeAction(record.action, question, page);\n\tconst rawRepoName =\n\t\trecord.repoName ??\n\t\trecord.repo ??\n\t\trecord.repos ??\n\t\trecord.repository ??\n\t\trecord.repositories ??\n\t\trecord.githubRepo ??\n\t\trecord.githubRepos;\n\tconst repoNames = normalizeRepoNames(rawRepoName);\n\n\tif (action === \"question\") {\n\t\tif (!question) throw new Error(\"question is required when action is question\");\n\t\treturn {\n\t\t\taction,\n\t\t\trepoName: repoNames.length > 1 ? repoNames : repoNames[0],\n\t\t\tquestion,\n\t\t};\n\t}\n\n\tif (repoNames.length !== 1) {\n\t\tthrow new Error(`${action} action requires exactly one repository`);\n\t}\n\n\t// page is meaningful only for contents; structure/question ignore it.\n\treturn {\n\t\taction,\n\t\trepoName: repoNames[0],\n\t\t...(action === \"contents\" && page !== undefined ? { page } : {}),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/extensions/deepwiki/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAU,CAAC;AAC/E,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,MAAM,oBAAoB,GAAG,UAAU,CAAC,gBAAgB,EAAE;IACzD,WAAW,EACV,sOAAsO;CACvO,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/C,MAAM,EAAE,oBAAoB;IAC5B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC;QACpB,IAAI,CAAC,MAAM,CAAC;YACX,SAAS,EAAE,CAAC;YACZ,WAAW,EACV,oMAAoM;SACrM,CAAC;QACF,IAAI,CAAC,KAAK,CACT,IAAI,CAAC,MAAM,CAAC;YACX,SAAS,EAAE,CAAC;YACZ,WAAW,EAAE,4CAA4C;SACzD,CAAC,EACF;YACC,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,kBAAkB;YAC5B,WAAW,EACV,2HAA2H;SAC5H,CACD;KACD,CAAC;IACF,QAAQ,EAAE,IAAI,CAAC,QAAQ,CACtB,IAAI,CAAC,MAAM,CAAC;QACX,SAAS,EAAE,CAAC;QACZ,WAAW,EACV,iKAAiK;KAClK,CAAC,CACF;IACD,IAAI,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,KAAK,CAAC,C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ACjB,MAAM,CAAC,YAAY;QACnB,MAAM,CAAC,UAAU;QACjB,MAAM,CAAC,WAAW,CAAC;IACpB,MAAM,SAAS,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAElD,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC/E,OAAO;YACN,MAAM;YACN,QAAQ,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACzD,QAAQ;SACR,CAAC;IACH,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yCAAyC,CAAC,CAAC;IACrE,CAAC;IAED,sEAAsE;IACtE,OAAO;QACN,MAAM;QACN,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;QACtB,GAAG,CAAC,MAAM,KAAK,UAAU,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC;AACH,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\n\nimport { normalizePageRef } from \"./contents.ts\";\n\nexport const DEEPWIKI_ACTIONS = [\"structure\", \"contents\", \"question\"] as const;\nconst MAX_QUESTION_REPOS = 10;\n\nconst DeepWikiActionSchema = StringEnum(DEEPWIKI_ACTIONS, {\n\tdescription:\n\t\t\"DeepWiki operation: structure lists a repo's generated wiki pages, contents reads one page of that wiki (or all of it when page is omitted), and question answers focused repo/reference/comparison questions across up to 10 repos.\",\n});\n\nexport const DeepWikiParamsSchema = Type.Object({\n\taction: DeepWikiActionSchema,\n\trepoName: Type.Union([\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription:\n\t\t\t\t'One public GitHub repo as \"owner/repo\" (preferred), or a GitHub/DeepWiki URL. Required for structure and contents; for question with a single repo use this string form — not a one-element array.',\n\t\t}),\n\t\tType.Array(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tdescription: 'Public GitHub repo in \"owner/repo\" format.',\n\t\t\t}),\n\t\t\t{\n\t\t\t\tminItems: 1,\n\t\t\t\tmaxItems: MAX_QUESTION_REPOS,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Only for action question when comparing 2-10 repos. Each entry is owner/repo. For one repo use a string repoName instead.\",\n\t\t\t},\n\t\t),\n\t]),\n\tquestion: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription:\n\t\t\t\t\"Required for action question. Ask a focused question about architecture, APIs, implementation patterns, extension points, onboarding, or cross-repo comparison.\",\n\t\t}),\n\t),\n\tpage: Type.Optional(\n\t\tType.Union([Type.String({ minLength: 1 }), Type.Number()], {\n\t\t\tdescription:\n\t\t\t\t'Only for action contents: one page by 1-based index or by title from structure (e.g. \"Extension System\") — titles do not include outline numbers like \"4.4\". Run structure first if unsure. Prefer page reads over omitting page.',\n\t\t}),\n\t),\n});\n\nexport type DeepWikiAction = (typeof DEEPWIKI_ACTIONS)[number];\nexport type DeepWikiParams = Static<typeof DeepWikiParamsSchema>;\n\nconst ACTION_ALIASES: Record<string, DeepWikiAction> = {\n\task: \"question\",\n\task_question: \"question\",\n\tcontents: \"contents\",\n\tcontent: \"contents\",\n\tfull: \"contents\",\n\tmap: \"structure\",\n\tpages: \"structure\",\n\tquestion: \"question\",\n\tquery: \"question\",\n\tread_wiki_contents: \"contents\",\n\tread_wiki_structure: \"structure\",\n\tstructure: \"structure\",\n\ttopics: \"structure\",\n\twiki: \"contents\",\n};\n\nconst GITHUB_OWNER_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38}[A-Za-z0-9])?$/;\nconst GITHUB_REPO_RE = /^[A-Za-z0-9._-]{1,100}$/;\n\nfunction readString(record: Record<string, unknown>, keys: string[]): string | undefined {\n\tfor (const key of keys) {\n\t\tconst value = record[key];\n\t\tif (typeof value === \"string\" && value.trim()) return value.trim();\n\t}\n\treturn undefined;\n}\n\nfunction readPageRef(record: Record<string, unknown>): string | number | undefined {\n\tfor (const key of [\"page\", \"pageName\", \"pageTitle\"]) {\n\t\tconst value = record[key];\n\t\tif (typeof value === \"number\" && Number.isFinite(value)) return value;\n\t\tif (typeof value === \"string\" && value.trim()) return normalizePageRef(value.trim());\n\t}\n\treturn undefined;\n}\n\nfunction coerceRepoNameInput(value: unknown): unknown {\n\tif (Array.isArray(value)) return value;\n\tif (typeof value !== \"string\") return value;\n\tconst trimmed = value.trim();\n\tif (!trimmed.startsWith(\"[\")) return value;\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(trimmed);\n\t\tif (Array.isArray(parsed)) return parsed;\n\t} catch {\n\t\t/* keep original string */\n\t}\n\treturn value;\n}\n\nfunction normalizeAction(\n\taction: unknown,\n\tquestion: string | undefined,\n\tpage: string | number | undefined,\n): DeepWikiAction {\n\tif (typeof action === \"string\") {\n\t\tconst key = action\n\t\t\t.trim()\n\t\t\t.toLowerCase()\n\t\t\t.replace(/[\\s-]+/g, \"_\");\n\t\tif (!key) return inferAction(question, page);\n\t\tconst normalized = ACTION_ALIASES[key];\n\t\tif (normalized) return normalized;\n\t\tthrow new Error(`unsupported deepwiki action: ${action}`);\n\t}\n\tif (action !== undefined && action !== null) {\n\t\tthrow new Error(\"deepwiki action must be a string\");\n\t}\n\treturn inferAction(question, page);\n}\n\nfunction inferAction(question: string | undefined, page: string | number | undefined): DeepWikiAction {\n\tif (question) return \"question\";\n\tif (page !== undefined) return \"contents\";\n\treturn \"structure\";\n}\n\nexport function normalizeRepoName(value: unknown): string {\n\tif (typeof value !== \"string\") throw new Error(\"repoName is required\");\n\n\tconst input = value.trim().replace(/^\\/+|\\/+$/g, \"\");\n\tif (!input) throw new Error(\"repoName is required\");\n\n\tlet owner: string | undefined;\n\tlet repo: string | undefined;\n\n\tconst sshMatch = input.match(/^git@github\\.com:([^/\\s]+)\\/([^/\\s]+?)(?:\\.git)?$/i);\n\tif (sshMatch) {\n\t\towner = sshMatch[1];\n\t\trepo = sshMatch[2];\n\t} else if (/^(?:https?:\\/\\/)?(?:www\\.)?(?:github\\.com|deepwiki\\.com)\\//i.test(input)) {\n\t\tconst urlInput = /^[a-z][a-z0-9+.-]*:\\/\\//i.test(input) ? input : `https://${input}`;\n\t\ttry {\n\t\t\tconst url = new URL(urlInput);\n\t\t\tconst [urlOwner, urlRepo] = url.pathname.replace(/^\\/+|\\/+$/g, \"\").split(\"/\");\n\t\t\towner = urlOwner;\n\t\t\trepo = urlRepo?.replace(/\\.git$/i, \"\");\n\t\t} catch {\n\t\t\tthrow new Error('repoName must use \"owner/repo\" format');\n\t\t}\n\t} else {\n\t\tconst parts = input.replace(/\\.git$/i, \"\").split(\"/\");\n\t\tif (parts.length === 2) {\n\t\t\t[owner, repo] = parts;\n\t\t}\n\t}\n\n\tif (!owner || !repo || !GITHUB_OWNER_RE.test(owner) || !GITHUB_REPO_RE.test(repo)) {\n\t\tthrow new Error('repoName must use a public GitHub \"owner/repo\" identifier');\n\t}\n\treturn `${owner}/${repo}`;\n}\n\nfunction normalizeRepoNames(value: unknown): string[] {\n\tvalue = coerceRepoNameInput(value);\n\tconst values =\n\t\ttypeof value === \"string\" && value.includes(\",\")\n\t\t\t? value\n\t\t\t\t\t.split(\",\")\n\t\t\t\t\t.map((repo) => repo.trim())\n\t\t\t\t\t.filter(Boolean)\n\t\t\t: Array.isArray(value)\n\t\t\t\t? value\n\t\t\t\t: [value];\n\tconst repos = values.map((item) => normalizeRepoName(item));\n\tconst seen = new Set<string>();\n\tconst unique: string[] = [];\n\tfor (const repo of repos) {\n\t\tconst key = repo.toLowerCase();\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tunique.push(repo);\n\t}\n\tif (unique.length > MAX_QUESTION_REPOS) {\n\t\tthrow new Error(`question action supports at most ${MAX_QUESTION_REPOS} repositories`);\n\t}\n\treturn unique;\n}\n\nexport function normalizeDeepWikiParams(input: unknown): DeepWikiParams {\n\tif (!input || typeof input !== \"object\") {\n\t\tthrow new Error(\"deepwiki arguments must be an object\");\n\t}\n\n\tconst record = input as Record<string, unknown>;\n\tconst question = readString(record, [\"question\", \"query\", \"prompt\"]);\n\tconst page = readPageRef(record);\n\tconst action = normalizeAction(record.action, question, page);\n\tconst rawRepoName =\n\t\trecord.repoName ??\n\t\trecord.repo ??\n\t\trecord.repos ??\n\t\trecord.repository ??\n\t\trecord.repositories ??\n\t\trecord.githubRepo ??\n\t\trecord.githubRepos;\n\tconst repoNames = normalizeRepoNames(rawRepoName);\n\n\tif (action === \"question\") {\n\t\tif (!question) throw new Error(\"question is required when action is question\");\n\t\treturn {\n\t\t\taction,\n\t\t\trepoName: repoNames.length > 1 ? repoNames : repoNames[0],\n\t\t\tquestion,\n\t\t};\n\t}\n\n\tif (repoNames.length !== 1) {\n\t\tthrow new Error(`${action} action requires exactly one repository`);\n\t}\n\n\t// page is meaningful only for contents; structure/question ignore it.\n\treturn {\n\t\taction,\n\t\trepoName: repoNames[0],\n\t\t...(action === \"contents\" && page !== undefined ? { page } : {}),\n\t};\n}\n"]}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const QUESTION_TOOL_NAME = "question";
|
|
9
9
|
export declare const QUESTION_LABEL = "Question";
|
|
10
|
-
export declare const QUESTION_DESCRIPTION = "Ask the user 1-4 structured multiple-choice questions
|
|
11
|
-
export declare const QUESTION_PROMPT_SNIPPET = "Ask the user structured multiple-choice questions when blocked on a decision only they can make
|
|
10
|
+
export declare const QUESTION_DESCRIPTION = "Ask the user 1-4 structured multiple-choice questions and return their selections. Never author an 'Other'-style option or a vague label like 'Option A' \u2014 the UI adds a custom-answer path itself. If you recommend an option, put it first and append ' (Recommended)' to its label.";
|
|
11
|
+
export declare const QUESTION_PROMPT_SNIPPET = "Ask the user structured multiple-choice questions when blocked on a decision only they can make";
|
|
12
12
|
export declare const QUESTION_PROMPT_GUIDELINES: string[];
|
|
13
13
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/extensions/question/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/extensions/question/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,cAAc,aAAa,CAAC;AAKzC,eAAO,MAAM,oBAAoB,gSACwP,CAAC;AAE1R,eAAO,MAAM,uBAAuB,oGAC8D,CAAC;AAEnG,eAAO,MAAM,0BAA0B,UAItC,CAAC"}
|
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export const QUESTION_TOOL_NAME = "question";
|
|
9
9
|
export const QUESTION_LABEL = "Question";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// Mechanism plus the two rules the schema cannot state: the recommended-option
|
|
11
|
+
// convention, and the reserved/vague labels models reach for most often.
|
|
12
|
+
// Per-field authoring rules and limits live in QuestionParams.
|
|
13
|
+
export const QUESTION_DESCRIPTION = "Ask the user 1-4 structured multiple-choice questions and return their selections. Never author an 'Other'-style option or a vague label like 'Option A' — the UI adds a custom-answer path itself. If you recommend an option, put it first and append ' (Recommended)' to its label.";
|
|
14
|
+
export const QUESTION_PROMPT_SNIPPET = "Ask the user structured multiple-choice questions when blocked on a decision only they can make";
|
|
12
15
|
export const QUESTION_PROMPT_GUIDELINES = [
|
|
13
16
|
"Use `question` only for decisions you cannot resolve from the request, the code, or sensible defaults (direction, preference, permissions, destructive choices); for everything else choose a reasonable default and state it.",
|
|
14
17
|
"Batch related decisions into one `question` call (1-4 questions); ask no more than needed to unblock the next step.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/question/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAChC,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/question/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,+EAA+E;AAC/E,yEAAyE;AACzE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAChC,wRAAwR,CAAC;AAE1R,MAAM,CAAC,MAAM,uBAAuB,GACnC,iGAAiG,CAAC;AAEnG,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACzC,gOAAgO;IAChO,qHAAqH;IACrH,0HAA0H;CAC1H,CAAC","sourcesContent":["/**\n * constants.ts — question tool identity + prompt copy.\n *\n * Name/label/description/promptSnippet/promptGuidelines live here so\n * `index.ts` only assembles the tool. Prompt copy is the model-facing\n * contract; keep it stable.\n */\n\nexport const QUESTION_TOOL_NAME = \"question\";\nexport const QUESTION_LABEL = \"Question\";\n\n// Mechanism plus the two rules the schema cannot state: the recommended-option\n// convention, and the reserved/vague labels models reach for most often.\n// Per-field authoring rules and limits live in QuestionParams.\nexport const QUESTION_DESCRIPTION =\n\t\"Ask the user 1-4 structured multiple-choice questions and return their selections. Never author an 'Other'-style option or a vague label like 'Option A' — the UI adds a custom-answer path itself. If you recommend an option, put it first and append ' (Recommended)' to its label.\";\n\nexport const QUESTION_PROMPT_SNIPPET =\n\t\"Ask the user structured multiple-choice questions when blocked on a decision only they can make\";\n\nexport const QUESTION_PROMPT_GUIDELINES = [\n\t\"Use `question` only for decisions you cannot resolve from the request, the code, or sensible defaults (direction, preference, permissions, destructive choices); for everything else choose a reasonable default and state it.\",\n\t\"Batch related decisions into one `question` call (1-4 questions); ask no more than needed to unblock the next step.\",\n\t\"Treat `question` answers as decisions: act on them without re-litigating, and do not re-ask unless circumstances change.\",\n];\n"]}
|
|
@@ -10,5 +10,14 @@ export declare function toNestedUsage(usage: SubagentUsage): Usage;
|
|
|
10
10
|
export declare function assistantText(message: AgentMessage | undefined): string;
|
|
11
11
|
export declare function finalAssistantText(messages: readonly AgentMessage[]): string;
|
|
12
12
|
export declare function activitySummary(toolName: string, args: unknown): string;
|
|
13
|
+
export declare function formatTokens(value: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Activity summary for the synthetic auto-compaction entry. The before/after
|
|
16
|
+
* pair is only known once a compaction succeeds; a failed or aborted one keeps
|
|
17
|
+
* the neutral label and carries its reason in the entry's resultSummary.
|
|
18
|
+
*/
|
|
19
|
+
export declare function compactionSummary(tokensBefore: number | undefined, tokensAfter: number | undefined): string;
|
|
20
|
+
/** Failure reason for the compaction activity; bounded like {@link resultSummary}. */
|
|
21
|
+
export declare function compactionError(error: string): string;
|
|
13
22
|
export declare function resultSummary(result: unknown): string;
|
|
14
23
|
//# sourceMappingURL=activity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/activity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,wEAAyE,CAAC;AAEvG,wBA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AAG,SAAS,GAAG,MAAM,CAMvE;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAM5E;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAWvE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG3G;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAoBrD"}
|
|
@@ -82,6 +82,27 @@ export function activitySummary(toolName, args) {
|
|
|
82
82
|
return `Find ${boundText(input.pattern, 120)}`;
|
|
83
83
|
return toolName;
|
|
84
84
|
}
|
|
85
|
+
export function formatTokens(value) {
|
|
86
|
+
if (value < 1_000)
|
|
87
|
+
return String(value);
|
|
88
|
+
if (value < 1_000_000)
|
|
89
|
+
return `${(value / 1_000).toFixed(value < 10_000 ? 1 : 0)}k`;
|
|
90
|
+
return `${(value / 1_000_000).toFixed(1)}M`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Activity summary for the synthetic auto-compaction entry. The before/after
|
|
94
|
+
* pair is only known once a compaction succeeds; a failed or aborted one keeps
|
|
95
|
+
* the neutral label and carries its reason in the entry's resultSummary.
|
|
96
|
+
*/
|
|
97
|
+
export function compactionSummary(tokensBefore, tokensAfter) {
|
|
98
|
+
if (tokensBefore && tokensAfter)
|
|
99
|
+
return `Compacted ${formatTokens(tokensBefore)} → ${formatTokens(tokensAfter)}`;
|
|
100
|
+
return "Compact context";
|
|
101
|
+
}
|
|
102
|
+
/** Failure reason for the compaction activity; bounded like {@link resultSummary}. */
|
|
103
|
+
export function compactionError(error) {
|
|
104
|
+
return boundText(error.replace(/\s+/gu, " ").trim(), 240);
|
|
105
|
+
}
|
|
85
106
|
export function resultSummary(result) {
|
|
86
107
|
if (!result || typeof result !== "object")
|
|
87
108
|
return "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../../src/extensions/subagent/activity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,yDAAyD;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,CAAU,CAAC;AAEvG,MAAM,UAAU,UAAU;IACzB,OAAO;QACN,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,CAAC;KACP,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAqB,EAAE,KAAwB;IACvE,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,KAAK,MAAM,KAAK,IAAI,gBAAgB;QAAE,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzE,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,CAAC;IACtC,wEAAwE;IACxE,0DAA0D;IAC1D,IAAI,KAAK,CAAC,WAAW;QAAE,MAAM,CAAC,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAqB,EAAE,MAAqB;IACtE,MAAM,CAAC,KAAK,IAAI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AAK,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,QAAQ,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;IAC7G,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAe;IAC5C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACrD,MAAM,OAAO,GAAI,MAAgC,CAAC,OAAO,CAAC;IAC1D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,OAAO,SAAS,CACf,OAAO;SACL,MAAM,CAAC,CAAC,IAAI,EAA0C,EAAE;QACxD,OAAO,OAAO,CACb,IAAI;YACH,OAAO,IAAI,KAAK,QAAQ;YACvB,IAA2B,CAAC,IAAI,KAAK,MAAM;YAC5C,OAAQ,IAA2B,CAAC,IAAI,KAAK,QAAQ,CACtD,CAAC;IACH,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;SACxB,IAAI,CAAC,IAAI,CAAC;SACV,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,IAAI,EAAE,EACR,GAAG,CACH,CAAC;AACH,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { Usage } from \"@earendil-works/pi-ai\";\nimport { TASK_OUTPUT_LIMIT } from \"./constants.ts\";\nimport { boundText } from \"./text.ts\";\nimport type { SubagentUsage } from \"./types.ts\";\n\n/** The usage fields that are summed when aggregating. */\nexport const USAGE_SUM_FIELDS = [\"input\", \"output\", \"cacheRead\", \"cacheWrite\", \"totalTokens\"] as const;\n\nexport function emptyUsage(): SubagentUsage {\n\treturn {\n\t\tturns: 0,\n\t\ttoolUses: 0,\n\t\tinput: 0,\n\t\toutput: 0,\n\t\tcacheRead: 0,\n\t\tcacheWrite: 0,\n\t\ttotalTokens: 0,\n\t\tcost: 0,\n\t};\n}\n\nexport function addUsage(target: SubagentUsage, usage: Usage | undefined): void {\n\tif (!usage) return;\n\tfor (const field of USAGE_SUM_FIELDS) target[field] += usage[field] ?? 0;\n\ttarget.cost += usage.cost?.total ?? 0;\n\t// Watermark, not a sum: the latest request's total is the context size,\n\t// and it can shrink again after the worker auto-compacts.\n\tif (usage.totalTokens) target.contextTokens = usage.totalTokens;\n}\n\nexport function mergeUsage(target: SubagentUsage, source: SubagentUsage): void {\n\ttarget.turns += source.turns;\n\ttarget.toolUses += source.toolUses;\n\tfor (const field of USAGE_SUM_FIELDS) target[field] += source[field];\n\ttarget.cost += source.cost;\n\tif (source.contextTokens) {\n\t\ttarget.contextTokens = Math.max(target.contextTokens ?? 0, source.contextTokens);\n\t}\n}\n\nexport function toNestedUsage(usage: SubagentUsage): Usage {\n\treturn {\n\t\tinput: usage.input,\n\t\toutput: usage.output,\n\t\tcacheRead: usage.cacheRead,\n\t\tcacheWrite: usage.cacheWrite,\n\t\ttotalTokens: usage.totalTokens,\n\t\tcost: {\n\t\t\tinput: 0,\n\t\t\toutput: 0,\n\t\t\tcacheRead: 0,\n\t\t\tcacheWrite: 0,\n\t\t\ttotal: usage.cost,\n\t\t},\n\t};\n}\n\nexport function assistantText(message: AgentMessage | undefined): string {\n\tif (!message || message.role !== \"assistant\") return \"\";\n\treturn message.content\n\t\t.filter((part): part is { type: \"text\"; text: string } => part.type === \"text\")\n\t\t.map((part) => part.text)\n\t\t.join(\"\");\n}\n\nexport function finalAssistantText(messages: readonly AgentMessage[]): string {\n\tfor (let index = messages.length - 1; index >= 0; index--) {\n\t\tconst text = assistantText(messages[index]);\n\t\tif (text) return boundText(text, TASK_OUTPUT_LIMIT);\n\t}\n\treturn \"\";\n}\n\nexport function activitySummary(toolName: string, args: unknown): string {\n\tif (!args || typeof args !== \"object\" || Array.isArray(args)) return toolName;\n\tconst input = args as Record<string, unknown>;\n\tconst path =\n\t\ttypeof input.path === \"string\" ? input.path : typeof input.file_path === \"string\" ? input.file_path : undefined;\n\tif (toolName === \"bash\" && typeof input.command === \"string\")\n\t\treturn `Run ${boundText(input.command.replace(/\\s+/gu, \" \"), 160)}`;\n\tif (path) return `${toolName} ${boundText(path, 180)}`;\n\tif (toolName === \"grep\" && typeof input.pattern === \"string\") return `Search ${boundText(input.pattern, 120)}`;\n\tif (toolName === \"find\" && typeof input.pattern === \"string\") return `Find ${boundText(input.pattern, 120)}`;\n\treturn toolName;\n}\n\nexport function resultSummary(result: unknown): string {\n\tif (!result || typeof result !== \"object\") return \"\";\n\tconst content = (result as { content?: unknown }).content;\n\tif (!Array.isArray(content)) return \"\";\n\treturn boundText(\n\t\tcontent\n\t\t\t.filter((part): part is { type: \"text\"; text: string } => {\n\t\t\t\treturn Boolean(\n\t\t\t\t\tpart &&\n\t\t\t\t\t\ttypeof part === \"object\" &&\n\t\t\t\t\t\t(part as { type?: unknown }).type === \"text\" &&\n\t\t\t\t\t\ttypeof (part as { text?: unknown }).text === \"string\",\n\t\t\t\t);\n\t\t\t})\n\t\t\t.map((part) => part.text)\n\t\t\t.join(\"\\n\")\n\t\t\t.replace(/\\s+/gu, \" \")\n\t\t\t.trim(),\n\t\t240,\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"activity.js","sourceRoot":"","sources":["../../../src/extensions/subagent/activity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,yDAAyD;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,CAAU,CAAC;AAEvG,MAAM,UAAU,UAAU;IACzB,OAAO;QACN,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,SAAS,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AAO,aAAa,YAAY,CAAC,YAAY,CAAC,MAAM,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;IACjH,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAe;IAC5C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACrD,MAAM,OAAO,GAAI,MAAgC,CAAC,OAAO,CAAC;IAC1D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,OAAO,SAAS,CACf,OAAO;SACL,MAAM,CAAC,CAAC,IAAI,EAA0C,EAAE;QACxD,OAAO,OAAO,CACb,IAAI;YACH,OAAO,IAAI,KAAK,QAAQ;YACvB,IAA2B,CAAC,IAAI,KAAK,MAAM;YAC5C,OAAQ,IAA2B,CAAC,IAAI,KAAK,QAAQ,CACtD,CAAC;IACH,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;SACxB,IAAI,CAAC,IAAI,CAAC;SACV,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,IAAI,EAAE,EACR,GAAG,CACH,CAAC;AACH,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { Usage } from \"@earendil-works/pi-ai\";\nimport { TASK_OUTPUT_LIMIT } from \"./constants.ts\";\nimport { boundText } from \"./text.ts\";\nimport type { SubagentUsage } from \"./types.ts\";\n\n/** The usage fields that are summed when aggregating. */\nexport const USAGE_SUM_FIELDS = [\"input\", \"output\", \"cacheRead\", \"cacheWrite\", \"totalTokens\"] as const;\n\nexport function emptyUsage(): SubagentUsage {\n\treturn {\n\t\tturns: 0,\n\t\ttoolUses: 0,\n\t\tinput: 0,\n\t\toutput: 0,\n\t\tcacheRead: 0,\n\t\tcacheWrite: 0,\n\t\ttotalTokens: 0,\n\t\tcost: 0,\n\t};\n}\n\nexport function addUsage(target: SubagentUsage, usage: Usage | undefined): void {\n\tif (!usage) return;\n\tfor (const field of USAGE_SUM_FIELDS) target[field] += usage[field] ?? 0;\n\ttarget.cost += usage.cost?.total ?? 0;\n\t// Watermark, not a sum: the latest request's total is the context size,\n\t// and it can shrink again after the worker auto-compacts.\n\tif (usage.totalTokens) target.contextTokens = usage.totalTokens;\n}\n\nexport function mergeUsage(target: SubagentUsage, source: SubagentUsage): void {\n\ttarget.turns += source.turns;\n\ttarget.toolUses += source.toolUses;\n\tfor (const field of USAGE_SUM_FIELDS) target[field] += source[field];\n\ttarget.cost += source.cost;\n\tif (source.contextTokens) {\n\t\ttarget.contextTokens = Math.max(target.contextTokens ?? 0, source.contextTokens);\n\t}\n}\n\nexport function toNestedUsage(usage: SubagentUsage): Usage {\n\treturn {\n\t\tinput: usage.input,\n\t\toutput: usage.output,\n\t\tcacheRead: usage.cacheRead,\n\t\tcacheWrite: usage.cacheWrite,\n\t\ttotalTokens: usage.totalTokens,\n\t\tcost: {\n\t\t\tinput: 0,\n\t\t\toutput: 0,\n\t\t\tcacheRead: 0,\n\t\t\tcacheWrite: 0,\n\t\t\ttotal: usage.cost,\n\t\t},\n\t};\n}\n\nexport function assistantText(message: AgentMessage | undefined): string {\n\tif (!message || message.role !== \"assistant\") return \"\";\n\treturn message.content\n\t\t.filter((part): part is { type: \"text\"; text: string } => part.type === \"text\")\n\t\t.map((part) => part.text)\n\t\t.join(\"\");\n}\n\nexport function finalAssistantText(messages: readonly AgentMessage[]): string {\n\tfor (let index = messages.length - 1; index >= 0; index--) {\n\t\tconst text = assistantText(messages[index]);\n\t\tif (text) return boundText(text, TASK_OUTPUT_LIMIT);\n\t}\n\treturn \"\";\n}\n\nexport function activitySummary(toolName: string, args: unknown): string {\n\tif (!args || typeof args !== \"object\" || Array.isArray(args)) return toolName;\n\tconst input = args as Record<string, unknown>;\n\tconst path =\n\t\ttypeof input.path === \"string\" ? input.path : typeof input.file_path === \"string\" ? input.file_path : undefined;\n\tif (toolName === \"bash\" && typeof input.command === \"string\")\n\t\treturn `Run ${boundText(input.command.replace(/\\s+/gu, \" \"), 160)}`;\n\tif (path) return `${toolName} ${boundText(path, 180)}`;\n\tif (toolName === \"grep\" && typeof input.pattern === \"string\") return `Search ${boundText(input.pattern, 120)}`;\n\tif (toolName === \"find\" && typeof input.pattern === \"string\") return `Find ${boundText(input.pattern, 120)}`;\n\treturn toolName;\n}\n\nexport function formatTokens(value: number): string {\n\tif (value < 1_000) return String(value);\n\tif (value < 1_000_000) return `${(value / 1_000).toFixed(value < 10_000 ? 1 : 0)}k`;\n\treturn `${(value / 1_000_000).toFixed(1)}M`;\n}\n\n/**\n * Activity summary for the synthetic auto-compaction entry. The before/after\n * pair is only known once a compaction succeeds; a failed or aborted one keeps\n * the neutral label and carries its reason in the entry's resultSummary.\n */\nexport function compactionSummary(tokensBefore: number | undefined, tokensAfter: number | undefined): string {\n\tif (tokensBefore && tokensAfter) return `Compacted ${formatTokens(tokensBefore)} → ${formatTokens(tokensAfter)}`;\n\treturn \"Compact context\";\n}\n\n/** Failure reason for the compaction activity; bounded like {@link resultSummary}. */\nexport function compactionError(error: string): string {\n\treturn boundText(error.replace(/\\s+/gu, \" \").trim(), 240);\n}\n\nexport function resultSummary(result: unknown): string {\n\tif (!result || typeof result !== \"object\") return \"\";\n\tconst content = (result as { content?: unknown }).content;\n\tif (!Array.isArray(content)) return \"\";\n\treturn boundText(\n\t\tcontent\n\t\t\t.filter((part): part is { type: \"text\"; text: string } => {\n\t\t\t\treturn Boolean(\n\t\t\t\t\tpart &&\n\t\t\t\t\t\ttypeof part === \"object\" &&\n\t\t\t\t\t\t(part as { type?: unknown }).type === \"text\" &&\n\t\t\t\t\t\ttypeof (part as { text?: unknown }).text === \"string\",\n\t\t\t\t);\n\t\t\t})\n\t\t\t.map((part) => part.text)\n\t\t\t.join(\"\\n\")\n\t\t\t.replace(/\\s+/gu, \" \")\n\t\t\t.trim(),\n\t\t240,\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/agents.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAGlE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EA6BjD,CAAC;AAQF,wBAAgB,uBAAuB,IAAI,MAAM,CAYhD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_AGENT_TOOLS, EXPLORER_TOOLS,
|
|
1
|
+
import { DEFAULT_AGENT_TOOLS, EXPLORER_TOOLS, MAX_TASKS } from "./constants.js";
|
|
2
2
|
// Static display titles for the two built-in profiles; this file owns the
|
|
3
3
|
// model-facing copy, and renderers/commands share these labels.
|
|
4
4
|
export const AGENT_PROFILE_LABELS = {
|
|
@@ -35,17 +35,21 @@ export const AGENT_PROFILES = [
|
|
|
35
35
|
];
|
|
36
36
|
// Static model-facing guidance: there are exactly two profiles and one
|
|
37
37
|
// tasks-array parameter shape, so the description never depends on discovery.
|
|
38
|
+
// Concurrency and result ordering live on the tasks parameter; when-to-delegate
|
|
39
|
+
// routing lives in promptGuidelines. The self-contained-briefing rule is stated
|
|
40
|
+
// here as well as on the prompt parameter because it is the failure mode workers
|
|
41
|
+
// hit most often.
|
|
38
42
|
export function subagentToolDescription() {
|
|
39
43
|
return [
|
|
40
44
|
"Delegate bounded work to isolated one-shot subagents. Workers cannot see the parent conversation: each task needs a complete self-contained briefing, and you receive only their final reports.",
|
|
41
45
|
"",
|
|
42
|
-
`Provide 1-${MAX_TASKS} independent tasks
|
|
46
|
+
`Provide 1-${MAX_TASKS} independent tasks; for sequential work, call this tool again with the previous result folded into the next briefing.`,
|
|
43
47
|
"",
|
|
44
48
|
"Agent profiles:",
|
|
45
49
|
"- explorer (default): read-only investigation — finding files, searching code, and answering codebase questions; bash is restricted to read-only inspection (git log/diff/blame, ls, cat, and similar). Never use for changes.",
|
|
46
50
|
"- general: implementation — edits, fixes, refactors, and verification in a scoped area; use when the task changes files.",
|
|
47
51
|
"",
|
|
48
|
-
"
|
|
52
|
+
"Never delegate with vague instructions: state what must be investigated or changed and the expected output.",
|
|
49
53
|
].join("\n");
|
|
50
54
|
}
|
|
51
55
|
//# sourceMappingURL=agents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../src/extensions/subagent/agents.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../src/extensions/subagent/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,SAAS,EAA0B,MAAM,gBAAgB,CAAC;AAGxG,0EAA0E;AAC1E,gEAAgE;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAsC;IACtE,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAA4B;IACtD;QACC,IAAI,EAAE,UAAU;QAChB,WAAW,EACV,4VAA4V;QAC7V,KAAK,EAAE,CAAC,GAAG,cAAc,CAAC;QAC1B,YAAY,EAAE;YACb,qFAAqF;YACrF,yDAAyD;YACzD,oIAAoI;YACpI,8GAA8G;YAC9G,wOAAwO;YACxO,sLAAsL;YACtL,mGAAmG;SACnG,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,gBAAgB,EAAE,IAAI;KACtB;IACD;QACC,IAAI,EAAE,SAAS;QACf,WAAW,EACV,kLAAkL;QACnL,KAAK,EAAE,CAAC,GAAG,mBAAmB,CAAC;QAC/B,YAAY,EAAE;YACb,gEAAgE;YAChE,iEAAiE;YACjE,2GAA2G;YAC3G,oHAAoH;SACpH,CAAC,IAAI,CAAC,IAAI,CAAC;KACZ;CACD,CAAC;AAEF,uEAAuE;AACvE,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,kBAAkB;AAClB,MAAM,UAAU,uBAAuB;IACtC,OAAO;QACN,iMAAiM;QACjM,EAAE;QACF,aAAa,SAAS,uHAAuH;QAC7I,EAAE;QACF,iBAAiB;QACjB,gOAAgO;QAChO,0HAA0H;QAC1H,EAAE;QACF,6GAA6G;KAC7G,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { DEFAULT_AGENT_TOOLS, EXPLORER_TOOLS, MAX_TASKS, type SubagentAgentName } from \"./constants.ts\";\nimport type { AgentProfile } from \"./types.ts\";\n\n// Static display titles for the two built-in profiles; this file owns the\n// model-facing copy, and renderers/commands share these labels.\nexport const AGENT_PROFILE_LABELS: Record<SubagentAgentName, string> = {\n\texplorer: \"Explorer\",\n\tgeneral: \"General\",\n};\n\nexport const AGENT_PROFILES: readonly AgentProfile[] = [\n\t{\n\t\tname: \"explorer\",\n\t\tdescription:\n\t\t\t'Fast read-only agent for finding files, searching code, and answering codebase questions. Can inspect git history (log, blame, diff) via read-only bash. State thoroughness in the prompt: \"quick\" for a targeted lookup, \"medium\" for checking likely related locations, or \"very thorough\" for exhaustive sweeps across locations and naming conventions',\n\t\ttools: [...EXPLORER_TOOLS],\n\t\tsystemPrompt: [\n\t\t\t\"You are a fast read-only exploration agent; return findings as quickly as possible.\",\n\t\t\t\"Explore the delegated question without modifying files.\",\n\t\t\t\"Use read and search tools to gather exact evidence, batching independent searches and reads instead of running them one at a time.\",\n\t\t\t\"bash is for read-only inspection only: git log/diff/blame/show/status, ls, wc, head, tail, cat, and similar.\",\n\t\t\t\"Never run anything that modifies state: no file creation or deletion, no redirect (>, >>) or heredoc writes, no temp files, no git commands that write (add, commit, checkout, restore, stash, clean), no installs, no network access.\",\n\t\t\t\"Match the depth the caller requested: quick targets the direct question, medium checks likely related locations, and very thorough sweeps multiple locations and naming conventions.\",\n\t\t\t\"Return concise findings with precise paths, symbols, relationships, and unresolved uncertainties.\",\n\t\t].join(\"\\n\"),\n\t\tomitContextFiles: true,\n\t},\n\t{\n\t\tname: \"general\",\n\t\tdescription:\n\t\t\t\"Implementation agent for bounded coding tasks: edits, fixes, refactors, and verification in a scoped area. Use when the task changes files; use explorer for read-only questions\",\n\t\ttools: [...DEFAULT_AGENT_TOOLS],\n\t\tsystemPrompt: [\n\t\t\t\"Work independently on the delegated task from start to finish.\",\n\t\t\t\"Inspect relevant repository instructions before changing files.\",\n\t\t\t\"Prefer editing existing files; never create documentation files unless the task explicitly asks for them.\",\n\t\t\t\"Keep changes focused, run appropriate verification, and report exact paths, checks, blockers, and remaining risks.\",\n\t\t].join(\"\\n\"),\n\t},\n];\n\n// Static model-facing guidance: there are exactly two profiles and one\n// tasks-array parameter shape, so the description never depends on discovery.\n// Concurrency and result ordering live on the tasks parameter; when-to-delegate\n// routing lives in promptGuidelines. The self-contained-briefing rule is stated\n// here as well as on the prompt parameter because it is the failure mode workers\n// hit most often.\nexport function subagentToolDescription(): string {\n\treturn [\n\t\t\"Delegate bounded work to isolated one-shot subagents. Workers cannot see the parent conversation: each task needs a complete self-contained briefing, and you receive only their final reports.\",\n\t\t\"\",\n\t\t`Provide 1-${MAX_TASKS} independent tasks; for sequential work, call this tool again with the previous result folded into the next briefing.`,\n\t\t\"\",\n\t\t\"Agent profiles:\",\n\t\t\"- explorer (default): read-only investigation — finding files, searching code, and answering codebase questions; bash is restricted to read-only inspection (git log/diff/blame, ls, cat, and similar). Never use for changes.\",\n\t\t\"- general: implementation — edits, fixes, refactors, and verification in a scoped area; use when the task changes files.\",\n\t\t\"\",\n\t\t\"Never delegate with vague instructions: state what must be investigated or changed and the expected output.\",\n\t].join(\"\\n\");\n}\n"]}
|
|
@@ -14,6 +14,7 @@ export declare const EXPLORER_TOOLS: readonly ["read", "grep", "find", "ls", "ba
|
|
|
14
14
|
export declare const THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
15
15
|
export declare const ACTIVITY_LIMIT = 80;
|
|
16
16
|
export declare const ACTIVITY_TEXT_LIMIT: number;
|
|
17
|
+
export declare const COMPACTION_ACTIVITY_ID = "compaction";
|
|
17
18
|
export declare const TASK_OUTPUT_LIMIT: number;
|
|
18
19
|
export declare const TOTAL_OUTPUT_LIMIT: number;
|
|
19
20
|
export declare const ERROR_TEXT_LIMIT: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,oBAAoB,kBAAkB,CAAC;AAEpD,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,eAAe,IAAI,CAAC;AAKjC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAI9C,eAAO,MAAM,oBAAoB,kCAAmC,CAAC;AACrE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAGtE,eAAO,MAAM,mBAA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,10 @@ export const THINKING_LEVELS = [
|
|
|
30
30
|
];
|
|
31
31
|
export const ACTIVITY_LIMIT = 80;
|
|
32
32
|
export const ACTIVITY_TEXT_LIMIT = 24 * 1024;
|
|
33
|
+
// Auto-compaction enters the activity log as a synthetic entry so the worker's
|
|
34
|
+
// context maintenance is visible alongside its tool calls. Only one compaction
|
|
35
|
+
// can run at a time, so a single fixed id is enough to pair start with end.
|
|
36
|
+
export const COMPACTION_ACTIVITY_ID = "compaction";
|
|
33
37
|
// Per-task ceiling for the model-facing report; the total cap below wins
|
|
34
38
|
// when the batch is large enough that a fair share would exceed it.
|
|
35
39
|
export const TASK_OUTPUT_LIMIT = 32 * 1024;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/subagent/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AAC9C,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAC;AAEpD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC,yEAAyE;AACzE,0EAA0E;AAC1E,uDAAuD;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE9C,4EAA4E;AAC5E,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,UAAU,EAAE,SAAS,CAAU,CAAC;AAGrE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAC9E,4EAA4E;AAC5E,sEAAsE;AACtE,mBAAmB;AACnB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAU,CAAC;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,KAAK;IACL,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;CACuC,CAAC;AAE9C,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AACjC,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC7C,yEAAyE;AACzE,oEAAoE;AACpE,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC3C,mEAAmE;AACnE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,CAAC;AACzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC/C,yEAAyE;AACzE,yEAAyE;AACzE,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\n\nexport const SUBAGENT_TOOL_NAME = \"subagent\";\nexport const SUBAGENT_TOOL_LABEL = \"Subagent\";\nexport const SUBAGENT_COMMAND_NAME = \"agents\";\nexport const SUBAGENT_CONFIG_VERSION = 1;\nexport const SUBAGENT_CONFIG_FILE = \"subagent.json\";\n\nexport const MAX_TASKS = 8;\nexport const MAX_CONCURRENCY = 5;\n\n// Task-level retry for failures that bypass the session's own auto-retry\n// (preflight throws such as auth checks). Only runs that produced nothing\n// are retried, so a retry never discards partial work.\nexport const TASK_RETRY_LIMIT = 2;\nexport const TASK_RETRY_BASE_DELAY_MS = 1_000;\n\n// The only selectable agents: the schema's agent field restricts task items\n// to these names, resolve.ts defaults an omitted/null agent to explorer.\nexport const SUBAGENT_AGENT_NAMES = [\"explorer\", \"general\"] as const;\nexport type SubagentAgentName = (typeof SUBAGENT_AGENT_NAMES)[number];\n\n// Matches the parent session's default toolset; bash covers search needs.\nexport const DEFAULT_AGENT_TOOLS = [\"read\", \"bash\", \"edit\", \"write\"] as const;\n// The read-only explorer profile gets the standalone search tools plus bash\n// for read-only inspection (git history, counting); the system prompt\n// constrains bash.\nexport const EXPLORER_TOOLS = [\"read\", \"grep\", \"find\", \"ls\", \"bash\"] as const;\n\nexport const THINKING_LEVELS = [\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\",\n\t\"max\",\n] as const satisfies readonly ThinkingLevel[];\n\nexport const ACTIVITY_LIMIT = 80;\nexport const ACTIVITY_TEXT_LIMIT = 24 * 1024;\n// Per-task ceiling for the model-facing report; the total cap below wins\n// when the batch is large enough that a fair share would exceed it.\nexport const TASK_OUTPUT_LIMIT = 32 * 1024;\n// Total cap for the model-facing report across every task section.\nexport const TOTAL_OUTPUT_LIMIT = 48 * 1024;\nexport const ERROR_TEXT_LIMIT = 8 * 1024;\nexport const RETRY_ERROR_TEXT_LIMIT = 160;\nexport const DETAILS_OUTPUT_LIMIT = 120 * 1024;\n// Bounded per run inside DETAILS_OUTPUT_LIMIT; each activity costs up to\n// ~600 bytes, so 12 keeps an 8-run parallel batch from starving outputs.\nexport const DETAILS_ACTIVITY_LIMIT = 12;\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/subagent/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GA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AAG,IAAI,CAAC;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,CAAC;AACzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC/C,yEAAyE;AACzE,yEAAyE;AACzE,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\n\nexport const SUBAGENT_TOOL_NAME = \"subagent\";\nexport const SUBAGENT_TOOL_LABEL = \"Subagent\";\nexport const SUBAGENT_COMMAND_NAME = \"agents\";\nexport const SUBAGENT_CONFIG_VERSION = 1;\nexport const SUBAGENT_CONFIG_FILE = \"subagent.json\";\n\nexport const MAX_TASKS = 8;\nexport const MAX_CONCURRENCY = 5;\n\n// Task-level retry for failures that bypass the session's own auto-retry\n// (preflight throws such as auth checks). Only runs that produced nothing\n// are retried, so a retry never discards partial work.\nexport const TASK_RETRY_LIMIT = 2;\nexport const TASK_RETRY_BASE_DELAY_MS = 1_000;\n\n// The only selectable agents: the schema's agent field restricts task items\n// to these names, resolve.ts defaults an omitted/null agent to explorer.\nexport const SUBAGENT_AGENT_NAMES = [\"explorer\", \"general\"] as const;\nexport type SubagentAgentName = (typeof SUBAGENT_AGENT_NAMES)[number];\n\n// Matches the parent session's default toolset; bash covers search needs.\nexport const DEFAULT_AGENT_TOOLS = [\"read\", \"bash\", \"edit\", \"write\"] as const;\n// The read-only explorer profile gets the standalone search tools plus bash\n// for read-only inspection (git history, counting); the system prompt\n// constrains bash.\nexport const EXPLORER_TOOLS = [\"read\", \"grep\", \"find\", \"ls\", \"bash\"] as const;\n\nexport const THINKING_LEVELS = [\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\",\n\t\"max\",\n] as const satisfies readonly ThinkingLevel[];\n\nexport const ACTIVITY_LIMIT = 80;\nexport const ACTIVITY_TEXT_LIMIT = 24 * 1024;\n// Auto-compaction enters the activity log as a synthetic entry so the worker's\n// context maintenance is visible alongside its tool calls. Only one compaction\n// can run at a time, so a single fixed id is enough to pair start with end.\nexport const COMPACTION_ACTIVITY_ID = \"compaction\";\n// Per-task ceiling for the model-facing report; the total cap below wins\n// when the batch is large enough that a fair share would exceed it.\nexport const TASK_OUTPUT_LIMIT = 32 * 1024;\n// Total cap for the model-facing report across every task section.\nexport const TOTAL_OUTPUT_LIMIT = 48 * 1024;\nexport const ERROR_TEXT_LIMIT = 8 * 1024;\nexport const RETRY_ERROR_TEXT_LIMIT = 160;\nexport const DETAILS_OUTPUT_LIMIT = 120 * 1024;\n// Bounded per run inside DETAILS_OUTPUT_LIMIT; each activity costs up to\n// ~600 bytes, so 12 keeps an 8-run parallel batch from starving outputs.\nexport const DETAILS_ACTIVITY_LIMIT = 12;\n"]}
|