@ascenda-one/gemini-hooks 0.1.33 → 0.1.34
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 +3 -1
- package/dist/cli.js +1053 -243
- package/dist/cli.js.map +1 -1
- package/dist/liveSignal.js +7 -5
- package/dist/liveSignal.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -961,7 +961,7 @@ var require_collectorVersion = __commonJS({
|
|
|
961
961
|
exports.COLLECTOR_VERSION = exports.UNRELEASED_COLLECTOR_VERSION = void 0;
|
|
962
962
|
exports.describeCollectorVersion = describeCollectorVersion;
|
|
963
963
|
exports.UNRELEASED_COLLECTOR_VERSION = "unreleased";
|
|
964
|
-
exports.COLLECTOR_VERSION = "0.1.
|
|
964
|
+
exports.COLLECTOR_VERSION = "0.1.34" ? "0.1.34" : exports.UNRELEASED_COLLECTOR_VERSION;
|
|
965
965
|
function describeCollectorVersion(version = exports.COLLECTOR_VERSION) {
|
|
966
966
|
return version === exports.UNRELEASED_COLLECTOR_VERSION ? `${version} (built from a checkout, not a release)` : version;
|
|
967
967
|
}
|
|
@@ -3670,6 +3670,771 @@ var require_setupDisclosure = __commonJS({
|
|
|
3670
3670
|
}
|
|
3671
3671
|
});
|
|
3672
3672
|
|
|
3673
|
+
// ../packages/tool-kit/out/hookRunner.js
|
|
3674
|
+
var require_hookRunner = __commonJS({
|
|
3675
|
+
"../packages/tool-kit/out/hookRunner.js"(exports) {
|
|
3676
|
+
"use strict";
|
|
3677
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3678
|
+
if (k2 === void 0) k2 = k;
|
|
3679
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3680
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3681
|
+
desc = { enumerable: true, get: function() {
|
|
3682
|
+
return m[k];
|
|
3683
|
+
} };
|
|
3684
|
+
}
|
|
3685
|
+
Object.defineProperty(o, k2, desc);
|
|
3686
|
+
} : function(o, m, k, k2) {
|
|
3687
|
+
if (k2 === void 0) k2 = k;
|
|
3688
|
+
o[k2] = m[k];
|
|
3689
|
+
});
|
|
3690
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
3691
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
3692
|
+
} : function(o, v) {
|
|
3693
|
+
o["default"] = v;
|
|
3694
|
+
});
|
|
3695
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
3696
|
+
var ownKeys = function(o) {
|
|
3697
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
3698
|
+
var ar = [];
|
|
3699
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
3700
|
+
return ar;
|
|
3701
|
+
};
|
|
3702
|
+
return ownKeys(o);
|
|
3703
|
+
};
|
|
3704
|
+
return function(mod) {
|
|
3705
|
+
if (mod && mod.__esModule) return mod;
|
|
3706
|
+
var result = {};
|
|
3707
|
+
if (mod != null) {
|
|
3708
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
3709
|
+
}
|
|
3710
|
+
__setModuleDefault(result, mod);
|
|
3711
|
+
return result;
|
|
3712
|
+
};
|
|
3713
|
+
}();
|
|
3714
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3715
|
+
exports.hookRunnerPaths = hookRunnerPaths;
|
|
3716
|
+
exports.hookLauncherScript = hookLauncherScript;
|
|
3717
|
+
exports.installHookRunner = installHookRunner;
|
|
3718
|
+
exports.removeHookRunner = removeHookRunner;
|
|
3719
|
+
exports.hookRunnerCommand = hookRunnerCommand;
|
|
3720
|
+
exports.lastHookPath = lastHookPath;
|
|
3721
|
+
exports.stampLastHook = stampLastHook2;
|
|
3722
|
+
exports.readLastHook = readLastHook;
|
|
3723
|
+
exports.describeAge = describeAge;
|
|
3724
|
+
exports.resolveHookNode = resolveHookNode;
|
|
3725
|
+
exports.tidyHomePath = tidyHomePath;
|
|
3726
|
+
var child_process_1 = __require("child_process");
|
|
3727
|
+
var fs = __importStar(__require("fs"));
|
|
3728
|
+
var path2 = __importStar(__require("path"));
|
|
3729
|
+
var tokenStore_1 = require_tokenStore();
|
|
3730
|
+
function hookRunnerPaths(binaryName) {
|
|
3731
|
+
const launcher = path2.join((0, tokenStore_1.ascendaHome)(), "bin", binaryName);
|
|
3732
|
+
return { launcher, bundle: `${launcher}.mjs`, record: `${launcher}.node`, noNode: `${launcher}.no-node` };
|
|
3733
|
+
}
|
|
3734
|
+
var LAUNCHER_MANAGEMENT_COMMANDS = ["setup", "install", "status", "uninstall", "doctor", "pair", "join", "object", "-h", "--help"];
|
|
3735
|
+
function hookLauncherScript(options) {
|
|
3736
|
+
const { binaryName, setupCommand, loudEvent } = options;
|
|
3737
|
+
return [
|
|
3738
|
+
"#!/bin/sh",
|
|
3739
|
+
`# Ascenda hook launcher (${binaryName}). Written by \`setup\`, replaced by the`,
|
|
3740
|
+
"# next one; edits here are lost. Finds a Node to run the hook bundle beside it.",
|
|
3741
|
+
"",
|
|
3742
|
+
'dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) || exit 0',
|
|
3743
|
+
`bundle="$dir/${binaryName}.mjs"`,
|
|
3744
|
+
`record="$dir/${binaryName}.node"`,
|
|
3745
|
+
`missing="$dir/${binaryName}.no-node"`,
|
|
3746
|
+
"",
|
|
3747
|
+
'runs() { [ -n "$1" ] && [ -f "$1" ] && [ -x "$1" ]; }',
|
|
3748
|
+
"",
|
|
3749
|
+
"# The hook bundle needs Node 20 or newer. Checked only while searching, so",
|
|
3750
|
+
"# the recorded path costs nothing to reuse.",
|
|
3751
|
+
"recent() {",
|
|
3752
|
+
` runs "$1" && "$1" -e 'process.exit(parseInt(process.versions.node, 10) >= 20 ? 0 : 1)' >/dev/null 2>&1`,
|
|
3753
|
+
"}",
|
|
3754
|
+
"",
|
|
3755
|
+
"newest_nvm() {",
|
|
3756
|
+
' [ -d "$HOME/.nvm/versions/node" ] || return 0',
|
|
3757
|
+
` ls "$HOME/.nvm/versions/node" 2>/dev/null | sed 's/^v//' | sort -t. -k1,1n -k2,2n -k3,3n | tail -n 1 | sed 's/^/v/'`,
|
|
3758
|
+
"}",
|
|
3759
|
+
"",
|
|
3760
|
+
'node=""',
|
|
3761
|
+
"how=recorded",
|
|
3762
|
+
'[ -r "$record" ] && IFS= read -r node < "$record"',
|
|
3763
|
+
"",
|
|
3764
|
+
'if ! runs "$node"; then',
|
|
3765
|
+
' node=""',
|
|
3766
|
+
" how=found",
|
|
3767
|
+
' nvm_default=""',
|
|
3768
|
+
' if [ -r "$HOME/.nvm/alias/default" ]; then',
|
|
3769
|
+
' IFS= read -r wanted < "$HOME/.nvm/alias/default"',
|
|
3770
|
+
" wanted=${wanted#v}",
|
|
3771
|
+
' for candidate in "$HOME/.nvm/versions/node/v$wanted"*; do',
|
|
3772
|
+
' [ -x "$candidate/bin/node" ] && nvm_default="$candidate/bin/node"',
|
|
3773
|
+
" done",
|
|
3774
|
+
" fi",
|
|
3775
|
+
" nvm_newest=$(newest_nvm)",
|
|
3776
|
+
" for candidate in \\",
|
|
3777
|
+
' "$(command -v node 2>/dev/null)" \\',
|
|
3778
|
+
" /opt/homebrew/bin/node \\",
|
|
3779
|
+
" /usr/local/bin/node \\",
|
|
3780
|
+
' "$HOME/.volta/bin/node" \\',
|
|
3781
|
+
' "$nvm_default" \\',
|
|
3782
|
+
' "$HOME/.local/share/fnm/aliases/default/bin/node" \\',
|
|
3783
|
+
' "$HOME/Library/Application Support/fnm/aliases/default/bin/node" \\',
|
|
3784
|
+
' "$HOME/.asdf/shims/node" \\',
|
|
3785
|
+
' "$HOME/.local/share/mise/shims/node" \\',
|
|
3786
|
+
' "$HOME/.nvm/versions/node/$nvm_newest/bin/node"',
|
|
3787
|
+
" do",
|
|
3788
|
+
' if recent "$candidate"; then node=$candidate; break; fi',
|
|
3789
|
+
" done",
|
|
3790
|
+
' if [ -n "$node" ]; then',
|
|
3791
|
+
` printf '%s\\n' "$node" > "$record.$$" 2>/dev/null && mv -f "$record.$$" "$record" 2>/dev/null`,
|
|
3792
|
+
' rm -f "$missing" 2>/dev/null',
|
|
3793
|
+
" fi",
|
|
3794
|
+
"fi",
|
|
3795
|
+
"",
|
|
3796
|
+
'if [ -n "$ASCENDA_HOOK_LAUNCHER_PROBE" ]; then',
|
|
3797
|
+
' [ -n "$node" ] || { echo "no Node 20 or newer found on PATH or in the usual install locations" >&2; exit 1; }',
|
|
3798
|
+
` printf '%s\\t%s\\n' "$node" "$how"`,
|
|
3799
|
+
" exit 0",
|
|
3800
|
+
"fi",
|
|
3801
|
+
"",
|
|
3802
|
+
'if [ -z "$node" ]; then',
|
|
3803
|
+
' date -u +%Y-%m-%dT%H:%M:%SZ > "$missing" 2>/dev/null',
|
|
3804
|
+
' case "$1" in',
|
|
3805
|
+
...loudEvent ? [
|
|
3806
|
+
` ${loudEvent})`,
|
|
3807
|
+
" cat >/dev/null 2>&1",
|
|
3808
|
+
` echo "Ascenda hooks cannot find Node 20 or newer, so none of them are running. Install Node, then run: ${setupCommand}" >&2`,
|
|
3809
|
+
" exit 1 ;;"
|
|
3810
|
+
] : [],
|
|
3811
|
+
` ${LAUNCHER_MANAGEMENT_COMMANDS.join("|")})`,
|
|
3812
|
+
` echo "${binaryName}: no Node 20 or newer found on PATH or in the usual install locations." >&2`,
|
|
3813
|
+
" exit 1 ;;",
|
|
3814
|
+
" *)",
|
|
3815
|
+
" # A hook: say nothing per tool call. status and doctor read the",
|
|
3816
|
+
" # file written above.",
|
|
3817
|
+
" cat >/dev/null 2>&1",
|
|
3818
|
+
" exit 0 ;;",
|
|
3819
|
+
" esac",
|
|
3820
|
+
"fi",
|
|
3821
|
+
"",
|
|
3822
|
+
'exec "$node" "$bundle" "$@"',
|
|
3823
|
+
""
|
|
3824
|
+
].join("\n");
|
|
3825
|
+
}
|
|
3826
|
+
function installHookRunner(options) {
|
|
3827
|
+
const paths = hookRunnerPaths(options.binaryName);
|
|
3828
|
+
if (options.dryRun)
|
|
3829
|
+
return paths.launcher;
|
|
3830
|
+
const source = path2.resolve(options.source ?? process.argv[1]);
|
|
3831
|
+
fs.mkdirSync(path2.dirname(paths.launcher), { recursive: true });
|
|
3832
|
+
if (process.platform === "win32") {
|
|
3833
|
+
if (source !== path2.resolve(paths.launcher))
|
|
3834
|
+
fs.copyFileSync(source, paths.launcher);
|
|
3835
|
+
return paths.launcher;
|
|
3836
|
+
}
|
|
3837
|
+
if (source !== path2.resolve(paths.bundle))
|
|
3838
|
+
writeAtomically(paths.bundle, fs.readFileSync(source), 493);
|
|
3839
|
+
writeAtomically(paths.launcher, hookLauncherScript(options), 493);
|
|
3840
|
+
writeAtomically(paths.record, `${process.execPath}
|
|
3841
|
+
`, 420);
|
|
3842
|
+
fs.rmSync(paths.noNode, { force: true });
|
|
3843
|
+
return paths.launcher;
|
|
3844
|
+
}
|
|
3845
|
+
function removeHookRunner(binaryName) {
|
|
3846
|
+
const removed = [];
|
|
3847
|
+
for (const file of Object.values(hookRunnerPaths(binaryName))) {
|
|
3848
|
+
if (!fs.existsSync(file))
|
|
3849
|
+
continue;
|
|
3850
|
+
fs.rmSync(file, { force: true });
|
|
3851
|
+
removed.push(file);
|
|
3852
|
+
}
|
|
3853
|
+
return removed;
|
|
3854
|
+
}
|
|
3855
|
+
function hookRunnerCommand(launcher) {
|
|
3856
|
+
return process.platform === "win32" ? `"${process.execPath}" "${launcher}"` : `"${launcher}"`;
|
|
3857
|
+
}
|
|
3858
|
+
function writeAtomically(target, contents, mode) {
|
|
3859
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
3860
|
+
fs.writeFileSync(tmp, contents, { mode });
|
|
3861
|
+
fs.chmodSync(tmp, mode);
|
|
3862
|
+
fs.renameSync(tmp, target);
|
|
3863
|
+
}
|
|
3864
|
+
var stateDir = () => process.env.ASCENDA_STATE_DIR ?? path2.join((0, tokenStore_1.ascendaHome)(), "state");
|
|
3865
|
+
function lastHookPath(tool) {
|
|
3866
|
+
return path2.join(stateDir(), `${tool}-last-hook.json`);
|
|
3867
|
+
}
|
|
3868
|
+
function stampLastHook2(tool, event, now = /* @__PURE__ */ new Date()) {
|
|
3869
|
+
try {
|
|
3870
|
+
fs.mkdirSync(stateDir(), { recursive: true });
|
|
3871
|
+
const file = lastHookPath(tool);
|
|
3872
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
3873
|
+
fs.writeFileSync(tmp, `${JSON.stringify({ event, at: now.toISOString() })}
|
|
3874
|
+
`, { mode: 384 });
|
|
3875
|
+
fs.renameSync(tmp, file);
|
|
3876
|
+
} catch {
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
function readLastHook(tool) {
|
|
3880
|
+
try {
|
|
3881
|
+
const parsed = JSON.parse(fs.readFileSync(lastHookPath(tool), "utf8"));
|
|
3882
|
+
if (typeof parsed.event !== "string" || typeof parsed.at !== "string")
|
|
3883
|
+
return void 0;
|
|
3884
|
+
return { event: parsed.event, at: parsed.at };
|
|
3885
|
+
} catch {
|
|
3886
|
+
return void 0;
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
function describeAge(ms) {
|
|
3890
|
+
if (!Number.isFinite(ms) || ms < 0)
|
|
3891
|
+
return "just now";
|
|
3892
|
+
const seconds = Math.round(ms / 1e3);
|
|
3893
|
+
if (seconds < 60)
|
|
3894
|
+
return `${seconds} s ago`;
|
|
3895
|
+
const minutes = Math.round(seconds / 60);
|
|
3896
|
+
if (minutes < 60)
|
|
3897
|
+
return `${minutes} min ago`;
|
|
3898
|
+
const hours = Math.round(minutes / 60);
|
|
3899
|
+
if (hours < 48)
|
|
3900
|
+
return `${hours} h ago`;
|
|
3901
|
+
return `${Math.round(hours / 24)} days ago`;
|
|
3902
|
+
}
|
|
3903
|
+
function resolveHookNode(launcher) {
|
|
3904
|
+
if (!fs.existsSync(launcher))
|
|
3905
|
+
return { problem: "the hook launcher is not installed" };
|
|
3906
|
+
const probe = (0, child_process_1.spawnSync)("/bin/sh", [launcher], {
|
|
3907
|
+
encoding: "utf8",
|
|
3908
|
+
timeout: 5e3,
|
|
3909
|
+
env: { HOME: process.env.HOME ?? "", PATH: "/usr/bin:/bin:/usr/sbin:/sbin", ASCENDA_HOOK_LAUNCHER_PROBE: "1" }
|
|
3910
|
+
});
|
|
3911
|
+
const [node, how] = (probe.stdout ?? "").trim().split(" ");
|
|
3912
|
+
if (probe.status !== 0 || !node) {
|
|
3913
|
+
return { problem: (probe.stderr ?? "").trim() || "the launcher found no Node it can run" };
|
|
3914
|
+
}
|
|
3915
|
+
const version = (0, child_process_1.spawnSync)(node, ["--version"], { encoding: "utf8", timeout: 5e3 });
|
|
3916
|
+
if (version.status !== 0)
|
|
3917
|
+
return { node, how, problem: `${node} did not run` };
|
|
3918
|
+
return { node, how, version: version.stdout.trim() };
|
|
3919
|
+
}
|
|
3920
|
+
function tidyHomePath(file, home = process.env.HOME ?? "") {
|
|
3921
|
+
return home && file.startsWith(`${home}/`) ? `~${file.slice(home.length)}` : file;
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
});
|
|
3925
|
+
|
|
3926
|
+
// ../packages/tool-kit/out/saverHandoff.js
|
|
3927
|
+
var require_saverHandoff = __commonJS({
|
|
3928
|
+
"../packages/tool-kit/out/saverHandoff.js"(exports) {
|
|
3929
|
+
"use strict";
|
|
3930
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3931
|
+
if (k2 === void 0) k2 = k;
|
|
3932
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3933
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3934
|
+
desc = { enumerable: true, get: function() {
|
|
3935
|
+
return m[k];
|
|
3936
|
+
} };
|
|
3937
|
+
}
|
|
3938
|
+
Object.defineProperty(o, k2, desc);
|
|
3939
|
+
} : function(o, m, k, k2) {
|
|
3940
|
+
if (k2 === void 0) k2 = k;
|
|
3941
|
+
o[k2] = m[k];
|
|
3942
|
+
});
|
|
3943
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
3944
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
3945
|
+
} : function(o, v) {
|
|
3946
|
+
o["default"] = v;
|
|
3947
|
+
});
|
|
3948
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
3949
|
+
var ownKeys = function(o) {
|
|
3950
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
3951
|
+
var ar = [];
|
|
3952
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
3953
|
+
return ar;
|
|
3954
|
+
};
|
|
3955
|
+
return ownKeys(o);
|
|
3956
|
+
};
|
|
3957
|
+
return function(mod) {
|
|
3958
|
+
if (mod && mod.__esModule) return mod;
|
|
3959
|
+
var result = {};
|
|
3960
|
+
if (mod != null) {
|
|
3961
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
3962
|
+
}
|
|
3963
|
+
__setModuleDefault(result, mod);
|
|
3964
|
+
return result;
|
|
3965
|
+
};
|
|
3966
|
+
}();
|
|
3967
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3968
|
+
exports.SAVER_REPLAY_SCHEMA = exports.SAVER_REPLAY_WINDOW_MS = void 0;
|
|
3969
|
+
exports.saverContainerDir = saverContainerDir;
|
|
3970
|
+
exports.saverSupportDir = saverSupportDir;
|
|
3971
|
+
exports.saverReplayPath = saverReplayPath;
|
|
3972
|
+
exports.saverStatusDir = saverStatusDir;
|
|
3973
|
+
exports.holdForSaver = holdForSaver;
|
|
3974
|
+
exports.heldForSaver = heldForSaver;
|
|
3975
|
+
exports.readSaverStatuses = readSaverStatuses;
|
|
3976
|
+
exports.probeSocket = probeSocket;
|
|
3977
|
+
var fs = __importStar(__require("fs"));
|
|
3978
|
+
var net = __importStar(__require("net"));
|
|
3979
|
+
var os2 = __importStar(__require("os"));
|
|
3980
|
+
var path2 = __importStar(__require("path"));
|
|
3981
|
+
var SAVER_HOST_BUNDLE_ID = "com.apple.ScreenSaver.Engine.legacyScreenSaver";
|
|
3982
|
+
function saverContainerDir() {
|
|
3983
|
+
return process.env.ASCENDA_SAVER_CONTAINER ?? path2.join(os2.homedir(), "Library", "Containers", SAVER_HOST_BUNDLE_ID, "Data");
|
|
3984
|
+
}
|
|
3985
|
+
function saverSupportDir() {
|
|
3986
|
+
return path2.join(saverContainerDir(), "Library", "Application Support", "AscendaWaterlineSaver");
|
|
3987
|
+
}
|
|
3988
|
+
function saverReplayPath() {
|
|
3989
|
+
return path2.join(saverContainerDir(), "l.replay.json");
|
|
3990
|
+
}
|
|
3991
|
+
function saverStatusDir() {
|
|
3992
|
+
return path2.join(saverSupportDir(), "status");
|
|
3993
|
+
}
|
|
3994
|
+
exports.SAVER_REPLAY_WINDOW_MS = 30 * 60 * 1e3;
|
|
3995
|
+
var SAVER_REPLAY_MAX = 32;
|
|
3996
|
+
exports.SAVER_REPLAY_SCHEMA = 1;
|
|
3997
|
+
function holdForSaver(signal, now = Date.now()) {
|
|
3998
|
+
try {
|
|
3999
|
+
if (process.env.ASCENDA_LIVE_BUS_SOCKET && !process.env.ASCENDA_SAVER_CONTAINER)
|
|
4000
|
+
return;
|
|
4001
|
+
if (!fs.existsSync(saverSupportDir()))
|
|
4002
|
+
return;
|
|
4003
|
+
const wire = signal;
|
|
4004
|
+
const tool = wire.tool;
|
|
4005
|
+
const session = wire.session;
|
|
4006
|
+
const event = wire.event;
|
|
4007
|
+
if (typeof tool !== "string" || typeof session !== "string" || typeof event !== "string")
|
|
4008
|
+
return;
|
|
4009
|
+
const file = saverReplayPath();
|
|
4010
|
+
const kept = readHeld(file).filter((held) => now - held.at <= exports.SAVER_REPLAY_WINDOW_MS && !(held.tool === tool && held.session === session));
|
|
4011
|
+
kept.push({ ...wire, tool, session, event, at: now });
|
|
4012
|
+
kept.sort((a, b) => a.at - b.at);
|
|
4013
|
+
const body = JSON.stringify({ schema: exports.SAVER_REPLAY_SCHEMA, signals: kept.slice(-SAVER_REPLAY_MAX) });
|
|
4014
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
4015
|
+
fs.writeFileSync(tmp, `${body}
|
|
4016
|
+
`, { mode: 384 });
|
|
4017
|
+
fs.renameSync(tmp, file);
|
|
4018
|
+
} catch {
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
function readHeld(file) {
|
|
4022
|
+
try {
|
|
4023
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
4024
|
+
if (parsed.schema !== exports.SAVER_REPLAY_SCHEMA || !Array.isArray(parsed.signals))
|
|
4025
|
+
return [];
|
|
4026
|
+
return parsed.signals.filter((held) => typeof held === "object" && held !== null && typeof held.tool === "string" && typeof held.session === "string" && typeof held.event === "string" && typeof held.at === "number");
|
|
4027
|
+
} catch {
|
|
4028
|
+
return [];
|
|
4029
|
+
}
|
|
4030
|
+
}
|
|
4031
|
+
function heldForSaver(now = Date.now()) {
|
|
4032
|
+
const held = readHeld(saverReplayPath()).filter((entry) => now - entry.at <= exports.SAVER_REPLAY_WINDOW_MS);
|
|
4033
|
+
if (held.length === 0)
|
|
4034
|
+
return { count: 0 };
|
|
4035
|
+
return { count: held.length, newestAgeMs: now - Math.max(...held.map((entry) => entry.at)) };
|
|
4036
|
+
}
|
|
4037
|
+
function readSaverStatuses(now = Date.now()) {
|
|
4038
|
+
let names;
|
|
4039
|
+
try {
|
|
4040
|
+
names = fs.readdirSync(saverStatusDir()).filter((name) => name.endsWith(".json"));
|
|
4041
|
+
} catch {
|
|
4042
|
+
return [];
|
|
4043
|
+
}
|
|
4044
|
+
const readings = [];
|
|
4045
|
+
for (const name of names) {
|
|
4046
|
+
try {
|
|
4047
|
+
const status = JSON.parse(fs.readFileSync(path2.join(saverStatusDir(), name), "utf8"));
|
|
4048
|
+
if (typeof status.pid !== "number" || typeof status.updatedAt !== "string")
|
|
4049
|
+
continue;
|
|
4050
|
+
readings.push({ ...status, alive: processAlive(status.pid), ageMs: now - Date.parse(status.updatedAt) });
|
|
4051
|
+
} catch {
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
return readings.sort((a, b) => a.ageMs - b.ageMs);
|
|
4055
|
+
}
|
|
4056
|
+
function processAlive(pid) {
|
|
4057
|
+
try {
|
|
4058
|
+
process.kill(pid, 0);
|
|
4059
|
+
return true;
|
|
4060
|
+
} catch (error) {
|
|
4061
|
+
return error.code === "EPERM";
|
|
4062
|
+
}
|
|
4063
|
+
}
|
|
4064
|
+
function probeSocket(socketPath, timeoutMs = 300) {
|
|
4065
|
+
return new Promise((resolve) => {
|
|
4066
|
+
try {
|
|
4067
|
+
if (!fs.statSync(socketPath).isSocket()) {
|
|
4068
|
+
resolve("absent");
|
|
4069
|
+
return;
|
|
4070
|
+
}
|
|
4071
|
+
} catch {
|
|
4072
|
+
resolve("absent");
|
|
4073
|
+
return;
|
|
4074
|
+
}
|
|
4075
|
+
let settled = false;
|
|
4076
|
+
const finish = (state) => {
|
|
4077
|
+
if (settled)
|
|
4078
|
+
return;
|
|
4079
|
+
settled = true;
|
|
4080
|
+
clearTimeout(timer);
|
|
4081
|
+
socket.destroy();
|
|
4082
|
+
resolve(state);
|
|
4083
|
+
};
|
|
4084
|
+
const socket = net.createConnection(socketPath);
|
|
4085
|
+
const timer = setTimeout(() => finish("unreachable"), timeoutMs);
|
|
4086
|
+
socket.on("connect", () => finish("listening"));
|
|
4087
|
+
socket.on("error", (error) => finish(error.code === "ECONNREFUSED" || error.code === "ENOENT" ? "stale" : "unreachable"));
|
|
4088
|
+
});
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
});
|
|
4092
|
+
|
|
4093
|
+
// ../packages/tool-kit/out/liveBus.js
|
|
4094
|
+
var require_liveBus = __commonJS({
|
|
4095
|
+
"../packages/tool-kit/out/liveBus.js"(exports) {
|
|
4096
|
+
"use strict";
|
|
4097
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4098
|
+
if (k2 === void 0) k2 = k;
|
|
4099
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4100
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4101
|
+
desc = { enumerable: true, get: function() {
|
|
4102
|
+
return m[k];
|
|
4103
|
+
} };
|
|
4104
|
+
}
|
|
4105
|
+
Object.defineProperty(o, k2, desc);
|
|
4106
|
+
} : function(o, m, k, k2) {
|
|
4107
|
+
if (k2 === void 0) k2 = k;
|
|
4108
|
+
o[k2] = m[k];
|
|
4109
|
+
});
|
|
4110
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
4111
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
4112
|
+
} : function(o, v) {
|
|
4113
|
+
o["default"] = v;
|
|
4114
|
+
});
|
|
4115
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
4116
|
+
var ownKeys = function(o) {
|
|
4117
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
4118
|
+
var ar = [];
|
|
4119
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
4120
|
+
return ar;
|
|
4121
|
+
};
|
|
4122
|
+
return ownKeys(o);
|
|
4123
|
+
};
|
|
4124
|
+
return function(mod) {
|
|
4125
|
+
if (mod && mod.__esModule) return mod;
|
|
4126
|
+
var result = {};
|
|
4127
|
+
if (mod != null) {
|
|
4128
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
4129
|
+
}
|
|
4130
|
+
__setModuleDefault(result, mod);
|
|
4131
|
+
return result;
|
|
4132
|
+
};
|
|
4133
|
+
}();
|
|
4134
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4135
|
+
exports.SAVER_HOST_BUNDLE_ID = exports.LIVE_BUS_BACKGROUND_TRUST_MS = void 0;
|
|
4136
|
+
exports.liveBusSocketCandidates = liveBusSocketCandidates;
|
|
4137
|
+
exports.existingSocketCandidates = existingSocketCandidates;
|
|
4138
|
+
exports.liveBusSocketPath = liveBusSocketPath;
|
|
4139
|
+
exports.bucketPromptSize = bucketPromptSize2;
|
|
4140
|
+
exports.emitLiveSignal = emitLiveSignal2;
|
|
4141
|
+
exports.deliverLine = deliverLine;
|
|
4142
|
+
var fs = __importStar(__require("fs"));
|
|
4143
|
+
var net = __importStar(__require("net"));
|
|
4144
|
+
var os2 = __importStar(__require("os"));
|
|
4145
|
+
var path2 = __importStar(__require("path"));
|
|
4146
|
+
var hookSet_1 = require_hookSet();
|
|
4147
|
+
var saverHandoff_1 = require_saverHandoff();
|
|
4148
|
+
var WRITE_TIMEOUT_MS = 50;
|
|
4149
|
+
exports.LIVE_BUS_BACKGROUND_TRUST_MS = 60 * 60 * 1e3;
|
|
4150
|
+
var APP_BUNDLE_ID = "one.ascenda.ascendaMissionControl";
|
|
4151
|
+
exports.SAVER_HOST_BUNDLE_ID = "com.apple.ScreenSaver.Engine.legacyScreenSaver";
|
|
4152
|
+
function liveBusSocketCandidates() {
|
|
4153
|
+
const override = process.env.ASCENDA_LIVE_BUS_SOCKET;
|
|
4154
|
+
if (override)
|
|
4155
|
+
return [override];
|
|
4156
|
+
const home = os2.homedir();
|
|
4157
|
+
return [
|
|
4158
|
+
path2.join(home, ".ascenda", "live.sock"),
|
|
4159
|
+
path2.join(home, "Library", "Containers", APP_BUNDLE_ID, "Data", ".ascenda", "live.sock"),
|
|
4160
|
+
path2.join(home, "Library", "Containers", exports.SAVER_HOST_BUNDLE_ID, "Data", "l.sock")
|
|
4161
|
+
];
|
|
4162
|
+
}
|
|
4163
|
+
function existingSocketCandidates() {
|
|
4164
|
+
const candidates = liveBusSocketCandidates();
|
|
4165
|
+
if (process.env.ASCENDA_LIVE_BUS_SOCKET)
|
|
4166
|
+
return candidates;
|
|
4167
|
+
return candidates.filter((candidate) => {
|
|
4168
|
+
try {
|
|
4169
|
+
return fs.statSync(candidate).isSocket();
|
|
4170
|
+
} catch {
|
|
4171
|
+
return false;
|
|
4172
|
+
}
|
|
4173
|
+
});
|
|
4174
|
+
}
|
|
4175
|
+
function liveBusSocketPath() {
|
|
4176
|
+
return existingSocketCandidates()[0] ?? liveBusSocketCandidates()[0];
|
|
4177
|
+
}
|
|
4178
|
+
function bucketPromptSize2(text) {
|
|
4179
|
+
const length = typeof text === "string" ? text.length : 0;
|
|
4180
|
+
if (length <= 280)
|
|
4181
|
+
return "s";
|
|
4182
|
+
if (length <= 2e3)
|
|
4183
|
+
return "m";
|
|
4184
|
+
if (length <= 8e3)
|
|
4185
|
+
return "l";
|
|
4186
|
+
return "xl";
|
|
4187
|
+
}
|
|
4188
|
+
var NOBODY_LISTENING = /* @__PURE__ */ new Set(["ECONNREFUSED", "ENOENT"]);
|
|
4189
|
+
function onTheWire(signal) {
|
|
4190
|
+
const out = { ...signal };
|
|
4191
|
+
if ("hookSet" in out && !(0, hookSet_1.isHookSet)(out.hookSet))
|
|
4192
|
+
delete out.hookSet;
|
|
4193
|
+
if ("viaPlugin" in out && out.viaPlugin !== true)
|
|
4194
|
+
delete out.viaPlugin;
|
|
4195
|
+
return out;
|
|
4196
|
+
}
|
|
4197
|
+
function emitLiveSignal2(signal) {
|
|
4198
|
+
const wire = onTheWire(signal);
|
|
4199
|
+
return deliverLine(`${JSON.stringify(wire)}
|
|
4200
|
+
`).then((delivered) => {
|
|
4201
|
+
if (!delivered)
|
|
4202
|
+
(0, saverHandoff_1.holdForSaver)(wire);
|
|
4203
|
+
});
|
|
4204
|
+
}
|
|
4205
|
+
function deliverLine(line) {
|
|
4206
|
+
return new Promise((resolve) => {
|
|
4207
|
+
const candidates = existingSocketCandidates();
|
|
4208
|
+
if (candidates.length === 0) {
|
|
4209
|
+
resolve(void 0);
|
|
4210
|
+
return;
|
|
4211
|
+
}
|
|
4212
|
+
let settled = false;
|
|
4213
|
+
let accepted;
|
|
4214
|
+
let socket;
|
|
4215
|
+
const drop = () => {
|
|
4216
|
+
try {
|
|
4217
|
+
socket?.destroy();
|
|
4218
|
+
} catch {
|
|
4219
|
+
}
|
|
4220
|
+
socket = void 0;
|
|
4221
|
+
};
|
|
4222
|
+
const done = () => {
|
|
4223
|
+
if (settled)
|
|
4224
|
+
return;
|
|
4225
|
+
settled = true;
|
|
4226
|
+
clearTimeout(timer);
|
|
4227
|
+
drop();
|
|
4228
|
+
resolve(accepted);
|
|
4229
|
+
};
|
|
4230
|
+
const timer = setTimeout(done, WRITE_TIMEOUT_MS);
|
|
4231
|
+
const tryFrom = (index) => {
|
|
4232
|
+
if (settled)
|
|
4233
|
+
return;
|
|
4234
|
+
if (index >= candidates.length) {
|
|
4235
|
+
done();
|
|
4236
|
+
return;
|
|
4237
|
+
}
|
|
4238
|
+
let attempt;
|
|
4239
|
+
try {
|
|
4240
|
+
attempt = net.createConnection(candidates[index]);
|
|
4241
|
+
} catch {
|
|
4242
|
+
tryFrom(index + 1);
|
|
4243
|
+
return;
|
|
4244
|
+
}
|
|
4245
|
+
socket = attempt;
|
|
4246
|
+
if (typeof attempt.unref === "function")
|
|
4247
|
+
attempt.unref();
|
|
4248
|
+
let connected = false;
|
|
4249
|
+
attempt.on("error", (error) => {
|
|
4250
|
+
if (settled || socket !== attempt)
|
|
4251
|
+
return;
|
|
4252
|
+
if (!connected && error.code && NOBODY_LISTENING.has(error.code)) {
|
|
4253
|
+
drop();
|
|
4254
|
+
tryFrom(index + 1);
|
|
4255
|
+
return;
|
|
4256
|
+
}
|
|
4257
|
+
done();
|
|
4258
|
+
});
|
|
4259
|
+
attempt.on("connect", () => {
|
|
4260
|
+
if (settled || socket !== attempt)
|
|
4261
|
+
return;
|
|
4262
|
+
connected = true;
|
|
4263
|
+
accepted = candidates[index];
|
|
4264
|
+
try {
|
|
4265
|
+
attempt.write(line, done);
|
|
4266
|
+
} catch {
|
|
4267
|
+
done();
|
|
4268
|
+
}
|
|
4269
|
+
});
|
|
4270
|
+
};
|
|
4271
|
+
tryFrom(0);
|
|
4272
|
+
});
|
|
4273
|
+
}
|
|
4274
|
+
}
|
|
4275
|
+
});
|
|
4276
|
+
|
|
4277
|
+
// ../packages/tool-kit/out/terminalStyle.js
|
|
4278
|
+
var require_terminalStyle = __commonJS({
|
|
4279
|
+
"../packages/tool-kit/out/terminalStyle.js"(exports) {
|
|
4280
|
+
"use strict";
|
|
4281
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4282
|
+
exports.colourEnabled = colourEnabled;
|
|
4283
|
+
exports.terminalStyle = terminalStyle;
|
|
4284
|
+
function colourEnabled(stream = process.stdout, env = process.env) {
|
|
4285
|
+
if (env.NO_COLOR !== void 0 && env.NO_COLOR !== "")
|
|
4286
|
+
return false;
|
|
4287
|
+
if (env.FORCE_COLOR !== void 0)
|
|
4288
|
+
return env.FORCE_COLOR !== "0";
|
|
4289
|
+
if (env.TERM === "dumb")
|
|
4290
|
+
return false;
|
|
4291
|
+
return Boolean(stream.isTTY);
|
|
4292
|
+
}
|
|
4293
|
+
function terminalStyle(enabled = colourEnabled()) {
|
|
4294
|
+
const wrap = (open, close) => (text) => enabled ? `\x1B[${open}m${text}\x1B[${close}m` : text;
|
|
4295
|
+
const bold = wrap(1, 22);
|
|
4296
|
+
const dim = wrap(2, 22);
|
|
4297
|
+
const green = wrap(32, 39);
|
|
4298
|
+
const yellow = wrap(33, 39);
|
|
4299
|
+
const red = wrap(31, 39);
|
|
4300
|
+
const cyan = wrap(36, 39);
|
|
4301
|
+
const colour = { ok: green, warn: yellow, bad: red, info: dim };
|
|
4302
|
+
const marks = { ok: "\u2713", warn: "!", bad: "\u2717", info: "\xB7" };
|
|
4303
|
+
return {
|
|
4304
|
+
enabled,
|
|
4305
|
+
bold,
|
|
4306
|
+
dim,
|
|
4307
|
+
green,
|
|
4308
|
+
yellow,
|
|
4309
|
+
red,
|
|
4310
|
+
cyan,
|
|
4311
|
+
mark: (tone) => colour[tone](marks[tone]),
|
|
4312
|
+
tone: (tone, text) => colour[tone](text)
|
|
4313
|
+
};
|
|
4314
|
+
}
|
|
4315
|
+
}
|
|
4316
|
+
});
|
|
4317
|
+
|
|
4318
|
+
// ../packages/tool-kit/out/liveSignalDoctor.js
|
|
4319
|
+
var require_liveSignalDoctor = __commonJS({
|
|
4320
|
+
"../packages/tool-kit/out/liveSignalDoctor.js"(exports) {
|
|
4321
|
+
"use strict";
|
|
4322
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4323
|
+
exports.DOCTOR_VALUE_COLUMN = void 0;
|
|
4324
|
+
exports.doctorRow = doctorRow;
|
|
4325
|
+
exports.liveSignalDoctorLines = liveSignalDoctorLines;
|
|
4326
|
+
var hookRunner_1 = require_hookRunner();
|
|
4327
|
+
var liveBus_1 = require_liveBus();
|
|
4328
|
+
var saverHandoff_1 = require_saverHandoff();
|
|
4329
|
+
var terminalStyle_1 = require_terminalStyle();
|
|
4330
|
+
exports.DOCTOR_VALUE_COLUMN = 25;
|
|
4331
|
+
function doctorRow(ui, tone, label, value) {
|
|
4332
|
+
return ` ${ui.mark(tone)} ${label.padEnd(exports.DOCTOR_VALUE_COLUMN - 5)} ${value}`;
|
|
4333
|
+
}
|
|
4334
|
+
async function liveSignalDoctorLines(options) {
|
|
4335
|
+
const ui = options.ui ?? (0, terminalStyle_1.terminalStyle)();
|
|
4336
|
+
const lines = [` ${ui.bold("Live signal")} ${ui.dim("(this machine; needs no pairing)")}`];
|
|
4337
|
+
const now = Date.now();
|
|
4338
|
+
let problems = 0;
|
|
4339
|
+
const row = (tone, label, value) => {
|
|
4340
|
+
if (tone === "bad" || tone === "warn")
|
|
4341
|
+
problems += 1;
|
|
4342
|
+
lines.push(doctorRow(ui, tone, label, tone === "bad" ? ui.red(value) : value));
|
|
4343
|
+
};
|
|
4344
|
+
const more = (value) => lines.push(`${" ".repeat(exports.DOCTOR_VALUE_COLUMN)}${value}`);
|
|
4345
|
+
if (options.launcher && process.platform !== "win32") {
|
|
4346
|
+
const node = (0, hookRunner_1.resolveHookNode)(options.launcher);
|
|
4347
|
+
if (node.problem)
|
|
4348
|
+
row("bad", "Node", `${node.problem}. Install Node 20 or newer, then run setup again`);
|
|
4349
|
+
else
|
|
4350
|
+
row("ok", "Node", `${node.node} ${ui.dim(`(${node.version}, ${node.how === "recorded" ? "recorded at setup" : "found by the launcher"})`)}`);
|
|
4351
|
+
}
|
|
4352
|
+
if (options.registrations.length === 0)
|
|
4353
|
+
row("bad", "Hooks", `not registered. Run: ${options.setupCommand}`);
|
|
4354
|
+
for (const entry of options.registrations) {
|
|
4355
|
+
const where = entry.homeProject ? `loads only when ${options.displayName} starts in the home folder. Run setup again to move it to every project` : entry.scope === "user" ? "every project" : "this project only";
|
|
4356
|
+
const complete = entry.registered === options.eventCount;
|
|
4357
|
+
row(entry.homeProject || !complete ? "warn" : entry.scope === "user" ? "ok" : "info", "Hooks", `${entry.registered}/${options.eventCount} in ${entry.file} ${ui.dim(`(${where})`)}`);
|
|
4358
|
+
}
|
|
4359
|
+
if (options.registrations.length > 1) {
|
|
4360
|
+
problems += 1;
|
|
4361
|
+
more(ui.yellow("Registered in more than one file, so each event runs more than once. Run setup again to fix."));
|
|
4362
|
+
}
|
|
4363
|
+
const last = (0, hookRunner_1.readLastHook)(options.tool);
|
|
4364
|
+
if (last)
|
|
4365
|
+
row("ok", "Last hook", `${last.event}, ${(0, hookRunner_1.describeAge)(now - Date.parse(last.at))}`);
|
|
4366
|
+
else
|
|
4367
|
+
row("info", "Last hook", `none yet. Start ${options.displayName} (restart it if it was open during setup)${options.lookHint ? `, then ${options.lookHint}` : ""}`);
|
|
4368
|
+
const [appSocket, appContainerSocket, saverSocket] = (0, liveBus_1.liveBusSocketCandidates)();
|
|
4369
|
+
const appState = await (0, saverHandoff_1.probeSocket)(appSocket);
|
|
4370
|
+
const legacyState = appContainerSocket ? await (0, saverHandoff_1.probeSocket)(appContainerSocket) : "absent";
|
|
4371
|
+
if (appState === "listening" || legacyState === "listening")
|
|
4372
|
+
row("ok", "Desktop app", "listening. It takes every signal, and the saver mirrors it");
|
|
4373
|
+
else
|
|
4374
|
+
row("info", "Desktop app", "not listening");
|
|
4375
|
+
const saverState = saverSocket ? await (0, saverHandoff_1.probeSocket)(saverSocket) : "absent";
|
|
4376
|
+
const live = (0, saverHandoff_1.readSaverStatuses)(now).filter((status) => status.alive);
|
|
4377
|
+
const holder = live.find((status) => status.ownsBus);
|
|
4378
|
+
const saver = describeSaver(saverState, holder, live);
|
|
4379
|
+
row(saver.tone, "Screen saver", saver.text);
|
|
4380
|
+
for (const status of live)
|
|
4381
|
+
more(ui.dim(describeProcess(status, now)));
|
|
4382
|
+
const held = (0, saverHandoff_1.heldForSaver)(now);
|
|
4383
|
+
if (held.count > 0) {
|
|
4384
|
+
row("info", "Held for the saver", `${held.count} session${held.count === 1 ? "" : "s"}, newest ${(0, hookRunner_1.describeAge)(held.newestAgeMs ?? 0)}. Replayed when the saver starts`);
|
|
4385
|
+
}
|
|
4386
|
+
const trip = await pingRoundTrip(saverSocket, options.selfCommand);
|
|
4387
|
+
row(trip.tone, "Round trip", trip.text);
|
|
4388
|
+
lines.push("");
|
|
4389
|
+
lines.push(problems === 0 ? ` ${ui.mark("ok")} ${ui.bold("Ready.")} The hooks can run, and the screen saver hears them while it's on screen.` : ` ${ui.mark("bad")} ${ui.bold(`${problems} problem${problems === 1 ? "" : "s"} above.`)} Each line says how to fix it.`);
|
|
4390
|
+
return lines;
|
|
4391
|
+
}
|
|
4392
|
+
function describeSaver(state, holder, live) {
|
|
4393
|
+
if (state === "listening") {
|
|
4394
|
+
if (!holder)
|
|
4395
|
+
return { tone: "warn", text: "listening, from a process that isn't reporting. Restart it: killall legacyScreenSaver" };
|
|
4396
|
+
if (holder.saverViews === 0) {
|
|
4397
|
+
return { tone: "bad", text: `pid ${holder.pid} holds the socket but isn't drawing the saver, so signals go nowhere you can see. Fix: killall legacyScreenSaver` };
|
|
4398
|
+
}
|
|
4399
|
+
return { tone: "ok", text: `listening, pid ${holder.pid}, on screen` };
|
|
4400
|
+
}
|
|
4401
|
+
if (state === "stale")
|
|
4402
|
+
return { tone: "info", text: "not running (a socket file was left behind, which is harmless)" };
|
|
4403
|
+
if (live.some((status) => status.previewViews > 0)) {
|
|
4404
|
+
return { tone: "info", text: "not running. The System Settings preview never listens, so it stays still; the water goes live once the saver itself runs" };
|
|
4405
|
+
}
|
|
4406
|
+
return { tone: "info", text: "not running. That's normal: it listens only while it's on screen" };
|
|
4407
|
+
}
|
|
4408
|
+
function describeProcess(status, now) {
|
|
4409
|
+
const what = [
|
|
4410
|
+
status.saverViews > 0 ? `saver on ${status.saverViews} display${status.saverViews === 1 ? "" : "s"}` : void 0,
|
|
4411
|
+
status.previewViews > 0 ? "preview" : void 0
|
|
4412
|
+
].filter(Boolean).join(" + ") || "not drawing";
|
|
4413
|
+
const heard = status.lastSignalAt ? `last signal ${status.lastSignalEvent ?? ""} ${(0, hookRunner_1.describeAge)(now - Date.parse(status.lastSignalAt))}`.replace(/\s+/g, " ") : "no signal yet";
|
|
4414
|
+
const replay = status.replayed > 0 ? `, replayed ${status.replayed} since this process started` : "";
|
|
4415
|
+
const beat = status.ageMs > 1e4 ? `, heartbeat ${(0, hookRunner_1.describeAge)(status.ageMs)} (not animating)` : "";
|
|
4416
|
+
return `pid ${status.pid} ${status.version ?? ""}: ${what}, ${status.mode ?? "?"}${status.ownsBus ? ", owns the socket" : ""}, ${heard}${replay}${beat}`.replace(/\s+:/, ":");
|
|
4417
|
+
}
|
|
4418
|
+
async function pingRoundTrip(saverSocket, selfCommand) {
|
|
4419
|
+
const session = `doctor-${process.pid}-${Date.now()}`;
|
|
4420
|
+
const accepted = await (0, liveBus_1.deliverLine)(`${JSON.stringify({ tool: "doctor", session, event: "ping" })}
|
|
4421
|
+
`);
|
|
4422
|
+
if (!accepted) {
|
|
4423
|
+
return { tone: "info", text: `nobody is listening right now, so there is nothing to test. To test the saver: open -a ScreenSaverEngine; sleep 5; ${selfCommand} doctor` };
|
|
4424
|
+
}
|
|
4425
|
+
if (accepted !== saverSocket)
|
|
4426
|
+
return { tone: "ok", text: `the desktop app took it (${accepted})` };
|
|
4427
|
+
for (let waited = 0; waited < 2e3; waited += 100) {
|
|
4428
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
4429
|
+
const answered = (0, saverHandoff_1.readSaverStatuses)().find((status) => status.lastPingSession === session);
|
|
4430
|
+
if (answered)
|
|
4431
|
+
return { tone: "ok", text: `OK. The screen saver (pid ${answered.pid}) received it` };
|
|
4432
|
+
}
|
|
4433
|
+
return { tone: "bad", text: "the saver's socket took the ping but no saver reported it. It may be a version from before 0.8.1, or stuck. Fix: killall legacyScreenSaver" };
|
|
4434
|
+
}
|
|
4435
|
+
}
|
|
4436
|
+
});
|
|
4437
|
+
|
|
3673
4438
|
// ../packages/tool-kit/out/studyNotices.js
|
|
3674
4439
|
var require_studyNotices = __commonJS({
|
|
3675
4440
|
"../packages/tool-kit/out/studyNotices.js"(exports) {
|
|
@@ -3919,10 +4684,12 @@ var require_cliAgentSetup = __commonJS({
|
|
|
3919
4684
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3920
4685
|
exports.isCliAgentManagementCommand = isCliAgentManagementCommand2;
|
|
3921
4686
|
exports.cliAgentHookBinPath = cliAgentHookBinPath;
|
|
4687
|
+
exports.cliAgentSelfCommand = cliAgentSelfCommand;
|
|
3922
4688
|
exports.runCliAgentSetup = runCliAgentSetup2;
|
|
3923
4689
|
exports.writeHookSettings = writeHookSettings;
|
|
3924
4690
|
exports.registeredHookSets = registeredHookSets;
|
|
3925
4691
|
exports.findStaleHookCommands = findStaleHookCommands;
|
|
4692
|
+
exports.cliAgentRegistrations = cliAgentRegistrations;
|
|
3926
4693
|
var crypto = __importStar(__require("crypto"));
|
|
3927
4694
|
var fs = __importStar(__require("fs"));
|
|
3928
4695
|
var os2 = __importStar(__require("os"));
|
|
@@ -3934,22 +4701,29 @@ var require_cliAgentSetup = __commonJS({
|
|
|
3934
4701
|
var hookSet_1 = require_hookSet();
|
|
3935
4702
|
var initiatives_1 = require_initiatives();
|
|
3936
4703
|
var setupDisclosure_1 = require_setupDisclosure();
|
|
4704
|
+
var hookRunner_1 = require_hookRunner();
|
|
4705
|
+
var liveSignalDoctor_1 = require_liveSignalDoctor();
|
|
3937
4706
|
var stateStore_1 = require_stateStore();
|
|
3938
4707
|
var studyJoin_1 = require_studyJoin();
|
|
3939
4708
|
var studyNotices_1 = require_studyNotices();
|
|
4709
|
+
var terminalStyle_1 = require_terminalStyle();
|
|
3940
4710
|
var tokenStore_1 = require_tokenStore();
|
|
3941
|
-
var MANAGEMENT_COMMANDS = /* @__PURE__ */ new Set(["setup", "install", "status", "uninstall", "join", "object", "-h", "--help"]);
|
|
4711
|
+
var MANAGEMENT_COMMANDS = /* @__PURE__ */ new Set(["setup", "install", "status", "uninstall", "doctor", "join", "object", "-h", "--help"]);
|
|
3942
4712
|
function isCliAgentManagementCommand2(argument) {
|
|
3943
4713
|
return argument !== void 0 && MANAGEMENT_COMMANDS.has(argument);
|
|
3944
4714
|
}
|
|
3945
4715
|
function cliAgentHookBinPath(binaryName) {
|
|
3946
|
-
return
|
|
4716
|
+
return (0, hookRunner_1.hookRunnerPaths)(binaryName).launcher;
|
|
4717
|
+
}
|
|
4718
|
+
function cliAgentSelfCommand(spec) {
|
|
4719
|
+
return process.platform === "win32" ? `npx ${spec.packageName}` : (0, hookRunner_1.tidyHomePath)(cliAgentHookBinPath(spec.binaryName), os2.homedir());
|
|
3947
4720
|
}
|
|
3948
4721
|
function usage(spec) {
|
|
3949
4722
|
return `${spec.binaryName} setup \u2014 wire ${spec.displayName} to Ascenda telemetry
|
|
3950
4723
|
|
|
3951
4724
|
npx ${spec.packageName} setup [options]
|
|
3952
4725
|
npx ${spec.packageName} status
|
|
4726
|
+
npx ${spec.packageName} doctor
|
|
3953
4727
|
npx ${spec.packageName} uninstall
|
|
3954
4728
|
npx ${spec.packageName} join <code>
|
|
3955
4729
|
npx ${spec.packageName} object <purpose> [--undo]
|
|
@@ -3960,7 +4734,7 @@ Options
|
|
|
3960
4734
|
--tool-installation-id <id> reuse an existing pairing instead of creating one
|
|
3961
4735
|
--token <eventWriteToken> reuse an existing token (stored 0600, never printed)
|
|
3962
4736
|
--no-pair install without pairing: local features on, nothing sent
|
|
3963
|
-
--scope project
|
|
4737
|
+
--scope user|project where hooks are registered (default user: every project)
|
|
3964
4738
|
--project-dir <path> project root for --scope project (default cwd)
|
|
3965
4739
|
--dry-run print what would change, write nothing
|
|
3966
4740
|
-h, --help
|
|
@@ -3986,29 +4760,26 @@ Options
|
|
|
3986
4760
|
return await printStatus(options, spec);
|
|
3987
4761
|
if (options.action === "uninstall")
|
|
3988
4762
|
return uninstall(options, spec);
|
|
4763
|
+
if (options.action === "doctor")
|
|
4764
|
+
return await runDoctor(options, spec);
|
|
3989
4765
|
const apiBaseUrl = (options.apiBaseUrl ?? (0, credentials_1.readHostCredentials)(spec.host)?.apiBaseUrl ?? hookAdapter_1.DEFAULT_API_BASE_URL).replace(/\/$/, "");
|
|
3990
|
-
|
|
3991
|
-
console.log(`
|
|
3992
|
-
|
|
3993
|
-
`);
|
|
4766
|
+
const ui = (0, terminalStyle_1.terminalStyle)();
|
|
4767
|
+
const row = (tone, label, value) => console.log(` ${ui.mark(tone)} ${label.padEnd(12)} ${value}`);
|
|
4768
|
+
const detail = (label, value) => console.log(ui.dim(` ${label.padEnd(12)} ${value}`));
|
|
4769
|
+
console.log(`${ui.bold("Ascenda setup")} ${ui.dim(`\xB7 ${spec.displayName} \xB7 ${apiBaseUrl}`)}`);
|
|
4770
|
+
if (!options.skipPairing)
|
|
4771
|
+
console.log(`
|
|
4772
|
+
${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName: spec.displayName })}`);
|
|
4773
|
+
console.log("");
|
|
3994
4774
|
let identity;
|
|
3995
|
-
|
|
3996
|
-
if (options.skipPairing) {
|
|
3997
|
-
unpairedReason = "asked not to pair (--no-pair)";
|
|
3998
|
-
} else {
|
|
4775
|
+
if (!options.skipPairing)
|
|
3999
4776
|
identity = await resolveIdentity(apiBaseUrl, options, spec);
|
|
4000
|
-
if (identity) {
|
|
4001
|
-
console.log(` pairing ${identity.toolInstallationId}${identity.paired ? " (new)" : " (existing)"}`);
|
|
4002
|
-
} else {
|
|
4003
|
-
unpairedReason = "pairing did not finish \u2014 installing the local half anyway";
|
|
4004
|
-
}
|
|
4005
|
-
}
|
|
4006
|
-
if (unpairedReason) {
|
|
4007
|
-
console.log(` pairing none: ${unpairedReason}`);
|
|
4008
|
-
console.log(" local features on, nothing is sent");
|
|
4009
|
-
}
|
|
4010
4777
|
const binary = installBinary(spec, options.dryRun);
|
|
4011
|
-
|
|
4778
|
+
const node = options.dryRun || process.platform === "win32" ? void 0 : (0, hookRunner_1.resolveHookNode)(binary);
|
|
4779
|
+
if (node?.problem)
|
|
4780
|
+
row("bad", "hook binary", `${(0, hookRunner_1.tidyHomePath)(binary, os2.homedir())}, but ${node.problem}. Install Node 20 or newer, then run setup again`);
|
|
4781
|
+
else
|
|
4782
|
+
row("ok", "hook binary", `${(0, hookRunner_1.tidyHomePath)(binary, os2.homedir())}${node?.version ? ui.dim(` (Node ${node.version})`) : ""}`);
|
|
4012
4783
|
if (!options.dryRun) {
|
|
4013
4784
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4014
4785
|
const toolInstallationId = identity?.toolInstallationId ?? options.toolInstallationId ?? (0, credentials_1.readHostCredentials)(spec.host)?.toolInstallationId ?? `${spec.toolType}:${crypto.randomUUID()}`;
|
|
@@ -4018,31 +4789,76 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
|
|
|
4018
4789
|
...identity ? { pairedAt: now } : { localOnly: true, installedAt: now }
|
|
4019
4790
|
});
|
|
4020
4791
|
}
|
|
4021
|
-
|
|
4792
|
+
if (isHomeProject(options)) {
|
|
4793
|
+
detail("scope", "user (a project install in the home folder only loads when the agent starts there)");
|
|
4794
|
+
options.scope = "user";
|
|
4795
|
+
}
|
|
4022
4796
|
const settingsFile = spec.settings.settingsPath(options.scope, options.projectDir);
|
|
4023
4797
|
const before = registeredHookSets(readSettings(settingsFile), spec);
|
|
4024
4798
|
const written = writeHookSettings(settingsFile, binary, spec, options.dryRun);
|
|
4025
4799
|
if (written === null)
|
|
4026
4800
|
return 1;
|
|
4027
|
-
|
|
4801
|
+
const reach = options.scope === "user" ? "every project" : "this project only";
|
|
4802
|
+
row("ok", "hooks", `${(0, hookRunner_1.tidyHomePath)(settingsFile, os2.homedir())} ${ui.dim(`(${spec.hookEvents.length} events, ${reach}${written ? "" : ", already current"})`)}`);
|
|
4028
4803
|
const changes = spec.hookSet === void 0 ? void 0 : (0, hookSet_1.describeHookSetChanges)((0, hookSet_1.hookSetChanges)(before, spec.hookEvents), spec.hookSet);
|
|
4029
4804
|
if (changes)
|
|
4030
|
-
|
|
4805
|
+
detail("", changes);
|
|
4806
|
+
const otherFile = spec.settings.settingsPath(options.scope === "user" ? "project" : "user", options.projectDir);
|
|
4807
|
+
if (otherFile !== settingsFile && registeredHookSets(readSettings(otherFile), spec).size > 0) {
|
|
4808
|
+
if (options.dryRun) {
|
|
4809
|
+
row("info", "moved", `would remove the copy in ${(0, hookRunner_1.tidyHomePath)(otherFile, os2.homedir())}, so each event runs once`);
|
|
4810
|
+
} else if (removeOurHookEntries(otherFile, spec)) {
|
|
4811
|
+
row("ok", "moved", `removed the copy in ${(0, hookRunner_1.tidyHomePath)(otherFile, os2.homedir())}, so each event runs once ${ui.dim("(backup beside it)")}`);
|
|
4812
|
+
} else {
|
|
4813
|
+
row("warn", "note", `${(0, hookRunner_1.tidyHomePath)(otherFile, os2.homedir())} registers these hooks too, so each event runs twice.`);
|
|
4814
|
+
detail("", `Remove the ${spec.binaryName} entries from one of the two files.`);
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
const chosenLocal = options.skipPairing;
|
|
4818
|
+
if (identity)
|
|
4819
|
+
row("ok", "pairing", `${identity.toolInstallationId}${ui.dim(identity.paired ? " (new)" : " (existing)")}`);
|
|
4820
|
+
else if (chosenLocal)
|
|
4821
|
+
row("info", "pairing", `none, as asked ${ui.dim("(--no-pair)")}`);
|
|
4822
|
+
else
|
|
4823
|
+
row("warn", "pairing", "not paired: pairing did not finish");
|
|
4824
|
+
detail("credentials", `${(0, hookRunner_1.tidyHomePath)((0, credentials_1.credentialsFilePath)(), os2.homedir())} (tools.${spec.host})`);
|
|
4031
4825
|
if (options.dryRun) {
|
|
4032
|
-
console.log("\nDry run
|
|
4826
|
+
console.log("\nDry run. Nothing was written.");
|
|
4033
4827
|
return 0;
|
|
4034
4828
|
}
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4829
|
+
const self = cliAgentSelfCommand(spec);
|
|
4830
|
+
const next = (label, value) => console.log(` ${ui.bold(label.padEnd(6))} ${value}`);
|
|
4831
|
+
console.log("");
|
|
4832
|
+
if (chosenLocal) {
|
|
4833
|
+
console.log(`${ui.mark("ok")} ${ui.bold("Ready.")} The screen saver and the Ascenda app's live view work now.`);
|
|
4834
|
+
console.log(" They run on this machine and need no account or pairing.");
|
|
4835
|
+
} else if (!identity) {
|
|
4836
|
+
console.log(`${ui.mark("warn")} ${ui.bold("Installed, not paired.")} The screen saver and the live view work now.`);
|
|
4837
|
+
console.log(" Your sessions won't reach Ascenda's servers until pairing completes.");
|
|
4838
|
+
} else {
|
|
4839
|
+
console.log(`${ui.mark("ok")} ${ui.bold("Done.")} Paired, and the hooks are installed.`);
|
|
4840
|
+
}
|
|
4841
|
+
console.log("");
|
|
4842
|
+
next("Next", spec.restartHint);
|
|
4843
|
+
next("Check", ui.cyan(`${self} doctor`));
|
|
4844
|
+
if (!identity)
|
|
4845
|
+
next(chosenLocal ? "Pair" : "Retry", `${ui.cyan(`${self} setup`)}${chosenLocal ? ui.dim(" (optional)") : ""}`);
|
|
4846
|
+
if (chosenLocal) {
|
|
4847
|
+
console.log("");
|
|
4848
|
+
console.log(ui.dim(" Pairing sends the details below to Ascenda's servers, under the account the"));
|
|
4849
|
+
console.log(ui.dim(" Ascenda app is signed in to when you confirm the code, so your sessions appear"));
|
|
4850
|
+
console.log(ui.dim(" in the app. Until you pair, nothing leaves this machine."));
|
|
4851
|
+
console.log("");
|
|
4852
|
+
console.log(ui.dim((0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName: spec.displayName }).split("\n").map((line) => ` ${line}`).join("\n")));
|
|
4039
4853
|
}
|
|
4040
|
-
console.log(`Check anytime: npx ${spec.packageName} status`);
|
|
4041
4854
|
return 0;
|
|
4042
4855
|
}
|
|
4856
|
+
function isHomeProject(options) {
|
|
4857
|
+
return options.scope === "project" && path2.resolve(options.projectDir) === path2.resolve(os2.homedir());
|
|
4858
|
+
}
|
|
4043
4859
|
function parseArgs(argv, spec) {
|
|
4044
4860
|
const options = {
|
|
4045
|
-
scope: "
|
|
4861
|
+
scope: "user",
|
|
4046
4862
|
projectDir: process.cwd(),
|
|
4047
4863
|
dryRun: false,
|
|
4048
4864
|
skipPairing: false,
|
|
@@ -4067,6 +4883,9 @@ Done. ${spec.restartHint}`);
|
|
|
4067
4883
|
case "uninstall":
|
|
4068
4884
|
options.action = "uninstall";
|
|
4069
4885
|
break;
|
|
4886
|
+
case "doctor":
|
|
4887
|
+
options.action = "doctor";
|
|
4888
|
+
break;
|
|
4070
4889
|
case "--api-base-url":
|
|
4071
4890
|
options.apiBaseUrl = next();
|
|
4072
4891
|
break;
|
|
@@ -4224,17 +5043,7 @@ Pairing ${status.status}. Run setup again.`);
|
|
|
4224
5043
|
return void 0;
|
|
4225
5044
|
}
|
|
4226
5045
|
function installBinary(spec, dryRun) {
|
|
4227
|
-
|
|
4228
|
-
if (dryRun)
|
|
4229
|
-
return target;
|
|
4230
|
-
const source = process.argv[1];
|
|
4231
|
-
fs.mkdirSync(path2.dirname(target), { recursive: true });
|
|
4232
|
-
if (path2.resolve(source) !== path2.resolve(target)) {
|
|
4233
|
-
fs.copyFileSync(source, target);
|
|
4234
|
-
}
|
|
4235
|
-
if (process.platform !== "win32")
|
|
4236
|
-
fs.chmodSync(target, 493);
|
|
4237
|
-
return target;
|
|
5046
|
+
return (0, hookRunner_1.installHookRunner)({ binaryName: spec.binaryName, setupCommand: `npx ${spec.packageName} setup`, dryRun });
|
|
4238
5047
|
}
|
|
4239
5048
|
function writeHookSettings(settingsFile, binary, spec, dryRun) {
|
|
4240
5049
|
let settings = { ...spec.settings.scaffold ?? {} };
|
|
@@ -4275,7 +5084,7 @@ ${serialised}`);
|
|
|
4275
5084
|
return true;
|
|
4276
5085
|
}
|
|
4277
5086
|
function hookCommand(binary, spec) {
|
|
4278
|
-
return
|
|
5087
|
+
return `${(0, hookRunner_1.hookRunnerCommand)(binary)}${(0, hookSet_1.hookSetArgument)(spec.hookSet)}`;
|
|
4279
5088
|
}
|
|
4280
5089
|
function registeredHookSets(settings, spec) {
|
|
4281
5090
|
const sets = /* @__PURE__ */ new Map();
|
|
@@ -4328,7 +5137,18 @@ ${serialised}`);
|
|
|
4328
5137
|
console.log(`pairing ${credentials?.toolInstallationId ?? "\u2014 not paired"}${localOnly ? " (installed, not paired \u2014 local features active, telemetry inactive)" : ""}`);
|
|
4329
5138
|
console.log(`token ${localOnly ? "\u2014 none needed until this install is paired" : tokenFile && (0, tokenStore_1.readTokenFile)(tokenFile) ? "present" : "\u2014 missing"}`);
|
|
4330
5139
|
console.log(`hook binary ${fs.existsSync(binary) ? binary : "\u2014 not installed"}`);
|
|
5140
|
+
const node = process.platform === "win32" ? void 0 : (0, hookRunner_1.resolveHookNode)(binary);
|
|
5141
|
+
if (node) {
|
|
5142
|
+
console.log(node.problem ? `node \u2014 ${node.problem}. Install Node 20 or newer, then run setup again` : `node ${node.node} (${node.version}, ${node.how === "recorded" ? "recorded at setup" : "found by the launcher"})`);
|
|
5143
|
+
}
|
|
5144
|
+
const last = (0, hookRunner_1.readLastHook)(spec.host);
|
|
5145
|
+
console.log(last ? `last hook ${last.event}, ${(0, hookRunner_1.describeAge)(Date.now() - Date.parse(last.at))}` : `last hook \u2014 none has run yet. Start ${spec.displayName} (restart it if it was open during setup)`);
|
|
4331
5146
|
console.log(`hooks ${registered}/${spec.hookEvents.length} registered in ${settingsFile}`);
|
|
5147
|
+
const otherScope = options.scope === "user" ? "project" : "user";
|
|
5148
|
+
const otherFile = spec.settings.settingsPath(otherScope, options.projectDir);
|
|
5149
|
+
const elsewhere = registered === 0 && otherFile !== settingsFile ? countRegistered(readSettings(otherFile), spec) : 0;
|
|
5150
|
+
if (elsewhere > 0)
|
|
5151
|
+
console.log(` ${elsewhere}/${spec.hookEvents.length} found in ${otherFile} (--scope ${otherScope})`);
|
|
4332
5152
|
if (spec.hookSet !== void 0 && registered > 0) {
|
|
4333
5153
|
const sets = [...registeredHookSets(settings, spec).values()];
|
|
4334
5154
|
const oldest = Math.min(...sets);
|
|
@@ -4354,38 +5174,116 @@ ${serialised}`);
|
|
|
4354
5174
|
if (process.stdout.isTTY)
|
|
4355
5175
|
await notices.markShown();
|
|
4356
5176
|
const paired = localOnly || credentials?.toolInstallationId !== void 0;
|
|
4357
|
-
const
|
|
5177
|
+
const wired = registered === spec.hookEvents.length || options.scope === "project" && elsewhere === spec.hookEvents.length;
|
|
5178
|
+
const healthy = paired && wired && fs.existsSync(binary) && !stale.length && !node?.problem;
|
|
4358
5179
|
return healthy ? 0 : 1;
|
|
4359
5180
|
}
|
|
5181
|
+
function countRegistered(settings, spec) {
|
|
5182
|
+
return spec.hookEvents.filter((event) => (settings.hooks?.[event] ?? []).some((entry) => isOurs(entry, spec))).length;
|
|
5183
|
+
}
|
|
5184
|
+
function cliAgentRegistrations(spec, projectDir = process.cwd()) {
|
|
5185
|
+
const home = os2.homedir();
|
|
5186
|
+
const userFile = spec.settings.settingsPath("user", projectDir);
|
|
5187
|
+
const projectFile = spec.settings.settingsPath("project", projectDir);
|
|
5188
|
+
const found = [];
|
|
5189
|
+
for (const [scope, file] of [["user", userFile], ["project", projectFile]]) {
|
|
5190
|
+
if (scope === "project" && file === userFile)
|
|
5191
|
+
continue;
|
|
5192
|
+
const registered = countRegistered(readSettings(file), spec);
|
|
5193
|
+
if (registered === 0)
|
|
5194
|
+
continue;
|
|
5195
|
+
found.push({
|
|
5196
|
+
file: (0, hookRunner_1.tidyHomePath)(file, home),
|
|
5197
|
+
registered,
|
|
5198
|
+
scope,
|
|
5199
|
+
homeProject: scope === "project" && path2.resolve(projectDir) === path2.resolve(home)
|
|
5200
|
+
});
|
|
5201
|
+
}
|
|
5202
|
+
return found;
|
|
5203
|
+
}
|
|
5204
|
+
async function runDoctor(options, spec) {
|
|
5205
|
+
const ui = (0, terminalStyle_1.terminalStyle)();
|
|
5206
|
+
const lines = [`${ui.bold("Ascenda doctor")} ${ui.dim(`\xB7 ${spec.displayName}`)}`, ""];
|
|
5207
|
+
try {
|
|
5208
|
+
lines.push(...await (0, liveSignalDoctor_1.liveSignalDoctorLines)({
|
|
5209
|
+
displayName: spec.displayName,
|
|
5210
|
+
tool: spec.host,
|
|
5211
|
+
launcher: process.platform === "win32" ? void 0 : cliAgentHookBinPath(spec.binaryName),
|
|
5212
|
+
registrations: cliAgentRegistrations(spec, options.projectDir),
|
|
5213
|
+
eventCount: spec.hookEvents.length,
|
|
5214
|
+
selfCommand: cliAgentSelfCommand(spec),
|
|
5215
|
+
setupCommand: `npx ${spec.packageName} setup`,
|
|
5216
|
+
ui
|
|
5217
|
+
}));
|
|
5218
|
+
} catch (error) {
|
|
5219
|
+
lines.push(` Live signal (could not be checked: ${error instanceof Error ? error.message : String(error)})`);
|
|
5220
|
+
}
|
|
5221
|
+
lines.push("", ...accountLines(ui, spec));
|
|
5222
|
+
console.log(lines.join("\n"));
|
|
5223
|
+
return 0;
|
|
5224
|
+
}
|
|
5225
|
+
function accountLines(ui, spec) {
|
|
5226
|
+
const credentials = (0, credentials_1.readHostCredentials)(spec.host);
|
|
5227
|
+
const id = credentials?.toolInstallationId;
|
|
5228
|
+
const localOnly = (0, credentials_1.isLocalOnlyHostInstall)(spec.host, (installationId) => (0, tokenStore_1.readTokenFile)((0, tokenStore_1.defaultTokenFilePath)(installationId)) !== void 0);
|
|
5229
|
+
const row = (tone, label, value) => ` ${ui.mark(tone)} ${label.padEnd(20)} ${value}`;
|
|
5230
|
+
if (!id || localOnly) {
|
|
5231
|
+
return [
|
|
5232
|
+
` ${ui.bold("Account sync")} ${ui.dim("(optional; this install isn't paired)")}`,
|
|
5233
|
+
...id ? [ui.dim(row("info", "Installation id", id))] : [],
|
|
5234
|
+
"",
|
|
5235
|
+
" Not paired, which is fine: the screen saver and the live view above work",
|
|
5236
|
+
" without it. Nothing leaves this machine and nothing is queued. To send your",
|
|
5237
|
+
" sessions to Ascenda's servers, so they appear in the app:",
|
|
5238
|
+
` ${ui.cyan(`${cliAgentSelfCommand(spec)} setup`)}`
|
|
5239
|
+
];
|
|
5240
|
+
}
|
|
5241
|
+
const token = (0, tokenStore_1.readTokenFile)((0, tokenStore_1.defaultTokenFilePath)(id)) ?? process.env.ASCENDA_EVENT_WRITE_TOKEN?.trim();
|
|
5242
|
+
const state = (0, stateStore_1.readCollectorState)((0, stateStore_1.defaultStateFilePath)(id));
|
|
5243
|
+
const outcome = state?.lastOutcome;
|
|
5244
|
+
return [
|
|
5245
|
+
` ${ui.bold("Account sync")}`,
|
|
5246
|
+
row("info", "Installation id", id),
|
|
5247
|
+
token ? row("ok", "Token", "present") : row("bad", "Token", ui.red(`missing, so nothing can be sent. Run: npx ${spec.packageName} setup`)),
|
|
5248
|
+
outcome ? row(outcome === "accepted" ? "ok" : "warn", "Last send", `${outcome}${state?.lastAttemptAt ? ui.dim(` (${state.lastAttemptAt})`) : ""}`) : row("info", "Last send", "none yet")
|
|
5249
|
+
];
|
|
5250
|
+
}
|
|
5251
|
+
function removeOurHookEntries(settingsFile, spec) {
|
|
5252
|
+
if (!fs.existsSync(settingsFile))
|
|
5253
|
+
return true;
|
|
5254
|
+
try {
|
|
5255
|
+
const settings = JSON.parse(fs.readFileSync(settingsFile, "utf8"));
|
|
5256
|
+
const hooks = { ...settings.hooks ?? {} };
|
|
5257
|
+
for (const event of Object.keys(hooks)) {
|
|
5258
|
+
const kept = hooks[event].filter((entry) => !isOurs(entry, spec));
|
|
5259
|
+
if (kept.length)
|
|
5260
|
+
hooks[event] = kept;
|
|
5261
|
+
else
|
|
5262
|
+
delete hooks[event];
|
|
5263
|
+
}
|
|
5264
|
+
const updated = { ...settings, hooks };
|
|
5265
|
+
if (!Object.keys(hooks).length)
|
|
5266
|
+
delete updated.hooks;
|
|
5267
|
+
fs.copyFileSync(settingsFile, `${settingsFile}.ascenda-backup`);
|
|
5268
|
+
fs.writeFileSync(settingsFile, `${JSON.stringify(updated, null, 2)}
|
|
5269
|
+
`, "utf8");
|
|
5270
|
+
return true;
|
|
5271
|
+
} catch {
|
|
5272
|
+
return false;
|
|
5273
|
+
}
|
|
5274
|
+
}
|
|
4360
5275
|
function uninstall(options, spec) {
|
|
4361
5276
|
const settingsFile = spec.settings.settingsPath(options.scope, options.projectDir);
|
|
4362
5277
|
if (fs.existsSync(settingsFile)) {
|
|
4363
|
-
|
|
4364
|
-
const settings = JSON.parse(fs.readFileSync(settingsFile, "utf8"));
|
|
4365
|
-
const hooks = { ...settings.hooks ?? {} };
|
|
4366
|
-
for (const event of Object.keys(hooks)) {
|
|
4367
|
-
const kept = hooks[event].filter((entry) => !isOurs(entry, spec));
|
|
4368
|
-
if (kept.length)
|
|
4369
|
-
hooks[event] = kept;
|
|
4370
|
-
else
|
|
4371
|
-
delete hooks[event];
|
|
4372
|
-
}
|
|
4373
|
-
const updated = { ...settings, hooks };
|
|
4374
|
-
if (!Object.keys(hooks).length)
|
|
4375
|
-
delete updated.hooks;
|
|
4376
|
-
fs.copyFileSync(settingsFile, `${settingsFile}.ascenda-backup`);
|
|
4377
|
-
fs.writeFileSync(settingsFile, `${JSON.stringify(updated, null, 2)}
|
|
4378
|
-
`, "utf8");
|
|
4379
|
-
console.log(`hooks removed from ${settingsFile}`);
|
|
4380
|
-
} catch {
|
|
5278
|
+
if (!removeOurHookEntries(settingsFile, spec)) {
|
|
4381
5279
|
console.error(`could not parse ${settingsFile} \u2014 remove the ascenda hook entries by hand`);
|
|
4382
5280
|
return 1;
|
|
4383
5281
|
}
|
|
5282
|
+
console.log(`hooks removed from ${settingsFile}`);
|
|
4384
5283
|
}
|
|
4385
|
-
const
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
console.log(`removed ${binary}`);
|
|
5284
|
+
for (const file of (0, hookRunner_1.removeHookRunner)(spec.binaryName)) {
|
|
5285
|
+
if (!file.endsWith(".node") && !file.endsWith(".no-node"))
|
|
5286
|
+
console.log(`removed ${file}`);
|
|
4389
5287
|
}
|
|
4390
5288
|
if ((0, credentials_1.readHostCredentials)(spec.host)) {
|
|
4391
5289
|
(0, credentials_1.removeHostCredentials)(spec.host);
|
|
@@ -4477,180 +5375,6 @@ var require_turnState = __commonJS({
|
|
|
4477
5375
|
}
|
|
4478
5376
|
});
|
|
4479
5377
|
|
|
4480
|
-
// ../packages/tool-kit/out/liveBus.js
|
|
4481
|
-
var require_liveBus = __commonJS({
|
|
4482
|
-
"../packages/tool-kit/out/liveBus.js"(exports) {
|
|
4483
|
-
"use strict";
|
|
4484
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4485
|
-
if (k2 === void 0) k2 = k;
|
|
4486
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4487
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4488
|
-
desc = { enumerable: true, get: function() {
|
|
4489
|
-
return m[k];
|
|
4490
|
-
} };
|
|
4491
|
-
}
|
|
4492
|
-
Object.defineProperty(o, k2, desc);
|
|
4493
|
-
} : function(o, m, k, k2) {
|
|
4494
|
-
if (k2 === void 0) k2 = k;
|
|
4495
|
-
o[k2] = m[k];
|
|
4496
|
-
});
|
|
4497
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
4498
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
4499
|
-
} : function(o, v) {
|
|
4500
|
-
o["default"] = v;
|
|
4501
|
-
});
|
|
4502
|
-
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
4503
|
-
var ownKeys = function(o) {
|
|
4504
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
4505
|
-
var ar = [];
|
|
4506
|
-
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
4507
|
-
return ar;
|
|
4508
|
-
};
|
|
4509
|
-
return ownKeys(o);
|
|
4510
|
-
};
|
|
4511
|
-
return function(mod) {
|
|
4512
|
-
if (mod && mod.__esModule) return mod;
|
|
4513
|
-
var result = {};
|
|
4514
|
-
if (mod != null) {
|
|
4515
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
4516
|
-
}
|
|
4517
|
-
__setModuleDefault(result, mod);
|
|
4518
|
-
return result;
|
|
4519
|
-
};
|
|
4520
|
-
}();
|
|
4521
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4522
|
-
exports.LIVE_BUS_BACKGROUND_TRUST_MS = void 0;
|
|
4523
|
-
exports.liveBusSocketCandidates = liveBusSocketCandidates;
|
|
4524
|
-
exports.liveBusSocketPath = liveBusSocketPath;
|
|
4525
|
-
exports.bucketPromptSize = bucketPromptSize2;
|
|
4526
|
-
exports.emitLiveSignal = emitLiveSignal2;
|
|
4527
|
-
var fs = __importStar(__require("fs"));
|
|
4528
|
-
var net = __importStar(__require("net"));
|
|
4529
|
-
var os2 = __importStar(__require("os"));
|
|
4530
|
-
var path2 = __importStar(__require("path"));
|
|
4531
|
-
var hookSet_1 = require_hookSet();
|
|
4532
|
-
var WRITE_TIMEOUT_MS = 50;
|
|
4533
|
-
exports.LIVE_BUS_BACKGROUND_TRUST_MS = 60 * 60 * 1e3;
|
|
4534
|
-
var APP_BUNDLE_ID = "one.ascenda.ascendaMissionControl";
|
|
4535
|
-
var SAVER_HOST_BUNDLE_ID = "com.apple.ScreenSaver.Engine.legacyScreenSaver";
|
|
4536
|
-
function liveBusSocketCandidates() {
|
|
4537
|
-
const override = process.env.ASCENDA_LIVE_BUS_SOCKET;
|
|
4538
|
-
if (override)
|
|
4539
|
-
return [override];
|
|
4540
|
-
const home = os2.homedir();
|
|
4541
|
-
return [
|
|
4542
|
-
path2.join(home, ".ascenda", "live.sock"),
|
|
4543
|
-
path2.join(home, "Library", "Containers", APP_BUNDLE_ID, "Data", ".ascenda", "live.sock"),
|
|
4544
|
-
path2.join(home, "Library", "Containers", SAVER_HOST_BUNDLE_ID, "Data", "l.sock")
|
|
4545
|
-
];
|
|
4546
|
-
}
|
|
4547
|
-
function existingSocketCandidates() {
|
|
4548
|
-
const candidates = liveBusSocketCandidates();
|
|
4549
|
-
if (process.env.ASCENDA_LIVE_BUS_SOCKET)
|
|
4550
|
-
return candidates;
|
|
4551
|
-
return candidates.filter((candidate) => {
|
|
4552
|
-
try {
|
|
4553
|
-
return fs.statSync(candidate).isSocket();
|
|
4554
|
-
} catch {
|
|
4555
|
-
return false;
|
|
4556
|
-
}
|
|
4557
|
-
});
|
|
4558
|
-
}
|
|
4559
|
-
function liveBusSocketPath() {
|
|
4560
|
-
return existingSocketCandidates()[0] ?? liveBusSocketCandidates()[0];
|
|
4561
|
-
}
|
|
4562
|
-
function bucketPromptSize2(text) {
|
|
4563
|
-
const length = typeof text === "string" ? text.length : 0;
|
|
4564
|
-
if (length <= 280)
|
|
4565
|
-
return "s";
|
|
4566
|
-
if (length <= 2e3)
|
|
4567
|
-
return "m";
|
|
4568
|
-
if (length <= 8e3)
|
|
4569
|
-
return "l";
|
|
4570
|
-
return "xl";
|
|
4571
|
-
}
|
|
4572
|
-
var NOBODY_LISTENING = /* @__PURE__ */ new Set(["ECONNREFUSED", "ENOENT"]);
|
|
4573
|
-
function onTheWire(signal) {
|
|
4574
|
-
const out = { ...signal };
|
|
4575
|
-
if ("hookSet" in out && !(0, hookSet_1.isHookSet)(out.hookSet))
|
|
4576
|
-
delete out.hookSet;
|
|
4577
|
-
if ("viaPlugin" in out && out.viaPlugin !== true)
|
|
4578
|
-
delete out.viaPlugin;
|
|
4579
|
-
return out;
|
|
4580
|
-
}
|
|
4581
|
-
function emitLiveSignal2(signal) {
|
|
4582
|
-
return new Promise((resolve) => {
|
|
4583
|
-
const candidates = existingSocketCandidates();
|
|
4584
|
-
if (candidates.length === 0) {
|
|
4585
|
-
resolve();
|
|
4586
|
-
return;
|
|
4587
|
-
}
|
|
4588
|
-
let settled = false;
|
|
4589
|
-
let socket;
|
|
4590
|
-
const drop = () => {
|
|
4591
|
-
try {
|
|
4592
|
-
socket?.destroy();
|
|
4593
|
-
} catch {
|
|
4594
|
-
}
|
|
4595
|
-
socket = void 0;
|
|
4596
|
-
};
|
|
4597
|
-
const done = () => {
|
|
4598
|
-
if (settled)
|
|
4599
|
-
return;
|
|
4600
|
-
settled = true;
|
|
4601
|
-
clearTimeout(timer);
|
|
4602
|
-
drop();
|
|
4603
|
-
resolve();
|
|
4604
|
-
};
|
|
4605
|
-
const timer = setTimeout(done, WRITE_TIMEOUT_MS);
|
|
4606
|
-
if (typeof timer.unref === "function")
|
|
4607
|
-
timer.unref();
|
|
4608
|
-
const tryFrom = (index) => {
|
|
4609
|
-
if (settled)
|
|
4610
|
-
return;
|
|
4611
|
-
if (index >= candidates.length) {
|
|
4612
|
-
done();
|
|
4613
|
-
return;
|
|
4614
|
-
}
|
|
4615
|
-
let attempt;
|
|
4616
|
-
try {
|
|
4617
|
-
attempt = net.createConnection(candidates[index]);
|
|
4618
|
-
} catch {
|
|
4619
|
-
tryFrom(index + 1);
|
|
4620
|
-
return;
|
|
4621
|
-
}
|
|
4622
|
-
socket = attempt;
|
|
4623
|
-
if (typeof attempt.unref === "function")
|
|
4624
|
-
attempt.unref();
|
|
4625
|
-
let connected = false;
|
|
4626
|
-
attempt.on("error", (error) => {
|
|
4627
|
-
if (settled || socket !== attempt)
|
|
4628
|
-
return;
|
|
4629
|
-
if (!connected && error.code && NOBODY_LISTENING.has(error.code)) {
|
|
4630
|
-
drop();
|
|
4631
|
-
tryFrom(index + 1);
|
|
4632
|
-
return;
|
|
4633
|
-
}
|
|
4634
|
-
done();
|
|
4635
|
-
});
|
|
4636
|
-
attempt.on("connect", () => {
|
|
4637
|
-
if (settled || socket !== attempt)
|
|
4638
|
-
return;
|
|
4639
|
-
connected = true;
|
|
4640
|
-
try {
|
|
4641
|
-
attempt.write(`${JSON.stringify(onTheWire(signal))}
|
|
4642
|
-
`, done);
|
|
4643
|
-
} catch {
|
|
4644
|
-
done();
|
|
4645
|
-
}
|
|
4646
|
-
});
|
|
4647
|
-
};
|
|
4648
|
-
tryFrom(0);
|
|
4649
|
-
});
|
|
4650
|
-
}
|
|
4651
|
-
}
|
|
4652
|
-
});
|
|
4653
|
-
|
|
4654
5378
|
// ../packages/tool-kit/out/agentProcess.js
|
|
4655
5379
|
var require_agentProcess = __commonJS({
|
|
4656
5380
|
"../packages/tool-kit/out/agentProcess.js"(exports) {
|
|
@@ -4797,7 +5521,8 @@ var require_out2 = __commonJS({
|
|
|
4797
5521
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4798
5522
|
exports.FREE_TEXT_KEYS = exports.FAMILY_SENTENCES = exports.ALWAYS_SENT = exports.writeHookSettings = exports.runCliAgentSetup = exports.registeredHookSets = exports.isCliAgentManagementCommand = exports.findStaleHookCommands = exports.cliAgentHookBinPath = exports.resolveContextHashes = exports.resolveCliAgentInstallationId = exports.loadCliAgentConfig = exports.deliverHookEvents = exports.MissingInstallationIdError = exports.DEFAULT_API_BASE_URL = exports.resolveEventLogPath = exports.expandUserPath = exports.appendEventLog = exports.EVENT_LOG_ENV_VAR = exports.buildEventPayload = exports.TOKEN_RENEW_LEAD_MS = exports.AscendaSemanticEventError = exports.AscendaEventSender = exports.describeCollectorVersion = exports.UNRELEASED_COLLECTOR_VERSION = exports.COLLECTOR_VERSION = exports.mintIdempotencyKey = exports.looksLikeCorrection = exports.outcomeForHook = exports.inferOutcome = exports.getNestedNumber = exports.getNestedString = exports.getNested = exports.getNumber = exports.getString = exports.localHourAt = exports.utcOffsetMinutesAt = exports.BUSINESS_DAY = exports.isOutsideBusinessHours = exports.isAfterHours = exports.bucketDurationMs = exports.bucketLinesChanged = exports.classifyModelClass = exports.autonomyBand = exports.invitesDebrief = exports.classifyWorkMilestone = exports.isReworkGitAction = exports.classifyGitAction = exports.isVerificationCommand = exports.classifyCommand = void 0;
|
|
4799
5523
|
exports.recordWorkContextAlias = exports.recordWorkContext = exports.readBranchName = exports.normalizeBranchName = exports.deriveBranchHashForCwd = exports.deriveBranchHash = exports.deriveWorkContext = exports.hashWithMachineSalt = exports.readOrCreateMachineSalt = exports.machineSaltFilePath = exports.fixedTimeProvider = exports.systemTimeProvider = exports.enforceOutboxBounds = exports.claimOutbox = exports.readOutboxSummary = exports.appendToOutbox = exports.defaultOutboxFilePath = exports.outboxDrainEnabled = exports.DEFAULT_OUTBOX_DRAIN_BATCH_SIZE = exports.DEFAULT_OUTBOX_MAX_AGE_MS = exports.DEFAULT_OUTBOX_MAX_ENTRIES = exports.OUTBOX_DRAIN_ENV_VAR = exports.recordOutboxDiscard = exports.unresolvedToolInstallationId = exports.unresolvedStateFilePath = exports.markFailureNotified = exports.shouldAnnounceFailure = exports.recordSendOutcome = exports.readCollectorState = exports.defaultStateFilePath = exports.tokenExpiryFilePath = exports.readTokenFile = exports.readTokenExpiry = exports.persistEventWriteToken = exports.listPersistedToolInstallationIds = exports.defaultTokenFilePath = exports.ascendaHome = exports.EVENT_TOKEN_TTL_MS = exports.recordTurnStart = exports.consumeTurnDurationMs = exports.writeTopLevelCredentials = exports.writeMachineCredentials = exports.writeHostCredentials = exports.removeHostCredentials = exports.readMachineCredentials = exports.readHostCredentials = exports.isLocalOnlyHostInstall = exports.credentialsFilePath = exports.renderSetupDisclosure = exports.REFUSALS = void 0;
|
|
4800
|
-
exports.
|
|
5524
|
+
exports.findAgentProcess = exports.findAgentPid = exports.AGENT_PROCESS = exports.readViaPlugin = exports.readHookSet = exports.isHookSet = exports.hookSetOfCommand = exports.hookSetChanges = exports.hookSetArgument = exports.describeHookSetChanges = exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = exports.liveSignalDoctorLines = exports.doctorRow = exports.DOCTOR_VALUE_COLUMN = exports.tidyHomePath = exports.stampLastHook = exports.resolveHookNode = exports.removeHookRunner = exports.readLastHook = exports.lastHookPath = exports.installHookRunner = exports.hookRunnerPaths = exports.hookRunnerCommand = exports.hookLauncherScript = exports.describeAge = exports.terminalStyle = exports.colourEnabled = exports.SAVER_REPLAY_WINDOW_MS = exports.saverSupportDir = exports.saverStatusDir = exports.saverReplayPath = exports.saverContainerDir = exports.readSaverStatuses = exports.probeSocket = exports.heldForSaver = exports.holdForSaver = exports.LIVE_BUS_BACKGROUND_TRUST_MS = exports.liveBusSocketCandidates = exports.liveBusSocketPath = exports.bucketPromptSize = exports.deliverLine = exports.emitLiveSignal = exports.recordForgeProjectAlias = exports.forgeFullNameFromConfig = exports.readForgeFullName = exports.parseForgeFullName = exports.forgeProjectHash = exports.workContextRegistryFilePath = exports.readWorkContextRegistry = void 0;
|
|
5525
|
+
exports.runStudyJoin = exports.studyNoticeStatus = exports.runStudyObjection = exports.renderStudyNotices = exports.NOTICED_PURPOSES = exports.renderInitiatives = exports.initiativesStatusLines = exports.INITIATIVE_COPY = exports.startStudyJoin = exports.setStudyObjection = exports.markStudyNoticeShown = exports.readStudyNotices = exports.readInitiatives = exports.isRetryableStatus = exports.parseIngestResponse = exports.postToolEventsBatch = exports.postToolEvent = exports.renewToolToken = exports.getStudyJoinStatus = exports.getPairingStatus = exports.createPairingSession = exports.AscendaApiError = exports.scriptMarkerIn = exports.psLookup = exports.psArgsLookup = exports.livePidFields = void 0;
|
|
4801
5526
|
var commandClassifier_1 = require_commandClassifier();
|
|
4802
5527
|
Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
|
|
4803
5528
|
return commandClassifier_1.classifyCommand;
|
|
@@ -5147,6 +5872,9 @@ var require_out2 = __commonJS({
|
|
|
5147
5872
|
Object.defineProperty(exports, "emitLiveSignal", { enumerable: true, get: function() {
|
|
5148
5873
|
return liveBus_1.emitLiveSignal;
|
|
5149
5874
|
} });
|
|
5875
|
+
Object.defineProperty(exports, "deliverLine", { enumerable: true, get: function() {
|
|
5876
|
+
return liveBus_1.deliverLine;
|
|
5877
|
+
} });
|
|
5150
5878
|
Object.defineProperty(exports, "bucketPromptSize", { enumerable: true, get: function() {
|
|
5151
5879
|
return liveBus_1.bucketPromptSize;
|
|
5152
5880
|
} });
|
|
@@ -5159,6 +5887,85 @@ var require_out2 = __commonJS({
|
|
|
5159
5887
|
Object.defineProperty(exports, "LIVE_BUS_BACKGROUND_TRUST_MS", { enumerable: true, get: function() {
|
|
5160
5888
|
return liveBus_1.LIVE_BUS_BACKGROUND_TRUST_MS;
|
|
5161
5889
|
} });
|
|
5890
|
+
var saverHandoff_1 = require_saverHandoff();
|
|
5891
|
+
Object.defineProperty(exports, "holdForSaver", { enumerable: true, get: function() {
|
|
5892
|
+
return saverHandoff_1.holdForSaver;
|
|
5893
|
+
} });
|
|
5894
|
+
Object.defineProperty(exports, "heldForSaver", { enumerable: true, get: function() {
|
|
5895
|
+
return saverHandoff_1.heldForSaver;
|
|
5896
|
+
} });
|
|
5897
|
+
Object.defineProperty(exports, "probeSocket", { enumerable: true, get: function() {
|
|
5898
|
+
return saverHandoff_1.probeSocket;
|
|
5899
|
+
} });
|
|
5900
|
+
Object.defineProperty(exports, "readSaverStatuses", { enumerable: true, get: function() {
|
|
5901
|
+
return saverHandoff_1.readSaverStatuses;
|
|
5902
|
+
} });
|
|
5903
|
+
Object.defineProperty(exports, "saverContainerDir", { enumerable: true, get: function() {
|
|
5904
|
+
return saverHandoff_1.saverContainerDir;
|
|
5905
|
+
} });
|
|
5906
|
+
Object.defineProperty(exports, "saverReplayPath", { enumerable: true, get: function() {
|
|
5907
|
+
return saverHandoff_1.saverReplayPath;
|
|
5908
|
+
} });
|
|
5909
|
+
Object.defineProperty(exports, "saverStatusDir", { enumerable: true, get: function() {
|
|
5910
|
+
return saverHandoff_1.saverStatusDir;
|
|
5911
|
+
} });
|
|
5912
|
+
Object.defineProperty(exports, "saverSupportDir", { enumerable: true, get: function() {
|
|
5913
|
+
return saverHandoff_1.saverSupportDir;
|
|
5914
|
+
} });
|
|
5915
|
+
Object.defineProperty(exports, "SAVER_REPLAY_WINDOW_MS", { enumerable: true, get: function() {
|
|
5916
|
+
return saverHandoff_1.SAVER_REPLAY_WINDOW_MS;
|
|
5917
|
+
} });
|
|
5918
|
+
var terminalStyle_1 = require_terminalStyle();
|
|
5919
|
+
Object.defineProperty(exports, "colourEnabled", { enumerable: true, get: function() {
|
|
5920
|
+
return terminalStyle_1.colourEnabled;
|
|
5921
|
+
} });
|
|
5922
|
+
Object.defineProperty(exports, "terminalStyle", { enumerable: true, get: function() {
|
|
5923
|
+
return terminalStyle_1.terminalStyle;
|
|
5924
|
+
} });
|
|
5925
|
+
var hookRunner_1 = require_hookRunner();
|
|
5926
|
+
Object.defineProperty(exports, "describeAge", { enumerable: true, get: function() {
|
|
5927
|
+
return hookRunner_1.describeAge;
|
|
5928
|
+
} });
|
|
5929
|
+
Object.defineProperty(exports, "hookLauncherScript", { enumerable: true, get: function() {
|
|
5930
|
+
return hookRunner_1.hookLauncherScript;
|
|
5931
|
+
} });
|
|
5932
|
+
Object.defineProperty(exports, "hookRunnerCommand", { enumerable: true, get: function() {
|
|
5933
|
+
return hookRunner_1.hookRunnerCommand;
|
|
5934
|
+
} });
|
|
5935
|
+
Object.defineProperty(exports, "hookRunnerPaths", { enumerable: true, get: function() {
|
|
5936
|
+
return hookRunner_1.hookRunnerPaths;
|
|
5937
|
+
} });
|
|
5938
|
+
Object.defineProperty(exports, "installHookRunner", { enumerable: true, get: function() {
|
|
5939
|
+
return hookRunner_1.installHookRunner;
|
|
5940
|
+
} });
|
|
5941
|
+
Object.defineProperty(exports, "lastHookPath", { enumerable: true, get: function() {
|
|
5942
|
+
return hookRunner_1.lastHookPath;
|
|
5943
|
+
} });
|
|
5944
|
+
Object.defineProperty(exports, "readLastHook", { enumerable: true, get: function() {
|
|
5945
|
+
return hookRunner_1.readLastHook;
|
|
5946
|
+
} });
|
|
5947
|
+
Object.defineProperty(exports, "removeHookRunner", { enumerable: true, get: function() {
|
|
5948
|
+
return hookRunner_1.removeHookRunner;
|
|
5949
|
+
} });
|
|
5950
|
+
Object.defineProperty(exports, "resolveHookNode", { enumerable: true, get: function() {
|
|
5951
|
+
return hookRunner_1.resolveHookNode;
|
|
5952
|
+
} });
|
|
5953
|
+
Object.defineProperty(exports, "stampLastHook", { enumerable: true, get: function() {
|
|
5954
|
+
return hookRunner_1.stampLastHook;
|
|
5955
|
+
} });
|
|
5956
|
+
Object.defineProperty(exports, "tidyHomePath", { enumerable: true, get: function() {
|
|
5957
|
+
return hookRunner_1.tidyHomePath;
|
|
5958
|
+
} });
|
|
5959
|
+
var liveSignalDoctor_1 = require_liveSignalDoctor();
|
|
5960
|
+
Object.defineProperty(exports, "DOCTOR_VALUE_COLUMN", { enumerable: true, get: function() {
|
|
5961
|
+
return liveSignalDoctor_1.DOCTOR_VALUE_COLUMN;
|
|
5962
|
+
} });
|
|
5963
|
+
Object.defineProperty(exports, "doctorRow", { enumerable: true, get: function() {
|
|
5964
|
+
return liveSignalDoctor_1.doctorRow;
|
|
5965
|
+
} });
|
|
5966
|
+
Object.defineProperty(exports, "liveSignalDoctorLines", { enumerable: true, get: function() {
|
|
5967
|
+
return liveSignalDoctor_1.liveSignalDoctorLines;
|
|
5968
|
+
} });
|
|
5162
5969
|
var hookSet_1 = require_hookSet();
|
|
5163
5970
|
Object.defineProperty(exports, "HOOK_SET_FLAG", { enumerable: true, get: function() {
|
|
5164
5971
|
return hookSet_1.HOOK_SET_FLAG;
|
|
@@ -5391,6 +6198,8 @@ function liveSignalFor(hookName, input) {
|
|
|
5391
6198
|
return { event: "compaction" };
|
|
5392
6199
|
case "AfterAgent":
|
|
5393
6200
|
return { event: "stop" };
|
|
6201
|
+
case "SessionEnd":
|
|
6202
|
+
return { event: "halted" };
|
|
5394
6203
|
case "Notification":
|
|
5395
6204
|
return (0, import_tool_kit2.getString)(input, ["notification_type"]) === "ToolPermission" ? { event: "awaiting" } : void 0;
|
|
5396
6205
|
default:
|
|
@@ -5444,6 +6253,7 @@ async function main() {
|
|
|
5444
6253
|
}
|
|
5445
6254
|
const sessionId = typeof input.session_id === "string" ? input.session_id : void 0;
|
|
5446
6255
|
let turnDurationMs;
|
|
6256
|
+
(0, import_tool_kit3.stampLastHook)(GEMINI_HOST, hookName);
|
|
5447
6257
|
if (hookName === "BeforeAgent") (0, import_tool_kit3.recordTurnStart)(GEMINI_HOST, sessionId);
|
|
5448
6258
|
if (hookName === "AfterAgent") turnDurationMs = (0, import_tool_kit3.consumeTurnDurationMs)(GEMINI_HOST, sessionId);
|
|
5449
6259
|
await emitLive(hookName, input, sessionId);
|