@andorra-labs/code 0.1.17 → 0.1.19
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-jev-savings.d.ts +4 -0
- package/dist/src/account-jev-savings.js +92 -0
- package/dist/src/acp-agent.js +2 -2
- package/dist/src/agent-execution.js +441 -53
- package/dist/src/agent-mcp.js +7 -1
- package/dist/src/agent-modifiers.js +5 -7
- package/dist/src/analytics.d.ts +19 -1
- package/dist/src/analytics.js +9 -1
- package/dist/src/andorra/entry.js +15 -6
- package/dist/src/andorra/errors.js +3 -0
- package/dist/src/andorra/hosted.d.ts +8 -0
- package/dist/src/andorra/hosted.js +22 -3
- package/dist/src/andorra/streams.d.ts +49 -0
- package/dist/src/andorra/streams.js +98 -0
- package/dist/src/antigravity-acp.d.ts +28 -0
- package/dist/src/antigravity-acp.js +150 -0
- package/dist/src/antigravity-terminal.d.ts +2 -0
- package/dist/src/antigravity-terminal.js +214 -0
- package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
- package/dist/src/app-server/adaptive-routing-settings.js +69 -0
- package/dist/src/app-server/artifact.d.ts +14 -0
- package/dist/src/app-server/artifact.js +46 -0
- package/dist/src/app-server/legal-protocol.d.ts +33 -0
- package/dist/src/app-server/legal-protocol.js +16 -0
- package/dist/src/app-server/protocol.d.ts +34 -3
- package/dist/src/app-server/protocol.js +3 -1
- package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
- package/dist/src/app-server/telemetry-protocol.js +2 -0
- package/dist/src/app-server/telemetry.d.ts +38 -0
- package/dist/src/app-server/telemetry.js +163 -0
- package/dist/src/app-server/workspace.d.ts +21 -0
- package/dist/src/app-server/workspace.js +192 -10
- package/dist/src/app-server.d.ts +82 -26
- package/dist/src/app-server.js +1573 -417
- package/dist/src/attachments.d.ts +10 -0
- package/dist/src/attachments.js +102 -7
- package/dist/src/auth/AuthManager.d.ts +11 -2
- package/dist/src/auth/AuthManager.js +56 -13
- package/dist/src/auth/index.d.ts +5 -1
- package/dist/src/auth/index.js +8 -1
- package/dist/src/auth/lifecycle.d.ts +13 -0
- package/dist/src/auth/lifecycle.js +109 -0
- package/dist/src/auth/store.d.ts +1 -0
- package/dist/src/auth/store.js +12 -0
- package/dist/src/auth/types.d.ts +12 -0
- package/dist/src/automation-runner.js +2 -0
- package/dist/src/automation-service.js +7 -2
- package/dist/src/automation-tool.js +2 -1
- package/dist/src/benchmark-scores.d.ts +88 -0
- package/dist/src/benchmark-scores.js +302 -0
- package/dist/src/bridge/command.js +16 -1
- package/dist/src/bridge/control.d.ts +3 -1
- package/dist/src/bridge/control.js +9 -3
- package/dist/src/bridge/engines.d.ts +2 -0
- package/dist/src/bridge/engines.js +9 -0
- package/dist/src/bridge/github.d.ts +108 -0
- package/dist/src/bridge/github.js +378 -0
- package/dist/src/bridge/host-ops.d.ts +3 -3
- package/dist/src/bridge/host-ops.js +14 -2
- package/dist/src/bridge/host.d.ts +2 -0
- package/dist/src/bridge/host.js +70 -16
- package/dist/src/bridge/protocol.d.ts +1 -0
- package/dist/src/bridge/protocol.js +1 -0
- package/dist/src/browser-panel-tool.d.ts +12 -0
- package/dist/src/browser-panel-tool.js +30 -3
- package/dist/src/browser-runner.js +53 -62
- package/dist/src/browser-server.js +10 -4
- package/dist/src/browser-session.d.ts +14 -0
- package/dist/src/browser-session.js +57 -12
- package/dist/src/browser-view.d.ts +40 -1
- package/dist/src/browser-view.js +163 -9
- package/dist/src/browser-window-style.d.ts +27 -0
- package/dist/src/browser-window-style.js +244 -0
- package/dist/src/bug-report-attachments.d.ts +48 -0
- package/dist/src/bug-report-attachments.js +327 -0
- package/dist/src/bug-report.d.ts +23 -3
- package/dist/src/bug-report.js +72 -9
- package/dist/src/claude-provider.d.ts +1 -0
- package/dist/src/claude-provider.js +77 -36
- package/dist/src/cli.d.ts +1 -3
- package/dist/src/cli.js +245 -62
- package/dist/src/codex-provider.d.ts +1 -0
- package/dist/src/codex-provider.js +44 -8
- package/dist/src/coding-tools.d.ts +1 -0
- package/dist/src/coding-tools.js +28 -7
- package/dist/src/command-screens.d.ts +1 -1
- package/dist/src/command-screens.js +2 -2
- package/dist/src/commands.d.ts +9 -2
- package/dist/src/commands.js +69 -64
- package/dist/src/completion.js +13 -7
- package/dist/src/config.d.ts +14 -3
- package/dist/src/config.js +57 -17
- package/dist/src/context-budget.d.ts +11 -2
- package/dist/src/context-budget.js +38 -4
- package/dist/src/context-compaction.d.ts +10 -8
- package/dist/src/context-compaction.js +23 -24
- package/dist/src/deadline.js +1 -1
- package/dist/src/decision/DecisionEngine.d.ts +2 -0
- package/dist/src/decision/DecisionManager.d.ts +16 -0
- package/dist/src/decision/DecisionManager.js +75 -2
- package/dist/src/decision/applyTaskKind.d.ts +8 -0
- package/dist/src/decision/applyTaskKind.js +53 -0
- package/dist/src/decision/applyToolMenu.js +6 -2
- package/dist/src/decision/hostedPolicy.js +6 -3
- package/dist/src/decision/optimizationPolicy.d.ts +10 -0
- package/dist/src/decision/optimizationPolicy.js +23 -3
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +4 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.js +29 -7
- package/dist/src/decision/providers/index.js +1 -1
- package/dist/src/decision/taskKind.d.ts +52 -0
- package/dist/src/decision/taskKind.js +76 -0
- package/dist/src/decision/toolFamilies.js +1 -1
- package/dist/src/decision/types.d.ts +3 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/efficiency.d.ts +80 -1
- package/dist/src/efficiency.js +119 -4
- package/dist/src/effort-routing.d.ts +27 -0
- package/dist/src/effort-routing.js +34 -0
- package/dist/src/evidence.d.ts +110 -0
- package/dist/src/evidence.js +195 -0
- package/dist/src/extensions.d.ts +2 -0
- package/dist/src/extensions.js +30 -20
- package/dist/src/github-app/agent-writes.d.ts +1 -1
- package/dist/src/github-app/agent-writes.js +1 -1
- package/dist/src/github-app/client.d.ts +19 -0
- package/dist/src/github-app/client.js +21 -1
- package/dist/src/github-app/event-source.d.ts +0 -5
- package/dist/src/github-app/event-source.js +1 -31
- package/dist/src/github-app/metrics.d.ts +2 -5
- package/dist/src/github-app/metrics.js +2 -14
- package/dist/src/github-app/review-loop.d.ts +5 -5
- package/dist/src/github-app/review-loop.js +1 -1
- package/dist/src/github-app/review-node.d.ts +2 -2
- package/dist/src/github-app/triggers.d.ts +3 -3
- package/dist/src/github-names.d.ts +7 -0
- package/dist/src/github-names.js +7 -0
- package/dist/src/glob-search.d.ts +1 -0
- package/dist/src/glob-search.js +3 -0
- package/dist/src/google-provider.d.ts +5 -28
- package/dist/src/google-provider.js +6 -141
- package/dist/src/graph-editor-session.d.ts +1 -0
- package/dist/src/graph-editor-session.js +2 -0
- package/dist/src/graph-health.js +3 -1
- package/dist/src/graph-preview.d.ts +2 -0
- package/dist/src/graph-preview.js +1 -0
- package/dist/src/graph-runner.js +20 -14
- package/dist/src/graph-selection.d.ts +3 -1
- package/dist/src/graph-selection.js +2 -2
- package/dist/src/graph-server.d.ts +8 -1
- package/dist/src/graph-server.js +49 -12
- package/dist/src/graph-sync.d.ts +2 -1
- package/dist/src/graph-sync.js +13 -0
- package/dist/src/graph-ui/app.js +49 -8
- package/dist/src/graph-ui/index.html +1 -1
- package/dist/src/graphs.d.ts +23 -1
- package/dist/src/graphs.js +58 -7
- package/dist/src/grok-provider.js +17 -14
- package/dist/src/hardened-runtime.js +39 -25
- package/dist/src/jev-savings.d.ts +4 -0
- package/dist/src/jev-savings.js +13 -0
- package/dist/src/legal/client.d.ts +25 -0
- package/dist/src/legal/client.js +47 -0
- package/dist/src/legal/command.d.ts +13 -0
- package/dist/src/legal/command.js +98 -0
- package/dist/src/legal/documents.d.ts +2 -0
- package/dist/src/legal/documents.js +14 -0
- package/dist/src/legal/gate.d.ts +13 -0
- package/dist/src/legal/gate.js +96 -0
- package/dist/src/legal/manifest.d.ts +21 -0
- package/dist/src/legal/manifest.js +23 -0
- package/dist/src/legal/receipt.d.ts +13 -0
- package/dist/src/legal/receipt.js +137 -0
- package/dist/src/legal/release.d.ts +27 -0
- package/dist/src/legal/release.js +28 -0
- package/dist/src/managed-sign-in.d.ts +0 -1
- package/dist/src/managed-sign-in.js +0 -13
- package/dist/src/membership.d.ts +27 -1
- package/dist/src/membership.js +139 -7
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.js +3 -7
- package/dist/src/model-override.d.ts +2 -1
- package/dist/src/model-override.js +9 -0
- package/dist/src/model-pool.d.ts +99 -0
- package/dist/src/model-pool.js +136 -0
- package/dist/src/model-relay/local.js +5 -0
- package/dist/src/model-relay/remote.d.ts +2 -0
- package/dist/src/model-relay/remote.js +4 -0
- package/dist/src/model-tiers.d.ts +16 -1
- package/dist/src/model-tiers.js +31 -7
- package/dist/src/opencode-cli-provider.js +59 -56
- package/dist/src/opencode-provider.js +16 -13
- package/dist/src/permissions.d.ts +5 -0
- package/dist/src/permissions.js +7 -0
- package/dist/src/plan-pass.js +2 -1
- package/dist/src/pool-scores.d.ts +45 -0
- package/dist/src/pool-scores.js +40 -0
- package/dist/src/provider-connection.js +3 -17
- package/dist/src/provider-engine.d.ts +13 -1
- package/dist/src/provider-engine.js +116 -12
- package/dist/src/provider-request-error.d.ts +8 -0
- package/dist/src/provider-request-error.js +12 -0
- package/dist/src/provider-settings.d.ts +1 -1
- package/dist/src/provider-settings.js +36 -18
- package/dist/src/provider-turn-deadline.d.ts +39 -0
- package/dist/src/provider-turn-deadline.js +139 -0
- package/dist/src/providers.d.ts +8 -9
- package/dist/src/providers.js +211 -150
- package/dist/src/pull-request-merge.d.ts +1 -8
- package/dist/src/pull-request-merge.js +0 -4
- package/dist/src/pull-requests.d.ts +83 -57
- package/dist/src/pull-requests.js +266 -225
- package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
- package/dist/src/qa/runtime/ProcessManager.js +9 -3
- package/dist/src/react-runtime.js +245 -71
- package/dist/src/reasoning-probe-cloud.d.ts +10 -0
- package/dist/src/reasoning-probe-cloud.js +209 -0
- package/dist/src/remote/engine-pool.d.ts +3 -0
- package/dist/src/remote/engine-pool.js +88 -21
- package/dist/src/remote/recovery.d.ts +6 -0
- package/dist/src/remote/recovery.js +37 -0
- package/dist/src/run-records.d.ts +13 -3
- package/dist/src/run-records.js +59 -34
- package/dist/src/runtime.d.ts +47 -2
- package/dist/src/runtime.js +33 -7
- package/dist/src/session-summary.d.ts +8 -0
- package/dist/src/session-summary.js +34 -0
- package/dist/src/sessions.d.ts +32 -0
- package/dist/src/sessions.js +65 -3
- package/dist/src/shell.js +6 -0
- package/dist/src/side-panel.js +36 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +4 -10
- package/dist/src/sign-in-offer.js +1 -1
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
- package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
- package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
- package/dist/src/skills/bundled/provenance.json +3 -3
- package/dist/src/subagent-run.js +50 -50
- package/dist/src/subscription-usage.d.ts +50 -0
- package/dist/src/subscription-usage.js +92 -0
- package/dist/src/task-checkout.d.ts +157 -0
- package/dist/src/task-checkout.js +628 -0
- package/dist/src/telemetry/access.d.ts +18 -0
- package/dist/src/telemetry/access.js +43 -0
- package/dist/src/telemetry/aggregate.d.ts +18 -2
- package/dist/src/telemetry/aggregate.js +22 -9
- package/dist/src/telemetry/capture-core.d.ts +33 -14
- package/dist/src/telemetry/capture-core.js +124 -25
- package/dist/src/telemetry/capture.d.ts +3 -2
- package/dist/src/telemetry/capture.js +21 -1
- package/dist/src/telemetry/decision-capture.js +4 -0
- package/dist/src/telemetry/emitter.d.ts +6 -7
- package/dist/src/telemetry/emitter.js +124 -29
- package/dist/src/telemetry/gate.d.ts +41 -2
- package/dist/src/telemetry/gate.js +89 -4
- package/dist/src/telemetry/home.d.ts +1 -0
- package/dist/src/telemetry/home.js +20 -0
- package/dist/src/telemetry/identity.d.ts +6 -3
- package/dist/src/telemetry/identity.js +19 -6
- package/dist/src/telemetry/lifecycle.d.ts +8 -0
- package/dist/src/telemetry/lifecycle.js +76 -0
- package/dist/src/telemetry/outbox.d.ts +13 -8
- package/dist/src/telemetry/outbox.js +68 -12
- package/dist/src/telemetry/permission-command.d.ts +38 -0
- package/dist/src/telemetry/permission-command.js +208 -0
- package/dist/src/telemetry/permission.d.ts +168 -0
- package/dist/src/telemetry/permission.js +662 -0
- package/dist/src/telemetry/record-installation.d.ts +1 -0
- package/dist/src/telemetry/record-installation.js +9 -0
- package/dist/src/telemetry/region-data.d.ts +12 -0
- package/dist/src/telemetry/region-data.js +1314 -0
- package/dist/src/telemetry/region.d.ts +34 -0
- package/dist/src/telemetry/region.js +87 -0
- package/dist/src/telemetry/run-privacy.d.ts +11 -0
- package/dist/src/telemetry/run-privacy.js +165 -0
- package/dist/src/telemetry/schema.d.ts +27 -6
- package/dist/src/telemetry/schema.js +109 -14
- package/dist/src/telemetry/state.d.ts +11 -7
- package/dist/src/telemetry/state.js +39 -6
- package/dist/src/telemetry/surface.d.ts +20 -3
- package/dist/src/telemetry/surface.js +71 -15
- package/dist/src/telemetry/uploader.d.ts +6 -11
- package/dist/src/telemetry/uploader.js +72 -46
- package/dist/src/telemetry/uploads.d.ts +5 -1
- package/dist/src/telemetry/uploads.js +25 -6
- package/dist/src/telemetry/version.d.ts +5 -0
- package/dist/src/telemetry/version.js +34 -0
- package/dist/src/telemetry/workspace.d.ts +4 -1
- package/dist/src/telemetry/workspace.js +18 -3
- package/dist/src/terminal-ui.d.ts +3 -0
- package/dist/src/terminal-ui.js +48 -6
- package/dist/src/test-edit-guard.d.ts +30 -0
- package/dist/src/test-edit-guard.js +167 -2
- package/dist/src/thinking-level-detect.d.ts +13 -0
- package/dist/src/thinking-level-detect.js +52 -0
- package/dist/src/thinking-levels.d.ts +30 -0
- package/dist/src/thinking-levels.js +131 -0
- package/dist/src/timers.d.ts +3 -0
- package/dist/src/todos.d.ts +2 -1
- package/dist/src/todos.js +24 -4
- package/dist/src/tool-argument-coercion.d.ts +7 -0
- package/dist/src/tool-argument-coercion.js +49 -0
- package/dist/src/tool-catalog.d.ts +2 -2
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/tools.js +67 -22
- package/dist/src/transcript.js +3 -2
- package/dist/src/types.d.ts +48 -1
- package/dist/src/update.js +4 -0
- package/dist/src/usage-analytics.d.ts +7 -0
- package/dist/src/usage-analytics.js +85 -13
- package/dist/telemetry-consent-v1 +1 -0
- package/package.json +97 -96
|
@@ -7,6 +7,8 @@ import { isDeepStrictEqual, promisify } from 'node:util';
|
|
|
7
7
|
import { resolveClaudeExecutable } from './claude-executable.js';
|
|
8
8
|
import { resolveTrustedTaskkill } from './shell.js';
|
|
9
9
|
import { createDecodeWindow } from './providers.js';
|
|
10
|
+
import { reportedModel } from './telemetry/schema.js';
|
|
11
|
+
import { withProviderTurnDeadline } from './provider-turn-deadline.js';
|
|
10
12
|
const executeFile = promisify(execFile);
|
|
11
13
|
const OUTPUT_LIMIT = 8 * 1024 * 1024;
|
|
12
14
|
const AUXILIARY_BUDGET_USD = '0.000000001';
|
|
@@ -382,6 +384,29 @@ function structuredResponse(value, names) {
|
|
|
382
384
|
function sameCalls(first, second) {
|
|
383
385
|
return isDeepStrictEqual(first.map(call => ({ name: call.name, arguments: JSON.parse(call.arguments) })), second.map(call => ({ name: call.name, arguments: JSON.parse(call.arguments) })));
|
|
384
386
|
}
|
|
387
|
+
function servedClaudeModel(events, result) {
|
|
388
|
+
const models = events.flatMap(frame => {
|
|
389
|
+
if (frame?.parent_tool_use_id)
|
|
390
|
+
return [];
|
|
391
|
+
if (frame?.type === 'assistant')
|
|
392
|
+
return [frame.message?.model];
|
|
393
|
+
if (frame?.type === 'stream_event' && frame.event?.type === 'message_start')
|
|
394
|
+
return [frame.event.message?.model];
|
|
395
|
+
return [];
|
|
396
|
+
});
|
|
397
|
+
if (result.modelUsage !== undefined) {
|
|
398
|
+
const usage = result.modelUsage;
|
|
399
|
+
if (usage === null || typeof usage !== 'object' || Array.isArray(usage))
|
|
400
|
+
return undefined;
|
|
401
|
+
const keys = Object.keys(usage);
|
|
402
|
+
// A CLI result can contain more than one model. Its aggregate usage belongs to no single model.
|
|
403
|
+
if (keys.length > 1)
|
|
404
|
+
return undefined;
|
|
405
|
+
models.push(...keys);
|
|
406
|
+
}
|
|
407
|
+
const seen = new Set(models.filter(value => value !== undefined).map(reportedModel));
|
|
408
|
+
return seen.size === 1 ? [...seen][0] : undefined;
|
|
409
|
+
}
|
|
385
410
|
export function parseClaudeResponse(output, tools = []) {
|
|
386
411
|
const events = frames(output);
|
|
387
412
|
const results = events.filter(frame => frame?.type === 'result');
|
|
@@ -452,6 +477,11 @@ export function parseClaudeResponse(output, tools = []) {
|
|
|
452
477
|
`<tool_use_error>Error: No such tool available: ${block.name}.</tool_use_error>`,
|
|
453
478
|
`<tool_use_error>Error: No such tool available: ${block.name}. ${block.name} is disabled for this session, in subagents as well as here.</tool_use_error>`,
|
|
454
479
|
`<tool_use_error>Error: No such tool available: ${block.name}. ${block.name} exists but is not enabled in this context. Use one of the available tools instead.</tool_use_error>`,
|
|
480
|
+
// Claude Code 2.1.331 wordings: each still says the tool did not run.
|
|
481
|
+
`<tool_use_error>Error: No such tool available: ${block.name}. ${block.name} is not among the tools available here. Continue with the tools you have.</tool_use_error>`,
|
|
482
|
+
`<tool_use_error>Error: No such tool available: ${block.name}. ${block.name} is disabled for this session.</tool_use_error>`,
|
|
483
|
+
`<tool_use_error>Error: No such tool available: ${block.name}. ${block.name} is still listed for this conversation but is switched off in this session right now, so it cannot run. Continue without it.</tool_use_error>`,
|
|
484
|
+
`<tool_use_error>Error: No such tool available: ${block.name}. ${block.name} is still listed for this conversation, but nothing in this session provides it right now (its source was removed or disconnected, or this version no longer has it), so it cannot run. Continue without it.</tool_use_error>`,
|
|
455
485
|
];
|
|
456
486
|
if (observations.length !== 1 || observations[0].is_error !== true || typeof observations[0].content !== 'string'
|
|
457
487
|
|| !unavailable.includes(observations[0].content)) {
|
|
@@ -482,6 +512,9 @@ export function parseClaudeResponse(output, tools = []) {
|
|
|
482
512
|
throw new MalformedClaudeStep(`Claude did not return a complete Andorra model step (${incompleteStep(result, Boolean(structured), texts.length > 0, acknowledgements)})`);
|
|
483
513
|
if (result.usage)
|
|
484
514
|
response.usage = claudeUsage(result.usage);
|
|
515
|
+
const servedModel = servedClaudeModel(events, result);
|
|
516
|
+
if (servedModel)
|
|
517
|
+
response.servedModel = servedModel;
|
|
485
518
|
return response;
|
|
486
519
|
}
|
|
487
520
|
function incompleteStep(result, structured, answeredInText, acknowledgements) {
|
|
@@ -558,9 +591,10 @@ export function parseClaudeAuxiliaryResponse(output, maxTokens) {
|
|
|
558
591
|
}
|
|
559
592
|
if (texts.length > 1)
|
|
560
593
|
throw new Error('Claude returned conflicting auxiliary text blocks');
|
|
561
|
-
|
|
594
|
+
const servedModel = servedClaudeModel(events, result);
|
|
595
|
+
return { text: texts.join(''), toolCalls: [], usage: claudeUsage(usage), stopReason, ...(servedModel ? { servedModel } : {}) };
|
|
562
596
|
}
|
|
563
|
-
function stampClaudeDelta(decode, line) {
|
|
597
|
+
function stampClaudeDelta(decode, line, progress) {
|
|
564
598
|
if (!line.includes('content_block_delta'))
|
|
565
599
|
return;
|
|
566
600
|
let frame;
|
|
@@ -574,8 +608,10 @@ function stampClaudeDelta(decode, line) {
|
|
|
574
608
|
return;
|
|
575
609
|
const delta = frame.event.delta;
|
|
576
610
|
const text = delta?.text ?? delta?.partial_json ?? delta?.thinking;
|
|
577
|
-
if (typeof text === 'string' && text)
|
|
611
|
+
if (typeof text === 'string' && text) {
|
|
578
612
|
decode.stamp(text);
|
|
613
|
+
progress();
|
|
614
|
+
}
|
|
579
615
|
}
|
|
580
616
|
function withDecodeMs(response, decodeMs) {
|
|
581
617
|
if (decodeMs !== undefined && response.usage && response.usage.outputTokens !== undefined)
|
|
@@ -592,6 +628,8 @@ export function claudeRequestBlocks(messages, tools) {
|
|
|
592
628
|
}
|
|
593
629
|
export function createClaudeAdapter(_config, dependencies = {}) {
|
|
594
630
|
const run = dependencies.run ?? runClaudeProcess;
|
|
631
|
+
// The Claude CLI has no `none` or `minimal` level; its lowest is `low`.
|
|
632
|
+
const savedEffort = _config.reasoningEffort === 'none' || _config.reasoningEffort === 'minimal' ? 'low' : _config.reasoningEffort;
|
|
595
633
|
return {
|
|
596
634
|
async listModels(signal) { return (await readClaudeCatalog(signal, dependencies)).models; },
|
|
597
635
|
async generate(request) {
|
|
@@ -601,40 +639,43 @@ export function createClaudeAdapter(_config, dependencies = {}) {
|
|
|
601
639
|
throw new Error('Invalid auxiliary output allowance.');
|
|
602
640
|
if (auxiliary && request.tools.length)
|
|
603
641
|
throw new Error('Claude cannot apply an auxiliary output allowance to tool-bearing requests.');
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
'--
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
response
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
642
|
+
return withProviderTurnDeadline(request.signal, async (deadline) => {
|
|
643
|
+
const { signal } = deadline;
|
|
644
|
+
if (!await signedIn(run, signal))
|
|
645
|
+
throw new Error(signInMessage);
|
|
646
|
+
const content = claudeRequestBlocks(request.messages, request.tools);
|
|
647
|
+
const args = [...claudeIsolationArgs, '--print', '--input-format', 'stream-json', '--output-format', 'stream-json', '--verbose',
|
|
648
|
+
'--max-turns', '1',
|
|
649
|
+
'--model', request.model, ...(!auxiliary && savedEffort !== undefined && request.model === _config.model ? ['--effort', savedEffort] : []), ...(auxiliary
|
|
650
|
+
? ['--include-partial-messages', '--max-budget-usd', AUXILIARY_BUDGET_USD, '--system-prompt', auxiliarySystemPrompt]
|
|
651
|
+
: ['--include-partial-messages', '--json-schema', JSON.stringify(outputSchema), '--system-prompt', systemPrompt])];
|
|
652
|
+
const compose = (note) => `${JSON.stringify({ type: 'user', client_composed: true,
|
|
653
|
+
message: { role: 'user', content: note ? [...content, { type: 'text', text: note }] : content } })}\n`;
|
|
654
|
+
let input = compose();
|
|
655
|
+
for (let attempt = 1;; attempt++) {
|
|
656
|
+
deadline.waitForResponse();
|
|
657
|
+
request.onRequest?.();
|
|
658
|
+
const decode = createDecodeWindow(dependencies.now);
|
|
659
|
+
const output = await run(args, input, signal, { acceptedExitCodes: [0, 1], onLine: line => stampClaudeDelta(decode, line, deadline.progress),
|
|
660
|
+
...(auxiliary ? { maxTokens: request.maxTokens } : {}) });
|
|
661
|
+
signal.throwIfAborted();
|
|
662
|
+
if (auxiliary)
|
|
663
|
+
return { ...withDecodeMs(parseClaudeAuxiliaryResponse(output, request.maxTokens), decode.measure()), authMode: 'linked-account' };
|
|
664
|
+
try {
|
|
665
|
+
const response = withDecodeMs(parseClaudeResponse(output, request.tools), decode.measure());
|
|
666
|
+
if (response.usage)
|
|
667
|
+
response.usage.requests = attempt;
|
|
668
|
+
return { ...response, authMode: 'linked-account' };
|
|
669
|
+
}
|
|
670
|
+
catch (error) {
|
|
671
|
+
if (!(error instanceof MalformedClaudeStep) || attempt >= STEP_ATTEMPTS)
|
|
672
|
+
throw error;
|
|
673
|
+
await request.onRetry?.({ retry: attempt, maxRetries: STEP_ATTEMPTS - 1, delayMs: 0, reason: `${error.message}. Asking again.`, quiet: true, code: 'malformed_response',
|
|
674
|
+
...(error.unparsedReply === undefined ? {} : { unparsedReply: error.unparsedReply }) });
|
|
675
|
+
input = compose(retryNote(error.message));
|
|
676
|
+
}
|
|
636
677
|
}
|
|
637
|
-
}
|
|
678
|
+
});
|
|
638
679
|
},
|
|
639
680
|
};
|
|
640
681
|
}
|
package/dist/src/cli.d.ts
CHANGED
|
@@ -13,9 +13,7 @@ export declare function isContinuationPrompt(text: string): boolean;
|
|
|
13
13
|
export declare function continuedTodos(task: string, lastRun?: RunResult): import('./todos.js').TodoItem[];
|
|
14
14
|
export { providerSecrets };
|
|
15
15
|
export declare function appendRunEvent(directory: string, event: RuntimeEvent): Promise<void>;
|
|
16
|
-
export type ResolvedNodeModel = import('./runtime.js').ResolvedGraphModel
|
|
17
|
-
reasoningEffort?: string;
|
|
18
|
-
};
|
|
16
|
+
export type ResolvedNodeModel = import('./runtime.js').ResolvedGraphModel;
|
|
19
17
|
export declare function withNodeModelResolution(event: RuntimeEvent, lookup: (provider: string, model: string) => Promise<ResolvedNodeModel | undefined> | undefined): Promise<RuntimeEvent>;
|
|
20
18
|
export declare function main(argv?: string[], dependencies?: {
|
|
21
19
|
loadGraph?: typeof loadAccessibleGraph;
|