@nettee/beacon 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dashboard/export.js
CHANGED
|
@@ -3,7 +3,7 @@ import { mkdtemp, readdir, readFile, realpath, rm } from "node:fs/promises";
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { basename, dirname, isAbsolute, join, sep } from "node:path";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
|
-
import { fillExportedHtmlSystemPrompt,
|
|
6
|
+
import { fillExportedHtmlSystemPrompt, pickExportedSystemPrompt, } from "./session-prompt.js";
|
|
7
7
|
const execFileAsync = promisify(execFile);
|
|
8
8
|
function isInside(root, candidate) {
|
|
9
9
|
return candidate === root || candidate.startsWith(`${root}${sep}`);
|
|
@@ -44,7 +44,7 @@ export async function exportSessionHtml(request) {
|
|
|
44
44
|
windowsHide: true,
|
|
45
45
|
});
|
|
46
46
|
const html = await readFile(outputPath, "utf8");
|
|
47
|
-
const systemPrompt =
|
|
47
|
+
const systemPrompt = pickExportedSystemPrompt(await readFile(jsonlPath, "utf8"), request.systemPrompt);
|
|
48
48
|
return systemPrompt
|
|
49
49
|
? fillExportedHtmlSystemPrompt(html, systemPrompt)
|
|
50
50
|
: html;
|
package/dist/dashboard/server.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createServer, } from "node:http";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { loadProfile } from "../config/profile.js";
|
|
5
|
+
import { buildAgentSystemPrompt } from "../runtime/system-prompt.js";
|
|
4
6
|
import { exportSessionHtml } from "./export.js";
|
|
5
7
|
import { findRunSummary, listRunSummaries, runIdPattern, toRunListItem, } from "./records.js";
|
|
6
8
|
import { sendStaticFile } from "./static.js";
|
|
@@ -18,6 +20,17 @@ function sendText(response, status, body) {
|
|
|
18
20
|
export function defaultUiDirectory() {
|
|
19
21
|
return join(dirname(fileURLToPath(import.meta.url)), "ui");
|
|
20
22
|
}
|
|
23
|
+
async function beaconOwnedSystemPrompt(summary, profilesDirectory) {
|
|
24
|
+
if (summary.systemPrompt)
|
|
25
|
+
return summary.systemPrompt;
|
|
26
|
+
try {
|
|
27
|
+
return buildAgentSystemPrompt(await loadProfile(summary.profileId, profilesDirectory));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Old runs without a stored prompt: reconstruction needs a readable Profile.
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
21
34
|
export async function startDashboard(options) {
|
|
22
35
|
const cache = new Map();
|
|
23
36
|
const inflight = new Map();
|
|
@@ -63,6 +76,7 @@ export async function startDashboard(options) {
|
|
|
63
76
|
sessionDirectory: options.sessionDirectory,
|
|
64
77
|
runId: summary.runId,
|
|
65
78
|
sessionPath: summary.sessionPath,
|
|
79
|
+
systemPrompt: await beaconOwnedSystemPrompt(summary, options.profilesDirectory),
|
|
66
80
|
timeoutMs: options.exportTimeoutMs,
|
|
67
81
|
}).finally(() => {
|
|
68
82
|
inflight.delete(runId);
|
|
@@ -23,6 +23,13 @@ function systemMessageText(content, sections) {
|
|
|
23
23
|
.filter((part) => part.length > 0)
|
|
24
24
|
.join("\n\n");
|
|
25
25
|
}
|
|
26
|
+
function nonempty(value) {
|
|
27
|
+
return value && value.length > 0 ? value : undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Prefer a JSONL system message; otherwise the Beacon-owned `--system-prompt` text. */
|
|
30
|
+
export function pickExportedSystemPrompt(jsonl, beaconOwned) {
|
|
31
|
+
return systemPromptFromJsonl(jsonl) ?? nonempty(beaconOwned);
|
|
32
|
+
}
|
|
26
33
|
export function systemPromptFromJsonl(jsonl) {
|
|
27
34
|
const contents = [];
|
|
28
35
|
const sections = new Map();
|
package/dist/run/orchestrator.js
CHANGED
|
@@ -80,6 +80,11 @@ export class RunOrchestrator {
|
|
|
80
80
|
throw new Error(`Unknown Trigger ${triggerKey}`);
|
|
81
81
|
return found;
|
|
82
82
|
}
|
|
83
|
+
agentSystemPrompt(existing) {
|
|
84
|
+
return existing && existing.length > 0
|
|
85
|
+
? existing
|
|
86
|
+
: buildAgentSystemPrompt(this.options.profile);
|
|
87
|
+
}
|
|
83
88
|
newRun(runId, state, failure) {
|
|
84
89
|
const timestamp = this.timestamp();
|
|
85
90
|
return {
|
|
@@ -95,6 +100,7 @@ export class RunOrchestrator {
|
|
|
95
100
|
promptDigest: createHash("sha256")
|
|
96
101
|
.update(this.options.profile.prompt)
|
|
97
102
|
.digest("hex"),
|
|
103
|
+
systemPrompt: this.agentSystemPrompt(),
|
|
98
104
|
...(failure ? { failure } : {}),
|
|
99
105
|
};
|
|
100
106
|
}
|
|
@@ -193,6 +199,7 @@ export class RunOrchestrator {
|
|
|
193
199
|
sessionId: current.run.runId,
|
|
194
200
|
sessionPath: join(this.options.sessionDirectory, this.options.profile.id, current.run.runId),
|
|
195
201
|
};
|
|
202
|
+
const systemPrompt = this.agentSystemPrompt(current.run.systemPrompt);
|
|
196
203
|
return {
|
|
197
204
|
...current,
|
|
198
205
|
run: {
|
|
@@ -200,6 +207,7 @@ export class RunOrchestrator {
|
|
|
200
207
|
...session,
|
|
201
208
|
state: "starting",
|
|
202
209
|
startedAt: this.timestamp(),
|
|
210
|
+
systemPrompt,
|
|
203
211
|
},
|
|
204
212
|
};
|
|
205
213
|
});
|
|
@@ -214,7 +222,7 @@ export class RunOrchestrator {
|
|
|
214
222
|
workspace: this.options.profile.workspace,
|
|
215
223
|
provider: this.options.profile.model.provider,
|
|
216
224
|
model: this.options.profile.model.id,
|
|
217
|
-
systemPrompt:
|
|
225
|
+
systemPrompt: record.run.systemPrompt,
|
|
218
226
|
outcome: { ...submission.binding, cliPath: this.options.beaconCliPath },
|
|
219
227
|
session: {
|
|
220
228
|
id: record.run.sessionId,
|