bernard-agent 0.8.1 → 0.9.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 +80 -44
- package/dist/agent.d.ts +14 -3
- package/dist/agent.js +228 -38
- package/dist/agent.js.map +1 -1
- package/dist/builtin-specialists/correction-agent.json +32 -0
- package/dist/builtin-specialists/file-wrapper.json +43 -0
- package/dist/builtin-specialists/shell-wrapper.json +50 -0
- package/dist/builtin-specialists/specialist-creator.json +32 -0
- package/dist/builtin-specialists/web-wrapper.json +38 -0
- package/dist/candidate-bootstrap.d.ts +18 -0
- package/dist/candidate-bootstrap.js +61 -0
- package/dist/candidate-bootstrap.js.map +1 -0
- package/dist/config.d.ts +126 -10
- package/dist/config.js +222 -45
- package/dist/config.js.map +1 -1
- package/dist/context.js +23 -6
- package/dist/context.js.map +1 -1
- package/dist/correction-candidates.d.ts +54 -0
- package/dist/correction-candidates.js +138 -0
- package/dist/correction-candidates.js.map +1 -0
- package/dist/correction.d.ts +67 -0
- package/dist/correction.js +138 -0
- package/dist/correction.js.map +1 -0
- package/dist/critic.js +2 -1
- package/dist/critic.js.map +1 -1
- package/dist/cron/notes-store.d.ts +41 -0
- package/dist/cron/notes-store.js +134 -0
- package/dist/cron/notes-store.js.map +1 -0
- package/dist/cron/runner.js +25 -3
- package/dist/cron/runner.js.map +1 -1
- package/dist/cron/scoped-notes-tools.d.ts +24 -0
- package/dist/cron/scoped-notes-tools.js +50 -0
- package/dist/cron/scoped-notes-tools.js.map +1 -0
- package/dist/custom-providers.d.ts +80 -0
- package/dist/custom-providers.js +238 -0
- package/dist/custom-providers.js.map +1 -0
- package/dist/fs-utils.d.ts +2 -0
- package/dist/fs-utils.js +44 -0
- package/dist/fs-utils.js.map +1 -0
- package/dist/history.js +3 -1
- package/dist/history.js.map +1 -1
- package/dist/image.d.ts +59 -0
- package/dist/image.js +228 -0
- package/dist/image.js.map +1 -0
- package/dist/index.js +72 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +1 -1
- package/dist/mcp.js.map +1 -1
- package/dist/memory.d.ts +13 -0
- package/dist/memory.js +45 -4
- package/dist/memory.js.map +1 -1
- package/dist/menu.d.ts +97 -0
- package/dist/menu.js +338 -0
- package/dist/menu.js.map +1 -0
- package/dist/os-info.d.ts +22 -0
- package/dist/os-info.js +111 -0
- package/dist/os-info.js.map +1 -0
- package/dist/output.d.ts +35 -1
- package/dist/output.js +256 -45
- package/dist/output.js.map +1 -1
- package/dist/pac.d.ts +14 -2
- package/dist/pac.js +5 -5
- package/dist/pac.js.map +1 -1
- package/dist/paths.d.ts +5 -0
- package/dist/paths.js +6 -1
- package/dist/paths.js.map +1 -1
- package/dist/plan-store.d.ts +47 -0
- package/dist/plan-store.js +94 -0
- package/dist/plan-store.js.map +1 -0
- package/dist/prompt-rewriter.d.ts +29 -0
- package/dist/prompt-rewriter.js +155 -0
- package/dist/prompt-rewriter.js.map +1 -0
- package/dist/providers/index.d.ts +56 -4
- package/dist/providers/index.js +86 -5
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/profiles.d.ts +37 -0
- package/dist/providers/profiles.js +110 -0
- package/dist/providers/profiles.js.map +1 -0
- package/dist/providers/types.d.ts +11 -2
- package/dist/providers/types.js +3 -0
- package/dist/providers/types.js.map +1 -1
- package/dist/rag-query.js +15 -1
- package/dist/rag-query.js.map +1 -1
- package/dist/react.d.ts +38 -0
- package/dist/react.js +116 -0
- package/dist/react.js.map +1 -0
- package/dist/reasoning-log.d.ts +30 -0
- package/dist/reasoning-log.js +102 -0
- package/dist/reasoning-log.js.map +1 -0
- package/dist/reference-resolver.d.ts +47 -0
- package/dist/reference-resolver.js +316 -0
- package/dist/reference-resolver.js.map +1 -0
- package/dist/reference-tool-lookup.d.ts +37 -0
- package/dist/reference-tool-lookup.js +318 -0
- package/dist/reference-tool-lookup.js.map +1 -0
- package/dist/repl.js +1038 -371
- package/dist/repl.js.map +1 -1
- package/dist/setup.js +2 -1
- package/dist/setup.js.map +1 -1
- package/dist/specialist-detector.js +2 -1
- package/dist/specialist-detector.js.map +1 -1
- package/dist/specialists.d.ts +74 -3
- package/dist/specialists.js +152 -20
- package/dist/specialists.js.map +1 -1
- package/dist/structured-output.d.ts +58 -0
- package/dist/structured-output.js +138 -0
- package/dist/structured-output.js.map +1 -0
- package/dist/theme.d.ts +2 -0
- package/dist/theme.js +18 -12
- package/dist/theme.js.map +1 -1
- package/dist/tool-call-repair.d.ts +29 -0
- package/dist/tool-call-repair.js +99 -0
- package/dist/tool-call-repair.js.map +1 -0
- package/dist/tool-profiles.d.ts +70 -0
- package/dist/tool-profiles.js +385 -0
- package/dist/tool-profiles.js.map +1 -0
- package/dist/tools/activity-summary.d.ts +15 -0
- package/dist/tools/activity-summary.js +44 -0
- package/dist/tools/activity-summary.js.map +1 -0
- package/dist/tools/ask-user.d.ts +49 -0
- package/dist/tools/ask-user.js +52 -0
- package/dist/tools/ask-user.js.map +1 -0
- package/dist/tools/augment.d.ts +17 -0
- package/dist/tools/augment.js +102 -0
- package/dist/tools/augment.js.map +1 -0
- package/dist/tools/cron-logs.js +7 -0
- package/dist/tools/cron-logs.js.map +1 -1
- package/dist/tools/cron-notes.d.ts +52 -0
- package/dist/tools/cron-notes.js +105 -0
- package/dist/tools/cron-notes.js.map +1 -0
- package/dist/tools/datetime.d.ts +7 -0
- package/dist/tools/datetime.js +29 -3
- package/dist/tools/datetime.js.map +1 -1
- package/dist/tools/evaluate.d.ts +20 -0
- package/dist/tools/evaluate.js +29 -0
- package/dist/tools/evaluate.js.map +1 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/mcp.d.ts +3 -3
- package/dist/tools/plan.d.ts +81 -0
- package/dist/tools/plan.js +108 -0
- package/dist/tools/plan.js.map +1 -0
- package/dist/tools/result-cap.d.ts +24 -0
- package/dist/tools/result-cap.js +44 -0
- package/dist/tools/result-cap.js.map +1 -0
- package/dist/tools/routine.d.ts +3 -3
- package/dist/tools/shell.d.ts +14 -1
- package/dist/tools/shell.js +86 -4
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/specialist-run.d.ts +5 -3
- package/dist/tools/specialist-run.js +115 -24
- package/dist/tools/specialist-run.js.map +1 -1
- package/dist/tools/specialist.d.ts +83 -3
- package/dist/tools/specialist.js +83 -3
- package/dist/tools/specialist.js.map +1 -1
- package/dist/tools/subagent.js +32 -14
- package/dist/tools/subagent.js.map +1 -1
- package/dist/tools/task.d.ts +5 -5
- package/dist/tools/task.js +9 -42
- package/dist/tools/task.js.map +1 -1
- package/dist/tools/think.d.ts +18 -0
- package/dist/tools/think.js +25 -0
- package/dist/tools/think.js.map +1 -0
- package/dist/tools/tool-wrapper-run.d.ts +121 -0
- package/dist/tools/tool-wrapper-run.js +382 -0
- package/dist/tools/tool-wrapper-run.js.map +1 -0
- package/dist/tools/types.d.ts +28 -2
- package/dist/tools/web-search.d.ts +31 -0
- package/dist/tools/web-search.js +172 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/wrap-with-specialist.d.ts +55 -0
- package/dist/tools/wrap-with-specialist.js +137 -0
- package/dist/tools/wrap-with-specialist.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A record of a failed tool-wrapper invocation that the correction agent
|
|
3
|
+
* should review at session close. Each candidate captures enough context for
|
|
4
|
+
* a follow-up run (the original input, the attempted call, the error) so the
|
|
5
|
+
* correction agent can propose a fix, validate it by re-executing, and — only
|
|
6
|
+
* if validation succeeds — update the target specialist's examples.
|
|
7
|
+
*/
|
|
8
|
+
export interface CorrectionCandidate {
|
|
9
|
+
id: string;
|
|
10
|
+
specialistId: string;
|
|
11
|
+
input: string;
|
|
12
|
+
/** Stringified tool call that failed (best-effort capture). */
|
|
13
|
+
attemptedCall: string;
|
|
14
|
+
/** The error message observed. */
|
|
15
|
+
error: string;
|
|
16
|
+
/** ISO timestamp. */
|
|
17
|
+
createdAt: string;
|
|
18
|
+
/** Populated by the correction agent after validation. */
|
|
19
|
+
proposedGood?: string;
|
|
20
|
+
proposedBad?: string;
|
|
21
|
+
/** True only after the proposed good example executed successfully. */
|
|
22
|
+
validated: boolean;
|
|
23
|
+
status: 'pending' | 'applied' | 'rejected' | 'invalid';
|
|
24
|
+
/** Free-form notes from the correction agent (why it rejected, etc.). */
|
|
25
|
+
notes?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const MAX_PENDING_CORRECTIONS = 50;
|
|
28
|
+
/**
|
|
29
|
+
* Disk-backed store for correction candidates. Each candidate is a separate
|
|
30
|
+
* JSON file under {@link CORRECTION_CANDIDATES_DIR}. Writes are atomic.
|
|
31
|
+
*
|
|
32
|
+
* Mirrors the `CandidateStore` pattern used for specialist candidates.
|
|
33
|
+
*/
|
|
34
|
+
export declare class CorrectionCandidateStore {
|
|
35
|
+
constructor();
|
|
36
|
+
/** Returns all candidates newest-first, skipping corrupt files. */
|
|
37
|
+
list(): CorrectionCandidate[];
|
|
38
|
+
/** Returns only pending candidates. */
|
|
39
|
+
listPending(): CorrectionCandidate[];
|
|
40
|
+
get(id: string): CorrectionCandidate | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Enqueues a new pending correction candidate. Silently no-ops when the
|
|
43
|
+
* pending list would exceed {@link MAX_PENDING_CORRECTIONS} — we never want
|
|
44
|
+
* logging to block a tool call.
|
|
45
|
+
*/
|
|
46
|
+
enqueue(input: {
|
|
47
|
+
specialistId: string;
|
|
48
|
+
input: string;
|
|
49
|
+
attemptedCall: string;
|
|
50
|
+
error: string;
|
|
51
|
+
}): CorrectionCandidate | undefined;
|
|
52
|
+
update(id: string, patch: Partial<CorrectionCandidate>): CorrectionCandidate | undefined;
|
|
53
|
+
delete(id: string): boolean;
|
|
54
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.CorrectionCandidateStore = exports.MAX_PENDING_CORRECTIONS = void 0;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const crypto = __importStar(require("node:crypto"));
|
|
40
|
+
const paths_js_1 = require("./paths.js");
|
|
41
|
+
const fs_utils_js_1 = require("./fs-utils.js");
|
|
42
|
+
exports.MAX_PENDING_CORRECTIONS = 50;
|
|
43
|
+
/**
|
|
44
|
+
* Disk-backed store for correction candidates. Each candidate is a separate
|
|
45
|
+
* JSON file under {@link CORRECTION_CANDIDATES_DIR}. Writes are atomic.
|
|
46
|
+
*
|
|
47
|
+
* Mirrors the `CandidateStore` pattern used for specialist candidates.
|
|
48
|
+
*/
|
|
49
|
+
class CorrectionCandidateStore {
|
|
50
|
+
constructor() {
|
|
51
|
+
fs.mkdirSync(paths_js_1.CORRECTION_CANDIDATES_DIR, { recursive: true });
|
|
52
|
+
}
|
|
53
|
+
/** Returns all candidates newest-first, skipping corrupt files. */
|
|
54
|
+
list() {
|
|
55
|
+
if (!fs.existsSync(paths_js_1.CORRECTION_CANDIDATES_DIR))
|
|
56
|
+
return [];
|
|
57
|
+
const files = fs.readdirSync(paths_js_1.CORRECTION_CANDIDATES_DIR).filter((f) => f.endsWith('.json'));
|
|
58
|
+
const candidates = [];
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
try {
|
|
61
|
+
const raw = fs.readFileSync(path.join(paths_js_1.CORRECTION_CANDIDATES_DIR, file), 'utf-8');
|
|
62
|
+
candidates.push(JSON.parse(raw));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
/* skip corrupt */
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return candidates.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
69
|
+
}
|
|
70
|
+
/** Returns only pending candidates. */
|
|
71
|
+
listPending() {
|
|
72
|
+
return this.list().filter((c) => c.status === 'pending');
|
|
73
|
+
}
|
|
74
|
+
get(id) {
|
|
75
|
+
try {
|
|
76
|
+
const filePath = path.join(paths_js_1.CORRECTION_CANDIDATES_DIR, `${id}.json`);
|
|
77
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Enqueues a new pending correction candidate. Silently no-ops when the
|
|
85
|
+
* pending list would exceed {@link MAX_PENDING_CORRECTIONS} — we never want
|
|
86
|
+
* logging to block a tool call.
|
|
87
|
+
*/
|
|
88
|
+
enqueue(input) {
|
|
89
|
+
// Lightweight count: just count .json files instead of reading+parsing all of them.
|
|
90
|
+
// Slightly over-counts (includes non-pending), but never under-counts pending.
|
|
91
|
+
try {
|
|
92
|
+
const fileCount = fs
|
|
93
|
+
.readdirSync(paths_js_1.CORRECTION_CANDIDATES_DIR)
|
|
94
|
+
.filter((f) => f.endsWith('.json')).length;
|
|
95
|
+
if (fileCount >= exports.MAX_PENDING_CORRECTIONS)
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
const candidate = {
|
|
102
|
+
id: crypto.randomUUID(),
|
|
103
|
+
specialistId: input.specialistId,
|
|
104
|
+
input: input.input,
|
|
105
|
+
attemptedCall: input.attemptedCall,
|
|
106
|
+
error: input.error,
|
|
107
|
+
createdAt: new Date().toISOString(),
|
|
108
|
+
validated: false,
|
|
109
|
+
status: 'pending',
|
|
110
|
+
};
|
|
111
|
+
try {
|
|
112
|
+
(0, fs_utils_js_1.atomicWriteFileSync)(path.join(paths_js_1.CORRECTION_CANDIDATES_DIR, `${candidate.id}.json`), JSON.stringify(candidate, null, 2));
|
|
113
|
+
return candidate;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
update(id, patch) {
|
|
120
|
+
const existing = this.get(id);
|
|
121
|
+
if (!existing)
|
|
122
|
+
return undefined;
|
|
123
|
+
const merged = { ...existing, ...patch, id: existing.id };
|
|
124
|
+
(0, fs_utils_js_1.atomicWriteFileSync)(path.join(paths_js_1.CORRECTION_CANDIDATES_DIR, `${id}.json`), JSON.stringify(merged, null, 2));
|
|
125
|
+
return merged;
|
|
126
|
+
}
|
|
127
|
+
delete(id) {
|
|
128
|
+
try {
|
|
129
|
+
fs.unlinkSync(path.join(paths_js_1.CORRECTION_CANDIDATES_DIR, `${id}.json`));
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.CorrectionCandidateStore = CorrectionCandidateStore;
|
|
138
|
+
//# sourceMappingURL=correction-candidates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correction-candidates.js","sourceRoot":"","sources":["../src/correction-candidates.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAClC,oDAAsC;AACtC,yCAAuD;AACvD,+CAAoD;AA6BvC,QAAA,uBAAuB,GAAG,EAAE,CAAC;AAE1C;;;;;GAKG;AACH,MAAa,wBAAwB;IACnC;QACE,EAAE,CAAC,SAAS,CAAC,oCAAyB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,mEAAmE;IACnE,IAAI;QACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,oCAAyB,CAAC;YAAE,OAAO,EAAE,CAAC;QACzD,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,oCAAyB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3F,MAAM,UAAU,GAA0B,EAAE,CAAC;QAC7C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,oCAAyB,EAAE,IAAI,CAA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AE,OAAO,CAAC,CAAC,CAAC;YAClE,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAlGD,4DAkGC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { BernardConfig } from './config.js';
|
|
2
|
+
import type { MemoryStore } from './memory.js';
|
|
3
|
+
import type { RAGStore } from './rag.js';
|
|
4
|
+
import type { RoutineStore } from './routines.js';
|
|
5
|
+
import type { ToolOptions } from './tools/types.js';
|
|
6
|
+
import type { CandidateStoreReader } from './specialist-candidates.js';
|
|
7
|
+
import { SpecialistStore } from './specialists.js';
|
|
8
|
+
import { CorrectionCandidateStore, type CorrectionCandidate } from './correction-candidates.js';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
declare const CorrectionOutcomeSchema: z.ZodObject<{
|
|
11
|
+
/** Whether the correction-agent was able to derive a corrected call AND validate it. */
|
|
12
|
+
validated: z.ZodBoolean;
|
|
13
|
+
/** Set when examples were actually appended to the target specialist. */
|
|
14
|
+
applied: z.ZodBoolean;
|
|
15
|
+
/** Short explanation for logging. */
|
|
16
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
applied: boolean;
|
|
19
|
+
validated: boolean;
|
|
20
|
+
notes?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
applied: boolean;
|
|
23
|
+
validated: boolean;
|
|
24
|
+
notes?: string | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
type CorrectionOutcome = z.infer<typeof CorrectionOutcomeSchema>;
|
|
27
|
+
export interface RunCorrectionDeps {
|
|
28
|
+
config: BernardConfig;
|
|
29
|
+
toolOptions: ToolOptions;
|
|
30
|
+
memoryStore: MemoryStore;
|
|
31
|
+
specialistStore: SpecialistStore;
|
|
32
|
+
correctionStore: CorrectionCandidateStore;
|
|
33
|
+
ragStore?: RAGStore;
|
|
34
|
+
routineStore?: RoutineStore;
|
|
35
|
+
candidateStore?: CandidateStoreReader;
|
|
36
|
+
mcpTools?: Record<string, any>;
|
|
37
|
+
/** Optional pre-built tool for testing. Falls back to createToolWrapperRunTool(...) when absent. */
|
|
38
|
+
toolWrapperRun?: {
|
|
39
|
+
execute: (args: any, opts: any) => Promise<any>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Runs the correction-agent meta-specialist over any pending correction
|
|
44
|
+
* candidates. Called at REPL shutdown when `BERNARD_CORRECTION_ENABLED` is
|
|
45
|
+
* truthy and the bundled `correction-agent` specialist exists.
|
|
46
|
+
*
|
|
47
|
+
* The correction-agent receives one candidate at a time and is instructed
|
|
48
|
+
* (via its system prompt + bundled examples) to:
|
|
49
|
+
* 1. Propose a corrected tool call (proposedGood) and label the failed one
|
|
50
|
+
* (proposedBad).
|
|
51
|
+
* 2. Validate by re-running the proposed good call via `tool_wrapper_run`
|
|
52
|
+
* against the target specialist.
|
|
53
|
+
* 3. If validation succeeds, append examples to the target specialist via
|
|
54
|
+
* the `specialist` tool.
|
|
55
|
+
* 4. Return a JSON object `{status, result: {validated, applied, notes?}}`.
|
|
56
|
+
*
|
|
57
|
+
* This orchestrator then updates the candidate's status based on the outcome.
|
|
58
|
+
* It never mutates a specialist directly — the validation-before-commit rule
|
|
59
|
+
* lives inside the correction-agent itself.
|
|
60
|
+
*/
|
|
61
|
+
export declare function runCorrectionAgent(deps: RunCorrectionDeps, prefetchedPending?: CorrectionCandidate[]): Promise<{
|
|
62
|
+
processed: number;
|
|
63
|
+
applied: number;
|
|
64
|
+
skipped: number;
|
|
65
|
+
}>;
|
|
66
|
+
export declare function extractOutcome(text: string): CorrectionOutcome | undefined;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCorrectionAgent = runCorrectionAgent;
|
|
4
|
+
exports.extractOutcome = extractOutcome;
|
|
5
|
+
const tool_wrapper_run_js_1 = require("./tools/tool-wrapper-run.js");
|
|
6
|
+
const structured_output_js_1 = require("./structured-output.js");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const logger_js_1 = require("./logger.js");
|
|
9
|
+
const output_js_1 = require("./output.js");
|
|
10
|
+
/** ID of the bundled correction-agent specialist. */
|
|
11
|
+
const CORRECTION_SPECIALIST_ID = 'correction-agent';
|
|
12
|
+
/** Max candidates processed per session close. Keeps shutdown fast. */
|
|
13
|
+
const MAX_CANDIDATES_PER_RUN = 5;
|
|
14
|
+
const CorrectionOutcomeSchema = zod_1.z.object({
|
|
15
|
+
/** Whether the correction-agent was able to derive a corrected call AND validate it. */
|
|
16
|
+
validated: zod_1.z.boolean(),
|
|
17
|
+
/** Set when examples were actually appended to the target specialist. */
|
|
18
|
+
applied: zod_1.z.boolean(),
|
|
19
|
+
/** Short explanation for logging. */
|
|
20
|
+
notes: zod_1.z.string().optional(),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Runs the correction-agent meta-specialist over any pending correction
|
|
24
|
+
* candidates. Called at REPL shutdown when `BERNARD_CORRECTION_ENABLED` is
|
|
25
|
+
* truthy and the bundled `correction-agent` specialist exists.
|
|
26
|
+
*
|
|
27
|
+
* The correction-agent receives one candidate at a time and is instructed
|
|
28
|
+
* (via its system prompt + bundled examples) to:
|
|
29
|
+
* 1. Propose a corrected tool call (proposedGood) and label the failed one
|
|
30
|
+
* (proposedBad).
|
|
31
|
+
* 2. Validate by re-running the proposed good call via `tool_wrapper_run`
|
|
32
|
+
* against the target specialist.
|
|
33
|
+
* 3. If validation succeeds, append examples to the target specialist via
|
|
34
|
+
* the `specialist` tool.
|
|
35
|
+
* 4. Return a JSON object `{status, result: {validated, applied, notes?}}`.
|
|
36
|
+
*
|
|
37
|
+
* This orchestrator then updates the candidate's status based on the outcome.
|
|
38
|
+
* It never mutates a specialist directly — the validation-before-commit rule
|
|
39
|
+
* lives inside the correction-agent itself.
|
|
40
|
+
*/
|
|
41
|
+
async function runCorrectionAgent(deps, prefetchedPending) {
|
|
42
|
+
const pending = prefetchedPending ?? deps.correctionStore.listPending();
|
|
43
|
+
if (pending.length === 0)
|
|
44
|
+
return { processed: 0, applied: 0, skipped: 0 };
|
|
45
|
+
const correctionSpecialist = deps.specialistStore.get(CORRECTION_SPECIALIST_ID);
|
|
46
|
+
if (!correctionSpecialist) {
|
|
47
|
+
(0, logger_js_1.debugLog)('correction:skip', `No specialist named "${CORRECTION_SPECIALIST_ID}" — skipping.`);
|
|
48
|
+
return { processed: 0, applied: 0, skipped: pending.length };
|
|
49
|
+
}
|
|
50
|
+
const batch = pending.slice(0, MAX_CANDIDATES_PER_RUN);
|
|
51
|
+
const toolWrapperRun = deps.toolWrapperRun ??
|
|
52
|
+
(0, tool_wrapper_run_js_1.createToolWrapperRunTool)(deps.config, deps.toolOptions, deps.memoryStore, deps.specialistStore, deps.correctionStore, deps.mcpTools, deps.ragStore, deps.routineStore, deps.candidateStore);
|
|
53
|
+
let applied = 0;
|
|
54
|
+
let processed = 0;
|
|
55
|
+
const skipped = pending.length - batch.length;
|
|
56
|
+
(0, output_js_1.printInfo)(`Running correction agent over ${batch.length} pending candidate${batch.length === 1 ? '' : 's'}...`);
|
|
57
|
+
for (const candidate of batch) {
|
|
58
|
+
processed++;
|
|
59
|
+
const input = formatCandidatePrompt(candidate);
|
|
60
|
+
try {
|
|
61
|
+
const raw = await toolWrapperRun.execute({
|
|
62
|
+
specialistId: CORRECTION_SPECIALIST_ID,
|
|
63
|
+
input,
|
|
64
|
+
}, { toolCallId: `correction-${candidate.id}`, messages: [] });
|
|
65
|
+
const text = typeof raw === 'string' ? raw : JSON.stringify(raw);
|
|
66
|
+
const outcome = extractOutcome(text);
|
|
67
|
+
if (outcome && outcome.applied) {
|
|
68
|
+
applied++;
|
|
69
|
+
deps.correctionStore.update(candidate.id, {
|
|
70
|
+
status: 'applied',
|
|
71
|
+
validated: true,
|
|
72
|
+
notes: outcome.notes,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else if (outcome && outcome.validated) {
|
|
76
|
+
deps.correctionStore.update(candidate.id, {
|
|
77
|
+
status: 'rejected',
|
|
78
|
+
validated: true,
|
|
79
|
+
notes: outcome.notes ?? 'Validated but not applied (agent declined commit).',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
deps.correctionStore.update(candidate.id, {
|
|
84
|
+
status: 'invalid',
|
|
85
|
+
validated: false,
|
|
86
|
+
notes: outcome?.notes ?? 'Correction agent could not validate a fix.',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
92
|
+
(0, logger_js_1.debugLog)('correction:error', { candidateId: candidate.id, message });
|
|
93
|
+
deps.correctionStore.update(candidate.id, {
|
|
94
|
+
status: 'invalid',
|
|
95
|
+
validated: false,
|
|
96
|
+
notes: `Correction agent errored: ${message}`,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (applied > 0) {
|
|
101
|
+
(0, output_js_1.printInfo)(`Correction agent updated ${applied} specialist${applied === 1 ? '' : 's'}.`);
|
|
102
|
+
}
|
|
103
|
+
return { processed, applied, skipped };
|
|
104
|
+
}
|
|
105
|
+
function formatCandidatePrompt(candidate) {
|
|
106
|
+
return [
|
|
107
|
+
`Candidate ID: ${candidate.id}`,
|
|
108
|
+
`Target specialist: ${candidate.specialistId}`,
|
|
109
|
+
`Original request: ${candidate.input}`,
|
|
110
|
+
`Attempted call: ${candidate.attemptedCall}`,
|
|
111
|
+
`Error observed: ${candidate.error}`,
|
|
112
|
+
'',
|
|
113
|
+
'Diagnose the failure, propose a corrected tool call (proposedGood) and record the bad one (proposedBad), validate the fix by running tool_wrapper_run against the target specialist, and — only if validation returns status: "ok" — append the good/bad pair to the target specialist via the specialist tool (action: "update"). Report the final outcome.',
|
|
114
|
+
].join('\n');
|
|
115
|
+
}
|
|
116
|
+
function extractOutcome(text) {
|
|
117
|
+
// The correction-agent returns the WrapperResult shape; its .result field is what we care about.
|
|
118
|
+
const wrapper = (0, structured_output_js_1.parseStructuredOutput)(text, structured_output_js_1.WrapperResultSchema);
|
|
119
|
+
if (wrapper && wrapper.status === 'ok') {
|
|
120
|
+
const inner = CorrectionOutcomeSchema.safeParse(wrapper.result);
|
|
121
|
+
if (inner.success)
|
|
122
|
+
return inner.data;
|
|
123
|
+
// Accept a minimal shape too
|
|
124
|
+
if (wrapper.result && typeof wrapper.result === 'object') {
|
|
125
|
+
const obj = wrapper.result;
|
|
126
|
+
if (typeof obj.applied === 'boolean' || typeof obj.validated === 'boolean') {
|
|
127
|
+
return {
|
|
128
|
+
validated: Boolean(obj.validated),
|
|
129
|
+
applied: Boolean(obj.applied),
|
|
130
|
+
notes: typeof obj.notes === 'string' ? obj.notes : undefined,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Fallback — scan the text for a bare outcome object.
|
|
136
|
+
return (0, structured_output_js_1.parseStructuredOutput)(text, CorrectionOutcomeSchema);
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=correction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correction.js","sourceRoot":"","sources":["../src/correction.ts"],"names":[],"mappings":";;AA+DA,gDAwFC;AAcD,wCAoBC;AAjLD,qEAAuE;AACvE,iEAAoF;AACpF,6BAAwB;AACxB,2CAAuC;AACvC,2CAAwC;AAExC,qDAAqD;AACrD,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAEpD,uEAAuE;AACvE,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC,MAAM,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,wFAAwF;IACxF,SAAS,EAAE,OAAC,CAAC,OAAO,EAAE;IACtB,yEAAyE;IAC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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,iGAAiG;IACjG,MAAM,OAAO,GAAG,IAAA,4CAAqB,EAAC,IAAI,EAAE,0CAAmB,CAAC,CAAC;IACjE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,uBAAuB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAChE,IAAI,KAAK,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC,IAAI,CAAC;QACrC,6BAA6B;QAC7B,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACzD,MAAM,GAAG,GAAG,OAAO,CAAC,MAAiC,CAAC;YACtD,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC3E,OAAO;oBACL,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;oBACjC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;oBAC7B,KAAK,EAAE,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;iBAC7D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IACD,sDAAsD;IACtD,OAAO,IAAA,4CAAqB,EAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;AAC9D,CAAC"}
|
package/dist/critic.js
CHANGED
|
@@ -93,7 +93,8 @@ ${truncatedLog
|
|
|
93
93
|
})
|
|
94
94
|
.join('\n\n')}`;
|
|
95
95
|
const result = await (0, ai_1.generateText)({
|
|
96
|
-
model: (0, index_js_1.
|
|
96
|
+
model: (0, index_js_1.getModelForConfig)(config, config.provider, config.model),
|
|
97
|
+
providerOptions: (0, index_js_1.getProviderOptionsForConfig)(config, config.provider),
|
|
97
98
|
system: exports.CRITIC_SYSTEM_PROMPT,
|
|
98
99
|
messages: [{ role: 'user', content: criticMessage }],
|
|
99
100
|
maxSteps: 1,
|
package/dist/critic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"critic.js","sourceRoot":"","sources":["../src/critic.ts"],"names":[],"mappings":";;;AAoDA,gDAYC;AAYD,
|
|
1
|
+
{"version":3,"file":"critic.js","sourceRoot":"","sources":["../src/critic.ts"],"names":[],"mappings":";;;AAoDA,gDAYC;AAYD,8BA6EC;AAzJD,2BAAkC;AAClC,mDAAsF;AACtF,2CAKqB;AACrB,2CAAuC;AAGvC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AACxC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AACxC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEvB,QAAA,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;gKAoB4H,CAAC;AAOpJ,QAAA,kBAAkB,GAAG,CAAC,CAAC;AAQpC,8EAA8E;AAC9E,SAAgB,kBAAkB,CAChC,KAAiD;IAEjD,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/C,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7B,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAA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AO,EAAE,MAAM,CAAC,CAAC;YACjD,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,OAAkC;gBAClD,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAA,oBAAQ,EAAC,cAAc,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Maximum characters per note entry (enforced by writers). */
|
|
2
|
+
export declare const MAX_NOTE_LENGTH = 1000;
|
|
3
|
+
/** A single persistent note entry for a cron job. */
|
|
4
|
+
export interface CronNoteEntry {
|
|
5
|
+
timestamp: string;
|
|
6
|
+
runId?: string;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
/** On-disk shape of a cron job's notes file. */
|
|
10
|
+
export interface CronNotes {
|
|
11
|
+
jobId: string;
|
|
12
|
+
entries: CronNoteEntry[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Per-job persistent note store. Each job's notes live in their own JSON file
|
|
16
|
+
* under {@link CRON_NOTES_DIR} and survive daemon restarts. Entries are
|
|
17
|
+
* append-only with a bounded cap of {@link MAX_ENTRIES} (oldest dropped first).
|
|
18
|
+
*/
|
|
19
|
+
export declare class CronNotesStore {
|
|
20
|
+
constructor();
|
|
21
|
+
static get notesDir(): string;
|
|
22
|
+
private sanitizeJobId;
|
|
23
|
+
private notesPath;
|
|
24
|
+
/** Reads all note entries for a job. Returns an empty record if no file exists. */
|
|
25
|
+
read(jobId: string): CronNotes;
|
|
26
|
+
/**
|
|
27
|
+
* Appends a note entry, capping at {@link MAX_ENTRIES} (oldest dropped).
|
|
28
|
+
* Returns the new entry and the post-append total so callers don't need a
|
|
29
|
+
* follow-up read to report counts.
|
|
30
|
+
*/
|
|
31
|
+
append(jobId: string, text: string, runId?: string): {
|
|
32
|
+
entry: CronNoteEntry;
|
|
33
|
+
total: number;
|
|
34
|
+
};
|
|
35
|
+
/** Lists job IDs that have notes files on disk. */
|
|
36
|
+
listJobIds(): string[];
|
|
37
|
+
/** Deletes the notes file for a job. Returns `false` if nothing existed. */
|
|
38
|
+
clear(jobId: string): boolean;
|
|
39
|
+
/** Returns only entries tagged with the given runId. */
|
|
40
|
+
entriesForRun(jobId: string, runId: string): CronNoteEntry[];
|
|
41
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.CronNotesStore = exports.MAX_NOTE_LENGTH = void 0;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const paths_js_1 = require("../paths.js");
|
|
40
|
+
const fs_utils_js_1 = require("../fs-utils.js");
|
|
41
|
+
const memory_js_1 = require("../memory.js");
|
|
42
|
+
const MAX_ENTRIES = 100;
|
|
43
|
+
/** Maximum characters per note entry (enforced by writers). */
|
|
44
|
+
exports.MAX_NOTE_LENGTH = 1000;
|
|
45
|
+
/**
|
|
46
|
+
* Per-job persistent note store. Each job's notes live in their own JSON file
|
|
47
|
+
* under {@link CRON_NOTES_DIR} and survive daemon restarts. Entries are
|
|
48
|
+
* append-only with a bounded cap of {@link MAX_ENTRIES} (oldest dropped first).
|
|
49
|
+
*/
|
|
50
|
+
class CronNotesStore {
|
|
51
|
+
constructor() {
|
|
52
|
+
fs.mkdirSync(paths_js_1.CRON_NOTES_DIR, { recursive: true });
|
|
53
|
+
}
|
|
54
|
+
static get notesDir() {
|
|
55
|
+
return paths_js_1.CRON_NOTES_DIR;
|
|
56
|
+
}
|
|
57
|
+
sanitizeJobId(jobId) {
|
|
58
|
+
const cleaned = (0, memory_js_1.sanitizeKey)(jobId);
|
|
59
|
+
if (!cleaned)
|
|
60
|
+
throw new Error(`Invalid jobId: ${JSON.stringify(jobId)}`);
|
|
61
|
+
return cleaned;
|
|
62
|
+
}
|
|
63
|
+
notesPath(jobId) {
|
|
64
|
+
return path.join(paths_js_1.CRON_NOTES_DIR, `${this.sanitizeJobId(jobId)}.json`);
|
|
65
|
+
}
|
|
66
|
+
/** Reads all note entries for a job. Returns an empty record if no file exists. */
|
|
67
|
+
read(jobId) {
|
|
68
|
+
const safeId = this.sanitizeJobId(jobId);
|
|
69
|
+
const filePath = this.notesPath(safeId);
|
|
70
|
+
if (!fs.existsSync(filePath))
|
|
71
|
+
return { jobId: safeId, entries: [] };
|
|
72
|
+
try {
|
|
73
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
74
|
+
const parsed = JSON.parse(raw);
|
|
75
|
+
return {
|
|
76
|
+
jobId: parsed.jobId ?? safeId,
|
|
77
|
+
entries: Array.isArray(parsed.entries) ? parsed.entries : [],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error instanceof SyntaxError) {
|
|
82
|
+
return { jobId: safeId, entries: [] };
|
|
83
|
+
}
|
|
84
|
+
if (typeof error === 'object' &&
|
|
85
|
+
error !== null &&
|
|
86
|
+
'code' in error &&
|
|
87
|
+
error.code === 'ENOENT') {
|
|
88
|
+
return { jobId: safeId, entries: [] };
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Appends a note entry, capping at {@link MAX_ENTRIES} (oldest dropped).
|
|
95
|
+
* Returns the new entry and the post-append total so callers don't need a
|
|
96
|
+
* follow-up read to report counts.
|
|
97
|
+
*/
|
|
98
|
+
append(jobId, text, runId) {
|
|
99
|
+
const safeId = this.sanitizeJobId(jobId);
|
|
100
|
+
const current = this.read(safeId);
|
|
101
|
+
const entry = {
|
|
102
|
+
timestamp: new Date().toISOString(),
|
|
103
|
+
text,
|
|
104
|
+
...(runId ? { runId } : {}),
|
|
105
|
+
};
|
|
106
|
+
const nextEntries = [...current.entries, entry].slice(-MAX_ENTRIES);
|
|
107
|
+
const payload = { jobId: safeId, entries: nextEntries };
|
|
108
|
+
(0, fs_utils_js_1.atomicWriteFileSync)(this.notesPath(safeId), JSON.stringify(payload, null, 2));
|
|
109
|
+
return { entry, total: nextEntries.length };
|
|
110
|
+
}
|
|
111
|
+
/** Lists job IDs that have notes files on disk. */
|
|
112
|
+
listJobIds() {
|
|
113
|
+
if (!fs.existsSync(paths_js_1.CRON_NOTES_DIR))
|
|
114
|
+
return [];
|
|
115
|
+
return fs
|
|
116
|
+
.readdirSync(paths_js_1.CRON_NOTES_DIR)
|
|
117
|
+
.filter((f) => f.endsWith('.json'))
|
|
118
|
+
.map((f) => f.replace(/\.json$/, ''));
|
|
119
|
+
}
|
|
120
|
+
/** Deletes the notes file for a job. Returns `false` if nothing existed. */
|
|
121
|
+
clear(jobId) {
|
|
122
|
+
const filePath = this.notesPath(jobId);
|
|
123
|
+
if (!fs.existsSync(filePath))
|
|
124
|
+
return false;
|
|
125
|
+
fs.unlinkSync(filePath);
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
/** Returns only entries tagged with the given runId. */
|
|
129
|
+
entriesForRun(jobId, runId) {
|
|
130
|
+
return this.read(jobId).entries.filter((e) => e.runId === runId);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.CronNotesStore = CronNotesStore;
|
|
134
|
+
//# sourceMappingURL=notes-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notes-store.js","sourceRoot":"","sources":["../../src/cron/notes-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAClC,0CAA6C;AAC7C,gDAAqD;AACrD,4CAA2C;AAE3C,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,+DAA+D;AAClD,QAAA,eAAe,GAAG,IAAI,CAAC;AAepC;;;;GAIG;AACH,MAAa,cAAc;IACzB;QACE,EAAE,CAAC,SAAS,CAAC,yBAAc,EAAE,EAAE,SAAS,EAAE,IAAI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