@andorra-labs/code 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/account-presentation.js +3 -3
- package/dist/src/agent-execution.d.ts +2 -0
- package/dist/src/agent-execution.js +526 -41
- package/dist/src/agent-mcp-catalog.d.ts +21 -0
- package/dist/src/agent-mcp-catalog.js +40 -0
- package/dist/src/agent-mcp.d.ts +36 -3
- package/dist/src/agent-mcp.js +114 -45
- package/dist/src/app-server/protocol.d.ts +57 -5
- package/dist/src/app-server/protocol.js +18 -1
- package/dist/src/app-server/workspace.d.ts +9 -1
- package/dist/src/app-server/workspace.js +50 -3
- package/dist/src/app-server.d.ts +115 -41
- package/dist/src/app-server.js +1316 -221
- package/dist/src/auth/AuthManager.d.ts +33 -1
- package/dist/src/auth/AuthManager.js +138 -10
- package/dist/src/auth/callback-page.d.ts +4 -0
- package/dist/src/auth/callback-page.js +70 -0
- package/dist/src/auth/callback.d.ts +39 -0
- package/dist/src/auth/callback.js +146 -22
- package/dist/src/auth/index.d.ts +10 -6
- package/dist/src/auth/index.js +2 -2
- package/dist/src/auth/store.d.ts +142 -3
- package/dist/src/auth/store.js +334 -13
- package/dist/src/auth/types.d.ts +17 -1
- package/dist/src/auth-commands.d.ts +11 -2
- package/dist/src/auth-commands.js +14 -7
- package/dist/src/automation-runner.d.ts +9 -0
- package/dist/src/automation-runner.js +22 -1
- package/dist/src/automation-tool.js +18 -3
- package/dist/src/automations.d.ts +5 -0
- package/dist/src/automations.js +11 -1
- package/dist/src/browser-captcha-tool.d.ts +54 -0
- package/dist/src/browser-captcha-tool.js +374 -0
- package/dist/src/browser-panel-tool.d.ts +7 -0
- package/dist/src/browser-panel-tool.js +74 -3
- package/dist/src/browser-runner.js +19 -4
- package/dist/src/browser-server.js +21 -1
- package/dist/src/browser-session.d.ts +16 -0
- package/dist/src/browser-session.js +35 -0
- package/dist/src/browser-ui/app.js +193 -3
- package/dist/src/browser-ui/style.css +15 -1
- package/dist/src/browser-view.d.ts +72 -4
- package/dist/src/browser-view.js +229 -17
- package/dist/src/capabilities.d.ts +9 -3
- package/dist/src/capabilities.js +20 -5
- package/dist/src/capsolver.d.ts +60 -0
- package/dist/src/capsolver.js +101 -0
- package/dist/src/claude-provider.d.ts +6 -0
- package/dist/src/claude-provider.js +34 -3
- package/dist/src/cli-executable.d.ts +33 -0
- package/dist/src/cli-executable.js +64 -0
- package/dist/src/cli-process.d.ts +47 -0
- package/dist/src/cli-process.js +113 -0
- package/dist/src/cli-sign-in.d.ts +68 -0
- package/dist/src/cli-sign-in.js +224 -0
- package/dist/src/cli.js +84 -26
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
- package/dist/src/codex-provider.js +12 -0
- package/dist/src/coding-tools.d.ts +5 -0
- package/dist/src/coding-tools.js +98 -53
- package/dist/src/command-output-tap.d.ts +16 -0
- package/dist/src/command-output-tap.js +45 -0
- package/dist/src/command-screens.js +3 -3
- package/dist/src/commands.d.ts +15 -2
- package/dist/src/commands.js +14 -13
- package/dist/src/completion.d.ts +23 -5
- package/dist/src/completion.js +380 -17
- package/dist/src/config.d.ts +61 -0
- package/dist/src/config.js +276 -12
- package/dist/src/context-budget.d.ts +7 -0
- package/dist/src/context-budget.js +18 -1
- package/dist/src/deadline.js +6 -0
- package/dist/src/decision/FactContinuations.d.ts +41 -6
- package/dist/src/decision/FactContinuations.js +211 -64
- package/dist/src/decision/PreparedSteps.js +3 -1
- package/dist/src/decision/checks.d.ts +25 -0
- package/dist/src/decision/checks.js +77 -6
- package/dist/src/delegation-changes.d.ts +109 -0
- package/dist/src/delegation-changes.js +431 -0
- package/dist/src/extensions.d.ts +1 -0
- package/dist/src/extensions.js +16 -3
- package/dist/src/graph-provider-portability.js +2 -2
- package/dist/src/graph-quota.d.ts +1 -1
- package/dist/src/graph-quota.js +1 -1
- package/dist/src/graph-runner.js +35 -21
- package/dist/src/graph-selection.d.ts +6 -0
- package/dist/src/graph-selection.js +10 -0
- package/dist/src/graph-server.d.ts +8 -0
- package/dist/src/graph-server.js +76 -6
- package/dist/src/graph-sync.d.ts +65 -0
- package/dist/src/graph-sync.js +433 -13
- package/dist/src/graph-tool.d.ts +52 -0
- package/dist/src/graph-tool.js +136 -0
- package/dist/src/graph-ui/app.js +272 -50
- package/dist/src/graph-ui/controls.js +6 -0
- package/dist/src/graph-ui/drafts.js +39 -0
- package/dist/src/graph-ui/embed.js +1 -1
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +2 -2
- package/dist/src/graph-ui/skill-picker.js +242 -0
- package/dist/src/graph-ui/studio.css +7 -5
- package/dist/src/graph-ui/style.css +65 -12
- package/dist/src/graphs.d.ts +60 -5
- package/dist/src/graphs.js +191 -37
- package/dist/src/grok-provider.d.ts +50 -0
- package/dist/src/grok-provider.js +186 -0
- package/dist/src/handoffs.d.ts +13 -0
- package/dist/src/handoffs.js +31 -1
- package/dist/src/hardened-runtime.d.ts +4 -4
- package/dist/src/hardened-runtime.js +109 -9
- package/dist/src/managed-sign-in.d.ts +38 -0
- package/dist/src/managed-sign-in.js +169 -0
- package/dist/src/markdown.d.ts +5 -0
- package/dist/src/markdown.js +5 -2
- package/dist/src/mcp.js +11 -0
- package/dist/src/membership.d.ts +8 -1
- package/dist/src/membership.js +15 -5
- package/dist/src/model-metadata.js +14 -2
- package/dist/src/model-override.d.ts +10 -0
- package/dist/src/model-override.js +20 -0
- package/dist/src/opencode-cli-provider.d.ts +122 -0
- package/dist/src/opencode-cli-provider.js +415 -0
- package/dist/src/opencode-provider.js +23 -8
- package/dist/src/palette.d.ts +2 -0
- package/dist/src/palette.js +2 -0
- package/dist/src/permissions.d.ts +19 -1
- package/dist/src/permissions.js +30 -1
- package/dist/src/powershell-pool.d.ts +11 -2
- package/dist/src/powershell-pool.js +34 -5
- package/dist/src/provider-connection.js +36 -0
- package/dist/src/provider-engine.d.ts +2 -1
- package/dist/src/provider-engine.js +64 -13
- package/dist/src/provider-import.js +6 -1
- package/dist/src/provider-keys.d.ts +48 -0
- package/dist/src/provider-keys.js +121 -0
- package/dist/src/provider-settings.js +22 -3
- package/dist/src/providers.d.ts +12 -1
- package/dist/src/providers.js +27 -8
- package/dist/src/pull-requests.d.ts +123 -20
- package/dist/src/pull-requests.js +334 -84
- package/dist/src/qa/qa-authorize.js +9 -1
- package/dist/src/qa/runtime/ProcessManager.d.ts +6 -0
- package/dist/src/qa/runtime/ProcessManager.js +16 -0
- package/dist/src/react-runtime.js +106 -7
- package/dist/src/read-image.d.ts +30 -0
- package/dist/src/read-image.js +97 -0
- package/dist/src/remote/engine-pool.js +1 -1
- package/dist/src/run-progress.js +6 -1
- package/dist/src/run-records.d.ts +133 -27
- package/dist/src/run-records.js +320 -40
- package/dist/src/runtime.d.ts +38 -1
- package/dist/src/runtime.js +27 -4
- package/dist/src/save-lock.d.ts +11 -0
- package/dist/src/save-lock.js +29 -2
- package/dist/src/secret-redaction.d.ts +13 -0
- package/dist/src/secret-redaction.js +71 -0
- package/dist/src/session-summary.d.ts +10 -4
- package/dist/src/session-summary.js +14 -7
- package/dist/src/sessions.js +8 -2
- package/dist/src/shell.js +4 -1
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +1 -1
- package/dist/src/skill-commands.d.ts +2 -0
- package/dist/src/skill-commands.js +2 -0
- package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
- package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
- package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +100 -0
- package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
- package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
- package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
- package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
- package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
- package/dist/src/skills/bundled/provenance.json +50 -0
- package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
- package/dist/src/skills/invocable-skills.d.ts +41 -0
- package/dist/src/skills/invocable-skills.js +49 -0
- package/dist/src/skills/prompt-skills.d.ts +1 -0
- package/dist/src/skills/prompt-skills.js +33 -0
- package/dist/src/skills/runtime-skills.d.ts +4 -0
- package/dist/src/skills/runtime-skills.js +21 -0
- package/dist/src/structured-step.d.ts +55 -0
- package/dist/src/structured-step.js +85 -0
- package/dist/src/subagent-run.d.ts +1 -1
- package/dist/src/subagent-run.js +29 -33
- package/dist/src/telemetry/schema.d.ts +2 -2
- package/dist/src/telemetry/schema.js +3 -2
- package/dist/src/terminal-ui.d.ts +38 -0
- package/dist/src/terminal-ui.js +126 -28
- package/dist/src/timers.d.ts +21 -2
- package/dist/src/timers.js +12 -4
- package/dist/src/tool-dependencies.js +4 -0
- package/dist/src/tool-names.d.ts +18 -0
- package/dist/src/tool-names.js +26 -0
- package/dist/src/tools.d.ts +9 -0
- package/dist/src/tools.js +159 -20
- package/dist/src/trajectory.js +32 -12
- package/dist/src/transcript.js +5 -0
- package/dist/src/types.d.ts +36 -0
- package/dist/src/web-search.d.ts +59 -0
- package/dist/src/web-search.js +216 -0
- package/docs/agents/README.md +2 -2
- package/docs/agents/mcp-server.md +28 -3
- package/docs/agents/subagent-mode.md +7 -4
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/security.md +4 -2
- package/docs/getting-started/accounts.md +15 -4
- package/docs/getting-started/configure-providers.md +30 -3
- package/docs/guides/README.md +1 -0
- package/docs/guides/browser.md +12 -0
- package/docs/guides/desktop-app.md +11 -4
- package/docs/guides/graph-builder.md +9 -1
- package/docs/guides/web-search.md +47 -0
- package/docs/reference/cli.md +4 -3
- package/docs/reference/config.md +4 -4
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +295 -0
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +291 -0
- package/package.json +1 -1
- package/tests/permissions-test-plan.md +2 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { credentialStoreMode, KeyringAbsentError, KeyringCredentialStore } from './auth/store.js';
|
|
3
|
+
/**
|
|
4
|
+
* Saved provider API keys, kept in the OS credential store rather than in `config.json`.
|
|
5
|
+
*
|
|
6
|
+
* Each provider's key lives in its own vault entry, scoped by the configuration directory and the
|
|
7
|
+
* provider id, under its own service so `andorra logout --all` (which clears sign-ins) never touches
|
|
8
|
+
* them. One entry per key keeps each within the store's per-entry bound however many providers are
|
|
9
|
+
* configured, and lets a save write only the keys that changed. The configuration file keeps a
|
|
10
|
+
* `providerKeys: "keyring"` marker in their place; the keys are read back into memory when the
|
|
11
|
+
* configuration loads, so everything downstream of `loadConfig` sees exactly the provider objects it
|
|
12
|
+
* always did.
|
|
13
|
+
*
|
|
14
|
+
* Where the machine has no OS store (Linux without Secret Service), or the user chose
|
|
15
|
+
* `ANDORRA_CREDENTIAL_STORE=file`, keys stay in the owner-only `config.json` as before: that is
|
|
16
|
+
* the same fallback a sign-in takes. On Windows and macOS a failing store is reported instead.
|
|
17
|
+
*/
|
|
18
|
+
export const PROVIDER_KEY_SERVICE = 'Andorra Code provider keys';
|
|
19
|
+
/** The value `config.json` holds in `providerKeys` while its keys are in the OS store. */
|
|
20
|
+
export const PROVIDER_KEYS_IN_KEYRING = 'keyring';
|
|
21
|
+
const keyringVault = (directory, provider) => new KeyringCredentialStore(`provider-keys|${resolve(directory)}|${provider}`, undefined, { service: PROVIDER_KEY_SERVICE });
|
|
22
|
+
let vaultFor = keyringVault;
|
|
23
|
+
let fallbackPlatform = process.platform !== 'win32' && process.platform !== 'darwin';
|
|
24
|
+
/** Tests replace the OS store (and the platform's fallback rule); the returned function restores both. */
|
|
25
|
+
export function setProviderKeyVaultForTesting(factory, options = {}) {
|
|
26
|
+
const previous = vaultFor, previousFallback = fallbackPlatform;
|
|
27
|
+
vaultFor = factory ?? keyringVault;
|
|
28
|
+
if (options.fallback !== undefined)
|
|
29
|
+
fallbackPlatform = options.fallback;
|
|
30
|
+
return () => { vaultFor = previous; fallbackPlatform = previousFallback; };
|
|
31
|
+
}
|
|
32
|
+
const UNLOCK = 'Unlock it and retry, or set ANDORRA_CREDENTIAL_STORE=file to keep provider API keys in config.json instead.';
|
|
33
|
+
/** Reads of one key made before one is reported as failing. */
|
|
34
|
+
const READ_ATTEMPTS = 3;
|
|
35
|
+
/**
|
|
36
|
+
* One provider's saved key. A read takes no lock, so it can fetch a manifest that a concurrent
|
|
37
|
+
* save then replaces, deleting the chunks it names; a later read sees the finished save, and only
|
|
38
|
+
* a failure that repeats is reported.
|
|
39
|
+
*/
|
|
40
|
+
async function readKey(directory, provider) {
|
|
41
|
+
for (let attempt = 1;; attempt++) {
|
|
42
|
+
try {
|
|
43
|
+
return (await vaultFor(directory, provider).read()) || undefined;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (attempt >= READ_ATTEMPTS)
|
|
47
|
+
throw new Error(`Unable to read saved provider API keys from the OS credential store. ${UNLOCK}`, { cause: error });
|
|
48
|
+
await new Promise(done => setTimeout(done, 25 * attempt));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** The keys a configuration directory saved for these providers, by provider id. */
|
|
53
|
+
export async function readProviderKeys(directory, providers) {
|
|
54
|
+
const keys = new Map();
|
|
55
|
+
for (const provider of new Set(providers)) {
|
|
56
|
+
const key = await readKey(directory, provider);
|
|
57
|
+
if (key !== undefined)
|
|
58
|
+
keys.set(provider, key);
|
|
59
|
+
}
|
|
60
|
+
return keys;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Save the keys in the OS store: each key that differs from `current` (what the vault already
|
|
64
|
+
* holds, when known) is written, so an unchanged key is not rewritten on every save. Keys that
|
|
65
|
+
* are no longer configured are left for the caller to remove once the configuration that drops
|
|
66
|
+
* them is published. Returns false, having saved nothing, when the keys belong in `config.json`
|
|
67
|
+
* instead: `ANDORRA_CREDENTIAL_STORE=file`, or no OS store on a platform where that falls back.
|
|
68
|
+
*/
|
|
69
|
+
export async function storeProviderKeys(directory, keys, current, environment = process.env) {
|
|
70
|
+
const mode = credentialStoreMode(environment);
|
|
71
|
+
if (mode === 'file')
|
|
72
|
+
return false;
|
|
73
|
+
const written = [];
|
|
74
|
+
try {
|
|
75
|
+
for (const [provider, key] of keys) {
|
|
76
|
+
if (current?.get(provider) === key)
|
|
77
|
+
continue;
|
|
78
|
+
// Recorded before the write: one that fails partway can leave chunks holding the key, and
|
|
79
|
+
// the rollback below removes them.
|
|
80
|
+
written.push(provider);
|
|
81
|
+
await vaultFor(directory, provider).write(key);
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
// A save that stops partway puts back the keys it already replaced, so the configuration still
|
|
87
|
+
// on disk keeps the keys it names.
|
|
88
|
+
if (current)
|
|
89
|
+
await restoreProviderKeys(directory, written, current);
|
|
90
|
+
if (mode === 'auto' && fallbackPlatform && error instanceof KeyringAbsentError)
|
|
91
|
+
return false;
|
|
92
|
+
throw new Error(`Unable to save provider API keys in the OS credential store. ${UNLOCK}`, { cause: error });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Put the vault back the way `current` describes it for these providers, after a save that wrote
|
|
97
|
+
* them could not publish its configuration. Best-effort: the save's own failure is what is reported.
|
|
98
|
+
*/
|
|
99
|
+
export async function restoreProviderKeys(directory, providers, current) {
|
|
100
|
+
for (const provider of providers) {
|
|
101
|
+
const key = current.get(provider);
|
|
102
|
+
await (key === undefined ? vaultFor(directory, provider).remove() : vaultFor(directory, provider).write(key)).catch(() => { });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Delete the keys a configuration directory saved for these providers. A machine without an OS store holds none. */
|
|
106
|
+
export async function removeProviderKeys(directory, providers) {
|
|
107
|
+
for (const provider of new Set(providers)) {
|
|
108
|
+
try {
|
|
109
|
+
await vaultFor(directory, provider).remove();
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error instanceof KeyringAbsentError)
|
|
113
|
+
return;
|
|
114
|
+
throw new Error('Unable to remove saved provider API keys from the OS credential store. Unlock it and retry.', { cause: error });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** Whether saving should move plaintext keys out of `config.json` on this machine. */
|
|
119
|
+
export function providerKeysBelongInKeyring(environment = process.env) {
|
|
120
|
+
return credentialStoreMode(environment) !== 'file';
|
|
121
|
+
}
|
|
@@ -5,6 +5,8 @@ import { codexAccountHome } from './codex-rpc.js';
|
|
|
5
5
|
import { randomUUID } from 'node:crypto';
|
|
6
6
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
7
7
|
import { ANTHROPIC_CONSOLE_BASE_URL, anthropicAccountHome } from './anthropic-credentials.js';
|
|
8
|
+
import { GROK_BASE_URL } from './grok-provider.js';
|
|
9
|
+
import { OPENCODE_BASE_URL } from './opencode-cli-provider.js';
|
|
8
10
|
const defaultConsoleAuth = async () => new (await import('./anthropic-console-auth.js')).AnthropicConsoleAuth();
|
|
9
11
|
/** Provider edits remain isolated until the caller atomically persists the returned draft. */
|
|
10
12
|
export async function editProviderSettings(config, id, ui, signal, login = async (options) => (await import('./codex-auth.js')).loginCodex(options), retire = retireUnsavedCodexAccounts, consoleAuth = defaultConsoleAuth) {
|
|
@@ -57,7 +59,8 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
|
|
|
57
59
|
{ id: 'glm', label: 'GLM Coding Plan (Z.ai)' },
|
|
58
60
|
{ id: 'openai', label: 'OpenAI' }, { id: 'anthropic', label: 'Anthropic' },
|
|
59
61
|
{ id: 'local', label: 'Local server' }, { id: 'codex', label: 'ChatGPT / Codex' },
|
|
60
|
-
{ id: 'claude', label: 'Claude subscription' }, { id: '
|
|
62
|
+
{ id: 'claude', label: 'Claude subscription' }, { id: 'grok', label: 'Grok subscription (Grok CLI)' },
|
|
63
|
+
{ id: 'opencode', label: 'OpenCode (CLI sign-in)' }, { id: 'opencode-go', label: 'OpenCode Go' },
|
|
61
64
|
{ id: 'custom', label: 'Custom provider' },
|
|
62
65
|
]);
|
|
63
66
|
if (!preset || signal.aborted)
|
|
@@ -73,6 +76,8 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
|
|
|
73
76
|
local: { type: 'openai-compatible', baseUrl: 'http://127.0.0.1:1234/v1', model: '' },
|
|
74
77
|
codex: { type: 'codex', baseUrl: 'https://chatgpt.com/backend-api/codex', model: '' },
|
|
75
78
|
claude: { type: 'claude', baseUrl: 'https://api.anthropic.com', model: '' },
|
|
79
|
+
grok: { type: 'grok', baseUrl: GROK_BASE_URL, model: '' },
|
|
80
|
+
opencode: { type: 'opencode', baseUrl: OPENCODE_BASE_URL, model: '' },
|
|
76
81
|
'opencode-go': { type: 'opencode-go', baseUrl: 'https://opencode.ai/inference/go', model: '' },
|
|
77
82
|
custom: { type: 'openai-compatible', baseUrl: 'https://api.openai.com/v1', model: '' },
|
|
78
83
|
};
|
|
@@ -128,7 +133,9 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
|
|
|
128
133
|
while (!signal.aborted) {
|
|
129
134
|
const isCodex = provider.type === 'codex';
|
|
130
135
|
const isClaude = provider.type === 'claude';
|
|
131
|
-
const
|
|
136
|
+
const isGrok = provider.type === 'grok';
|
|
137
|
+
const isOpenCode = provider.type === 'opencode';
|
|
138
|
+
const managed = isCodex || isClaude || isGrok || isOpenCode;
|
|
132
139
|
// A Console sign-in fixes the protocol and endpoint and replaces the key rows with the sign-in.
|
|
133
140
|
const isConsole = provider.type === 'anthropic' && provider.anthropicAuth === 'console';
|
|
134
141
|
const field = await choose(`Providers > ${provider.id}`, [
|
|
@@ -144,7 +151,7 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
|
|
|
144
151
|
{ id: 'apiKey', label: `API key: ${provider.apiKey ? 'saved (hidden)' : 'not saved'}` },
|
|
145
152
|
{ id: 'apiKeyEnv', label: `Environment fallback: ${provider.apiKeyEnv ?? 'none'}` },
|
|
146
153
|
...(provider.apiKey || provider.apiKeyEnv ? [{ id: 'clearAuth', label: 'Remove authentication' }] : []),
|
|
147
|
-
] : [{ id: 'login', label: isClaude ? 'Check Claude Code sign-in' : 'Sign in with ChatGPT / Codex' }]),
|
|
154
|
+
] : [{ id: 'login', label: isClaude ? 'Check Claude Code sign-in' : isGrok ? 'Check Grok sign-in' : isOpenCode ? 'Check OpenCode connection' : 'Sign in with ChatGPT / Codex' }]),
|
|
148
155
|
{ id: 'name', label: `Display name: ${provider.name || 'not set'}` },
|
|
149
156
|
{ id: 'model', label: `Active model: ${provider.model || 'not set'}` },
|
|
150
157
|
{ id: 'models', label: `Models: ${providerModels(provider).length || 'none'} configured` },
|
|
@@ -396,6 +403,18 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
|
|
|
396
403
|
throw new Error('Run claude auth login on this machine, then retry.');
|
|
397
404
|
return catalog.models.map(id => ({ id }));
|
|
398
405
|
}
|
|
406
|
+
if (isGrok) {
|
|
407
|
+
const catalog = await (await import('./grok-provider.js')).readGrokCatalog(loadSignal);
|
|
408
|
+
if (!catalog.signedIn)
|
|
409
|
+
throw new Error('Run grok login on this machine, then retry.');
|
|
410
|
+
return catalog.models.map(id => ({ id }));
|
|
411
|
+
}
|
|
412
|
+
if (isOpenCode) {
|
|
413
|
+
const catalog = await (await import('./opencode-cli-provider.js')).readOpenCodeCatalog(loadSignal);
|
|
414
|
+
if (!catalog.models.length)
|
|
415
|
+
throw new Error('Run opencode auth login on this machine, then retry.');
|
|
416
|
+
return catalog.models.map(model => ({ id: model.id }));
|
|
417
|
+
}
|
|
399
418
|
const result = await login({ signal: loadSignal, write: text => ui.print?.(text), home: codexAccountHome(candidate.codexAccount) });
|
|
400
419
|
if (result.email !== undefined)
|
|
401
420
|
candidate.codexEmail = result.email;
|
package/dist/src/providers.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { ModelAdapter } from './types.js';
|
|
2
2
|
export declare const REASONING_EFFORTS: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
3
3
|
export type ReasoningEffort = typeof REASONING_EFFORTS[number];
|
|
4
|
+
/** Every provider type a configuration may name. */
|
|
5
|
+
export declare const PROVIDER_TYPES: readonly ["openai-compatible", "anthropic", "codex", "claude", "opencode-go", "grok", "opencode"];
|
|
6
|
+
export type ProviderType = typeof PROVIDER_TYPES[number];
|
|
7
|
+
/**
|
|
8
|
+
* Types that run through a vendor CLI's own sign-in on this machine instead of a key Andorra holds.
|
|
9
|
+
*
|
|
10
|
+
* They carry no credential fields, use a fixed marker base URL, and bound each request themselves,
|
|
11
|
+
* so configuration rejects key and timeout overrides on them rather than silently ignoring them.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SIGN_IN_PROVIDER_TYPES: readonly ["codex", "claude", "grok", "opencode"];
|
|
14
|
+
export declare function isSignInProviderType(type: unknown): type is typeof SIGN_IN_PROVIDER_TYPES[number];
|
|
4
15
|
/**
|
|
5
16
|
* Inactivity bound for inference, and wall-clock bound for other HTTP requests,
|
|
6
17
|
* in milliseconds, when a provider does not configure its own.
|
|
@@ -62,7 +73,7 @@ export declare const MODEL_LISTING_TIMEOUT_MS = 30000;
|
|
|
62
73
|
export declare function deadlinePhrase(ms: number): string;
|
|
63
74
|
export interface ProviderConfig {
|
|
64
75
|
id: string;
|
|
65
|
-
type:
|
|
76
|
+
type: ProviderType;
|
|
66
77
|
baseUrl: string;
|
|
67
78
|
/** Actual credential saved locally; takes precedence over apiKeyEnv. Never display or log it. */
|
|
68
79
|
apiKey?: string;
|
package/dist/src/providers.js
CHANGED
|
@@ -3,9 +3,25 @@ import { COMPLETION_TOOL } from './completion.js';
|
|
|
3
3
|
import { createCodexAdapter } from './codex-provider.js';
|
|
4
4
|
import { createClaudeAdapter } from './claude-provider.js';
|
|
5
5
|
import { createOpenCodeAdapter } from './opencode-provider.js';
|
|
6
|
+
import { createGrokAdapter } from './grok-provider.js';
|
|
7
|
+
import { createOpenCodeCliAdapter } from './opencode-cli-provider.js';
|
|
6
8
|
import { providerAuthHeaders } from './anthropic-credentials.js';
|
|
7
9
|
import { generateEngineResponse, isEngineContextOverflow } from './provider-engine.js';
|
|
8
10
|
export const REASONING_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
11
|
+
/** Every provider type a configuration may name. */
|
|
12
|
+
export const PROVIDER_TYPES = ['openai-compatible', 'anthropic', 'codex', 'claude', 'opencode-go', 'grok', 'opencode'];
|
|
13
|
+
/**
|
|
14
|
+
* Types that run through a vendor CLI's own sign-in on this machine instead of a key Andorra holds.
|
|
15
|
+
*
|
|
16
|
+
* They carry no credential fields, use a fixed marker base URL, and bound each request themselves,
|
|
17
|
+
* so configuration rejects key and timeout overrides on them rather than silently ignoring them.
|
|
18
|
+
*/
|
|
19
|
+
export const SIGN_IN_PROVIDER_TYPES = ['codex', 'claude', 'grok', 'opencode'];
|
|
20
|
+
export function isSignInProviderType(type) {
|
|
21
|
+
return SIGN_IN_PROVIDER_TYPES.includes(type);
|
|
22
|
+
}
|
|
23
|
+
/** The product name messages use for a sign-in type. */
|
|
24
|
+
const SIGN_IN_PRODUCT = { codex: 'Codex', claude: 'Claude', grok: 'Grok', opencode: 'OpenCode' };
|
|
9
25
|
/**
|
|
10
26
|
* Inactivity bound for inference, and wall-clock bound for other HTTP requests,
|
|
11
27
|
* in milliseconds, when a provider does not configure its own.
|
|
@@ -42,10 +58,8 @@ export function assertRequestTimeout(provider) {
|
|
|
42
58
|
const value = provider.requestTimeoutMs;
|
|
43
59
|
if (value === undefined)
|
|
44
60
|
return;
|
|
45
|
-
if (provider.type
|
|
46
|
-
throw new Error(
|
|
47
|
-
if (provider.type === 'claude')
|
|
48
|
-
throw new Error('Claude providers bound each request at ten minutes; requestTimeoutMs is not supported');
|
|
61
|
+
if (isSignInProviderType(provider.type))
|
|
62
|
+
throw new Error(`${SIGN_IN_PRODUCT[provider.type]} providers bound each request at ten minutes; requestTimeoutMs is not supported`);
|
|
49
63
|
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0 || value > MAX_REQUEST_TIMEOUT_MS) {
|
|
50
64
|
throw new Error(`Provider requestTimeoutMs must be 0 (no timeout) or an integer of milliseconds up to ${MAX_REQUEST_TIMEOUT_MS}`);
|
|
51
65
|
}
|
|
@@ -64,10 +78,8 @@ export function assertStreamIdleTimeout(provider) {
|
|
|
64
78
|
const value = provider.streamIdleTimeoutMs;
|
|
65
79
|
if (value === undefined)
|
|
66
80
|
return;
|
|
67
|
-
if (provider.type
|
|
68
|
-
throw new Error(
|
|
69
|
-
if (provider.type === 'claude')
|
|
70
|
-
throw new Error('Claude providers bound each request at ten minutes; streamIdleTimeoutMs is not supported');
|
|
81
|
+
if (isSignInProviderType(provider.type))
|
|
82
|
+
throw new Error(`${SIGN_IN_PRODUCT[provider.type]} providers bound each request at ten minutes; streamIdleTimeoutMs is not supported`);
|
|
71
83
|
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0 || value > MAX_REQUEST_TIMEOUT_MS) {
|
|
72
84
|
throw new Error(`Provider streamIdleTimeoutMs must be 0 (no bound) or an integer of milliseconds up to ${MAX_REQUEST_TIMEOUT_MS}`);
|
|
73
85
|
}
|
|
@@ -255,6 +267,9 @@ export function assertProviderCredentials(provider) {
|
|
|
255
267
|
if (provider.type === 'claude' && (provider.apiKey !== undefined || provider.apiKeyEnv !== undefined)) {
|
|
256
268
|
throw new Error('Claude providers use Claude Code sign-in; API key overrides are not supported.');
|
|
257
269
|
}
|
|
270
|
+
if ((provider.type === 'grok' || provider.type === 'opencode') && (provider.apiKey !== undefined || provider.apiKeyEnv !== undefined)) {
|
|
271
|
+
throw new Error(`${SIGN_IN_PRODUCT[provider.type]} providers use their CLI sign-in; API key overrides are not supported.`);
|
|
272
|
+
}
|
|
258
273
|
if (provider.apiKey !== undefined && (typeof provider.apiKey !== 'string' || !/^[\x21-\x7e]+$/.test(provider.apiKey))) {
|
|
259
274
|
throw new Error('API key must be nonempty and contain no whitespace or control characters.');
|
|
260
275
|
}
|
|
@@ -836,6 +851,10 @@ export function createAdapter(config) {
|
|
|
836
851
|
return createCodexAdapter(config);
|
|
837
852
|
if (config.type === 'claude')
|
|
838
853
|
return createClaudeAdapter(config);
|
|
854
|
+
if (config.type === 'grok')
|
|
855
|
+
return createGrokAdapter(config);
|
|
856
|
+
if (config.type === 'opencode')
|
|
857
|
+
return createOpenCodeCliAdapter(config);
|
|
839
858
|
if (config.type === 'opencode-go')
|
|
840
859
|
return createOpenCodeAdapter(config);
|
|
841
860
|
let base;
|
|
@@ -13,9 +13,9 @@ export interface SessionPullRequest {
|
|
|
13
13
|
number: number;
|
|
14
14
|
title?: string;
|
|
15
15
|
state: PullRequestState;
|
|
16
|
+
/** Wake the session when a code-review bot comments. Never on for a merged or closed PR: it switches itself off. */
|
|
16
17
|
autoFix: boolean;
|
|
17
18
|
mergeWhenReady: boolean;
|
|
18
|
-
autoArchive: boolean;
|
|
19
19
|
/** When the PR was attached: a top-level comment older than this was never the session's to answer. */
|
|
20
20
|
attachedAt: string;
|
|
21
21
|
/** The newest review comment Auto-fix has already handed to the agent. */
|
|
@@ -30,16 +30,24 @@ export interface SessionPullRequest {
|
|
|
30
30
|
};
|
|
31
31
|
/** The selections of the run that attached or last configured the PR, so an Auto-fix run continues under them. */
|
|
32
32
|
carry?: WakeCarry;
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/** The signed-in `gh` account that can read this PR; every call for it runs as this account. */
|
|
34
|
+
ghUser?: string;
|
|
35
|
+
/** Why the watcher last could not read this PR; cleared by the next successful read. */
|
|
36
|
+
watchError?: string;
|
|
35
37
|
updatedAt: string;
|
|
36
38
|
}
|
|
37
39
|
export type PullRequestState = 'open' | 'draft' | 'merged' | 'closed';
|
|
40
|
+
/** Whether GitHub is done with the PR: once merged or closed there is nothing left to fix, merge or convert. */
|
|
41
|
+
export declare const isFinishedPullRequest: (state: PullRequestState) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* A merged or closed PR with Auto-fix switched off and its pending wake forgotten: there is nothing left to fix, so
|
|
44
|
+
* the setting stops on its own instead of staying on for a PR that can no longer change. An open PR is unchanged.
|
|
45
|
+
*/
|
|
46
|
+
export declare function settleFinishedPullRequest(pullRequest: SessionPullRequest): SessionPullRequest;
|
|
38
47
|
/** The settings a caller may change; `draft` converts the PR to a draft or marks it ready. */
|
|
39
48
|
export interface PullRequestSettings {
|
|
40
49
|
autoFix?: boolean;
|
|
41
50
|
mergeWhenReady?: boolean;
|
|
42
|
-
autoArchive?: boolean;
|
|
43
51
|
draft?: boolean;
|
|
44
52
|
}
|
|
45
53
|
export interface PullRequestRef {
|
|
@@ -62,15 +70,71 @@ export declare function listPullRequests(home: string): Promise<{
|
|
|
62
70
|
pullRequest: SessionPullRequest;
|
|
63
71
|
}[]>;
|
|
64
72
|
export declare function withPullRequest<T>(home: string, sessionId: string, work: () => Promise<T>): Promise<T>;
|
|
65
|
-
/**
|
|
66
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Runs `gh` with the given arguments and resolves to its stdout; a nonzero exit rejects with its stderr.
|
|
75
|
+
* With `user`, the command runs as that signed-in account, whichever one `gh` has active.
|
|
76
|
+
*/
|
|
77
|
+
export type GhRunner = (args: readonly string[], options?: {
|
|
78
|
+
user?: string;
|
|
79
|
+
}) => Promise<string>;
|
|
80
|
+
/** Runs one `gh` command in the given environment and resolves to its stdout. */
|
|
81
|
+
export type GhExec = (args: readonly string[], env: NodeJS.ProcessEnv) => Promise<string>;
|
|
82
|
+
export declare function createGhRunner(exec?: GhExec): GhRunner;
|
|
67
83
|
export declare const runGh: GhRunner;
|
|
68
|
-
/** The PR's title, state and auto-merge as GitHub reports them
|
|
69
|
-
export
|
|
84
|
+
/** The PR's title, state and auto-merge as GitHub reports them. */
|
|
85
|
+
export interface PullRequestView {
|
|
70
86
|
title: string;
|
|
71
87
|
state: PullRequestState;
|
|
72
88
|
autoMerge: boolean;
|
|
89
|
+
}
|
|
90
|
+
/** The PR's title, state and auto-merge as GitHub reports them now, read as `user` when given. */
|
|
91
|
+
export declare function viewPullRequest(gh: GhRunner, url: string, user?: string): Promise<PullRequestView>;
|
|
92
|
+
/** The signed-in github.com accounts `gh` can use, the active one first. */
|
|
93
|
+
export declare function ghAccounts(gh: GhRunner): Promise<string[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Whether a `gh` failure says the account cannot see the PR (or has no usable token, including a saved account that
|
|
96
|
+
* was signed out), rather than an outage. A rate limit answers 403 too, but it is an outage: the account may well
|
|
97
|
+
* see the PR once the limit lifts.
|
|
98
|
+
*/
|
|
99
|
+
export declare function isGhAccessError(error: unknown): boolean;
|
|
100
|
+
/** Whether a `gh auth status` failure means this `gh` cannot list accounts at all (an older gh without `--json`). */
|
|
101
|
+
export declare function isGhListingUnsupported(error: unknown): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* The first signed-in account that can read the PR, with what it read; `undefined` when none can, or when `gh`
|
|
104
|
+
* cannot list accounts at all (an older gh). The active account is tried first, so a PR it can read never switches
|
|
105
|
+
* accounts. A failure that is not about access (an outage, including a listing that fails for any other reason or
|
|
106
|
+
* answers something that is not JSON) is thrown: it does not mean nobody can read the PR. `undefined` means either
|
|
107
|
+
* nobody can read it or `gh` cannot list accounts, so callers that must tell those apart use
|
|
108
|
+
* `readPullRequestAsAnyAccount`.
|
|
109
|
+
*/
|
|
110
|
+
export declare function findPullRequestAccount(gh: GhRunner, url: string): Promise<{
|
|
111
|
+
user: string;
|
|
112
|
+
seen: PullRequestView;
|
|
113
|
+
} | undefined>;
|
|
114
|
+
/**
|
|
115
|
+
* Read a PR as whichever signed-in account can see it: when a PR is attached, and when the watcher must detect the
|
|
116
|
+
* account again. `ghUser` names the account that read it whenever `gh` can list accounts; without a list the
|
|
117
|
+
* environment's account is asked. Callers record "no account can read it" ONLY on `unreadable`, which means every
|
|
118
|
+
* listed account (or, without a list, the environment's) was refused. A result with only `failed` is an outage (the
|
|
119
|
+
* error that stopped the detection), or a `gh` that cannot list accounts and whose environment read also failed for
|
|
120
|
+
* a reason other than access; the PR is then tracked as open until the watcher reads it.
|
|
121
|
+
*/
|
|
122
|
+
export declare function readPullRequestAsAnyAccount(gh: GhRunner, url: string): Promise<{
|
|
123
|
+
seen?: PullRequestView;
|
|
124
|
+
ghUser?: string;
|
|
125
|
+
unreadable?: true;
|
|
126
|
+
failed?: unknown;
|
|
73
127
|
}>;
|
|
128
|
+
/**
|
|
129
|
+
* `gh` bound to the account saved on the record, or the active account when none is saved. The bound runner must
|
|
130
|
+
* never be passed to `ghAccounts` or `findPullRequestAccount`: with a token injected, `gh auth status` reports
|
|
131
|
+
* only that token's account.
|
|
132
|
+
*/
|
|
133
|
+
export declare function ghFor(gh: GhRunner, pullRequest: {
|
|
134
|
+
ghUser?: string;
|
|
135
|
+
}): GhRunner;
|
|
136
|
+
/** What the Pull request row says when no signed-in account can read the PR. */
|
|
137
|
+
export declare const noAccountMessage: (url: string) => string;
|
|
74
138
|
/** A freshly attached PR with every setting off. */
|
|
75
139
|
export declare function newPullRequest(ref: PullRequestRef, now?: Date): SessionPullRequest;
|
|
76
140
|
/**
|
|
@@ -85,6 +149,16 @@ export declare function newPullRequest(ref: PullRequestRef, now?: Date): Session
|
|
|
85
149
|
* that was skipped because the stored flag already said "off" would leave the PR merging against the user's word.
|
|
86
150
|
*/
|
|
87
151
|
export declare function applyPullRequestSettings(gh: GhRunner, current: SessionPullRequest, changes: PullRequestSettings, now?: Date): Promise<SessionPullRequest>;
|
|
152
|
+
/**
|
|
153
|
+
* Apply settings as the record's account, and when that account can no longer see the PR (signed out, access
|
|
154
|
+
* removed), find one that can, keep it on the result, and apply once more. The watcher only re-detects the PRs it
|
|
155
|
+
* polls, so this is how a menu change recovers for a PR with Auto-fix off. Any other failure, or
|
|
156
|
+
* a re-detection that finds the same account or nobody, throws the original error; an outage while re-detecting is
|
|
157
|
+
* named as such, with the access error as its cause. The retry cannot apply a GitHub-side change twice, because
|
|
158
|
+
* `applyPullRequestSettings` re-decides each change against a fresh `pr view`, so a step that succeeded before the
|
|
159
|
+
* access error is skipped on the second attempt.
|
|
160
|
+
*/
|
|
161
|
+
export declare function applyPullRequestSettingsAsReadableAccount(gh: GhRunner, current: SessionPullRequest, changes: PullRequestSettings, now?: Date): Promise<SessionPullRequest>;
|
|
88
162
|
/** A session's pull request as its run's `pull_request` tool reaches it; bound to that session by the engine. */
|
|
89
163
|
export interface PullRequestControl {
|
|
90
164
|
status(): Promise<SessionPullRequest | undefined>;
|
|
@@ -109,10 +183,19 @@ export declare class PullRequestCreateDetector {
|
|
|
109
183
|
}): PullRequestRef | undefined;
|
|
110
184
|
}
|
|
111
185
|
/**
|
|
112
|
-
* The review
|
|
186
|
+
* The code-review bots whose comments Auto-fix answers, by GitHub login (GraphQL reports a bot's login without the
|
|
187
|
+
* `[bot]` suffix the REST API adds; both spellings match). Nobody else wakes the agent: not CI or deployment bots,
|
|
188
|
+
* not the agent's own replies and `@codex review` requests (posted as whichever signed-in account it ran `gh` as,
|
|
189
|
+
* which need not be the account the watcher reads with), and not people.
|
|
190
|
+
*/
|
|
191
|
+
export declare const CODE_REVIEWER_LOGINS: readonly string[];
|
|
192
|
+
/** Whether `login` is one of the code-review bots Auto-fix answers. */
|
|
193
|
+
export declare function isCodeReviewer(login: string | undefined): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* The code reviewers' comments that arrived since Auto-fix last woke the agent.
|
|
113
196
|
*
|
|
114
|
-
* Counted: comments in unresolved review threads, and top-level
|
|
115
|
-
*
|
|
197
|
+
* Counted: comments by a code-review bot (`CODE_REVIEWER_LOGINS`) in unresolved review threads, and its top-level
|
|
198
|
+
* PR comments posted after the PR was attached. Any other author's comment is never a reason to wake the agent.
|
|
116
199
|
*/
|
|
117
200
|
export declare function newReviewComments(gh: GhRunner, pullRequest: SessionPullRequest): Promise<{
|
|
118
201
|
threads: number;
|
|
@@ -122,6 +205,8 @@ export declare function newReviewComments(gh: GhRunner, pullRequest: SessionPull
|
|
|
122
205
|
/**
|
|
123
206
|
* The prompt Auto-fix delivers. It names the PR and how much is new, never the comments themselves: their text
|
|
124
207
|
* is third-party content, and the agent reads it through `gh` as tool output rather than as the user's words.
|
|
208
|
+
* When the PR is read as a saved account, the prompt names it (the engine's own record, not third-party text) and
|
|
209
|
+
* says how to run `gh` as it: the agent's shell runs as the active keyring account, which may not see the PR.
|
|
125
210
|
*/
|
|
126
211
|
export declare function autoFixPrompt(pullRequest: SessionPullRequest, found: {
|
|
127
212
|
threads: number;
|
|
@@ -148,8 +233,6 @@ export interface PullRequestWatcherOptions {
|
|
|
148
233
|
intervalMs?: number;
|
|
149
234
|
/** A PR's stored state changed. */
|
|
150
235
|
onUpdated: (sessionId: string, pullRequest: SessionPullRequest) => void;
|
|
151
|
-
/** File the session away; `false` (a run is active) or a rejection is retried on the next poll. */
|
|
152
|
-
archive: (sessionId: string) => Promise<boolean>;
|
|
153
236
|
/** Arm an Auto-fix prompt for the session, continuing under `carry`; returns the wake's id. */
|
|
154
237
|
wake: (sessionId: string, prompt: string, carry: WakeCarry | undefined) => string;
|
|
155
238
|
/** Whether this engine still holds the wake `id`, armed and not yet delivered. */
|
|
@@ -158,10 +241,13 @@ export interface PullRequestWatcherOptions {
|
|
|
158
241
|
/** Overridable for tests; defaults to the home's exclusive watcher lease. */
|
|
159
242
|
claim?: () => Promise<boolean>;
|
|
160
243
|
}
|
|
161
|
-
/**
|
|
244
|
+
/**
|
|
245
|
+
* Whether a PR still needs the watcher: an unfinished PR until GitHub calls it finished, so the card's state chip
|
|
246
|
+
* never goes stale. A merged or closed PR never does.
|
|
247
|
+
*/
|
|
162
248
|
export declare function pullRequestNeedsWatch(pullRequest: SessionPullRequest): boolean;
|
|
163
249
|
/**
|
|
164
|
-
* Polls
|
|
250
|
+
* Polls every unfinished PR, and wakes the agent for new code-reviewer comments on the ones with Auto-fix on.
|
|
165
251
|
*
|
|
166
252
|
* The timer is unref'd and every poll is serialized: a slow `gh` never stacks a second poll on the first.
|
|
167
253
|
*/
|
|
@@ -177,15 +263,32 @@ export declare class PullRequestWatcher {
|
|
|
177
263
|
/** One pass over every watched PR. Public so a test (or a just-changed setting) can run one now. */
|
|
178
264
|
poll(): Promise<void>;
|
|
179
265
|
private pass;
|
|
266
|
+
/**
|
|
267
|
+
* The PR as GitHub reports it, read as the record's account (the active one when none is saved). An account that
|
|
268
|
+
* cannot see it is replaced by one that can (`account`: the login to save, or `null` to clear a stale one when only
|
|
269
|
+
* the environment's account could read it; absent: no change). When no signed-in account can, the record says so,
|
|
270
|
+
* once, and this poll skips the PR. Any other failure (an outage, a rate limit) is thrown to the pass, which logs it.
|
|
271
|
+
*/
|
|
272
|
+
private read;
|
|
180
273
|
private check;
|
|
181
274
|
}
|
|
182
275
|
/**
|
|
183
|
-
* Whether an Auto-fix wake should
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
276
|
+
* Whether an Auto-fix wake should be delivered now, decided at delivery rather than at arming, with GitHub asked
|
|
277
|
+
* first.
|
|
278
|
+
*
|
|
279
|
+
* The PR can be dismissed, replaced or switched off while the wake waits out a busy engine, from this engine or
|
|
280
|
+
* another, and a prompt telling the agent to fix and push must not outlive the user's word that it should stop. Nor
|
|
281
|
+
* is the record's state enough: a PR merged or closed by hand on GitHub is only seen at the watcher's next poll, so
|
|
282
|
+
* GitHub is read every time instead of trusting the record.
|
|
283
|
+
*
|
|
284
|
+
* `deliver` is true only when the PR is open on GitHub and the record still asks for this wake. A finished PR is
|
|
285
|
+
* saved as GitHub reports it, with Auto-fix switched off, and returned as `pullRequest` for the caller to publish.
|
|
286
|
+
* A failed read throws: the caller keeps the wake and asks again later rather than sending it unconfirmed.
|
|
187
287
|
*/
|
|
188
|
-
export declare function
|
|
288
|
+
export declare function confirmAutoFixWake(home: string, gh: GhRunner, sessionId: string, wakeId: string): Promise<{
|
|
289
|
+
deliver: boolean;
|
|
290
|
+
pullRequest?: SessionPullRequest;
|
|
291
|
+
}>;
|
|
189
292
|
/** Forget the pending Auto-fix wake on a record that keeps the PR (Auto-fix switched off). */
|
|
190
293
|
export declare function withoutPendingFix(pullRequest: SessionPullRequest): SessionPullRequest;
|
|
191
294
|
/**
|