@ascenda-one/agent-mcp 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
@@ -510,6 +510,24 @@ var require_metricKeys = __commonJS({
510
510
  cacheReadTokens: { family: "context", readBy: ["backend"], backendAliases: ["cacheReadTokens", "cache_read_tokens"], unit: "tokens" },
511
511
  queuedPrompts: { family: "counts", readBy: ["backend"], backendAliases: ["queuedPrompts", "queued_prompts"] },
512
512
  linesChangedBucket: { family: "edits", readBy: ["backend"], backendAliases: ["linesChangedBucket", "lines_changed_bucket"] },
513
+ gitAction: {
514
+ family: "git",
515
+ readBy: ["backend"],
516
+ backendAliases: ["gitAction", "git_action"],
517
+ note: "The live hooks set it on a shell event; the git extractor sets it to commit on each commit event it emits."
518
+ },
519
+ repoKey: {
520
+ family: "repo",
521
+ readBy: ["backend"],
522
+ backendAliases: ["repoKey", "repo_key"],
523
+ 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."
524
+ },
525
+ branchKey: {
526
+ family: "repo",
527
+ readBy: ["backend"],
528
+ backendAliases: ["branchKey", "branch_key"],
529
+ note: "forgeBranchKey of the repository and the branch a commit is reachable from. Absent on the default branch, like the live hooks."
530
+ },
513
531
  // ── Read by the local handoff only ──────────────────────────────────────
514
532
  activeMinutes: { family: "session", readBy: ["handoff"], unit: "minutes" },
515
533
  syntheticPromptLines: {
@@ -732,6 +750,23 @@ var require_metricKeys = __commonJS({
732
750
  backendAliases: ["toolName", "tool_name"],
733
751
  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."
734
752
  },
753
+ activity: {
754
+ family: "git",
755
+ readBy: ["diagnostic"],
756
+ 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."
757
+ },
758
+ 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." },
759
+ 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." },
760
+ linesAddedBucket: { family: "git", readBy: ["diagnostic"], note: "Lines added by a commit, in the same buckets as linesChangedBucket." },
761
+ linesRemovedBucket: { family: "git", readBy: ["diagnostic"], note: "Lines removed by a commit, in the same buckets as linesChangedBucket." },
762
+ gitReposRead: { family: "reading", readBy: ["diagnostic"], note: "Git extractor epoch: repositories whose history was read." },
763
+ gitReposSkipped: { family: "reading", readBy: ["diagnostic"], note: "Git extractor epoch: repositories a transcript named that could not be read (deleted, not a repository, git failed)." },
764
+ 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." },
765
+ compactionOrdinal: {
766
+ family: "context",
767
+ readBy: ["diagnostic"],
768
+ 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."
769
+ },
735
770
  toolResultCount: { family: "tools", readBy: ["diagnostic"] },
736
771
  toolResultErrorCount: { family: "outcome", readBy: ["diagnostic"] },
737
772
  unknownBubbles: { family: "reading", readBy: ["diagnostic"] },
@@ -891,7 +926,10 @@ var require_out = __commonJS({
891
926
  importSchema: "transport",
892
927
  // The version of the Ascenda collector that sent this event. Names the
893
928
  // build, and nothing about the work it observed.
894
- collectorVersion: "transport"
929
+ collectorVersion: "transport",
930
+ // The operating system the collector runs on, from a closed list. Names
931
+ // the machine's system, and nothing about the work it observed.
932
+ collectorPlatform: "transport"
895
933
  };
896
934
  exports.EVENT_METADATA_FIELDS = [
897
935
  "language",
@@ -935,7 +973,8 @@ var require_out = __commonJS({
935
973
  "importKey",
936
974
  "extractionId",
937
975
  "importSchema",
938
- "collectorVersion"
976
+ "collectorVersion",
977
+ "collectorPlatform"
939
978
  ];
940
979
  exports.DELIVERY_ENVELOPE_KEYS = ["toolInstallationId", "idempotencyKey"];
941
980
  function joinEventPayload(envelope, body) {
@@ -1139,6 +1178,79 @@ var require_payload = __commonJS({
1139
1178
  }
1140
1179
  });
1141
1180
 
1181
+ // ../packages/tool-kit/out/collectorPlatform.js
1182
+ var require_collectorPlatform = __commonJS({
1183
+ "../packages/tool-kit/out/collectorPlatform.js"(exports) {
1184
+ "use strict";
1185
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
1186
+ if (k2 === void 0) k2 = k;
1187
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1188
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1189
+ desc = { enumerable: true, get: function() {
1190
+ return m[k];
1191
+ } };
1192
+ }
1193
+ Object.defineProperty(o, k2, desc);
1194
+ } : function(o, m, k, k2) {
1195
+ if (k2 === void 0) k2 = k;
1196
+ o[k2] = m[k];
1197
+ });
1198
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
1199
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1200
+ } : function(o, v) {
1201
+ o["default"] = v;
1202
+ });
1203
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
1204
+ var ownKeys = function(o) {
1205
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1206
+ var ar = [];
1207
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1208
+ return ar;
1209
+ };
1210
+ return ownKeys(o);
1211
+ };
1212
+ return function(mod) {
1213
+ if (mod && mod.__esModule) return mod;
1214
+ var result = {};
1215
+ if (mod != null) {
1216
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1217
+ }
1218
+ __setModuleDefault(result, mod);
1219
+ return result;
1220
+ };
1221
+ }();
1222
+ Object.defineProperty(exports, "__esModule", { value: true });
1223
+ exports.COLLECTOR_PLATFORM = void 0;
1224
+ exports.detectCollectorPlatform = detectCollectorPlatform;
1225
+ var os = __importStar(__require("os"));
1226
+ function detectCollectorPlatform(probe = {}) {
1227
+ const platform = probe.platform ?? process.platform;
1228
+ switch (platform) {
1229
+ case "darwin":
1230
+ case "win32":
1231
+ return platform;
1232
+ case "linux": {
1233
+ const env = probe.env ?? process.env;
1234
+ if (env.WSL_DISTRO_NAME || env.WSL_INTEROP)
1235
+ return "wsl";
1236
+ const release = probe.release ?? safeRelease();
1237
+ return /microsoft/i.test(release) ? "wsl" : "linux";
1238
+ }
1239
+ default:
1240
+ return "other";
1241
+ }
1242
+ }
1243
+ function safeRelease() {
1244
+ try {
1245
+ return os.release();
1246
+ } catch {
1247
+ return "";
1248
+ }
1249
+ }
1250
+ exports.COLLECTOR_PLATFORM = detectCollectorPlatform();
1251
+ }
1252
+ });
1253
+
1142
1254
  // ../packages/tool-kit/out/collectorVersion.js
