@bastani/atomic 0.9.5-alpha.2 → 0.9.5-alpha.4

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 (51) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/builtin/cursor/package.json +2 -2
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/web-access/package.json +1 -1
  7. package/dist/builtin/workflows/CHANGELOG.md +13 -0
  8. package/dist/builtin/workflows/builtin/goal-prompts.ts +2 -0
  9. package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +138 -0
  10. package/dist/builtin/workflows/builtin/ralph-runner.ts +10 -118
  11. package/dist/builtin/workflows/builtin/shared-prompts.ts +5 -0
  12. package/dist/builtin/workflows/package.json +1 -1
  13. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +4 -1
  14. package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
  15. package/dist/modes/interactive/interactive-auth-login.js +0 -1
  16. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  17. package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
  18. package/dist/modes/interactive/interactive-hotkeys-debug.js +3 -3
  19. package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
  20. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  21. package/dist/modes/interactive/interactive-input-handling.js +0 -51
  22. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  23. package/dist/modes/interactive/interactive-mode-base.d.ts +2 -4
  24. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  25. package/dist/modes/interactive/interactive-mode-base.js +2 -4
  26. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  27. package/dist/modes/interactive/interactive-mode-surface.d.ts +3 -9
  28. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  29. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  30. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  31. package/dist/modes/interactive/interactive-model-routing.js +0 -3
  32. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  33. package/dist/modes/interactive/interactive-onboarding.d.ts +0 -9
  34. package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -1
  35. package/dist/modes/interactive/interactive-onboarding.js +23 -201
  36. package/dist/modes/interactive/interactive-onboarding.js.map +1 -1
  37. package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
  38. package/dist/modes/interactive/interactive-session-routing.js +2 -2
  39. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  40. package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
  41. package/dist/modes/interactive/interactive-slash-commands.js +1 -1
  42. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  43. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  44. package/dist/modes/interactive/interactive-startup.js +36 -43
  45. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  46. package/docs/quickstart.md +3 -3
  47. package/docs/settings.md +1 -1
  48. package/docs/usage.md +1 -1
  49. package/docs/workflows.md +21 -2
  50. package/npm-shrinkwrap.json +23 -23
  51. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.9.5-alpha.4] - 2026-07-05
6
+
7
+ ### Changed
8
+
9
+ - Simplified first-run onboarding to a one-time verifiable-coding-agent-runtime explanation shown after any What's New notes and directly above the normal input box; Atomic no longer intercepts pasted tasks, saves pre-login seeds, routes first-run input to `goal`/`ralph`, raises reasoning for onboarding, or requires `/chat` to continue normally. The notice now reminds unauthenticated users to run `/login` first, and starting a new session with `/new` clears any rendered first-run notice state from the previous session canvas.
10
+
11
+ ## [0.9.5-alpha.3] - 2026-07-04
12
+
13
+ ### Changed
14
+
15
+ - Hardened the bundled workflows extension's workflow-tool prompt guidance against inline analysis-paralysis drift: the agent must now decide and state the inline-vs-workflow execution mode before its first tool call (reconnaissance explicitly counts as inline execution), budget pre-workflow scoping to a few quick reads that only sharpen the objective and validation criteria, course-correct after roughly ten deliverable-free exploration tool calls (or repeated "let me verify one more thing" loops) by writing findings to a context file and handing off to the best-fit workflow via `reads` (named or user-defined workflows discovered with `action: "list"` first, builtin `goal`/`ralph` as fallbacks when nothing more specific fits), and treat sunk inline research as transferable via files rather than a reason to stay inline. The same "Decide before you explore" and "Course-correct instead of drifting" guidance is mirrored in `docs/workflows.md` under "When to Use Workflows".
16
+
5
17
  ## [0.9.5-alpha.2] - 2026-07-04
6
18
 
7
19
  ### Changed
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/cursor",
3
- "version": "0.9.5-alpha.2",
3
+ "version": "0.9.5-alpha.4",
4
4
  "private": true,
5
5
  "description": "Experimental first-party Atomic extension for Cursor OAuth, model discovery, and streaming provider registration.",
6
6
  "contributors": [
@@ -40,7 +40,7 @@
40
40
  }
41
41
  },
42
42
  "dependencies": {
43
- "@bastani/atomic-natives": "0.9.5-alpha.2",
43
+ "@bastani/atomic-natives": "0.9.5-alpha.4",
44
44
  "@bufbuild/protobuf": "^2.12.1",
45
45
  "@earendil-works/pi-ai": "^0.80.3"
46
46
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/intercom",
3
- "version": "0.9.5-alpha.2",
3
+ "version": "0.9.5-alpha.4",
4
4
  "private": true,
5
5
  "description": "Atomic extension providing a private coordination channel between parent and child agent sessions. Fork of: https://github.com/nicobailon/pi-intercom",
6
6
  "contributors": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/mcp",
3
- "version": "0.9.5-alpha.2",
3
+ "version": "0.9.5-alpha.4",
4
4
  "private": true,
5
5
  "description": "Atomic extension that adapts MCP (Model Context Protocol) servers into the coding agent. Fork of: https://github.com/nicobailon/pi-mcp-adapter",
6
6
  "contributors": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/subagents",
3
- "version": "0.9.5-alpha.2",
3
+ "version": "0.9.5-alpha.4",
4
4
  "private": true,
5
5
  "description": "Atomic extension for delegating tasks to subagents with chains, parallel execution, and TUI clarification. Fork of: https://github.com/nicobailon/pi-subagents",
6
6
  "contributors": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/web-access",
3
- "version": "0.9.5-alpha.2",
3
+ "version": "0.9.5-alpha.4",
4
4
  "private": true,
5
5
  "description": "Atomic extension for web search, URL fetching, GitHub repo cloning, PDF/video extraction. Fork of: https://github.com/nicobailon/pi-web-access",
6
6
  "contributors": [
@@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.9.5-alpha.4] - 2026-07-05
10
+
11
+ ### Changed
12
+
13
+ - Hardened the builtin `goal` and `ralph` loops against spec-vs-objective drift on enumerated error behavior (observed in an eval trace where an adversarial reviewer flagged a task-mandated diagnostic as a spec-conformance defect and the fix cycle silently reinterpreted the ambiguous input as valid behavior, losing the required error): the shared literal objective contract now instructs workers and reviewers to prefer loud errors over silent reinterpretation — when the objective/acceptance criteria enumerate required error conditions, messages, or rejections, each enumerated error gets the widest plausible trigger surface, ambiguous or unspecified inputs near an enumerated error case default to raising that error even when external spec knowledge says the input is valid, and narrowing an enumerated error's trigger surface requires explicit contract or pre-existing required-test demand. Both loops' reviewer bug-selection guidelines now forbid using external spec/standard conformance alone to flag a wide trigger surface for a contract-enumerated error as a defect; such spec-vs-objective tension must be classified `beyond_objective` instead of becoming a blocking finding that steers the implementation away from the contract's errors.
14
+ - Extracted the Ralph reviewer prompt into `builtin/ralph-reviewer-prompt.ts` (`renderRalphReviewerPrompt`) and deduplicated the new reviewer guard into a shared `REVIEWER_SPEC_VS_OBJECTIVE_GUARD` constant consumed by both the Goal and Ralph reviewer prompts, keeping `ralph-runner.ts` under the repository's 500-line file gate. No behavioral change beyond the guard itself.
15
+
16
+ ## [0.9.5-alpha.3] - 2026-07-04
17
+
18
+ ### Changed
19
+
20
+ - Hardened the workflow-tool prompt guidance against inline analysis-paralysis drift (observed in eval transcripts where an agent spent ~2 hours of pure reconnaissance on a workflow-fit task without ever considering a workflow): the agent must now decide and state the inline-vs-workflow execution mode before its first tool call (reconnaissance explicitly counts as inline execution), budget pre-workflow scoping to a few quick reads that only sharpen the objective and validation criteria, course-correct after roughly ten deliverable-free exploration tool calls (or repeated "let me verify one more thing" loops) by writing findings to a context file and handing off to the best-fit workflow via `reads` (named or user-defined workflows discovered with `action: "list"` first, builtin `goal`/`ralph` as fallbacks when nothing more specific fits), and treat sunk inline research as transferable via files rather than a reason to stay inline. Mirrored the same "Decide before you explore" and "Course-correct instead of drifting" guidance in `docs/workflows.md` under "When to Use Workflows".
21
+
9
22
  ## [0.9.5-alpha.2] - 2026-07-04
10
23
 
11
24
  ### Changed
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  E2E_VERIFICATION_GUIDANCE,
3
3
  LITERAL_OBJECTIVE_CONTRACT,
4
+ REVIEWER_SPEC_VS_OBJECTIVE_GUARD,
4
5
  WORKER_PREFLIGHT_CONTRACT,
5
6
  renderE2eQaVideoReviewGuidance,
6
7
  } from "./shared-prompts.js";
