@ascenda-one/agent-mcp 0.1.38 → 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.
- package/dist/cli.js +322 -84
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -926,7 +926,10 @@ var require_out = __commonJS({
|
|
|
926
926
|
importSchema: "transport",
|
|
927
927
|
// The version of the Ascenda collector that sent this event. Names the
|
|
928
928
|
// build, and nothing about the work it observed.
|
|
929
|
-
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"
|
|
930
933
|
};
|
|
931
934
|
exports.EVENT_METADATA_FIELDS = [
|
|
932
935
|
"language",
|
|
@@ -970,7 +973,8 @@ var require_out = __commonJS({
|
|
|
970
973
|
"importKey",
|
|
971
974
|
"extractionId",
|
|
972
975
|
"importSchema",
|
|
973
|
-
"collectorVersion"
|
|
976
|
+
"collectorVersion",
|
|
977
|
+
"collectorPlatform"
|
|
974
978
|
];
|
|
975
979
|
exports.DELIVERY_ENVELOPE_KEYS = ["toolInstallationId", "idempotencyKey"];
|
|
976
980
|
function joinEventPayload(envelope, body) {
|
|
@@ -1174,6 +1178,79 @@ var require_payload = __commonJS({
|
|
|
1174
1178
|
}
|
|
1175
1179
|
});
|
|
1176
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
|
+
|
|
1177
1254
|
// ../packages/tool-kit/out/collectorVersion.js
|
|
1178
1255
|
var require_collectorVersion = __commonJS({
|
|
1179
1256
|
"../packages/tool-kit/out/collectorVersion.js"(exports) {
|
|
@@ -1182,7 +1259,7 @@ var require_collectorVersion = __commonJS({
|
|
|
1182
1259
|
exports.COLLECTOR_VERSION = exports.UNRELEASED_COLLECTOR_VERSION = void 0;
|
|
1183
1260
|
exports.describeCollectorVersion = describeCollectorVersion;
|
|
1184
1261
|
exports.UNRELEASED_COLLECTOR_VERSION = "unreleased";
|
|
1185
|
-
exports.COLLECTOR_VERSION = "0.1.
|
|
1262
|
+
exports.COLLECTOR_VERSION = "0.1.39" ? "0.1.39" : exports.UNRELEASED_COLLECTOR_VERSION;
|
|
1186
1263
|
function describeCollectorVersion(version2 = exports.COLLECTOR_VERSION) {
|
|
1187
1264
|
return version2 === exports.UNRELEASED_COLLECTOR_VERSION ? `${version2} (built from a checkout, not a release)` : version2;
|
|
1188
1265
|
}
|
|
@@ -2310,14 +2387,14 @@ var require_http = __commonJS({
|
|
|
2310
2387
|
}
|
|
2311
2388
|
};
|
|
2312
2389
|
exports.AscendaApiError = AscendaApiError;
|
|
2313
|
-
async function createPairingSession(apiBaseUrl, toolInstallationId, toolType, displayName) {
|
|
2390
|
+
async function createPairingSession(apiBaseUrl, toolInstallationId, toolType, displayName, orgJoinCode) {
|
|
2314
2391
|
const response = await fetch(`${apiBaseUrl}/v1/tool-pairing-sessions`, {
|
|
2315
2392
|
method: "POST",
|
|
2316
2393
|
headers: { "Content-Type": "application/json" },
|
|
2317
|
-
body: JSON.stringify({ toolInstallationId, toolType, displayName })
|
|
2394
|
+
body: JSON.stringify({ toolInstallationId, toolType, displayName, ...orgJoinCode ? { orgJoinCode, mode: "report" } : {} })
|
|
2318
2395
|
});
|
|
2319
2396
|
if (!response.ok)
|
|
2320
|
-
throw
|
|
2397
|
+
throw await apiError(response);
|
|
2321
2398
|
return await response.json();
|
|
2322
2399
|
}
|
|
2323
2400
|
async function getPairingStatus(apiBaseUrl, pairingSessionId) {
|
|
@@ -2567,6 +2644,7 @@ var require_eventSender = __commonJS({
|
|
|
2567
2644
|
var tokenStore_1 = require_tokenStore();
|
|
2568
2645
|
var stateStore_1 = require_stateStore();
|
|
2569
2646
|
var payload_1 = require_payload();
|
|
2647
|
+
var collectorPlatform_1 = require_collectorPlatform();
|
|
2570
2648
|
var collectorVersion_1 = require_collectorVersion();
|
|
2571
2649
|
var AscendaSemanticEventError = class extends Error {
|
|
2572
2650
|
constructor(message) {
|
|
@@ -2594,7 +2672,7 @@ var require_eventSender = __commonJS({
|
|
|
2594
2672
|
return (0, tool_contract_1.joinEventPayload)({ toolInstallationId: identity.toolInstallationId, idempotencyKey: (0, payload_1.mintIdempotencyKey)() }, buildEventBody(identity, mapped));
|
|
2595
2673
|
}
|
|
2596
2674
|
function withCollectorVersion(metadata) {
|
|
2597
|
-
return { ...metadata, collectorVersion: collectorVersion_1.COLLECTOR_VERSION };
|
|
2675
|
+
return { ...metadata, collectorVersion: collectorVersion_1.COLLECTOR_VERSION, collectorPlatform: collectorPlatform_1.COLLECTOR_PLATFORM };
|
|
2598
2676
|
}
|
|
2599
2677
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
2600
2678
|
var RETRY_DELAY_MS = 250;
|
|
@@ -3972,62 +4050,6 @@ var require_confirmLinks = __commonJS({
|
|
|
3972
4050
|
}
|
|
3973
4051
|
});
|
|
3974
4052
|
|
|
3975
|
-
// ../packages/tool-kit/out/hookSet.js
|
|
3976
|
-
var require_hookSet = __commonJS({
|
|
3977
|
-
"../packages/tool-kit/out/hookSet.js"(exports) {
|
|
3978
|
-
"use strict";
|
|
3979
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3980
|
-
exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = void 0;
|
|
3981
|
-
exports.hookSetArgument = hookSetArgument;
|
|
3982
|
-
exports.readHookSet = readHookSet;
|
|
3983
|
-
exports.isHookSet = isHookSet;
|
|
3984
|
-
exports.readViaPlugin = readViaPlugin;
|
|
3985
|
-
exports.hookSetOfCommand = hookSetOfCommand;
|
|
3986
|
-
exports.hookSetChanges = hookSetChanges;
|
|
3987
|
-
exports.describeHookSetChanges = describeHookSetChanges;
|
|
3988
|
-
exports.HOOK_SET_FLAG = "--hook-set";
|
|
3989
|
-
exports.UNVERSIONED_HOOK_SET = 1;
|
|
3990
|
-
function hookSetArgument(hookSet) {
|
|
3991
|
-
return hookSet === void 0 ? "" : ` ${exports.HOOK_SET_FLAG} ${hookSet}`;
|
|
3992
|
-
}
|
|
3993
|
-
function readHookSet(argv) {
|
|
3994
|
-
const index = argv.indexOf(exports.HOOK_SET_FLAG);
|
|
3995
|
-
if (index === -1)
|
|
3996
|
-
return void 0;
|
|
3997
|
-
const raw = argv[index + 1];
|
|
3998
|
-
if (raw === void 0 || !/^[1-9]\d*$/.test(raw))
|
|
3999
|
-
return void 0;
|
|
4000
|
-
const value = Number(raw);
|
|
4001
|
-
return isHookSet(value) ? value : void 0;
|
|
4002
|
-
}
|
|
4003
|
-
function isHookSet(value) {
|
|
4004
|
-
return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
|
|
4005
|
-
}
|
|
4006
|
-
function readViaPlugin(env) {
|
|
4007
|
-
return env.CLAUDE_PLUGIN_ROOT ? true : void 0;
|
|
4008
|
-
}
|
|
4009
|
-
function hookSetOfCommand(command) {
|
|
4010
|
-
const match = command.match(/--hook-set\s+(\d+)/);
|
|
4011
|
-
return match ? Number(match[1]) : exports.UNVERSIONED_HOOK_SET;
|
|
4012
|
-
}
|
|
4013
|
-
function hookSetChanges(before, events) {
|
|
4014
|
-
const added = events.filter((event) => !before.has(event));
|
|
4015
|
-
const sets = [...before.values()];
|
|
4016
|
-
return sets.length ? { added, previousSet: Math.min(...sets) } : { added };
|
|
4017
|
-
}
|
|
4018
|
-
function describeHookSetChanges(changes, hookSet) {
|
|
4019
|
-
if (changes.previousSet === void 0)
|
|
4020
|
-
return void 0;
|
|
4021
|
-
const parts = [];
|
|
4022
|
-
if (changes.added.length)
|
|
4023
|
-
parts.push(`added ${changes.added.join(", ")}`);
|
|
4024
|
-
if (changes.previousSet < hookSet)
|
|
4025
|
-
parts.push(`hook set ${changes.previousSet} \u2192 ${hookSet}`);
|
|
4026
|
-
return parts.length ? `upgraded: ${parts.join("; ")}` : void 0;
|
|
4027
|
-
}
|
|
4028
|
-
}
|
|
4029
|
-
});
|
|
4030
|
-
|
|
4031
4053
|
// ../packages/tool-kit/out/studyJoin.js
|
|
4032
4054
|
var require_studyJoin = __commonJS({
|
|
4033
4055
|
"../packages/tool-kit/out/studyJoin.js"(exports) {
|
|
@@ -4074,6 +4096,7 @@ var require_studyJoin = __commonJS({
|
|
|
4074
4096
|
exports.formatWindow = formatWindow;
|
|
4075
4097
|
exports.describeStudyGrant = describeStudyGrant;
|
|
4076
4098
|
exports.describeStudyKind = describeStudyKind;
|
|
4099
|
+
exports.describeRefusal = describeRefusal;
|
|
4077
4100
|
var readline = __importStar(__require("node:readline"));
|
|
4078
4101
|
var confirmLinks_1 = require_confirmLinks();
|
|
4079
4102
|
var http_1 = require_http();
|
|
@@ -4290,6 +4313,182 @@ var require_studyJoin = __commonJS({
|
|
|
4290
4313
|
}
|
|
4291
4314
|
});
|
|
4292
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
|
+
|
|
4293
4492
|
// ../packages/tool-kit/out/initiatives.js
|
|
4294
4493
|
var require_initiatives = __commonJS({
|
|
4295
4494
|
"../packages/tool-kit/out/initiatives.js"(exports) {
|
|
@@ -5642,8 +5841,8 @@ var require_cliAgentSetup = __commonJS({
|
|
|
5642
5841
|
var credentials_1 = require_credentials();
|
|
5643
5842
|
var eventLog_1 = require_eventLog();
|
|
5644
5843
|
var hookAdapter_1 = require_hookAdapter();
|
|
5645
|
-
var confirmLinks_1 = require_confirmLinks();
|
|
5646
5844
|
var http_1 = require_http();
|
|
5845
|
+
var pairingStudyJoin_1 = require_pairingStudyJoin();
|
|
5647
5846
|
var hookSet_1 = require_hookSet();
|
|
5648
5847
|
var initiatives_1 = require_initiatives();
|
|
5649
5848
|
var settingsFile_1 = require_settingsFile();
|
|
@@ -5968,16 +6167,19 @@ ${usage(spec)}`);
|
|
|
5968
6167
|
return { toolInstallationId: existingId ?? `${spec.toolType}:<paired at run time>`, paired: false };
|
|
5969
6168
|
}
|
|
5970
6169
|
const toolInstallationId = existingId ?? `${spec.toolType}:${crypto.randomUUID()}`;
|
|
5971
|
-
let
|
|
6170
|
+
let attempt;
|
|
5972
6171
|
try {
|
|
5973
|
-
|
|
6172
|
+
attempt = await (0, pairingStudyJoin_1.createPairingAttempt)(apiBaseUrl, toolInstallationId, spec.toolType, `${spec.displayName} on ${os.hostname()}`);
|
|
5974
6173
|
} catch (error2) {
|
|
5975
6174
|
console.error(`
|
|
5976
6175
|
Could not reach ${apiBaseUrl} to pair: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
5977
6176
|
console.error("Start the local dev server and use --local, or pass --api-base-url for your backend.");
|
|
5978
6177
|
return void 0;
|
|
5979
6178
|
}
|
|
5980
|
-
|
|
6179
|
+
if (attempt.refusal)
|
|
6180
|
+
console.log(`
|
|
6181
|
+
${attempt.refusal} Pairing without the study.`);
|
|
6182
|
+
const token = await pollForToken(apiBaseUrl, attempt);
|
|
5981
6183
|
if (!token)
|
|
5982
6184
|
return void 0;
|
|
5983
6185
|
(0, tokenStore_1.persistEventWriteToken)((0, tokenStore_1.defaultTokenFilePath)(toolInstallationId), token);
|
|
@@ -5995,28 +6197,32 @@ Could not reach ${apiBaseUrl} to pair: ${error2 instanceof Error ? error2.messag
|
|
|
5995
6197
|
}
|
|
5996
6198
|
return "keep";
|
|
5997
6199
|
}
|
|
5998
|
-
async function pollForToken(apiBaseUrl,
|
|
5999
|
-
const
|
|
6000
|
-
|
|
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...");
|
|
6001
6208
|
while (Date.now() < deadline) {
|
|
6002
|
-
const status = await (0, http_1.getPairingStatus)(apiBaseUrl, pairingSessionId);
|
|
6003
|
-
|
|
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));
|
|
6004
6214
|
return status.eventWriteToken;
|
|
6215
|
+
}
|
|
6005
6216
|
if (status.status === "expired" || status.status === "cancelled") {
|
|
6006
6217
|
console.error(`
|
|
6007
6218
|
Pairing ${status.status}. Run setup again.`);
|
|
6219
|
+
(0, pairingStudyJoin_1.writePairingJoinOutcome)((0, pairingStudyJoin_1.pairingJoinOutcome)(attempt, status.status, studyJoin));
|
|
6008
6220
|
return void 0;
|
|
6009
6221
|
}
|
|
6010
|
-
if (!announced) {
|
|
6011
|
-
console.log("");
|
|
6012
|
-
for (const line of (0, confirmLinks_1.pairingConfirmLines)(qrUrl, code))
|
|
6013
|
-
console.log(` ${line}`);
|
|
6014
|
-
console.log(" Waiting...");
|
|
6015
|
-
announced = true;
|
|
6016
|
-
}
|
|
6017
6222
|
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
6018
6223
|
}
|
|
6019
6224
|
console.error("\nPairing timed out. Run setup again.");
|
|
6225
|
+
(0, pairingStudyJoin_1.writePairingJoinOutcome)((0, pairingStudyJoin_1.pairingJoinOutcome)(attempt, "gave_up", studyJoin));
|
|
6020
6226
|
return void 0;
|
|
6021
6227
|
}
|
|
6022
6228
|
function installBinary(spec, dryRun) {
|
|
@@ -6743,11 +6949,11 @@ var require_out3 = __commonJS({
|
|
|
6743
6949
|
"../packages/tool-kit/out/index.js"(exports) {
|
|
6744
6950
|
"use strict";
|
|
6745
6951
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6746
|
-
exports.
|
|
6747
|
-
exports.
|
|
6748
|
-
exports.
|
|
6749
|
-
exports.
|
|
6750
|
-
exports.studyJoinConfirmUrl = exports.pairingConfirmUrl = exports.pairingConfirmLines = exports.runStudyJoin = exports.formatWindow = exports.describeStudyGrant = exports.describeStudyKind = 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;
|
|
6751
6957
|
var commandClassifier_1 = require_commandClassifier();
|
|
6752
6958
|
Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
|
|
6753
6959
|
return commandClassifier_1.classifyCommand;
|
|
@@ -6835,6 +7041,13 @@ var require_out3 = __commonJS({
|
|
|
6835
7041
|
Object.defineProperty(exports, "mintIdempotencyKey", { enumerable: true, get: function() {
|
|
6836
7042
|
return payload_1.mintIdempotencyKey;
|
|
6837
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
|
+
} });
|
|
6838
7051
|
var collectorVersion_1 = require_collectorVersion();
|
|
6839
7052
|
Object.defineProperty(exports, "COLLECTOR_VERSION", { enumerable: true, get: function() {
|
|
6840
7053
|
return collectorVersion_1.COLLECTOR_VERSION;
|
|
@@ -7419,6 +7632,9 @@ var require_out3 = __commonJS({
|
|
|
7419
7632
|
return studyNotices_1.studyNoticeStatus;
|
|
7420
7633
|
} });
|
|
7421
7634
|
var studyJoin_1 = require_studyJoin();
|
|
7635
|
+
Object.defineProperty(exports, "describeStudyJoinRefusal", { enumerable: true, get: function() {
|
|
7636
|
+
return studyJoin_1.describeRefusal;
|
|
7637
|
+
} });
|
|
7422
7638
|
Object.defineProperty(exports, "describeStudyKind", { enumerable: true, get: function() {
|
|
7423
7639
|
return studyJoin_1.describeStudyKind;
|
|
7424
7640
|
} });
|
|
@@ -7441,6 +7657,28 @@ var require_out3 = __commonJS({
|
|
|
7441
7657
|
Object.defineProperty(exports, "studyJoinConfirmUrl", { enumerable: true, get: function() {
|
|
7442
7658
|
return confirmLinks_1.studyJoinConfirmUrl;
|
|
7443
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
|
+
} });
|
|
7444
7682
|
}
|
|
7445
7683
|
});
|
|
7446
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.
|
|
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",
|