1143
1255
  var require_collectorVersion = __commonJS({
1144
1256
  "../packages/tool-kit/out/collectorVersion.js"(exports) {
@@ -1147,7 +1259,7 @@ var require_collectorVersion = __commonJS({
1147
1259
  exports.COLLECTOR_VERSION = exports.UNRELEASED_COLLECTOR_VERSION = void 0;
1148
1260
  exports.describeCollectorVersion = describeCollectorVersion;
1149
1261
  exports.UNRELEASED_COLLECTOR_VERSION = "unreleased";
1150
- exports.COLLECTOR_VERSION = "0.1.37" ? "0.1.37" : exports.UNRELEASED_COLLECTOR_VERSION;
1262
+ exports.COLLECTOR_VERSION = "0.1.39" ? "0.1.39" : exports.UNRELEASED_COLLECTOR_VERSION;
1151
1263
  function describeCollectorVersion(version2 = exports.COLLECTOR_VERSION) {
1152
1264
  return version2 === exports.UNRELEASED_COLLECTOR_VERSION ? `${version2} (built from a checkout, not a release)` : version2;
1153
1265
  }
@@ -2275,14 +2387,14 @@ var require_http = __commonJS({
2275
2387
  }
2276
2388
  };
2277
2389
  exports.AscendaApiError = AscendaApiError;
2278
- async function createPairingSession(apiBaseUrl, toolInstallationId, toolType, displayName) {
2390
+ async function createPairingSession(apiBaseUrl, toolInstallationId, toolType, displayName, orgJoinCode) {
2279
2391
  const response = await fetch(`${apiBaseUrl}/v1/tool-pairing-sessions`, {
2280
2392
  method: "POST",
2281
2393
  headers: { "Content-Type": "application/json" },
2282
- body: JSON.stringify({ toolInstallationId, toolType, displayName })
2394
+ body: JSON.stringify({ toolInstallationId, toolType, displayName, ...orgJoinCode ? { orgJoinCode, mode: "report" } : {} })
2283
2395
  });
2284
2396
  if (!response.ok)
2285
- throw new AscendaApiError(response.status, void 0, await response.text());
2397
+ throw await apiError(response);
2286
2398
  return await response.json();
2287
2399
  }
2288
2400
  async function getPairingStatus(apiBaseUrl, pairingSessionId) {
@@ -2532,6 +2644,7 @@ var require_eventSender = __commonJS({
2532
2644
  var tokenStore_1 = require_tokenStore();
2533
2645
  var stateStore_1 = require_stateStore();
2534
2646
  var payload_1 = require_payload();
2647
+ var collectorPlatform_1 = require_collectorPlatform();
2535
2648
  var collectorVersion_1 = require_collectorVersion();
2536
2649
  var AscendaSemanticEventError = class extends Error {
2537
2650
  constructor(message) {
@@ -2559,7 +2672,7 @@ var require_eventSender = __commonJS({
2559
2672
  return (0, tool_contract_1.joinEventPayload)({ toolInstallationId: identity.toolInstallationId, idempotencyKey: (0, payload_1.mintIdempotencyKey)() }, buildEventBody(identity, mapped));
2560
2673
  }
2561
2674
  function withCollectorVersion(metadata) {
2562
- return { ...metadata, collectorVersion: collectorVersion_1.COLLECTOR_VERSION };
2675
+ return { ...metadata, collectorVersion: collectorVersion_1.COLLECTOR_VERSION, collectorPlatform: collectorPlatform_1.COLLECTOR_PLATFORM };
2563
2676
  }
2564
2677
  var DEFAULT_TIMEOUT_MS = 5e3;
2565
2678
  var RETRY_DELAY_MS = 250;
@@ -3903,58 +4016,36 @@ var require_hookAdapter = __commonJS({
3903
4016
  }
3904
4017
  });
3905
4018
 
3906
- // ../packages/tool-kit/out/hookSet.js
3907
- var require_hookSet = __commonJS({
3908
- "../packages/tool-kit/out/hookSet.js"(exports) {
4019
+ // ../packages/tool-kit/out/confirmLinks.js
4020
+ var require_confirmLinks = __commonJS({
4021
+ "../packages/tool-kit/out/confirmLinks.js"(exports) {
3909
4022
  "use strict";
3910
4023
  Object.defineProperty(exports, "__esModule", { value: true });
3911
- exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = void 0;
3912
- exports.hookSetArgument = hookSetArgument;
3913
- exports.readHookSet = readHookSet;
3914
- exports.isHookSet = isHookSet;
3915
- exports.readViaPlugin = readViaPlugin;
3916
- exports.hookSetOfCommand = hookSetOfCommand;
3917
- exports.hookSetChanges = hookSetChanges;
3918
- exports.describeHookSetChanges = describeHookSetChanges;
3919
- exports.HOOK_SET_FLAG = "--hook-set";
3920
- exports.UNVERSIONED_HOOK_SET = 1;
3921
- function hookSetArgument(hookSet) {
3922
- return hookSet === void 0 ? "" : ` ${exports.HOOK_SET_FLAG} ${hookSet}`;
3923
- }
3924
- function readHookSet(argv) {
3925
- const index = argv.indexOf(exports.HOOK_SET_FLAG);
3926
- if (index === -1)
4024
+ exports.pairingConfirmUrl = pairingConfirmUrl;
4025
+ exports.pairingConfirmLines = pairingConfirmLines;
4026
+ exports.studyJoinConfirmUrl = studyJoinConfirmUrl;
4027
+ function pairingConfirmUrl(qrUrl) {
4028
+ return isHttps(qrUrl) ? qrUrl : void 0;
4029
+ }
4030
+ function pairingConfirmLines(qrUrl, code) {
4031
+ const url = pairingConfirmUrl(qrUrl);
4032
+ if (!url)
4033
+ return [`Confirm in the Ascenda app \u2014 code ${code}`];
4034
+ return [`Open this link to confirm: ${url}`, `Or paste code ${code} in the Ascenda app.`];
4035
+ }
4036
+ function studyJoinConfirmUrl(apiBaseUrl, deviceCode) {
4037
+ if (!isHttps(apiBaseUrl))
3927
4038
  return void 0;
3928
- const raw = argv[index + 1];
3929
- if (raw === void 0 || !/^[1-9]\d*$/.test(raw))
3930
- return void 0;
3931
- const value = Number(raw);
3932
- return isHookSet(value) ? value : void 0;
3933
- }
3934
- function isHookSet(value) {
3935
- return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
3936
- }
3937
- function readViaPlugin(env) {
3938
- return env.CLAUDE_PLUGIN_ROOT ? true : void 0;
3939
- }
3940
- function hookSetOfCommand(command) {
3941
- const match = command.match(/--hook-set\s+(\d+)/);
3942
- return match ? Number(match[1]) : exports.UNVERSIONED_HOOK_SET;
3943
- }
3944
- function hookSetChanges(before, events) {
3945
- const added = events.filter((event) => !before.has(event));
3946
- const sets = [...before.values()];
3947
- return sets.length ? { added, previousSet: Math.min(...sets) } : { added };
4039
+ return `${apiBaseUrl.replace(/\/+$/, "")}/join/${encodeURIComponent(deviceCode)}`;
3948
4040
  }
3949
- function describeHookSetChanges(changes, hookSet) {
3950
- if (changes.previousSet === void 0)
3951
- return void 0;
3952
- const parts = [];
3953
- if (changes.added.length)
3954
- parts.push(`added ${changes.added.join(", ")}`);
3955
- if (changes.previousSet < hookSet)
3956
- parts.push(`hook set ${changes.previousSet} \u2192 ${hookSet}`);
3957
- return parts.length ? `upgraded: ${parts.join("; ")}` : void 0;
4041
+ function isHttps(value) {
4042
+ if (!value)
4043
+ return false;
4044
+ try {
4045
+ return new URL(value).protocol === "https:";
4046
+ } catch {
4047
+ return false;
4048
+ }
3958
4049
  }
3959
4050
  }
3960
4051
  });
@@ -4003,12 +4094,17 @@ var require_studyJoin = __commonJS({
4003
4094
  Object.defineProperty(exports, "__esModule", { value: true });
4004
4095
  exports.runStudyJoin = runStudyJoin;
4005
4096
  exports.formatWindow = formatWindow;
4097
+ exports.describeStudyGrant = describeStudyGrant;
4098
+ exports.describeStudyKind = describeStudyKind;
4099
+ exports.describeRefusal = describeRefusal;
4006
4100
  var readline = __importStar(__require("node:readline"));
4101
+ var confirmLinks_1 = require_confirmLinks();
4007
4102
  var http_1 = require_http();
4008
4103
  var STUDY_JOIN_MODE = "report";
4009
4104
  var POLL_INTERVAL_MS = 3e3;
4010
4105
  var POLL_TIMEOUT_MS = 11 * 60 * 1e3;
4011
4106
  async function runStudyJoin(ctx) {
4107
+ const report = (outcome) => ctx.onOutcome?.(outcome);
4012
4108
  const stdin = ctx.stdin ?? process.stdin;
4013
4109
  const stdout = ctx.stdout ?? process.stdout;
4014
4110
  const stderr = ctx.stderr ?? process.stderr;
@@ -4016,10 +4112,12 @@ var require_studyJoin = __commonJS({
4016
4112
  `);
4017
4113
  if (!stdin.isTTY || !stdout.isTTY) {
4018
4114
  stderr.write("join needs an interactive terminal (stdin and stdout). Run it directly, not from a script or a pipe.\n");
4115
+ report({ status: "no_terminal", granted: [] });
4019
4116
  return 0;
4020
4117
  }
4021
4118
  if (!ctx.joinCode) {
4022
4119
  stderr.write("Usage: join <code>\n");
4120
+ report({ status: "failed", granted: [], message: "No join code given." });
4023
4121
  return 1;
4024
4122
  }
4025
4123
  let start;
@@ -4028,6 +4126,7 @@ var require_studyJoin = __commonJS({
4028
4126
  } catch (error2) {
4029
4127
  stderr.write(`${describeStartError(error2)}
4030
4128
  `);
4129
+ report({ status: "failed", granted: [], message: describeStartError(error2) });
4031
4130
  return 1;
4032
4131
  }
4033
4132
  print("");
@@ -4036,7 +4135,7 @@ var require_studyJoin = __commonJS({
4036
4135
  print("");
4037
4136
  print("Report (30 days) grants:");
4038
4137
  for (const grant of start.grants)
4039
- print(` ${describeGrant(grant)}`);
4138
+ print(` ${describeStudyGrant(grant)}`);
4040
4139
  print("");
4041
4140
  print("Study mode needs the Ascenda app. Open the app to join that way instead.");
4042
4141
  print("");
@@ -4047,10 +4146,17 @@ var require_studyJoin = __commonJS({
4047
4146
  const answer = await askChoice(stdin, stdout);
4048
4147
  if (!/^(1|report)$/i.test(answer)) {
4049
4148
  print("Not now.");
4149
+ report({ status: "not_now", start, granted: [] });
4050
4150
  return 0;
4051
4151
  }
4052
4152
  print("");
4053
- print(`Confirm in the Ascenda app with code ${start.deviceCode}`);
4153
+ const confirmUrl = (0, confirmLinks_1.studyJoinConfirmUrl)(ctx.apiBaseUrl, start.deviceCode);
4154
+ if (confirmUrl) {
4155
+ print(`Open this link to confirm: ${confirmUrl}`);
4156
+ print(`Or confirm in the Ascenda app with code ${start.deviceCode}.`);
4157
+ } else {
4158
+ print(`Confirm in the Ascenda app with code ${start.deviceCode}`);
4159
+ }
4054
4160
  print(`Waiting for confirmation (expires ${formatLocalTime(start.expiresAt)})...`);
4055
4161
  const pollIntervalMs = ctx.pollIntervalMs ?? POLL_INTERVAL_MS;
4056
4162
  const deadline = Math.min(Date.parse(start.expiresAt) || Date.now() + POLL_TIMEOUT_MS, Date.now() + POLL_TIMEOUT_MS);
@@ -4064,6 +4170,7 @@ var require_studyJoin = __commonJS({
4064
4170
  continue;
4065
4171
  stderr.write(`${describeStartError(error2)}
4066
4172
  `);
4173
+ report({ status: "failed", start, granted: [], message: describeStartError(error2) });
4067
4174
  return 1;
4068
4175
  }
4069
4176
  if (poll.status === "pending")
@@ -4073,20 +4180,23 @@ var require_studyJoin = __commonJS({
4073
4180
  if (granted.length === 0) {
4074
4181
  print("");
4075
4182
  print("Nothing was granted. Run join again, or check with your organisation.");
4183
+ report({ status: "refused", start, granted: [], message: "Nothing was granted." });
4076
4184
  return 1;
4077
4185
  }
4078
4186
  print("");
4079
4187
  print("Joined. Granted:");
4080
4188
  for (const grant of granted)
4081
- print(` ${describeGrant(grant)}`);
4189
+ print(` ${describeStudyGrant(grant)}`);
4082
4190
  print("");
4083
4191
  print("Each of these can be turned off separately, in the app's consent settings.");
4084
4192
  print("The organisation sees group counts, never who joined.");
4193
+ report({ status: "joined", start, granted });
4085
4194
  return 0;
4086
4195
  }
4087
4196
  if (poll.status === "expired") {
4088
4197
  print("");
4089
4198
  print("This code expired before it was confirmed. Run join again for a fresh code.");
4199
+ report({ status: "expired", start, granted: [] });
4090
4200
  return 1;
4091
4201
  }
4092
4202
  if (poll.refusedReason === "grant_failed") {
@@ -4097,19 +4207,22 @@ var require_studyJoin = __commonJS({
4097
4207
  print("");
4098
4208
  print("Granted before the failure:");
4099
4209
  for (const grant of granted)
4100
- print(` ${describeGrant(grant)}`);
4210
+ print(` ${describeStudyGrant(grant)}`);
4101
4211
  print("");
4102
4212
  print("Each of these can be turned off separately, in the app's consent settings.");
4103
4213
  }
4104
4214
  print("Run join again, or check with your organisation.");
4215
+ report({ status: "refused", start, granted, refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason) });
4105
4216
  return 1;
4106
4217
  }
4107
4218
  print("");
4108
4219
  print(describeRefusal(poll.refusedReason));
4220
+ report({ status: "refused", start, granted: [], refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason) });
4109
4221
  return 1;
4110
4222
  }
4111
4223
  print("");
4112
4224
  print("Timed out waiting for confirmation. Run join again for a fresh code.");
4225
+ report({ status: "expired", start, granted: [] });
4113
4226
  return 1;
4114
4227
  }
4115
4228
  function isRetryablePollError(error2) {
@@ -4152,7 +4265,7 @@ var require_studyJoin = __commonJS({
4152
4265
  501: "AI assistant data processing consent",
4153
4266
  507: "Import of the AI-work history already on your machine"
4154
4267
  };
4155
- function describeGrant(grant) {
4268
+ function describeStudyGrant(grant) {
4156
4269
  return GRANT_SENTENCES[grant.code] ?? humanise(grant.name);
4157
4270
  }
4158
4271
  var STUDY_KIND_SENTENCES = {
@@ -4172,7 +4285,7 @@ var require_studyJoin = __commonJS({
4172
4285
  // table is ever consulted — present so the type stays exhaustive, and as
4173
4286
  // a plain fallback should something call this function with it directly.
4174
4287
  grant_failed: "Join failed partway through. Some grants may not have gone through.",
4175
- declined: "You declined in the app. Nothing was granted.",
4288
+ declined: "You declined the join. Nothing was granted.",
4176
4289
  not_enrolled: "That study couldn't enrol you, so nothing was granted."
4177
4290
  };
4178
4291
  function describeRefusal(refusedReason) {
@@ -4200,6 +4313,182 @@ var require_studyJoin = __commonJS({
4200
4313
  }
4201
4314
  });
4202
4315
 
4316
+ // ../packages/tool-kit/out/pairingStudyJoin.js
4317
+ var require_pairingStudyJoin = __commonJS({
4318
+ "../packages/tool-kit/out/pairingStudyJoin.js"(exports) {
4319
+ "use strict";
4320
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
4321
+ if (k2 === void 0) k2 = k;
4322
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4323
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4324
+ desc = { enumerable: true, get: function() {
4325
+ return m[k];
4326
+ } };
4327
+ }
4328
+ Object.defineProperty(o, k2, desc);
4329
+ } : function(o, m, k, k2) {
4330
+ if (k2 === void 0) k2 = k;
4331
+ o[k2] = m[k];
4332
+ });
4333
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
4334
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
4335
+ } : function(o, v) {
4336
+ o["default"] = v;
4337
+ });
4338
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
4339
+ var ownKeys = function(o) {
4340
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
4341
+ var ar = [];
4342
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
4343
+ return ar;
4344
+ };
4345
+ return ownKeys(o);
4346
+ };
4347
+ return function(mod) {
4348
+ if (mod && mod.__esModule) return mod;
4349
+ var result = {};
4350
+ if (mod != null) {
4351
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
4352
+ }
4353
+ __setModuleDefault(result, mod);
4354
+ return result;
4355
+ };
4356
+ }();
4357
+ Object.defineProperty(exports, "__esModule", { value: true });
4358
+ exports.PAIR_JOIN_OUTCOME_FILE_ENV = exports.PAIR_ORG_JOIN_CODE_ENV = void 0;
4359
+ exports.createPairingAttempt = createPairingAttempt;
4360
+ exports.pairingAttemptLines = pairingAttemptLines;
4361
+ exports.settleStudyJoin = settleStudyJoin;
4362
+ exports.writePairingJoinOutcome = writePairingJoinOutcome;
4363
+ exports.pairingJoinOutcome = pairingJoinOutcome;
4364
+ var fs = __importStar(__require("node:fs"));
4365
+ var confirmLinks_1 = require_confirmLinks();
4366
+ var studyJoin_1 = require_studyJoin();
4367
+ var http_1 = require_http();
4368
+ exports.PAIR_ORG_JOIN_CODE_ENV = "ASCENDA_PAIR_ORG_JOIN_CODE";
4369
+ exports.PAIR_JOIN_OUTCOME_FILE_ENV = "ASCENDA_PAIR_JOIN_OUTCOME_FILE";
4370
+ var CREATE_REFUSALS = {
4371
+ join_code_not_found: "That code is not a study anyone can join. Check it and try again.",
4372
+ no_live_study: "There's nothing open to join with that code right now.",
4373
+ unknown_mode: "This tool only offers Report mode from the command line."
4374
+ };
4375
+ var JOIN_SETTLE_MS = 6e4;
4376
+ async function createPairingAttempt(apiBaseUrl, toolInstallationId, toolType, displayName, env = process.env) {
4377
+ const orgJoinCode = env[exports.PAIR_ORG_JOIN_CODE_ENV]?.trim();
4378
+ if (!orgJoinCode)
4379
+ return { session: await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName), carriesJoin: false };
4380
+ let refusal;
4381
+ try {
4382
+ const session = await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName, orgJoinCode);
4383
+ return { session, carriesJoin: session.studyJoin !== void 0 };
4384
+ } catch (error2) {
4385
+ if (!(error2 instanceof http_1.AscendaApiError) || error2.status >= 500)
4386
+ throw error2;
4387
+ refusal = error2.errorCode ? CREATE_REFUSALS[error2.errorCode] : void 0;
4388
+ }
4389
+ return { session: await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName), carriesJoin: false, refusal };
4390
+ }
4391
+ function pairingAttemptLines(attempt) {
4392
+ const { session } = attempt;
4393
+ const join = attempt.carriesJoin ? session.studyJoin : void 0;
4394
+ if (!join)
4395
+ return (0, confirmLinks_1.pairingConfirmLines)(session.qrUrl, session.code);
4396
+ return [
4397
+ `This also joins ${join.organisationName} (${(0, studyJoin_1.formatWindow)(join.windowStartUtc, join.windowEndUtc)}). The page shows what you'd share before you confirm.`,
4398
+ `Open this link to confirm: ${session.qrUrl}`
4399
+ ];
4400
+ }
4401
+ async function settleStudyJoin(apiBaseUrl, pairingSessionId, last, wait = 1e3) {
4402
+ let current = last;
4403
+ const deadline = Date.now() + JOIN_SETTLE_MS;
4404
+ while (current && current.status === "pending" && Date.now() < deadline) {
4405
+ await new Promise((resolve) => setTimeout(resolve, wait));
4406
+ let status;
4407
+ try {
4408
+ status = await (0, http_1.getPairingStatus)(apiBaseUrl, pairingSessionId);
4409
+ } catch {
4410
+ continue;
4411
+ }
4412
+ current = status.studyJoin ?? current;
4413
+ }
4414
+ return current;
4415
+ }
4416
+ function writePairingJoinOutcome(outcome, env = process.env) {
4417
+ const file = env[exports.PAIR_JOIN_OUTCOME_FILE_ENV]?.trim();
4418
+ if (!file)
4419
+ return;
4420
+ try {
4421
+ fs.writeFileSync(file, `${JSON.stringify(outcome)}
4422
+ `, { mode: 384 });
4423
+ } catch {
4424
+ }
4425
+ }
4426
+ function pairingJoinOutcome(attempt, pairing, studyJoin) {
4427
+ if (!attempt)
4428
+ return { join: "none", pairing };
4429
+ if (attempt.refusal)
4430
+ return { join: "refused", pairing, message: attempt.refusal };
4431
+ return { join: attempt.carriesJoin ? "carried" : "not_carried", pairing, studyJoin };
4432
+ }
4433
+ }
4434
+ });
4435
+
4436
+ // ../packages/tool-kit/out/hookSet.js
4437
+ var require_hookSet = __commonJS({
4438
+ "../packages/tool-kit/out/hookSet.js"(exports) {
4439
+ "use strict";
4440
+ Object.defineProperty(exports, "__esModule", { value: true });
4441
+ exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = void 0;
4442
+ exports.hookSetArgument = hookSetArgument;
4443
+ exports.readHookSet = readHookSet;
4444
+ exports.isHookSet = isHookSet;
4445
+ exports.readViaPlugin = readViaPlugin;
4446
+ exports.hookSetOfCommand = hookSetOfCommand;
4447
+ exports.hookSetChanges = hookSetChanges;
4448
+ exports.describeHookSetChanges = describeHookSetChanges;
4449
+ exports.HOOK_SET_FLAG = "--hook-set";
4450
+ exports.UNVERSIONED_HOOK_SET = 1;
4451
+ function hookSetArgument(hookSet) {
4452
+ return hookSet === void 0 ? "" : ` ${exports.HOOK_SET_FLAG} ${hookSet}`;
4453
+ }
4454
+ function readHookSet(argv) {
4455
+ const index = argv.indexOf(exports.HOOK_SET_FLAG);
4456
+ if (index === -1)
4457
+ return void 0;
4458
+ const raw = argv[index + 1];
4459
+ if (raw === void 0 || !/^[1-9]\d*$/.test(raw))
4460
+ return void 0;
4461
+ const value = Number(raw);
4462
+ return isHookSet(value) ? value : void 0;
4463
+ }
4464
+ function isHookSet(value) {
4465
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
4466
+ }
4467
+ function readViaPlugin(env) {
4468
+ return env.CLAUDE_PLUGIN_ROOT ? true : void 0;
4469
+ }
4470
+ function hookSetOfCommand(command) {
4471
+ const match = command.match(/--hook-set\s+(\d+)/);
4472
+ return match ? Number(match[1]) : exports.UNVERSIONED_HOOK_SET;
4473
+ }
4474
+ function hookSetChanges(before, events) {
4475
+ const added = events.filter((event) => !before.has(event));
4476
+ const sets = [...before.values()];
4477
+ return sets.length ? { added, previousSet: Math.min(...sets) } : { added };
4478
+ }
4479
+ function describeHookSetChanges(changes, hookSet) {
4480
+ if (changes.previousSet === void 0)
4481
+ return void 0;
4482
+ const parts = [];
4483
+ if (changes.added.length)
4484
+ parts.push(`added ${changes.added.join(", ")}`);
4485
+ if (changes.previousSet < hookSet)
4486
+ parts.push(`hook set ${changes.previousSet} \u2192 ${hookSet}`);
4487
+ return parts.length ? `upgraded: ${parts.join("; ")}` : void 0;
4488
+ }
4489
+ }
4490
+ });
4491
+
4203
4492
  // ../packages/tool-kit/out/initiatives.js
4204
4493
  var require_initiatives = __commonJS({
4205
4494
  "../packages/tool-kit/out/initiatives.js"(exports) {
@@ -5553,6 +5842,7 @@ var require_cliAgentSetup = __commonJS({
5553
5842
  var eventLog_1 = require_eventLog();
5554
5843
  var hookAdapter_1 = require_hookAdapter();
5555
5844
  var http_1 = require_http();
5845
+ var pairingStudyJoin_1 = require_pairingStudyJoin();
5556
5846
  var hookSet_1 = require_hookSet();
5557
5847
  var initiatives_1 = require_initiatives();
5558
5848
  var settingsFile_1 = require_settingsFile();
@@ -5877,16 +6167,19 @@ ${usage(spec)}`);
5877
6167
  return { toolInstallationId: existingId ?? `${spec.toolType}:<paired at run time>`, paired: false };
5878
6168
  }
5879
6169
  const toolInstallationId = existingId ?? `${spec.toolType}:${crypto.randomUUID()}`;
5880
- let session;
6170
+ let attempt;
5881
6171
  try {
5882
- session = await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, spec.toolType, `${spec.displayName} on ${os.hostname()}`);
6172
+ attempt = await (0, pairingStudyJoin_1.createPairingAttempt)(apiBaseUrl, toolInstallationId, spec.toolType, `${spec.displayName} on ${os.hostname()}`);
5883
6173
  } catch (error2) {
5884
6174
  console.error(`
5885
6175
  Could not reach ${apiBaseUrl} to pair: ${error2 instanceof Error ? error2.message : String(error2)}`);
5886
6176
  console.error("Start the local dev server and use --local, or pass --api-base-url for your backend.");
5887
6177
  return void 0;
5888
6178
  }
5889
- const token = await pollForToken(apiBaseUrl, session.pairingSessionId, session.code, session.expiresAt);
6179
+ if (attempt.refusal)
6180
+ console.log(`
6181
+ ${attempt.refusal} Pairing without the study.`);
6182
+ const token = await pollForToken(apiBaseUrl, attempt);
5890
6183
  if (!token)
5891
6184
  return void 0;
5892
6185
  (0, tokenStore_1.persistEventWriteToken)((0, tokenStore_1.defaultTokenFilePath)(toolInstallationId), token);
@@ -5904,27 +6197,32 @@ Could not reach ${apiBaseUrl} to pair: ${error2 instanceof Error ? error2.messag
5904
6197
  }
5905
6198
  return "keep";
5906
6199
  }
5907
- async function pollForToken(apiBaseUrl, pairingSessionId, code, expiresAt) {
5908
- const deadline = Math.min(Date.parse(expiresAt) || Date.now() + 3e5, Date.now() + 3e5);
5909
- let announced = false;
6200
+ async function pollForToken(apiBaseUrl, attempt) {
6201
+ const { session } = attempt;
6202
+ const deadline = Math.min(Date.parse(session.expiresAt) || Date.now() + 3e5, Date.now() + 3e5);
6203
+ let studyJoin;
6204
+ console.log("");
6205
+ for (const line of (0, pairingStudyJoin_1.pairingAttemptLines)(attempt))
6206
+ console.log(` ${line}`);
6207
+ console.log(" Waiting...");
5910
6208
  while (Date.now() < deadline) {
5911
- const status = await (0, http_1.getPairingStatus)(apiBaseUrl, pairingSessionId);
5912
- if (status.status === "paired" && status.eventWriteToken)
6209
+ const status = await (0, http_1.getPairingStatus)(apiBaseUrl, session.pairingSessionId);
6210
+ studyJoin = status.studyJoin ?? studyJoin;
6211
+ if (status.status === "paired" && status.eventWriteToken) {
6212
+ studyJoin = await (0, pairingStudyJoin_1.settleStudyJoin)(apiBaseUrl, session.pairingSessionId, studyJoin);
6213
+ (0, pairingStudyJoin_1.writePairingJoinOutcome)((0, pairingStudyJoin_1.pairingJoinOutcome)(attempt, "paired", studyJoin));
5913
6214
  return status.eventWriteToken;
6215
+ }
5914
6216
  if (status.status === "expired" || status.status === "cancelled") {
5915
6217
  console.error(`
5916
6218
  Pairing ${status.status}. Run setup again.`);
6219
+ (0, pairingStudyJoin_1.writePairingJoinOutcome)((0, pairingStudyJoin_1.pairingJoinOutcome)(attempt, status.status, studyJoin));
5917
6220
  return void 0;
5918
6221
  }
5919
- if (!announced) {
5920
- console.log(`
5921
- Confirm in the Ascenda app \u2014 code ${code}`);
5922
- console.log(" Waiting...");
5923
- announced = true;
5924
- }
5925
6222
  await new Promise((resolve) => setTimeout(resolve, 2e3));
5926
6223
  }
5927
6224
  console.error("\nPairing timed out. Run setup again.");
6225
+ (0, pairingStudyJoin_1.writePairingJoinOutcome)((0, pairingStudyJoin_1.pairingJoinOutcome)(attempt, "gave_up", studyJoin));
5928
6226
  return void 0;
5929
6227
  }
5930
6228
  function installBinary(spec, dryRun) {
@@ -6651,11 +6949,11 @@ var require_out3 = __commonJS({
6651
6949
  "../packages/tool-kit/out/index.js"(exports) {
6652
6950
  "use strict";
6653
6951
  Object.defineProperty(exports, "__esModule", { value: true });
6654
- 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;
6655
- 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;
6656
- 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;
6657
- 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;
6658
- 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;
6952
+ 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;
6953
+ 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;
6954
+ 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;
6955
+ 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;
6956
+ 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;
6659
6957
  var commandClassifier_1 = require_commandClassifier();
6660
6958
  Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
6661
6959
  return commandClassifier_1.classifyCommand;
@@ -6743,6 +7041,13 @@ var require_out3 = __commonJS({
6743
7041
  Object.defineProperty(exports, "mintIdempotencyKey", { enumerable: true, get: function() {
6744
7042
  return payload_1.mintIdempotencyKey;
6745
7043
  } });
7044
+ var collectorPlatform_1 = require_collectorPlatform();
7045
+ Object.defineProperty(exports, "COLLECTOR_PLATFORM", { enumerable: true, get: function() {
7046
+ return collectorPlatform_1.COLLECTOR_PLATFORM;
7047
+ } });
7048
+ Object.defineProperty(exports, "detectCollectorPlatform", { enumerable: true, get: function() {
7049
+ return collectorPlatform_1.detectCollectorPlatform;
7050
+ } });
6746
7051
  var collectorVersion_1 = require_collectorVersion();
6747
7052
  Object.defineProperty(exports, "COLLECTOR_VERSION", { enumerable: true, get: function() {
6748
7053
  return collectorVersion_1.COLLECTOR_VERSION;
@@ -7327,9 +7632,53 @@ var require_out3 = __commonJS({
7327
7632
  return studyNotices_1.studyNoticeStatus;
7328
7633
  } });
7329
7634
  var studyJoin_1 = require_studyJoin();
7635
+ Object.defineProperty(exports, "describeStudyJoinRefusal", { enumerable: true, get: function() {
7636
+ return studyJoin_1.describeRefusal;
7637
+ } });
7638
+ Object.defineProperty(exports, "describeStudyKind", { enumerable: true, get: function() {
7639
+ return studyJoin_1.describeStudyKind;
7640
+ } });
7641
+ Object.defineProperty(exports, "describeStudyGrant", { enumerable: true, get: function() {
7642
+ return studyJoin_1.describeStudyGrant;
7643
+ } });
7644
+ Object.defineProperty(exports, "formatWindow", { enumerable: true, get: function() {
7645
+ return studyJoin_1.formatWindow;
7646
+ } });
7330
7647
  Object.defineProperty(exports, "runStudyJoin", { enumerable: true, get: function() {
7331
7648
  return studyJoin_1.runStudyJoin;
7332
7649
  } });
7650
+ var confirmLinks_1 = require_confirmLinks();
7651
+ Object.defineProperty(exports, "pairingConfirmLines", { enumerable: true, get: function() {
7652
+ return confirmLinks_1.pairingConfirmLines;
7653
+ } });
7654
+ Object.defineProperty(exports, "pairingConfirmUrl", { enumerable: true, get: function() {
7655
+ return confirmLinks_1.pairingConfirmUrl;
7656
+ } });
7657
+ Object.defineProperty(exports, "studyJoinConfirmUrl", { enumerable: true, get: function() {
7658
+ return confirmLinks_1.studyJoinConfirmUrl;
7659
+ } });
7660
+ var pairingStudyJoin_1 = require_pairingStudyJoin();
7661
+ Object.defineProperty(exports, "PAIR_JOIN_OUTCOME_FILE_ENV", { enumerable: true, get: function() {
7662
+ return pairingStudyJoin_1.PAIR_JOIN_OUTCOME_FILE_ENV;
7663
+ } });
7664
+ Object.defineProperty(exports, "PAIR_ORG_JOIN_CODE_ENV", { enumerable: true, get: function() {
7665
+ return pairingStudyJoin_1.PAIR_ORG_JOIN_CODE_ENV;
7666
+ } });
7667
+ Object.defineProperty(exports, "createPairingAttempt", { enumerable: true, get: function() {
7668
+ return pairingStudyJoin_1.createPairingAttempt;
7669
+ } });
7670
+ Object.defineProperty(exports, "pairingAttemptLines", { enumerable: true, get: function() {
7671
+ return pairingStudyJoin_1.pairingAttemptLines;
7672
+ } });
7673
+ Object.defineProperty(exports, "pairingJoinOutcome", { enumerable: true, get: function() {
7674
+ return pairingStudyJoin_1.pairingJoinOutcome;
7675
+ } });
7676
+ Object.defineProperty(exports, "settleStudyJoin", { enumerable: true, get: function() {
7677
+ return pairingStudyJoin_1.settleStudyJoin;
7678
+ } });
7679
+ Object.defineProperty(exports, "writePairingJoinOutcome", { enumerable: true, get: function() {
7680
+ return pairingStudyJoin_1.writePairingJoinOutcome;
7681
+ } });
7333
7682
  }
7334
7683
  });
7335
7684
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "publishConfig": { "access": "public" },
3
3
  "name": "@ascenda-one/agent-mcp",
4
- "version": "0.1.37",
4
+ "version": "0.1.39",
5
5
  "description": "MCP server exposing ascenda_emit_work_signal — the one submission interface for agent-observed (semantic) work-friction signals.",
6
6
  "repository": {
7
7
  "type": "git",