@@ -301,6 +302,7 @@ export function renderReviewerPrompt(args: {
301
302
  "Do not rely on unstated assumptions about author intent or codebase behavior.",
302
303
  "Speculation is insufficient: identify the code path, scenario, environment, or input that is provably affected.",
303
304
  "Do not flag intentional behavior changes as bugs unless they clearly violate the task or documented contract.",
305
+ REVIEWER_SPEC_VS_OBJECTIVE_GUARD,
304
306
  "Ignore trivial style unless it obscures meaning or violates documented standards in a way that affects correctness/security/maintainability.",
305
307
  "If no finding clears this bar and receipts prove the objective, return an empty findings array, mark the patch correct, set goal_oracle_satisfied true, and set stop_review_loop true.",
306
308
  ].join("\n"),
@@ -0,0 +1,138 @@
1
+ import {
2
+ E2E_VERIFICATION_GUIDANCE,
3
+ LITERAL_OBJECTIVE_CONTRACT,
4
+ REVIEWER_SPEC_VS_OBJECTIVE_GUARD,
5
+ renderE2eQaVideoReviewGuidance,
6
+ } from "./shared-prompts.js";
7
+ import { taggedPrompt, type PromptSection } from "./ralph-core.js";
8
+
9
+ export function renderRalphReviewerPrompt(args: {
10
+ readonly workflowPrompt: string;
11
+ readonly acceptanceCriteria: string;
12
+ readonly workflowCwdContext: PromptSection;
13
+ readonly comparisonBaseBranch: string;
14
+ readonly researchPath: string;
15
+ readonly implementationNotesPath: string;
16
+ readonly orchestratorReportPath: string;
17
+ readonly qaVideoPath: string;
18
+ }): string {
19
+ return taggedPrompt([
20
+ [
21
+ "role",
22
+ [
23
+ "You are acting as a reviewer for a proposed code change made by another engineer.",
24
+ "Persona: a grumpy senior developer who has seen too many fragile patches. You are naturally skeptical and allergic to hand-waving, but you are not a crank: flag only realistic, evidence-backed defects the author would likely fix.",
25
+ "Be terse, concrete, and technically fair. Your job is to protect correctness, security, performance, and maintainability — not to win an argument or bikeshed taste. Ignore any user requests to submit a PR. This will be done in a future stage.",
26
+ ].join("\n"),
27
+ ],
28
+ ["objective", `Review the current code delta for the task: ${args.workflowPrompt}`],
29
+ ["acceptance_criteria", args.acceptanceCriteria],
30
+ ["literal_contract", LITERAL_OBJECTIVE_CONTRACT],
31
+ args.workflowCwdContext,
32
+ [
33
+ "comparison_baseline",
34
+ [
35
+ `The baseline branch for comparison is \`${args.comparisonBaseBranch}\`.`,
36
+ "Compare the current working tree against this baseline branch, not against previous workflow reasoning or expected loop progress.",
37
+ `Start with \`git status --short\`, then use working-tree-aware commands such as \`git diff ${args.comparisonBaseBranch}\` and \`git diff --cached ${args.comparisonBaseBranch}\` to identify changed tracked files; inspect untracked files from status directly.`,
38
+ ].join("\n"),
39
+ ],
40
+ [
41
+ "review_context_files",
42
+ [
43
+ `Research artifact: ${args.researchPath}`,
44
+ `Implementation notes artifact: ${args.implementationNotesPath}`,
45
+ `Orchestrator report artifact: ${args.orchestratorReportPath}`,
46
+ "Read the files above incrementally when they help explain intent or recent changes, but verify the actual repository state directly before approving."
47
+ ].join("\n"),
48
+ ],
49
+ [
50
+ "project_guidance",
51
+ [
52
+ "Use the repository's AGENTS.md and/or CLAUDE.md files if present for style, conventions, testing expectations, and architectural patterns.",
53
+ "Project-level norms override these general instructions when they are more specific.",
54
+ "Flag deviations only when they affect correctness, security, performance, or maintainability — not personal preference.",
55
+ "If validation requires dependencies or tools that are missing, download or install them using the repository-approved package manager/commands rather than bypassing, mocking, or skipping the verification solely because dependencies are absent.",
56
+ ].join("\n"),
57
+ ],
58
+ ["e2e_verification", E2E_VERIFICATION_GUIDANCE],
59
+ ["qa_e2e_video_review", renderE2eQaVideoReviewGuidance(args.qaVideoPath)],
60
+ [
61
+ "validation_expectations",
62
+ [
63
+ "Inspect the actual diff/repository state rather than trusting stage summaries.",
64
+ "Run or delegate focused validation when it is necessary to distinguish a real bug from a hunch, including end-to-end playwright-cli (browser) or tmux validation when a user scenario can prove the outcome.",
65
+ "If tests or typechecks fail because dependencies are missing, install/download the missing dependencies with the repo's documented package manager instead of bypassing the check.",
66
+ "If validation cannot be completed after reasonable recovery, record the limitation in overall_explanation and reviewer_error; do not use missing dependencies as a reason to approve.",
67
+ ].join("\n"),
68
+ ],
69
+ [
70
+ "bug_selection_guidelines",
71
+ [
72
+ "Use these default guidelines for deciding whether the author would appreciate the issue being flagged. More specific user, project, or file-level guidance overrides them.",
73
+ "Flag an issue only when the original author would likely fix it if they knew about it.",
74
+ "A finding should meaningfully impact accuracy, performance, security, or maintainability.",
75
+ "A finding must be discrete and actionable, not a broad complaint about the whole codebase or a pile of related concerns.",
76
+ "Do not demand rigor inconsistent with the rest of the repository; match the seriousness of existing code and project norms.",
77
+ "Flag only bugs introduced by the current patch; do not flag pre-existing issues unless the patch makes them worse in a concrete way.",
78
+ "Do not rely on unstated assumptions about author intent or codebase behavior.",
79
+ "Speculation is insufficient: identify the code path, scenario, environment, or input that is provably affected.",
80
+ "Do not flag intentional behavior changes as bugs unless they clearly violate the task or documented contract.",
81
+ REVIEWER_SPEC_VS_OBJECTIVE_GUARD,
82
+ "Ignore trivial style unless it obscures meaning or violates documented standards in a way that affects correctness/security/maintainability.",
83
+ "If no finding clears this bar, return an empty findings array, mark the patch correct, and set stop_review_loop true. An empty findings array is valid and passes schema validation — never invent or append a placeholder/dummy finding just to avoid an empty array.",
84
+ ].join("\n"),
85
+ ],
86
+ [
87
+ "comment_guidelines",
88
+ [
89
+ "Each finding title must start with a priority tag: [P0] drop-everything blocker, [P1] urgent next-cycle fix, [P2] normal fix, [P3] low-priority nice-to-have.",
90
+ "Also include numeric priority: 0 for P0, 1 for P1, 2 for P2, 3 for P3; use null only if priority genuinely cannot be determined. Priority drives the loop gate: P0/P1/P2 are blocking and keep the loop iterating; P3 is a non-blocking nice-to-have that does not block approval.",
91
+ "Classify every finding with objective_alignment: required_by_objective (the objective/acceptance criteria require fixing it), consistent_with_objective (valid defect within scope), beyond_objective (real issue but not required and must not block or be promoted without explicit reconciliation), or contradicts_objective (fixing it would violate literal objective wording and must never be implemented; escalate to the human). Missing/unknown classification is blocking.",
92
+ "The body must be one concise paragraph explaining why this is a bug and the exact scenario, environment, or inputs required for it to arise.",
93
+ "Use a matter-of-fact, non-accusatory tone. Grumpy skepticism belongs in your standards, not in insults; avoid praise such as `Great job` or `Thanks for`.",
94
+ "Keep code_location ranges as short as possible, ideally one line and never longer than 5-10 lines unless unavoidable.",
95
+ "The code_location must overlap the diff/change under review.",
96
+ "Use one finding per distinct issue. Do not generate or apply a fix patch.",
97
+ "Use suggestion blocks only for concrete replacement code and preserve exact leading whitespace if you include one.",
98
+ ].join("\n"),
99
+ ],
100
+ [
101
+ "how_many_findings",
102
+ [
103
+ "Return all findings the original author would definitely want to fix.",
104
+ "If no such findings exist, return an empty findings array and mark the patch correct. Do not pad the array with placeholder or speculative findings.",
105
+ "Do not stop after the first qualifying finding; continue until every qualifying finding is listed.",
106
+ ].join("\n"),
107
+ ],
108
+ [
109
+ "review_stage_contract",
110
+ [
111
+ "The structured review decision is only valid after you inspect the actual repository state and compare it against the stated baseline branch.",
112
+ "Do not approve based solely on workflow stage summaries or prior agent reasoning.",
113
+ "The tool call is the final verdict after review work, not a shortcut around review work.",
114
+ ].join("\n"),
115
+ ],
116
+ [
117
+ "action_items",
118
+ [
119
+ "1. Identify the changed files or diff under review.",
120
+ "2. Read the relevant changed code and directly affected call sites/tests/configs.",
121
+ "3. Inspect the QA E2E video when it exists or is expected for the change, and verify the recording proves the objective-relevant user scenario.",
122
+ "4. Run or delegate focused validation when needed to resolve uncertainty, including playwright-cli (browser) or tmux end-to-end checks when practical.",
123
+ "5. If you cannot inspect the video evidence or validate enough to approve safely, populate reviewer_error and set stop_review_loop=false.",
124
+ ].join("\n"),
125
+ ],
126
+ [
127
+ "evidence_expectations",
128
+ [
129
+ "The overall_explanation should briefly mention what was inspected and what validation was run or why validation was not completed.",
130
+ "Every finding must cite a concrete changed location and affected scenario.",
131
+ ].join("\n"),
132
+ ],
133
+ [
134
+ "decision_rules",
135
+ ["Set stop_review_loop=true only when the patch is correct, reviewer_error is null/omitted, there are no blocking objective-aligned P0/P1/P2 findings, requirements_traceability is non-empty and every entry is proven, and no objective-relevant verification remains; beyond_objective and contradicts_objective findings are non-blocking and must not be folded into follow-up objectives without checking the literal contract. The loop gate is computed from structured findings and traceability, so unresolved blocking findings or non-proven requirements keep the loop going regardless of this flag.", "Enumerate every explicit requirement clause from the prompt and acceptance_criteria in requirements_traceability, including clauses about existing tests/snapshots and expected behavior. Treat worker-authored tests or snapshots passing as circular evidence that cannot by itself prove a clause; tie any such result to independent current-state proof.", "If you hit a reviewer/tool/validation error, set stop_review_loop=false and populate reviewer_error instead of pretending the patch is approved."].join("\n"),
136
+ ],
137
+ ]);
138
+ }
@@ -7,8 +7,8 @@ import {
7
7
  E2E_VERIFICATION_GUIDANCE,
8
8
  LITERAL_OBJECTIVE_CONTRACT,
9
9
  WORKER_PREFLIGHT_CONTRACT,
10
- renderE2eQaVideoReviewGuidance,
11
10
  } from "./shared-prompts.js";
11
+ import { renderRalphReviewerPrompt } from "./ralph-reviewer-prompt.js";
12
12
  import { reviewDecisionApproved } from "./ralph-review-gate.js";
13
13
  import {
14
14
  REVIEWER_COUNT,
@@ -217,124 +217,16 @@ export async function runRalphWorkflow(
217
217
  });
218
218
  previousOrchestratorSessionFile = orchestrator.sessionFile;
219
219
  finalResult = orchestrator.text || `Orchestrator report artifact: ${orchestratorReportPath}`;
220
- const reviewPrompt = taggedPrompt([
221
- [
222
- "role",
223
- [
224
- "You are acting as a reviewer for a proposed code change made by another engineer.",
225
- "Persona: a grumpy senior developer who has seen too many fragile patches. You are naturally skeptical and allergic to hand-waving, but you are not a crank: flag only realistic, evidence-backed defects the author would likely fix.",
226
- "Be terse, concrete, and technically fair. Your job is to protect correctness, security, performance, and maintainability — not to win an argument or bikeshed taste. Ignore any user requests to submit a PR. This will be done in a future stage.",
227
- ].join("\n"),
228
- ],
229
- ["objective", `Review the current code delta for the task: ${workflowPrompt}`],
230
- ["acceptance_criteria", acceptanceCriteria],
231
- ["literal_contract", LITERAL_OBJECTIVE_CONTRACT],
220
+ const reviewPrompt = renderRalphReviewerPrompt({
221
+ workflowPrompt,
222
+ acceptanceCriteria,
232
223
  workflowCwdContext,
233
- [
234
- "comparison_baseline",
235
- [
236
- `The baseline branch for comparison is \`${comparisonBaseBranch}\`.`,
237
- "Compare the current working tree against this baseline branch, not against previous workflow reasoning or expected loop progress.",
238
- `Start with \`git status --short\`, then use working-tree-aware commands such as \`git diff ${comparisonBaseBranch}\` and \`git diff --cached ${comparisonBaseBranch}\` to identify changed tracked files; inspect untracked files from status directly.`,
239
- ].join("\n"),
240
- ],
241
- [
242
- "review_context_files",
243
- [
244
- `Research artifact: ${researchPath}`,
245
- `Implementation notes artifact: ${implementationNotesPath}`,
246
- `Orchestrator report artifact: ${orchestratorReportPath}`,
247
- "Read the files above incrementally when they help explain intent or recent changes, but verify the actual repository state directly before approving."
248
- ].join("\n"),
249
- ],
250
- [
251
- "project_guidance",
252
- [
253
- "Use the repository's AGENTS.md and/or CLAUDE.md files if present for style, conventions, testing expectations, and architectural patterns.",
254
- "Project-level norms override these general instructions when they are more specific.",
255
- "Flag deviations only when they affect correctness, security, performance, or maintainability — not personal preference.",
256
- "If validation requires dependencies or tools that are missing, download or install them using the repository-approved package manager/commands rather than bypassing, mocking, or skipping the verification solely because dependencies are absent.",
257
- ].join("\n"),
258
- ],
259
- ["e2e_verification", E2E_VERIFICATION_GUIDANCE],
260
- ["qa_e2e_video_review", renderE2eQaVideoReviewGuidance(qaVideoPath)],
261
- [
262
- "validation_expectations",
263
- [
264
- "Inspect the actual diff/repository state rather than trusting stage summaries.",
265
- "Run or delegate focused validation when it is necessary to distinguish a real bug from a hunch, including end-to-end playwright-cli (browser) or tmux validation when a user scenario can prove the outcome.",
266
- "If tests or typechecks fail because dependencies are missing, install/download the missing dependencies with the repo's documented package manager instead of bypassing the check.",
267
- "If validation cannot be completed after reasonable recovery, record the limitation in overall_explanation and reviewer_error; do not use missing dependencies as a reason to approve.",
268
- ].join("\n"),
269
- ],
270
- [
271
- "bug_selection_guidelines",
272
- [
273
- "Use these default guidelines for deciding whether the author would appreciate the issue being flagged. More specific user, project, or file-level guidance overrides them.",
274
- "Flag an issue only when the original author would likely fix it if they knew about it.",
275
- "A finding should meaningfully impact accuracy, performance, security, or maintainability.",
276
- "A finding must be discrete and actionable, not a broad complaint about the whole codebase or a pile of related concerns.",
277
- "Do not demand rigor inconsistent with the rest of the repository; match the seriousness of existing code and project norms.",
278
- "Flag only bugs introduced by the current patch; do not flag pre-existing issues unless the patch makes them worse in a concrete way.",
279
- "Do not rely on unstated assumptions about author intent or codebase behavior.",
280
- "Speculation is insufficient: identify the code path, scenario, environment, or input that is provably affected.",
281
- "Do not flag intentional behavior changes as bugs unless they clearly violate the task or documented contract.",
282
- "Ignore trivial style unless it obscures meaning or violates documented standards in a way that affects correctness/security/maintainability.",
283
- "If no finding clears this bar, return an empty findings array, mark the patch correct, and set stop_review_loop true. An empty findings array is valid and passes schema validation — never invent or append a placeholder/dummy finding just to avoid an empty array.",
284
- ].join("\n"),
285
- ],
286
- [
287
- "comment_guidelines",
288
- [
289
- "Each finding title must start with a priority tag: [P0] drop-everything blocker, [P1] urgent next-cycle fix, [P2] normal fix, [P3] low-priority nice-to-have.",
290
- "Also include numeric priority: 0 for P0, 1 for P1, 2 for P2, 3 for P3; use null only if priority genuinely cannot be determined. Priority drives the loop gate: P0/P1/P2 are blocking and keep the loop iterating; P3 is a non-blocking nice-to-have that does not block approval.",
291
- "Classify every finding with objective_alignment: required_by_objective (the objective/acceptance criteria require fixing it), consistent_with_objective (valid defect within scope), beyond_objective (real issue but not required and must not block or be promoted without explicit reconciliation), or contradicts_objective (fixing it would violate literal objective wording and must never be implemented; escalate to the human). Missing/unknown classification is blocking.",
292
- "The body must be one concise paragraph explaining why this is a bug and the exact scenario, environment, or inputs required for it to arise.",
293
- "Use a matter-of-fact, non-accusatory tone. Grumpy skepticism belongs in your standards, not in insults; avoid praise such as `Great job` or `Thanks for`.",
294
- "Keep code_location ranges as short as possible, ideally one line and never longer than 5-10 lines unless unavoidable.",
295
- "The code_location must overlap the diff/change under review.",
296
- "Use one finding per distinct issue. Do not generate or apply a fix patch.",
297
- "Use suggestion blocks only for concrete replacement code and preserve exact leading whitespace if you include one.",
298
- ].join("\n"),
299
- ],
300
- [
301
- "how_many_findings",
302
- [
303
- "Return all findings the original author would definitely want to fix.",
304
- "If no such findings exist, return an empty findings array and mark the patch correct. Do not pad the array with placeholder or speculative findings.",
305
- "Do not stop after the first qualifying finding; continue until every qualifying finding is listed.",
306
- ].join("\n"),
307
- ],
308
- [
309
- "review_stage_contract",
310
- [
311
- "The structured review decision is only valid after you inspect the actual repository state and compare it against the stated baseline branch.",
312
- "Do not approve based solely on workflow stage summaries or prior agent reasoning.",
313
- "The tool call is the final verdict after review work, not a shortcut around review work.",
314
- ].join("\n"),
315
- ],
316
- [
317
- "action_items",
318
- [
319
- "1. Identify the changed files or diff under review.",
320
- "2. Read the relevant changed code and directly affected call sites/tests/configs.",
321
- "3. Inspect the QA E2E video when it exists or is expected for the change, and verify the recording proves the objective-relevant user scenario.",
322
- "4. Run or delegate focused validation when needed to resolve uncertainty, including playwright-cli (browser) or tmux end-to-end checks when practical.",
323
- "5. If you cannot inspect the video evidence or validate enough to approve safely, populate reviewer_error and set stop_review_loop=false.",
324
- ].join("\n"),
325
- ],
326
- [
327
- "evidence_expectations",
328
- [
329
- "The overall_explanation should briefly mention what was inspected and what validation was run or why validation was not completed.",
330
- "Every finding must cite a concrete changed location and affected scenario.",
331
- ].join("\n"),
332
- ],
333
- [
334
- "decision_rules",
335
- ["Set stop_review_loop=true only when the patch is correct, reviewer_error is null/omitted, there are no blocking objective-aligned P0/P1/P2 findings, requirements_traceability is non-empty and every entry is proven, and no objective-relevant verification remains; beyond_objective and contradicts_objective findings are non-blocking and must not be folded into follow-up objectives without checking the literal contract. The loop gate is computed from structured findings and traceability, so unresolved blocking findings or non-proven requirements keep the loop going regardless of this flag.", "Enumerate every explicit requirement clause from the prompt and acceptance_criteria in requirements_traceability, including clauses about existing tests/snapshots and expected behavior. Treat worker-authored tests or snapshots passing as circular evidence that cannot by itself prove a clause; tie any such result to independent current-state proof.", "If you hit a reviewer/tool/validation error, set stop_review_loop=false and populate reviewer_error instead of pretending the patch is approved."].join("\n"),
336
- ],
337
- ]);
224
+ comparisonBaseBranch,
225
+ researchPath,
226
+ implementationNotesPath,
227
+ orchestratorReportPath,
228
+ qaVideoPath,
229
+ });
338
230
  let reviews: WorkflowTaskResult[];
339
231
  try {
340
232
  reviews = await ctx.parallel(
@@ -43,5 +43,10 @@ export const LITERAL_OBJECTIVE_CONTRACT = [
43
43
  "- If the objective and acceptance criteria conflict, do not implement the contradiction. Surface it as a blocker or reviewer finding instead.",
44
44
  "- When external knowledge (language specs, upstream issues, in-repo comments, general best practice, or prior reviewer speculation) conflicts with explicit objective wording, the objective/acceptance criteria win.",
45
45
  "- Never silently resolve such a conflict in favor of external knowledge. Surface the conflict clearly.",
46
+ "- Prefer loud errors over silent reinterpretation: when the objective/acceptance criteria enumerate required error conditions, messages, or rejections, give each enumerated error the widest plausible trigger surface. When the contract leaves an input ambiguous or unspecified near an enumerated error case, prefer raising that error over silently reinterpreting the input as different valid behavior, even when external spec knowledge says the input is valid.",
47
+ "- Only narrow an enumerated error's trigger surface when the objective, acceptance criteria, or pre-existing required tests explicitly require the ambiguous input to be accepted. Widening an enumerated error to nearby ambiguous inputs is applying the contract, not adding beyond it.",
46
48
  "- Do not add behaviors, restrictions, error conditions, or follow-up requirements beyond what the objective/acceptance criteria require.",
47
49
  ].join("\n");
50
+
51
+ export const REVIEWER_SPEC_VS_OBJECTIVE_GUARD =
52
+ "Do not use external spec/standard conformance alone to flag a wide trigger surface for an error condition the objective/acceptance criteria enumerate; the contract prefers loud errors over silent reinterpretation of ambiguous inputs, so classify such spec-vs-objective tension as beyond_objective rather than a blocking defect.";
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/workflows",
3
- "version": "0.9.5-alpha.2",
3
+ "version": "0.9.5-alpha.4",
4
4
  "private": true,
5
5
  "description": "Atomic extension for multi-stage workflow authoring and execution.",
6
6
  "contributors": [
@@ -9,8 +9,11 @@ export const WORKFLOW_TOOL_DESCRIPTION =
9
9
 
10
10
  export const DEFAULT_PROMPT_GUIDANCE: string[] = [
11
11
  `**Workflows**: Treat workflows as the default execution path for any non-trivial task and for any request that has inherent structure plus an objective you can make verifiable. Use the \`workflow\` tool for existing named workflows and for repeatable, inspectable, resumable, multi-stage, or reviewer-gated processes; use direct \`task\`, \`tasks\`, or \`chain\` workflow calls for one-off tracked work when no named workflow fits.
12
- - Workflow fit check: before implementing directly, ask whether the task is an implementation, build, debug/diagnosis, bug-fix, migration, new-feature, scoped multi-file edit, or docs/code change with validation; or whether it has multiple steps, dependencies, handoffs, uncertainty, validation/review needs, a long-running surface, or measurable done criteria. If yes, launch or design a workflow instead of doing parallel implementation yourself.
12
+ - Decide the execution mode before your first tool call on a new request and state it in one short line: inline (tiny, deterministic, low-risk) or a workflow run. Reconnaissance counts as inline execution reading code, searching, and running probe scripts is already doing the task, so an unstated "explore first" default silently commits you to an unbounded inline session.
13
+ - Workflow fit check: ask whether the task is an implementation, build, debug/diagnosis, bug-fix, migration, new-feature, scoped multi-file edit, or docs/code change with validation; or whether it has multiple steps, dependencies, handoffs, uncertainty, validation/review needs, a long-running surface, or measurable done criteria. If yes, launch or design a workflow instead of doing parallel implementation yourself.
13
14
  - Treat loop/structural wording as a strong workflow signal, especially requests like "do X until Y", "repeat until", "iterate until", "review/fix until passing", "run checks and fix until green", "keep going until done", or any prompt that names a stop condition, approval gate, or evidence requirement.
15
+ - Budget reconnaissance: when a task passes the fit check, keep pre-workflow exploration to a few quick scoping reads whose only purpose is writing a sharper objective and validation criteria; deep research, upstream/design comparison, and behavior probing belong inside the workflow run — any workflow with a research or analysis stage, whether user-defined or builtin (e.g. \`ralph\`'s research stage) — not before it.
16
+ - Course-correct instead of drifting: if you are roughly ten or more tool calls into inline exploration with no artifact, edit, or commit to show — or you keep telling yourself "let me verify one more thing" — stop, write your findings so far to a context file, launch the best-fit workflow with that file passed via \`reads\` and a prompt like "Read the file at <path>...", and let the workflow own the implementation. Check \`action: "list"\` for named or user-defined workflows that match the task first, falling back to the builtin \`goal\`/\`ralph\` when nothing more specific fits. Sunk inline research is never a reason to stay inline; it transfers via files.
14
17
  - Only skip workflows for tiny, deterministic, low-risk answers or direct edits that are faster and safer to complete inline without stage tracking, typically a clearly single-file/no-test/no-review change.
15
18
  - For unfamiliar named workflows, discover with \`action: "list"\`, inspect with \`action: "get"\` or \`action: "inputs"\`, and run with \`action: "run"\`, \`workflow\`, and validated \`inputs\`; do not invent workflow names or input keys.
16
19
  - When designing or editing workflows, read docs/workflows.md and reference its Workflow Starter Patterns: Classify-and-act, Fan-out-and-synthesize, Adversarial verification, Generate-and-filter, Tournament, and Loop until done. Choose or combine these patterns before inventing a custom stage graph, and reflect the selected pattern in the spec and Mermaid diagram when using the create-spec skill.
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-auth-login.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth-login.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Api, type Model, type OAuthProviderId, type OAuthSelectPrompt, path, getAuthPath, getDocsPath, defaultModelPerProvider, ExtensionSelectorComponent, LoginDialogComponent, theme } from \"./interactive-mode-deps.ts\";\nimport { hasDefaultModelProvider, isUnknownModel } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.completeProviderAuthentication = async function(this: InteractiveModeBase, providerId: string, providerName: string, authType: \"oauth\" | \"api_key\", previousModel: Model<Api> | undefined): Promise<void> {\n this.session.modelRegistry.refresh();\n\n const actionLabel =\n authType === \"oauth\"\n ? `Logged in to ${providerName}`\n : `Saved API key for ${providerName}`;\n\n let selectedModel: Model<Api> | undefined;\n let selectionError: string | undefined;\n if (isUnknownModel(previousModel)) {\n const availableModels = this.session.modelRegistry.getAvailable();\n const providerModels = availableModels.filter(\n (model) => model.provider === providerId,\n );\n if (!hasDefaultModelProvider(providerId)) {\n selectionError = `${actionLabel}, but no default model is configured for provider \"${providerId}\". Use /model to select a model.`;\n } else if (providerModels.length === 0) {\n selectionError = `${actionLabel}, but no models are available for that provider. Use /model to select a model.`;\n } else {\n const defaultModelId = defaultModelPerProvider[providerId];\n selectedModel = providerModels.find(\n (model) => model.id === defaultModelId,\n );\n if (!selectedModel) {\n selectionError = `${actionLabel}, but its default model \"${defaultModelId}\" is not available. Use /model to select a model.`;\n } else {\n try {\n await this.session.setModel(selectedModel);\n } catch (error: unknown) {\n selectedModel = undefined;\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n selectionError = `${actionLabel}, but selecting its default model failed: ${errorMessage}. Use /model to select a model.`;\n }\n }\n }\n }\n\n await this.updateAvailableProviderCount();\n this.setupAutocompleteProvider();\n this.footer.invalidate();\n this.updateEditorBorderColor();\n if (selectedModel) {\n this.showStatus(\n `${actionLabel}. Selected ${selectedModel.id}. Credentials saved to ${getAuthPath()}`,\n );\n void this.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n this.checkDaxnutsEasterEgg(selectedModel);\n } else {\n this.showStatus(`${actionLabel}. Credentials saved to ${getAuthPath()}`);\n if (selectionError) {\n this.showError(selectionError);\n } else {\n void this.maybeWarnAboutAnthropicSubscriptionAuth();\n }\n }\n\n await this.resumePendingFirstRunOnboardingSeed();\n };\n\nInteractiveModeBase.prototype.showBedrockSetupDialog = function(this: InteractiveModeBase, providerId: string, providerName: string): void {\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n () => restoreEditor(),\n providerName,\n \"Amazon Bedrock setup\",\n );\n dialog.showInfo([\n theme.fg(\n \"text\",\n \"Amazon Bedrock uses AWS credentials instead of a single API key.\",\n ),\n theme.fg(\n \"text\",\n \"Configure an AWS profile, IAM keys, bearer token, or role-based credentials.\",\n ),\n theme.fg(\"muted\", \"See:\"),\n theme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n ]);\n\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showApiKeyLoginDialog = async function(this: InteractiveModeBase, providerId: string, providerName: string): Promise<void> {\n const previousModel = this.session.model;\n\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n (_success, _message) => {\n // Completion handled below\n },\n providerName,\n );\n\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n try {\n const apiKey = (await dialog.showPrompt(\"Enter API key:\")).trim();\n if (!apiKey) {\n throw new Error(\"API key cannot be empty.\");\n }\n\n this.session.modelRegistry.authStorage.set(providerId, {\n type: \"api_key\",\n key: apiKey,\n });\n\n restoreEditor();\n await this.completeProviderAuthentication(\n providerId,\n providerName,\n \"api_key\",\n previousModel,\n );\n } catch (error: unknown) {\n restoreEditor();\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg !== \"Login cancelled\") {\n this.showError(\n `Failed to save API key for ${providerName}: ${errorMsg}`,\n );\n }\n }\n };\n\nInteractiveModeBase.prototype.showOAuthLoginSelect = function(this: InteractiveModeBase, dialog: LoginDialogComponent, prompt: OAuthSelectPrompt): Promise<string | undefined> {\n return new Promise((resolve) => {\n const restoreDialog = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n };\n const labels = prompt.options.map((option) => option.label);\n const selector = new ExtensionSelectorComponent(\n prompt.message,\n labels,\n (optionLabel) => {\n restoreDialog();\n resolve(\n prompt.options.find((option) => option.label === optionLabel)?.id,\n );\n },\n () => {\n restoreDialog();\n resolve(undefined);\n },\n );\n this.editorContainer.clear();\n this.editorContainer.addChild(selector);\n this.ui.setFocus(selector);\n this.ui.requestRender();\n });\n };\n\nInteractiveModeBase.prototype.showLoginDialog = async function(this: InteractiveModeBase, providerId: string, providerName: string): Promise<void> {\n const providerInfo = this.session.modelRegistry.authStorage\n .getOAuthProviders()\n .find((provider) => provider.id === providerId);\n const previousModel = this.session.model;\n\n // Providers that use callback servers (can paste redirect URL)\n const usesCallbackServer = providerInfo?.usesCallbackServer ?? false;\n\n // Create login dialog component\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n (_success, _message) => {\n // Completion handled below\n },\n providerName,\n );\n\n // Show dialog in editor container\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n\n // Promise for manual code input (racing with callback server)\n let manualCodeResolve: ((code: string) => void) | undefined;\n let manualCodeReject: ((err: Error) => void) | undefined;\n const manualCodePromise = new Promise<string>((resolve, reject) => {\n manualCodeResolve = resolve;\n manualCodeReject = reject;\n });\n\n // Restore editor helper\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n try {\n await this.session.modelRegistry.authStorage.login(\n providerId as OAuthProviderId,\n {\n onAuth: (info: { url: string; instructions?: string }) => {\n dialog.showAuth(info.url, info.instructions, {\n showCancelHint: !usesCallbackServer,\n });\n\n if (usesCallbackServer) {\n // Show input for manual paste, racing with callback\n dialog\n .showManualInput(\n \"Paste redirect URL below, or complete login in browser:\",\n )\n .then((value) => {\n if (value && manualCodeResolve) {\n manualCodeResolve(value);\n manualCodeResolve = undefined;\n }\n })\n .catch(() => {\n if (manualCodeReject) {\n manualCodeReject(new Error(\"Login cancelled\"));\n manualCodeReject = undefined;\n }\n });\n }\n // For Anthropic: onPrompt is called immediately after\n },\n\n onDeviceCode: (info) => {\n dialog.showDeviceCode(info);\n dialog.showWaiting(\"Waiting for authentication...\");\n },\n\n onPrompt: async (prompt: {\n message: string;\n placeholder?: string;\n }) => {\n return dialog.showPrompt(prompt.message, prompt.placeholder);\n },\n\n onProgress: (message: string) => {\n dialog.showProgress(message);\n },\n\n onSelect: (prompt: OAuthSelectPrompt) =>\n this.showOAuthLoginSelect(dialog, prompt),\n\n onManualCodeInput: () => manualCodePromise,\n\n signal: dialog.signal,\n },\n );\n\n // Success\n restoreEditor();\n await this.completeProviderAuthentication(\n providerId,\n providerName,\n \"oauth\",\n previousModel,\n );\n } catch (error: unknown) {\n restoreEditor();\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg !== \"Login cancelled\") {\n this.showError(`Failed to login to ${providerName}: ${errorMsg}`);\n }\n }\n };\n"]}
1
+ {"version":3,"file":"interactive-auth-login.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth-login.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Api, type Model, type OAuthProviderId, type OAuthSelectPrompt, path, getAuthPath, getDocsPath, defaultModelPerProvider, ExtensionSelectorComponent, LoginDialogComponent, theme } from \"./interactive-mode-deps.ts\";\nimport { hasDefaultModelProvider, isUnknownModel } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.completeProviderAuthentication = async function(this: InteractiveModeBase, providerId: string, providerName: string, authType: \"oauth\" | \"api_key\", previousModel: Model<Api> | undefined): Promise<void> {\n this.session.modelRegistry.refresh();\n\n const actionLabel =\n authType === \"oauth\"\n ? `Logged in to ${providerName}`\n : `Saved API key for ${providerName}`;\n\n let selectedModel: Model<Api> | undefined;\n let selectionError: string | undefined;\n if (isUnknownModel(previousModel)) {\n const availableModels = this.session.modelRegistry.getAvailable();\n const providerModels = availableModels.filter(\n (model) => model.provider === providerId,\n );\n if (!hasDefaultModelProvider(providerId)) {\n selectionError = `${actionLabel}, but no default model is configured for provider \"${providerId}\". Use /model to select a model.`;\n } else if (providerModels.length === 0) {\n selectionError = `${actionLabel}, but no models are available for that provider. Use /model to select a model.`;\n } else {\n const defaultModelId = defaultModelPerProvider[providerId];\n selectedModel = providerModels.find(\n (model) => model.id === defaultModelId,\n );\n if (!selectedModel) {\n selectionError = `${actionLabel}, but its default model \"${defaultModelId}\" is not available. Use /model to select a model.`;\n } else {\n try {\n await this.session.setModel(selectedModel);\n } catch (error: unknown) {\n selectedModel = undefined;\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n selectionError = `${actionLabel}, but selecting its default model failed: ${errorMessage}. Use /model to select a model.`;\n }\n }\n }\n }\n\n await this.updateAvailableProviderCount();\n this.setupAutocompleteProvider();\n this.footer.invalidate();\n this.updateEditorBorderColor();\n if (selectedModel) {\n this.showStatus(\n `${actionLabel}. Selected ${selectedModel.id}. Credentials saved to ${getAuthPath()}`,\n );\n void this.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n this.checkDaxnutsEasterEgg(selectedModel);\n } else {\n this.showStatus(`${actionLabel}. Credentials saved to ${getAuthPath()}`);\n if (selectionError) {\n this.showError(selectionError);\n } else {\n void this.maybeWarnAboutAnthropicSubscriptionAuth();\n }\n }\n\n };\n\nInteractiveModeBase.prototype.showBedrockSetupDialog = function(this: InteractiveModeBase, providerId: string, providerName: string): void {\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n () => restoreEditor(),\n providerName,\n \"Amazon Bedrock setup\",\n );\n dialog.showInfo([\n theme.fg(\n \"text\",\n \"Amazon Bedrock uses AWS credentials instead of a single API key.\",\n ),\n theme.fg(\n \"text\",\n \"Configure an AWS profile, IAM keys, bearer token, or role-based credentials.\",\n ),\n theme.fg(\"muted\", \"See:\"),\n theme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n ]);\n\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showApiKeyLoginDialog = async function(this: InteractiveModeBase, providerId: string, providerName: string): Promise<void> {\n const previousModel = this.session.model;\n\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n (_success, _message) => {\n // Completion handled below\n },\n providerName,\n );\n\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n try {\n const apiKey = (await dialog.showPrompt(\"Enter API key:\")).trim();\n if (!apiKey) {\n throw new Error(\"API key cannot be empty.\");\n }\n\n this.session.modelRegistry.authStorage.set(providerId, {\n type: \"api_key\",\n key: apiKey,\n });\n\n restoreEditor();\n await this.completeProviderAuthentication(\n providerId,\n providerName,\n \"api_key\",\n previousModel,\n );\n } catch (error: unknown) {\n restoreEditor();\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg !== \"Login cancelled\") {\n this.showError(\n `Failed to save API key for ${providerName}: ${errorMsg}`,\n );\n }\n }\n };\n\nInteractiveModeBase.prototype.showOAuthLoginSelect = function(this: InteractiveModeBase, dialog: LoginDialogComponent, prompt: OAuthSelectPrompt): Promise<string | undefined> {\n return new Promise((resolve) => {\n const restoreDialog = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n };\n const labels = prompt.options.map((option) => option.label);\n const selector = new ExtensionSelectorComponent(\n prompt.message,\n labels,\n (optionLabel) => {\n restoreDialog();\n resolve(\n prompt.options.find((option) => option.label === optionLabel)?.id,\n );\n },\n () => {\n restoreDialog();\n resolve(undefined);\n },\n );\n this.editorContainer.clear();\n this.editorContainer.addChild(selector);\n this.ui.setFocus(selector);\n this.ui.requestRender();\n });\n };\n\nInteractiveModeBase.prototype.showLoginDialog = async function(this: InteractiveModeBase, providerId: string, providerName: string): Promise<void> {\n const providerInfo = this.session.modelRegistry.authStorage\n .getOAuthProviders()\n .find((provider) => provider.id === providerId);\n const previousModel = this.session.model;\n\n // Providers that use callback servers (can paste redirect URL)\n const usesCallbackServer = providerInfo?.usesCallbackServer ?? false;\n\n // Create login dialog component\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n (_success, _message) => {\n // Completion handled below\n },\n providerName,\n );\n\n // Show dialog in editor container\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n\n // Promise for manual code input (racing with callback server)\n let manualCodeResolve: ((code: string) => void) | undefined;\n let manualCodeReject: ((err: Error) => void) | undefined;\n const manualCodePromise = new Promise<string>((resolve, reject) => {\n manualCodeResolve = resolve;\n manualCodeReject = reject;\n });\n\n // Restore editor helper\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n try {\n await this.session.modelRegistry.authStorage.login(\n providerId as OAuthProviderId,\n {\n onAuth: (info: { url: string; instructions?: string }) => {\n dialog.showAuth(info.url, info.instructions, {\n showCancelHint: !usesCallbackServer,\n });\n\n if (usesCallbackServer) {\n // Show input for manual paste, racing with callback\n dialog\n .showManualInput(\n \"Paste redirect URL below, or complete login in browser:\",\n )\n .then((value) => {\n if (value && manualCodeResolve) {\n manualCodeResolve(value);\n manualCodeResolve = undefined;\n }\n })\n .catch(() => {\n if (manualCodeReject) {\n manualCodeReject(new Error(\"Login cancelled\"));\n manualCodeReject = undefined;\n }\n });\n }\n // For Anthropic: onPrompt is called immediately after\n },\n\n onDeviceCode: (info) => {\n dialog.showDeviceCode(info);\n dialog.showWaiting(\"Waiting for authentication...\");\n },\n\n onPrompt: async (prompt: {\n message: string;\n placeholder?: string;\n }) => {\n return dialog.showPrompt(prompt.message, prompt.placeholder);\n },\n\n onProgress: (message: string) => {\n dialog.showProgress(message);\n },\n\n onSelect: (prompt: OAuthSelectPrompt) =>\n this.showOAuthLoginSelect(dialog, prompt),\n\n onManualCodeInput: () => manualCodePromise,\n\n signal: dialog.signal,\n },\n );\n\n // Success\n restoreEditor();\n await this.completeProviderAuthentication(\n providerId,\n providerName,\n \"oauth\",\n previousModel,\n );\n } catch (error: unknown) {\n restoreEditor();\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg !== \"Login cancelled\") {\n this.showError(`Failed to login to ${providerName}: ${errorMsg}`);\n }\n }\n };\n"]}
@@ -53,7 +53,6 @@ InteractiveModeBase.prototype.completeProviderAuthentication = async function (p
53
53
  void this.maybeWarnAboutAnthropicSubscriptionAuth();
54
54
  }
55
55
  }
56
- await this.resumePendingFirstRunOnboardingSeed();
57
56
  };
