@bastani/atomic 0.9.55 → 0.9.56

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.
Files changed (98) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +12 -0
  3. package/dist/builtin/intercom/index.bundle.mjs +2 -1
  4. package/dist/builtin/intercom/package.json +1 -1
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/package.json +1 -1
  7. package/dist/builtin/web-access/package.json +1 -1
  8. package/dist/builtin/workflows/package.json +1 -1
  9. package/dist/cli/args.d.ts.map +1 -1
  10. package/dist/cli/args.js +4 -3
  11. package/dist/cli/args.js.map +1 -1
  12. package/dist/config-self-update.d.ts +1 -0
  13. package/dist/config-self-update.d.ts.map +1 -1
  14. package/dist/config-self-update.js +7 -7
  15. package/dist/config-self-update.js.map +1 -1
  16. package/dist/config.d.ts +13 -0
  17. package/dist/config.d.ts.map +1 -1
  18. package/dist/config.js +23 -1
  19. package/dist/config.js.map +1 -1
  20. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  21. package/dist/core/export-html/tool-renderer.js +3 -0
  22. package/dist/core/export-html/tool-renderer.js.map +1 -1
  23. package/dist/core/extensions/index.d.ts +1 -1
  24. package/dist/core/extensions/index.d.ts.map +1 -1
  25. package/dist/core/extensions/index.js.map +1 -1
  26. package/dist/core/extensions/message-types.d.ts +3 -2
  27. package/dist/core/extensions/message-types.d.ts.map +1 -1
  28. package/dist/core/extensions/message-types.js.map +1 -1
  29. package/dist/core/extensions/tool-types.d.ts +2 -1
  30. package/dist/core/extensions/tool-types.d.ts.map +1 -1
  31. package/dist/core/extensions/tool-types.js.map +1 -1
  32. package/dist/core/extensions/ui-types.d.ts +12 -1
  33. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  34. package/dist/core/extensions/ui-types.js.map +1 -1
  35. package/dist/core/settings-schema.d.ts +1 -0
  36. package/dist/core/settings-schema.d.ts.map +1 -1
  37. package/dist/core/settings-schema.js +4 -0
  38. package/dist/core/settings-schema.js.map +1 -1
  39. package/dist/core/slash-commands.js +1 -1
  40. package/dist/core/slash-commands.js.map +1 -1
  41. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  42. package/dist/extensions/mcp/cli.js +27 -8
  43. package/dist/extensions/mcp/cli.js.map +1 -1
  44. package/dist/extensions/tool-search/tool.d.ts +21 -3
  45. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  46. package/dist/extensions/tool-search/tool.js +88 -35
  47. package/dist/extensions/tool-search/tool.js.map +1 -1
  48. package/dist/index-extensions.d.ts +1 -1
  49. package/dist/index-extensions.d.ts.map +1 -1
  50. package/dist/index-extensions.js.map +1 -1
  51. package/dist/modes/interactive/chat-input-actions.d.ts +2 -0
  52. package/dist/modes/interactive/chat-input-actions.d.ts.map +1 -1
  53. package/dist/modes/interactive/chat-input-actions.js +4 -1
  54. package/dist/modes/interactive/chat-input-actions.js.map +1 -1
  55. package/dist/modes/interactive/components/chat-session-host-editor.js +1 -0
  56. package/dist/modes/interactive/components/chat-session-host-editor.js.map +1 -1
  57. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  58. package/dist/modes/interactive/components/custom-entry.js +2 -1
  59. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  60. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  61. package/dist/modes/interactive/components/custom-message.js +2 -1
  62. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  63. package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
  64. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  65. package/dist/modes/interactive/components/extension-editor.js +4 -0
  66. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  67. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  68. package/dist/modes/interactive/components/tool-execution.js +3 -1
  69. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  70. package/dist/modes/interactive/external-editor.d.ts +1 -0
  71. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  72. package/dist/modes/interactive/external-editor.js +15 -5
  73. package/dist/modes/interactive/external-editor.js.map +1 -1
  74. package/dist/modes/interactive/interactive-editor-actions.js +1 -0
  75. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  76. package/dist/package-manager-cli.d.ts.map +1 -1
  77. package/dist/package-manager-cli.js +46 -2
  78. package/dist/package-manager-cli.js.map +1 -1
  79. package/dist/utils/clipboard-image.d.ts.map +1 -1
  80. package/dist/utils/clipboard-image.js +2 -0
  81. package/dist/utils/clipboard-image.js.map +1 -1
  82. package/dist/utils/clipboard.d.ts.map +1 -1
  83. package/dist/utils/clipboard.js +10 -0
  84. package/dist/utils/clipboard.js.map +1 -1
  85. package/dist/utils/open-browser.d.ts.map +1 -1
  86. package/dist/utils/open-browser.js +3 -1
  87. package/dist/utils/open-browser.js.map +1 -1
  88. package/docs/environment-variables.md +1 -0
  89. package/docs/extensions/authoring.md +10 -11
  90. package/docs/extensions/ui.md +2 -0
  91. package/docs/mcp-servers.md +3 -3
  92. package/docs/reference/cli.md +15 -3
  93. package/docs/sessions.md +10 -0
  94. package/docs/settings.md +1 -0
  95. package/examples/extensions/debug-provider.ts +2 -2
  96. package/npm-shrinkwrap.json +32 -32
  97. package/package.json +3 -3
  98. package/schemas/settings.schema.json +8 -0
