@oh-my-matrix/autopilot 2.1.2 → 3.0.0
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/README.md +105 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +308 -92
- package/dist/index.js.map +1 -1
- package/dist/src/autopilot-state.d.ts +17 -0
- package/dist/src/autopilot-state.d.ts.map +1 -1
- package/dist/src/autopilot-state.js +52 -8
- package/dist/src/autopilot-state.js.map +1 -1
- package/dist/src/command-runner.d.ts +2 -6
- package/dist/src/command-runner.d.ts.map +1 -1
- package/dist/src/command-runner.js +4 -34
- package/dist/src/command-runner.js.map +1 -1
- package/dist/src/completion-detector.d.ts.map +1 -1
- package/dist/src/completion-detector.js +16 -8
- package/dist/src/completion-detector.js.map +1 -1
- package/dist/src/effort-injection.d.ts +21 -2
- package/dist/src/effort-injection.d.ts.map +1 -1
- package/dist/src/effort-injection.js +33 -9
- package/dist/src/effort-injection.js.map +1 -1
- package/dist/src/event-shape.contract.d.ts +21 -0
- package/dist/src/event-shape.contract.d.ts.map +1 -0
- package/dist/src/event-shape.contract.js +10 -0
- package/dist/src/event-shape.contract.js.map +1 -0
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/logger.js +42 -7
- package/dist/src/logger.js.map +1 -1
- package/dist/src/model-routing.d.ts +36 -0
- package/dist/src/model-routing.d.ts.map +1 -0
- package/dist/src/model-routing.js +106 -0
- package/dist/src/model-routing.js.map +1 -0
- package/dist/src/orchestrator.d.ts +34 -1
- package/dist/src/orchestrator.d.ts.map +1 -1
- package/dist/src/orchestrator.js +113 -12
- package/dist/src/orchestrator.js.map +1 -1
- package/dist/src/projection.d.ts +8 -2
- package/dist/src/projection.d.ts.map +1 -1
- package/dist/src/projection.js +15 -1
- package/dist/src/projection.js.map +1 -1
- package/dist/src/stall-detector.d.ts +4 -1
- package/dist/src/stall-detector.d.ts.map +1 -1
- package/dist/src/stall-detector.js +7 -3
- package/dist/src/stall-detector.js.map +1 -1
- package/dist/src/tool-error-tracker.d.ts +16 -0
- package/dist/src/tool-error-tracker.d.ts.map +1 -1
- package/dist/src/tool-error-tracker.js +16 -0
- package/dist/src/tool-error-tracker.js.map +1 -1
- package/dist/src/types.d.ts +67 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +45 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/workflow-config.d.ts.map +1 -1
- package/dist/src/workflow-config.js +108 -14
- package/dist/src/workflow-config.js.map +1 -1
- package/openclaw.plugin.json +34 -2
- package/package.json +23 -13
- package/LICENSE +0 -21
- package/dist/src/audit-persister.d.ts +0 -25
- package/dist/src/audit-persister.d.ts.map +0 -1
- package/dist/src/audit-persister.js +0 -162
- package/dist/src/audit-persister.js.map +0 -1
- package/dist/src/permission-policy.d.ts +0 -36
- package/dist/src/permission-policy.d.ts.map +0 -1
- package/dist/src/permission-policy.js +0 -265
- package/dist/src/permission-policy.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effort-injection.js","sourceRoot":"","sources":["../../src/effort-injection.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"effort-injection.js","sourceRoot":"","sources":["../../src/effort-injection.ts"],"names":[],"mappings":";;AAcA,oDAaC;AAcD,4DAQC;AAxCD;;;;GAIG;AACH,SAAgB,oBAAoB,CAClC,MAAc,EACd,YAA+B,MAAM;IAErC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACtC,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,KAAK;YACR,OAAO,2FAA2F,CAAC;QACrG,KAAK,QAAQ;YACX,OAAO,gFAAgF,CAAC;QAC1F,KAAK,MAAM;YACT,OAAO,uEAAuE,CAAC;IACnF,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,wBAAwB,CACtC,kBAA0B,EAC1B,cAA0C,EAC1C,kBAAqC,MAAM;IAE3C,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC/C,IAAI,kBAAkB,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC;IAC3C,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time contract pinning the OpenClaw `before_tool_call` event shape that
|
|
3
|
+
* autopilot's permission hook (index.ts `before_tool_call`) reads.
|
|
4
|
+
*
|
|
5
|
+
* If openclaw ever changes `PluginHookBeforeToolCallEvent` (renames `params`,
|
|
6
|
+
* drops `toolName`, moves the shell command off `params.command`), THIS FILE
|
|
7
|
+
* FAILS TO BUILD — surfacing the break at compile time instead of as a silent
|
|
8
|
+
* fail-open at runtime (the hook would read `undefined` and degrade to
|
|
9
|
+
* classifying by `toolName` alone, letting shell commands through unchecked).
|
|
10
|
+
*
|
|
11
|
+
* Mirrors dynamic-workflows/src/event-shape.contract.ts. Verified live shape
|
|
12
|
+
* (2026-06-28 capture): top-level keys are exactly `toolName` / `params` /
|
|
13
|
+
* `runId` / `toolCallId` — NO `args`, `toolKind`, or `cwd`. The command lives in
|
|
14
|
+
* `params.command` (shell string); cwd in `params.workdir`.
|
|
15
|
+
*
|
|
16
|
+
* Not re-exported from the package barrel: this is a build-time assertion, not
|
|
17
|
+
* part of autopilot's public API.
|
|
18
|
+
*/
|
|
19
|
+
import type { PluginHookBeforeToolCallEvent } from 'openclaw/dist/plugin-sdk/plugin-runtime';
|
|
20
|
+
export declare const REAL_BEFORE_TOOL_CALL_SHAPE: PluginHookBeforeToolCallEvent;
|
|
21
|
+
//# sourceMappingURL=event-shape.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-shape.contract.d.ts","sourceRoot":"","sources":["../../src/event-shape.contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAE7F,eAAO,MAAM,2BAA2B,EAAE,6BAKzC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REAL_BEFORE_TOOL_CALL_SHAPE = void 0;
|
|
4
|
+
exports.REAL_BEFORE_TOOL_CALL_SHAPE = {
|
|
5
|
+
toolName: 'exec',
|
|
6
|
+
params: { command: 'git reset --hard HEAD~1', workdir: '/ws' },
|
|
7
|
+
runId: 'contract-run',
|
|
8
|
+
toolCallId: 'contract-call',
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=event-shape.contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-shape.contract.js","sourceRoot":"","sources":["../../src/event-shape.contract.ts"],"names":[],"mappings":";;;AAoBa,QAAA,2BAA2B,GAAkC;IACxE,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,KAAK,EAAE;IAC9D,KAAK,EAAE,cAAc;IACrB,UAAU,EAAE,eAAe;CAC5B,CAAC"}
|
package/dist/src/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAqE/D,0EAA0E;AAC1E,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAI5C;AAED,mEAAmE;AACnE,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAI7C;AAED,mEAAmE;AACnE,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAI9C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAClC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,IAAI,CAQN"}
|
package/dist/src/logger.js
CHANGED
|
@@ -28,7 +28,14 @@ function shouldLog(level) {
|
|
|
28
28
|
}
|
|
29
29
|
function emitJson(level, msg, ctx) {
|
|
30
30
|
const record = { ts: Date.now(), level, msg, ...ctx };
|
|
31
|
-
|
|
31
|
+
let line;
|
|
32
|
+
try {
|
|
33
|
+
line = JSON.stringify(record);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Circular ref or BigInt in ctx — the logger must never throw into a hook.
|
|
37
|
+
line = JSON.stringify({ ts: record.ts, level, msg, ctxError: 'unserializable' });
|
|
38
|
+
}
|
|
32
39
|
if (level === 'error')
|
|
33
40
|
console.error(line);
|
|
34
41
|
else if (level === 'warn')
|
|
@@ -44,12 +51,36 @@ function emitText(level, args) {
|
|
|
44
51
|
else
|
|
45
52
|
console.log(...args);
|
|
46
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Split variadic log args into a message string + a merged context object.
|
|
56
|
+
* Object args have their structure PRESERVED (merged into ctx) instead of being
|
|
57
|
+
* flattened to "[object Object]"; primitive/array args join into the message.
|
|
58
|
+
* This is what lets JSON-mode `log('x', { runId })` emit a real runId field
|
|
59
|
+
* instead of a lost blob. Text mode is unaffected (it passes raw args through).
|
|
60
|
+
*/
|
|
61
|
+
function splitArgs(args) {
|
|
62
|
+
const parts = [];
|
|
63
|
+
let ctx = {};
|
|
64
|
+
for (const a of args) {
|
|
65
|
+
// Arrays are object-typed but flatten poorly into ctx ({0:..,1:..}); keep
|
|
66
|
+
// them in the message like before. Only plain objects merge into ctx.
|
|
67
|
+
if (a !== null && typeof a === 'object' && !Array.isArray(a)) {
|
|
68
|
+
ctx = { ...ctx, ...a };
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
parts.push(String(a));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { msg: parts.join(' '), ctx };
|
|
75
|
+
}
|
|
47
76
|
/** Log an informational message (gated by AUTOPILOT_LOG_LEVEL >= info) */
|
|
48
77
|
function log(...args) {
|
|
49
78
|
if (!shouldLog('info'))
|
|
50
79
|
return;
|
|
51
|
-
if (isJsonFormat())
|
|
52
|
-
|
|
80
|
+
if (isJsonFormat()) {
|
|
81
|
+
const { msg, ctx } = splitArgs(args);
|
|
82
|
+
emitJson('info', msg, ctx);
|
|
83
|
+
}
|
|
53
84
|
else
|
|
54
85
|
emitText('info', args);
|
|
55
86
|
}
|
|
@@ -57,8 +88,10 @@ function log(...args) {
|
|
|
57
88
|
function warn(...args) {
|
|
58
89
|
if (!shouldLog('warn'))
|
|
59
90
|
return;
|
|
60
|
-
if (isJsonFormat())
|
|
61
|
-
|
|
91
|
+
if (isJsonFormat()) {
|
|
92
|
+
const { msg, ctx } = splitArgs(args);
|
|
93
|
+
emitJson('warn', msg, ctx);
|
|
94
|
+
}
|
|
62
95
|
else
|
|
63
96
|
emitText('warn', args);
|
|
64
97
|
}
|
|
@@ -66,8 +99,10 @@ function warn(...args) {
|
|
|
66
99
|
function error(...args) {
|
|
67
100
|
if (!shouldLog('error'))
|
|
68
101
|
return;
|
|
69
|
-
if (isJsonFormat())
|
|
70
|
-
|
|
102
|
+
if (isJsonFormat()) {
|
|
103
|
+
const { msg, ctx } = splitArgs(args);
|
|
104
|
+
emitJson('error', msg, ctx);
|
|
105
|
+
}
|
|
71
106
|
else
|
|
72
107
|
emitText('error', args);
|
|
73
108
|
}
|
package/dist/src/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";;AAkFA,kBAIC;AAGD,oBAIC;AAGD,sBAIC;AAOD,wCAYC;AAzGD,MAAM,cAAc,GAA6B;IAC/C,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;CACV,CAAC;AAEF,SAAS,eAAe;IACtB,MAAM,GAAG,GAAG,OAAO,OAAO,KAAK,WAAW;QACxC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QAC5D,CAAC,CAAC,SAAS,CAAC;IACd,IAAI,GAAG,IAAI,GAAG,IAAI,cAAc;QAAE,OAAO,GAAe,CAAC;IACzD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,YAAY;IACnB,OAAO,OAAO,OAAO,KAAK,WAAW;QACnC,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,MAAM,CAAC;AAChD,CAAC;AAED,SAAS,SAAS,CAAC,KAAe;IAChC,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,eAAe,EAAE,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAkC,EAAE,GAAW,EAAE,GAA6B;IAC9F,MAAM,MAAM,GAA4B,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAC/E,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,C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,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO;IAC9B,IAAI,YAAY,EAAE,EAAE,CAAC;QACnB,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClF,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,KAAK,KAAK,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model tier routing for autopilot.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions — no side effects, no I/O. Gateway consumes the resolved
|
|
5
|
+
* model via the before_model_resolve hook (modelOverride).
|
|
6
|
+
*
|
|
7
|
+
* Routing priority:
|
|
8
|
+
* 1. Subagent with explicit subagentTier -> subagentTier
|
|
9
|
+
* 2. Evidence gate running (validation phase) -> validationTier
|
|
10
|
+
* 3. Initial turns (totalContinuations <= 1) -> initialTurnTier
|
|
11
|
+
* 4. Otherwise -> defaultTier
|
|
12
|
+
*
|
|
13
|
+
* If modelIds[tier] is unset, resolveModelId returns undefined and no
|
|
14
|
+
* modelOverride is emitted — the session inherits its declared model.
|
|
15
|
+
*/
|
|
16
|
+
import { type ModelTier, type ModelRoutingConfig, type EvidenceStatus } from './types';
|
|
17
|
+
/** Resolve the model tier for the current turn (phase-aware). */
|
|
18
|
+
export declare function resolveModelTier(totalContinuations: number, evidenceStatus: EvidenceStatus | undefined, isSubagent: boolean, config?: ModelRoutingConfig): ModelTier;
|
|
19
|
+
/** Resolve a concrete model ID for a tier. undefined => no override (inherit). */
|
|
20
|
+
export declare function resolveModelId(tier: ModelTier, config?: ModelRoutingConfig): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Detect subagent sessions by the sessionKey marker.
|
|
23
|
+
* OpenClaw subagent keys: agent:<main>:subagent:<sub>
|
|
24
|
+
* Source: openclaw/src/infra/state-migrations.ts:367-369
|
|
25
|
+
*/
|
|
26
|
+
export declare function isSubagentSession(sessionKey?: string): boolean;
|
|
27
|
+
/** Extract the parent (main agent) session key from a subagent key. */
|
|
28
|
+
export declare function extractParentSessionKey(sessionKey?: string): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Parse a ModelRoutingConfig from raw plugin config (camelCase) OR
|
|
31
|
+
* WORKFLOW.md front-matter (snake_case). Accepts both key styles so one
|
|
32
|
+
* parser serves openclaw.plugin.json configSchema and WORKFLOW.md.
|
|
33
|
+
* Returns undefined when defaultTier is absent/invalid (=> no routing).
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseModelRouting(raw: unknown): ModelRoutingConfig | undefined;
|
|
36
|
+
//# sourceMappingURL=model-routing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-routing.d.ts","sourceRoot":"","sources":["../../src/model-routing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAe,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAkBpG,iEAAiE;AACjE,wBAAgB,gBAAgB,CAC9B,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,UAAU,EAAE,OAAO,EACnB,MAAM,CAAC,EAAE,kBAAkB,GAC1B,SAAS,CAWX;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,EACf,MAAM,CAAC,EAAE,kBAAkB,GAC1B,MAAM,GAAG,SAAS,CAEpB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,uEAAuE;AACvE,wBAAgB,uBAAuB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM/E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAwB9E"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveModelTier = resolveModelTier;
|
|
4
|
+
exports.resolveModelId = resolveModelId;
|
|
5
|
+
exports.isSubagentSession = isSubagentSession;
|
|
6
|
+
exports.extractParentSessionKey = extractParentSessionKey;
|
|
7
|
+
exports.parseModelRouting = parseModelRouting;
|
|
8
|
+
/**
|
|
9
|
+
* Model tier routing for autopilot.
|
|
10
|
+
*
|
|
11
|
+
* Pure functions — no side effects, no I/O. Gateway consumes the resolved
|
|
12
|
+
* model via the before_model_resolve hook (modelOverride).
|
|
13
|
+
*
|
|
14
|
+
* Routing priority:
|
|
15
|
+
* 1. Subagent with explicit subagentTier -> subagentTier
|
|
16
|
+
* 2. Evidence gate running (validation phase) -> validationTier
|
|
17
|
+
* 3. Initial turns (totalContinuations <= 1) -> initialTurnTier
|
|
18
|
+
* 4. Otherwise -> defaultTier
|
|
19
|
+
*
|
|
20
|
+
* If modelIds[tier] is unset, resolveModelId returns undefined and no
|
|
21
|
+
* modelOverride is emitted — the session inherits its declared model.
|
|
22
|
+
*/
|
|
23
|
+
const types_1 = require("./types");
|
|
24
|
+
// MODEL_TIERS (from types.ts) is the single source of truth for the tier set;
|
|
25
|
+
// ModelTier is derived from it, so this allowlist cannot drift out of sync.
|
|
26
|
+
function asTier(v) {
|
|
27
|
+
return typeof v === 'string' && types_1.MODEL_TIERS.includes(v)
|
|
28
|
+
? v
|
|
29
|
+
: undefined;
|
|
30
|
+
}
|
|
31
|
+
const DEFAULT_ROUTING = {
|
|
32
|
+
defaultTier: 'standard',
|
|
33
|
+
initialTurnTier: 'premium',
|
|
34
|
+
validationTier: 'standard',
|
|
35
|
+
};
|
|
36
|
+
/** Resolve the model tier for the current turn (phase-aware). */
|
|
37
|
+
function resolveModelTier(totalContinuations, evidenceStatus, isSubagent, config) {
|
|
38
|
+
if (isSubagent && config?.subagentTier) {
|
|
39
|
+
return config.subagentTier;
|
|
40
|
+
}
|
|
41
|
+
if (evidenceStatus === 'running') {
|
|
42
|
+
return config?.validationTier ?? DEFAULT_ROUTING.validationTier;
|
|
43
|
+
}
|
|
44
|
+
if (totalContinuations <= 1) {
|
|
45
|
+
return config?.initialTurnTier ?? DEFAULT_ROUTING.initialTurnTier;
|
|
46
|
+
}
|
|
47
|
+
return config?.defaultTier ?? DEFAULT_ROUTING.defaultTier;
|
|
48
|
+
}
|
|
49
|
+
/** Resolve a concrete model ID for a tier. undefined => no override (inherit). */
|
|
50
|
+
function resolveModelId(tier, config) {
|
|
51
|
+
return config?.modelIds?.[tier];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Detect subagent sessions by the sessionKey marker.
|
|
55
|
+
* OpenClaw subagent keys: agent:<main>:subagent:<sub>
|
|
56
|
+
* Source: openclaw/src/infra/state-migrations.ts:367-369
|
|
57
|
+
*/
|
|
58
|
+
function isSubagentSession(sessionKey) {
|
|
59
|
+
return !!sessionKey && sessionKey.includes(':subagent:');
|
|
60
|
+
}
|
|
61
|
+
/** Extract the parent (main agent) session key from a subagent key. */
|
|
62
|
+
function extractParentSessionKey(sessionKey) {
|
|
63
|
+
if (!sessionKey)
|
|
64
|
+
return undefined;
|
|
65
|
+
const idx = sessionKey.indexOf(':subagent:');
|
|
66
|
+
// idx > 0 (not >= 0) is load-bearing: a malformed ':subagent:'-prefixed key
|
|
67
|
+
// has no parent prefix and must yield undefined, not an empty string.
|
|
68
|
+
return idx > 0 ? sessionKey.substring(0, idx) : undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Parse a ModelRoutingConfig from raw plugin config (camelCase) OR
|
|
72
|
+
* WORKFLOW.md front-matter (snake_case). Accepts both key styles so one
|
|
73
|
+
* parser serves openclaw.plugin.json configSchema and WORKFLOW.md.
|
|
74
|
+
* Returns undefined when defaultTier is absent/invalid (=> no routing).
|
|
75
|
+
*/
|
|
76
|
+
function parseModelRouting(raw) {
|
|
77
|
+
if (typeof raw !== 'object' || raw === null)
|
|
78
|
+
return undefined;
|
|
79
|
+
const r = raw;
|
|
80
|
+
const defaultTier = asTier(r.defaultTier) ?? asTier(r.default_tier);
|
|
81
|
+
if (!defaultTier)
|
|
82
|
+
return undefined;
|
|
83
|
+
const result = { defaultTier };
|
|
84
|
+
const initial = asTier(r.initialTurnTier) ?? asTier(r.initial_turn_tier);
|
|
85
|
+
if (initial)
|
|
86
|
+
result.initialTurnTier = initial;
|
|
87
|
+
const validation = asTier(r.validationTier) ?? asTier(r.validation_tier);
|
|
88
|
+
if (validation)
|
|
89
|
+
result.validationTier = validation;
|
|
90
|
+
const subagent = asTier(r.subagentTier) ?? asTier(r.subagent_tier);
|
|
91
|
+
if (subagent)
|
|
92
|
+
result.subagentTier = subagent;
|
|
93
|
+
const idsRaw = r.modelIds ?? r.model_ids;
|
|
94
|
+
if (typeof idsRaw === 'object' && idsRaw !== null) {
|
|
95
|
+
const ids = idsRaw;
|
|
96
|
+
const parsed = {};
|
|
97
|
+
for (const t of types_1.MODEL_TIERS) {
|
|
98
|
+
if (typeof ids[t] === 'string')
|
|
99
|
+
parsed[t] = ids[t];
|
|
100
|
+
}
|
|
101
|
+
if (Object.keys(parsed).length > 0)
|
|
102
|
+
result.modelIds = parsed;
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=model-routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-routing.js","sourceRoot":"","sources":["../../src/model-routing.ts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MAAM,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC;IACzC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClD,MAAM,GAAG,GAAG,MAAiC,CAAC;QAC9C,MAAM,MAAM,GAAuC,EAAE,CAAC;QACtD,KAAK,MAAM,CAAC,IAAI,mBAAW,EAAE,CAAC;YAC5B,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ;gBAAE,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAW,CAAC;QAC/D,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC;IAC/D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -6,11 +6,44 @@
|
|
|
6
6
|
* No side effects — no file I/O, no IPC, no network.
|
|
7
7
|
*/
|
|
8
8
|
import type { AutopilotState, OrchestratorEvent, BlockedReason } from './types';
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Recoverable blocked reasons that can be resumed.
|
|
11
|
+
*
|
|
12
|
+
* W1 Phase 1.5: re-derived from the pauseReasonToBlockedReason mapping. The 5
|
|
13
|
+
* new terminal BlockedReasons (max_total_reached, tool_error_repeated,
|
|
14
|
+
* loop_breaker_triggered, context_overflow_unrecoverable, injection_rejected)
|
|
15
|
+
* are deliberately NON-resumable EXCEPT injection_rejected — a workflow
|
|
16
|
+
* injection failure is transient (the host may accept it on retry), so it stays
|
|
17
|
+
* resumable. This is a deliberate widening documented in ADR-016.
|
|
18
|
+
*/
|
|
10
19
|
export declare const RESUMABLE_BLOCKED_REASONS: ReadonlySet<BlockedReason>;
|
|
20
|
+
/**
|
|
21
|
+
* Derive the user-facing `status` field from `orchestrationState` + `blockedReason`.
|
|
22
|
+
*
|
|
23
|
+
* W1 (dual state machine collapse): `status` is moving toward being a derived
|
|
24
|
+
* field with the reducer as its sole writer. This function encodes the mapping
|
|
25
|
+
* so that, once all writers route through the reducer, `status` is always a
|
|
26
|
+
* pure function of orchState — eliminating the H1-class bug where the two
|
|
27
|
+
* fields could disagree.
|
|
28
|
+
*
|
|
29
|
+
* Mapping (evidence-based from current autopilot-state.ts setter behavior):
|
|
30
|
+
* done → 'done'
|
|
31
|
+
* blocked + user_stopped → 'idle' (terminal, user-initiated)
|
|
32
|
+
* blocked + resumable reason → 'paused' (recoverable)
|
|
33
|
+
* blocked + other non-resumable → 'paused' (parked, not resumable)
|
|
34
|
+
* unclaimed/claimed/running/released/retry_queued → 'running'
|
|
35
|
+
*
|
|
36
|
+
* NOTE: this is currently reference-only — no production writer uses it yet.
|
|
37
|
+
* Phase 2 will route all writers through the reducer, which will call this.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deriveStatus(state: Pick<AutopilotState, 'orchestrationState' | 'blockedReason'>): AutopilotState['status'];
|
|
11
40
|
/**
|
|
12
41
|
* Apply an orchestrator event to the current state.
|
|
13
42
|
* Returns a new state object (immutable).
|
|
43
|
+
*
|
|
44
|
+
* W1 Phase 3: the reducer is the sole writer of `status`. Every return path
|
|
45
|
+
* flows through a post-switch derivation step that sets `status = deriveStatus(result)`,
|
|
46
|
+
* guaranteeing status is always consistent with orchState+blockedReason.
|
|
14
47
|
*/
|
|
15
48
|
export declare function orchestratorReducer(state: AutopilotState, event: OrchestratorEvent): AutopilotState;
|
|
16
49
|
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAEjB,aAAa,EACd,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EAEjB,aAAa,EACd,MAAM,SAAS,CAAC;AAKjB;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,aAAa,CAK/D,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,oBAAoB,GAAG,eAAe,CAAC,GAAG,cAAc,CAAC,QAAQ,CAAC,CAU1H;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,iBAAiB,GACvB,cAAc,CAKhB"}
|
package/dist/src/orchestrator.js
CHANGED
|
@@ -1,20 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RESUMABLE_BLOCKED_REASONS = void 0;
|
|
4
|
+
exports.deriveStatus = deriveStatus;
|
|
4
5
|
exports.orchestratorReducer = orchestratorReducer;
|
|
5
6
|
const types_1 = require("./types");
|
|
6
7
|
const retry_queue_1 = require("./retry-queue");
|
|
7
|
-
|
|
8
|
+
const workflow_config_1 = require("./workflow-config");
|
|
9
|
+
/**
|
|
10
|
+
* Recoverable blocked reasons that can be resumed.
|
|
11
|
+
*
|
|
12
|
+
* W1 Phase 1.5: re-derived from the pauseReasonToBlockedReason mapping. The 5
|
|
13
|
+
* new terminal BlockedReasons (max_total_reached, tool_error_repeated,
|
|
14
|
+
* loop_breaker_triggered, context_overflow_unrecoverable, injection_rejected)
|
|
15
|
+
* are deliberately NON-resumable EXCEPT injection_rejected — a workflow
|
|
16
|
+
* injection failure is transient (the host may accept it on retry), so it stays
|
|
17
|
+
* resumable. This is a deliberate widening documented in ADR-016.
|
|
18
|
+
*/
|
|
8
19
|
exports.RESUMABLE_BLOCKED_REASONS = new Set([
|
|
9
20
|
'stalled',
|
|
10
21
|
'validation_failed',
|
|
11
22
|
'evidence_missing',
|
|
23
|
+
'injection_rejected', // W1: deliberate widening (transient injection failure)
|
|
12
24
|
]);
|
|
25
|
+
/**
|
|
26
|
+
* Derive the user-facing `status` field from `orchestrationState` + `blockedReason`.
|
|
27
|
+
*
|
|
28
|
+
* W1 (dual state machine collapse): `status` is moving toward being a derived
|
|
29
|
+
* field with the reducer as its sole writer. This function encodes the mapping
|
|
30
|
+
* so that, once all writers route through the reducer, `status` is always a
|
|
31
|
+
* pure function of orchState — eliminating the H1-class bug where the two
|
|
32
|
+
* fields could disagree.
|
|
33
|
+
*
|
|
34
|
+
* Mapping (evidence-based from current autopilot-state.ts setter behavior):
|
|
35
|
+
* done → 'done'
|
|
36
|
+
* blocked + user_stopped → 'idle' (terminal, user-initiated)
|
|
37
|
+
* blocked + resumable reason → 'paused' (recoverable)
|
|
38
|
+
* blocked + other non-resumable → 'paused' (parked, not resumable)
|
|
39
|
+
* unclaimed/claimed/running/released/retry_queued → 'running'
|
|
40
|
+
*
|
|
41
|
+
* NOTE: this is currently reference-only — no production writer uses it yet.
|
|
42
|
+
* Phase 2 will route all writers through the reducer, which will call this.
|
|
43
|
+
*/
|
|
44
|
+
function deriveStatus(state) {
|
|
45
|
+
const orch = state.orchestrationState;
|
|
46
|
+
if (orch === undefined)
|
|
47
|
+
return 'idle'; // pre-activate / no run
|
|
48
|
+
if (orch === 'done')
|
|
49
|
+
return 'done';
|
|
50
|
+
if (orch === 'blocked') {
|
|
51
|
+
if (state.blockedReason === 'user_stopped')
|
|
52
|
+
return 'idle';
|
|
53
|
+
return 'paused';
|
|
54
|
+
}
|
|
55
|
+
// unclaimed, claimed, running, released, retry_queued — all active states.
|
|
56
|
+
return 'running';
|
|
57
|
+
}
|
|
13
58
|
/**
|
|
14
59
|
* Apply an orchestrator event to the current state.
|
|
15
60
|
* Returns a new state object (immutable).
|
|
61
|
+
*
|
|
62
|
+
* W1 Phase 3: the reducer is the sole writer of `status`. Every return path
|
|
63
|
+
* flows through a post-switch derivation step that sets `status = deriveStatus(result)`,
|
|
64
|
+
* guaranteeing status is always consistent with orchState+blockedReason.
|
|
16
65
|
*/
|
|
17
66
|
function orchestratorReducer(state, event) {
|
|
67
|
+
const next = reducerCore(state, event);
|
|
68
|
+
// Sole-writer invariant: status is always derived, never independently set.
|
|
69
|
+
const derivedStatus = deriveStatus(next);
|
|
70
|
+
return next.status === derivedStatus ? next : { ...next, status: derivedStatus };
|
|
71
|
+
}
|
|
72
|
+
function reducerCore(state, event) {
|
|
18
73
|
switch (event.type) {
|
|
19
74
|
// ─── idle → unclaimed ─────────────────────────────────────
|
|
20
75
|
case 'activate_requested': {
|
|
@@ -46,6 +101,11 @@ function orchestratorReducer(state, event) {
|
|
|
46
101
|
};
|
|
47
102
|
}
|
|
48
103
|
// ─── unclaimed + workspace_failed → blocked ───────────────
|
|
104
|
+
// M2 NOTE: this event + permission_denied below are defined in the reducer
|
|
105
|
+
// but never dispatched from index.ts. Tool blocks are handled by the host's
|
|
106
|
+
// before_tool_call veto, not via orchestrator events. Kept as reducer-level
|
|
107
|
+
// API surface for future use (e.g. if workspace creation moves into the
|
|
108
|
+
// orchestrator). Tests cover the reducer contract; the dispatch gap is intentional.
|
|
49
109
|
case 'workspace_failed': {
|
|
50
110
|
if (state.orchestrationState !== 'unclaimed')
|
|
51
111
|
return state;
|
|
@@ -95,7 +155,7 @@ function orchestratorReducer(state, event) {
|
|
|
95
155
|
// Error path
|
|
96
156
|
const classification = (0, retry_queue_1.classifyRecoverability)(event.error ?? 'unknown error');
|
|
97
157
|
const maxRetries = state.workflow?.maxRetries ?? 3;
|
|
98
|
-
const maxRetryBackoffMs = state.workflow?.maxRetryBackoffMs ??
|
|
158
|
+
const maxRetryBackoffMs = state.workflow?.maxRetryBackoffMs ?? workflow_config_1.DEFAULT_WORKFLOW_CONFIG.maxRetryBackoffMs;
|
|
99
159
|
const currentAttempt = (state.retry?.attempt ?? 0) + 1;
|
|
100
160
|
if (!(0, retry_queue_1.shouldRetry)({ attempt: currentAttempt, maxRetries, recoverable: classification.recoverable })) {
|
|
101
161
|
// Unrecoverable or max retries reached → blocked
|
|
@@ -104,7 +164,10 @@ function orchestratorReducer(state, event) {
|
|
|
104
164
|
orchestrationState: 'blocked',
|
|
105
165
|
blockedReason: classification.recoverable
|
|
106
166
|
? 'max_retries_reached'
|
|
107
|
-
:
|
|
167
|
+
// W1b: don't use toBlockedReason (falls back to validation_failed which
|
|
168
|
+
// is RESUMABLE). Use the explicit non-resumable default for unrecognized
|
|
169
|
+
// error strings, and only map known ones directly.
|
|
170
|
+
: (0, types_1.toBlockedReason)(event.error ?? 'unknown error', 'unrecoverable_error'),
|
|
108
171
|
lastActivityAt: event.now,
|
|
109
172
|
};
|
|
110
173
|
}
|
|
@@ -117,12 +180,15 @@ function orchestratorReducer(state, event) {
|
|
|
117
180
|
lastActivityAt: event.now,
|
|
118
181
|
};
|
|
119
182
|
}
|
|
120
|
-
// ─── running + stall_timeout → retry_queued ────────────────
|
|
183
|
+
// ─── running/claimed + stall_timeout → retry_queued ────────────────
|
|
184
|
+
// M3: also accept 'claimed' — a claimed run that never receives a turn stalls
|
|
185
|
+
// and should transition to retry_queued (or blocked if retries exhausted),
|
|
186
|
+
// not linger until the 24h orphan sweep.
|
|
121
187
|
case 'stall_timeout': {
|
|
122
|
-
if (state.orchestrationState !== 'running')
|
|
188
|
+
if (state.orchestrationState !== 'running' && state.orchestrationState !== 'claimed')
|
|
123
189
|
return state;
|
|
124
190
|
const maxRetries = state.workflow?.maxRetries ?? 3;
|
|
125
|
-
const maxRetryBackoffMs = state.workflow?.maxRetryBackoffMs ??
|
|
191
|
+
const maxRetryBackoffMs = state.workflow?.maxRetryBackoffMs ?? workflow_config_1.DEFAULT_WORKFLOW_CONFIG.maxRetryBackoffMs;
|
|
126
192
|
const currentAttempt = (state.retry?.attempt ?? 0) + 1;
|
|
127
193
|
if (!(0, retry_queue_1.shouldRetry)({ attempt: currentAttempt, maxRetries, recoverable: true })) {
|
|
128
194
|
return {
|
|
@@ -151,6 +217,7 @@ function orchestratorReducer(state, event) {
|
|
|
151
217
|
return {
|
|
152
218
|
...state,
|
|
153
219
|
orchestrationState: 'claimed',
|
|
220
|
+
needsCrossTurnResume: true,
|
|
154
221
|
lastActivityAt: event.now,
|
|
155
222
|
};
|
|
156
223
|
}
|
|
@@ -184,7 +251,7 @@ function orchestratorReducer(state, event) {
|
|
|
184
251
|
}
|
|
185
252
|
// Failed → check retry
|
|
186
253
|
const maxRetries = state.workflow?.maxRetries ?? 3;
|
|
187
|
-
const maxRetryBackoffMs = state.workflow?.maxRetryBackoffMs ??
|
|
254
|
+
const maxRetryBackoffMs = state.workflow?.maxRetryBackoffMs ?? workflow_config_1.DEFAULT_WORKFLOW_CONFIG.maxRetryBackoffMs;
|
|
188
255
|
const currentAttempt = (state.retry?.attempt ?? 0) + 1;
|
|
189
256
|
if ((0, retry_queue_1.shouldRetry)({ attempt: currentAttempt, maxRetries, recoverable: true })) {
|
|
190
257
|
const retryEntry = (0, retry_queue_1.buildRetryEntry)(currentAttempt, 'validation_failed', event.now, maxRetryBackoffMs);
|
|
@@ -228,18 +295,52 @@ function orchestratorReducer(state, event) {
|
|
|
228
295
|
lastActivityAt: event.now,
|
|
229
296
|
};
|
|
230
297
|
}
|
|
231
|
-
// ─── blocked
|
|
232
|
-
|
|
233
|
-
|
|
298
|
+
// ─── pause_requested → blocked (W1 Phase 1.5, TENSION 3) ────────────
|
|
299
|
+
// Routes the 4 pause() call sites through the reducer so status derives
|
|
300
|
+
// from orchState, not an imperative setter. The PauseReason maps to a
|
|
301
|
+
// BlockedReason via pauseReasonToBlockedReason (total — no fallback that
|
|
302
|
+
// could make terminal reasons look resumable, TENSION 1).
|
|
303
|
+
//
|
|
304
|
+
// TENSION 3 reconciliation: pause_requested is status-only. If the reducer
|
|
305
|
+
// already moved off the running family (e.g. agent_turn_finished fired an
|
|
306
|
+
// error → retry_queued/blocked), pause_requested NO-OPS — the reducer's own
|
|
307
|
+
// retry/block decision wins. This prevents a double-transition where a
|
|
308
|
+
// loop-breaker pause arrives after the turn already failed and retried.
|
|
309
|
+
case 'pause_requested': {
|
|
310
|
+
// TENSION 3: exclude 'retry_queued' — a recoverable breaker under retry cap
|
|
311
|
+
// must survive a subsequent pause_requested (branch-A contract). Only
|
|
312
|
+
// pause from the active-running family, not from an already-retrying state.
|
|
313
|
+
const runningFamily = [
|
|
314
|
+
'running', 'claimed', 'released', 'unclaimed',
|
|
315
|
+
];
|
|
316
|
+
if (!runningFamily.includes(state.orchestrationState))
|
|
234
317
|
return state;
|
|
235
|
-
|
|
236
|
-
|
|
318
|
+
return {
|
|
319
|
+
...state,
|
|
320
|
+
orchestrationState: 'blocked',
|
|
321
|
+
blockedReason: (0, types_1.pauseReasonToBlockedReason)(event.reason),
|
|
322
|
+
lastActivityAt: event.now,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
// ─── blocked/unclaimed + resume_requested → claimed (only recoverable)
|
|
326
|
+
case 'resume_requested': {
|
|
327
|
+
// REV-1 fix: also handle 'unclaimed' (a run paused before dispatch).
|
|
328
|
+
// Without this, resume of an unclaimed run is a silent no-op: state stays
|
|
329
|
+
// unclaimed, kickResumedTurn early-returns, but the caller sees success.
|
|
330
|
+
if (state.orchestrationState !== 'blocked' && state.orchestrationState !== 'unclaimed')
|
|
237
331
|
return state;
|
|
332
|
+
// For blocked runs, only recoverable reasons can resume.
|
|
333
|
+
if (state.orchestrationState === 'blocked') {
|
|
334
|
+
const reason = state.blockedReason;
|
|
335
|
+
if (!reason || !exports.RESUMABLE_BLOCKED_REASONS.has(reason)) {
|
|
336
|
+
return state;
|
|
337
|
+
}
|
|
238
338
|
}
|
|
239
339
|
return {
|
|
240
340
|
...state,
|
|
241
341
|
orchestrationState: 'claimed',
|
|
242
342
|
blockedReason: undefined,
|
|
343
|
+
needsCrossTurnResume: true,
|
|
243
344
|
lastActivityAt: event.now,
|
|
244
345
|
};
|
|
245
346
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/orchestrator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/orchestrator.ts"],"names":[],"mappings":";;;AAqDA,oCAUC;AAUD,kDAQC;AApED,mCAAsE;AACtE,+CAAqF;AACrF,uDAA4D;AAE5D;;;;;;;;;GASG;AACU,QAAA,yBAAyB,GAA+B,IAAI,GAAG,CAAC;IAC3E,SAAS;IACT,mBAAmB;IACnB,kBAAkB;IAClB,oBAAoB,EAAE,wDAAwD;CAC/E,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,YAAY,CAAC,KAAmE;IAC9F,MAAM,IAAI,GAAG,KAAK,CAAC,kBAAkB,CAAC;IACtC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,CAAC,wBAAwB;IAC/D,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,IAAI,KAAK,CAAC,aAAa,KAAK,cAAc;YAAE,OAAO,MAAM,CAAC;QAC1D,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,2EAA2E;IAC3E,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,KAAqB,EACrB,KAAwB;IAExB,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACvC,4EAA4E;IAC5E,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AACnF,CAAC;AAED,SAAS,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-
import type { AutopilotState, ToolErrorEntry, EvidenceCommandResult } from './types';
|
|
1
|
+
import type { AutopilotState, ToolErrorEntry, EvidenceCommandResult, ThinkingIntensity, ModelTier, AutopilotConfig } from './types';
|
|
2
2
|
export interface AutopilotProjection {
|
|
3
3
|
status: AutopilotState['status'];
|
|
4
4
|
enabled: boolean;
|
|
@@ -35,6 +35,12 @@ export interface AutopilotProjection {
|
|
|
35
35
|
lastEvidenceCommands?: EvidenceCommandResult[];
|
|
36
36
|
workflowSource?: 'workflow_md' | 'default' | 'last_valid';
|
|
37
37
|
workflowConfigError?: string;
|
|
38
|
+
/** Current resolved thinking intensity (observability only) */
|
|
39
|
+
thinkingIntensity?: ThinkingIntensity;
|
|
40
|
+
/** Current resolved model tier (observability) */
|
|
41
|
+
modelTier?: ModelTier;
|
|
42
|
+
/** Recommended model ID for current tier (observability) */
|
|
43
|
+
recommendedModelId?: string;
|
|
38
44
|
}
|
|
39
45
|
/**
|
|
40
46
|
* Claude API pricing constants used for cost estimation.
|
|
@@ -43,5 +49,5 @@ export interface AutopilotProjection {
|
|
|
43
49
|
*/
|
|
44
50
|
export declare const AUTOPILOT_INPUT_COST_PER_M_USD = 3;
|
|
45
51
|
export declare const AUTOPILOT_OUTPUT_COST_PER_M_USD = 15;
|
|
46
|
-
export declare function projectState(state: AutopilotState | undefined): AutopilotProjection | undefined;
|
|
52
|
+
export declare function projectState(state: AutopilotState | undefined, config?: Pick<AutopilotConfig, 'thinkingIntensity' | 'modelRouting'>): AutopilotProjection | undefined;
|
|
47
53
|
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/projection.ts"],"names":[],"mapp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