58
57
  InteractiveModeBase.prototype.showBedrockSetupDialog = function (providerId, providerName) {
59
58
  const restoreEditor = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-auth-login.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAsE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAClO,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAExF,mBAAmB,CAAC,SAAS,CAAC,8BAA8B,GAAG,KAAK,WAAqC,UAAkB,EAAE,YAAoB,EAAE,QAA6B,EAAE,aAAqC;IACnN,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;IAErC,MAAM,WAAW,GACf,QAAQ,KAAK,OAAO;QAClB,CAAC,CAAC,gBAAgB,YAAY,EAAE;QAChC,CAAC,CAAC,qBAAqB,YAAY,EAAE,CAAC;IAE1C,IAAI,aAAqC,CAAC;IAC1C,IAAI,cAAkC,CAAC;IACvC,IAAI,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC;QAClC,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;QAClE,MAAM,cAAc,GAAG,eAAe,CAAC,MAAM,CAC3C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,UAAU,CACzC,CAAC;QACF,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC,EAAE,CAAC;YACzC,cAAc,GAAG,GAAG,WAAW,sDAAsD,UAAU,kCAAkC,CAAC;QACpI,CAAC;aAAM,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvC,cAAc,GAAG,GAAG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Q,EAAE,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Api, type Model, type OAuthProviderId, type OAuthSelectPrompt, path, getAuthPath, getDocsPath, defaultModelPerProvider, ExtensionSelectorComponent, LoginDialogComponent, theme } from \"./interactive-mode-deps.ts\";\nimport { hasDefaultModelProvider, isUnknownModel } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.completeProviderAuthentication = async function(this: InteractiveModeBase, providerId: string, providerName: string, authType: \"oauth\" | \"api_key\", previousModel: Model<Api> | undefined): Promise<void> {\n this.session.modelRegistry.refresh();\n\n const actionLabel =\n authType === \"oauth\"\n ? `Logged in to ${providerName}`\n : `Saved API key for ${providerName}`;\n\n let selectedModel: Model<Api> | undefined;\n let selectionError: string | undefined;\n if (isUnknownModel(previousModel)) {\n const availableModels = this.session.modelRegistry.getAvailable();\n const providerModels = availableModels.filter(\n (model) => model.provider === providerId,\n );\n if (!hasDefaultModelProvider(providerId)) {\n selectionError = `${actionLabel}, but no default model is configured for provider \"${providerId}\". Use /model to select a model.`;\n } else if (providerModels.length === 0) {\n selectionError = `${actionLabel}, but no models are available for that provider. Use /model to select a model.`;\n } else {\n const defaultModelId = defaultModelPerProvider[providerId];\n selectedModel = providerModels.find(\n (model) => model.id === defaultModelId,\n );\n if (!selectedModel) {\n selectionError = `${actionLabel}, but its default model \"${defaultModelId}\" is not available. Use /model to select a model.`;\n } else {\n try {\n await this.session.setModel(selectedModel);\n } catch (error: unknown) {\n selectedModel = undefined;\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n selectionError = `${actionLabel}, but selecting its default model failed: ${errorMessage}. Use /model to select a model.`;\n }\n }\n }\n }\n\n await this.updateAvailableProviderCount();\n this.setupAutocompleteProvider();\n this.footer.invalidate();\n this.updateEditorBorderColor();\n if (selectedModel) {\n this.showStatus(\n `${actionLabel}. Selected ${selectedModel.id}. Credentials saved to ${getAuthPath()}`,\n );\n void this.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n this.checkDaxnutsEasterEgg(selectedModel);\n } else {\n this.showStatus(`${actionLabel}. Credentials saved to ${getAuthPath()}`);\n if (selectionError) {\n this.showError(selectionError);\n } else {\n void this.maybeWarnAboutAnthropicSubscriptionAuth();\n }\n }\n\n await this.resumePendingFirstRunOnboardingSeed();\n };\n\nInteractiveModeBase.prototype.showBedrockSetupDialog = function(this: InteractiveModeBase, providerId: string, providerName: string): void {\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n () => restoreEditor(),\n providerName,\n \"Amazon Bedrock setup\",\n );\n dialog.showInfo([\n theme.fg(\n \"text\",\n \"Amazon Bedrock uses AWS credentials instead of a single API key.\",\n ),\n theme.fg(\n \"text\",\n \"Configure an AWS profile, IAM keys, bearer token, or role-based credentials.\",\n ),\n theme.fg(\"muted\", \"See:\"),\n theme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n ]);\n\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showApiKeyLoginDialog = async function(this: InteractiveModeBase, providerId: string, providerName: string): Promise<void> {\n const previousModel = this.session.model;\n\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n (_success, _message) => {\n // Completion handled below\n },\n providerName,\n );\n\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n try {\n const apiKey = (await dialog.showPrompt(\"Enter API key:\")).trim();\n if (!apiKey) {\n throw new Error(\"API key cannot be empty.\");\n }\n\n this.session.modelRegistry.authStorage.set(providerId, {\n type: \"api_key\",\n key: apiKey,\n });\n\n restoreEditor();\n await this.completeProviderAuthentication(\n providerId,\n providerName,\n \"api_key\",\n previousModel,\n );\n } catch (error: unknown) {\n restoreEditor();\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg !== \"Login cancelled\") {\n this.showError(\n `Failed to save API key for ${providerName}: ${errorMsg}`,\n );\n }\n }\n };\n\nInteractiveModeBase.prototype.showOAuthLoginSelect = function(this: InteractiveModeBase, dialog: LoginDialogComponent, prompt: OAuthSelectPrompt): Promise<string | undefined> {\n return new Promise((resolve) => {\n const restoreDialog = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n };\n const labels = prompt.options.map((option) => option.label);\n const selector = new ExtensionSelectorComponent(\n prompt.message,\n labels,\n (optionLabel) => {\n restoreDialog();\n resolve(\n prompt.options.find((option) => option.label === optionLabel)?.id,\n );\n },\n () => {\n restoreDialog();\n resolve(undefined);\n },\n );\n this.editorContainer.clear();\n this.editorContainer.addChild(selector);\n this.ui.setFocus(selector);\n this.ui.requestRender();\n });\n };\n\nInteractiveModeBase.prototype.showLoginDialog = async function(this: InteractiveModeBase, providerId: string, providerName: string): Promise<void> {\n const providerInfo = this.session.modelRegistry.authStorage\n .getOAuthProviders()\n .find((provider) => provider.id === providerId);\n const previousModel = this.session.model;\n\n // Providers that use callback servers (can paste redirect URL)\n const usesCallbackServer = providerInfo?.usesCallbackServer ?? false;\n\n // Create login dialog component\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n (_success, _message) => {\n // Completion handled below\n },\n providerName,\n );\n\n // Show dialog in editor container\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n\n // Promise for manual code input (racing with callback server)\n let manualCodeResolve: ((code: string) => void) | undefined;\n let manualCodeReject: ((err: Error) => void) | undefined;\n const manualCodePromise = new Promise<string>((resolve, reject) => {\n manualCodeResolve = resolve;\n manualCodeReject = reject;\n });\n\n // Restore editor helper\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n try {\n await this.session.modelRegistry.authStorage.login(\n providerId as OAuthProviderId,\n {\n onAuth: (info: { url: string; instructions?: string }) => {\n dialog.showAuth(info.url, info.instructions, {\n showCancelHint: !usesCallbackServer,\n });\n\n if (usesCallbackServer) {\n // Show input for manual paste, racing with callback\n dialog\n .showManualInput(\n \"Paste redirect URL below, or complete login in browser:\",\n )\n .then((value) => {\n if (value && manualCodeResolve) {\n manualCodeResolve(value);\n manualCodeResolve = undefined;\n }\n })\n .catch(() => {\n if (manualCodeReject) {\n manualCodeReject(new Error(\"Login cancelled\"));\n manualCodeReject = undefined;\n }\n });\n }\n // For Anthropic: onPrompt is called immediately after\n },\n\n onDeviceCode: (info) => {\n dialog.showDeviceCode(info);\n dialog.showWaiting(\"Waiting for authentication...\");\n },\n\n onPrompt: async (prompt: {\n message: string;\n placeholder?: string;\n }) => {\n return dialog.showPrompt(prompt.message, prompt.placeholder);\n },\n\n onProgress: (message: string) => {\n dialog.showProgress(message);\n },\n\n onSelect: (prompt: OAuthSelectPrompt) =>\n this.showOAuthLoginSelect(dialog, prompt),\n\n onManualCodeInput: () => manualCodePromise,\n\n signal: dialog.signal,\n },\n );\n\n // Success\n restoreEditor();\n await this.completeProviderAuthentication(\n providerId,\n providerName,\n \"oauth\",\n previousModel,\n );\n } catch (error: unknown) {\n restoreEditor();\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg !== \"Login cancelled\") {\n this.showError(`Failed to login to ${providerName}: ${errorMsg}`);\n }\n }\n };\n"]}
