@agentsky/sky 3.48.2 → 3.49.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/dist/{chunk-W24YSGH4.js → chunk-2YUZZ5VG.js} +7 -856
- package/dist/{chunk-ZRV3UUW5.js → chunk-6LRSRXQI.js} +1 -1
- package/dist/{chunk-PGX3AGCZ.js → chunk-7JFTEJ7B.js} +1 -1
- package/dist/chunk-BKNZQZZD.js +857 -0
- package/dist/{chunk-RKMMLSGJ.js → chunk-CK7N635F.js} +1 -1
- package/dist/{chunk-NAIYHS6Q.js → chunk-HFWHVU72.js} +2 -1
- package/dist/{chunk-A45NGV2Q.js → chunk-HGL7TLNA.js} +2 -2
- package/dist/{chunk-ZF2P6PKM.js → chunk-HNUY5PBQ.js} +2 -2
- package/dist/{chunk-OJ5ERABF.js → chunk-IO2N34S2.js} +1 -1
- package/dist/{chunk-UJS4JIE2.js → chunk-JMGVHVOS.js} +10 -10
- package/dist/{chunk-CV2ZRIF7.js → chunk-QTE5OMZY.js} +4 -4
- package/dist/{chunk-FVIPGI3E.js → chunk-RVI7ZWR2.js} +5 -5
- package/dist/chunk-TGU7T4O7.js +1363 -0
- package/dist/{chunk-NJPIE762.js → chunk-UYBKORXA.js} +43 -24
- package/dist/chunk-YO2XUCCF.js +30 -0
- package/dist/{chunk-6D36IT7T.js → chunk-ZOXE2XNH.js} +2 -2
- package/dist/{compute-AERPKXJ3.js → compute-4MMGFJGE.js} +2 -2
- package/dist/{compute-report-CTT4WBSQ.js → compute-report-LIMMRQY3.js} +15 -13
- package/dist/grok-bot-export-7LSTXWJW.js +57 -0
- package/dist/index.js +599 -1770
- package/dist/{local-skills-E56TR7O6.js → local-skills-5LJST7EP.js} +3 -3
- package/dist/{local-skills-run-TST44QSA.js → local-skills-run-6SZJQSVF.js} +9 -9
- package/dist/{mcp-register-HDOVT4QT.js → mcp-register-XY4MR3ZZ.js} +3 -3
- package/dist/{mcp-serve-2LBAEAJX.js → mcp-serve-QROKKUJV.js} +6 -6
- package/dist/{trace-S2XZC75N.js → trace-SJZ25T35.js} +4 -3
- package/dist/{trace-exclusions-JEGMUPWQ.js → trace-exclusions-IC6OA2ND.js} +3 -2
- package/dist/trace-handoff-CD5LOS7B.js +116 -0
- package/dist/{trace-library-HN5TU5EJ.js → trace-library-V23TEXG4.js} +14 -8
- package/dist/trace-privacy-DU3TL5EO.js +11 -0
- package/package.json +1 -1
- package/vendor/trace-collect/SOURCE.json +2 -1
- package/vendor/trace-collect/sources/_pii.mjs +56 -0
- package/vendor/trace-collect/sources/grok-bot.mjs +180 -0
- package/vendor/trace-collect/sources/index.mjs +4 -2
- package/vendor/trace-collect/sources/muse-agent.mjs +95 -0
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
turnOffLocalSkills,
|
|
13
13
|
turnOnLocalSkills,
|
|
14
14
|
unpinLocalSkill
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-HNUY5PBQ.js";
|
|
16
|
+
import "./chunk-7JFTEJ7B.js";
|
|
17
17
|
import "./chunk-XHZJG3QT.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-6LRSRXQI.js";
|
|
19
19
|
import "./chunk-MLKGABMK.js";
|
|
20
20
|
export {
|
|
21
21
|
checkedWithin,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SetupJournal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZOXE2XNH.js";
|
|
4
4
|
import {
|
|
5
5
|
workspaceSlug
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-HGL7TLNA.js";
|
|
7
|
+
import "./chunk-HFWHVU72.js";
|
|
8
8
|
import {
|
|
9
9
|
detectHermes
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CK7N635F.js";
|
|
11
11
|
import {
|
|
12
12
|
detectLocalAgents
|
|
13
13
|
} from "./chunk-2H4W5ZKZ.js";
|
|
@@ -16,17 +16,17 @@ import {
|
|
|
16
16
|
loadLocalSkillState,
|
|
17
17
|
skillTargets,
|
|
18
18
|
syncLocalSkills
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-HNUY5PBQ.js";
|
|
20
|
+
import "./chunk-7JFTEJ7B.js";
|
|
21
21
|
import "./chunk-XHZJG3QT.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-6LRSRXQI.js";
|
|
23
23
|
import "./chunk-MLKGABMK.js";
|
|
24
24
|
|
|
25
25
|
// src/local-skills-run.ts
|
|
26
26
|
var HOOK_RECHECK_MS = 5 * 60 * 1e3;
|
|
27
27
|
async function localSkillWorkspace(explicit) {
|
|
28
28
|
if (explicit) return explicit;
|
|
29
|
-
const { loadSyncConfig } = await import("./trace-library-
|
|
29
|
+
const { loadSyncConfig } = await import("./trace-library-V23TEXG4.js");
|
|
30
30
|
return loadSyncConfig().fallback ?? await workspaceSlug();
|
|
31
31
|
}
|
|
32
32
|
async function refreshLocalSkills(opts = {}) {
|
|
@@ -36,7 +36,7 @@ async function refreshLocalSkills(opts = {}) {
|
|
|
36
36
|
const targets = skillTargets(detectLocalAgents(), hermes?.root ?? null);
|
|
37
37
|
const workspace = await localSkillWorkspace(opts.workspace);
|
|
38
38
|
if (!targets.length) return { workspace, checked: false, skills: [] };
|
|
39
|
-
const { libraryRequest } = await import("./trace-library-
|
|
39
|
+
const { libraryRequest } = await import("./trace-library-V23TEXG4.js");
|
|
40
40
|
const journal = opts.dryRun ? void 0 : new SetupJournal();
|
|
41
41
|
try {
|
|
42
42
|
return await syncLocalSkills({ workspace, targets, journal, dryRun: opts.dryRun, request: (method, path, slug) => libraryRequest(method, path, slug) });
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
registeredToolList,
|
|
16
16
|
systemCommandRunner,
|
|
17
17
|
withoutTomlServer
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-CK7N635F.js";
|
|
19
19
|
import "./chunk-2H4W5ZKZ.js";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-7JFTEJ7B.js";
|
|
21
|
+
import "./chunk-6LRSRXQI.js";
|
|
22
22
|
import "./chunk-MLKGABMK.js";
|
|
23
23
|
export {
|
|
24
24
|
MCP_SERVER_NAME,
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
forwardLine,
|
|
3
3
|
serveMcp,
|
|
4
4
|
shortToolCount
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-QTE5OMZY.js";
|
|
6
|
+
import "./chunk-HGL7TLNA.js";
|
|
7
|
+
import "./chunk-HFWHVU72.js";
|
|
8
|
+
import "./chunk-CK7N635F.js";
|
|
9
9
|
import "./chunk-2H4W5ZKZ.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-7JFTEJ7B.js";
|
|
11
11
|
import "./chunk-XHZJG3QT.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-6LRSRXQI.js";
|
|
13
13
|
import "./chunk-MLKGABMK.js";
|
|
14
14
|
export {
|
|
15
15
|
forwardLine,
|
|
@@ -22,10 +22,11 @@ import {
|
|
|
22
22
|
traceDir,
|
|
23
23
|
uninstallClaudeHooks,
|
|
24
24
|
writeState
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-RVI7ZWR2.js";
|
|
26
|
+
import "./chunk-2YUZZ5VG.js";
|
|
27
|
+
import "./chunk-BKNZQZZD.js";
|
|
26
28
|
import "./chunk-XHZJG3QT.js";
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-W24YSGH4.js";
|
|
29
|
+
import "./chunk-6LRSRXQI.js";
|
|
29
30
|
import "./chunk-MLKGABMK.js";
|
|
30
31
|
export {
|
|
31
32
|
BATCH_MAX,
|
|
@@ -6,8 +6,9 @@ import {
|
|
|
6
6
|
loadExclusions,
|
|
7
7
|
macSettingsPath,
|
|
8
8
|
stillExcluded
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-IO2N34S2.js";
|
|
10
|
+
import "./chunk-2YUZZ5VG.js";
|
|
11
|
+
import "./chunk-BKNZQZZD.js";
|
|
11
12
|
import "./chunk-MLKGABMK.js";
|
|
12
13
|
export {
|
|
13
14
|
changeExclusions,
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeConversation
|
|
3
|
+
} from "./chunk-TGU7T4O7.js";
|
|
4
|
+
import {
|
|
5
|
+
describeFindings,
|
|
6
|
+
privateHold
|
|
7
|
+
} from "./chunk-YO2XUCCF.js";
|
|
8
|
+
import "./chunk-BKNZQZZD.js";
|
|
9
|
+
import "./chunk-MLKGABMK.js";
|
|
10
|
+
|
|
11
|
+
// src/trace-handoff.ts
|
|
12
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
13
|
+
import { homedir } from "os";
|
|
14
|
+
import { dirname, join, resolve } from "path";
|
|
15
|
+
import { pathToFileURL } from "url";
|
|
16
|
+
var HANDOFF_TARGETS = ["claude_code", "codex", "agentsky", "grok-bot"];
|
|
17
|
+
function args(input) {
|
|
18
|
+
return input && typeof input === "object" && !Array.isArray(input) ? input : input === void 0 || input === null ? {} : { input };
|
|
19
|
+
}
|
|
20
|
+
function handoffNote(trace, transcript) {
|
|
21
|
+
const lines = [
|
|
22
|
+
`[Handoff from ${trace.harness}] This conversation was recorded by another agent (${trace.harness}${trace.title ? `: "${trace.title}"` : ""}, ${trace.messages.length} messages${trace.started_at ? `, from ${trace.started_at}` : ""}${trace.ended_at ? ` to ${trace.ended_at}` : ""}) and continues below in full, as it was written. Read it before you act, then reconcile the latest request with what was already done.`
|
|
23
|
+
];
|
|
24
|
+
for (const limit of trace.provenance?.limitations ?? []) lines.push(`Recording limit: ${limit}`);
|
|
25
|
+
if (trace.sensitive) lines.push(`It holds personal data (${describeFindings(trace.privacy)}): do not copy it into shared places.`);
|
|
26
|
+
if (transcript) lines.push(`Full transcript as collected: ${transcript}`);
|
|
27
|
+
return lines.join("\n");
|
|
28
|
+
}
|
|
29
|
+
function traceConversation(trace, opts = {}) {
|
|
30
|
+
const messages = [];
|
|
31
|
+
const owners = /* @__PURE__ */ new Map();
|
|
32
|
+
let clock = trace.started_at ?? (opts.now ?? /* @__PURE__ */ new Date()).toISOString();
|
|
33
|
+
const open = (role, at) => {
|
|
34
|
+
if (at) clock = at;
|
|
35
|
+
const message = { id: `m${messages.length}`, role, created_at: at ?? clock, parts: [], metadata: { engine: trace.harness } };
|
|
36
|
+
messages.push(message);
|
|
37
|
+
return message;
|
|
38
|
+
};
|
|
39
|
+
const add = (message, part) => {
|
|
40
|
+
message.parts.push({ ...part, index: message.parts.length });
|
|
41
|
+
};
|
|
42
|
+
if (opts.note !== false) add(open("user"), { type: "text", text: handoffNote(trace, opts.transcript ?? null) });
|
|
43
|
+
for (const entry of trace.messages) {
|
|
44
|
+
if (entry.role === "user") {
|
|
45
|
+
if (entry.text) add(open("user", entry.ts), { type: "text", text: entry.text });
|
|
46
|
+
} else if (entry.role === "assistant") {
|
|
47
|
+
const message = open("agent", entry.ts);
|
|
48
|
+
if (entry.text) add(message, { type: "text", text: entry.text });
|
|
49
|
+
for (const call of entry.tool_calls ?? []) {
|
|
50
|
+
add(message, { type: "tool_call", call_id: call.id, tool_name: call.name, args: args(call.input) });
|
|
51
|
+
owners.set(call.id, message);
|
|
52
|
+
}
|
|
53
|
+
if (!message.parts.length) messages.pop();
|
|
54
|
+
} else if (entry.role === "tool") {
|
|
55
|
+
const owner = entry.tool_use_id ? owners.get(entry.tool_use_id) : void 0;
|
|
56
|
+
if (owner) {
|
|
57
|
+
add(owner, { type: "tool_result", call_id: entry.tool_use_id, tool_name: entry.tool_name ?? "tool", status: entry.is_error ? "error" : "ok", result: { output: entry.text ?? "" } });
|
|
58
|
+
owners.delete(entry.tool_use_id);
|
|
59
|
+
} else if (entry.text) {
|
|
60
|
+
const last = messages.at(-1);
|
|
61
|
+
const target = last && last.role === "agent" ? last : open("agent", entry.ts);
|
|
62
|
+
add(target, { type: "text", text: `[A ${entry.tool_name ?? "tool"} result whose call was not recorded: ${entry.text}]` });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { engine: trace.harness, nativeId: null, cwd: trace.cwd || null, model: trace.model || null, messages };
|
|
67
|
+
}
|
|
68
|
+
async function findTrace(ref, store, collectorDir) {
|
|
69
|
+
const candidates = [];
|
|
70
|
+
if (existsSync(ref) && lstatSync(ref).isFile()) candidates.push(resolve(ref));
|
|
71
|
+
else if (existsSync(store)) {
|
|
72
|
+
for (const dir of readdirSync(store, { withFileTypes: true })) {
|
|
73
|
+
if (!dir.isDirectory()) continue;
|
|
74
|
+
const file = join(store, dir.name, `${ref.replace(/[^\w.-]+/g, "_")}.json`);
|
|
75
|
+
if (existsSync(file)) candidates.push(file);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const file of candidates) {
|
|
79
|
+
try {
|
|
80
|
+
const trace = JSON.parse(readFileSync(file, "utf8"));
|
|
81
|
+
if (trace.format === "trace/v1" && Array.isArray(trace.messages)) return { path: file, trace };
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (collectorDir && candidates.length === 1 && existsSync(candidates[0])) {
|
|
86
|
+
try {
|
|
87
|
+
const { normalizeAny } = await import(pathToFileURL(join(collectorDir, "normalize.mjs")).href);
|
|
88
|
+
const trace = normalizeAny(readFileSync(candidates[0], "utf8"), candidates[0]);
|
|
89
|
+
if (trace.messages?.length) return { path: candidates[0], trace };
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function handOff(trace, engine, folder, opts = {}) {
|
|
96
|
+
const conversation = traceConversation(trace, { transcript: opts.transcript, now: opts.now });
|
|
97
|
+
const session = writeConversation(engine, conversation, { cwd: folder, now: opts.now });
|
|
98
|
+
const root = opts.home ?? (engine === "codex" ? process.env.CODEX_HOME || join(homedir(), ".codex") : process.env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"));
|
|
99
|
+
const target = join(root, session.path);
|
|
100
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
101
|
+
if (existsSync(target)) renameSync(target, `${target}.before-agentsky-${Date.now()}`);
|
|
102
|
+
writeFileSync(target, session.content, { mode: 384 });
|
|
103
|
+
mkdirSync(folder, { recursive: true });
|
|
104
|
+
return { target: engine, engine, nativeId: session.nativeId, folder, file: target, resume: `cd ${JSON.stringify(folder)} && ${session.resume.replace(/^cd [^&]*&& /, "")}`, report: session.report };
|
|
105
|
+
}
|
|
106
|
+
function agentskyHold(trace, workspace, config, allowShared = false) {
|
|
107
|
+
return privateHold({ ...trace }, workspace ?? "", config, allowShared);
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
HANDOFF_TARGETS,
|
|
111
|
+
agentskyHold,
|
|
112
|
+
findTrace,
|
|
113
|
+
handOff,
|
|
114
|
+
handoffNote,
|
|
115
|
+
traceConversation
|
|
116
|
+
};
|
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
SYNC_STATE_NAMES,
|
|
5
5
|
capturePaused,
|
|
6
6
|
collectorBody,
|
|
7
|
+
collectorDir,
|
|
7
8
|
collectorHarness,
|
|
9
|
+
collectorStore,
|
|
8
10
|
discoverSessions,
|
|
9
11
|
hookSessionRef,
|
|
10
12
|
importExport,
|
|
@@ -29,15 +31,17 @@ import {
|
|
|
29
31
|
syncConfigPath,
|
|
30
32
|
syncDir,
|
|
31
33
|
syncTraces
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import "./chunk-
|
|
36
|
-
import "./chunk-
|
|
34
|
+
} from "./chunk-UYBKORXA.js";
|
|
35
|
+
import "./chunk-IO2N34S2.js";
|
|
36
|
+
import "./chunk-HFWHVU72.js";
|
|
37
|
+
import "./chunk-YO2XUCCF.js";
|
|
38
|
+
import "./chunk-RVI7ZWR2.js";
|
|
39
|
+
import "./chunk-2YUZZ5VG.js";
|
|
40
|
+
import "./chunk-BKNZQZZD.js";
|
|
41
|
+
import "./chunk-HNUY5PBQ.js";
|
|
42
|
+
import "./chunk-7JFTEJ7B.js";
|
|
37
43
|
import "./chunk-XHZJG3QT.js";
|
|
38
|
-
import "./chunk-
|
|
39
|
-
import "./chunk-OJ5ERABF.js";
|
|
40
|
-
import "./chunk-W24YSGH4.js";
|
|
44
|
+
import "./chunk-6LRSRXQI.js";
|
|
41
45
|
import "./chunk-MLKGABMK.js";
|
|
42
46
|
export {
|
|
43
47
|
LAUNCHD_LABEL,
|
|
@@ -45,7 +49,9 @@ export {
|
|
|
45
49
|
SYNC_STATE_NAMES,
|
|
46
50
|
capturePaused,
|
|
47
51
|
collectorBody,
|
|
52
|
+
collectorDir,
|
|
48
53
|
collectorHarness,
|
|
54
|
+
collectorStore,
|
|
49
55
|
discoverSessions,
|
|
50
56
|
hookSessionRef,
|
|
51
57
|
importExport,
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"commit": "73cd14fe234439c1a81cb44e82f05577ad1ec2ce",
|
|
5
5
|
"dirty": false,
|
|
6
6
|
"local_patches": [
|
|
7
|
-
"Full per-session native source references, Hermes state.db (including profiles) and DSH/Cursor sidecars; lossless normalization of tool outputs; include small sessions. Upstream repository was unavailable during takeover."
|
|
7
|
+
"Full per-session native source references, Hermes state.db (including profiles) and DSH/Cursor sidecars; lossless normalization of tool outputs; include small sessions. Upstream repository was unavailable during takeover.",
|
|
8
|
+
"Added the grok-bot export adapter (sources/grok-bot.mjs) and the personal-data detector (sources/_pii.mjs); writeSessions reports sessions that hold personal data."
|
|
8
9
|
]
|
|
9
10
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Personal-data detector for traces whose source redaction does not cover private life (passport, medical, insurance,
|
|
2
|
+
// phone numbers, addresses, government and financial identifiers). It counts findings per category and never keeps a
|
|
3
|
+
// matched value, so its report is safe to print and to store beside the session.
|
|
4
|
+
|
|
5
|
+
const luhn = (digits) => {
|
|
6
|
+
let sum = 0;
|
|
7
|
+
for (let i = 0; i < digits.length; i++) {
|
|
8
|
+
let d = Number(digits[digits.length - 1 - i]);
|
|
9
|
+
if (i % 2) { d *= 2; if (d > 9) d -= 9; }
|
|
10
|
+
sum += d;
|
|
11
|
+
}
|
|
12
|
+
return sum % 10 === 0;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const CATEGORIES = {
|
|
16
|
+
passport_immigration: /\b(passports?|visas?|green ?card|i-?94|i-?20|i-?765|i-?485|uscis|immigration|work permit|ead card|naturali[sz]ation)\b|护照|签证|绿卡|入境|移民局|工卡/i,
|
|
17
|
+
medical: /\b(medical|doctor|clinic|hospital|diagnos\w*|symptoms?|prescriptions?|medications?|therapy|therapist|blood test|lab results?|surgery|physical exam|vaccin\w*|allerg\w*|pregnan\w*|dermatolog\w*|dentist)\b|体检|查体|医生|医院|看病|吃药|病历|处方|诊断|手术|疫苗|过敏/i,
|
|
18
|
+
insurance: /\b(insurance|policy (number|no\.?)|member id|group (number|id)|claims?|deductibles?|co-?pays?|premiums?|aetna|cigna|kaiser|blue cross|anthem|united ?health)\b|保险|保单|理赔/i,
|
|
19
|
+
phone: /(?<![\d.])(?:\+\d{1,3}[\s.-]?)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}(?!\d)|(?<![\d.])\+\d{1,3}[\s-]?\d{6,12}(?!\d)|(?<![\d.])1[3-9]\d{9}(?!\d)/,
|
|
20
|
+
address: /\b\d{1,6}\s+[A-Za-z0-9.' ]{2,30}\s(?:st|street|ave|avenue|rd|road|blvd|boulevard|dr|drive|ln|lane|ct|court|way|pl|place|apt|unit|suite)\b\.?|\b[A-Z]{2}\s\d{5}(?:-\d{4})?\b|\d+\s*(?:号楼|号院|栋|单元|弄)|[一-龥]{2,}(?:路|街|大道)\d+号/i,
|
|
21
|
+
government_id: /\b\d{3}-\d{2}-\d{4}\b|\b(?:ssn|social security|driver'?s? licen[sc]e|tax id|itin|a-?number|身份证|社保)\b/i,
|
|
22
|
+
financial: /\b(bank account|routing number|account number|iban|swift code|credit card|debit card|cvv|brokerage|mortgage|loan)\b|银行卡|账号|信用卡/i,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const CARD = /(?<![\d-])(?:\d[ -]?){13,19}(?![\d-])/g;
|
|
26
|
+
|
|
27
|
+
/** Findings in one text: { category: count }, empty when nothing private was found. */
|
|
28
|
+
export function scanText(text) {
|
|
29
|
+
const found = {};
|
|
30
|
+
const s = String(text ?? "");
|
|
31
|
+
if (!s) return found;
|
|
32
|
+
for (const [category, pattern] of Object.entries(CATEGORIES)) {
|
|
33
|
+
const re = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`);
|
|
34
|
+
const n = (s.match(re) ?? []).length;
|
|
35
|
+
if (n) found[category] = n;
|
|
36
|
+
}
|
|
37
|
+
for (const m of s.matchAll(CARD)) {
|
|
38
|
+
const digits = m[0].replace(/\D/g, "");
|
|
39
|
+
if (digits.length >= 13 && digits.length <= 19 && luhn(digits)) found.financial = (found.financial ?? 0) + 1;
|
|
40
|
+
}
|
|
41
|
+
return found;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** What a session's messages hold that is private: { sensitive, findings, messages_flagged, messages }. */
|
|
45
|
+
export function privacyReport(messages) {
|
|
46
|
+
const findings = {};
|
|
47
|
+
let flagged = 0;
|
|
48
|
+
for (const m of messages) {
|
|
49
|
+
const parts = [m.text, m.thinking, ...(m.tool_calls ?? []).map((c) => (typeof c.input === "string" ? c.input : JSON.stringify(c.input ?? {})))];
|
|
50
|
+
const here = scanText(parts.filter(Boolean).join("\n"));
|
|
51
|
+
const categories = Object.keys(here);
|
|
52
|
+
if (categories.length) flagged++;
|
|
53
|
+
for (const [category, n] of Object.entries(here)) findings[category] = (findings[category] ?? 0) + n;
|
|
54
|
+
}
|
|
55
|
+
return { sensitive: Object.keys(findings).length > 0, findings, messages_flagged: flagged, messages: messages.length };
|
|
56
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// Grok Bot trace export: a folder (or zip) with manifest.json and sessions/*.jsonl, written by the Grok Bot agent's
|
|
2
|
+
// "trace export" task. Rows are flat: session_id, session_title, source, entry_id|position, seq, role (user |
|
|
3
|
+
// assistant | tool), timestamp ("YYYY-MM-DD HH:MM:SS <IANA zone>"), tool_name, args, result_summary, text.
|
|
4
|
+
// The main chat comes from a search index (user and assistant text only); an executor subagent file comes from a
|
|
5
|
+
// transcript reader and can miss positions. The manifest says which, and this keeps its notes with each session.
|
|
6
|
+
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { FORMAT } from "../normalize.mjs";
|
|
9
|
+
import { privacyReport } from "./_pii.mjs";
|
|
10
|
+
|
|
11
|
+
const MANIFEST = /(?:^|\/)manifest\.json$/;
|
|
12
|
+
const SESSION_FILE = /(?:^|\/)sessions\/[^/]+\.jsonl$/;
|
|
13
|
+
|
|
14
|
+
function offsetMs(instant, zone) {
|
|
15
|
+
const parts = new Intl.DateTimeFormat("en-US", { timeZone: zone, hourCycle: "h23", year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }).formatToParts(new Date(instant));
|
|
16
|
+
const get = (type) => Number(parts.find((p) => p.type === type).value);
|
|
17
|
+
return Date.UTC(get("year"), get("month") - 1, get("day"), get("hour"), get("minute"), get("second")) - Math.floor(instant / 1000) * 1000;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** "2026-10-27 12:09:18 America/Los_Angeles" as an ISO instant; null when absent or unreadable. */
|
|
21
|
+
export function parseStamp(value) {
|
|
22
|
+
if (typeof value !== "string") return null;
|
|
23
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?\s*(\S+)?$/.exec(value.trim());
|
|
24
|
+
if (!m) { const t = Date.parse(value); return Number.isFinite(t) ? new Date(t).toISOString() : null; }
|
|
25
|
+
const [, y, mo, d, h, mi, s, zone] = m;
|
|
26
|
+
const wall = Date.UTC(Number(y), Number(mo) - 1, Number(d), Number(h), Number(mi), Number(s));
|
|
27
|
+
if (!zone || zone === "Z" || zone === "UTC") return new Date(wall).toISOString();
|
|
28
|
+
try {
|
|
29
|
+
let guess = wall - offsetMs(wall, zone);
|
|
30
|
+
guess = wall - offsetMs(guess, zone);
|
|
31
|
+
return new Date(guess).toISOString();
|
|
32
|
+
} catch { return null; }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const present = (v) => v !== null && v !== undefined && v !== "" && v !== "None";
|
|
36
|
+
const asInput = (args) => {
|
|
37
|
+
if (!present(args)) return {};
|
|
38
|
+
if (typeof args !== "string") return args;
|
|
39
|
+
try { return JSON.parse(args); } catch { return { input: args }; }
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function parseRows(raw) {
|
|
43
|
+
const rows = [];
|
|
44
|
+
for (const line of raw.split("\n")) {
|
|
45
|
+
if (!line.trim()) continue;
|
|
46
|
+
try { const row = JSON.parse(line); if (row && typeof row === "object") rows.push(row); } catch { /* a cut-off line */ }
|
|
47
|
+
}
|
|
48
|
+
return rows;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const orderOf = (row) => Number(row.seq ?? row.position ?? 0);
|
|
52
|
+
|
|
53
|
+
/** One export file's rows as trace/v1 messages: tool calls on assistant messages, results as tool messages. */
|
|
54
|
+
export function messagesOf(rows, sessionId) {
|
|
55
|
+
const messages = [];
|
|
56
|
+
const open = [];
|
|
57
|
+
let orphans = 0;
|
|
58
|
+
for (const row of [...rows].sort((a, b) => orderOf(a) - orderOf(b))) {
|
|
59
|
+
const ts = parseStamp(row.timestamp);
|
|
60
|
+
const at = ts ? { ts } : {};
|
|
61
|
+
const text = present(row.text) ? String(row.text) : "";
|
|
62
|
+
const slot = row.seq ?? row.position ?? messages.length;
|
|
63
|
+
if (row.role === "user") {
|
|
64
|
+
messages.push({ role: "user", ...at, text });
|
|
65
|
+
} else if (row.role === "assistant") {
|
|
66
|
+
const message = { role: "assistant", ...at, text };
|
|
67
|
+
if (present(row.tool_name)) {
|
|
68
|
+
const call = { id: `${sessionId}:${slot}`, name: String(row.tool_name), input: asInput(row.args) };
|
|
69
|
+
message.tool_calls = [call];
|
|
70
|
+
open.push(call);
|
|
71
|
+
}
|
|
72
|
+
messages.push(message);
|
|
73
|
+
} else if (row.role === "tool") {
|
|
74
|
+
const name = present(row.tool_name) ? String(row.tool_name) : "tool";
|
|
75
|
+
const at0 = open.findIndex((c) => c.name === name);
|
|
76
|
+
const call = at0 >= 0 ? open.splice(at0, 1)[0] : null;
|
|
77
|
+
if (!call) orphans++;
|
|
78
|
+
messages.push({ role: "tool", ...at, tool_use_id: call?.id ?? `${sessionId}:orphan:${slot}`, tool_name: name, is_error: false, text: present(row.result_summary) ? String(row.result_summary) : text });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { messages, orphanResults: orphans, unansweredCalls: open.length };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The recording gaps in a few words, for the session's title where every list shows it. */
|
|
85
|
+
function gapTag(entry) {
|
|
86
|
+
const tags = [];
|
|
87
|
+
if (!(entry.tool_count > 0) && entry.kind === "main-chat") tags.push("text only: no tool calls or reasoning recorded");
|
|
88
|
+
if (entry.missing_positions?.length) tags.push(`positions ${entry.missing_positions.join(", ")} missing`);
|
|
89
|
+
return tags.length ? ` [${tags.join("; ")}]` : "";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function limitations(entry) {
|
|
93
|
+
const out = [];
|
|
94
|
+
if (!(entry.tool_count > 0) && entry.kind === "main-chat") out.push("The main chat has no tool calls, tool results or reasoning: only user and assistant text was recoverable.");
|
|
95
|
+
if (entry.missing_positions?.length) out.push(`Transcript positions ${entry.missing_positions.join(", ")} of ${entry.raw_total ?? "?"} are missing, so the start of this session is not recorded.`);
|
|
96
|
+
if (entry.notes) out.push(String(entry.notes));
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function grokBotSessions(manifest, read) {
|
|
101
|
+
const out = [];
|
|
102
|
+
for (const entry of manifest.sessions ?? []) {
|
|
103
|
+
let rows;
|
|
104
|
+
try { rows = parseRows(read(entry.file)); } catch { continue; }
|
|
105
|
+
const id = String(entry.id || rows[0]?.session_id || createHash("sha256").update(entry.file).digest("hex").slice(0, 16));
|
|
106
|
+
const { messages, orphanResults, unansweredCalls } = messagesOf(rows, id);
|
|
107
|
+
const stamps = messages.map((m) => m.ts).filter(Boolean).sort();
|
|
108
|
+
const first = parseStamp(entry.first_timestamp) ?? stamps[0] ?? null;
|
|
109
|
+
const last = parseStamp(entry.last_timestamp) ?? stamps.at(-1) ?? null;
|
|
110
|
+
const privacy = privacyReport(messages);
|
|
111
|
+
out.push({
|
|
112
|
+
format: FORMAT,
|
|
113
|
+
harness: "grok-bot",
|
|
114
|
+
model: "",
|
|
115
|
+
session_id: id,
|
|
116
|
+
title: `${entry.title || rows[0]?.session_title || "Grok Bot session"}${gapTag(entry)}`,
|
|
117
|
+
started_at: first,
|
|
118
|
+
ended_at: last,
|
|
119
|
+
cwd: "",
|
|
120
|
+
source: "grok-bot-export",
|
|
121
|
+
...(limitations(entry).length ? { source_gaps: limitations(entry) } : {}),
|
|
122
|
+
sensitive: privacy.sensitive,
|
|
123
|
+
privacy,
|
|
124
|
+
provenance: {
|
|
125
|
+
agent: manifest.agent_name || "Grok Bot",
|
|
126
|
+
agent_id: manifest.agent_id || null,
|
|
127
|
+
kind: entry.kind || null,
|
|
128
|
+
recovered_from: entry.source || null,
|
|
129
|
+
expected_messages: entry.message_count ?? null,
|
|
130
|
+
rows_read: rows.length,
|
|
131
|
+
counts_match: entry.message_count == null ? null : entry.message_count === rows.length,
|
|
132
|
+
user_count: entry.user_count ?? null,
|
|
133
|
+
assistant_count: entry.assistant_count ?? null,
|
|
134
|
+
tool_count: entry.tool_count ?? null,
|
|
135
|
+
missing_positions: entry.missing_positions ?? [],
|
|
136
|
+
raw_positions: entry.raw_positions ?? null,
|
|
137
|
+
raw_total: entry.raw_total ?? null,
|
|
138
|
+
redactions: entry.redactions ?? null,
|
|
139
|
+
orphan_tool_results: orphanResults,
|
|
140
|
+
unanswered_tool_calls: unansweredCalls,
|
|
141
|
+
limitations: limitations(entry),
|
|
142
|
+
notes: entry.notes ?? null,
|
|
143
|
+
range: manifest.extra?.date_range ?? null,
|
|
144
|
+
},
|
|
145
|
+
messages,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function manifestOf(l) {
|
|
152
|
+
for (const name of l.names.filter((n) => MANIFEST.test(n))) {
|
|
153
|
+
try {
|
|
154
|
+
const m = JSON.parse(l.read(name));
|
|
155
|
+
if (m && Array.isArray(m.sessions) && m.sessions.every((s) => typeof s?.file === "string") && typeof m.agent_name === "string") return { name, manifest: m };
|
|
156
|
+
} catch { /* not this one */ }
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export default {
|
|
162
|
+
id: "grok-bot",
|
|
163
|
+
name: "Grok Bot (trace export)",
|
|
164
|
+
kind: "export",
|
|
165
|
+
how: "the Grok Bot trace-export folder (manifest.json + sessions/*.jsonl), or a zip of it: sky trace sync --import <folder>",
|
|
166
|
+
sniff(l) {
|
|
167
|
+
return l.names.some((n) => SESSION_FILE.test(n)) && manifestOf(l) !== null;
|
|
168
|
+
},
|
|
169
|
+
*collect(input, { listing: l }) {
|
|
170
|
+
const found = manifestOf(l);
|
|
171
|
+
if (!found) return;
|
|
172
|
+
const prefix = found.name.slice(0, found.name.length - "manifest.json".length);
|
|
173
|
+
const read = (file) => {
|
|
174
|
+
const name = l.names.find((n) => n === `${prefix}sessions/${file}` || n.endsWith(`/sessions/${file}`) || n === `sessions/${file}`);
|
|
175
|
+
if (!name) throw new Error(`${file} is not in the export`);
|
|
176
|
+
return l.read(name);
|
|
177
|
+
};
|
|
178
|
+
yield* grokBotSessions(found.manifest, read);
|
|
179
|
+
},
|
|
180
|
+
};
|
|
@@ -57,10 +57,12 @@ export function listing(input) {
|
|
|
57
57
|
/** Write sessions as <dir>/<id>/<session_id>.json; unchanged sessions are not rewritten. */
|
|
58
58
|
export function writeSessions(sessions, dir) {
|
|
59
59
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
60
|
-
let written = 0, total = 0;
|
|
60
|
+
let written = 0, total = 0, held = 0;
|
|
61
|
+
const findings = {};
|
|
61
62
|
for (const s of sessions) {
|
|
62
63
|
if (!Array.isArray(s?.messages)) continue;
|
|
63
64
|
total++;
|
|
65
|
+
if (s.sensitive) { held++; for (const [k, n] of Object.entries(s.privacy?.findings ?? {})) findings[k] = (findings[k] ?? 0) + n; }
|
|
64
66
|
const name = String(s.session_id || "").replace(/[^\w.-]+/g, "_").slice(0, 120) || `session-${total}`;
|
|
65
67
|
const p = path.join(dir, `${name}.json`);
|
|
66
68
|
// Adapters keep original session records separate from the searchable projection.
|
|
@@ -81,7 +83,7 @@ export function writeSessions(sessions, dir) {
|
|
|
81
83
|
fs.writeFileSync(p, body, { mode: 0o600 });
|
|
82
84
|
written++;
|
|
83
85
|
}
|
|
84
|
-
return { total, written };
|
|
86
|
+
return { total, written, ...(held ? { sensitive: held, findings } : {}) };
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
function fingerprint(root) {
|