@ascenda-one/agent-mcp 0.1.34 → 0.1.35

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.
Files changed (4) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/dist/cli.js +617 -375
  4. package/package.json +3 -2
package/dist/cli.js CHANGED
@@ -633,9 +633,11 @@ var require_out = __commonJS({
633
633
  "../packages/tool-contract/out/index.js"(exports) {
634
634
  "use strict";
635
635
  Object.defineProperty(exports, "__esModule", { value: true });
636
- exports.backendMetricKeys = exports.METRIC_KEYS = exports.ASCENDA_SEMANTIC_PROVENANCE = exports.ASCENDA_HISTORICAL_CONSENT_SCOPE = exports.ASCENDA_COLLABORATION_CONSENT_SCOPE = exports.ASCENDA_SEMANTIC_CONSENT_SCOPE = exports.ASCENDA_PROVENANCE = exports.ASCENDA_CONSENT_SCOPE = exports.EVENT_WORKLOAD_CATEGORY = exports.TOOL_EVENT_DELIVERED_STATUSES = exports.IDEMPOTENCY_KEY_MAX_LENGTH = exports.EVENT_METADATA_FIELDS = exports.EVENT_METADATA_DISCLOSURE = exports.COLLABORATION_EVENT_TYPES = exports.SEMANTIC_WORK_SIGNAL_EVENT_TYPES = exports.ASCENDA_ELAPSED_QUANTITIES = exports.ASCENDA_ACTIVE_TIME_QUANTITIES = exports.ASCENDA_TOOL_TYPES = exports.ASCENDA_TELEMETRY_SOURCES = void 0;
636
+ exports.backendMetricKeys = exports.METRIC_KEYS = exports.ASCENDA_SEMANTIC_PROVENANCE = exports.ASCENDA_HISTORICAL_CONSENT_SCOPE = exports.ASCENDA_COLLABORATION_CONSENT_SCOPE = exports.ASCENDA_SEMANTIC_CONSENT_SCOPE = exports.ASCENDA_PROVENANCE = exports.ASCENDA_CONSENT_SCOPE = exports.EVENT_WORKLOAD_CATEGORY = exports.TOOL_EVENT_DELIVERED_STATUSES = exports.IDEMPOTENCY_KEY_MAX_LENGTH = exports.DELIVERY_ENVELOPE_KEYS = exports.EVENT_METADATA_FIELDS = exports.EVENT_METADATA_DISCLOSURE = exports.COLLABORATION_EVENT_TYPES = exports.SEMANTIC_WORK_SIGNAL_EVENT_TYPES = exports.ASCENDA_ELAPSED_QUANTITIES = exports.ASCENDA_ACTIVE_TIME_QUANTITIES = exports.ASCENDA_TOOL_TYPES = exports.ASCENDA_TELEMETRY_SOURCES = void 0;
637
637
  exports.combineDisjointHalves = combineDisjointHalves;
638
638
  exports.requireComparableQuantities = requireComparableQuantities;
639
+ exports.joinEventPayload = joinEventPayload;
640
+ exports.splitEventPayload = splitEventPayload;
639
641
  exports.ASCENDA_TELEMETRY_SOURCES = [
640
642
  "vscode_extension",
641
643
  "cursor_mcp",
@@ -787,6 +789,24 @@ var require_out = __commonJS({
787
789
  "importSchema",
788
790
  "collectorVersion"
789
791
  ];
792
+ exports.DELIVERY_ENVELOPE_KEYS = ["toolInstallationId", "idempotencyKey"];
793
+ function joinEventPayload(envelope, body) {
794
+ const payload = { toolInstallationId: envelope.toolInstallationId };
795
+ for (const [key, value] of Object.entries(body)) {
796
+ payload[key] = value;
797
+ if (key === "occurredAt" && envelope.idempotencyKey !== void 0) {
798
+ payload.idempotencyKey = envelope.idempotencyKey;
799
+ }
800
+ }
801
+ return payload;
802
+ }
803
+ function splitEventPayload(payload) {
804
+ const { toolInstallationId, idempotencyKey, ...body } = payload;
805
+ const envelope = { toolInstallationId };
806
+ if (idempotencyKey !== void 0)
807
+ envelope.idempotencyKey = idempotencyKey;
808
+ return { envelope, body };
809
+ }
790
810
  exports.IDEMPOTENCY_KEY_MAX_LENGTH = 128;
791
811
  exports.TOOL_EVENT_DELIVERED_STATUSES = ["accepted", "duplicate"];
792
812
  exports.EVENT_WORKLOAD_CATEGORY = {
@@ -965,13 +985,387 @@ var require_collectorVersion = __commonJS({
965
985
  exports.COLLECTOR_VERSION = exports.UNRELEASED_COLLECTOR_VERSION = void 0;
966
986
  exports.describeCollectorVersion = describeCollectorVersion;
967
987
  exports.UNRELEASED_COLLECTOR_VERSION = "unreleased";
968
- exports.COLLECTOR_VERSION = "0.1.34" ? "0.1.34" : exports.UNRELEASED_COLLECTOR_VERSION;
988
+ exports.COLLECTOR_VERSION = "0.1.35" ? "0.1.35" : exports.UNRELEASED_COLLECTOR_VERSION;
969
989
  function describeCollectorVersion(version2 = exports.COLLECTOR_VERSION) {
970
990
  return version2 === exports.UNRELEASED_COLLECTOR_VERSION ? `${version2} (built from a checkout, not a release)` : version2;
971
991
  }
972
992
  }
973
993
  });
974
994
 
995
+ // ../packages/agent-events/out/index.js
996
+ var require_out2 = __commonJS({
997
+ "../packages/agent-events/out/index.js"(exports) {
998
+ "use strict";
999
+ Object.defineProperty(exports, "__esModule", { value: true });
1000
+ exports.KNOWN_AGENTS = exports.AGENT_EVENT_KINDS = exports.AGENT_EVENT_SCHEMA = void 0;
1001
+ exports.isAgentEventV0 = isAgentEventV0;
1002
+ exports.parseEventLogLine = parseEventLogLine;
1003
+ exports.normaliseKind = normaliseKind;
1004
+ exports.AGENT_EVENT_SCHEMA = "agent-event/v0";
1005
+ exports.AGENT_EVENT_KINDS = [
1006
+ "session.started",
1007
+ "session.ended",
1008
+ "prompt.submitted",
1009
+ "tool.started",
1010
+ "tool.completed",
1011
+ "tool.failed",
1012
+ "turn.completed",
1013
+ "agent.waiting",
1014
+ "context.compacted",
1015
+ "subagent.started",
1016
+ "subagent.stopped",
1017
+ "other"
1018
+ ];
1019
+ exports.KNOWN_AGENTS = ["claude_code", "codex", "cursor", "gemini_cli", "windsurf", "vscode"];
1020
+ function isAgentEventV0(value) {
1021
+ if (!value || typeof value !== "object")
1022
+ return false;
1023
+ const e = value;
1024
+ return e.schema === exports.AGENT_EVENT_SCHEMA && typeof e.id === "string" && e.id.length > 0 && typeof e.time === "string" && !Number.isNaN(Date.parse(e.time)) && typeof e.agent === "string" && e.agent.length > 0 && typeof e.kind === "string";
1025
+ }
1026
+ function parseEventLogLine(line) {
1027
+ if (!line.trim())
1028
+ return void 0;
1029
+ try {
1030
+ const parsed = JSON.parse(line);
1031
+ return isAgentEventV0(parsed?.event) ? parsed.event : void 0;
1032
+ } catch {
1033
+ return void 0;
1034
+ }
1035
+ }
1036
+ function normaliseKind(kind) {
1037
+ return exports.AGENT_EVENT_KINDS.includes(kind) ? kind : "other";
1038
+ }
1039
+ }
1040
+ });
1041
+
1042
+ // ../packages/tool-kit/out/agentEvent.js
1043
+ var require_agentEvent = __commonJS({
1044
+ "../packages/tool-kit/out/agentEvent.js"(exports) {
1045
+ "use strict";
1046
+ Object.defineProperty(exports, "__esModule", { value: true });
1047
+ exports.toAgentEvent = toAgentEvent;
1048
+ var agent_events_1 = require_out2();
1049
+ var KIND_BY_TYPE = {
1050
+ create_focus_session: "session.started",
1051
+ recovery_offline_period: "session.ended",
1052
+ ai_prompt_submitted: "prompt.submitted",
1053
+ ai_tool_call_started: "tool.started",
1054
+ ai_tool_call_completed: "tool.completed",
1055
+ ai_file_write: "tool.completed",
1056
+ ai_file_edit: "tool.completed",
1057
+ editor_verification_activity: "tool.completed",
1058
+ ai_tool_call_failed: "tool.failed",
1059
+ compile_error: "tool.failed",
1060
+ tool_failure: "tool.failed",
1061
+ ai_turn_completed: "turn.completed",
1062
+ supervision_interruption: "agent.waiting",
1063
+ context_compression_manual: "context.compacted",
1064
+ context_compression_auto: "context.compacted",
1065
+ subagent_started: "subagent.started",
1066
+ subagent_stopped: "subagent.stopped"
1067
+ };
1068
+ function agentOf(payload) {
1069
+ const host = stringField(payload.metadata?.host);
1070
+ if (host)
1071
+ return host;
1072
+ return payload.source === "vscode_extension" ? "vscode" : payload.source;
1073
+ }
1074
+ function stringField(value) {
1075
+ return typeof value === "string" && value.length > 0 ? value : void 0;
1076
+ }
1077
+ function toAgentEvent(payload) {
1078
+ const metadata = payload.metadata ?? {};
1079
+ const kind = KIND_BY_TYPE[payload.eventType] ?? "other";
1080
+ const tool = kind.startsWith("tool.") ? stringField(metadata.toolName) : void 0;
1081
+ const outcome = stringField(metadata.outcome);
1082
+ return {
1083
+ schema: agent_events_1.AGENT_EVENT_SCHEMA,
1084
+ id: payload.idempotencyKey ?? `${payload.toolInstallationId}:${payload.occurredAt}:${payload.eventType}`,
1085
+ time: payload.occurredAt,
1086
+ // `+ 0` turns the -0 a UTC machine computes into 0, which is what JSON
1087
+ // writes anyway; without it the event in memory and the one on disk differ.
1088
+ ...typeof payload.utcOffsetMinutes === "number" ? { utcOffsetMinutes: payload.utcOffsetMinutes + 0 } : {},
1089
+ agent: agentOf(payload),
1090
+ kind,
1091
+ ...stringField(payload.sessionId) ? { sessionId: payload.sessionId } : {},
1092
+ ...stringField(metadata.subagentId) ? { subagentId: metadata.subagentId } : {},
1093
+ ...tool ? { tool } : {},
1094
+ ...outcome && outcome !== "unknown" ? { outcome } : {},
1095
+ ...stringField(metadata.durationBucket) ? { durationBucket: metadata.durationBucket } : {},
1096
+ ...stringField(payload.projectHash) ? { projectHash: payload.projectHash } : {},
1097
+ ...stringField(metadata.collectorVersion) ? { collectorVersion: metadata.collectorVersion } : {},
1098
+ sourceType: payload.eventType
1099
+ };
1100
+ }
1101
+ }
1102
+ });
1103
+
1104
+ // ../packages/tool-kit/out/tokenStore.js
1105
+ var require_tokenStore = __commonJS({
1106
+ "../packages/tool-kit/out/tokenStore.js"(exports) {
1107
+ "use strict";
1108
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
1109
+ if (k2 === void 0) k2 = k;
1110
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1111
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1112
+ desc = { enumerable: true, get: function() {
1113
+ return m[k];
1114
+ } };
1115
+ }
1116
+ Object.defineProperty(o, k2, desc);
1117
+ } : function(o, m, k, k2) {
1118
+ if (k2 === void 0) k2 = k;
1119
+ o[k2] = m[k];
1120
+ });
1121
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
1122
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1123
+ } : function(o, v) {
1124
+ o["default"] = v;
1125
+ });
1126
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
1127
+ var ownKeys = function(o) {
1128
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1129
+ var ar = [];
1130
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1131
+ return ar;
1132
+ };
1133
+ return ownKeys(o);
1134
+ };
1135
+ return function(mod) {
1136
+ if (mod && mod.__esModule) return mod;
1137
+ var result = {};
1138
+ if (mod != null) {
1139
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1140
+ }
1141
+ __setModuleDefault(result, mod);
1142
+ return result;
1143
+ };
1144
+ }();
1145
+ Object.defineProperty(exports, "__esModule", { value: true });
1146
+ exports.EVENT_TOKEN_TTL_MS = void 0;
1147
+ exports.ascendaHome = ascendaHome;
1148
+ exports.defaultTokenFilePath = defaultTokenFilePath2;
1149
+ exports.tokenExpiryFilePath = tokenExpiryFilePath;
1150
+ exports.persistEventWriteToken = persistEventWriteToken2;
1151
+ exports.readTokenExpiry = readTokenExpiry;
1152
+ exports.listPersistedToolInstallationIds = listPersistedToolInstallationIds;
1153
+ exports.readTokenFile = readTokenFile2;
1154
+ exports.sanitizeFilePart = sanitizeFilePart;
1155
+ var fs = __importStar(__require("fs"));
1156
+ var os = __importStar(__require("os"));
1157
+ var path = __importStar(__require("path"));
1158
+ function ascendaHome(home = os.homedir()) {
1159
+ return process.env.ASCENDA_HOME ?? path.join(home, ".ascenda");
1160
+ }
1161
+ function defaultTokenFilePath2(toolInstallationId) {
1162
+ return path.join(ascendaHome(), "tokens", sanitizeFilePart(toolInstallationId));
1163
+ }
1164
+ function tokenExpiryFilePath(tokenFilePath) {
1165
+ return path.join(path.dirname(tokenFilePath), "expiry", path.basename(tokenFilePath));
1166
+ }
1167
+ function persistEventWriteToken2(tokenFilePath, token, expiresAt) {
1168
+ const dir = path.dirname(tokenFilePath);
1169
+ fs.mkdirSync(dir, { recursive: true, mode: 448 });
1170
+ fs.writeFileSync(tokenFilePath, token, { encoding: "utf8", mode: 384 });
1171
+ if (process.platform !== "win32") {
1172
+ fs.chmodSync(dir, 448);
1173
+ fs.chmodSync(tokenFilePath, 384);
1174
+ }
1175
+ const expiryFile = tokenExpiryFilePath(tokenFilePath);
1176
+ try {
1177
+ if (expiresAt && Number.isFinite(Date.parse(expiresAt))) {
1178
+ fs.mkdirSync(path.dirname(expiryFile), { recursive: true, mode: 448 });
1179
+ fs.writeFileSync(expiryFile, expiresAt, { encoding: "utf8", mode: 384 });
1180
+ } else {
1181
+ fs.rmSync(expiryFile, { force: true });
1182
+ }
1183
+ } catch {
1184
+ }
1185
+ }
1186
+ exports.EVENT_TOKEN_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
1187
+ function readTokenExpiry(tokenFilePath) {
1188
+ try {
1189
+ const recorded = Date.parse(fs.readFileSync(tokenExpiryFilePath(tokenFilePath), "utf8").trim());
1190
+ if (Number.isFinite(recorded))
1191
+ return recorded;
1192
+ } catch {
1193
+ }
1194
+ try {
1195
+ return fs.statSync(tokenFilePath).mtimeMs + exports.EVENT_TOKEN_TTL_MS;
1196
+ } catch {
1197
+ return void 0;
1198
+ }
1199
+ }
1200
+ function listPersistedToolInstallationIds(toolType) {
1201
+ const prefix = `${sanitizeFilePart(toolType)}_`;
1202
+ const dir = path.join(ascendaHome(), "tokens");
1203
+ let names;
1204
+ try {
1205
+ names = fs.readdirSync(dir);
1206
+ } catch {
1207
+ return [];
1208
+ }
1209
+ const ids = [];
1210
+ for (const name of names.sort()) {
1211
+ if (!name.startsWith(prefix) || name.length === prefix.length)
1212
+ continue;
1213
+ const file = path.join(dir, name);
1214
+ try {
1215
+ if (!fs.statSync(file).isFile())
1216
+ continue;
1217
+ } catch {
1218
+ continue;
1219
+ }
1220
+ if (readTokenFile2(file) === void 0)
1221
+ continue;
1222
+ ids.push(`${toolType}:${name.slice(prefix.length)}`);
1223
+ }
1224
+ return ids;
1225
+ }
1226
+ function readTokenFile2(tokenFilePath) {
1227
+ try {
1228
+ if (!fs.existsSync(tokenFilePath))
1229
+ return void 0;
1230
+ const value = fs.readFileSync(tokenFilePath, "utf8").trim();
1231
+ return value || void 0;
1232
+ } catch {
1233
+ return void 0;
1234
+ }
1235
+ }
1236
+ function sanitizeFilePart(value) {
1237
+ return value.replace(/[^a-zA-Z0-9._-]/g, "_");
1238
+ }
1239
+ }
1240
+ });
1241
+
1242
+ // ../packages/tool-kit/out/credentials.js
1243
+ var require_credentials = __commonJS({
1244
+ "../packages/tool-kit/out/credentials.js"(exports) {
1245
+ "use strict";
1246
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
1247
+ if (k2 === void 0) k2 = k;
1248
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1249
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1250
+ desc = { enumerable: true, get: function() {
1251
+ return m[k];
1252
+ } };
1253
+ }
1254
+ Object.defineProperty(o, k2, desc);
1255
+ } : function(o, m, k, k2) {
1256
+ if (k2 === void 0) k2 = k;
1257
+ o[k2] = m[k];
1258
+ });
1259
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
1260
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1261
+ } : function(o, v) {
1262
+ o["default"] = v;
1263
+ });
1264
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
1265
+ var ownKeys = function(o) {
1266
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1267
+ var ar = [];
1268
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1269
+ return ar;
1270
+ };
1271
+ return ownKeys(o);
1272
+ };
1273
+ return function(mod) {
1274
+ if (mod && mod.__esModule) return mod;
1275
+ var result = {};
1276
+ if (mod != null) {
1277
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1278
+ }
1279
+ __setModuleDefault(result, mod);
1280
+ return result;
1281
+ };
1282
+ }();
1283
+ Object.defineProperty(exports, "__esModule", { value: true });
1284
+ exports.credentialsFilePath = credentialsFilePath;
1285
+ exports.readMachineCredentials = readMachineCredentials;
1286
+ exports.writeMachineCredentials = writeMachineCredentials;
1287
+ exports.writeTopLevelCredentials = writeTopLevelCredentials;
1288
+ exports.writeEventLogSetting = writeEventLogSetting;
1289
+ exports.isLocalOnlyHostInstall = isLocalOnlyHostInstall;
1290
+ exports.readHostCredentials = readHostCredentials;
1291
+ exports.writeHostCredentials = writeHostCredentials;
1292
+ exports.removeHostCredentials = removeHostCredentials;
1293
+ var fs = __importStar(__require("fs"));
1294
+ var path = __importStar(__require("path"));
1295
+ var tokenStore_1 = require_tokenStore();
1296
+ function credentialsFilePath() {
1297
+ return path.join((0, tokenStore_1.ascendaHome)(), "credentials.json");
1298
+ }
1299
+ function readMachineCredentials() {
1300
+ try {
1301
+ const raw = fs.readFileSync(credentialsFilePath(), "utf8").trim();
1302
+ if (!raw)
1303
+ return void 0;
1304
+ const parsed = JSON.parse(raw);
1305
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
1306
+ return void 0;
1307
+ return parsed;
1308
+ } catch {
1309
+ return void 0;
1310
+ }
1311
+ }
1312
+ function writeMachineCredentials(credentials) {
1313
+ const file = credentialsFilePath();
1314
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 448 });
1315
+ fs.writeFileSync(file, `${JSON.stringify(credentials, null, 2)}
1316
+ `, { encoding: "utf8", mode: 384 });
1317
+ if (process.platform !== "win32") {
1318
+ fs.chmodSync(path.dirname(file), 448);
1319
+ fs.chmodSync(file, 384);
1320
+ }
1321
+ }
1322
+ function writeTopLevelCredentials(credentials) {
1323
+ const existing = readMachineCredentials();
1324
+ const eventLogPath = credentials.eventLogPath ?? existing?.eventLogPath;
1325
+ writeMachineCredentials({
1326
+ ...credentials,
1327
+ ...eventLogPath ? { eventLogPath } : {},
1328
+ ...existing?.tools ? { tools: existing.tools } : {}
1329
+ });
1330
+ }
1331
+ function writeEventLogSetting(value) {
1332
+ const existing = readMachineCredentials() ?? {};
1333
+ writeMachineCredentials({ ...existing, eventLogPath: value });
1334
+ }
1335
+ function isLocalOnlyHostInstall(host, hasToken) {
1336
+ const credentials = readHostCredentials(host);
1337
+ if (!credentials?.localOnly)
1338
+ return false;
1339
+ if (process.env.ASCENDA_EVENT_WRITE_TOKEN)
1340
+ return false;
1341
+ return !(credentials.toolInstallationId && hasToken(credentials.toolInstallationId));
1342
+ }
1343
+ function readHostCredentials(host) {
1344
+ const entry = readMachineCredentials()?.tools?.[host];
1345
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
1346
+ return void 0;
1347
+ return entry;
1348
+ }
1349
+ function writeHostCredentials(host, credentials) {
1350
+ const existing = readMachineCredentials() ?? {};
1351
+ writeMachineCredentials({ ...existing, tools: { ...existing.tools ?? {}, [host]: credentials } });
1352
+ }
1353
+ function removeHostCredentials(host) {
1354
+ const existing = readMachineCredentials();
1355
+ if (!existing?.tools || !(host in existing.tools))
1356
+ return;
1357
+ const tools = { ...existing.tools };
1358
+ delete tools[host];
1359
+ const next = { ...existing };
1360
+ if (Object.keys(tools).length)
1361
+ next.tools = tools;
1362
+ else
1363
+ delete next.tools;
1364
+ writeMachineCredentials(next);
1365
+ }
1366
+ }
1367
+ });
1368
+
975
1369
  // ../packages/tool-kit/out/eventLog.js