@@ -1 +1 @@
1
- {"version":3,"file":"slash-commands.js","sourceRoot":"","sources":["../../src/core/slash-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA8BxC,MAAM,0BAA0B,GAAuB;IACtD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,mCAAmC,EAAE;IACzF,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,yCAAyC,EAAE;IAC7F,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE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";\nimport type { SourceInfo } from \"./source-info.ts\";\n\nexport type SlashCommandSource = \"extension\" | \"prompt\" | \"skill\";\n\nexport interface SlashCommandInfo {\n\tname: string;\n\tdescription?: string;\n\tsource: SlashCommandSource;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface BuiltinSlashCommand {\n\tname: string;\n\tdescription: string;\n\targumentHint?: string;\n\tgetArgumentCompletions?: (argumentPrefix: string) => AutocompleteItem[] | null | Promise<AutocompleteItem[] | null>;\n}\n\ntype WorkflowInputCompletionMetadata = {\n\tdescription: string;\n\tkind?: \"boolean\" | \"number\" | \"string\";\n};\n\ntype WorkflowCompletionMetadata = {\n\tname: string;\n\tdescription: string;\n\tinputs: Record<string, WorkflowInputCompletionMetadata>;\n};\n\nconst WORKFLOW_ADMIN_COMPLETIONS: AutocompleteItem[] = [\n\t{ value: \"connect \", label: \"connect\", description: \"Attach to a run (picker if no id)\" },\n\t{ value: \"attach \", label: \"attach\", description: \"Open the in-place attach pane on a node\" },\n\t{ value: \"list \", label: \"list\", description: \"List registered workflows\" },\n\t{ value: \"status \", label: \"status\", description: \"List current-session active and retained terminal runs\" },\n\t{ value: \"pause \", label: \"pause\", description: \"Pause a run\" },\n\t{ value: \"quit \", label: \"quit\", description: \"Quit a run and keep it resumable\" },\n\t{ value: \"resume \", label: \"resume\", description: \"Re-open overlay for a run\" },\n\t{ value: \"inputs \", label: \"inputs\", description: \"Show a workflow's input schema\" },\n\t{ value: \"reload \", label: \"reload\", description: \"Reload workflow resources\" },\n];\n\nconst BUNDLED_WORKFLOW_COMPLETION_METADATA: WorkflowCompletionMetadata[] = [\n\t{\n\t\tname: \"adversarial-verification\",\n\t\tdescription:\n\t\t\t\"Produce a candidate, score independent per-criterion verifier reports, and apply a deterministic mean-and-veto gate with bounded repairs.\",\n\t\tinputs: {\n\t\t\ttask: { description: \"Task whose candidate result must be independently verified.\", kind: \"string\" },\n\t\t\tverifier_count: {\n\t\t\t\tdescription: \"Number of independent verifiers for each criterion per round.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tmax_repairs: { description: \"Maximum candidate repair rounds before rejection.\", kind: \"number\" },\n\t\t\tcriteria: { description: \"Criteria record of name-to-description entries, or criteria.md markdown.\" },\n\t\t\taccept_mean: {\n\t\t\t\tdescription: \"Mean score required for acceptance on the 1–20 verification scale.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\treask_limit: { description: \"Maximum bounded re-ask waves for invalid criterion reports.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"classify-and-act\",\n\t\tdescription:\n\t\t\t\"Classify a task with structured confidence, route deterministically to an isolated category action, and ask for human selection when confidence is low.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Task to classify and execute.\", kind: \"string\" },\n\t\t\tcategories: { description: \"Ordered action categories available to the classifier and fallback chooser.\" },\n\t\t\tconfidence_threshold: {\n\t\t\t\tdescription: \"Minimum structured confidence required to route without human selection.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"fan-out-and-synthesize\",\n\t\tdescription:\n\t\t\t\"Partition a task, run bounded independent artifact branches, then synthesize all evidence at an explicit barrier.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Task to partition, investigate, and synthesize.\", kind: \"string\" },\n\t\t\tmax_branches: {\n\t\t\t\tdescription: \"Maximum number of independent partitions produced and executed.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tmax_concurrency: { description: \"Maximum number of branch agents running concurrently.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"generate-and-filter\",\n\t\tdescription:\n\t\t\t\"Generate more independent candidates than needed, deduplicate and filter them by rubric, optionally judge them, and return a parent-consumable shortlist.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Prompt for candidate generation and selection.\", kind: \"string\" },\n\t\t\tnum_candidates: { description: \"Number of independent candidates to generate.\", kind: \"number\" },\n\t\t\tshortlist_size: { description: \"Maximum number of candidates in the final shortlist.\", kind: \"number\" },\n\t\t\tuse_judge: { description: \"Whether an independent judge reviews the filtered shortlist.\", kind: \"boolean\" },\n\t\t\tmax_concurrency: { description: \"Maximum simultaneous generator stages.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"goal\",\n\t\tdescription:\n\t\t\t\"Goal Runner workflow with bounded sub-agent orchestration turns, immutable acceptance criteria, ledger artifacts, parallel reviewers, and reducer-gated completion. When launching follow-up goal runs from review findings, pass the ORIGINAL task text as acceptance_criteria so deltas cannot drift from the literal contract. If the task includes submitting a pull request (or MR/review), remove that final action from the objective text and set create_pr=true instead when preparing the workflow inputs.\",\n\t\tinputs: {\n\t\t\tobjective: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"The objective or delta for this Goal Runner workflow run. Do not include PR/MR submission instructions here; strip them from the task text and request them via create_pr=true instead.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tacceptance_criteria: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Original immutable task contract this run must remain consistent with. Defaults to objective. Orchestrators launching follow-up runs from reviewer findings should pass the ORIGINAL task text here.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tmax_turns: {\n\t\t\t\tdescription: \"Maximum orchestrator/review turns before Goal Runner stops as needs_human.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tbase_branch: {\n\t\t\t\tdescription: \"Optional branch reviewers compare the current code delta against (default origin/main).\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tgit_worktree_dir: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional Git worktree path. Leave at the default unless the user explicitly requested worktree isolation — stages never create git worktrees on their own. Must start inside a Git repo; absolute paths are used as-is, relative paths resolve from the repo root, existing Git worktrees from the invoking repository are reused/shared as-is, and missing paths are created from base_branch.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tcreate_pr: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Whether to run the final pull-request creation stage after reviewer/reducer approval. Defaults to false; prompt text alone does not opt in. If the task asks to submit a PR/MR/review, remove that from the objective text and set this to true — only the final stage then attempts provider-appropriate PR/MR/review creation after Goal completes.\",\n\t\t\t\tkind: \"boolean\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"loop-until-done\",\n\t\tdescription:\n\t\t\t\"Repeat evidence-producing work and independent completion evaluation against a durable ledger until done or an inspectable iteration-limit failure.\",\n\t\tinputs: {\n\t\t\tprompt: {\n\t\t\t\tdescription: \"Objective whose explicit completion condition controls the bounded loop.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tmax_iterations: {\n\t\t\t\tdescription: \"Maximum work/evaluation iterations before returning an inspectable failed status (1-20).\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tprogress_scoring: {\n\t\t\t\tdescription: \"Enable advisory progress scoring after each completed iteration.\",\n\t\t\t\tkind: \"boolean\",\n\t\t\t},\n\t\t\tprogress_repeats: {\n\t\t\t\tdescription: \"Number of advisory progress-scoring repeats per iteration.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"open-claude-design\",\n\t\tdescription:\n\t\t\t\"AI-powered design workflow: combined discovery/init → design-system/reference research → curated reference discovery → HTML generation → one live review session → rich HTML handoff. The discovery stage asks what to build, the output type, and which references to emulate, then runs impeccable init for PRODUCT.md/DESIGN.md (references take precedence over project context). The user reviews the generated HTML in one live session.\",\n\t\tinputs: {\n\t\t\tprompt: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"What to design (for example, a dashboard, page, component, or prototype). The discovery stage refines this into a confirmed brief and asks for the output type and references.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tdiscover_references: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Discover beautiful, current reference designs from notable design websites (Awwwards, recent.design, Dribbble, Monet, Motionsites) and feed them to generation. Set false to skip the network/browser reference pass.\",\n\t\t\t\tkind: \"boolean\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"ralph\",\n\t\tdescription:\n\t\t\t\"Raw prompt → research-prompt-refinement → research → orchestrate → multi-model parallel review loop with bounded iteration and immutable acceptance criteria. When launching follow-up ralph runs from review findings, pass the ORIGINAL task text as acceptance_criteria so deltas cannot drift from the literal contract. If the task includes submitting a pull request (or MR/review), remove that final action from the prompt text and set create_pr=true instead when preparing the workflow inputs.\",\n\t\tinputs: {\n\t\t\tprompt: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"The task or goal to research, execute, and refine. Do not include PR/MR submission instructions here; strip them from the task text and request them via create_pr=true instead.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tacceptance_criteria: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Original immutable task contract this run must remain consistent with. Defaults to prompt. Orchestrators launching follow-up runs from reviewer findings should pass the ORIGINAL task text here.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tmax_loops: { description: \"Maximum research/orchestrate/review iterations (default 10).\", kind: \"number\" },\n\t\t\tbase_branch: {\n\t\t\t\tdescription: \"Branch reviewers compare the current code delta against (default origin/main).\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tgit_worktree_dir: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional Git worktree path. Leave at the default unless the user explicitly requested worktree isolation — stages never create git worktrees on their own. Must start inside a Git repo; absolute paths are used as-is, relative paths resolve from the repo root, existing Git worktrees from the invoking repository are reused/shared as-is, and missing paths are created from base_branch.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tcreate_pr: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Whether to run the final pull-request creation stage. Defaults to false; prompt text alone does not opt in. If the task asks to submit a PR/MR/review, remove that from the prompt text and set this to true — only the final stage then attempts provider-appropriate PR/MR/review creation.\",\n\t\t\t\tkind: \"boolean\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"tournament\",\n\t\tdescription:\n\t\t\t\"Run independent whole-task attempts through a soft-scored pivot-pairing schedule and return an auditable ranking.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Task every competing agent must attempt independently.\", kind: \"string\" },\n\t\t\tnum_attempts: { description: \"Number of independent whole-task attempts (2-8).\", kind: \"number\" },\n\t\t\tmax_concurrency: {\n\t\t\t\tdescription: \"Maximum simultaneously active attempts or pairwise judges (1-8).\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tn_evaluations: {\n\t\t\t\tdescription: \"Number of repeated evaluations per criterion and directed pair.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tpivots: {\n\t\t\t\tdescription: \"Number of pivot candidates used for the second comparison phase.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tseed: { description: \"Seed for the deterministic comparison schedule.\", kind: \"number\" },\n\t\t\tcriteria: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional V1 judge criteria; accepts a markdown rubric, record, string list, or CriterionInput list; omitted uses the default three-criterion rubric.\",\n\t\t\t},\n\t\t\tmodels: { description: \"Optional ordered model ids assigned round-robin to attempt slots.\" },\n\t\t},\n\t},\n];\n\nfunction completeWorkflowToken(argumentText: string, candidates: AutocompleteItem[]): AutocompleteItem[] | null {\n\tconst tokenStart = /\\s$/.test(argumentText)\n\t\t? argumentText.length\n\t\t: Math.max(argumentText.lastIndexOf(\" \"), argumentText.lastIndexOf(\"\\t\")) + 1;\n\tconst head = argumentText.slice(0, tokenStart);\n\tconst token = argumentText.slice(tokenStart);\n\tconst normalizedToken = token.trimEnd();\n\tconst filtered = candidates\n\t\t.filter((candidate) => candidate.value.startsWith(token) && candidate.value.trimEnd() !== normalizedToken)\n\t\t.map((candidate) => ({ ...candidate, value: `${head}${candidate.value}` }));\n\treturn filtered.length > 0 ? filtered : null;\n}\n\nfunction bundledWorkflowNameItems(): AutocompleteItem[] {\n\treturn BUNDLED_WORKFLOW_COMPLETION_METADATA.map((workflow) => ({\n\t\tvalue: `${workflow.name} `,\n\t\tlabel: workflow.name,\n\t\tdescription: `Run workflow: ${workflow.name}`,\n\t}));\n}\n\nexport function getBundledWorkflowArgumentCompletions(argumentPrefix: string): AutocompleteItem[] | null {\n\tconst parts = argumentPrefix.trim().split(/\\s+/).filter(Boolean);\n\tconst subcommand = parts[0] ?? \"\";\n\tconst workflowItems = bundledWorkflowNameItems();\n\tif (!argumentPrefix.includes(\" \")) {\n\t\treturn completeWorkflowToken(argumentPrefix, [...WORKFLOW_ADMIN_COMPLETIONS, ...workflowItems]);\n\t}\n\tif (subcommand === \"inputs\") return completeWorkflowToken(argumentPrefix, workflowItems);\n\tif (subcommand === \"pause\") {\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: \"--all \", label: \"--all\", description: \"Pause all in-flight runs\" },\n\t\t\t{ value: \"--yes \", label: \"--yes\", description: \"Skip confirmation\" },\n\t\t\t{ value: \"-y \", label: \"-y\", description: \"Skip confirmation\" },\n\t\t]);\n\t}\n\tif (subcommand === \"quit\") {\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: \"--all \", label: \"--all\", description: \"Quit and keep all in-flight runs resumable\" },\n\t\t]);\n\t}\n\tif (!subcommand) return completeWorkflowToken(argumentPrefix, [...WORKFLOW_ADMIN_COMPLETIONS, ...workflowItems]);\n\n\tconst workflow = BUNDLED_WORKFLOW_COMPLETION_METADATA.find((candidate) => candidate.name === subcommand);\n\tif (!workflow) return null;\n\tconst tokenStart = /\\s$/.test(argumentPrefix)\n\t\t? argumentPrefix.length\n\t\t: Math.max(argumentPrefix.lastIndexOf(\" \"), argumentPrefix.lastIndexOf(\"\\t\")) + 1;\n\tconst token = argumentPrefix.slice(tokenStart);\n\tconst equalsIndex = token.indexOf(\"=\");\n\tif (equalsIndex > 0) {\n\t\tconst inputName = token.slice(0, equalsIndex);\n\t\tconst input = workflow.inputs[inputName];\n\t\tif (input?.kind !== \"boolean\") return null;\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: `${inputName}=true `, label: \"true\", description: inputName },\n\t\t\t{ value: `${inputName}=false `, label: \"false\", description: inputName },\n\t\t]);\n\t}\n\n\treturn completeWorkflowToken(argumentPrefix, [\n\t\t{ value: \"--no-picker \", label: \"--no-picker\", description: \"Skip interactive input picker\" },\n\t\t{ value: \"--help \", label: \"--help\", description: \"Show this workflow's input schema\" },\n\t\t...Object.entries(workflow.inputs).map(([name, input]) => ({\n\t\t\tvalue: `${name}=`,\n\t\t\tlabel: name,\n\t\t\tdescription: input.description,\n\t\t})),\n\t]);\n}\n\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"settings\", description: \"Open settings menu\" },\n\t{ name: \"model\", description: \"Select model (opens selector UI)\", argumentHint: \"<provider/model>\" },\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\n\t{ name: \"thinking\", description: \"Set thinking level\", argumentHint: \"<level>\" },\n\t{ name: \"scoped-models\", description: \"Enable/disable models for ctrl+p cycling\" },\n\t{ name: \"export\", description: \"Export session (HTML default, or specify path: .html/.jsonl)\" },\n\t{ name: \"import\", description: \"Import and resume a session from a JSONL file\" },\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\n\t{ name: \"name\", description: \"Set session display name\" },\n\t{ name: \"session\", description: \"Show session info and stats\" },\n\t{ name: \"tools\", description: \"Show which tools are active, inactive (and why), or missing\" },\n\t{ name: \"tasks\", description: \"Inspect agents and shells, view output, and manage running tasks\" },\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\n\t{ name: \"fork\", description: \"Create a new fork from a previous user message\" },\n\t{ name: \"clone\", description: \"Duplicate the current session at the current position\" },\n\t{ name: \"trust\", description: \"Save project trust decision for future sessions\" },\n\t{ name: \"login\", description: \"Configure provider authentication\", argumentHint: \"<provider>\" },\n\t{ name: \"logout\", description: \"Remove provider authentication\", argumentHint: \"<provider>\" },\n\t{ name: \"new\", description: \"Start a new session\" },\n\t{ name: \"compact\", description: \"Compact older context with verbatim line ranges\" },\n\t{ name: \"resume\", description: \"Resume a different session\" },\n\t{ name: \"reload\", description: \"Reload keybindings, extensions, skills, prompts, and themes\" },\n\t{ name: \"exit\", description: `Exit ${APP_NAME}` },\n\t{ name: \"quit\", description: `Quit ${APP_NAME}` },\n];\n\nexport const BUNDLED_EXTENSION_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"agents\", description: \"Browse available subagents and inspect their configuration\" },\n\t{\n\t\tname: \"workflow\",\n\t\tdescription:\n\t\t\t\"Run or inspect Atomic workflows. Usage: /workflow <name> [key=value…] | /workflow [list|status|connect|attach|quit|pause|resume|inputs|reload] [args]\",\n\t\tgetArgumentCompletions: getBundledWorkflowArgumentCompletions,\n\t},\n\t{ name: \"mcp\", description: \"Show MCP server status\" },\n\t{ name: \"mcp-auth\", description: \"Authenticate with an MCP server (OAuth)\" },\n\t{ name: \"curator\", description: \"Toggle or configure the search curator workflow\" },\n\t{ name: \"google-account\", description: \"Show the active Google account for Gemini Web\" },\n\t{ name: \"search\", description: \"Browse stored web search results\" },\n\t{ name: \"websearch\", description: \"Open web search curator\" },\n\t{ name: \"intercom\", description: \"Open session intercom overlay\" },\n];\n"]}
1
+ {"version":3,"file":"slash-commands.js","sourceRoot":"","sources":["../../src/core/slash-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA8BxC,MAAM,0BAA0B,GAAuB;IACtD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,mCAAmC,EAAE;IACzF,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,yCAAyC,EAAE;IAC7F,EAAE,KAAK,E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\";\nimport { APP_NAME } from \"../config.js\";\nimport type { SourceInfo } from \"./source-info.ts\";\n\nexport type SlashCommandSource = \"extension\" | \"prompt\" | \"skill\";\n\nexport interface SlashCommandInfo {\n\tname: string;\n\tdescription?: string;\n\tsource: SlashCommandSource;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface BuiltinSlashCommand {\n\tname: string;\n\tdescription: string;\n\targumentHint?: string;\n\tgetArgumentCompletions?: (argumentPrefix: string) => AutocompleteItem[] | null | Promise<AutocompleteItem[] | null>;\n}\n\ntype WorkflowInputCompletionMetadata = {\n\tdescription: string;\n\tkind?: \"boolean\" | \"number\" | \"string\";\n};\n\ntype WorkflowCompletionMetadata = {\n\tname: string;\n\tdescription: string;\n\tinputs: Record<string, WorkflowInputCompletionMetadata>;\n};\n\nconst WORKFLOW_ADMIN_COMPLETIONS: AutocompleteItem[] = [\n\t{ value: \"connect \", label: \"connect\", description: \"Attach to a run (picker if no id)\" },\n\t{ value: \"attach \", label: \"attach\", description: \"Open the in-place attach pane on a node\" },\n\t{ value: \"list \", label: \"list\", description: \"List registered workflows\" },\n\t{ value: \"status \", label: \"status\", description: \"List current-session active and retained terminal runs\" },\n\t{ value: \"pause \", label: \"pause\", description: \"Pause a run\" },\n\t{ value: \"quit \", label: \"quit\", description: \"Quit a run and keep it resumable\" },\n\t{ value: \"resume \", label: \"resume\", description: \"Re-open overlay for a run\" },\n\t{ value: \"inputs \", label: \"inputs\", description: \"Show a workflow's input schema\" },\n\t{ value: \"reload \", label: \"reload\", description: \"Reload workflow resources\" },\n];\n\nconst BUNDLED_WORKFLOW_COMPLETION_METADATA: WorkflowCompletionMetadata[] = [\n\t{\n\t\tname: \"adversarial-verification\",\n\t\tdescription:\n\t\t\t\"Produce a candidate, score independent per-criterion verifier reports, and apply a deterministic mean-and-veto gate with bounded repairs.\",\n\t\tinputs: {\n\t\t\ttask: { description: \"Task whose candidate result must be independently verified.\", kind: \"string\" },\n\t\t\tverifier_count: {\n\t\t\t\tdescription: \"Number of independent verifiers for each criterion per round.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tmax_repairs: { description: \"Maximum candidate repair rounds before rejection.\", kind: \"number\" },\n\t\t\tcriteria: { description: \"Criteria record of name-to-description entries, or criteria.md markdown.\" },\n\t\t\taccept_mean: {\n\t\t\t\tdescription: \"Mean score required for acceptance on the 1–20 verification scale.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\treask_limit: { description: \"Maximum bounded re-ask waves for invalid criterion reports.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"classify-and-act\",\n\t\tdescription:\n\t\t\t\"Classify a task with structured confidence, route deterministically to an isolated category action, and ask for human selection when confidence is low.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Task to classify and execute.\", kind: \"string\" },\n\t\t\tcategories: { description: \"Ordered action categories available to the classifier and fallback chooser.\" },\n\t\t\tconfidence_threshold: {\n\t\t\t\tdescription: \"Minimum structured confidence required to route without human selection.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"fan-out-and-synthesize\",\n\t\tdescription:\n\t\t\t\"Partition a task, run bounded independent artifact branches, then synthesize all evidence at an explicit barrier.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Task to partition, investigate, and synthesize.\", kind: \"string\" },\n\t\t\tmax_branches: {\n\t\t\t\tdescription: \"Maximum number of independent partitions produced and executed.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tmax_concurrency: { description: \"Maximum number of branch agents running concurrently.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"generate-and-filter\",\n\t\tdescription:\n\t\t\t\"Generate more independent candidates than needed, deduplicate and filter them by rubric, optionally judge them, and return a parent-consumable shortlist.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Prompt for candidate generation and selection.\", kind: \"string\" },\n\t\t\tnum_candidates: { description: \"Number of independent candidates to generate.\", kind: \"number\" },\n\t\t\tshortlist_size: { description: \"Maximum number of candidates in the final shortlist.\", kind: \"number\" },\n\t\t\tuse_judge: { description: \"Whether an independent judge reviews the filtered shortlist.\", kind: \"boolean\" },\n\t\t\tmax_concurrency: { description: \"Maximum simultaneous generator stages.\", kind: \"number\" },\n\t\t},\n\t},\n\t{\n\t\tname: \"goal\",\n\t\tdescription:\n\t\t\t\"Goal Runner workflow with bounded sub-agent orchestration turns, immutable acceptance criteria, ledger artifacts, parallel reviewers, and reducer-gated completion. When launching follow-up goal runs from review findings, pass the ORIGINAL task text as acceptance_criteria so deltas cannot drift from the literal contract. If the task includes submitting a pull request (or MR/review), remove that final action from the objective text and set create_pr=true instead when preparing the workflow inputs.\",\n\t\tinputs: {\n\t\t\tobjective: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"The objective or delta for this Goal Runner workflow run. Do not include PR/MR submission instructions here; strip them from the task text and request them via create_pr=true instead.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tacceptance_criteria: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Original immutable task contract this run must remain consistent with. Defaults to objective. Orchestrators launching follow-up runs from reviewer findings should pass the ORIGINAL task text here.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tmax_turns: {\n\t\t\t\tdescription: \"Maximum orchestrator/review turns before Goal Runner stops as needs_human.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tbase_branch: {\n\t\t\t\tdescription: \"Optional branch reviewers compare the current code delta against (default origin/main).\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tgit_worktree_dir: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional Git worktree path. Leave at the default unless the user explicitly requested worktree isolation — stages never create git worktrees on their own. Must start inside a Git repo; absolute paths are used as-is, relative paths resolve from the repo root, existing Git worktrees from the invoking repository are reused/shared as-is, and missing paths are created from base_branch.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tcreate_pr: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Whether to run the final pull-request creation stage after reviewer/reducer approval. Defaults to false; prompt text alone does not opt in. If the task asks to submit a PR/MR/review, remove that from the objective text and set this to true — only the final stage then attempts provider-appropriate PR/MR/review creation after Goal completes.\",\n\t\t\t\tkind: \"boolean\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"loop-until-done\",\n\t\tdescription:\n\t\t\t\"Repeat evidence-producing work and independent completion evaluation against a durable ledger until done or an inspectable iteration-limit failure.\",\n\t\tinputs: {\n\t\t\tprompt: {\n\t\t\t\tdescription: \"Objective whose explicit completion condition controls the bounded loop.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tmax_iterations: {\n\t\t\t\tdescription: \"Maximum work/evaluation iterations before returning an inspectable failed status (1-20).\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tprogress_scoring: {\n\t\t\t\tdescription: \"Enable advisory progress scoring after each completed iteration.\",\n\t\t\t\tkind: \"boolean\",\n\t\t\t},\n\t\t\tprogress_repeats: {\n\t\t\t\tdescription: \"Number of advisory progress-scoring repeats per iteration.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"open-claude-design\",\n\t\tdescription:\n\t\t\t\"AI-powered design workflow: combined discovery/init → design-system/reference research → curated reference discovery → HTML generation → one live review session → rich HTML handoff. The discovery stage asks what to build, the output type, and which references to emulate, then runs impeccable init for PRODUCT.md/DESIGN.md (references take precedence over project context). The user reviews the generated HTML in one live session.\",\n\t\tinputs: {\n\t\t\tprompt: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"What to design (for example, a dashboard, page, component, or prototype). The discovery stage refines this into a confirmed brief and asks for the output type and references.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tdiscover_references: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Discover beautiful, current reference designs from notable design websites (Awwwards, recent.design, Dribbble, Monet, Motionsites) and feed them to generation. Set false to skip the network/browser reference pass.\",\n\t\t\t\tkind: \"boolean\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"ralph\",\n\t\tdescription:\n\t\t\t\"Raw prompt → research-prompt-refinement → research → orchestrate → multi-model parallel review loop with bounded iteration and immutable acceptance criteria. When launching follow-up ralph runs from review findings, pass the ORIGINAL task text as acceptance_criteria so deltas cannot drift from the literal contract. If the task includes submitting a pull request (or MR/review), remove that final action from the prompt text and set create_pr=true instead when preparing the workflow inputs.\",\n\t\tinputs: {\n\t\t\tprompt: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"The task or goal to research, execute, and refine. Do not include PR/MR submission instructions here; strip them from the task text and request them via create_pr=true instead.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tacceptance_criteria: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Original immutable task contract this run must remain consistent with. Defaults to prompt. Orchestrators launching follow-up runs from reviewer findings should pass the ORIGINAL task text here.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tmax_loops: { description: \"Maximum research/orchestrate/review iterations (default 10).\", kind: \"number\" },\n\t\t\tbase_branch: {\n\t\t\t\tdescription: \"Branch reviewers compare the current code delta against (default origin/main).\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tgit_worktree_dir: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional Git worktree path. Leave at the default unless the user explicitly requested worktree isolation — stages never create git worktrees on their own. Must start inside a Git repo; absolute paths are used as-is, relative paths resolve from the repo root, existing Git worktrees from the invoking repository are reused/shared as-is, and missing paths are created from base_branch.\",\n\t\t\t\tkind: \"string\",\n\t\t\t},\n\t\t\tcreate_pr: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Whether to run the final pull-request creation stage. Defaults to false; prompt text alone does not opt in. If the task asks to submit a PR/MR/review, remove that from the prompt text and set this to true — only the final stage then attempts provider-appropriate PR/MR/review creation.\",\n\t\t\t\tkind: \"boolean\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tname: \"tournament\",\n\t\tdescription:\n\t\t\t\"Run independent whole-task attempts through a soft-scored pivot-pairing schedule and return an auditable ranking.\",\n\t\tinputs: {\n\t\t\tprompt: { description: \"Task every competing agent must attempt independently.\", kind: \"string\" },\n\t\t\tnum_attempts: { description: \"Number of independent whole-task attempts (2-8).\", kind: \"number\" },\n\t\t\tmax_concurrency: {\n\t\t\t\tdescription: \"Maximum simultaneously active attempts or pairwise judges (1-8).\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tn_evaluations: {\n\t\t\t\tdescription: \"Number of repeated evaluations per criterion and directed pair.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tpivots: {\n\t\t\t\tdescription: \"Number of pivot candidates used for the second comparison phase.\",\n\t\t\t\tkind: \"number\",\n\t\t\t},\n\t\t\tseed: { description: \"Seed for the deterministic comparison schedule.\", kind: \"number\" },\n\t\t\tcriteria: {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional V1 judge criteria; accepts a markdown rubric, record, string list, or CriterionInput list; omitted uses the default three-criterion rubric.\",\n\t\t\t},\n\t\t\tmodels: { description: \"Optional ordered model ids assigned round-robin to attempt slots.\" },\n\t\t},\n\t},\n];\n\nfunction completeWorkflowToken(argumentText: string, candidates: AutocompleteItem[]): AutocompleteItem[] | null {\n\tconst tokenStart = /\\s$/.test(argumentText)\n\t\t? argumentText.length\n\t\t: Math.max(argumentText.lastIndexOf(\" \"), argumentText.lastIndexOf(\"\\t\")) + 1;\n\tconst head = argumentText.slice(0, tokenStart);\n\tconst token = argumentText.slice(tokenStart);\n\tconst normalizedToken = token.trimEnd();\n\tconst filtered = candidates\n\t\t.filter((candidate) => candidate.value.startsWith(token) && candidate.value.trimEnd() !== normalizedToken)\n\t\t.map((candidate) => ({ ...candidate, value: `${head}${candidate.value}` }));\n\treturn filtered.length > 0 ? filtered : null;\n}\n\nfunction bundledWorkflowNameItems(): AutocompleteItem[] {\n\treturn BUNDLED_WORKFLOW_COMPLETION_METADATA.map((workflow) => ({\n\t\tvalue: `${workflow.name} `,\n\t\tlabel: workflow.name,\n\t\tdescription: `Run workflow: ${workflow.name}`,\n\t}));\n}\n\nexport function getBundledWorkflowArgumentCompletions(argumentPrefix: string): AutocompleteItem[] | null {\n\tconst parts = argumentPrefix.trim().split(/\\s+/).filter(Boolean);\n\tconst subcommand = parts[0] ?? \"\";\n\tconst workflowItems = bundledWorkflowNameItems();\n\tif (!argumentPrefix.includes(\" \")) {\n\t\treturn completeWorkflowToken(argumentPrefix, [...WORKFLOW_ADMIN_COMPLETIONS, ...workflowItems]);\n\t}\n\tif (subcommand === \"inputs\") return completeWorkflowToken(argumentPrefix, workflowItems);\n\tif (subcommand === \"pause\") {\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: \"--all \", label: \"--all\", description: \"Pause all in-flight runs\" },\n\t\t\t{ value: \"--yes \", label: \"--yes\", description: \"Skip confirmation\" },\n\t\t\t{ value: \"-y \", label: \"-y\", description: \"Skip confirmation\" },\n\t\t]);\n\t}\n\tif (subcommand === \"quit\") {\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: \"--all \", label: \"--all\", description: \"Quit and keep all in-flight runs resumable\" },\n\t\t]);\n\t}\n\tif (!subcommand) return completeWorkflowToken(argumentPrefix, [...WORKFLOW_ADMIN_COMPLETIONS, ...workflowItems]);\n\n\tconst workflow = BUNDLED_WORKFLOW_COMPLETION_METADATA.find((candidate) => candidate.name === subcommand);\n\tif (!workflow) return null;\n\tconst tokenStart = /\\s$/.test(argumentPrefix)\n\t\t? argumentPrefix.length\n\t\t: Math.max(argumentPrefix.lastIndexOf(\" \"), argumentPrefix.lastIndexOf(\"\\t\")) + 1;\n\tconst token = argumentPrefix.slice(tokenStart);\n\tconst equalsIndex = token.indexOf(\"=\");\n\tif (equalsIndex > 0) {\n\t\tconst inputName = token.slice(0, equalsIndex);\n\t\tconst input = workflow.inputs[inputName];\n\t\tif (input?.kind !== \"boolean\") return null;\n\t\treturn completeWorkflowToken(argumentPrefix, [\n\t\t\t{ value: `${inputName}=true `, label: \"true\", description: inputName },\n\t\t\t{ value: `${inputName}=false `, label: \"false\", description: inputName },\n\t\t]);\n\t}\n\n\treturn completeWorkflowToken(argumentPrefix, [\n\t\t{ value: \"--no-picker \", label: \"--no-picker\", description: \"Skip interactive input picker\" },\n\t\t{ value: \"--help \", label: \"--help\", description: \"Show this workflow's input schema\" },\n\t\t...Object.entries(workflow.inputs).map(([name, input]) => ({\n\t\t\tvalue: `${name}=`,\n\t\t\tlabel: name,\n\t\t\tdescription: input.description,\n\t\t})),\n\t]);\n}\n\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"settings\", description: \"Open settings menu\" },\n\t{ name: \"model\", description: \"Select model (opens selector UI)\", argumentHint: \"<provider/model>\" },\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\n\t{ name: \"thinking\", description: \"Set thinking level\", argumentHint: \"<level>\" },\n\t{ name: \"scoped-models\", description: \"Enable/disable models for ctrl+p cycling\" },\n\t{ name: \"export\", description: \"Export session (HTML default, or specify path: .html/.jsonl)\" },\n\t{ name: \"import\", description: \"Import and resume a session from a JSONL file\" },\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\n\t{ name: \"name\", description: \"Set session display name\" },\n\t{ name: \"session\", description: \"Show session info and stats\" },\n\t{ name: \"tools\", description: \"Show which tools are active, inactive (and why), or missing\" },\n\t{ name: \"tasks\", description: \"Inspect agents and shells, view output, and manage running tasks\" },\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\n\t{ name: \"fork\", description: \"Create a new fork from a previous user message\" },\n\t{ name: \"clone\", description: \"Duplicate the current session at the current position\" },\n\t{ name: \"trust\", description: \"Save project trust decision for future sessions\" },\n\t{ name: \"login\", description: \"Configure provider authentication\", argumentHint: \"<provider>\" },\n\t{ name: \"logout\", description: \"Remove provider authentication\", argumentHint: \"<provider>\" },\n\t{ name: \"new\", description: \"Start a new session\" },\n\t{ name: \"compact\", description: \"Compact older context with verbatim line ranges\" },\n\t{ name: \"resume\", description: \"Resume another session\" },\n\t{ name: \"reload\", description: \"Reload keybindings, extensions, skills, prompts, and themes\" },\n\t{ name: \"exit\", description: `Exit ${APP_NAME}` },\n\t{ name: \"quit\", description: `Quit ${APP_NAME}` },\n];\n\nexport const BUNDLED_EXTENSION_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"agents\", description: \"Browse available subagents and inspect their configuration\" },\n\t{\n\t\tname: \"workflow\",\n\t\tdescription:\n\t\t\t\"Run or inspect Atomic workflows. Usage: /workflow <name> [key=value…] | /workflow [list|status|connect|attach|quit|pause|resume|inputs|reload] [args]\",\n\t\tgetArgumentCompletions: getBundledWorkflowArgumentCompletions,\n\t},\n\t{ name: \"mcp\", description: \"Show MCP server status\" },\n\t{ name: \"mcp-auth\", description: \"Authenticate with an MCP server (OAuth)\" },\n\t{ name: \"curator\", description: \"Toggle or configure the search curator workflow\" },\n\t{ name: \"google-account\", description: \"Show the active Google account for Gemini Web\" },\n\t{ name: \"search\", description: \"Browse stored web search results\" },\n\t{ name: \"websearch\", description: \"Open web search curator\" },\n\t{ name: \"intercom\", description: \"Open session intercom overlay\" },\n];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/extensions/mcp/cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,OAAO,EAEN,uBAAuB,EAKvB,MAAM,cAAc,CAAC;AAgDtB,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC,wCAAwC;IACxC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,kCAAkC;IAClC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B;AA8FD,oDAAoD;AACpD,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2E/F"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/extensions/mcp/cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,OAAO,EAEN,uBAAuB,EAKvB,MAAM,cAAc,CAAC;AAgDtB,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC,wCAAwC;IACxC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,kCAAkC;IAClC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B;AA+FD,oDAAoD;AACpD,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqF/F"}
@@ -19,8 +19,8 @@ const HELP = `${chalk.bold("Usage:")}
19
19
  ${APP_NAME} mcp add <server> [options] --url <url>
20
20
  ${APP_NAME} mcp remove <server> [-l]
21
21
  ${APP_NAME} mcp list [--json]
22
- ${APP_NAME} mcp login <server> [--timeout <seconds>]
23
- ${APP_NAME} mcp logout <server>
22
+ ${APP_NAME} mcp login <server> [-l] [--timeout <seconds>]
23
+ ${APP_NAME} mcp logout <server> [-l]
24
24
 
25
25
  Configure and check MCP servers and sign in to OAuth servers without starting a session.
26
26
  Reads ~/${CONFIG_DIR_NAME}/agent/mcp.json and, in trusted projects, ${CONFIG_DIR_NAME}/mcp.json.
@@ -32,7 +32,7 @@ Commands:
32
32
  login <server> Sign in through the browser
33
33
  logout <server> Delete the stored OAuth credentials
34
34
 
35
- Options for add and remove:
35
+ Options for add, remove, login, and logout:
36
36
  -l, --local Use ${CONFIG_DIR_NAME}/mcp.json in the current project instead of the global file
37
37
 
38
38
  Options for add:
@@ -86,7 +86,8 @@ function parseOptions(args, known, error, maxPositionals = Number.POSITIVE_INFIN
86
86
  const values = new Map();
87
87
  const lists = new Map();
88
88
  for (let index = 0; index < args.length; index++) {
89
- const arg = OPTION_ALIASES.get(args[index]) ?? args[index];
89
+ const typed = args[index];
90
+ const arg = OPTION_ALIASES.get(typed) ?? typed;
90
91
  if (arg === "--" || positional.length >= maxPositionals) {
91
92
  positional.push(...args.slice(arg === "--" ? index + 1 : index));
92
93
  break;
@@ -98,7 +99,7 @@ function parseOptions(args, known, error, maxPositionals = Number.POSITIVE_INFIN
98
99
  const name = arg.slice(2);
99
100
  const kind = known[name];
100
101
  if (!kind) {
101
- error(`Unknown option ${arg}.\n${HELP_HINT}`);
102
+ error(`Unknown option ${typed}.\n${HELP_HINT}`);
102
103
  return undefined;
103
104
  }
104
105
  if (kind === "flag") {
@@ -151,17 +152,23 @@ export async function runMcpCommand(args, options) {
151
152
  }
152
153
  case "login":
153
154
  case "logout": {
154
- const parsed = parseOptions(rest, command === "login" ? { timeout: "value" } : {}, error);
155
+ const parsed = parseOptions(rest, command === "login" ? { local: "flag", timeout: "value" } : { local: "flag" }, error);
155
156
  if (!parsed)
156
157
  return 1;
157
158
  const [name, ...extra] = parsed.positional;
158
159
  if (!name || extra.length > 0) {
159
- error(`Usage: ${APP_NAME} mcp ${command} <server>\n${HELP_HINT}`);
160
+ error(`Usage: ${APP_NAME} mcp ${command} <server> [-l]\n${HELP_HINT}`);
160
161
  return 1;
161
162
  }
162
163
  const entry = loaded.servers.find((server) => server.name === name);
163
164
  if (!entry) {
164
- error(`No MCP server named "${name}".${untrustedNote ? ` ${untrustedNote}` : ""} Configured: ${loaded.servers.map((server) => server.name).join(", ") || "none"}.`);
165
+ const names = loaded.servers.map((server) => server.name);
166
+ const suggestion = names.find((candidate) => editDistance(candidate, name) <= 2);
167
+ error(`No MCP server named "${name}".${suggestion ? ` Did you mean "${suggestion}"?` : ""}${untrustedNote ? ` ${untrustedNote}` : ""} Configured: ${names.join(", ") || "none"}.`);
168
+ return 1;
169
+ }
170
+ if (parsed.values.has("local") && entry.scope !== "project") {
171
+ error(`MCP server "${name}" is defined in ${entry.source}, not in the project; omit --local.`);
165
172
  return 1;
166
173
  }
167
174
  const connection = createConnection(entry, options, credentials);
@@ -192,6 +199,18 @@ export async function runMcpCommand(args, options) {
192
199
  return 1;
193
200
  }
194
201
  }
202
+ /** Levenshtein distance, to suggest a configured server name for a mistyped one. */
203
+ function editDistance(a, b) {
204
+ let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
205
+ for (let i = 1; i <= a.length; i++) {
206
+ const current = [i];
207
+ for (let j = 1; j <= b.length; j++) {
208
+ current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
209
+ }
210
+ previous = current;
211
+ }
212
+ return previous[b.length];
213
+ }
195
214
  /** Parse `KEY=VALUE` pairs of a repeatable option into a record. */
196
215
  function parsePairs(option, pairs, error) {
197
216
  if (!pairs)
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/extensions/mcp/cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,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AC,CAAC;AACV,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,kBAAkB,CAAC,MAAmB,EAAE,WAAoB;IAC1E,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/G,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,IAAI,CAAC;QACJ,OAAO,MAAM,QAAQ,CAAC,QAAQ,CAAC,gFAAgF,EAAE;YAChH,MAAM;SACN,CAAC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;YAAS,CAAC;QACV,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/**\n * `pi mcp`: add, remove, and check MCP servers and sign in to them outside a session. Agents run it\n * through bash to configure servers, verify an `mcp.json` they wrote, and start an OAuth sign-in;\n * the user only approves access in the browser. Running sessions pick up new credentials on their\n * next turn.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { createInterface } from \"node:readline/promises\";\nimport chalk from \"chalk\";\nimport { APP_NAME, CONFIG_DIR_NAME } from \"../../config.js\";\nimport { validateMcpServerConfig } from \"../../core/mcp-servers.ts\";\nimport { ProjectTrustStore } from \"../../core/trust-manager.ts\";\nimport { openBrowser } from \"../../utils/open-browser.ts\";\nimport {\n\taddMcpServerConfig,\n\tgetMcpToolExposure,\n\ttype LoadedMcpConfig,\n\tloadMcpConfig,\n\ttype McpServerEntry,\n\tremoveMcpServerConfig,\n} from \"./config.ts\";\nimport {\n\tcreateDefaultTransport,\n\tMcpOAuthCredentialStore,\n\tMcpServerConnection,\n\tMcpServerLog,\n\tMcpSignInCancelledError,\n\tsignInMcpServer,\n} from \"./runtime.ts\";\n\nconst HELP = `${chalk.bold(\"Usage:\")}\n ${APP_NAME} mcp add <server> [options] -- <command> [args...]\n ${APP_NAME} mcp add <server> [options] --url <url>\n ${APP_NAME} mcp remove <server> [-l]\n ${APP_NAME} mcp list [--json]\n ${APP_NAME} mcp login <server> [--timeout <seconds>]\n ${APP_NAME} mcp logout <server>\n\nConfigure and check MCP servers and sign in to OAuth servers without starting a session.\nReads ~/${CONFIG_DIR_NAME}/agent/mcp.json and, in trusted projects, ${CONFIG_DIR_NAME}/mcp.json.\n\nCommands:\n add <server> Add or replace a server in mcp.json\n remove <server> Remove a server from mcp.json\n list Show state, tools, and errors (exits 1 on failure)\n login <server> Sign in through the browser\n logout <server> Delete the stored OAuth credentials\n\nOptions for add and remove:\n -l, --local Use ${CONFIG_DIR_NAME}/mcp.json in the current project instead of the global file\n\nOptions for add:\n --url <url> Streamable HTTP server URL (instead of a command)\n --env <KEY=VALUE> Environment variable for a stdio server (repeatable)\n --cwd <dir> Working directory for a stdio server\n --header <KEY=VALUE> HTTP header (repeatable)\n --bearer-token-env-var <NAME>\n Send \"Authorization: Bearer \\${NAME}\"\n --oauth-client-id <id> Pre-registered OAuth client id\n --oauth-client-secret <secret>\n OAuth client secret (may be \\${NAME} or !command)\n --oauth-callback-port <port>\n Fixed OAuth callback port\n --oauth-client-name <name>\n Client name sent when registering with the OAuth server\n --exposure <mode> codemode (default), deferred, direct, or hidden\n --description <text> What the server offers, shown in the system prompt\n\nOther options:\n --json Print the list as JSON\n --timeout <seconds> How long login may take in total (default: 300)`;\n\nconst HELP_HINT = chalk.dim(`Use \"${APP_NAME} mcp --help\" for usage.`);\n\nconst DEFAULT_LOGIN_TIMEOUT_SECONDS = 300;\n\nexport interface McpCommandOptions {\n\tcwd: string;\n\tagentDir: string;\n\t/** Defaults to `mcp-auth.json` in the agent directory. */\n\tcredentials?: McpOAuthCredentialStore;\n\t/** Defaults to the platform browser. */\n\topenUrl?: (url: string) => void;\n\t/** Defaults to console output. */\n\tlog?: (line: string) => void;\n\terror?: (line: string) => void;\n}\n\ninterface ServerReport {\n\tname: string;\n\tscope: string;\n\tsource: string;\n\t/** Project `mcp.json` that overrides `enabled`, `exposure`, or `toolExposure` of this global server. */\n\toverride?: string;\n\tenabled: boolean;\n\texposure: string;\n\ttransport: string;\n\tstate: string;\n\ttools: string[];\n\t/** Tools whose exposure differs from the server's, from `toolExposure`. */\n\ttoolExposure?: Record<string, string>;\n\tresources?: true;\n\terror?: string;\n}\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction describeTransport(entry: McpServerEntry): string {\n\tconst { config } = entry;\n\treturn \"url\" in config ? config.url : [config.command, ...(config.args ?? [])].join(\" \");\n}\n\nfunction createConnection(entry: McpServerEntry, options: McpCommandOptions, credentials: McpOAuthCredentialStore) {\n\treturn new McpServerConnection({\n\t\tentry,\n\t\tcwd: options.cwd,\n\t\tcreateTransport: createDefaultTransport,\n\t\tcredentials,\n\t\tlog: new McpServerLog(join(options.agentDir, \"mcp.log\")),\n\t\tonTools: () => {},\n\t});\n}\n\n/** Short spellings of options. `-l`/`--local` match `pi install`. */\nconst OPTION_ALIASES = new Map([[\"-l\", \"--local\"]]);\n\ninterface ParsedOptions {\n\tpositional: string[];\n\tvalues: Map<string, string | true>;\n\t/** Values of `list` options, in order. */\n\tlists: Map<string, string[]>;\n}\n\n/**\n * Parse `--name value` options; returns undefined and reports unknown ones. `--` ends the options,\n * as does reaching `maxPositionals` positional arguments: the remaining arguments are positional,\n * so a command's own options (`add <server> <command> --flag`) are passed through.\n */\nfunction parseOptions(\n\targs: string[],\n\tknown: Record<string, \"flag\" | \"value\" | \"list\">,\n\terror: (line: string) => void,\n\tmaxPositionals = Number.POSITIVE_INFINITY,\n): ParsedOptions | undefined {\n\tconst positional: string[] = [];\n\tconst values = new Map<string, string | true>();\n\tconst lists = new Map<string, string[]>();\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst arg = OPTION_ALIASES.get(args[index]) ?? args[index];\n\t\tif (arg === \"--\" || positional.length >= maxPositionals) {\n\t\t\tpositional.push(...args.slice(arg === \"--\" ? index + 1 : index));\n\t\t\tbreak;\n\t\t}\n\t\tif (!arg.startsWith(\"--\")) {\n\t\t\tpositional.push(arg);\n\t\t\tcontinue;\n\t\t}\n\t\tconst name = arg.slice(2);\n\t\tconst kind = known[name];\n\t\tif (!kind) {\n\t\t\terror(`Unknown option ${arg}.\\n${HELP_HINT}`);\n\t\t\treturn undefined;\n\t\t}\n\t\tif (kind === \"flag\") {\n\t\t\tvalues.set(name, true);\n\t\t\tcontinue;\n\t\t}\n\t\tconst value = args[++index];\n\t\tif (value === undefined) {\n\t\t\terror(`${arg} needs a value.`);\n\t\t\treturn undefined;\n\t\t}\n\t\tif (kind === \"list\") lists.set(name, [...(lists.get(name) ?? []), value]);\n\t\telse values.set(name, value);\n\t}\n\treturn { positional, values, lists };\n}\n\n/** Run `pi mcp <args>` and return the exit code. */\nexport async function runMcpCommand(args: string[], options: McpCommandOptions): Promise<number> {\n\tconst log = options.log ?? ((line: string) => console.log(line));\n\tconst error = options.error ?? ((line: string) => console.error(line));\n\tconst [command, ...rest] = args;\n\tif (command === undefined || command === \"help\" || args.includes(\"--help\") || args.includes(\"-h\")) {\n\t\tlog(HELP);\n\t\treturn 0;\n\t}\n\n\tconst projectConfig = join(options.cwd, CONFIG_DIR_NAME, \"mcp.json\");\n\tif (command === \"add\" || command === \"remove\") {\n\t\treturn command === \"add\"\n\t\t\t? add(rest, projectConfig, options, log, error)\n\t\t\t: remove(rest, projectConfig, options, log, error);\n\t}\n\tconst projectTrusted = new ProjectTrustStore(options.agentDir).get(options.cwd) === true;\n\tconst loaded = loadMcpConfig({ agentDir: options.agentDir, cwd: options.cwd, projectTrusted });\n\tconst untrustedNote =\n\t\t!projectTrusted && existsSync(projectConfig)\n\t\t\t? `${projectConfig} is ignored because the project is not trusted. Start ${APP_NAME} in the project to trust it.`\n\t\t\t: undefined;\n\tconst credentials = options.credentials ?? new McpOAuthCredentialStore();\n\n\tswitch (command) {\n\t\tcase \"list\": {\n\t\t\tconst parsed = parseOptions(rest, { json: \"flag\" }, error);\n\t\t\tif (!parsed) return 1;\n\t\t\tif (parsed.positional.length > 0) {\n\t\t\t\terror(`Usage: ${APP_NAME} mcp list [--json]\\n${HELP_HINT}`);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\treturn list(loaded, parsed.values.has(\"json\"), untrustedNote, options, credentials, log);\n\t\t}\n\t\tcase \"login\":\n\t\tcase \"logout\": {\n\t\t\tconst parsed = parseOptions(rest, command === \"login\" ? { timeout: \"value\" } : {}, error);\n\t\t\tif (!parsed) return 1;\n\t\t\tconst [name, ...extra] = parsed.positional;\n\t\t\tif (!name || extra.length > 0) {\n\t\t\t\terror(`Usage: ${APP_NAME} mcp ${command} <server>\\n${HELP_HINT}`);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tconst entry = loaded.servers.find((server) => server.name === name);\n\t\t\tif (!entry) {\n\t\t\t\terror(\n\t\t\t\t\t`No MCP server named \"${name}\".${untrustedNote ? ` ${untrustedNote}` : \"\"} Configured: ${loaded.servers.map((server) => server.name).join(\", \") || \"none\"}.`,\n\t\t\t\t);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tconst connection = createConnection(entry, options, credentials);\n\t\t\tconst url = connection.oauthUrl;\n\t\t\tif (!url) {\n\t\t\t\terror(`MCP server \"${name}\" does not use OAuth. Only HTTP servers without an Authorization header do.`);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif (command === \"logout\") {\n\t\t\t\tconst removed = await credentials.removeAsync(name, url);\n\t\t\t\tlog(removed ? `Signed out of MCP server \"${name}\".` : `No stored credentials for MCP server \"${name}\".`);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tconst timeout = Number(parsed.values.get(\"timeout\") ?? DEFAULT_LOGIN_TIMEOUT_SECONDS);\n\t\t\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\t\t\terror(\"--timeout must be a positive number of seconds.\");\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn await login(entry, connection, url, timeout * 1000, options, credentials, log, error);\n\t\t\t} finally {\n\t\t\t\tawait connection.close();\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\terror(`Unknown mcp command \"${command}\".\\n${HELP_HINT}`);\n\t\t\treturn 1;\n\t}\n}\n\n/** Parse `KEY=VALUE` pairs of a repeatable option into a record. */\nfunction parsePairs(option: string, pairs: string[] | undefined, error: (line: string) => void) {\n\tif (!pairs) return {};\n\tconst record: Record<string, string> = {};\n\tfor (const pair of pairs) {\n\t\tconst separator = pair.indexOf(\"=\");\n\t\tif (separator <= 0) {\n\t\t\terror(`--${option} expects KEY=VALUE, got \"${pair}\".`);\n\t\t\treturn undefined;\n\t\t}\n\t\trecord[pair.slice(0, separator)] = pair.slice(separator + 1);\n\t}\n\treturn record;\n}\n\nfunction add(\n\targs: string[],\n\tprojectConfig: string,\n\toptions: McpCommandOptions,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): number {\n\tconst usage = `Usage: ${APP_NAME} mcp add <server> [options] (--url <url> | -- <command> [args...])\\n${HELP_HINT}`;\n\tconst parsed = parseOptions(\n\t\targs,\n\t\t{\n\t\t\tlocal: \"flag\",\n\t\t\turl: \"value\",\n\t\t\tenv: \"list\",\n\t\t\tcwd: \"value\",\n\t\t\theader: \"list\",\n\t\t\t\"bearer-token-env-var\": \"value\",\n\t\t\t\"oauth-client-id\": \"value\",\n\t\t\t\"oauth-client-secret\": \"value\",\n\t\t\t\"oauth-callback-port\": \"value\",\n\t\t\t\"oauth-client-name\": \"value\",\n\t\t\texposure: \"value\",\n\t\t\tdescription: \"value\",\n\t\t},\n\t\terror,\n\t\t2,\n\t);\n\tif (!parsed) return 1;\n\tconst { positional, values, lists } = parsed;\n\tconst [name, ...command] = positional;\n\tconst url = values.get(\"url\");\n\tif (!name || (url === undefined) === (command.length === 0)) {\n\t\terror(usage);\n\t\treturn 1;\n\t}\n\tconst value = (option: string) => {\n\t\tconst found = values.get(option);\n\t\treturn typeof found === \"string\" ? found : undefined;\n\t};\n\tconst exposure = value(\"exposure\");\n\tconst httpOnly = [\n\t\t\"header\",\n\t\t\"bearer-token-env-var\",\n\t\t\"oauth-client-id\",\n\t\t\"oauth-client-secret\",\n\t\t\"oauth-callback-port\",\n\t\t\"oauth-client-name\",\n\t];\n\tconst stdioOnly = [\"env\", \"cwd\"];\n\tconst misplaced = (url === undefined ? httpOnly : stdioOnly).find(\n\t\t(option) => values.has(option) || lists.has(option),\n\t);\n\tif (misplaced) {\n\t\terror(`--${misplaced} only applies to ${url === undefined ? \"HTTP servers (--url)\" : \"stdio servers\"}.`);\n\t\treturn 1;\n\t}\n\n\tlet config: Record<string, unknown>;\n\tif (typeof url === \"string\") {\n\t\tconst headers = parsePairs(\"header\", lists.get(\"header\"), error);\n\t\tif (!headers) return 1;\n\t\tconst bearer = value(\"bearer-token-env-var\");\n\t\tif (bearer !== undefined) headers.Authorization = `Bearer \\${${bearer}}`;\n\t\tconst port = value(\"oauth-callback-port\");\n\t\tconst oauth = {\n\t\t\t...(value(\"oauth-client-id\") === undefined ? {} : { clientId: value(\"oauth-client-id\") }),\n\t\t\t...(value(\"oauth-client-secret\") === undefined ? {} : { clientSecret: value(\"oauth-client-secret\") }),\n\t\t\t...(port === undefined ? {} : { callbackPort: Number(port) }),\n\t\t\t...(value(\"oauth-client-name\") === undefined ? {} : { clientName: value(\"oauth-client-name\") }),\n\t\t};\n\t\tconfig = {\n\t\t\turl,\n\t\t\t...(Object.keys(headers).length > 0 ? { headers } : {}),\n\t\t\t...(Object.keys(oauth).length > 0 ? { oauth } : {}),\n\t\t};\n\t} else {\n\t\tconst env = parsePairs(\"env\", lists.get(\"env\"), error);\n\t\tif (!env) return 1;\n\t\tconst [executable, ...commandArgs] = command;\n\t\tconfig = {\n\t\t\tcommand: executable,\n\t\t\t...(commandArgs.length > 0 ? { args: commandArgs } : {}),\n\t\t\t...(Object.keys(env).length > 0 ? { env } : {}),\n\t\t\t...(value(\"cwd\") === undefined ? {} : { cwd: value(\"cwd\") }),\n\t\t};\n\t}\n\tif (exposure !== undefined) config.exposure = exposure;\n\tconst description = value(\"description\");\n\tif (description !== undefined) config.description = description;\n\tconst validated = validateMcpServerConfig(name, config);\n\tif (typeof validated === \"string\") {\n\t\terror(validated);\n\t\treturn 1;\n\t}\n\n\tconst project = values.has(\"local\");\n\tconst path = project ? projectConfig : join(options.agentDir, \"mcp.json\");\n\tconst scope = project ? \"project\" : \"global\";\n\tlet replaced: boolean;\n\ttry {\n\t\treplaced = addMcpServerConfig(path, name, validated);\n\t} catch (addError) {\n\t\terror(`Could not update ${path}: ${errorMessage(addError)}`);\n\t\treturn 1;\n\t}\n\tlog(`${replaced ? \"Replaced\" : \"Added\"} ${scope} MCP server \"${name}\" in ${path}.`);\n\tif (project && new ProjectTrustStore(options.agentDir).get(options.cwd) !== true) {\n\t\tlog(`The project is not trusted, so ${path} is ignored until you start ${APP_NAME} in the project and trust it.`);\n\t}\n\t// HTTP servers without an Authorization header may use OAuth.\n\tconst mayNeedSignIn =\n\t\t\"url\" in validated &&\n\t\t!Object.keys(validated.headers ?? {}).some((header) => header.toLowerCase() === \"authorization\");\n\tlog(\n\t\t`Check it with: ${APP_NAME} mcp list${mayNeedSignIn ? `. If it requires sign-in: ${APP_NAME} mcp login ${name}` : \"\"}`,\n\t);\n\treturn 0;\n}\n\nfunction remove(\n\targs: string[],\n\tprojectConfig: string,\n\toptions: McpCommandOptions,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): number {\n\tconst parsed = parseOptions(args, { local: \"flag\" }, error);\n\tif (!parsed) return 1;\n\tconst [name, ...extra] = parsed.positional;\n\tif (!name || extra.length > 0) {\n\t\terror(`Usage: ${APP_NAME} mcp remove <server> [-l]\\n${HELP_HINT}`);\n\t\treturn 1;\n\t}\n\tconst project = parsed.values.has(\"local\");\n\tconst globalConfig = join(options.agentDir, \"mcp.json\");\n\tconst path = project ? projectConfig : globalConfig;\n\tconst scope = project ? \"project\" : \"global\";\n\tlet removed: boolean;\n\ttry {\n\t\tremoved = removeMcpServerConfig(path, name);\n\t} catch (removeError) {\n\t\terror(`Could not update ${path}: ${errorMessage(removeError)}`);\n\t\treturn 1;\n\t}\n\tif (removed) {\n\t\tlog(`Removed ${scope} MCP server \"${name}\" from ${path}.`);\n\t\treturn 0;\n\t}\n\tconst other = loadMcpConfig({ agentDir: options.agentDir, cwd: options.cwd, projectTrusted: true }).servers.find(\n\t\t(server) => server.name === name && server.scope !== scope,\n\t);\n\terror(\n\t\t`No ${scope} MCP server named \"${name}\" in ${path}.${other ? ` It is defined in ${other.source}${other.scope === \"project\" ? \"; use --local\" : \"; omit --local\"}.` : \"\"}`,\n\t);\n\treturn 1;\n}\n\nasync function list(\n\tloaded: LoadedMcpConfig,\n\tjson: boolean,\n\tuntrustedNote: string | undefined,\n\toptions: McpCommandOptions,\n\tcredentials: McpOAuthCredentialStore,\n\tlog: (line: string) => void,\n): Promise<number> {\n\tconst reports = await Promise.all(\n\t\tloaded.servers.map(async (entry): Promise<ServerReport> => {\n\t\t\tconst report: ServerReport = {\n\t\t\t\tname: entry.name,\n\t\t\t\tscope: entry.scope ?? \"global\",\n\t\t\t\tsource: entry.source,\n\t\t\t\t...(entry.override ? { override: entry.override } : {}),\n\t\t\t\tenabled: entry.config.enabled !== false,\n\t\t\t\texposure: entry.config.exposure ?? \"codemode\",\n\t\t\t\ttransport: describeTransport(entry),\n\t\t\t\tstate: \"disabled\",\n\t\t\t\ttools: [],\n\t\t\t};\n\t\t\tif (!report.enabled) return report;\n\t\t\tconst connection = createConnection(entry, options, credentials);\n\t\t\ttry {\n\t\t\t\tawait connection.getClient();\n\t\t\t} catch {\n\t\t\t\t// The connection records the state and error.\n\t\t\t}\n\t\t\treport.state = connection.state;\n\t\t\treport.tools = connection.tools.map((tool) => tool.name);\n\t\t\tconst overrides = connection.tools.flatMap((tool) => {\n\t\t\t\tconst exposure = getMcpToolExposure(entry.config, tool.name);\n\t\t\t\treturn exposure === report.exposure ? [] : [[tool.name, exposure] as const];\n\t\t\t});\n\t\t\tif (overrides.length > 0) report.toolExposure = Object.fromEntries(overrides);\n\t\t\tif (connection.hasResources) report.resources = true;\n\t\t\tif (connection.state !== \"connected\" && connection.error) report.error = connection.error;\n\t\t\tawait connection.close();\n\t\t\treturn report;\n\t\t}),\n\t);\n\tconst failed = loaded.errors.length > 0 || reports.some((report) => report.enabled && report.state !== \"connected\");\n\n\tif (json) {\n\t\tlog(\n\t\t\tJSON.stringify(\n\t\t\t\t{ servers: reports, errors: loaded.errors, ...(untrustedNote ? { note: untrustedNote } : {}) },\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t);\n\t\treturn failed ? 1 : 0;\n\t}\n\tif (reports.length === 0 && loaded.errors.length === 0) {\n\t\tlog(\n\t\t\t`No MCP servers configured. Add them to ${join(options.agentDir, \"mcp.json\")} or ${CONFIG_DIR_NAME}/mcp.json.`,\n\t\t);\n\t}\n\tfor (const report of reports) {\n\t\tconst state =\n\t\t\treport.state === \"connected\"\n\t\t\t\t? `connected, ${report.tools.length} tool${report.tools.length === 1 ? \"\" : \"s\"}`\n\t\t\t\t: report.state === \"needs-auth\"\n\t\t\t\t\t? \"needs sign-in\"\n\t\t\t\t\t: report.state;\n\t\tlog(`${report.name}: ${state} (${report.exposure}, ${report.scope})`);\n\t\tlog(` ${report.transport}`);\n\t\tif (report.override) log(` project override: ${report.override}`);\n\t\tif (report.state === \"needs-auth\") log(` sign in with: ${APP_NAME} mcp login ${report.name}`);\n\t\tif (report.tools.length > 0) {\n\t\t\tconst tools = report.tools.map((tool) => {\n\t\t\t\tconst exposure = report.toolExposure?.[tool];\n\t\t\t\treturn exposure ? `${tool} [${exposure}]` : tool;\n\t\t\t});\n\t\t\tlog(` tools: ${tools.join(\", \")}`);\n\t\t}\n\t\tif (report.resources) log(\" offers resources\");\n\t\tif (report.error) log(` ${report.error.split(\"\\n\").join(\"\\n \")}`);\n\t}\n\tfor (const configError of loaded.errors) log(`config error: ${configError}`);\n\tif (untrustedNote) log(untrustedNote);\n\treturn failed ? 1 : 0;\n}\n\nasync function login(\n\tentry: McpServerEntry,\n\tconnection: McpServerConnection,\n\turl: string,\n\ttimeoutMs: number,\n\toptions: McpCommandOptions,\n\tcredentials: McpOAuthCredentialStore,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): Promise<number> {\n\tconst { name } = entry;\n\t// Connecting first answers whether a sign-in is needed and records the server's challenge.\n\ttry {\n\t\tawait connection.getClient();\n\t\tlog(`Already signed in to MCP server \"${name}\" (${connection.tools.length} tools).`);\n\t\treturn 0;\n\t} catch {\n\t\tif (connection.state !== \"needs-auth\") {\n\t\t\terror(`MCP server \"${name}\" failed to connect: ${connection.error ?? \"unknown error\"}`);\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tconst openUrl = options.openUrl ?? openBrowser;\n\tconst interactive = process.stdin.isTTY === true && options.openUrl === undefined;\n\ttry {\n\t\tawait signInMcpServer({\n\t\t\tserverUrl: url,\n\t\t\tstore: credentials.forServer(name, url),\n\t\t\tsettings: connection.oauthSettings(),\n\t\t\tchallenge: connection.challenge,\n\t\t\tprompt: {\n\t\t\t\tshowAuthorizationUrl: (authorizationUrl) => {\n\t\t\t\t\tlog(`Sign in to MCP server \"${name}\" in your browser:\\n${authorizationUrl.href}`);\n\t\t\t\t\topenUrl(authorizationUrl.href);\n\t\t\t\t},\n\t\t\t\tpromptForRedirectUrl: (signal) => waitForRedirectUrl(signal, interactive),\n\t\t\t},\n\t\t\tsignal: AbortSignal.timeout(timeoutMs),\n\t\t});\n\t} catch (signInError) {\n\t\terror(\n\t\t\tsignInError instanceof McpSignInCancelledError\n\t\t\t\t? `Sign-in to MCP server \"${name}\" was cancelled or not completed within ${Math.round(timeoutMs / 1000)} seconds.`\n\t\t\t\t: `Sign-in to MCP server \"${name}\" failed: ${errorMessage(signInError)}`,\n\t\t);\n\t\treturn 1;\n\t}\n\tconnection.challenge = undefined;\n\ttry {\n\t\tawait connection.reconnect();\n\t} catch (connectError) {\n\t\terror(`Signed in, but ${errorMessage(connectError)}`);\n\t\treturn 1;\n\t}\n\tlog(`Signed in to MCP server \"${name}\" (${connection.tools.length} tools).`);\n\treturn 0;\n}\n\n/**\n * The pasted redirect URL in a terminal; otherwise only the browser callback can finish the sign-in.\n * Resolves to undefined when `signal` aborts: the callback arrived, or the sign-in timed out.\n */\nasync function waitForRedirectUrl(signal: AbortSignal, interactive: boolean): Promise<string | undefined> {\n\tif (!interactive) {\n\t\tif (!signal.aborted) await new Promise((resolve) => signal.addEventListener(\"abort\", resolve, { once: true }));\n\t\treturn undefined;\n\t}\n\tconst readline = createInterface({ input: process.stdin, output: process.stderr });\n\ttry {\n\t\treturn await readline.question(\"If the browser cannot reach this machine, paste the URL it was redirected to: \", {\n\t\t\tsignal,\n\t\t});\n\t} catch {\n\t\treturn undefined;\n\t} finally {\n\t\treadline.close();\n\t}\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/extensions/mcp/cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE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7E,OAAO,CAAC,CAAC;AACV,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,kBAAkB,CAAC,MAAmB,EAAE,WAAoB;IAC1E,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/G,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,IAAI,CAAC;QACJ,OAAO,MAAM,QAAQ,CAAC,QAAQ,CAAC,gFAAgF,EAAE;YAChH,MAAM;SACN,CAAC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;YAAS,CAAC;QACV,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/**\n * `pi mcp`: add, remove, and check MCP servers and sign in to them outside a session. Agents run it\n * through bash to configure servers, verify an `mcp.json` they wrote, and start an OAuth sign-in;\n * the user only approves access in the browser. Running sessions pick up new credentials on their\n * next turn.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { createInterface } from \"node:readline/promises\";\nimport chalk from \"chalk\";\nimport { APP_NAME, CONFIG_DIR_NAME } from \"../../config.js\";\nimport { validateMcpServerConfig } from \"../../core/mcp-servers.ts\";\nimport { ProjectTrustStore } from \"../../core/trust-manager.ts\";\nimport { openBrowser } from \"../../utils/open-browser.ts\";\nimport {\n\taddMcpServerConfig,\n\tgetMcpToolExposure,\n\ttype LoadedMcpConfig,\n\tloadMcpConfig,\n\ttype McpServerEntry,\n\tremoveMcpServerConfig,\n} from \"./config.ts\";\nimport {\n\tcreateDefaultTransport,\n\tMcpOAuthCredentialStore,\n\tMcpServerConnection,\n\tMcpServerLog,\n\tMcpSignInCancelledError,\n\tsignInMcpServer,\n} from \"./runtime.ts\";\n\nconst HELP = `${chalk.bold(\"Usage:\")}\n ${APP_NAME} mcp add <server> [options] -- <command> [args...]\n ${APP_NAME} mcp add <server> [options] --url <url>\n ${APP_NAME} mcp remove <server> [-l]\n ${APP_NAME} mcp list [--json]\n ${APP_NAME} mcp login <server> [-l] [--timeout <seconds>]\n ${APP_NAME} mcp logout <server> [-l]\n\nConfigure and check MCP servers and sign in to OAuth servers without starting a session.\nReads ~/${CONFIG_DIR_NAME}/agent/mcp.json and, in trusted projects, ${CONFIG_DIR_NAME}/mcp.json.\n\nCommands:\n add <server> Add or replace a server in mcp.json\n remove <server> Remove a server from mcp.json\n list Show state, tools, and errors (exits 1 on failure)\n login <server> Sign in through the browser\n logout <server> Delete the stored OAuth credentials\n\nOptions for add, remove, login, and logout:\n -l, --local Use ${CONFIG_DIR_NAME}/mcp.json in the current project instead of the global file\n\nOptions for add:\n --url <url> Streamable HTTP server URL (instead of a command)\n --env <KEY=VALUE> Environment variable for a stdio server (repeatable)\n --cwd <dir> Working directory for a stdio server\n --header <KEY=VALUE> HTTP header (repeatable)\n --bearer-token-env-var <NAME>\n Send \"Authorization: Bearer \\${NAME}\"\n --oauth-client-id <id> Pre-registered OAuth client id\n --oauth-client-secret <secret>\n OAuth client secret (may be \\${NAME} or !command)\n --oauth-callback-port <port>\n Fixed OAuth callback port\n --oauth-client-name <name>\n Client name sent when registering with the OAuth server\n --exposure <mode> codemode (default), deferred, direct, or hidden\n --description <text> What the server offers, shown in the system prompt\n\nOther options:\n --json Print the list as JSON\n --timeout <seconds> How long login may take in total (default: 300)`;\n\nconst HELP_HINT = chalk.dim(`Use \"${APP_NAME} mcp --help\" for usage.`);\n\nconst DEFAULT_LOGIN_TIMEOUT_SECONDS = 300;\n\nexport interface McpCommandOptions {\n\tcwd: string;\n\tagentDir: string;\n\t/** Defaults to `mcp-auth.json` in the agent directory. */\n\tcredentials?: McpOAuthCredentialStore;\n\t/** Defaults to the platform browser. */\n\topenUrl?: (url: string) => void;\n\t/** Defaults to console output. */\n\tlog?: (line: string) => void;\n\terror?: (line: string) => void;\n}\n\ninterface ServerReport {\n\tname: string;\n\tscope: string;\n\tsource: string;\n\t/** Project `mcp.json` that overrides `enabled`, `exposure`, or `toolExposure` of this global server. */\n\toverride?: string;\n\tenabled: boolean;\n\texposure: string;\n\ttransport: string;\n\tstate: string;\n\ttools: string[];\n\t/** Tools whose exposure differs from the server's, from `toolExposure`. */\n\ttoolExposure?: Record<string, string>;\n\tresources?: true;\n\terror?: string;\n}\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nfunction describeTransport(entry: McpServerEntry): string {\n\tconst { config } = entry;\n\treturn \"url\" in config ? config.url : [config.command, ...(config.args ?? [])].join(\" \");\n}\n\nfunction createConnection(entry: McpServerEntry, options: McpCommandOptions, credentials: McpOAuthCredentialStore) {\n\treturn new McpServerConnection({\n\t\tentry,\n\t\tcwd: options.cwd,\n\t\tcreateTransport: createDefaultTransport,\n\t\tcredentials,\n\t\tlog: new McpServerLog(join(options.agentDir, \"mcp.log\")),\n\t\tonTools: () => {},\n\t});\n}\n\n/** Short spellings of options. `-l`/`--local` match `pi install`. */\nconst OPTION_ALIASES = new Map([[\"-l\", \"--local\"]]);\n\ninterface ParsedOptions {\n\tpositional: string[];\n\tvalues: Map<string, string | true>;\n\t/** Values of `list` options, in order. */\n\tlists: Map<string, string[]>;\n}\n\n/**\n * Parse `--name value` options; returns undefined and reports unknown ones. `--` ends the options,\n * as does reaching `maxPositionals` positional arguments: the remaining arguments are positional,\n * so a command's own options (`add <server> <command> --flag`) are passed through.\n */\nfunction parseOptions(\n\targs: string[],\n\tknown: Record<string, \"flag\" | \"value\" | \"list\">,\n\terror: (line: string) => void,\n\tmaxPositionals = Number.POSITIVE_INFINITY,\n): ParsedOptions | undefined {\n\tconst positional: string[] = [];\n\tconst values = new Map<string, string | true>();\n\tconst lists = new Map<string, string[]>();\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst typed = args[index];\n\t\tconst arg = OPTION_ALIASES.get(typed) ?? typed;\n\t\tif (arg === \"--\" || positional.length >= maxPositionals) {\n\t\t\tpositional.push(...args.slice(arg === \"--\" ? index + 1 : index));\n\t\t\tbreak;\n\t\t}\n\t\tif (!arg.startsWith(\"--\")) {\n\t\t\tpositional.push(arg);\n\t\t\tcontinue;\n\t\t}\n\t\tconst name = arg.slice(2);\n\t\tconst kind = known[name];\n\t\tif (!kind) {\n\t\t\terror(`Unknown option ${typed}.\\n${HELP_HINT}`);\n\t\t\treturn undefined;\n\t\t}\n\t\tif (kind === \"flag\") {\n\t\t\tvalues.set(name, true);\n\t\t\tcontinue;\n\t\t}\n\t\tconst value = args[++index];\n\t\tif (value === undefined) {\n\t\t\terror(`${arg} needs a value.`);\n\t\t\treturn undefined;\n\t\t}\n\t\tif (kind === \"list\") lists.set(name, [...(lists.get(name) ?? []), value]);\n\t\telse values.set(name, value);\n\t}\n\treturn { positional, values, lists };\n}\n\n/** Run `pi mcp <args>` and return the exit code. */\nexport async function runMcpCommand(args: string[], options: McpCommandOptions): Promise<number> {\n\tconst log = options.log ?? ((line: string) => console.log(line));\n\tconst error = options.error ?? ((line: string) => console.error(line));\n\tconst [command, ...rest] = args;\n\tif (command === undefined || command === \"help\" || args.includes(\"--help\") || args.includes(\"-h\")) {\n\t\tlog(HELP);\n\t\treturn 0;\n\t}\n\n\tconst projectConfig = join(options.cwd, CONFIG_DIR_NAME, \"mcp.json\");\n\tif (command === \"add\" || command === \"remove\") {\n\t\treturn command === \"add\"\n\t\t\t? add(rest, projectConfig, options, log, error)\n\t\t\t: remove(rest, projectConfig, options, log, error);\n\t}\n\tconst projectTrusted = new ProjectTrustStore(options.agentDir).get(options.cwd) === true;\n\tconst loaded = loadMcpConfig({ agentDir: options.agentDir, cwd: options.cwd, projectTrusted });\n\tconst untrustedNote =\n\t\t!projectTrusted && existsSync(projectConfig)\n\t\t\t? `${projectConfig} is ignored because the project is not trusted. Start ${APP_NAME} in the project to trust it.`\n\t\t\t: undefined;\n\tconst credentials = options.credentials ?? new McpOAuthCredentialStore();\n\n\tswitch (command) {\n\t\tcase \"list\": {\n\t\t\tconst parsed = parseOptions(rest, { json: \"flag\" }, error);\n\t\t\tif (!parsed) return 1;\n\t\t\tif (parsed.positional.length > 0) {\n\t\t\t\terror(`Usage: ${APP_NAME} mcp list [--json]\\n${HELP_HINT}`);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\treturn list(loaded, parsed.values.has(\"json\"), untrustedNote, options, credentials, log);\n\t\t}\n\t\tcase \"login\":\n\t\tcase \"logout\": {\n\t\t\tconst parsed = parseOptions(\n\t\t\t\trest,\n\t\t\t\tcommand === \"login\" ? { local: \"flag\", timeout: \"value\" } : { local: \"flag\" },\n\t\t\t\terror,\n\t\t\t);\n\t\t\tif (!parsed) return 1;\n\t\t\tconst [name, ...extra] = parsed.positional;\n\t\t\tif (!name || extra.length > 0) {\n\t\t\t\terror(`Usage: ${APP_NAME} mcp ${command} <server> [-l]\\n${HELP_HINT}`);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tconst entry = loaded.servers.find((server) => server.name === name);\n\t\t\tif (!entry) {\n\t\t\t\tconst names = loaded.servers.map((server) => server.name);\n\t\t\t\tconst suggestion = names.find((candidate) => editDistance(candidate, name) <= 2);\n\t\t\t\terror(\n\t\t\t\t\t`No MCP server named \"${name}\".${suggestion ? ` Did you mean \"${suggestion}\"?` : \"\"}${untrustedNote ? ` ${untrustedNote}` : \"\"} Configured: ${names.join(\", \") || \"none\"}.`,\n\t\t\t\t);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif (parsed.values.has(\"local\") && entry.scope !== \"project\") {\n\t\t\t\terror(`MCP server \"${name}\" is defined in ${entry.source}, not in the project; omit --local.`);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tconst connection = createConnection(entry, options, credentials);\n\t\t\tconst url = connection.oauthUrl;\n\t\t\tif (!url) {\n\t\t\t\terror(`MCP server \"${name}\" does not use OAuth. Only HTTP servers without an Authorization header do.`);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif (command === \"logout\") {\n\t\t\t\tconst removed = await credentials.removeAsync(name, url);\n\t\t\t\tlog(removed ? `Signed out of MCP server \"${name}\".` : `No stored credentials for MCP server \"${name}\".`);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tconst timeout = Number(parsed.values.get(\"timeout\") ?? DEFAULT_LOGIN_TIMEOUT_SECONDS);\n\t\t\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\t\t\terror(\"--timeout must be a positive number of seconds.\");\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn await login(entry, connection, url, timeout * 1000, options, credentials, log, error);\n\t\t\t} finally {\n\t\t\t\tawait connection.close();\n\t\t\t}\n\t\t}\n\t\tdefault:\n\t\t\terror(`Unknown mcp command \"${command}\".\\n${HELP_HINT}`);\n\t\t\treturn 1;\n\t}\n}\n\n/** Levenshtein distance, to suggest a configured server name for a mistyped one. */\nfunction editDistance(a: string, b: string): number {\n\tlet previous = Array.from({ length: b.length + 1 }, (_, index) => index);\n\tfor (let i = 1; i <= a.length; i++) {\n\t\tconst current = [i];\n\t\tfor (let j = 1; j <= b.length; j++) {\n\t\t\tcurrent[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));\n\t\t}\n\t\tprevious = current;\n\t}\n\treturn previous[b.length];\n}\n\n/** Parse `KEY=VALUE` pairs of a repeatable option into a record. */\nfunction parsePairs(option: string, pairs: string[] | undefined, error: (line: string) => void) {\n\tif (!pairs) return {};\n\tconst record: Record<string, string> = {};\n\tfor (const pair of pairs) {\n\t\tconst separator = pair.indexOf(\"=\");\n\t\tif (separator <= 0) {\n\t\t\terror(`--${option} expects KEY=VALUE, got \"${pair}\".`);\n\t\t\treturn undefined;\n\t\t}\n\t\trecord[pair.slice(0, separator)] = pair.slice(separator + 1);\n\t}\n\treturn record;\n}\n\nfunction add(\n\targs: string[],\n\tprojectConfig: string,\n\toptions: McpCommandOptions,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): number {\n\tconst usage = `Usage: ${APP_NAME} mcp add <server> [options] (--url <url> | -- <command> [args...])\\n${HELP_HINT}`;\n\tconst parsed = parseOptions(\n\t\targs,\n\t\t{\n\t\t\tlocal: \"flag\",\n\t\t\turl: \"value\",\n\t\t\tenv: \"list\",\n\t\t\tcwd: \"value\",\n\t\t\theader: \"list\",\n\t\t\t\"bearer-token-env-var\": \"value\",\n\t\t\t\"oauth-client-id\": \"value\",\n\t\t\t\"oauth-client-secret\": \"value\",\n\t\t\t\"oauth-callback-port\": \"value\",\n\t\t\t\"oauth-client-name\": \"value\",\n\t\t\texposure: \"value\",\n\t\t\tdescription: \"value\",\n\t\t},\n\t\terror,\n\t\t2,\n\t);\n\tif (!parsed) return 1;\n\tconst { positional, values, lists } = parsed;\n\tconst [name, ...command] = positional;\n\tconst url = values.get(\"url\");\n\tif (!name || (url === undefined) === (command.length === 0)) {\n\t\terror(usage);\n\t\treturn 1;\n\t}\n\tconst value = (option: string) => {\n\t\tconst found = values.get(option);\n\t\treturn typeof found === \"string\" ? found : undefined;\n\t};\n\tconst exposure = value(\"exposure\");\n\tconst httpOnly = [\n\t\t\"header\",\n\t\t\"bearer-token-env-var\",\n\t\t\"oauth-client-id\",\n\t\t\"oauth-client-secret\",\n\t\t\"oauth-callback-port\",\n\t\t\"oauth-client-name\",\n\t];\n\tconst stdioOnly = [\"env\", \"cwd\"];\n\tconst misplaced = (url === undefined ? httpOnly : stdioOnly).find(\n\t\t(option) => values.has(option) || lists.has(option),\n\t);\n\tif (misplaced) {\n\t\terror(`--${misplaced} only applies to ${url === undefined ? \"HTTP servers (--url)\" : \"stdio servers\"}.`);\n\t\treturn 1;\n\t}\n\n\tlet config: Record<string, unknown>;\n\tif (typeof url === \"string\") {\n\t\tconst headers = parsePairs(\"header\", lists.get(\"header\"), error);\n\t\tif (!headers) return 1;\n\t\tconst bearer = value(\"bearer-token-env-var\");\n\t\tif (bearer !== undefined) headers.Authorization = `Bearer \\${${bearer}}`;\n\t\tconst port = value(\"oauth-callback-port\");\n\t\tconst oauth = {\n\t\t\t...(value(\"oauth-client-id\") === undefined ? {} : { clientId: value(\"oauth-client-id\") }),\n\t\t\t...(value(\"oauth-client-secret\") === undefined ? {} : { clientSecret: value(\"oauth-client-secret\") }),\n\t\t\t...(port === undefined ? {} : { callbackPort: Number(port) }),\n\t\t\t...(value(\"oauth-client-name\") === undefined ? {} : { clientName: value(\"oauth-client-name\") }),\n\t\t};\n\t\tconfig = {\n\t\t\turl,\n\t\t\t...(Object.keys(headers).length > 0 ? { headers } : {}),\n\t\t\t...(Object.keys(oauth).length > 0 ? { oauth } : {}),\n\t\t};\n\t} else {\n\t\tconst env = parsePairs(\"env\", lists.get(\"env\"), error);\n\t\tif (!env) return 1;\n\t\tconst [executable, ...commandArgs] = command;\n\t\tconfig = {\n\t\t\tcommand: executable,\n\t\t\t...(commandArgs.length > 0 ? { args: commandArgs } : {}),\n\t\t\t...(Object.keys(env).length > 0 ? { env } : {}),\n\t\t\t...(value(\"cwd\") === undefined ? {} : { cwd: value(\"cwd\") }),\n\t\t};\n\t}\n\tif (exposure !== undefined) config.exposure = exposure;\n\tconst description = value(\"description\");\n\tif (description !== undefined) config.description = description;\n\tconst validated = validateMcpServerConfig(name, config);\n\tif (typeof validated === \"string\") {\n\t\terror(validated);\n\t\treturn 1;\n\t}\n\n\tconst project = values.has(\"local\");\n\tconst path = project ? projectConfig : join(options.agentDir, \"mcp.json\");\n\tconst scope = project ? \"project\" : \"global\";\n\tlet replaced: boolean;\n\ttry {\n\t\treplaced = addMcpServerConfig(path, name, validated);\n\t} catch (addError) {\n\t\terror(`Could not update ${path}: ${errorMessage(addError)}`);\n\t\treturn 1;\n\t}\n\tlog(`${replaced ? \"Replaced\" : \"Added\"} ${scope} MCP server \"${name}\" in ${path}.`);\n\tif (project && new ProjectTrustStore(options.agentDir).get(options.cwd) !== true) {\n\t\tlog(`The project is not trusted, so ${path} is ignored until you start ${APP_NAME} in the project and trust it.`);\n\t}\n\t// HTTP servers without an Authorization header may use OAuth.\n\tconst mayNeedSignIn =\n\t\t\"url\" in validated &&\n\t\t!Object.keys(validated.headers ?? {}).some((header) => header.toLowerCase() === \"authorization\");\n\tlog(\n\t\t`Check it with: ${APP_NAME} mcp list${mayNeedSignIn ? `. If it requires sign-in: ${APP_NAME} mcp login ${name}` : \"\"}`,\n\t);\n\treturn 0;\n}\n\nfunction remove(\n\targs: string[],\n\tprojectConfig: string,\n\toptions: McpCommandOptions,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): number {\n\tconst parsed = parseOptions(args, { local: \"flag\" }, error);\n\tif (!parsed) return 1;\n\tconst [name, ...extra] = parsed.positional;\n\tif (!name || extra.length > 0) {\n\t\terror(`Usage: ${APP_NAME} mcp remove <server> [-l]\\n${HELP_HINT}`);\n\t\treturn 1;\n\t}\n\tconst project = parsed.values.has(\"local\");\n\tconst globalConfig = join(options.agentDir, \"mcp.json\");\n\tconst path = project ? projectConfig : globalConfig;\n\tconst scope = project ? \"project\" : \"global\";\n\tlet removed: boolean;\n\ttry {\n\t\tremoved = removeMcpServerConfig(path, name);\n\t} catch (removeError) {\n\t\terror(`Could not update ${path}: ${errorMessage(removeError)}`);\n\t\treturn 1;\n\t}\n\tif (removed) {\n\t\tlog(`Removed ${scope} MCP server \"${name}\" from ${path}.`);\n\t\treturn 0;\n\t}\n\tconst other = loadMcpConfig({ agentDir: options.agentDir, cwd: options.cwd, projectTrusted: true }).servers.find(\n\t\t(server) => server.name === name && server.scope !== scope,\n\t);\n\terror(\n\t\t`No ${scope} MCP server named \"${name}\" in ${path}.${other ? ` It is defined in ${other.source}${other.scope === \"project\" ? \"; use --local\" : \"; omit --local\"}.` : \"\"}`,\n\t);\n\treturn 1;\n}\n\nasync function list(\n\tloaded: LoadedMcpConfig,\n\tjson: boolean,\n\tuntrustedNote: string | undefined,\n\toptions: McpCommandOptions,\n\tcredentials: McpOAuthCredentialStore,\n\tlog: (line: string) => void,\n): Promise<number> {\n\tconst reports = await Promise.all(\n\t\tloaded.servers.map(async (entry): Promise<ServerReport> => {\n\t\t\tconst report: ServerReport = {\n\t\t\t\tname: entry.name,\n\t\t\t\tscope: entry.scope ?? \"global\",\n\t\t\t\tsource: entry.source,\n\t\t\t\t...(entry.override ? { override: entry.override } : {}),\n\t\t\t\tenabled: entry.config.enabled !== false,\n\t\t\t\texposure: entry.config.exposure ?? \"codemode\",\n\t\t\t\ttransport: describeTransport(entry),\n\t\t\t\tstate: \"disabled\",\n\t\t\t\ttools: [],\n\t\t\t};\n\t\t\tif (!report.enabled) return report;\n\t\t\tconst connection = createConnection(entry, options, credentials);\n\t\t\ttry {\n\t\t\t\tawait connection.getClient();\n\t\t\t} catch {\n\t\t\t\t// The connection records the state and error.\n\t\t\t}\n\t\t\treport.state = connection.state;\n\t\t\treport.tools = connection.tools.map((tool) => tool.name);\n\t\t\tconst overrides = connection.tools.flatMap((tool) => {\n\t\t\t\tconst exposure = getMcpToolExposure(entry.config, tool.name);\n\t\t\t\treturn exposure === report.exposure ? [] : [[tool.name, exposure] as const];\n\t\t\t});\n\t\t\tif (overrides.length > 0) report.toolExposure = Object.fromEntries(overrides);\n\t\t\tif (connection.hasResources) report.resources = true;\n\t\t\tif (connection.state !== \"connected\" && connection.error) report.error = connection.error;\n\t\t\tawait connection.close();\n\t\t\treturn report;\n\t\t}),\n\t);\n\tconst failed = loaded.errors.length > 0 || reports.some((report) => report.enabled && report.state !== \"connected\");\n\n\tif (json) {\n\t\tlog(\n\t\t\tJSON.stringify(\n\t\t\t\t{ servers: reports, errors: loaded.errors, ...(untrustedNote ? { note: untrustedNote } : {}) },\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t);\n\t\treturn failed ? 1 : 0;\n\t}\n\tif (reports.length === 0 && loaded.errors.length === 0) {\n\t\tlog(\n\t\t\t`No MCP servers configured. Add them to ${join(options.agentDir, \"mcp.json\")} or ${CONFIG_DIR_NAME}/mcp.json.`,\n\t\t);\n\t}\n\tfor (const report of reports) {\n\t\tconst state =\n\t\t\treport.state === \"connected\"\n\t\t\t\t? `connected, ${report.tools.length} tool${report.tools.length === 1 ? \"\" : \"s\"}`\n\t\t\t\t: report.state === \"needs-auth\"\n\t\t\t\t\t? \"needs sign-in\"\n\t\t\t\t\t: report.state;\n\t\tlog(`${report.name}: ${state} (${report.exposure}, ${report.scope})`);\n\t\tlog(` ${report.transport}`);\n\t\tif (report.override) log(` project override: ${report.override}`);\n\t\tif (report.state === \"needs-auth\") log(` sign in with: ${APP_NAME} mcp login ${report.name}`);\n\t\tif (report.tools.length > 0) {\n\t\t\tconst tools = report.tools.map((tool) => {\n\t\t\t\tconst exposure = report.toolExposure?.[tool];\n\t\t\t\treturn exposure ? `${tool} [${exposure}]` : tool;\n\t\t\t});\n\t\t\tlog(` tools: ${tools.join(\", \")}`);\n\t\t}\n\t\tif (report.resources) log(\" offers resources\");\n\t\tif (report.error) log(` ${report.error.split(\"\\n\").join(\"\\n \")}`);\n\t}\n\tfor (const configError of loaded.errors) log(`config error: ${configError}`);\n\tif (untrustedNote) log(untrustedNote);\n\treturn failed ? 1 : 0;\n}\n\nasync function login(\n\tentry: McpServerEntry,\n\tconnection: McpServerConnection,\n\turl: string,\n\ttimeoutMs: number,\n\toptions: McpCommandOptions,\n\tcredentials: McpOAuthCredentialStore,\n\tlog: (line: string) => void,\n\terror: (line: string) => void,\n): Promise<number> {\n\tconst { name } = entry;\n\t// Connecting first answers whether a sign-in is needed and records the server's challenge.\n\ttry {\n\t\tawait connection.getClient();\n\t\tlog(`Already signed in to MCP server \"${name}\" (${connection.tools.length} tools).`);\n\t\treturn 0;\n\t} catch {\n\t\tif (connection.state !== \"needs-auth\") {\n\t\t\terror(`MCP server \"${name}\" failed to connect: ${connection.error ?? \"unknown error\"}`);\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tconst openUrl = options.openUrl ?? openBrowser;\n\tconst interactive = process.stdin.isTTY === true && options.openUrl === undefined;\n\ttry {\n\t\tawait signInMcpServer({\n\t\t\tserverUrl: url,\n\t\t\tstore: credentials.forServer(name, url),\n\t\t\tsettings: connection.oauthSettings(),\n\t\t\tchallenge: connection.challenge,\n\t\t\tprompt: {\n\t\t\t\tshowAuthorizationUrl: (authorizationUrl) => {\n\t\t\t\t\tlog(`Sign in to MCP server \"${name}\" in your browser:\\n${authorizationUrl.href}`);\n\t\t\t\t\topenUrl(authorizationUrl.href);\n\t\t\t\t},\n\t\t\t\tpromptForRedirectUrl: (signal) => waitForRedirectUrl(signal, interactive),\n\t\t\t},\n\t\t\tsignal: AbortSignal.timeout(timeoutMs),\n\t\t});\n\t} catch (signInError) {\n\t\terror(\n\t\t\tsignInError instanceof McpSignInCancelledError\n\t\t\t\t? `Sign-in to MCP server \"${name}\" was cancelled or not completed within ${Math.round(timeoutMs / 1000)} seconds.`\n\t\t\t\t: `Sign-in to MCP server \"${name}\" failed: ${errorMessage(signInError)}`,\n\t\t);\n\t\treturn 1;\n\t}\n\tconnection.challenge = undefined;\n\ttry {\n\t\tawait connection.reconnect();\n\t} catch (connectError) {\n\t\terror(`Signed in, but ${errorMessage(connectError)}`);\n\t\treturn 1;\n\t}\n\tlog(`Signed in to MCP server \"${name}\" (${connection.tools.length} tools).`);\n\treturn 0;\n}\n\n/**\n * The pasted redirect URL in a terminal; otherwise only the browser callback can finish the sign-in.\n * Resolves to undefined when `signal` aborts: the callback arrived, or the sign-in timed out.\n */\nasync function waitForRedirectUrl(signal: AbortSignal, interactive: boolean): Promise<string | undefined> {\n\tif (!interactive) {\n\t\tif (!signal.aborted) await new Promise((resolve) => signal.addEventListener(\"abort\", resolve, { once: true }));\n\t\treturn undefined;\n\t}\n\tconst readline = createInterface({ input: process.stdin, output: process.stderr });\n\ttry {\n\t\treturn await readline.question(\"If the browser cannot reach this machine, paste the URL it was redirected to: \", {\n\t\t\tsignal,\n\t\t});\n\t} catch {\n\t\treturn undefined;\n\t} finally {\n\t\treadline.close();\n\t}\n}\n"]}
@@ -2,9 +2,13 @@ import { type Static, Type } from "typebox";
2
2
  import type { ExtensionAPI, ToolDefinition, ToolInfo, ToolNamespace } from "../../core/extensions/types.ts";
3
3
  export declare const TOOL_SEARCH_TOOL_NAME = "tool_search";
4
4
  export declare const DEFAULT_TOOL_SEARCH_LIMIT = 8;
5
+ /** A tool as the ranker sees it: its name and the texts built by {@link createToolSearchDocument}. */
5
6
  export interface ToolSearchDocument {
6
7
  name: string;
8
+ /** Description, schema descriptions, and property names. */
7
9
  text: string;
10
+ /** Name, description, and instructions of the tool's namespace. */
11
+ namespaceText?: string;
8
12
  }
9
13
  export interface ToolSearchMatch {
10
14
  name: string;
@@ -13,7 +17,12 @@ export interface ToolSearchMatch {
13
17
  export interface ToolRanker {
14
18
  rank(query: string, documents: readonly ToolSearchDocument[], limit: number): ToolSearchMatch[];
15
19
  }
20
+ /** Unicode word segmentation with identifier boundaries and English stop words and singular forms. */
16
21
  export declare function tokenize(text: string): string[];
22
+ /**
23
+ * Search text of a tool: the description and the schema descriptions and property names, and
24
+ * separately the namespace name, description, and instructions. The ranker reads the name from `name`.
25
+ */
17
26
  export declare function createToolSearchDocument(tool: Pick<ToolInfo, "name" | "description" | "parameters">, namespace?: ToolNamespace): ToolSearchDocument;
18
27
  /**
19
28
  * The tool names `query` names, as {@link isNameQuery} matches them: the exact name when it is
@@ -22,9 +31,18 @@ export declare function createToolSearchDocument(tool: Pick<ToolInfo, "name" | "
22
31
  */
23
32
  export declare function resolveToolNames(query: string, names: readonly string[]): string[];
24
33
  /**
25
- * Okapi BM25 with the usual parameters. A query that names a tool ranks that tool first, because
26
- * length normalization can otherwise rank a short description sharing the name's words above it.
27
- * Ties keep document order.
34
+ * Okapi BM25 over the description, with the name and the namespace as separate fields:
35
+ * - a query that names a tool (see {@link isNameQuery}) ranks that tool first, before coverage;
36
+ * - a tool that matches more of the query's terms, in any field, ranks above one that matches
37
+ * fewer, whatever their scores: for `screenshot window`, a tool whose description has both words
38
+ * beats `window`, whose name has one;
39
+ * - a query term in the name scores more than any number of mentions in the description;
40
+ * - a tool whose whole local name is in the query (`app` in `peekaboo app` for
41
+ * `mcp__peekaboo__app`) gets a bonus worth one more match of every query term, so among tools
42
+ * matching as many terms it mostly wins over tools that only mention the words.
43
+ *
44
+ * The description alone is length-normalized, so a long name or long namespace instructions do
45
+ * not lower a tool's score. Ties keep document order.
28
46
  */
29
47
  export declare class Bm25Ranker implements ToolRanker {
30
48
  private readonly k1;
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/extensions/tool-search/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG5G,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AACnD,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AACD,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,UAAU;IAC1B,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,kBAAkB,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe,EAAE,CAAC;CAChG;AA8BD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,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