@ascenda-one/gemini-hooks 0.1.37 → 0.1.39

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 (2) hide show
  1. package/dist/cli.js +429 -80
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -506,6 +506,24 @@ var require_metricKeys = __commonJS({
506
506
  cacheReadTokens: { family: "context", readBy: ["backend"], backendAliases: ["cacheReadTokens", "cache_read_tokens"], unit: "tokens" },
507
507
  queuedPrompts: { family: "counts", readBy: ["backend"], backendAliases: ["queuedPrompts", "queued_prompts"] },
508
508
  linesChangedBucket: { family: "edits", readBy: ["backend"], backendAliases: ["linesChangedBucket", "lines_changed_bucket"] },
509
+ gitAction: {
510
+ family: "git",
511
+ readBy: ["backend"],
512
+ backendAliases: ["gitAction", "git_action"],
513
+ note: "The live hooks set it on a shell event; the git extractor sets it to commit on each commit event it emits."
514
+ },
515
+ repoKey: {
516
+ family: "repo",
517
+ readBy: ["backend"],
518
+ backendAliases: ["repoKey", "repo_key"],
519
+ note: "Same derivation as the live hooks (forgeRepoKey of the github.com remote), so a commit joins a session and a pull request. Absent for other forges, a checkout with no remote, and when repo keys are turned off."
520
+ },
521
+ branchKey: {
522
+ family: "repo",
523
+ readBy: ["backend"],
524
+ backendAliases: ["branchKey", "branch_key"],
525
+ note: "forgeBranchKey of the repository and the branch a commit is reachable from. Absent on the default branch, like the live hooks."
526
+ },
509
527
  // ── Read by the local handoff only ──────────────────────────────────────
510
528
  activeMinutes: { family: "session", readBy: ["handoff"], unit: "minutes" },
511
529
  syntheticPromptLines: {
@@ -728,6 +746,23 @@ var require_metricKeys = __commonJS({
728
746
  backendAliases: ["toolName", "tool_name"],
729
747
  note: "Set per ai_tool_call_started event by #43's extractors. Declared diagnostic until 23 Sep 2026 on the belief that nothing resolved it server-side; two backend readers do \u2014 one to see a sub-agent dispatch, one composing per-tool metrics. This is the inverse of the mismatch this module was written for: contextUsagePercent was a key nobody read, and a key a reader resolves without being declared drops nothing, so it has no symptom at all. What it costs is that readBy stops being a true census of what the server sees, which is what you consult when deciding what a collector should stop sending. Registered after the fact in the first place: #38 and #43 merged past each other, and the union caught it on the next compile \u2014 metaLines all over again."
730
748
  },
749
+ activity: {
750
+ family: "git",
751
+ readBy: ["diagnostic"],
752
+ note: "Names what an editor_activity row is. The git extractor sends git_commit; the backend cadence reader keys on gitAction, and this is how a person reading the row tells it from an editor event."
753
+ },
754
+ isMergeCommit: { family: "git", readBy: ["diagnostic"], note: "True when the commit has more than one parent. A merge commit carries no size figures: they would only restate the commits it merged." },
755
+ authoredByMe: { family: "git", readBy: ["diagnostic"], note: "Whether the commit's author email matches the git config email on this machine. The extractor emits only commits where it does, so today this is always true; the key exists so a wider read can be told apart." },
756
+ linesAddedBucket: { family: "git", readBy: ["diagnostic"], note: "Lines added by a commit, in the same buckets as linesChangedBucket." },
757
+ linesRemovedBucket: { family: "git", readBy: ["diagnostic"], note: "Lines removed by a commit, in the same buckets as linesChangedBucket." },
758
+ gitReposRead: { family: "reading", readBy: ["diagnostic"], note: "Git extractor epoch: repositories whose history was read." },
759
+ gitReposSkipped: { family: "reading", readBy: ["diagnostic"], note: "Git extractor epoch: repositories a transcript named that could not be read (deleted, not a repository, git failed)." },
760
+ gitReposWithoutIdentity: { family: "reading", readBy: ["diagnostic"], note: "Git extractor epoch: repositories with no user.email in git config, so no commit could be called mine and none was emitted." },
761
+ compactionOrdinal: {
762
+ family: "context",
763
+ readBy: ["diagnostic"],
764
+ note: "Claude Code only: 1-based position of this compaction within its session, counting manual and auto together. Present on per-compaction context_compression_* rows. Older imports wrote one row per session and trigger at the session's last timestamp, with no ordinal and compactionCount set to the session total. Where a session has ordinal rows, a reader should ignore its rows without one."
765
+ },
731
766
  toolResultCount: { family: "tools", readBy: ["diagnostic"] },
732
767
  toolResultErrorCount: { family: "outcome", readBy: ["diagnostic"] },
733
768
  unknownBubbles: { family: "reading", readBy: ["diagnostic"] },
@@ -887,7 +922,10 @@ var require_out = __commonJS({
887
922
  importSchema: "transport",
888
923
  // The version of the Ascenda collector that sent this event. Names the
889
924
  // build, and nothing about the work it observed.
890
- collectorVersion: "transport"
925
+ collectorVersion: "transport",
926
+ // The operating system the collector runs on, from a closed list. Names
927
+ // the machine's system, and nothing about the work it observed.
928
+ collectorPlatform: "transport"
891
929
  };
892
930
  exports.EVENT_METADATA_FIELDS = [
893
931
  "language",
@@ -931,7 +969,8 @@ var require_out = __commonJS({
931
969
  "importKey",
932
970
  "extractionId",
933
971
  "importSchema",
934
- "collectorVersion"
972
+ "collectorVersion",
973
+ "collectorPlatform"
935
974
  ];
936
975
  exports.DELIVERY_ENVELOPE_KEYS = ["toolInstallationId", "idempotencyKey"];
937
976
  function joinEventPayload(envelope, body) {
@@ -1135,6 +1174,79 @@ var require_payload = __commonJS({
1135
1174
  }
1136
1175
  });
1137
1176
 
1177
+ // ../packages/tool-kit/out/collectorPlatform.js
1178
+ var require_collectorPlatform = __commonJS({
1179
+ "../packages/tool-kit/out/collectorPlatform.js"(exports) {
1180
+ "use strict";
1181
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
1182
+ if (k2 === void 0) k2 = k;
1183
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1184
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1185
+ desc = { enumerable: true, get: function() {
1186
+ return m[k];
1187
+ } };
1188
+ }
1189
+ Object.defineProperty(o, k2, desc);
1190
+ } : function(o, m, k, k2) {
1191
+ if (k2 === void 0) k2 = k;
1192
+ o[k2] = m[k];
1193
+ });
1194
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
1195
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1196
+ } : function(o, v) {
1197
+ o["default"] = v;
1198
+ });
1199
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
1200
+ var ownKeys = function(o) {
1201
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1202
+ var ar = [];
1203
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1204
+ return ar;
1205
+ };
1206
+ return ownKeys(o);
1207
+ };
1208
+ return function(mod) {
1209
+ if (mod && mod.__esModule) return mod;
1210
+ var result = {};
1211
+ if (mod != null) {
1212
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1213
+ }
1214
+ __setModuleDefault(result, mod);
1215
+ return result;
1216
+ };
1217
+ }();
1218
+ Object.defineProperty(exports, "__esModule", { value: true });
1219
+ exports.COLLECTOR_PLATFORM = void 0;
1220
+ exports.detectCollectorPlatform = detectCollectorPlatform;
1221
+ var os2 = __importStar(__require("os"));
1222
+ function detectCollectorPlatform(probe = {}) {
1223
+ const platform = probe.platform ?? process.platform;
1224
+ switch (platform) {
1225
+ case "darwin":
1226
+ case "win32":
1227
+ return platform;
1228
+ case "linux": {
1229
+ const env = probe.env ?? process.env;
1230
+ if (env.WSL_DISTRO_NAME || env.WSL_INTEROP)
1231
+ return "wsl";
1232
+ const release = probe.release ?? safeRelease();
1233
+ return /microsoft/i.test(release) ? "wsl" : "linux";
1234
+ }
1235
+ default:
1236
+ return "other";
1237
+ }
1238
+ }
1239
+ function safeRelease() {
1240
+ try {
1241
+ return os2.release();
1242
+ } catch {
1243
+ return "";
1244
+ }
1245
+ }
1246
+ exports.COLLECTOR_PLATFORM = detectCollectorPlatform();
1247
+ }
1248
+ });
1249
+
1138
1250
  // ../packages/tool-kit/out/collectorVersion.js