976
1370
  var require_eventLog = __commonJS({
977
1371
  "../packages/tool-kit/out/eventLog.js"(exports) {
@@ -1014,14 +1408,22 @@ var require_eventLog = __commonJS({
1014
1408
  };
1015
1409
  }();
1016
1410
  Object.defineProperty(exports, "__esModule", { value: true });
1017
- exports.EVENT_LOG_ENV_VAR = void 0;
1411
+ exports.EVENT_LOG_OFF = exports.EVENT_LOG_ENV_VAR = void 0;
1018
1412
  exports.expandUserPath = expandUserPath;
1413
+ exports.defaultEventLogPath = defaultEventLogPath;
1414
+ exports.resolveEventLog = resolveEventLog;
1019
1415
  exports.resolveEventLogPath = resolveEventLogPath;
1416
+ exports.describeEventLog = describeEventLog;
1417
+ exports.parseEventLogFlag = parseEventLogFlag;
1020
1418
  exports.appendEventLog = appendEventLog;
1021
1419
  var fs = __importStar(__require("fs"));
1022
1420
  var os = __importStar(__require("os"));
1023
1421
  var path = __importStar(__require("path"));
1422
+ var agentEvent_1 = require_agentEvent();
1423
+ var credentials_1 = require_credentials();
1424
+ var tokenStore_1 = require_tokenStore();
1024
1425
  exports.EVENT_LOG_ENV_VAR = "ASCENDA_EVENT_LOG_FILE";
1426
+ exports.EVENT_LOG_OFF = "off";
1025
1427
  var MAX_BYTES = 5 * 1024 * 1024;
1026
1428
  function expandUserPath(configured) {
1027
1429
  const value = configured?.trim();
@@ -1033,15 +1435,55 @@ var require_eventLog = __commonJS({
1033
1435
  return path.join(os.homedir(), value.slice(2));
1034
1436
  return path.resolve(value);
1035
1437
  }
1036
- function resolveEventLogPath() {
1037
- return expandUserPath(process.env[exports.EVENT_LOG_ENV_VAR]);
1438
+ function defaultEventLogPath() {
1439
+ return path.join((0, tokenStore_1.ascendaHome)(), "events.jsonl");
1440
+ }
1441
+ function resolveEventLog(options = {}) {
1442
+ for (const [source, raw] of [
1443
+ ["env", process.env[exports.EVENT_LOG_ENV_VAR]],
1444
+ ["credentials", (0, credentials_1.readMachineCredentials)()?.eventLogPath]
1445
+ ]) {
1446
+ const value = raw?.trim();
1447
+ if (!value)
1448
+ continue;
1449
+ if (value.toLowerCase() === exports.EVENT_LOG_OFF)
1450
+ return { path: void 0, source: "disabled" };
1451
+ return { path: expandUserPath(value), source };
1452
+ }
1453
+ if (options.localOnly)
1454
+ return { path: defaultEventLogPath(), source: "unpaired-default" };
1455
+ return { path: void 0, source: "off" };
1456
+ }
1457
+ function resolveEventLogPath(options = {}) {
1458
+ return resolveEventLog(options).path;
1459
+ }
1460
+ function describeEventLog(setting, command) {
1461
+ switch (setting.source) {
1462
+ case "env":
1463
+ return `${setting.path} (from ${exports.EVENT_LOG_ENV_VAR})`;
1464
+ case "credentials":
1465
+ return `${setting.path} (set by ${command} --event-log)`;
1466
+ case "unpaired-default":
1467
+ return `${setting.path} (on because this install isn't paired; ${command} --event-log off to stop)`;
1468
+ case "disabled":
1469
+ return `off (turned off; ${command} --event-log to turn it on)`;
1470
+ case "off":
1471
+ return `off (${command} --event-log to keep a local copy of every event)`;
1472
+ }
1473
+ }
1474
+ function parseEventLogFlag(argv, index) {
1475
+ const peek = argv[index + 1];
1476
+ if (peek !== void 0 && !peek.startsWith("-"))
1477
+ return { value: peek, consumed: 1 };
1478
+ return { value: defaultEventLogPath(), consumed: 0 };
1038
1479
  }
1039
1480
  function appendEventLog(logFilePath, entry) {
1040
1481
  try {
1041
1482
  rotateIfLarge(logFilePath);
1042
1483
  const dir = path.dirname(logFilePath);
1043
1484
  fs.mkdirSync(dir, { recursive: true, mode: 448 });
1044
- fs.appendFileSync(logFilePath, `${JSON.stringify(entry)}
1485
+ const line = { ...entry, event: entry.event ?? (0, agentEvent_1.toAgentEvent)(entry.payload) };
1486
+ fs.appendFileSync(logFilePath, `${JSON.stringify(line)}
1045
1487
  `, { encoding: "utf8", mode: 384 });
1046
1488
  if (process.platform !== "win32")
1047
1489
  fs.chmodSync(logFilePath, 384);
@@ -1214,237 +1656,99 @@ var require_http = __commonJS({
1214
1656
  async function renewToolToken(apiBaseUrl, eventWriteToken, signal) {
1215
1657
  const response = await fetch(`${apiBaseUrl}/v1/tool-events/renew-token`, {
1216
1658
  method: "POST",
1217
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${eventWriteToken}` },
1218
- signal
1219
- });
1220
- if (response.status === 401)
1221
- return null;
1222
- if (!response.ok)
1223
- throw new AscendaApiError(response.status, void 0, await response.text());
1224
- return await response.json();
1225
- }
1226
- function isDeliveredStatus(value) {
1227
- return typeof value === "string" && tool_contract_1.TOOL_EVENT_DELIVERED_STATUSES.includes(value);
1228
- }
1229
- function readSuccessBody(body) {
1230
- let parsed;
1231
- try {
1232
- parsed = JSON.parse(body);
1233
- } catch {
1234
- return { duplicates: 0 };
1235
- }
1236
- if (!parsed || typeof parsed !== "object")
1237
- return { duplicates: 0 };
1238
- const single = parsed.status;
1239
- if (isDeliveredStatus(single))
1240
- return { duplicates: single === "duplicate" ? 1 : 0 };
1241
- const raw = parsed.results;
1242
- if (!Array.isArray(raw))
1243
- return { duplicates: 0 };
1244
- const results = [];
1245
- for (const item of raw) {
1246
- if (!item || typeof item !== "object")
1247
- continue;
1248
- const { index, status, reason } = item;
1249
- if (typeof index !== "number" || typeof status !== "string")
1250
- continue;
1251
- results.push({ index, status, ...typeof reason === "string" ? { reason } : {} });
1252
- }
1253
- return { duplicates: results.filter((item) => item.status === "duplicate").length, results };
1254
- }
1255
- function isRetryableStatus(status) {
1256
- return status === 408 || status === 429 || status !== void 0 && status >= 500 && status <= 599;
1257
- }
1258
- async function postToolEvent(apiBaseUrl, eventWriteToken, payload, signal) {
1259
- return sendIngest(`${apiBaseUrl}/v1/tool-events`, eventWriteToken, JSON.stringify(payload), signal);
1260
- }
1261
- async function postToolEventsBatch(apiBaseUrl, eventWriteToken, payloads, signal) {
1262
- return sendIngest(`${apiBaseUrl}/v1/tool-events/batch`, eventWriteToken, JSON.stringify({ events: payloads }), signal);
1263
- }
1264
- async function sendIngest(url, eventWriteToken, body, signal) {
1265
- try {
1266
- const response = await fetch(url, {
1267
- method: "POST",
1268
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${eventWriteToken}` },
1269
- body,
1270
- signal
1271
- });
1272
- return parseIngestResponse(response);
1273
- } catch (error2) {
1274
- return {
1275
- result: "transport_error",
1276
- detail: error2 instanceof Error ? `${error2.name}: ${error2.message}` : String(error2)
1277
- };
1278
- }
1279
- }
1280
- async function parseIngestResponse(response) {
1281
- if (response.ok) {
1282
- const outcome = { result: "accepted", httpStatus: response.status };
1283
- let read = { duplicates: 0 };
1284
- try {
1285
- read = readSuccessBody(await response.text());
1286
- } catch {
1287
- read = { duplicates: 0 };
1288
- }
1289
- return {
1290
- ...outcome,
1291
- ...read.duplicates > 0 ? { duplicates: read.duplicates } : {},
1292
- ...read.results !== void 0 ? { results: read.results } : {}
1293
- };
1294
- }
1295
- const body = await response.text();
1296
- let errorCode;
1297
- try {
1298
- errorCode = JSON.parse(body).error;
1299
- } catch {
1300
- errorCode = void 0;
1301
- }
1302
- const base = { httpStatus: response.status, errorCode, detail: body || void 0 };
1303
- if (response.status === 401)
1304
- return { ...base, result: "auth_failed" };
1305
- if (response.status === 403 && errorCode === "consent_missing_or_expired")
1306
- return { ...base, result: "consent_missing" };
1307
- if (response.status === 400 || response.status === 422)
1308
- return { ...base, result: "validation_failed" };
1309
- return { ...base, result: "transport_error" };
1310
- }
1311
- }
1312
- });
1313
-
1314
- // ../packages/tool-kit/out/tokenStore.js
1315
- var require_tokenStore = __commonJS({
1316
- "../packages/tool-kit/out/tokenStore.js"(exports) {
1317
- "use strict";
1318
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
1319
- if (k2 === void 0) k2 = k;
1320
- var desc = Object.getOwnPropertyDescriptor(m, k);
1321
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1322
- desc = { enumerable: true, get: function() {
1323
- return m[k];
1324
- } };
1325
- }
1326
- Object.defineProperty(o, k2, desc);
1327
- } : function(o, m, k, k2) {
1328
- if (k2 === void 0) k2 = k;
1329
- o[k2] = m[k];
1330
- });
1331
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
1332
- Object.defineProperty(o, "default", { enumerable: true, value: v });
1333
- } : function(o, v) {
1334
- o["default"] = v;
1335
- });
1336
- var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
1337
- var ownKeys = function(o) {
1338
- ownKeys = Object.getOwnPropertyNames || function(o2) {
1339
- var ar = [];
1340
- for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1341
- return ar;
1342
- };
1343
- return ownKeys(o);
1344
- };
1345
- return function(mod) {
1346
- if (mod && mod.__esModule) return mod;
1347
- var result = {};
1348
- if (mod != null) {
1349
- for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1350
- }
1351
- __setModuleDefault(result, mod);
1352
- return result;
1353
- };
1354
- }();
1355
- Object.defineProperty(exports, "__esModule", { value: true });
1356
- exports.EVENT_TOKEN_TTL_MS = void 0;
1357
- exports.ascendaHome = ascendaHome;
1358
- exports.defaultTokenFilePath = defaultTokenFilePath2;
1359
- exports.tokenExpiryFilePath = tokenExpiryFilePath;
1360
- exports.persistEventWriteToken = persistEventWriteToken2;
1361
- exports.readTokenExpiry = readTokenExpiry;
1362
- exports.listPersistedToolInstallationIds = listPersistedToolInstallationIds;
1363
- exports.readTokenFile = readTokenFile2;
1364
- exports.sanitizeFilePart = sanitizeFilePart;
1365
- var fs = __importStar(__require("fs"));
1366
- var os = __importStar(__require("os"));
1367
- var path = __importStar(__require("path"));
1368
- function ascendaHome(home = os.homedir()) {
1369
- return process.env.ASCENDA_HOME ?? path.join(home, ".ascenda");
1370
- }
1371
- function defaultTokenFilePath2(toolInstallationId) {
1372
- return path.join(ascendaHome(), "tokens", sanitizeFilePart(toolInstallationId));
1373
- }
1374
- function tokenExpiryFilePath(tokenFilePath) {
1375
- return path.join(path.dirname(tokenFilePath), "expiry", path.basename(tokenFilePath));
1376
- }
1377
- function persistEventWriteToken2(tokenFilePath, token, expiresAt) {
1378
- const dir = path.dirname(tokenFilePath);
1379
- fs.mkdirSync(dir, { recursive: true, mode: 448 });
1380
- fs.writeFileSync(tokenFilePath, token, { encoding: "utf8", mode: 384 });
1381
- if (process.platform !== "win32") {
1382
- fs.chmodSync(dir, 448);
1383
- fs.chmodSync(tokenFilePath, 384);
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
- }
1659
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${eventWriteToken}` },
1660
+ signal
1661
+ });
1662
+ if (response.status === 401)
1663
+ return null;
1664
+ if (!response.ok)
1665
+ throw new AscendaApiError(response.status, void 0, await response.text());
1666
+ return await response.json();
1395
1667
  }
1396
- exports.EVENT_TOKEN_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
1397
- function readTokenExpiry(tokenFilePath) {
1668
+ function isDeliveredStatus(value) {
1669
+ return typeof value === "string" && tool_contract_1.TOOL_EVENT_DELIVERED_STATUSES.includes(value);
1670
+ }
1671
+ function readSuccessBody(body) {
1672
+ let parsed;
1398
1673
  try {
1399
- const recorded = Date.parse(fs.readFileSync(tokenExpiryFilePath(tokenFilePath), "utf8").trim());
1400
- if (Number.isFinite(recorded))
1401
- return recorded;
1674
+ parsed = JSON.parse(body);
1402
1675
  } catch {
1676
+ return { duplicates: 0 };
1403
1677
  }
1404
- try {
1405
- return fs.statSync(tokenFilePath).mtimeMs + exports.EVENT_TOKEN_TTL_MS;
1406
- } catch {
1407
- return void 0;
1678
+ if (!parsed || typeof parsed !== "object")
1679
+ return { duplicates: 0 };
1680
+ const single = parsed.status;
1681
+ if (isDeliveredStatus(single))
1682
+ return { duplicates: single === "duplicate" ? 1 : 0 };
1683
+ const raw = parsed.results;
1684
+ if (!Array.isArray(raw))
1685
+ return { duplicates: 0 };
1686
+ const results = [];
1687
+ for (const item of raw) {
1688
+ if (!item || typeof item !== "object")
1689
+ continue;
1690
+ const { index, status, reason } = item;
1691
+ if (typeof index !== "number" || typeof status !== "string")
1692
+ continue;
1693
+ results.push({ index, status, ...typeof reason === "string" ? { reason } : {} });
1408
1694
  }
1695
+ return { duplicates: results.filter((item) => item.status === "duplicate").length, results };
1409
1696
  }
1410
- function listPersistedToolInstallationIds(toolType) {
1411
- const prefix = `${sanitizeFilePart(toolType)}_`;
1412
- const dir = path.join(ascendaHome(), "tokens");
1413
- let names;
1697
+ function isRetryableStatus(status) {
1698
+ return status === 408 || status === 429 || status !== void 0 && status >= 500 && status <= 599;
1699
+ }
1700
+ async function postToolEvent(apiBaseUrl, eventWriteToken, payload, signal) {
1701
+ return sendIngest(`${apiBaseUrl}/v1/tool-events`, eventWriteToken, JSON.stringify(payload), signal);
1702
+ }
1703
+ async function postToolEventsBatch(apiBaseUrl, eventWriteToken, payloads, signal) {
1704
+ return sendIngest(`${apiBaseUrl}/v1/tool-events/batch`, eventWriteToken, JSON.stringify({ events: payloads }), signal);
1705
+ }
1706
+ async function sendIngest(url, eventWriteToken, body, signal) {
1414
1707
  try {
1415
- names = fs.readdirSync(dir);
1416
- } catch {
1417
- return [];
1708
+ const response = await fetch(url, {
1709
+ method: "POST",
1710
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${eventWriteToken}` },
1711
+ body,
1712
+ signal
1713
+ });
1714
+ return parseIngestResponse(response);
1715
+ } catch (error2) {
1716
+ return {
1717
+ result: "transport_error",
1718
+ detail: error2 instanceof Error ? `${error2.name}: ${error2.message}` : String(error2)
1719
+ };
1418
1720
  }
1419
- const ids = [];
1420
- for (const name of names.sort()) {
1421
- if (!name.startsWith(prefix) || name.length === prefix.length)
1422
- continue;
1423
- const file = path.join(dir, name);
1721
+ }
1722
+ async function parseIngestResponse(response) {
1723
+ if (response.ok) {
1724
+ const outcome = { result: "accepted", httpStatus: response.status };
1725
+ let read = { duplicates: 0 };
1424
1726
  try {
1425
- if (!fs.statSync(file).isFile())
1426
- continue;
1727
+ read = readSuccessBody(await response.text());
1427
1728
  } catch {
1428
- continue;
1729
+ read = { duplicates: 0 };
1429
1730
  }
1430
- if (readTokenFile2(file) === void 0)
1431
- continue;
1432
- ids.push(`${toolType}:${name.slice(prefix.length)}`);
1731
+ return {
1732
+ ...outcome,
1733
+ ...read.duplicates > 0 ? { duplicates: read.duplicates } : {},
1734
+ ...read.results !== void 0 ? { results: read.results } : {}
1735
+ };
1433
1736
  }
1434
- return ids;
1435
- }
1436
- function readTokenFile2(tokenFilePath) {
1737
+ const body = await response.text();
1738
+ let errorCode;
1437
1739
  try {
1438
- if (!fs.existsSync(tokenFilePath))
1439
- return void 0;
1440
- const value = fs.readFileSync(tokenFilePath, "utf8").trim();
1441
- return value || void 0;
1740
+ errorCode = JSON.parse(body).error;
1442
1741
  } catch {
1443
- return void 0;
1742
+ errorCode = void 0;
1444
1743
  }
1445
- }
1446
- function sanitizeFilePart(value) {
1447
- return value.replace(/[^a-zA-Z0-9._-]/g, "_");
1744
+ const base = { httpStatus: response.status, errorCode, detail: body || void 0 };
1745
+ if (response.status === 401)
1746
+ return { ...base, result: "auth_failed" };
1747
+ if (response.status === 403 && errorCode === "consent_missing_or_expired")
1748
+ return { ...base, result: "consent_missing" };
1749
+ if (response.status === 400 || response.status === 422)
1750
+ return { ...base, result: "validation_failed" };
1751
+ return { ...base, result: "transport_error" };
1448
1752
  }
1449
1753
  }
1450
1754
  });
@@ -1853,6 +2157,7 @@ var require_eventSender = __commonJS({
1853
2157
  "use strict";
1854
2158
  Object.defineProperty(exports, "__esModule", { value: true });
1855
2159
  exports.AscendaEventSender = exports.TOKEN_RENEW_LEAD_MS = exports.AscendaSemanticEventError = void 0;
2160
+ exports.buildEventBody = buildEventBody;
1856
2161
  exports.buildEventPayload = buildEventPayload;
1857
2162
  var afterHours_1 = require_afterHours();
1858
2163
  var tool_contract_1 = require_out();
@@ -1871,12 +2176,10 @@ var require_eventSender = __commonJS({
1871
2176
  }
1872
2177
  };
1873
2178
  exports.AscendaSemanticEventError = AscendaSemanticEventError;
1874
- function buildEventPayload(identity, mapped) {
2179
+ function buildEventBody(identity, mapped) {
1875
2180
  return {
1876
- toolInstallationId: identity.toolInstallationId,
1877
2181
  source: identity.source,
1878
2182
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1879
- idempotencyKey: (0, payload_1.mintIdempotencyKey)(),
1880
2183
  utcOffsetMinutes: (0, afterHours_1.utcOffsetMinutesAt)(/* @__PURE__ */ new Date()),
1881
2184
  sessionId: identity.sessionId ?? void 0,
1882
2185
  workspaceHash: identity.workspaceHash ?? void 0,
@@ -1888,6 +2191,9 @@ var require_eventSender = __commonJS({
1888
2191
  metadata: withCollectorVersion(mapped.metadata)
1889
2192
  };
1890
2193
  }
2194
+ function buildEventPayload(identity, mapped) {
2195
+ return (0, tool_contract_1.joinEventPayload)({ toolInstallationId: identity.toolInstallationId, idempotencyKey: (0, payload_1.mintIdempotencyKey)() }, buildEventBody(identity, mapped));
2196
+ }
1891
2197
  function withCollectorVersion(metadata) {
1892
2198
  return { ...metadata, collectorVersion: collectorVersion_1.COLLECTOR_VERSION };
1893
2199
  }
@@ -1963,12 +2269,10 @@ var require_eventSender = __commonJS({
1963
2269
  if (!mapped.metadata.skillVersion || !mapped.metadata.skillVersion.trim()) {
1964
2270
  throw new AscendaSemanticEventError(`metadata.skillVersion is required for semantic event "${mapped.eventType}".`);
1965
2271
  }
1966
- const payload = {
1967
- toolInstallationId: this.config.toolInstallationId,
2272
+ const body = {
1968
2273
  source: this.config.source,
1969
2274
  eventType: mapped.eventType,
1970
2275
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1971
- idempotencyKey: (0, payload_1.mintIdempotencyKey)(),
1972
2276
  utcOffsetMinutes: (0, afterHours_1.utcOffsetMinutesAt)(/* @__PURE__ */ new Date()),
1973
2277
  severity: "low",
1974
2278
  sessionId: this.config.sessionId ?? void 0,
@@ -1979,7 +2283,7 @@ var require_eventSender = __commonJS({
1979
2283
  privacyMode: "metadata_only",
1980
2284
  metadata: withCollectorVersion(mapped.metadata)
1981
2285
  };
1982
- return this.post(payload);
2286
+ return this.post((0, tool_contract_1.joinEventPayload)(this.envelope(), body));
1983
2287
  }
1984
2288
  /**
1985
2289
  * Sends a collaboration event under `workflow_telemetry`.
@@ -1994,12 +2298,10 @@ var require_eventSender = __commonJS({
1994
2298
  if (!tool_contract_1.COLLABORATION_EVENT_TYPES.includes(mapped.eventType)) {
1995
2299
  throw new AscendaSemanticEventError(`"${mapped.eventType}" is not a collaboration event type. Use send() for a deterministic host event.`);
1996
2300
  }
1997
- const payload = {
1998
- toolInstallationId: this.config.toolInstallationId,
2301
+ const body = {
1999
2302
  source: this.config.source,
2000
2303
  eventType: mapped.eventType,
2001
2304
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
2002
- idempotencyKey: (0, payload_1.mintIdempotencyKey)(),
2003
2305
  utcOffsetMinutes: (0, afterHours_1.utcOffsetMinutesAt)(/* @__PURE__ */ new Date()),
2004
2306
  severity: "low",
2005
2307
  sessionId: this.config.sessionId ?? void 0,
@@ -2010,7 +2312,11 @@ var require_eventSender = __commonJS({
2010
2312
  privacyMode: "metadata_only",
2011
2313
  metadata: withCollectorVersion(mapped.metadata)
2012
2314
  };
2013
- return this.post(payload);
2315
+ return this.post((0, tool_contract_1.joinEventPayload)(this.envelope(), body));
2316
+ }
2317
+ /** A fresh envelope per event: the key belongs to the event, so every retry of it reuses this one. */
2318
+ envelope() {
2319
+ return { toolInstallationId: this.config.toolInstallationId, idempotencyKey: (0, payload_1.mintIdempotencyKey)() };
2014
2320
  }
2015
2321
  /**
2016
2322
  * The single choke point every event passes through, and therefore the only
@@ -2430,123 +2736,6 @@ var require_contextRegistry = __commonJS({
2430
2736
  }
2431
2737
  });
2432
2738
 
2433
- // ../packages/tool-kit/out/credentials.js
2434
- var require_credentials = __commonJS({
2435
- "../packages/tool-kit/out/credentials.js"(exports) {
2436
- "use strict";
2437
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
2438
- if (k2 === void 0) k2 = k;
2439
- var desc = Object.getOwnPropertyDescriptor(m, k);
2440
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2441
- desc = { enumerable: true, get: function() {
2442
- return m[k];
2443
- } };
2444
- }
2445
- Object.defineProperty(o, k2, desc);
2446
- } : function(o, m, k, k2) {
2447
- if (k2 === void 0) k2 = k;
2448
- o[k2] = m[k];
2449
- });
2450
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
2451
- Object.defineProperty(o, "default", { enumerable: true, value: v });
2452
- } : function(o, v) {
2453
- o["default"] = v;
2454
- });
2455
- var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
2456
- var ownKeys = function(o) {
2457
- ownKeys = Object.getOwnPropertyNames || function(o2) {
2458
- var ar = [];
2459
- for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
2460
- return ar;
2461
- };
2462
- return ownKeys(o);
2463
- };
2464
- return function(mod) {
2465
- if (mod && mod.__esModule) return mod;
2466
- var result = {};
2467
- if (mod != null) {
2468
- for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2469
- }
2470
- __setModuleDefault(result, mod);
2471
- return result;
2472
- };
2473
- }();
2474
- Object.defineProperty(exports, "__esModule", { value: true });
2475
- exports.credentialsFilePath = credentialsFilePath;
2476
- exports.readMachineCredentials = readMachineCredentials;
2477
- exports.writeMachineCredentials = writeMachineCredentials;
2478
- exports.writeTopLevelCredentials = writeTopLevelCredentials;
2479
- exports.isLocalOnlyHostInstall = isLocalOnlyHostInstall;
2480
- exports.readHostCredentials = readHostCredentials;
2481
- exports.writeHostCredentials = writeHostCredentials;
2482
- exports.removeHostCredentials = removeHostCredentials;
2483
- var fs = __importStar(__require("fs"));
2484
- var path = __importStar(__require("path"));
2485
- var tokenStore_1 = require_tokenStore();
2486
- function credentialsFilePath() {
2487
- return path.join((0, tokenStore_1.ascendaHome)(), "credentials.json");
2488
- }
2489
- function readMachineCredentials() {
2490
- try {
2491
- const raw = fs.readFileSync(credentialsFilePath(), "utf8").trim();
2492
- if (!raw)
2493
- return void 0;
2494
- const parsed = JSON.parse(raw);
2495
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
2496
- return void 0;
2497
- return parsed;
2498
- } catch {
2499
- return void 0;
2500
- }
2501
- }
2502
- function writeMachineCredentials(credentials) {
2503
- const file = credentialsFilePath();
2504
- fs.mkdirSync(path.dirname(file), { recursive: true, mode: 448 });
2505
- fs.writeFileSync(file, `${JSON.stringify(credentials, null, 2)}
2506
- `, { encoding: "utf8", mode: 384 });
2507
- if (process.platform !== "win32") {
2508
- fs.chmodSync(path.dirname(file), 448);
2509
- fs.chmodSync(file, 384);
2510
- }
2511
- }
2512
- function writeTopLevelCredentials(credentials) {
2513
- const existing = readMachineCredentials();
2514
- writeMachineCredentials({ ...credentials, ...existing?.tools ? { tools: existing.tools } : {} });
2515
- }
2516
- function isLocalOnlyHostInstall(host, hasToken) {
2517
- const credentials = readHostCredentials(host);
2518
- if (!credentials?.localOnly)
2519
- return false;
2520
- if (process.env.ASCENDA_EVENT_WRITE_TOKEN)
2521
- return false;
2522
- return !(credentials.toolInstallationId && hasToken(credentials.toolInstallationId));
2523
- }
2524
- function readHostCredentials(host) {
2525
- const entry = readMachineCredentials()?.tools?.[host];
2526
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
2527
- return void 0;
2528
- return entry;
2529
- }
2530
- function writeHostCredentials(host, credentials) {
2531
- const existing = readMachineCredentials() ?? {};
2532
- writeMachineCredentials({ ...existing, tools: { ...existing.tools ?? {}, [host]: credentials } });
2533
- }
2534
- function removeHostCredentials(host) {
2535
- const existing = readMachineCredentials();
2536
- if (!existing?.tools || !(host in existing.tools))
2537
- return;
2538
- const tools = { ...existing.tools };
2539
- delete tools[host];
2540
- const next = { ...existing };
2541
- if (Object.keys(tools).length)
2542
- next.tools = tools;
2543
- else
2544
- delete next.tools;
2545
- writeMachineCredentials(next);
2546
- }
2547
- }
2548
- });
2549
-
2550
2739
  // ../packages/tool-kit/out/forgeProject.js
2551
2740
  var require_forgeProject = __commonJS({
2552
2741
  "../packages/tool-kit/out/forgeProject.js"(exports) {
@@ -3090,8 +3279,12 @@ var require_hookAdapter = __commonJS({
3090
3279
  return;
3091
3280
  const notice = options.onNotice ?? ((message) => console.error(message));
3092
3281
  const hasToken = (id) => (0, tokenStore_1.readTokenFile)(process.env.ASCENDA_EVENT_WRITE_TOKEN_FILE ?? (0, tokenStore_1.defaultTokenFilePath)(id)) !== void 0;
3093
- if (options.host && (0, credentials_1.isLocalOnlyHostInstall)(options.host, hasToken))
3282
+ if (options.host && (0, credentials_1.isLocalOnlyHostInstall)(options.host, hasToken)) {
3283
+ const logFile = (0, eventLog_1.resolveEventLogPath)({ localOnly: true });
3284
+ if (logFile)
3285
+ logUnsent(logFile, events, options);
3094
3286
  return;
3287
+ }
3095
3288
  let config2;
3096
3289
  try {
3097
3290
  config2 = loadCliAgentConfig(options.toolType, options.sessionId, options.cwd, options);
@@ -3101,20 +3294,7 @@ var require_hookAdapter = __commonJS({
3101
3294
  const logFile = (0, eventLog_1.resolveEventLogPath)();
3102
3295
  if (!logFile)
3103
3296
  throw error2;
3104
- const contextHashes = resolveContextHashes(options.cwd);
3105
- for (const event of events) {
3106
- (0, eventLog_1.appendEventLog)(logFile, {
3107
- loggedAt: (/* @__PURE__ */ new Date()).toISOString(),
3108
- delivery: "not_sent",
3109
- payload: (0, eventSender_1.buildEventPayload)({
3110
- toolInstallationId: `${options.toolType}:unpaired`,
3111
- source: options.source,
3112
- sessionId: options.sessionId ?? null,
3113
- workspaceHash: contextHashes.workspaceHash,
3114
- projectHash: contextHashes.projectHash
3115
- }, event)
3116
- });
3117
- }
3297
+ logUnsent(logFile, events, options);
3118
3298
  return;
3119
3299
  }
3120
3300
  const sender = new eventSender_1.AscendaEventSender({
@@ -3144,6 +3324,22 @@ var require_hookAdapter = __commonJS({
3144
3324
  return;
3145
3325
  }
3146
3326
  }
3327
+ function logUnsent(logFile, events, options) {
3328
+ const contextHashes = resolveContextHashes(options.cwd);
3329
+ for (const event of events) {
3330
+ (0, eventLog_1.appendEventLog)(logFile, {
3331
+ loggedAt: (/* @__PURE__ */ new Date()).toISOString(),
3332
+ delivery: "not_sent",
3333
+ payload: (0, eventSender_1.buildEventPayload)({
3334
+ toolInstallationId: `${options.toolType}:unpaired`,
3335
+ source: options.source,
3336
+ sessionId: process.env.ASCENDA_SESSION_ID?.trim() || options.sessionId || null,
3337
+ workspaceHash: contextHashes.workspaceHash,
3338
+ projectHash: contextHashes.projectHash
3339
+ }, event)
3340
+ });
3341
+ }
3342
+ }
3147
3343
  function journalSkippedSend(host, error2) {
3148
3344
  const who = host ? `${host}: ` : "";
3149
3345
  (0, stateStore_1.recordSendOutcome)((0, stateStore_1.unresolvedStateFilePath)(error2.toolType), (0, stateStore_1.unresolvedToolInstallationId)(error2.toolType), "skipped_no_installation_id", {
@@ -4700,6 +4896,7 @@ var require_cliAgentSetup = __commonJS({
4700
4896
  var path = __importStar(__require("path"));
4701
4897
  var collectorVersion_1 = require_collectorVersion();
4702
4898
  var credentials_1 = require_credentials();
4899
+ var eventLog_1 = require_eventLog();
4703
4900
  var hookAdapter_1 = require_hookAdapter();
4704
4901
  var http_1 = require_http();
4705
4902
  var hookSet_1 = require_hookSet();
@@ -4738,6 +4935,8 @@ Options
4738
4935
  --tool-installation-id <id> reuse an existing pairing instead of creating one
4739
4936
  --token <eventWriteToken> reuse an existing token (stored 0600, never printed)
4740
4937
  --no-pair install without pairing: local features on, nothing sent
4938
+ --event-log [path|off] keep every event in a local JSONL file (default ~/.ascenda/events.jsonl).
4939
+ On by default when not paired; machine-wide, shared by every agent
4741
4940
  --scope user|project where hooks are registered (default user: every project)
4742
4941
  --project-dir <path> project root for --scope project (default cwd)
4743
4942
  --dry-run print what would change, write nothing
@@ -4792,6 +4991,8 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
4792
4991
  toolInstallationId,
4793
4992
  ...identity ? { pairedAt: now } : { localOnly: true, installedAt: now }
4794
4993
  });
4994
+ if (options.eventLog !== void 0)
4995
+ (0, credentials_1.writeEventLogSetting)(options.eventLog);
4795
4996
  }
4796
4997
  if (isHomeProject(options)) {
4797
4998
  detail("scope", "user (a project install in the home folder only loads when the agent starts there)");
@@ -4826,6 +5027,11 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
4826
5027
  else
4827
5028
  row("warn", "pairing", "not paired: pairing did not finish");
4828
5029
  detail("credentials", `${(0, hookRunner_1.tidyHomePath)((0, credentials_1.credentialsFilePath)(), os.homedir())} (tools.${spec.host})`);
5030
+ const eventLog = (0, eventLog_1.resolveEventLog)({ localOnly: !identity });
5031
+ if (eventLog.path)
5032
+ row("ok", "events", `${(0, hookRunner_1.tidyHomePath)(eventLog.path, os.homedir())} ${ui.dim("(on this machine only)")}`);
5033
+ else if (options.eventLog !== void 0)
5034
+ row("info", "events", "off");
4829
5035
  if (options.dryRun) {
4830
5036
  console.log("\nDry run. Nothing was written.");
4831
5037
  return 0;
@@ -4836,6 +5042,8 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
4836
5042
  if (chosenLocal) {
4837
5043
  console.log(`${ui.mark("ok")} ${ui.bold("Ready.")} The screen saver and the Ascenda app's live view work now.`);
4838
5044
  console.log(" They run on this machine and need no account or pairing.");
5045
+ if (eventLog.path)
5046
+ console.log(` Every event is also written to ${(0, hookRunner_1.tidyHomePath)(eventLog.path, os.homedir())}, for you or any tool to read.`);
4839
5047
  } else if (!identity) {
4840
5048
  console.log(`${ui.mark("warn")} ${ui.bold("Installed, not paired.")} The screen saver and the live view work now.`);
4841
5049
  console.log(" Your sessions won't reach Ascenda's servers until pairing completes.");
@@ -4918,6 +5126,12 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
4918
5126
  case "--dry-run":
4919
5127
  options.dryRun = true;
4920
5128
  break;
5129
+ case "--event-log": {
5130
+ const { value, consumed } = (0, eventLog_1.parseEventLogFlag)(argv, i);
5131
+ options.eventLog = value;
5132
+ i += consumed;
5133
+ break;
5134
+ }
4921
5135
  case "--no-pair":
4922
5136
  // `--no-pairing` is the spelling this landed under first. Both appeared
4923
5137
  // only in an unreleased changelog, so this alias exists to spare anyone
@@ -5140,6 +5354,7 @@ ${serialised}`);
5140
5354
  console.log(`api base url ${credentials?.apiBaseUrl ?? "\u2014 not configured"}`);
5141
5355
  console.log(`pairing ${credentials?.toolInstallationId ?? "\u2014 not paired"}${localOnly ? " (installed, not paired \u2014 local features active, telemetry inactive)" : ""}`);
5142
5356
  console.log(`token ${localOnly ? "\u2014 none needed until this install is paired" : tokenFile && (0, tokenStore_1.readTokenFile)(tokenFile) ? "present" : "\u2014 missing"}`);
5357
+ console.log(`event log ${(0, eventLog_1.describeEventLog)((0, eventLog_1.resolveEventLog)({ localOnly }), `npx ${spec.packageName} setup`)}`);
5143
5358
  console.log(`hook binary ${fs.existsSync(binary) ? binary : "\u2014 not installed"}`);
5144
5359
  const node = process.platform === "win32" ? void 0 : (0, hookRunner_1.resolveHookNode)(binary);
5145
5360
  if (node) {
@@ -5223,6 +5438,8 @@ ${serialised}`);
5223
5438
  lines.push(` Live signal (could not be checked: ${error2 instanceof Error ? error2.message : String(error2)})`);
5224
5439
  }
5225
5440
  lines.push("", ...accountLines(ui, spec));
5441
+ const localOnly = (0, credentials_1.isLocalOnlyHostInstall)(spec.host, (id) => (0, tokenStore_1.readTokenFile)((0, tokenStore_1.defaultTokenFilePath)(id)) !== void 0);
5442
+ lines.push("", ` ${ui.bold("Local events")} ${(0, eventLog_1.describeEventLog)((0, eventLog_1.resolveEventLog)({ localOnly }), `npx ${spec.packageName} setup`)}`);
5226
5443
  console.log(lines.join("\n"));
5227
5444
  return 0;
5228
5445
  }
@@ -5236,9 +5453,9 @@ ${serialised}`);
5236
5453
  ` ${ui.bold("Account sync")} ${ui.dim("(optional; this install isn't paired)")}`,
5237
5454
  ...id ? [ui.dim(row("info", "Installation id", id))] : [],
5238
5455
  "",
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:",
5456
+ " Not paired, which is fine: the screen saver, the live view and the local",
5457
+ " event log work without it. Nothing leaves this machine and nothing is queued.",
5458
+ " To send your sessions to Ascenda's servers, so they appear in the app:",
5242
5459
  ` ${ui.cyan(`${cliAgentSelfCommand(spec)} setup`)}`
5243
5460
  ];
5244
5461
  }
@@ -5519,14 +5736,14 @@ var require_agentProcess = __commonJS({
5519
5736
  });
5520
5737
 
5521
5738
  // ../packages/tool-kit/out/index.js
5522
- var require_out2 = __commonJS({
5739
+ var require_out3 = __commonJS({
5523
5740
  "../packages/tool-kit/out/index.js"(exports) {
5524
5741
  "use strict";
5525
5742
  Object.defineProperty(exports, "__esModule", { value: true });
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;
5743
+ exports.findStaleHookCommands = exports.cliAgentHookBinPath = exports.resolveContextHashes = exports.resolveCliAgentInstallationId = exports.loadCliAgentConfig = exports.deliverHookEvents = exports.MissingInstallationIdError = exports.DEFAULT_API_BASE_URL = exports.resolveEventLogPath = exports.resolveEventLog = exports.parseEventLogFlag = exports.expandUserPath = exports.describeEventLog = exports.defaultEventLogPath = exports.appendEventLog = exports.EVENT_LOG_OFF = exports.EVENT_LOG_ENV_VAR = exports.toAgentEvent = exports.buildEventPayload = exports.buildEventBody = 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;
5744
+ 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.writeEventLogSetting = exports.writeHostCredentials = exports.removeHostCredentials = exports.readMachineCredentials = exports.readHostCredentials = exports.isLocalOnlyHostInstall = exports.credentialsFilePath = exports.renderSetupDisclosure = exports.REFUSALS = exports.FREE_TEXT_KEYS = exports.FAMILY_SENTENCES = exports.ALWAYS_SENT = exports.writeHookSettings = exports.runCliAgentSetup = exports.registeredHookSets = exports.isCliAgentManagementCommand = void 0;
5745
+ 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 = exports.recordWorkContextAlias = exports.recordWorkContext = exports.readBranchName = exports.normalizeBranchName = exports.deriveBranchHashForCwd = exports.deriveBranchHash = exports.deriveWorkContext = exports.hashWithMachineSalt = void 0;
5746
+ 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 = exports.findAgentProcess = exports.findAgentPid = exports.AGENT_PROCESS = exports.readViaPlugin = exports.readHookSet = exports.isHookSet = exports.hookSetOfCommand = exports.hookSetChanges = void 0;
5530
5747
  var commandClassifier_1 = require_commandClassifier();
5531
5748
  Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
5532
5749
  return commandClassifier_1.classifyCommand;
@@ -5627,19 +5844,41 @@ var require_out2 = __commonJS({
5627
5844
  Object.defineProperty(exports, "TOKEN_RENEW_LEAD_MS", { enumerable: true, get: function() {
5628
5845
  return eventSender_1.TOKEN_RENEW_LEAD_MS;
5629
5846
  } });
5847
+ Object.defineProperty(exports, "buildEventBody", { enumerable: true, get: function() {
5848
+ return eventSender_1.buildEventBody;
5849
+ } });
5630
5850
  Object.defineProperty(exports, "buildEventPayload", { enumerable: true, get: function() {
5631
5851
  return eventSender_1.buildEventPayload;
5632
5852
  } });
5853
+ var agentEvent_1 = require_agentEvent();
5854
+ Object.defineProperty(exports, "toAgentEvent", { enumerable: true, get: function() {
5855
+ return agentEvent_1.toAgentEvent;
5856
+ } });
5633
5857
  var eventLog_1 = require_eventLog();
5634
5858
  Object.defineProperty(exports, "EVENT_LOG_ENV_VAR", { enumerable: true, get: function() {
5635
5859
  return eventLog_1.EVENT_LOG_ENV_VAR;
5636
5860
  } });
5861
+ Object.defineProperty(exports, "EVENT_LOG_OFF", { enumerable: true, get: function() {
5862
+ return eventLog_1.EVENT_LOG_OFF;
5863
+ } });
5637
5864
  Object.defineProperty(exports, "appendEventLog", { enumerable: true, get: function() {
5638
5865
  return eventLog_1.appendEventLog;
5639
5866
  } });
5867
+ Object.defineProperty(exports, "defaultEventLogPath", { enumerable: true, get: function() {
5868
+ return eventLog_1.defaultEventLogPath;
5869
+ } });
5870
+ Object.defineProperty(exports, "describeEventLog", { enumerable: true, get: function() {
5871
+ return eventLog_1.describeEventLog;
5872
+ } });
5640
5873
  Object.defineProperty(exports, "expandUserPath", { enumerable: true, get: function() {
5641
5874
  return eventLog_1.expandUserPath;
5642
5875
  } });
5876
+ Object.defineProperty(exports, "parseEventLogFlag", { enumerable: true, get: function() {
5877
+ return eventLog_1.parseEventLogFlag;
5878
+ } });
5879
+ Object.defineProperty(exports, "resolveEventLog", { enumerable: true, get: function() {
5880
+ return eventLog_1.resolveEventLog;
5881
+ } });
5643
5882
  Object.defineProperty(exports, "resolveEventLogPath", { enumerable: true, get: function() {
5644
5883
  return eventLog_1.resolveEventLogPath;
5645
5884
  } });
@@ -5716,6 +5955,9 @@ var require_out2 = __commonJS({
5716
5955
  Object.defineProperty(exports, "writeHostCredentials", { enumerable: true, get: function() {
5717
5956
  return credentials_1.writeHostCredentials;
5718
5957
  } });
5958
+ Object.defineProperty(exports, "writeEventLogSetting", { enumerable: true, get: function() {
5959
+ return credentials_1.writeEventLogSetting;
5960
+ } });
5719
5961
  Object.defineProperty(exports, "writeMachineCredentials", { enumerable: true, get: function() {
5720
5962
  return credentials_1.writeMachineCredentials;
5721
5963
  } });
@@ -19093,7 +19335,7 @@ var StdioServerTransport = class {
19093
19335
  };
19094
19336
 
19095
19337
  // src/config.ts
19096
- var import_tool_kit = __toESM(require_out2(), 1);
19338
+ var import_tool_kit = __toESM(require_out3(), 1);
19097
19339
  import { randomUUID } from "node:crypto";
19098
19340
  function loadConfigFromEnv() {
19099
19341
  const apiBaseUrl = (process.env.ASCENDA_API_BASE_URL ?? "https://api.ascenda.one").replace(/\/$/, "");
@@ -27222,7 +27464,7 @@ var EMPTY_COMPLETION_RESULT = {
27222
27464
  };
27223
27465
 
27224
27466
  // src/server.ts
27225
- var import_tool_kit2 = __toESM(require_out2(), 1);
27467
+ var import_tool_kit2 = __toESM(require_out3(), 1);
27226
27468
  var import_tool_contract = __toESM(require_out(), 1);
27227
27469
  var RESERVED_METADATA_KEYS = /* @__PURE__ */ new Set([
27228
27470
  "skillVersion",