chat-recall 0.7.21 → 0.7.23
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 +16 -1
- package/dist/cli.js +807 -372
- package/dist/cli.js.map +1 -1
- package/dist/install-hooks.d.ts +10 -0
- package/dist/install-hooks.d.ts.map +1 -1
- package/dist/install-hooks.js +74 -2
- package/dist/install-hooks.js.map +1 -1
- package/dist/mcp-relay.js +1 -1
- package/dist/mcp.js +704 -294
- package/dist/message-hook-core.d.ts +28 -2
- package/dist/message-hook-core.d.ts.map +1 -1
- package/dist/message-hook-core.js +101 -5
- package/dist/message-hook-core.js.map +1 -1
- package/dist/message-hook.js +103 -18
- package/dist/message-hook.js.map +1 -1
- package/dist/scan-worker.js +4 -0
- package/dist/watch.js +9 -5
- package/package.json +2 -2
- package/skills/chat-recall-sessions/SKILL.md +6 -0
package/dist/mcp.js
CHANGED
|
@@ -443,30 +443,30 @@ var require_caller = __commonJS({
|
|
|
443
443
|
var require_redact = __commonJS({
|
|
444
444
|
"../../node_modules/@pinojs/redact/index.js"(exports, module) {
|
|
445
445
|
"use strict";
|
|
446
|
-
function deepClone(
|
|
447
|
-
if (
|
|
448
|
-
return
|
|
446
|
+
function deepClone(obj2) {
|
|
447
|
+
if (obj2 === null || typeof obj2 !== "object") {
|
|
448
|
+
return obj2;
|
|
449
449
|
}
|
|
450
|
-
if (
|
|
451
|
-
return new Date(
|
|
450
|
+
if (obj2 instanceof Date) {
|
|
451
|
+
return new Date(obj2.getTime());
|
|
452
452
|
}
|
|
453
|
-
if (
|
|
453
|
+
if (obj2 instanceof Array) {
|
|
454
454
|
const cloned = [];
|
|
455
|
-
for (let i = 0; i <
|
|
456
|
-
cloned[i] = deepClone(
|
|
455
|
+
for (let i = 0; i < obj2.length; i++) {
|
|
456
|
+
cloned[i] = deepClone(obj2[i]);
|
|
457
457
|
}
|
|
458
458
|
return cloned;
|
|
459
459
|
}
|
|
460
|
-
if (typeof
|
|
461
|
-
const cloned = Object.create(Object.getPrototypeOf(
|
|
462
|
-
for (const key2 in
|
|
463
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
464
|
-
cloned[key2] = deepClone(
|
|
460
|
+
if (typeof obj2 === "object") {
|
|
461
|
+
const cloned = Object.create(Object.getPrototypeOf(obj2));
|
|
462
|
+
for (const key2 in obj2) {
|
|
463
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key2)) {
|
|
464
|
+
cloned[key2] = deepClone(obj2[key2]);
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
467
|
return cloned;
|
|
468
468
|
}
|
|
469
|
-
return
|
|
469
|
+
return obj2;
|
|
470
470
|
}
|
|
471
471
|
function parsePath(path2) {
|
|
472
472
|
const parts = [];
|
|
@@ -511,8 +511,8 @@ var require_redact = __commonJS({
|
|
|
511
511
|
}
|
|
512
512
|
return parts;
|
|
513
513
|
}
|
|
514
|
-
function setValue(
|
|
515
|
-
let current =
|
|
514
|
+
function setValue(obj2, parts, value) {
|
|
515
|
+
let current = obj2;
|
|
516
516
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
517
517
|
const key2 = parts[i];
|
|
518
518
|
if (typeof current !== "object" || current === null || !(key2 in current)) {
|
|
@@ -543,8 +543,8 @@ var require_redact = __commonJS({
|
|
|
543
543
|
}
|
|
544
544
|
return true;
|
|
545
545
|
}
|
|
546
|
-
function removeKey(
|
|
547
|
-
let current =
|
|
546
|
+
function removeKey(obj2, parts) {
|
|
547
|
+
let current = obj2;
|
|
548
548
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
549
549
|
const key2 = parts[i];
|
|
550
550
|
if (typeof current !== "object" || current === null || !(key2 in current)) {
|
|
@@ -576,8 +576,8 @@ var require_redact = __commonJS({
|
|
|
576
576
|
return true;
|
|
577
577
|
}
|
|
578
578
|
var PATH_NOT_FOUND = /* @__PURE__ */ Symbol("PATH_NOT_FOUND");
|
|
579
|
-
function getValueIfExists(
|
|
580
|
-
let current =
|
|
579
|
+
function getValueIfExists(obj2, parts) {
|
|
580
|
+
let current = obj2;
|
|
581
581
|
for (const part of parts) {
|
|
582
582
|
if (current === null || current === void 0) {
|
|
583
583
|
return PATH_NOT_FOUND;
|
|
@@ -592,8 +592,8 @@ var require_redact = __commonJS({
|
|
|
592
592
|
}
|
|
593
593
|
return current;
|
|
594
594
|
}
|
|
595
|
-
function getValue(
|
|
596
|
-
let current =
|
|
595
|
+
function getValue(obj2, parts) {
|
|
596
|
+
let current = obj2;
|
|
597
597
|
for (const part of parts) {
|
|
598
598
|
if (current === null || current === void 0) {
|
|
599
599
|
return void 0;
|
|
@@ -605,30 +605,30 @@ var require_redact = __commonJS({
|
|
|
605
605
|
}
|
|
606
606
|
return current;
|
|
607
607
|
}
|
|
608
|
-
function redactPaths(
|
|
608
|
+
function redactPaths(obj2, paths, censor, remove = false) {
|
|
609
609
|
for (const path2 of paths) {
|
|
610
610
|
const parts = parsePath(path2);
|
|
611
611
|
if (parts.includes("*")) {
|
|
612
|
-
redactWildcardPath(
|
|
612
|
+
redactWildcardPath(obj2, parts, censor, path2, remove);
|
|
613
613
|
} else {
|
|
614
614
|
if (remove) {
|
|
615
|
-
removeKey(
|
|
615
|
+
removeKey(obj2, parts);
|
|
616
616
|
} else {
|
|
617
|
-
const value = getValueIfExists(
|
|
617
|
+
const value = getValueIfExists(obj2, parts);
|
|
618
618
|
if (value === PATH_NOT_FOUND) {
|
|
619
619
|
continue;
|
|
620
620
|
}
|
|
621
621
|
const actualCensor = typeof censor === "function" ? censor(value, parts) : censor;
|
|
622
|
-
setValue(
|
|
622
|
+
setValue(obj2, parts, actualCensor);
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
|
-
function redactWildcardPath(
|
|
627
|
+
function redactWildcardPath(obj2, parts, censor, originalPath, remove = false) {
|
|
628
628
|
const wildcardIndex = parts.indexOf("*");
|
|
629
629
|
if (wildcardIndex === parts.length - 1) {
|
|
630
630
|
const parentParts = parts.slice(0, -1);
|
|
631
|
-
let current =
|
|
631
|
+
let current = obj2;
|
|
632
632
|
for (const part of parentParts) {
|
|
633
633
|
if (current === null || current === void 0) return;
|
|
634
634
|
if (typeof current !== "object" || current === null) return;
|
|
@@ -666,10 +666,10 @@ var require_redact = __commonJS({
|
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
} else {
|
|
669
|
-
redactIntermediateWildcard(
|
|
669
|
+
redactIntermediateWildcard(obj2, parts, censor, wildcardIndex, originalPath, remove);
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
|
-
function redactIntermediateWildcard(
|
|
672
|
+
function redactIntermediateWildcard(obj2, parts, censor, wildcardIndex, originalPath, remove = false) {
|
|
673
673
|
const beforeWildcard = parts.slice(0, wildcardIndex);
|
|
674
674
|
const afterWildcard = parts.slice(wildcardIndex + 1);
|
|
675
675
|
const pathArray = [];
|
|
@@ -710,9 +710,9 @@ var require_redact = __commonJS({
|
|
|
710
710
|
}
|
|
711
711
|
}
|
|
712
712
|
if (beforeWildcard.length === 0) {
|
|
713
|
-
traverse(
|
|
713
|
+
traverse(obj2, 0);
|
|
714
714
|
} else {
|
|
715
|
-
let current =
|
|
715
|
+
let current = obj2;
|
|
716
716
|
for (let i = 0; i < beforeWildcard.length; i++) {
|
|
717
717
|
const part = beforeWildcard[i];
|
|
718
718
|
if (current === null || current === void 0) return;
|
|
@@ -743,9 +743,9 @@ var require_redact = __commonJS({
|
|
|
743
743
|
}
|
|
744
744
|
return pathStructure;
|
|
745
745
|
}
|
|
746
|
-
function selectiveClone(
|
|
746
|
+
function selectiveClone(obj2, pathStructure) {
|
|
747
747
|
if (!pathStructure) {
|
|
748
|
-
return
|
|
748
|
+
return obj2;
|
|
749
749
|
}
|
|
750
750
|
function cloneSelectively(source, pathMap, depth = 0) {
|
|
751
751
|
if (!pathMap || pathMap.size === 0) {
|
|
@@ -781,7 +781,7 @@ var require_redact = __commonJS({
|
|
|
781
781
|
}
|
|
782
782
|
return cloned;
|
|
783
783
|
}
|
|
784
|
-
return cloneSelectively(
|
|
784
|
+
return cloneSelectively(obj2, pathStructure);
|
|
785
785
|
}
|
|
786
786
|
function validatePath(path2) {
|
|
787
787
|
if (typeof path2 !== "string") {
|
|
@@ -840,17 +840,17 @@ var require_redact = __commonJS({
|
|
|
840
840
|
} = options;
|
|
841
841
|
validatePaths(paths);
|
|
842
842
|
const pathStructure = buildPathStructure(paths);
|
|
843
|
-
return function redact(
|
|
844
|
-
if (strict && (
|
|
845
|
-
if (
|
|
846
|
-
return serialize ? serialize(
|
|
843
|
+
return function redact(obj2) {
|
|
844
|
+
if (strict && (obj2 === null || typeof obj2 !== "object")) {
|
|
845
|
+
if (obj2 === null || obj2 === void 0) {
|
|
846
|
+
return serialize ? serialize(obj2) : obj2;
|
|
847
847
|
}
|
|
848
|
-
if (typeof
|
|
849
|
-
return serialize ? serialize(
|
|
848
|
+
if (typeof obj2 !== "object") {
|
|
849
|
+
return serialize ? serialize(obj2) : obj2;
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
|
-
const cloned = selectiveClone(
|
|
853
|
-
const original =
|
|
852
|
+
const cloned = selectiveClone(obj2, pathStructure);
|
|
853
|
+
const original = obj2;
|
|
854
854
|
let actualCensor = censor;
|
|
855
855
|
if (typeof censor === "function") {
|
|
856
856
|
actualCensor = censor;
|
|
@@ -1838,10 +1838,10 @@ var require_on_exit_leak_free = __commonJS({
|
|
|
1838
1838
|
}
|
|
1839
1839
|
function callRefs(event) {
|
|
1840
1840
|
for (const ref of refs[event]) {
|
|
1841
|
-
const
|
|
1841
|
+
const obj2 = ref.deref();
|
|
1842
1842
|
const fn = ref.fn;
|
|
1843
|
-
if (
|
|
1844
|
-
fn(
|
|
1843
|
+
if (obj2 !== void 0) {
|
|
1844
|
+
fn(obj2, event);
|
|
1845
1845
|
}
|
|
1846
1846
|
}
|
|
1847
1847
|
refs[event] = [];
|
|
@@ -1853,32 +1853,32 @@ var require_on_exit_leak_free = __commonJS({
|
|
|
1853
1853
|
uninstall(event);
|
|
1854
1854
|
}
|
|
1855
1855
|
}
|
|
1856
|
-
function _register(event,
|
|
1857
|
-
if (
|
|
1856
|
+
function _register(event, obj2, fn) {
|
|
1857
|
+
if (obj2 === void 0) {
|
|
1858
1858
|
throw new Error("the object can't be undefined");
|
|
1859
1859
|
}
|
|
1860
1860
|
install(event);
|
|
1861
|
-
const ref = new WeakRef(
|
|
1861
|
+
const ref = new WeakRef(obj2);
|
|
1862
1862
|
ref.fn = fn;
|
|
1863
1863
|
ensureRegistry();
|
|
1864
|
-
registry.register(
|
|
1864
|
+
registry.register(obj2, ref);
|
|
1865
1865
|
refs[event].push(ref);
|
|
1866
1866
|
}
|
|
1867
|
-
function register(
|
|
1868
|
-
_register("exit",
|
|
1867
|
+
function register(obj2, fn) {
|
|
1868
|
+
_register("exit", obj2, fn);
|
|
1869
1869
|
}
|
|
1870
|
-
function registerBeforeExit(
|
|
1871
|
-
_register("beforeExit",
|
|
1870
|
+
function registerBeforeExit(obj2, fn) {
|
|
1871
|
+
_register("beforeExit", obj2, fn);
|
|
1872
1872
|
}
|
|
1873
|
-
function unregister(
|
|
1873
|
+
function unregister(obj2) {
|
|
1874
1874
|
if (registry === void 0) {
|
|
1875
1875
|
return;
|
|
1876
1876
|
}
|
|
1877
|
-
registry.unregister(
|
|
1877
|
+
registry.unregister(obj2);
|
|
1878
1878
|
for (const event of ["exit", "beforeExit"]) {
|
|
1879
1879
|
refs[event] = refs[event].filter((ref) => {
|
|
1880
1880
|
const _obj = ref.deref();
|
|
1881
|
-
return _obj && _obj !==
|
|
1881
|
+
return _obj && _obj !== obj2;
|
|
1882
1882
|
});
|
|
1883
1883
|
uninstall(event);
|
|
1884
1884
|
}
|
|
@@ -2034,7 +2034,7 @@ var require_thread_stream = __commonJS({
|
|
|
2034
2034
|
var { version: version2 } = require_package();
|
|
2035
2035
|
var { EventEmitter } = __require("events");
|
|
2036
2036
|
var { Worker: Worker2 } = __require("worker_threads");
|
|
2037
|
-
var { join:
|
|
2037
|
+
var { join: join63 } = __require("path");
|
|
2038
2038
|
var { pathToFileURL } = __require("url");
|
|
2039
2039
|
var { wait } = require_wait();
|
|
2040
2040
|
var {
|
|
@@ -2077,7 +2077,7 @@ var require_thread_stream = __commonJS({
|
|
|
2077
2077
|
function createWorker(stream, opts) {
|
|
2078
2078
|
const { filename, workerData } = opts;
|
|
2079
2079
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
2080
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
2080
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join63(__dirname, "lib", "worker.js");
|
|
2081
2081
|
const worker = new Worker2(toExecute, {
|
|
2082
2082
|
...opts.workerOpts,
|
|
2083
2083
|
trackUnmanagedFds: false,
|
|
@@ -2480,7 +2480,7 @@ var require_transport = __commonJS({
|
|
|
2480
2480
|
"use strict";
|
|
2481
2481
|
var { createRequire: createRequire3 } = __require("module");
|
|
2482
2482
|
var getCallers = require_caller();
|
|
2483
|
-
var { join:
|
|
2483
|
+
var { join: join63, isAbsolute: isAbsolute4, sep: sep4 } = __require("node:path");
|
|
2484
2484
|
var sleep = require_atomic_sleep();
|
|
2485
2485
|
var onExit = require_on_exit_leak_free();
|
|
2486
2486
|
var ThreadStream = require_thread_stream();
|
|
@@ -2543,7 +2543,7 @@ var require_transport = __commonJS({
|
|
|
2543
2543
|
throw new Error("only one of target or targets can be specified");
|
|
2544
2544
|
}
|
|
2545
2545
|
if (targets) {
|
|
2546
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
2546
|
+
target = bundlerOverrides["pino-worker"] || join63(__dirname, "worker.js");
|
|
2547
2547
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
2548
2548
|
return {
|
|
2549
2549
|
...dest,
|
|
@@ -2561,7 +2561,7 @@ var require_transport = __commonJS({
|
|
|
2561
2561
|
});
|
|
2562
2562
|
});
|
|
2563
2563
|
} else if (pipeline) {
|
|
2564
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
2564
|
+
target = bundlerOverrides["pino-worker"] || join63(__dirname, "worker.js");
|
|
2565
2565
|
options.pipelines = [pipeline.map((dest) => {
|
|
2566
2566
|
return {
|
|
2567
2567
|
...dest,
|
|
@@ -2583,7 +2583,7 @@ var require_transport = __commonJS({
|
|
|
2583
2583
|
return origin;
|
|
2584
2584
|
}
|
|
2585
2585
|
if (origin === "pino/file") {
|
|
2586
|
-
return
|
|
2586
|
+
return join63(__dirname, "..", "file.js");
|
|
2587
2587
|
}
|
|
2588
2588
|
let fixTarget2;
|
|
2589
2589
|
for (const filePath of callers) {
|
|
@@ -2706,14 +2706,14 @@ var require_tools = __commonJS({
|
|
|
2706
2706
|
}
|
|
2707
2707
|
return point < 32 ? JSON.stringify(str) : '"' + result + '"';
|
|
2708
2708
|
}
|
|
2709
|
-
function asJson(
|
|
2709
|
+
function asJson(obj2, msg, num, time) {
|
|
2710
2710
|
if (asJsonChan.hasSubscribers === false) {
|
|
2711
|
-
return _asJson.call(this,
|
|
2711
|
+
return _asJson.call(this, obj2, msg, num, time);
|
|
2712
2712
|
}
|
|
2713
2713
|
const store2 = { instance: this, arguments };
|
|
2714
|
-
return asJsonChan.traceSync(_asJson, store2, this,
|
|
2714
|
+
return asJsonChan.traceSync(_asJson, store2, this, obj2, msg, num, time);
|
|
2715
2715
|
}
|
|
2716
|
-
function _asJson(
|
|
2716
|
+
function _asJson(obj2, msg, num, time) {
|
|
2717
2717
|
const stringify2 = this[stringifySym];
|
|
2718
2718
|
const stringifySafe = this[stringifySafeSym];
|
|
2719
2719
|
const stringifiers = this[stringifiersSym];
|
|
@@ -2727,13 +2727,13 @@ var require_tools = __commonJS({
|
|
|
2727
2727
|
data = data + chindings;
|
|
2728
2728
|
let value;
|
|
2729
2729
|
if (formatters.log) {
|
|
2730
|
-
|
|
2730
|
+
obj2 = formatters.log(obj2);
|
|
2731
2731
|
}
|
|
2732
2732
|
const wildcardStringifier = stringifiers[wildcardFirstSym];
|
|
2733
2733
|
let propStr = "";
|
|
2734
|
-
for (const key2 in
|
|
2735
|
-
value =
|
|
2736
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
2734
|
+
for (const key2 in obj2) {
|
|
2735
|
+
value = obj2[key2];
|
|
2736
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key2) && value !== void 0) {
|
|
2737
2737
|
if (serializers[key2]) {
|
|
2738
2738
|
value = serializers[key2](value);
|
|
2739
2739
|
} else if (key2 === errorKey && serializers.err) {
|
|
@@ -2899,13 +2899,13 @@ var require_tools = __commonJS({
|
|
|
2899
2899
|
return { opts, stream };
|
|
2900
2900
|
};
|
|
2901
2901
|
}
|
|
2902
|
-
function stringify(
|
|
2902
|
+
function stringify(obj2, stringifySafeFn) {
|
|
2903
2903
|
try {
|
|
2904
|
-
return JSON.stringify(
|
|
2904
|
+
return JSON.stringify(obj2);
|
|
2905
2905
|
} catch (_) {
|
|
2906
2906
|
try {
|
|
2907
2907
|
const stringify2 = stringifySafeFn || this[stringifySafeSym];
|
|
2908
|
-
return stringify2(
|
|
2908
|
+
return stringify2(obj2);
|
|
2909
2909
|
} catch (_2) {
|
|
2910
2910
|
return '"[unable to serialize, circular reference is too complex to analyze]"';
|
|
2911
2911
|
}
|
|
@@ -3355,29 +3355,29 @@ var require_proto = __commonJS({
|
|
|
3355
3355
|
const errorKey = this[errorKeySym];
|
|
3356
3356
|
const messageKey = this[messageKeySym];
|
|
3357
3357
|
const mixinMergeStrategy = this[mixinMergeStrategySym] || defaultMixinMergeStrategy;
|
|
3358
|
-
let
|
|
3358
|
+
let obj2;
|
|
3359
3359
|
const streamWriteHook = this[hooksSym].streamWrite;
|
|
3360
3360
|
if (_obj === void 0 || _obj === null) {
|
|
3361
|
-
|
|
3361
|
+
obj2 = {};
|
|
3362
3362
|
} else if (_obj instanceof Error) {
|
|
3363
|
-
|
|
3363
|
+
obj2 = { [errorKey]: _obj };
|
|
3364
3364
|
if (msg === void 0) {
|
|
3365
3365
|
msg = _obj.message;
|
|
3366
3366
|
}
|
|
3367
3367
|
} else {
|
|
3368
|
-
|
|
3368
|
+
obj2 = _obj;
|
|
3369
3369
|
if (msg === void 0 && _obj[messageKey] === void 0 && _obj[errorKey]) {
|
|
3370
3370
|
msg = _obj[errorKey].message;
|
|
3371
3371
|
}
|
|
3372
3372
|
}
|
|
3373
3373
|
if (mixin) {
|
|
3374
|
-
|
|
3374
|
+
obj2 = mixinMergeStrategy(obj2, mixin(obj2, num, this));
|
|
3375
3375
|
}
|
|
3376
|
-
const s = this[asJsonSym](
|
|
3376
|
+
const s = this[asJsonSym](obj2, msg, num, t);
|
|
3377
3377
|
const stream = this[streamSym];
|
|
3378
3378
|
if (stream[needsMetadataGsym] === true) {
|
|
3379
3379
|
stream.lastLevel = num;
|
|
3380
|
-
stream.lastObj =
|
|
3380
|
+
stream.lastObj = obj2;
|
|
3381
3381
|
stream.lastMsg = msg;
|
|
3382
3382
|
stream.lastTime = t.slice(this[timeSliceIndexSym]);
|
|
3383
3383
|
stream.lastLogger = this;
|
|
@@ -3572,7 +3572,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
3572
3572
|
return circularValue;
|
|
3573
3573
|
}
|
|
3574
3574
|
let res = "";
|
|
3575
|
-
let
|
|
3575
|
+
let join63 = ",";
|
|
3576
3576
|
const originalIndentation = indentation;
|
|
3577
3577
|
if (Array.isArray(value)) {
|
|
3578
3578
|
if (value.length === 0) {
|
|
@@ -3586,7 +3586,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
3586
3586
|
indentation += spacer;
|
|
3587
3587
|
res += `
|
|
3588
3588
|
${indentation}`;
|
|
3589
|
-
|
|
3589
|
+
join63 = `,
|
|
3590
3590
|
${indentation}`;
|
|
3591
3591
|
}
|
|
3592
3592
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -3594,13 +3594,13 @@ ${indentation}`;
|
|
|
3594
3594
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
3595
3595
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
3596
3596
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
3597
|
-
res +=
|
|
3597
|
+
res += join63;
|
|
3598
3598
|
}
|
|
3599
3599
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
3600
3600
|
res += tmp !== void 0 ? tmp : "null";
|
|
3601
3601
|
if (value.length - 1 > maximumBreadth) {
|
|
3602
3602
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
3603
|
-
res += `${
|
|
3603
|
+
res += `${join63}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
3604
3604
|
}
|
|
3605
3605
|
if (spacer !== "") {
|
|
3606
3606
|
res += `
|
|
@@ -3621,7 +3621,7 @@ ${originalIndentation}`;
|
|
|
3621
3621
|
let separator = "";
|
|
3622
3622
|
if (spacer !== "") {
|
|
3623
3623
|
indentation += spacer;
|
|
3624
|
-
|
|
3624
|
+
join63 = `,
|
|
3625
3625
|
${indentation}`;
|
|
3626
3626
|
whitespace = " ";
|
|
3627
3627
|
}
|
|
@@ -3635,13 +3635,13 @@ ${indentation}`;
|
|
|
3635
3635
|
const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
|
|
3636
3636
|
if (tmp !== void 0) {
|
|
3637
3637
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
3638
|
-
separator =
|
|
3638
|
+
separator = join63;
|
|
3639
3639
|
}
|
|
3640
3640
|
}
|
|
3641
3641
|
if (keyLength > maximumBreadth) {
|
|
3642
3642
|
const removedKeys = keyLength - maximumBreadth;
|
|
3643
3643
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
3644
|
-
separator =
|
|
3644
|
+
separator = join63;
|
|
3645
3645
|
}
|
|
3646
3646
|
if (spacer !== "" && separator.length > 1) {
|
|
3647
3647
|
res = `
|
|
@@ -3682,7 +3682,7 @@ ${originalIndentation}`;
|
|
|
3682
3682
|
}
|
|
3683
3683
|
const originalIndentation = indentation;
|
|
3684
3684
|
let res = "";
|
|
3685
|
-
let
|
|
3685
|
+
let join63 = ",";
|
|
3686
3686
|
if (Array.isArray(value)) {
|
|
3687
3687
|
if (value.length === 0) {
|
|
3688
3688
|
return "[]";
|
|
@@ -3695,7 +3695,7 @@ ${originalIndentation}`;
|
|
|
3695
3695
|
indentation += spacer;
|
|
3696
3696
|
res += `
|
|
3697
3697
|
${indentation}`;
|
|
3698
|
-
|
|
3698
|
+
join63 = `,
|
|
3699
3699
|
${indentation}`;
|
|
3700
3700
|
}
|
|
3701
3701
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -3703,13 +3703,13 @@ ${indentation}`;
|
|
|
3703
3703
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
3704
3704
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
3705
3705
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
3706
|
-
res +=
|
|
3706
|
+
res += join63;
|
|
3707
3707
|
}
|
|
3708
3708
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
3709
3709
|
res += tmp !== void 0 ? tmp : "null";
|
|
3710
3710
|
if (value.length - 1 > maximumBreadth) {
|
|
3711
3711
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
3712
|
-
res += `${
|
|
3712
|
+
res += `${join63}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
3713
3713
|
}
|
|
3714
3714
|
if (spacer !== "") {
|
|
3715
3715
|
res += `
|
|
@@ -3722,7 +3722,7 @@ ${originalIndentation}`;
|
|
|
3722
3722
|
let whitespace = "";
|
|
3723
3723
|
if (spacer !== "") {
|
|
3724
3724
|
indentation += spacer;
|
|
3725
|
-
|
|
3725
|
+
join63 = `,
|
|
3726
3726
|
${indentation}`;
|
|
3727
3727
|
whitespace = " ";
|
|
3728
3728
|
}
|
|
@@ -3731,7 +3731,7 @@ ${indentation}`;
|
|
|
3731
3731
|
const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
|
|
3732
3732
|
if (tmp !== void 0) {
|
|
3733
3733
|
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
3734
|
-
separator =
|
|
3734
|
+
separator = join63;
|
|
3735
3735
|
}
|
|
3736
3736
|
}
|
|
3737
3737
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -3789,20 +3789,20 @@ ${originalIndentation}`;
|
|
|
3789
3789
|
indentation += spacer;
|
|
3790
3790
|
let res2 = `
|
|
3791
3791
|
${indentation}`;
|
|
3792
|
-
const
|
|
3792
|
+
const join64 = `,
|
|
3793
3793
|
${indentation}`;
|
|
3794
3794
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
3795
3795
|
let i = 0;
|
|
3796
3796
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
3797
3797
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
3798
3798
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
3799
|
-
res2 +=
|
|
3799
|
+
res2 += join64;
|
|
3800
3800
|
}
|
|
3801
3801
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
3802
3802
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
3803
3803
|
if (value.length - 1 > maximumBreadth) {
|
|
3804
3804
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
3805
|
-
res2 += `${
|
|
3805
|
+
res2 += `${join64}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
3806
3806
|
}
|
|
3807
3807
|
res2 += `
|
|
3808
3808
|
${originalIndentation}`;
|
|
@@ -3818,16 +3818,16 @@ ${originalIndentation}`;
|
|
|
3818
3818
|
return '"[Object]"';
|
|
3819
3819
|
}
|
|
3820
3820
|
indentation += spacer;
|
|
3821
|
-
const
|
|
3821
|
+
const join63 = `,
|
|
3822
3822
|
${indentation}`;
|
|
3823
3823
|
let res = "";
|
|
3824
3824
|
let separator = "";
|
|
3825
3825
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
3826
3826
|
if (isTypedArrayWithEntries(value)) {
|
|
3827
|
-
res += stringifyTypedArray(value,
|
|
3827
|
+
res += stringifyTypedArray(value, join63, maximumBreadth);
|
|
3828
3828
|
keys = keys.slice(value.length);
|
|
3829
3829
|
maximumPropertiesToStringify -= value.length;
|
|
3830
|
-
separator =
|
|
3830
|
+
separator = join63;
|
|
3831
3831
|
}
|
|
3832
3832
|
if (deterministic) {
|
|
3833
3833
|
keys = sort(keys, comparator);
|
|
@@ -3838,13 +3838,13 @@ ${indentation}`;
|
|
|
3838
3838
|
const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
|
|
3839
3839
|
if (tmp !== void 0) {
|
|
3840
3840
|
res += `${separator}${strEscape(key3)}: ${tmp}`;
|
|
3841
|
-
separator =
|
|
3841
|
+
separator = join63;
|
|
3842
3842
|
}
|
|
3843
3843
|
}
|
|
3844
3844
|
if (keyLength > maximumBreadth) {
|
|
3845
3845
|
const removedKeys = keyLength - maximumBreadth;
|
|
3846
3846
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
3847
|
-
separator =
|
|
3847
|
+
separator = join63;
|
|
3848
3848
|
}
|
|
3849
3849
|
if (separator !== "") {
|
|
3850
3850
|
res = `
|
|
@@ -5036,30 +5036,30 @@ function declaredOrigin(value) {
|
|
|
5036
5036
|
const kind = value.kind;
|
|
5037
5037
|
return typeof kind === "string" && kind ? kind : void 0;
|
|
5038
5038
|
}
|
|
5039
|
-
function userRecordOrigin(
|
|
5040
|
-
if (
|
|
5039
|
+
function userRecordOrigin(obj2, text) {
|
|
5040
|
+
if (obj2.isSidechain === true)
|
|
5041
5041
|
return "subagent";
|
|
5042
|
-
if (
|
|
5042
|
+
if (obj2.isCompactSummary === true)
|
|
5043
5043
|
return "compact-summary";
|
|
5044
|
-
const declared = declaredOrigin(
|
|
5044
|
+
const declared = declaredOrigin(obj2.origin);
|
|
5045
5045
|
if (declared && declared !== "human")
|
|
5046
5046
|
return declared;
|
|
5047
|
-
if (
|
|
5047
|
+
if (obj2.isMeta === true)
|
|
5048
5048
|
return "meta";
|
|
5049
5049
|
if (declared === "human")
|
|
5050
5050
|
return "human";
|
|
5051
5051
|
return originFromText(text);
|
|
5052
5052
|
}
|
|
5053
|
-
function queuedCommandPrompt(
|
|
5054
|
-
if (
|
|
5053
|
+
function queuedCommandPrompt(obj2) {
|
|
5054
|
+
if (obj2.type !== "attachment")
|
|
5055
5055
|
return null;
|
|
5056
|
-
const att =
|
|
5056
|
+
const att = obj2.attachment;
|
|
5057
5057
|
if (!att || att.type !== "queued_command")
|
|
5058
5058
|
return null;
|
|
5059
5059
|
const text = promptText(att.prompt);
|
|
5060
5060
|
if (!text)
|
|
5061
5061
|
return null;
|
|
5062
|
-
if (
|
|
5062
|
+
if (obj2.isSidechain === true)
|
|
5063
5063
|
return { text, origin: "subagent" };
|
|
5064
5064
|
const declared = declaredOrigin(att.origin);
|
|
5065
5065
|
if (declared)
|
|
@@ -7914,30 +7914,30 @@ var init_codex = __esm({
|
|
|
7914
7914
|
lineNum++;
|
|
7915
7915
|
if (!line.trim())
|
|
7916
7916
|
continue;
|
|
7917
|
-
let
|
|
7917
|
+
let obj2;
|
|
7918
7918
|
try {
|
|
7919
|
-
|
|
7919
|
+
obj2 = JSON.parse(line);
|
|
7920
7920
|
} catch {
|
|
7921
7921
|
continue;
|
|
7922
7922
|
}
|
|
7923
|
-
const tsIso = typeof
|
|
7923
|
+
const tsIso = typeof obj2.timestamp === "string" ? obj2.timestamp : void 0;
|
|
7924
7924
|
const ts = tsIso ? Date.parse(tsIso) || mtime : mtime;
|
|
7925
|
-
const payload =
|
|
7926
|
-
if (
|
|
7925
|
+
const payload = obj2.payload || {};
|
|
7926
|
+
if (obj2.type === "event_msg" && payload.type === "user_message") {
|
|
7927
7927
|
const text = String(payload.message || "").trim();
|
|
7928
7928
|
if (text && !isCodexInjectedWrapper(text)) {
|
|
7929
7929
|
events.push({ kind: "user", ts, tsIso, line: lineNum, text });
|
|
7930
7930
|
}
|
|
7931
|
-
} else if (
|
|
7931
|
+
} else if (obj2.type === "response_item" && payload.type === "message" && payload.role === "user") {
|
|
7932
7932
|
const text = flattenContent(payload.content).trim();
|
|
7933
7933
|
if (text && !isCodexInjectedWrapper(text)) {
|
|
7934
7934
|
events.push({ kind: "user", ts, tsIso, line: lineNum, text });
|
|
7935
7935
|
}
|
|
7936
|
-
} else if (
|
|
7936
|
+
} else if (obj2.type === "response_item" && payload.type === "message" && payload.role === "assistant") {
|
|
7937
7937
|
const text = flattenContent(payload.content).trim();
|
|
7938
7938
|
if (text)
|
|
7939
7939
|
events.push({ kind: "assistant_text", ts, tsIso, line: lineNum, text });
|
|
7940
|
-
} else if (
|
|
7940
|
+
} else if (obj2.type === "response_item" && payload.type === "function_call") {
|
|
7941
7941
|
const toolName = String(payload.name || "");
|
|
7942
7942
|
const callId = String(payload.call_id || "");
|
|
7943
7943
|
let args = payload.arguments;
|
|
@@ -7961,7 +7961,7 @@ var init_codex = __esm({
|
|
|
7961
7961
|
toolInput: args,
|
|
7962
7962
|
command
|
|
7963
7963
|
});
|
|
7964
|
-
} else if (
|
|
7964
|
+
} else if (obj2.type === "response_item" && payload.type === "function_call_output") {
|
|
7965
7965
|
const callId = String(payload.call_id || "");
|
|
7966
7966
|
const out = payload.output;
|
|
7967
7967
|
let body2 = "";
|
|
@@ -8221,14 +8221,14 @@ function extractProjectPathFromTranscript(path2, homeDir) {
|
|
|
8221
8221
|
for (const line of content.split("\n")) {
|
|
8222
8222
|
if (!line.trim())
|
|
8223
8223
|
continue;
|
|
8224
|
-
let
|
|
8224
|
+
let obj2;
|
|
8225
8225
|
try {
|
|
8226
|
-
|
|
8226
|
+
obj2 = JSON.parse(line);
|
|
8227
8227
|
} catch {
|
|
8228
8228
|
continue;
|
|
8229
8229
|
}
|
|
8230
|
-
if (
|
|
8231
|
-
const match =
|
|
8230
|
+
if (obj2.source === "USER_EXPLICIT" && obj2.type === "USER_INPUT" && typeof obj2.content === "string") {
|
|
8231
|
+
const match = obj2.content.match(/format\s+\[URI\]\s*->\s*\[CorpusName\]:\s*\n?\s*([^\s\n]+)\s*->/);
|
|
8232
8232
|
if (match && match[1])
|
|
8233
8233
|
return match[1].trim();
|
|
8234
8234
|
}
|
|
@@ -8346,6 +8346,10 @@ var init_agy = __esm({
|
|
|
8346
8346
|
sharedSettingsFile() {
|
|
8347
8347
|
return join11(this.sharedRootDir(), "settings.json");
|
|
8348
8348
|
}
|
|
8349
|
+
/** The global hooks file the CLI reads. It does not read hooks from its own home directory. */
|
|
8350
|
+
sharedHooksFile() {
|
|
8351
|
+
return join11(this.sharedRootDir(), "config", "hooks.json");
|
|
8352
|
+
}
|
|
8349
8353
|
sharedProjectsJson() {
|
|
8350
8354
|
return join11(this.sharedRootDir(), "projects.json");
|
|
8351
8355
|
}
|
|
@@ -8442,9 +8446,9 @@ var init_agy = __esm({
|
|
|
8442
8446
|
const lines = readFileSync6(filePath, "utf-8").split("\n").filter(Boolean);
|
|
8443
8447
|
messageCount = lines.length;
|
|
8444
8448
|
for (const line of lines) {
|
|
8445
|
-
const
|
|
8446
|
-
if (
|
|
8447
|
-
const content =
|
|
8449
|
+
const obj2 = JSON.parse(line);
|
|
8450
|
+
if (obj2.source === "USER_EXPLICIT" && obj2.type === "USER_INPUT" && typeof obj2.content === "string") {
|
|
8451
|
+
const content = obj2.content;
|
|
8448
8452
|
const match = content.match(/<USER_REQUEST>([\s\S]*?)<\/USER_REQUEST>/);
|
|
8449
8453
|
const rawText = match ? match[1].trim() : content.trim();
|
|
8450
8454
|
firstPrompt = flatString(rawText.slice(0, 200));
|
|
@@ -8553,27 +8557,27 @@ var init_agy = __esm({
|
|
|
8553
8557
|
lineNum++;
|
|
8554
8558
|
if (!line.trim())
|
|
8555
8559
|
continue;
|
|
8556
|
-
let
|
|
8560
|
+
let obj2;
|
|
8557
8561
|
try {
|
|
8558
|
-
|
|
8562
|
+
obj2 = JSON.parse(line);
|
|
8559
8563
|
} catch {
|
|
8560
8564
|
continue;
|
|
8561
8565
|
}
|
|
8562
|
-
const tsIso = typeof
|
|
8566
|
+
const tsIso = typeof obj2.created_at === "string" ? obj2.created_at : void 0;
|
|
8563
8567
|
const ts = tsIso ? Date.parse(tsIso) || mtimeFallback : mtimeFallback;
|
|
8564
|
-
if (
|
|
8565
|
-
const content = typeof
|
|
8568
|
+
if (obj2.source === "USER_EXPLICIT" && obj2.type === "USER_INPUT") {
|
|
8569
|
+
const content = typeof obj2.content === "string" ? obj2.content : "";
|
|
8566
8570
|
const match = content.match(/<USER_REQUEST>([\s\S]*?)<\/USER_REQUEST>/);
|
|
8567
8571
|
const text = match ? match[1].trim() : content.trim();
|
|
8568
8572
|
if (text) {
|
|
8569
8573
|
events.push({ kind: "user", ts, tsIso, line: lineNum, text });
|
|
8570
8574
|
}
|
|
8571
|
-
} else if (
|
|
8572
|
-
const content = typeof
|
|
8575
|
+
} else if (obj2.source === "MODEL" && obj2.type === "PLANNER_RESPONSE") {
|
|
8576
|
+
const content = typeof obj2.content === "string" ? obj2.content.trim() : "";
|
|
8573
8577
|
if (content) {
|
|
8574
8578
|
events.push({ kind: "assistant_text", ts, tsIso, line: lineNum, text: content });
|
|
8575
8579
|
}
|
|
8576
|
-
const tcs = Array.isArray(
|
|
8580
|
+
const tcs = Array.isArray(obj2.tool_calls) ? obj2.tool_calls : [];
|
|
8577
8581
|
for (const tc of tcs) {
|
|
8578
8582
|
let toolName = String(tc?.name || "");
|
|
8579
8583
|
if (!toolName)
|
|
@@ -8601,12 +8605,12 @@ var init_agy = __esm({
|
|
|
8601
8605
|
command
|
|
8602
8606
|
});
|
|
8603
8607
|
}
|
|
8604
|
-
} else if (
|
|
8605
|
-
const resultBody = typeof
|
|
8606
|
-
const isError =
|
|
8608
|
+
} else if (obj2.source === "MODEL" && obj2.type !== "PLANNER_RESPONSE") {
|
|
8609
|
+
const resultBody = typeof obj2.content === "string" ? obj2.content : "";
|
|
8610
|
+
const isError = obj2.status === "ERROR" || obj2.status === "FAILED";
|
|
8607
8611
|
let matchedIndex = -1;
|
|
8608
8612
|
for (let i = 0; i < pendingToolCalls.length; i++) {
|
|
8609
|
-
if (matchesTool(
|
|
8613
|
+
if (matchesTool(obj2.type, pendingToolCalls[i].name)) {
|
|
8610
8614
|
matchedIndex = i;
|
|
8611
8615
|
break;
|
|
8612
8616
|
}
|
|
@@ -8624,7 +8628,7 @@ var init_agy = __esm({
|
|
|
8624
8628
|
toolName = popped.name;
|
|
8625
8629
|
} else {
|
|
8626
8630
|
toolUseId = `agy_tc_orphan_${toolUseCounter++}`;
|
|
8627
|
-
toolName =
|
|
8631
|
+
toolName = obj2.type.toLowerCase();
|
|
8628
8632
|
}
|
|
8629
8633
|
}
|
|
8630
8634
|
events.push({
|
|
@@ -9095,22 +9099,22 @@ function readTranscriptEvents(rawText, mtimeFallback = 0) {
|
|
|
9095
9099
|
lineNum++;
|
|
9096
9100
|
if (!line.trim())
|
|
9097
9101
|
continue;
|
|
9098
|
-
let
|
|
9102
|
+
let obj2;
|
|
9099
9103
|
try {
|
|
9100
|
-
|
|
9104
|
+
obj2 = JSON.parse(line);
|
|
9101
9105
|
} catch {
|
|
9102
9106
|
continue;
|
|
9103
9107
|
}
|
|
9104
|
-
if (!
|
|
9108
|
+
if (!obj2.role)
|
|
9105
9109
|
continue;
|
|
9106
|
-
const message =
|
|
9110
|
+
const message = obj2.message;
|
|
9107
9111
|
const content = Array.isArray(message?.content) ? message.content : [];
|
|
9108
9112
|
for (const part of content) {
|
|
9109
9113
|
if (!part || typeof part !== "object")
|
|
9110
9114
|
continue;
|
|
9111
9115
|
const p = part;
|
|
9112
9116
|
if (p.type === "text" && typeof p.text === "string") {
|
|
9113
|
-
if (
|
|
9117
|
+
if (obj2.role === "user") {
|
|
9114
9118
|
const { text, ts } = unwrapUserText(p.text);
|
|
9115
9119
|
if (ts)
|
|
9116
9120
|
clock = ts;
|
|
@@ -10385,19 +10389,19 @@ function parsePiFile(path2) {
|
|
|
10385
10389
|
for (const line of raw.split("\n")) {
|
|
10386
10390
|
if (!line.trim())
|
|
10387
10391
|
continue;
|
|
10388
|
-
let
|
|
10392
|
+
let obj2;
|
|
10389
10393
|
try {
|
|
10390
|
-
|
|
10394
|
+
obj2 = JSON.parse(line);
|
|
10391
10395
|
} catch {
|
|
10392
10396
|
continue;
|
|
10393
10397
|
}
|
|
10394
|
-
if (!
|
|
10398
|
+
if (!obj2 || typeof obj2 !== "object")
|
|
10395
10399
|
continue;
|
|
10396
|
-
if (
|
|
10397
|
-
out.header =
|
|
10400
|
+
if (obj2.type === "session" && !out.header) {
|
|
10401
|
+
out.header = obj2;
|
|
10398
10402
|
continue;
|
|
10399
10403
|
}
|
|
10400
|
-
out.entries.push(
|
|
10404
|
+
out.entries.push(obj2);
|
|
10401
10405
|
}
|
|
10402
10406
|
return out;
|
|
10403
10407
|
}
|
|
@@ -10439,10 +10443,10 @@ function readPiHeader(path2) {
|
|
|
10439
10443
|
const firstLine = buf.toString("utf-8", 0, n).split("\n", 1)[0];
|
|
10440
10444
|
if (!firstLine.trim())
|
|
10441
10445
|
return null;
|
|
10442
|
-
const
|
|
10443
|
-
if (!
|
|
10446
|
+
const obj2 = JSON.parse(firstLine);
|
|
10447
|
+
if (!obj2 || typeof obj2 !== "object" || obj2.type !== "session")
|
|
10444
10448
|
return null;
|
|
10445
|
-
return
|
|
10449
|
+
return obj2;
|
|
10446
10450
|
} catch {
|
|
10447
10451
|
return null;
|
|
10448
10452
|
} finally {
|
|
@@ -10770,17 +10774,17 @@ var init_pi = __esm({
|
|
|
10770
10774
|
lineNum++;
|
|
10771
10775
|
if (!line.trim())
|
|
10772
10776
|
continue;
|
|
10773
|
-
let
|
|
10777
|
+
let obj2;
|
|
10774
10778
|
try {
|
|
10775
|
-
|
|
10779
|
+
obj2 = JSON.parse(line);
|
|
10776
10780
|
} catch {
|
|
10777
10781
|
continue;
|
|
10778
10782
|
}
|
|
10779
|
-
const tsIso = typeof
|
|
10780
|
-
const msgTs = typeof
|
|
10783
|
+
const tsIso = typeof obj2.timestamp === "string" ? obj2.timestamp : void 0;
|
|
10784
|
+
const msgTs = typeof obj2.message?.timestamp === "number" ? obj2.message.timestamp : void 0;
|
|
10781
10785
|
const ts = tsIso ? Date.parse(tsIso) || mtimeFallback : msgTs ?? mtimeFallback;
|
|
10782
|
-
if (
|
|
10783
|
-
const msg =
|
|
10786
|
+
if (obj2.type === "message") {
|
|
10787
|
+
const msg = obj2.message || {};
|
|
10784
10788
|
const role = msg.role;
|
|
10785
10789
|
if (role === "user") {
|
|
10786
10790
|
const text = piText(msg.content).trim();
|
|
@@ -10859,12 +10863,12 @@ var init_pi = __esm({
|
|
|
10859
10863
|
}
|
|
10860
10864
|
continue;
|
|
10861
10865
|
}
|
|
10862
|
-
if (
|
|
10863
|
-
events.push({ kind: "summary", ts, tsIso, line: lineNum, text:
|
|
10866
|
+
if (obj2.type === "compaction" && typeof obj2.summary === "string" && obj2.summary.trim()) {
|
|
10867
|
+
events.push({ kind: "summary", ts, tsIso, line: lineNum, text: obj2.summary.trim() });
|
|
10864
10868
|
continue;
|
|
10865
10869
|
}
|
|
10866
|
-
if (
|
|
10867
|
-
events.push({ kind: "summary", ts, tsIso, line: lineNum, text:
|
|
10870
|
+
if (obj2.type === "branch_summary" && typeof obj2.summary === "string" && obj2.summary.trim()) {
|
|
10871
|
+
events.push({ kind: "summary", ts, tsIso, line: lineNum, text: obj2.summary.trim() });
|
|
10868
10872
|
}
|
|
10869
10873
|
}
|
|
10870
10874
|
return events;
|
|
@@ -11231,17 +11235,17 @@ function stripBanners(s) {
|
|
|
11231
11235
|
function promptFromLine(raw, maxLength) {
|
|
11232
11236
|
if (!raw.trim())
|
|
11233
11237
|
return null;
|
|
11234
|
-
let
|
|
11238
|
+
let obj2;
|
|
11235
11239
|
try {
|
|
11236
|
-
|
|
11240
|
+
obj2 = JSON.parse(raw);
|
|
11237
11241
|
} catch {
|
|
11238
11242
|
return null;
|
|
11239
11243
|
}
|
|
11240
|
-
if (
|
|
11244
|
+
if (obj2.type !== "user")
|
|
11241
11245
|
return null;
|
|
11242
|
-
if (
|
|
11246
|
+
if (obj2.isSidechain === true)
|
|
11243
11247
|
return null;
|
|
11244
|
-
const message =
|
|
11248
|
+
const message = obj2.message;
|
|
11245
11249
|
if (!message)
|
|
11246
11250
|
return null;
|
|
11247
11251
|
const content = message.content;
|
|
@@ -11732,17 +11736,17 @@ var init_claude = __esm({
|
|
|
11732
11736
|
lineNum++;
|
|
11733
11737
|
if (!line.trim())
|
|
11734
11738
|
continue;
|
|
11735
|
-
let
|
|
11739
|
+
let obj2;
|
|
11736
11740
|
try {
|
|
11737
|
-
|
|
11741
|
+
obj2 = JSON.parse(line);
|
|
11738
11742
|
} catch {
|
|
11739
11743
|
continue;
|
|
11740
11744
|
}
|
|
11741
|
-
const tsIso = typeof
|
|
11745
|
+
const tsIso = typeof obj2.timestamp === "string" ? obj2.timestamp : void 0;
|
|
11742
11746
|
const ts = tsIso ? Date.parse(tsIso) || mtime : mtime;
|
|
11743
|
-
if (
|
|
11744
|
-
if (
|
|
11745
|
-
const text = stripReminders(
|
|
11747
|
+
if (obj2.type === "queue-operation") {
|
|
11748
|
+
if (obj2.operation === "enqueue" && typeof obj2.content === "string") {
|
|
11749
|
+
const text = stripReminders(obj2.content);
|
|
11746
11750
|
if (text && originFromText(text) === "human") {
|
|
11747
11751
|
const e = { kind: "user", ts, tsIso, line: lineNum, text };
|
|
11748
11752
|
events.push(e);
|
|
@@ -11755,15 +11759,15 @@ var init_claude = __esm({
|
|
|
11755
11759
|
}
|
|
11756
11760
|
continue;
|
|
11757
11761
|
}
|
|
11758
|
-
const delivered = queuedCommandPrompt(
|
|
11762
|
+
const delivered = queuedCommandPrompt(obj2);
|
|
11759
11763
|
if (delivered) {
|
|
11760
11764
|
const text = stripReminders(delivered.text);
|
|
11761
11765
|
if (text && delivered.origin === "human")
|
|
11762
11766
|
pushPrompt({ kind: "user", ts, tsIso, line: lineNum, text });
|
|
11763
11767
|
continue;
|
|
11764
11768
|
}
|
|
11765
|
-
if (
|
|
11766
|
-
const msg =
|
|
11769
|
+
if (obj2.type === "user") {
|
|
11770
|
+
const msg = obj2.message;
|
|
11767
11771
|
const content = msg?.content;
|
|
11768
11772
|
let text = "";
|
|
11769
11773
|
const toolResults = [];
|
|
@@ -11796,7 +11800,7 @@ var init_claude = __esm({
|
|
|
11796
11800
|
}
|
|
11797
11801
|
}
|
|
11798
11802
|
const spoken = stripReminders(text);
|
|
11799
|
-
if (spoken && userRecordOrigin(
|
|
11803
|
+
if (spoken && userRecordOrigin(obj2, spoken) === "human") {
|
|
11800
11804
|
pushPrompt({ kind: "user", ts, tsIso, line: lineNum, text: spoken });
|
|
11801
11805
|
}
|
|
11802
11806
|
for (const tr of toolResults) {
|
|
@@ -11812,13 +11816,13 @@ var init_claude = __esm({
|
|
|
11812
11816
|
resultBytes: tr.body.length
|
|
11813
11817
|
});
|
|
11814
11818
|
}
|
|
11815
|
-
} else if (
|
|
11816
|
-
const summary = typeof
|
|
11819
|
+
} else if (obj2.type === "summary") {
|
|
11820
|
+
const summary = typeof obj2.summary === "string" ? obj2.summary : "";
|
|
11817
11821
|
if (summary) {
|
|
11818
11822
|
events.push({ kind: "summary", ts, tsIso, line: lineNum, text: summary });
|
|
11819
11823
|
}
|
|
11820
|
-
} else if (
|
|
11821
|
-
const msg =
|
|
11824
|
+
} else if (obj2.type === "assistant") {
|
|
11825
|
+
const msg = obj2.message;
|
|
11822
11826
|
const content = msg?.content;
|
|
11823
11827
|
if (!Array.isArray(content))
|
|
11824
11828
|
continue;
|
|
@@ -12296,9 +12300,9 @@ function readCwdFromJsonl(sessionPath) {
|
|
|
12296
12300
|
if (!line || !line.includes('"cwd"'))
|
|
12297
12301
|
continue;
|
|
12298
12302
|
try {
|
|
12299
|
-
const
|
|
12300
|
-
if (typeof
|
|
12301
|
-
return
|
|
12303
|
+
const obj2 = JSON.parse(line);
|
|
12304
|
+
if (typeof obj2.cwd === "string" && obj2.cwd)
|
|
12305
|
+
return obj2.cwd;
|
|
12302
12306
|
} catch {
|
|
12303
12307
|
}
|
|
12304
12308
|
}
|
|
@@ -12380,25 +12384,25 @@ async function parseSessionFile(sessionPath, maxMessages = 50) {
|
|
|
12380
12384
|
lineNum++;
|
|
12381
12385
|
if (!line.trim())
|
|
12382
12386
|
continue;
|
|
12383
|
-
let
|
|
12387
|
+
let obj2;
|
|
12384
12388
|
try {
|
|
12385
|
-
|
|
12389
|
+
obj2 = JSON.parse(line);
|
|
12386
12390
|
} catch {
|
|
12387
12391
|
continue;
|
|
12388
12392
|
}
|
|
12389
12393
|
try {
|
|
12390
|
-
const msgType =
|
|
12391
|
-
if (!content.metadata.gitBranch &&
|
|
12392
|
-
content.metadata.gitBranch =
|
|
12394
|
+
const msgType = obj2.type;
|
|
12395
|
+
if (!content.metadata.gitBranch && obj2.gitBranch) {
|
|
12396
|
+
content.metadata.gitBranch = obj2.gitBranch;
|
|
12393
12397
|
}
|
|
12394
|
-
if (!content.metadata.slug &&
|
|
12395
|
-
content.metadata.slug =
|
|
12398
|
+
if (!content.metadata.slug && obj2.slug) {
|
|
12399
|
+
content.metadata.slug = obj2.slug;
|
|
12396
12400
|
}
|
|
12397
|
-
if (msgType === "system" &&
|
|
12398
|
-
content.metadata.durationMs +=
|
|
12401
|
+
if (msgType === "system" && obj2.subtype === "turn_duration" && obj2.durationMs) {
|
|
12402
|
+
content.metadata.durationMs += obj2.durationMs;
|
|
12399
12403
|
}
|
|
12400
12404
|
if (msgType === "file-history-snapshot") {
|
|
12401
|
-
const snapshot2 =
|
|
12405
|
+
const snapshot2 = obj2.snapshot;
|
|
12402
12406
|
if (snapshot2 && typeof snapshot2 === "object") {
|
|
12403
12407
|
const backups = snapshot2.trackedFileBackups;
|
|
12404
12408
|
if (backups && typeof backups === "object") {
|
|
@@ -12409,14 +12413,14 @@ async function parseSessionFile(sessionPath, maxMessages = 50) {
|
|
|
12409
12413
|
}
|
|
12410
12414
|
}
|
|
12411
12415
|
if (msgType === "summary") {
|
|
12412
|
-
const summary =
|
|
12416
|
+
const summary = obj2.summary;
|
|
12413
12417
|
if (summary) {
|
|
12414
12418
|
content.summaries.push(summary);
|
|
12415
12419
|
}
|
|
12416
12420
|
} else if (msgType === "user") {
|
|
12417
12421
|
if (userCount >= maxMessages)
|
|
12418
12422
|
continue;
|
|
12419
|
-
const msg =
|
|
12423
|
+
const msg = obj2.message;
|
|
12420
12424
|
let text = "";
|
|
12421
12425
|
if (msg && typeof msg === "object") {
|
|
12422
12426
|
const msgContent = msg.content;
|
|
@@ -12445,18 +12449,18 @@ async function parseSessionFile(sessionPath, maxMessages = 50) {
|
|
|
12445
12449
|
text = textParts.join("\n");
|
|
12446
12450
|
}
|
|
12447
12451
|
}
|
|
12448
|
-
if (text && userRecordOrigin(
|
|
12452
|
+
if (text && userRecordOrigin(obj2, text) === "human")
|
|
12449
12453
|
recordPrompt(text, lineNum);
|
|
12450
12454
|
} else if (msgType === "queue-operation") {
|
|
12451
|
-
if (
|
|
12452
|
-
recordPrompt(
|
|
12455
|
+
if (obj2.operation === "enqueue" && typeof obj2.content === "string" && originFromText(obj2.content) === "human") {
|
|
12456
|
+
recordPrompt(obj2.content, lineNum, "enqueue");
|
|
12453
12457
|
}
|
|
12454
12458
|
} else if (msgType === "attachment") {
|
|
12455
|
-
const queued = queuedCommandPrompt(
|
|
12459
|
+
const queued = queuedCommandPrompt(obj2);
|
|
12456
12460
|
if (queued?.origin === "human")
|
|
12457
12461
|
recordPrompt(queued.text, lineNum, "delivery");
|
|
12458
12462
|
} else if (msgType === "assistant") {
|
|
12459
|
-
const msg =
|
|
12463
|
+
const msg = obj2.message;
|
|
12460
12464
|
if (!msg || typeof msg !== "object")
|
|
12461
12465
|
continue;
|
|
12462
12466
|
if (msg.model && typeof msg.model === "string") {
|
|
@@ -12522,7 +12526,7 @@ async function parseSessionFile(sessionPath, maxMessages = 50) {
|
|
|
12522
12526
|
}
|
|
12523
12527
|
}
|
|
12524
12528
|
}
|
|
12525
|
-
const toolResult =
|
|
12529
|
+
const toolResult = obj2.toolUseResult;
|
|
12526
12530
|
if (toolResult && typeof toolResult === "object" && toolCount < maxMessages) {
|
|
12527
12531
|
const resultText2 = toolResult.result;
|
|
12528
12532
|
const query = toolResult.query;
|
|
@@ -12611,10 +12615,10 @@ async function parseMessagesFromFile(sessionPath) {
|
|
|
12611
12615
|
}
|
|
12612
12616
|
function messagesFromRawLines(raw) {
|
|
12613
12617
|
const toolResults = /* @__PURE__ */ new Map();
|
|
12614
|
-
for (const { obj } of raw) {
|
|
12615
|
-
if (
|
|
12618
|
+
for (const { obj: obj2 } of raw) {
|
|
12619
|
+
if (obj2?.type !== "user")
|
|
12616
12620
|
continue;
|
|
12617
|
-
const content =
|
|
12621
|
+
const content = obj2.message?.content;
|
|
12618
12622
|
if (!Array.isArray(content))
|
|
12619
12623
|
continue;
|
|
12620
12624
|
for (const block of content) {
|
|
@@ -12627,12 +12631,12 @@ function messagesFromRawLines(raw) {
|
|
|
12627
12631
|
}
|
|
12628
12632
|
}
|
|
12629
12633
|
const messages = [];
|
|
12630
|
-
for (const { line, obj } of raw) {
|
|
12631
|
-
if (!
|
|
12634
|
+
for (const { line, obj: obj2 } of raw) {
|
|
12635
|
+
if (!obj2 || typeof obj2 !== "object")
|
|
12632
12636
|
continue;
|
|
12633
|
-
const timestamp = typeof
|
|
12634
|
-
if (
|
|
12635
|
-
const content =
|
|
12637
|
+
const timestamp = typeof obj2.timestamp === "string" ? obj2.timestamp : void 0;
|
|
12638
|
+
if (obj2.type === "user") {
|
|
12639
|
+
const content = obj2.message?.content;
|
|
12636
12640
|
let text = "";
|
|
12637
12641
|
if (typeof content === "string") {
|
|
12638
12642
|
text = content;
|
|
@@ -12644,18 +12648,18 @@ function messagesFromRawLines(raw) {
|
|
|
12644
12648
|
const cleaned = stripBanners2(text);
|
|
12645
12649
|
if (!cleaned)
|
|
12646
12650
|
continue;
|
|
12647
|
-
const origin = userRecordOrigin(
|
|
12651
|
+
const origin = userRecordOrigin(obj2, cleaned);
|
|
12648
12652
|
messages.push({ line, role: "user", content: cleaned, timestamp, ...origin === "human" ? {} : { origin } });
|
|
12649
|
-
} else if (
|
|
12650
|
-
const queued = queuedCommandPrompt(
|
|
12653
|
+
} else if (obj2.type === "attachment") {
|
|
12654
|
+
const queued = queuedCommandPrompt(obj2);
|
|
12651
12655
|
if (!queued)
|
|
12652
12656
|
continue;
|
|
12653
12657
|
const cleaned = stripBanners2(queued.text);
|
|
12654
12658
|
if (!cleaned)
|
|
12655
12659
|
continue;
|
|
12656
12660
|
messages.push({ line, role: "user", content: cleaned, timestamp, ...queued.origin === "human" ? {} : { origin: queued.origin } });
|
|
12657
|
-
} else if (
|
|
12658
|
-
const blocks = Array.isArray(
|
|
12661
|
+
} else if (obj2.type === "assistant") {
|
|
12662
|
+
const blocks = Array.isArray(obj2.message?.content) ? obj2.message.content : [];
|
|
12659
12663
|
const thinkingBlock = blocks.find((c) => c?.type === "thinking");
|
|
12660
12664
|
const textBlock = blocks.find((c) => c?.type === "text");
|
|
12661
12665
|
const toolUses = blocks.filter((c) => c?.type === "tool_use");
|
|
@@ -12681,10 +12685,10 @@ function messagesFromRawLines(raw) {
|
|
|
12681
12685
|
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
12682
12686
|
timestamp
|
|
12683
12687
|
});
|
|
12684
|
-
} else if (
|
|
12685
|
-
messages.push({ line, role: "summary", content:
|
|
12686
|
-
} else if (
|
|
12687
|
-
const c =
|
|
12688
|
+
} else if (obj2.type === "summary" && typeof obj2.summary === "string") {
|
|
12689
|
+
messages.push({ line, role: "summary", content: obj2.summary });
|
|
12690
|
+
} else if (obj2.type === "system" && obj2.subtype === "away_summary") {
|
|
12691
|
+
const c = obj2.content;
|
|
12688
12692
|
const text = typeof c === "string" ? c : Array.isArray(c) ? c.filter((b) => b?.type === "text" && typeof b.text === "string").map((b) => b.text).join("\n") : "";
|
|
12689
12693
|
if (text.trim())
|
|
12690
12694
|
messages.push({ line, role: "summary", content: stripBanners2(text), timestamp });
|
|
@@ -12882,31 +12886,31 @@ function parseCodexTranscriptText(text) {
|
|
|
12882
12886
|
if (!line.trim())
|
|
12883
12887
|
continue;
|
|
12884
12888
|
try {
|
|
12885
|
-
const
|
|
12886
|
-
if (
|
|
12887
|
-
const text2 = String(
|
|
12889
|
+
const obj2 = JSON.parse(line);
|
|
12890
|
+
if (obj2.type === "event_msg" && obj2.payload?.type === "user_message") {
|
|
12891
|
+
const text2 = String(obj2.payload.message || "").trim();
|
|
12888
12892
|
if (!text2 || isCodexInjectedWrapper2(text2))
|
|
12889
12893
|
continue;
|
|
12890
12894
|
messages.push({
|
|
12891
12895
|
line: lineNum,
|
|
12892
12896
|
role: "user",
|
|
12893
12897
|
content: text2,
|
|
12894
|
-
timestamp:
|
|
12898
|
+
timestamp: obj2.timestamp
|
|
12895
12899
|
});
|
|
12896
|
-
} else if (
|
|
12897
|
-
if (
|
|
12900
|
+
} else if (obj2.type === "response_item" && obj2.payload?.type === "message") {
|
|
12901
|
+
if (obj2.payload.role !== "assistant")
|
|
12898
12902
|
continue;
|
|
12899
|
-
const text2 = flattenCodexContent(
|
|
12903
|
+
const text2 = flattenCodexContent(obj2.payload.content);
|
|
12900
12904
|
if (!text2.trim())
|
|
12901
12905
|
continue;
|
|
12902
12906
|
messages.push({
|
|
12903
12907
|
line: lineNum,
|
|
12904
12908
|
role: "assistant",
|
|
12905
12909
|
content: text2,
|
|
12906
|
-
timestamp:
|
|
12910
|
+
timestamp: obj2.timestamp
|
|
12907
12911
|
});
|
|
12908
|
-
} else if (
|
|
12909
|
-
const summary = Array.isArray(
|
|
12912
|
+
} else if (obj2.type === "response_item" && obj2.payload?.type === "reasoning") {
|
|
12913
|
+
const summary = Array.isArray(obj2.payload.summary) ? obj2.payload.summary.map((s) => s?.text || "").filter(Boolean).join("\n") : "";
|
|
12910
12914
|
if (!summary.trim())
|
|
12911
12915
|
continue;
|
|
12912
12916
|
messages.push({
|
|
@@ -12914,10 +12918,10 @@ function parseCodexTranscriptText(text) {
|
|
|
12914
12918
|
role: "assistant",
|
|
12915
12919
|
content: "",
|
|
12916
12920
|
thinking: summary,
|
|
12917
|
-
timestamp:
|
|
12921
|
+
timestamp: obj2.timestamp
|
|
12918
12922
|
});
|
|
12919
|
-
} else if (
|
|
12920
|
-
let input =
|
|
12923
|
+
} else if (obj2.type === "response_item" && obj2.payload?.type === "function_call") {
|
|
12924
|
+
let input = obj2.payload.arguments || {};
|
|
12921
12925
|
if (typeof input === "string") {
|
|
12922
12926
|
try {
|
|
12923
12927
|
input = JSON.parse(input);
|
|
@@ -12928,8 +12932,8 @@ function parseCodexTranscriptText(text) {
|
|
|
12928
12932
|
line: lineNum,
|
|
12929
12933
|
role: "assistant",
|
|
12930
12934
|
content: "",
|
|
12931
|
-
toolCalls: [{ name:
|
|
12932
|
-
timestamp:
|
|
12935
|
+
toolCalls: [{ name: obj2.payload.name || "", input }],
|
|
12936
|
+
timestamp: obj2.timestamp
|
|
12933
12937
|
});
|
|
12934
12938
|
}
|
|
12935
12939
|
} catch {
|
|
@@ -13374,7 +13378,7 @@ async function archiveRawSession(store2, sessionId) {
|
|
|
13374
13378
|
}
|
|
13375
13379
|
function detectForkPredecessor(sessionPath) {
|
|
13376
13380
|
const { readFileSync: readFileSync51, readdirSync: readdirSync35 } = requireFs();
|
|
13377
|
-
const { dirname: dirname22, join:
|
|
13381
|
+
const { dirname: dirname22, join: join63, basename: basename26 } = requirePath();
|
|
13378
13382
|
let text;
|
|
13379
13383
|
try {
|
|
13380
13384
|
text = readFileSync51(sessionPath, "utf-8");
|
|
@@ -13411,7 +13415,7 @@ function detectForkPredecessor(sessionPath) {
|
|
|
13411
13415
|
if (!f.endsWith(".jsonl") || f === self || f === "sessions-index.json")
|
|
13412
13416
|
continue;
|
|
13413
13417
|
try {
|
|
13414
|
-
if (readFileSync51(
|
|
13418
|
+
if (readFileSync51(join63(dir, f), "utf-8").includes(`"uuid":"${headParent}"`)) {
|
|
13415
13419
|
return basename26(f, ".jsonl");
|
|
13416
13420
|
}
|
|
13417
13421
|
} catch {
|
|
@@ -20438,7 +20442,7 @@ var require_anchors = __commonJS({
|
|
|
20438
20442
|
var require_applyReviver = __commonJS({
|
|
20439
20443
|
"../../node_modules/yaml/dist/doc/applyReviver.js"(exports) {
|
|
20440
20444
|
"use strict";
|
|
20441
|
-
function applyReviver(reviver,
|
|
20445
|
+
function applyReviver(reviver, obj2, key2, val) {
|
|
20442
20446
|
if (val && typeof val === "object") {
|
|
20443
20447
|
if (Array.isArray(val)) {
|
|
20444
20448
|
for (let i = 0, len = val.length; i < len; ++i) {
|
|
@@ -20478,7 +20482,7 @@ var require_applyReviver = __commonJS({
|
|
|
20478
20482
|
}
|
|
20479
20483
|
}
|
|
20480
20484
|
}
|
|
20481
|
-
return reviver.call(
|
|
20485
|
+
return reviver.call(obj2, key2, val);
|
|
20482
20486
|
}
|
|
20483
20487
|
exports.applyReviver = applyReviver;
|
|
20484
20488
|
}
|
|
@@ -21414,10 +21418,10 @@ var require_stringify = __commonJS({
|
|
|
21414
21418
|
return match.find((t) => t.format === item.format) ?? match[0];
|
|
21415
21419
|
}
|
|
21416
21420
|
let tagObj = void 0;
|
|
21417
|
-
let
|
|
21421
|
+
let obj2;
|
|
21418
21422
|
if (identity.isScalar(item)) {
|
|
21419
|
-
|
|
21420
|
-
let match = tags.filter((t) => t.identify?.(
|
|
21423
|
+
obj2 = item.value;
|
|
21424
|
+
let match = tags.filter((t) => t.identify?.(obj2));
|
|
21421
21425
|
if (match.length > 1) {
|
|
21422
21426
|
const testMatch = match.filter((t) => t.test);
|
|
21423
21427
|
if (testMatch.length > 0)
|
|
@@ -21425,11 +21429,11 @@ var require_stringify = __commonJS({
|
|
|
21425
21429
|
}
|
|
21426
21430
|
tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
|
|
21427
21431
|
} else {
|
|
21428
|
-
|
|
21429
|
-
tagObj = tags.find((t) => t.nodeClass &&
|
|
21432
|
+
obj2 = item;
|
|
21433
|
+
tagObj = tags.find((t) => t.nodeClass && obj2 instanceof t.nodeClass);
|
|
21430
21434
|
}
|
|
21431
21435
|
if (!tagObj) {
|
|
21432
|
-
const name =
|
|
21436
|
+
const name = obj2?.constructor?.name ?? (obj2 === null ? "null" : typeof obj2);
|
|
21433
21437
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
21434
21438
|
}
|
|
21435
21439
|
return tagObj;
|
|
@@ -21985,23 +21989,23 @@ var require_YAMLMap = __commonJS({
|
|
|
21985
21989
|
* A generic collection parsing method that can be extended
|
|
21986
21990
|
* to other node classes that inherit from YAMLMap
|
|
21987
21991
|
*/
|
|
21988
|
-
static from(schema,
|
|
21992
|
+
static from(schema, obj2, ctx) {
|
|
21989
21993
|
const { keepUndefined, replacer } = ctx;
|
|
21990
21994
|
const map = new this(schema);
|
|
21991
21995
|
const add = (key2, value) => {
|
|
21992
21996
|
if (typeof replacer === "function")
|
|
21993
|
-
value = replacer.call(
|
|
21997
|
+
value = replacer.call(obj2, key2, value);
|
|
21994
21998
|
else if (Array.isArray(replacer) && !replacer.includes(key2))
|
|
21995
21999
|
return;
|
|
21996
22000
|
if (value !== void 0 || keepUndefined)
|
|
21997
22001
|
map.items.push(Pair.createPair(key2, value, ctx));
|
|
21998
22002
|
};
|
|
21999
|
-
if (
|
|
22000
|
-
for (const [key2, value] of
|
|
22003
|
+
if (obj2 instanceof Map) {
|
|
22004
|
+
for (const [key2, value] of obj2)
|
|
22001
22005
|
add(key2, value);
|
|
22002
|
-
} else if (
|
|
22003
|
-
for (const key2 of Object.keys(
|
|
22004
|
-
add(key2,
|
|
22006
|
+
} else if (obj2 && typeof obj2 === "object") {
|
|
22007
|
+
for (const key2 of Object.keys(obj2))
|
|
22008
|
+
add(key2, obj2[key2]);
|
|
22005
22009
|
}
|
|
22006
22010
|
if (typeof schema.sortMapEntries === "function") {
|
|
22007
22011
|
map.items.sort(schema.sortMapEntries);
|
|
@@ -22111,7 +22115,7 @@ var require_map = __commonJS({
|
|
|
22111
22115
|
onError("Expected a mapping for this tag");
|
|
22112
22116
|
return map2;
|
|
22113
22117
|
},
|
|
22114
|
-
createNode: (schema,
|
|
22118
|
+
createNode: (schema, obj2, ctx) => YAMLMap.YAMLMap.from(schema, obj2, ctx)
|
|
22115
22119
|
};
|
|
22116
22120
|
exports.map = map;
|
|
22117
22121
|
}
|
|
@@ -22207,15 +22211,15 @@ var require_YAMLSeq = __commonJS({
|
|
|
22207
22211
|
onComment
|
|
22208
22212
|
});
|
|
22209
22213
|
}
|
|
22210
|
-
static from(schema,
|
|
22214
|
+
static from(schema, obj2, ctx) {
|
|
22211
22215
|
const { replacer } = ctx;
|
|
22212
22216
|
const seq = new this(schema);
|
|
22213
|
-
if (
|
|
22217
|
+
if (obj2 && Symbol.iterator in Object(obj2)) {
|
|
22214
22218
|
let i = 0;
|
|
22215
|
-
for (let it of
|
|
22219
|
+
for (let it of obj2) {
|
|
22216
22220
|
if (typeof replacer === "function") {
|
|
22217
|
-
const key2 =
|
|
22218
|
-
it = replacer.call(
|
|
22221
|
+
const key2 = obj2 instanceof Set ? it : String(i++);
|
|
22222
|
+
it = replacer.call(obj2, key2, it);
|
|
22219
22223
|
}
|
|
22220
22224
|
seq.items.push(createNode.createNode(it, void 0, ctx));
|
|
22221
22225
|
}
|
|
@@ -22249,7 +22253,7 @@ var require_seq = __commonJS({
|
|
|
22249
22253
|
onError("Expected a sequence for this tag");
|
|
22250
22254
|
return seq2;
|
|
22251
22255
|
},
|
|
22252
|
-
createNode: (schema,
|
|
22256
|
+
createNode: (schema, obj2, ctx) => YAMLSeq.YAMLSeq.from(schema, obj2, ctx)
|
|
22253
22257
|
};
|
|
22254
22258
|
exports.seq = seq;
|
|
22255
22259
|
}
|
|
@@ -27468,15 +27472,15 @@ var init_mcps_source = __esm({
|
|
|
27468
27472
|
});
|
|
27469
27473
|
}
|
|
27470
27474
|
}
|
|
27471
|
-
async *fromObject(
|
|
27472
|
-
if (!
|
|
27475
|
+
async *fromObject(obj2, ctx) {
|
|
27476
|
+
if (!obj2 || typeof obj2 !== "object")
|
|
27473
27477
|
return;
|
|
27474
27478
|
let mtime = 0;
|
|
27475
27479
|
try {
|
|
27476
27480
|
mtime = statSync37(ctx.filePath).mtimeMs;
|
|
27477
27481
|
} catch {
|
|
27478
27482
|
}
|
|
27479
|
-
for (const [name, cfgRaw] of Object.entries(
|
|
27483
|
+
for (const [name, cfgRaw] of Object.entries(obj2)) {
|
|
27480
27484
|
const cfg = cfgRaw || {};
|
|
27481
27485
|
const cmd = redactInlineSecrets(commandPreview(cfg)).text;
|
|
27482
27486
|
const allow = Array.isArray(cfg.alwaysAllow) ? cfg.alwaysAllow.slice(0, 8) : [];
|
|
@@ -28848,7 +28852,7 @@ var init_http = __esm({
|
|
|
28848
28852
|
CLI_VERSION = JSON.parse(readFileSync41(new URL("../package.json", import.meta.url), "utf-8")).version || CLI_VERSION;
|
|
28849
28853
|
} catch {
|
|
28850
28854
|
try {
|
|
28851
|
-
if (true) CLI_VERSION = "0.7.
|
|
28855
|
+
if (true) CLI_VERSION = "0.7.23";
|
|
28852
28856
|
} catch {
|
|
28853
28857
|
}
|
|
28854
28858
|
}
|
|
@@ -29232,7 +29236,7 @@ function serverAllowsTelemetry(serverUrl) {
|
|
|
29232
29236
|
function mayReport(serverUrl) {
|
|
29233
29237
|
return userConsents() && serverAllowsTelemetry(serverUrl);
|
|
29234
29238
|
}
|
|
29235
|
-
function findSensitiveKeys(
|
|
29239
|
+
function findSensitiveKeys(obj2, where = "") {
|
|
29236
29240
|
const out = [];
|
|
29237
29241
|
const walk = (v, at) => {
|
|
29238
29242
|
if (!v || typeof v !== "object") return;
|
|
@@ -29245,7 +29249,7 @@ function findSensitiveKeys(obj, where = "") {
|
|
|
29245
29249
|
walk(val, at ? `${at}.${k}` : k);
|
|
29246
29250
|
}
|
|
29247
29251
|
};
|
|
29248
|
-
walk(
|
|
29252
|
+
walk(obj2, where);
|
|
29249
29253
|
return out;
|
|
29250
29254
|
}
|
|
29251
29255
|
function assertNoSensitiveKeys(payload) {
|
|
@@ -29346,7 +29350,7 @@ var init_telemetry = __esm({
|
|
|
29346
29350
|
init_sync_client();
|
|
29347
29351
|
cliVersion2 = () => {
|
|
29348
29352
|
try {
|
|
29349
|
-
return true ? "0.7.
|
|
29353
|
+
return true ? "0.7.23" : "dev";
|
|
29350
29354
|
} catch {
|
|
29351
29355
|
return "dev";
|
|
29352
29356
|
}
|
|
@@ -31741,7 +31745,7 @@ var init_sync_client = __esm({
|
|
|
31741
31745
|
ownVersion = JSON.parse(readFileSync44(join55(dir, "../package.json"), "utf-8")).version || ownVersion;
|
|
31742
31746
|
} catch {
|
|
31743
31747
|
try {
|
|
31744
|
-
if (true) ownVersion = "0.7.
|
|
31748
|
+
if (true) ownVersion = "0.7.23";
|
|
31745
31749
|
} catch {
|
|
31746
31750
|
}
|
|
31747
31751
|
}
|
|
@@ -32563,6 +32567,7 @@ __export(guard_registration_exports, {
|
|
|
32563
32567
|
guardTargets: () => guardTargets,
|
|
32564
32568
|
guardWrapperName: () => guardWrapperName,
|
|
32565
32569
|
guardWrapperSource: () => guardWrapperSource,
|
|
32570
|
+
legacyAgyHooksFile: () => legacyAgyHooksFile,
|
|
32566
32571
|
opencodeConfigDir: () => opencodeConfigDir,
|
|
32567
32572
|
opencodePluginDir: () => opencodePluginDir,
|
|
32568
32573
|
opencodePluginSource: () => opencodePluginSource,
|
|
@@ -32571,6 +32576,9 @@ __export(guard_registration_exports, {
|
|
|
32571
32576
|
});
|
|
32572
32577
|
import { homedir as homedir20 } from "os";
|
|
32573
32578
|
import { join as join60 } from "path";
|
|
32579
|
+
function legacyAgyHooksFile() {
|
|
32580
|
+
return join60(agyBackend.homeDir(), "hooks.json");
|
|
32581
|
+
}
|
|
32574
32582
|
function opencodeConfigDir() {
|
|
32575
32583
|
const xdg = process.env.XDG_CONFIG_HOME;
|
|
32576
32584
|
const base2 = xdg && xdg.trim() ? xdg : join60(homedir20(), ".config");
|
|
@@ -32597,7 +32605,7 @@ function guardTargets() {
|
|
|
32597
32605
|
{
|
|
32598
32606
|
tool: "agy",
|
|
32599
32607
|
label: "Antigravity",
|
|
32600
|
-
configPath:
|
|
32608
|
+
configPath: agyBackend.sharedHooksFile(),
|
|
32601
32609
|
homeDir: agyBackend.homeDir()
|
|
32602
32610
|
},
|
|
32603
32611
|
{
|
|
@@ -32747,14 +32755,24 @@ function ask(payload) {
|
|
|
32747
32755
|
});
|
|
32748
32756
|
}
|
|
32749
32757
|
|
|
32750
|
-
|
|
32751
|
-
|
|
32752
|
-
|
|
32753
|
-
|
|
32754
|
-
|
|
32755
|
-
|
|
32756
|
-
|
|
32757
|
-
|
|
32758
|
+
async function check(tool, args) {
|
|
32759
|
+
const verdict = await ask({ tool, args });
|
|
32760
|
+
if (!verdict || !verdict.message) return;
|
|
32761
|
+
if (verdict.block) throw new Error(verdict.message);
|
|
32762
|
+
console.error(verdict.message);
|
|
32763
|
+
}
|
|
32764
|
+
|
|
32765
|
+
async function setup(ctx) {
|
|
32766
|
+
await ctx.tool.hook("execute.before", (event) => check(event?.tool, event?.input));
|
|
32767
|
+
}
|
|
32768
|
+
|
|
32769
|
+
async function server() {
|
|
32770
|
+
return {
|
|
32771
|
+
"tool.execute.before": (input, output) => check(input?.tool, output?.args),
|
|
32772
|
+
};
|
|
32773
|
+
}
|
|
32774
|
+
|
|
32775
|
+
export default { id: "${GUARD_ID}", server, setup };
|
|
32758
32776
|
`;
|
|
32759
32777
|
}
|
|
32760
32778
|
var GUARD_ID, AGY_MATCHER, CODEX_MATCHER, TIMEOUT_SECS, isOurs, asArray2;
|
|
@@ -32771,6 +32789,336 @@ var init_guard_registration = __esm({
|
|
|
32771
32789
|
}
|
|
32772
32790
|
});
|
|
32773
32791
|
|
|
32792
|
+
// ../engine/dist/core/message-registration.js
|
|
32793
|
+
var message_registration_exports = {};
|
|
32794
|
+
__export(message_registration_exports, {
|
|
32795
|
+
MESSAGES_ID: () => MESSAGES_ID,
|
|
32796
|
+
isOurPluginSource: () => isOurPluginSource,
|
|
32797
|
+
messageCommand: () => messageCommand,
|
|
32798
|
+
messageTargets: () => messageTargets,
|
|
32799
|
+
messageWrapperName: () => messageWrapperName,
|
|
32800
|
+
messageWrapperSource: () => messageWrapperSource,
|
|
32801
|
+
opencodeMessagesSource: () => opencodeMessagesSource,
|
|
32802
|
+
piAgentDir: () => piAgentDir,
|
|
32803
|
+
piMessagesSource: () => piMessagesSource,
|
|
32804
|
+
registerMessages: () => registerMessages,
|
|
32805
|
+
unregisterMessages: () => unregisterMessages
|
|
32806
|
+
});
|
|
32807
|
+
import { homedir as homedir21 } from "os";
|
|
32808
|
+
import { join as join61 } from "path";
|
|
32809
|
+
function piAgentDir() {
|
|
32810
|
+
const dir = process.env.PI_CODING_AGENT_DIR;
|
|
32811
|
+
return dir && dir.trim() ? dir : join61(homedir21(), ".pi", "agent");
|
|
32812
|
+
}
|
|
32813
|
+
function messageTargets() {
|
|
32814
|
+
return [
|
|
32815
|
+
{
|
|
32816
|
+
tool: "codex",
|
|
32817
|
+
label: "Codex",
|
|
32818
|
+
configPath: join61(codexBackend.homeDir(), "hooks.json"),
|
|
32819
|
+
homeDir: codexBackend.homeDir(),
|
|
32820
|
+
// Codex binds its approval to the hook's hash, and only a person can give it.
|
|
32821
|
+
note: "Codex asks you to approve a hook before it runs one. Run /hooks in Codex once to approve the message hook."
|
|
32822
|
+
},
|
|
32823
|
+
{
|
|
32824
|
+
tool: "agy",
|
|
32825
|
+
label: "Antigravity",
|
|
32826
|
+
configPath: agyBackend.sharedHooksFile(),
|
|
32827
|
+
homeDir: agyBackend.homeDir()
|
|
32828
|
+
},
|
|
32829
|
+
{
|
|
32830
|
+
tool: "cursor",
|
|
32831
|
+
label: "Cursor",
|
|
32832
|
+
configPath: join61(cursorBackend.homeDir(), "hooks.json"),
|
|
32833
|
+
homeDir: cursorBackend.homeDir(),
|
|
32834
|
+
note: "Cursor delivers a message at the start of a session and when the agent stops, as a follow-up prompt."
|
|
32835
|
+
},
|
|
32836
|
+
{
|
|
32837
|
+
tool: "opencode",
|
|
32838
|
+
label: "OpenCode",
|
|
32839
|
+
configPath: join61(opencodePluginDir(), `${MESSAGES_ID}.js`),
|
|
32840
|
+
homeDir: opencodeConfigDir()
|
|
32841
|
+
},
|
|
32842
|
+
{
|
|
32843
|
+
tool: "pi",
|
|
32844
|
+
label: "pi",
|
|
32845
|
+
configPath: join61(piAgentDir(), "extensions", `${MESSAGES_ID}.js`),
|
|
32846
|
+
homeDir: piAgentDir()
|
|
32847
|
+
}
|
|
32848
|
+
];
|
|
32849
|
+
}
|
|
32850
|
+
function messageWrapperName(tool) {
|
|
32851
|
+
return `chat_recall_messages_${tool}.sh`;
|
|
32852
|
+
}
|
|
32853
|
+
function messageWrapperSource(tool, nodePath, hookEntry) {
|
|
32854
|
+
return `#!/bin/sh
|
|
32855
|
+
# Written by \`chat-recall install-hooks\`. Re-running replaces it.
|
|
32856
|
+
exec ${JSON.stringify(nodePath)} ${JSON.stringify(hookEntry)} --tool ${tool} "$@"
|
|
32857
|
+
`;
|
|
32858
|
+
}
|
|
32859
|
+
function messageCommand(wrapperPath, args = "") {
|
|
32860
|
+
const p = wrapperPath.includes(" ") ? `"${wrapperPath}"` : wrapperPath;
|
|
32861
|
+
return args ? `${p} ${args}` : p;
|
|
32862
|
+
}
|
|
32863
|
+
function mergeCodex2(config2, command) {
|
|
32864
|
+
const c = obj(config2);
|
|
32865
|
+
const hooks = obj(c.hooks);
|
|
32866
|
+
for (const event of CODEX_EVENTS) {
|
|
32867
|
+
const kept = asArray3(hooks[event]).filter((e) => !asArray3(e?.hooks).some((h) => isOurs2(h?.command)));
|
|
32868
|
+
kept.push({ hooks: [{ type: "command", command, timeout: TIMEOUT_SECS2 }] });
|
|
32869
|
+
hooks[event] = kept;
|
|
32870
|
+
}
|
|
32871
|
+
c.hooks = hooks;
|
|
32872
|
+
return c;
|
|
32873
|
+
}
|
|
32874
|
+
function stripCodex2(config2) {
|
|
32875
|
+
const c = obj(config2);
|
|
32876
|
+
const hooks = obj(c.hooks);
|
|
32877
|
+
let removed = 0;
|
|
32878
|
+
for (const event of CODEX_EVENTS) {
|
|
32879
|
+
const before = asArray3(hooks[event]);
|
|
32880
|
+
const kept = before.filter((e) => !asArray3(e?.hooks).some((h) => isOurs2(h?.command)));
|
|
32881
|
+
removed += before.length - kept.length;
|
|
32882
|
+
if (kept.length)
|
|
32883
|
+
hooks[event] = kept;
|
|
32884
|
+
else
|
|
32885
|
+
delete hooks[event];
|
|
32886
|
+
}
|
|
32887
|
+
if (Object.keys(hooks).length)
|
|
32888
|
+
c.hooks = hooks;
|
|
32889
|
+
else
|
|
32890
|
+
delete c.hooks;
|
|
32891
|
+
return { config: c, removed };
|
|
32892
|
+
}
|
|
32893
|
+
function mergeAgy2(config2, command) {
|
|
32894
|
+
const c = obj(config2);
|
|
32895
|
+
const run2 = (event) => [{ type: "command", command: `${command} --event ${event}`, timeout: TIMEOUT_SECS2 }];
|
|
32896
|
+
c[MESSAGES_ID] = {
|
|
32897
|
+
enabled: true,
|
|
32898
|
+
SessionStart: run2("SessionStart"),
|
|
32899
|
+
PreInvocation: run2("PreInvocation"),
|
|
32900
|
+
Stop: run2("Stop")
|
|
32901
|
+
};
|
|
32902
|
+
return c;
|
|
32903
|
+
}
|
|
32904
|
+
function stripAgy2(config2) {
|
|
32905
|
+
const c = obj(config2);
|
|
32906
|
+
const had = Object.prototype.hasOwnProperty.call(c, MESSAGES_ID) ? 1 : 0;
|
|
32907
|
+
delete c[MESSAGES_ID];
|
|
32908
|
+
return { config: c, removed: had };
|
|
32909
|
+
}
|
|
32910
|
+
function mergeCursor2(config2, command) {
|
|
32911
|
+
const c = obj(config2);
|
|
32912
|
+
c.version = typeof c.version === "number" ? c.version : 1;
|
|
32913
|
+
const hooks = obj(c.hooks);
|
|
32914
|
+
for (const event of CURSOR_EVENTS) {
|
|
32915
|
+
const kept = asArray3(hooks[event]).filter((e) => !isOurs2(e?.command));
|
|
32916
|
+
kept.push({ command, timeout: TIMEOUT_SECS2 });
|
|
32917
|
+
hooks[event] = kept;
|
|
32918
|
+
}
|
|
32919
|
+
c.hooks = hooks;
|
|
32920
|
+
return c;
|
|
32921
|
+
}
|
|
32922
|
+
function stripCursor2(config2) {
|
|
32923
|
+
const c = obj(config2);
|
|
32924
|
+
const hooks = obj(c.hooks);
|
|
32925
|
+
let removed = 0;
|
|
32926
|
+
for (const event of CURSOR_EVENTS) {
|
|
32927
|
+
const before = asArray3(hooks[event]);
|
|
32928
|
+
const kept = before.filter((e) => !isOurs2(e?.command));
|
|
32929
|
+
removed += before.length - kept.length;
|
|
32930
|
+
if (kept.length)
|
|
32931
|
+
hooks[event] = kept;
|
|
32932
|
+
else
|
|
32933
|
+
delete hooks[event];
|
|
32934
|
+
}
|
|
32935
|
+
c.hooks = hooks;
|
|
32936
|
+
return { config: c, removed };
|
|
32937
|
+
}
|
|
32938
|
+
function registerMessages(tool, config2, command) {
|
|
32939
|
+
switch (tool) {
|
|
32940
|
+
case "codex":
|
|
32941
|
+
return mergeCodex2(config2, command);
|
|
32942
|
+
case "agy":
|
|
32943
|
+
return mergeAgy2(config2, command);
|
|
32944
|
+
case "cursor":
|
|
32945
|
+
return mergeCursor2(config2, command);
|
|
32946
|
+
}
|
|
32947
|
+
}
|
|
32948
|
+
function unregisterMessages(tool, config2) {
|
|
32949
|
+
switch (tool) {
|
|
32950
|
+
case "codex":
|
|
32951
|
+
return stripCodex2(config2);
|
|
32952
|
+
case "agy":
|
|
32953
|
+
return stripAgy2(config2);
|
|
32954
|
+
case "cursor":
|
|
32955
|
+
return stripCursor2(config2);
|
|
32956
|
+
}
|
|
32957
|
+
}
|
|
32958
|
+
function isOurPluginSource(source) {
|
|
32959
|
+
return source.includes(`${MESSAGES_ID}: written by`);
|
|
32960
|
+
}
|
|
32961
|
+
function runnerSource(wrapperPath) {
|
|
32962
|
+
return `import { spawn } from "child_process";
|
|
32963
|
+
|
|
32964
|
+
const HOOK = ${JSON.stringify(wrapperPath)};
|
|
32965
|
+
|
|
32966
|
+
function runHook(sessionId, event, cwd) {
|
|
32967
|
+
return new Promise((resolve) => {
|
|
32968
|
+
let out = "";
|
|
32969
|
+
let child;
|
|
32970
|
+
try {
|
|
32971
|
+
child = spawn(HOOK, [], { stdio: ["pipe", "pipe", "ignore"] });
|
|
32972
|
+
} catch {
|
|
32973
|
+
resolve("");
|
|
32974
|
+
return;
|
|
32975
|
+
}
|
|
32976
|
+
const done = setTimeout(() => { child.kill(); resolve(""); }, ${TIMEOUT_SECS2 * 1e3});
|
|
32977
|
+
child.stdout.on("data", (c) => { out += c; });
|
|
32978
|
+
child.on("error", () => { clearTimeout(done); resolve(""); });
|
|
32979
|
+
child.on("close", () => { clearTimeout(done); resolve(out.trim()); });
|
|
32980
|
+
child.stdin.end(JSON.stringify({ session_id: sessionId, hook_event_name: event, cwd }));
|
|
32981
|
+
});
|
|
32982
|
+
}
|
|
32983
|
+
`;
|
|
32984
|
+
}
|
|
32985
|
+
function opencodeMessagesSource(wrapperPath) {
|
|
32986
|
+
return `// ${MESSAGES_ID}: written by \`chat-recall install-hooks\`. Re-running replaces it.
|
|
32987
|
+
//
|
|
32988
|
+
// Reports each opencode session to chat-recall and adds the messages that
|
|
32989
|
+
// other sessions sent it to the next prompt.
|
|
32990
|
+
${runnerSource(wrapperPath)}
|
|
32991
|
+
const RUN_END = new Set(["session.execution.succeeded", "session.execution.failed", "session.execution.interrupted", "session.idle"]);
|
|
32992
|
+
|
|
32993
|
+
async function setup(ctx) {
|
|
32994
|
+
const dir = ctx?.location?.directory;
|
|
32995
|
+
const started = new Set();
|
|
32996
|
+
const children = new Set();
|
|
32997
|
+
const isChild = async (id) => {
|
|
32998
|
+
if (children.has(id)) return true;
|
|
32999
|
+
try {
|
|
33000
|
+
const s = await ctx.session.get({ sessionID: id });
|
|
33001
|
+
if (s?.parentID) { children.add(id); return true; }
|
|
33002
|
+
} catch { /* unknown: treat as a main session */ }
|
|
33003
|
+
return false;
|
|
33004
|
+
};
|
|
33005
|
+
await ctx.session.hook("prompt", async (event) => {
|
|
33006
|
+
const id = event?.sessionID;
|
|
33007
|
+
if (!id || !event.prompt || (await isChild(id))) return;
|
|
33008
|
+
const parts = [];
|
|
33009
|
+
if (!started.has(id)) {
|
|
33010
|
+
started.add(id);
|
|
33011
|
+
parts.push(await runHook("opencode_" + id, "SessionStart", dir));
|
|
33012
|
+
}
|
|
33013
|
+
parts.push(await runHook("opencode_" + id, "UserPromptSubmit", dir));
|
|
33014
|
+
const text = parts.filter(Boolean).join("\\n\\n");
|
|
33015
|
+
if (text) event.prompt.text = [event.prompt.text, text].filter(Boolean).join("\\n\\n");
|
|
33016
|
+
});
|
|
33017
|
+
const controller = new AbortController();
|
|
33018
|
+
(async () => {
|
|
33019
|
+
try {
|
|
33020
|
+
for await (const ev of ctx.event.subscribe({ signal: controller.signal })) {
|
|
33021
|
+
const id = ev?.data?.sessionID ?? ev?.properties?.sessionID;
|
|
33022
|
+
if (!id || !started.has(id)) continue;
|
|
33023
|
+
if (RUN_END.has(ev.type)) await runHook("opencode_" + id, "Stop", dir);
|
|
33024
|
+
else if (ev.type === "session.deleted") {
|
|
33025
|
+
started.delete(id);
|
|
33026
|
+
await runHook("opencode_" + id, "SessionEnd", dir);
|
|
33027
|
+
}
|
|
33028
|
+
}
|
|
33029
|
+
} catch { /* the subscription ends with the plugin */ }
|
|
33030
|
+
})();
|
|
33031
|
+
return () => controller.abort();
|
|
33032
|
+
}
|
|
33033
|
+
|
|
33034
|
+
const pending = new Map();
|
|
33035
|
+
const children = new Set();
|
|
33036
|
+
let seq = 0;
|
|
33037
|
+
|
|
33038
|
+
function partId() {
|
|
33039
|
+
seq += 1;
|
|
33040
|
+
return "prt_" + Date.now().toString(16) + seq.toString(16).padStart(4, "0") + "chatrecall";
|
|
33041
|
+
}
|
|
33042
|
+
|
|
33043
|
+
async function server({ directory }) {
|
|
33044
|
+
return {
|
|
33045
|
+
event: async ({ event }) => {
|
|
33046
|
+
const info = event?.properties?.info;
|
|
33047
|
+
if (event?.type === "session.created" && info?.id) {
|
|
33048
|
+
if (info.parentID) { children.add(info.id); return; }
|
|
33049
|
+
const text = await runHook("opencode_" + info.id, "SessionStart", directory);
|
|
33050
|
+
if (text) pending.set(info.id, text);
|
|
33051
|
+
} else if (event?.type === "session.idle" && event.properties?.sessionID && !children.has(event.properties.sessionID)) {
|
|
33052
|
+
await runHook("opencode_" + event.properties.sessionID, "Stop", directory);
|
|
33053
|
+
} else if (event?.type === "session.deleted" && info?.id) {
|
|
33054
|
+
children.delete(info.id);
|
|
33055
|
+
pending.delete(info.id);
|
|
33056
|
+
await runHook("opencode_" + info.id, "SessionEnd", directory);
|
|
33057
|
+
}
|
|
33058
|
+
},
|
|
33059
|
+
"chat.message": async (input, output) => {
|
|
33060
|
+
const id = input?.sessionID;
|
|
33061
|
+
if (!id || children.has(id) || !output?.message) return;
|
|
33062
|
+
const before = pending.get(id) ?? "";
|
|
33063
|
+
pending.delete(id);
|
|
33064
|
+
const now = await runHook("opencode_" + id, "UserPromptSubmit", directory);
|
|
33065
|
+
const text = [before, now].filter(Boolean).join("\\n\\n");
|
|
33066
|
+
if (!text) return;
|
|
33067
|
+
output.parts.push({ id: partId(), sessionID: id, messageID: output.message.id, type: "text", text, synthetic: true });
|
|
33068
|
+
},
|
|
33069
|
+
};
|
|
33070
|
+
}
|
|
33071
|
+
|
|
33072
|
+
export default { id: "${MESSAGES_ID}", server, setup };
|
|
33073
|
+
`;
|
|
33074
|
+
}
|
|
33075
|
+
function piMessagesSource(wrapperPath) {
|
|
33076
|
+
return `// ${MESSAGES_ID}: written by \`chat-recall install-hooks\`. Re-running replaces it.
|
|
33077
|
+
//
|
|
33078
|
+
// Reports each pi session to chat-recall and adds the messages that other
|
|
33079
|
+
// sessions sent it to the next prompt.
|
|
33080
|
+
${runnerSource(wrapperPath)}
|
|
33081
|
+
export default function (pi) {
|
|
33082
|
+
let pending = "";
|
|
33083
|
+
const idOf = (ctx) => "pi_" + ctx.sessionManager.getSessionId();
|
|
33084
|
+
const cwdOf = (ctx) => ctx.sessionManager.getCwd();
|
|
33085
|
+
|
|
33086
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
33087
|
+
pending = await runHook(idOf(ctx), "SessionStart", cwdOf(ctx));
|
|
33088
|
+
});
|
|
33089
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
33090
|
+
if (event.messageType !== "user") return;
|
|
33091
|
+
const now = await runHook(idOf(ctx), "UserPromptSubmit", cwdOf(ctx));
|
|
33092
|
+
const text = [pending, now].filter(Boolean).join("\\n\\n");
|
|
33093
|
+
pending = "";
|
|
33094
|
+
if (!text) return;
|
|
33095
|
+
return { message: { customType: "${MESSAGES_ID}", content: text, display: true } };
|
|
33096
|
+
});
|
|
33097
|
+
pi.on("agent_end", async (_event, ctx) => {
|
|
33098
|
+
await runHook(idOf(ctx), "Stop", cwdOf(ctx));
|
|
33099
|
+
});
|
|
33100
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
33101
|
+
await runHook(idOf(ctx), "SessionEnd", cwdOf(ctx));
|
|
33102
|
+
});
|
|
33103
|
+
}
|
|
33104
|
+
`;
|
|
33105
|
+
}
|
|
33106
|
+
var MESSAGES_ID, TIMEOUT_SECS2, isOurs2, asArray3, obj, CODEX_EVENTS, CURSOR_EVENTS;
|
|
33107
|
+
var init_message_registration = __esm({
|
|
33108
|
+
"../engine/dist/core/message-registration.js"() {
|
|
33109
|
+
"use strict";
|
|
33110
|
+
init_backends();
|
|
33111
|
+
init_guard_registration();
|
|
33112
|
+
MESSAGES_ID = "chat-recall-messages";
|
|
33113
|
+
TIMEOUT_SECS2 = 10;
|
|
33114
|
+
isOurs2 = (cmd) => typeof cmd === "string" && cmd.includes("chat_recall_messages_");
|
|
33115
|
+
asArray3 = (v) => Array.isArray(v) ? v : [];
|
|
33116
|
+
obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? { ...v } : {};
|
|
33117
|
+
CODEX_EVENTS = ["SessionStart", "UserPromptSubmit", "Stop", "SessionEnd"];
|
|
33118
|
+
CURSOR_EVENTS = ["sessionStart", "beforeSubmitPrompt", "stop", "sessionEnd"];
|
|
33119
|
+
}
|
|
33120
|
+
});
|
|
33121
|
+
|
|
32774
33122
|
// src/install-hooks.ts
|
|
32775
33123
|
var install_hooks_exports = {};
|
|
32776
33124
|
__export(install_hooks_exports, {
|
|
@@ -32786,7 +33134,7 @@ __export(install_hooks_exports, {
|
|
|
32786
33134
|
uninstallHooks: () => uninstallHooks
|
|
32787
33135
|
});
|
|
32788
33136
|
import { chmodSync as chmodSync7, copyFileSync as copyFileSync3, existsSync as existsSync51, mkdirSync as mkdirSync16, readFileSync as readFileSync49, realpathSync as realpathSync6, renameSync as renameSync6, unlinkSync as unlinkSync4, writeFileSync as writeFileSync14 } from "node:fs";
|
|
32789
|
-
import { dirname as dirname21, join as
|
|
33137
|
+
import { dirname as dirname21, join as join62 } from "node:path";
|
|
32790
33138
|
function isOurEntry(entry) {
|
|
32791
33139
|
const cmd = entry?.hooks?.[0]?.command;
|
|
32792
33140
|
if (typeof cmd !== "string") return false;
|
|
@@ -32796,8 +33144,8 @@ function claudeSettingsFiles() {
|
|
|
32796
33144
|
const out = [];
|
|
32797
33145
|
const seen = /* @__PURE__ */ new Set();
|
|
32798
33146
|
for (const home of claudeHomeDirs()) {
|
|
32799
|
-
if (!existsSync51(
|
|
32800
|
-
const file =
|
|
33147
|
+
if (!existsSync51(join62(home, "projects"))) continue;
|
|
33148
|
+
const file = join62(home, "settings.json");
|
|
32801
33149
|
let key2;
|
|
32802
33150
|
try {
|
|
32803
33151
|
key2 = realpathSync6(file);
|
|
@@ -32813,9 +33161,9 @@ function claudeSettingsFiles() {
|
|
|
32813
33161
|
}
|
|
32814
33162
|
function findScript(distDir, name) {
|
|
32815
33163
|
return [
|
|
32816
|
-
|
|
32817
|
-
|
|
32818
|
-
|
|
33164
|
+
join62(distDir, "..", "hooks", name),
|
|
33165
|
+
join62(distDir, "..", "..", "hooks", name),
|
|
33166
|
+
join62(distDir, "..", "..", "..", "hooks", name)
|
|
32819
33167
|
].find((p) => existsSync51(p));
|
|
32820
33168
|
}
|
|
32821
33169
|
function hookEntries(sel, paths) {
|
|
@@ -32880,7 +33228,7 @@ function writeJsonAtomic(file, value) {
|
|
|
32880
33228
|
renameSync6(tmp, target);
|
|
32881
33229
|
}
|
|
32882
33230
|
function statePath() {
|
|
32883
|
-
return
|
|
33231
|
+
return join62(getHooksDir(), "install.json");
|
|
32884
33232
|
}
|
|
32885
33233
|
function readState() {
|
|
32886
33234
|
try {
|
|
@@ -32898,7 +33246,7 @@ async function installHooks(distDir, sel = ALL_HOOKS) {
|
|
|
32898
33246
|
if (!sel[key2]) continue;
|
|
32899
33247
|
const source = findScript(distDir, SCRIPTS[key2]);
|
|
32900
33248
|
if (!source) continue;
|
|
32901
|
-
const target =
|
|
33249
|
+
const target = join62(scriptsDir, SCRIPTS[key2]);
|
|
32902
33250
|
copyFileSync3(source, target);
|
|
32903
33251
|
chmodSync7(target, 493);
|
|
32904
33252
|
scripts[key2] = target;
|
|
@@ -32910,7 +33258,16 @@ async function installHooks(distDir, sel = ALL_HOOKS) {
|
|
|
32910
33258
|
cliEntry: resolveCliEntry(distDir),
|
|
32911
33259
|
messageHookEntry: resolveMessageHookEntry(distDir)
|
|
32912
33260
|
});
|
|
32913
|
-
const report = {
|
|
33261
|
+
const report = {
|
|
33262
|
+
written: [],
|
|
33263
|
+
skipped: [],
|
|
33264
|
+
migrated: 0,
|
|
33265
|
+
shellSkipped,
|
|
33266
|
+
scriptsDir,
|
|
33267
|
+
selection: sel,
|
|
33268
|
+
guardTargets: [],
|
|
33269
|
+
messageTargets: []
|
|
33270
|
+
};
|
|
32914
33271
|
for (const settingsFile of claudeSettingsFiles()) {
|
|
32915
33272
|
const config2 = readJson4(settingsFile);
|
|
32916
33273
|
if (!config2) {
|
|
@@ -32920,9 +33277,12 @@ async function installHooks(distDir, sel = ALL_HOOKS) {
|
|
|
32920
33277
|
mergeOurEntries(config2, entries);
|
|
32921
33278
|
writeJsonAtomic(settingsFile, config2);
|
|
32922
33279
|
report.written.push(settingsFile);
|
|
32923
|
-
report.migrated += migrateHooksJson(
|
|
33280
|
+
report.migrated += migrateHooksJson(join62(dirname21(settingsFile), "hooks.json"));
|
|
32924
33281
|
}
|
|
32925
33282
|
if (sel.guard && scripts.guard) report.guardTargets = await addGuardToOtherTools(scriptsDir, scripts.guard);
|
|
33283
|
+
if (sel.messages && !shellSkipped) {
|
|
33284
|
+
report.messageTargets = await addMessagesToOtherTools(scriptsDir, process.execPath, resolveMessageHookEntry(distDir));
|
|
33285
|
+
}
|
|
32926
33286
|
writeJsonAtomic(statePath(), { version: cliVersion(), selection: sel });
|
|
32927
33287
|
return report;
|
|
32928
33288
|
}
|
|
@@ -32937,9 +33297,9 @@ function migrateHooksJson(file) {
|
|
|
32937
33297
|
return removed;
|
|
32938
33298
|
}
|
|
32939
33299
|
async function uninstallHooks() {
|
|
32940
|
-
const report = { removed: 0, files: [], guardRemoved: [] };
|
|
33300
|
+
const report = { removed: 0, files: [], guardRemoved: [], messagesRemoved: [] };
|
|
32941
33301
|
for (const settingsFile of claudeSettingsFiles()) {
|
|
32942
|
-
for (const file of [settingsFile,
|
|
33302
|
+
for (const file of [settingsFile, join62(dirname21(settingsFile), "hooks.json")]) {
|
|
32943
33303
|
if (!existsSync51(file)) continue;
|
|
32944
33304
|
const config2 = readJson4(file);
|
|
32945
33305
|
if (!config2) continue;
|
|
@@ -32951,6 +33311,7 @@ async function uninstallHooks() {
|
|
|
32951
33311
|
}
|
|
32952
33312
|
}
|
|
32953
33313
|
report.guardRemoved = await removeGuardFromOtherTools();
|
|
33314
|
+
report.messagesRemoved = await removeMessagesFromOtherTools();
|
|
32954
33315
|
writeJsonAtomic(statePath(), { version: cliVersion(), selection: ALL_HOOKS, uninstalled: true });
|
|
32955
33316
|
return report;
|
|
32956
33317
|
}
|
|
@@ -32974,9 +33335,10 @@ async function ensureHooks(distDir) {
|
|
|
32974
33335
|
async function addGuardToOtherTools(scriptsDir, guardScript) {
|
|
32975
33336
|
const reg = await Promise.resolve().then(() => (init_guard_registration(), guard_registration_exports));
|
|
32976
33337
|
const out = [];
|
|
33338
|
+
removeLegacyAgyGuard(reg);
|
|
32977
33339
|
for (const target of reg.guardTargets()) {
|
|
32978
33340
|
if (!existsSync51(target.homeDir)) continue;
|
|
32979
|
-
const wrapper =
|
|
33341
|
+
const wrapper = join62(scriptsDir, reg.guardWrapperName(target.tool));
|
|
32980
33342
|
writeFileSync14(wrapper, reg.guardWrapperSource(target.tool, guardScript));
|
|
32981
33343
|
chmodSync7(wrapper, 493);
|
|
32982
33344
|
mkdirSync16(dirname21(target.configPath), { recursive: true });
|
|
@@ -32993,6 +33355,7 @@ async function addGuardToOtherTools(scriptsDir, guardScript) {
|
|
|
32993
33355
|
async function removeGuardFromOtherTools() {
|
|
32994
33356
|
const reg = await Promise.resolve().then(() => (init_guard_registration(), guard_registration_exports));
|
|
32995
33357
|
const out = [];
|
|
33358
|
+
removeLegacyAgyGuard(reg);
|
|
32996
33359
|
for (const target of reg.guardTargets()) {
|
|
32997
33360
|
if (!existsSync51(target.configPath)) continue;
|
|
32998
33361
|
if (target.tool === "opencode") {
|
|
@@ -33007,6 +33370,53 @@ async function removeGuardFromOtherTools() {
|
|
|
33007
33370
|
}
|
|
33008
33371
|
return out;
|
|
33009
33372
|
}
|
|
33373
|
+
function removeLegacyAgyGuard(reg) {
|
|
33374
|
+
const file = reg.legacyAgyHooksFile();
|
|
33375
|
+
if (!existsSync51(file)) return;
|
|
33376
|
+
const r = reg.unregisterGuard("agy", readJson4(file) ?? {});
|
|
33377
|
+
if (r.removed) writeJsonAtomic(file, r.config);
|
|
33378
|
+
}
|
|
33379
|
+
async function addMessagesToOtherTools(scriptsDir, nodePath, hookEntry) {
|
|
33380
|
+
const reg = await Promise.resolve().then(() => (init_message_registration(), message_registration_exports));
|
|
33381
|
+
const out = [];
|
|
33382
|
+
for (const target of reg.messageTargets()) {
|
|
33383
|
+
if (!existsSync51(target.homeDir)) continue;
|
|
33384
|
+
const wrapper = join62(scriptsDir, reg.messageWrapperName(target.tool));
|
|
33385
|
+
writeFileSync14(wrapper, reg.messageWrapperSource(target.tool, nodePath, hookEntry));
|
|
33386
|
+
chmodSync7(wrapper, 493);
|
|
33387
|
+
mkdirSync16(dirname21(target.configPath), { recursive: true });
|
|
33388
|
+
if (target.tool === "opencode") {
|
|
33389
|
+
writeFileSync14(target.configPath, reg.opencodeMessagesSource(wrapper));
|
|
33390
|
+
} else if (target.tool === "pi") {
|
|
33391
|
+
writeFileSync14(target.configPath, reg.piMessagesSource(wrapper));
|
|
33392
|
+
} else {
|
|
33393
|
+
const config2 = readJson4(target.configPath);
|
|
33394
|
+
if (!config2) continue;
|
|
33395
|
+
writeJsonAtomic(target.configPath, reg.registerMessages(target.tool, config2, reg.messageCommand(wrapper)));
|
|
33396
|
+
}
|
|
33397
|
+
out.push({ label: target.label, configPath: target.configPath, note: target.note });
|
|
33398
|
+
}
|
|
33399
|
+
return out;
|
|
33400
|
+
}
|
|
33401
|
+
async function removeMessagesFromOtherTools() {
|
|
33402
|
+
const reg = await Promise.resolve().then(() => (init_message_registration(), message_registration_exports));
|
|
33403
|
+
const out = [];
|
|
33404
|
+
for (const target of reg.messageTargets()) {
|
|
33405
|
+
if (!existsSync51(target.configPath)) continue;
|
|
33406
|
+
if (target.tool === "opencode" || target.tool === "pi") {
|
|
33407
|
+
if (!reg.isOurPluginSource(readFileSync49(target.configPath, "utf-8"))) continue;
|
|
33408
|
+
unlinkSync4(target.configPath);
|
|
33409
|
+
} else {
|
|
33410
|
+
const config2 = readJson4(target.configPath);
|
|
33411
|
+
if (!config2) continue;
|
|
33412
|
+
const r = reg.unregisterMessages(target.tool, config2);
|
|
33413
|
+
if (r.removed === 0) continue;
|
|
33414
|
+
writeJsonAtomic(target.configPath, r.config);
|
|
33415
|
+
}
|
|
33416
|
+
out.push({ label: target.label, configPath: target.configPath });
|
|
33417
|
+
}
|
|
33418
|
+
return out;
|
|
33419
|
+
}
|
|
33010
33420
|
var ALL_HOOKS, SCRIPTS, HOOK_EVENTS;
|
|
33011
33421
|
var init_install_hooks = __esm({
|
|
33012
33422
|
"src/install-hooks.ts"() {
|
|
@@ -34700,9 +35110,9 @@ var WriteAheadLog = class {
|
|
|
34700
35110
|
logWithResult(operation, params, result) {
|
|
34701
35111
|
this.log(operation, params, result);
|
|
34702
35112
|
}
|
|
34703
|
-
redactSensitive(
|
|
35113
|
+
redactSensitive(obj2) {
|
|
34704
35114
|
const safe = {};
|
|
34705
|
-
for (const [key2, value] of Object.entries(
|
|
35115
|
+
for (const [key2, value] of Object.entries(obj2)) {
|
|
34706
35116
|
if (REDACT_KEYS.has(key2)) {
|
|
34707
35117
|
if (typeof value === "string") {
|
|
34708
35118
|
safe[key2] = value.length <= MAX_PREVIEW_LENGTH ? value : `[${value.length} chars] ${value.slice(0, MAX_PREVIEW_LENGTH)}...`;
|
|
@@ -39754,7 +40164,7 @@ function installCrashGuards() {
|
|
|
39754
40164
|
reportClientEvent2("mcp_crash", { message: err.stack || err.message });
|
|
39755
40165
|
});
|
|
39756
40166
|
}
|
|
39757
|
-
var RELAY_VERSION = true ? "0.7.
|
|
40167
|
+
var RELAY_VERSION = true ? "0.7.23" : "0.0.0";
|
|
39758
40168
|
function daemonIdleSecs() {
|
|
39759
40169
|
const raw = process.env.CHAT_RECALL_DAEMON_IDLE_SECS;
|
|
39760
40170
|
if (raw === void 0) return 900;
|