@andorra-labs/code 0.1.17 → 0.1.18
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/agent-execution.js +97 -11
- package/dist/src/andorra/errors.js +3 -0
- package/dist/src/app-server/protocol.d.ts +13 -2
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server/workspace.d.ts +19 -0
- package/dist/src/app-server/workspace.js +155 -4
- package/dist/src/app-server.d.ts +32 -1
- package/dist/src/app-server.js +622 -74
- package/dist/src/attachments.d.ts +10 -0
- package/dist/src/attachments.js +102 -7
- package/dist/src/automation-tool.js +2 -1
- package/dist/src/bridge/command.js +12 -0
- package/dist/src/bridge/control.d.ts +3 -1
- package/dist/src/bridge/control.js +7 -2
- 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 +1 -1
- package/dist/src/bridge/host-ops.js +11 -1
- package/dist/src/bridge/host.js +7 -4
- 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/cli.d.ts +1 -3
- package/dist/src/cli.js +10 -4
- package/dist/src/codex-provider.js +1 -1
- package/dist/src/coding-tools.js +9 -2
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +2 -1
- package/dist/src/completion.js +8 -4
- package/dist/src/config.js +3 -1
- package/dist/src/context-budget.js +15 -2
- package/dist/src/decision/DecisionEngine.d.ts +2 -0
- package/dist/src/decision/DecisionManager.d.ts +11 -0
- package/dist/src/decision/DecisionManager.js +36 -0
- package/dist/src/decision/applyTaskKind.d.ts +8 -0
- package/dist/src/decision/applyTaskKind.js +53 -0
- package/dist/src/decision/hostedPolicy.js +2 -1
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +2 -0
- package/dist/src/decision/providers/AndorraDecisionProvider.js +12 -0
- package/dist/src/decision/taskKind.d.ts +52 -0
- package/dist/src/decision/taskKind.js +76 -0
- package/dist/src/decision/types.d.ts +1 -1
- package/dist/src/default-graph.js +1 -1
- package/dist/src/efficiency.d.ts +5 -0
- package/dist/src/efficiency.js +5 -1
- 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/github-app/client.d.ts +19 -0
- package/dist/src/github-app/client.js +21 -1
- package/dist/src/github-names.d.ts +7 -0
- package/dist/src/github-names.js +7 -0
- package/dist/src/graph-preview.d.ts +2 -0
- package/dist/src/graph-preview.js +1 -0
- package/dist/src/graph-runner.js +1 -1
- package/dist/src/graph-server.js +4 -2
- package/dist/src/graph-ui/app.js +30 -0
- package/dist/src/graphs.d.ts +6 -0
- package/dist/src/graphs.js +7 -2
- package/dist/src/hardened-runtime.js +32 -21
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-override.d.ts +2 -1
- package/dist/src/model-override.js +9 -0
- package/dist/src/model-tiers.d.ts +3 -0
- package/dist/src/model-tiers.js +3 -3
- package/dist/src/provider-engine.d.ts +13 -1
- package/dist/src/provider-engine.js +74 -0
- package/dist/src/providers.d.ts +5 -0
- package/dist/src/providers.js +34 -8
- package/dist/src/pull-requests.d.ts +11 -1
- package/dist/src/pull-requests.js +53 -2
- package/dist/src/react-runtime.js +98 -15
- package/dist/src/remote/engine-pool.js +5 -5
- package/dist/src/runtime.d.ts +29 -1
- package/dist/src/runtime.js +8 -0
- package/dist/src/sessions.d.ts +24 -0
- package/dist/src/sessions.js +55 -2
- package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
- package/dist/src/skills/bundled/provenance.json +1 -1
- package/dist/src/task-checkout.d.ts +141 -0
- package/dist/src/task-checkout.js +558 -0
- 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 +11 -0
- package/dist/src/thinking-level-detect.js +47 -0
- package/dist/src/thinking-levels.d.ts +30 -0
- package/dist/src/thinking-levels.js +124 -0
- package/dist/src/timers.d.ts +1 -0
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/transcript.js +1 -1
- package/dist/src/types.d.ts +34 -0
- package/package.json +1 -1
package/dist/src/commands.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { currentGraphSubject } from './graph-selection.js';
|
|
|
4
4
|
import { loadAccessibleGraph, requireGraphMembership } from './membership.js';
|
|
5
5
|
import type { Config } from './config.js';
|
|
6
6
|
import { type SessionGoal } from './session-goal.js';
|
|
7
|
-
import type
|
|
7
|
+
import { type Completion, type RunResult } from './runtime.js';
|
|
8
8
|
import type { Usage } from './types.js';
|
|
9
9
|
import type { CodeIntelligenceManager } from './code-intelligence/CodeIntelligenceManager.js';
|
|
10
10
|
import { logoutCodex } from './codex-auth.js';
|
package/dist/src/commands.js
CHANGED
|
@@ -11,6 +11,7 @@ import { GraphProviderUnavailableError } from './graph-provider-portability.js';
|
|
|
11
11
|
import { confirmAndApplyModelOverride } from './model-override.js';
|
|
12
12
|
import { applyGoalCommand } from './session-goal.js';
|
|
13
13
|
import { changeConfigFile, configDirectory, loadConfig, loadSavedAnalytics } from './config.js';
|
|
14
|
+
import { turnModelCompletion } from './runtime.js';
|
|
14
15
|
import { applyModelContextWindow, modelDisplayName, modelIdForDisplayName, providerLabel, recordProviderModel, REASONING_EFFORTS } from './providers.js';
|
|
15
16
|
import { resolveRepositoryId } from './code-intelligence/repository.js';
|
|
16
17
|
import { logoutCodex } from './codex-auth.js';
|
|
@@ -97,7 +98,7 @@ export function compactHistory(turns) {
|
|
|
97
98
|
}];
|
|
98
99
|
}
|
|
99
100
|
export function compactedContextEstimate(turns) {
|
|
100
|
-
return Math.ceil(JSON.stringify(turns).length / 4);
|
|
101
|
+
return Math.ceil(JSON.stringify(turns.map(turn => ({ ...turn, completion: turnModelCompletion(turn.completion) }))).length / 4);
|
|
101
102
|
}
|
|
102
103
|
const CODEGRAPH_USAGE = 'Usage: /codegraph status|enable|disable|rebuild. Add --global to enable|disable to set the saved default for every project (this clears per-repository overrides).';
|
|
103
104
|
async function codegraphCommand(action, scope, state, signal) {
|
package/dist/src/completion.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateJsonSchemaValue } from '../vendor/zcode/source/tool/json-schema.js';
|
|
2
2
|
import { interruptsParagraph } from './markdown.js';
|
|
3
|
+
import { OUTCOMES_SCHEMA, parseOutcomes } from './evidence.js';
|
|
3
4
|
export const COMPLETION_TOOL = 'complete_agent';
|
|
4
5
|
export const FINAL_RESPONSE_GUIDANCE = "Only when this node is responsible for producing the final user answer, its summary must satisfy the user's response requirements: include complete requested files and exact formatting, including requested code fences, without abbreviation, path substitution, or offers to provide content later. Each fence opens and closes on its own line; a file written to the workspace that the user did not ask to see in the answer is named by path, not reproduced. Intermediate intake, research, and delegation nodes must instead keep a concise handoff and preserve these final-answer acceptance requirements in the downstream task instruction or output; do not implement or reproduce the final deliverable before handing off.";
|
|
5
6
|
export const RESPONSE_STRUCTURE_GUIDANCE = `Write user-facing text, including the final summary, as structured markdown rather than one unbroken paragraph. Lead with the outcome in one or two sentences. Match the length to the work: a small change or a short answer is a few sentences or bullets with no headings; larger work uses short headings (## What changed, ## Not done) and bullet lists for parallel items. Do not list the checks again in the summary, because the tests array is shown beside it. Throughout, put every command, file content, and code sample in a fenced code block whose fences sit on their own lines; keep sentences short and omit filler. Inside a JSON string the line breaks are written as \\n escapes, and they are expected: never flatten the summary into one line to keep the JSON valid. In the tests array, write one short line per check: the check that ran, then its outcome.`;
|
|
@@ -66,6 +67,7 @@ export function completionTool(options) {
|
|
|
66
67
|
type: 'object',
|
|
67
68
|
properties: {
|
|
68
69
|
summary: { type: 'string', description: SUMMARY_DESCRIPTION }, tests: { type: 'array', items: { type: 'string', description: 'One short line: the check that ran, then its outcome.' } },
|
|
70
|
+
outcomes: OUTCOMES_SCHEMA,
|
|
69
71
|
...(options.finalAnswerOutcomes?.length ? { remaining: { type: 'array', maxItems: REMAINING_LIMIT, items: { type: 'string' }, description: REMAINING_DESCRIPTION } } : {}),
|
|
70
72
|
...(outcomes ? { artifacts: { type: 'array', maxItems: 50, items: { type: 'object', properties: { type: { type: 'string' }, ref: { type: 'string' } }, required: ['type', 'ref'], additionalProperties: false } } } : {}),
|
|
71
73
|
...(outcomes ? { outcome: { type: 'string', enum: outcomes }, output: providerOutputSchema(options.outputSchema ?? { type: 'object' }) } : {}),
|
|
@@ -394,8 +396,8 @@ function splitFusedArguments(envelope, notes) {
|
|
|
394
396
|
notes?.push(`completion fields ${fields.map(([name]) => name).join(', ')} arrived fused into one key by leaked argument markup and were split apart`);
|
|
395
397
|
}
|
|
396
398
|
}
|
|
397
|
-
const EMBEDDED_ENVELOPE_FIELD = /"\s*,\s*"(tests|outcome|output|artifacts)"\s*:/;
|
|
398
|
-
const EMBEDDED_FIELDS = ['tests', 'outcome', 'output', 'artifacts', 'remaining'];
|
|
399
|
+
const EMBEDDED_ENVELOPE_FIELD = /"\s*,\s*"(tests|outcome|output|artifacts|outcomes)"\s*:/;
|
|
400
|
+
const EMBEDDED_FIELDS = ['tests', 'outcome', 'output', 'artifacts', 'remaining', 'outcomes'];
|
|
399
401
|
const RAW_CONTROL = { '\n': '\\n', '\r': '\\r', '\t': '\\t' };
|
|
400
402
|
function emptyField(value) {
|
|
401
403
|
if (value === undefined || value === null)
|
|
@@ -623,13 +625,15 @@ export function parseCompletion(text, options, reject, notes, stopReason) {
|
|
|
623
625
|
if (written === undefined)
|
|
624
626
|
notes?.push(OUTPUT_STOOD_IN_NOTE);
|
|
625
627
|
const summary = written === undefined ? decodeDoubleEscapedSummary(JSON.stringify(output).slice(0, 2000), notes) : stripEchoedEnvelope(rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(written, notes)), outcome, notes);
|
|
626
|
-
|
|
628
|
+
const outcomes = parseOutcomes(value.outcomes, notes);
|
|
629
|
+
return { summary, ...(outcomes ? { outcomes } : {}),
|
|
627
630
|
tests: Array.isArray(value.tests) && value.tests.every((item) => typeof item === 'string') ? value.tests : [], outcome, output,
|
|
628
631
|
artifacts: value.artifacts ?? [], ...(remainingItems(value.remaining) ? { remaining: remainingItems(value.remaining) } : {}) };
|
|
629
632
|
}
|
|
630
633
|
if (value && typeof value.summary === 'string' && value.summary.trim()
|
|
631
634
|
&& Array.isArray(value.tests) && value.tests.every((x) => typeof x === 'string')) {
|
|
632
|
-
|
|
635
|
+
const outcomes = parseOutcomes(value.outcomes, notes);
|
|
636
|
+
return { summary: stripEchoedEnvelope(rejectEmbeddedEnvelope(decodeDoubleEscapedSummary(value.summary, notes)), typeof value.outcome === "string" ? value.outcome : undefined, notes), tests: value.tests, ...(outcomes ? { outcomes } : {}) };
|
|
633
637
|
}
|
|
634
638
|
throw new Error("Completion needs a nonempty summary and a tests array of strings");
|
|
635
639
|
}
|
package/dist/src/config.js
CHANGED
|
@@ -7,6 +7,7 @@ import { isIP } from 'node:net';
|
|
|
7
7
|
import { cleanModelName, fallbackProviderId } from './andorra/entry.js';
|
|
8
8
|
import { readHostedState } from './andorra/state.js';
|
|
9
9
|
import { isModelParameters } from './providers.js';
|
|
10
|
+
import { validateThinkingLevels } from './thinking-levels.js';
|
|
10
11
|
import { assertProviderCredentials, assertRequestTimeout, assertStreamIdleTimeout, MAX_CODEX_ACCOUNT_KEY_LENGTH, MAX_PROVIDER_NAME_LENGTH, PROVIDER_TYPES, REASONING_EFFORTS } from './providers.js';
|
|
11
12
|
import { GOOGLE_BASE_URL } from './google-provider.js';
|
|
12
13
|
import { GROK_BASE_URL } from './grok-provider.js';
|
|
@@ -487,6 +488,7 @@ export function validateConfig(value) {
|
|
|
487
488
|
if (p.reasoningEffort !== undefined && (!['openai-compatible', 'opencode-go', 'anthropic'].includes(p.type) || !REASONING_EFFORTS.includes(p.reasoningEffort))) {
|
|
488
489
|
throw new Error('Invalid reasoningEffort: use an OpenAI-compatible, OpenCode Go or Anthropic provider and none, minimal, low, medium, high, xhigh, or max');
|
|
489
490
|
}
|
|
491
|
+
validateThinkingLevels(p.thinkingLevels, p.type);
|
|
490
492
|
assertRequestTimeout(p);
|
|
491
493
|
assertStreamIdleTimeout(p);
|
|
492
494
|
assertProviderCredentials(p);
|
|
@@ -1043,6 +1045,6 @@ export function validateDecisionConfig(value) {
|
|
|
1043
1045
|
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash || (url.protocol === 'http:' && !privateHttpHost(url.hostname)))
|
|
1044
1046
|
throw new Error('decisions.endpoint requires HTTPS or private HTTP without credentials, query or fragment');
|
|
1045
1047
|
}
|
|
1046
|
-
if (c.features !== undefined && (!c.features || typeof c.features !== 'object' || Array.isArray(c.features) || Object.entries(c.features).some(([key, v]) => !['toolRouting', 'codeGraphRouting', 'memoryRouting', 'webRouting', 'delegationRouting', 'verificationRouting', 'riskClassification', 'resultRouting'].includes(key) || typeof v !== 'boolean')))
|
|
1048
|
+
if (c.features !== undefined && (!c.features || typeof c.features !== 'object' || Array.isArray(c.features) || Object.entries(c.features).some(([key, v]) => !['toolRouting', 'taskRouting', 'codeGraphRouting', 'memoryRouting', 'webRouting', 'delegationRouting', 'verificationRouting', 'riskClassification', 'resultRouting'].includes(key) || typeof v !== 'boolean')))
|
|
1047
1049
|
throw new Error('Invalid decisions.features');
|
|
1048
1050
|
}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { getAutoCompactThreshold } from '../vendor/zcode/source/compact/policy.js';
|
|
2
2
|
import { estimateMessageTokens } from '../vendor/zcode/source/compact/manual.js';
|
|
3
3
|
import { MICROCOMPACT_CLEARED_TOOL_RESULT_MESSAGE, maybeLocalMicrocompactMessages } from '../vendor/zcode/source/compact/microcompact.js';
|
|
4
|
+
/**
|
|
5
|
+
* A turn holding Andorra's router's `reasoning_details` goes back with its thinking inside them and its readable
|
|
6
|
+
* reasoning as a blank, so the readable copy is not counted a second time.
|
|
7
|
+
*/
|
|
8
|
+
function countedReasoning(message) {
|
|
9
|
+
return message.providerContinuation?.reasoningDetails?.length ? undefined : message.reasoningContent;
|
|
10
|
+
}
|
|
4
11
|
export function serializeContext(messages) {
|
|
5
|
-
return JSON.stringify(messages, (key, value)
|
|
12
|
+
return JSON.stringify(messages, function (key, value) {
|
|
13
|
+
if (key === 'images' && Array.isArray(value))
|
|
14
|
+
return value.map(image => ({ mimeType: image.mimeType, nativeImage: true }));
|
|
15
|
+
if (key === 'reasoningContent' && this !== null && typeof this === 'object' && countedReasoning(this) === undefined)
|
|
16
|
+
return undefined;
|
|
17
|
+
return value;
|
|
18
|
+
});
|
|
6
19
|
}
|
|
7
20
|
export function pruneHistoricalImages(messages, keepToolTurns = 5) {
|
|
8
21
|
const turns = messages.filter(message => message.role === 'assistant' && message.toolCalls?.length);
|
|
@@ -45,7 +58,7 @@ export function dropRejectedImages(messages) {
|
|
|
45
58
|
return images;
|
|
46
59
|
}
|
|
47
60
|
export function estimateContextTokens(messages, toolChars) {
|
|
48
|
-
const contentTokens = estimateMessageTokens(messages.map(message => ({ role: message.role, content: message.content + (message
|
|
61
|
+
const contentTokens = estimateMessageTokens(messages.map(message => ({ role: message.role, content: message.content + (countedReasoning(message) ?? '') + (message.providerContinuation ? JSON.stringify(message.providerContinuation) : ''), toolCalls: message.toolCalls?.map(call => { let input; try {
|
|
49
62
|
input = JSON.parse(call.arguments);
|
|
50
63
|
}
|
|
51
64
|
catch {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DecisionBatch, DecisionQuestion, DecisionState } from './types.js';
|
|
2
2
|
import type { FactRequest } from './facts.js';
|
|
3
3
|
import type { ToolRouteEvidence, ToolRouteRequest } from './routeTools.js';
|
|
4
|
+
import type { TaskKindEvidence, TaskKindRequest } from './taskKind.js';
|
|
4
5
|
export type DecisionObservation = {
|
|
5
6
|
kind: 'dispatch';
|
|
6
7
|
} | {
|
|
@@ -19,5 +20,6 @@ export type DecisionRequestOptions = {
|
|
|
19
20
|
export interface DecisionProvider {
|
|
20
21
|
evaluate(state: DecisionState, questions: DecisionQuestion[], signal?: AbortSignal, observe?: DecisionObserver, options?: DecisionRequestOptions): Promise<DecisionBatch>;
|
|
21
22
|
evaluateToolMenu?(request: ToolRouteRequest, signal?: AbortSignal, observe?: DecisionObserver): Promise<ToolRouteEvidence>;
|
|
23
|
+
evaluateTaskKind?(request: TaskKindRequest, signal?: AbortSignal, observe?: DecisionObserver): Promise<TaskKindEvidence>;
|
|
22
24
|
evaluateFact?(fact: FactRequest, signal?: AbortSignal, observe?: DecisionObserver): Promise<number>;
|
|
23
25
|
}
|
|
@@ -4,6 +4,7 @@ import type { DecisionProvider } from './DecisionEngine.js';
|
|
|
4
4
|
import { type AgentDecisionState, type DecisionBatch, type DecisionConfig, type DecisionIdentity, type DecisionQuestion, type DecisionRouting } from './types.js';
|
|
5
5
|
import { type FactRequest } from './facts.js';
|
|
6
6
|
import { type ToolRouteEvidence, type ToolRouteRequest } from './routeTools.js';
|
|
7
|
+
import { type TaskKindEvidence, type TaskKindRequest } from './taskKind.js';
|
|
7
8
|
export declare const toolFamilyQuestion: (family: string) => string;
|
|
8
9
|
export declare function decisionRoleChoices(roles: string[], provider: DecisionConfig['provider']): string[];
|
|
9
10
|
export declare function preflightQuestions(config: DecisionConfig, roles: string[], capabilities?: AgentDecisionState['capabilities']): DecisionQuestion[];
|
|
@@ -14,10 +15,17 @@ export declare class DecisionManager {
|
|
|
14
15
|
private readonly onEvent?;
|
|
15
16
|
private readonly factGates;
|
|
16
17
|
private warnedSkillLimit;
|
|
18
|
+
/** Whether task-type routing runs when the configuration does not set a mode: the account's plan decides. */
|
|
19
|
+
readonly taskKindOnByDefault: boolean;
|
|
20
|
+
/** Set once the hosted service has answered that it does not know the task-type call, so a process asks an old service only once. */
|
|
21
|
+
private static taskKindUnsupported;
|
|
22
|
+
/** For tests: forget that a service refused the task-type call. */
|
|
23
|
+
static resetTaskKindSupport(): void;
|
|
17
24
|
constructor(options?: {
|
|
18
25
|
config?: DecisionConfig;
|
|
19
26
|
provider?: DecisionProvider;
|
|
20
27
|
onEvent?: EventSink;
|
|
28
|
+
taskKindOnByDefault?: boolean;
|
|
21
29
|
});
|
|
22
30
|
get enabled(): boolean;
|
|
23
31
|
get active(): boolean;
|
|
@@ -27,6 +35,7 @@ export declare class DecisionManager {
|
|
|
27
35
|
get factsEnabled(): boolean;
|
|
28
36
|
get toolTrimmingEnabled(): boolean;
|
|
29
37
|
get toolMenuEnabled(): boolean;
|
|
38
|
+
get taskKindEnabled(): boolean;
|
|
30
39
|
get skillRoutingEnabled(): boolean;
|
|
31
40
|
private events;
|
|
32
41
|
observe(state: AgentDecisionState, identity: DecisionIdentity, baseline: {
|
|
@@ -41,6 +50,8 @@ export declare class DecisionManager {
|
|
|
41
50
|
fact(request: FactRequest, identity: DecisionIdentity, signal: AbortSignal, sink?: EventSink | undefined): Promise<number | undefined>;
|
|
42
51
|
private observer;
|
|
43
52
|
toolMenu(request: ToolRouteRequest, identity: DecisionIdentity, signal: AbortSignal, sink?: EventSink | undefined): Promise<ToolRouteEvidence | undefined>;
|
|
53
|
+
/** What the run's first message asks for; undefined when the service is off, unreachable, slow or answers out of contract. */
|
|
54
|
+
taskKind(request: TaskKindRequest, identity: DecisionIdentity, signal: AbortSignal, sink?: EventSink | undefined): Promise<TaskKindEvidence | undefined>;
|
|
44
55
|
private request;
|
|
45
56
|
private settle;
|
|
46
57
|
}
|
|
@@ -10,6 +10,7 @@ import { HOSTED_SKILL_LIMIT, hostedSkillLimitNotice, rankHostedSkills } from './
|
|
|
10
10
|
import { markFactGuidance } from './guidancePolicy.js';
|
|
11
11
|
import { actionablePreflightQuestion, answerOnlyTask } from './optimizationPolicy.js';
|
|
12
12
|
import { parseToolRouteEvidence } from './routeTools.js';
|
|
13
|
+
import { parseTaskKindEvidence } from './taskKind.js';
|
|
13
14
|
import { pickJevRequestPhrase } from './requestPhrases.js';
|
|
14
15
|
const FACT_TIMEOUT_MS = 2000;
|
|
15
16
|
const families = new Set(['filesystem-read', 'filesystem-write', 'code-search', 'codegraph', 'git', 'shell', 'memory', 'web', 'browser', 'subagents', 'artifact']);
|
|
@@ -63,7 +64,14 @@ export class DecisionManager {
|
|
|
63
64
|
onEvent;
|
|
64
65
|
factGates = new Map();
|
|
65
66
|
warnedSkillLimit = false;
|
|
67
|
+
/** Whether task-type routing runs when the configuration does not set a mode: the account's plan decides. */
|
|
68
|
+
taskKindOnByDefault;
|
|
69
|
+
/** Set once the hosted service has answered that it does not know the task-type call, so a process asks an old service only once. */
|
|
70
|
+
static taskKindUnsupported = false;
|
|
71
|
+
/** For tests: forget that a service refused the task-type call. */
|
|
72
|
+
static resetTaskKindSupport() { DecisionManager.taskKindUnsupported = false; }
|
|
66
73
|
constructor(options = {}) {
|
|
74
|
+
this.taskKindOnByDefault = options.taskKindOnByDefault === true;
|
|
67
75
|
validateDecisionConfig(options.config ?? {});
|
|
68
76
|
this.config = structuredClone({ ...options.config, mode: options.config?.mode ?? DECISION_DEFAULTS.mode, provider: options.config?.provider ?? DECISION_DEFAULTS.provider, requestTimeoutMs: options.config?.requestTimeoutMs ?? DECISION_DEFAULTS.requestTimeoutMs });
|
|
69
77
|
this.provider = this.config.mode === 'off' || this.config.provider === 'none' ? new NoOpDecisionProvider() : options.provider ?? createDecisionProvider(this.config);
|
|
@@ -77,6 +85,7 @@ export class DecisionManager {
|
|
|
77
85
|
get factsEnabled() { return this.resultRouting && this.style === 'facts'; }
|
|
78
86
|
get toolTrimmingEnabled() { return this.style === 'questions'; }
|
|
79
87
|
get toolMenuEnabled() { return this.active && this.config.provider === 'andorra' && this.config.features?.toolRouting !== false; }
|
|
88
|
+
get taskKindEnabled() { return this.active && this.config.provider === 'andorra' && this.config.features?.taskRouting !== false; }
|
|
80
89
|
get skillRoutingEnabled() { return this.active && this.config.provider === 'andorra' && this.config.features?.toolRouting !== false; }
|
|
81
90
|
events(identity, stage, sink = this.onEvent, applicationSink) {
|
|
82
91
|
const identitySnapshot = { ...identity, requestId: randomUUID() };
|
|
@@ -222,6 +231,33 @@ export class DecisionManager {
|
|
|
222
231
|
return evidence;
|
|
223
232
|
}, evidence => ({ tool_menu: { confidence: evidence.confidence, selected: evidence.probabilities[evidence.choice], version: evidence.version } }), signal, emit, Math.min(this.config.requestTimeoutMs ?? FACT_TIMEOUT_MS, FACT_TIMEOUT_MS));
|
|
224
233
|
}
|
|
234
|
+
/** What the run's first message asks for; undefined when the service is off, unreachable, slow or answers out of contract. */
|
|
235
|
+
async taskKind(request, identity, signal, sink = this.onEvent) {
|
|
236
|
+
if (!this.taskKindEnabled || signal.aborted)
|
|
237
|
+
return undefined;
|
|
238
|
+
const publish = this.events(identity, 'task_kind', sink);
|
|
239
|
+
if (DecisionManager.taskKindUnsupported) {
|
|
240
|
+
publish('decision.skipped', { reason: 'routing_protocol_unavailable' });
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
const emit = (type, data) => {
|
|
244
|
+
if (type === 'decision.fallback' && data.reason === 'decision_protocol_unsupported')
|
|
245
|
+
DecisionManager.taskKindUnsupported = true;
|
|
246
|
+
publish(type, data);
|
|
247
|
+
};
|
|
248
|
+
const evaluate = this.provider.evaluateTaskKind?.bind(this.provider);
|
|
249
|
+
if (!evaluate) {
|
|
250
|
+
emit('decision.skipped', { reason: 'routing_protocol_unavailable' });
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
const snapshot = structuredClone(request);
|
|
254
|
+
return this.settle(['task_kind'], aborted => evaluate(snapshot, aborted, this.observer(emit)), value => {
|
|
255
|
+
const evidence = parseTaskKindEvidence(value);
|
|
256
|
+
if (!evidence)
|
|
257
|
+
throw new Error('invalid_response');
|
|
258
|
+
return evidence;
|
|
259
|
+
}, evidence => ({ task_kind: { choice: evidence.choice, confidence: evidence.confidence, selected: evidence.probabilities[evidence.choice], version: evidence.version } }), signal, emit, Math.min(this.config.requestTimeoutMs ?? FACT_TIMEOUT_MS, FACT_TIMEOUT_MS));
|
|
260
|
+
}
|
|
225
261
|
async request(snapshot, questions, signal, emit) {
|
|
226
262
|
if (!questions.length)
|
|
227
263
|
return undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HardenedRunOptions } from '../react-runtime.js';
|
|
2
|
+
/**
|
|
3
|
+
* Asks the hosted classifier what the run's first message calls for and records the verdict on the
|
|
4
|
+
* run. Only the agent whose answer ends a run is asked, and only for a first message: a follow-up
|
|
5
|
+
* is read against the conversation, which the classifier does not see. In `shadow` mode the answer
|
|
6
|
+
* is recorded and nothing changes; any failure leaves the run exactly as it was.
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyTaskKind(options: HardenedRunOptions): Promise<HardenedRunOptions>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { clipFactText } from './facts.js';
|
|
3
|
+
import { TASK_KIND_TASK_CHARS, decideTaskKind, makeTaskKindRequest, taskKindNote } from './taskKind.js';
|
|
4
|
+
/**
|
|
5
|
+
* Asks the hosted classifier what the run's first message calls for and records the verdict on the
|
|
6
|
+
* run. Only the agent whose answer ends a run is asked, and only for a first message: a follow-up
|
|
7
|
+
* is read against the conversation, which the classifier does not see. In `shadow` mode the answer
|
|
8
|
+
* is recorded and nothing changes; any failure leaves the run exactly as it was.
|
|
9
|
+
*/
|
|
10
|
+
export async function applyTaskKind(options) {
|
|
11
|
+
const manager = options.decisionManager;
|
|
12
|
+
// An explicit mode wins. Without one, a Paid account classifies and every other plan does not.
|
|
13
|
+
const mode = options.efficiency?.taskKindRouting?.mode ?? (manager?.taskKindOnByDefault ? 'on' : 'off');
|
|
14
|
+
if (mode === 'off' || !manager?.taskKindEnabled)
|
|
15
|
+
return options;
|
|
16
|
+
if (options.subagentId || !options.finalAnswerOutcomes?.length || options.canonicalTask !== undefined)
|
|
17
|
+
return options;
|
|
18
|
+
if (options.history?.length || options.resumeMessages?.length || options.previousConversation?.messages?.length
|
|
19
|
+
|| Object.keys(options.predecessorOutputs ?? {}).length)
|
|
20
|
+
return options;
|
|
21
|
+
const task = clipFactText(options.decisionTask ?? options.task, TASK_KIND_TASK_CHARS);
|
|
22
|
+
if (!task.trim())
|
|
23
|
+
return options;
|
|
24
|
+
const pause = options.context.runControl?.signal;
|
|
25
|
+
const signal = pause ? AbortSignal.any([options.context.signal, pause]) : options.context.signal;
|
|
26
|
+
const identity = { runId: options.runId ?? randomUUID(), nodeId: options.nodeId ?? 'engineer', invocationId: randomUUID() };
|
|
27
|
+
const emit = async (data) => {
|
|
28
|
+
try {
|
|
29
|
+
await options.onEvent?.({ type: 'efficiency.task_kind', time: new Date().toISOString(), data: { ...identity, mode, ...data } });
|
|
30
|
+
}
|
|
31
|
+
catch { }
|
|
32
|
+
};
|
|
33
|
+
try {
|
|
34
|
+
const request = makeTaskKindRequest(task);
|
|
35
|
+
const decided = decideTaskKind(await manager.taskKind(request, identity, signal, options.onEvent));
|
|
36
|
+
options.context.signal.throwIfAborted();
|
|
37
|
+
if (pause?.aborted)
|
|
38
|
+
return options;
|
|
39
|
+
const verdict = decided.verdict;
|
|
40
|
+
const note = verdict ? taskKindNote(verdict.kind) : undefined;
|
|
41
|
+
void emit({ reason: mode === 'shadow' && verdict ? 'shadow' : decided.reason, kind: decided.evidence?.choice, confidence: decided.evidence?.confidence,
|
|
42
|
+
noted: mode === 'on' && !!note, expectsChange: verdict?.expectsChange ?? false,
|
|
43
|
+
requestHash: createHash('sha256').update(JSON.stringify({ taskKind: request })).digest('hex'), requestChars: JSON.stringify({ taskKind: request }).length });
|
|
44
|
+
if (mode !== 'on' || !verdict)
|
|
45
|
+
return options;
|
|
46
|
+
return { ...options, taskKind: { ...verdict, ...(note ? { note } : {}) } };
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
options.context.signal.throwIfAborted();
|
|
50
|
+
await emit({ reason: pause?.aborted ? 'paused' : 'routing_unavailable' });
|
|
51
|
+
return options;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -8,7 +8,8 @@ export function resolveDecisionConfig(membership, enabled = true, decisions) {
|
|
|
8
8
|
}
|
|
9
9
|
export function hostedDecisionPolicy(membership, enabled = true, decisions) {
|
|
10
10
|
return {
|
|
11
|
-
|
|
11
|
+
// Task-type routing costs one hosted decision per run: on by default where decisions are not capped.
|
|
12
|
+
decisionManager: new DecisionManager({ config: resolveDecisionConfig(membership, enabled, decisions), taskKindOnByDefault: membership.tier === 'paid' }),
|
|
12
13
|
decisionNodeOptIn: true,
|
|
13
14
|
};
|
|
14
15
|
}
|
|
@@ -2,6 +2,7 @@ import type { DecisionProvider, DecisionObserver, DecisionRequestOptions } from
|
|
|
2
2
|
import type { DecisionBatch, DecisionQuestion, DecisionState } from '../types.js';
|
|
3
3
|
import { type FactRequest } from '../facts.js';
|
|
4
4
|
import { type ToolRouteRequest, type ToolRouteEvidence } from '../routeTools.js';
|
|
5
|
+
import { type TaskKindEvidence, type TaskKindRequest } from '../taskKind.js';
|
|
5
6
|
export declare class AndorraDecisionProvider implements DecisionProvider {
|
|
6
7
|
private readonly dependencies?;
|
|
7
8
|
constructor(dependencies?: {
|
|
@@ -14,5 +15,6 @@ export declare class AndorraDecisionProvider implements DecisionProvider {
|
|
|
14
15
|
private evaluateOnce;
|
|
15
16
|
evaluateFact(fact: FactRequest, signal?: AbortSignal, observe?: DecisionObserver): Promise<number>;
|
|
16
17
|
evaluateToolMenu(request: ToolRouteRequest, signal?: AbortSignal, observe?: DecisionObserver): Promise<ToolRouteEvidence>;
|
|
18
|
+
evaluateTaskKind(request: TaskKindRequest, signal?: AbortSignal, observe?: DecisionObserver): Promise<TaskKindEvidence>;
|
|
17
19
|
private post;
|
|
18
20
|
}
|
|
@@ -2,6 +2,7 @@ import { normalizeAnswers } from './HttpDecisionProvider.js';
|
|
|
2
2
|
import { validateBatch } from '../DecisionPolicy.js';
|
|
3
3
|
import { clipFactText, factProbability, FACT_LIMITS } from '../facts.js';
|
|
4
4
|
import { parseToolRouteEvidence } from '../routeTools.js';
|
|
5
|
+
import { parseTaskKindEvidence } from '../taskKind.js';
|
|
5
6
|
import { abstainSkill, chunkSkills, expandSkillAnswer, HOSTED_SKILLS_PER_REQUEST, LEGACY_HOSTED_SKILLS_PER_REQUEST, mergeNoSkill } from '../hostedSkills.js';
|
|
6
7
|
const HOSTED_REQUEST_BYTES = 32_768;
|
|
7
8
|
const CLIP_MARKER = '\n…[Jev routing context clipped]…\n';
|
|
@@ -254,6 +255,17 @@ export class AndorraDecisionProvider {
|
|
|
254
255
|
throw new Error('invalid_response');
|
|
255
256
|
return evidence;
|
|
256
257
|
}
|
|
258
|
+
async evaluateTaskKind(request, signal, observe) {
|
|
259
|
+
signal?.throwIfAborted();
|
|
260
|
+
const body = JSON.stringify({ taskKind: request });
|
|
261
|
+
if (Buffer.byteLength(body, 'utf8') > HOSTED_REQUEST_BYTES)
|
|
262
|
+
throw new Error('decision_input_too_large');
|
|
263
|
+
const response = await this.post(body, signal, observe);
|
|
264
|
+
const evidence = parseTaskKindEvidence(response.taskKind);
|
|
265
|
+
if (!evidence)
|
|
266
|
+
throw new Error('invalid_response');
|
|
267
|
+
return evidence;
|
|
268
|
+
}
|
|
257
269
|
async post(body, signal, observe) {
|
|
258
270
|
const auth = this.dependencies ?? await (async () => {
|
|
259
271
|
const { getAccessToken, getAuthConfiguration } = await import('../../auth/index.js');
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the first message of a run asks the agent to deliver, as judged by the hosted classifier.
|
|
3
|
+
* The classifier's wording lives on the server; the client sends only the task text and receives
|
|
4
|
+
* a probability for each kind. The verdict is advice to the model and a fact for the finish check.
|
|
5
|
+
* It grants no permission and changes no tool.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TASK_KIND_VERSION: 1;
|
|
8
|
+
export declare const TASK_KIND_MODEL = "jev-1.13.0";
|
|
9
|
+
export declare const TASK_KIND_UNCLEAR = "needs_clarification";
|
|
10
|
+
export declare const TASK_KINDS: readonly ["fix_defect", "make_change", "answer_question", "investigate", "run_or_verify", "general"];
|
|
11
|
+
export type TaskKind = typeof TASK_KINDS[number];
|
|
12
|
+
export declare const TASK_KIND_CHOICES: readonly string[];
|
|
13
|
+
/** Below this a verdict is not used, and the finish check never relies on a weaker one. */
|
|
14
|
+
export declare const TASK_KIND_CONFIDENCE_FLOOR = 0.9;
|
|
15
|
+
/**
|
|
16
|
+
* A one-line bug report ("why is the button doing nothing?") is read as a defect with less
|
|
17
|
+
* confidence than a full issue, and the note for it only restates what the default instruction
|
|
18
|
+
* already asks. So the note is added from this lower floor, while the notes that tell the model
|
|
19
|
+
* not to edit, and the finish check, keep the stricter one.
|
|
20
|
+
*/
|
|
21
|
+
export declare const TASK_KIND_DEFECT_NOTE_FLOOR = 0.7;
|
|
22
|
+
export declare const TASK_KIND_TASK_CHARS = 3000;
|
|
23
|
+
export interface TaskKindRequest {
|
|
24
|
+
version: typeof TASK_KIND_VERSION;
|
|
25
|
+
model: typeof TASK_KIND_MODEL;
|
|
26
|
+
task: string;
|
|
27
|
+
}
|
|
28
|
+
export interface TaskKindEvidence {
|
|
29
|
+
version: typeof TASK_KIND_VERSION;
|
|
30
|
+
model: typeof TASK_KIND_MODEL;
|
|
31
|
+
choice: string;
|
|
32
|
+
confidence: number;
|
|
33
|
+
probabilities: Record<string, number>;
|
|
34
|
+
}
|
|
35
|
+
export interface TaskKindVerdict {
|
|
36
|
+
kind: TaskKind;
|
|
37
|
+
confidence: number;
|
|
38
|
+
/** The task is not delivered while the workspace's code is unchanged. */
|
|
39
|
+
expectsChange: boolean;
|
|
40
|
+
}
|
|
41
|
+
export type TaskKindReason = 'selected' | 'invalid_or_unavailable_evidence' | 'needs_clarification' | 'low_confidence';
|
|
42
|
+
export declare function makeTaskKindRequest(task: string): TaskKindRequest;
|
|
43
|
+
export declare function parseTaskKindEvidence(value: unknown): TaskKindEvidence | undefined;
|
|
44
|
+
export declare function decideTaskKind(raw: unknown): {
|
|
45
|
+
verdict?: TaskKindVerdict;
|
|
46
|
+
reason: TaskKindReason;
|
|
47
|
+
evidence?: TaskKindEvidence;
|
|
48
|
+
};
|
|
49
|
+
/** The sentence appended to the run's first message for a kind, when one helps. */
|
|
50
|
+
export declare function taskKindNote(kind: TaskKind): string | undefined;
|
|
51
|
+
/** The reminder for a run whose task calls for a code change and that finishes with the code unchanged. */
|
|
52
|
+
export declare function unchangedWorkNudge(kind: TaskKind): string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the first message of a run asks the agent to deliver, as judged by the hosted classifier.
|
|
3
|
+
* The classifier's wording lives on the server; the client sends only the task text and receives
|
|
4
|
+
* a probability for each kind. The verdict is advice to the model and a fact for the finish check.
|
|
5
|
+
* It grants no permission and changes no tool.
|
|
6
|
+
*/
|
|
7
|
+
export const TASK_KIND_VERSION = 1;
|
|
8
|
+
export const TASK_KIND_MODEL = 'jev-1.13.0';
|
|
9
|
+
export const TASK_KIND_UNCLEAR = 'needs_clarification';
|
|
10
|
+
export const TASK_KINDS = ['fix_defect', 'make_change', 'answer_question', 'investigate', 'run_or_verify', 'general'];
|
|
11
|
+
export const TASK_KIND_CHOICES = [...TASK_KINDS, TASK_KIND_UNCLEAR];
|
|
12
|
+
/** Below this a verdict is not used, and the finish check never relies on a weaker one. */
|
|
13
|
+
export const TASK_KIND_CONFIDENCE_FLOOR = 0.9;
|
|
14
|
+
/**
|
|
15
|
+
* A one-line bug report ("why is the button doing nothing?") is read as a defect with less
|
|
16
|
+
* confidence than a full issue, and the note for it only restates what the default instruction
|
|
17
|
+
* already asks. So the note is added from this lower floor, while the notes that tell the model
|
|
18
|
+
* not to edit, and the finish check, keep the stricter one.
|
|
19
|
+
*/
|
|
20
|
+
export const TASK_KIND_DEFECT_NOTE_FLOOR = 0.7;
|
|
21
|
+
export const TASK_KIND_TASK_CHARS = 3_000;
|
|
22
|
+
const own = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
23
|
+
const unit = (value) => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
24
|
+
export function makeTaskKindRequest(task) {
|
|
25
|
+
if (typeof task !== 'string' || !task.trim() || task.length > TASK_KIND_TASK_CHARS)
|
|
26
|
+
throw new Error('Invalid task-kind task');
|
|
27
|
+
return { version: TASK_KIND_VERSION, model: TASK_KIND_MODEL, task };
|
|
28
|
+
}
|
|
29
|
+
export function parseTaskKindEvidence(value) {
|
|
30
|
+
if (!own(value) || value.version !== TASK_KIND_VERSION || value.model !== TASK_KIND_MODEL
|
|
31
|
+
|| typeof value.choice !== 'string' || !TASK_KIND_CHOICES.includes(value.choice) || !unit(value.confidence)
|
|
32
|
+
|| !own(value.probabilities))
|
|
33
|
+
return undefined;
|
|
34
|
+
const scores = value.probabilities;
|
|
35
|
+
if (Object.keys(scores).length !== TASK_KIND_CHOICES.length
|
|
36
|
+
|| TASK_KIND_CHOICES.some(id => !Object.hasOwn(scores, id) || !unit(scores[id])))
|
|
37
|
+
return undefined;
|
|
38
|
+
const probabilities = Object.fromEntries(TASK_KIND_CHOICES.map(id => [id, scores[id]]));
|
|
39
|
+
if (Math.abs(Object.values(probabilities).reduce((sum, p) => sum + p, 0) - 1) > 1e-6
|
|
40
|
+
|| probabilities[value.choice] !== Math.max(...Object.values(probabilities)))
|
|
41
|
+
return undefined;
|
|
42
|
+
return { version: TASK_KIND_VERSION, model: TASK_KIND_MODEL, choice: value.choice, confidence: value.confidence, probabilities };
|
|
43
|
+
}
|
|
44
|
+
export function decideTaskKind(raw) {
|
|
45
|
+
const evidence = parseTaskKindEvidence(raw);
|
|
46
|
+
if (!evidence)
|
|
47
|
+
return { reason: 'invalid_or_unavailable_evidence' };
|
|
48
|
+
if (evidence.choice === TASK_KIND_UNCLEAR)
|
|
49
|
+
return { reason: 'needs_clarification', evidence };
|
|
50
|
+
const kind = evidence.choice;
|
|
51
|
+
if (evidence.confidence < (kind === 'fix_defect' ? TASK_KIND_DEFECT_NOTE_FLOOR : TASK_KIND_CONFIDENCE_FLOOR))
|
|
52
|
+
return { reason: 'low_confidence', evidence };
|
|
53
|
+
return { reason: 'selected', evidence, verdict: { kind, confidence: evidence.confidence,
|
|
54
|
+
expectsChange: (kind === 'fix_defect' || kind === 'make_change') && evidence.confidence >= TASK_KIND_CONFIDENCE_FLOOR } };
|
|
55
|
+
}
|
|
56
|
+
const NOTES = {
|
|
57
|
+
fix_defect: 'This task reports a defect in the code in this workspace. The expected result is the fix, made here and left in place, with any question in the task answered in the report. If the reported behavior turns out to be intended or cannot be reproduced, say so with the evidence instead of changing the code.',
|
|
58
|
+
// A requested change needs no reminder: the task already says what to change.
|
|
59
|
+
make_change: undefined,
|
|
60
|
+
answer_question: 'This task asks for an answer about the code, not a change to it. Read what is needed and answer; leave the workspace as it is unless the answer cannot be established without a temporary change, which is then removed.',
|
|
61
|
+
investigate: 'This task asks for findings, not a change. Temporary instrumentation is fine and is removed before finishing; report what was found and how it was confirmed.',
|
|
62
|
+
run_or_verify: 'This task asks for something to be run and its result reported. Report the commands and their actual output; change code only if the task also asks for failures to be fixed.',
|
|
63
|
+
general: undefined,
|
|
64
|
+
};
|
|
65
|
+
/** The sentence appended to the run's first message for a kind, when one helps. */
|
|
66
|
+
export function taskKindNote(kind) {
|
|
67
|
+
const note = NOTES[kind];
|
|
68
|
+
return note ? `Task type (a classifier's reading of the request above, not an instruction from the user; the request itself wins where they differ): ${note}` : undefined;
|
|
69
|
+
}
|
|
70
|
+
/** The reminder for a run whose task calls for a code change and that finishes with the code unchanged. */
|
|
71
|
+
export function unchangedWorkNudge(kind) {
|
|
72
|
+
const what = kind === 'fix_defect' ? 'reports a defect in the code in this workspace' : 'asks for a change to this workspace';
|
|
73
|
+
return `Completion not accepted yet. The task ${what}, and the workspace holds no change to its code. `
|
|
74
|
+
+ 'If the work was done and then removed, or was only described, make the change in the workspace and leave it in place; an explanation or a workaround does not deliver it. '
|
|
75
|
+
+ 'If no change is the right outcome (the behavior is intended, it cannot be reproduced, or the task needs only an answer), say why in the summary and call complete_agent again to finish; this reminder is not repeated.';
|
|
76
|
+
}
|
|
@@ -5,7 +5,7 @@ export interface DecisionConfig {
|
|
|
5
5
|
model?: string;
|
|
6
6
|
apiKeyEnv?: string;
|
|
7
7
|
requestTimeoutMs?: number;
|
|
8
|
-
features?: Partial<Record<'toolRouting' | 'codeGraphRouting' | 'memoryRouting' | 'webRouting' | 'delegationRouting' | 'verificationRouting' | 'riskClassification' | 'resultRouting', boolean>>;
|
|
8
|
+
features?: Partial<Record<'toolRouting' | 'taskRouting' | 'codeGraphRouting' | 'memoryRouting' | 'webRouting' | 'delegationRouting' | 'verificationRouting' | 'riskClassification' | 'resultRouting', boolean>>;
|
|
9
9
|
style?: 'facts' | 'questions';
|
|
10
10
|
}
|
|
11
11
|
export declare const DECISION_DEFAULTS: {
|
|
@@ -2,7 +2,7 @@ export const DEFAULT_AGENT_GRAPH = {
|
|
|
2
2
|
name: 'Andorra Agent', entry: 'engineer',
|
|
3
3
|
nodes: {
|
|
4
4
|
engineer: { id: 'engineer', name: 'Andorra Agent', type: 'agent', executor: 'react-basic',
|
|
5
|
-
instruction: 'Handle the user\'s task end to end, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly from the available sources. Ask for clarification when needed. Report the result and any remaining issues. For follow-up questions, use the retained conversation and prior results first. Answer directly when they contain the answer; do not restart completed work or scan unrelated files. Never guess a pull request number. Mention pull requests in the report only when the task asked for one or one was opened; a pull request nobody asked for is not unfinished work. Start new implementation work only when the user requests it.',
|
|
5
|
+
instruction: 'Handle the user\'s task end to end, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly from the available sources. Ask for clarification when needed. Report the result and any remaining issues. For follow-up questions, use the retained conversation and prior results first. Answer directly when they contain the answer; do not restart completed work or scan unrelated files. Never guess a pull request number. Mention pull requests in the report only when the task asked for one or one was opened; a pull request nobody asked for is not unfinished work. Start new implementation work only when the user requests it. A task that describes a defect in the code in this workspace is such a request, even when it is phrased as a question: fix the defect there and answer the question in the report.',
|
|
6
6
|
contextPolicy: { history: true }, jevEnabled: true,
|
|
7
7
|
subagents: { enabled: false }, position: { x: 120, y: 120 } },
|
|
8
8
|
done: { id: 'done', name: 'Done', type: 'end', position: { x: 440, y: 120 } },
|
package/dist/src/efficiency.d.ts
CHANGED
|
@@ -23,12 +23,17 @@ export interface ToolMenuRoutingConfig {
|
|
|
23
23
|
minSavingsChars?: number;
|
|
24
24
|
pinnedTools?: string[];
|
|
25
25
|
}
|
|
26
|
+
/** off: no call. shadow: classify and record, change nothing. on: note the first message and check the finish. Unset: on for a Paid account, off otherwise. */
|
|
27
|
+
export interface TaskKindRoutingConfig {
|
|
28
|
+
mode?: 'off' | 'shadow' | 'on';
|
|
29
|
+
}
|
|
26
30
|
export interface EfficiencyConfig {
|
|
27
31
|
deterministicContinuations?: boolean;
|
|
28
32
|
jevFactInterpretation?: boolean;
|
|
29
33
|
jevPreflight?: boolean;
|
|
30
34
|
projectSkillDiscovery?: boolean;
|
|
31
35
|
toolMenuRouting?: ToolMenuRoutingConfig;
|
|
36
|
+
taskKindRouting?: TaskKindRoutingConfig;
|
|
32
37
|
preparedContinuations?: boolean;
|
|
33
38
|
postflightOnlyWithCandidates?: boolean;
|
|
34
39
|
toolResultFiltering?: boolean;
|
package/dist/src/efficiency.js
CHANGED
|
@@ -17,7 +17,7 @@ export function validateEfficiencyConfig(value) {
|
|
|
17
17
|
if (!record(value))
|
|
18
18
|
throw new Error('Invalid efficiency configuration');
|
|
19
19
|
const independent = ['deterministicContinuations', 'jevFactInterpretation', 'jevPreflight', 'projectSkillDiscovery'];
|
|
20
|
-
const allowed = [...EFFICIENCY_FEATURES, ...independent, 'toolResultFilterThresholdChars', 'adaptiveRouting', 'toolMenuRouting'];
|
|
20
|
+
const allowed = [...EFFICIENCY_FEATURES, ...independent, 'toolResultFilterThresholdChars', 'adaptiveRouting', 'toolMenuRouting', 'taskKindRouting'];
|
|
21
21
|
for (const [key, entry] of Object.entries(value)) {
|
|
22
22
|
if (!allowed.includes(key))
|
|
23
23
|
throw new Error(`Unsupported efficiency configuration field: ${key}`);
|
|
@@ -27,6 +27,10 @@ export function validateEfficiencyConfig(value) {
|
|
|
27
27
|
const threshold = value.toolResultFilterThresholdChars;
|
|
28
28
|
if (threshold !== undefined && (!Number.isSafeInteger(threshold) || threshold < 1000 || threshold > 1_000_000))
|
|
29
29
|
throw new Error('efficiency.toolResultFilterThresholdChars must be an integer from 1000 to 1000000');
|
|
30
|
+
const kind = value.taskKindRouting;
|
|
31
|
+
if (kind !== undefined && (!record(kind) || Object.keys(kind).some(key => key !== 'mode')
|
|
32
|
+
|| (kind.mode !== undefined && (typeof kind.mode !== 'string' || !['off', 'shadow', 'on'].includes(kind.mode)))))
|
|
33
|
+
throw new Error('Invalid efficiency.taskKindRouting');
|
|
30
34
|
const menu = value.toolMenuRouting;
|
|
31
35
|
if (menu !== undefined) {
|
|
32
36
|
if (!record(menu) || Object.keys(menu).some(key => !['mode', 'topK', 'minSavingsChars', 'pinnedTools'].includes(key)))
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DecisionBatch } from './decision/types.js';
|
|
2
|
+
import type { ReasoningEffort } from './providers.js';
|
|
3
|
+
export interface EffortDecisionInput {
|
|
4
|
+
task: string;
|
|
5
|
+
/** The model's enabled levels, lowest first. A level that is not here is never returned. */
|
|
6
|
+
levels: readonly ReasoningEffort[];
|
|
7
|
+
hints?: DecisionBatch;
|
|
8
|
+
/** The level the node would run at without Auto. */
|
|
9
|
+
fallback?: ReasoningEffort;
|
|
10
|
+
/** The level of the attempt that just failed, and why it failed. */
|
|
11
|
+
previous?: {
|
|
12
|
+
level: ReasoningEffort;
|
|
13
|
+
reason?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface EffortDecision {
|
|
17
|
+
level?: ReasoningEffort;
|
|
18
|
+
evidence: 'hint' | 'lexical' | 'none' | 'escalation' | 'fixed';
|
|
19
|
+
}
|
|
20
|
+
/** A failed attempt moves up a level only when the failure suggests the model needed to think harder. */
|
|
21
|
+
export declare const EFFORT_ESCALATION_REASONS: ReadonlySet<string>;
|
|
22
|
+
/**
|
|
23
|
+
* The thinking level for one start of a node on Auto. Risk takes the highest enabled level, a confident complexity
|
|
24
|
+
* score is spread evenly across the enabled levels, and an obviously mechanical short task takes the lowest. With no
|
|
25
|
+
* decisive signal the node keeps the level it would have had, moved onto an enabled one.
|
|
26
|
+
*/
|
|
27
|
+
export declare function decideEffort(input: EffortDecisionInput): EffortDecision;
|