@oh-my-matrix/autopilot 2.1.1
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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1034 -0
- package/dist/index.js.map +1 -0
- package/dist/src/audit-persister.d.ts +25 -0
- package/dist/src/audit-persister.d.ts.map +1 -0
- package/dist/src/audit-persister.js +162 -0
- package/dist/src/audit-persister.js.map +1 -0
- package/dist/src/autopilot-state.d.ts +35 -0
- package/dist/src/autopilot-state.d.ts.map +1 -0
- package/dist/src/autopilot-state.js +121 -0
- package/dist/src/autopilot-state.js.map +1 -0
- package/dist/src/command-runner.d.ts +13 -0
- package/dist/src/command-runner.d.ts.map +1 -0
- package/dist/src/command-runner.js +148 -0
- package/dist/src/command-runner.js.map +1 -0
- package/dist/src/completion-detector.d.ts +21 -0
- package/dist/src/completion-detector.d.ts.map +1 -0
- package/dist/src/completion-detector.js +104 -0
- package/dist/src/completion-detector.js.map +1 -0
- package/dist/src/continuation-engine.d.ts +9 -0
- package/dist/src/continuation-engine.d.ts.map +1 -0
- package/dist/src/continuation-engine.js +76 -0
- package/dist/src/continuation-engine.js.map +1 -0
- package/dist/src/effort-injection.d.ts +9 -0
- package/dist/src/effort-injection.d.ts.map +1 -0
- package/dist/src/effort-injection.js +17 -0
- package/dist/src/effort-injection.js.map +1 -0
- package/dist/src/evidence-gate.d.ts +24 -0
- package/dist/src/evidence-gate.d.ts.map +1 -0
- package/dist/src/evidence-gate.js +86 -0
- package/dist/src/evidence-gate.js.map +1 -0
- package/dist/src/goal-manager.d.ts +5 -0
- package/dist/src/goal-manager.d.ts.map +1 -0
- package/dist/src/goal-manager.js +22 -0
- package/dist/src/goal-manager.js.map +1 -0
- package/dist/src/logger.d.ts +27 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +90 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/orchestrator.d.ts +16 -0
- package/dist/src/orchestrator.d.ts.map +1 -0
- package/dist/src/orchestrator.js +252 -0
- package/dist/src/orchestrator.js.map +1 -0
- package/dist/src/permission-policy.d.ts +36 -0
- package/dist/src/permission-policy.d.ts.map +1 -0
- package/dist/src/permission-policy.js +265 -0
- package/dist/src/permission-policy.js.map +1 -0
- package/dist/src/project-detector.d.ts +8 -0
- package/dist/src/project-detector.d.ts.map +1 -0
- package/dist/src/project-detector.js +130 -0
- package/dist/src/project-detector.js.map +1 -0
- package/dist/src/projection.d.ts +47 -0
- package/dist/src/projection.d.ts.map +1 -0
- package/dist/src/projection.js +58 -0
- package/dist/src/projection.js.map +1 -0
- package/dist/src/retry-queue.d.ts +25 -0
- package/dist/src/retry-queue.d.ts.map +1 -0
- package/dist/src/retry-queue.js +77 -0
- package/dist/src/retry-queue.js.map +1 -0
- package/dist/src/stall-detector.d.ts +22 -0
- package/dist/src/stall-detector.d.ts.map +1 -0
- package/dist/src/stall-detector.js +26 -0
- package/dist/src/stall-detector.js.map +1 -0
- package/dist/src/tool-error-tracker.d.ts +4 -0
- package/dist/src/tool-error-tracker.d.ts.map +1 -0
- package/dist/src/tool-error-tracker.js +18 -0
- package/dist/src/tool-error-tracker.js.map +1 -0
- package/dist/src/types.d.ts +223 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +55 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/workflow-config.d.ts +13 -0
- package/dist/src/workflow-config.d.ts.map +1 -0
- package/dist/src/workflow-config.js +422 -0
- package/dist/src/workflow-config.js.map +1 -0
- package/openclaw.plugin.json +62 -0
- package/package.json +56 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare function isTaskComplete(lastAssistantMessage?: string, stopHookActive?: boolean): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Detect when the model's response signals there is NO actionable task — it
|
|
4
|
+
* greeted the user and asked what to do, requested a concrete task, or stated
|
|
5
|
+
* outright that nothing can be acted on.
|
|
6
|
+
*
|
|
7
|
+
* `decideContinuation` uses this to stop the autonomous loop gracefully on
|
|
8
|
+
* non-task inputs (greetings like "你好", chit-chat, single-word messages)
|
|
9
|
+
* instead of burning the entire continuation budget looping "continue from
|
|
10
|
+
* where you left off" on a message that has nothing to act on.
|
|
11
|
+
*
|
|
12
|
+
* HIGH-PRECISION patterns only — a match triggers an immediate `complete`, so
|
|
13
|
+
* these must not fire during genuine task progress. We deliberately scope to:
|
|
14
|
+
* (1) greeting-style help offers ("有什么可以帮你的吗" / "how can I help"),
|
|
15
|
+
* (2) the model asking the user for direction ("请问需要我做什么"),
|
|
16
|
+
* (3) explicit "no task" statements ("没有具体的任务" / "there is no task").
|
|
17
|
+
* Generic mid-task clarification requests ("please provide more details about
|
|
18
|
+
* the API") are intentionally NOT matched — they are too close to normal work.
|
|
19
|
+
*/
|
|
20
|
+
export declare function hasNoActionableTask(lastAssistantMessage?: string): boolean;
|
|
21
|
+
//# sourceMappingURL=completion-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion-detector.d.ts","sourceRoot":"","sources":["../../src/completion-detector.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAC5B,oBAAoB,CAAC,EAAE,MAAM,EAC7B,cAAc,CAAC,EAAE,OAAO,GACvB,OAAO,CA6BT;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,OAAO,CAoC1E"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTaskComplete = isTaskComplete;
|
|
4
|
+
exports.hasNoActionableTask = hasNoActionableTask;
|
|
5
|
+
function isTaskComplete(lastAssistantMessage, stopHookActive) {
|
|
6
|
+
if (stopHookActive)
|
|
7
|
+
return false;
|
|
8
|
+
if (!lastAssistantMessage?.trim())
|
|
9
|
+
return false;
|
|
10
|
+
// Strip code blocks and inline code to avoid false positives
|
|
11
|
+
const stripped = lastAssistantMessage
|
|
12
|
+
.replace(/```[\s\S]*?```/g, '')
|
|
13
|
+
.replace(/`[^`]*`/g, '');
|
|
14
|
+
const lower = stripped.toLowerCase();
|
|
15
|
+
// Chinese: match after sentence boundary (punctuation, newline, or start).
|
|
16
|
+
// X-13: include \r so CRLF (\r\n) and lone CR boundaries match — Windows
|
|
17
|
+
// agents commonly emit \r\n line endings and a bare \r would otherwise
|
|
18
|
+
// prevent the trigger from firing.
|
|
19
|
+
const boundary = '(^|[。!?\\r\\n,,;;::])';
|
|
20
|
+
if (new RegExp(`${boundary}\\s*所有任务已完成`).test(lower))
|
|
21
|
+
return true;
|
|
22
|
+
if (new RegExp(`${boundary}\\s*任务全部完成`).test(lower))
|
|
23
|
+
return true;
|
|
24
|
+
if (new RegExp(`${boundary}\\s*全部步骤已完成`).test(lower))
|
|
25
|
+
return true;
|
|
26
|
+
// English: word-boundary + negation guard
|
|
27
|
+
if (/\ball\s+tasks\s+(?:have\s+)?been\s+completed\b/.test(lower))
|
|
28
|
+
return true;
|
|
29
|
+
if (/\ball\s+tasks\s+completed\b/.test(lower) && !/\bnot\s+all\s+tasks\b/.test(lower))
|
|
30
|
+
return true;
|
|
31
|
+
if (/\ball\s+steps\s+(?:have\s+)?been\s+completed\b/.test(lower))
|
|
32
|
+
return true;
|
|
33
|
+
if (/\ball\s+steps\s+completed\b/.test(lower) && !/\bnot\s+all\s+steps\b/.test(lower))
|
|
34
|
+
return true;
|
|
35
|
+
if (/\btask\s+is\s+complete\b/.test(lower) && !/\bnot\s+(?:yet\s+)?complete\b/.test(lower))
|
|
36
|
+
return true;
|
|
37
|
+
if (/\beverything\s+is\s+done\b/.test(lower) && !/\bnot\s+everything\b/.test(lower))
|
|
38
|
+
return true;
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Detect when the model's response signals there is NO actionable task — it
|
|
43
|
+
* greeted the user and asked what to do, requested a concrete task, or stated
|
|
44
|
+
* outright that nothing can be acted on.
|
|
45
|
+
*
|
|
46
|
+
* `decideContinuation` uses this to stop the autonomous loop gracefully on
|
|
47
|
+
* non-task inputs (greetings like "你好", chit-chat, single-word messages)
|
|
48
|
+
* instead of burning the entire continuation budget looping "continue from
|
|
49
|
+
* where you left off" on a message that has nothing to act on.
|
|
50
|
+
*
|
|
51
|
+
* HIGH-PRECISION patterns only — a match triggers an immediate `complete`, so
|
|
52
|
+
* these must not fire during genuine task progress. We deliberately scope to:
|
|
53
|
+
* (1) greeting-style help offers ("有什么可以帮你的吗" / "how can I help"),
|
|
54
|
+
* (2) the model asking the user for direction ("请问需要我做什么"),
|
|
55
|
+
* (3) explicit "no task" statements ("没有具体的任务" / "there is no task").
|
|
56
|
+
* Generic mid-task clarification requests ("please provide more details about
|
|
57
|
+
* the API") are intentionally NOT matched — they are too close to normal work.
|
|
58
|
+
*/
|
|
59
|
+
function hasNoActionableTask(lastAssistantMessage) {
|
|
60
|
+
if (!lastAssistantMessage?.trim())
|
|
61
|
+
return false;
|
|
62
|
+
// Strip code blocks and inline code — same guard as isTaskComplete, so a
|
|
63
|
+
// no-task phrase embedded in a code sample does not falsely stop the run.
|
|
64
|
+
const stripped = lastAssistantMessage
|
|
65
|
+
.replace(/```[\s\S]*?```/g, '')
|
|
66
|
+
.replace(/`[^`]*`/g, '');
|
|
67
|
+
const lower = stripped.toLowerCase();
|
|
68
|
+
// ─── Chinese ──────────────────────────────────────────────
|
|
69
|
+
// (1) Greeting help-offer. The trailing 帮 anchor prevents mid-task phrases
|
|
70
|
+
// like "有什么可以优化的" (what can be optimized) from matching.
|
|
71
|
+
if (/有什么.{0,6}(?:可以|能).{0,4}帮/.test(stripped))
|
|
72
|
+
return true;
|
|
73
|
+
// (2) Asking the user for direction ("请问需要我做什么 / 帮忙 / 效劳").
|
|
74
|
+
if (/请问.{0,8}(?:需要|想要|希望).{0,6}我.{0,6}(?:做|帮|效劳)/.test(stripped))
|
|
75
|
+
return true;
|
|
76
|
+
// (3) Request for a concrete task ("请告诉我具体的需求/任务").
|
|
77
|
+
if (/请(?:告诉我|提供|说明).{0,10}(?:具体|详细|明确).{0,4}(?:任务|需求|要求)/.test(stripped))
|
|
78
|
+
return true;
|
|
79
|
+
// (4) Explicit no-task. The (具体|明确|实际) qualifier is REQUIRED so that
|
|
80
|
+
// "还没有完成任务" / "没完成任务" (incomplete-but-working) does NOT match.
|
|
81
|
+
if (/(?:目前|现在|当前)?没有.{0,4}(?:具体|明确|实际).{0,2}(?:任务|需求)/.test(stripped))
|
|
82
|
+
return true;
|
|
83
|
+
// ─── English ──────────────────────────────────────────────
|
|
84
|
+
// (1) Greeting help-offer.
|
|
85
|
+
if (/how can i help/.test(lower))
|
|
86
|
+
return true;
|
|
87
|
+
if (/what can i do for you/.test(lower))
|
|
88
|
+
return true;
|
|
89
|
+
if (/is there (?:anything|something) i can (?:help|do)/.test(lower))
|
|
90
|
+
return true;
|
|
91
|
+
// (2) Asking the user for direction.
|
|
92
|
+
if (/what (?:would|do) you (?:like|want|need) me to do/.test(lower))
|
|
93
|
+
return true;
|
|
94
|
+
// (3) Explicit no-task. "task|thing" only (NOT "work") so "I don't have the
|
|
95
|
+
// workaround" cannot match on the "work" substring.
|
|
96
|
+
if (/i (?:don't|do not) (?:have|see).{0,15}(?:task|thing)/.test(lower))
|
|
97
|
+
return true;
|
|
98
|
+
if (/there(?:'s| is| are) no (?:actionable |specific |concrete )?(?:task|tasks|work)/.test(lower))
|
|
99
|
+
return true;
|
|
100
|
+
if (/nothing to (?:do|work on|implement|execute)/.test(lower))
|
|
101
|
+
return true;
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=completion-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion-detector.js","sourceRoot":"","sources":["../../src/completion-detector.ts"],"names":[],"mappings":";;AAAA,wCAg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IAAI,mDAAmD,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACjF,qCAAqC;IACrC,IAAI,mDAAmD,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACjF,4EAA4E;IAC5E,wDAAwD;IACxD,IAAI,sDAAsD,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpF,IAAI,iFAAiF,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/G,IAAI,6CAA6C,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE3E,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AutopilotState, ContinuationDecision } from './types';
|
|
2
|
+
interface FinalizeEvent {
|
|
3
|
+
lastAssistantMessage?: string;
|
|
4
|
+
stopHookActive?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function decideContinuation(state: AutopilotState, event: FinalizeEvent): ContinuationDecision;
|
|
7
|
+
export declare function buildRetryInstruction(state: AutopilotState): string;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=continuation-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"continuation-engine.d.ts","sourceRoot":"","sources":["../../src/continuation-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAIpE,UAAU,aAAa;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAcD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,aAAa,GACnB,oBAAoB,CAoDtB;AAID,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAWnE"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decideContinuation = decideContinuation;
|
|
4
|
+
exports.buildRetryInstruction = buildRetryInstruction;
|
|
5
|
+
const completion_detector_1 = require("./completion-detector");
|
|
6
|
+
const tool_error_tracker_1 = require("./tool-error-tracker");
|
|
7
|
+
/**
|
|
8
|
+
* P1-2: Minimum number of cross-turn continuations that must elapse before a
|
|
9
|
+
* textual completion signal (isTaskComplete) is trusted as 'complete'.
|
|
10
|
+
*
|
|
11
|
+
* Opening/mid-run summary phrasing ("所有任务已完成" / "all tasks completed") can
|
|
12
|
+
* fire on the very first turn and historically terminated long runs early.
|
|
13
|
+
* Requiring this many continuations forces the model to keep producing work
|
|
14
|
+
* (and evidence) before it is allowed to stop. Raise for stricter safety,
|
|
15
|
+
* lower for snappier simple-task handling.
|
|
16
|
+
*/
|
|
17
|
+
const MIN_TURNS_BEFORE_COMPLETE = 2;
|
|
18
|
+
function decideContinuation(state, event) {
|
|
19
|
+
if (!state.enabled || state.status !== 'running') {
|
|
20
|
+
return { action: 'finalize' };
|
|
21
|
+
}
|
|
22
|
+
if (event.stopHookActive) {
|
|
23
|
+
return { action: 'finalize' };
|
|
24
|
+
}
|
|
25
|
+
if ((0, completion_detector_1.isTaskComplete)(event.lastAssistantMessage, event.stopHookActive)) {
|
|
26
|
+
// P1-2: don't trust an early completion signal. If too few continuations
|
|
27
|
+
// have elapsed, demote to revise so the run continues and the model can
|
|
28
|
+
// demonstrate concrete progress before being allowed to complete.
|
|
29
|
+
if (state.totalContinuations < MIN_TURNS_BEFORE_COMPLETE) {
|
|
30
|
+
return {
|
|
31
|
+
action: 'revise',
|
|
32
|
+
retryInstruction: '[Autopilot] An early completion signal was detected. If the task is genuinely done, briefly state the concrete changes made; otherwise continue from where you left off. (early-completion guard)',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return { action: 'complete' };
|
|
36
|
+
}
|
|
37
|
+
// Non-task message (greetings like "你好", chit-chat, or the model stating it
|
|
38
|
+
// has nothing to act on): complete immediately. This BYPASSES
|
|
39
|
+
// MIN_TURNS_BEFORE_COMPLETE on purpose — forcing extra continuation turns on a
|
|
40
|
+
// message with no task is exactly the token-wasting loop we are fixing. The
|
|
41
|
+
// patterns in hasNoActionableTask are high-precision (help-offers / explicit
|
|
42
|
+
// no-task) so genuine task progress is not falsely stopped.
|
|
43
|
+
if ((0, completion_detector_1.hasNoActionableTask)(event.lastAssistantMessage)) {
|
|
44
|
+
return { action: 'complete' };
|
|
45
|
+
}
|
|
46
|
+
if ((0, tool_error_tracker_1.isThresholdExceeded)(state, state.toolErrorThreshold)) {
|
|
47
|
+
return { action: 'pause', pauseReason: 'tool_error_repeated' };
|
|
48
|
+
}
|
|
49
|
+
if (state.tokenBudget != null && state.totalTokensUsed >= state.tokenBudget) {
|
|
50
|
+
return { action: 'pause', pauseReason: 'token_budget_exceeded' };
|
|
51
|
+
}
|
|
52
|
+
if (state.totalContinuations >= state.maxTotalContinuations) {
|
|
53
|
+
return { action: 'pause', pauseReason: 'max_total_reached' };
|
|
54
|
+
}
|
|
55
|
+
if (state.turnAttempts >= state.maxAttemptsPerTurn) {
|
|
56
|
+
return { action: 'cross_turn' };
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
action: 'revise',
|
|
60
|
+
retryInstruction: buildRetryInstruction(state),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const MAX_INSTRUCTION_LENGTH = 2000;
|
|
64
|
+
function buildRetryInstruction(state) {
|
|
65
|
+
const goal = state.goal?.substring(0, 500) || '继续执行当前任务';
|
|
66
|
+
const progress = state.progress?.substring(0, 500) || '';
|
|
67
|
+
// Agent-facing instructions (not user-visible) — intentionally bypass i18n.
|
|
68
|
+
// English is used for better model comprehension across all language settings.
|
|
69
|
+
const parts = [`[Autopilot] Current goal: ${goal}`];
|
|
70
|
+
if (progress) {
|
|
71
|
+
parts.push(`[Autopilot] Progress so far: ${progress}`);
|
|
72
|
+
}
|
|
73
|
+
parts.push('[Autopilot] Continue from where you left off.');
|
|
74
|
+
return parts.join('\n').substring(0, MAX_INSTRUCTION_LENGTH);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=continuation-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"continuation-engine.js","sourceRoot":"","sources":["../../src/continuation-engine.ts"],"names":[],"mappings":";;AAqBA,gDAuDC;AAID,sDAWC;AA1FD,+DAA4E;AAC5E,6DAA2D;AAO3D;;;;;;;;;GASG;AACH,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAEpC,SAAgB,kBAAkB,CAChC,KAAqB,EACrB,KAAoB;IAEpB,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;IAED,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACzB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;IAED,IAAI,IAAA,oCAAc,EAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC;QACrE,yEAAyE;QACzE,wEAAwE;QACxE,kEAAkE;QAClE,IAAI,KAAK,CAAC,kBAAkB,GAAG,yBAAyB,EAAE,CAAC;YACzD,OAAO;gBACL,MAAM,EAAE,QAAQ;gBAChB,gBAAgB,EAAE,mMAAmM;aACtN,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC;IAED,4EAA4E;IAC5E,8DAA8D;IAC9D,+EAA+E;IAC/E,4EAA4E;IAC5E,6EAA6E;IAC7E,4DAA4D;IAC5D,IAAI,IAAA,yCAAmB,EAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACpD,OAAO,EAAE,M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C,QAAQ,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAC5D,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effort injection for autopilot agent_turn_prepare hook.
|
|
3
|
+
*
|
|
4
|
+
* When autopilot status is 'running', injects a context instruction
|
|
5
|
+
* to ensure the model uses high effort (extended thinking) for each turn.
|
|
6
|
+
* This prevents cross-turn effort degradation (TD-1).
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildEffortInjection(status: string): string | null;
|
|
9
|
+
//# sourceMappingURL=effort-injection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effort-injection.d.ts","sourceRoot":"","sources":["../../src/effort-injection.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKlE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildEffortInjection = buildEffortInjection;
|
|
4
|
+
/**
|
|
5
|
+
* Effort injection for autopilot agent_turn_prepare hook.
|
|
6
|
+
*
|
|
7
|
+
* When autopilot status is 'running', injects a context instruction
|
|
8
|
+
* to ensure the model uses high effort (extended thinking) for each turn.
|
|
9
|
+
* This prevents cross-turn effort degradation (TD-1).
|
|
10
|
+
*/
|
|
11
|
+
function buildEffortInjection(status) {
|
|
12
|
+
if (status === 'running') {
|
|
13
|
+
return '[autopilot-effort] Use high effort (extended thinking) for this turn.';
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=effort-injection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effort-injection.js","sourceRoot":"","sources":["../../src/effort-injection.ts"],"names":[],"mappings":";;AAOA,oDAKC;AAZD;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,MAAc;IACjD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,uEAAuE,CAAC;IACjF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M2.6 Evidence Gate
|
|
3
|
+
*
|
|
4
|
+
* Evaluates validation command results before marking a run as done.
|
|
5
|
+
* Pure functions — no command execution, no I/O.
|
|
6
|
+
*/
|
|
7
|
+
import type { ValidationCommand, EvidenceCommandResult, EvidenceSummary } from './types';
|
|
8
|
+
export interface EvaluateEvidenceInput {
|
|
9
|
+
commands: ValidationCommand[];
|
|
10
|
+
results: EvidenceCommandResult[];
|
|
11
|
+
diffSummary: string;
|
|
12
|
+
now: number;
|
|
13
|
+
failOnOptional?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Evaluate evidence from validation command results.
|
|
17
|
+
* Returns an EvidenceSummary with pass/fail/skipped status.
|
|
18
|
+
*/
|
|
19
|
+
export declare function evaluateEvidence(input: EvaluateEvidenceInput): EvidenceSummary;
|
|
20
|
+
/**
|
|
21
|
+
* Truncate and clean up diff summary for display.
|
|
22
|
+
*/
|
|
23
|
+
export declare function summarizeDiff(diff: string): string;
|
|
24
|
+
//# sourceMappingURL=evidence-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence-gate.d.ts","sourceRoot":"","sources":["../../src/evidence-gate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEzF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAID;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,eAAe,CAwE9E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlD"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluateEvidence = evaluateEvidence;
|
|
4
|
+
exports.summarizeDiff = summarizeDiff;
|
|
5
|
+
const MAX_DIFF_SUMMARY_LENGTH = 500;
|
|
6
|
+
/**
|
|
7
|
+
* Evaluate evidence from validation command results.
|
|
8
|
+
* Returns an EvidenceSummary with pass/fail/skipped status.
|
|
9
|
+
*/
|
|
10
|
+
function evaluateEvidence(input) {
|
|
11
|
+
const { commands, results, diffSummary, now, failOnOptional = false } = input;
|
|
12
|
+
// No validation commands configured → skipped
|
|
13
|
+
if (commands.length === 0) {
|
|
14
|
+
return {
|
|
15
|
+
status: 'skipped',
|
|
16
|
+
diffSummary: summarizeDiff(diffSummary),
|
|
17
|
+
commands: [],
|
|
18
|
+
completedAt: now,
|
|
19
|
+
failureReason: 'no validation commands configured',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Build a map of results by id for lookup
|
|
23
|
+
const resultsById = new Map();
|
|
24
|
+
for (const r of results) {
|
|
25
|
+
resultsById.set(r.id, r);
|
|
26
|
+
}
|
|
27
|
+
// Track which required commands failed
|
|
28
|
+
const failedRequiredIds = [];
|
|
29
|
+
const failedOptionalIds = [];
|
|
30
|
+
for (const cmd of commands) {
|
|
31
|
+
const result = resultsById.get(cmd.id);
|
|
32
|
+
if (!result || result.status === 'skipped') {
|
|
33
|
+
// Command was never run or was skipped
|
|
34
|
+
if (cmd.required) {
|
|
35
|
+
failedRequiredIds.push(cmd.id);
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (result.status === 'failed' || result.status === 'timeout') {
|
|
40
|
+
if (cmd.required) {
|
|
41
|
+
failedRequiredIds.push(cmd.id);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
failedOptionalIds.push(cmd.id);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Determine final status
|
|
49
|
+
if (failedRequiredIds.length > 0) {
|
|
50
|
+
return {
|
|
51
|
+
status: 'failed',
|
|
52
|
+
diffSummary: summarizeDiff(diffSummary),
|
|
53
|
+
commands: results,
|
|
54
|
+
completedAt: now,
|
|
55
|
+
failureReason: `required command(s) failed: ${failedRequiredIds.join(', ')}`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (failedOptionalIds.length > 0 && failOnOptional) {
|
|
59
|
+
return {
|
|
60
|
+
status: 'failed',
|
|
61
|
+
diffSummary: summarizeDiff(diffSummary),
|
|
62
|
+
commands: results,
|
|
63
|
+
completedAt: now,
|
|
64
|
+
failureReason: `optional command(s) failed: ${failedOptionalIds.join(', ')}`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// All required passed, optional failures are acceptable
|
|
68
|
+
return {
|
|
69
|
+
status: 'passed',
|
|
70
|
+
diffSummary: summarizeDiff(diffSummary),
|
|
71
|
+
commands: results,
|
|
72
|
+
completedAt: now,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Truncate and clean up diff summary for display.
|
|
77
|
+
*/
|
|
78
|
+
function summarizeDiff(diff) {
|
|
79
|
+
if (!diff)
|
|
80
|
+
return '';
|
|
81
|
+
if (diff.length > MAX_DIFF_SUMMARY_LENGTH) {
|
|
82
|
+
return diff.substring(0, MAX_DIFF_SUMMARY_LENGTH - 3) + '...';
|
|
83
|
+
}
|
|
84
|
+
return diff;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=evidence-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence-gate.js","sourceRoot":"","sources":["../../src/evidence-gate.ts"],"names":[],"mappings":";;AAsBA,4CAwEC;AAKD,sCAMC;AAzFD,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,cAAc,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;IAE9E,8CAA8C;IAC9C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC;YACvC,QAAQ,EAAE,EAAE;YACZ,WAAW,EAAE,GAAG;YAChB,aAAa,EAAE,mCAAmC;SACnD,CAAC;IACJ,CAAC;IAED,0CAA0C;IAC1C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAiC,CAAC;IAC7D,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED,uCAAuC;IACvC,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,MAAM,iBAAiB,GAAa,EAAE,CAAC;IAEvC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEvC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC3C,uCAAuC;YACvC,IAAI,GAAG,CAAC,QAAQ,E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CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,IAAI,IAAI,CAAC,MAAM,GAAG,uBAAuB,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,uBAAuB,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AutopilotState } from './types';
|
|
2
|
+
export declare function captureGoal(state: AutopilotState, userMessage: string): AutopilotState;
|
|
3
|
+
export declare function preserveGoalBeforeCompaction(state: AutopilotState): AutopilotState;
|
|
4
|
+
export declare function restoreGoalAfterCompaction(state: AutopilotState): AutopilotState;
|
|
5
|
+
//# sourceMappingURL=goal-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goal-manager.d.ts","sourceRoot":"","sources":["../../src/goal-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG9C,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,CAGtF;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAGlF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAGhF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.captureGoal = captureGoal;
|
|
4
|
+
exports.preserveGoalBeforeCompaction = preserveGoalBeforeCompaction;
|
|
5
|
+
exports.restoreGoalAfterCompaction = restoreGoalAfterCompaction;
|
|
6
|
+
const autopilot_state_1 = require("./autopilot-state");
|
|
7
|
+
function captureGoal(state, userMessage) {
|
|
8
|
+
if (!state.enabled || !userMessage.trim())
|
|
9
|
+
return state;
|
|
10
|
+
return (0, autopilot_state_1.setGoal)(state, userMessage.trim());
|
|
11
|
+
}
|
|
12
|
+
function preserveGoalBeforeCompaction(state) {
|
|
13
|
+
if (!state.enabled || !state.goal)
|
|
14
|
+
return state;
|
|
15
|
+
return (0, autopilot_state_1.snapshotGoal)(state);
|
|
16
|
+
}
|
|
17
|
+
function restoreGoalAfterCompaction(state) {
|
|
18
|
+
if (!state.enabled)
|
|
19
|
+
return state;
|
|
20
|
+
return (0, autopilot_state_1.restoreGoalFromSnapshot)(state);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=goal-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goal-manager.js","sourceRoot":"","sources":["../../src/goal-manager.ts"],"names":[],"mappings":";;AAGA,kCAGC;AAED,oEAGC;AAED,gEAGC;AAfD,uDAAmF;AAEnF,SAAgB,WAAW,CAAC,KAAqB,EAAE,WAAmB;IACpE,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;QAAE,OAAO,KAAK,CAAC;IACxD,OAAO,IAAA,yBAAO,EAAC,KAAK,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,SAAgB,4BAA4B,CAAC,KAAqB;IAChE,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAChD,OAAO,IAAA,8BAAY,EAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,SAAgB,0BAA0B,CAAC,KAAqB;IAC9D,IAAI,CAAC,KAAK,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IACjC,OAAO,IAAA,yCAAuB,EAAC,KAAK,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M-1: Autopilot Logger — gated console output with optional JSON format.
|
|
3
|
+
*
|
|
4
|
+
* All autopilot logging should go through this module instead of raw
|
|
5
|
+
* console.log/warn/error. Two env vars control behavior:
|
|
6
|
+
*
|
|
7
|
+
* AUTOPILOT_LOG_LEVEL — verbosity: debug | info (default) | warn | error | silent
|
|
8
|
+
* AUTOPILOT_LOG_FORMAT — output format: text (default) | json
|
|
9
|
+
*
|
|
10
|
+
* JSON mode emits one JSON object per line: { ts, level, msg, ...ctx }
|
|
11
|
+
* Text mode emits plain string args (backward-compatible with existing behavior).
|
|
12
|
+
*/
|
|
13
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
14
|
+
/** Log an informational message (gated by AUTOPILOT_LOG_LEVEL >= info) */
|
|
15
|
+
export declare function log(...args: unknown[]): void;
|
|
16
|
+
/** Log a warning message (gated by AUTOPILOT_LOG_LEVEL >= warn) */
|
|
17
|
+
export declare function warn(...args: unknown[]): void;
|
|
18
|
+
/** Log an error message (gated by AUTOPILOT_LOG_LEVEL >= error) */
|
|
19
|
+
export declare function error(...args: unknown[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Log a structured message with additional context fields.
|
|
22
|
+
* In JSON mode: emits { ts, level, msg, ...ctx }.
|
|
23
|
+
* In text mode: emits "[level] msg {ctx}" via the appropriate console method.
|
|
24
|
+
*/
|
|
25
|
+
export declare function logWithContext(level: Exclude<LogLevel, 'silent'>, msg: string, ctx: Record<string, unknown>): void;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +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;AAyC/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"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.log = log;
|
|
4
|
+
exports.warn = warn;
|
|
5
|
+
exports.error = error;
|
|
6
|
+
exports.logWithContext = logWithContext;
|
|
7
|
+
const LEVEL_PRIORITY = {
|
|
8
|
+
debug: 0,
|
|
9
|
+
info: 1,
|
|
10
|
+
warn: 2,
|
|
11
|
+
error: 3,
|
|
12
|
+
silent: 4,
|
|
13
|
+
};
|
|
14
|
+
function getCurrentLevel() {
|
|
15
|
+
const env = typeof process !== 'undefined'
|
|
16
|
+
? (process.env.AUTOPILOT_LOG_LEVEL ?? process.env.LOG_LEVEL)
|
|
17
|
+
: undefined;
|
|
18
|
+
if (env && env in LEVEL_PRIORITY)
|
|
19
|
+
return env;
|
|
20
|
+
return 'info';
|
|
21
|
+
}
|
|
22
|
+
function isJsonFormat() {
|
|
23
|
+
return typeof process !== 'undefined' &&
|
|
24
|
+
process.env.AUTOPILOT_LOG_FORMAT === 'json';
|
|
25
|
+
}
|
|
26
|
+
function shouldLog(level) {
|
|
27
|
+
return LEVEL_PRIORITY[level] >= LEVEL_PRIORITY[getCurrentLevel()];
|
|
28
|
+
}
|
|
29
|
+
function emitJson(level, msg, ctx) {
|
|
30
|
+
const record = { ts: Date.now(), level, msg, ...ctx };
|
|
31
|
+
const line = JSON.stringify(record);
|
|
32
|
+
if (level === 'error')
|
|
33
|
+
console.error(line);
|
|
34
|
+
else if (level === 'warn')
|
|
35
|
+
console.warn(line);
|
|
36
|
+
else
|
|
37
|
+
console.log(line);
|
|
38
|
+
}
|
|
39
|
+
function emitText(level, args) {
|
|
40
|
+
if (level === 'error')
|
|
41
|
+
console.error(...args);
|
|
42
|
+
else if (level === 'warn')
|
|
43
|
+
console.warn(...args);
|
|
44
|
+
else
|
|
45
|
+
console.log(...args);
|
|
46
|
+
}
|
|
47
|
+
/** Log an informational message (gated by AUTOPILOT_LOG_LEVEL >= info) */
|
|
48
|
+
function log(...args) {
|
|
49
|
+
if (!shouldLog('info'))
|
|
50
|
+
return;
|
|
51
|
+
if (isJsonFormat())
|
|
52
|
+
emitJson('info', args.map(String).join(' '));
|
|
53
|
+
else
|
|
54
|
+
emitText('info', args);
|
|
55
|
+
}
|
|
56
|
+
/** Log a warning message (gated by AUTOPILOT_LOG_LEVEL >= warn) */
|
|
57
|
+
function warn(...args) {
|
|
58
|
+
if (!shouldLog('warn'))
|
|
59
|
+
return;
|
|
60
|
+
if (isJsonFormat())
|
|
61
|
+
emitJson('warn', args.map(String).join(' '));
|
|
62
|
+
else
|
|
63
|
+
emitText('warn', args);
|
|
64
|
+
}
|
|
65
|
+
/** Log an error message (gated by AUTOPILOT_LOG_LEVEL >= error) */
|
|
66
|
+
function error(...args) {
|
|
67
|
+
if (!shouldLog('error'))
|
|
68
|
+
return;
|
|
69
|
+
if (isJsonFormat())
|
|
70
|
+
emitJson('error', args.map(String).join(' '));
|
|
71
|
+
else
|
|
72
|
+
emitText('error', args);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Log a structured message with additional context fields.
|
|
76
|
+
* In JSON mode: emits { ts, level, msg, ...ctx }.
|
|
77
|
+
* In text mode: emits "[level] msg {ctx}" via the appropriate console method.
|
|
78
|
+
*/
|
|
79
|
+
function logWithContext(level, msg, ctx) {
|
|
80
|
+
if (!shouldLog(level))
|
|
81
|
+
return;
|
|
82
|
+
if (isJsonFormat()) {
|
|
83
|
+
emitJson(level, msg, ctx);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const ctxStr = Object.entries(ctx).map(([k, v]) => `${k}=${String(v)}`).join(' ');
|
|
87
|
+
emitText(level, [`[${level}] ${msg}`, ctxStr]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";;AAsDA,kBAIC;AAGD,oBAIC;AAGD,sBAIC;AAOD,wCAYC;AA7ED,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,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AAmE;AACnE,SAAgB,KAAK,CAAC,GAAG,IAAe;IACtC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAAE,OAAO;IAChC,IAAI,YAAY,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;QAC7D,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAC5B,KAAkC,EAClC,GAAW,EACX,GAA4B;IAE5B,IAAI,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,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M2.5 Orchestrator Reducer
|
|
3
|
+
*
|
|
4
|
+
* Pure function state machine for Autopilot orchestration.
|
|
5
|
+
* Single-writer constraint: all state transitions go through this reducer.
|
|
6
|
+
* No side effects — no file I/O, no IPC, no network.
|
|
7
|
+
*/
|
|
8
|
+
import type { AutopilotState, OrchestratorEvent, BlockedReason } from './types';
|
|
9
|
+
/** Recoverable blocked reasons that can be resumed */
|
|
10
|
+
export declare const RESUMABLE_BLOCKED_REASONS: ReadonlySet<BlockedReason>;
|
|
11
|
+
/**
|
|
12
|
+
* Apply an orchestrator event to the current state.
|
|
13
|
+
* Returns a new state object (immutable).
|
|
14
|
+
*/
|
|
15
|
+
export declare function orchestratorReducer(state: AutopilotState, event: OrchestratorEvent): AutopilotState;
|
|
16
|
+
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -0,0 +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;AAIjB,sDAAsD;AACtD,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,aAAa,CAI/D,CAAC;AAEH;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,iBAAiB,GACvB,cAAc,CAsPhB"}
|