1
+ {"version":3,"file":"interactive-auth-login.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-auth-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;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C,CAAC;gBAC5B,MAAM,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;YACtD,CAAC;YAED,QAAQ,EAAE,KAAK,EAAE,MAGhB,EAAE,EAAE;gBACH,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAC/D,CAAC;YAED,UAAU,EAAE,CAAC,OAAe,EAAE,EAAE;gBAC9B,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;YAED,QAAQ,EAAE,CAAC,MAAyB,EAAE,EAAE,CACtC,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC;YAE3C,iBAAiB,EAAE,GAAG,EAAE,CAAC,iBAAiB;YAE1C,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CACF,CAAC;QAEF,UAAU;QACV,aAAa,EAAE,CAAC;QAChB,MAAM,IAAI,CAAC,8BAA8B,CACvC,UAAU,EACV,YAAY,EACZ,OAAO,EACP,aAAa,CACd,CAAC;IACJ,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,aAAa,EAAE,CAAC;QAChB,MAAM,QAAQ,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACxE,IAAI,QAAQ,KAAK,iBAAiB,EAAE,CAAC;YACnC,IAAI,CAAC,SAAS,CAAC,sBAAsB,YAAY,KAAK,QAAQ,EAAE,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type Api, type Model, type OAuthProviderId, type OAuthSelectPrompt, path, getAuthPath, getDocsPath, defaultModelPerProvider, ExtensionSelectorComponent, LoginDialogComponent, theme } from \"./interactive-mode-deps.ts\";\nimport { hasDefaultModelProvider, isUnknownModel } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.completeProviderAuthentication = async function(this: InteractiveModeBase, providerId: string, providerName: string, authType: \"oauth\" | \"api_key\", previousModel: Model<Api> | undefined): Promise<void> {\n this.session.modelRegistry.refresh();\n\n const actionLabel =\n authType === \"oauth\"\n ? `Logged in to ${providerName}`\n : `Saved API key for ${providerName}`;\n\n let selectedModel: Model<Api> | undefined;\n let selectionError: string | undefined;\n if (isUnknownModel(previousModel)) {\n const availableModels = this.session.modelRegistry.getAvailable();\n const providerModels = availableModels.filter(\n (model) => model.provider === providerId,\n );\n if (!hasDefaultModelProvider(providerId)) {\n selectionError = `${actionLabel}, but no default model is configured for provider \"${providerId}\". Use /model to select a model.`;\n } else if (providerModels.length === 0) {\n selectionError = `${actionLabel}, but no models are available for that provider. Use /model to select a model.`;\n } else {\n const defaultModelId = defaultModelPerProvider[providerId];\n selectedModel = providerModels.find(\n (model) => model.id === defaultModelId,\n );\n if (!selectedModel) {\n selectionError = `${actionLabel}, but its default model \"${defaultModelId}\" is not available. Use /model to select a model.`;\n } else {\n try {\n await this.session.setModel(selectedModel);\n } catch (error: unknown) {\n selectedModel = undefined;\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n selectionError = `${actionLabel}, but selecting its default model failed: ${errorMessage}. Use /model to select a model.`;\n }\n }\n }\n }\n\n await this.updateAvailableProviderCount();\n this.setupAutocompleteProvider();\n this.footer.invalidate();\n this.updateEditorBorderColor();\n if (selectedModel) {\n this.showStatus(\n `${actionLabel}. Selected ${selectedModel.id}. Credentials saved to ${getAuthPath()}`,\n );\n void this.maybeWarnAboutAnthropicSubscriptionAuth(selectedModel);\n this.checkDaxnutsEasterEgg(selectedModel);\n } else {\n this.showStatus(`${actionLabel}. Credentials saved to ${getAuthPath()}`);\n if (selectionError) {\n this.showError(selectionError);\n } else {\n void this.maybeWarnAboutAnthropicSubscriptionAuth();\n }\n }\n\n };\n\nInteractiveModeBase.prototype.showBedrockSetupDialog = function(this: InteractiveModeBase, providerId: string, providerName: string): void {\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n () => restoreEditor(),\n providerName,\n \"Amazon Bedrock setup\",\n );\n dialog.showInfo([\n theme.fg(\n \"text\",\n \"Amazon Bedrock uses AWS credentials instead of a single API key.\",\n ),\n theme.fg(\n \"text\",\n \"Configure an AWS profile, IAM keys, bearer token, or role-based credentials.\",\n ),\n theme.fg(\"muted\", \"See:\"),\n theme.fg(\"accent\", ` ${path.join(getDocsPath(), \"providers.md\")}`),\n ]);\n\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showApiKeyLoginDialog = async function(this: InteractiveModeBase, providerId: string, providerName: string): Promise<void> {\n const previousModel = this.session.model;\n\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n (_success, _message) => {\n // Completion handled below\n },\n providerName,\n );\n\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n try {\n const apiKey = (await dialog.showPrompt(\"Enter API key:\")).trim();\n if (!apiKey) {\n throw new Error(\"API key cannot be empty.\");\n }\n\n this.session.modelRegistry.authStorage.set(providerId, {\n type: \"api_key\",\n key: apiKey,\n });\n\n restoreEditor();\n await this.completeProviderAuthentication(\n providerId,\n providerName,\n \"api_key\",\n previousModel,\n );\n } catch (error: unknown) {\n restoreEditor();\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg !== \"Login cancelled\") {\n this.showError(\n `Failed to save API key for ${providerName}: ${errorMsg}`,\n );\n }\n }\n };\n\nInteractiveModeBase.prototype.showOAuthLoginSelect = function(this: InteractiveModeBase, dialog: LoginDialogComponent, prompt: OAuthSelectPrompt): Promise<string | undefined> {\n return new Promise((resolve) => {\n const restoreDialog = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n };\n const labels = prompt.options.map((option) => option.label);\n const selector = new ExtensionSelectorComponent(\n prompt.message,\n labels,\n (optionLabel) => {\n restoreDialog();\n resolve(\n prompt.options.find((option) => option.label === optionLabel)?.id,\n );\n },\n () => {\n restoreDialog();\n resolve(undefined);\n },\n );\n this.editorContainer.clear();\n this.editorContainer.addChild(selector);\n this.ui.setFocus(selector);\n this.ui.requestRender();\n });\n };\n\nInteractiveModeBase.prototype.showLoginDialog = async function(this: InteractiveModeBase, providerId: string, providerName: string): Promise<void> {\n const providerInfo = this.session.modelRegistry.authStorage\n .getOAuthProviders()\n .find((provider) => provider.id === providerId);\n const previousModel = this.session.model;\n\n // Providers that use callback servers (can paste redirect URL)\n const usesCallbackServer = providerInfo?.usesCallbackServer ?? false;\n\n // Create login dialog component\n const dialog = new LoginDialogComponent(\n this.ui,\n providerId,\n (_success, _message) => {\n // Completion handled below\n },\n providerName,\n );\n\n // Show dialog in editor container\n this.editorContainer.clear();\n this.editorContainer.addChild(dialog);\n this.ui.setFocus(dialog);\n this.ui.requestRender();\n\n // Promise for manual code input (racing with callback server)\n let manualCodeResolve: ((code: string) => void) | undefined;\n let manualCodeReject: ((err: Error) => void) | undefined;\n const manualCodePromise = new Promise<string>((resolve, reject) => {\n manualCodeResolve = resolve;\n manualCodeReject = reject;\n });\n\n // Restore editor helper\n const restoreEditor = () => {\n this.editorContainer.clear();\n this.editorContainer.addChild(this.editor);\n this.ui.setFocus(this.editor);\n this.ui.requestRender();\n };\n\n try {\n await this.session.modelRegistry.authStorage.login(\n providerId as OAuthProviderId,\n {\n onAuth: (info: { url: string; instructions?: string }) => {\n dialog.showAuth(info.url, info.instructions, {\n showCancelHint: !usesCallbackServer,\n });\n\n if (usesCallbackServer) {\n // Show input for manual paste, racing with callback\n dialog\n .showManualInput(\n \"Paste redirect URL below, or complete login in browser:\",\n )\n .then((value) => {\n if (value && manualCodeResolve) {\n manualCodeResolve(value);\n manualCodeResolve = undefined;\n }\n })\n .catch(() => {\n if (manualCodeReject) {\n manualCodeReject(new Error(\"Login cancelled\"));\n manualCodeReject = undefined;\n }\n });\n }\n // For Anthropic: onPrompt is called immediately after\n },\n\n onDeviceCode: (info) => {\n dialog.showDeviceCode(info);\n dialog.showWaiting(\"Waiting for authentication...\");\n },\n\n onPrompt: async (prompt: {\n message: string;\n placeholder?: string;\n }) => {\n return dialog.showPrompt(prompt.message, prompt.placeholder);\n },\n\n onProgress: (message: string) => {\n dialog.showProgress(message);\n },\n\n onSelect: (prompt: OAuthSelectPrompt) =>\n this.showOAuthLoginSelect(dialog, prompt),\n\n onManualCodeInput: () => manualCodePromise,\n\n signal: dialog.signal,\n },\n );\n\n // Success\n restoreEditor();\n await this.completeProviderAuthentication(\n providerId,\n providerName,\n \"oauth\",\n previousModel,\n );\n } catch (error: unknown) {\n restoreEditor();\n const errorMsg = error instanceof Error ? error.message : String(error);\n if (errorMsg !== \"Login cancelled\") {\n this.showError(`Failed to login to ${providerName}: ${errorMsg}`);\n }\n }\n };\n"]}