@roarpeng/graphflow 1.12.2 → 1.14.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/CHANGELOG.md +43 -0
- package/README.md +7 -4
- package/README.zh.md +2 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +2 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/embedding-factory.d.ts.map +1 -1
- package/dist/config/embedding-factory.js +2 -1
- package/dist/config/embedding-factory.js.map +1 -1
- package/dist/config/embedding-model.d.ts +7 -0
- package/dist/config/embedding-model.d.ts.map +1 -0
- package/dist/config/embedding-model.js +10 -0
- package/dist/config/embedding-model.js.map +1 -0
- package/dist/core/types.d.ts +4 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/graph/context-slicer.d.ts.map +1 -1
- package/dist/graph/context-slicer.js +102 -0
- package/dist/graph/context-slicer.js.map +1 -1
- package/dist/graph/engineering-knowledge.d.ts +76 -0
- package/dist/graph/engineering-knowledge.d.ts.map +1 -0
- package/dist/graph/engineering-knowledge.js +170 -0
- package/dist/graph/engineering-knowledge.js.map +1 -0
- package/dist/graph/graph-compression.d.ts.map +1 -1
- package/dist/graph/graph-compression.js +3 -0
- package/dist/graph/graph-compression.js.map +1 -1
- package/dist/graph/graph-search.d.ts +26 -0
- package/dist/graph/graph-search.d.ts.map +1 -1
- package/dist/graph/graph-search.js +80 -0
- package/dist/graph/graph-search.js.map +1 -1
- package/dist/graph/memory-pack.d.ts +44 -1
- package/dist/graph/memory-pack.d.ts.map +1 -1
- package/dist/graph/memory-pack.js +134 -4
- package/dist/graph/memory-pack.js.map +1 -1
- package/dist/graph/snapshot-view.d.ts.map +1 -1
- package/dist/graph/snapshot-view.js +2 -0
- package/dist/graph/snapshot-view.js.map +1 -1
- package/dist/graph/team-governance.d.ts +48 -0
- package/dist/graph/team-governance.d.ts.map +1 -0
- package/dist/graph/team-governance.js +174 -0
- package/dist/graph/team-governance.js.map +1 -0
- package/dist/integrations/host-adapter.d.ts +14 -0
- package/dist/integrations/host-adapter.d.ts.map +1 -0
- package/dist/integrations/host-adapter.js +32 -0
- package/dist/integrations/host-adapter.js.map +1 -0
- package/dist/learning/dialogue-thread.d.ts +152 -0
- package/dist/learning/dialogue-thread.d.ts.map +1 -1
- package/dist/learning/dialogue-thread.js +439 -1
- package/dist/learning/dialogue-thread.js.map +1 -1
- package/dist/learning/embeddings.d.ts.map +1 -1
- package/dist/learning/embeddings.js +2 -1
- package/dist/learning/embeddings.js.map +1 -1
- package/dist/learning/episodic-memory.d.ts +4 -1
- package/dist/learning/episodic-memory.d.ts.map +1 -1
- package/dist/learning/episodic-memory.js +7 -1
- package/dist/learning/episodic-memory.js.map +1 -1
- package/dist/learning/evidence.d.ts +48 -0
- package/dist/learning/evidence.d.ts.map +1 -0
- package/dist/learning/evidence.js +112 -0
- package/dist/learning/evidence.js.map +1 -0
- package/dist/learning/turn-distillation.d.ts +24 -0
- package/dist/learning/turn-distillation.d.ts.map +1 -1
- package/dist/learning/turn-distillation.js +101 -0
- package/dist/learning/turn-distillation.js.map +1 -1
- package/dist/security/secure-store.d.ts +13 -0
- package/dist/security/secure-store.d.ts.map +1 -0
- package/dist/security/secure-store.js +42 -0
- package/dist/security/secure-store.js.map +1 -0
- package/dist/security/token-auth.d.ts +23 -0
- package/dist/security/token-auth.d.ts.map +1 -0
- package/dist/security/token-auth.js +86 -0
- package/dist/security/token-auth.js.map +1 -0
- package/dist/surfaces/cli/index.js +333 -3
- package/dist/surfaces/cli/index.js.map +1 -1
- package/dist/surfaces/cli/output.d.ts.map +1 -1
- package/dist/surfaces/cli/output.js +7 -2
- package/dist/surfaces/cli/output.js.map +1 -1
- package/dist/surfaces/cli/runtime/dialogue.d.ts +61 -0
- package/dist/surfaces/cli/runtime/dialogue.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/dialogue.js +121 -6
- package/dist/surfaces/cli/runtime/dialogue.js.map +1 -1
- package/dist/surfaces/cli/runtime/evidence.d.ts +34 -0
- package/dist/surfaces/cli/runtime/evidence.d.ts.map +1 -0
- package/dist/surfaces/cli/runtime/evidence.js +82 -0
- package/dist/surfaces/cli/runtime/evidence.js.map +1 -0
- package/dist/surfaces/cli/runtime/governance.d.ts +88 -0
- package/dist/surfaces/cli/runtime/governance.d.ts.map +1 -0
- package/dist/surfaces/cli/runtime/governance.js +245 -0
- package/dist/surfaces/cli/runtime/governance.js.map +1 -0
- package/dist/surfaces/cli/runtime/graph.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/graph.js +36 -3
- package/dist/surfaces/cli/runtime/graph.js.map +1 -1
- package/dist/surfaces/cli/runtime/routing.d.ts +4 -1
- package/dist/surfaces/cli/runtime/routing.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/routing.js +6 -2
- package/dist/surfaces/cli/runtime/routing.js.map +1 -1
- package/dist/surfaces/cli/runtime/types.d.ts +8 -0
- package/dist/surfaces/cli/runtime/types.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime.d.ts +3 -1
- package/dist/surfaces/cli/runtime.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime.js +23 -1
- package/dist/surfaces/cli/runtime.js.map +1 -1
- package/dist/surfaces/mcp/server.d.ts +7 -0
- package/dist/surfaces/mcp/server.d.ts.map +1 -1
- package/dist/surfaces/mcp/server.js +74 -5
- package/dist/surfaces/mcp/server.js.map +1 -1
- package/dist/surfaces/mcp/tool-definitions.d.ts.map +1 -1
- package/dist/surfaces/mcp/tool-definitions.js +8 -1
- package/dist/surfaces/mcp/tool-definitions.js.map +1 -1
- package/dist/surfaces/mcp/tool-handlers.d.ts.map +1 -1
- package/dist/surfaces/mcp/tool-handlers.js +22 -1
- package/dist/surfaces/mcp/tool-handlers.js.map +1 -1
- package/dsh/plugin.mjs +111 -6
- package/package.json +4 -1
- package/plugin.json +1 -1
- package/web/plugin.mjs +45 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encryptString = encryptString;
|
|
4
|
+
exports.decryptString = decryptString;
|
|
5
|
+
exports.encryptJson = encryptJson;
|
|
6
|
+
exports.decryptJson = decryptJson;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
function keyFromPassphrase(passphrase, salt) {
|
|
9
|
+
return (0, node_crypto_1.scryptSync)(passphrase, salt, 32, { N: 16384, r: 8, p: 1 });
|
|
10
|
+
}
|
|
11
|
+
function encryptString(plaintext, passphrase) {
|
|
12
|
+
const salt = (0, node_crypto_1.randomBytes)(16);
|
|
13
|
+
const iv = (0, node_crypto_1.randomBytes)(12);
|
|
14
|
+
const cipher = (0, node_crypto_1.createCipheriv)("aes-256-gcm", keyFromPassphrase(passphrase, salt), iv);
|
|
15
|
+
const ciphertext = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
16
|
+
return {
|
|
17
|
+
v: 1,
|
|
18
|
+
alg: "aes-256-gcm",
|
|
19
|
+
salt: salt.toString("base64"),
|
|
20
|
+
iv: iv.toString("base64"),
|
|
21
|
+
tag: cipher.getAuthTag().toString("base64"),
|
|
22
|
+
ciphertext: ciphertext.toString("base64"),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function decryptString(envelope, passphrase) {
|
|
26
|
+
if (envelope.alg !== "aes-256-gcm" || envelope.v !== 1) {
|
|
27
|
+
throw new Error("unsupported encrypted envelope");
|
|
28
|
+
}
|
|
29
|
+
const decipher = (0, node_crypto_1.createDecipheriv)(envelope.alg, keyFromPassphrase(passphrase, Buffer.from(envelope.salt, "base64")), Buffer.from(envelope.iv, "base64"));
|
|
30
|
+
decipher.setAuthTag(Buffer.from(envelope.tag, "base64"));
|
|
31
|
+
return Buffer.concat([
|
|
32
|
+
decipher.update(Buffer.from(envelope.ciphertext, "base64")),
|
|
33
|
+
decipher.final(),
|
|
34
|
+
]).toString("utf8");
|
|
35
|
+
}
|
|
36
|
+
function encryptJson(value, passphrase) {
|
|
37
|
+
return encryptString(JSON.stringify(value), passphrase);
|
|
38
|
+
}
|
|
39
|
+
function decryptJson(envelope, passphrase) {
|
|
40
|
+
return JSON.parse(decryptString(envelope, passphrase));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=secure-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-store.js","sourceRoot":"","sources":["../../src/security/secure-store.ts"],"names":[],"mappings":";;AAeA,sCAaC;AAED,sCAcC;AAED,kCAEC;AAED,kCAEC;AApDD,6CAAwF;AAWxF,SAAS,iBAAiB,CAAC,UAAkB,EAAE,IAAY;IACzD,OAAO,IAAA,wBAAU,EAAC,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpE,CAAC;AAED,SAAgB,aAAa,CAAC,SAAiB,EAAE,UAAkB;IACjE,MAAM,IAAI,GAAG,IAAA,yBAAW,EAAC,EAAE,CAAC,CAAC;IAC7B,MAAM,EAAE,GAAG,IAAA,yBAAW,EAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,MAAM,GAAG,IAAA,4BAAc,EAAC,aAAa,EAAE,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACtF,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACrF,OAAO;QACL,CAAC,EAAE,CAAC;QACJ,GAAG,EAAE,aAAa;QAClB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC7B,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACzB,GAAG,EAAE,MAAM,CAAC,UAAU,EA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TokenAuthConfig {
|
|
2
|
+
/** Shared-secret bearer tokens for local/team deployments. */
|
|
3
|
+
bearerTokens?: readonly string[];
|
|
4
|
+
/** HS256 JWT secret. */
|
|
5
|
+
jwtSecret?: string;
|
|
6
|
+
/** RS256/ES256 public key PEM for OIDC providers. */
|
|
7
|
+
publicKeyPem?: string;
|
|
8
|
+
issuer?: string;
|
|
9
|
+
audience?: string;
|
|
10
|
+
requiredScope?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function verifyAccessToken(authorizationHeader: string | undefined, config: TokenAuthConfig): Promise<{
|
|
13
|
+
authenticated: boolean;
|
|
14
|
+
subject?: string;
|
|
15
|
+
reason?: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function issueLocalJwt(subject: string, secret: string, options?: {
|
|
18
|
+
issuer?: string;
|
|
19
|
+
audience?: string;
|
|
20
|
+
scope?: string;
|
|
21
|
+
ttlSeconds?: number;
|
|
22
|
+
}): string;
|
|
23
|
+
//# sourceMappingURL=token-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-auth.d.ts","sourceRoot":"","sources":["../../src/security/token-auth.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAwCD,wBAAsB,iBAAiB,CACrC,mBAAmB,EAAE,MAAM,GAAG,SAAS,EACvC,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC;IAAE,aAAa,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAkDxE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACxF,MAAM,CAeR"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyAccessToken = verifyAccessToken;
|
|
4
|
+
exports.issueLocalJwt = issueLocalJwt;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
function splitToken(token) {
|
|
7
|
+
const parts = token.split(".");
|
|
8
|
+
if (parts.length !== 3)
|
|
9
|
+
return undefined;
|
|
10
|
+
try {
|
|
11
|
+
return {
|
|
12
|
+
header: JSON.parse(Buffer.from(parts[0], "base64url").toString("utf8")),
|
|
13
|
+
payload: JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8")),
|
|
14
|
+
signature: Buffer.from(parts[2], "base64url"),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function secureEquals(left, right) {
|
|
22
|
+
const a = Buffer.from(left);
|
|
23
|
+
const b = Buffer.from(right);
|
|
24
|
+
return a.length === b.length && (0, node_crypto_1.timingSafeEqual)(a, b);
|
|
25
|
+
}
|
|
26
|
+
async function verifyAccessToken(authorizationHeader, config) {
|
|
27
|
+
if (!authorizationHeader?.startsWith("Bearer ")) {
|
|
28
|
+
return { authenticated: false, reason: "missing bearer token" };
|
|
29
|
+
}
|
|
30
|
+
const token = authorizationHeader.slice(7).trim();
|
|
31
|
+
for (const expected of config.bearerTokens ?? []) {
|
|
32
|
+
if (expected && secureEquals(token, expected)) {
|
|
33
|
+
return { authenticated: true, subject: "bearer" };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const jwt = splitToken(token);
|
|
37
|
+
if (!jwt || typeof jwt.payload !== "object" || jwt.payload === null) {
|
|
38
|
+
return { authenticated: false, reason: "invalid token" };
|
|
39
|
+
}
|
|
40
|
+
const signed = `${token.split(".")[0]}.${token.split(".")[1]}`;
|
|
41
|
+
let verified = false;
|
|
42
|
+
if (jwt.header?.alg === "HS256" && config.jwtSecret) {
|
|
43
|
+
const expected = (0, node_crypto_1.createHmac)("sha256", config.jwtSecret).update(signed).digest();
|
|
44
|
+
verified = expected.length === jwt.signature.length && (0, node_crypto_1.timingSafeEqual)(expected, jwt.signature);
|
|
45
|
+
}
|
|
46
|
+
else if ((jwt.header?.alg === "RS256" || jwt.header?.alg === "ES256") &&
|
|
47
|
+
config.publicKeyPem) {
|
|
48
|
+
try {
|
|
49
|
+
verified = (0, node_crypto_1.verify)(jwt.header.alg, Buffer.from(signed), (0, node_crypto_1.createPublicKey)(config.publicKeyPem), jwt.signature);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
verified = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!verified)
|
|
56
|
+
return { authenticated: false, reason: "signature rejected" };
|
|
57
|
+
if (config.issuer && jwt.payload.iss !== config.issuer) {
|
|
58
|
+
return { authenticated: false, reason: "issuer rejected" };
|
|
59
|
+
}
|
|
60
|
+
const audience = Array.isArray(jwt.payload.aud) ? jwt.payload.aud : [jwt.payload.aud];
|
|
61
|
+
if (config.audience && !audience.includes(config.audience)) {
|
|
62
|
+
return { authenticated: false, reason: "audience rejected" };
|
|
63
|
+
}
|
|
64
|
+
const scopes = typeof jwt.payload.scope === "string" ? jwt.payload.scope.split(/\s+/) : [];
|
|
65
|
+
if (config.requiredScope && !scopes.includes(config.requiredScope)) {
|
|
66
|
+
return { authenticated: false, reason: "scope rejected" };
|
|
67
|
+
}
|
|
68
|
+
return { authenticated: true, subject: typeof jwt.payload.sub === "string" ? jwt.payload.sub : "jwt" };
|
|
69
|
+
}
|
|
70
|
+
function issueLocalJwt(subject, secret, options = {}) {
|
|
71
|
+
const encode = (value) => Buffer.from(JSON.stringify(value)).toString("base64url");
|
|
72
|
+
const now = Math.floor(Date.now() / 1000);
|
|
73
|
+
const header = encode({ alg: "HS256", typ: "JWT" });
|
|
74
|
+
const payload = encode({
|
|
75
|
+
sub: subject,
|
|
76
|
+
...(options.issuer ? { iss: options.issuer } : {}),
|
|
77
|
+
...(options.audience ? { aud: options.audience } : {}),
|
|
78
|
+
...(options.scope ? { scope: options.scope } : {}),
|
|
79
|
+
iat: now,
|
|
80
|
+
exp: now + (options.ttlSeconds ?? 3600),
|
|
81
|
+
});
|
|
82
|
+
const data = `${header}.${payload}`;
|
|
83
|
+
const signature = (0, node_crypto_1.createHmac)("sha256", secret).update(data).digest("base64url");
|
|
84
|
+
return `${data}.${signature}`;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=token-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-auth.js","sourceRoot":"","sources":["../../src/security/token-auth.ts"],"names":[],"mappings":";;AAoDA,8CAqDC;AAED,sCAmBC;AA9HD,6CAAmG;AAgCnG,SAAS,UAAU,CAAC,KAAa;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACzC,IAAI,CAAC;QACH,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAc;YACrF,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,C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ineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
4
5
|
const runtime_1 = require("./runtime");
|
|
5
6
|
const loader_js_1 = require("../../config/loader.js");
|
|
6
7
|
const episodic_memory_1 = require("../../learning/episodic-memory");
|
|
@@ -102,7 +103,7 @@ async function executeCommand(command, args, configPath) {
|
|
|
102
103
|
const episodeId = args[1]?.trim();
|
|
103
104
|
const success = (0, output_1.parseCliSuccess)(args[2]);
|
|
104
105
|
if (!episodeId || success === undefined) {
|
|
105
|
-
console.log("Usage: graphflow outcome report <episodeId> <success> [--lesson <text>]... [--
|
|
106
|
+
console.log("Usage: graphflow outcome report <episodeId> <success> [--lesson <text>]... [--commit <sha>] [--diff <diff>] [--test-command <cmd>] [--test-result pass|fail|unknown] [--user-confirmed] ...");
|
|
106
107
|
process.exitCode = 1;
|
|
107
108
|
return undefined;
|
|
108
109
|
}
|
|
@@ -112,6 +113,26 @@ async function executeCommand(command, args, configPath) {
|
|
|
112
113
|
const requirementIds = (0, output_1.collectCliFlagValues)(args, "--requirement-id");
|
|
113
114
|
const conceptIds = (0, output_1.collectCliFlagValues)(args, "--concept-id");
|
|
114
115
|
const codeHints = (0, output_1.collectCliFlagValues)(args, "--code-hint");
|
|
116
|
+
const commit = (0, output_1.readCliFlagValue)(args, "--commit");
|
|
117
|
+
const diff = (0, output_1.readCliFlagValue)(args, "--diff");
|
|
118
|
+
const testCommand = (0, output_1.readCliFlagValue)(args, "--test-command");
|
|
119
|
+
const testResultRaw = (0, output_1.readCliFlagValue)(args, "--test-result");
|
|
120
|
+
const evidenceSourceRaw = (0, output_1.readCliFlagValue)(args, "--evidence-source");
|
|
121
|
+
const repository = (0, output_1.readCliFlagValue)(args, "--repository");
|
|
122
|
+
const evidence = commit || testCommand ? {
|
|
123
|
+
...(repository ? { repository } : {}),
|
|
124
|
+
...(commit ? { commit } : {}),
|
|
125
|
+
...(diff ? { diff } : {}),
|
|
126
|
+
...(testCommand ? { testCommand } : {}),
|
|
127
|
+
testResult: testResultRaw === "pass" || testResultRaw === "fail" || testResultRaw === "unknown"
|
|
128
|
+
? testResultRaw
|
|
129
|
+
: "unknown",
|
|
130
|
+
artifacts: (0, output_1.collectCliFlagValues)(args, "--artifact"),
|
|
131
|
+
userConfirmed: args.includes("--user-confirmed"),
|
|
132
|
+
source: evidenceSourceRaw === "ci" || evidenceSourceRaw === "agent" || evidenceSourceRaw === "hook"
|
|
133
|
+
? evidenceSourceRaw
|
|
134
|
+
: "manual",
|
|
135
|
+
} : undefined;
|
|
115
136
|
const hasEngHints = requirementIds.length > 0 || conceptIds.length > 0 || codeHints.length > 0;
|
|
116
137
|
const data = await (0, runtime_1.reportOutcome)(episodeId, success, lessons, configPath, deviation, hasEngHints
|
|
117
138
|
? {
|
|
@@ -119,7 +140,7 @@ async function executeCommand(command, args, configPath) {
|
|
|
119
140
|
...(conceptIds.length > 0 ? { conceptIds } : {}),
|
|
120
141
|
...(codeHints.length > 0 ? { codeHints } : {}),
|
|
121
142
|
}
|
|
122
|
-
: undefined);
|
|
143
|
+
: undefined, evidence);
|
|
123
144
|
return {
|
|
124
145
|
command: "outcome-report",
|
|
125
146
|
data,
|
|
@@ -130,6 +151,215 @@ async function executeCommand(command, args, configPath) {
|
|
|
130
151
|
: `ok=false; reason=${data.reason ?? "unknown"}`,
|
|
131
152
|
};
|
|
132
153
|
}
|
|
154
|
+
if (command === "outcome" && args[0] === "backfill") {
|
|
155
|
+
const evidencePath = (0, output_1.readCliFlagValue)(args, "--evidence");
|
|
156
|
+
const journalPath = (0, output_1.readCliFlagValue)(args, "--journal");
|
|
157
|
+
const auditPath = (0, output_1.readCliFlagValue)(args, "--audit");
|
|
158
|
+
const actor = (0, output_1.readCliFlagValue)(args, "--actor");
|
|
159
|
+
if (!evidencePath) {
|
|
160
|
+
console.log("Usage: graphflow outcome backfill --evidence <entries.json|jsonl> [--journal <path>] [--dry-run]");
|
|
161
|
+
process.exitCode = 1;
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
const data = await (0, runtime_1.backfillOutcomeEvidence)({
|
|
165
|
+
evidencePath,
|
|
166
|
+
...(journalPath ? { journalPath } : {}),
|
|
167
|
+
...(configPath ? { configPath } : {}),
|
|
168
|
+
...(auditPath ? { auditPath } : {}),
|
|
169
|
+
...(actor ? { actor } : {}),
|
|
170
|
+
dryRun: args.includes("--dry-run"),
|
|
171
|
+
});
|
|
172
|
+
return {
|
|
173
|
+
command: "outcome-backfill",
|
|
174
|
+
data,
|
|
175
|
+
legacyText: `total=${data.total}; closed=${data.closed}; failed=${data.failed}; skipped=${data.skipped}`,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (command === "governance") {
|
|
179
|
+
const subcommand = args[0];
|
|
180
|
+
if (subcommand === "knowledge-upsert") {
|
|
181
|
+
const kind = (0, output_1.readCliFlagValue)(args, "--kind");
|
|
182
|
+
const key = (0, output_1.readCliFlagValue)(args, "--key");
|
|
183
|
+
const title = (0, output_1.readCliFlagValue)(args, "--title");
|
|
184
|
+
if (!kind || !key || !title) {
|
|
185
|
+
console.log("Usage: graphflow governance knowledge-upsert --kind <adr|invariant|api-contract|test> --key <key> --title <title> --content <text>");
|
|
186
|
+
process.exitCode = 1;
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
const versionRaw = (0, output_1.readCliFlagValue)(args, "--version");
|
|
190
|
+
const statusRaw = (0, output_1.readCliFlagValue)(args, "--status");
|
|
191
|
+
const requirementId = (0, output_1.readCliFlagValue)(args, "--requirement-id");
|
|
192
|
+
const data = await (0, runtime_1.upsertKnowledge)(configPath, {
|
|
193
|
+
kind,
|
|
194
|
+
key,
|
|
195
|
+
title,
|
|
196
|
+
content: (0, output_1.readCliFlagValue)(args, "--content") ?? "",
|
|
197
|
+
...(statusRaw === "draft" || statusRaw === "in_review" || statusRaw === "approved"
|
|
198
|
+
? { status: statusRaw }
|
|
199
|
+
: {}),
|
|
200
|
+
...(versionRaw ? { version: Number.parseInt(versionRaw, 10) } : {}),
|
|
201
|
+
sourceIds: (0, output_1.collectCliFlagValues)(args, "--source-id"),
|
|
202
|
+
...(requirementId ? { requirementId } : {}),
|
|
203
|
+
});
|
|
204
|
+
return { command: "governance-knowledge", data, legacyText: `${data.nodeId}; status=${data.record.status}` };
|
|
205
|
+
}
|
|
206
|
+
if (subcommand === "review-queue") {
|
|
207
|
+
const data = await (0, runtime_1.listKnowledgeQueue)(configPath);
|
|
208
|
+
return { command: "governance-review-queue", data, legacyText: `items=${data.length}` };
|
|
209
|
+
}
|
|
210
|
+
if (subcommand === "review") {
|
|
211
|
+
const nodeId = (0, output_1.readCliFlagValue)(args, "--node-id");
|
|
212
|
+
const decisionRaw = (0, output_1.readCliFlagValue)(args, "--decision");
|
|
213
|
+
if (!nodeId || !decisionRaw) {
|
|
214
|
+
console.log("Usage: graphflow governance review --node-id <id> --decision <approved|rejected> --role <role> --reason <text>");
|
|
215
|
+
process.exitCode = 1;
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
const data = await (0, runtime_1.reviewKnowledge)(configPath, nodeId, (0, output_1.readCliFlagValue)(args, "--role") ?? "admin", decisionRaw, (0, output_1.readCliFlagValue)(args, "--reason"));
|
|
219
|
+
return { command: "governance-review", data, legacyText: `updated=${data.updated}` };
|
|
220
|
+
}
|
|
221
|
+
if (subcommand === "trace") {
|
|
222
|
+
const requirementId = (0, output_1.readCliFlagValue)(args, "--requirement-id");
|
|
223
|
+
if (!requirementId) {
|
|
224
|
+
console.log("Usage: graphflow governance trace --requirement-id <id>");
|
|
225
|
+
process.exitCode = 1;
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
const data = await (0, runtime_1.traceRequirement)(configPath, requirementId);
|
|
229
|
+
return {
|
|
230
|
+
command: "governance-trace",
|
|
231
|
+
data,
|
|
232
|
+
legacyText: `code=${data.code.length}; tests=${data.tests.length}; governance=${data.governance.length}; episodes=${data.episodes.length}`,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
if (subcommand === "merge-artifacts") {
|
|
236
|
+
const base = (0, output_1.readCliFlagValue)(args, "--base");
|
|
237
|
+
const local = (0, output_1.readCliFlagValue)(args, "--local");
|
|
238
|
+
const remote = (0, output_1.readCliFlagValue)(args, "--remote");
|
|
239
|
+
const output = (0, output_1.readCliFlagValue)(args, "--output");
|
|
240
|
+
if (!base || !local || !remote || !output) {
|
|
241
|
+
console.log("Usage: graphflow governance merge-artifacts --base <json> --local <json> --remote <json> --output <json>");
|
|
242
|
+
process.exitCode = 1;
|
|
243
|
+
return undefined;
|
|
244
|
+
}
|
|
245
|
+
const result = (0, runtime_1.mergeArtifactFiles)(base, local, remote);
|
|
246
|
+
(0, runtime_1.writeMergedArtifact)(output, result.merged);
|
|
247
|
+
return {
|
|
248
|
+
command: "governance-merge",
|
|
249
|
+
data: { output, conflicts: result.conflicts },
|
|
250
|
+
legacyText: `nodes=${result.merged.nodes.length}; edges=${result.merged.edges.length}; conflicts=${result.conflicts.length}`,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (subcommand === "sign-artifact") {
|
|
254
|
+
const input = (0, output_1.readCliFlagValue)(args, "--input");
|
|
255
|
+
const secret = (0, output_1.readCliFlagValue)(args, "--secret");
|
|
256
|
+
if (!input || !secret) {
|
|
257
|
+
console.log("Usage: graphflow governance sign-artifact --input <artifact.json> --secret <passphrase> --output <signature.json>");
|
|
258
|
+
process.exitCode = 1;
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
const signature = (0, runtime_1.signArtifactFile)(input, secret);
|
|
262
|
+
const outputPath = (0, output_1.readCliFlagValue)(args, "--output") ?? `${input}.sig.json`;
|
|
263
|
+
(0, runtime_1.writeMergedArtifact)(outputPath, signature);
|
|
264
|
+
return { command: "governance-sign", data: { outputPath, signature }, legacyText: `algorithm=${signature.algorithm}` };
|
|
265
|
+
}
|
|
266
|
+
if (subcommand === "encrypted-artifact-export") {
|
|
267
|
+
const output = (0, output_1.readCliFlagValue)(args, "--output");
|
|
268
|
+
const passphrase = (0, output_1.readCliFlagValue)(args, "--passphrase");
|
|
269
|
+
if (!output || !passphrase) {
|
|
270
|
+
console.log("Usage: graphflow governance encrypted-artifact-export --output <artifact.enc.json> --passphrase <secret>");
|
|
271
|
+
process.exitCode = 1;
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
274
|
+
const data = (0, runtime_1.createSignedArtifactFile)(configPath, output, passphrase);
|
|
275
|
+
return { command: "governance-encrypted-export", data, legacyText: `path=${data.path}; nodes=${data.nodeCount}` };
|
|
276
|
+
}
|
|
277
|
+
if (subcommand === "encrypted-artifact-import") {
|
|
278
|
+
const input = (0, output_1.readCliFlagValue)(args, "--input");
|
|
279
|
+
const passphrase = (0, output_1.readCliFlagValue)(args, "--passphrase");
|
|
280
|
+
if (!input || !passphrase) {
|
|
281
|
+
console.log("Usage: graphflow governance encrypted-artifact-import --input <artifact.enc.json> --passphrase <secret>");
|
|
282
|
+
process.exitCode = 1;
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
const data = await (0, runtime_1.importSignedArtifactFile)(configPath, input, passphrase);
|
|
286
|
+
return { command: "governance-encrypted-import", data, legacyText: `nodes=${data.nodeCount}; edges=${data.edgeCount}` };
|
|
287
|
+
}
|
|
288
|
+
if (subcommand === "verify-artifact-signature") {
|
|
289
|
+
const input = (0, output_1.readCliFlagValue)(args, "--input");
|
|
290
|
+
const signaturePath = (0, output_1.readCliFlagValue)(args, "--signature");
|
|
291
|
+
const secret = (0, output_1.readCliFlagValue)(args, "--secret");
|
|
292
|
+
if (!input || !signaturePath || !secret) {
|
|
293
|
+
console.log("Usage: graphflow governance verify-artifact-signature --input <artifact.json> --signature <sig.json> --secret <passphrase>");
|
|
294
|
+
process.exitCode = 1;
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
const payload = JSON.parse((0, node_fs_1.readFileSync)(input, "utf8"));
|
|
298
|
+
const expected = (0, runtime_1.signArtifactFile)(input, secret);
|
|
299
|
+
const supplied = JSON.parse((0, node_fs_1.readFileSync)(signaturePath, "utf8"));
|
|
300
|
+
const valid = (0, runtime_1.verifyArtifactSignature)(payload, supplied.signature ?? "", secret) &&
|
|
301
|
+
expected.signature === supplied.signature;
|
|
302
|
+
return { command: "governance-verify", data: { valid }, legacyText: `valid=${valid}` };
|
|
303
|
+
}
|
|
304
|
+
if (subcommand === "quarantine") {
|
|
305
|
+
const ids = (0, output_1.collectCliFlagValues)(args, "--id");
|
|
306
|
+
if (ids.length === 0) {
|
|
307
|
+
console.log("Usage: graphflow governance quarantine --id <node-id>... [--reason <text>] [--audit <path>]");
|
|
308
|
+
process.exitCode = 1;
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
const actor = (0, output_1.readCliFlagValue)(args, "--actor");
|
|
312
|
+
const auditPath = (0, output_1.readCliFlagValue)(args, "--audit");
|
|
313
|
+
const reason = (0, output_1.readCliFlagValue)(args, "--reason");
|
|
314
|
+
const data = await (0, runtime_1.quarantineNodes)(configPath, ids, {
|
|
315
|
+
...(actor ? { actor } : {}),
|
|
316
|
+
...(auditPath ? { auditPath } : {}),
|
|
317
|
+
...(reason ? { reason } : {}),
|
|
318
|
+
});
|
|
319
|
+
return { command: "governance-quarantine", data, legacyText: `quarantined=${data.quarantined.length}; auditValid=${data.auditValid}` };
|
|
320
|
+
}
|
|
321
|
+
if (subcommand === "retention") {
|
|
322
|
+
const data = (0, runtime_1.retentionSummary)(configPath);
|
|
323
|
+
return { command: "governance-retention", data, legacyText: `retained=${data.retained.length}; expired=${data.expired.length}` };
|
|
324
|
+
}
|
|
325
|
+
if (subcommand === "profiles") {
|
|
326
|
+
const outputDir = (0, output_1.readCliFlagValue)(args, "--output-dir") ?? "graphflow-out/memory-profiles";
|
|
327
|
+
const httpUrl = (0, output_1.readCliFlagValue)(args, "--http-url");
|
|
328
|
+
const packageSpec = (0, output_1.readCliFlagValue)(args, "--package-spec");
|
|
329
|
+
const files = (0, runtime_1.exportMemoryProfiles)({
|
|
330
|
+
outputDir,
|
|
331
|
+
...(httpUrl ? { httpUrl } : {}),
|
|
332
|
+
stateful: args.includes("--stateful"),
|
|
333
|
+
...(packageSpec ? { packageSpec } : {}),
|
|
334
|
+
});
|
|
335
|
+
return { command: "governance-profiles", data: files, legacyText: Object.keys(files).join(",") };
|
|
336
|
+
}
|
|
337
|
+
if (subcommand === "release-gate") {
|
|
338
|
+
const minProvenSkills = Number.parseInt((0, output_1.readCliFlagValue)(args, "--min-proven-skills") ?? "1", 10);
|
|
339
|
+
const minFidelitySamples = Number.parseInt((0, output_1.readCliFlagValue)(args, "--min-fidelity-samples") ?? "1", 10);
|
|
340
|
+
const maxPendingRatio = Number.parseFloat((0, output_1.readCliFlagValue)(args, "--max-pending-ratio") ?? "0.5");
|
|
341
|
+
try {
|
|
342
|
+
const data = (0, runtime_1.releaseGate)(configPath, {
|
|
343
|
+
minProvenSkills,
|
|
344
|
+
minFidelitySamples,
|
|
345
|
+
maxPendingRatio,
|
|
346
|
+
});
|
|
347
|
+
return {
|
|
348
|
+
command: "governance-release-gate",
|
|
349
|
+
data,
|
|
350
|
+
legacyText: "release gates passed",
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
catch (error) {
|
|
354
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
355
|
+
process.exitCode = 1;
|
|
356
|
+
return undefined;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
console.log("Usage: graphflow governance <knowledge-upsert|review-queue|review|trace|merge-artifacts|sign-artifact|verify-artifact-signature|quarantine|retention|profiles|release-gate>");
|
|
360
|
+
process.exitCode = 1;
|
|
361
|
+
return undefined;
|
|
362
|
+
}
|
|
133
363
|
if (command === "insight" && args[0] === "submit") {
|
|
134
364
|
const task = (0, output_1.readCliFlagValue)(args, "--task") ??
|
|
135
365
|
(0, output_1.readCliFlagValue)(args, "--task-text");
|
|
@@ -647,10 +877,22 @@ async function executeCommand(command, args, configPath) {
|
|
|
647
877
|
const limitRaw = (0, output_1.readCliFlagValue)(args, "--limit");
|
|
648
878
|
const limit = limitRaw ? Number(limitRaw) : undefined;
|
|
649
879
|
if (limit !== undefined && (!Number.isInteger(limit) || limit <= 0)) {
|
|
650
|
-
console.log("Usage: graphflow dialogue list [--session <name|id>] [--limit N] [--json] [--config <path>]");
|
|
880
|
+
console.log("Usage: graphflow dialogue list [--session <name|id>] [--limit N] [--path <turnId>] [--json] [--config <path>]");
|
|
651
881
|
process.exitCode = 1;
|
|
652
882
|
return undefined;
|
|
653
883
|
}
|
|
884
|
+
const pathTurnId = (0, output_1.readCliFlagValue)(args, "--path");
|
|
885
|
+
if (pathTurnId) {
|
|
886
|
+
const steps = await (0, runtime_1.dialoguePathRuntime)(pathTurnId, {
|
|
887
|
+
...(configPath ? { configPath } : {}),
|
|
888
|
+
...(limit !== undefined ? { limit } : {}),
|
|
889
|
+
});
|
|
890
|
+
return {
|
|
891
|
+
command: "dialogue-path",
|
|
892
|
+
data: steps,
|
|
893
|
+
legacyText: formatDialoguePath(steps),
|
|
894
|
+
};
|
|
895
|
+
}
|
|
654
896
|
const sessionId = (0, output_1.readCliFlagValue)(args, "--session");
|
|
655
897
|
const data = await (0, runtime_1.listDialogueTurnsRuntime)(configPath, {
|
|
656
898
|
...(sessionId ? { sessionId } : {}),
|
|
@@ -662,6 +904,61 @@ async function executeCommand(command, args, configPath) {
|
|
|
662
904
|
legacyText: formatDialogueList(data),
|
|
663
905
|
};
|
|
664
906
|
}
|
|
907
|
+
if (command === "dialogue" && args[0] === "fork") {
|
|
908
|
+
const fromTurnId = (0, output_1.readCliFlagValue)(args, "--from");
|
|
909
|
+
if (!fromTurnId) {
|
|
910
|
+
console.log("Usage: graphflow dialogue fork --from <turnId> [--name <sessionName>] [--json] [--config <path>]");
|
|
911
|
+
process.exitCode = 1;
|
|
912
|
+
return undefined;
|
|
913
|
+
}
|
|
914
|
+
const forkName = (0, output_1.readCliFlagValue)(args, "--name");
|
|
915
|
+
const data = await (0, runtime_1.forkDialogueSessionRuntime)(fromTurnId, {
|
|
916
|
+
...(configPath ? { configPath } : {}),
|
|
917
|
+
...(forkName ? { forkName } : {}),
|
|
918
|
+
});
|
|
919
|
+
return {
|
|
920
|
+
command: "dialogue-fork",
|
|
921
|
+
data,
|
|
922
|
+
legacyText: data
|
|
923
|
+
? `forkedSession=${data.forkedSessionName}; sourceTurn=${data.sourceTurnId}; copiedTurns=${data.copiedTurns}`
|
|
924
|
+
: "not-found",
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
if (command === "dialogue" && args[0] === "traces") {
|
|
928
|
+
const limitRaw = (0, output_1.readCliFlagValue)(args, "--limit");
|
|
929
|
+
const limit = limitRaw ? Number(limitRaw) : undefined;
|
|
930
|
+
const sessionId = (0, output_1.readCliFlagValue)(args, "--session");
|
|
931
|
+
const data = await (0, runtime_1.listDialogueTracesRuntime)(configPath, {
|
|
932
|
+
...(sessionId ? { sessionId } : {}),
|
|
933
|
+
...(limit !== undefined ? { limit } : {}),
|
|
934
|
+
});
|
|
935
|
+
return {
|
|
936
|
+
command: "dialogue-traces",
|
|
937
|
+
data,
|
|
938
|
+
legacyText: formatDialogueTraces(data),
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
if (command === "dialogue" && args[0] === "search") {
|
|
942
|
+
const query = (0, output_1.readCliFlagValue)(args, "--query")
|
|
943
|
+
?? args.slice(1).filter((part) => part !== "--include-superseded" && !part.startsWith("--")).join(" ").trim();
|
|
944
|
+
if (!query) {
|
|
945
|
+
console.log('Usage: graphflow dialogue search "<query>" [--limit N] [--include-superseded] [--json] [--config <path>]');
|
|
946
|
+
process.exitCode = 1;
|
|
947
|
+
return undefined;
|
|
948
|
+
}
|
|
949
|
+
const limitRaw = (0, output_1.readCliFlagValue)(args, "--limit");
|
|
950
|
+
const limit = limitRaw ? Number(limitRaw) : undefined;
|
|
951
|
+
const data = await (0, runtime_1.searchDialogueTurnsRuntime)(query, {
|
|
952
|
+
...(configPath ? { configPath } : {}),
|
|
953
|
+
...(limit !== undefined ? { limit } : {}),
|
|
954
|
+
...(args.includes("--include-superseded") ? { includeSuperseded: true } : {}),
|
|
955
|
+
});
|
|
956
|
+
return {
|
|
957
|
+
command: "dialogue-search",
|
|
958
|
+
data,
|
|
959
|
+
legacyText: formatDialogueSearch(data),
|
|
960
|
+
};
|
|
961
|
+
}
|
|
665
962
|
if (command === "dialogue" && args[0] === "record") {
|
|
666
963
|
const input = (0, runtime_1.resolveDialogueRecordInput)(args);
|
|
667
964
|
const query = input.query;
|
|
@@ -700,9 +997,11 @@ async function executeCommand(command, args, configPath) {
|
|
|
700
997
|
}
|
|
701
998
|
if (command === "dialogue" && args[0] === "distill") {
|
|
702
999
|
const all = args.includes("--all");
|
|
1000
|
+
const useLlm = args.includes("--llm");
|
|
703
1001
|
const sessionId = (0, output_1.readCliFlagValue)(args, "--session");
|
|
704
1002
|
const data = await (0, runtime_1.distillDialogueTurnsRuntime)(configPath, {
|
|
705
1003
|
...(all ? { all: true } : {}),
|
|
1004
|
+
...(useLlm ? { useLlm: true } : {}),
|
|
706
1005
|
...(sessionId ? { sessionId } : {}),
|
|
707
1006
|
});
|
|
708
1007
|
return {
|
|
@@ -742,6 +1041,37 @@ function formatDialogueList(items) {
|
|
|
742
1041
|
function formatDialogueDistill(data) {
|
|
743
1042
|
return `updated=${data.updated}; unchanged=${data.unchanged}; total=${data.total}`;
|
|
744
1043
|
}
|
|
1044
|
+
function formatDialoguePath(steps) {
|
|
1045
|
+
const lines = [`steps=${steps.length}`];
|
|
1046
|
+
for (const step of steps) {
|
|
1047
|
+
const fork = step.forkBoundary ? " [fork]" : "";
|
|
1048
|
+
const jump = step.jumped ? " jump" : "";
|
|
1049
|
+
const stale = step.invalidAt !== undefined ? " (superseded)" : "";
|
|
1050
|
+
lines.push(`seq=${step.seq}${fork}${jump}${stale}; q=${step.userQuery}; a=${step.assistantReply || "(pending)"}`);
|
|
1051
|
+
}
|
|
1052
|
+
return lines.join("\n");
|
|
1053
|
+
}
|
|
1054
|
+
function formatDialogueTraces(traces) {
|
|
1055
|
+
const lines = [`count=${traces.length}`];
|
|
1056
|
+
for (const trace of traces) {
|
|
1057
|
+
lines.push(`turn#${trace.turnSeq} ${trace.agentKind}:${trace.status} ${trace.label}; at=${new Date(trace.createdAt).toISOString()}`);
|
|
1058
|
+
}
|
|
1059
|
+
return lines.join("\n");
|
|
1060
|
+
}
|
|
1061
|
+
function formatDialogueSearch(hits) {
|
|
1062
|
+
const lines = [`hits=${hits.length}`];
|
|
1063
|
+
for (const hit of hits) {
|
|
1064
|
+
const stale = hit.superseded ? " (superseded)" : "";
|
|
1065
|
+
lines.push(`seq=${hit.seq}${stale}; q=${hit.userQuery}`);
|
|
1066
|
+
if (hit.title)
|
|
1067
|
+
lines.push(` title=${hit.title}`);
|
|
1068
|
+
if (hit.summary)
|
|
1069
|
+
lines.push(` a=${hit.summary}`);
|
|
1070
|
+
if (hit.correctionLine)
|
|
1071
|
+
lines.push(` ${hit.correctionLine}`);
|
|
1072
|
+
}
|
|
1073
|
+
return lines.join("\n");
|
|
1074
|
+
}
|
|
745
1075
|
function formatValidationResult(data) {
|
|
746
1076
|
const lines = [
|
|
747
1077
|
`configPath=${data.configPath}`,
|