@ascenda-one/agent-mcp 0.1.28 → 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 +1 -1
- package/dist/cli.js +2260 -229
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -724,6 +724,10 @@ var require_out = __commonJS({
|
|
|
724
724
|
// One constant word, from the agent itself. The session sentence names it.
|
|
725
725
|
sessionEndReason: "session",
|
|
726
726
|
interruptionKind: "waiting",
|
|
727
|
+
// Claude Code's own opaque id for one subagent, and the class it belongs
|
|
728
|
+
// to. Never the agent's name or anything it was asked.
|
|
729
|
+
subagentId: "subagents",
|
|
730
|
+
subagentClass: "subagents",
|
|
727
731
|
// Free text by type, and written by no hook mapper — the IDE extension's
|
|
728
732
|
// test signal is the only producer. The setup disclosure's third refusal
|
|
729
733
|
// line says as much, and tool-kit's guard test fails if a mapper starts.
|
|
@@ -772,6 +776,8 @@ var require_out = __commonJS({
|
|
|
772
776
|
"runtime",
|
|
773
777
|
"sessionEndReason",
|
|
774
778
|
"interruptionKind",
|
|
779
|
+
"subagentId",
|
|
780
|
+
"subagentClass",
|
|
775
781
|
"simulated",
|
|
776
782
|
"relatedEventType",
|
|
777
783
|
"skillVersion",
|
|
@@ -819,6 +825,12 @@ var require_out = __commonJS({
|
|
|
819
825
|
// `ai_prompt_submitted` closes. Neutral so a marker sent once per turn
|
|
820
826
|
// doesn't weigh on any workload leg.
|
|
821
827
|
ai_turn_completed: "neutral",
|
|
828
|
+
// A subagent began or finished under a session. Boundaries, not work: the
|
|
829
|
+
// subagent's own tool calls and edits arrive as their own events and carry
|
|
830
|
+
// their own categories. A reader pairs these on `subagentId` to count how
|
|
831
|
+
// many agents ran at once; neutral so that count weighs on no workload leg.
|
|
832
|
+
subagent_started: "neutral",
|
|
833
|
+
subagent_stopped: "neutral",
|
|
822
834
|
// The agent stopped and is waiting on the person: Claude Code's
|
|
823
835
|
// `Notification`, Codex's `PermissionRequest`. Supervision, beside the other
|
|
824
836
|
// oversight overhead, because that is what it is — time the person spends
|
|
@@ -953,7 +965,7 @@ var require_collectorVersion = __commonJS({
|
|
|
953
965
|
exports.COLLECTOR_VERSION = exports.UNRELEASED_COLLECTOR_VERSION = void 0;
|
|
954
966
|
exports.describeCollectorVersion = describeCollectorVersion;
|
|
955
967
|
exports.UNRELEASED_COLLECTOR_VERSION = "unreleased";
|
|
956
|
-
exports.COLLECTOR_VERSION = "0.1.
|
|
968
|
+
exports.COLLECTOR_VERSION = "0.1.34" ? "0.1.34" : exports.UNRELEASED_COLLECTOR_VERSION;
|
|
957
969
|
function describeCollectorVersion(version2 = exports.COLLECTOR_VERSION) {
|
|
958
970
|
return version2 === exports.UNRELEASED_COLLECTOR_VERSION ? `${version2} (built from a checkout, not a release)` : version2;
|
|
959
971
|
}
|
|
@@ -1055,6 +1067,12 @@ var require_http = __commonJS({
|
|
|
1055
1067
|
exports.AscendaApiError = void 0;
|
|
1056
1068
|
exports.createPairingSession = createPairingSession;
|
|
1057
1069
|
exports.getPairingStatus = getPairingStatus;
|
|
1070
|
+
exports.startStudyJoin = startStudyJoin;
|
|
1071
|
+
exports.getStudyJoinStatus = getStudyJoinStatus;
|
|
1072
|
+
exports.readInitiatives = readInitiatives;
|
|
1073
|
+
exports.readStudyNotices = readStudyNotices;
|
|
1074
|
+
exports.setStudyObjection = setStudyObjection;
|
|
1075
|
+
exports.markStudyNoticeShown = markStudyNoticeShown;
|
|
1058
1076
|
exports.renewToolToken = renewToolToken;
|
|
1059
1077
|
exports.isRetryableStatus = isRetryableStatus;
|
|
1060
1078
|
exports.postToolEvent = postToolEvent;
|
|
@@ -1091,6 +1109,108 @@ var require_http = __commonJS({
|
|
|
1091
1109
|
throw new AscendaApiError(response.status, void 0, await response.text());
|
|
1092
1110
|
return await response.json();
|
|
1093
1111
|
}
|
|
1112
|
+
async function startStudyJoin(apiBaseUrl, eventWriteToken, joinCode, mode) {
|
|
1113
|
+
const response = await fetch(`${apiBaseUrl}/v1/org-study-join-sessions`, {
|
|
1114
|
+
method: "POST",
|
|
1115
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${eventWriteToken}` },
|
|
1116
|
+
body: JSON.stringify({ joinCode, mode })
|
|
1117
|
+
});
|
|
1118
|
+
if (!response.ok)
|
|
1119
|
+
throw await apiError(response);
|
|
1120
|
+
return await response.json();
|
|
1121
|
+
}
|
|
1122
|
+
async function getStudyJoinStatus(apiBaseUrl, eventWriteToken, joinSessionId) {
|
|
1123
|
+
const response = await fetch(`${apiBaseUrl}/v1/org-study-join-sessions/${encodeURIComponent(joinSessionId)}/status`, {
|
|
1124
|
+
method: "GET",
|
|
1125
|
+
headers: { Accept: "application/json", Authorization: `Bearer ${eventWriteToken}` }
|
|
1126
|
+
});
|
|
1127
|
+
if (!response.ok)
|
|
1128
|
+
throw await apiError(response);
|
|
1129
|
+
return await response.json();
|
|
1130
|
+
}
|
|
1131
|
+
async function readInitiatives(apiBaseUrl, eventWriteToken, signal) {
|
|
1132
|
+
let response;
|
|
1133
|
+
try {
|
|
1134
|
+
response = await fetch(`${apiBaseUrl}/v1/tool-installations/initiatives`, {
|
|
1135
|
+
method: "GET",
|
|
1136
|
+
headers: { Accept: "application/json", Authorization: `Bearer ${eventWriteToken}` },
|
|
1137
|
+
signal
|
|
1138
|
+
});
|
|
1139
|
+
} catch (error2) {
|
|
1140
|
+
return { kind: "failed", reason: error2 instanceof Error && error2.name === "TimeoutError" ? "the request timed out" : "the server could not be reached" };
|
|
1141
|
+
}
|
|
1142
|
+
if (response.status === 401)
|
|
1143
|
+
return { kind: "rejected", httpStatus: 401 };
|
|
1144
|
+
if (!response.ok)
|
|
1145
|
+
return { kind: "failed", reason: `the server answered HTTP ${response.status}` };
|
|
1146
|
+
let body;
|
|
1147
|
+
try {
|
|
1148
|
+
body = await response.json();
|
|
1149
|
+
} catch {
|
|
1150
|
+
return { kind: "failed", reason: "the reply was not readable" };
|
|
1151
|
+
}
|
|
1152
|
+
if (!Array.isArray(body))
|
|
1153
|
+
return { kind: "failed", reason: "the reply was not a list" };
|
|
1154
|
+
return { kind: "ok", initiatives: body };
|
|
1155
|
+
}
|
|
1156
|
+
async function readStudyNotices(apiBaseUrl, eventWriteToken, signal) {
|
|
1157
|
+
let response;
|
|
1158
|
+
try {
|
|
1159
|
+
response = await fetch(`${apiBaseUrl}/v1/tool-installations/study-notices`, {
|
|
1160
|
+
method: "GET",
|
|
1161
|
+
headers: { Accept: "application/json", Authorization: `Bearer ${eventWriteToken}` },
|
|
1162
|
+
signal
|
|
1163
|
+
});
|
|
1164
|
+
} catch (error2) {
|
|
1165
|
+
return { kind: "failed", reason: error2 instanceof Error && error2.name === "TimeoutError" ? "the request timed out" : "the server could not be reached" };
|
|
1166
|
+
}
|
|
1167
|
+
if (response.status === 404)
|
|
1168
|
+
return { kind: "absent" };
|
|
1169
|
+
if (response.status === 401)
|
|
1170
|
+
return { kind: "rejected", httpStatus: 401 };
|
|
1171
|
+
if (!response.ok)
|
|
1172
|
+
return { kind: "failed", reason: `the server answered HTTP ${response.status}` };
|
|
1173
|
+
let body;
|
|
1174
|
+
try {
|
|
1175
|
+
body = await response.json();
|
|
1176
|
+
} catch {
|
|
1177
|
+
return { kind: "absent" };
|
|
1178
|
+
}
|
|
1179
|
+
if (!Array.isArray(body))
|
|
1180
|
+
return { kind: "absent" };
|
|
1181
|
+
return { kind: "ok", notices: body };
|
|
1182
|
+
}
|
|
1183
|
+
async function setStudyObjection(apiBaseUrl, eventWriteToken, code, objected) {
|
|
1184
|
+
const response = await fetch(`${apiBaseUrl}/v1/tool-installations/study-notices/${encodeURIComponent(String(code))}/objection`, {
|
|
1185
|
+
method: objected ? "POST" : "DELETE",
|
|
1186
|
+
headers: { Authorization: `Bearer ${eventWriteToken}` }
|
|
1187
|
+
});
|
|
1188
|
+
if (!response.ok)
|
|
1189
|
+
throw await apiError(response);
|
|
1190
|
+
}
|
|
1191
|
+
async function markStudyNoticeShown(apiBaseUrl, eventWriteToken, organisationId, code, signal) {
|
|
1192
|
+
try {
|
|
1193
|
+
const response = await fetch(`${apiBaseUrl}/v1/tool-installations/study-notices/${encodeURIComponent(organisationId)}/${encodeURIComponent(String(code))}/shown`, {
|
|
1194
|
+
method: "POST",
|
|
1195
|
+
headers: { Authorization: `Bearer ${eventWriteToken}` },
|
|
1196
|
+
signal
|
|
1197
|
+
});
|
|
1198
|
+
return response.ok;
|
|
1199
|
+
} catch {
|
|
1200
|
+
return false;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
async function apiError(response) {
|
|
1204
|
+
const body = await response.text();
|
|
1205
|
+
let errorCode;
|
|
1206
|
+
try {
|
|
1207
|
+
const parsed = JSON.parse(body);
|
|
1208
|
+
errorCode = parsed.code ?? parsed.error;
|
|
1209
|
+
} catch {
|
|
1210
|
+
errorCode = void 0;
|
|
1211
|
+
}
|
|
1212
|
+
return new AscendaApiError(response.status, errorCode, body);
|
|
1213
|
+
}
|
|
1094
1214
|
async function renewToolToken(apiBaseUrl, eventWriteToken, signal) {
|
|
1095
1215
|
const response = await fetch(`${apiBaseUrl}/v1/tool-events/renew-token`, {
|
|
1096
1216
|
method: "POST",
|
|
@@ -1233,9 +1353,12 @@ var require_tokenStore = __commonJS({
|
|
|
1233
1353
|
};
|
|
1234
1354
|
}();
|
|
1235
1355
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1356
|
+
exports.EVENT_TOKEN_TTL_MS = void 0;
|
|
1236
1357
|
exports.ascendaHome = ascendaHome;
|
|
1237
1358
|
exports.defaultTokenFilePath = defaultTokenFilePath2;
|
|
1359
|
+
exports.tokenExpiryFilePath = tokenExpiryFilePath;
|
|
1238
1360
|
exports.persistEventWriteToken = persistEventWriteToken2;
|
|
1361
|
+
exports.readTokenExpiry = readTokenExpiry;
|
|
1239
1362
|
exports.listPersistedToolInstallationIds = listPersistedToolInstallationIds;
|
|
1240
1363
|
exports.readTokenFile = readTokenFile2;
|
|
1241
1364
|
exports.sanitizeFilePart = sanitizeFilePart;
|
|
@@ -1248,7 +1371,10 @@ var require_tokenStore = __commonJS({
|
|
|
1248
1371
|
function defaultTokenFilePath2(toolInstallationId) {
|
|
1249
1372
|
return path.join(ascendaHome(), "tokens", sanitizeFilePart(toolInstallationId));
|
|
1250
1373
|
}
|
|
1251
|
-
function
|
|
1374
|
+
function tokenExpiryFilePath(tokenFilePath) {
|
|
1375
|
+
return path.join(path.dirname(tokenFilePath), "expiry", path.basename(tokenFilePath));
|
|
1376
|
+
}
|
|
1377
|
+
function persistEventWriteToken2(tokenFilePath, token, expiresAt) {
|
|
1252
1378
|
const dir = path.dirname(tokenFilePath);
|
|
1253
1379
|
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
1254
1380
|
fs.writeFileSync(tokenFilePath, token, { encoding: "utf8", mode: 384 });
|
|
@@ -1256,6 +1382,30 @@ var require_tokenStore = __commonJS({
|
|
|
1256
1382
|
fs.chmodSync(dir, 448);
|
|
1257
1383
|
fs.chmodSync(tokenFilePath, 384);
|
|
1258
1384
|
}
|
|
1385
|
+
const expiryFile = tokenExpiryFilePath(tokenFilePath);
|
|
1386
|
+
try {
|
|
1387
|
+
if (expiresAt && Number.isFinite(Date.parse(expiresAt))) {
|
|
1388
|
+
fs.mkdirSync(path.dirname(expiryFile), { recursive: true, mode: 448 });
|
|
1389
|
+
fs.writeFileSync(expiryFile, expiresAt, { encoding: "utf8", mode: 384 });
|
|
1390
|
+
} else {
|
|
1391
|
+
fs.rmSync(expiryFile, { force: true });
|
|
1392
|
+
}
|
|
1393
|
+
} catch {
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
exports.EVENT_TOKEN_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
1397
|
+
function readTokenExpiry(tokenFilePath) {
|
|
1398
|
+
try {
|
|
1399
|
+
const recorded = Date.parse(fs.readFileSync(tokenExpiryFilePath(tokenFilePath), "utf8").trim());
|
|
1400
|
+
if (Number.isFinite(recorded))
|
|
1401
|
+
return recorded;
|
|
1402
|
+
} catch {
|
|
1403
|
+
}
|
|
1404
|
+
try {
|
|
1405
|
+
return fs.statSync(tokenFilePath).mtimeMs + exports.EVENT_TOKEN_TTL_MS;
|
|
1406
|
+
} catch {
|
|
1407
|
+
return void 0;
|
|
1408
|
+
}
|
|
1259
1409
|
}
|
|
1260
1410
|
function listPersistedToolInstallationIds(toolType) {
|
|
1261
1411
|
const prefix = `${sanitizeFilePart(toolType)}_`;
|
|
@@ -1702,7 +1852,7 @@ var require_eventSender = __commonJS({
|
|
|
1702
1852
|
"../packages/tool-kit/out/eventSender.js"(exports) {
|
|
1703
1853
|
"use strict";
|
|
1704
1854
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1705
|
-
exports.AscendaEventSender = exports.AscendaSemanticEventError = void 0;
|
|
1855
|
+
exports.AscendaEventSender = exports.TOKEN_RENEW_LEAD_MS = exports.AscendaSemanticEventError = void 0;
|
|
1706
1856
|
exports.buildEventPayload = buildEventPayload;
|
|
1707
1857
|
var afterHours_1 = require_afterHours();
|
|
1708
1858
|
var tool_contract_1 = require_out();
|
|
@@ -1743,6 +1893,7 @@ var require_eventSender = __commonJS({
|
|
|
1743
1893
|
}
|
|
1744
1894
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
1745
1895
|
var RETRY_DELAY_MS = 250;
|
|
1896
|
+
exports.TOKEN_RENEW_LEAD_MS = 21 * 24 * 60 * 60 * 1e3;
|
|
1746
1897
|
var AscendaEventSender2 = class {
|
|
1747
1898
|
config;
|
|
1748
1899
|
eventWriteToken;
|
|
@@ -1750,6 +1901,8 @@ var require_eventSender = __commonJS({
|
|
|
1750
1901
|
lastDrain;
|
|
1751
1902
|
/** One outbox pass per sender, i.e. per hook process. The hook is on the user's critical path. */
|
|
1752
1903
|
outboxServiced = false;
|
|
1904
|
+
/** One look at the token's expiry per sender, for the same reason. */
|
|
1905
|
+
expiryChecked = false;
|
|
1753
1906
|
/** Resolved once, so every clock read in one pass sees the same instant. */
|
|
1754
1907
|
time;
|
|
1755
1908
|
constructor(config2) {
|
|
@@ -1873,6 +2026,7 @@ var require_eventSender = __commonJS({
|
|
|
1873
2026
|
* hook during an outage to one bounded round trip instead of three.
|
|
1874
2027
|
*/
|
|
1875
2028
|
async post(payload) {
|
|
2029
|
+
await this.renewIfExpiring();
|
|
1876
2030
|
const halted = await this.serviceOutbox();
|
|
1877
2031
|
let outcome;
|
|
1878
2032
|
let queued = false;
|
|
@@ -2078,21 +2232,49 @@ var require_eventSender = __commonJS({
|
|
|
2078
2232
|
return;
|
|
2079
2233
|
(0, eventLog_1.appendEventLog)(logFile, { loggedAt: (/* @__PURE__ */ new Date()).toISOString(), delivery, payload, ...outbox ? { outbox } : {} });
|
|
2080
2234
|
}
|
|
2081
|
-
/**
|
|
2235
|
+
/**
|
|
2236
|
+
* Renews ahead of expiry, at most once per sender. Waiting for the 401
|
|
2237
|
+
* doesn't work: by then the token has expired, and the server won't renew
|
|
2238
|
+
* an expired token.
|
|
2239
|
+
*/
|
|
2240
|
+
async renewIfExpiring() {
|
|
2241
|
+
if (this.expiryChecked || this.config.renewToken === false)
|
|
2242
|
+
return;
|
|
2243
|
+
this.expiryChecked = true;
|
|
2244
|
+
const expiresAt = (0, tokenStore_1.readTokenExpiry)(this.config.tokenFilePath);
|
|
2245
|
+
if (expiresAt === void 0 || this.time.now() < expiresAt - exports.TOKEN_RENEW_LEAD_MS)
|
|
2246
|
+
return;
|
|
2247
|
+
await this.renewEventToken();
|
|
2248
|
+
}
|
|
2249
|
+
/**
|
|
2250
|
+
* Never throws: a renewal that errors is a failed renewal, not a failed turn.
|
|
2251
|
+
*
|
|
2252
|
+
* A refused renewal usually means another process got there first. Hooks
|
|
2253
|
+
* and the MCP server share one token file, and renewing revokes the token
|
|
2254
|
+
* it replaces, so the loser holds a revoked token while the winner's
|
|
2255
|
+
* replacement is already on disk. Adopting that counts as a renewal.
|
|
2256
|
+
*/
|
|
2082
2257
|
async renewEventToken() {
|
|
2083
2258
|
if (this.config.renewToken === false)
|
|
2084
2259
|
return false;
|
|
2085
2260
|
try {
|
|
2086
2261
|
const renewed = await (0, http_1.renewToolToken)(this.config.apiBaseUrl, this.eventWriteToken, this.signal());
|
|
2087
2262
|
if (!renewed)
|
|
2088
|
-
return
|
|
2263
|
+
return this.adoptPersistedToken();
|
|
2089
2264
|
this.eventWriteToken = renewed.eventWriteToken;
|
|
2090
|
-
(0, tokenStore_1.persistEventWriteToken)(this.config.tokenFilePath, renewed.eventWriteToken);
|
|
2265
|
+
(0, tokenStore_1.persistEventWriteToken)(this.config.tokenFilePath, renewed.eventWriteToken, renewed.expiresAt);
|
|
2091
2266
|
return true;
|
|
2092
2267
|
} catch {
|
|
2093
2268
|
return false;
|
|
2094
2269
|
}
|
|
2095
2270
|
}
|
|
2271
|
+
adoptPersistedToken() {
|
|
2272
|
+
const persisted = (0, tokenStore_1.readTokenFile)(this.config.tokenFilePath);
|
|
2273
|
+
if (!persisted || persisted === this.eventWriteToken)
|
|
2274
|
+
return false;
|
|
2275
|
+
this.eventWriteToken = persisted;
|
|
2276
|
+
return true;
|
|
2277
|
+
}
|
|
2096
2278
|
signal() {
|
|
2097
2279
|
return AbortSignal.timeout(this.config.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
2098
2280
|
}
|
|
@@ -2975,6 +3157,477 @@ var require_hookAdapter = __commonJS({
|
|
|
2975
3157
|
}
|
|
2976
3158
|
});
|
|
2977
3159
|
|
|
3160
|
+
// ../packages/tool-kit/out/hookSet.js
|
|
3161
|
+
var require_hookSet = __commonJS({
|
|
3162
|
+
"../packages/tool-kit/out/hookSet.js"(exports) {
|
|
3163
|
+
"use strict";
|
|
3164
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3165
|
+
exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = void 0;
|
|
3166
|
+
exports.hookSetArgument = hookSetArgument;
|
|
3167
|
+
exports.readHookSet = readHookSet;
|
|
3168
|
+
exports.isHookSet = isHookSet;
|
|
3169
|
+
exports.readViaPlugin = readViaPlugin;
|
|
3170
|
+
exports.hookSetOfCommand = hookSetOfCommand;
|
|
3171
|
+
exports.hookSetChanges = hookSetChanges;
|
|
3172
|
+
exports.describeHookSetChanges = describeHookSetChanges;
|
|
3173
|
+
exports.HOOK_SET_FLAG = "--hook-set";
|
|
3174
|
+
exports.UNVERSIONED_HOOK_SET = 1;
|
|
3175
|
+
function hookSetArgument(hookSet) {
|
|
3176
|
+
return hookSet === void 0 ? "" : ` ${exports.HOOK_SET_FLAG} ${hookSet}`;
|
|
3177
|
+
}
|
|
3178
|
+
function readHookSet(argv) {
|
|
3179
|
+
const index = argv.indexOf(exports.HOOK_SET_FLAG);
|
|
3180
|
+
if (index === -1)
|
|
3181
|
+
return void 0;
|
|
3182
|
+
const raw = argv[index + 1];
|
|
3183
|
+
if (raw === void 0 || !/^[1-9]\d*$/.test(raw))
|
|
3184
|
+
return void 0;
|
|
3185
|
+
const value = Number(raw);
|
|
3186
|
+
return isHookSet(value) ? value : void 0;
|
|
3187
|
+
}
|
|
3188
|
+
function isHookSet(value) {
|
|
3189
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
|
|
3190
|
+
}
|
|
3191
|
+
function readViaPlugin(env) {
|
|
3192
|
+
return env.CLAUDE_PLUGIN_ROOT ? true : void 0;
|
|
3193
|
+
}
|
|
3194
|
+
function hookSetOfCommand(command) {
|
|
3195
|
+
const match = command.match(/--hook-set\s+(\d+)/);
|
|
3196
|
+
return match ? Number(match[1]) : exports.UNVERSIONED_HOOK_SET;
|
|
3197
|
+
}
|
|
3198
|
+
function hookSetChanges(before, events) {
|
|
3199
|
+
const added = events.filter((event) => !before.has(event));
|
|
3200
|
+
const sets = [...before.values()];
|
|
3201
|
+
return sets.length ? { added, previousSet: Math.min(...sets) } : { added };
|
|
3202
|
+
}
|
|
3203
|
+
function describeHookSetChanges(changes, hookSet) {
|
|
3204
|
+
if (changes.previousSet === void 0)
|
|
3205
|
+
return void 0;
|
|
3206
|
+
const parts = [];
|
|
3207
|
+
if (changes.added.length)
|
|
3208
|
+
parts.push(`added ${changes.added.join(", ")}`);
|
|
3209
|
+
if (changes.previousSet < hookSet)
|
|
3210
|
+
parts.push(`hook set ${changes.previousSet} \u2192 ${hookSet}`);
|
|
3211
|
+
return parts.length ? `upgraded: ${parts.join("; ")}` : void 0;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
});
|
|
3215
|
+
|
|
3216
|
+
// ../packages/tool-kit/out/studyJoin.js
|
|
3217
|
+
var require_studyJoin = __commonJS({
|
|
3218
|
+
"../packages/tool-kit/out/studyJoin.js"(exports) {
|
|
3219
|
+
"use strict";
|
|
3220
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3221
|
+
if (k2 === void 0) k2 = k;
|
|
3222
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3223
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3224
|
+
desc = { enumerable: true, get: function() {
|
|
3225
|
+
return m[k];
|
|
3226
|
+
} };
|
|
3227
|
+
}
|
|
3228
|
+
Object.defineProperty(o, k2, desc);
|
|
3229
|
+
} : function(o, m, k, k2) {
|
|
3230
|
+
if (k2 === void 0) k2 = k;
|
|
3231
|
+
o[k2] = m[k];
|
|
3232
|
+
});
|
|
3233
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
3234
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
3235
|
+
} : function(o, v) {
|
|
3236
|
+
o["default"] = v;
|
|
3237
|
+
});
|
|
3238
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
3239
|
+
var ownKeys = function(o) {
|
|
3240
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
3241
|
+
var ar = [];
|
|
3242
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
3243
|
+
return ar;
|
|
3244
|
+
};
|
|
3245
|
+
return ownKeys(o);
|
|
3246
|
+
};
|
|
3247
|
+
return function(mod) {
|
|
3248
|
+
if (mod && mod.__esModule) return mod;
|
|
3249
|
+
var result = {};
|
|
3250
|
+
if (mod != null) {
|
|
3251
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
3252
|
+
}
|
|
3253
|
+
__setModuleDefault(result, mod);
|
|
3254
|
+
return result;
|
|
3255
|
+
};
|
|
3256
|
+
}();
|
|
3257
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3258
|
+
exports.runStudyJoin = runStudyJoin;
|
|
3259
|
+
exports.formatWindow = formatWindow;
|
|
3260
|
+
var readline = __importStar(__require("node:readline"));
|
|
3261
|
+
var http_1 = require_http();
|
|
3262
|
+
var STUDY_JOIN_MODE = "report";
|
|
3263
|
+
var POLL_INTERVAL_MS = 3e3;
|
|
3264
|
+
var POLL_TIMEOUT_MS = 11 * 60 * 1e3;
|
|
3265
|
+
async function runStudyJoin(ctx) {
|
|
3266
|
+
const stdin = ctx.stdin ?? process.stdin;
|
|
3267
|
+
const stdout = ctx.stdout ?? process.stdout;
|
|
3268
|
+
const stderr = ctx.stderr ?? process.stderr;
|
|
3269
|
+
const print = (line) => stdout.write(`${line}
|
|
3270
|
+
`);
|
|
3271
|
+
if (!stdin.isTTY || !stdout.isTTY) {
|
|
3272
|
+
stderr.write("join needs an interactive terminal (stdin and stdout). Run it directly, not from a script or a pipe.\n");
|
|
3273
|
+
return 0;
|
|
3274
|
+
}
|
|
3275
|
+
if (!ctx.joinCode) {
|
|
3276
|
+
stderr.write("Usage: join <code>\n");
|
|
3277
|
+
return 1;
|
|
3278
|
+
}
|
|
3279
|
+
let start;
|
|
3280
|
+
try {
|
|
3281
|
+
start = await (0, http_1.startStudyJoin)(ctx.apiBaseUrl, ctx.eventWriteToken, ctx.joinCode, STUDY_JOIN_MODE);
|
|
3282
|
+
} catch (error2) {
|
|
3283
|
+
stderr.write(`${describeStartError(error2)}
|
|
3284
|
+
`);
|
|
3285
|
+
return 1;
|
|
3286
|
+
}
|
|
3287
|
+
print("");
|
|
3288
|
+
print(`${start.organisationName}: ${describeStudyKind(start.studyKind)}`);
|
|
3289
|
+
print(formatWindow(start.windowStartUtc, start.windowEndUtc));
|
|
3290
|
+
print("");
|
|
3291
|
+
print("Report (30 days) grants:");
|
|
3292
|
+
for (const grant of start.grants)
|
|
3293
|
+
print(` ${describeGrant(grant)}`);
|
|
3294
|
+
print("");
|
|
3295
|
+
print("Study mode needs the Ascenda app. Open the app to join that way instead.");
|
|
3296
|
+
print("");
|
|
3297
|
+
print("Join in:");
|
|
3298
|
+
print(" 1) Report (30 days)");
|
|
3299
|
+
print(" 2) Not now");
|
|
3300
|
+
print("");
|
|
3301
|
+
const answer = await askChoice(stdin, stdout);
|
|
3302
|
+
if (!/^(1|report)$/i.test(answer)) {
|
|
3303
|
+
print("Not now.");
|
|
3304
|
+
return 0;
|
|
3305
|
+
}
|
|
3306
|
+
print("");
|
|
3307
|
+
print(`Confirm in the Ascenda app with code ${start.deviceCode}`);
|
|
3308
|
+
print(`Waiting for confirmation (expires ${formatLocalTime(start.expiresAt)})...`);
|
|
3309
|
+
const pollIntervalMs = ctx.pollIntervalMs ?? POLL_INTERVAL_MS;
|
|
3310
|
+
const deadline = Math.min(Date.parse(start.expiresAt) || Date.now() + POLL_TIMEOUT_MS, Date.now() + POLL_TIMEOUT_MS);
|
|
3311
|
+
while (Date.now() < deadline) {
|
|
3312
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
3313
|
+
let poll;
|
|
3314
|
+
try {
|
|
3315
|
+
poll = await (0, http_1.getStudyJoinStatus)(ctx.apiBaseUrl, ctx.eventWriteToken, start.joinSessionId);
|
|
3316
|
+
} catch (error2) {
|
|
3317
|
+
if (isRetryablePollError(error2))
|
|
3318
|
+
continue;
|
|
3319
|
+
stderr.write(`${describeStartError(error2)}
|
|
3320
|
+
`);
|
|
3321
|
+
return 1;
|
|
3322
|
+
}
|
|
3323
|
+
if (poll.status === "pending")
|
|
3324
|
+
continue;
|
|
3325
|
+
if (poll.status === "confirmed") {
|
|
3326
|
+
const granted = poll.granted ?? [];
|
|
3327
|
+
if (granted.length === 0) {
|
|
3328
|
+
print("");
|
|
3329
|
+
print("Nothing was granted. Run join again, or check with your organisation.");
|
|
3330
|
+
return 1;
|
|
3331
|
+
}
|
|
3332
|
+
print("");
|
|
3333
|
+
print("Joined. Granted:");
|
|
3334
|
+
for (const grant of granted)
|
|
3335
|
+
print(` ${describeGrant(grant)}`);
|
|
3336
|
+
print("");
|
|
3337
|
+
print("Each of these can be turned off separately, in the app's consent settings.");
|
|
3338
|
+
print("The organisation sees group counts, never who joined.");
|
|
3339
|
+
return 0;
|
|
3340
|
+
}
|
|
3341
|
+
if (poll.status === "expired") {
|
|
3342
|
+
print("");
|
|
3343
|
+
print("This code expired before it was confirmed. Run join again for a fresh code.");
|
|
3344
|
+
return 1;
|
|
3345
|
+
}
|
|
3346
|
+
if (poll.refusedReason === "grant_failed") {
|
|
3347
|
+
print("");
|
|
3348
|
+
print("Join failed partway through. Some grants may not have gone through.");
|
|
3349
|
+
const granted = poll.granted ?? [];
|
|
3350
|
+
if (granted.length > 0) {
|
|
3351
|
+
print("");
|
|
3352
|
+
print("Granted before the failure:");
|
|
3353
|
+
for (const grant of granted)
|
|
3354
|
+
print(` ${describeGrant(grant)}`);
|
|
3355
|
+
print("");
|
|
3356
|
+
print("Each of these can be turned off separately, in the app's consent settings.");
|
|
3357
|
+
}
|
|
3358
|
+
print("Run join again, or check with your organisation.");
|
|
3359
|
+
return 1;
|
|
3360
|
+
}
|
|
3361
|
+
print("");
|
|
3362
|
+
print(describeRefusal(poll.refusedReason));
|
|
3363
|
+
return 1;
|
|
3364
|
+
}
|
|
3365
|
+
print("");
|
|
3366
|
+
print("Timed out waiting for confirmation. Run join again for a fresh code.");
|
|
3367
|
+
return 1;
|
|
3368
|
+
}
|
|
3369
|
+
function isRetryablePollError(error2) {
|
|
3370
|
+
if (error2 instanceof http_1.AscendaApiError)
|
|
3371
|
+
return error2.status >= 500 && error2.status <= 599;
|
|
3372
|
+
return true;
|
|
3373
|
+
}
|
|
3374
|
+
function askChoice(stdin, stdout) {
|
|
3375
|
+
return new Promise((resolve) => {
|
|
3376
|
+
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
3377
|
+
let settled = false;
|
|
3378
|
+
const finish = (value) => {
|
|
3379
|
+
if (settled)
|
|
3380
|
+
return;
|
|
3381
|
+
settled = true;
|
|
3382
|
+
rl.close();
|
|
3383
|
+
resolve(value.trim());
|
|
3384
|
+
};
|
|
3385
|
+
rl.question("Choice [Not now]: ", finish);
|
|
3386
|
+
rl.once("close", () => finish(""));
|
|
3387
|
+
});
|
|
3388
|
+
}
|
|
3389
|
+
function formatLocalTime(iso) {
|
|
3390
|
+
const date3 = new Date(iso);
|
|
3391
|
+
if (Number.isNaN(date3.getTime()))
|
|
3392
|
+
return iso;
|
|
3393
|
+
return new Intl.DateTimeFormat(void 0, { day: "numeric", month: "short", hour: "numeric", minute: "2-digit" }).format(date3);
|
|
3394
|
+
}
|
|
3395
|
+
function formatWindow(startUtc, endUtc) {
|
|
3396
|
+
const start = new Date(startUtc);
|
|
3397
|
+
const end = new Date(endUtc);
|
|
3398
|
+
const sameYear = start.getUTCFullYear() === end.getUTCFullYear();
|
|
3399
|
+
const dayMonth = { day: "numeric", month: "short", timeZone: "UTC" };
|
|
3400
|
+
const withYear = { ...dayMonth, year: "numeric" };
|
|
3401
|
+
const startFmt = new Intl.DateTimeFormat("en-GB", sameYear ? dayMonth : withYear);
|
|
3402
|
+
const endFmt = new Intl.DateTimeFormat("en-GB", withYear);
|
|
3403
|
+
return `${startFmt.format(start)} \u2013 ${endFmt.format(end)}`;
|
|
3404
|
+
}
|
|
3405
|
+
var GRANT_SENTENCES = {
|
|
3406
|
+
501: "AI assistant data processing consent",
|
|
3407
|
+
507: "Import of the AI-work history already on your machine"
|
|
3408
|
+
};
|
|
3409
|
+
function describeGrant(grant) {
|
|
3410
|
+
return GRANT_SENTENCES[grant.code] ?? humanise(grant.name);
|
|
3411
|
+
}
|
|
3412
|
+
var STUDY_KIND_SENTENCES = {
|
|
3413
|
+
Report30: "a 30-day report",
|
|
3414
|
+
Study90: "a 90-day study"
|
|
3415
|
+
};
|
|
3416
|
+
function describeStudyKind(studyKind) {
|
|
3417
|
+
return STUDY_KIND_SENTENCES[studyKind] ?? humanise(studyKind);
|
|
3418
|
+
}
|
|
3419
|
+
function humanise(name) {
|
|
3420
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim() || name;
|
|
3421
|
+
}
|
|
3422
|
+
var REFUSED_REASON_MESSAGES = {
|
|
3423
|
+
study_no_longer_live: "That study is no longer open to join.",
|
|
3424
|
+
withdrawn: "You're no longer an active participant in that study.",
|
|
3425
|
+
// Handled as its own branch above, with its granted list, before this
|
|
3426
|
+
// table is ever consulted — present so the type stays exhaustive, and as
|
|
3427
|
+
// a plain fallback should something call this function with it directly.
|
|
3428
|
+
grant_failed: "Join failed partway through. Some grants may not have gone through.",
|
|
3429
|
+
declined: "You declined in the app. Nothing was granted.",
|
|
3430
|
+
not_enrolled: "That study couldn't enrol you, so nothing was granted."
|
|
3431
|
+
};
|
|
3432
|
+
function describeRefusal(refusedReason) {
|
|
3433
|
+
if (refusedReason && REFUSED_REASON_MESSAGES[refusedReason])
|
|
3434
|
+
return REFUSED_REASON_MESSAGES[refusedReason];
|
|
3435
|
+
return "The join didn't go through. Nothing new was granted.";
|
|
3436
|
+
}
|
|
3437
|
+
var START_ERROR_MESSAGES = {
|
|
3438
|
+
join_code_not_found: "That code is not a study anyone can join. Check it and try again.",
|
|
3439
|
+
unknown_mode: "This tool only offers Report mode from the command line.",
|
|
3440
|
+
no_live_study: "There's nothing open to join with that code right now.",
|
|
3441
|
+
too_many_open_sessions: "This tool has too many joins waiting to be confirmed. Confirm one, or let one expire, then try again.",
|
|
3442
|
+
unknown_session: "That join can no longer be found. Run join again for a fresh code."
|
|
3443
|
+
};
|
|
3444
|
+
function describeStartError(error2) {
|
|
3445
|
+
if (error2 instanceof http_1.AscendaApiError) {
|
|
3446
|
+
if (error2.errorCode && START_ERROR_MESSAGES[error2.errorCode])
|
|
3447
|
+
return START_ERROR_MESSAGES[error2.errorCode];
|
|
3448
|
+
if (error2.status === 401)
|
|
3449
|
+
return "This tool's pairing was rejected. Re-pair it, then try again.";
|
|
3450
|
+
return `Could not reach the join code (HTTP ${error2.status}).`;
|
|
3451
|
+
}
|
|
3452
|
+
return error2 instanceof Error ? error2.message : String(error2);
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
3455
|
+
});
|
|
3456
|
+
|
|
3457
|
+
// ../packages/tool-kit/out/initiatives.js
|
|
3458
|
+
var require_initiatives = __commonJS({
|
|
3459
|
+
"../packages/tool-kit/out/initiatives.js"(exports) {
|
|
3460
|
+
"use strict";
|
|
3461
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3462
|
+
exports.INITIATIVE_COPY = void 0;
|
|
3463
|
+
exports.initiativesStatusLines = initiativesStatusLines;
|
|
3464
|
+
exports.renderInitiatives = renderInitiatives;
|
|
3465
|
+
var http_1 = require_http();
|
|
3466
|
+
var studyJoin_1 = require_studyJoin();
|
|
3467
|
+
var READ_TIMEOUT_MS = 5e3;
|
|
3468
|
+
exports.INITIATIVE_COPY = {
|
|
3469
|
+
outcomes: {
|
|
3470
|
+
moved_as_declared: "Moved the way declared, beyond the cohort's own variation",
|
|
3471
|
+
moved_against_declared: "Moved the other way, beyond the cohort's own variation",
|
|
3472
|
+
moved_no_direction_declared: "Moved beyond the cohort's own variation; no direction was declared",
|
|
3473
|
+
within_own_variation: "No further from the baseline than the cohort's own week-to-week variation",
|
|
3474
|
+
withheld: "Withheld"
|
|
3475
|
+
},
|
|
3476
|
+
withheldReasons: {
|
|
3477
|
+
cohort_below_minimum: "the cohort was too small to report on when the scoring window closed",
|
|
3478
|
+
below_minimum_cohort: "the cohort was too small to report on when the scoring window closed",
|
|
3479
|
+
below_minimum_cohort_size: "the cohort was too small to report on when the scoring window closed",
|
|
3480
|
+
baseline_withheld: "the baseline was withheld"
|
|
3481
|
+
}
|
|
3482
|
+
};
|
|
3483
|
+
var OUTCOME_EMPTY = "Not stated";
|
|
3484
|
+
var OUTCOME_UNKNOWN = "An outcome this app does not recognise";
|
|
3485
|
+
var WITHHELD_UNKNOWN = "Withheld, for a reason this version of the app doesn't name yet.";
|
|
3486
|
+
var DIRECTION_WORDS = {
|
|
3487
|
+
up: "Expected to rise",
|
|
3488
|
+
down: "Expected to fall",
|
|
3489
|
+
none_declared: "No direction declared"
|
|
3490
|
+
};
|
|
3491
|
+
var DIRECTION_UNKNOWN = "A direction this app does not recognise";
|
|
3492
|
+
async function initiativesStatusLines(ctx) {
|
|
3493
|
+
const heading = "Changes your organisation has published to you";
|
|
3494
|
+
if (!ctx.eventWriteToken) {
|
|
3495
|
+
return [heading, " Not checked: this install holds no token, so nothing was fetched."];
|
|
3496
|
+
}
|
|
3497
|
+
const read = await (0, http_1.readInitiatives)(ctx.apiBaseUrl, ctx.eventWriteToken, AbortSignal.timeout(ctx.fetchTimeoutMs ?? READ_TIMEOUT_MS));
|
|
3498
|
+
if (read.kind === "rejected") {
|
|
3499
|
+
return [
|
|
3500
|
+
heading,
|
|
3501
|
+
` Couldn't check: the server turned this install's request down. If that keeps happening, pair again with \`${ctx.pairCommand}\`.`
|
|
3502
|
+
];
|
|
3503
|
+
}
|
|
3504
|
+
if (read.kind === "failed") {
|
|
3505
|
+
return [heading, ` Couldn't check: ${read.reason}. Run status again to retry.`];
|
|
3506
|
+
}
|
|
3507
|
+
return [heading, ...renderInitiatives(read.initiatives)];
|
|
3508
|
+
}
|
|
3509
|
+
function renderInitiatives(entries, copy = exports.INITIATIVE_COPY) {
|
|
3510
|
+
if (entries.length === 0)
|
|
3511
|
+
return [" None published to you."];
|
|
3512
|
+
const lines = [];
|
|
3513
|
+
let unreadable = 0;
|
|
3514
|
+
for (const entry of entries) {
|
|
3515
|
+
const initiative = asInitiative(entry);
|
|
3516
|
+
if (!initiative) {
|
|
3517
|
+
unreadable += 1;
|
|
3518
|
+
continue;
|
|
3519
|
+
}
|
|
3520
|
+
lines.push(...renderOne(initiative, copy));
|
|
3521
|
+
}
|
|
3522
|
+
if (unreadable > 0) {
|
|
3523
|
+
lines.push(` ${unreadable === 1 ? "1 entry" : `${unreadable} entries`} in the list couldn't be read by this version of the tool.`);
|
|
3524
|
+
}
|
|
3525
|
+
return lines;
|
|
3526
|
+
}
|
|
3527
|
+
function renderOne(initiative, copy) {
|
|
3528
|
+
const lines = [` ${initiative.organisationName}: ${initiative.title}`];
|
|
3529
|
+
lines.push(` ${describeStatus(initiative)}`);
|
|
3530
|
+
if (initiative.summaryForCohort) {
|
|
3531
|
+
for (const line of initiative.summaryForCohort.split(/\r?\n/))
|
|
3532
|
+
lines.push(` ${line}`);
|
|
3533
|
+
}
|
|
3534
|
+
if (initiative.direction)
|
|
3535
|
+
lines.push(` ${DIRECTION_WORDS[initiative.direction] ?? DIRECTION_UNKNOWN}`);
|
|
3536
|
+
lines.push(` Scoring window: ${formatWindowOrRaw(initiative.scoringStartUtc, initiative.scoringEndUtc)}`);
|
|
3537
|
+
if (initiative.result)
|
|
3538
|
+
lines.push(...renderResult(initiative.result, initiative.measureUnit, copy));
|
|
3539
|
+
lines.push("");
|
|
3540
|
+
return lines;
|
|
3541
|
+
}
|
|
3542
|
+
function describeStatus(initiative) {
|
|
3543
|
+
switch (initiative.status) {
|
|
3544
|
+
case "published":
|
|
3545
|
+
return "Published, not scored yet.";
|
|
3546
|
+
case "scored":
|
|
3547
|
+
return "Scored.";
|
|
3548
|
+
case "withdrawn":
|
|
3549
|
+
return initiative.withdrawnUtc ? `Withdrawn on ${formatDay(initiative.withdrawnUtc)}. It won't be scored.` : "Withdrawn. It won't be scored.";
|
|
3550
|
+
default:
|
|
3551
|
+
return "Status not recognised.";
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
function renderResult(result, unit, copy) {
|
|
3555
|
+
const lines = [];
|
|
3556
|
+
const show = (n) => unit ? `${figure(n)} ${unit}` : figure(n);
|
|
3557
|
+
if (result.value === null) {
|
|
3558
|
+
const why = copy.withheldReasons[result.withheldReason ?? ""];
|
|
3559
|
+
lines.push(` ${why ? `Withheld: ${why}.` : WITHHELD_UNKNOWN}`);
|
|
3560
|
+
return lines;
|
|
3561
|
+
}
|
|
3562
|
+
lines.push(` Result: ${show(result.value)}`);
|
|
3563
|
+
lines.push(` ${movementLine(result)}`);
|
|
3564
|
+
lines.push(` ${result.outcome ? copy.outcomes[result.outcome] ?? OUTCOME_UNKNOWN : OUTCOME_EMPTY}`);
|
|
3565
|
+
return lines;
|
|
3566
|
+
}
|
|
3567
|
+
function movementLine(result) {
|
|
3568
|
+
if (result.outcome === "within_own_variation")
|
|
3569
|
+
return "No material change against frozen baseline";
|
|
3570
|
+
if (result.delta === null)
|
|
3571
|
+
return "No reading";
|
|
3572
|
+
if (result.delta > 0)
|
|
3573
|
+
return `Up ${figure(result.delta)} against frozen baseline`;
|
|
3574
|
+
if (result.delta < 0)
|
|
3575
|
+
return `Down ${figure(Math.abs(result.delta))} against frozen baseline`;
|
|
3576
|
+
return "No change against frozen baseline";
|
|
3577
|
+
}
|
|
3578
|
+
function figure(n) {
|
|
3579
|
+
return String(Number(n.toPrecision(12)));
|
|
3580
|
+
}
|
|
3581
|
+
function asInitiative(value) {
|
|
3582
|
+
if (!value || typeof value !== "object")
|
|
3583
|
+
return void 0;
|
|
3584
|
+
const o = value;
|
|
3585
|
+
if (typeof o.title !== "string" || typeof o.status !== "string")
|
|
3586
|
+
return void 0;
|
|
3587
|
+
return {
|
|
3588
|
+
id: typeof o.id === "string" ? o.id : "",
|
|
3589
|
+
organisationName: typeof o.organisationName === "string" ? o.organisationName : "Your organisation",
|
|
3590
|
+
title: o.title,
|
|
3591
|
+
summaryForCohort: typeof o.summaryForCohort === "string" ? o.summaryForCohort : "",
|
|
3592
|
+
measureUnit: typeof o.measureUnit === "string" ? o.measureUnit : null,
|
|
3593
|
+
scoringStartUtc: typeof o.scoringStartUtc === "string" ? o.scoringStartUtc : "",
|
|
3594
|
+
scoringEndUtc: typeof o.scoringEndUtc === "string" ? o.scoringEndUtc : "",
|
|
3595
|
+
withdrawnUtc: typeof o.withdrawnUtc === "string" ? o.withdrawnUtc : null,
|
|
3596
|
+
status: o.status,
|
|
3597
|
+
direction: typeof o.direction === "string" ? o.direction : null,
|
|
3598
|
+
result: asResult(o.result)
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
function asResult(value) {
|
|
3602
|
+
if (!value || typeof value !== "object")
|
|
3603
|
+
return null;
|
|
3604
|
+
const r = value;
|
|
3605
|
+
const num = (x) => typeof x === "number" && Number.isFinite(x) ? x : null;
|
|
3606
|
+
return {
|
|
3607
|
+
scoredAtUtc: typeof r.scoredAtUtc === "string" ? r.scoredAtUtc : "",
|
|
3608
|
+
value: num(r.value),
|
|
3609
|
+
baselineValue: num(r.baselineValue),
|
|
3610
|
+
delta: num(r.delta),
|
|
3611
|
+
movement: typeof r.movement === "string" ? r.movement : null,
|
|
3612
|
+
outcome: typeof r.outcome === "string" ? r.outcome : "",
|
|
3613
|
+
withheldReason: typeof r.withheldReason === "string" ? r.withheldReason : null,
|
|
3614
|
+
basis: typeof r.basis === "string" ? r.basis : null
|
|
3615
|
+
};
|
|
3616
|
+
}
|
|
3617
|
+
function formatWindowOrRaw(startUtc, endUtc) {
|
|
3618
|
+
if (Number.isNaN(Date.parse(startUtc)) || Number.isNaN(Date.parse(endUtc)))
|
|
3619
|
+
return "not given";
|
|
3620
|
+
return (0, studyJoin_1.formatWindow)(startUtc, endUtc);
|
|
3621
|
+
}
|
|
3622
|
+
function formatDay(iso) {
|
|
3623
|
+
const date3 = new Date(iso);
|
|
3624
|
+
if (Number.isNaN(date3.getTime()))
|
|
3625
|
+
return iso;
|
|
3626
|
+
return new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short", year: "numeric", timeZone: "UTC" }).format(date3);
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
});
|
|
3630
|
+
|
|
2978
3631
|
// ../packages/tool-kit/out/setupDisclosure.js
|
|
2979
3632
|
var require_setupDisclosure = __commonJS({
|
|
2980
3633
|
"../packages/tool-kit/out/setupDisclosure.js"(exports) {
|
|
@@ -2995,6 +3648,7 @@ var require_setupDisclosure = __commonJS({
|
|
|
2995
3648
|
edits: "roughly how much a file changed, as a bucket, and whether you edited it after the agent wrote it",
|
|
2996
3649
|
context: "how full the context window got",
|
|
2997
3650
|
waiting: "that your agent stopped and waited for you, as one word: permission_request, idle_prompt, or other",
|
|
3651
|
+
subagents: "when a subagent starts and stops, the id your agent gives it, and whether it was built in, from a plugin or one you defined \u2014 never its name or what it was asked",
|
|
2998
3652
|
reading: "what the reader could not make sense of \u2014 lines it failed to parse, files it could not open, and prompts it judged machine-written rather than typed"
|
|
2999
3653
|
};
|
|
3000
3654
|
exports.ALWAYS_SENT = ["session", "counts", "tools", "outcome", "repo", "clock"];
|
|
@@ -3020,9 +3674,9 @@ var require_setupDisclosure = __commonJS({
|
|
|
3020
3674
|
}
|
|
3021
3675
|
});
|
|
3022
3676
|
|
|
3023
|
-
// ../packages/tool-kit/out/
|
|
3024
|
-
var
|
|
3025
|
-
"../packages/tool-kit/out/
|
|
3677
|
+
// ../packages/tool-kit/out/hookRunner.js
|
|
3678
|
+
var require_hookRunner = __commonJS({
|
|
3679
|
+
"../packages/tool-kit/out/hookRunner.js"(exports) {
|
|
3026
3680
|
"use strict";
|
|
3027
3681
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3028
3682
|
if (k2 === void 0) k2 = k;
|
|
@@ -3062,48 +3716,1039 @@ var require_cliAgentSetup = __commonJS({
|
|
|
3062
3716
|
};
|
|
3063
3717
|
}();
|
|
3064
3718
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3065
|
-
exports.
|
|
3066
|
-
exports.
|
|
3067
|
-
exports.
|
|
3068
|
-
exports.
|
|
3069
|
-
exports.
|
|
3070
|
-
|
|
3719
|
+
exports.hookRunnerPaths = hookRunnerPaths;
|
|
3720
|
+
exports.hookLauncherScript = hookLauncherScript;
|
|
3721
|
+
exports.installHookRunner = installHookRunner;
|
|
3722
|
+
exports.removeHookRunner = removeHookRunner;
|
|
3723
|
+
exports.hookRunnerCommand = hookRunnerCommand;
|
|
3724
|
+
exports.lastHookPath = lastHookPath;
|
|
3725
|
+
exports.stampLastHook = stampLastHook;
|
|
3726
|
+
exports.readLastHook = readLastHook;
|
|
3727
|
+
exports.describeAge = describeAge;
|
|
3728
|
+
exports.resolveHookNode = resolveHookNode;
|
|
3729
|
+
exports.tidyHomePath = tidyHomePath;
|
|
3730
|
+
var child_process_1 = __require("child_process");
|
|
3071
3731
|
var fs = __importStar(__require("fs"));
|
|
3072
|
-
var os = __importStar(__require("os"));
|
|
3073
3732
|
var path = __importStar(__require("path"));
|
|
3074
|
-
var collectorVersion_1 = require_collectorVersion();
|
|
3075
|
-
var credentials_1 = require_credentials();
|
|
3076
|
-
var hookAdapter_1 = require_hookAdapter();
|
|
3077
|
-
var http_1 = require_http();
|
|
3078
|
-
var setupDisclosure_1 = require_setupDisclosure();
|
|
3079
3733
|
var tokenStore_1 = require_tokenStore();
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
return
|
|
3734
|
+
function hookRunnerPaths(binaryName) {
|
|
3735
|
+
const launcher = path.join((0, tokenStore_1.ascendaHome)(), "bin", binaryName);
|
|
3736
|
+
return { launcher, bundle: `${launcher}.mjs`, record: `${launcher}.node`, noNode: `${launcher}.no-node` };
|
|
3083
3737
|
}
|
|
3084
|
-
|
|
3085
|
-
|
|
3738
|
+
var LAUNCHER_MANAGEMENT_COMMANDS = ["setup", "install", "status", "uninstall", "doctor", "pair", "join", "object", "-h", "--help"];
|
|
3739
|
+
function hookLauncherScript(options) {
|
|
3740
|
+
const { binaryName, setupCommand, loudEvent } = options;
|
|
3741
|
+
return [
|
|
3742
|
+
"#!/bin/sh",
|
|
3743
|
+
`# Ascenda hook launcher (${binaryName}). Written by \`setup\`, replaced by the`,
|
|
3744
|
+
"# next one; edits here are lost. Finds a Node to run the hook bundle beside it.",
|
|
3745
|
+
"",
|
|
3746
|
+
'dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) || exit 0',
|
|
3747
|
+
`bundle="$dir/${binaryName}.mjs"`,
|
|
3748
|
+
`record="$dir/${binaryName}.node"`,
|
|
3749
|
+
`missing="$dir/${binaryName}.no-node"`,
|
|
3750
|
+
"",
|
|
3751
|
+
'runs() { [ -n "$1" ] && [ -f "$1" ] && [ -x "$1" ]; }',
|
|
3752
|
+
"",
|
|
3753
|
+
"# The hook bundle needs Node 20 or newer. Checked only while searching, so",
|
|
3754
|
+
"# the recorded path costs nothing to reuse.",
|
|
3755
|
+
"recent() {",
|
|
3756
|
+
` runs "$1" && "$1" -e 'process.exit(parseInt(process.versions.node, 10) >= 20 ? 0 : 1)' >/dev/null 2>&1`,
|
|
3757
|
+
"}",
|
|
3758
|
+
"",
|
|
3759
|
+
"newest_nvm() {",
|
|
3760
|
+
' [ -d "$HOME/.nvm/versions/node" ] || return 0',
|
|
3761
|
+
` 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/'`,
|
|
3762
|
+
"}",
|
|
3763
|
+
"",
|
|
3764
|
+
'node=""',
|
|
3765
|
+
"how=recorded",
|
|
3766
|
+
'[ -r "$record" ] && IFS= read -r node < "$record"',
|
|
3767
|
+
"",
|
|
3768
|
+
'if ! runs "$node"; then',
|
|
3769
|
+
' node=""',
|
|
3770
|
+
" how=found",
|
|
3771
|
+
' nvm_default=""',
|
|
3772
|
+
' if [ -r "$HOME/.nvm/alias/default" ]; then',
|
|
3773
|
+
' IFS= read -r wanted < "$HOME/.nvm/alias/default"',
|
|
3774
|
+
" wanted=${wanted#v}",
|
|
3775
|
+
' for candidate in "$HOME/.nvm/versions/node/v$wanted"*; do',
|
|
3776
|
+
' [ -x "$candidate/bin/node" ] && nvm_default="$candidate/bin/node"',
|
|
3777
|
+
" done",
|
|
3778
|
+
" fi",
|
|
3779
|
+
" nvm_newest=$(newest_nvm)",
|
|
3780
|
+
" for candidate in \\",
|
|
3781
|
+
' "$(command -v node 2>/dev/null)" \\',
|
|
3782
|
+
" /opt/homebrew/bin/node \\",
|
|
3783
|
+
" /usr/local/bin/node \\",
|
|
3784
|
+
' "$HOME/.volta/bin/node" \\',
|
|
3785
|
+
' "$nvm_default" \\',
|
|
3786
|
+
' "$HOME/.local/share/fnm/aliases/default/bin/node" \\',
|
|
3787
|
+
' "$HOME/Library/Application Support/fnm/aliases/default/bin/node" \\',
|
|
3788
|
+
' "$HOME/.asdf/shims/node" \\',
|
|
3789
|
+
' "$HOME/.local/share/mise/shims/node" \\',
|
|
3790
|
+
' "$HOME/.nvm/versions/node/$nvm_newest/bin/node"',
|
|
3791
|
+
" do",
|
|
3792
|
+
' if recent "$candidate"; then node=$candidate; break; fi',
|
|
3793
|
+
" done",
|
|
3794
|
+
' if [ -n "$node" ]; then',
|
|
3795
|
+
` printf '%s\\n' "$node" > "$record.$$" 2>/dev/null && mv -f "$record.$$" "$record" 2>/dev/null`,
|
|
3796
|
+
' rm -f "$missing" 2>/dev/null',
|
|
3797
|
+
" fi",
|
|
3798
|
+
"fi",
|
|
3799
|
+
"",
|
|
3800
|
+
'if [ -n "$ASCENDA_HOOK_LAUNCHER_PROBE" ]; then',
|
|
3801
|
+
' [ -n "$node" ] || { echo "no Node 20 or newer found on PATH or in the usual install locations" >&2; exit 1; }',
|
|
3802
|
+
` printf '%s\\t%s\\n' "$node" "$how"`,
|
|
3803
|
+
" exit 0",
|
|
3804
|
+
"fi",
|
|
3805
|
+
"",
|
|
3806
|
+
'if [ -z "$node" ]; then',
|
|
3807
|
+
' date -u +%Y-%m-%dT%H:%M:%SZ > "$missing" 2>/dev/null',
|
|
3808
|
+
' case "$1" in',
|
|
3809
|
+
...loudEvent ? [
|
|
3810
|
+
` ${loudEvent})`,
|
|
3811
|
+
" cat >/dev/null 2>&1",
|
|
3812
|
+
` echo "Ascenda hooks cannot find Node 20 or newer, so none of them are running. Install Node, then run: ${setupCommand}" >&2`,
|
|
3813
|
+
" exit 1 ;;"
|
|
3814
|
+
] : [],
|
|
3815
|
+
` ${LAUNCHER_MANAGEMENT_COMMANDS.join("|")})`,
|
|
3816
|
+
` echo "${binaryName}: no Node 20 or newer found on PATH or in the usual install locations." >&2`,
|
|
3817
|
+
" exit 1 ;;",
|
|
3818
|
+
" *)",
|
|
3819
|
+
" # A hook: say nothing per tool call. status and doctor read the",
|
|
3820
|
+
" # file written above.",
|
|
3821
|
+
" cat >/dev/null 2>&1",
|
|
3822
|
+
" exit 0 ;;",
|
|
3823
|
+
" esac",
|
|
3824
|
+
"fi",
|
|
3825
|
+
"",
|
|
3826
|
+
'exec "$node" "$bundle" "$@"',
|
|
3827
|
+
""
|
|
3828
|
+
].join("\n");
|
|
3829
|
+
}
|
|
3830
|
+
function installHookRunner(options) {
|
|
3831
|
+
const paths = hookRunnerPaths(options.binaryName);
|
|
3832
|
+
if (options.dryRun)
|
|
3833
|
+
return paths.launcher;
|
|
3834
|
+
const source = path.resolve(options.source ?? process.argv[1]);
|
|
3835
|
+
fs.mkdirSync(path.dirname(paths.launcher), { recursive: true });
|
|
3836
|
+
if (process.platform === "win32") {
|
|
3837
|
+
if (source !== path.resolve(paths.launcher))
|
|
3838
|
+
fs.copyFileSync(source, paths.launcher);
|
|
3839
|
+
return paths.launcher;
|
|
3840
|
+
}
|
|
3841
|
+
if (source !== path.resolve(paths.bundle))
|
|
3842
|
+
writeAtomically(paths.bundle, fs.readFileSync(source), 493);
|
|
3843
|
+
writeAtomically(paths.launcher, hookLauncherScript(options), 493);
|
|
3844
|
+
writeAtomically(paths.record, `${process.execPath}
|
|
3845
|
+
`, 420);
|
|
3846
|
+
fs.rmSync(paths.noNode, { force: true });
|
|
3847
|
+
return paths.launcher;
|
|
3848
|
+
}
|
|
3849
|
+
function removeHookRunner(binaryName) {
|
|
3850
|
+
const removed = [];
|
|
3851
|
+
for (const file of Object.values(hookRunnerPaths(binaryName))) {
|
|
3852
|
+
if (!fs.existsSync(file))
|
|
3853
|
+
continue;
|
|
3854
|
+
fs.rmSync(file, { force: true });
|
|
3855
|
+
removed.push(file);
|
|
3856
|
+
}
|
|
3857
|
+
return removed;
|
|
3086
3858
|
}
|
|
3087
|
-
function
|
|
3088
|
-
return
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3859
|
+
function hookRunnerCommand(launcher) {
|
|
3860
|
+
return process.platform === "win32" ? `"${process.execPath}" "${launcher}"` : `"${launcher}"`;
|
|
3861
|
+
}
|
|
3862
|
+
function writeAtomically(target, contents, mode) {
|
|
3863
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
3864
|
+
fs.writeFileSync(tmp, contents, { mode });
|
|
3865
|
+
fs.chmodSync(tmp, mode);
|
|
3866
|
+
fs.renameSync(tmp, target);
|
|
3867
|
+
}
|
|
3868
|
+
var stateDir = () => process.env.ASCENDA_STATE_DIR ?? path.join((0, tokenStore_1.ascendaHome)(), "state");
|
|
3869
|
+
function lastHookPath(tool) {
|
|
3870
|
+
return path.join(stateDir(), `${tool}-last-hook.json`);
|
|
3871
|
+
}
|
|
3872
|
+
function stampLastHook(tool, event, now = /* @__PURE__ */ new Date()) {
|
|
3873
|
+
try {
|
|
3874
|
+
fs.mkdirSync(stateDir(), { recursive: true });
|
|
3875
|
+
const file = lastHookPath(tool);
|
|
3876
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
3877
|
+
fs.writeFileSync(tmp, `${JSON.stringify({ event, at: now.toISOString() })}
|
|
3878
|
+
`, { mode: 384 });
|
|
3879
|
+
fs.renameSync(tmp, file);
|
|
3880
|
+
} catch {
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
function readLastHook(tool) {
|
|
3884
|
+
try {
|
|
3885
|
+
const parsed = JSON.parse(fs.readFileSync(lastHookPath(tool), "utf8"));
|
|
3886
|
+
if (typeof parsed.event !== "string" || typeof parsed.at !== "string")
|
|
3887
|
+
return void 0;
|
|
3888
|
+
return { event: parsed.event, at: parsed.at };
|
|
3889
|
+
} catch {
|
|
3890
|
+
return void 0;
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
function describeAge(ms) {
|
|
3894
|
+
if (!Number.isFinite(ms) || ms < 0)
|
|
3895
|
+
return "just now";
|
|
3896
|
+
const seconds = Math.round(ms / 1e3);
|
|
3897
|
+
if (seconds < 60)
|
|
3898
|
+
return `${seconds} s ago`;
|
|
3899
|
+
const minutes = Math.round(seconds / 60);
|
|
3900
|
+
if (minutes < 60)
|
|
3901
|
+
return `${minutes} min ago`;
|
|
3902
|
+
const hours = Math.round(minutes / 60);
|
|
3903
|
+
if (hours < 48)
|
|
3904
|
+
return `${hours} h ago`;
|
|
3905
|
+
return `${Math.round(hours / 24)} days ago`;
|
|
3906
|
+
}
|
|
3907
|
+
function resolveHookNode(launcher) {
|
|
3908
|
+
if (!fs.existsSync(launcher))
|
|
3909
|
+
return { problem: "the hook launcher is not installed" };
|
|
3910
|
+
const probe = (0, child_process_1.spawnSync)("/bin/sh", [launcher], {
|
|
3911
|
+
encoding: "utf8",
|
|
3912
|
+
timeout: 5e3,
|
|
3913
|
+
env: { HOME: process.env.HOME ?? "", PATH: "/usr/bin:/bin:/usr/sbin:/sbin", ASCENDA_HOOK_LAUNCHER_PROBE: "1" }
|
|
3914
|
+
});
|
|
3915
|
+
const [node, how] = (probe.stdout ?? "").trim().split(" ");
|
|
3916
|
+
if (probe.status !== 0 || !node) {
|
|
3917
|
+
return { problem: (probe.stderr ?? "").trim() || "the launcher found no Node it can run" };
|
|
3918
|
+
}
|
|
3919
|
+
const version2 = (0, child_process_1.spawnSync)(node, ["--version"], { encoding: "utf8", timeout: 5e3 });
|
|
3920
|
+
if (version2.status !== 0)
|
|
3921
|
+
return { node, how, problem: `${node} did not run` };
|
|
3922
|
+
return { node, how, version: version2.stdout.trim() };
|
|
3923
|
+
}
|
|
3924
|
+
function tidyHomePath(file, home = process.env.HOME ?? "") {
|
|
3925
|
+
return home && file.startsWith(`${home}/`) ? `~${file.slice(home.length)}` : file;
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
});
|
|
3929
|
+
|
|
3930
|
+
// ../packages/tool-kit/out/saverHandoff.js
|
|
3931
|
+
var require_saverHandoff = __commonJS({
|
|
3932
|
+
"../packages/tool-kit/out/saverHandoff.js"(exports) {
|
|
3933
|
+
"use strict";
|
|
3934
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3935
|
+
if (k2 === void 0) k2 = k;
|
|
3936
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3937
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3938
|
+
desc = { enumerable: true, get: function() {
|
|
3939
|
+
return m[k];
|
|
3940
|
+
} };
|
|
3941
|
+
}
|
|
3942
|
+
Object.defineProperty(o, k2, desc);
|
|
3943
|
+
} : function(o, m, k, k2) {
|
|
3944
|
+
if (k2 === void 0) k2 = k;
|
|
3945
|
+
o[k2] = m[k];
|
|
3946
|
+
});
|
|
3947
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
3948
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
3949
|
+
} : function(o, v) {
|
|
3950
|
+
o["default"] = v;
|
|
3951
|
+
});
|
|
3952
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
3953
|
+
var ownKeys = function(o) {
|
|
3954
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
3955
|
+
var ar = [];
|
|
3956
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
3957
|
+
return ar;
|
|
3958
|
+
};
|
|
3959
|
+
return ownKeys(o);
|
|
3960
|
+
};
|
|
3961
|
+
return function(mod) {
|
|
3962
|
+
if (mod && mod.__esModule) return mod;
|
|
3963
|
+
var result = {};
|
|
3964
|
+
if (mod != null) {
|
|
3965
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
3966
|
+
}
|
|
3967
|
+
__setModuleDefault(result, mod);
|
|
3968
|
+
return result;
|
|
3969
|
+
};
|
|
3970
|
+
}();
|
|
3971
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3972
|
+
exports.SAVER_REPLAY_SCHEMA = exports.SAVER_REPLAY_WINDOW_MS = void 0;
|
|
3973
|
+
exports.saverContainerDir = saverContainerDir;
|
|
3974
|
+
exports.saverSupportDir = saverSupportDir;
|
|
3975
|
+
exports.saverReplayPath = saverReplayPath;
|
|
3976
|
+
exports.saverStatusDir = saverStatusDir;
|
|
3977
|
+
exports.holdForSaver = holdForSaver;
|
|
3978
|
+
exports.heldForSaver = heldForSaver;
|
|
3979
|
+
exports.readSaverStatuses = readSaverStatuses;
|
|
3980
|
+
exports.probeSocket = probeSocket;
|
|
3981
|
+
var fs = __importStar(__require("fs"));
|
|
3982
|
+
var net = __importStar(__require("net"));
|
|
3983
|
+
var os = __importStar(__require("os"));
|
|
3984
|
+
var path = __importStar(__require("path"));
|
|
3985
|
+
var SAVER_HOST_BUNDLE_ID = "com.apple.ScreenSaver.Engine.legacyScreenSaver";
|
|
3986
|
+
function saverContainerDir() {
|
|
3987
|
+
return process.env.ASCENDA_SAVER_CONTAINER ?? path.join(os.homedir(), "Library", "Containers", SAVER_HOST_BUNDLE_ID, "Data");
|
|
3988
|
+
}
|
|
3989
|
+
function saverSupportDir() {
|
|
3990
|
+
return path.join(saverContainerDir(), "Library", "Application Support", "AscendaWaterlineSaver");
|
|
3991
|
+
}
|
|
3992
|
+
function saverReplayPath() {
|
|
3993
|
+
return path.join(saverContainerDir(), "l.replay.json");
|
|
3994
|
+
}
|
|
3995
|
+
function saverStatusDir() {
|
|
3996
|
+
return path.join(saverSupportDir(), "status");
|
|
3997
|
+
}
|
|
3998
|
+
exports.SAVER_REPLAY_WINDOW_MS = 30 * 60 * 1e3;
|
|
3999
|
+
var SAVER_REPLAY_MAX = 32;
|
|
4000
|
+
exports.SAVER_REPLAY_SCHEMA = 1;
|
|
4001
|
+
function holdForSaver(signal, now = Date.now()) {
|
|
4002
|
+
try {
|
|
4003
|
+
if (process.env.ASCENDA_LIVE_BUS_SOCKET && !process.env.ASCENDA_SAVER_CONTAINER)
|
|
4004
|
+
return;
|
|
4005
|
+
if (!fs.existsSync(saverSupportDir()))
|
|
4006
|
+
return;
|
|
4007
|
+
const wire = signal;
|
|
4008
|
+
const tool = wire.tool;
|
|
4009
|
+
const session = wire.session;
|
|
4010
|
+
const event = wire.event;
|
|
4011
|
+
if (typeof tool !== "string" || typeof session !== "string" || typeof event !== "string")
|
|
4012
|
+
return;
|
|
4013
|
+
const file = saverReplayPath();
|
|
4014
|
+
const kept = readHeld(file).filter((held) => now - held.at <= exports.SAVER_REPLAY_WINDOW_MS && !(held.tool === tool && held.session === session));
|
|
4015
|
+
kept.push({ ...wire, tool, session, event, at: now });
|
|
4016
|
+
kept.sort((a, b) => a.at - b.at);
|
|
4017
|
+
const body = JSON.stringify({ schema: exports.SAVER_REPLAY_SCHEMA, signals: kept.slice(-SAVER_REPLAY_MAX) });
|
|
4018
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
4019
|
+
fs.writeFileSync(tmp, `${body}
|
|
4020
|
+
`, { mode: 384 });
|
|
4021
|
+
fs.renameSync(tmp, file);
|
|
4022
|
+
} catch {
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
function readHeld(file) {
|
|
4026
|
+
try {
|
|
4027
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
4028
|
+
if (parsed.schema !== exports.SAVER_REPLAY_SCHEMA || !Array.isArray(parsed.signals))
|
|
4029
|
+
return [];
|
|
4030
|
+
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");
|
|
4031
|
+
} catch {
|
|
4032
|
+
return [];
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
function heldForSaver(now = Date.now()) {
|
|
4036
|
+
const held = readHeld(saverReplayPath()).filter((entry) => now - entry.at <= exports.SAVER_REPLAY_WINDOW_MS);
|
|
4037
|
+
if (held.length === 0)
|
|
4038
|
+
return { count: 0 };
|
|
4039
|
+
return { count: held.length, newestAgeMs: now - Math.max(...held.map((entry) => entry.at)) };
|
|
4040
|
+
}
|
|
4041
|
+
function readSaverStatuses(now = Date.now()) {
|
|
4042
|
+
let names;
|
|
4043
|
+
try {
|
|
4044
|
+
names = fs.readdirSync(saverStatusDir()).filter((name) => name.endsWith(".json"));
|
|
4045
|
+
} catch {
|
|
4046
|
+
return [];
|
|
4047
|
+
}
|
|
4048
|
+
const readings = [];
|
|
4049
|
+
for (const name of names) {
|
|
4050
|
+
try {
|
|
4051
|
+
const status = JSON.parse(fs.readFileSync(path.join(saverStatusDir(), name), "utf8"));
|
|
4052
|
+
if (typeof status.pid !== "number" || typeof status.updatedAt !== "string")
|
|
4053
|
+
continue;
|
|
4054
|
+
readings.push({ ...status, alive: processAlive(status.pid), ageMs: now - Date.parse(status.updatedAt) });
|
|
4055
|
+
} catch {
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
return readings.sort((a, b) => a.ageMs - b.ageMs);
|
|
4059
|
+
}
|
|
4060
|
+
function processAlive(pid) {
|
|
4061
|
+
try {
|
|
4062
|
+
process.kill(pid, 0);
|
|
4063
|
+
return true;
|
|
4064
|
+
} catch (error2) {
|
|
4065
|
+
return error2.code === "EPERM";
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
function probeSocket(socketPath, timeoutMs = 300) {
|
|
4069
|
+
return new Promise((resolve) => {
|
|
4070
|
+
try {
|
|
4071
|
+
if (!fs.statSync(socketPath).isSocket()) {
|
|
4072
|
+
resolve("absent");
|
|
4073
|
+
return;
|
|
4074
|
+
}
|
|
4075
|
+
} catch {
|
|
4076
|
+
resolve("absent");
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
let settled = false;
|
|
4080
|
+
const finish = (state) => {
|
|
4081
|
+
if (settled)
|
|
4082
|
+
return;
|
|
4083
|
+
settled = true;
|
|
4084
|
+
clearTimeout(timer);
|
|
4085
|
+
socket.destroy();
|
|
4086
|
+
resolve(state);
|
|
4087
|
+
};
|
|
4088
|
+
const socket = net.createConnection(socketPath);
|
|
4089
|
+
const timer = setTimeout(() => finish("unreachable"), timeoutMs);
|
|
4090
|
+
socket.on("connect", () => finish("listening"));
|
|
4091
|
+
socket.on("error", (error2) => finish(error2.code === "ECONNREFUSED" || error2.code === "ENOENT" ? "stale" : "unreachable"));
|
|
4092
|
+
});
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
});
|
|
4096
|
+
|
|
4097
|
+
// ../packages/tool-kit/out/liveBus.js
|
|
4098
|
+
var require_liveBus = __commonJS({
|
|
4099
|
+
"../packages/tool-kit/out/liveBus.js"(exports) {
|
|
4100
|
+
"use strict";
|
|
4101
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4102
|
+
if (k2 === void 0) k2 = k;
|
|
4103
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4104
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4105
|
+
desc = { enumerable: true, get: function() {
|
|
4106
|
+
return m[k];
|
|
4107
|
+
} };
|
|
4108
|
+
}
|
|
4109
|
+
Object.defineProperty(o, k2, desc);
|
|
4110
|
+
} : function(o, m, k, k2) {
|
|
4111
|
+
if (k2 === void 0) k2 = k;
|
|
4112
|
+
o[k2] = m[k];
|
|
4113
|
+
});
|
|
4114
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
4115
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
4116
|
+
} : function(o, v) {
|
|
4117
|
+
o["default"] = v;
|
|
4118
|
+
});
|
|
4119
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
4120
|
+
var ownKeys = function(o) {
|
|
4121
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
4122
|
+
var ar = [];
|
|
4123
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
4124
|
+
return ar;
|
|
4125
|
+
};
|
|
4126
|
+
return ownKeys(o);
|
|
4127
|
+
};
|
|
4128
|
+
return function(mod) {
|
|
4129
|
+
if (mod && mod.__esModule) return mod;
|
|
4130
|
+
var result = {};
|
|
4131
|
+
if (mod != null) {
|
|
4132
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
4133
|
+
}
|
|
4134
|
+
__setModuleDefault(result, mod);
|
|
4135
|
+
return result;
|
|
4136
|
+
};
|
|
4137
|
+
}();
|
|
4138
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4139
|
+
exports.SAVER_HOST_BUNDLE_ID = exports.LIVE_BUS_BACKGROUND_TRUST_MS = void 0;
|
|
4140
|
+
exports.liveBusSocketCandidates = liveBusSocketCandidates;
|
|
4141
|
+
exports.existingSocketCandidates = existingSocketCandidates;
|
|
4142
|
+
exports.liveBusSocketPath = liveBusSocketPath;
|
|
4143
|
+
exports.bucketPromptSize = bucketPromptSize;
|
|
4144
|
+
exports.emitLiveSignal = emitLiveSignal;
|
|
4145
|
+
exports.deliverLine = deliverLine;
|
|
4146
|
+
var fs = __importStar(__require("fs"));
|
|
4147
|
+
var net = __importStar(__require("net"));
|
|
4148
|
+
var os = __importStar(__require("os"));
|
|
4149
|
+
var path = __importStar(__require("path"));
|
|
4150
|
+
var hookSet_1 = require_hookSet();
|
|
4151
|
+
var saverHandoff_1 = require_saverHandoff();
|
|
4152
|
+
var WRITE_TIMEOUT_MS = 50;
|
|
4153
|
+
exports.LIVE_BUS_BACKGROUND_TRUST_MS = 60 * 60 * 1e3;
|
|
4154
|
+
var APP_BUNDLE_ID = "one.ascenda.ascendaMissionControl";
|
|
4155
|
+
exports.SAVER_HOST_BUNDLE_ID = "com.apple.ScreenSaver.Engine.legacyScreenSaver";
|
|
4156
|
+
function liveBusSocketCandidates() {
|
|
4157
|
+
const override = process.env.ASCENDA_LIVE_BUS_SOCKET;
|
|
4158
|
+
if (override)
|
|
4159
|
+
return [override];
|
|
4160
|
+
const home = os.homedir();
|
|
4161
|
+
return [
|
|
4162
|
+
path.join(home, ".ascenda", "live.sock"),
|
|
4163
|
+
path.join(home, "Library", "Containers", APP_BUNDLE_ID, "Data", ".ascenda", "live.sock"),
|
|
4164
|
+
path.join(home, "Library", "Containers", exports.SAVER_HOST_BUNDLE_ID, "Data", "l.sock")
|
|
4165
|
+
];
|
|
4166
|
+
}
|
|
4167
|
+
function existingSocketCandidates() {
|
|
4168
|
+
const candidates = liveBusSocketCandidates();
|
|
4169
|
+
if (process.env.ASCENDA_LIVE_BUS_SOCKET)
|
|
4170
|
+
return candidates;
|
|
4171
|
+
return candidates.filter((candidate) => {
|
|
4172
|
+
try {
|
|
4173
|
+
return fs.statSync(candidate).isSocket();
|
|
4174
|
+
} catch {
|
|
4175
|
+
return false;
|
|
4176
|
+
}
|
|
4177
|
+
});
|
|
4178
|
+
}
|
|
4179
|
+
function liveBusSocketPath() {
|
|
4180
|
+
return existingSocketCandidates()[0] ?? liveBusSocketCandidates()[0];
|
|
4181
|
+
}
|
|
4182
|
+
function bucketPromptSize(text) {
|
|
4183
|
+
const length = typeof text === "string" ? text.length : 0;
|
|
4184
|
+
if (length <= 280)
|
|
4185
|
+
return "s";
|
|
4186
|
+
if (length <= 2e3)
|
|
4187
|
+
return "m";
|
|
4188
|
+
if (length <= 8e3)
|
|
4189
|
+
return "l";
|
|
4190
|
+
return "xl";
|
|
4191
|
+
}
|
|
4192
|
+
var NOBODY_LISTENING = /* @__PURE__ */ new Set(["ECONNREFUSED", "ENOENT"]);
|
|
4193
|
+
function onTheWire(signal) {
|
|
4194
|
+
const out = { ...signal };
|
|
4195
|
+
if ("hookSet" in out && !(0, hookSet_1.isHookSet)(out.hookSet))
|
|
4196
|
+
delete out.hookSet;
|
|
4197
|
+
if ("viaPlugin" in out && out.viaPlugin !== true)
|
|
4198
|
+
delete out.viaPlugin;
|
|
4199
|
+
return out;
|
|
4200
|
+
}
|
|
4201
|
+
function emitLiveSignal(signal) {
|
|
4202
|
+
const wire = onTheWire(signal);
|
|
4203
|
+
return deliverLine(`${JSON.stringify(wire)}
|
|
4204
|
+
`).then((delivered) => {
|
|
4205
|
+
if (!delivered)
|
|
4206
|
+
(0, saverHandoff_1.holdForSaver)(wire);
|
|
4207
|
+
});
|
|
4208
|
+
}
|
|
4209
|
+
function deliverLine(line) {
|
|
4210
|
+
return new Promise((resolve) => {
|
|
4211
|
+
const candidates = existingSocketCandidates();
|
|
4212
|
+
if (candidates.length === 0) {
|
|
4213
|
+
resolve(void 0);
|
|
4214
|
+
return;
|
|
4215
|
+
}
|
|
4216
|
+
let settled = false;
|
|
4217
|
+
let accepted;
|
|
4218
|
+
let socket;
|
|
4219
|
+
const drop = () => {
|
|
4220
|
+
try {
|
|
4221
|
+
socket?.destroy();
|
|
4222
|
+
} catch {
|
|
4223
|
+
}
|
|
4224
|
+
socket = void 0;
|
|
4225
|
+
};
|
|
4226
|
+
const done = () => {
|
|
4227
|
+
if (settled)
|
|
4228
|
+
return;
|
|
4229
|
+
settled = true;
|
|
4230
|
+
clearTimeout(timer);
|
|
4231
|
+
drop();
|
|
4232
|
+
resolve(accepted);
|
|
4233
|
+
};
|
|
4234
|
+
const timer = setTimeout(done, WRITE_TIMEOUT_MS);
|
|
4235
|
+
const tryFrom = (index) => {
|
|
4236
|
+
if (settled)
|
|
4237
|
+
return;
|
|
4238
|
+
if (index >= candidates.length) {
|
|
4239
|
+
done();
|
|
4240
|
+
return;
|
|
4241
|
+
}
|
|
4242
|
+
let attempt;
|
|
4243
|
+
try {
|
|
4244
|
+
attempt = net.createConnection(candidates[index]);
|
|
4245
|
+
} catch {
|
|
4246
|
+
tryFrom(index + 1);
|
|
4247
|
+
return;
|
|
4248
|
+
}
|
|
4249
|
+
socket = attempt;
|
|
4250
|
+
if (typeof attempt.unref === "function")
|
|
4251
|
+
attempt.unref();
|
|
4252
|
+
let connected = false;
|
|
4253
|
+
attempt.on("error", (error2) => {
|
|
4254
|
+
if (settled || socket !== attempt)
|
|
4255
|
+
return;
|
|
4256
|
+
if (!connected && error2.code && NOBODY_LISTENING.has(error2.code)) {
|
|
4257
|
+
drop();
|
|
4258
|
+
tryFrom(index + 1);
|
|
4259
|
+
return;
|
|
4260
|
+
}
|
|
4261
|
+
done();
|
|
4262
|
+
});
|
|
4263
|
+
attempt.on("connect", () => {
|
|
4264
|
+
if (settled || socket !== attempt)
|
|
4265
|
+
return;
|
|
4266
|
+
connected = true;
|
|
4267
|
+
accepted = candidates[index];
|
|
4268
|
+
try {
|
|
4269
|
+
attempt.write(line, done);
|
|
4270
|
+
} catch {
|
|
4271
|
+
done();
|
|
4272
|
+
}
|
|
4273
|
+
});
|
|
4274
|
+
};
|
|
4275
|
+
tryFrom(0);
|
|
4276
|
+
});
|
|
4277
|
+
}
|
|
4278
|
+
}
|
|
4279
|
+
});
|
|
4280
|
+
|
|
4281
|
+
// ../packages/tool-kit/out/terminalStyle.js
|
|
4282
|
+
var require_terminalStyle = __commonJS({
|
|
4283
|
+
"../packages/tool-kit/out/terminalStyle.js"(exports) {
|
|
4284
|
+
"use strict";
|
|
4285
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4286
|
+
exports.colourEnabled = colourEnabled;
|
|
4287
|
+
exports.terminalStyle = terminalStyle;
|
|
4288
|
+
function colourEnabled(stream = process.stdout, env = process.env) {
|
|
4289
|
+
if (env.NO_COLOR !== void 0 && env.NO_COLOR !== "")
|
|
4290
|
+
return false;
|
|
4291
|
+
if (env.FORCE_COLOR !== void 0)
|
|
4292
|
+
return env.FORCE_COLOR !== "0";
|
|
4293
|
+
if (env.TERM === "dumb")
|
|
4294
|
+
return false;
|
|
4295
|
+
return Boolean(stream.isTTY);
|
|
4296
|
+
}
|
|
4297
|
+
function terminalStyle(enabled = colourEnabled()) {
|
|
4298
|
+
const wrap = (open, close) => (text) => enabled ? `\x1B[${open}m${text}\x1B[${close}m` : text;
|
|
4299
|
+
const bold = wrap(1, 22);
|
|
4300
|
+
const dim = wrap(2, 22);
|
|
4301
|
+
const green = wrap(32, 39);
|
|
4302
|
+
const yellow = wrap(33, 39);
|
|
4303
|
+
const red = wrap(31, 39);
|
|
4304
|
+
const cyan = wrap(36, 39);
|
|
4305
|
+
const colour = { ok: green, warn: yellow, bad: red, info: dim };
|
|
4306
|
+
const marks = { ok: "\u2713", warn: "!", bad: "\u2717", info: "\xB7" };
|
|
4307
|
+
return {
|
|
4308
|
+
enabled,
|
|
4309
|
+
bold,
|
|
4310
|
+
dim,
|
|
4311
|
+
green,
|
|
4312
|
+
yellow,
|
|
4313
|
+
red,
|
|
4314
|
+
cyan,
|
|
4315
|
+
mark: (tone) => colour[tone](marks[tone]),
|
|
4316
|
+
tone: (tone, text) => colour[tone](text)
|
|
4317
|
+
};
|
|
4318
|
+
}
|
|
4319
|
+
}
|
|
4320
|
+
});
|
|
4321
|
+
|
|
4322
|
+
// ../packages/tool-kit/out/liveSignalDoctor.js
|
|
4323
|
+
var require_liveSignalDoctor = __commonJS({
|
|
4324
|
+
"../packages/tool-kit/out/liveSignalDoctor.js"(exports) {
|
|
4325
|
+
"use strict";
|
|
4326
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4327
|
+
exports.DOCTOR_VALUE_COLUMN = void 0;
|
|
4328
|
+
exports.doctorRow = doctorRow;
|
|
4329
|
+
exports.liveSignalDoctorLines = liveSignalDoctorLines;
|
|
4330
|
+
var hookRunner_1 = require_hookRunner();
|
|
4331
|
+
var liveBus_1 = require_liveBus();
|
|
4332
|
+
var saverHandoff_1 = require_saverHandoff();
|
|
4333
|
+
var terminalStyle_1 = require_terminalStyle();
|
|
4334
|
+
exports.DOCTOR_VALUE_COLUMN = 25;
|
|
4335
|
+
function doctorRow(ui, tone, label, value) {
|
|
4336
|
+
return ` ${ui.mark(tone)} ${label.padEnd(exports.DOCTOR_VALUE_COLUMN - 5)} ${value}`;
|
|
4337
|
+
}
|
|
4338
|
+
async function liveSignalDoctorLines(options) {
|
|
4339
|
+
const ui = options.ui ?? (0, terminalStyle_1.terminalStyle)();
|
|
4340
|
+
const lines = [` ${ui.bold("Live signal")} ${ui.dim("(this machine; needs no pairing)")}`];
|
|
4341
|
+
const now = Date.now();
|
|
4342
|
+
let problems = 0;
|
|
4343
|
+
const row = (tone, label, value) => {
|
|
4344
|
+
if (tone === "bad" || tone === "warn")
|
|
4345
|
+
problems += 1;
|
|
4346
|
+
lines.push(doctorRow(ui, tone, label, tone === "bad" ? ui.red(value) : value));
|
|
4347
|
+
};
|
|
4348
|
+
const more = (value) => lines.push(`${" ".repeat(exports.DOCTOR_VALUE_COLUMN)}${value}`);
|
|
4349
|
+
if (options.launcher && process.platform !== "win32") {
|
|
4350
|
+
const node = (0, hookRunner_1.resolveHookNode)(options.launcher);
|
|
4351
|
+
if (node.problem)
|
|
4352
|
+
row("bad", "Node", `${node.problem}. Install Node 20 or newer, then run setup again`);
|
|
4353
|
+
else
|
|
4354
|
+
row("ok", "Node", `${node.node} ${ui.dim(`(${node.version}, ${node.how === "recorded" ? "recorded at setup" : "found by the launcher"})`)}`);
|
|
4355
|
+
}
|
|
4356
|
+
if (options.registrations.length === 0)
|
|
4357
|
+
row("bad", "Hooks", `not registered. Run: ${options.setupCommand}`);
|
|
4358
|
+
for (const entry of options.registrations) {
|
|
4359
|
+
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";
|
|
4360
|
+
const complete = entry.registered === options.eventCount;
|
|
4361
|
+
row(entry.homeProject || !complete ? "warn" : entry.scope === "user" ? "ok" : "info", "Hooks", `${entry.registered}/${options.eventCount} in ${entry.file} ${ui.dim(`(${where})`)}`);
|
|
4362
|
+
}
|
|
4363
|
+
if (options.registrations.length > 1) {
|
|
4364
|
+
problems += 1;
|
|
4365
|
+
more(ui.yellow("Registered in more than one file, so each event runs more than once. Run setup again to fix."));
|
|
4366
|
+
}
|
|
4367
|
+
const last = (0, hookRunner_1.readLastHook)(options.tool);
|
|
4368
|
+
if (last)
|
|
4369
|
+
row("ok", "Last hook", `${last.event}, ${(0, hookRunner_1.describeAge)(now - Date.parse(last.at))}`);
|
|
4370
|
+
else
|
|
4371
|
+
row("info", "Last hook", `none yet. Start ${options.displayName} (restart it if it was open during setup)${options.lookHint ? `, then ${options.lookHint}` : ""}`);
|
|
4372
|
+
const [appSocket, appContainerSocket, saverSocket] = (0, liveBus_1.liveBusSocketCandidates)();
|
|
4373
|
+
const appState = await (0, saverHandoff_1.probeSocket)(appSocket);
|
|
4374
|
+
const legacyState = appContainerSocket ? await (0, saverHandoff_1.probeSocket)(appContainerSocket) : "absent";
|
|
4375
|
+
if (appState === "listening" || legacyState === "listening")
|
|
4376
|
+
row("ok", "Desktop app", "listening. It takes every signal, and the saver mirrors it");
|
|
4377
|
+
else
|
|
4378
|
+
row("info", "Desktop app", "not listening");
|
|
4379
|
+
const saverState = saverSocket ? await (0, saverHandoff_1.probeSocket)(saverSocket) : "absent";
|
|
4380
|
+
const live = (0, saverHandoff_1.readSaverStatuses)(now).filter((status) => status.alive);
|
|
4381
|
+
const holder = live.find((status) => status.ownsBus);
|
|
4382
|
+
const saver = describeSaver(saverState, holder, live);
|
|
4383
|
+
row(saver.tone, "Screen saver", saver.text);
|
|
4384
|
+
for (const status of live)
|
|
4385
|
+
more(ui.dim(describeProcess(status, now)));
|
|
4386
|
+
const held = (0, saverHandoff_1.heldForSaver)(now);
|
|
4387
|
+
if (held.count > 0) {
|
|
4388
|
+
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`);
|
|
4389
|
+
}
|
|
4390
|
+
const trip = await pingRoundTrip(saverSocket, options.selfCommand);
|
|
4391
|
+
row(trip.tone, "Round trip", trip.text);
|
|
4392
|
+
lines.push("");
|
|
4393
|
+
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.`);
|
|
4394
|
+
return lines;
|
|
4395
|
+
}
|
|
4396
|
+
function describeSaver(state, holder, live) {
|
|
4397
|
+
if (state === "listening") {
|
|
4398
|
+
if (!holder)
|
|
4399
|
+
return { tone: "warn", text: "listening, from a process that isn't reporting. Restart it: killall legacyScreenSaver" };
|
|
4400
|
+
if (holder.saverViews === 0) {
|
|
4401
|
+
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` };
|
|
4402
|
+
}
|
|
4403
|
+
return { tone: "ok", text: `listening, pid ${holder.pid}, on screen` };
|
|
4404
|
+
}
|
|
4405
|
+
if (state === "stale")
|
|
4406
|
+
return { tone: "info", text: "not running (a socket file was left behind, which is harmless)" };
|
|
4407
|
+
if (live.some((status) => status.previewViews > 0)) {
|
|
4408
|
+
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" };
|
|
4409
|
+
}
|
|
4410
|
+
return { tone: "info", text: "not running. That's normal: it listens only while it's on screen" };
|
|
4411
|
+
}
|
|
4412
|
+
function describeProcess(status, now) {
|
|
4413
|
+
const what = [
|
|
4414
|
+
status.saverViews > 0 ? `saver on ${status.saverViews} display${status.saverViews === 1 ? "" : "s"}` : void 0,
|
|
4415
|
+
status.previewViews > 0 ? "preview" : void 0
|
|
4416
|
+
].filter(Boolean).join(" + ") || "not drawing";
|
|
4417
|
+
const heard = status.lastSignalAt ? `last signal ${status.lastSignalEvent ?? ""} ${(0, hookRunner_1.describeAge)(now - Date.parse(status.lastSignalAt))}`.replace(/\s+/g, " ") : "no signal yet";
|
|
4418
|
+
const replay = status.replayed > 0 ? `, replayed ${status.replayed} since this process started` : "";
|
|
4419
|
+
const beat = status.ageMs > 1e4 ? `, heartbeat ${(0, hookRunner_1.describeAge)(status.ageMs)} (not animating)` : "";
|
|
4420
|
+
return `pid ${status.pid} ${status.version ?? ""}: ${what}, ${status.mode ?? "?"}${status.ownsBus ? ", owns the socket" : ""}, ${heard}${replay}${beat}`.replace(/\s+:/, ":");
|
|
4421
|
+
}
|
|
4422
|
+
async function pingRoundTrip(saverSocket, selfCommand) {
|
|
4423
|
+
const session = `doctor-${process.pid}-${Date.now()}`;
|
|
4424
|
+
const accepted = await (0, liveBus_1.deliverLine)(`${JSON.stringify({ tool: "doctor", session, event: "ping" })}
|
|
4425
|
+
`);
|
|
4426
|
+
if (!accepted) {
|
|
4427
|
+
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` };
|
|
4428
|
+
}
|
|
4429
|
+
if (accepted !== saverSocket)
|
|
4430
|
+
return { tone: "ok", text: `the desktop app took it (${accepted})` };
|
|
4431
|
+
for (let waited = 0; waited < 2e3; waited += 100) {
|
|
4432
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
4433
|
+
const answered = (0, saverHandoff_1.readSaverStatuses)().find((status) => status.lastPingSession === session);
|
|
4434
|
+
if (answered)
|
|
4435
|
+
return { tone: "ok", text: `OK. The screen saver (pid ${answered.pid}) received it` };
|
|
4436
|
+
}
|
|
4437
|
+
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" };
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
});
|
|
4441
|
+
|
|
4442
|
+
// ../packages/tool-kit/out/studyNotices.js
|
|
4443
|
+
var require_studyNotices = __commonJS({
|
|
4444
|
+
"../packages/tool-kit/out/studyNotices.js"(exports) {
|
|
4445
|
+
"use strict";
|
|
4446
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4447
|
+
exports.NOTICED_PURPOSES = void 0;
|
|
4448
|
+
exports.studyNoticeStatus = studyNoticeStatus;
|
|
4449
|
+
exports.renderStudyNotices = renderStudyNotices;
|
|
4450
|
+
exports.runStudyObjection = runStudyObjection;
|
|
4451
|
+
var http_1 = require_http();
|
|
4452
|
+
var READ_TIMEOUT_MS = 5e3;
|
|
4453
|
+
var NOTICE_LABEL = "Counted unless you object";
|
|
4454
|
+
var PROCESSOR = "Ascenda";
|
|
4455
|
+
exports.NOTICED_PURPOSES = [
|
|
4456
|
+
{ code: 501, slug: "telemetry", title: "Live tool telemetry" },
|
|
4457
|
+
{ code: 507, slug: "import", title: "One-time import of past AI work" },
|
|
4458
|
+
{ code: 11, slug: "work-patterns", title: "Work-pattern axes in the group figures" }
|
|
4459
|
+
];
|
|
4460
|
+
var BASIS_WORDS = {
|
|
4461
|
+
legitimate_interests: "legitimate interests",
|
|
4462
|
+
collective_agreement: "a collective agreement"
|
|
4463
|
+
};
|
|
4464
|
+
async function studyNoticeStatus(ctx) {
|
|
4465
|
+
const nothing = { lines: [], markShown: async () => {
|
|
4466
|
+
} };
|
|
4467
|
+
const token = ctx.eventWriteToken;
|
|
4468
|
+
if (!token)
|
|
4469
|
+
return nothing;
|
|
4470
|
+
const read = await (0, http_1.readStudyNotices)(ctx.apiBaseUrl, token, AbortSignal.timeout(ctx.fetchTimeoutMs ?? READ_TIMEOUT_MS));
|
|
4471
|
+
if (read.kind !== "ok")
|
|
4472
|
+
return nothing;
|
|
4473
|
+
const lines = renderStudyNotices(read.notices, ctx.commandPrefix, ctx.now);
|
|
4474
|
+
if (lines.length === 0)
|
|
4475
|
+
return nothing;
|
|
4476
|
+
const unshown = shownPurposes(read.notices).filter((n) => !n.noticeFromUtc && n.organisationId);
|
|
4477
|
+
return {
|
|
4478
|
+
lines,
|
|
4479
|
+
markShown: async () => {
|
|
4480
|
+
const signal = AbortSignal.timeout(ctx.fetchTimeoutMs ?? READ_TIMEOUT_MS);
|
|
4481
|
+
await Promise.all(unshown.map((n) => (0, http_1.markStudyNoticeShown)(ctx.apiBaseUrl, token, n.organisationId, n.code, signal)));
|
|
4482
|
+
}
|
|
4483
|
+
};
|
|
4484
|
+
}
|
|
4485
|
+
function shownPurposes(entries) {
|
|
4486
|
+
return entries.map(asNotice).filter((n) => n !== void 0 && exports.NOTICED_PURPOSES.some((p) => p.code === n.code));
|
|
4487
|
+
}
|
|
4488
|
+
function renderStudyNotices(entries, commandPrefix, now = /* @__PURE__ */ new Date()) {
|
|
4489
|
+
const body = [];
|
|
4490
|
+
let unreadable = 0;
|
|
4491
|
+
for (const entry of entries) {
|
|
4492
|
+
const notice = asNotice(entry);
|
|
4493
|
+
const purpose = notice && exports.NOTICED_PURPOSES.find((p) => p.code === notice.code);
|
|
4494
|
+
if (!notice || !purpose) {
|
|
4495
|
+
unreadable += 1;
|
|
4496
|
+
continue;
|
|
4497
|
+
}
|
|
4498
|
+
body.push(...renderOne(notice, purpose, commandPrefix, now));
|
|
4499
|
+
}
|
|
4500
|
+
if (body.length === 0)
|
|
4501
|
+
return [];
|
|
4502
|
+
if (unreadable > 0) {
|
|
4503
|
+
body.push(` ${unreadable === 1 ? "1 entry" : `${unreadable} entries`} in the list couldn't be read by this version of the tool.`);
|
|
4504
|
+
}
|
|
4505
|
+
return ["", "Your organisation's study", ...body];
|
|
4506
|
+
}
|
|
4507
|
+
function renderOne(notice, purpose, commandPrefix, now) {
|
|
4508
|
+
const org = notice.organisationName;
|
|
4509
|
+
const command = `${commandPrefix} object ${purpose.slug}`;
|
|
4510
|
+
const lines = [` ${org}: ${purpose.title}`];
|
|
4511
|
+
lines.push(` ${notice.label || NOTICE_LABEL}`);
|
|
4512
|
+
lines.push(` ${basisLine(notice)}`);
|
|
4513
|
+
if (notice.signatoryName)
|
|
4514
|
+
lines.push(` Recorded by ${notice.signatoryName}.`);
|
|
4515
|
+
lines.push(` ${notice.processor || PROCESSOR} processes this for ${org}.`);
|
|
4516
|
+
if (notice.objected === true) {
|
|
4517
|
+
lines.push(" You objected. You are left out from the next report on.");
|
|
4518
|
+
lines.push(` To undo: ${command} --undo`);
|
|
4519
|
+
} else if (notice.objected === false) {
|
|
4520
|
+
lines.push(" You haven't objected.");
|
|
4521
|
+
if (notice.noticeFromUtc && isDate(notice.noticeFromUtc)) {
|
|
4522
|
+
const starts = notice.countingFromUtc && isDate(notice.countingFromUtc) ? notice.countingFromUtc : new Date(Date.parse(notice.noticeFromUtc) + NOTICE_PERIOD_MS).toISOString();
|
|
4523
|
+
if (Date.parse(starts) > now.getTime()) {
|
|
4524
|
+
lines.push(` Notice given ${formatDay(notice.noticeFromUtc)}. Counting starts ${formatDay(starts)}.`);
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
lines.push(` To object: ${command}. No reason is asked. You are left out from the next report on, and earlier reports stay as they were.`);
|
|
4528
|
+
} else {
|
|
4529
|
+
lines.push(" This version of the tool couldn't read whether you've objected. Run status again.");
|
|
4530
|
+
lines.push(` To object: ${command}`);
|
|
4531
|
+
lines.push(` To undo: ${command} --undo`);
|
|
4532
|
+
}
|
|
4533
|
+
lines.push("");
|
|
4534
|
+
return lines;
|
|
4535
|
+
}
|
|
4536
|
+
function basisLine(notice) {
|
|
4537
|
+
const words = notice.basisLabel ?? BASIS_WORDS[notice.basis];
|
|
4538
|
+
const head = words ? `${notice.organisationName}'s basis is ${words}.` : `${notice.organisationName}'s basis is one this version of the tool can't name.`;
|
|
4539
|
+
const dated = notice.documentDate && isDate(notice.documentDate) ? formatDay(notice.documentDate) : null;
|
|
4540
|
+
const ref = notice.documentReference ? `ref ${notice.documentReference}` : null;
|
|
4541
|
+
const title = notice.documentTitle ? dated ? `${notice.documentTitle} (${dated})` : notice.documentTitle : null;
|
|
4542
|
+
const document = [title, ref].filter((part) => Boolean(part)).join(", ");
|
|
4543
|
+
return document ? `${head} Document: ${document}.` : head;
|
|
4544
|
+
}
|
|
4545
|
+
var NOTICE_PERIOD_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
4546
|
+
function asNotice(value) {
|
|
4547
|
+
if (!value || typeof value !== "object")
|
|
4548
|
+
return void 0;
|
|
4549
|
+
const o = value;
|
|
4550
|
+
if (typeof o.code !== "number")
|
|
4551
|
+
return void 0;
|
|
4552
|
+
if (typeof o.mode === "string" && o.mode.trim().toLowerCase() !== "notice")
|
|
4553
|
+
return void 0;
|
|
4554
|
+
const str = (x) => typeof x === "string" && x.trim() ? x : null;
|
|
4555
|
+
return {
|
|
4556
|
+
organisationId: str(o.organisationId),
|
|
4557
|
+
organisationName: str(o.organisationName) ?? "Your organisation",
|
|
4558
|
+
code: o.code,
|
|
4559
|
+
name: str(o.name),
|
|
4560
|
+
label: str(o.label),
|
|
4561
|
+
processor: str(o.processor),
|
|
4562
|
+
basis: typeof o.basis === "string" ? o.basis : "",
|
|
4563
|
+
basisLabel: str(o.basisLabel),
|
|
4564
|
+
documentTitle: str(o.documentTitle),
|
|
4565
|
+
documentDate: str(o.documentDate),
|
|
4566
|
+
documentReference: str(o.documentReference),
|
|
4567
|
+
signatoryName: str(o.signatoryName),
|
|
4568
|
+
objected: typeof o.objected === "boolean" ? o.objected : null,
|
|
4569
|
+
objectedAtUtc: str(o.objectedAtUtc),
|
|
4570
|
+
noticeFromUtc: str(o.noticeFromUtc),
|
|
4571
|
+
countingFromUtc: str(o.countingFromUtc)
|
|
4572
|
+
};
|
|
4573
|
+
}
|
|
4574
|
+
async function runStudyObjection(ctx) {
|
|
4575
|
+
const stdin = ctx.stdin ?? process.stdin;
|
|
4576
|
+
const stdout = ctx.stdout ?? process.stdout;
|
|
4577
|
+
const stderr = ctx.stderr ?? process.stderr;
|
|
4578
|
+
const print = (line) => stdout.write(`${line}
|
|
4579
|
+
`);
|
|
4580
|
+
if (!stdin.isTTY || !stdout.isTTY) {
|
|
4581
|
+
stderr.write("object needs an interactive terminal (stdin and stdout). Run it directly, not from a script or a pipe.\n");
|
|
4582
|
+
return 1;
|
|
4583
|
+
}
|
|
4584
|
+
const undo = ctx.argv.includes("--undo");
|
|
4585
|
+
const rest = ctx.argv.filter((a) => a !== "--undo");
|
|
4586
|
+
const purpose = rest.length === 1 ? exports.NOTICED_PURPOSES.find((p) => p.slug === rest[0]) : void 0;
|
|
4587
|
+
if (!purpose) {
|
|
4588
|
+
stderr.write(objectionUsage(ctx.commandPrefix));
|
|
4589
|
+
return 1;
|
|
4590
|
+
}
|
|
4591
|
+
if (!ctx.eventWriteToken) {
|
|
4592
|
+
stderr.write(`This install isn't paired, so there's nothing to object to. Pair with \`${ctx.pairCommand}\`.
|
|
4593
|
+
`);
|
|
4594
|
+
return 1;
|
|
4595
|
+
}
|
|
4596
|
+
const command = `${ctx.commandPrefix} object ${purpose.slug}`;
|
|
4597
|
+
try {
|
|
4598
|
+
await (0, http_1.setStudyObjection)(ctx.apiBaseUrl, ctx.eventWriteToken, purpose.code, !undo);
|
|
4599
|
+
} catch (error2) {
|
|
4600
|
+
stderr.write(`${describeObjectionError(error2, purpose, undo, ctx.pairCommand)}
|
|
4601
|
+
`);
|
|
4602
|
+
return 1;
|
|
4603
|
+
}
|
|
4604
|
+
if (undo) {
|
|
4605
|
+
print(`Objection withdrawn: ${purpose.title}.`);
|
|
4606
|
+
print("You're counted again from the next report.");
|
|
4607
|
+
print(`To object again: ${command}`);
|
|
4608
|
+
} else {
|
|
4609
|
+
print(`Objected: ${purpose.title}.`);
|
|
4610
|
+
print("You objected. You are left out from the next report on, and earlier reports stay as they were.");
|
|
4611
|
+
print(`To undo: ${command} --undo`);
|
|
4612
|
+
}
|
|
4613
|
+
return 0;
|
|
4614
|
+
}
|
|
4615
|
+
function objectionUsage(commandPrefix) {
|
|
4616
|
+
const lines = [`Usage: ${commandPrefix} object <purpose> [--undo]`, "", "Purposes:"];
|
|
4617
|
+
for (const p of exports.NOTICED_PURPOSES)
|
|
4618
|
+
lines.push(` ${p.slug.padEnd(14)}${p.title}`);
|
|
4619
|
+
lines.push("", "status shows which of these your organisation counts unless you object.");
|
|
4620
|
+
return `${lines.join("\n")}
|
|
4621
|
+
`;
|
|
4622
|
+
}
|
|
4623
|
+
function describeObjectionError(error2, purpose, undo, pairCommand) {
|
|
4624
|
+
if (error2 instanceof http_1.AscendaApiError) {
|
|
4625
|
+
if (error2.status === 404 && error2.errorCode === "not_noticed") {
|
|
4626
|
+
return undo ? `Your organisation doesn't count you for ${purpose.title} unless you object, so there's no objection to undo.` : `Your organisation doesn't count you for ${purpose.title} unless you object, so there's nothing to object to.`;
|
|
4627
|
+
}
|
|
4628
|
+
if (error2.status === 401)
|
|
4629
|
+
return `The server turned this install's request down. If that keeps happening, pair again with \`${pairCommand}\`.`;
|
|
4630
|
+
if (error2.status === 404)
|
|
4631
|
+
return "This server doesn't take objections yet. Nothing changed.";
|
|
4632
|
+
return `Couldn't record that (HTTP ${error2.status}). Nothing changed. Run it again to retry.`;
|
|
4633
|
+
}
|
|
4634
|
+
return "Couldn't reach the server. Nothing changed. Run it again to retry.";
|
|
4635
|
+
}
|
|
4636
|
+
function isDate(iso) {
|
|
4637
|
+
return !Number.isNaN(Date.parse(iso));
|
|
4638
|
+
}
|
|
4639
|
+
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
4640
|
+
function formatDay(iso) {
|
|
4641
|
+
const date3 = new Date(iso);
|
|
4642
|
+
return `${date3.getUTCDate()} ${MONTHS[date3.getUTCMonth()]} ${date3.getUTCFullYear()}`;
|
|
4643
|
+
}
|
|
4644
|
+
}
|
|
4645
|
+
});
|
|
4646
|
+
|
|
4647
|
+
// ../packages/tool-kit/out/cliAgentSetup.js
|
|
4648
|
+
var require_cliAgentSetup = __commonJS({
|
|
4649
|
+
"../packages/tool-kit/out/cliAgentSetup.js"(exports) {
|
|
4650
|
+
"use strict";
|
|
4651
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4652
|
+
if (k2 === void 0) k2 = k;
|
|
4653
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4654
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4655
|
+
desc = { enumerable: true, get: function() {
|
|
4656
|
+
return m[k];
|
|
4657
|
+
} };
|
|
4658
|
+
}
|
|
4659
|
+
Object.defineProperty(o, k2, desc);
|
|
4660
|
+
} : function(o, m, k, k2) {
|
|
4661
|
+
if (k2 === void 0) k2 = k;
|
|
4662
|
+
o[k2] = m[k];
|
|
4663
|
+
});
|
|
4664
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
4665
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
4666
|
+
} : function(o, v) {
|
|
4667
|
+
o["default"] = v;
|
|
4668
|
+
});
|
|
4669
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
4670
|
+
var ownKeys = function(o) {
|
|
4671
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
4672
|
+
var ar = [];
|
|
4673
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
4674
|
+
return ar;
|
|
4675
|
+
};
|
|
4676
|
+
return ownKeys(o);
|
|
4677
|
+
};
|
|
4678
|
+
return function(mod) {
|
|
4679
|
+
if (mod && mod.__esModule) return mod;
|
|
4680
|
+
var result = {};
|
|
4681
|
+
if (mod != null) {
|
|
4682
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
4683
|
+
}
|
|
4684
|
+
__setModuleDefault(result, mod);
|
|
4685
|
+
return result;
|
|
4686
|
+
};
|
|
4687
|
+
}();
|
|
4688
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4689
|
+
exports.isCliAgentManagementCommand = isCliAgentManagementCommand;
|
|
4690
|
+
exports.cliAgentHookBinPath = cliAgentHookBinPath;
|
|
4691
|
+
exports.cliAgentSelfCommand = cliAgentSelfCommand;
|
|
4692
|
+
exports.runCliAgentSetup = runCliAgentSetup;
|
|
4693
|
+
exports.writeHookSettings = writeHookSettings;
|
|
4694
|
+
exports.registeredHookSets = registeredHookSets;
|
|
4695
|
+
exports.findStaleHookCommands = findStaleHookCommands;
|
|
4696
|
+
exports.cliAgentRegistrations = cliAgentRegistrations;
|
|
4697
|
+
var crypto = __importStar(__require("crypto"));
|
|
4698
|
+
var fs = __importStar(__require("fs"));
|
|
4699
|
+
var os = __importStar(__require("os"));
|
|
4700
|
+
var path = __importStar(__require("path"));
|
|
4701
|
+
var collectorVersion_1 = require_collectorVersion();
|
|
4702
|
+
var credentials_1 = require_credentials();
|
|
4703
|
+
var hookAdapter_1 = require_hookAdapter();
|
|
4704
|
+
var http_1 = require_http();
|
|
4705
|
+
var hookSet_1 = require_hookSet();
|
|
4706
|
+
var initiatives_1 = require_initiatives();
|
|
4707
|
+
var setupDisclosure_1 = require_setupDisclosure();
|
|
4708
|
+
var hookRunner_1 = require_hookRunner();
|
|
4709
|
+
var liveSignalDoctor_1 = require_liveSignalDoctor();
|
|
4710
|
+
var stateStore_1 = require_stateStore();
|
|
4711
|
+
var studyJoin_1 = require_studyJoin();
|
|
4712
|
+
var studyNotices_1 = require_studyNotices();
|
|
4713
|
+
var terminalStyle_1 = require_terminalStyle();
|
|
4714
|
+
var tokenStore_1 = require_tokenStore();
|
|
4715
|
+
var MANAGEMENT_COMMANDS = /* @__PURE__ */ new Set(["setup", "install", "status", "uninstall", "doctor", "join", "object", "-h", "--help"]);
|
|
4716
|
+
function isCliAgentManagementCommand(argument) {
|
|
4717
|
+
return argument !== void 0 && MANAGEMENT_COMMANDS.has(argument);
|
|
4718
|
+
}
|
|
4719
|
+
function cliAgentHookBinPath(binaryName) {
|
|
4720
|
+
return (0, hookRunner_1.hookRunnerPaths)(binaryName).launcher;
|
|
4721
|
+
}
|
|
4722
|
+
function cliAgentSelfCommand(spec) {
|
|
4723
|
+
return process.platform === "win32" ? `npx ${spec.packageName}` : (0, hookRunner_1.tidyHomePath)(cliAgentHookBinPath(spec.binaryName), os.homedir());
|
|
4724
|
+
}
|
|
4725
|
+
function usage(spec) {
|
|
4726
|
+
return `${spec.binaryName} setup \u2014 wire ${spec.displayName} to Ascenda telemetry
|
|
4727
|
+
|
|
4728
|
+
npx ${spec.packageName} setup [options]
|
|
4729
|
+
npx ${spec.packageName} status
|
|
4730
|
+
npx ${spec.packageName} doctor
|
|
4731
|
+
npx ${spec.packageName} uninstall
|
|
4732
|
+
npx ${spec.packageName} join <code>
|
|
4733
|
+
npx ${spec.packageName} object <purpose> [--undo]
|
|
4734
|
+
|
|
4735
|
+
Options
|
|
4736
|
+
--api-base-url <url> ingest host (default ${hookAdapter_1.DEFAULT_API_BASE_URL})
|
|
4737
|
+
--local [port] shorthand for the local dev server (default port 4477)
|
|
4738
|
+
--tool-installation-id <id> reuse an existing pairing instead of creating one
|
|
4739
|
+
--token <eventWriteToken> reuse an existing token (stored 0600, never printed)
|
|
4740
|
+
--no-pair install without pairing: local features on, nothing sent
|
|
4741
|
+
--scope user|project where hooks are registered (default user: every project)
|
|
4742
|
+
--project-dir <path> project root for --scope project (default cwd)
|
|
4743
|
+
--dry-run print what would change, write nothing
|
|
4744
|
+
-h, --help
|
|
3104
4745
|
`;
|
|
3105
4746
|
}
|
|
3106
4747
|
async function runCliAgentSetup(argv, spec) {
|
|
4748
|
+
if (argv[0] === "join")
|
|
4749
|
+
return runCliAgentStudyJoin(argv.slice(1), spec);
|
|
4750
|
+
if (argv[0] === "object")
|
|
4751
|
+
return runCliAgentStudyObjection(argv.slice(1), spec);
|
|
3107
4752
|
let options;
|
|
3108
4753
|
try {
|
|
3109
4754
|
options = parseArgs(argv, spec);
|
|
@@ -3116,32 +4761,29 @@ Options
|
|
|
3116
4761
|
return 0;
|
|
3117
4762
|
}
|
|
3118
4763
|
if (options.action === "status")
|
|
3119
|
-
return printStatus(options, spec);
|
|
4764
|
+
return await printStatus(options, spec);
|
|
3120
4765
|
if (options.action === "uninstall")
|
|
3121
4766
|
return uninstall(options, spec);
|
|
4767
|
+
if (options.action === "doctor")
|
|
4768
|
+
return await runDoctor(options, spec);
|
|
3122
4769
|
const apiBaseUrl = (options.apiBaseUrl ?? (0, credentials_1.readHostCredentials)(spec.host)?.apiBaseUrl ?? hookAdapter_1.DEFAULT_API_BASE_URL).replace(/\/$/, "");
|
|
3123
|
-
|
|
3124
|
-
console.log(`
|
|
3125
|
-
|
|
3126
|
-
`);
|
|
4770
|
+
const ui = (0, terminalStyle_1.terminalStyle)();
|
|
4771
|
+
const row = (tone, label, value) => console.log(` ${ui.mark(tone)} ${label.padEnd(12)} ${value}`);
|
|
4772
|
+
const detail = (label, value) => console.log(ui.dim(` ${label.padEnd(12)} ${value}`));
|
|
4773
|
+
console.log(`${ui.bold("Ascenda setup")} ${ui.dim(`\xB7 ${spec.displayName} \xB7 ${apiBaseUrl}`)}`);
|
|
4774
|
+
if (!options.skipPairing)
|
|
4775
|
+
console.log(`
|
|
4776
|
+
${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName: spec.displayName })}`);
|
|
4777
|
+
console.log("");
|
|
3127
4778
|
let identity;
|
|
3128
|
-
|
|
3129
|
-
if (options.skipPairing) {
|
|
3130
|
-
unpairedReason = "asked not to pair (--no-pair)";
|
|
3131
|
-
} else {
|
|
4779
|
+
if (!options.skipPairing)
|
|
3132
4780
|
identity = await resolveIdentity(apiBaseUrl, options, spec);
|
|
3133
|
-
if (identity) {
|
|
3134
|
-
console.log(` pairing ${identity.toolInstallationId}${identity.paired ? " (new)" : " (existing)"}`);
|
|
3135
|
-
} else {
|
|
3136
|
-
unpairedReason = "pairing did not finish \u2014 installing the local half anyway";
|
|
3137
|
-
}
|
|
3138
|
-
}
|
|
3139
|
-
if (unpairedReason) {
|
|
3140
|
-
console.log(` pairing none: ${unpairedReason}`);
|
|
3141
|
-
console.log(" local features on, nothing is sent");
|
|
3142
|
-
}
|
|
3143
4781
|
const binary = installBinary(spec, options.dryRun);
|
|
3144
|
-
|
|
4782
|
+
const node = options.dryRun || process.platform === "win32" ? void 0 : (0, hookRunner_1.resolveHookNode)(binary);
|
|
4783
|
+
if (node?.problem)
|
|
4784
|
+
row("bad", "hook binary", `${(0, hookRunner_1.tidyHomePath)(binary, os.homedir())}, but ${node.problem}. Install Node 20 or newer, then run setup again`);
|
|
4785
|
+
else
|
|
4786
|
+
row("ok", "hook binary", `${(0, hookRunner_1.tidyHomePath)(binary, os.homedir())}${node?.version ? ui.dim(` (Node ${node.version})`) : ""}`);
|
|
3145
4787
|
if (!options.dryRun) {
|
|
3146
4788
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3147
4789
|
const toolInstallationId = identity?.toolInstallationId ?? options.toolInstallationId ?? (0, credentials_1.readHostCredentials)(spec.host)?.toolInstallationId ?? `${spec.toolType}:${crypto.randomUUID()}`;
|
|
@@ -3151,27 +4793,76 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
|
|
|
3151
4793
|
...identity ? { pairedAt: now } : { localOnly: true, installedAt: now }
|
|
3152
4794
|
});
|
|
3153
4795
|
}
|
|
3154
|
-
|
|
4796
|
+
if (isHomeProject(options)) {
|
|
4797
|
+
detail("scope", "user (a project install in the home folder only loads when the agent starts there)");
|
|
4798
|
+
options.scope = "user";
|
|
4799
|
+
}
|
|
3155
4800
|
const settingsFile = spec.settings.settingsPath(options.scope, options.projectDir);
|
|
4801
|
+
const before = registeredHookSets(readSettings(settingsFile), spec);
|
|
3156
4802
|
const written = writeHookSettings(settingsFile, binary, spec, options.dryRun);
|
|
3157
4803
|
if (written === null)
|
|
3158
4804
|
return 1;
|
|
3159
|
-
|
|
4805
|
+
const reach = options.scope === "user" ? "every project" : "this project only";
|
|
4806
|
+
row("ok", "hooks", `${(0, hookRunner_1.tidyHomePath)(settingsFile, os.homedir())} ${ui.dim(`(${spec.hookEvents.length} events, ${reach}${written ? "" : ", already current"})`)}`);
|
|
4807
|
+
const changes = spec.hookSet === void 0 ? void 0 : (0, hookSet_1.describeHookSetChanges)((0, hookSet_1.hookSetChanges)(before, spec.hookEvents), spec.hookSet);
|
|
4808
|
+
if (changes)
|
|
4809
|
+
detail("", changes);
|
|
4810
|
+
const otherFile = spec.settings.settingsPath(options.scope === "user" ? "project" : "user", options.projectDir);
|
|
4811
|
+
if (otherFile !== settingsFile && registeredHookSets(readSettings(otherFile), spec).size > 0) {
|
|
4812
|
+
if (options.dryRun) {
|
|
4813
|
+
row("info", "moved", `would remove the copy in ${(0, hookRunner_1.tidyHomePath)(otherFile, os.homedir())}, so each event runs once`);
|
|
4814
|
+
} else if (removeOurHookEntries(otherFile, spec)) {
|
|
4815
|
+
row("ok", "moved", `removed the copy in ${(0, hookRunner_1.tidyHomePath)(otherFile, os.homedir())}, so each event runs once ${ui.dim("(backup beside it)")}`);
|
|
4816
|
+
} else {
|
|
4817
|
+
row("warn", "note", `${(0, hookRunner_1.tidyHomePath)(otherFile, os.homedir())} registers these hooks too, so each event runs twice.`);
|
|
4818
|
+
detail("", `Remove the ${spec.binaryName} entries from one of the two files.`);
|
|
4819
|
+
}
|
|
4820
|
+
}
|
|
4821
|
+
const chosenLocal = options.skipPairing;
|
|
4822
|
+
if (identity)
|
|
4823
|
+
row("ok", "pairing", `${identity.toolInstallationId}${ui.dim(identity.paired ? " (new)" : " (existing)")}`);
|
|
4824
|
+
else if (chosenLocal)
|
|
4825
|
+
row("info", "pairing", `none, as asked ${ui.dim("(--no-pair)")}`);
|
|
4826
|
+
else
|
|
4827
|
+
row("warn", "pairing", "not paired: pairing did not finish");
|
|
4828
|
+
detail("credentials", `${(0, hookRunner_1.tidyHomePath)((0, credentials_1.credentialsFilePath)(), os.homedir())} (tools.${spec.host})`);
|
|
3160
4829
|
if (options.dryRun) {
|
|
3161
|
-
console.log("\nDry run
|
|
4830
|
+
console.log("\nDry run. Nothing was written.");
|
|
3162
4831
|
return 0;
|
|
3163
4832
|
}
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
4833
|
+
const self = cliAgentSelfCommand(spec);
|
|
4834
|
+
const next = (label, value) => console.log(` ${ui.bold(label.padEnd(6))} ${value}`);
|
|
4835
|
+
console.log("");
|
|
4836
|
+
if (chosenLocal) {
|
|
4837
|
+
console.log(`${ui.mark("ok")} ${ui.bold("Ready.")} The screen saver and the Ascenda app's live view work now.`);
|
|
4838
|
+
console.log(" They run on this machine and need no account or pairing.");
|
|
4839
|
+
} else if (!identity) {
|
|
4840
|
+
console.log(`${ui.mark("warn")} ${ui.bold("Installed, not paired.")} The screen saver and the live view work now.`);
|
|
4841
|
+
console.log(" Your sessions won't reach Ascenda's servers until pairing completes.");
|
|
4842
|
+
} else {
|
|
4843
|
+
console.log(`${ui.mark("ok")} ${ui.bold("Done.")} Paired, and the hooks are installed.`);
|
|
4844
|
+
}
|
|
4845
|
+
console.log("");
|
|
4846
|
+
next("Next", spec.restartHint);
|
|
4847
|
+
next("Check", ui.cyan(`${self} doctor`));
|
|
4848
|
+
if (!identity)
|
|
4849
|
+
next(chosenLocal ? "Pair" : "Retry", `${ui.cyan(`${self} setup`)}${chosenLocal ? ui.dim(" (optional)") : ""}`);
|
|
4850
|
+
if (chosenLocal) {
|
|
4851
|
+
console.log("");
|
|
4852
|
+
console.log(ui.dim(" Pairing sends the details below to Ascenda's servers, under the account the"));
|
|
4853
|
+
console.log(ui.dim(" Ascenda app is signed in to when you confirm the code, so your sessions appear"));
|
|
4854
|
+
console.log(ui.dim(" in the app. Until you pair, nothing leaves this machine."));
|
|
4855
|
+
console.log("");
|
|
4856
|
+
console.log(ui.dim((0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName: spec.displayName }).split("\n").map((line) => ` ${line}`).join("\n")));
|
|
3168
4857
|
}
|
|
3169
|
-
console.log(`Check anytime: npx ${spec.packageName} status`);
|
|
3170
4858
|
return 0;
|
|
3171
4859
|
}
|
|
4860
|
+
function isHomeProject(options) {
|
|
4861
|
+
return options.scope === "project" && path.resolve(options.projectDir) === path.resolve(os.homedir());
|
|
4862
|
+
}
|
|
3172
4863
|
function parseArgs(argv, spec) {
|
|
3173
4864
|
const options = {
|
|
3174
|
-
scope: "
|
|
4865
|
+
scope: "user",
|
|
3175
4866
|
projectDir: process.cwd(),
|
|
3176
4867
|
dryRun: false,
|
|
3177
4868
|
skipPairing: false,
|
|
@@ -3196,6 +4887,9 @@ Done. ${spec.restartHint}`);
|
|
|
3196
4887
|
case "uninstall":
|
|
3197
4888
|
options.action = "uninstall";
|
|
3198
4889
|
break;
|
|
4890
|
+
case "doctor":
|
|
4891
|
+
options.action = "doctor";
|
|
4892
|
+
break;
|
|
3199
4893
|
case "--api-base-url":
|
|
3200
4894
|
options.apiBaseUrl = next();
|
|
3201
4895
|
break;
|
|
@@ -3244,6 +4938,45 @@ ${usage(spec)}`);
|
|
|
3244
4938
|
}
|
|
3245
4939
|
return options;
|
|
3246
4940
|
}
|
|
4941
|
+
async function runCliAgentStudyJoin(argv, spec) {
|
|
4942
|
+
const joinCode = argv[0];
|
|
4943
|
+
if (!joinCode || joinCode.startsWith("-")) {
|
|
4944
|
+
console.error(`Usage: npx ${spec.packageName} join <code>`);
|
|
4945
|
+
return 1;
|
|
4946
|
+
}
|
|
4947
|
+
const pairing = resolvePairedToken(spec);
|
|
4948
|
+
if (!pairing)
|
|
4949
|
+
return 1;
|
|
4950
|
+
return (0, studyJoin_1.runStudyJoin)({ ...pairing, displayName: spec.displayName, joinCode });
|
|
4951
|
+
}
|
|
4952
|
+
async function runCliAgentStudyObjection(argv, spec) {
|
|
4953
|
+
const pairing = resolvePairedToken(spec);
|
|
4954
|
+
if (!pairing)
|
|
4955
|
+
return 1;
|
|
4956
|
+
return (0, studyNotices_1.runStudyObjection)({
|
|
4957
|
+
...pairing,
|
|
4958
|
+
commandPrefix: `npx ${spec.packageName}`,
|
|
4959
|
+
pairCommand: `npx ${spec.packageName} setup`,
|
|
4960
|
+
argv
|
|
4961
|
+
});
|
|
4962
|
+
}
|
|
4963
|
+
function resolvePairedToken(spec) {
|
|
4964
|
+
const setupCommand = `npx ${spec.packageName} setup`;
|
|
4965
|
+
let toolInstallationId;
|
|
4966
|
+
try {
|
|
4967
|
+
({ toolInstallationId } = (0, hookAdapter_1.resolveCliAgentInstallationId)(spec.toolType, { host: spec.host, setupCommand }));
|
|
4968
|
+
} catch (error2) {
|
|
4969
|
+
console.error(error2 instanceof hookAdapter_1.MissingInstallationIdError ? error2.message : error2 instanceof Error ? error2.message : String(error2));
|
|
4970
|
+
return void 0;
|
|
4971
|
+
}
|
|
4972
|
+
const eventWriteToken = (0, tokenStore_1.readTokenFile)(process.env.ASCENDA_EVENT_WRITE_TOKEN_FILE ?? (0, tokenStore_1.defaultTokenFilePath)(toolInstallationId)) ?? process.env.ASCENDA_EVENT_WRITE_TOKEN;
|
|
4973
|
+
if (!eventWriteToken) {
|
|
4974
|
+
console.error(`Not paired: no write token for ${toolInstallationId}. Run: ${setupCommand}`);
|
|
4975
|
+
return void 0;
|
|
4976
|
+
}
|
|
4977
|
+
const apiBaseUrl = (process.env.ASCENDA_API_BASE_URL ?? (0, credentials_1.readHostCredentials)(spec.host)?.apiBaseUrl ?? hookAdapter_1.DEFAULT_API_BASE_URL).replace(/\/$/, "");
|
|
4978
|
+
return { apiBaseUrl, eventWriteToken };
|
|
4979
|
+
}
|
|
3247
4980
|
async function resolveIdentity(apiBaseUrl, options, spec) {
|
|
3248
4981
|
const existingId = options.toolInstallationId ?? (0, credentials_1.readHostCredentials)(spec.host)?.toolInstallationId;
|
|
3249
4982
|
if (existingId && options.token) {
|
|
@@ -3251,8 +4984,13 @@ ${usage(spec)}`);
|
|
|
3251
4984
|
(0, tokenStore_1.persistEventWriteToken)((0, tokenStore_1.defaultTokenFilePath)(existingId), options.token);
|
|
3252
4985
|
return { toolInstallationId: existingId, paired: false };
|
|
3253
4986
|
}
|
|
3254
|
-
|
|
3255
|
-
|
|
4987
|
+
const existingToken = existingId ? (0, tokenStore_1.readTokenFile)((0, tokenStore_1.defaultTokenFilePath)(existingId)) : void 0;
|
|
4988
|
+
if (existingId && existingToken) {
|
|
4989
|
+
const check2 = await checkSavedToken(apiBaseUrl, existingId, existingToken);
|
|
4990
|
+
if (check2 === "keep")
|
|
4991
|
+
return { toolInstallationId: existingId, paired: false };
|
|
4992
|
+
console.log(`
|
|
4993
|
+
The saved token for ${existingId} isn't accepted any more. Pairing again.`);
|
|
3256
4994
|
}
|
|
3257
4995
|
if (options.dryRun) {
|
|
3258
4996
|
return { toolInstallationId: existingId ?? `${spec.toolType}:<paired at run time>`, paired: false };
|
|
@@ -3273,6 +5011,18 @@ Could not reach ${apiBaseUrl} to pair: ${error2 instanceof Error ? error2.messag
|
|
|
3273
5011
|
(0, tokenStore_1.persistEventWriteToken)((0, tokenStore_1.defaultTokenFilePath)(toolInstallationId), token);
|
|
3274
5012
|
return { toolInstallationId, paired: true };
|
|
3275
5013
|
}
|
|
5014
|
+
var TOKEN_CHECK_TIMEOUT_MS = 5e3;
|
|
5015
|
+
async function checkSavedToken(apiBaseUrl, toolInstallationId, token) {
|
|
5016
|
+
const read = await (0, http_1.readInitiatives)(apiBaseUrl, token, AbortSignal.timeout(TOKEN_CHECK_TIMEOUT_MS));
|
|
5017
|
+
if (read.kind === "rejected")
|
|
5018
|
+
return "repair";
|
|
5019
|
+
if (read.kind === "failed" && (0, stateStore_1.readCollectorState)((0, stateStore_1.defaultStateFilePath)(toolInstallationId))?.lastOutcome === "auth_failed") {
|
|
5020
|
+
console.log(`
|
|
5021
|
+
Couldn't check the saved token (${read.reason}), and the last send was refused.`);
|
|
5022
|
+
console.log(" Keeping it for now. Run setup again once the server is reachable.");
|
|
5023
|
+
}
|
|
5024
|
+
return "keep";
|
|
5025
|
+
}
|
|
3276
5026
|
async function pollForToken(apiBaseUrl, pairingSessionId, code, expiresAt) {
|
|
3277
5027
|
const deadline = Math.min(Date.parse(expiresAt) || Date.now() + 3e5, Date.now() + 3e5);
|
|
3278
5028
|
let announced = false;
|
|
@@ -3297,17 +5047,7 @@ Pairing ${status.status}. Run setup again.`);
|
|
|
3297
5047
|
return void 0;
|
|
3298
5048
|
}
|
|
3299
5049
|
function installBinary(spec, dryRun) {
|
|
3300
|
-
|
|
3301
|
-
if (dryRun)
|
|
3302
|
-
return target;
|
|
3303
|
-
const source = process.argv[1];
|
|
3304
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
3305
|
-
if (path.resolve(source) !== path.resolve(target)) {
|
|
3306
|
-
fs.copyFileSync(source, target);
|
|
3307
|
-
}
|
|
3308
|
-
if (process.platform !== "win32")
|
|
3309
|
-
fs.chmodSync(target, 493);
|
|
3310
|
-
return target;
|
|
5050
|
+
return (0, hookRunner_1.installHookRunner)({ binaryName: spec.binaryName, setupCommand: `npx ${spec.packageName} setup`, dryRun });
|
|
3311
5051
|
}
|
|
3312
5052
|
function writeHookSettings(settingsFile, binary, spec, dryRun) {
|
|
3313
5053
|
let settings = { ...spec.settings.scaffold ?? {} };
|
|
@@ -3324,7 +5064,7 @@ ${settingsFile} is not valid JSON. Fix or move it, then run setup again.`);
|
|
|
3324
5064
|
}
|
|
3325
5065
|
}
|
|
3326
5066
|
}
|
|
3327
|
-
const command = hookCommand(binary);
|
|
5067
|
+
const command = hookCommand(binary, spec);
|
|
3328
5068
|
const hooks = { ...settings.hooks ?? {} };
|
|
3329
5069
|
for (const event of spec.hookEvents) {
|
|
3330
5070
|
const kept = (hooks[event] ?? []).filter((entry) => !isOurs(entry, spec));
|
|
@@ -3347,8 +5087,20 @@ ${serialised}`);
|
|
|
3347
5087
|
fs.writeFileSync(settingsFile, serialised, "utf8");
|
|
3348
5088
|
return true;
|
|
3349
5089
|
}
|
|
3350
|
-
function hookCommand(binary) {
|
|
3351
|
-
return
|
|
5090
|
+
function hookCommand(binary, spec) {
|
|
5091
|
+
return `${(0, hookRunner_1.hookRunnerCommand)(binary)}${(0, hookSet_1.hookSetArgument)(spec.hookSet)}`;
|
|
5092
|
+
}
|
|
5093
|
+
function registeredHookSets(settings, spec) {
|
|
5094
|
+
const sets = /* @__PURE__ */ new Map();
|
|
5095
|
+
for (const [event, entries] of Object.entries(settings.hooks ?? {})) {
|
|
5096
|
+
for (const entry of entries ?? []) {
|
|
5097
|
+
if (!isOurs(entry, spec))
|
|
5098
|
+
continue;
|
|
5099
|
+
const set = (0, hookSet_1.hookSetOfCommand)(spec.settings.commandOf(entry));
|
|
5100
|
+
sets.set(event, Math.min(set, sets.get(event) ?? set));
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
return sets;
|
|
3352
5104
|
}
|
|
3353
5105
|
function isOurs(entry, spec) {
|
|
3354
5106
|
const command = spec.settings.commandOf(entry);
|
|
@@ -3375,7 +5127,7 @@ ${serialised}`);
|
|
|
3375
5127
|
return {};
|
|
3376
5128
|
}
|
|
3377
5129
|
}
|
|
3378
|
-
function printStatus(options, spec) {
|
|
5130
|
+
async function printStatus(options, spec) {
|
|
3379
5131
|
const credentials = (0, credentials_1.readHostCredentials)(spec.host);
|
|
3380
5132
|
const settingsFile = spec.settings.settingsPath(options.scope, options.projectDir);
|
|
3381
5133
|
const binary = cliAgentHookBinPath(spec.binaryName);
|
|
@@ -3389,46 +5141,153 @@ ${serialised}`);
|
|
|
3389
5141
|
console.log(`pairing ${credentials?.toolInstallationId ?? "\u2014 not paired"}${localOnly ? " (installed, not paired \u2014 local features active, telemetry inactive)" : ""}`);
|
|
3390
5142
|
console.log(`token ${localOnly ? "\u2014 none needed until this install is paired" : tokenFile && (0, tokenStore_1.readTokenFile)(tokenFile) ? "present" : "\u2014 missing"}`);
|
|
3391
5143
|
console.log(`hook binary ${fs.existsSync(binary) ? binary : "\u2014 not installed"}`);
|
|
5144
|
+
const node = process.platform === "win32" ? void 0 : (0, hookRunner_1.resolveHookNode)(binary);
|
|
5145
|
+
if (node) {
|
|
5146
|
+
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"})`);
|
|
5147
|
+
}
|
|
5148
|
+
const last = (0, hookRunner_1.readLastHook)(spec.host);
|
|
5149
|
+
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)`);
|
|
3392
5150
|
console.log(`hooks ${registered}/${spec.hookEvents.length} registered in ${settingsFile}`);
|
|
5151
|
+
const otherScope = options.scope === "user" ? "project" : "user";
|
|
5152
|
+
const otherFile = spec.settings.settingsPath(otherScope, options.projectDir);
|
|
5153
|
+
const elsewhere = registered === 0 && otherFile !== settingsFile ? countRegistered(readSettings(otherFile), spec) : 0;
|
|
5154
|
+
if (elsewhere > 0)
|
|
5155
|
+
console.log(` ${elsewhere}/${spec.hookEvents.length} found in ${otherFile} (--scope ${otherScope})`);
|
|
5156
|
+
if (spec.hookSet !== void 0 && registered > 0) {
|
|
5157
|
+
const sets = [...registeredHookSets(settings, spec).values()];
|
|
5158
|
+
const oldest = Math.min(...sets);
|
|
5159
|
+
console.log(oldest < spec.hookSet ? `hook set ${oldest}, this version registers ${spec.hookSet}. Upgrade: npx ${spec.packageName} setup${options.scope === "user" ? " --scope user" : ""}` : `hook set ${spec.hookSet} (current)`);
|
|
5160
|
+
}
|
|
3393
5161
|
if (stale.length) {
|
|
3394
5162
|
console.log(`stale hooks ${stale.length} not pointing at the installed binary \u2014 each one fails silently per event:`);
|
|
3395
5163
|
for (const command of stale)
|
|
3396
5164
|
console.log(` ${command}`);
|
|
3397
5165
|
console.log(` Remove them from ${settingsFile} by hand; setup cannot tell them from a hook you wrote.`);
|
|
3398
5166
|
}
|
|
5167
|
+
const tokenValue = localOnly ? void 0 : (tokenFile ? (0, tokenStore_1.readTokenFile)(tokenFile) : void 0) ?? (process.env.ASCENDA_EVENT_WRITE_TOKEN?.trim() || void 0);
|
|
5168
|
+
const apiBaseUrl = (process.env.ASCENDA_API_BASE_URL ?? credentials?.apiBaseUrl ?? hookAdapter_1.DEFAULT_API_BASE_URL).replace(/\/$/, "");
|
|
5169
|
+
const [initiativeLines, notices] = await Promise.all([
|
|
5170
|
+
(0, initiatives_1.initiativesStatusLines)({ apiBaseUrl, eventWriteToken: tokenValue, pairCommand: `npx ${spec.packageName} setup` }),
|
|
5171
|
+
(0, studyNotices_1.studyNoticeStatus)({ apiBaseUrl, eventWriteToken: tokenValue, commandPrefix: `npx ${spec.packageName}` })
|
|
5172
|
+
]);
|
|
5173
|
+
console.log("");
|
|
5174
|
+
for (const line of initiativeLines)
|
|
5175
|
+
console.log(line);
|
|
5176
|
+
for (const line of notices.lines)
|
|
5177
|
+
console.log(line);
|
|
5178
|
+
if (process.stdout.isTTY)
|
|
5179
|
+
await notices.markShown();
|
|
3399
5180
|
const paired = localOnly || credentials?.toolInstallationId !== void 0;
|
|
3400
|
-
const
|
|
5181
|
+
const wired = registered === spec.hookEvents.length || options.scope === "project" && elsewhere === spec.hookEvents.length;
|
|
5182
|
+
const healthy = paired && wired && fs.existsSync(binary) && !stale.length && !node?.problem;
|
|
3401
5183
|
return healthy ? 0 : 1;
|
|
3402
5184
|
}
|
|
5185
|
+
function countRegistered(settings, spec) {
|
|
5186
|
+
return spec.hookEvents.filter((event) => (settings.hooks?.[event] ?? []).some((entry) => isOurs(entry, spec))).length;
|
|
5187
|
+
}
|
|
5188
|
+
function cliAgentRegistrations(spec, projectDir = process.cwd()) {
|
|
5189
|
+
const home = os.homedir();
|
|
5190
|
+
const userFile = spec.settings.settingsPath("user", projectDir);
|
|
5191
|
+
const projectFile = spec.settings.settingsPath("project", projectDir);
|
|
5192
|
+
const found = [];
|
|
5193
|
+
for (const [scope, file] of [["user", userFile], ["project", projectFile]]) {
|
|
5194
|
+
if (scope === "project" && file === userFile)
|
|
5195
|
+
continue;
|
|
5196
|
+
const registered = countRegistered(readSettings(file), spec);
|
|
5197
|
+
if (registered === 0)
|
|
5198
|
+
continue;
|
|
5199
|
+
found.push({
|
|
5200
|
+
file: (0, hookRunner_1.tidyHomePath)(file, home),
|
|
5201
|
+
registered,
|
|
5202
|
+
scope,
|
|
5203
|
+
homeProject: scope === "project" && path.resolve(projectDir) === path.resolve(home)
|
|
5204
|
+
});
|
|
5205
|
+
}
|
|
5206
|
+
return found;
|
|
5207
|
+
}
|
|
5208
|
+
async function runDoctor(options, spec) {
|
|
5209
|
+
const ui = (0, terminalStyle_1.terminalStyle)();
|
|
5210
|
+
const lines = [`${ui.bold("Ascenda doctor")} ${ui.dim(`\xB7 ${spec.displayName}`)}`, ""];
|
|
5211
|
+
try {
|
|
5212
|
+
lines.push(...await (0, liveSignalDoctor_1.liveSignalDoctorLines)({
|
|
5213
|
+
displayName: spec.displayName,
|
|
5214
|
+
tool: spec.host,
|
|
5215
|
+
launcher: process.platform === "win32" ? void 0 : cliAgentHookBinPath(spec.binaryName),
|
|
5216
|
+
registrations: cliAgentRegistrations(spec, options.projectDir),
|
|
5217
|
+
eventCount: spec.hookEvents.length,
|
|
5218
|
+
selfCommand: cliAgentSelfCommand(spec),
|
|
5219
|
+
setupCommand: `npx ${spec.packageName} setup`,
|
|
5220
|
+
ui
|
|
5221
|
+
}));
|
|
5222
|
+
} catch (error2) {
|
|
5223
|
+
lines.push(` Live signal (could not be checked: ${error2 instanceof Error ? error2.message : String(error2)})`);
|
|
5224
|
+
}
|
|
5225
|
+
lines.push("", ...accountLines(ui, spec));
|
|
5226
|
+
console.log(lines.join("\n"));
|
|
5227
|
+
return 0;
|
|
5228
|
+
}
|
|
5229
|
+
function accountLines(ui, spec) {
|
|
5230
|
+
const credentials = (0, credentials_1.readHostCredentials)(spec.host);
|
|
5231
|
+
const id = credentials?.toolInstallationId;
|
|
5232
|
+
const localOnly = (0, credentials_1.isLocalOnlyHostInstall)(spec.host, (installationId) => (0, tokenStore_1.readTokenFile)((0, tokenStore_1.defaultTokenFilePath)(installationId)) !== void 0);
|
|
5233
|
+
const row = (tone, label, value) => ` ${ui.mark(tone)} ${label.padEnd(20)} ${value}`;
|
|
5234
|
+
if (!id || localOnly) {
|
|
5235
|
+
return [
|
|
5236
|
+
` ${ui.bold("Account sync")} ${ui.dim("(optional; this install isn't paired)")}`,
|
|
5237
|
+
...id ? [ui.dim(row("info", "Installation id", id))] : [],
|
|
5238
|
+
"",
|
|
5239
|
+
" Not paired, which is fine: the screen saver and the live view above work",
|
|
5240
|
+
" without it. Nothing leaves this machine and nothing is queued. To send your",
|
|
5241
|
+
" sessions to Ascenda's servers, so they appear in the app:",
|
|
5242
|
+
` ${ui.cyan(`${cliAgentSelfCommand(spec)} setup`)}`
|
|
5243
|
+
];
|
|
5244
|
+
}
|
|
5245
|
+
const token = (0, tokenStore_1.readTokenFile)((0, tokenStore_1.defaultTokenFilePath)(id)) ?? process.env.ASCENDA_EVENT_WRITE_TOKEN?.trim();
|
|
5246
|
+
const state = (0, stateStore_1.readCollectorState)((0, stateStore_1.defaultStateFilePath)(id));
|
|
5247
|
+
const outcome = state?.lastOutcome;
|
|
5248
|
+
return [
|
|
5249
|
+
` ${ui.bold("Account sync")}`,
|
|
5250
|
+
row("info", "Installation id", id),
|
|
5251
|
+
token ? row("ok", "Token", "present") : row("bad", "Token", ui.red(`missing, so nothing can be sent. Run: npx ${spec.packageName} setup`)),
|
|
5252
|
+
outcome ? row(outcome === "accepted" ? "ok" : "warn", "Last send", `${outcome}${state?.lastAttemptAt ? ui.dim(` (${state.lastAttemptAt})`) : ""}`) : row("info", "Last send", "none yet")
|
|
5253
|
+
];
|
|
5254
|
+
}
|
|
5255
|
+
function removeOurHookEntries(settingsFile, spec) {
|
|
5256
|
+
if (!fs.existsSync(settingsFile))
|
|
5257
|
+
return true;
|
|
5258
|
+
try {
|
|
5259
|
+
const settings = JSON.parse(fs.readFileSync(settingsFile, "utf8"));
|
|
5260
|
+
const hooks = { ...settings.hooks ?? {} };
|
|
5261
|
+
for (const event of Object.keys(hooks)) {
|
|
5262
|
+
const kept = hooks[event].filter((entry) => !isOurs(entry, spec));
|
|
5263
|
+
if (kept.length)
|
|
5264
|
+
hooks[event] = kept;
|
|
5265
|
+
else
|
|
5266
|
+
delete hooks[event];
|
|
5267
|
+
}
|
|
5268
|
+
const updated = { ...settings, hooks };
|
|
5269
|
+
if (!Object.keys(hooks).length)
|
|
5270
|
+
delete updated.hooks;
|
|
5271
|
+
fs.copyFileSync(settingsFile, `${settingsFile}.ascenda-backup`);
|
|
5272
|
+
fs.writeFileSync(settingsFile, `${JSON.stringify(updated, null, 2)}
|
|
5273
|
+
`, "utf8");
|
|
5274
|
+
return true;
|
|
5275
|
+
} catch {
|
|
5276
|
+
return false;
|
|
5277
|
+
}
|
|
5278
|
+
}
|
|
3403
5279
|
function uninstall(options, spec) {
|
|
3404
5280
|
const settingsFile = spec.settings.settingsPath(options.scope, options.projectDir);
|
|
3405
5281
|
if (fs.existsSync(settingsFile)) {
|
|
3406
|
-
|
|
3407
|
-
const settings = JSON.parse(fs.readFileSync(settingsFile, "utf8"));
|
|
3408
|
-
const hooks = { ...settings.hooks ?? {} };
|
|
3409
|
-
for (const event of Object.keys(hooks)) {
|
|
3410
|
-
const kept = hooks[event].filter((entry) => !isOurs(entry, spec));
|
|
3411
|
-
if (kept.length)
|
|
3412
|
-
hooks[event] = kept;
|
|
3413
|
-
else
|
|
3414
|
-
delete hooks[event];
|
|
3415
|
-
}
|
|
3416
|
-
const updated = { ...settings, hooks };
|
|
3417
|
-
if (!Object.keys(hooks).length)
|
|
3418
|
-
delete updated.hooks;
|
|
3419
|
-
fs.copyFileSync(settingsFile, `${settingsFile}.ascenda-backup`);
|
|
3420
|
-
fs.writeFileSync(settingsFile, `${JSON.stringify(updated, null, 2)}
|
|
3421
|
-
`, "utf8");
|
|
3422
|
-
console.log(`hooks removed from ${settingsFile}`);
|
|
3423
|
-
} catch {
|
|
5282
|
+
if (!removeOurHookEntries(settingsFile, spec)) {
|
|
3424
5283
|
console.error(`could not parse ${settingsFile} \u2014 remove the ascenda hook entries by hand`);
|
|
3425
5284
|
return 1;
|
|
3426
5285
|
}
|
|
5286
|
+
console.log(`hooks removed from ${settingsFile}`);
|
|
3427
5287
|
}
|
|
3428
|
-
const
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
console.log(`removed ${binary}`);
|
|
5288
|
+
for (const file of (0, hookRunner_1.removeHookRunner)(spec.binaryName)) {
|
|
5289
|
+
if (!file.endsWith(".node") && !file.endsWith(".no-node"))
|
|
5290
|
+
console.log(`removed ${file}`);
|
|
3432
5291
|
}
|
|
3433
5292
|
if ((0, credentials_1.readHostCredentials)(spec.host)) {
|
|
3434
5293
|
(0, credentials_1.removeHostCredentials)(spec.host);
|
|
@@ -3520,9 +5379,9 @@ var require_turnState = __commonJS({
|
|
|
3520
5379
|
}
|
|
3521
5380
|
});
|
|
3522
5381
|
|
|
3523
|
-
// ../packages/tool-kit/out/
|
|
3524
|
-
var
|
|
3525
|
-
"../packages/tool-kit/out/
|
|
5382
|
+
// ../packages/tool-kit/out/agentProcess.js
|
|
5383
|
+
var require_agentProcess = __commonJS({
|
|
5384
|
+
"../packages/tool-kit/out/agentProcess.js"(exports) {
|
|
3526
5385
|
"use strict";
|
|
3527
5386
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3528
5387
|
if (k2 === void 0) k2 = k;
|
|
@@ -3562,123 +5421,99 @@ var require_liveBus = __commonJS({
|
|
|
3562
5421
|
};
|
|
3563
5422
|
}();
|
|
3564
5423
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3565
|
-
exports.
|
|
3566
|
-
exports.
|
|
3567
|
-
exports.
|
|
3568
|
-
exports.
|
|
3569
|
-
|
|
3570
|
-
var
|
|
3571
|
-
var os = __importStar(__require("os"));
|
|
5424
|
+
exports.psArgsLookup = exports.psLookup = exports.AGENT_PROCESS = void 0;
|
|
5425
|
+
exports.scriptMarkerIn = scriptMarkerIn;
|
|
5426
|
+
exports.findAgentProcess = findAgentProcess;
|
|
5427
|
+
exports.findAgentPid = findAgentPid;
|
|
5428
|
+
exports.livePidFields = livePidFields;
|
|
5429
|
+
var child_process_1 = __require("child_process");
|
|
3572
5430
|
var path = __importStar(__require("path"));
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
5431
|
+
exports.AGENT_PROCESS = {
|
|
5432
|
+
claude_code: {
|
|
5433
|
+
executable: (command) => path.basename(command) === "claude" || /\/claude\/versions\/[^/]+$/.test(command) || /\/@anthropic-ai\/claude-code\/bin\/claude\.exe$/.test(command),
|
|
5434
|
+
scriptMarkers: ["@anthropic-ai/claude-code"]
|
|
5435
|
+
},
|
|
5436
|
+
codex: {
|
|
5437
|
+
executable: (command) => /^codex(-(aarch64|x86_64)-apple-darwin)?$/.test(path.basename(command)),
|
|
5438
|
+
args: (args) => !/\s(app-server|mcp-server)(\s|$)/.test(args)
|
|
5439
|
+
},
|
|
5440
|
+
gemini_cli: {
|
|
5441
|
+
executable: () => false,
|
|
5442
|
+
args: (args) => !/\s--(experimental-)?acp(\s|=|$)/.test(args),
|
|
5443
|
+
scriptMarkers: ["@google/gemini-cli"]
|
|
5444
|
+
}
|
|
5445
|
+
};
|
|
5446
|
+
var SCRIPT_RUNTIME = /^(node|bun|deno)$/;
|
|
5447
|
+
function scriptMarkerIn(args, markers) {
|
|
5448
|
+
return markers.find((marker) => args.includes(`/${marker}/`));
|
|
3586
5449
|
}
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
}
|
|
3595
|
-
|
|
5450
|
+
var MAX_DEPTH = 6;
|
|
5451
|
+
var PS_TIMEOUT_MS = 100;
|
|
5452
|
+
function ps(columns, pid) {
|
|
5453
|
+
try {
|
|
5454
|
+
const result = (0, child_process_1.spawnSync)("/bin/ps", ["-o", columns, "-p", String(pid)], {
|
|
5455
|
+
encoding: "utf8",
|
|
5456
|
+
timeout: PS_TIMEOUT_MS
|
|
5457
|
+
});
|
|
5458
|
+
if (result.status !== 0 || typeof result.stdout !== "string")
|
|
5459
|
+
return void 0;
|
|
5460
|
+
const line = result.stdout.trim();
|
|
5461
|
+
return line === "" ? void 0 : line;
|
|
5462
|
+
} catch {
|
|
5463
|
+
return void 0;
|
|
5464
|
+
}
|
|
5465
|
+
}
|
|
5466
|
+
var psLookup = (pid) => {
|
|
5467
|
+
const line = ps("ppid=,comm=", pid);
|
|
5468
|
+
const match = line ? /^(\d+)\s+(.+)$/.exec(line) : null;
|
|
5469
|
+
return match ? { ppid: Number(match[1]), command: match[2] } : void 0;
|
|
5470
|
+
};
|
|
5471
|
+
exports.psLookup = psLookup;
|
|
5472
|
+
var psArgsLookup = (pid) => ps("args=", pid);
|
|
5473
|
+
exports.psArgsLookup = psArgsLookup;
|
|
5474
|
+
function findAgentProcess(rule, options = {}) {
|
|
5475
|
+
if (!rule)
|
|
5476
|
+
return void 0;
|
|
5477
|
+
if ((options.platform ?? process.platform) !== "darwin")
|
|
5478
|
+
return void 0;
|
|
5479
|
+
const lookup = options.lookup ?? exports.psLookup;
|
|
5480
|
+
const argsLookup = options.argsLookup ?? exports.psArgsLookup;
|
|
5481
|
+
const markers = rule.scriptMarkers ?? [];
|
|
5482
|
+
let pid = options.startPid ?? process.ppid;
|
|
5483
|
+
for (let depth = 0; depth < MAX_DEPTH && pid > 1; depth++) {
|
|
5484
|
+
const info = lookup(pid);
|
|
5485
|
+
if (!info)
|
|
5486
|
+
return void 0;
|
|
5487
|
+
if (pid !== process.pid) {
|
|
5488
|
+
if (rule.executable(info.command)) {
|
|
5489
|
+
return accepts(rule, rule.args ? argsLookup(pid) : "") ? { pid, match: "executable" } : void 0;
|
|
5490
|
+
}
|
|
5491
|
+
if (markers.length > 0 && SCRIPT_RUNTIME.test(path.basename(info.command))) {
|
|
5492
|
+
const args = argsLookup(pid);
|
|
5493
|
+
const marker = args === void 0 ? void 0 : scriptMarkerIn(args, markers);
|
|
5494
|
+
if (marker !== void 0) {
|
|
5495
|
+
return accepts(rule, args) ? { pid, match: "path", marker } : void 0;
|
|
5496
|
+
}
|
|
5497
|
+
}
|
|
3596
5498
|
}
|
|
3597
|
-
|
|
5499
|
+
pid = info.ppid;
|
|
5500
|
+
}
|
|
5501
|
+
return void 0;
|
|
3598
5502
|
}
|
|
3599
|
-
function
|
|
3600
|
-
|
|
5503
|
+
function accepts(rule, args) {
|
|
5504
|
+
if (!rule.args)
|
|
5505
|
+
return true;
|
|
5506
|
+
return args !== void 0 && rule.args(args);
|
|
3601
5507
|
}
|
|
3602
|
-
function
|
|
3603
|
-
|
|
3604
|
-
if (length <= 280)
|
|
3605
|
-
return "s";
|
|
3606
|
-
if (length <= 2e3)
|
|
3607
|
-
return "m";
|
|
3608
|
-
if (length <= 8e3)
|
|
3609
|
-
return "l";
|
|
3610
|
-
return "xl";
|
|
5508
|
+
function findAgentPid(rule, options = {}) {
|
|
5509
|
+
return findAgentProcess(rule, options)?.pid;
|
|
3611
5510
|
}
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
return;
|
|
3619
|
-
}
|
|
3620
|
-
let settled = false;
|
|
3621
|
-
let socket;
|
|
3622
|
-
const drop = () => {
|
|
3623
|
-
try {
|
|
3624
|
-
socket?.destroy();
|
|
3625
|
-
} catch {
|
|
3626
|
-
}
|
|
3627
|
-
socket = void 0;
|
|
3628
|
-
};
|
|
3629
|
-
const done = () => {
|
|
3630
|
-
if (settled)
|
|
3631
|
-
return;
|
|
3632
|
-
settled = true;
|
|
3633
|
-
clearTimeout(timer);
|
|
3634
|
-
drop();
|
|
3635
|
-
resolve();
|
|
3636
|
-
};
|
|
3637
|
-
const timer = setTimeout(done, WRITE_TIMEOUT_MS);
|
|
3638
|
-
if (typeof timer.unref === "function")
|
|
3639
|
-
timer.unref();
|
|
3640
|
-
const tryFrom = (index) => {
|
|
3641
|
-
if (settled)
|
|
3642
|
-
return;
|
|
3643
|
-
if (index >= candidates.length) {
|
|
3644
|
-
done();
|
|
3645
|
-
return;
|
|
3646
|
-
}
|
|
3647
|
-
let attempt;
|
|
3648
|
-
try {
|
|
3649
|
-
attempt = net.createConnection(candidates[index]);
|
|
3650
|
-
} catch {
|
|
3651
|
-
tryFrom(index + 1);
|
|
3652
|
-
return;
|
|
3653
|
-
}
|
|
3654
|
-
socket = attempt;
|
|
3655
|
-
if (typeof attempt.unref === "function")
|
|
3656
|
-
attempt.unref();
|
|
3657
|
-
let connected = false;
|
|
3658
|
-
attempt.on("error", (error2) => {
|
|
3659
|
-
if (settled || socket !== attempt)
|
|
3660
|
-
return;
|
|
3661
|
-
if (!connected && error2.code && NOBODY_LISTENING.has(error2.code)) {
|
|
3662
|
-
drop();
|
|
3663
|
-
tryFrom(index + 1);
|
|
3664
|
-
return;
|
|
3665
|
-
}
|
|
3666
|
-
done();
|
|
3667
|
-
});
|
|
3668
|
-
attempt.on("connect", () => {
|
|
3669
|
-
if (settled || socket !== attempt)
|
|
3670
|
-
return;
|
|
3671
|
-
connected = true;
|
|
3672
|
-
try {
|
|
3673
|
-
attempt.write(`${JSON.stringify(signal)}
|
|
3674
|
-
`, done);
|
|
3675
|
-
} catch {
|
|
3676
|
-
done();
|
|
3677
|
-
}
|
|
3678
|
-
});
|
|
3679
|
-
};
|
|
3680
|
-
tryFrom(0);
|
|
3681
|
-
});
|
|
5511
|
+
function livePidFields(match) {
|
|
5512
|
+
if (!match)
|
|
5513
|
+
return {};
|
|
5514
|
+
if (match.match === "executable")
|
|
5515
|
+
return { pid: match.pid };
|
|
5516
|
+
return { pid: match.pid, pidMatch: "path", pidMarker: match.marker };
|
|
3682
5517
|
}
|
|
3683
5518
|
}
|
|
3684
5519
|
});
|
|
@@ -3688,9 +5523,10 @@ var require_out2 = __commonJS({
|
|
|
3688
5523
|
"../packages/tool-kit/out/index.js"(exports) {
|
|
3689
5524
|
"use strict";
|
|
3690
5525
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3691
|
-
exports.
|
|
3692
|
-
exports.
|
|
3693
|
-
exports.
|
|
5526
|
+
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;
|
|
5527
|
+
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;
|
|
5528
|
+
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;
|
|
5529
|
+
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;
|
|
3694
5530
|
var commandClassifier_1 = require_commandClassifier();
|
|
3695
5531
|
Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
|
|
3696
5532
|
return commandClassifier_1.classifyCommand;
|
|
@@ -3788,6 +5624,9 @@ var require_out2 = __commonJS({
|
|
|
3788
5624
|
Object.defineProperty(exports, "AscendaSemanticEventError", { enumerable: true, get: function() {
|
|
3789
5625
|
return eventSender_1.AscendaSemanticEventError;
|
|
3790
5626
|
} });
|
|
5627
|
+
Object.defineProperty(exports, "TOKEN_RENEW_LEAD_MS", { enumerable: true, get: function() {
|
|
5628
|
+
return eventSender_1.TOKEN_RENEW_LEAD_MS;
|
|
5629
|
+
} });
|
|
3791
5630
|
Object.defineProperty(exports, "buildEventPayload", { enumerable: true, get: function() {
|
|
3792
5631
|
return eventSender_1.buildEventPayload;
|
|
3793
5632
|
} });
|
|
@@ -3833,6 +5672,9 @@ var require_out2 = __commonJS({
|
|
|
3833
5672
|
Object.defineProperty(exports, "isCliAgentManagementCommand", { enumerable: true, get: function() {
|
|
3834
5673
|
return cliAgentSetup_1.isCliAgentManagementCommand;
|
|
3835
5674
|
} });
|
|
5675
|
+
Object.defineProperty(exports, "registeredHookSets", { enumerable: true, get: function() {
|
|
5676
|
+
return cliAgentSetup_1.registeredHookSets;
|
|
5677
|
+
} });
|
|
3836
5678
|
Object.defineProperty(exports, "runCliAgentSetup", { enumerable: true, get: function() {
|
|
3837
5679
|
return cliAgentSetup_1.runCliAgentSetup;
|
|
3838
5680
|
} });
|
|
@@ -3888,6 +5730,9 @@ var require_out2 = __commonJS({
|
|
|
3888
5730
|
return turnState_1.recordTurnStart;
|
|
3889
5731
|
} });
|
|
3890
5732
|
var tokenStore_1 = require_tokenStore();
|
|
5733
|
+
Object.defineProperty(exports, "EVENT_TOKEN_TTL_MS", { enumerable: true, get: function() {
|
|
5734
|
+
return tokenStore_1.EVENT_TOKEN_TTL_MS;
|
|
5735
|
+
} });
|
|
3891
5736
|
Object.defineProperty(exports, "ascendaHome", { enumerable: true, get: function() {
|
|
3892
5737
|
return tokenStore_1.ascendaHome;
|
|
3893
5738
|
} });
|
|
@@ -3900,9 +5745,15 @@ var require_out2 = __commonJS({
|
|
|
3900
5745
|
Object.defineProperty(exports, "persistEventWriteToken", { enumerable: true, get: function() {
|
|
3901
5746
|
return tokenStore_1.persistEventWriteToken;
|
|
3902
5747
|
} });
|
|
5748
|
+
Object.defineProperty(exports, "readTokenExpiry", { enumerable: true, get: function() {
|
|
5749
|
+
return tokenStore_1.readTokenExpiry;
|
|
5750
|
+
} });
|
|
3903
5751
|
Object.defineProperty(exports, "readTokenFile", { enumerable: true, get: function() {
|
|
3904
5752
|
return tokenStore_1.readTokenFile;
|
|
3905
5753
|
} });
|
|
5754
|
+
Object.defineProperty(exports, "tokenExpiryFilePath", { enumerable: true, get: function() {
|
|
5755
|
+
return tokenStore_1.tokenExpiryFilePath;
|
|
5756
|
+
} });
|
|
3906
5757
|
var stateStore_1 = require_stateStore();
|
|
3907
5758
|
Object.defineProperty(exports, "defaultStateFilePath", { enumerable: true, get: function() {
|
|
3908
5759
|
return stateStore_1.defaultStateFilePath;
|
|
@@ -4025,6 +5876,9 @@ var require_out2 = __commonJS({
|
|
|
4025
5876
|
Object.defineProperty(exports, "emitLiveSignal", { enumerable: true, get: function() {
|
|
4026
5877
|
return liveBus_1.emitLiveSignal;
|
|
4027
5878
|
} });
|
|
5879
|
+
Object.defineProperty(exports, "deliverLine", { enumerable: true, get: function() {
|
|
5880
|
+
return liveBus_1.deliverLine;
|
|
5881
|
+
} });
|
|
4028
5882
|
Object.defineProperty(exports, "bucketPromptSize", { enumerable: true, get: function() {
|
|
4029
5883
|
return liveBus_1.bucketPromptSize;
|
|
4030
5884
|
} });
|
|
@@ -4034,6 +5888,138 @@ var require_out2 = __commonJS({
|
|
|
4034
5888
|
Object.defineProperty(exports, "liveBusSocketCandidates", { enumerable: true, get: function() {
|
|
4035
5889
|
return liveBus_1.liveBusSocketCandidates;
|
|
4036
5890
|
} });
|
|
5891
|
+
Object.defineProperty(exports, "LIVE_BUS_BACKGROUND_TRUST_MS", { enumerable: true, get: function() {
|
|
5892
|
+
return liveBus_1.LIVE_BUS_BACKGROUND_TRUST_MS;
|
|
5893
|
+
} });
|
|
5894
|
+
var saverHandoff_1 = require_saverHandoff();
|
|
5895
|
+
Object.defineProperty(exports, "holdForSaver", { enumerable: true, get: function() {
|
|
5896
|
+
return saverHandoff_1.holdForSaver;
|
|
5897
|
+
} });
|
|
5898
|
+
Object.defineProperty(exports, "heldForSaver", { enumerable: true, get: function() {
|
|
5899
|
+
return saverHandoff_1.heldForSaver;
|
|
5900
|
+
} });
|
|
5901
|
+
Object.defineProperty(exports, "probeSocket", { enumerable: true, get: function() {
|
|
5902
|
+
return saverHandoff_1.probeSocket;
|
|
5903
|
+
} });
|
|
5904
|
+
Object.defineProperty(exports, "readSaverStatuses", { enumerable: true, get: function() {
|
|
5905
|
+
return saverHandoff_1.readSaverStatuses;
|
|
5906
|
+
} });
|
|
5907
|
+
Object.defineProperty(exports, "saverContainerDir", { enumerable: true, get: function() {
|
|
5908
|
+
return saverHandoff_1.saverContainerDir;
|
|
5909
|
+
} });
|
|
5910
|
+
Object.defineProperty(exports, "saverReplayPath", { enumerable: true, get: function() {
|
|
5911
|
+
return saverHandoff_1.saverReplayPath;
|
|
5912
|
+
} });
|
|
5913
|
+
Object.defineProperty(exports, "saverStatusDir", { enumerable: true, get: function() {
|
|
5914
|
+
return saverHandoff_1.saverStatusDir;
|
|
5915
|
+
} });
|
|
5916
|
+
Object.defineProperty(exports, "saverSupportDir", { enumerable: true, get: function() {
|
|
5917
|
+
return saverHandoff_1.saverSupportDir;
|
|
5918
|
+
} });
|
|
5919
|
+
Object.defineProperty(exports, "SAVER_REPLAY_WINDOW_MS", { enumerable: true, get: function() {
|
|
5920
|
+
return saverHandoff_1.SAVER_REPLAY_WINDOW_MS;
|
|
5921
|
+
} });
|
|
5922
|
+
var terminalStyle_1 = require_terminalStyle();
|
|
5923
|
+
Object.defineProperty(exports, "colourEnabled", { enumerable: true, get: function() {
|
|
5924
|
+
return terminalStyle_1.colourEnabled;
|
|
5925
|
+
} });
|
|
5926
|
+
Object.defineProperty(exports, "terminalStyle", { enumerable: true, get: function() {
|
|
5927
|
+
return terminalStyle_1.terminalStyle;
|
|
5928
|
+
} });
|
|
5929
|
+
var hookRunner_1 = require_hookRunner();
|
|
5930
|
+
Object.defineProperty(exports, "describeAge", { enumerable: true, get: function() {
|
|
5931
|
+
return hookRunner_1.describeAge;
|
|
5932
|
+
} });
|
|
5933
|
+
Object.defineProperty(exports, "hookLauncherScript", { enumerable: true, get: function() {
|
|
5934
|
+
return hookRunner_1.hookLauncherScript;
|
|
5935
|
+
} });
|
|
5936
|
+
Object.defineProperty(exports, "hookRunnerCommand", { enumerable: true, get: function() {
|
|
5937
|
+
return hookRunner_1.hookRunnerCommand;
|
|
5938
|
+
} });
|
|
5939
|
+
Object.defineProperty(exports, "hookRunnerPaths", { enumerable: true, get: function() {
|
|
5940
|
+
return hookRunner_1.hookRunnerPaths;
|
|
5941
|
+
} });
|
|
5942
|
+
Object.defineProperty(exports, "installHookRunner", { enumerable: true, get: function() {
|
|
5943
|
+
return hookRunner_1.installHookRunner;
|
|
5944
|
+
} });
|
|
5945
|
+
Object.defineProperty(exports, "lastHookPath", { enumerable: true, get: function() {
|
|
5946
|
+
return hookRunner_1.lastHookPath;
|
|
5947
|
+
} });
|
|
5948
|
+
Object.defineProperty(exports, "readLastHook", { enumerable: true, get: function() {
|
|
5949
|
+
return hookRunner_1.readLastHook;
|
|
5950
|
+
} });
|
|
5951
|
+
Object.defineProperty(exports, "removeHookRunner", { enumerable: true, get: function() {
|
|
5952
|
+
return hookRunner_1.removeHookRunner;
|
|
5953
|
+
} });
|
|
5954
|
+
Object.defineProperty(exports, "resolveHookNode", { enumerable: true, get: function() {
|
|
5955
|
+
return hookRunner_1.resolveHookNode;
|
|
5956
|
+
} });
|
|
5957
|
+
Object.defineProperty(exports, "stampLastHook", { enumerable: true, get: function() {
|
|
5958
|
+
return hookRunner_1.stampLastHook;
|
|
5959
|
+
} });
|
|
5960
|
+
Object.defineProperty(exports, "tidyHomePath", { enumerable: true, get: function() {
|
|
5961
|
+
return hookRunner_1.tidyHomePath;
|
|
5962
|
+
} });
|
|
5963
|
+
var liveSignalDoctor_1 = require_liveSignalDoctor();
|
|
5964
|
+
Object.defineProperty(exports, "DOCTOR_VALUE_COLUMN", { enumerable: true, get: function() {
|
|
5965
|
+
return liveSignalDoctor_1.DOCTOR_VALUE_COLUMN;
|
|
5966
|
+
} });
|
|
5967
|
+
Object.defineProperty(exports, "doctorRow", { enumerable: true, get: function() {
|
|
5968
|
+
return liveSignalDoctor_1.doctorRow;
|
|
5969
|
+
} });
|
|
5970
|
+
Object.defineProperty(exports, "liveSignalDoctorLines", { enumerable: true, get: function() {
|
|
5971
|
+
return liveSignalDoctor_1.liveSignalDoctorLines;
|
|
5972
|
+
} });
|
|
5973
|
+
var hookSet_1 = require_hookSet();
|
|
5974
|
+
Object.defineProperty(exports, "HOOK_SET_FLAG", { enumerable: true, get: function() {
|
|
5975
|
+
return hookSet_1.HOOK_SET_FLAG;
|
|
5976
|
+
} });
|
|
5977
|
+
Object.defineProperty(exports, "UNVERSIONED_HOOK_SET", { enumerable: true, get: function() {
|
|
5978
|
+
return hookSet_1.UNVERSIONED_HOOK_SET;
|
|
5979
|
+
} });
|
|
5980
|
+
Object.defineProperty(exports, "describeHookSetChanges", { enumerable: true, get: function() {
|
|
5981
|
+
return hookSet_1.describeHookSetChanges;
|
|
5982
|
+
} });
|
|
5983
|
+
Object.defineProperty(exports, "hookSetArgument", { enumerable: true, get: function() {
|
|
5984
|
+
return hookSet_1.hookSetArgument;
|
|
5985
|
+
} });
|
|
5986
|
+
Object.defineProperty(exports, "hookSetChanges", { enumerable: true, get: function() {
|
|
5987
|
+
return hookSet_1.hookSetChanges;
|
|
5988
|
+
} });
|
|
5989
|
+
Object.defineProperty(exports, "hookSetOfCommand", { enumerable: true, get: function() {
|
|
5990
|
+
return hookSet_1.hookSetOfCommand;
|
|
5991
|
+
} });
|
|
5992
|
+
Object.defineProperty(exports, "isHookSet", { enumerable: true, get: function() {
|
|
5993
|
+
return hookSet_1.isHookSet;
|
|
5994
|
+
} });
|
|
5995
|
+
Object.defineProperty(exports, "readHookSet", { enumerable: true, get: function() {
|
|
5996
|
+
return hookSet_1.readHookSet;
|
|
5997
|
+
} });
|
|
5998
|
+
Object.defineProperty(exports, "readViaPlugin", { enumerable: true, get: function() {
|
|
5999
|
+
return hookSet_1.readViaPlugin;
|
|
6000
|
+
} });
|
|
6001
|
+
var agentProcess_1 = require_agentProcess();
|
|
6002
|
+
Object.defineProperty(exports, "AGENT_PROCESS", { enumerable: true, get: function() {
|
|
6003
|
+
return agentProcess_1.AGENT_PROCESS;
|
|
6004
|
+
} });
|
|
6005
|
+
Object.defineProperty(exports, "findAgentPid", { enumerable: true, get: function() {
|
|
6006
|
+
return agentProcess_1.findAgentPid;
|
|
6007
|
+
} });
|
|
6008
|
+
Object.defineProperty(exports, "findAgentProcess", { enumerable: true, get: function() {
|
|
6009
|
+
return agentProcess_1.findAgentProcess;
|
|
6010
|
+
} });
|
|
6011
|
+
Object.defineProperty(exports, "livePidFields", { enumerable: true, get: function() {
|
|
6012
|
+
return agentProcess_1.livePidFields;
|
|
6013
|
+
} });
|
|
6014
|
+
Object.defineProperty(exports, "psArgsLookup", { enumerable: true, get: function() {
|
|
6015
|
+
return agentProcess_1.psArgsLookup;
|
|
6016
|
+
} });
|
|
6017
|
+
Object.defineProperty(exports, "psLookup", { enumerable: true, get: function() {
|
|
6018
|
+
return agentProcess_1.psLookup;
|
|
6019
|
+
} });
|
|
6020
|
+
Object.defineProperty(exports, "scriptMarkerIn", { enumerable: true, get: function() {
|
|
6021
|
+
return agentProcess_1.scriptMarkerIn;
|
|
6022
|
+
} });
|
|
4037
6023
|
var http_1 = require_http();
|
|
4038
6024
|
Object.defineProperty(exports, "AscendaApiError", { enumerable: true, get: function() {
|
|
4039
6025
|
return http_1.AscendaApiError;
|
|
@@ -4044,6 +6030,9 @@ var require_out2 = __commonJS({
|
|
|
4044
6030
|
Object.defineProperty(exports, "getPairingStatus", { enumerable: true, get: function() {
|
|
4045
6031
|
return http_1.getPairingStatus;
|
|
4046
6032
|
} });
|
|
6033
|
+
Object.defineProperty(exports, "getStudyJoinStatus", { enumerable: true, get: function() {
|
|
6034
|
+
return http_1.getStudyJoinStatus;
|
|
6035
|
+
} });
|
|
4047
6036
|
Object.defineProperty(exports, "renewToolToken", { enumerable: true, get: function() {
|
|
4048
6037
|
return http_1.renewToolToken;
|
|
4049
6038
|
} });
|
|
@@ -4059,6 +6048,48 @@ var require_out2 = __commonJS({
|
|
|
4059
6048
|
Object.defineProperty(exports, "isRetryableStatus", { enumerable: true, get: function() {
|
|
4060
6049
|
return http_1.isRetryableStatus;
|
|
4061
6050
|
} });
|
|
6051
|
+
Object.defineProperty(exports, "readInitiatives", { enumerable: true, get: function() {
|
|
6052
|
+
return http_1.readInitiatives;
|
|
6053
|
+
} });
|
|
6054
|
+
Object.defineProperty(exports, "readStudyNotices", { enumerable: true, get: function() {
|
|
6055
|
+
return http_1.readStudyNotices;
|
|
6056
|
+
} });
|
|
6057
|
+
Object.defineProperty(exports, "markStudyNoticeShown", { enumerable: true, get: function() {
|
|
6058
|
+
return http_1.markStudyNoticeShown;
|
|
6059
|
+
} });
|
|
6060
|
+
Object.defineProperty(exports, "setStudyObjection", { enumerable: true, get: function() {
|
|
6061
|
+
return http_1.setStudyObjection;
|
|
6062
|
+
} });
|
|
6063
|
+
Object.defineProperty(exports, "startStudyJoin", { enumerable: true, get: function() {
|
|
6064
|
+
return http_1.startStudyJoin;
|
|
6065
|
+
} });
|
|
6066
|
+
var initiatives_1 = require_initiatives();
|
|
6067
|
+
Object.defineProperty(exports, "INITIATIVE_COPY", { enumerable: true, get: function() {
|
|
6068
|
+
return initiatives_1.INITIATIVE_COPY;
|
|
6069
|
+
} });
|
|
6070
|
+
Object.defineProperty(exports, "initiativesStatusLines", { enumerable: true, get: function() {
|
|
6071
|
+
return initiatives_1.initiativesStatusLines;
|
|
6072
|
+
} });
|
|
6073
|
+
Object.defineProperty(exports, "renderInitiatives", { enumerable: true, get: function() {
|
|
6074
|
+
return initiatives_1.renderInitiatives;
|
|
6075
|
+
} });
|
|
6076
|
+
var studyNotices_1 = require_studyNotices();
|
|
6077
|
+
Object.defineProperty(exports, "NOTICED_PURPOSES", { enumerable: true, get: function() {
|
|
6078
|
+
return studyNotices_1.NOTICED_PURPOSES;
|
|
6079
|
+
} });
|
|
6080
|
+
Object.defineProperty(exports, "renderStudyNotices", { enumerable: true, get: function() {
|
|
6081
|
+
return studyNotices_1.renderStudyNotices;
|
|
6082
|
+
} });
|
|
6083
|
+
Object.defineProperty(exports, "runStudyObjection", { enumerable: true, get: function() {
|
|
6084
|
+
return studyNotices_1.runStudyObjection;
|
|
6085
|
+
} });
|
|
6086
|
+
Object.defineProperty(exports, "studyNoticeStatus", { enumerable: true, get: function() {
|
|
6087
|
+
return studyNotices_1.studyNoticeStatus;
|
|
6088
|
+
} });
|
|
6089
|
+
var studyJoin_1 = require_studyJoin();
|
|
6090
|
+
Object.defineProperty(exports, "runStudyJoin", { enumerable: true, get: function() {
|
|
6091
|
+
return studyJoin_1.runStudyJoin;
|
|
6092
|
+
} });
|
|
4062
6093
|
}
|
|
4063
6094
|
});
|
|
4064
6095
|
|