1139
1251
  var require_collectorVersion = __commonJS({
1140
1252
  "../packages/tool-kit/out/collectorVersion.js"(exports) {
@@ -1143,7 +1255,7 @@ var require_collectorVersion = __commonJS({
1143
1255
  exports.COLLECTOR_VERSION = exports.UNRELEASED_COLLECTOR_VERSION = void 0;
1144
1256
  exports.describeCollectorVersion = describeCollectorVersion;
1145
1257
  exports.UNRELEASED_COLLECTOR_VERSION = "unreleased";
1146
- exports.COLLECTOR_VERSION = "0.1.37" ? "0.1.37" : exports.UNRELEASED_COLLECTOR_VERSION;
1258
+ exports.COLLECTOR_VERSION = "0.1.39" ? "0.1.39" : exports.UNRELEASED_COLLECTOR_VERSION;
1147
1259
  function describeCollectorVersion(version = exports.COLLECTOR_VERSION) {
1148
1260
  return version === exports.UNRELEASED_COLLECTOR_VERSION ? `${version} (built from a checkout, not a release)` : version;
1149
1261
  }
@@ -2271,14 +2383,14 @@ var require_http = __commonJS({
2271
2383
  }
2272
2384
  };
2273
2385
  exports.AscendaApiError = AscendaApiError;
2274
- async function createPairingSession(apiBaseUrl, toolInstallationId, toolType, displayName) {
2386
+ async function createPairingSession(apiBaseUrl, toolInstallationId, toolType, displayName, orgJoinCode) {
2275
2387
  const response = await fetch(`${apiBaseUrl}/v1/tool-pairing-sessions`, {
2276
2388
  method: "POST",
2277
2389
  headers: { "Content-Type": "application/json" },
2278
- body: JSON.stringify({ toolInstallationId, toolType, displayName })
2390
+ body: JSON.stringify({ toolInstallationId, toolType, displayName, ...orgJoinCode ? { orgJoinCode, mode: "report" } : {} })
2279
2391
  });
2280
2392
  if (!response.ok)
2281
- throw new AscendaApiError(response.status, void 0, await response.text());
2393
+ throw await apiError(response);
2282
2394
  return await response.json();
2283
2395
  }
2284
2396
  async function getPairingStatus(apiBaseUrl, pairingSessionId) {
@@ -2528,6 +2640,7 @@ var require_eventSender = __commonJS({
2528
2640
  var tokenStore_1 = require_tokenStore();
2529
2641
  var stateStore_1 = require_stateStore();
2530
2642
  var payload_1 = require_payload();
2643
+ var collectorPlatform_1 = require_collectorPlatform();
2531
2644
  var collectorVersion_1 = require_collectorVersion();
2532
2645
  var AscendaSemanticEventError = class extends Error {
2533
2646
  constructor(message) {
@@ -2555,7 +2668,7 @@ var require_eventSender = __commonJS({
2555
2668
  return (0, tool_contract_1.joinEventPayload)({ toolInstallationId: identity.toolInstallationId, idempotencyKey: (0, payload_1.mintIdempotencyKey)() }, buildEventBody(identity, mapped));
2556
2669
  }
2557
2670
  function withCollectorVersion(metadata) {
2558
- return { ...metadata, collectorVersion: collectorVersion_1.COLLECTOR_VERSION };
2671
+ return { ...metadata, collectorVersion: collectorVersion_1.COLLECTOR_VERSION, collectorPlatform: collectorPlatform_1.COLLECTOR_PLATFORM };
2559
2672
  }
2560
2673
  var DEFAULT_TIMEOUT_MS = 5e3;
2561
2674
  var RETRY_DELAY_MS = 250;
@@ -3899,58 +4012,36 @@ var require_hookAdapter = __commonJS({
3899
4012
  }
3900
4013
  });
3901
4014
 
3902
- // ../packages/tool-kit/out/hookSet.js
3903
- var require_hookSet = __commonJS({
3904
- "../packages/tool-kit/out/hookSet.js"(exports) {
4015
+ // ../packages/tool-kit/out/confirmLinks.js
4016
+ var require_confirmLinks = __commonJS({
4017
+ "../packages/tool-kit/out/confirmLinks.js"(exports) {
3905
4018
  "use strict";
3906
4019
  Object.defineProperty(exports, "__esModule", { value: true });
3907
- exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = void 0;
3908
- exports.hookSetArgument = hookSetArgument;
3909
- exports.readHookSet = readHookSet2;
3910
- exports.isHookSet = isHookSet;
3911
- exports.readViaPlugin = readViaPlugin;
3912
- exports.hookSetOfCommand = hookSetOfCommand;
3913
- exports.hookSetChanges = hookSetChanges;
3914
- exports.describeHookSetChanges = describeHookSetChanges;
3915
- exports.HOOK_SET_FLAG = "--hook-set";
3916
- exports.UNVERSIONED_HOOK_SET = 1;
3917
- function hookSetArgument(hookSet) {
3918
- return hookSet === void 0 ? "" : ` ${exports.HOOK_SET_FLAG} ${hookSet}`;
3919
- }
3920
- function readHookSet2(argv) {
3921
- const index = argv.indexOf(exports.HOOK_SET_FLAG);
3922
- if (index === -1)
4020
+ exports.pairingConfirmUrl = pairingConfirmUrl;
4021
+ exports.pairingConfirmLines = pairingConfirmLines;
4022
+ exports.studyJoinConfirmUrl = studyJoinConfirmUrl;
4023
+ function pairingConfirmUrl(qrUrl) {
4024
+ return isHttps(qrUrl) ? qrUrl : void 0;
4025
+ }
4026
+ function pairingConfirmLines(qrUrl, code) {
4027
+ const url = pairingConfirmUrl(qrUrl);
4028
+ if (!url)
4029
+ return [`Confirm in the Ascenda app \u2014 code ${code}`];
4030
+ return [`Open this link to confirm: ${url}`, `Or paste code ${code} in the Ascenda app.`];
4031
+ }
4032
+ function studyJoinConfirmUrl(apiBaseUrl, deviceCode) {
4033
+ if (!isHttps(apiBaseUrl))
3923
4034
  return void 0;
3924
- const raw = argv[index + 1];
3925
- if (raw === void 0 || !/^[1-9]\d*$/.test(raw))
3926
- return void 0;
3927
- const value = Number(raw);
3928
- return isHookSet(value) ? value : void 0;
3929
- }
3930
- function isHookSet(value) {
3931
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
3932
- }
3933
- function readViaPlugin(env) {
3934
- return env.CLAUDE_PLUGIN_ROOT ? true : void 0;
3935
- }
3936
- function hookSetOfCommand(command) {
3937
- const match = command.match(/--hook-set\s+(\d+)/);
3938
- return match ? Number(match[1]) : exports.UNVERSIONED_HOOK_SET;
3939
- }
3940
- function hookSetChanges(before, events) {
3941
- const added = events.filter((event) => !before.has(event));
3942
- const sets = [...before.values()];
3943
- return sets.length ? { added, previousSet: Math.min(...sets) } : { added };
4035
+ return `${apiBaseUrl.replace(/\/+$/, "")}/join/${encodeURIComponent(deviceCode)}`;
3944
4036
  }
3945
- function describeHookSetChanges(changes, hookSet) {
3946
- if (changes.previousSet === void 0)
3947
- return void 0;
3948
- const parts = [];
3949
- if (changes.added.length)
3950
- parts.push(`added ${changes.added.join(", ")}`);
3951
- if (changes.previousSet < hookSet)
3952
- parts.push(`hook set ${changes.previousSet} \u2192 ${hookSet}`);
3953
- return parts.length ? `upgraded: ${parts.join("; ")}` : void 0;
4037
+ function isHttps(value) {
4038
+ if (!value)
4039
+ return false;
4040
+ try {
4041
+ return new URL(value).protocol === "https:";
4042
+ } catch {
4043
+ return false;
4044
+ }
3954
4045
  }
3955
4046
  }
3956
4047
  });
@@ -3999,12 +4090,17 @@ var require_studyJoin = __commonJS({
3999
4090
  Object.defineProperty(exports, "__esModule", { value: true });
4000
4091
  exports.runStudyJoin = runStudyJoin;
4001
4092
  exports.formatWindow = formatWindow;
4093
+ exports.describeStudyGrant = describeStudyGrant;
4094
+ exports.describeStudyKind = describeStudyKind;
4095
+ exports.describeRefusal = describeRefusal;
4002
4096
  var readline = __importStar(__require("node:readline"));
4097
+ var confirmLinks_1 = require_confirmLinks();
4003
4098
  var http_1 = require_http();
4004
4099
  var STUDY_JOIN_MODE = "report";
4005
4100
  var POLL_INTERVAL_MS = 3e3;
4006
4101
  var POLL_TIMEOUT_MS = 11 * 60 * 1e3;
4007
4102
  async function runStudyJoin(ctx) {
4103
+ const report = (outcome) => ctx.onOutcome?.(outcome);
4008
4104
  const stdin = ctx.stdin ?? process.stdin;
4009
4105
  const stdout = ctx.stdout ?? process.stdout;
4010
4106
  const stderr = ctx.stderr ?? process.stderr;
@@ -4012,10 +4108,12 @@ var require_studyJoin = __commonJS({
4012
4108
  `);
4013
4109
  if (!stdin.isTTY || !stdout.isTTY) {
4014
4110
  stderr.write("join needs an interactive terminal (stdin and stdout). Run it directly, not from a script or a pipe.\n");
4111
+ report({ status: "no_terminal", granted: [] });
4015
4112
  return 0;
4016
4113
  }
4017
4114
  if (!ctx.joinCode) {
4018
4115
  stderr.write("Usage: join <code>\n");
4116
+ report({ status: "failed", granted: [], message: "No join code given." });
4019
4117
  return 1;
4020
4118
  }
4021
4119
  let start;
@@ -4024,6 +4122,7 @@ var require_studyJoin = __commonJS({
4024
4122
  } catch (error) {
4025
4123
  stderr.write(`${describeStartError(error)}
4026
4124
  `);
4125
+ report({ status: "failed", granted: [], message: describeStartError(error) });
4027
4126
  return 1;
4028
4127
  }
4029
4128
  print("");
@@ -4032,7 +4131,7 @@ var require_studyJoin = __commonJS({
4032
4131
  print("");
4033
4132
  print("Report (30 days) grants:");
4034
4133
  for (const grant of start.grants)
4035
- print(` ${describeGrant(grant)}`);
4134
+ print(` ${describeStudyGrant(grant)}`);
4036
4135
  print("");
4037
4136
  print("Study mode needs the Ascenda app. Open the app to join that way instead.");
4038
4137
  print("");
@@ -4043,10 +4142,17 @@ var require_studyJoin = __commonJS({
4043
4142
  const answer = await askChoice(stdin, stdout);
4044
4143
  if (!/^(1|report)$/i.test(answer)) {
4045
4144
  print("Not now.");
4145
+ report({ status: "not_now", start, granted: [] });
4046
4146
  return 0;
4047
4147
  }
4048
4148
  print("");
4049
- print(`Confirm in the Ascenda app with code ${start.deviceCode}`);
4149
+ const confirmUrl = (0, confirmLinks_1.studyJoinConfirmUrl)(ctx.apiBaseUrl, start.deviceCode);
4150
+ if (confirmUrl) {
4151
+ print(`Open this link to confirm: ${confirmUrl}`);
4152
+ print(`Or confirm in the Ascenda app with code ${start.deviceCode}.`);
4153
+ } else {
4154
+ print(`Confirm in the Ascenda app with code ${start.deviceCode}`);
4155
+ }
4050
4156
  print(`Waiting for confirmation (expires ${formatLocalTime(start.expiresAt)})...`);
4051
4157
  const pollIntervalMs = ctx.pollIntervalMs ?? POLL_INTERVAL_MS;
4052
4158
  const deadline = Math.min(Date.parse(start.expiresAt) || Date.now() + POLL_TIMEOUT_MS, Date.now() + POLL_TIMEOUT_MS);
@@ -4060,6 +4166,7 @@ var require_studyJoin = __commonJS({
4060
4166
  continue;
4061
4167
  stderr.write(`${describeStartError(error)}
4062
4168
  `);
4169
+ report({ status: "failed", start, granted: [], message: describeStartError(error) });
4063
4170
  return 1;
4064
4171
  }
4065
4172
  if (poll.status === "pending")
@@ -4069,20 +4176,23 @@ var require_studyJoin = __commonJS({
4069
4176
  if (granted.length === 0) {
4070
4177
  print("");
4071
4178
  print("Nothing was granted. Run join again, or check with your organisation.");
4179
+ report({ status: "refused", start, granted: [], message: "Nothing was granted." });
4072
4180
  return 1;
4073
4181
  }
4074
4182
  print("");
4075
4183
  print("Joined. Granted:");
4076
4184
  for (const grant of granted)
4077
- print(` ${describeGrant(grant)}`);
4185
+ print(` ${describeStudyGrant(grant)}`);
4078
4186
  print("");
4079
4187
  print("Each of these can be turned off separately, in the app's consent settings.");
4080
4188
  print("The organisation sees group counts, never who joined.");
4189
+ report({ status: "joined", start, granted });
4081
4190
  return 0;
4082
4191
  }
4083
4192
  if (poll.status === "expired") {
4084
4193
  print("");
4085
4194
  print("This code expired before it was confirmed. Run join again for a fresh code.");
4195
+ report({ status: "expired", start, granted: [] });
4086
4196
  return 1;
4087
4197
  }
4088
4198
  if (poll.refusedReason === "grant_failed") {
@@ -4093,19 +4203,22 @@ var require_studyJoin = __commonJS({
4093
4203
  print("");
4094
4204
  print("Granted before the failure:");
4095
4205
  for (const grant of granted)
4096
- print(` ${describeGrant(grant)}`);
4206
+ print(` ${describeStudyGrant(grant)}`);
4097
4207
  print("");
4098
4208
  print("Each of these can be turned off separately, in the app's consent settings.");
4099
4209
  }
4100
4210
  print("Run join again, or check with your organisation.");
4211
+ report({ status: "refused", start, granted, refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason) });
4101
4212
  return 1;
4102
4213
  }
4103
4214
  print("");
4104
4215
  print(describeRefusal(poll.refusedReason));
4216
+ report({ status: "refused", start, granted: [], refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason) });
4105
4217
  return 1;
4106
4218
  }
4107
4219
  print("");
4108
4220
  print("Timed out waiting for confirmation. Run join again for a fresh code.");
4221
+ report({ status: "expired", start, granted: [] });
4109
4222
  return 1;
4110
4223
  }
4111
4224
  function isRetryablePollError(error) {
@@ -4148,7 +4261,7 @@ var require_studyJoin = __commonJS({
4148
4261
  501: "AI assistant data processing consent",
4149
4262
  507: "Import of the AI-work history already on your machine"
4150
4263
  };
4151
- function describeGrant(grant) {
4264
+ function describeStudyGrant(grant) {
4152
4265
  return GRANT_SENTENCES[grant.code] ?? humanise(grant.name);
4153
4266
  }
4154
4267
  var STUDY_KIND_SENTENCES = {
@@ -4168,7 +4281,7 @@ var require_studyJoin = __commonJS({
4168
4281
  // table is ever consulted — present so the type stays exhaustive, and as
4169
4282
  // a plain fallback should something call this function with it directly.
4170
4283
  grant_failed: "Join failed partway through. Some grants may not have gone through.",
4171
- declined: "You declined in the app. Nothing was granted.",
4284
+ declined: "You declined the join. Nothing was granted.",
4172
4285
  not_enrolled: "That study couldn't enrol you, so nothing was granted."
4173
4286
  };
4174
4287
  function describeRefusal(refusedReason) {
@@ -4196,6 +4309,182 @@ var require_studyJoin = __commonJS({
4196
4309
  }
4197
4310
  });
4198
4311
 
4312
+ // ../packages/tool-kit/out/pairingStudyJoin.js
4313
+ var require_pairingStudyJoin = __commonJS({
4314
+ "../packages/tool-kit/out/pairingStudyJoin.js"(exports) {
4315
+ "use strict";
4316
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
4317
+ if (k2 === void 0) k2 = k;
4318
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4319
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4320
+ desc = { enumerable: true, get: function() {
4321
+ return m[k];
4322
+ } };
4323
+ }
4324
+ Object.defineProperty(o, k2, desc);
4325
+ } : function(o, m, k, k2) {
4326
+ if (k2 === void 0) k2 = k;
4327
+ o[k2] = m[k];
4328
+ });
4329
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
4330
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
4331
+ } : function(o, v) {
4332
+ o["default"] = v;
4333
+ });
4334
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
4335
+ var ownKeys = function(o) {
4336
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
4337
+ var ar = [];
4338
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
4339
+ return ar;
4340
+ };
4341
+ return ownKeys(o);
4342
+ };
4343
+ return function(mod) {
4344
+ if (mod && mod.__esModule) return mod;
4345
+ var result = {};
4346
+ if (mod != null) {
4347
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
4348
+ }
4349
+ __setModuleDefault(result, mod);
4350
+ return result;
4351
+ };
4352
+ }();
4353
+ Object.defineProperty(exports, "__esModule", { value: true });
4354
+ exports.PAIR_JOIN_OUTCOME_FILE_ENV = exports.PAIR_ORG_JOIN_CODE_ENV = void 0;
4355
+ exports.createPairingAttempt = createPairingAttempt;
4356
+ exports.pairingAttemptLines = pairingAttemptLines;
4357
+ exports.settleStudyJoin = settleStudyJoin;
4358
+ exports.writePairingJoinOutcome = writePairingJoinOutcome;
4359
+ exports.pairingJoinOutcome = pairingJoinOutcome;
4360
+ var fs = __importStar(__require("node:fs"));
4361
+ var confirmLinks_1 = require_confirmLinks();
4362
+ var studyJoin_1 = require_studyJoin();
4363
+ var http_1 = require_http();
4364
+ exports.PAIR_ORG_JOIN_CODE_ENV = "ASCENDA_PAIR_ORG_JOIN_CODE";
4365
+ exports.PAIR_JOIN_OUTCOME_FILE_ENV = "ASCENDA_PAIR_JOIN_OUTCOME_FILE";
4366
+ var CREATE_REFUSALS = {
4367
+ join_code_not_found: "That code is not a study anyone can join. Check it and try again.",
4368
+ no_live_study: "There's nothing open to join with that code right now.",
4369
+ unknown_mode: "This tool only offers Report mode from the command line."
4370
+ };
4371
+ var JOIN_SETTLE_MS = 6e4;
4372
+ async function createPairingAttempt(apiBaseUrl, toolInstallationId, toolType, displayName, env = process.env) {
4373
+ const orgJoinCode = env[exports.PAIR_ORG_JOIN_CODE_ENV]?.trim();
4374
+ if (!orgJoinCode)
4375
+ return { session: await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName), carriesJoin: false };
4376
+ let refusal;
4377
+ try {
4378
+ const session = await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName, orgJoinCode);
4379
+ return { session, carriesJoin: session.studyJoin !== void 0 };
4380
+ } catch (error) {
4381
+ if (!(error instanceof http_1.AscendaApiError) || error.status >= 500)
4382
+ throw error;
4383
+ refusal = error.errorCode ? CREATE_REFUSALS[error.errorCode] : void 0;
4384
+ }
4385
+ return { session: await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName), carriesJoin: false, refusal };
4386
+ }
4387
+ function pairingAttemptLines(attempt) {
4388
+ const { session } = attempt;
4389
+ const join2 = attempt.carriesJoin ? session.studyJoin : void 0;
4390
+ if (!join2)
4391
+ return (0, confirmLinks_1.pairingConfirmLines)(session.qrUrl, session.code);
4392
+ return [
4393
+ `This also joins ${join2.organisationName} (${(0, studyJoin_1.formatWindow)(join2.windowStartUtc, join2.windowEndUtc)}). The page shows what you'd share before you confirm.`,
4394
+ `Open this link to confirm: ${session.qrUrl}`
4395
+ ];
4396
+ }
4397
+ async function settleStudyJoin(apiBaseUrl, pairingSessionId, last, wait = 1e3) {
4398
+ let current = last;
4399
+ const deadline = Date.now() + JOIN_SETTLE_MS;
4400
+ while (current && current.status === "pending" && Date.now() < deadline) {
4401
+ await new Promise((resolve) => setTimeout(resolve, wait));
4402
+ let status;
4403
+ try {
4404
+ status = await (0, http_1.getPairingStatus)(apiBaseUrl, pairingSessionId);
4405
+ } catch {
4406
+ continue;
4407
+ }
4408
+ current = status.studyJoin ?? current;
4409
+ }
4410
+ return current;
4411
+ }
4412
+ function writePairingJoinOutcome(outcome, env = process.env) {
4413
+ const file = env[exports.PAIR_JOIN_OUTCOME_FILE_ENV]?.trim();
4414
+ if (!file)
4415
+ return;
4416
+ try {
4417
+ fs.writeFileSync(file, `${JSON.stringify(outcome)}
4418
+ `, { mode: 384 });
4419
+ } catch {
4420
+ }
4421
+ }
4422
+ function pairingJoinOutcome(attempt, pairing, studyJoin) {
4423
+ if (!attempt)
4424
+ return { join: "none", pairing };
4425
+ if (attempt.refusal)
4426
+ return { join: "refused", pairing, message: attempt.refusal };
4427
+ return { join: attempt.carriesJoin ? "carried" : "not_carried", pairing, studyJoin };
4428
+ }
4429
+ }
4430
+ });
4431
+
4432
+ // ../packages/tool-kit/out/hookSet.js
4433
+ var require_hookSet = __commonJS({
4434
+ "../packages/tool-kit/out/hookSet.js"(exports) {
4435
+ "use strict";
4436
+ Object.defineProperty(exports, "__esModule", { value: true });
4437
+ exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = void 0;
4438
+ exports.hookSetArgument = hookSetArgument;
4439
+ exports.readHookSet = readHookSet2;
4440
+ exports.isHookSet = isHookSet;
4441
+ exports.readViaPlugin = readViaPlugin;
4442
+ exports.hookSetOfCommand = hookSetOfCommand;
4443
+ exports.hookSetChanges = hookSetChanges;
4444
+ exports.describeHookSetChanges = describeHookSetChanges;
4445
+ exports.HOOK_SET_FLAG = "--hook-set";
4446
+ exports.UNVERSIONED_HOOK_SET = 1;
4447
+ function hookSetArgument(hookSet) {
4448
+ return hookSet === void 0 ? "" : ` ${exports.HOOK_SET_FLAG} ${hookSet}`;
4449
+ }
4450
+ function readHookSet2(argv) {
4451
+ const index = argv.indexOf(exports.HOOK_SET_FLAG);
4452
+ if (index === -1)
4453
+ return void 0;
4454
+ const raw = argv[index + 1];
4455
+ if (raw === void 0 || !/^[1-9]\d*$/.test(raw))
4456
+ return void 0;
4457
+ const value = Number(raw);
4458
+ return isHookSet(value) ? value : void 0;
4459
+ }
4460
+ function isHookSet(value) {
4461
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
4462
+ }
4463
+ function readViaPlugin(env) {
4464
+ return env.CLAUDE_PLUGIN_ROOT ? true : void 0;
4465
+ }
4466
+ function hookSetOfCommand(command) {
4467
+ const match = command.match(/--hook-set\s+(\d+)/);
4468
+ return match ? Number(match[1]) : exports.UNVERSIONED_HOOK_SET;
4469
+ }
4470
+ function hookSetChanges(before, events) {
4471
+ const added = events.filter((event) => !before.has(event));
4472
+ const sets = [...before.values()];
4473
+ return sets.length ? { added, previousSet: Math.min(...sets) } : { added };
4474
+ }
4475
+ function describeHookSetChanges(changes, hookSet) {
4476
+ if (changes.previousSet === void 0)
4477
+ return void 0;
4478
+ const parts = [];
4479
+ if (changes.added.length)
4480
+ parts.push(`added ${changes.added.join(", ")}`);
4481
+ if (changes.previousSet < hookSet)
4482
+ parts.push(`hook set ${changes.previousSet} \u2192 ${hookSet}`);
4483
+ return parts.length ? `upgraded: ${parts.join("; ")}` : void 0;
4484
+ }
4485
+ }
4486
+ });
4487
+
4199
4488
  // ../packages/tool-kit/out/initiatives.js
4200
4489
  var require_initiatives = __commonJS({
4201
4490
  "../packages/tool-kit/out/initiatives.js"(exports) {
@@ -5549,6 +5838,7 @@ var require_cliAgentSetup = __commonJS({
5549
5838
  var eventLog_1 = require_eventLog();
5550
5839
  var hookAdapter_1 = require_hookAdapter();
5551
5840
  var http_1 = require_http();
5841
+ var pairingStudyJoin_1 = require_pairingStudyJoin();
5552
5842
  var hookSet_1 = require_hookSet();
5553
5843
  var initiatives_1 = require_initiatives();
5554
5844
  var settingsFile_1 = require_settingsFile();
@@ -5873,16 +6163,19 @@ ${usage(spec)}`);
5873
6163
  return { toolInstallationId: existingId ?? `${spec.toolType}:<paired at run time>`, paired: false };
5874
6164
  }
5875
6165
  const toolInstallationId = existingId ?? `${spec.toolType}:${crypto.randomUUID()}`;
5876
- let session;
6166
+ let attempt;
5877
6167
  try {
5878
- session = await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, spec.toolType, `${spec.displayName} on ${os2.hostname()}`);
6168
+ attempt = await (0, pairingStudyJoin_1.createPairingAttempt)(apiBaseUrl, toolInstallationId, spec.toolType, `${spec.displayName} on ${os2.hostname()}`);
5879
6169
  } catch (error) {
5880
6170
  console.error(`
5881
6171
  Could not reach ${apiBaseUrl} to pair: ${error instanceof Error ? error.message : String(error)}`);
5882
6172
  console.error("Start the local dev server and use --local, or pass --api-base-url for your backend.");
5883
6173
  return void 0;
5884
6174
  }
5885
- const token = await pollForToken(apiBaseUrl, session.pairingSessionId, session.code, session.expiresAt);
6175
+ if (attempt.refusal)
6176
+ console.log(`
6177
+ ${attempt.refusal} Pairing without the study.`);
6178
+ const token = await pollForToken(apiBaseUrl, attempt);
5886
6179
  if (!token)
5887
6180
  return void 0;
5888
6181
  (0, tokenStore_1.persistEventWriteToken)((0, tokenStore_1.defaultTokenFilePath)(toolInstallationId), token);
@@ -5900,27 +6193,32 @@ Could not reach ${apiBaseUrl} to pair: ${error instanceof Error ? error.message
5900
6193
  }
5901
6194
  return "keep";
5902
6195
  }
5903
- async function pollForToken(apiBaseUrl, pairingSessionId, code, expiresAt) {
5904
- const deadline = Math.min(Date.parse(expiresAt) || Date.now() + 3e5, Date.now() + 3e5);
5905
- let announced = false;
6196
+ async function pollForToken(apiBaseUrl, attempt) {
6197
+ const { session } = attempt;
6198
+ const deadline = Math.min(Date.parse(session.expiresAt) || Date.now() + 3e5, Date.now() + 3e5);
6199
+ let studyJoin;
6200
+ console.log("");
6201
+ for (const line of (0, pairingStudyJoin_1.pairingAttemptLines)(attempt))
6202
+ console.log(` ${line}`);
6203
+ console.log(" Waiting...");
5906
6204
  while (Date.now() < deadline) {
5907
- const status = await (0, http_1.getPairingStatus)(apiBaseUrl, pairingSessionId);
5908
- if (status.status === "paired" && status.eventWriteToken)
6205
+ const status = await (0, http_1.getPairingStatus)(apiBaseUrl, session.pairingSessionId);
6206
+ studyJoin = status.studyJoin ?? studyJoin;
6207
+ if (status.status === "paired" && status.eventWriteToken) {
6208
+ studyJoin = await (0, pairingStudyJoin_1.settleStudyJoin)(apiBaseUrl, session.pairingSessionId, studyJoin);
6209
+ (0, pairingStudyJoin_1.writePairingJoinOutcome)((0, pairingStudyJoin_1.pairingJoinOutcome)(attempt, "paired", studyJoin));
5909
6210
  return status.eventWriteToken;
6211
+ }
5910
6212
  if (status.status === "expired" || status.status === "cancelled") {
5911
6213
  console.error(`
5912
6214
  Pairing ${status.status}. Run setup again.`);
6215
+ (0, pairingStudyJoin_1.writePairingJoinOutcome)((0, pairingStudyJoin_1.pairingJoinOutcome)(attempt, status.status, studyJoin));
5913
6216
  return void 0;
5914
6217
  }
5915
- if (!announced) {
5916
- console.log(`
5917
- Confirm in the Ascenda app \u2014 code ${code}`);
5918
- console.log(" Waiting...");
5919
- announced = true;
5920
- }
5921
6218
  await new Promise((resolve) => setTimeout(resolve, 2e3));
5922
6219
  }
5923
6220
  console.error("\nPairing timed out. Run setup again.");
6221
+ (0, pairingStudyJoin_1.writePairingJoinOutcome)((0, pairingStudyJoin_1.pairingJoinOutcome)(attempt, "gave_up", studyJoin));
5924
6222
  return void 0;
5925
6223
  }
5926
6224
  function installBinary(spec, dryRun) {
@@ -6647,11 +6945,11 @@ var require_out3 = __commonJS({
6647
6945
  "../packages/tool-kit/out/index.js"(exports) {
6648
6946
  "use strict";
6649
6947
  Object.defineProperty(exports, "__esModule", { value: true });
6650
- 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.startBackgroundFlush = exports.runOutboxFlush = exports.hookDeliveryInline = exports.flushLockPath = exports.OUTBOX_FLUSH_COMMAND = exports.HOOK_DELIVERY_ENV_VAR = exports.FLUSH_LOCK_FRESH_MS = 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.shellCommandFacts = exports.invitesDebrief = exports.classifyMcpWorkMilestone = exports.classifyWorkMilestone = exports.isReworkGitAction = exports.classifyGitAction = exports.isVerificationCommand = exports.classifyCommand = void 0;
6651
- 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.readTurnPromptId = exports.consumeTurnDurationMs = exports.writeTopLevelCredentials = exports.writeMachineCredentials = exports.writeRepoKeysSetting = 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.trustProblemLines = exports.runCliAgentSetup = exports.registeredHookSets = exports.ourHookPositions = exports.isCliAgentManagementCommand = exports.findStaleHookCommands = exports.cliAgentHookBinPath = exports.resolveContextHashes = exports.resolveCliAgentInstallationId = exports.withPromptId = exports.withForgeKeys = exports.loadCliAgentConfig = exports.flushHookOutbox = exports.deliverHookEvents = exports.MissingInstallationIdError = exports.DEFAULT_API_BASE_URL = exports.resolveEventLogPath = void 0;
6652
- 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.repoKeysEnabled = exports.deriveForgeKeysForCwd = exports.REPO_KEYS_ENV_VAR = exports.recordForgeProjectAlias = exports.forgeFullNameFromConfig = exports.readForgeFullName = exports.parseForgeFullName = exports.forgeBranchKey = exports.forgeRepoKey = exports.forgeProjectHash = exports.workContextRegistryFilePath = exports.readWorkContextRegistry = 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 = void 0;
6653
- 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 = exports.hookSetArgument = exports.describeHookSetChanges = exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = exports.liveSignalDoctorLines = exports.doctorRow = exports.DOCTOR_VALUE_COLUMN = exports.pluginBundlePaths = exports.installPluginBundle = exports.describePluginBundleOutcome = exports.replaceSettingsFile = exports.writeAtomically = exports.tidyHomePath = exports.stampLastHook = exports.resolveHookNode = exports.removeHookRunner = exports.readLastHook = exports.lastHookPath = exports.isDowngrade = exports.installHookRunner = exports.hookRunnerPaths = exports.hookRunnerCommand = exports.hookLauncherScript = exports.describeAge = exports.terminalStyle = exports.colourEnabled = exports.SAVER_REPLAY_WINDOW_MS = void 0;
6654
- exports.runStudyJoin = exports.studyNoticeStatus = exports.runStudyObjection = exports.renderStudyNotices = exports.NOTICED_PURPOSES = exports.renderInitiatives = exports.initiativesStatusLines = exports.INITIATIVE_COPY = exports.startStudyJoin = exports.setStudyObjection = exports.markStudyNoticeShown = void 0;
6948
+ 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.startBackgroundFlush = exports.runOutboxFlush = exports.hookDeliveryInline = exports.flushLockPath = exports.OUTBOX_FLUSH_COMMAND = exports.HOOK_DELIVERY_ENV_VAR = exports.FLUSH_LOCK_FRESH_MS = exports.describeCollectorVersion = exports.UNRELEASED_COLLECTOR_VERSION = exports.COLLECTOR_VERSION = exports.detectCollectorPlatform = exports.COLLECTOR_PLATFORM = 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.shellCommandFacts = exports.invitesDebrief = exports.classifyMcpWorkMilestone = exports.classifyWorkMilestone = exports.isReworkGitAction = exports.classifyGitAction = exports.isVerificationCommand = exports.classifyCommand = void 0;
6949
+ 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.readTurnPromptId = exports.consumeTurnDurationMs = exports.writeTopLevelCredentials = exports.writeMachineCredentials = exports.writeRepoKeysSetting = 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.trustProblemLines = exports.runCliAgentSetup = exports.registeredHookSets = exports.ourHookPositions = exports.isCliAgentManagementCommand = exports.findStaleHookCommands = exports.cliAgentHookBinPath = exports.resolveContextHashes = exports.resolveCliAgentInstallationId = exports.withPromptId = exports.withForgeKeys = exports.loadCliAgentConfig = exports.flushHookOutbox = exports.deliverHookEvents = exports.MissingInstallationIdError = exports.DEFAULT_API_BASE_URL = exports.resolveEventLogPath = exports.resolveEventLog = exports.parseEventLogFlag = void 0;
6950
+ 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.repoKeysEnabled = exports.deriveForgeKeysForCwd = exports.REPO_KEYS_ENV_VAR = exports.recordForgeProjectAlias = exports.forgeFullNameFromConfig = exports.readForgeFullName = exports.parseForgeFullName = exports.forgeBranchKey = exports.forgeRepoKey = exports.forgeProjectHash = exports.workContextRegistryFilePath = exports.readWorkContextRegistry = 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 = void 0;
6951
+ 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 = exports.hookSetArgument = exports.describeHookSetChanges = exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = exports.liveSignalDoctorLines = exports.doctorRow = exports.DOCTOR_VALUE_COLUMN = exports.pluginBundlePaths = exports.installPluginBundle = exports.describePluginBundleOutcome = exports.replaceSettingsFile = exports.writeAtomically = exports.tidyHomePath = exports.stampLastHook = exports.resolveHookNode = exports.removeHookRunner = exports.readLastHook = exports.lastHookPath = exports.isDowngrade = exports.installHookRunner = exports.hookRunnerPaths = exports.hookRunnerCommand = exports.hookLauncherScript = exports.describeAge = exports.terminalStyle = exports.colourEnabled = exports.SAVER_REPLAY_WINDOW_MS = exports.saverSupportDir = exports.saverStatusDir = void 0;
6952
+ exports.writePairingJoinOutcome = exports.settleStudyJoin = exports.pairingJoinOutcome = exports.pairingAttemptLines = exports.createPairingAttempt = exports.PAIR_ORG_JOIN_CODE_ENV = exports.PAIR_JOIN_OUTCOME_FILE_ENV = exports.studyJoinConfirmUrl = exports.pairingConfirmUrl = exports.pairingConfirmLines = exports.runStudyJoin = exports.formatWindow = exports.describeStudyGrant = exports.describeStudyKind = exports.describeStudyJoinRefusal = 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 = void 0;
6655
6953
  var commandClassifier_1 = require_commandClassifier();
6656
6954
  Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
6657
6955
  return commandClassifier_1.classifyCommand;
@@ -6739,6 +7037,13 @@ var require_out3 = __commonJS({
6739
7037
  Object.defineProperty(exports, "mintIdempotencyKey", { enumerable: true, get: function() {
6740
7038
  return payload_1.mintIdempotencyKey;
6741
7039
  } });
7040
+ var collectorPlatform_1 = require_collectorPlatform();
7041
+ Object.defineProperty(exports, "COLLECTOR_PLATFORM", { enumerable: true, get: function() {
7042
+ return collectorPlatform_1.COLLECTOR_PLATFORM;
7043
+ } });
7044
+ Object.defineProperty(exports, "detectCollectorPlatform", { enumerable: true, get: function() {
7045
+ return collectorPlatform_1.detectCollectorPlatform;
7046
+ } });
6742
7047
  var collectorVersion_1 = require_collectorVersion();
6743
7048
  Object.defineProperty(exports, "COLLECTOR_VERSION", { enumerable: true, get: function() {
6744
7049
  return collectorVersion_1.COLLECTOR_VERSION;
@@ -7323,9 +7628,53 @@ var require_out3 = __commonJS({
7323
7628
  return studyNotices_1.studyNoticeStatus;
7324
7629
  } });
7325
7630
  var studyJoin_1 = require_studyJoin();
7631
+ Object.defineProperty(exports, "describeStudyJoinRefusal", { enumerable: true, get: function() {
7632
+ return studyJoin_1.describeRefusal;
7633
+ } });
7634
+ Object.defineProperty(exports, "describeStudyKind", { enumerable: true, get: function() {
7635
+ return studyJoin_1.describeStudyKind;
7636
+ } });
7637
+ Object.defineProperty(exports, "describeStudyGrant", { enumerable: true, get: function() {
7638
+ return studyJoin_1.describeStudyGrant;
7639
+ } });
7640
+ Object.defineProperty(exports, "formatWindow", { enumerable: true, get: function() {
7641
+ return studyJoin_1.formatWindow;
7642
+ } });
7326
7643
  Object.defineProperty(exports, "runStudyJoin", { enumerable: true, get: function() {
7327
7644
  return studyJoin_1.runStudyJoin;
7328
7645
  } });
7646
+ var confirmLinks_1 = require_confirmLinks();
7647
+ Object.defineProperty(exports, "pairingConfirmLines", { enumerable: true, get: function() {
7648
+ return confirmLinks_1.pairingConfirmLines;
7649
+ } });
7650
+ Object.defineProperty(exports, "pairingConfirmUrl", { enumerable: true, get: function() {
7651
+ return confirmLinks_1.pairingConfirmUrl;
7652
+ } });
7653
+ Object.defineProperty(exports, "studyJoinConfirmUrl", { enumerable: true, get: function() {
7654
+ return confirmLinks_1.studyJoinConfirmUrl;
7655
+ } });
7656
+ var pairingStudyJoin_1 = require_pairingStudyJoin();
7657
+ Object.defineProperty(exports, "PAIR_JOIN_OUTCOME_FILE_ENV", { enumerable: true, get: function() {
7658
+ return pairingStudyJoin_1.PAIR_JOIN_OUTCOME_FILE_ENV;
7659
+ } });
7660
+ Object.defineProperty(exports, "PAIR_ORG_JOIN_CODE_ENV", { enumerable: true, get: function() {
7661
+ return pairingStudyJoin_1.PAIR_ORG_JOIN_CODE_ENV;
7662
+ } });
7663
+ Object.defineProperty(exports, "createPairingAttempt", { enumerable: true, get: function() {
7664
+ return pairingStudyJoin_1.createPairingAttempt;
7665
+ } });
7666
+ Object.defineProperty(exports, "pairingAttemptLines", { enumerable: true, get: function() {
7667
+ return pairingStudyJoin_1.pairingAttemptLines;
7668
+ } });
7669
+ Object.defineProperty(exports, "pairingJoinOutcome", { enumerable: true, get: function() {
7670
+ return pairingStudyJoin_1.pairingJoinOutcome;
7671
+ } });
7672
+ Object.defineProperty(exports, "settleStudyJoin", { enumerable: true, get: function() {
7673
+ return pairingStudyJoin_1.settleStudyJoin;
7674
+ } });
7675
+ Object.defineProperty(exports, "writePairingJoinOutcome", { enumerable: true, get: function() {
7676
+ return pairingStudyJoin_1.writePairingJoinOutcome;
7677
+ } });
7329
7678
  }
7330
7679
  });
7331
7680
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "publishConfig": { "access": "public" },
3
3
  "name": "@ascenda-one/gemini-hooks",
4
- "version": "0.1.37",
4
+ "version": "0.1.39",
5
5
  "description": "Gemini CLI hooks adapter for Ascenda AI workload telemetry",
6
6
  "repository": {
7
7
  "type": "git",