@ascenda-one/github-collector 0.1.41 → 0.1.43
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 +2628 -1269
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -178,12 +178,27 @@ var require_gitActionClassifier = __commonJS({
|
|
|
178
178
|
}
|
|
179
179
|
if (i >= words.length)
|
|
180
180
|
return void 0;
|
|
181
|
-
return { verb: words[i], args: words.slice(i + 1) };
|
|
181
|
+
return { verb: words[i], args: withoutRedirects(words.slice(i + 1)) };
|
|
182
|
+
}
|
|
183
|
+
function withoutRedirects(words) {
|
|
184
|
+
const kept = [];
|
|
185
|
+
for (let i = 0; i < words.length; i++) {
|
|
186
|
+
const redirect = /^\d*(>>?|<)(.*)$/.exec(words[i]);
|
|
187
|
+
if (!redirect) {
|
|
188
|
+
kept.push(words[i]);
|
|
189
|
+
} else if (redirect[2] === "") {
|
|
190
|
+
i += 1;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return kept;
|
|
194
|
+
}
|
|
195
|
+
function isHeadRef(ref) {
|
|
196
|
+
return /^(head([~^@]|$)|@([~^]|$))/.test(ref);
|
|
182
197
|
}
|
|
183
198
|
function discardsWork({ verb, args }) {
|
|
184
199
|
switch (verb) {
|
|
185
200
|
case "restore":
|
|
186
|
-
return
|
|
201
|
+
return restoreDiscards(args);
|
|
187
202
|
case "switch":
|
|
188
203
|
return args.includes("--discard-changes") || args.includes("--force") || args.includes("-f");
|
|
189
204
|
case "clean": {
|
|
@@ -197,18 +212,43 @@ var require_gitActionClassifier = __commonJS({
|
|
|
197
212
|
return false;
|
|
198
213
|
}
|
|
199
214
|
}
|
|
215
|
+
function restoreDiscards(args) {
|
|
216
|
+
if (args.includes("--staged"))
|
|
217
|
+
return false;
|
|
218
|
+
if (args.includes("--ours") || args.includes("--theirs"))
|
|
219
|
+
return false;
|
|
220
|
+
const source = optionValue(args, "--source", "-s");
|
|
221
|
+
return source === void 0 || isHeadRef(source);
|
|
222
|
+
}
|
|
223
|
+
function optionValue(args, long, short) {
|
|
224
|
+
for (let i = 0; i < args.length; i++) {
|
|
225
|
+
if (args[i].startsWith(`${long}=`))
|
|
226
|
+
return args[i].slice(long.length + 1);
|
|
227
|
+
if (args[i] === long || args[i] === short)
|
|
228
|
+
return args[i + 1];
|
|
229
|
+
}
|
|
230
|
+
return void 0;
|
|
231
|
+
}
|
|
200
232
|
function checkoutDiscards(args) {
|
|
201
|
-
if (args.includes("--"))
|
|
202
|
-
return
|
|
233
|
+
if (args.includes("--ours") || args.includes("--theirs"))
|
|
234
|
+
return false;
|
|
235
|
+
const separator = args.indexOf("--");
|
|
236
|
+
if (separator !== -1) {
|
|
237
|
+
const source = args.slice(0, separator).find((a) => !a.startsWith("-"));
|
|
238
|
+
return source === void 0 || isHeadRef(source);
|
|
239
|
+
}
|
|
203
240
|
if (args.some((a) => ["-b", "--orphan", "--detach", "-d", "-t", "--track", "-B"].includes(a)))
|
|
204
241
|
return false;
|
|
205
242
|
const words = args.filter((a) => !a.startsWith("-"));
|
|
206
243
|
if (words.length >= 2)
|
|
207
|
-
return
|
|
244
|
+
return isHeadRef(words[0]) || looksLikePath(words[0]);
|
|
208
245
|
if (words.length === 1)
|
|
209
|
-
return
|
|
246
|
+
return looksLikePath(words[0]);
|
|
210
247
|
return false;
|
|
211
248
|
}
|
|
249
|
+
function looksLikePath(word) {
|
|
250
|
+
return /^\.{1,2}(\/|$)|\/$|[*?]|\.[a-z][a-z0-9]*$/.test(word);
|
|
251
|
+
}
|
|
212
252
|
}
|
|
213
253
|
});
|
|
214
254
|
|
|
@@ -309,7 +349,13 @@ var require_modelClassifier = __commonJS({
|
|
|
309
349
|
"../packages/tool-kit/out/modelClassifier.js"(exports) {
|
|
310
350
|
"use strict";
|
|
311
351
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
352
|
+
exports.PREMIUM_MODEL_CLASSES = void 0;
|
|
353
|
+
exports.isPremiumModelClass = isPremiumModelClass;
|
|
312
354
|
exports.classifyModelClass = classifyModelClass;
|
|
355
|
+
exports.PREMIUM_MODEL_CLASSES = /* @__PURE__ */ new Set(["anthropic:opus", "anthropic:fable"]);
|
|
356
|
+
function isPremiumModelClass(modelClass) {
|
|
357
|
+
return modelClass !== void 0 && exports.PREMIUM_MODEL_CLASSES.has(modelClass);
|
|
358
|
+
}
|
|
313
359
|
function classifyModelClass(raw) {
|
|
314
360
|
const candidate = raw;
|
|
315
361
|
if (candidate === void 0 || candidate === null)
|
|
@@ -321,6 +367,8 @@ var require_modelClassifier = __commonJS({
|
|
|
321
367
|
return void 0;
|
|
322
368
|
if (ROUTER_SENTINEL.test(value))
|
|
323
369
|
return "router:auto";
|
|
370
|
+
if (LOCAL_RUNTIME.test(value))
|
|
371
|
+
return "local:on_device";
|
|
324
372
|
const vendor = readModelVendor(value);
|
|
325
373
|
if (vendor === void 0)
|
|
326
374
|
return "unknown";
|
|
@@ -338,14 +386,22 @@ var require_modelClassifier = __commonJS({
|
|
|
338
386
|
return void 0;
|
|
339
387
|
}
|
|
340
388
|
var ROUTER_SENTINEL = /^(?:[a-z0-9][a-z0-9._-]*\/)?(?:auto|default)$/;
|
|
389
|
+
var LOCAL_RUNTIME = /\b(ollama|llamacpp|llama\.cpp|lmstudio|lm-studio|on[-_]?device)\b/;
|
|
341
390
|
var VENDOR_PATTERNS = [
|
|
342
391
|
[/\b(anthropic|claude|opus|sonnet|haiku|fable)\b/, "anthropic"],
|
|
343
392
|
[/\b(openai|gpt|o[1-9])\b/, "openai"],
|
|
344
|
-
[/\b(google|gemini
|
|
393
|
+
[/\b(google|gemini)\b/, "google"],
|
|
345
394
|
// xAI carries no corporate prefix in any observed id — the family name is
|
|
346
395
|
// the whole marker, exactly as `claude` and `gemini` are for theirs.
|
|
347
396
|
[/\b(xai|grok)\b/, "xai"],
|
|
348
|
-
[/\
|
|
397
|
+
[/\bdeepseek(?:-ai)?(?![a-z])/, "deepseek"],
|
|
398
|
+
[/\b(moonshot(?:ai)?|kimi)(?![a-z])/, "moonshot"],
|
|
399
|
+
[/\b(zhipu(?:ai)?|z-ai|zai-org|chatglm|glm)(?![a-z])/, "zhipu"],
|
|
400
|
+
[/\bminimax(?:ai)?(?![a-z])/, "minimax"],
|
|
401
|
+
[/\b(alibaba|qwen|qwq)(?![a-z])/, "alibaba"],
|
|
402
|
+
[/\b(mistral(?:ai)?|mixtral|codestral|devstral|magistral|ministral|pixtral)(?![a-z])/, "mistral"],
|
|
403
|
+
[/\b(meta-llama|meta|llama|codellama)(?![a-z])/, "meta"],
|
|
404
|
+
[/\blocal\b/, "local"]
|
|
349
405
|
];
|
|
350
406
|
var TIER_PATTERNS_BY_VENDOR = {
|
|
351
407
|
anthropic: [
|
|
@@ -361,127 +417,511 @@ var require_modelClassifier = __commonJS({
|
|
|
361
417
|
// distinction the ids do not yet draw — `<vendor>:unknown` is waiting for
|
|
362
418
|
// the day one does.
|
|
363
419
|
xai: [[/\bgrok\b/, "xai:grok"]],
|
|
364
|
-
|
|
420
|
+
deepseek: [],
|
|
421
|
+
moonshot: [],
|
|
422
|
+
zhipu: [],
|
|
423
|
+
minimax: [],
|
|
424
|
+
alibaba: [],
|
|
425
|
+
mistral: [],
|
|
426
|
+
meta: [],
|
|
427
|
+
// The runtime words are read before any vendor, so only a bare `local`
|
|
428
|
+
// reaches here, and it names no runtime.
|
|
429
|
+
local: []
|
|
365
430
|
};
|
|
366
431
|
var UNKNOWN_TIER_BY_VENDOR = {
|
|
367
432
|
anthropic: "anthropic:unknown",
|
|
368
433
|
openai: "openai:unknown",
|
|
369
434
|
google: "google:unknown",
|
|
370
435
|
xai: "xai:unknown",
|
|
436
|
+
deepseek: "deepseek:unknown",
|
|
437
|
+
moonshot: "moonshot:unknown",
|
|
438
|
+
zhipu: "zhipu:unknown",
|
|
439
|
+
minimax: "minimax:unknown",
|
|
440
|
+
alibaba: "alibaba:unknown",
|
|
441
|
+
mistral: "mistral:unknown",
|
|
442
|
+
meta: "meta:unknown",
|
|
371
443
|
local: "local:unknown"
|
|
372
444
|
};
|
|
373
445
|
}
|
|
374
446
|
});
|
|
375
447
|
|
|
376
|
-
// ../packages/tool-kit/out/
|
|
377
|
-
var
|
|
378
|
-
"../packages/tool-kit/out/
|
|
448
|
+
// ../packages/tool-kit/out/effortClassifier.js
|
|
449
|
+
var require_effortClassifier = __commonJS({
|
|
450
|
+
"../packages/tool-kit/out/effortClassifier.js"(exports) {
|
|
379
451
|
"use strict";
|
|
380
452
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
381
|
-
exports.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (
|
|
385
|
-
return "0";
|
|
386
|
-
if (count <= 10)
|
|
387
|
-
return "1-10";
|
|
388
|
-
if (count <= 50)
|
|
389
|
-
return "10-50";
|
|
390
|
-
if (count <= 200)
|
|
391
|
-
return "50-200";
|
|
392
|
-
return "200+";
|
|
393
|
-
}
|
|
394
|
-
function bucketDurationMs(durationMs) {
|
|
395
|
-
if (typeof durationMs !== "number" || !Number.isFinite(durationMs) || durationMs < 0)
|
|
453
|
+
exports.classifyEffortClass = classifyEffortClass;
|
|
454
|
+
function classifyEffortClass(raw) {
|
|
455
|
+
const candidate = raw;
|
|
456
|
+
if (candidate === void 0 || candidate === null)
|
|
396
457
|
return void 0;
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
if (
|
|
401
|
-
return
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
458
|
+
if (typeof candidate !== "string")
|
|
459
|
+
return "unknown";
|
|
460
|
+
const value = candidate.trim().toLowerCase();
|
|
461
|
+
if (!value)
|
|
462
|
+
return void 0;
|
|
463
|
+
return EFFORT_CLASS_BY_LEVEL[value] ?? "unknown";
|
|
464
|
+
}
|
|
465
|
+
var EFFORT_CLASS_BY_LEVEL = {
|
|
466
|
+
none: "low",
|
|
467
|
+
minimal: "low",
|
|
468
|
+
low: "low",
|
|
469
|
+
medium: "medium",
|
|
470
|
+
high: "high",
|
|
471
|
+
xhigh: "xhigh",
|
|
472
|
+
max: "max"
|
|
473
|
+
};
|
|
410
474
|
}
|
|
411
475
|
});
|
|
412
476
|
|
|
413
|
-
// ../packages/tool-kit/out/
|
|
414
|
-
var
|
|
415
|
-
"../packages/tool-kit/out/
|
|
477
|
+
// ../packages/tool-kit/out/modelRoute.js
|
|
478
|
+
var require_modelRoute = __commonJS({
|
|
479
|
+
"../packages/tool-kit/out/modelRoute.js"(exports) {
|
|
416
480
|
"use strict";
|
|
417
481
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
418
|
-
exports.
|
|
419
|
-
exports.
|
|
420
|
-
exports.
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
482
|
+
exports.modelRouteFromSlug = modelRouteFromSlug;
|
|
483
|
+
exports.modelRouteFromCodexProvider = modelRouteFromCodexProvider;
|
|
484
|
+
exports.claudeCodeModelRoute = claudeCodeModelRoute;
|
|
485
|
+
function modelRouteFromSlug(raw) {
|
|
486
|
+
if (typeof raw !== "string")
|
|
487
|
+
return void 0;
|
|
488
|
+
const value = raw.trim().toLowerCase();
|
|
489
|
+
if (!value)
|
|
490
|
+
return void 0;
|
|
491
|
+
for (const [pattern, route] of SLUG_ROUTES) {
|
|
492
|
+
if (pattern.test(value))
|
|
493
|
+
return route;
|
|
494
|
+
}
|
|
495
|
+
return void 0;
|
|
496
|
+
}
|
|
497
|
+
var BEDROCK_VENDORS = "anthropic|amazon|meta|mistral|cohere|ai21|deepseek|qwen|openai|writer|moonshot|minimax|stability";
|
|
498
|
+
var SLUG_ROUTES = [
|
|
499
|
+
// Local runtimes first: `ollama/…` says where the weights ran whatever the
|
|
500
|
+
// rest of the id says.
|
|
501
|
+
[/^(ollama|ollama_chat|lmstudio|lm_studio|lm-studio|llamacpp|llama\.cpp)\//, "local"],
|
|
502
|
+
[/\b(ollama|llamacpp|lmstudio)\b/, "local"],
|
|
503
|
+
[/^(bedrock|bedrock_converse|amazon-bedrock|aws-bedrock)\//, "bedrock"],
|
|
504
|
+
[/^arn:aws[a-z-]*:bedrock:/, "bedrock"],
|
|
505
|
+
// `us.anthropic.claude-…-v1:0`, `eu.meta.llama3-…`, `anthropic.claude-…`.
|
|
506
|
+
// The vendor dot is what makes it Bedrock's form: no other surface writes
|
|
507
|
+
// `vendor.model`.
|
|
508
|
+
[new RegExp(`^(?:(?:us|eu|apac|us-gov|global|jp|au|ca)\\.)?(?:${BEDROCK_VENDORS})\\.[a-z0-9]`), "bedrock"],
|
|
509
|
+
[/^(vertex_ai|vertex|vertex_ai_beta|google-vertex|vertexai)\//, "vertex"],
|
|
510
|
+
[/(^|\/)publishers\/[a-z0-9-]+\/models\//, "vertex"],
|
|
511
|
+
[/^(azure|azure_ai|azure-openai|azureai)\//, "azure"],
|
|
512
|
+
[/^(openrouter|litellm|litellm_proxy|portkey|helicone|together_ai|together|fireworks_ai|fireworks|groq|deepinfra|cloudflare)\//, "gateway"]
|
|
513
|
+
];
|
|
514
|
+
function modelRouteFromCodexProvider(raw) {
|
|
515
|
+
if (typeof raw !== "string")
|
|
516
|
+
return void 0;
|
|
517
|
+
const value = raw.trim().toLowerCase();
|
|
518
|
+
if (!value)
|
|
519
|
+
return void 0;
|
|
520
|
+
return CODEX_PROVIDER_ROUTES[value] ?? "custom_endpoint";
|
|
521
|
+
}
|
|
522
|
+
var CODEX_PROVIDER_ROUTES = {
|
|
523
|
+
openai: "direct",
|
|
524
|
+
azure: "azure",
|
|
525
|
+
"azure-openai": "azure",
|
|
526
|
+
oss: "local",
|
|
527
|
+
ollama: "local",
|
|
528
|
+
lmstudio: "local",
|
|
529
|
+
"lm-studio": "local",
|
|
530
|
+
bedrock: "bedrock",
|
|
531
|
+
"amazon-bedrock": "bedrock",
|
|
532
|
+
vertex: "vertex",
|
|
533
|
+
vertexai: "vertex",
|
|
534
|
+
openrouter: "gateway",
|
|
535
|
+
litellm: "gateway",
|
|
536
|
+
portkey: "gateway"
|
|
428
537
|
};
|
|
429
|
-
function
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
538
|
+
function claudeCodeModelRoute(env, slug) {
|
|
539
|
+
if (isTruthySetting(env.CLAUDE_CODE_USE_BEDROCK))
|
|
540
|
+
return "bedrock";
|
|
541
|
+
if (isTruthySetting(env.CLAUDE_CODE_USE_VERTEX))
|
|
542
|
+
return "vertex";
|
|
543
|
+
if (isTruthySetting(env.CLAUDE_CODE_USE_FOUNDRY))
|
|
544
|
+
return "azure";
|
|
545
|
+
const fromSlug = modelRouteFromSlug(slug);
|
|
546
|
+
if (fromSlug)
|
|
547
|
+
return fromSlug;
|
|
548
|
+
if (typeof env.ANTHROPIC_BASE_URL === "string" && env.ANTHROPIC_BASE_URL.trim() !== "")
|
|
549
|
+
return "custom_endpoint";
|
|
550
|
+
return "direct";
|
|
551
|
+
}
|
|
552
|
+
function isTruthySetting(value) {
|
|
553
|
+
if (value === void 0)
|
|
437
554
|
return false;
|
|
438
|
-
|
|
555
|
+
const v = value.trim().toLowerCase();
|
|
556
|
+
return v !== "" && v !== "0" && v !== "false" && v !== "no" && v !== "off";
|
|
439
557
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
// ../packages/tool-kit/out/tokenStore.js
|
|
562
|
+
var require_tokenStore = __commonJS({
|
|
563
|
+
"../packages/tool-kit/out/tokenStore.js"(exports) {
|
|
564
|
+
"use strict";
|
|
565
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
566
|
+
if (k2 === void 0) k2 = k;
|
|
567
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
568
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
569
|
+
desc = { enumerable: true, get: function() {
|
|
570
|
+
return m[k];
|
|
571
|
+
} };
|
|
572
|
+
}
|
|
573
|
+
Object.defineProperty(o, k2, desc);
|
|
574
|
+
} : function(o, m, k, k2) {
|
|
575
|
+
if (k2 === void 0) k2 = k;
|
|
576
|
+
o[k2] = m[k];
|
|
577
|
+
});
|
|
578
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
579
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
580
|
+
} : function(o, v) {
|
|
581
|
+
o["default"] = v;
|
|
582
|
+
});
|
|
583
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
584
|
+
var ownKeys = function(o) {
|
|
585
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
586
|
+
var ar = [];
|
|
587
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
588
|
+
return ar;
|
|
589
|
+
};
|
|
590
|
+
return ownKeys(o);
|
|
591
|
+
};
|
|
592
|
+
return function(mod) {
|
|
593
|
+
if (mod && mod.__esModule) return mod;
|
|
594
|
+
var result = {};
|
|
595
|
+
if (mod != null) {
|
|
596
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
597
|
+
}
|
|
598
|
+
__setModuleDefault(result, mod);
|
|
599
|
+
return result;
|
|
600
|
+
};
|
|
601
|
+
}();
|
|
602
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
603
|
+
exports.EVENT_TOKEN_TTL_MS = void 0;
|
|
604
|
+
exports.ascendaHome = ascendaHome;
|
|
605
|
+
exports.defaultTokenFilePath = defaultTokenFilePath2;
|
|
606
|
+
exports.tokenExpiryFilePath = tokenExpiryFilePath;
|
|
607
|
+
exports.persistEventWriteToken = persistEventWriteToken2;
|
|
608
|
+
exports.readTokenExpiry = readTokenExpiry;
|
|
609
|
+
exports.listPersistedToolInstallationIds = listPersistedToolInstallationIds;
|
|
610
|
+
exports.readTokenFile = readTokenFile2;
|
|
611
|
+
exports.sanitizeFilePart = sanitizeFilePart;
|
|
612
|
+
var fs = __importStar(__require("fs"));
|
|
613
|
+
var os = __importStar(__require("os"));
|
|
614
|
+
var path = __importStar(__require("path"));
|
|
615
|
+
function ascendaHome(home = os.homedir()) {
|
|
616
|
+
return process.env.ASCENDA_HOME ?? path.join(home, ".ascenda");
|
|
449
617
|
}
|
|
450
|
-
function
|
|
451
|
-
|
|
452
|
-
if (!match)
|
|
453
|
-
return fallback;
|
|
454
|
-
const hours = Number(match[1]);
|
|
455
|
-
const minutes = Number(match[2]);
|
|
456
|
-
if (Number.isNaN(hours) || Number.isNaN(minutes))
|
|
457
|
-
return fallback;
|
|
458
|
-
return Math.max(0, Math.min(23, hours)) * 60 + Math.max(0, Math.min(59, minutes));
|
|
618
|
+
function defaultTokenFilePath2(toolInstallationId) {
|
|
619
|
+
return path.join(ascendaHome(), "tokens", sanitizeFilePart(toolInstallationId));
|
|
459
620
|
}
|
|
460
|
-
function
|
|
461
|
-
return
|
|
621
|
+
function tokenExpiryFilePath(tokenFilePath) {
|
|
622
|
+
return path.join(path.dirname(tokenFilePath), "expiry", path.basename(tokenFilePath));
|
|
462
623
|
}
|
|
463
|
-
function
|
|
464
|
-
const
|
|
465
|
-
|
|
624
|
+
function persistEventWriteToken2(tokenFilePath, token, expiresAt) {
|
|
625
|
+
const dir = path.dirname(tokenFilePath);
|
|
626
|
+
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
627
|
+
fs.writeFileSync(tokenFilePath, token, { encoding: "utf8", mode: 384 });
|
|
628
|
+
if (process.platform !== "win32") {
|
|
629
|
+
fs.chmodSync(dir, 448);
|
|
630
|
+
fs.chmodSync(tokenFilePath, 384);
|
|
631
|
+
}
|
|
632
|
+
const expiryFile = tokenExpiryFilePath(tokenFilePath);
|
|
633
|
+
try {
|
|
634
|
+
if (expiresAt && Number.isFinite(Date.parse(expiresAt))) {
|
|
635
|
+
fs.mkdirSync(path.dirname(expiryFile), { recursive: true, mode: 448 });
|
|
636
|
+
fs.writeFileSync(expiryFile, expiresAt, { encoding: "utf8", mode: 384 });
|
|
637
|
+
} else {
|
|
638
|
+
fs.rmSync(expiryFile, { force: true });
|
|
639
|
+
}
|
|
640
|
+
} catch {
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
exports.EVENT_TOKEN_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
644
|
+
function readTokenExpiry(tokenFilePath) {
|
|
645
|
+
try {
|
|
646
|
+
const recorded = Date.parse(fs.readFileSync(tokenExpiryFilePath(tokenFilePath), "utf8").trim());
|
|
647
|
+
if (Number.isFinite(recorded))
|
|
648
|
+
return recorded;
|
|
649
|
+
} catch {
|
|
650
|
+
}
|
|
651
|
+
try {
|
|
652
|
+
return fs.statSync(tokenFilePath).mtimeMs + exports.EVENT_TOKEN_TTL_MS;
|
|
653
|
+
} catch {
|
|
654
|
+
return void 0;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
function listPersistedToolInstallationIds(toolType) {
|
|
658
|
+
const prefix = `${sanitizeFilePart(toolType)}_`;
|
|
659
|
+
const dir = path.join(ascendaHome(), "tokens");
|
|
660
|
+
let names;
|
|
661
|
+
try {
|
|
662
|
+
names = fs.readdirSync(dir);
|
|
663
|
+
} catch {
|
|
664
|
+
return [];
|
|
665
|
+
}
|
|
666
|
+
const ids = [];
|
|
667
|
+
for (const name of names.sort()) {
|
|
668
|
+
if (!name.startsWith(prefix) || name.length === prefix.length)
|
|
669
|
+
continue;
|
|
670
|
+
const file = path.join(dir, name);
|
|
671
|
+
try {
|
|
672
|
+
if (!fs.statSync(file).isFile())
|
|
673
|
+
continue;
|
|
674
|
+
} catch {
|
|
675
|
+
continue;
|
|
676
|
+
}
|
|
677
|
+
if (readTokenFile2(file) === void 0)
|
|
678
|
+
continue;
|
|
679
|
+
ids.push(`${toolType}:${name.slice(prefix.length)}`);
|
|
680
|
+
}
|
|
681
|
+
return ids;
|
|
682
|
+
}
|
|
683
|
+
function readTokenFile2(tokenFilePath) {
|
|
684
|
+
try {
|
|
685
|
+
if (!fs.existsSync(tokenFilePath))
|
|
686
|
+
return void 0;
|
|
687
|
+
const value = fs.readFileSync(tokenFilePath, "utf8").trim();
|
|
688
|
+
return value || void 0;
|
|
689
|
+
} catch {
|
|
690
|
+
return void 0;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
function sanitizeFilePart(value) {
|
|
694
|
+
return value.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
466
695
|
}
|
|
467
696
|
}
|
|
468
697
|
});
|
|
469
698
|
|
|
470
|
-
// ../packages/tool-
|
|
471
|
-
var
|
|
472
|
-
"../packages/tool-
|
|
699
|
+
// ../packages/tool-kit/out/modelState.js
|
|
700
|
+
var require_modelState = __commonJS({
|
|
701
|
+
"../packages/tool-kit/out/modelState.js"(exports) {
|
|
473
702
|
"use strict";
|
|
474
|
-
Object.
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
703
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
704
|
+
if (k2 === void 0) k2 = k;
|
|
705
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
706
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
707
|
+
desc = { enumerable: true, get: function() {
|
|
708
|
+
return m[k];
|
|
709
|
+
} };
|
|
710
|
+
}
|
|
711
|
+
Object.defineProperty(o, k2, desc);
|
|
712
|
+
} : function(o, m, k, k2) {
|
|
713
|
+
if (k2 === void 0) k2 = k;
|
|
714
|
+
o[k2] = m[k];
|
|
715
|
+
});
|
|
716
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
717
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
718
|
+
} : function(o, v) {
|
|
719
|
+
o["default"] = v;
|
|
720
|
+
});
|
|
721
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
722
|
+
var ownKeys = function(o) {
|
|
723
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
724
|
+
var ar = [];
|
|
725
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
726
|
+
return ar;
|
|
727
|
+
};
|
|
728
|
+
return ownKeys(o);
|
|
729
|
+
};
|
|
730
|
+
return function(mod) {
|
|
731
|
+
if (mod && mod.__esModule) return mod;
|
|
732
|
+
var result = {};
|
|
733
|
+
if (mod != null) {
|
|
734
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
735
|
+
}
|
|
736
|
+
__setModuleDefault(result, mod);
|
|
737
|
+
return result;
|
|
738
|
+
};
|
|
739
|
+
}();
|
|
740
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
741
|
+
exports.readSentModelId = readSentModelId;
|
|
742
|
+
exports.recordSentModelId = recordSentModelId;
|
|
743
|
+
exports.clearSentModelId = clearSentModelId;
|
|
744
|
+
exports.modelFieldsFor = modelFieldsFor;
|
|
745
|
+
exports.withModelOnChange = withModelOnChange;
|
|
746
|
+
var fs = __importStar(__require("fs"));
|
|
747
|
+
var path = __importStar(__require("path"));
|
|
748
|
+
var tokenStore_1 = require_tokenStore();
|
|
749
|
+
var modelClassifier_1 = require_modelClassifier();
|
|
750
|
+
var stateDir = () => process.env.ASCENDA_STATE_DIR ?? path.join((0, tokenStore_1.ascendaHome)(), "state");
|
|
751
|
+
function modelFile(agent, sessionId) {
|
|
752
|
+
return path.join(stateDir(), `${sanitize(agent)}-model-${sanitize(sessionId)}`);
|
|
753
|
+
}
|
|
754
|
+
function sanitize(value) {
|
|
755
|
+
return value.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
756
|
+
}
|
|
757
|
+
function readSentModelId(agent, sessionId) {
|
|
758
|
+
if (!sessionId)
|
|
759
|
+
return void 0;
|
|
760
|
+
try {
|
|
761
|
+
const id = fs.readFileSync(modelFile(agent, sessionId), "utf8").trim();
|
|
762
|
+
return id || void 0;
|
|
763
|
+
} catch {
|
|
764
|
+
return void 0;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function recordSentModelId(agent, sessionId, modelId) {
|
|
768
|
+
if (!sessionId || !modelId)
|
|
769
|
+
return;
|
|
770
|
+
try {
|
|
771
|
+
fs.mkdirSync(stateDir(), { recursive: true });
|
|
772
|
+
fs.writeFileSync(modelFile(agent, sessionId), modelId, { encoding: "utf8", mode: 384 });
|
|
773
|
+
} catch {
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
function clearSentModelId(agent, sessionId) {
|
|
777
|
+
if (!sessionId)
|
|
778
|
+
return;
|
|
779
|
+
try {
|
|
780
|
+
fs.rmSync(modelFile(agent, sessionId), { force: true });
|
|
781
|
+
} catch {
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
function modelFieldsFor(raw, route) {
|
|
785
|
+
if (typeof raw !== "string")
|
|
786
|
+
return void 0;
|
|
787
|
+
const modelId = raw.trim();
|
|
788
|
+
if (!modelId || modelId.length > 200)
|
|
789
|
+
return void 0;
|
|
790
|
+
const modelClass = (0, modelClassifier_1.classifyModelClass)(modelId);
|
|
791
|
+
if (modelClass === void 0)
|
|
792
|
+
return void 0;
|
|
793
|
+
return { modelId, modelClass, ...route ? { modelRoute: route } : {} };
|
|
794
|
+
}
|
|
795
|
+
function withModelOnChange(events, fields, lastSentModelId, force = false) {
|
|
796
|
+
if (events.length === 0 || !fields)
|
|
797
|
+
return { events };
|
|
798
|
+
if (!force && fields.modelId === lastSentModelId)
|
|
799
|
+
return { events };
|
|
800
|
+
const [first, ...rest] = events;
|
|
801
|
+
return {
|
|
802
|
+
events: [{ ...first, metadata: { ...first.metadata ?? {}, ...fields } }, ...rest],
|
|
803
|
+
sent: fields.modelId
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
// ../packages/tool-kit/out/buckets.js
|
|
810
|
+
var require_buckets = __commonJS({
|
|
811
|
+
"../packages/tool-kit/out/buckets.js"(exports) {
|
|
812
|
+
"use strict";
|
|
813
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
814
|
+
exports.bucketLinesChanged = bucketLinesChanged;
|
|
815
|
+
exports.bucketDurationMs = bucketDurationMs;
|
|
816
|
+
function bucketLinesChanged(count) {
|
|
817
|
+
if (count <= 0)
|
|
818
|
+
return "0";
|
|
819
|
+
if (count <= 10)
|
|
820
|
+
return "1-10";
|
|
821
|
+
if (count <= 50)
|
|
822
|
+
return "10-50";
|
|
823
|
+
if (count <= 200)
|
|
824
|
+
return "50-200";
|
|
825
|
+
return "200+";
|
|
826
|
+
}
|
|
827
|
+
function bucketDurationMs(durationMs) {
|
|
828
|
+
if (typeof durationMs !== "number" || !Number.isFinite(durationMs) || durationMs < 0)
|
|
829
|
+
return void 0;
|
|
830
|
+
const minutes = durationMs / 6e4;
|
|
831
|
+
if (minutes <= 1)
|
|
832
|
+
return "0-1m";
|
|
833
|
+
if (minutes <= 5)
|
|
834
|
+
return "1-5m";
|
|
835
|
+
if (minutes <= 10)
|
|
836
|
+
return "5-10m";
|
|
837
|
+
if (minutes <= 30)
|
|
838
|
+
return "10-30m";
|
|
839
|
+
if (minutes <= 60)
|
|
840
|
+
return "30-60m";
|
|
841
|
+
return "60m+";
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
// ../packages/tool-kit/out/afterHours.js
|
|
847
|
+
var require_afterHours = __commonJS({
|
|
848
|
+
"../packages/tool-kit/out/afterHours.js"(exports) {
|
|
849
|
+
"use strict";
|
|
850
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
851
|
+
exports.BUSINESS_DAY = void 0;
|
|
852
|
+
exports.isOutsideBusinessHours = isOutsideBusinessHours;
|
|
853
|
+
exports.isAfterHours = isAfterHours;
|
|
854
|
+
exports.utcOffsetMinutesAt = utcOffsetMinutesAt;
|
|
855
|
+
exports.localHourAt = localHourAt;
|
|
856
|
+
exports.BUSINESS_DAY = {
|
|
857
|
+
/** 0 = Sunday … 6 = Saturday. */
|
|
858
|
+
days: [1, 2, 3, 4, 5],
|
|
859
|
+
start: "09:00",
|
|
860
|
+
end: "17:00"
|
|
861
|
+
};
|
|
862
|
+
function isOutsideBusinessHours(at = /* @__PURE__ */ new Date(), opts = {}) {
|
|
863
|
+
const days = opts.days ?? exports.BUSINESS_DAY.days;
|
|
864
|
+
if (!days.includes(at.getDay()))
|
|
865
|
+
return true;
|
|
866
|
+
const minutes = at.getHours() * 60 + at.getMinutes();
|
|
867
|
+
const start = parseTimeToMinutes(opts.start ?? exports.BUSINESS_DAY.start, 9 * 60);
|
|
868
|
+
const end = parseTimeToMinutes(opts.end ?? exports.BUSINESS_DAY.end, 17 * 60);
|
|
869
|
+
if (start >= end)
|
|
870
|
+
return false;
|
|
871
|
+
return minutes < start || minutes >= end;
|
|
872
|
+
}
|
|
873
|
+
function isAfterHours(now = /* @__PURE__ */ new Date(), start = "19:00", end = "07:00") {
|
|
874
|
+
const currentMinutes = now.getHours() * 60 + now.getMinutes();
|
|
875
|
+
const startMinutes = parseTimeToMinutes(start, 19 * 60);
|
|
876
|
+
const endMinutes = parseTimeToMinutes(end, 7 * 60);
|
|
877
|
+
if (startMinutes === endMinutes)
|
|
878
|
+
return false;
|
|
879
|
+
if (startMinutes < endMinutes)
|
|
880
|
+
return currentMinutes >= startMinutes && currentMinutes < endMinutes;
|
|
881
|
+
return currentMinutes >= startMinutes || currentMinutes < endMinutes;
|
|
882
|
+
}
|
|
883
|
+
function parseTimeToMinutes(value, fallback) {
|
|
884
|
+
const match = /^(\d{1,2}):(\d{2})$/.exec(value.trim());
|
|
885
|
+
if (!match)
|
|
886
|
+
return fallback;
|
|
887
|
+
const hours = Number(match[1]);
|
|
888
|
+
const minutes = Number(match[2]);
|
|
889
|
+
if (Number.isNaN(hours) || Number.isNaN(minutes))
|
|
890
|
+
return fallback;
|
|
891
|
+
return Math.max(0, Math.min(23, hours)) * 60 + Math.max(0, Math.min(59, minutes));
|
|
892
|
+
}
|
|
893
|
+
function utcOffsetMinutesAt(at) {
|
|
894
|
+
return -at.getTimezoneOffset();
|
|
895
|
+
}
|
|
896
|
+
function localHourAt(at, utcOffsetMinutes) {
|
|
897
|
+
const shifted = new Date(at.getTime() + utcOffsetMinutes * 6e4);
|
|
898
|
+
return shifted.getUTCHours();
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
// ../packages/tool-contract/out/metricKeys.js
|
|
904
|
+
var require_metricKeys = __commonJS({
|
|
905
|
+
"../packages/tool-contract/out/metricKeys.js"(exports) {
|
|
906
|
+
"use strict";
|
|
907
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
908
|
+
exports.METRIC_KEYS = void 0;
|
|
909
|
+
exports.localMetricKeys = localMetricKeys;
|
|
910
|
+
exports.backendMetricKeys = backendMetricKeys;
|
|
911
|
+
var CONTEXT_WINDOW_CANONICAL_ALIASES = [
|
|
912
|
+
"contextWindowPeakPct",
|
|
479
913
|
"context_window_peak_pct",
|
|
480
914
|
"contextWindowPct",
|
|
481
915
|
"context_window_pct"
|
|
482
916
|
];
|
|
483
917
|
var CONTEXT_WINDOW_CURSOR_PERCENT_ALIASES = ["contextUsagePercent"];
|
|
484
918
|
exports.METRIC_KEYS = {
|
|
919
|
+
extractorRevision: {
|
|
920
|
+
family: "transport",
|
|
921
|
+
readBy: ["backend"],
|
|
922
|
+
backendAliases: ["extractorRevision"],
|
|
923
|
+
note: "Which rung of the store's extractor produced the row; the backend replaces a stored row when a higher one arrives under the same importKey."
|
|
924
|
+
},
|
|
485
925
|
// ── Read by a backend reader ────────────────────────────────────────────
|
|
486
926
|
contextWindowPeakPct: {
|
|
487
927
|
family: "context",
|
|
@@ -501,8 +941,12 @@ var require_metricKeys = __commonJS({
|
|
|
501
941
|
sessionMinutes: { family: "session", readBy: ["backend"], backendAliases: ["sessionMinutes", "session_minutes"], unit: "minutes" },
|
|
502
942
|
durationBucket: { family: "session", readBy: ["backend", "handoff"], backendAliases: ["durationBucket", "duration_bucket"] },
|
|
503
943
|
afterHoursPrompts: { family: "clock", readBy: ["backend", "handoff"], backendAliases: ["afterHoursPrompts", "after_hours_prompts"] },
|
|
944
|
+
/** Input tokens billed at the full rate: cache reads and cache writes
|
|
945
|
+
* excluded. Every extractor ships it on this definition, so
|
|
946
|
+
* `inputTokens + cacheReadTokens + cacheCreationTokens` is the whole input. */
|
|
504
947
|
inputTokens: { family: "context", readBy: ["backend"], backendAliases: ["inputTokens", "input_tokens"], unit: "tokens" },
|
|
505
948
|
outputTokens: { family: "context", readBy: ["backend"], backendAliases: ["outputTokens", "output_tokens"], unit: "tokens" },
|
|
949
|
+
/** Input tokens served from the prompt cache. Not part of `inputTokens`. */
|
|
506
950
|
cacheReadTokens: { family: "context", readBy: ["backend"], backendAliases: ["cacheReadTokens", "cache_read_tokens"], unit: "tokens" },
|
|
507
951
|
queuedPrompts: { family: "counts", readBy: ["backend"], backendAliases: ["queuedPrompts", "queued_prompts"] },
|
|
508
952
|
linesChangedBucket: { family: "edits", readBy: ["backend"], backendAliases: ["linesChangedBucket", "lines_changed_bucket"] },
|
|
@@ -524,6 +968,57 @@ var require_metricKeys = __commonJS({
|
|
|
524
968
|
backendAliases: ["branchKey", "branch_key"],
|
|
525
969
|
note: "forgeBranchKey of the repository and the branch a commit is reachable from. Absent on the default branch, like the live hooks."
|
|
526
970
|
},
|
|
971
|
+
// Codex's own usage-limit readings: `rate_limits` on its token_count lines,
|
|
972
|
+
// main thread only. The limit's id and name, the plan and the credit
|
|
973
|
+
// balance on the same object are never read. A session whose rollouts
|
|
974
|
+
// carried no readings has none of these keys.
|
|
975
|
+
//
|
|
976
|
+
// `family: "local"`, all seven. They say how much of an allowance was left
|
|
977
|
+
// on an account with the provider, which is a fact about the account and
|
|
978
|
+
// not about how the work went, so they are read on the machine and never
|
|
979
|
+
// sent. `ship.ts` leaves a `local` key out of the wire payload, and
|
|
980
|
+
// `localMetricKeys.test.mjs` holds it to that.
|
|
981
|
+
usageLimitShortPeakPct: {
|
|
982
|
+
family: "local",
|
|
983
|
+
readBy: ["handoff"],
|
|
984
|
+
unit: "percent (0\u2013100), whole number",
|
|
985
|
+
note: "Stays on the machine: an account's allowance, not the work. The largest used_percent of the short (primary) window the session saw. Five hours on every build seen; usageLimitShortWindowMinutes says. Each day slice carries that day's own peak under the same name."
|
|
986
|
+
},
|
|
987
|
+
usageLimitLongPeakPct: {
|
|
988
|
+
family: "local",
|
|
989
|
+
readBy: ["handoff"],
|
|
990
|
+
unit: "percent (0\u2013100), whole number",
|
|
991
|
+
note: "Stays on the machine, as the short window does. The same for the long (secondary) window. Weekly on every build seen."
|
|
992
|
+
},
|
|
993
|
+
usageLimitShortWindowMinutes: {
|
|
994
|
+
family: "local",
|
|
995
|
+
readBy: ["handoff"],
|
|
996
|
+
unit: "minutes",
|
|
997
|
+
note: "Stays on the machine. The short window's size as the rollout reported it, never assumed."
|
|
998
|
+
},
|
|
999
|
+
usageLimitLongWindowMinutes: {
|
|
1000
|
+
family: "local",
|
|
1001
|
+
readBy: ["handoff"],
|
|
1002
|
+
unit: "minutes",
|
|
1003
|
+
note: "Stays on the machine. The long window's size as the rollout reported it."
|
|
1004
|
+
},
|
|
1005
|
+
usageLimitReached: {
|
|
1006
|
+
family: "local",
|
|
1007
|
+
readBy: ["handoff"],
|
|
1008
|
+
unit: "boolean",
|
|
1009
|
+
note: "Stays on the machine. True when a reading carried a non-null rate_limit_reached_type. Present only beside the peaks."
|
|
1010
|
+
},
|
|
1011
|
+
usageLimitReachedType: {
|
|
1012
|
+
family: "local",
|
|
1013
|
+
readBy: ["handoff"],
|
|
1014
|
+
note: "Stays on the machine. Which limit was hit: primary, secondary, or other for any value outside that list."
|
|
1015
|
+
},
|
|
1016
|
+
usageLimitFirstReachedAt: {
|
|
1017
|
+
family: "local",
|
|
1018
|
+
readBy: ["handoff"],
|
|
1019
|
+
unit: "ISO 8601 instant",
|
|
1020
|
+
note: "Stays on the machine. The first reading that carried a reached type."
|
|
1021
|
+
},
|
|
527
1022
|
// ── Read by the local handoff only ──────────────────────────────────────
|
|
528
1023
|
activeMinutes: { family: "session", readBy: ["handoff"], unit: "minutes" },
|
|
529
1024
|
syntheticPromptLines: {
|
|
@@ -532,6 +1027,12 @@ var require_metricKeys = __commonJS({
|
|
|
532
1027
|
unit: "lines",
|
|
533
1028
|
note: "Main-thread user lines the runtime wrote on the person's behalf (notifications, its own bookkeeping, slash-command wrappers, interrupt markers) and promptCount left out. Claude Code only; the receipt for the handoff's promptBasis. Counted per transcript, so a resumed transcript's copies count again."
|
|
534
1029
|
},
|
|
1030
|
+
repeatedLines: {
|
|
1031
|
+
family: "reading",
|
|
1032
|
+
readBy: ["diagnostic"],
|
|
1033
|
+
unit: "lines",
|
|
1034
|
+
note: "Lines read but left out of every count because they repeat one already read: a uuid seen earlier in the same transcript (a resume can write the same lines twice), or, in a forked subagent's transcript, a line its parent's main transcript holds. Claude Code only; shipped when above 0."
|
|
1035
|
+
},
|
|
535
1036
|
dispatchedPromptLines: {
|
|
536
1037
|
family: "reading",
|
|
537
1038
|
readBy: ["handoff"],
|
|
@@ -618,6 +1119,36 @@ var require_metricKeys = __commonJS({
|
|
|
618
1119
|
backendAliases: ["primaryModel", "primary_model"],
|
|
619
1120
|
note: "Read twice: the desktop's local handoff folds it, and a server-side reader resolves it to group a bucket's sessions by the model that served them. Declared handoff-only until 23 Sep 2026 \u2014 see toolName for why that direction of mistake has no symptom."
|
|
620
1121
|
},
|
|
1122
|
+
primaryEffort: {
|
|
1123
|
+
family: "model",
|
|
1124
|
+
readBy: ["handoff"],
|
|
1125
|
+
note: "Claude Code and Codex: the effort level on most of the session's main-thread model turns, as the store wrote it (low, medium, high, xhigh). Absent where the store wrote none, which older Claude Code builds didn't. ship.ts adds effortClass beside it on the way out. The ordered switches ride beside metrics as effortChanges, since a list can't be a metric. The backend reader arrives in its own change."
|
|
1126
|
+
},
|
|
1127
|
+
modelRoute: {
|
|
1128
|
+
family: "model",
|
|
1129
|
+
readBy: ["handoff"],
|
|
1130
|
+
note: "Who served the session's model, one word: direct, bedrock, vertex, azure, gateway, custom_endpoint, local. Codex reads session_meta.model_provider (a provider not built into Codex reads as custom_endpoint, never its name); Claude Code and the other stores read only the slug's own prefix, so a plain slug leaves it off. Never a URL, host or region. ship.ts derives it from primaryModel where the extractor set none. The backend reader arrives in its own change."
|
|
1131
|
+
},
|
|
1132
|
+
modelTurns: {
|
|
1133
|
+
family: "model",
|
|
1134
|
+
readBy: ["handoff"],
|
|
1135
|
+
note: "Claude Code and Codex: the session's model mix as a JSON object in a string, raw slug to count, at most 8 entries, largest first. The counts are the ones primaryModel is chosen from (Claude Code: main-thread API messages plus advisor iterations; Codex: turn_context lines on every thread), so its largest entry is primaryModel unless two models tie. Turns past the cap are in modelTurnsOmitted. See modelTurns.ts."
|
|
1136
|
+
},
|
|
1137
|
+
modelTurnsOmitted: {
|
|
1138
|
+
family: "model",
|
|
1139
|
+
readBy: ["handoff"],
|
|
1140
|
+
note: "Turns on models left out of modelTurns by its cap, or on a slug too long to be a model id. Absent when nothing was left out."
|
|
1141
|
+
},
|
|
1142
|
+
mainThreadToolCallCount: {
|
|
1143
|
+
family: "tools",
|
|
1144
|
+
readBy: ["handoff"],
|
|
1145
|
+
note: "Claude Code and Codex: tool calls the session's own thread issued, subagents excluded. The denominator for mainThreadToolFailureCount. Equal to toolCallCount on Claude Code, which already counts the main thread only; Codex's toolCallCount includes subagent threads."
|
|
1146
|
+
},
|
|
1147
|
+
mainThreadToolFailureCount: {
|
|
1148
|
+
family: "outcome",
|
|
1149
|
+
readBy: ["handoff"],
|
|
1150
|
+
note: "Claude Code and Codex: main-thread tool calls whose result was an error, one per call. Same basis as mainThreadToolCallCount, so the two divide. toolFailureCount keeps its meaning (it adds subagent failures and API errors) and is not a numerator for toolCallCount."
|
|
1151
|
+
},
|
|
621
1152
|
requestCount: { family: "counts", readBy: ["handoff"] },
|
|
622
1153
|
sessionStartedAt: { family: "session", readBy: ["handoff"] },
|
|
623
1154
|
subagentComposers: { family: "counts", readBy: ["handoff"] },
|
|
@@ -685,6 +1216,76 @@ var require_metricKeys = __commonJS({
|
|
|
685
1216
|
subagentAssistantTurns: { family: "counts", readBy: ["diagnostic"] },
|
|
686
1217
|
subagentPrompts: { family: "counts", readBy: ["diagnostic"] },
|
|
687
1218
|
subagentTokensTotal: { family: "context", readBy: ["diagnostic"] },
|
|
1219
|
+
// ── Cost-finding evidence (Claude Code). Counts only: skill, MCP server and
|
|
1220
|
+
// agent names stay on the machine. Each family ships behind its own seen
|
|
1221
|
+
// flag, so an absent key means "not measured", never zero.
|
|
1222
|
+
skillListingSeen: {
|
|
1223
|
+
family: "tools",
|
|
1224
|
+
readBy: ["diagnostic"],
|
|
1225
|
+
note: "Claude Code only: true when the transcript listed the skills in context (a skill_listing attachment). Without it the session ships no skill keys, since a skill can't be called unused off a list nobody saw. The backend reader arrives in its own change."
|
|
1226
|
+
},
|
|
1227
|
+
skillsListed: {
|
|
1228
|
+
family: "tools",
|
|
1229
|
+
readBy: ["diagnostic"],
|
|
1230
|
+
note: "Claude Code only: how many skills were in the session's context at the end, from its skill_listing attachments (an initial listing replaces the set, a later one adds to it). A count; the names aren't read past the fold. Shipped with skillListingSeen. The backend reader arrives in its own change."
|
|
1231
|
+
},
|
|
1232
|
+
skillsInvoked: {
|
|
1233
|
+
family: "tools",
|
|
1234
|
+
readBy: ["diagnostic"],
|
|
1235
|
+
note: "Claude Code only: distinct listed skills the session loaded, from invoked_skills attachments and Skill tool calls, main thread and subagents. Shipped with skillListingSeen. The backend reader arrives in its own change."
|
|
1236
|
+
},
|
|
1237
|
+
mcpListingSeen: {
|
|
1238
|
+
family: "tools",
|
|
1239
|
+
readBy: ["diagnostic"],
|
|
1240
|
+
note: "Claude Code only: true when the transcript recorded which MCP servers were in context (mcp_instructions_delta or deferred_tools_delta). Without it the session ships no MCP keys. The backend reader arrives in its own change."
|
|
1241
|
+
},
|
|
1242
|
+
mcpServersLoaded: {
|
|
1243
|
+
family: "tools",
|
|
1244
|
+
readBy: ["diagnostic"],
|
|
1245
|
+
note: "Claude Code only: distinct MCP servers in context at the end: servers with instructions, servers with deferred tools, and any server whose tool was called. Shipped with mcpListingSeen. The backend reader arrives in its own change."
|
|
1246
|
+
},
|
|
1247
|
+
mcpServersUsed: {
|
|
1248
|
+
family: "tools",
|
|
1249
|
+
readBy: ["diagnostic"],
|
|
1250
|
+
note: "Claude Code only: distinct MCP servers whose tools the session called, main thread and subagents, read from the raw mcp__<server>__<tool> name before toolName truncation. Shipped with mcpListingSeen. The backend reader arrives in its own change."
|
|
1251
|
+
},
|
|
1252
|
+
mcpServersFailed: {
|
|
1253
|
+
family: "tools",
|
|
1254
|
+
readBy: ["diagnostic"],
|
|
1255
|
+
note: "Claude Code only: distinct MCP servers a deferred_tools_delta reported as failed and that never loaded later in the session. Shipped with mcpListingSeen. The backend reader arrives in its own change."
|
|
1256
|
+
},
|
|
1257
|
+
speedSeen: {
|
|
1258
|
+
family: "model",
|
|
1259
|
+
readBy: ["diagnostic"],
|
|
1260
|
+
note: "Claude Code only: true once any owned assistant line carried usage.speed. Without it fastTurns and subagentFastTurns are absent, because the build didn't record the field. The backend reader arrives in its own change."
|
|
1261
|
+
},
|
|
1262
|
+
fastTurns: {
|
|
1263
|
+
family: "model",
|
|
1264
|
+
readBy: ["diagnostic"],
|
|
1265
|
+
note: "Claude Code only: main-thread API messages (one per message, however many lines it spans) whose usage.speed was fast. Shipped with speedSeen. The backend reader arrives in its own change."
|
|
1266
|
+
},
|
|
1267
|
+
subagentFastTurns: {
|
|
1268
|
+
family: "subagents",
|
|
1269
|
+
readBy: ["diagnostic"],
|
|
1270
|
+
note: "Claude Code only: subagent API messages whose usage.speed was fast, counted like fastTurns. Shipped with speedSeen. The backend reader arrives in its own change."
|
|
1271
|
+
},
|
|
1272
|
+
deepTurns200k: {
|
|
1273
|
+
family: "context",
|
|
1274
|
+
readBy: ["diagnostic"],
|
|
1275
|
+
unit: "messages",
|
|
1276
|
+
note: "Claude Code only: main-thread API messages whose context (input + cache read + cache write tokens) was above 200,000. A fixed cut point, so sessions compare without the raw series. The backend reader arrives in its own change."
|
|
1277
|
+
},
|
|
1278
|
+
deepTurns400k: {
|
|
1279
|
+
family: "context",
|
|
1280
|
+
readBy: ["diagnostic"],
|
|
1281
|
+
unit: "messages",
|
|
1282
|
+
note: "Claude Code only: the same count above 400,000 tokens. The backend reader arrives in its own change."
|
|
1283
|
+
},
|
|
1284
|
+
premiumSubagents: {
|
|
1285
|
+
family: "subagents",
|
|
1286
|
+
readBy: ["diagnostic"],
|
|
1287
|
+
note: "Claude Code only: subagents whose receipt modelClass is in PREMIUM_MODEL_CLASSES (tool-kit: anthropic:opus, anthropic:fable). 0 for a session with no subagents. The backend reader arrives in its own change."
|
|
1288
|
+
},
|
|
688
1289
|
advisorMessageCount: {
|
|
689
1290
|
family: "counts",
|
|
690
1291
|
readBy: ["diagnostic"],
|
|
@@ -696,6 +1297,8 @@ var require_metricKeys = __commonJS({
|
|
|
696
1297
|
unit: "tokens",
|
|
697
1298
|
note: "Claude Code only: input, output and cache tokens spent by advisor calls. A part of the session totals, not an addition to them."
|
|
698
1299
|
},
|
|
1300
|
+
/** Input tokens written to the prompt cache. Not part of `inputTokens`.
|
|
1301
|
+
* Absent, never 0, where the store doesn't record the figure. */
|
|
699
1302
|
cacheCreationTokens: {
|
|
700
1303
|
family: "context",
|
|
701
1304
|
readBy: ["diagnostic"],
|
|
@@ -749,7 +1352,7 @@ var require_metricKeys = __commonJS({
|
|
|
749
1352
|
clientName: {
|
|
750
1353
|
family: "session",
|
|
751
1354
|
readBy: ["diagnostic"],
|
|
752
|
-
note: "Copilot CLI
|
|
1355
|
+
note: "Copilot CLI: workspace.yaml's client_name, one constant word naming what started the CLI (vscode, vscode-agent-host); absent on sessions written before the field existed, which were the standalone CLI. Claude Code: claude-desktop-cowork on sessions read from Claude Desktop's Cowork config dirs, absent on the rest."
|
|
753
1356
|
},
|
|
754
1357
|
totalApiDurationMs: {
|
|
755
1358
|
family: "session",
|
|
@@ -807,7 +1410,12 @@ var require_metricKeys = __commonJS({
|
|
|
807
1410
|
unparsedBubbles: { family: "reading", readBy: ["diagnostic"] },
|
|
808
1411
|
unparsedChatSessionFiles: { family: "reading", readBy: ["diagnostic"] },
|
|
809
1412
|
unparsedHistoryFiles: { family: "reading", readBy: ["diagnostic"] },
|
|
810
|
-
|
|
1413
|
+
duplicateRolloutFiles: {
|
|
1414
|
+
family: "reading",
|
|
1415
|
+
readBy: ["diagnostic"],
|
|
1416
|
+
note: "Codex only: rollout files skipped because the same rollout sat under both sessions/ and archived_sessions/. One copy is read; the other would have counted its prompts and tool calls twice."
|
|
1417
|
+
},
|
|
1418
|
+
unparsedLines: { family: "reading", readBy: ["diagnostic"] },
|
|
811
1419
|
unreadableChatSessionFiles: { family: "reading", readBy: ["diagnostic"] },
|
|
812
1420
|
unreadableHistoryFiles: { family: "reading", readBy: ["diagnostic"] },
|
|
813
1421
|
unreadableRolloutFiles: {
|
|
@@ -817,6 +1425,9 @@ var require_metricKeys = __commonJS({
|
|
|
817
1425
|
},
|
|
818
1426
|
unrecognisedChatSessionFiles: { family: "reading", readBy: ["diagnostic"] }
|
|
819
1427
|
};
|
|
1428
|
+
function localMetricKeys() {
|
|
1429
|
+
return new Set(Object.entries(exports.METRIC_KEYS).filter(([, spec]) => spec.family === "local").map(([key]) => key));
|
|
1430
|
+
}
|
|
820
1431
|
function backendMetricKeys() {
|
|
821
1432
|
return Object.entries(exports.METRIC_KEYS).filter(([, spec]) => spec.readBy.includes("backend")).map(([key, spec]) => [key, spec.backendAliases ?? [key]]);
|
|
822
1433
|
}
|
|
@@ -828,7 +1439,7 @@ var require_out = __commonJS({
|
|
|
828
1439
|
"../packages/tool-contract/out/index.js"(exports) {
|
|
829
1440
|
"use strict";
|
|
830
1441
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
831
|
-
exports.backendMetricKeys = exports.METRIC_KEYS = exports.ASCENDA_SEMANTIC_PROVENANCE = exports.ASCENDA_HISTORICAL_CONSENT_SCOPE = exports.ASCENDA_COLLABORATION_CONSENT_SCOPE = exports.ASCENDA_SEMANTIC_CONSENT_SCOPE = exports.ASCENDA_PROVENANCE = exports.ASCENDA_CONSENT_SCOPE = exports.EVENT_WORKLOAD_CATEGORY = exports.TOOL_EVENT_DELIVERED_STATUSES = exports.IDEMPOTENCY_KEY_MAX_LENGTH = exports.DELIVERY_ENVELOPE_KEYS = exports.EVENT_METADATA_FIELDS = exports.EVENT_METADATA_DISCLOSURE = exports.COLLABORATION_EVENT_TYPES = exports.SEMANTIC_WORK_SIGNAL_EVENT_TYPES = exports.ASCENDA_ELAPSED_QUANTITIES = exports.ASCENDA_ACTIVE_TIME_QUANTITIES = exports.ASCENDA_TOOL_TYPES = exports.ASCENDA_TELEMETRY_SOURCES = void 0;
|
|
1442
|
+
exports.localMetricKeys = exports.backendMetricKeys = exports.METRIC_KEYS = exports.ASCENDA_SEMANTIC_PROVENANCE = exports.ASCENDA_HISTORICAL_CONSENT_SCOPE = exports.ASCENDA_COLLABORATION_CONSENT_SCOPE = exports.ASCENDA_SEMANTIC_CONSENT_SCOPE = exports.ASCENDA_PROVENANCE = exports.ASCENDA_CONSENT_SCOPE = exports.EVENT_WORKLOAD_CATEGORY = exports.TOOL_EVENT_DELIVERED_STATUSES = exports.IDEMPOTENCY_KEY_MAX_LENGTH = exports.DELIVERY_ENVELOPE_KEYS = exports.EVENT_METADATA_FIELDS = exports.EVENT_METADATA_DISCLOSURE = exports.COLLABORATION_EVENT_TYPES = exports.SEMANTIC_WORK_SIGNAL_EVENT_TYPES = exports.ASCENDA_ELAPSED_QUANTITIES = exports.ASCENDA_ACTIVE_TIME_QUANTITIES = exports.ASCENDA_TOOL_TYPES = exports.ASCENDA_TELEMETRY_SOURCES = void 0;
|
|
832
1443
|
exports.combineDisjointHalves = combineDisjointHalves;
|
|
833
1444
|
exports.requireComparableQuantities = requireComparableQuantities;
|
|
834
1445
|
exports.joinEventPayload = joinEventPayload;
|
|
@@ -920,10 +1531,19 @@ var require_out = __commonJS({
|
|
|
920
1531
|
autonomyMode: "posture",
|
|
921
1532
|
modelClass: "model",
|
|
922
1533
|
modelId: "model",
|
|
1534
|
+
// The effort setting is a model setting, so it shares the model family:
|
|
1535
|
+
// the same consent covers it, and the pairing sentence names it.
|
|
1536
|
+
effortLevel: "model",
|
|
1537
|
+
effortClass: "model",
|
|
1538
|
+
// Who served the model, one word from a closed list. Never a host.
|
|
1539
|
+
modelRoute: "model",
|
|
923
1540
|
userModified: "edits",
|
|
924
1541
|
outcome: "outcome",
|
|
925
1542
|
trigger: "outcome",
|
|
926
1543
|
promptClass: "counts",
|
|
1544
|
+
// One letter for how long the prompt was, worked out on this machine.
|
|
1545
|
+
// Never the text or its length.
|
|
1546
|
+
promptSizeBucket: "counts",
|
|
927
1547
|
reason: "outcome",
|
|
928
1548
|
afterHours: "clock",
|
|
929
1549
|
activity: "counts",
|
|
@@ -952,6 +1572,9 @@ var require_out = __commonJS({
|
|
|
952
1572
|
importKey: "transport",
|
|
953
1573
|
extractionId: "transport",
|
|
954
1574
|
importSchema: "transport",
|
|
1575
|
+
// A whole number naming which rung of a store's extractor produced the row.
|
|
1576
|
+
// Says nothing about the work itself.
|
|
1577
|
+
extractorRevision: "transport",
|
|
955
1578
|
// The version of the Ascenda collector that sent this event. Names the
|
|
956
1579
|
// build, and nothing about the work it observed.
|
|
957
1580
|
collectorVersion: "transport",
|
|
@@ -979,10 +1602,14 @@ var require_out = __commonJS({
|
|
|
979
1602
|
"autonomyMode",
|
|
980
1603
|
"modelClass",
|
|
981
1604
|
"modelId",
|
|
1605
|
+
"effortLevel",
|
|
1606
|
+
"effortClass",
|
|
1607
|
+
"modelRoute",
|
|
982
1608
|
"userModified",
|
|
983
1609
|
"outcome",
|
|
984
1610
|
"trigger",
|
|
985
1611
|
"promptClass",
|
|
1612
|
+
"promptSizeBucket",
|
|
986
1613
|
"reason",
|
|
987
1614
|
"afterHours",
|
|
988
1615
|
"activity",
|
|
@@ -1001,6 +1628,7 @@ var require_out = __commonJS({
|
|
|
1001
1628
|
"importKey",
|
|
1002
1629
|
"extractionId",
|
|
1003
1630
|
"importSchema",
|
|
1631
|
+
"extractorRevision",
|
|
1004
1632
|
"collectorVersion",
|
|
1005
1633
|
"collectorPlatform"
|
|
1006
1634
|
];
|
|
@@ -1111,6 +1739,9 @@ var require_out = __commonJS({
|
|
|
1111
1739
|
Object.defineProperty(exports, "backendMetricKeys", { enumerable: true, get: function() {
|
|
1112
1740
|
return metricKeys_1.backendMetricKeys;
|
|
1113
1741
|
} });
|
|
1742
|
+
Object.defineProperty(exports, "localMetricKeys", { enumerable: true, get: function() {
|
|
1743
|
+
return metricKeys_1.localMetricKeys;
|
|
1744
|
+
} });
|
|
1114
1745
|
}
|
|
1115
1746
|
});
|
|
1116
1747
|
|
|
@@ -1287,151 +1918,13 @@ var require_collectorVersion = __commonJS({
|
|
|
1287
1918
|
exports.COLLECTOR_VERSION = exports.UNRELEASED_COLLECTOR_VERSION = void 0;
|
|
1288
1919
|
exports.describeCollectorVersion = describeCollectorVersion;
|
|
1289
1920
|
exports.UNRELEASED_COLLECTOR_VERSION = "unreleased";
|
|
1290
|
-
exports.COLLECTOR_VERSION = "0.1.
|
|
1921
|
+
exports.COLLECTOR_VERSION = "0.1.43" ? "0.1.43" : exports.UNRELEASED_COLLECTOR_VERSION;
|
|
1291
1922
|
function describeCollectorVersion(version = exports.COLLECTOR_VERSION) {
|
|
1292
1923
|
return version === exports.UNRELEASED_COLLECTOR_VERSION ? `${version} (built from a checkout, not a release)` : version;
|
|
1293
1924
|
}
|
|
1294
1925
|
}
|
|
1295
1926
|
});
|
|
1296
1927
|
|
|
1297
|
-
// ../packages/tool-kit/out/tokenStore.js
|
|
1298
|
-
var require_tokenStore = __commonJS({
|
|
1299
|
-
"../packages/tool-kit/out/tokenStore.js"(exports) {
|
|
1300
|
-
"use strict";
|
|
1301
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
1302
|
-
if (k2 === void 0) k2 = k;
|
|
1303
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1304
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1305
|
-
desc = { enumerable: true, get: function() {
|
|
1306
|
-
return m[k];
|
|
1307
|
-
} };
|
|
1308
|
-
}
|
|
1309
|
-
Object.defineProperty(o, k2, desc);
|
|
1310
|
-
} : function(o, m, k, k2) {
|
|
1311
|
-
if (k2 === void 0) k2 = k;
|
|
1312
|
-
o[k2] = m[k];
|
|
1313
|
-
});
|
|
1314
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
1315
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1316
|
-
} : function(o, v) {
|
|
1317
|
-
o["default"] = v;
|
|
1318
|
-
});
|
|
1319
|
-
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
1320
|
-
var ownKeys = function(o) {
|
|
1321
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
1322
|
-
var ar = [];
|
|
1323
|
-
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
1324
|
-
return ar;
|
|
1325
|
-
};
|
|
1326
|
-
return ownKeys(o);
|
|
1327
|
-
};
|
|
1328
|
-
return function(mod) {
|
|
1329
|
-
if (mod && mod.__esModule) return mod;
|
|
1330
|
-
var result = {};
|
|
1331
|
-
if (mod != null) {
|
|
1332
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
1333
|
-
}
|
|
1334
|
-
__setModuleDefault(result, mod);
|
|
1335
|
-
return result;
|
|
1336
|
-
};
|
|
1337
|
-
}();
|
|
1338
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1339
|
-
exports.EVENT_TOKEN_TTL_MS = void 0;
|
|
1340
|
-
exports.ascendaHome = ascendaHome;
|
|
1341
|
-
exports.defaultTokenFilePath = defaultTokenFilePath2;
|
|
1342
|
-
exports.tokenExpiryFilePath = tokenExpiryFilePath;
|
|
1343
|
-
exports.persistEventWriteToken = persistEventWriteToken2;
|
|
1344
|
-
exports.readTokenExpiry = readTokenExpiry;
|
|
1345
|
-
exports.listPersistedToolInstallationIds = listPersistedToolInstallationIds;
|
|
1346
|
-
exports.readTokenFile = readTokenFile2;
|
|
1347
|
-
exports.sanitizeFilePart = sanitizeFilePart;
|
|
1348
|
-
var fs = __importStar(__require("fs"));
|
|
1349
|
-
var os = __importStar(__require("os"));
|
|
1350
|
-
var path = __importStar(__require("path"));
|
|
1351
|
-
function ascendaHome(home = os.homedir()) {
|
|
1352
|
-
return process.env.ASCENDA_HOME ?? path.join(home, ".ascenda");
|
|
1353
|
-
}
|
|
1354
|
-
function defaultTokenFilePath2(toolInstallationId) {
|
|
1355
|
-
return path.join(ascendaHome(), "tokens", sanitizeFilePart(toolInstallationId));
|
|
1356
|
-
}
|
|
1357
|
-
function tokenExpiryFilePath(tokenFilePath) {
|
|
1358
|
-
return path.join(path.dirname(tokenFilePath), "expiry", path.basename(tokenFilePath));
|
|
1359
|
-
}
|
|
1360
|
-
function persistEventWriteToken2(tokenFilePath, token, expiresAt) {
|
|
1361
|
-
const dir = path.dirname(tokenFilePath);
|
|
1362
|
-
fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
1363
|
-
fs.writeFileSync(tokenFilePath, token, { encoding: "utf8", mode: 384 });
|
|
1364
|
-
if (process.platform !== "win32") {
|
|
1365
|
-
fs.chmodSync(dir, 448);
|
|
1366
|
-
fs.chmodSync(tokenFilePath, 384);
|
|
1367
|
-
}
|
|
1368
|
-
const expiryFile = tokenExpiryFilePath(tokenFilePath);
|
|
1369
|
-
try {
|
|
1370
|
-
if (expiresAt && Number.isFinite(Date.parse(expiresAt))) {
|
|
1371
|
-
fs.mkdirSync(path.dirname(expiryFile), { recursive: true, mode: 448 });
|
|
1372
|
-
fs.writeFileSync(expiryFile, expiresAt, { encoding: "utf8", mode: 384 });
|
|
1373
|
-
} else {
|
|
1374
|
-
fs.rmSync(expiryFile, { force: true });
|
|
1375
|
-
}
|
|
1376
|
-
} catch {
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
exports.EVENT_TOKEN_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
1380
|
-
function readTokenExpiry(tokenFilePath) {
|
|
1381
|
-
try {
|
|
1382
|
-
const recorded = Date.parse(fs.readFileSync(tokenExpiryFilePath(tokenFilePath), "utf8").trim());
|
|
1383
|
-
if (Number.isFinite(recorded))
|
|
1384
|
-
return recorded;
|
|
1385
|
-
} catch {
|
|
1386
|
-
}
|
|
1387
|
-
try {
|
|
1388
|
-
return fs.statSync(tokenFilePath).mtimeMs + exports.EVENT_TOKEN_TTL_MS;
|
|
1389
|
-
} catch {
|
|
1390
|
-
return void 0;
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
function listPersistedToolInstallationIds(toolType) {
|
|
1394
|
-
const prefix = `${sanitizeFilePart(toolType)}_`;
|
|
1395
|
-
const dir = path.join(ascendaHome(), "tokens");
|
|
1396
|
-
let names;
|
|
1397
|
-
try {
|
|
1398
|
-
names = fs.readdirSync(dir);
|
|
1399
|
-
} catch {
|
|
1400
|
-
return [];
|
|
1401
|
-
}
|
|
1402
|
-
const ids = [];
|
|
1403
|
-
for (const name of names.sort()) {
|
|
1404
|
-
if (!name.startsWith(prefix) || name.length === prefix.length)
|
|
1405
|
-
continue;
|
|
1406
|
-
const file = path.join(dir, name);
|
|
1407
|
-
try {
|
|
1408
|
-
if (!fs.statSync(file).isFile())
|
|
1409
|
-
continue;
|
|
1410
|
-
} catch {
|
|
1411
|
-
continue;
|
|
1412
|
-
}
|
|
1413
|
-
if (readTokenFile2(file) === void 0)
|
|
1414
|
-
continue;
|
|
1415
|
-
ids.push(`${toolType}:${name.slice(prefix.length)}`);
|
|
1416
|
-
}
|
|
1417
|
-
return ids;
|
|
1418
|
-
}
|
|
1419
|
-
function readTokenFile2(tokenFilePath) {
|
|
1420
|
-
try {
|
|
1421
|
-
if (!fs.existsSync(tokenFilePath))
|
|
1422
|
-
return void 0;
|
|
1423
|
-
const value = fs.readFileSync(tokenFilePath, "utf8").trim();
|
|
1424
|
-
return value || void 0;
|
|
1425
|
-
} catch {
|
|
1426
|
-
return void 0;
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
function sanitizeFilePart(value) {
|
|
1430
|
-
return value.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
});
|
|
1434
|
-
|
|
1435
1928
|
// ../packages/tool-kit/out/stateStore.js
|
|
1436
1929
|
var require_stateStore = __commonJS({
|
|
1437
1930
|
"../packages/tool-kit/out/stateStore.js"(exports) {
|
|
@@ -1811,9 +2304,9 @@ var require_outbox = __commonJS({
|
|
|
1811
2304
|
}
|
|
1812
2305
|
});
|
|
1813
2306
|
|
|
1814
|
-
// ../packages/tool-kit/out/
|
|
1815
|
-
var
|
|
1816
|
-
"../packages/tool-kit/out/
|
|
2307
|
+
// ../packages/tool-kit/out/hookRunner.js
|
|
2308
|
+
var require_hookRunner = __commonJS({
|
|
2309
|
+
"../packages/tool-kit/out/hookRunner.js"(exports) {
|
|
1817
2310
|
"use strict";
|
|
1818
2311
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
1819
2312
|
if (k2 === void 0) k2 = k;
|
|
@@ -1853,94 +2346,615 @@ var require_backgroundDelivery = __commonJS({
|
|
|
1853
2346
|
};
|
|
1854
2347
|
}();
|
|
1855
2348
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1856
|
-
exports.
|
|
1857
|
-
exports.
|
|
1858
|
-
exports.
|
|
1859
|
-
exports.
|
|
1860
|
-
exports.
|
|
1861
|
-
|
|
2349
|
+
exports.hookRunnerPaths = hookRunnerPaths;
|
|
2350
|
+
exports.hookLauncherScript = hookLauncherScript;
|
|
2351
|
+
exports.isDowngrade = isDowngrade;
|
|
2352
|
+
exports.installHookRunner = installHookRunner;
|
|
2353
|
+
exports.removeHookRunner = removeHookRunner;
|
|
2354
|
+
exports.hookRunnerCommand = hookRunnerCommand;
|
|
2355
|
+
exports.writeAtomically = writeAtomically;
|
|
2356
|
+
exports.lastHookPath = lastHookPath;
|
|
2357
|
+
exports.stampLastHook = stampLastHook;
|
|
2358
|
+
exports.readLastHook = readLastHook;
|
|
2359
|
+
exports.describeAge = describeAge;
|
|
2360
|
+
exports.resolveHookNode = resolveHookNode;
|
|
2361
|
+
exports.tidyHomePath = tidyHomePath;
|
|
1862
2362
|
var child_process_1 = __require("child_process");
|
|
1863
|
-
var
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
return env[exports.HOOK_DELIVERY_ENV_VAR]?.trim().toLowerCase() === "inline" || !(0, outbox_1.outboxDrainEnabled)(env);
|
|
1871
|
-
}
|
|
1872
|
-
function flushLockPath(outboxFilePath) {
|
|
1873
|
-
return `${outboxFilePath}.flushing`;
|
|
1874
|
-
}
|
|
1875
|
-
function lockIsFresh(lockPath, now) {
|
|
1876
|
-
try {
|
|
1877
|
-
return now - fs.statSync(lockPath).mtimeMs < exports.FLUSH_LOCK_FRESH_MS;
|
|
1878
|
-
} catch {
|
|
1879
|
-
return false;
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
function touchLock(lockPath) {
|
|
1883
|
-
try {
|
|
1884
|
-
fs.writeFileSync(lockPath, `${process.pid}
|
|
1885
|
-
`, { encoding: "utf8", mode: 384 });
|
|
1886
|
-
} catch {
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
function removeLock(lockPath) {
|
|
1890
|
-
try {
|
|
1891
|
-
fs.unlinkSync(lockPath);
|
|
1892
|
-
} catch {
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
|
-
function outboxHasEntries(outboxFilePath) {
|
|
1896
|
-
try {
|
|
1897
|
-
return fs.statSync(outboxFilePath).size > 0;
|
|
1898
|
-
} catch {
|
|
1899
|
-
return false;
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
function startBackgroundFlush(options) {
|
|
1903
|
-
const lockPath = flushLockPath(options.outboxFilePath);
|
|
1904
|
-
const now = options.now ?? Date.now();
|
|
1905
|
-
if (lockIsFresh(lockPath, now))
|
|
1906
|
-
return false;
|
|
1907
|
-
const script = options.script ?? process.argv[1];
|
|
1908
|
-
if (!script)
|
|
1909
|
-
return false;
|
|
1910
|
-
try {
|
|
1911
|
-
touchLock(lockPath);
|
|
1912
|
-
const child = (0, child_process_1.spawn)(process.execPath, [script, exports.OUTBOX_FLUSH_COMMAND], {
|
|
1913
|
-
detached: true,
|
|
1914
|
-
stdio: "ignore",
|
|
1915
|
-
windowsHide: true,
|
|
1916
|
-
env: process.env
|
|
1917
|
-
});
|
|
1918
|
-
child.on("error", () => removeLock(lockPath));
|
|
1919
|
-
child.unref();
|
|
1920
|
-
return true;
|
|
1921
|
-
} catch {
|
|
1922
|
-
removeLock(lockPath);
|
|
1923
|
-
return false;
|
|
1924
|
-
}
|
|
2363
|
+
var fs = __importStar(__require("fs"));
|
|
2364
|
+
var path = __importStar(__require("path"));
|
|
2365
|
+
var collectorVersion_1 = require_collectorVersion();
|
|
2366
|
+
var tokenStore_1 = require_tokenStore();
|
|
2367
|
+
function hookRunnerPaths(binaryName) {
|
|
2368
|
+
const launcher = path.join((0, tokenStore_1.ascendaHome)(), "bin", binaryName);
|
|
2369
|
+
return { launcher, bundle: `${launcher}.mjs`, record: `${launcher}.node`, noNode: `${launcher}.no-node`, version: `${launcher}.version` };
|
|
1925
2370
|
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
const
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
2371
|
+
var LAUNCHER_MANAGEMENT_COMMANDS = ["setup", "install", "status", "uninstall", "doctor", "pair", "join", "object", "-h", "--help"];
|
|
2372
|
+
function hookLauncherScript(options) {
|
|
2373
|
+
const { binaryName, setupCommand, loudEvent } = options;
|
|
2374
|
+
return [
|
|
2375
|
+
"#!/bin/sh",
|
|
2376
|
+
`# Ascenda hook launcher (${binaryName}). Written by \`setup\`, replaced by the`,
|
|
2377
|
+
"# next one; edits here are lost. Finds a Node to run the hook bundle beside it.",
|
|
2378
|
+
"",
|
|
2379
|
+
'dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) || exit 0',
|
|
2380
|
+
`bundle="$dir/${binaryName}.mjs"`,
|
|
2381
|
+
`record="$dir/${binaryName}.node"`,
|
|
2382
|
+
`missing="$dir/${binaryName}.no-node"`,
|
|
2383
|
+
"",
|
|
2384
|
+
'runs() { [ -n "$1" ] && [ -f "$1" ] && [ -x "$1" ]; }',
|
|
2385
|
+
"",
|
|
2386
|
+
"# The hook bundle needs Node 20 or newer. Checked only while searching, so",
|
|
2387
|
+
"# the recorded path costs nothing to reuse.",
|
|
2388
|
+
"recent() {",
|
|
2389
|
+
` runs "$1" && "$1" -e 'process.exit(parseInt(process.versions.node, 10) >= 20 ? 0 : 1)' >/dev/null 2>&1`,
|
|
2390
|
+
"}",
|
|
2391
|
+
"",
|
|
2392
|
+
"newest_nvm() {",
|
|
2393
|
+
' [ -d "$HOME/.nvm/versions/node" ] || return 0',
|
|
2394
|
+
` ls "$HOME/.nvm/versions/node" 2>/dev/null | sed 's/^v//' | sort -t. -k1,1n -k2,2n -k3,3n | tail -n 1 | sed 's/^/v/'`,
|
|
2395
|
+
"}",
|
|
2396
|
+
"",
|
|
2397
|
+
'node=""',
|
|
2398
|
+
"how=recorded",
|
|
2399
|
+
'[ -r "$record" ] && IFS= read -r node < "$record"',
|
|
2400
|
+
"",
|
|
2401
|
+
'if ! runs "$node"; then',
|
|
2402
|
+
' node=""',
|
|
2403
|
+
" how=found",
|
|
2404
|
+
' nvm_default=""',
|
|
2405
|
+
' if [ -r "$HOME/.nvm/alias/default" ]; then',
|
|
2406
|
+
' IFS= read -r wanted < "$HOME/.nvm/alias/default"',
|
|
2407
|
+
" wanted=${wanted#v}",
|
|
2408
|
+
' for candidate in "$HOME/.nvm/versions/node/v$wanted"*; do',
|
|
2409
|
+
' [ -x "$candidate/bin/node" ] && nvm_default="$candidate/bin/node"',
|
|
2410
|
+
" done",
|
|
2411
|
+
" fi",
|
|
2412
|
+
" nvm_newest=$(newest_nvm)",
|
|
2413
|
+
" for candidate in \\",
|
|
2414
|
+
' "$(command -v node 2>/dev/null)" \\',
|
|
2415
|
+
" /opt/homebrew/bin/node \\",
|
|
2416
|
+
" /usr/local/bin/node \\",
|
|
2417
|
+
' "$HOME/.volta/bin/node" \\',
|
|
2418
|
+
' "$nvm_default" \\',
|
|
2419
|
+
' "$HOME/.local/share/fnm/aliases/default/bin/node" \\',
|
|
2420
|
+
' "$HOME/Library/Application Support/fnm/aliases/default/bin/node" \\',
|
|
2421
|
+
' "$HOME/.asdf/shims/node" \\',
|
|
2422
|
+
' "$HOME/.local/share/mise/shims/node" \\',
|
|
2423
|
+
' "$HOME/.nvm/versions/node/$nvm_newest/bin/node"',
|
|
2424
|
+
" do",
|
|
2425
|
+
' if recent "$candidate"; then node=$candidate; break; fi',
|
|
2426
|
+
" done",
|
|
2427
|
+
' if [ -n "$node" ]; then',
|
|
2428
|
+
` printf '%s\\n' "$node" > "$record.$$" 2>/dev/null && mv -f "$record.$$" "$record" 2>/dev/null`,
|
|
2429
|
+
' rm -f "$missing" 2>/dev/null',
|
|
2430
|
+
" fi",
|
|
2431
|
+
"fi",
|
|
2432
|
+
"",
|
|
2433
|
+
'if [ -n "$ASCENDA_HOOK_LAUNCHER_PROBE" ]; then',
|
|
2434
|
+
' [ -n "$node" ] || { echo "no Node 20 or newer found on PATH or in the usual install locations" >&2; exit 1; }',
|
|
2435
|
+
` printf '%s\\t%s\\n' "$node" "$how"`,
|
|
2436
|
+
" exit 0",
|
|
2437
|
+
"fi",
|
|
2438
|
+
"",
|
|
2439
|
+
'if [ -z "$node" ]; then',
|
|
2440
|
+
' date -u +%Y-%m-%dT%H:%M:%SZ > "$missing" 2>/dev/null',
|
|
2441
|
+
' case "$1" in',
|
|
2442
|
+
...loudEvent ? [
|
|
2443
|
+
` ${loudEvent})`,
|
|
2444
|
+
" cat >/dev/null 2>&1",
|
|
2445
|
+
` echo "Ascenda hooks cannot find Node 20 or newer, so none of them are running. Install Node, then run: ${setupCommand}" >&2`,
|
|
2446
|
+
" exit 1 ;;"
|
|
2447
|
+
] : [],
|
|
2448
|
+
` ${LAUNCHER_MANAGEMENT_COMMANDS.join("|")})`,
|
|
2449
|
+
` echo "${binaryName}: no Node 20 or newer found on PATH or in the usual install locations." >&2`,
|
|
2450
|
+
" exit 1 ;;",
|
|
2451
|
+
" *)",
|
|
2452
|
+
" # A hook: say nothing per tool call. status and doctor read the",
|
|
2453
|
+
" # file written above.",
|
|
2454
|
+
" cat >/dev/null 2>&1",
|
|
2455
|
+
" exit 0 ;;",
|
|
2456
|
+
" esac",
|
|
2457
|
+
"fi",
|
|
2458
|
+
"",
|
|
2459
|
+
'exec "$node" "$bundle" "$@"',
|
|
2460
|
+
""
|
|
2461
|
+
].join("\n");
|
|
2462
|
+
}
|
|
2463
|
+
function releaseOf(version) {
|
|
2464
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec((version ?? "").trim());
|
|
2465
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : void 0;
|
|
2466
|
+
}
|
|
2467
|
+
function isDowngrade(installed, incoming) {
|
|
2468
|
+
const have = releaseOf(installed);
|
|
2469
|
+
const want = releaseOf(incoming);
|
|
2470
|
+
if (!have || !want)
|
|
2471
|
+
return false;
|
|
2472
|
+
for (let i = 0; i < 3; i++) {
|
|
2473
|
+
if (have[i] !== want[i])
|
|
2474
|
+
return have[i] > want[i];
|
|
2475
|
+
}
|
|
2476
|
+
return false;
|
|
2477
|
+
}
|
|
2478
|
+
function readInstalledVersion(file) {
|
|
2479
|
+
try {
|
|
2480
|
+
return fs.readFileSync(file, "utf8").trim() || void 0;
|
|
2481
|
+
} catch {
|
|
2482
|
+
return void 0;
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
function installHookRunner(options) {
|
|
2486
|
+
const paths = hookRunnerPaths(options.binaryName);
|
|
2487
|
+
if (options.dryRun)
|
|
2488
|
+
return paths.launcher;
|
|
2489
|
+
const source = path.resolve(options.source ?? process.argv[1]);
|
|
2490
|
+
const incoming = options.version ?? collectorVersion_1.COLLECTOR_VERSION;
|
|
2491
|
+
const installed = readInstalledVersion(paths.version);
|
|
2492
|
+
const installedFile = process.platform === "win32" ? paths.launcher : paths.bundle;
|
|
2493
|
+
if (installed && fs.existsSync(installedFile) && isDowngrade(installed, incoming)) {
|
|
2494
|
+
options.onKeptNewer?.(installed, incoming);
|
|
2495
|
+
if (process.platform !== "win32" && !fs.existsSync(paths.launcher))
|
|
2496
|
+
writeAtomically(paths.launcher, hookLauncherScript(options), 493);
|
|
2497
|
+
return paths.launcher;
|
|
2498
|
+
}
|
|
2499
|
+
fs.mkdirSync(path.dirname(paths.launcher), { recursive: true });
|
|
2500
|
+
if (process.platform === "win32") {
|
|
2501
|
+
if (source !== path.resolve(paths.launcher))
|
|
2502
|
+
fs.copyFileSync(source, paths.launcher);
|
|
2503
|
+
writeAtomically(paths.version, `${incoming}
|
|
2504
|
+
`, 420);
|
|
2505
|
+
return paths.launcher;
|
|
2506
|
+
}
|
|
2507
|
+
if (source !== path.resolve(paths.bundle))
|
|
2508
|
+
writeAtomically(paths.bundle, fs.readFileSync(source), 493);
|
|
2509
|
+
writeAtomically(paths.launcher, hookLauncherScript(options), 493);
|
|
2510
|
+
writeAtomically(paths.record, `${process.execPath}
|
|
2511
|
+
`, 420);
|
|
2512
|
+
if (source !== path.resolve(paths.bundle))
|
|
2513
|
+
writeAtomically(paths.version, `${incoming}
|
|
2514
|
+
`, 420);
|
|
2515
|
+
fs.rmSync(paths.noNode, { force: true });
|
|
2516
|
+
return paths.launcher;
|
|
2517
|
+
}
|
|
2518
|
+
function removeHookRunner(binaryName) {
|
|
2519
|
+
const removed = [];
|
|
2520
|
+
for (const file of Object.values(hookRunnerPaths(binaryName))) {
|
|
2521
|
+
if (!fs.existsSync(file))
|
|
2522
|
+
continue;
|
|
2523
|
+
fs.rmSync(file, { force: true });
|
|
2524
|
+
removed.push(file);
|
|
2525
|
+
}
|
|
2526
|
+
return removed;
|
|
2527
|
+
}
|
|
2528
|
+
function hookRunnerCommand(launcher, platform = process.platform) {
|
|
2529
|
+
return platform === "win32" ? `"${process.execPath}" "${launcher}"` : `"${launcher}"`;
|
|
2530
|
+
}
|
|
2531
|
+
function writeAtomically(target, contents, mode) {
|
|
2532
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
2533
|
+
fs.writeFileSync(tmp, contents, { mode });
|
|
2534
|
+
fs.chmodSync(tmp, mode);
|
|
2535
|
+
fs.renameSync(tmp, target);
|
|
2536
|
+
}
|
|
2537
|
+
var stateDir = () => process.env.ASCENDA_STATE_DIR ?? path.join((0, tokenStore_1.ascendaHome)(), "state");
|
|
2538
|
+
function lastHookPath(tool) {
|
|
2539
|
+
return path.join(stateDir(), `${tool}-last-hook.json`);
|
|
2540
|
+
}
|
|
2541
|
+
function stampLastHook(tool, event, now = /* @__PURE__ */ new Date()) {
|
|
2542
|
+
try {
|
|
2543
|
+
fs.mkdirSync(stateDir(), { recursive: true });
|
|
2544
|
+
const file = lastHookPath(tool);
|
|
2545
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
2546
|
+
fs.writeFileSync(tmp, `${JSON.stringify({ event, at: now.toISOString() })}
|
|
2547
|
+
`, { mode: 384 });
|
|
2548
|
+
fs.renameSync(tmp, file);
|
|
2549
|
+
} catch {
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
function readLastHook(tool) {
|
|
2553
|
+
try {
|
|
2554
|
+
const parsed = JSON.parse(fs.readFileSync(lastHookPath(tool), "utf8"));
|
|
2555
|
+
if (typeof parsed.event !== "string" || typeof parsed.at !== "string")
|
|
2556
|
+
return void 0;
|
|
2557
|
+
return { event: parsed.event, at: parsed.at };
|
|
2558
|
+
} catch {
|
|
2559
|
+
return void 0;
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
function describeAge(ms) {
|
|
2563
|
+
if (!Number.isFinite(ms) || ms < 0)
|
|
2564
|
+
return "just now";
|
|
2565
|
+
const seconds = Math.round(ms / 1e3);
|
|
2566
|
+
if (seconds < 60)
|
|
2567
|
+
return `${seconds} s ago`;
|
|
2568
|
+
const minutes = Math.round(seconds / 60);
|
|
2569
|
+
if (minutes < 60)
|
|
2570
|
+
return `${minutes} min ago`;
|
|
2571
|
+
const hours = Math.round(minutes / 60);
|
|
2572
|
+
if (hours < 48)
|
|
2573
|
+
return `${hours} h ago`;
|
|
2574
|
+
return `${Math.round(hours / 24)} days ago`;
|
|
2575
|
+
}
|
|
2576
|
+
function resolveHookNode(launcher) {
|
|
2577
|
+
if (!fs.existsSync(launcher))
|
|
2578
|
+
return { problem: "the hook launcher is not installed" };
|
|
2579
|
+
const probe = (0, child_process_1.spawnSync)("/bin/sh", [launcher], {
|
|
2580
|
+
encoding: "utf8",
|
|
2581
|
+
timeout: 5e3,
|
|
2582
|
+
env: { HOME: process.env.HOME ?? "", PATH: "/usr/bin:/bin:/usr/sbin:/sbin", ASCENDA_HOOK_LAUNCHER_PROBE: "1" }
|
|
2583
|
+
});
|
|
2584
|
+
const [node, how] = (probe.stdout ?? "").trim().split(" ");
|
|
2585
|
+
if (probe.status !== 0 || !node) {
|
|
2586
|
+
return { problem: (probe.stderr ?? "").trim() || "the launcher found no Node it can run" };
|
|
2587
|
+
}
|
|
2588
|
+
const version = (0, child_process_1.spawnSync)(node, ["--version"], { encoding: "utf8", timeout: 5e3 });
|
|
2589
|
+
if (version.status !== 0)
|
|
2590
|
+
return { node, how, problem: `${node} did not run` };
|
|
2591
|
+
return { node, how, version: version.stdout.trim() };
|
|
2592
|
+
}
|
|
2593
|
+
function tidyHomePath(file, home = process.env.HOME ?? "") {
|
|
2594
|
+
return home && file.startsWith(`${home}/`) ? `~${file.slice(home.length)}` : file;
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
});
|
|
2598
|
+
|
|
2599
|
+
// ../packages/tool-kit/out/releaseCheck.js
|
|
2600
|
+
var require_releaseCheck = __commonJS({
|
|
2601
|
+
"../packages/tool-kit/out/releaseCheck.js"(exports) {
|
|
2602
|
+
"use strict";
|
|
2603
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2604
|
+
if (k2 === void 0) k2 = k;
|
|
2605
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2606
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2607
|
+
desc = { enumerable: true, get: function() {
|
|
2608
|
+
return m[k];
|
|
2609
|
+
} };
|
|
2610
|
+
}
|
|
2611
|
+
Object.defineProperty(o, k2, desc);
|
|
2612
|
+
} : function(o, m, k, k2) {
|
|
2613
|
+
if (k2 === void 0) k2 = k;
|
|
2614
|
+
o[k2] = m[k];
|
|
2615
|
+
});
|
|
2616
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
2617
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
2618
|
+
} : function(o, v) {
|
|
2619
|
+
o["default"] = v;
|
|
2620
|
+
});
|
|
2621
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
2622
|
+
var ownKeys = function(o) {
|
|
2623
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
2624
|
+
var ar = [];
|
|
2625
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
2626
|
+
return ar;
|
|
2627
|
+
};
|
|
2628
|
+
return ownKeys(o);
|
|
2629
|
+
};
|
|
2630
|
+
return function(mod) {
|
|
2631
|
+
if (mod && mod.__esModule) return mod;
|
|
2632
|
+
var result = {};
|
|
2633
|
+
if (mod != null) {
|
|
2634
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
2635
|
+
}
|
|
2636
|
+
__setModuleDefault(result, mod);
|
|
2637
|
+
return result;
|
|
2638
|
+
};
|
|
2639
|
+
}();
|
|
2640
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2641
|
+
exports.RELEASE_CHECK_RETRY_MS = exports.RELEASE_CHECK_INTERVAL_MS = exports.RELEASE_CHECK_ENV_VAR = exports.RELEASE_MANIFEST_URL = void 0;
|
|
2642
|
+
exports.releaseCheckDisabled = releaseCheckDisabled;
|
|
2643
|
+
exports.releaseCheckPath = releaseCheckPath;
|
|
2644
|
+
exports.readReleaseCheck = readReleaseCheck;
|
|
2645
|
+
exports.compareReleases = compareReleases;
|
|
2646
|
+
exports.releaseStanding = releaseStanding;
|
|
2647
|
+
exports.refreshReleaseCheck = refreshReleaseCheck;
|
|
2648
|
+
exports.runsFromInstalledBundle = runsFromInstalledBundle;
|
|
2649
|
+
exports.pendingReleaseNotice = pendingReleaseNotice;
|
|
2650
|
+
exports.describeReleaseCheck = describeReleaseCheck;
|
|
2651
|
+
exports.installedBundleVersion = installedBundleVersion;
|
|
2652
|
+
var fs = __importStar(__require("fs"));
|
|
2653
|
+
var path = __importStar(__require("path"));
|
|
2654
|
+
var collectorVersion_1 = require_collectorVersion();
|
|
2655
|
+
var hookRunner_1 = require_hookRunner();
|
|
2656
|
+
var tokenStore_1 = require_tokenStore();
|
|
2657
|
+
exports.RELEASE_MANIFEST_URL = "https://github.com/ascendaone-com/ai-engineer-tools/releases/latest/download/manifest.json";
|
|
2658
|
+
exports.RELEASE_CHECK_ENV_VAR = "ASCENDA_DISABLE_UPDATE_CHECK";
|
|
2659
|
+
exports.RELEASE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
2660
|
+
exports.RELEASE_CHECK_RETRY_MS = 60 * 60 * 1e3;
|
|
2661
|
+
var FETCH_TIMEOUT_MS = 3e3;
|
|
2662
|
+
var SUMMARY_MAX_CHARS = 200;
|
|
2663
|
+
function releaseCheckDisabled(env = process.env) {
|
|
2664
|
+
return env[exports.RELEASE_CHECK_ENV_VAR]?.trim().toLowerCase() === "true";
|
|
2665
|
+
}
|
|
2666
|
+
function releaseCheckPath() {
|
|
2667
|
+
return path.join((0, tokenStore_1.ascendaHome)(), "state", "release-check.json");
|
|
2668
|
+
}
|
|
2669
|
+
function readReleaseCheck(file = releaseCheckPath()) {
|
|
2670
|
+
try {
|
|
2671
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
2672
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
2673
|
+
} catch {
|
|
2674
|
+
return void 0;
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
function writeReleaseCheck(file, check) {
|
|
2678
|
+
try {
|
|
2679
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 448 });
|
|
2680
|
+
(0, hookRunner_1.writeAtomically)(file, `${JSON.stringify(check, null, 2)}
|
|
2681
|
+
`, 384);
|
|
2682
|
+
} catch {
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
function parseRelease(version) {
|
|
2686
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec((version ?? "").trim());
|
|
2687
|
+
if (!match)
|
|
2688
|
+
return void 0;
|
|
2689
|
+
return { core: [Number(match[1]), Number(match[2]), Number(match[3])], pre: match[4] };
|
|
2690
|
+
}
|
|
2691
|
+
function compareReleases(a, b) {
|
|
2692
|
+
const left = parseRelease(a);
|
|
2693
|
+
const right = parseRelease(b);
|
|
2694
|
+
if (!left || !right)
|
|
2695
|
+
return void 0;
|
|
2696
|
+
for (let i = 0; i < 3; i++) {
|
|
2697
|
+
if (left.core[i] !== right.core[i])
|
|
2698
|
+
return left.core[i] - right.core[i];
|
|
2699
|
+
}
|
|
2700
|
+
if (left.pre === right.pre)
|
|
2701
|
+
return 0;
|
|
2702
|
+
if (left.pre === void 0)
|
|
2703
|
+
return 1;
|
|
2704
|
+
if (right.pre === void 0)
|
|
2705
|
+
return -1;
|
|
2706
|
+
return left.pre < right.pre ? -1 : 1;
|
|
2707
|
+
}
|
|
2708
|
+
function releaseStanding(installed, check) {
|
|
2709
|
+
const latest = check?.latestVersion;
|
|
2710
|
+
if (!latest)
|
|
2711
|
+
return void 0;
|
|
2712
|
+
const floor = check.minCollectorVersion;
|
|
2713
|
+
const belowFloor = floor !== void 0 && (compareReleases(installed, floor) ?? 0) < 0;
|
|
2714
|
+
if (belowFloor)
|
|
2715
|
+
return { kind: "unsupported", latest, floor };
|
|
2716
|
+
const behind = compareReleases(installed, latest);
|
|
2717
|
+
if (behind === void 0)
|
|
2718
|
+
return void 0;
|
|
2719
|
+
return behind < 0 ? { kind: "behind", latest } : { kind: "current", latest };
|
|
2720
|
+
}
|
|
2721
|
+
async function refreshReleaseCheck(options = {}) {
|
|
2722
|
+
const file = options.file ?? releaseCheckPath();
|
|
2723
|
+
const now = options.now ?? Date.now();
|
|
2724
|
+
const installed = options.installed ?? collectorVersion_1.COLLECTOR_VERSION;
|
|
2725
|
+
const previous = readReleaseCheck(file);
|
|
2726
|
+
if (releaseCheckDisabled(options.env) || installed === collectorVersion_1.UNRELEASED_COLLECTOR_VERSION)
|
|
2727
|
+
return previous;
|
|
2728
|
+
const since = (stamp) => {
|
|
2729
|
+
const at = stamp ? Date.parse(stamp) : NaN;
|
|
2730
|
+
return Number.isFinite(at) ? now - at : Infinity;
|
|
2731
|
+
};
|
|
2732
|
+
if (since(previous?.checkedAt) < exports.RELEASE_CHECK_INTERVAL_MS)
|
|
2733
|
+
return previous;
|
|
2734
|
+
if (since(previous?.attemptedAt) < exports.RELEASE_CHECK_RETRY_MS)
|
|
2735
|
+
return previous;
|
|
2736
|
+
const attemptedAt = new Date(now).toISOString();
|
|
2737
|
+
const fetched = await fetchManifest(options.fetchImpl ?? fetch);
|
|
2738
|
+
const next = fetched ? { ...previous, ...fetched, checkedAt: attemptedAt, attemptedAt } : { ...previous, attemptedAt };
|
|
2739
|
+
writeReleaseCheck(file, next);
|
|
2740
|
+
return next;
|
|
2741
|
+
}
|
|
2742
|
+
async function fetchManifest(fetchImpl) {
|
|
2743
|
+
try {
|
|
2744
|
+
const response = await fetchImpl(exports.RELEASE_MANIFEST_URL, {
|
|
2745
|
+
headers: { accept: "application/json" },
|
|
2746
|
+
redirect: "follow",
|
|
2747
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
|
|
2748
|
+
});
|
|
2749
|
+
if (!response.ok)
|
|
2750
|
+
return void 0;
|
|
2751
|
+
const manifest = await response.json();
|
|
2752
|
+
const latestVersion = typeof manifest.version === "string" && parseRelease(manifest.version) ? manifest.version : void 0;
|
|
2753
|
+
if (!latestVersion)
|
|
2754
|
+
return void 0;
|
|
2755
|
+
const floor = manifest.compatibility?.minCollectorVersion;
|
|
2756
|
+
const summary = typeof manifest.summary === "string" ? manifest.summary.trim() : "";
|
|
2757
|
+
return {
|
|
2758
|
+
latestVersion,
|
|
2759
|
+
...summary && summary.length <= SUMMARY_MAX_CHARS ? { latestSummary: summary } : {},
|
|
2760
|
+
...typeof floor === "string" && parseRelease(floor) ? { minCollectorVersion: floor } : {},
|
|
2761
|
+
...typeof manifest.minNode === "number" ? { minNode: manifest.minNode } : {}
|
|
2762
|
+
};
|
|
2763
|
+
} catch {
|
|
2764
|
+
return void 0;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
function runsFromInstalledBundle(script = process.argv[1]) {
|
|
2768
|
+
if (!script)
|
|
2769
|
+
return false;
|
|
2770
|
+
return path.dirname(path.resolve(script)) === path.join((0, tokenStore_1.ascendaHome)(), "bin");
|
|
2771
|
+
}
|
|
2772
|
+
function pendingReleaseNotice(options) {
|
|
2773
|
+
if (releaseCheckDisabled(options.env))
|
|
2774
|
+
return void 0;
|
|
2775
|
+
const installed = options.installed ?? collectorVersion_1.COLLECTOR_VERSION;
|
|
2776
|
+
if (installed === collectorVersion_1.UNRELEASED_COLLECTOR_VERSION)
|
|
2777
|
+
return void 0;
|
|
2778
|
+
const file = options.file ?? releaseCheckPath();
|
|
2779
|
+
const check = readReleaseCheck(file);
|
|
2780
|
+
const standing = releaseStanding(installed, check);
|
|
2781
|
+
if (!check || !standing || standing.kind === "current")
|
|
2782
|
+
return void 0;
|
|
2783
|
+
if (standing.kind === "behind" && check.notifiedFor === standing.latest)
|
|
2784
|
+
return void 0;
|
|
2785
|
+
const nodeMajor = options.nodeMajor ?? Number(process.versions.node.split(".")[0]);
|
|
2786
|
+
const node = check.minNode !== void 0 && nodeMajor < check.minNode ? ` ${standing.latest} needs Node ${check.minNode} or newer and these hooks run on Node ${nodeMajor}, so update Node first.` : "";
|
|
2787
|
+
const run = `Run \`${options.setupCommand}\`, then restart ${options.agentName}.`;
|
|
2788
|
+
const news = standing.kind === "behind" && check.latestSummary ? ` What's new: ${check.latestSummary}` : "";
|
|
2789
|
+
const text = standing.kind === "unsupported" ? `Ascenda note: the Ascenda hooks here are ${installed}, older than the oldest supported release (${standing.floor}). ${run}${node} This note repeats each session until they're updated.` : `Ascenda note: the Ascenda hooks here are ${installed}, and ${standing.latest} is out.${news} ${run}${node} This note appears once per release.`;
|
|
2790
|
+
return {
|
|
2791
|
+
text,
|
|
2792
|
+
markShown: () => {
|
|
2793
|
+
if (standing.kind !== "behind")
|
|
2794
|
+
return;
|
|
2795
|
+
writeReleaseCheck(file, { ...readReleaseCheck(file), notifiedFor: standing.latest });
|
|
2796
|
+
}
|
|
2797
|
+
};
|
|
2798
|
+
}
|
|
2799
|
+
function describeReleaseCheck(options) {
|
|
2800
|
+
if (options.localOnly)
|
|
2801
|
+
return "\u2014 not checked: an unpaired install makes no network requests";
|
|
2802
|
+
if (releaseCheckDisabled(options.env))
|
|
2803
|
+
return `\u2014 not checked: ${exports.RELEASE_CHECK_ENV_VAR} is set`;
|
|
2804
|
+
const check = readReleaseCheck(options.file);
|
|
2805
|
+
if (!check?.latestVersion || !check.checkedAt)
|
|
2806
|
+
return "\u2014 not checked yet; the background sender checks once a day";
|
|
2807
|
+
const age = (0, hookRunner_1.describeAge)((options.now ?? Date.now()) - Date.parse(check.checkedAt));
|
|
2808
|
+
const standing = releaseStanding(options.installed, check);
|
|
2809
|
+
if (!standing)
|
|
2810
|
+
return `${check.latestVersion} (checked ${age})`;
|
|
2811
|
+
if (standing.kind === "current")
|
|
2812
|
+
return `${check.latestVersion}, up to date (checked ${age})`;
|
|
2813
|
+
const below = standing.kind === "unsupported" ? `, and ${options.installed} is below the oldest supported release (${standing.floor})` : "";
|
|
2814
|
+
const news = check.latestSummary ? ` What's new: ${check.latestSummary}` : "";
|
|
2815
|
+
return `${check.latestVersion} (checked ${age})${below}.${news} Update: ${options.setupCommand}`;
|
|
2816
|
+
}
|
|
2817
|
+
function installedBundleVersion(versionFile) {
|
|
2818
|
+
try {
|
|
2819
|
+
return fs.readFileSync(versionFile, "utf8").trim() || void 0;
|
|
2820
|
+
} catch {
|
|
2821
|
+
return void 0;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
});
|
|
2826
|
+
|
|
2827
|
+
// ../packages/tool-kit/out/backgroundDelivery.js
|
|
2828
|
+
var require_backgroundDelivery = __commonJS({
|
|
2829
|
+
"../packages/tool-kit/out/backgroundDelivery.js"(exports) {
|
|
2830
|
+
"use strict";
|
|
2831
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2832
|
+
if (k2 === void 0) k2 = k;
|
|
2833
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2834
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2835
|
+
desc = { enumerable: true, get: function() {
|
|
2836
|
+
return m[k];
|
|
2837
|
+
} };
|
|
2838
|
+
}
|
|
2839
|
+
Object.defineProperty(o, k2, desc);
|
|
2840
|
+
} : function(o, m, k, k2) {
|
|
2841
|
+
if (k2 === void 0) k2 = k;
|
|
2842
|
+
o[k2] = m[k];
|
|
2843
|
+
});
|
|
2844
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
2845
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
2846
|
+
} : function(o, v) {
|
|
2847
|
+
o["default"] = v;
|
|
2848
|
+
});
|
|
2849
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
2850
|
+
var ownKeys = function(o) {
|
|
2851
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
2852
|
+
var ar = [];
|
|
2853
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
2854
|
+
return ar;
|
|
2855
|
+
};
|
|
2856
|
+
return ownKeys(o);
|
|
2857
|
+
};
|
|
2858
|
+
return function(mod) {
|
|
2859
|
+
if (mod && mod.__esModule) return mod;
|
|
2860
|
+
var result = {};
|
|
2861
|
+
if (mod != null) {
|
|
2862
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
2863
|
+
}
|
|
2864
|
+
__setModuleDefault(result, mod);
|
|
2865
|
+
return result;
|
|
2866
|
+
};
|
|
2867
|
+
}();
|
|
2868
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2869
|
+
exports.FLUSH_LOCK_FRESH_MS = exports.OUTBOX_FLUSH_COMMAND = exports.HOOK_DELIVERY_ENV_VAR = void 0;
|
|
2870
|
+
exports.hookDeliveryInline = hookDeliveryInline;
|
|
2871
|
+
exports.flushLockPath = flushLockPath;
|
|
2872
|
+
exports.startBackgroundFlush = startBackgroundFlush;
|
|
2873
|
+
exports.runOutboxFlush = runOutboxFlush;
|
|
2874
|
+
var fs = __importStar(__require("fs"));
|
|
2875
|
+
var child_process_1 = __require("child_process");
|
|
2876
|
+
var outbox_1 = require_outbox();
|
|
2877
|
+
var releaseCheck_1 = require_releaseCheck();
|
|
2878
|
+
exports.HOOK_DELIVERY_ENV_VAR = "ASCENDA_HOOK_DELIVERY";
|
|
2879
|
+
exports.OUTBOX_FLUSH_COMMAND = "__flush-outbox";
|
|
2880
|
+
exports.FLUSH_LOCK_FRESH_MS = 2e4;
|
|
2881
|
+
var FLUSH_MAX_PASSES = 20;
|
|
2882
|
+
var FLUSH_MAX_RUN_MS = 6e4;
|
|
2883
|
+
function hookDeliveryInline(env = process.env) {
|
|
2884
|
+
return env[exports.HOOK_DELIVERY_ENV_VAR]?.trim().toLowerCase() === "inline" || !(0, outbox_1.outboxDrainEnabled)(env);
|
|
2885
|
+
}
|
|
2886
|
+
function flushLockPath(outboxFilePath) {
|
|
2887
|
+
return `${outboxFilePath}.flushing`;
|
|
2888
|
+
}
|
|
2889
|
+
function lockIsFresh(lockPath, now) {
|
|
2890
|
+
try {
|
|
2891
|
+
return now - fs.statSync(lockPath).mtimeMs < exports.FLUSH_LOCK_FRESH_MS;
|
|
2892
|
+
} catch {
|
|
2893
|
+
return false;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
function touchLock(lockPath) {
|
|
2897
|
+
try {
|
|
2898
|
+
fs.writeFileSync(lockPath, `${process.pid}
|
|
2899
|
+
`, { encoding: "utf8", mode: 384 });
|
|
2900
|
+
} catch {
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
function removeLock(lockPath) {
|
|
2904
|
+
try {
|
|
2905
|
+
fs.unlinkSync(lockPath);
|
|
2906
|
+
} catch {
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
function outboxHasEntries(outboxFilePath) {
|
|
2910
|
+
try {
|
|
2911
|
+
return fs.statSync(outboxFilePath).size > 0;
|
|
2912
|
+
} catch {
|
|
2913
|
+
return false;
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
function startBackgroundFlush(options) {
|
|
2917
|
+
const lockPath = flushLockPath(options.outboxFilePath);
|
|
2918
|
+
const now = options.now ?? Date.now();
|
|
2919
|
+
if (lockIsFresh(lockPath, now))
|
|
2920
|
+
return false;
|
|
2921
|
+
const script = options.script ?? process.argv[1];
|
|
2922
|
+
if (!script)
|
|
2923
|
+
return false;
|
|
2924
|
+
try {
|
|
2925
|
+
touchLock(lockPath);
|
|
2926
|
+
const child = (0, child_process_1.spawn)(process.execPath, [script, exports.OUTBOX_FLUSH_COMMAND], {
|
|
2927
|
+
detached: true,
|
|
2928
|
+
stdio: "ignore",
|
|
2929
|
+
windowsHide: true,
|
|
2930
|
+
env: process.env
|
|
2931
|
+
});
|
|
2932
|
+
child.on("error", () => removeLock(lockPath));
|
|
2933
|
+
child.unref();
|
|
2934
|
+
return true;
|
|
2935
|
+
} catch {
|
|
2936
|
+
removeLock(lockPath);
|
|
2937
|
+
return false;
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
async function runOutboxFlush(sender, now = Date.now) {
|
|
2941
|
+
const outboxFilePath = sender.outboxFilePath();
|
|
2942
|
+
const lockPath = flushLockPath(outboxFilePath);
|
|
2943
|
+
const started = now();
|
|
2944
|
+
let last;
|
|
2945
|
+
let passes = 0;
|
|
2946
|
+
const drain = async () => {
|
|
2947
|
+
while (passes < FLUSH_MAX_PASSES && now() - started < FLUSH_MAX_RUN_MS) {
|
|
2948
|
+
passes += 1;
|
|
2949
|
+
touchLock(lockPath);
|
|
2950
|
+
last = await sender.flushOutbox();
|
|
2951
|
+
if (!last || last.found === 0 || last.halted || !last.sendEnabled)
|
|
2952
|
+
return;
|
|
2953
|
+
if (last.delivered === 0 && last.discarded === 0)
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2956
|
+
};
|
|
2957
|
+
try {
|
|
1944
2958
|
await drain();
|
|
1945
2959
|
removeLock(lockPath);
|
|
1946
2960
|
if (!last?.halted && last?.sendEnabled !== false && outboxHasEntries(outboxFilePath)) {
|
|
@@ -1951,6 +2965,7 @@ var require_backgroundDelivery = __commonJS({
|
|
|
1951
2965
|
} catch {
|
|
1952
2966
|
removeLock(lockPath);
|
|
1953
2967
|
}
|
|
2968
|
+
await (0, releaseCheck_1.refreshReleaseCheck)();
|
|
1954
2969
|
return last;
|
|
1955
2970
|
}
|
|
1956
2971
|
}
|
|
@@ -2393,6 +3408,8 @@ var require_http = __commonJS({
|
|
|
2393
3408
|
exports.createPairingSession = createPairingSession;
|
|
2394
3409
|
exports.getPairingStatus = getPairingStatus;
|
|
2395
3410
|
exports.startStudyJoin = startStudyJoin;
|
|
3411
|
+
exports.previewJoinCode = previewJoinCode;
|
|
3412
|
+
exports.startSquadronJoin = startSquadronJoin;
|
|
2396
3413
|
exports.getStudyJoinStatus = getStudyJoinStatus;
|
|
2397
3414
|
exports.readInitiatives = readInitiatives;
|
|
2398
3415
|
exports.readStudyNotices = readStudyNotices;
|
|
@@ -2418,27 +3435,52 @@ var require_http = __commonJS({
|
|
|
2418
3435
|
async function createPairingSession(apiBaseUrl, toolInstallationId, toolType, displayName, orgJoinCode) {
|
|
2419
3436
|
const response = await fetch(`${apiBaseUrl}/v1/tool-pairing-sessions`, {
|
|
2420
3437
|
method: "POST",
|
|
2421
|
-
headers: { "Content-Type": "application/json" },
|
|
2422
|
-
body: JSON.stringify({ toolInstallationId, toolType, displayName, ...orgJoinCode ? { orgJoinCode, mode: "report" } : {} })
|
|
3438
|
+
headers: { "Content-Type": "application/json" },
|
|
3439
|
+
body: JSON.stringify({ toolInstallationId, toolType, displayName, ...orgJoinCode ? { orgJoinCode, mode: "report" } : {} })
|
|
3440
|
+
});
|
|
3441
|
+
if (!response.ok)
|
|
3442
|
+
throw await apiError(response);
|
|
3443
|
+
return await response.json();
|
|
3444
|
+
}
|
|
3445
|
+
async function getPairingStatus(apiBaseUrl, pairingSessionId) {
|
|
3446
|
+
const response = await fetch(`${apiBaseUrl}/v1/tool-pairing-sessions/${encodeURIComponent(pairingSessionId)}/status`, {
|
|
3447
|
+
method: "GET",
|
|
3448
|
+
headers: { Accept: "application/json" }
|
|
3449
|
+
});
|
|
3450
|
+
if (!response.ok)
|
|
3451
|
+
throw new AscendaApiError(response.status, void 0, await response.text());
|
|
3452
|
+
return await response.json();
|
|
3453
|
+
}
|
|
3454
|
+
async function startStudyJoin(apiBaseUrl, eventWriteToken, joinCode, mode) {
|
|
3455
|
+
const response = await fetch(`${apiBaseUrl}/v1/org-study-join-sessions`, {
|
|
3456
|
+
method: "POST",
|
|
3457
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${eventWriteToken}` },
|
|
3458
|
+
body: JSON.stringify({ joinCode, mode })
|
|
2423
3459
|
});
|
|
2424
3460
|
if (!response.ok)
|
|
2425
3461
|
throw await apiError(response);
|
|
2426
3462
|
return await response.json();
|
|
2427
3463
|
}
|
|
2428
|
-
async function
|
|
2429
|
-
const response = await fetch(`${apiBaseUrl}/
|
|
3464
|
+
async function previewJoinCode(apiBaseUrl, joinCode) {
|
|
3465
|
+
const response = await fetch(`${apiBaseUrl}/api/share/join/${encodeURIComponent(joinCode)}`, {
|
|
2430
3466
|
method: "GET",
|
|
2431
3467
|
headers: { Accept: "application/json" }
|
|
2432
3468
|
});
|
|
2433
3469
|
if (!response.ok)
|
|
2434
|
-
throw
|
|
3470
|
+
throw await apiError(response);
|
|
2435
3471
|
return await response.json();
|
|
2436
3472
|
}
|
|
2437
|
-
async function
|
|
3473
|
+
async function startSquadronJoin(apiBaseUrl, eventWriteToken, seat) {
|
|
2438
3474
|
const response = await fetch(`${apiBaseUrl}/v1/org-study-join-sessions`, {
|
|
2439
3475
|
method: "POST",
|
|
2440
3476
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${eventWriteToken}` },
|
|
2441
|
-
body: JSON.stringify({
|
|
3477
|
+
body: JSON.stringify({
|
|
3478
|
+
joinCode: seat.joinCode,
|
|
3479
|
+
mode: "jam",
|
|
3480
|
+
handle: seat.handle,
|
|
3481
|
+
...seat.aircraft ? { aircraft: seat.aircraft } : {},
|
|
3482
|
+
...seat.colour ? { colour: seat.colour } : {}
|
|
3483
|
+
})
|
|
2442
3484
|
});
|
|
2443
3485
|
if (!response.ok)
|
|
2444
3486
|
throw await apiError(response);
|
|
@@ -3939,422 +4981,153 @@ var require_hookAdapter = __commonJS({
|
|
|
3939
4981
|
if (options.host && (0, credentials_1.isLocalOnlyHostInstall)(options.host, hasToken)) {
|
|
3940
4982
|
const logFile = (0, eventLog_1.resolveEventLogPath)({ localOnly: true });
|
|
3941
4983
|
if (logFile)
|
|
3942
|
-
logUnsent(logFile, events, options);
|
|
3943
|
-
return;
|
|
3944
|
-
}
|
|
3945
|
-
let config;
|
|
3946
|
-
try {
|
|
3947
|
-
config = loadCliAgentConfig(options.toolType, options.sessionId, options.cwd, options);
|
|
3948
|
-
} catch (error) {
|
|
3949
|
-
if (error instanceof MissingInstallationIdError)
|
|
3950
|
-
journalSkippedSend(options.host, error);
|
|
3951
|
-
const logFile = (0, eventLog_1.resolveEventLogPath)();
|
|
3952
|
-
if (!logFile)
|
|
3953
|
-
throw error;
|
|
3954
|
-
logUnsent(logFile, events, options);
|
|
3955
|
-
if (!(error instanceof MissingInstallationIdError))
|
|
3956
|
-
throw error;
|
|
3957
|
-
return;
|
|
3958
|
-
}
|
|
3959
|
-
const sender = new eventSender_1.AscendaEventSender({
|
|
3960
|
-
apiBaseUrl: config.apiBaseUrl,
|
|
3961
|
-
toolInstallationId: config.toolInstallationId,
|
|
3962
|
-
source: options.source,
|
|
3963
|
-
eventWriteToken: config.eventWriteToken,
|
|
3964
|
-
tokenFilePath: config.tokenFilePath,
|
|
3965
|
-
sessionId: config.sessionId,
|
|
3966
|
-
workspaceHash: config.workspaceHash,
|
|
3967
|
-
projectHash: config.projectHash,
|
|
3968
|
-
timeoutMs: config.timeoutMs
|
|
3969
|
-
});
|
|
3970
|
-
if ((0, backgroundDelivery_1.hookDeliveryInline)()) {
|
|
3971
|
-
for (const event of events) {
|
|
3972
|
-
const result = await sender.send(event);
|
|
3973
|
-
if (result === "accepted")
|
|
3974
|
-
continue;
|
|
3975
|
-
const message2 = noticeFor(result);
|
|
3976
|
-
if (message2)
|
|
3977
|
-
notice(message2);
|
|
3978
|
-
return;
|
|
3979
|
-
}
|
|
3980
|
-
return;
|
|
3981
|
-
}
|
|
3982
|
-
for (const event of events)
|
|
3983
|
-
sender.queue(event);
|
|
3984
|
-
(0, backgroundDelivery_1.startBackgroundFlush)({ outboxFilePath: sender.outboxFilePath() });
|
|
3985
|
-
const last = (0, stateStore_1.readCollectorState)(sender.stateFilePath())?.lastOutcome;
|
|
3986
|
-
const message = last ? noticeFor(last) : void 0;
|
|
3987
|
-
if (message)
|
|
3988
|
-
notice(message);
|
|
3989
|
-
}
|
|
3990
|
-
function noticeFor(result) {
|
|
3991
|
-
if (result === "accepted" || result === "duplicate")
|
|
3992
|
-
return void 0;
|
|
3993
|
-
if (result === "consent_missing")
|
|
3994
|
-
return "Ascenda telemetry paused: renew IDE telemetry consent in the Ascenda app.";
|
|
3995
|
-
if (result === "auth_failed")
|
|
3996
|
-
return "Ascenda telemetry paused: connection revoked or expired. Re-pair via an Ascenda IDE extension or pairing-sim.";
|
|
3997
|
-
if (result === "transport_error")
|
|
3998
|
-
return "Ascenda telemetry paused: the ingest endpoint could not be reached; the event is kept in the outbox. Your work is unaffected.";
|
|
3999
|
-
if (result === "outbox_discarded")
|
|
4000
|
-
return void 0;
|
|
4001
|
-
return `Ascenda telemetry rejected: ${result}`;
|
|
4002
|
-
}
|
|
4003
|
-
async function flushHookOutbox(options) {
|
|
4004
|
-
let config;
|
|
4005
|
-
try {
|
|
4006
|
-
config = loadCliAgentPairing(options.toolType, options);
|
|
4007
|
-
} catch {
|
|
4008
|
-
return;
|
|
4009
|
-
}
|
|
4010
|
-
const sender = new eventSender_1.AscendaEventSender({
|
|
4011
|
-
apiBaseUrl: config.apiBaseUrl,
|
|
4012
|
-
toolInstallationId: config.toolInstallationId,
|
|
4013
|
-
source: options.source,
|
|
4014
|
-
eventWriteToken: config.eventWriteToken,
|
|
4015
|
-
tokenFilePath: config.tokenFilePath,
|
|
4016
|
-
timeoutMs: config.timeoutMs
|
|
4017
|
-
});
|
|
4018
|
-
await (0, backgroundDelivery_1.runOutboxFlush)(sender);
|
|
4019
|
-
}
|
|
4020
|
-
function logUnsent(logFile, events, options) {
|
|
4021
|
-
const contextHashes = resolveContextHashes(options.cwd);
|
|
4022
|
-
for (const event of events) {
|
|
4023
|
-
(0, eventLog_1.appendEventLog)(logFile, {
|
|
4024
|
-
loggedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4025
|
-
delivery: "not_sent",
|
|
4026
|
-
payload: (0, eventSender_1.buildEventPayload)({
|
|
4027
|
-
toolInstallationId: `${options.toolType}:unpaired`,
|
|
4028
|
-
source: options.source,
|
|
4029
|
-
sessionId: process.env.ASCENDA_SESSION_ID?.trim() || options.sessionId || null,
|
|
4030
|
-
workspaceHash: contextHashes.workspaceHash,
|
|
4031
|
-
projectHash: contextHashes.projectHash
|
|
4032
|
-
}, event)
|
|
4033
|
-
});
|
|
4034
|
-
}
|
|
4035
|
-
}
|
|
4036
|
-
function journalSkippedSend(host, error) {
|
|
4037
|
-
const who = host ? `${host}: ` : "";
|
|
4038
|
-
(0, stateStore_1.recordSendOutcome)((0, stateStore_1.unresolvedStateFilePath)(error.toolType), (0, stateStore_1.unresolvedToolInstallationId)(error.toolType), "skipped_no_installation_id", {
|
|
4039
|
-
detail: error.candidates.length === 0 ? `${who}no ASCENDA_TOOL_INSTALLATION_ID, no credentials.json pairing, no ${error.toolType} token file` : `${who}no ASCENDA_TOOL_INSTALLATION_ID, no credentials.json pairing, ${error.candidates.length} ${error.toolType} token files (${error.candidates.join(", ")})`
|
|
4040
|
-
});
|
|
4041
|
-
}
|
|
4042
|
-
function parsePositiveInt(value) {
|
|
4043
|
-
const n = Number(value);
|
|
4044
|
-
return Number.isInteger(n) && n > 0 ? n : void 0;
|
|
4045
|
-
}
|
|
4046
|
-
}
|
|
4047
|
-
});
|
|
4048
|
-
|
|
4049
|
-
// ../packages/tool-kit/out/confirmLinks.js
|
|
4050
|
-
var require_confirmLinks = __commonJS({
|
|
4051
|
-
"../packages/tool-kit/out/confirmLinks.js"(exports) {
|
|
4052
|
-
"use strict";
|
|
4053
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4054
|
-
exports.pairingConfirmUrl = pairingConfirmUrl;
|
|
4055
|
-
exports.pairingConfirmLines = pairingConfirmLines;
|
|
4056
|
-
exports.studyJoinConfirmUrl = studyJoinConfirmUrl;
|
|
4057
|
-
function pairingConfirmUrl(qrUrl) {
|
|
4058
|
-
return isHttps(qrUrl) ? qrUrl : void 0;
|
|
4059
|
-
}
|
|
4060
|
-
function pairingConfirmLines(qrUrl, code) {
|
|
4061
|
-
const url = pairingConfirmUrl(qrUrl);
|
|
4062
|
-
if (!url)
|
|
4063
|
-
return [`Confirm in the Ascenda app \u2014 code ${code}`];
|
|
4064
|
-
return [`Open this link to confirm: ${url}`, `Or paste code ${code} in the Ascenda app.`];
|
|
4065
|
-
}
|
|
4066
|
-
function studyJoinConfirmUrl(apiBaseUrl, deviceCode) {
|
|
4067
|
-
if (!isHttps(apiBaseUrl))
|
|
4068
|
-
return void 0;
|
|
4069
|
-
return `${apiBaseUrl.replace(/\/+$/, "")}/join/${encodeURIComponent(deviceCode)}`;
|
|
4070
|
-
}
|
|
4071
|
-
function isHttps(value) {
|
|
4072
|
-
if (!value)
|
|
4073
|
-
return false;
|
|
4074
|
-
try {
|
|
4075
|
-
return new URL(value).protocol === "https:";
|
|
4076
|
-
} catch {
|
|
4077
|
-
return false;
|
|
4078
|
-
}
|
|
4079
|
-
}
|
|
4080
|
-
}
|
|
4081
|
-
});
|
|
4082
|
-
|
|
4083
|
-
// ../packages/tool-kit/out/studyJoin.js
|
|
4084
|
-
var require_studyJoin = __commonJS({
|
|
4085
|
-
"../packages/tool-kit/out/studyJoin.js"(exports) {
|
|
4086
|
-
"use strict";
|
|
4087
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4088
|
-
if (k2 === void 0) k2 = k;
|
|
4089
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4090
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4091
|
-
desc = { enumerable: true, get: function() {
|
|
4092
|
-
return m[k];
|
|
4093
|
-
} };
|
|
4094
|
-
}
|
|
4095
|
-
Object.defineProperty(o, k2, desc);
|
|
4096
|
-
} : function(o, m, k, k2) {
|
|
4097
|
-
if (k2 === void 0) k2 = k;
|
|
4098
|
-
o[k2] = m[k];
|
|
4099
|
-
});
|
|
4100
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
4101
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
4102
|
-
} : function(o, v) {
|
|
4103
|
-
o["default"] = v;
|
|
4104
|
-
});
|
|
4105
|
-
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
4106
|
-
var ownKeys = function(o) {
|
|
4107
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
4108
|
-
var ar = [];
|
|
4109
|
-
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
4110
|
-
return ar;
|
|
4111
|
-
};
|
|
4112
|
-
return ownKeys(o);
|
|
4113
|
-
};
|
|
4114
|
-
return function(mod) {
|
|
4115
|
-
if (mod && mod.__esModule) return mod;
|
|
4116
|
-
var result = {};
|
|
4117
|
-
if (mod != null) {
|
|
4118
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
4119
|
-
}
|
|
4120
|
-
__setModuleDefault(result, mod);
|
|
4121
|
-
return result;
|
|
4122
|
-
};
|
|
4123
|
-
}();
|
|
4124
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4125
|
-
exports.gitOfferLine = gitOfferLine;
|
|
4126
|
-
exports.runStudyJoin = runStudyJoin;
|
|
4127
|
-
exports.formatWindow = formatWindow;
|
|
4128
|
-
exports.describeStudyGrant = describeStudyGrant;
|
|
4129
|
-
exports.describeStudyKind = describeStudyKind;
|
|
4130
|
-
exports.describeRefusal = describeRefusal;
|
|
4131
|
-
var readline = __importStar(__require("node:readline"));
|
|
4132
|
-
var confirmLinks_1 = require_confirmLinks();
|
|
4133
|
-
var http_1 = require_http();
|
|
4134
|
-
function gitOfferLine(optionalImportStores) {
|
|
4135
|
-
if (!optionalImportStores?.includes("git"))
|
|
4136
|
-
return void 0;
|
|
4137
|
-
return "The page also has an unticked box for git history: commit times, size buckets, files changed and whether each is a merge. No messages, paths, names or emails.";
|
|
4138
|
-
}
|
|
4139
|
-
var STUDY_JOIN_MODE = "report";
|
|
4140
|
-
var POLL_INTERVAL_MS = 3e3;
|
|
4141
|
-
var POLL_TIMEOUT_MS = 11 * 60 * 1e3;
|
|
4142
|
-
async function runStudyJoin(ctx) {
|
|
4143
|
-
const report = (outcome) => ctx.onOutcome?.(outcome);
|
|
4144
|
-
const stdin = ctx.stdin ?? process.stdin;
|
|
4145
|
-
const stdout = ctx.stdout ?? process.stdout;
|
|
4146
|
-
const stderr = ctx.stderr ?? process.stderr;
|
|
4147
|
-
const print = (line) => stdout.write(`${line}
|
|
4148
|
-
`);
|
|
4149
|
-
if (!stdin.isTTY || !stdout.isTTY) {
|
|
4150
|
-
stderr.write("join needs an interactive terminal (stdin and stdout). Run it directly, not from a script or a pipe.\n");
|
|
4151
|
-
report({ status: "no_terminal", granted: [] });
|
|
4152
|
-
return 0;
|
|
4153
|
-
}
|
|
4154
|
-
if (!ctx.joinCode) {
|
|
4155
|
-
stderr.write("Usage: join <code>\n");
|
|
4156
|
-
report({ status: "failed", granted: [], message: "No join code given." });
|
|
4157
|
-
return 1;
|
|
4158
|
-
}
|
|
4159
|
-
let start;
|
|
4160
|
-
try {
|
|
4161
|
-
start = await (0, http_1.startStudyJoin)(ctx.apiBaseUrl, ctx.eventWriteToken, ctx.joinCode, STUDY_JOIN_MODE);
|
|
4162
|
-
} catch (error) {
|
|
4163
|
-
stderr.write(`${describeStartError(error)}
|
|
4164
|
-
`);
|
|
4165
|
-
report({ status: "failed", granted: [], message: describeStartError(error) });
|
|
4166
|
-
return 1;
|
|
4167
|
-
}
|
|
4168
|
-
print("");
|
|
4169
|
-
print(`${start.organisationName}: ${describeStudyKind(start.studyKind)}`);
|
|
4170
|
-
print(formatWindow(start.windowStartUtc, start.windowEndUtc));
|
|
4171
|
-
print("");
|
|
4172
|
-
print("Report (30 days) grants:");
|
|
4173
|
-
for (const grant of start.grants)
|
|
4174
|
-
print(` ${describeStudyGrant(grant)}`);
|
|
4175
|
-
const gitOffer = gitOfferLine(start.optionalImportStores);
|
|
4176
|
-
if (gitOffer)
|
|
4177
|
-
print(gitOffer);
|
|
4178
|
-
print("");
|
|
4179
|
-
print("Study mode needs the Ascenda app. Open the app to join that way instead.");
|
|
4180
|
-
print("");
|
|
4181
|
-
print("Join in:");
|
|
4182
|
-
print(" 1) Report (30 days)");
|
|
4183
|
-
print(" 2) Not now");
|
|
4184
|
-
print("");
|
|
4185
|
-
const answer = await askChoice(stdin, stdout);
|
|
4186
|
-
if (!/^(1|report)$/i.test(answer)) {
|
|
4187
|
-
print("Not now.");
|
|
4188
|
-
report({ status: "not_now", start, granted: [] });
|
|
4189
|
-
return 0;
|
|
4984
|
+
logUnsent(logFile, events, options);
|
|
4985
|
+
return;
|
|
4190
4986
|
}
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4987
|
+
let config;
|
|
4988
|
+
try {
|
|
4989
|
+
config = loadCliAgentConfig(options.toolType, options.sessionId, options.cwd, options);
|
|
4990
|
+
} catch (error) {
|
|
4991
|
+
if (error instanceof MissingInstallationIdError)
|
|
4992
|
+
journalSkippedSend(options.host, error);
|
|
4993
|
+
const logFile = (0, eventLog_1.resolveEventLogPath)();
|
|
4994
|
+
if (!logFile)
|
|
4995
|
+
throw error;
|
|
4996
|
+
logUnsent(logFile, events, options);
|
|
4997
|
+
if (!(error instanceof MissingInstallationIdError))
|
|
4998
|
+
throw error;
|
|
4999
|
+
return;
|
|
4198
5000
|
}
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
5001
|
+
const sender = new eventSender_1.AscendaEventSender({
|
|
5002
|
+
apiBaseUrl: config.apiBaseUrl,
|
|
5003
|
+
toolInstallationId: config.toolInstallationId,
|
|
5004
|
+
source: options.source,
|
|
5005
|
+
eventWriteToken: config.eventWriteToken,
|
|
5006
|
+
tokenFilePath: config.tokenFilePath,
|
|
5007
|
+
sessionId: config.sessionId,
|
|
5008
|
+
workspaceHash: config.workspaceHash,
|
|
5009
|
+
projectHash: config.projectHash,
|
|
5010
|
+
timeoutMs: config.timeoutMs
|
|
5011
|
+
});
|
|
5012
|
+
if ((0, backgroundDelivery_1.hookDeliveryInline)()) {
|
|
5013
|
+
for (const event of events) {
|
|
5014
|
+
const result = await sender.send(event);
|
|
5015
|
+
if (result === "accepted")
|
|
4209
5016
|
continue;
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
return
|
|
4214
|
-
}
|
|
4215
|
-
if (poll.status === "pending")
|
|
4216
|
-
continue;
|
|
4217
|
-
if (poll.status === "confirmed") {
|
|
4218
|
-
const granted = poll.granted ?? [];
|
|
4219
|
-
if (granted.length === 0) {
|
|
4220
|
-
print("");
|
|
4221
|
-
print("Nothing was granted. Run join again, or check with your organisation.");
|
|
4222
|
-
report({ status: "refused", start, granted: [], message: "Nothing was granted." });
|
|
4223
|
-
return 1;
|
|
4224
|
-
}
|
|
4225
|
-
print("");
|
|
4226
|
-
print("Joined. Granted:");
|
|
4227
|
-
for (const grant of granted)
|
|
4228
|
-
print(` ${describeStudyGrant(grant)}`);
|
|
4229
|
-
print("");
|
|
4230
|
-
print("Each of these can be turned off separately, in the app's consent settings.");
|
|
4231
|
-
print("The organisation sees group counts, never who joined.");
|
|
4232
|
-
report({ status: "joined", start, granted, importStores: poll.importStores ?? null });
|
|
4233
|
-
return 0;
|
|
4234
|
-
}
|
|
4235
|
-
if (poll.status === "expired") {
|
|
4236
|
-
print("");
|
|
4237
|
-
print("This code expired before it was confirmed. Run join again for a fresh code.");
|
|
4238
|
-
report({ status: "expired", start, granted: [] });
|
|
4239
|
-
return 1;
|
|
4240
|
-
}
|
|
4241
|
-
if (poll.refusedReason === "grant_failed") {
|
|
4242
|
-
print("");
|
|
4243
|
-
print("Join failed partway through. Some grants may not have gone through.");
|
|
4244
|
-
const granted = poll.granted ?? [];
|
|
4245
|
-
if (granted.length > 0) {
|
|
4246
|
-
print("");
|
|
4247
|
-
print("Granted before the failure:");
|
|
4248
|
-
for (const grant of granted)
|
|
4249
|
-
print(` ${describeStudyGrant(grant)}`);
|
|
4250
|
-
print("");
|
|
4251
|
-
print("Each of these can be turned off separately, in the app's consent settings.");
|
|
4252
|
-
}
|
|
4253
|
-
print("Run join again, or check with your organisation.");
|
|
4254
|
-
report({ status: "refused", start, granted, refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason), importStores: poll.importStores ?? null });
|
|
4255
|
-
return 1;
|
|
5017
|
+
const message2 = noticeFor(result);
|
|
5018
|
+
if (message2)
|
|
5019
|
+
notice(message2);
|
|
5020
|
+
return;
|
|
4256
5021
|
}
|
|
4257
|
-
|
|
4258
|
-
print(describeRefusal(poll.refusedReason));
|
|
4259
|
-
report({ status: "refused", start, granted: [], refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason) });
|
|
4260
|
-
return 1;
|
|
5022
|
+
return;
|
|
4261
5023
|
}
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
5024
|
+
for (const event of events)
|
|
5025
|
+
sender.queue(event);
|
|
5026
|
+
(0, backgroundDelivery_1.startBackgroundFlush)({ outboxFilePath: sender.outboxFilePath() });
|
|
5027
|
+
const last = (0, stateStore_1.readCollectorState)(sender.stateFilePath())?.lastOutcome;
|
|
5028
|
+
const message = last ? noticeFor(last) : void 0;
|
|
5029
|
+
if (message)
|
|
5030
|
+
notice(message);
|
|
4266
5031
|
}
|
|
4267
|
-
function
|
|
4268
|
-
if (
|
|
4269
|
-
return
|
|
4270
|
-
|
|
5032
|
+
function noticeFor(result) {
|
|
5033
|
+
if (result === "accepted" || result === "duplicate")
|
|
5034
|
+
return void 0;
|
|
5035
|
+
if (result === "consent_missing")
|
|
5036
|
+
return "Ascenda telemetry paused: renew IDE telemetry consent in the Ascenda app.";
|
|
5037
|
+
if (result === "auth_failed")
|
|
5038
|
+
return "Ascenda telemetry paused: connection revoked or expired. Re-pair via an Ascenda IDE extension or pairing-sim.";
|
|
5039
|
+
if (result === "transport_error")
|
|
5040
|
+
return "Ascenda telemetry paused: the ingest endpoint could not be reached; the event is kept in the outbox. Your work is unaffected.";
|
|
5041
|
+
if (result === "outbox_discarded")
|
|
5042
|
+
return void 0;
|
|
5043
|
+
return `Ascenda telemetry rejected: ${result}`;
|
|
4271
5044
|
}
|
|
4272
|
-
function
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
5045
|
+
async function flushHookOutbox(options) {
|
|
5046
|
+
let config;
|
|
5047
|
+
try {
|
|
5048
|
+
config = loadCliAgentPairing(options.toolType, options);
|
|
5049
|
+
} catch {
|
|
5050
|
+
return;
|
|
5051
|
+
}
|
|
5052
|
+
const sender = new eventSender_1.AscendaEventSender({
|
|
5053
|
+
apiBaseUrl: config.apiBaseUrl,
|
|
5054
|
+
toolInstallationId: config.toolInstallationId,
|
|
5055
|
+
source: options.source,
|
|
5056
|
+
eventWriteToken: config.eventWriteToken,
|
|
5057
|
+
tokenFilePath: config.tokenFilePath,
|
|
5058
|
+
timeoutMs: config.timeoutMs
|
|
4285
5059
|
});
|
|
5060
|
+
await (0, backgroundDelivery_1.runOutboxFlush)(sender);
|
|
4286
5061
|
}
|
|
4287
|
-
function
|
|
4288
|
-
const
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
5062
|
+
function logUnsent(logFile, events, options) {
|
|
5063
|
+
const contextHashes = resolveContextHashes(options.cwd);
|
|
5064
|
+
for (const event of events) {
|
|
5065
|
+
(0, eventLog_1.appendEventLog)(logFile, {
|
|
5066
|
+
loggedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5067
|
+
delivery: "not_sent",
|
|
5068
|
+
payload: (0, eventSender_1.buildEventPayload)({
|
|
5069
|
+
toolInstallationId: `${options.toolType}:unpaired`,
|
|
5070
|
+
source: options.source,
|
|
5071
|
+
sessionId: process.env.ASCENDA_SESSION_ID?.trim() || options.sessionId || null,
|
|
5072
|
+
workspaceHash: contextHashes.workspaceHash,
|
|
5073
|
+
projectHash: contextHashes.projectHash
|
|
5074
|
+
}, event)
|
|
5075
|
+
});
|
|
5076
|
+
}
|
|
4302
5077
|
}
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
return GRANT_SENTENCES[grant.code] ?? humanise(grant.name);
|
|
5078
|
+
function journalSkippedSend(host, error) {
|
|
5079
|
+
const who = host ? `${host}: ` : "";
|
|
5080
|
+
(0, stateStore_1.recordSendOutcome)((0, stateStore_1.unresolvedStateFilePath)(error.toolType), (0, stateStore_1.unresolvedToolInstallationId)(error.toolType), "skipped_no_installation_id", {
|
|
5081
|
+
detail: error.candidates.length === 0 ? `${who}no ASCENDA_TOOL_INSTALLATION_ID, no credentials.json pairing, no ${error.toolType} token file` : `${who}no ASCENDA_TOOL_INSTALLATION_ID, no credentials.json pairing, ${error.candidates.length} ${error.toolType} token files (${error.candidates.join(", ")})`
|
|
5082
|
+
});
|
|
4309
5083
|
}
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
};
|
|
4314
|
-
function describeStudyKind(studyKind) {
|
|
4315
|
-
return STUDY_KIND_SENTENCES[studyKind] ?? humanise(studyKind);
|
|
5084
|
+
function parsePositiveInt(value) {
|
|
5085
|
+
const n = Number(value);
|
|
5086
|
+
return Number.isInteger(n) && n > 0 ? n : void 0;
|
|
4316
5087
|
}
|
|
4317
|
-
|
|
4318
|
-
|
|
5088
|
+
}
|
|
5089
|
+
});
|
|
5090
|
+
|
|
5091
|
+
// ../packages/tool-kit/out/confirmLinks.js
|
|
5092
|
+
var require_confirmLinks = __commonJS({
|
|
5093
|
+
"../packages/tool-kit/out/confirmLinks.js"(exports) {
|
|
5094
|
+
"use strict";
|
|
5095
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5096
|
+
exports.WEEKLY_POSTER_CONNECT_URL = void 0;
|
|
5097
|
+
exports.pairingConfirmUrl = pairingConfirmUrl;
|
|
5098
|
+
exports.pairingConfirmLines = pairingConfirmLines;
|
|
5099
|
+
exports.studyJoinConfirmUrl = studyJoinConfirmUrl;
|
|
5100
|
+
exports.WEEKLY_POSTER_CONNECT_URL = "https://me.ascendaflow.com/connect";
|
|
5101
|
+
function pairingConfirmUrl(qrUrl) {
|
|
5102
|
+
return isHttps(qrUrl) ? qrUrl : void 0;
|
|
4319
5103
|
}
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
grant_failed: "Join failed partway through. Some grants may not have gone through.",
|
|
4327
|
-
declined: "You declined the join. Nothing was granted.",
|
|
4328
|
-
not_enrolled: "That study couldn't enrol you, so nothing was granted."
|
|
4329
|
-
};
|
|
4330
|
-
function describeRefusal(refusedReason) {
|
|
4331
|
-
if (refusedReason && REFUSED_REASON_MESSAGES[refusedReason])
|
|
4332
|
-
return REFUSED_REASON_MESSAGES[refusedReason];
|
|
4333
|
-
return "The join didn't go through. Nothing new was granted.";
|
|
5104
|
+
function pairingConfirmLines(qrUrl, code) {
|
|
5105
|
+
const url = pairingConfirmUrl(qrUrl);
|
|
5106
|
+
const where = [" Ascenda Flow, under Connections \u2192 Ingest telemetry", ` ${exports.WEEKLY_POSTER_CONNECT_URL}, for the weekly poster`];
|
|
5107
|
+
if (!url)
|
|
5108
|
+
return [`Confirm code ${code} in either place:`, ...where];
|
|
5109
|
+
return [`Open this link to confirm: ${url}`, `Or enter code ${code} in either place:`, ...where];
|
|
4334
5110
|
}
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
return "This tool's pairing was rejected. Re-pair it, then try again.";
|
|
4348
|
-
return `Could not reach the join code (HTTP ${error.status}).`;
|
|
5111
|
+
function studyJoinConfirmUrl(apiBaseUrl, deviceCode) {
|
|
5112
|
+
if (!isHttps(apiBaseUrl))
|
|
5113
|
+
return void 0;
|
|
5114
|
+
return `${apiBaseUrl.replace(/\/+$/, "")}/join/${encodeURIComponent(deviceCode)}`;
|
|
5115
|
+
}
|
|
5116
|
+
function isHttps(value) {
|
|
5117
|
+
if (!value)
|
|
5118
|
+
return false;
|
|
5119
|
+
try {
|
|
5120
|
+
return new URL(value).protocol === "https:";
|
|
5121
|
+
} catch {
|
|
5122
|
+
return false;
|
|
4349
5123
|
}
|
|
4350
|
-
return error instanceof Error ? error.message : String(error);
|
|
4351
5124
|
}
|
|
4352
5125
|
}
|
|
4353
5126
|
});
|
|
4354
5127
|
|
|
4355
|
-
// ../packages/tool-kit/out/
|
|
4356
|
-
var
|
|
4357
|
-
"../packages/tool-kit/out/
|
|
5128
|
+
// ../packages/tool-kit/out/studyJoin.js
|
|
5129
|
+
var require_studyJoin = __commonJS({
|
|
5130
|
+
"../packages/tool-kit/out/studyJoin.js"(exports) {
|
|
4358
5131
|
"use strict";
|
|
4359
5132
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4360
5133
|
if (k2 === void 0) k2 = k;
|
|
@@ -4394,319 +5167,239 @@ var require_pairingStudyJoin = __commonJS({
|
|
|
4394
5167
|
};
|
|
4395
5168
|
}();
|
|
4396
5169
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4397
|
-
exports.
|
|
4398
|
-
exports.
|
|
4399
|
-
exports.
|
|
4400
|
-
exports.
|
|
4401
|
-
exports.
|
|
4402
|
-
exports.
|
|
4403
|
-
var
|
|
5170
|
+
exports.gitOfferLine = gitOfferLine;
|
|
5171
|
+
exports.runStudyJoin = runStudyJoin;
|
|
5172
|
+
exports.formatWindow = formatWindow;
|
|
5173
|
+
exports.describeStudyGrant = describeStudyGrant;
|
|
5174
|
+
exports.describeStudyKind = describeStudyKind;
|
|
5175
|
+
exports.describeRefusal = describeRefusal;
|
|
5176
|
+
var readline = __importStar(__require("node:readline"));
|
|
4404
5177
|
var confirmLinks_1 = require_confirmLinks();
|
|
4405
|
-
var studyJoin_1 = require_studyJoin();
|
|
4406
5178
|
var http_1 = require_http();
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
var CREATE_REFUSALS = {
|
|
4410
|
-
join_code_not_found: "That code is not a study anyone can join. Check it and try again.",
|
|
4411
|
-
no_live_study: "There's nothing open to join with that code right now.",
|
|
4412
|
-
unknown_mode: "This tool only offers Report mode from the command line."
|
|
4413
|
-
};
|
|
4414
|
-
var JOIN_SETTLE_MS = 6e4;
|
|
4415
|
-
async function createPairingAttempt(apiBaseUrl, toolInstallationId, toolType, displayName, env = process.env) {
|
|
4416
|
-
const orgJoinCode = env[exports.PAIR_ORG_JOIN_CODE_ENV]?.trim();
|
|
4417
|
-
if (!orgJoinCode)
|
|
4418
|
-
return { session: await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName), carriesJoin: false };
|
|
4419
|
-
let refusal;
|
|
4420
|
-
try {
|
|
4421
|
-
const session = await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName, orgJoinCode);
|
|
4422
|
-
return { session, carriesJoin: session.studyJoin !== void 0 };
|
|
4423
|
-
} catch (error) {
|
|
4424
|
-
if (!(error instanceof http_1.AscendaApiError) || error.status >= 500)
|
|
4425
|
-
throw error;
|
|
4426
|
-
refusal = error.errorCode ? CREATE_REFUSALS[error.errorCode] : void 0;
|
|
4427
|
-
}
|
|
4428
|
-
return { session: await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName), carriesJoin: false, refusal };
|
|
4429
|
-
}
|
|
4430
|
-
function pairingAttemptLines(attempt) {
|
|
4431
|
-
const { session } = attempt;
|
|
4432
|
-
const join = attempt.carriesJoin ? session.studyJoin : void 0;
|
|
4433
|
-
if (!join)
|
|
4434
|
-
return (0, confirmLinks_1.pairingConfirmLines)(session.qrUrl, session.code);
|
|
4435
|
-
const gitOffer = (0, studyJoin_1.gitOfferLine)(join.optionalImportStores);
|
|
4436
|
-
return [
|
|
4437
|
-
`This also joins ${join.organisationName} (${(0, studyJoin_1.formatWindow)(join.windowStartUtc, join.windowEndUtc)}). The page shows what you'd share before you confirm.`,
|
|
4438
|
-
...gitOffer ? [gitOffer] : [],
|
|
4439
|
-
`Open this link to confirm: ${session.qrUrl}`
|
|
4440
|
-
];
|
|
4441
|
-
}
|
|
4442
|
-
async function settleStudyJoin(apiBaseUrl, pairingSessionId, last, wait = 1e3) {
|
|
4443
|
-
let current = last;
|
|
4444
|
-
const deadline = Date.now() + JOIN_SETTLE_MS;
|
|
4445
|
-
while (current && current.status === "pending" && Date.now() < deadline) {
|
|
4446
|
-
await new Promise((resolve) => setTimeout(resolve, wait));
|
|
4447
|
-
let status;
|
|
4448
|
-
try {
|
|
4449
|
-
status = await (0, http_1.getPairingStatus)(apiBaseUrl, pairingSessionId);
|
|
4450
|
-
} catch {
|
|
4451
|
-
continue;
|
|
4452
|
-
}
|
|
4453
|
-
current = status.studyJoin ?? current;
|
|
4454
|
-
}
|
|
4455
|
-
return current;
|
|
4456
|
-
}
|
|
4457
|
-
function writePairingJoinOutcome(outcome, env = process.env) {
|
|
4458
|
-
const file = env[exports.PAIR_JOIN_OUTCOME_FILE_ENV]?.trim();
|
|
4459
|
-
if (!file)
|
|
4460
|
-
return;
|
|
4461
|
-
try {
|
|
4462
|
-
fs.writeFileSync(file, `${JSON.stringify(outcome)}
|
|
4463
|
-
`, { mode: 384 });
|
|
4464
|
-
} catch {
|
|
4465
|
-
}
|
|
4466
|
-
}
|
|
4467
|
-
function pairingJoinOutcome(attempt, pairing, studyJoin) {
|
|
4468
|
-
if (!attempt)
|
|
4469
|
-
return { join: "none", pairing };
|
|
4470
|
-
if (attempt.refusal)
|
|
4471
|
-
return { join: "refused", pairing, message: attempt.refusal };
|
|
4472
|
-
return { join: attempt.carriesJoin ? "carried" : "not_carried", pairing, studyJoin };
|
|
4473
|
-
}
|
|
4474
|
-
}
|
|
4475
|
-
});
|
|
4476
|
-
|
|
4477
|
-
// ../packages/tool-kit/out/hookSet.js
|
|
4478
|
-
var require_hookSet = __commonJS({
|
|
4479
|
-
"../packages/tool-kit/out/hookSet.js"(exports) {
|
|
4480
|
-
"use strict";
|
|
4481
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4482
|
-
exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = void 0;
|
|
4483
|
-
exports.hookSetArgument = hookSetArgument;
|
|
4484
|
-
exports.readHookSet = readHookSet;
|
|
4485
|
-
exports.isHookSet = isHookSet;
|
|
4486
|
-
exports.readViaPlugin = readViaPlugin;
|
|
4487
|
-
exports.hookSetOfCommand = hookSetOfCommand;
|
|
4488
|
-
exports.hookSetChanges = hookSetChanges;
|
|
4489
|
-
exports.describeHookSetChanges = describeHookSetChanges;
|
|
4490
|
-
exports.HOOK_SET_FLAG = "--hook-set";
|
|
4491
|
-
exports.UNVERSIONED_HOOK_SET = 1;
|
|
4492
|
-
function hookSetArgument(hookSet) {
|
|
4493
|
-
return hookSet === void 0 ? "" : ` ${exports.HOOK_SET_FLAG} ${hookSet}`;
|
|
4494
|
-
}
|
|
4495
|
-
function readHookSet(argv) {
|
|
4496
|
-
const index = argv.indexOf(exports.HOOK_SET_FLAG);
|
|
4497
|
-
if (index === -1)
|
|
4498
|
-
return void 0;
|
|
4499
|
-
const raw = argv[index + 1];
|
|
4500
|
-
if (raw === void 0 || !/^[1-9]\d*$/.test(raw))
|
|
4501
|
-
return void 0;
|
|
4502
|
-
const value = Number(raw);
|
|
4503
|
-
return isHookSet(value) ? value : void 0;
|
|
4504
|
-
}
|
|
4505
|
-
function isHookSet(value) {
|
|
4506
|
-
return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
|
|
4507
|
-
}
|
|
4508
|
-
function readViaPlugin(env) {
|
|
4509
|
-
return env.CLAUDE_PLUGIN_ROOT ? true : void 0;
|
|
4510
|
-
}
|
|
4511
|
-
function hookSetOfCommand(command) {
|
|
4512
|
-
const match = command.match(/--hook-set\s+(\d+)/);
|
|
4513
|
-
return match ? Number(match[1]) : exports.UNVERSIONED_HOOK_SET;
|
|
4514
|
-
}
|
|
4515
|
-
function hookSetChanges(before, events) {
|
|
4516
|
-
const added = events.filter((event) => !before.has(event));
|
|
4517
|
-
const sets = [...before.values()];
|
|
4518
|
-
return sets.length ? { added, previousSet: Math.min(...sets) } : { added };
|
|
4519
|
-
}
|
|
4520
|
-
function describeHookSetChanges(changes, hookSet) {
|
|
4521
|
-
if (changes.previousSet === void 0)
|
|
5179
|
+
function gitOfferLine(optionalImportStores) {
|
|
5180
|
+
if (!optionalImportStores?.includes("git"))
|
|
4522
5181
|
return void 0;
|
|
4523
|
-
|
|
4524
|
-
if (changes.added.length)
|
|
4525
|
-
parts.push(`added ${changes.added.join(", ")}`);
|
|
4526
|
-
if (changes.previousSet < hookSet)
|
|
4527
|
-
parts.push(`hook set ${changes.previousSet} \u2192 ${hookSet}`);
|
|
4528
|
-
return parts.length ? `upgraded: ${parts.join("; ")}` : void 0;
|
|
5182
|
+
return "The page also has an unticked box for git history: commit times, size buckets, files changed and whether each is a merge. No messages, paths, names or emails.";
|
|
4529
5183
|
}
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
exports.INITIATIVE_COPY = {
|
|
4545
|
-
outcomes: {
|
|
4546
|
-
moved_as_declared: "Moved the way declared, beyond the cohort's own variation",
|
|
4547
|
-
moved_against_declared: "Moved the other way, beyond the cohort's own variation",
|
|
4548
|
-
moved_no_direction_declared: "Moved beyond the cohort's own variation; no direction was declared",
|
|
4549
|
-
within_own_variation: "No further from the baseline than the cohort's own week-to-week variation",
|
|
4550
|
-
withheld: "Withheld"
|
|
4551
|
-
},
|
|
4552
|
-
withheldReasons: {
|
|
4553
|
-
cohort_below_minimum: "the cohort was too small to report on when the scoring window closed",
|
|
4554
|
-
below_minimum_cohort: "the cohort was too small to report on when the scoring window closed",
|
|
4555
|
-
below_minimum_cohort_size: "the cohort was too small to report on when the scoring window closed",
|
|
4556
|
-
baseline_withheld: "the baseline was withheld"
|
|
5184
|
+
var STUDY_JOIN_MODE = "report";
|
|
5185
|
+
var POLL_INTERVAL_MS = 3e3;
|
|
5186
|
+
var POLL_TIMEOUT_MS = 11 * 60 * 1e3;
|
|
5187
|
+
async function runStudyJoin(ctx) {
|
|
5188
|
+
const report = (outcome) => ctx.onOutcome?.(outcome);
|
|
5189
|
+
const stdin = ctx.stdin ?? process.stdin;
|
|
5190
|
+
const stdout = ctx.stdout ?? process.stdout;
|
|
5191
|
+
const stderr = ctx.stderr ?? process.stderr;
|
|
5192
|
+
const print = (line) => stdout.write(`${line}
|
|
5193
|
+
`);
|
|
5194
|
+
if (!stdin.isTTY || !stdout.isTTY) {
|
|
5195
|
+
stderr.write("join needs an interactive terminal (stdin and stdout). Run it directly, not from a script or a pipe.\n");
|
|
5196
|
+
report({ status: "no_terminal", granted: [] });
|
|
5197
|
+
return 0;
|
|
4557
5198
|
}
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
var DIRECTION_WORDS = {
|
|
4563
|
-
up: "Expected to rise",
|
|
4564
|
-
down: "Expected to fall",
|
|
4565
|
-
none_declared: "No direction declared"
|
|
4566
|
-
};
|
|
4567
|
-
var DIRECTION_UNKNOWN = "A direction this app does not recognise";
|
|
4568
|
-
async function initiativesStatusLines(ctx) {
|
|
4569
|
-
const heading = "Changes your organisation has published to you";
|
|
4570
|
-
if (!ctx.eventWriteToken) {
|
|
4571
|
-
return [heading, " Not checked: this install holds no token, so nothing was fetched."];
|
|
5199
|
+
if (!ctx.joinCode) {
|
|
5200
|
+
stderr.write("Usage: join <code>\n");
|
|
5201
|
+
report({ status: "failed", granted: [], message: "No join code given." });
|
|
5202
|
+
return 1;
|
|
4572
5203
|
}
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
5204
|
+
let start;
|
|
5205
|
+
try {
|
|
5206
|
+
start = await (0, http_1.startStudyJoin)(ctx.apiBaseUrl, ctx.eventWriteToken, ctx.joinCode, STUDY_JOIN_MODE);
|
|
5207
|
+
} catch (error) {
|
|
5208
|
+
stderr.write(`${describeStartError(error)}
|
|
5209
|
+
`);
|
|
5210
|
+
report({ status: "failed", granted: [], message: describeStartError(error) });
|
|
5211
|
+
return 1;
|
|
4579
5212
|
}
|
|
4580
|
-
|
|
4581
|
-
|
|
5213
|
+
print("");
|
|
5214
|
+
print(`${start.organisationName}: ${describeStudyKind(start.studyKind)}`);
|
|
5215
|
+
print(formatWindow(start.windowStartUtc, start.windowEndUtc));
|
|
5216
|
+
print("");
|
|
5217
|
+
print("Report (30 days) grants:");
|
|
5218
|
+
for (const grant of start.grants)
|
|
5219
|
+
print(` ${describeStudyGrant(grant)}`);
|
|
5220
|
+
const gitOffer = gitOfferLine(start.optionalImportStores);
|
|
5221
|
+
if (gitOffer)
|
|
5222
|
+
print(gitOffer);
|
|
5223
|
+
print("");
|
|
5224
|
+
print("Study mode needs the Ascenda app. Open the app to join that way instead.");
|
|
5225
|
+
print("");
|
|
5226
|
+
print("Join in:");
|
|
5227
|
+
print(" 1) Report (30 days)");
|
|
5228
|
+
print(" 2) Not now");
|
|
5229
|
+
print("");
|
|
5230
|
+
const answer = await askChoice(stdin, stdout);
|
|
5231
|
+
if (!/^(1|report)$/i.test(answer)) {
|
|
5232
|
+
print("Not now.");
|
|
5233
|
+
report({ status: "not_now", start, granted: [] });
|
|
5234
|
+
return 0;
|
|
5235
|
+
}
|
|
5236
|
+
print("");
|
|
5237
|
+
const confirmUrl = (0, confirmLinks_1.studyJoinConfirmUrl)(ctx.apiBaseUrl, start.deviceCode);
|
|
5238
|
+
if (confirmUrl) {
|
|
5239
|
+
print(`Open this link to confirm: ${confirmUrl}`);
|
|
5240
|
+
print(`Or confirm in the Ascenda app with code ${start.deviceCode}.`);
|
|
5241
|
+
} else {
|
|
5242
|
+
print(`Confirm in the Ascenda app with code ${start.deviceCode}`);
|
|
4582
5243
|
}
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
5244
|
+
print(`Waiting for confirmation (expires ${formatLocalTime(start.expiresAt)})...`);
|
|
5245
|
+
const pollIntervalMs = ctx.pollIntervalMs ?? POLL_INTERVAL_MS;
|
|
5246
|
+
const deadline = Math.min(Date.parse(start.expiresAt) || Date.now() + POLL_TIMEOUT_MS, Date.now() + POLL_TIMEOUT_MS);
|
|
5247
|
+
while (Date.now() < deadline) {
|
|
5248
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
5249
|
+
let poll;
|
|
5250
|
+
try {
|
|
5251
|
+
poll = await (0, http_1.getStudyJoinStatus)(ctx.apiBaseUrl, ctx.eventWriteToken, start.joinSessionId);
|
|
5252
|
+
} catch (error) {
|
|
5253
|
+
if (isRetryablePollError(error))
|
|
5254
|
+
continue;
|
|
5255
|
+
stderr.write(`${describeStartError(error)}
|
|
5256
|
+
`);
|
|
5257
|
+
report({ status: "failed", start, granted: [], message: describeStartError(error) });
|
|
5258
|
+
return 1;
|
|
5259
|
+
}
|
|
5260
|
+
if (poll.status === "pending")
|
|
4594
5261
|
continue;
|
|
5262
|
+
if (poll.status === "confirmed") {
|
|
5263
|
+
const granted = poll.granted ?? [];
|
|
5264
|
+
if (granted.length === 0) {
|
|
5265
|
+
print("");
|
|
5266
|
+
print("Nothing was granted. Run join again, or check with your organisation.");
|
|
5267
|
+
report({ status: "refused", start, granted: [], message: "Nothing was granted." });
|
|
5268
|
+
return 1;
|
|
5269
|
+
}
|
|
5270
|
+
print("");
|
|
5271
|
+
print("Joined. Granted:");
|
|
5272
|
+
for (const grant of granted)
|
|
5273
|
+
print(` ${describeStudyGrant(grant)}`);
|
|
5274
|
+
print("");
|
|
5275
|
+
print("Each of these can be turned off separately, in the app's consent settings.");
|
|
5276
|
+
print("The organisation sees group counts, never who joined.");
|
|
5277
|
+
report({ status: "joined", start, granted, importStores: poll.importStores ?? null });
|
|
5278
|
+
return 0;
|
|
4595
5279
|
}
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
5280
|
+
if (poll.status === "expired") {
|
|
5281
|
+
print("");
|
|
5282
|
+
print("This code expired before it was confirmed. Run join again for a fresh code.");
|
|
5283
|
+
report({ status: "expired", start, granted: [] });
|
|
5284
|
+
return 1;
|
|
5285
|
+
}
|
|
5286
|
+
if (poll.refusedReason === "grant_failed") {
|
|
5287
|
+
print("");
|
|
5288
|
+
print("Join failed partway through. Some grants may not have gone through.");
|
|
5289
|
+
const granted = poll.granted ?? [];
|
|
5290
|
+
if (granted.length > 0) {
|
|
5291
|
+
print("");
|
|
5292
|
+
print("Granted before the failure:");
|
|
5293
|
+
for (const grant of granted)
|
|
5294
|
+
print(` ${describeStudyGrant(grant)}`);
|
|
5295
|
+
print("");
|
|
5296
|
+
print("Each of these can be turned off separately, in the app's consent settings.");
|
|
5297
|
+
}
|
|
5298
|
+
print("Run join again, or check with your organisation.");
|
|
5299
|
+
report({ status: "refused", start, granted, refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason), importStores: poll.importStores ?? null });
|
|
5300
|
+
return 1;
|
|
5301
|
+
}
|
|
5302
|
+
print("");
|
|
5303
|
+
print(describeRefusal(poll.refusedReason));
|
|
5304
|
+
report({ status: "refused", start, granted: [], refusedReason: poll.refusedReason, message: describeRefusal(poll.refusedReason) });
|
|
5305
|
+
return 1;
|
|
4600
5306
|
}
|
|
4601
|
-
|
|
5307
|
+
print("");
|
|
5308
|
+
print("Timed out waiting for confirmation. Run join again for a fresh code.");
|
|
5309
|
+
report({ status: "expired", start, granted: [] });
|
|
5310
|
+
return 1;
|
|
4602
5311
|
}
|
|
4603
|
-
function
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
for (const line of initiative.summaryForCohort.split(/\r?\n/))
|
|
4608
|
-
lines.push(` ${line}`);
|
|
4609
|
-
}
|
|
4610
|
-
if (initiative.direction)
|
|
4611
|
-
lines.push(` ${DIRECTION_WORDS[initiative.direction] ?? DIRECTION_UNKNOWN}`);
|
|
4612
|
-
lines.push(` Scoring window: ${formatWindowOrRaw(initiative.scoringStartUtc, initiative.scoringEndUtc)}`);
|
|
4613
|
-
if (initiative.result)
|
|
4614
|
-
lines.push(...renderResult(initiative.result, initiative.measureUnit, copy));
|
|
4615
|
-
lines.push("");
|
|
4616
|
-
return lines;
|
|
5312
|
+
function isRetryablePollError(error) {
|
|
5313
|
+
if (error instanceof http_1.AscendaApiError)
|
|
5314
|
+
return error.status >= 500 && error.status <= 599;
|
|
5315
|
+
return true;
|
|
4617
5316
|
}
|
|
4618
|
-
function
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
5317
|
+
function askChoice(stdin, stdout) {
|
|
5318
|
+
return new Promise((resolve) => {
|
|
5319
|
+
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
5320
|
+
let settled = false;
|
|
5321
|
+
const finish = (value) => {
|
|
5322
|
+
if (settled)
|
|
5323
|
+
return;
|
|
5324
|
+
settled = true;
|
|
5325
|
+
rl.close();
|
|
5326
|
+
resolve(value.trim());
|
|
5327
|
+
};
|
|
5328
|
+
rl.question("Choice [Not now]: ", finish);
|
|
5329
|
+
rl.once("close", () => finish(""));
|
|
5330
|
+
});
|
|
4629
5331
|
}
|
|
4630
|
-
function
|
|
4631
|
-
const
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
lines.push(` ${why ? `Withheld: ${why}.` : WITHHELD_UNKNOWN}`);
|
|
4636
|
-
return lines;
|
|
4637
|
-
}
|
|
4638
|
-
lines.push(` Result: ${show(result.value)}`);
|
|
4639
|
-
lines.push(` ${movementLine(result)}`);
|
|
4640
|
-
lines.push(` ${result.outcome ? copy.outcomes[result.outcome] ?? OUTCOME_UNKNOWN : OUTCOME_EMPTY}`);
|
|
4641
|
-
return lines;
|
|
5332
|
+
function formatLocalTime(iso) {
|
|
5333
|
+
const date = new Date(iso);
|
|
5334
|
+
if (Number.isNaN(date.getTime()))
|
|
5335
|
+
return iso;
|
|
5336
|
+
return new Intl.DateTimeFormat(void 0, { day: "numeric", month: "short", hour: "numeric", minute: "2-digit" }).format(date);
|
|
4642
5337
|
}
|
|
4643
|
-
function
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
return "No change against frozen baseline";
|
|
5338
|
+
function formatWindow(startUtc, endUtc) {
|
|
5339
|
+
const start = new Date(startUtc);
|
|
5340
|
+
const end = new Date(endUtc);
|
|
5341
|
+
const sameYear = start.getUTCFullYear() === end.getUTCFullYear();
|
|
5342
|
+
const dayMonth = { day: "numeric", month: "short", timeZone: "UTC" };
|
|
5343
|
+
const withYear = { ...dayMonth, year: "numeric" };
|
|
5344
|
+
const startFmt = new Intl.DateTimeFormat("en-GB", sameYear ? dayMonth : withYear);
|
|
5345
|
+
const endFmt = new Intl.DateTimeFormat("en-GB", withYear);
|
|
5346
|
+
return `${startFmt.format(start)} \u2013 ${endFmt.format(end)}`;
|
|
4653
5347
|
}
|
|
4654
|
-
|
|
4655
|
-
|
|
5348
|
+
var GRANT_SENTENCES = {
|
|
5349
|
+
501: "AI assistant data processing consent",
|
|
5350
|
+
507: "Import of the AI-work history already on your machine"
|
|
5351
|
+
};
|
|
5352
|
+
function describeStudyGrant(grant) {
|
|
5353
|
+
return GRANT_SENTENCES[grant.code] ?? humanise(grant.name);
|
|
4656
5354
|
}
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
return {
|
|
4664
|
-
id: typeof o.id === "string" ? o.id : "",
|
|
4665
|
-
organisationName: typeof o.organisationName === "string" ? o.organisationName : "Your organisation",
|
|
4666
|
-
title: o.title,
|
|
4667
|
-
summaryForCohort: typeof o.summaryForCohort === "string" ? o.summaryForCohort : "",
|
|
4668
|
-
measureUnit: typeof o.measureUnit === "string" ? o.measureUnit : null,
|
|
4669
|
-
scoringStartUtc: typeof o.scoringStartUtc === "string" ? o.scoringStartUtc : "",
|
|
4670
|
-
scoringEndUtc: typeof o.scoringEndUtc === "string" ? o.scoringEndUtc : "",
|
|
4671
|
-
withdrawnUtc: typeof o.withdrawnUtc === "string" ? o.withdrawnUtc : null,
|
|
4672
|
-
status: o.status,
|
|
4673
|
-
direction: typeof o.direction === "string" ? o.direction : null,
|
|
4674
|
-
result: asResult(o.result)
|
|
4675
|
-
};
|
|
5355
|
+
var STUDY_KIND_SENTENCES = {
|
|
5356
|
+
Report30: "a 30-day report",
|
|
5357
|
+
Study90: "a 90-day study"
|
|
5358
|
+
};
|
|
5359
|
+
function describeStudyKind(studyKind) {
|
|
5360
|
+
return STUDY_KIND_SENTENCES[studyKind] ?? humanise(studyKind);
|
|
4676
5361
|
}
|
|
4677
|
-
function
|
|
4678
|
-
|
|
4679
|
-
return null;
|
|
4680
|
-
const r = value;
|
|
4681
|
-
const num = (x) => typeof x === "number" && Number.isFinite(x) ? x : null;
|
|
4682
|
-
return {
|
|
4683
|
-
scoredAtUtc: typeof r.scoredAtUtc === "string" ? r.scoredAtUtc : "",
|
|
4684
|
-
value: num(r.value),
|
|
4685
|
-
baselineValue: num(r.baselineValue),
|
|
4686
|
-
delta: num(r.delta),
|
|
4687
|
-
movement: typeof r.movement === "string" ? r.movement : null,
|
|
4688
|
-
outcome: typeof r.outcome === "string" ? r.outcome : "",
|
|
4689
|
-
withheldReason: typeof r.withheldReason === "string" ? r.withheldReason : null,
|
|
4690
|
-
basis: typeof r.basis === "string" ? r.basis : null
|
|
4691
|
-
};
|
|
5362
|
+
function humanise(name) {
|
|
5363
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim() || name;
|
|
4692
5364
|
}
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
5365
|
+
var REFUSED_REASON_MESSAGES = {
|
|
5366
|
+
study_no_longer_live: "That study is no longer open to join.",
|
|
5367
|
+
withdrawn: "You're no longer an active participant in that study.",
|
|
5368
|
+
// Handled as its own branch above, with its granted list, before this
|
|
5369
|
+
// table is ever consulted — present so the type stays exhaustive, and as
|
|
5370
|
+
// a plain fallback should something call this function with it directly.
|
|
5371
|
+
grant_failed: "Join failed partway through. Some grants may not have gone through.",
|
|
5372
|
+
declined: "You declined the join. Nothing was granted.",
|
|
5373
|
+
not_enrolled: "That study couldn't enrol you, so nothing was granted."
|
|
5374
|
+
};
|
|
5375
|
+
function describeRefusal(refusedReason) {
|
|
5376
|
+
if (refusedReason && REFUSED_REASON_MESSAGES[refusedReason])
|
|
5377
|
+
return REFUSED_REASON_MESSAGES[refusedReason];
|
|
5378
|
+
return "The join didn't go through. Nothing new was granted.";
|
|
4697
5379
|
}
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
5380
|
+
var START_ERROR_MESSAGES = {
|
|
5381
|
+
join_code_not_found: "That code is not a study anyone can join. Check it and try again.",
|
|
5382
|
+
unknown_mode: "This tool only offers Report mode from the command line.",
|
|
5383
|
+
no_live_study: "There's nothing open to join with that code right now.",
|
|
5384
|
+
too_many_open_sessions: "This tool has too many joins waiting to be confirmed. Confirm one, or let one expire, then try again.",
|
|
5385
|
+
unknown_session: "That join can no longer be found. Run join again for a fresh code."
|
|
5386
|
+
};
|
|
5387
|
+
function describeStartError(error) {
|
|
5388
|
+
if (error instanceof http_1.AscendaApiError) {
|
|
5389
|
+
if (error.errorCode && START_ERROR_MESSAGES[error.errorCode])
|
|
5390
|
+
return START_ERROR_MESSAGES[error.errorCode];
|
|
5391
|
+
if (error.status === 401)
|
|
5392
|
+
return "This tool's pairing was rejected. Re-pair it, then try again.";
|
|
5393
|
+
return `Could not reach the join code (HTTP ${error.status}).`;
|
|
5394
|
+
}
|
|
5395
|
+
return error instanceof Error ? error.message : String(error);
|
|
4703
5396
|
}
|
|
4704
5397
|
}
|
|
4705
5398
|
});
|
|
4706
5399
|
|
|
4707
|
-
// ../packages/tool-kit/out/
|
|
4708
|
-
var
|
|
4709
|
-
"../packages/tool-kit/out/
|
|
5400
|
+
// ../packages/tool-kit/out/pairingStudyJoin.js
|
|
5401
|
+
var require_pairingStudyJoin = __commonJS({
|
|
5402
|
+
"../packages/tool-kit/out/pairingStudyJoin.js"(exports) {
|
|
4710
5403
|
"use strict";
|
|
4711
5404
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4712
5405
|
if (k2 === void 0) k2 = k;
|
|
@@ -4746,252 +5439,312 @@ var require_hookRunner = __commonJS({
|
|
|
4746
5439
|
};
|
|
4747
5440
|
}();
|
|
4748
5441
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4749
|
-
exports.
|
|
4750
|
-
exports.
|
|
4751
|
-
exports.
|
|
4752
|
-
exports.
|
|
4753
|
-
exports.
|
|
4754
|
-
exports.
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
exports.
|
|
4760
|
-
exports.
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
var
|
|
4767
|
-
function
|
|
4768
|
-
const
|
|
4769
|
-
|
|
5442
|
+
exports.PAIR_JOIN_OUTCOME_FILE_ENV = exports.PAIR_ORG_JOIN_CODE_ENV = void 0;
|
|
5443
|
+
exports.createPairingAttempt = createPairingAttempt;
|
|
5444
|
+
exports.pairingAttemptLines = pairingAttemptLines;
|
|
5445
|
+
exports.settleStudyJoin = settleStudyJoin;
|
|
5446
|
+
exports.writePairingJoinOutcome = writePairingJoinOutcome;
|
|
5447
|
+
exports.pairingJoinOutcome = pairingJoinOutcome;
|
|
5448
|
+
var fs = __importStar(__require("node:fs"));
|
|
5449
|
+
var confirmLinks_1 = require_confirmLinks();
|
|
5450
|
+
var studyJoin_1 = require_studyJoin();
|
|
5451
|
+
var http_1 = require_http();
|
|
5452
|
+
exports.PAIR_ORG_JOIN_CODE_ENV = "ASCENDA_PAIR_ORG_JOIN_CODE";
|
|
5453
|
+
exports.PAIR_JOIN_OUTCOME_FILE_ENV = "ASCENDA_PAIR_JOIN_OUTCOME_FILE";
|
|
5454
|
+
var CREATE_REFUSALS = {
|
|
5455
|
+
join_code_not_found: "That code is not a study anyone can join. Check it and try again.",
|
|
5456
|
+
no_live_study: "There's nothing open to join with that code right now.",
|
|
5457
|
+
unknown_mode: "This tool only offers Report mode from the command line."
|
|
5458
|
+
};
|
|
5459
|
+
var JOIN_SETTLE_MS = 6e4;
|
|
5460
|
+
async function createPairingAttempt(apiBaseUrl, toolInstallationId, toolType, displayName, env = process.env) {
|
|
5461
|
+
const orgJoinCode = env[exports.PAIR_ORG_JOIN_CODE_ENV]?.trim();
|
|
5462
|
+
if (!orgJoinCode)
|
|
5463
|
+
return { session: await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName), carriesJoin: false };
|
|
5464
|
+
let refusal;
|
|
5465
|
+
try {
|
|
5466
|
+
const session = await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName, orgJoinCode);
|
|
5467
|
+
return { session, carriesJoin: session.studyJoin !== void 0 };
|
|
5468
|
+
} catch (error) {
|
|
5469
|
+
if (!(error instanceof http_1.AscendaApiError) || error.status >= 500)
|
|
5470
|
+
throw error;
|
|
5471
|
+
refusal = error.errorCode ? CREATE_REFUSALS[error.errorCode] : void 0;
|
|
5472
|
+
}
|
|
5473
|
+
return { session: await (0, http_1.createPairingSession)(apiBaseUrl, toolInstallationId, toolType, displayName), carriesJoin: false, refusal };
|
|
4770
5474
|
}
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
const
|
|
5475
|
+
function pairingAttemptLines(attempt) {
|
|
5476
|
+
const { session } = attempt;
|
|
5477
|
+
const join = attempt.carriesJoin ? session.studyJoin : void 0;
|
|
5478
|
+
if (!join)
|
|
5479
|
+
return (0, confirmLinks_1.pairingConfirmLines)(session.qrUrl, session.code);
|
|
5480
|
+
const gitOffer = (0, studyJoin_1.gitOfferLine)(join.optionalImportStores);
|
|
4774
5481
|
return [
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
'dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) || exit 0',
|
|
4780
|
-
`bundle="$dir/${binaryName}.mjs"`,
|
|
4781
|
-
`record="$dir/${binaryName}.node"`,
|
|
4782
|
-
`missing="$dir/${binaryName}.no-node"`,
|
|
4783
|
-
"",
|
|
4784
|
-
'runs() { [ -n "$1" ] && [ -f "$1" ] && [ -x "$1" ]; }',
|
|
4785
|
-
"",
|
|
4786
|
-
"# The hook bundle needs Node 20 or newer. Checked only while searching, so",
|
|
4787
|
-
"# the recorded path costs nothing to reuse.",
|
|
4788
|
-
"recent() {",
|
|
4789
|
-
` runs "$1" && "$1" -e 'process.exit(parseInt(process.versions.node, 10) >= 20 ? 0 : 1)' >/dev/null 2>&1`,
|
|
4790
|
-
"}",
|
|
4791
|
-
"",
|
|
4792
|
-
"newest_nvm() {",
|
|
4793
|
-
' [ -d "$HOME/.nvm/versions/node" ] || return 0',
|
|
4794
|
-
` ls "$HOME/.nvm/versions/node" 2>/dev/null | sed 's/^v//' | sort -t. -k1,1n -k2,2n -k3,3n | tail -n 1 | sed 's/^/v/'`,
|
|
4795
|
-
"}",
|
|
4796
|
-
"",
|
|
4797
|
-
'node=""',
|
|
4798
|
-
"how=recorded",
|
|
4799
|
-
'[ -r "$record" ] && IFS= read -r node < "$record"',
|
|
4800
|
-
"",
|
|
4801
|
-
'if ! runs "$node"; then',
|
|
4802
|
-
' node=""',
|
|
4803
|
-
" how=found",
|
|
4804
|
-
' nvm_default=""',
|
|
4805
|
-
' if [ -r "$HOME/.nvm/alias/default" ]; then',
|
|
4806
|
-
' IFS= read -r wanted < "$HOME/.nvm/alias/default"',
|
|
4807
|
-
" wanted=${wanted#v}",
|
|
4808
|
-
' for candidate in "$HOME/.nvm/versions/node/v$wanted"*; do',
|
|
4809
|
-
' [ -x "$candidate/bin/node" ] && nvm_default="$candidate/bin/node"',
|
|
4810
|
-
" done",
|
|
4811
|
-
" fi",
|
|
4812
|
-
" nvm_newest=$(newest_nvm)",
|
|
4813
|
-
" for candidate in \\",
|
|
4814
|
-
' "$(command -v node 2>/dev/null)" \\',
|
|
4815
|
-
" /opt/homebrew/bin/node \\",
|
|
4816
|
-
" /usr/local/bin/node \\",
|
|
4817
|
-
' "$HOME/.volta/bin/node" \\',
|
|
4818
|
-
' "$nvm_default" \\',
|
|
4819
|
-
' "$HOME/.local/share/fnm/aliases/default/bin/node" \\',
|
|
4820
|
-
' "$HOME/Library/Application Support/fnm/aliases/default/bin/node" \\',
|
|
4821
|
-
' "$HOME/.asdf/shims/node" \\',
|
|
4822
|
-
' "$HOME/.local/share/mise/shims/node" \\',
|
|
4823
|
-
' "$HOME/.nvm/versions/node/$nvm_newest/bin/node"',
|
|
4824
|
-
" do",
|
|
4825
|
-
' if recent "$candidate"; then node=$candidate; break; fi',
|
|
4826
|
-
" done",
|
|
4827
|
-
' if [ -n "$node" ]; then',
|
|
4828
|
-
` printf '%s\\n' "$node" > "$record.$$" 2>/dev/null && mv -f "$record.$$" "$record" 2>/dev/null`,
|
|
4829
|
-
' rm -f "$missing" 2>/dev/null',
|
|
4830
|
-
" fi",
|
|
4831
|
-
"fi",
|
|
4832
|
-
"",
|
|
4833
|
-
'if [ -n "$ASCENDA_HOOK_LAUNCHER_PROBE" ]; then',
|
|
4834
|
-
' [ -n "$node" ] || { echo "no Node 20 or newer found on PATH or in the usual install locations" >&2; exit 1; }',
|
|
4835
|
-
` printf '%s\\t%s\\n' "$node" "$how"`,
|
|
4836
|
-
" exit 0",
|
|
4837
|
-
"fi",
|
|
4838
|
-
"",
|
|
4839
|
-
'if [ -z "$node" ]; then',
|
|
4840
|
-
' date -u +%Y-%m-%dT%H:%M:%SZ > "$missing" 2>/dev/null',
|
|
4841
|
-
' case "$1" in',
|
|
4842
|
-
...loudEvent ? [
|
|
4843
|
-
` ${loudEvent})`,
|
|
4844
|
-
" cat >/dev/null 2>&1",
|
|
4845
|
-
` echo "Ascenda hooks cannot find Node 20 or newer, so none of them are running. Install Node, then run: ${setupCommand}" >&2`,
|
|
4846
|
-
" exit 1 ;;"
|
|
4847
|
-
] : [],
|
|
4848
|
-
` ${LAUNCHER_MANAGEMENT_COMMANDS.join("|")})`,
|
|
4849
|
-
` echo "${binaryName}: no Node 20 or newer found on PATH or in the usual install locations." >&2`,
|
|
4850
|
-
" exit 1 ;;",
|
|
4851
|
-
" *)",
|
|
4852
|
-
" # A hook: say nothing per tool call. status and doctor read the",
|
|
4853
|
-
" # file written above.",
|
|
4854
|
-
" cat >/dev/null 2>&1",
|
|
4855
|
-
" exit 0 ;;",
|
|
4856
|
-
" esac",
|
|
4857
|
-
"fi",
|
|
4858
|
-
"",
|
|
4859
|
-
'exec "$node" "$bundle" "$@"',
|
|
4860
|
-
""
|
|
4861
|
-
].join("\n");
|
|
5482
|
+
`This also joins ${join.organisationName} (${(0, studyJoin_1.formatWindow)(join.windowStartUtc, join.windowEndUtc)}). The page shows what you'd share before you confirm.`,
|
|
5483
|
+
...gitOffer ? [gitOffer] : [],
|
|
5484
|
+
`Open this link to confirm: ${session.qrUrl}`
|
|
5485
|
+
];
|
|
4862
5486
|
}
|
|
4863
|
-
function
|
|
4864
|
-
|
|
4865
|
-
|
|
5487
|
+
async function settleStudyJoin(apiBaseUrl, pairingSessionId, last, wait = 1e3) {
|
|
5488
|
+
let current = last;
|
|
5489
|
+
const deadline = Date.now() + JOIN_SETTLE_MS;
|
|
5490
|
+
while (current && current.status === "pending" && Date.now() < deadline) {
|
|
5491
|
+
await new Promise((resolve) => setTimeout(resolve, wait));
|
|
5492
|
+
let status;
|
|
5493
|
+
try {
|
|
5494
|
+
status = await (0, http_1.getPairingStatus)(apiBaseUrl, pairingSessionId);
|
|
5495
|
+
} catch {
|
|
5496
|
+
continue;
|
|
5497
|
+
}
|
|
5498
|
+
current = status.studyJoin ?? current;
|
|
5499
|
+
}
|
|
5500
|
+
return current;
|
|
4866
5501
|
}
|
|
4867
|
-
function
|
|
4868
|
-
const
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
5502
|
+
function writePairingJoinOutcome(outcome, env = process.env) {
|
|
5503
|
+
const file = env[exports.PAIR_JOIN_OUTCOME_FILE_ENV]?.trim();
|
|
5504
|
+
if (!file)
|
|
5505
|
+
return;
|
|
5506
|
+
try {
|
|
5507
|
+
fs.writeFileSync(file, `${JSON.stringify(outcome)}
|
|
5508
|
+
`, { mode: 384 });
|
|
5509
|
+
} catch {
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
5512
|
+
function pairingJoinOutcome(attempt, pairing, studyJoin) {
|
|
5513
|
+
if (!attempt)
|
|
5514
|
+
return { join: "none", pairing };
|
|
5515
|
+
if (attempt.refusal)
|
|
5516
|
+
return { join: "refused", pairing, message: attempt.refusal };
|
|
5517
|
+
return { join: attempt.carriesJoin ? "carried" : "not_carried", pairing, studyJoin };
|
|
5518
|
+
}
|
|
5519
|
+
}
|
|
5520
|
+
});
|
|
5521
|
+
|
|
5522
|
+
// ../packages/tool-kit/out/hookSet.js
|
|
5523
|
+
var require_hookSet = __commonJS({
|
|
5524
|
+
"../packages/tool-kit/out/hookSet.js"(exports) {
|
|
5525
|
+
"use strict";
|
|
5526
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5527
|
+
exports.UNVERSIONED_HOOK_SET = exports.HOOK_SET_FLAG = void 0;
|
|
5528
|
+
exports.hookSetArgument = hookSetArgument;
|
|
5529
|
+
exports.readHookSet = readHookSet;
|
|
5530
|
+
exports.isHookSet = isHookSet;
|
|
5531
|
+
exports.readViaPlugin = readViaPlugin;
|
|
5532
|
+
exports.hookSetOfCommand = hookSetOfCommand;
|
|
5533
|
+
exports.hookSetChanges = hookSetChanges;
|
|
5534
|
+
exports.describeHookSetChanges = describeHookSetChanges;
|
|
5535
|
+
exports.HOOK_SET_FLAG = "--hook-set";
|
|
5536
|
+
exports.UNVERSIONED_HOOK_SET = 1;
|
|
5537
|
+
function hookSetArgument(hookSet) {
|
|
5538
|
+
return hookSet === void 0 ? "" : ` ${exports.HOOK_SET_FLAG} ${hookSet}`;
|
|
5539
|
+
}
|
|
5540
|
+
function readHookSet(argv) {
|
|
5541
|
+
const index = argv.indexOf(exports.HOOK_SET_FLAG);
|
|
5542
|
+
if (index === -1)
|
|
5543
|
+
return void 0;
|
|
5544
|
+
const raw = argv[index + 1];
|
|
5545
|
+
if (raw === void 0 || !/^[1-9]\d*$/.test(raw))
|
|
5546
|
+
return void 0;
|
|
5547
|
+
const value = Number(raw);
|
|
5548
|
+
return isHookSet(value) ? value : void 0;
|
|
5549
|
+
}
|
|
5550
|
+
function isHookSet(value) {
|
|
5551
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
|
|
5552
|
+
}
|
|
5553
|
+
function readViaPlugin(env) {
|
|
5554
|
+
return env.CLAUDE_PLUGIN_ROOT ? true : void 0;
|
|
5555
|
+
}
|
|
5556
|
+
function hookSetOfCommand(command) {
|
|
5557
|
+
const match = command.match(/--hook-set\s+(\d+)/);
|
|
5558
|
+
return match ? Number(match[1]) : exports.UNVERSIONED_HOOK_SET;
|
|
5559
|
+
}
|
|
5560
|
+
function hookSetChanges(before, events) {
|
|
5561
|
+
const added = events.filter((event) => !before.has(event));
|
|
5562
|
+
const sets = [...before.values()];
|
|
5563
|
+
return sets.length ? { added, previousSet: Math.min(...sets) } : { added };
|
|
5564
|
+
}
|
|
5565
|
+
function describeHookSetChanges(changes, hookSet) {
|
|
5566
|
+
if (changes.previousSet === void 0)
|
|
5567
|
+
return void 0;
|
|
5568
|
+
const parts = [];
|
|
5569
|
+
if (changes.added.length)
|
|
5570
|
+
parts.push(`added ${changes.added.join(", ")}`);
|
|
5571
|
+
if (changes.previousSet < hookSet)
|
|
5572
|
+
parts.push(`hook set ${changes.previousSet} \u2192 ${hookSet}`);
|
|
5573
|
+
return parts.length ? `upgraded: ${parts.join("; ")}` : void 0;
|
|
5574
|
+
}
|
|
5575
|
+
}
|
|
5576
|
+
});
|
|
5577
|
+
|
|
5578
|
+
// ../packages/tool-kit/out/initiatives.js
|
|
5579
|
+
var require_initiatives = __commonJS({
|
|
5580
|
+
"../packages/tool-kit/out/initiatives.js"(exports) {
|
|
5581
|
+
"use strict";
|
|
5582
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5583
|
+
exports.INITIATIVE_COPY = void 0;
|
|
5584
|
+
exports.initiativesStatusLines = initiativesStatusLines;
|
|
5585
|
+
exports.renderInitiatives = renderInitiatives;
|
|
5586
|
+
var http_1 = require_http();
|
|
5587
|
+
var studyJoin_1 = require_studyJoin();
|
|
5588
|
+
var READ_TIMEOUT_MS = 5e3;
|
|
5589
|
+
exports.INITIATIVE_COPY = {
|
|
5590
|
+
outcomes: {
|
|
5591
|
+
moved_as_declared: "Moved the way declared, beyond the cohort's own variation",
|
|
5592
|
+
moved_against_declared: "Moved the other way, beyond the cohort's own variation",
|
|
5593
|
+
moved_no_direction_declared: "Moved beyond the cohort's own variation; no direction was declared",
|
|
5594
|
+
within_own_variation: "No further from the baseline than the cohort's own week-to-week variation",
|
|
5595
|
+
withheld: "Withheld"
|
|
5596
|
+
},
|
|
5597
|
+
withheldReasons: {
|
|
5598
|
+
cohort_below_minimum: "the cohort was too small to report on when the scoring window closed",
|
|
5599
|
+
below_minimum_cohort: "the cohort was too small to report on when the scoring window closed",
|
|
5600
|
+
below_minimum_cohort_size: "the cohort was too small to report on when the scoring window closed",
|
|
5601
|
+
baseline_withheld: "the baseline was withheld"
|
|
4875
5602
|
}
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
5603
|
+
};
|
|
5604
|
+
var OUTCOME_EMPTY = "Not stated";
|
|
5605
|
+
var OUTCOME_UNKNOWN = "An outcome this app does not recognise";
|
|
5606
|
+
var WITHHELD_UNKNOWN = "Withheld, for a reason this version of the app doesn't name yet.";
|
|
5607
|
+
var DIRECTION_WORDS = {
|
|
5608
|
+
up: "Expected to rise",
|
|
5609
|
+
down: "Expected to fall",
|
|
5610
|
+
none_declared: "No direction declared"
|
|
5611
|
+
};
|
|
5612
|
+
var DIRECTION_UNKNOWN = "A direction this app does not recognise";
|
|
5613
|
+
async function initiativesStatusLines(ctx) {
|
|
5614
|
+
const heading = "Changes your organisation has published to you";
|
|
5615
|
+
if (!ctx.eventWriteToken) {
|
|
5616
|
+
return [heading, " Not checked: this install holds no token, so nothing was fetched."];
|
|
4883
5617
|
}
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
const incoming = options.version ?? collectorVersion_1.COLLECTOR_VERSION;
|
|
4891
|
-
const installed = readInstalledVersion(paths.version);
|
|
4892
|
-
const installedFile = process.platform === "win32" ? paths.launcher : paths.bundle;
|
|
4893
|
-
if (installed && fs.existsSync(installedFile) && isDowngrade(installed, incoming)) {
|
|
4894
|
-
options.onKeptNewer?.(installed, incoming);
|
|
4895
|
-
if (process.platform !== "win32" && !fs.existsSync(paths.launcher))
|
|
4896
|
-
writeAtomically(paths.launcher, hookLauncherScript(options), 493);
|
|
4897
|
-
return paths.launcher;
|
|
5618
|
+
const read = await (0, http_1.readInitiatives)(ctx.apiBaseUrl, ctx.eventWriteToken, AbortSignal.timeout(ctx.fetchTimeoutMs ?? READ_TIMEOUT_MS));
|
|
5619
|
+
if (read.kind === "rejected") {
|
|
5620
|
+
return [
|
|
5621
|
+
heading,
|
|
5622
|
+
` Couldn't check: the server turned this install's request down. If that keeps happening, pair again with \`${ctx.pairCommand}\`.`
|
|
5623
|
+
];
|
|
4898
5624
|
}
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
if (source !== path.resolve(paths.launcher))
|
|
4902
|
-
fs.copyFileSync(source, paths.launcher);
|
|
4903
|
-
writeAtomically(paths.version, `${incoming}
|
|
4904
|
-
`, 420);
|
|
4905
|
-
return paths.launcher;
|
|
5625
|
+
if (read.kind === "failed") {
|
|
5626
|
+
return [heading, ` Couldn't check: ${read.reason}. Run status again to retry.`];
|
|
4906
5627
|
}
|
|
4907
|
-
|
|
4908
|
-
writeAtomically(paths.bundle, fs.readFileSync(source), 493);
|
|
4909
|
-
writeAtomically(paths.launcher, hookLauncherScript(options), 493);
|
|
4910
|
-
writeAtomically(paths.record, `${process.execPath}
|
|
4911
|
-
`, 420);
|
|
4912
|
-
if (source !== path.resolve(paths.bundle))
|
|
4913
|
-
writeAtomically(paths.version, `${incoming}
|
|
4914
|
-
`, 420);
|
|
4915
|
-
fs.rmSync(paths.noNode, { force: true });
|
|
4916
|
-
return paths.launcher;
|
|
5628
|
+
return [heading, ...renderInitiatives(read.initiatives)];
|
|
4917
5629
|
}
|
|
4918
|
-
function
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
5630
|
+
function renderInitiatives(entries, copy = exports.INITIATIVE_COPY) {
|
|
5631
|
+
if (entries.length === 0)
|
|
5632
|
+
return [" None published to you."];
|
|
5633
|
+
const lines = [];
|
|
5634
|
+
let unreadable = 0;
|
|
5635
|
+
for (const entry of entries) {
|
|
5636
|
+
const initiative = asInitiative(entry);
|
|
5637
|
+
if (!initiative) {
|
|
5638
|
+
unreadable += 1;
|
|
4922
5639
|
continue;
|
|
4923
|
-
|
|
4924
|
-
|
|
5640
|
+
}
|
|
5641
|
+
lines.push(...renderOne(initiative, copy));
|
|
4925
5642
|
}
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
return
|
|
5643
|
+
if (unreadable > 0) {
|
|
5644
|
+
lines.push(` ${unreadable === 1 ? "1 entry" : `${unreadable} entries`} in the list couldn't be read by this version of the tool.`);
|
|
5645
|
+
}
|
|
5646
|
+
return lines;
|
|
4930
5647
|
}
|
|
4931
|
-
function
|
|
4932
|
-
const
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
5648
|
+
function renderOne(initiative, copy) {
|
|
5649
|
+
const lines = [` ${initiative.organisationName}: ${initiative.title}`];
|
|
5650
|
+
lines.push(` ${describeStatus(initiative)}`);
|
|
5651
|
+
if (initiative.summaryForCohort) {
|
|
5652
|
+
for (const line of initiative.summaryForCohort.split(/\r?\n/))
|
|
5653
|
+
lines.push(` ${line}`);
|
|
5654
|
+
}
|
|
5655
|
+
if (initiative.direction)
|
|
5656
|
+
lines.push(` ${DIRECTION_WORDS[initiative.direction] ?? DIRECTION_UNKNOWN}`);
|
|
5657
|
+
lines.push(` Scoring window: ${formatWindowOrRaw(initiative.scoringStartUtc, initiative.scoringEndUtc)}`);
|
|
5658
|
+
if (initiative.result)
|
|
5659
|
+
lines.push(...renderResult(initiative.result, initiative.measureUnit, copy));
|
|
5660
|
+
lines.push("");
|
|
5661
|
+
return lines;
|
|
4936
5662
|
}
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
5663
|
+
function describeStatus(initiative) {
|
|
5664
|
+
switch (initiative.status) {
|
|
5665
|
+
case "published":
|
|
5666
|
+
return "Published, not scored yet.";
|
|
5667
|
+
case "scored":
|
|
5668
|
+
return "Scored.";
|
|
5669
|
+
case "withdrawn":
|
|
5670
|
+
return initiative.withdrawnUtc ? `Withdrawn on ${formatDay(initiative.withdrawnUtc)}. It won't be scored.` : "Withdrawn. It won't be scored.";
|
|
5671
|
+
default:
|
|
5672
|
+
return "Status not recognised.";
|
|
5673
|
+
}
|
|
4940
5674
|
}
|
|
4941
|
-
function
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
const
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
fs.renameSync(tmp, file);
|
|
4949
|
-
} catch {
|
|
5675
|
+
function renderResult(result, unit, copy) {
|
|
5676
|
+
const lines = [];
|
|
5677
|
+
const show = (n) => unit ? `${figure(n)} ${unit}` : figure(n);
|
|
5678
|
+
if (result.value === null) {
|
|
5679
|
+
const why = copy.withheldReasons[result.withheldReason ?? ""];
|
|
5680
|
+
lines.push(` ${why ? `Withheld: ${why}.` : WITHHELD_UNKNOWN}`);
|
|
5681
|
+
return lines;
|
|
4950
5682
|
}
|
|
5683
|
+
lines.push(` Result: ${show(result.value)}`);
|
|
5684
|
+
lines.push(` ${movementLine(result)}`);
|
|
5685
|
+
lines.push(` ${result.outcome ? copy.outcomes[result.outcome] ?? OUTCOME_UNKNOWN : OUTCOME_EMPTY}`);
|
|
5686
|
+
return lines;
|
|
4951
5687
|
}
|
|
4952
|
-
function
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
5688
|
+
function movementLine(result) {
|
|
5689
|
+
if (result.outcome === "within_own_variation")
|
|
5690
|
+
return "No material change against frozen baseline";
|
|
5691
|
+
if (result.delta === null)
|
|
5692
|
+
return "No reading";
|
|
5693
|
+
if (result.delta > 0)
|
|
5694
|
+
return `Up ${figure(result.delta)} against frozen baseline`;
|
|
5695
|
+
if (result.delta < 0)
|
|
5696
|
+
return `Down ${figure(Math.abs(result.delta))} against frozen baseline`;
|
|
5697
|
+
return "No change against frozen baseline";
|
|
5698
|
+
}
|
|
5699
|
+
function figure(n) {
|
|
5700
|
+
return String(Number(n.toPrecision(12)));
|
|
5701
|
+
}
|
|
5702
|
+
function asInitiative(value) {
|
|
5703
|
+
if (!value || typeof value !== "object")
|
|
4959
5704
|
return void 0;
|
|
4960
|
-
|
|
5705
|
+
const o = value;
|
|
5706
|
+
if (typeof o.title !== "string" || typeof o.status !== "string")
|
|
5707
|
+
return void 0;
|
|
5708
|
+
return {
|
|
5709
|
+
id: typeof o.id === "string" ? o.id : "",
|
|
5710
|
+
organisationName: typeof o.organisationName === "string" ? o.organisationName : "Your organisation",
|
|
5711
|
+
title: o.title,
|
|
5712
|
+
summaryForCohort: typeof o.summaryForCohort === "string" ? o.summaryForCohort : "",
|
|
5713
|
+
measureUnit: typeof o.measureUnit === "string" ? o.measureUnit : null,
|
|
5714
|
+
scoringStartUtc: typeof o.scoringStartUtc === "string" ? o.scoringStartUtc : "",
|
|
5715
|
+
scoringEndUtc: typeof o.scoringEndUtc === "string" ? o.scoringEndUtc : "",
|
|
5716
|
+
withdrawnUtc: typeof o.withdrawnUtc === "string" ? o.withdrawnUtc : null,
|
|
5717
|
+
status: o.status,
|
|
5718
|
+
direction: typeof o.direction === "string" ? o.direction : null,
|
|
5719
|
+
result: asResult(o.result)
|
|
5720
|
+
};
|
|
4961
5721
|
}
|
|
4962
|
-
function
|
|
4963
|
-
if (!
|
|
4964
|
-
return
|
|
4965
|
-
const
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
5722
|
+
function asResult(value) {
|
|
5723
|
+
if (!value || typeof value !== "object")
|
|
5724
|
+
return null;
|
|
5725
|
+
const r = value;
|
|
5726
|
+
const num = (x) => typeof x === "number" && Number.isFinite(x) ? x : null;
|
|
5727
|
+
return {
|
|
5728
|
+
scoredAtUtc: typeof r.scoredAtUtc === "string" ? r.scoredAtUtc : "",
|
|
5729
|
+
value: num(r.value),
|
|
5730
|
+
baselineValue: num(r.baselineValue),
|
|
5731
|
+
delta: num(r.delta),
|
|
5732
|
+
movement: typeof r.movement === "string" ? r.movement : null,
|
|
5733
|
+
outcome: typeof r.outcome === "string" ? r.outcome : "",
|
|
5734
|
+
withheldReason: typeof r.withheldReason === "string" ? r.withheldReason : null,
|
|
5735
|
+
basis: typeof r.basis === "string" ? r.basis : null
|
|
5736
|
+
};
|
|
4975
5737
|
}
|
|
4976
|
-
function
|
|
4977
|
-
if (
|
|
4978
|
-
return
|
|
4979
|
-
|
|
4980
|
-
encoding: "utf8",
|
|
4981
|
-
timeout: 5e3,
|
|
4982
|
-
env: { HOME: process.env.HOME ?? "", PATH: "/usr/bin:/bin:/usr/sbin:/sbin", ASCENDA_HOOK_LAUNCHER_PROBE: "1" }
|
|
4983
|
-
});
|
|
4984
|
-
const [node, how] = (probe.stdout ?? "").trim().split(" ");
|
|
4985
|
-
if (probe.status !== 0 || !node) {
|
|
4986
|
-
return { problem: (probe.stderr ?? "").trim() || "the launcher found no Node it can run" };
|
|
4987
|
-
}
|
|
4988
|
-
const version = (0, child_process_1.spawnSync)(node, ["--version"], { encoding: "utf8", timeout: 5e3 });
|
|
4989
|
-
if (version.status !== 0)
|
|
4990
|
-
return { node, how, problem: `${node} did not run` };
|
|
4991
|
-
return { node, how, version: version.stdout.trim() };
|
|
5738
|
+
function formatWindowOrRaw(startUtc, endUtc) {
|
|
5739
|
+
if (Number.isNaN(Date.parse(startUtc)) || Number.isNaN(Date.parse(endUtc)))
|
|
5740
|
+
return "not given";
|
|
5741
|
+
return (0, studyJoin_1.formatWindow)(startUtc, endUtc);
|
|
4992
5742
|
}
|
|
4993
|
-
function
|
|
4994
|
-
|
|
5743
|
+
function formatDay(iso) {
|
|
5744
|
+
const date = new Date(iso);
|
|
5745
|
+
if (Number.isNaN(date.getTime()))
|
|
5746
|
+
return iso;
|
|
5747
|
+
return new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short", year: "numeric", timeZone: "UTC" }).format(date);
|
|
4995
5748
|
}
|
|
4996
5749
|
}
|
|
4997
5750
|
});
|
|
@@ -5066,12 +5819,12 @@ var require_setupDisclosure = __commonJS({
|
|
|
5066
5819
|
exports.renderSetupDisclosure = renderSetupDisclosure;
|
|
5067
5820
|
exports.FAMILY_SENTENCES = {
|
|
5068
5821
|
session: "when a session starts and ends, the one-word reason for the end if your agent gives one, how long each turn took, and whether it ran on this machine or in a hosted cloud session",
|
|
5069
|
-
counts: "how many prompts you sent, how many replies came back, and what class of command ran in a terminal \u2014 test, lint, build, git and so on",
|
|
5822
|
+
counts: "how many prompts you sent and roughly how long each was, as one of four sizes, how many replies came back, and what class of command ran in a terminal \u2014 test, lint, build, git and so on",
|
|
5070
5823
|
tools: "the name of each tool your agent calls",
|
|
5071
5824
|
outcome: "whether a call succeeded, failed, or was interrupted",
|
|
5072
5825
|
clock: "your machine's offset from UTC, so an evening is read as an evening",
|
|
5073
5826
|
repo: "your project and branch as digests computed on this machine \u2014 never the names themselves",
|
|
5074
|
-
model: "which model served the session, by name and by tier",
|
|
5827
|
+
model: "which model served the session, by name and by tier, whether it came through the vendor, a cloud platform, a gateway or this machine (one word, never an address), and the effort level it was set to where your agent records one",
|
|
5075
5828
|
posture: "the permission posture your agent was working under \u2014 asking each time, accepting edits, and so on",
|
|
5076
5829
|
git: "that a commit, push or revert happened, and when a pull request opened or merged",
|
|
5077
5830
|
edits: "roughly how much a file changed, as a bucket, and whether you edited it after the agent wrote it",
|
|
@@ -5319,6 +6072,7 @@ var require_liveBus = __commonJS({
|
|
|
5319
6072
|
exports.existingSocketCandidates = existingSocketCandidates;
|
|
5320
6073
|
exports.liveBusSocketPath = liveBusSocketPath;
|
|
5321
6074
|
exports.bucketPromptSize = bucketPromptSize;
|
|
6075
|
+
exports.promptSizeMetadata = promptSizeMetadata;
|
|
5322
6076
|
exports.emitLiveSignal = emitLiveSignal;
|
|
5323
6077
|
exports.deliverLine = deliverLine;
|
|
5324
6078
|
var fs = __importStar(__require("fs"));
|
|
@@ -5367,6 +6121,9 @@ var require_liveBus = __commonJS({
|
|
|
5367
6121
|
return "l";
|
|
5368
6122
|
return "xl";
|
|
5369
6123
|
}
|
|
6124
|
+
function promptSizeMetadata(text) {
|
|
6125
|
+
return text === void 0 ? {} : { promptSizeBucket: bucketPromptSize(text) };
|
|
6126
|
+
}
|
|
5370
6127
|
var NOBODY_LISTENING = /* @__PURE__ */ new Set(["ECONNREFUSED", "ENOENT"]);
|
|
5371
6128
|
function onTheWire(signal) {
|
|
5372
6129
|
const out = { ...signal };
|
|
@@ -5879,6 +6636,7 @@ var require_cliAgentSetup = __commonJS({
|
|
|
5879
6636
|
var os = __importStar(__require("os"));
|
|
5880
6637
|
var path = __importStar(__require("path"));
|
|
5881
6638
|
var collectorVersion_1 = require_collectorVersion();
|
|
6639
|
+
var releaseCheck_1 = require_releaseCheck();
|
|
5882
6640
|
var credentials_1 = require_credentials();
|
|
5883
6641
|
var eventLog_1 = require_eventLog();
|
|
5884
6642
|
var hookAdapter_1 = require_hookAdapter();
|
|
@@ -6032,7 +6790,7 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
|
|
|
6032
6790
|
const next = (label, value) => console.log(` ${ui.bold(label.padEnd(6))} ${value}`);
|
|
6033
6791
|
console.log("");
|
|
6034
6792
|
if (chosenLocal) {
|
|
6035
|
-
console.log(`${ui.mark("ok")} ${ui.bold("Ready.")} The screen saver and
|
|
6793
|
+
console.log(`${ui.mark("ok")} ${ui.bold("Ready.")} The screen saver and Ascenda Flow's live view work now.`);
|
|
6036
6794
|
console.log(" They run on this machine and need no account or pairing.");
|
|
6037
6795
|
if (eventLog.path)
|
|
6038
6796
|
console.log(` Every event is also written to ${(0, hookRunner_1.tidyHomePath)(eventLog.path, os.homedir())}, for you or any tool to read.`);
|
|
@@ -6049,9 +6807,9 @@ ${(0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName:
|
|
|
6049
6807
|
next(chosenLocal ? "Pair" : "Retry", `${ui.cyan(`${self} setup`)}${chosenLocal ? ui.dim(" (optional)") : ""}`);
|
|
6050
6808
|
if (chosenLocal) {
|
|
6051
6809
|
console.log("");
|
|
6052
|
-
console.log(ui.dim(" Pairing sends the details below to Ascenda's servers, under the account
|
|
6053
|
-
console.log(ui.dim("
|
|
6054
|
-
console.log(ui.dim("
|
|
6810
|
+
console.log(ui.dim(" Pairing sends the details below to Ascenda's servers, under the account you"));
|
|
6811
|
+
console.log(ui.dim(" confirm the code with, in Ascenda Flow or at me.ascendaflow.com."));
|
|
6812
|
+
console.log(ui.dim(" Until you pair, nothing leaves this machine."));
|
|
6055
6813
|
console.log("");
|
|
6056
6814
|
console.log(ui.dim((0, setupDisclosure_1.renderSetupDisclosure)({ sends: spec.sends, displayName: spec.displayName }).split("\n").map((line) => ` ${line}`).join("\n")));
|
|
6057
6815
|
}
|
|
@@ -6470,6 +7228,11 @@ ${serialised}`);
|
|
|
6470
7228
|
console.log(`token ${localOnly ? "\u2014 none needed until this install is paired" : tokenFile && (0, tokenStore_1.readTokenFile)(tokenFile) ? "present" : "\u2014 missing"}`);
|
|
6471
7229
|
console.log(`event log ${(0, eventLog_1.describeEventLog)((0, eventLog_1.resolveEventLog)({ localOnly }), `npx ${spec.packageName} setup`)}`);
|
|
6472
7230
|
console.log(`hook binary ${fs.existsSync(binary) ? binary : "\u2014 not installed"}`);
|
|
7231
|
+
console.log(`latest ${(0, releaseCheck_1.describeReleaseCheck)({
|
|
7232
|
+
installed: (0, releaseCheck_1.installedBundleVersion)((0, hookRunner_1.hookRunnerPaths)(spec.binaryName).version) ?? collectorVersion_1.COLLECTOR_VERSION,
|
|
7233
|
+
setupCommand: `npx -y ${spec.packageName} setup`,
|
|
7234
|
+
localOnly
|
|
7235
|
+
})}`);
|
|
6473
7236
|
const node = process.platform === "win32" ? void 0 : (0, hookRunner_1.resolveHookNode)(binary);
|
|
6474
7237
|
if (node) {
|
|
6475
7238
|
console.log(node.problem ? `node \u2014 ${node.problem}. Install Node 20 or newer, then run setup again` : `node ${node.node} (${node.version}, ${node.how === "recorded" ? "recorded at setup" : "found by the launcher"})`);
|
|
@@ -6770,6 +7533,480 @@ var require_turnState = __commonJS({
|
|
|
6770
7533
|
}
|
|
6771
7534
|
});
|
|
6772
7535
|
|
|
7536
|
+
// ../packages/tool-kit/out/effortState.js
|
|
7537
|
+
var require_effortState = __commonJS({
|
|
7538
|
+
"../packages/tool-kit/out/effortState.js"(exports) {
|
|
7539
|
+
"use strict";
|
|
7540
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
7541
|
+
if (k2 === void 0) k2 = k;
|
|
7542
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7543
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7544
|
+
desc = { enumerable: true, get: function() {
|
|
7545
|
+
return m[k];
|
|
7546
|
+
} };
|
|
7547
|
+
}
|
|
7548
|
+
Object.defineProperty(o, k2, desc);
|
|
7549
|
+
} : function(o, m, k, k2) {
|
|
7550
|
+
if (k2 === void 0) k2 = k;
|
|
7551
|
+
o[k2] = m[k];
|
|
7552
|
+
});
|
|
7553
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
7554
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
7555
|
+
} : function(o, v) {
|
|
7556
|
+
o["default"] = v;
|
|
7557
|
+
});
|
|
7558
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
7559
|
+
var ownKeys = function(o) {
|
|
7560
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
7561
|
+
var ar = [];
|
|
7562
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
7563
|
+
return ar;
|
|
7564
|
+
};
|
|
7565
|
+
return ownKeys(o);
|
|
7566
|
+
};
|
|
7567
|
+
return function(mod) {
|
|
7568
|
+
if (mod && mod.__esModule) return mod;
|
|
7569
|
+
var result = {};
|
|
7570
|
+
if (mod != null) {
|
|
7571
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
7572
|
+
}
|
|
7573
|
+
__setModuleDefault(result, mod);
|
|
7574
|
+
return result;
|
|
7575
|
+
};
|
|
7576
|
+
}();
|
|
7577
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7578
|
+
exports.readSentEffortLevel = readSentEffortLevel;
|
|
7579
|
+
exports.recordSentEffortLevel = recordSentEffortLevel;
|
|
7580
|
+
exports.clearSentEffortLevel = clearSentEffortLevel;
|
|
7581
|
+
var fs = __importStar(__require("fs"));
|
|
7582
|
+
var path = __importStar(__require("path"));
|
|
7583
|
+
var tokenStore_1 = require_tokenStore();
|
|
7584
|
+
var stateDir = () => process.env.ASCENDA_STATE_DIR ?? path.join((0, tokenStore_1.ascendaHome)(), "state");
|
|
7585
|
+
function effortFile(agent, sessionId) {
|
|
7586
|
+
return path.join(stateDir(), `${sanitize(agent)}-effort-${sanitize(sessionId)}`);
|
|
7587
|
+
}
|
|
7588
|
+
function sanitize(value) {
|
|
7589
|
+
return value.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
7590
|
+
}
|
|
7591
|
+
function readSentEffortLevel(agent, sessionId) {
|
|
7592
|
+
if (!sessionId)
|
|
7593
|
+
return void 0;
|
|
7594
|
+
try {
|
|
7595
|
+
const level = fs.readFileSync(effortFile(agent, sessionId), "utf8").trim();
|
|
7596
|
+
return level || void 0;
|
|
7597
|
+
} catch {
|
|
7598
|
+
return void 0;
|
|
7599
|
+
}
|
|
7600
|
+
}
|
|
7601
|
+
function recordSentEffortLevel(agent, sessionId, level) {
|
|
7602
|
+
if (!sessionId || !level)
|
|
7603
|
+
return;
|
|
7604
|
+
try {
|
|
7605
|
+
fs.mkdirSync(stateDir(), { recursive: true });
|
|
7606
|
+
fs.writeFileSync(effortFile(agent, sessionId), level, { encoding: "utf8", mode: 384 });
|
|
7607
|
+
} catch {
|
|
7608
|
+
}
|
|
7609
|
+
}
|
|
7610
|
+
function clearSentEffortLevel(agent, sessionId) {
|
|
7611
|
+
if (!sessionId)
|
|
7612
|
+
return;
|
|
7613
|
+
try {
|
|
7614
|
+
fs.rmSync(effortFile(agent, sessionId), { force: true });
|
|
7615
|
+
} catch {
|
|
7616
|
+
}
|
|
7617
|
+
}
|
|
7618
|
+
}
|
|
7619
|
+
});
|
|
7620
|
+
|
|
7621
|
+
// ../packages/tool-kit/out/squadronJoin.js
|
|
7622
|
+
var require_squadronJoin = __commonJS({
|
|
7623
|
+
"../packages/tool-kit/out/squadronJoin.js"(exports) {
|
|
7624
|
+
"use strict";
|
|
7625
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
7626
|
+
if (k2 === void 0) k2 = k;
|
|
7627
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7628
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7629
|
+
desc = { enumerable: true, get: function() {
|
|
7630
|
+
return m[k];
|
|
7631
|
+
} };
|
|
7632
|
+
}
|
|
7633
|
+
Object.defineProperty(o, k2, desc);
|
|
7634
|
+
} : function(o, m, k, k2) {
|
|
7635
|
+
if (k2 === void 0) k2 = k;
|
|
7636
|
+
o[k2] = m[k];
|
|
7637
|
+
});
|
|
7638
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
7639
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
7640
|
+
} : function(o, v) {
|
|
7641
|
+
o["default"] = v;
|
|
7642
|
+
});
|
|
7643
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
7644
|
+
var ownKeys = function(o) {
|
|
7645
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
7646
|
+
var ar = [];
|
|
7647
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
7648
|
+
return ar;
|
|
7649
|
+
};
|
|
7650
|
+
return ownKeys(o);
|
|
7651
|
+
};
|
|
7652
|
+
return function(mod) {
|
|
7653
|
+
if (mod && mod.__esModule) return mod;
|
|
7654
|
+
var result = {};
|
|
7655
|
+
if (mod != null) {
|
|
7656
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
7657
|
+
}
|
|
7658
|
+
__setModuleDefault(result, mod);
|
|
7659
|
+
return result;
|
|
7660
|
+
};
|
|
7661
|
+
}();
|
|
7662
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7663
|
+
exports.SQUADRON_COLOURS = exports.SQUADRON_AIRCRAFT = void 0;
|
|
7664
|
+
exports.generateCallsign = generateCallsign;
|
|
7665
|
+
exports.normaliseBookingReference = normaliseBookingReference;
|
|
7666
|
+
exports.callsignProblem = callsignProblem;
|
|
7667
|
+
exports.runSquadronJoin = runSquadronJoin;
|
|
7668
|
+
exports.leaseEnd = leaseEnd;
|
|
7669
|
+
exports.describeGate = describeGate;
|
|
7670
|
+
exports.describeSquadronRefusal = describeSquadronRefusal;
|
|
7671
|
+
var readline = __importStar(__require("node:readline"));
|
|
7672
|
+
var node_crypto_1 = __require("node:crypto");
|
|
7673
|
+
var confirmLinks_1 = require_confirmLinks();
|
|
7674
|
+
var http_1 = require_http();
|
|
7675
|
+
exports.SQUADRON_AIRCRAFT = ["trainer", "airliner", "glider", "fighter", "stealth", "floatplane"];
|
|
7676
|
+
exports.SQUADRON_COLOURS = ["orange", "yellow", "ivory", "charcoal", "grey", "red"];
|
|
7677
|
+
var CALLSIGN_WORDS = ["Kestrel", "Falcon", "Heron", "Swift", "Osprey", "Raven", "Merlin", "Puffin", "Condor", "Harrier", "Kite", "Tern"];
|
|
7678
|
+
function generateCallsign() {
|
|
7679
|
+
return `${CALLSIGN_WORDS[(0, node_crypto_1.randomInt)(CALLSIGN_WORDS.length)]} ${String((0, node_crypto_1.randomInt)(10, 100))}`;
|
|
7680
|
+
}
|
|
7681
|
+
function normaliseBookingReference(raw) {
|
|
7682
|
+
const cleaned = (raw ?? "").replace(/[\s-]/g, "").toUpperCase();
|
|
7683
|
+
return /^[A-Z0-9]{6}$/.test(cleaned) ? cleaned : void 0;
|
|
7684
|
+
}
|
|
7685
|
+
function callsignProblem(callsign) {
|
|
7686
|
+
const trimmed = callsign.trim();
|
|
7687
|
+
if (trimmed.length === 0)
|
|
7688
|
+
return "A callsign can't be empty.";
|
|
7689
|
+
if (trimmed.length > 40)
|
|
7690
|
+
return "A callsign is 40 characters at most.";
|
|
7691
|
+
if (/[\u0000-\u001f\u007f]/.test(trimmed))
|
|
7692
|
+
return "A callsign can't contain control characters.";
|
|
7693
|
+
return void 0;
|
|
7694
|
+
}
|
|
7695
|
+
var POLL_INTERVAL_MS = 3e3;
|
|
7696
|
+
var POLL_TIMEOUT_MS = 11 * 60 * 1e3;
|
|
7697
|
+
async function runSquadronJoin(ctx) {
|
|
7698
|
+
const stdin = ctx.stdin ?? process.stdin;
|
|
7699
|
+
const stdout = ctx.stdout ?? process.stdout;
|
|
7700
|
+
const stderr = ctx.stderr ?? process.stderr;
|
|
7701
|
+
const print = (line = "") => stdout.write(`${line}
|
|
7702
|
+
`);
|
|
7703
|
+
if (!stdin.isTTY || !stdout.isTTY) {
|
|
7704
|
+
stderr.write("squadron needs an interactive terminal (stdin and stdout). Run it directly, not from a script or a pipe.\n");
|
|
7705
|
+
return 0;
|
|
7706
|
+
}
|
|
7707
|
+
const reference = normaliseBookingReference(ctx.bookingReference);
|
|
7708
|
+
if (!reference) {
|
|
7709
|
+
stderr.write("A booking reference is six letters or digits, like FEFBDH.\n");
|
|
7710
|
+
return 1;
|
|
7711
|
+
}
|
|
7712
|
+
let preview;
|
|
7713
|
+
try {
|
|
7714
|
+
preview = await (0, http_1.previewJoinCode)(ctx.apiBaseUrl, reference);
|
|
7715
|
+
} catch (error) {
|
|
7716
|
+
stderr.write(`${describeSquadronError(error)}
|
|
7717
|
+
`);
|
|
7718
|
+
return 1;
|
|
7719
|
+
}
|
|
7720
|
+
const jam = preview.jam;
|
|
7721
|
+
if (preview.labRole !== "Jam" || !jam) {
|
|
7722
|
+
stderr.write(`${reference} isn't a Squadron booking reference. If it's a study code, run join instead.
|
|
7723
|
+
`);
|
|
7724
|
+
return 1;
|
|
7725
|
+
}
|
|
7726
|
+
if (jam.acceptsJoins === false) {
|
|
7727
|
+
stderr.write(jam.isLocked ? "This sortie's gate is closed. Ask the host to open it.\n" : "This sortie isn't taking new pilots.\n");
|
|
7728
|
+
return 1;
|
|
7729
|
+
}
|
|
7730
|
+
const aircraftList = jam.aircraft?.length ? jam.aircraft : [...exports.SQUADRON_AIRCRAFT];
|
|
7731
|
+
const colourList = jam.colours?.length ? jam.colours : [...exports.SQUADRON_COLOURS];
|
|
7732
|
+
for (const [flag, value, list] of [["--aircraft", ctx.aircraft, aircraftList], ["--colour", ctx.colour, colourList]]) {
|
|
7733
|
+
if (value !== void 0 && !list.includes(value.trim().toLowerCase())) {
|
|
7734
|
+
stderr.write(`${flag} must be one of: ${list.join(", ")}.
|
|
7735
|
+
`);
|
|
7736
|
+
return 1;
|
|
7737
|
+
}
|
|
7738
|
+
}
|
|
7739
|
+
if (ctx.callsign !== void 0) {
|
|
7740
|
+
const problem = callsignProblem(ctx.callsign);
|
|
7741
|
+
if (problem) {
|
|
7742
|
+
stderr.write(`${problem}
|
|
7743
|
+
`);
|
|
7744
|
+
return 1;
|
|
7745
|
+
}
|
|
7746
|
+
}
|
|
7747
|
+
print();
|
|
7748
|
+
print(`Squadron: ${jam.name ?? preview.labName ?? reference}`);
|
|
7749
|
+
if (jam.mission)
|
|
7750
|
+
print(`Mission: ${jam.mission}`);
|
|
7751
|
+
print(describeGate(jam));
|
|
7752
|
+
print();
|
|
7753
|
+
const prompt = createPrompter(stdin, stdout);
|
|
7754
|
+
try {
|
|
7755
|
+
let callsign = ctx.callsign?.trim();
|
|
7756
|
+
if (callsign === void 0) {
|
|
7757
|
+
const suggested = (ctx.generateCallsign ?? generateCallsign)();
|
|
7758
|
+
for (; ; ) {
|
|
7759
|
+
const answer = await prompt.ask(`Callsign [${suggested}]: `);
|
|
7760
|
+
if (answer === void 0)
|
|
7761
|
+
return notNow(print);
|
|
7762
|
+
const chosen = answer === "" ? suggested : answer;
|
|
7763
|
+
const problem = callsignProblem(chosen);
|
|
7764
|
+
if (!problem) {
|
|
7765
|
+
callsign = chosen.trim();
|
|
7766
|
+
break;
|
|
7767
|
+
}
|
|
7768
|
+
print(problem);
|
|
7769
|
+
}
|
|
7770
|
+
}
|
|
7771
|
+
let aircraft = ctx.aircraft?.trim().toLowerCase();
|
|
7772
|
+
if (aircraft === void 0) {
|
|
7773
|
+
const suggested = aircraftList[(0, node_crypto_1.randomInt)(aircraftList.length)];
|
|
7774
|
+
aircraft = await askFromList(prompt, print, "Aircraft", aircraftList, suggested);
|
|
7775
|
+
if (aircraft === void 0)
|
|
7776
|
+
return notNow(print);
|
|
7777
|
+
}
|
|
7778
|
+
let colour = ctx.colour?.trim().toLowerCase();
|
|
7779
|
+
if (colour === void 0) {
|
|
7780
|
+
const picked = await askFromList(prompt, print, "Colour", colourList, "", "dealt for you");
|
|
7781
|
+
if (picked === void 0)
|
|
7782
|
+
return notNow(print);
|
|
7783
|
+
colour = picked === "" ? void 0 : picked;
|
|
7784
|
+
}
|
|
7785
|
+
print();
|
|
7786
|
+
print(`You'll confirm as ${callsign}, ${aircraft}${colour ? `, ${colour}` : ""}. The confirm page lets you change any of them.`);
|
|
7787
|
+
print();
|
|
7788
|
+
print("Joining shares, with this squadron only:");
|
|
7789
|
+
print(` your activity counts from ${ctx.displayName}: prompts, tool calls, turns and edits, as numbers`);
|
|
7790
|
+
print(" your callsign and aircraft, which the other pilots see");
|
|
7791
|
+
print("Never your prompts, code, file names or project names.");
|
|
7792
|
+
print("Sharing stops on the date the server gives when you join. It's printed then.");
|
|
7793
|
+
print();
|
|
7794
|
+
print(" 1) Join");
|
|
7795
|
+
print(" 2) Not now");
|
|
7796
|
+
print();
|
|
7797
|
+
const choice = await prompt.ask("Choice [Not now]: ");
|
|
7798
|
+
if (choice === void 0 || !/^(1|join|y|yes)$/i.test(choice))
|
|
7799
|
+
return notNow(print);
|
|
7800
|
+
prompt.close();
|
|
7801
|
+
let start;
|
|
7802
|
+
try {
|
|
7803
|
+
start = await (0, http_1.startSquadronJoin)(ctx.apiBaseUrl, ctx.eventWriteToken, { joinCode: reference, handle: callsign, aircraft, colour });
|
|
7804
|
+
} catch (error) {
|
|
7805
|
+
const doorClosed = error instanceof http_1.AscendaApiError && error.status === 404 && !error.errorCode?.startsWith("jam_");
|
|
7806
|
+
stderr.write(doorClosed ? "This server can't seat you in a sortie from the command line yet. Join from the Ascenda app instead.\n" : `${describeSquadronError(error)}
|
|
7807
|
+
`);
|
|
7808
|
+
return 1;
|
|
7809
|
+
}
|
|
7810
|
+
if (start.kind !== void 0 && start.kind !== "jam") {
|
|
7811
|
+
stderr.write(`${reference} opened a study join, not a sortie. Run join instead.
|
|
7812
|
+
`);
|
|
7813
|
+
return 1;
|
|
7814
|
+
}
|
|
7815
|
+
print();
|
|
7816
|
+
const confirmUrl = (0, confirmLinks_1.studyJoinConfirmUrl)(ctx.apiBaseUrl, start.deviceCode);
|
|
7817
|
+
if (confirmUrl) {
|
|
7818
|
+
print(`Open this link to confirm: ${confirmUrl}`);
|
|
7819
|
+
print(`Or confirm in the Ascenda app with code ${start.deviceCode}.`);
|
|
7820
|
+
} else {
|
|
7821
|
+
print(`Confirm in the Ascenda app with code ${start.deviceCode}`);
|
|
7822
|
+
}
|
|
7823
|
+
print(`Waiting for confirmation (expires ${formatLocalTime(start.expiresAt)})...`);
|
|
7824
|
+
const pollIntervalMs = ctx.pollIntervalMs ?? POLL_INTERVAL_MS;
|
|
7825
|
+
const deadline = Math.min(Date.parse(start.expiresAt) || Date.now() + POLL_TIMEOUT_MS, Date.now() + POLL_TIMEOUT_MS);
|
|
7826
|
+
while (Date.now() < deadline) {
|
|
7827
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
7828
|
+
let poll;
|
|
7829
|
+
try {
|
|
7830
|
+
poll = await (0, http_1.getStudyJoinStatus)(ctx.apiBaseUrl, ctx.eventWriteToken, start.joinSessionId);
|
|
7831
|
+
} catch (error) {
|
|
7832
|
+
if (!(error instanceof http_1.AscendaApiError) || error.status >= 500 && error.status <= 599)
|
|
7833
|
+
continue;
|
|
7834
|
+
stderr.write(`${describeSquadronError(error)}
|
|
7835
|
+
`);
|
|
7836
|
+
return 1;
|
|
7837
|
+
}
|
|
7838
|
+
if (poll.status === "pending")
|
|
7839
|
+
continue;
|
|
7840
|
+
if (poll.status === "confirmed") {
|
|
7841
|
+
const until = poll.endUtc ?? poll.jam?.endUtc ?? leaseEnd(poll.jam ?? {});
|
|
7842
|
+
const seat = poll.jam?.handle ? ` as ${poll.jam.handle}` : "";
|
|
7843
|
+
print();
|
|
7844
|
+
print(poll.jam?.alreadyJoined ? `You already have a seat${seat}.` : `Joined${seat}.`);
|
|
7845
|
+
print(until ? `Your activity counts are shared with this squadron until ${formatLocalDate(until)}.` : "Your activity counts are shared with this squadron until the sortie's sharing ends. The server didn't give a date.");
|
|
7846
|
+
print(describeStatusAfterJoin(poll.jam));
|
|
7847
|
+
return 0;
|
|
7848
|
+
}
|
|
7849
|
+
if (poll.status === "expired") {
|
|
7850
|
+
print();
|
|
7851
|
+
print("This code expired before it was confirmed. Run squadron again for a fresh code.");
|
|
7852
|
+
return 1;
|
|
7853
|
+
}
|
|
7854
|
+
print();
|
|
7855
|
+
print(describeSquadronRefusal(poll.refusedReason ?? void 0));
|
|
7856
|
+
return 1;
|
|
7857
|
+
}
|
|
7858
|
+
print();
|
|
7859
|
+
print("Timed out waiting for confirmation. Run squadron again for a fresh code.");
|
|
7860
|
+
return 1;
|
|
7861
|
+
} finally {
|
|
7862
|
+
prompt.close();
|
|
7863
|
+
}
|
|
7864
|
+
}
|
|
7865
|
+
function leaseEnd(jam) {
|
|
7866
|
+
const from = Date.parse(jam.startedAt ?? jam.quorumDeadline ?? "");
|
|
7867
|
+
if (Number.isNaN(from) || typeof jam.durationMinutes !== "number")
|
|
7868
|
+
return void 0;
|
|
7869
|
+
return new Date(from + (jam.durationMinutes + 7 * 24 * 60) * 6e4).toISOString();
|
|
7870
|
+
}
|
|
7871
|
+
function notNow(print) {
|
|
7872
|
+
print("Not now.");
|
|
7873
|
+
return 0;
|
|
7874
|
+
}
|
|
7875
|
+
async function askFromList(prompt, print, label, list, suggested, emptyMeans) {
|
|
7876
|
+
print(`${label === "Aircraft" ? "Aircraft" : `${label}s`}: ${list.join(", ")}`);
|
|
7877
|
+
for (; ; ) {
|
|
7878
|
+
const answer = await prompt.ask(`${label} [${emptyMeans ?? suggested}]: `);
|
|
7879
|
+
if (answer === void 0)
|
|
7880
|
+
return void 0;
|
|
7881
|
+
if (answer === "")
|
|
7882
|
+
return suggested;
|
|
7883
|
+
const value = answer.toLowerCase();
|
|
7884
|
+
const byNumber = /^\d+$/.test(value) ? list[Number(value) - 1] : void 0;
|
|
7885
|
+
if (byNumber)
|
|
7886
|
+
return byNumber;
|
|
7887
|
+
if (list.includes(value))
|
|
7888
|
+
return value;
|
|
7889
|
+
print(`Pick one of: ${list.join(", ")}.`);
|
|
7890
|
+
}
|
|
7891
|
+
}
|
|
7892
|
+
function describeGate(jam) {
|
|
7893
|
+
const length = jam.durationMinutes ? `${jam.durationMinutes}-minute flight plan` : "flight plan";
|
|
7894
|
+
if (jam.status === "live")
|
|
7895
|
+
return `In the air now, ${length}.`;
|
|
7896
|
+
const have = jam.activeParticipants ?? 0;
|
|
7897
|
+
const need = jam.minParticipants ?? 0;
|
|
7898
|
+
const deadline = jam.quorumDeadline ? `, gate closes ${formatLocalTime(jam.quorumDeadline)}` : "";
|
|
7899
|
+
return need > have ? `On the ground: ${have} of ${need} pilots in${deadline}. The ${length} starts when the squadron fills.` : `On the ground${deadline}. ${length[0].toUpperCase()}${length.slice(1)}.`;
|
|
7900
|
+
}
|
|
7901
|
+
function describeStatusAfterJoin(jam) {
|
|
7902
|
+
if (!jam)
|
|
7903
|
+
return "Open the Ascenda app to watch the squadron.";
|
|
7904
|
+
if (jam.status === "live" && jam.expiresAt)
|
|
7905
|
+
return `The squadron is in the air until ${formatLocalTime(jam.expiresAt)}. Open the Ascenda app to watch.`;
|
|
7906
|
+
const have = jam.activeParticipants;
|
|
7907
|
+
const need = jam.minParticipants;
|
|
7908
|
+
if (have !== void 0 && need !== void 0 && need > have)
|
|
7909
|
+
return `${have} of ${need} pilots in. The clock starts when the squadron fills.`;
|
|
7910
|
+
return "Open the Ascenda app to watch the squadron.";
|
|
7911
|
+
}
|
|
7912
|
+
function describeSquadronRefusal(code) {
|
|
7913
|
+
switch (code) {
|
|
7914
|
+
case "join_code_not_found":
|
|
7915
|
+
return "No sortie has that booking reference, or it has ended.";
|
|
7916
|
+
case "jam_closed":
|
|
7917
|
+
return "That sortie has ended.";
|
|
7918
|
+
case "jam_locked":
|
|
7919
|
+
return "This sortie's gate is closed. Ask the host to open it.";
|
|
7920
|
+
case "jam_already_left":
|
|
7921
|
+
return "You left this sortie, and leaving is final. Ask the host for a new one.";
|
|
7922
|
+
case "jam_handle_taken":
|
|
7923
|
+
return "Another pilot has that callsign. Run squadron again and pick another.";
|
|
7924
|
+
case "jam_requires_account":
|
|
7925
|
+
return "A sortie needs a signed-in Ascenda account, not a guest one.";
|
|
7926
|
+
case "jam_handle_required":
|
|
7927
|
+
case "jam_handle_too_long":
|
|
7928
|
+
case "jam_handle_invalid":
|
|
7929
|
+
return "The server didn't accept that callsign. Run squadron again and pick another.";
|
|
7930
|
+
case "jam_aircraft_unknown":
|
|
7931
|
+
return "The server didn't recognise that aircraft.";
|
|
7932
|
+
case "jam_colour_unknown":
|
|
7933
|
+
return "The server didn't recognise that colour.";
|
|
7934
|
+
case "unknown_mode":
|
|
7935
|
+
return "This server's join door didn't accept a sortie. It may be older than this command.";
|
|
7936
|
+
case "too_many_open_sessions":
|
|
7937
|
+
return "Too many joins are waiting to be confirmed. Confirm or let one expire, then try again.";
|
|
7938
|
+
case "jam_not_enabled":
|
|
7939
|
+
return "Squadron isn't switched on for this server yet.";
|
|
7940
|
+
default:
|
|
7941
|
+
return code ? `The server refused the join (${code}).` : "The server refused the join.";
|
|
7942
|
+
}
|
|
7943
|
+
}
|
|
7944
|
+
function describeSquadronError(error) {
|
|
7945
|
+
if (error instanceof http_1.AscendaApiError) {
|
|
7946
|
+
if (error.status === 401)
|
|
7947
|
+
return "This collector's pairing isn't accepted any more. Run pair, then try again.";
|
|
7948
|
+
if (error.status === 404 && !error.errorCode?.startsWith("jam_"))
|
|
7949
|
+
return describeSquadronRefusal("join_code_not_found");
|
|
7950
|
+
return describeSquadronRefusal(error.errorCode);
|
|
7951
|
+
}
|
|
7952
|
+
return `Couldn't reach Ascenda: ${error instanceof Error ? error.message : String(error)}`;
|
|
7953
|
+
}
|
|
7954
|
+
function createPrompter(stdin, stdout) {
|
|
7955
|
+
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
7956
|
+
let closed = false;
|
|
7957
|
+
const lines = [];
|
|
7958
|
+
let waiting;
|
|
7959
|
+
rl.on("line", (line) => {
|
|
7960
|
+
if (waiting) {
|
|
7961
|
+
const resolve = waiting;
|
|
7962
|
+
waiting = void 0;
|
|
7963
|
+
resolve(line.trim());
|
|
7964
|
+
} else {
|
|
7965
|
+
lines.push(line.trim());
|
|
7966
|
+
}
|
|
7967
|
+
});
|
|
7968
|
+
rl.on("close", () => {
|
|
7969
|
+
closed = true;
|
|
7970
|
+
if (waiting) {
|
|
7971
|
+
const resolve = waiting;
|
|
7972
|
+
waiting = void 0;
|
|
7973
|
+
resolve(void 0);
|
|
7974
|
+
}
|
|
7975
|
+
});
|
|
7976
|
+
return {
|
|
7977
|
+
ask(question) {
|
|
7978
|
+
if (lines.length > 0) {
|
|
7979
|
+
stdout.write(question);
|
|
7980
|
+
return Promise.resolve(lines.shift());
|
|
7981
|
+
}
|
|
7982
|
+
if (closed)
|
|
7983
|
+
return Promise.resolve(void 0);
|
|
7984
|
+
stdout.write(question);
|
|
7985
|
+
return new Promise((resolve) => {
|
|
7986
|
+
waiting = resolve;
|
|
7987
|
+
});
|
|
7988
|
+
},
|
|
7989
|
+
close() {
|
|
7990
|
+
if (!closed)
|
|
7991
|
+
rl.close();
|
|
7992
|
+
}
|
|
7993
|
+
};
|
|
7994
|
+
}
|
|
7995
|
+
function formatLocalTime(iso) {
|
|
7996
|
+
const date = new Date(iso);
|
|
7997
|
+
if (Number.isNaN(date.getTime()))
|
|
7998
|
+
return iso;
|
|
7999
|
+
return new Intl.DateTimeFormat(void 0, { day: "numeric", month: "short", hour: "numeric", minute: "2-digit" }).format(date);
|
|
8000
|
+
}
|
|
8001
|
+
function formatLocalDate(iso) {
|
|
8002
|
+
const date = new Date(iso);
|
|
8003
|
+
if (Number.isNaN(date.getTime()))
|
|
8004
|
+
return iso;
|
|
8005
|
+
return new Intl.DateTimeFormat(void 0, { day: "numeric", month: "short", year: "numeric" }).format(date);
|
|
8006
|
+
}
|
|
8007
|
+
}
|
|
8008
|
+
});
|
|
8009
|
+
|
|
6773
8010
|
// ../packages/tool-kit/out/pluginBundle.js
|
|
6774
8011
|
var require_pluginBundle = __commonJS({
|
|
6775
8012
|
"../packages/tool-kit/out/pluginBundle.js"(exports) {
|
|
@@ -7008,11 +8245,12 @@ var require_out3 = __commonJS({
|
|
|
7008
8245
|
"../packages/tool-kit/out/index.js"(exports) {
|
|
7009
8246
|
"use strict";
|
|
7010
8247
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7011
|
-
exports.
|
|
7012
|
-
exports.
|
|
7013
|
-
exports.
|
|
7014
|
-
exports.
|
|
7015
|
-
exports.
|
|
8248
|
+
exports.RELEASE_CHECK_ENV_VAR = 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.withModelOnChange = exports.modelFieldsFor = exports.clearSentModelId = exports.recordSentModelId = exports.readSentModelId = exports.claudeCodeModelRoute = exports.modelRouteFromCodexProvider = exports.modelRouteFromSlug = exports.classifyEffortClass = exports.isPremiumModelClass = exports.PREMIUM_MODEL_CLASSES = exports.classifyModelClass = exports.autonomyBand = exports.shellCommandFacts = exports.invitesDebrief = exports.classifyMcpWorkMilestone = exports.classifyWorkMilestone = exports.isReworkGitAction = exports.classifyGitAction = exports.isVerificationCommand = exports.classifyCommand = void 0;
|
|
8249
|
+
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 = 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.runsFromInstalledBundle = exports.releaseStanding = exports.releaseCheckPath = exports.refreshReleaseCheck = exports.readReleaseCheck = exports.pendingReleaseNotice = exports.installedBundleVersion = exports.describeReleaseCheck = exports.compareReleases = exports.RELEASE_MANIFEST_URL = void 0;
|
|
8250
|
+
exports.recordWorkContext = exports.readBranchName = exports.normalizeBranchName = exports.deriveBranchHashForCwd = exports.deriveBranchHash = exports.deriveWorkContext = exports.hashWithMachineSalt = exports.readOrCreateMachineSalt = exports.machineSaltFilePath = exports.fixedTimeProvider = exports.systemTimeProvider = exports.enforceOutboxBounds = exports.claimOutbox = exports.readOutboxSummary = exports.appendToOutbox = exports.defaultOutboxFilePath = exports.outboxDrainEnabled = exports.DEFAULT_OUTBOX_DRAIN_BATCH_SIZE = exports.DEFAULT_OUTBOX_MAX_AGE_MS = exports.DEFAULT_OUTBOX_MAX_ENTRIES = exports.OUTBOX_DRAIN_ENV_VAR = exports.recordOutboxDiscard = exports.unresolvedToolInstallationId = exports.unresolvedStateFilePath = exports.markFailureNotified = exports.shouldAnnounceFailure = exports.recordSendOutcome = exports.readCollectorState = exports.defaultStateFilePath = exports.tokenExpiryFilePath = exports.readTokenFile = exports.readTokenExpiry = exports.persistEventWriteToken = exports.listPersistedToolInstallationIds = exports.defaultTokenFilePath = exports.ascendaHome = exports.EVENT_TOKEN_TTL_MS = exports.recordSentEffortLevel = exports.readSentEffortLevel = exports.clearSentEffortLevel = exports.recordTurnStart = exports.readTurnPromptId = exports.consumeTurnDurationMs = exports.writeTopLevelCredentials = exports.writeMachineCredentials = exports.writeRepoKeysSetting = exports.writeEventLogSetting = exports.writeHostCredentials = exports.removeHostCredentials = exports.readMachineCredentials = void 0;
|
|
8251
|
+
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 = exports.saverReplayPath = exports.saverContainerDir = exports.readSaverStatuses = exports.probeSocket = exports.heldForSaver = exports.holdForSaver = exports.LIVE_BUS_BACKGROUND_TRUST_MS = exports.liveBusSocketCandidates = exports.liveBusSocketPath = exports.promptSizeMetadata = exports.bucketPromptSize = exports.deliverLine = exports.emitLiveSignal = exports.startSquadronJoin = exports.previewJoinCode = exports.SQUADRON_COLOURS = exports.SQUADRON_AIRCRAFT = exports.describeSquadronRefusal = exports.describeGate = exports.callsignProblem = exports.normaliseBookingReference = exports.generateCallsign = exports.leaseEnd = exports.runSquadronJoin = 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 = void 0;
|
|
8252
|
+
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 = 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 = void 0;
|
|
8253
|
+
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.WEEKLY_POSTER_CONNECT_URL = exports.runStudyJoin = exports.gitOfferLine = exports.formatWindow = exports.describeStudyGrant = exports.describeStudyKind = void 0;
|
|
7016
8254
|
var commandClassifier_1 = require_commandClassifier();
|
|
7017
8255
|
Object.defineProperty(exports, "classifyCommand", { enumerable: true, get: function() {
|
|
7018
8256
|
return commandClassifier_1.classifyCommand;
|
|
@@ -7049,6 +8287,42 @@ var require_out3 = __commonJS({
|
|
|
7049
8287
|
Object.defineProperty(exports, "classifyModelClass", { enumerable: true, get: function() {
|
|
7050
8288
|
return modelClassifier_1.classifyModelClass;
|
|
7051
8289
|
} });
|
|
8290
|
+
Object.defineProperty(exports, "PREMIUM_MODEL_CLASSES", { enumerable: true, get: function() {
|
|
8291
|
+
return modelClassifier_1.PREMIUM_MODEL_CLASSES;
|
|
8292
|
+
} });
|
|
8293
|
+
Object.defineProperty(exports, "isPremiumModelClass", { enumerable: true, get: function() {
|
|
8294
|
+
return modelClassifier_1.isPremiumModelClass;
|
|
8295
|
+
} });
|
|
8296
|
+
var effortClassifier_1 = require_effortClassifier();
|
|
8297
|
+
Object.defineProperty(exports, "classifyEffortClass", { enumerable: true, get: function() {
|
|
8298
|
+
return effortClassifier_1.classifyEffortClass;
|
|
8299
|
+
} });
|
|
8300
|
+
var modelRoute_1 = require_modelRoute();
|
|
8301
|
+
Object.defineProperty(exports, "modelRouteFromSlug", { enumerable: true, get: function() {
|
|
8302
|
+
return modelRoute_1.modelRouteFromSlug;
|
|
8303
|
+
} });
|
|
8304
|
+
Object.defineProperty(exports, "modelRouteFromCodexProvider", { enumerable: true, get: function() {
|
|
8305
|
+
return modelRoute_1.modelRouteFromCodexProvider;
|
|
8306
|
+
} });
|
|
8307
|
+
Object.defineProperty(exports, "claudeCodeModelRoute", { enumerable: true, get: function() {
|
|
8308
|
+
return modelRoute_1.claudeCodeModelRoute;
|
|
8309
|
+
} });
|
|
8310
|
+
var modelState_1 = require_modelState();
|
|
8311
|
+
Object.defineProperty(exports, "readSentModelId", { enumerable: true, get: function() {
|
|
8312
|
+
return modelState_1.readSentModelId;
|
|
8313
|
+
} });
|
|
8314
|
+
Object.defineProperty(exports, "recordSentModelId", { enumerable: true, get: function() {
|
|
8315
|
+
return modelState_1.recordSentModelId;
|
|
8316
|
+
} });
|
|
8317
|
+
Object.defineProperty(exports, "clearSentModelId", { enumerable: true, get: function() {
|
|
8318
|
+
return modelState_1.clearSentModelId;
|
|
8319
|
+
} });
|
|
8320
|
+
Object.defineProperty(exports, "modelFieldsFor", { enumerable: true, get: function() {
|
|
8321
|
+
return modelState_1.modelFieldsFor;
|
|
8322
|
+
} });
|
|
8323
|
+
Object.defineProperty(exports, "withModelOnChange", { enumerable: true, get: function() {
|
|
8324
|
+
return modelState_1.withModelOnChange;
|
|
8325
|
+
} });
|
|
7052
8326
|
var buckets_1 = require_buckets();
|
|
7053
8327
|
Object.defineProperty(exports, "bucketLinesChanged", { enumerable: true, get: function() {
|
|
7054
8328
|
return buckets_1.bucketLinesChanged;
|
|
@@ -7139,6 +8413,40 @@ var require_out3 = __commonJS({
|
|
|
7139
8413
|
Object.defineProperty(exports, "startBackgroundFlush", { enumerable: true, get: function() {
|
|
7140
8414
|
return backgroundDelivery_1.startBackgroundFlush;
|
|
7141
8415
|
} });
|
|
8416
|
+
var releaseCheck_1 = require_releaseCheck();
|
|
8417
|
+
Object.defineProperty(exports, "RELEASE_CHECK_ENV_VAR", { enumerable: true, get: function() {
|
|
8418
|
+
return releaseCheck_1.RELEASE_CHECK_ENV_VAR;
|
|
8419
|
+
} });
|
|
8420
|
+
Object.defineProperty(exports, "RELEASE_MANIFEST_URL", { enumerable: true, get: function() {
|
|
8421
|
+
return releaseCheck_1.RELEASE_MANIFEST_URL;
|
|
8422
|
+
} });
|
|
8423
|
+
Object.defineProperty(exports, "compareReleases", { enumerable: true, get: function() {
|
|
8424
|
+
return releaseCheck_1.compareReleases;
|
|
8425
|
+
} });
|
|
8426
|
+
Object.defineProperty(exports, "describeReleaseCheck", { enumerable: true, get: function() {
|
|
8427
|
+
return releaseCheck_1.describeReleaseCheck;
|
|
8428
|
+
} });
|
|
8429
|
+
Object.defineProperty(exports, "installedBundleVersion", { enumerable: true, get: function() {
|
|
8430
|
+
return releaseCheck_1.installedBundleVersion;
|
|
8431
|
+
} });
|
|
8432
|
+
Object.defineProperty(exports, "pendingReleaseNotice", { enumerable: true, get: function() {
|
|
8433
|
+
return releaseCheck_1.pendingReleaseNotice;
|
|
8434
|
+
} });
|
|
8435
|
+
Object.defineProperty(exports, "readReleaseCheck", { enumerable: true, get: function() {
|
|
8436
|
+
return releaseCheck_1.readReleaseCheck;
|
|
8437
|
+
} });
|
|
8438
|
+
Object.defineProperty(exports, "refreshReleaseCheck", { enumerable: true, get: function() {
|
|
8439
|
+
return releaseCheck_1.refreshReleaseCheck;
|
|
8440
|
+
} });
|
|
8441
|
+
Object.defineProperty(exports, "releaseCheckPath", { enumerable: true, get: function() {
|
|
8442
|
+
return releaseCheck_1.releaseCheckPath;
|
|
8443
|
+
} });
|
|
8444
|
+
Object.defineProperty(exports, "releaseStanding", { enumerable: true, get: function() {
|
|
8445
|
+
return releaseCheck_1.releaseStanding;
|
|
8446
|
+
} });
|
|
8447
|
+
Object.defineProperty(exports, "runsFromInstalledBundle", { enumerable: true, get: function() {
|
|
8448
|
+
return releaseCheck_1.runsFromInstalledBundle;
|
|
8449
|
+
} });
|
|
7142
8450
|
var eventSender_1 = require_eventSender();
|
|
7143
8451
|
Object.defineProperty(exports, "AscendaEventSender", { enumerable: true, get: function() {
|
|
7144
8452
|
return eventSender_1.AscendaEventSender;
|
|
@@ -7297,6 +8605,16 @@ var require_out3 = __commonJS({
|
|
|
7297
8605
|
Object.defineProperty(exports, "recordTurnStart", { enumerable: true, get: function() {
|
|
7298
8606
|
return turnState_1.recordTurnStart;
|
|
7299
8607
|
} });
|
|
8608
|
+
var effortState_1 = require_effortState();
|
|
8609
|
+
Object.defineProperty(exports, "clearSentEffortLevel", { enumerable: true, get: function() {
|
|
8610
|
+
return effortState_1.clearSentEffortLevel;
|
|
8611
|
+
} });
|
|
8612
|
+
Object.defineProperty(exports, "readSentEffortLevel", { enumerable: true, get: function() {
|
|
8613
|
+
return effortState_1.readSentEffortLevel;
|
|
8614
|
+
} });
|
|
8615
|
+
Object.defineProperty(exports, "recordSentEffortLevel", { enumerable: true, get: function() {
|
|
8616
|
+
return effortState_1.recordSentEffortLevel;
|
|
8617
|
+
} });
|
|
7300
8618
|
var tokenStore_1 = require_tokenStore();
|
|
7301
8619
|
Object.defineProperty(exports, "EVENT_TOKEN_TTL_MS", { enumerable: true, get: function() {
|
|
7302
8620
|
return tokenStore_1.EVENT_TOKEN_TTL_MS;
|
|
@@ -7456,6 +8774,41 @@ var require_out3 = __commonJS({
|
|
|
7456
8774
|
Object.defineProperty(exports, "repoKeysEnabled", { enumerable: true, get: function() {
|
|
7457
8775
|
return forgeKeys_1.repoKeysEnabled;
|
|
7458
8776
|
} });
|
|
8777
|
+
var squadronJoin_1 = require_squadronJoin();
|
|
8778
|
+
Object.defineProperty(exports, "runSquadronJoin", { enumerable: true, get: function() {
|
|
8779
|
+
return squadronJoin_1.runSquadronJoin;
|
|
8780
|
+
} });
|
|
8781
|
+
Object.defineProperty(exports, "leaseEnd", { enumerable: true, get: function() {
|
|
8782
|
+
return squadronJoin_1.leaseEnd;
|
|
8783
|
+
} });
|
|
8784
|
+
Object.defineProperty(exports, "generateCallsign", { enumerable: true, get: function() {
|
|
8785
|
+
return squadronJoin_1.generateCallsign;
|
|
8786
|
+
} });
|
|
8787
|
+
Object.defineProperty(exports, "normaliseBookingReference", { enumerable: true, get: function() {
|
|
8788
|
+
return squadronJoin_1.normaliseBookingReference;
|
|
8789
|
+
} });
|
|
8790
|
+
Object.defineProperty(exports, "callsignProblem", { enumerable: true, get: function() {
|
|
8791
|
+
return squadronJoin_1.callsignProblem;
|
|
8792
|
+
} });
|
|
8793
|
+
Object.defineProperty(exports, "describeGate", { enumerable: true, get: function() {
|
|
8794
|
+
return squadronJoin_1.describeGate;
|
|
8795
|
+
} });
|
|
8796
|
+
Object.defineProperty(exports, "describeSquadronRefusal", { enumerable: true, get: function() {
|
|
8797
|
+
return squadronJoin_1.describeSquadronRefusal;
|
|
8798
|
+
} });
|
|
8799
|
+
Object.defineProperty(exports, "SQUADRON_AIRCRAFT", { enumerable: true, get: function() {
|
|
8800
|
+
return squadronJoin_1.SQUADRON_AIRCRAFT;
|
|
8801
|
+
} });
|
|
8802
|
+
Object.defineProperty(exports, "SQUADRON_COLOURS", { enumerable: true, get: function() {
|
|
8803
|
+
return squadronJoin_1.SQUADRON_COLOURS;
|
|
8804
|
+
} });
|
|
8805
|
+
var http_1 = require_http();
|
|
8806
|
+
Object.defineProperty(exports, "previewJoinCode", { enumerable: true, get: function() {
|
|
8807
|
+
return http_1.previewJoinCode;
|
|
8808
|
+
} });
|
|
8809
|
+
Object.defineProperty(exports, "startSquadronJoin", { enumerable: true, get: function() {
|
|
8810
|
+
return http_1.startSquadronJoin;
|
|
8811
|
+
} });
|
|
7459
8812
|
var liveBus_1 = require_liveBus();
|
|
7460
8813
|
Object.defineProperty(exports, "emitLiveSignal", { enumerable: true, get: function() {
|
|
7461
8814
|
return liveBus_1.emitLiveSignal;
|
|
@@ -7466,6 +8819,9 @@ var require_out3 = __commonJS({
|
|
|
7466
8819
|
Object.defineProperty(exports, "bucketPromptSize", { enumerable: true, get: function() {
|
|
7467
8820
|
return liveBus_1.bucketPromptSize;
|
|
7468
8821
|
} });
|
|
8822
|
+
Object.defineProperty(exports, "promptSizeMetadata", { enumerable: true, get: function() {
|
|
8823
|
+
return liveBus_1.promptSizeMetadata;
|
|
8824
|
+
} });
|
|
7469
8825
|
Object.defineProperty(exports, "liveBusSocketPath", { enumerable: true, get: function() {
|
|
7470
8826
|
return liveBus_1.liveBusSocketPath;
|
|
7471
8827
|
} });
|
|
@@ -7624,48 +8980,48 @@ var require_out3 = __commonJS({
|
|
|
7624
8980
|
Object.defineProperty(exports, "scriptMarkerIn", { enumerable: true, get: function() {
|
|
7625
8981
|
return agentProcess_1.scriptMarkerIn;
|
|
7626
8982
|
} });
|
|
7627
|
-
var
|
|
8983
|
+
var http_2 = require_http();
|
|
7628
8984
|
Object.defineProperty(exports, "AscendaApiError", { enumerable: true, get: function() {
|
|
7629
|
-
return
|
|
8985
|
+
return http_2.AscendaApiError;
|
|
7630
8986
|
} });
|
|
7631
8987
|
Object.defineProperty(exports, "createPairingSession", { enumerable: true, get: function() {
|
|
7632
|
-
return
|
|
8988
|
+
return http_2.createPairingSession;
|
|
7633
8989
|
} });
|
|
7634
8990
|
Object.defineProperty(exports, "getPairingStatus", { enumerable: true, get: function() {
|
|
7635
|
-
return
|
|
8991
|
+
return http_2.getPairingStatus;
|
|
7636
8992
|
} });
|
|
7637
8993
|
Object.defineProperty(exports, "getStudyJoinStatus", { enumerable: true, get: function() {
|
|
7638
|
-
return
|
|
8994
|
+
return http_2.getStudyJoinStatus;
|
|
7639
8995
|
} });
|
|
7640
8996
|
Object.defineProperty(exports, "renewToolToken", { enumerable: true, get: function() {
|
|
7641
|
-
return
|
|
8997
|
+
return http_2.renewToolToken;
|
|
7642
8998
|
} });
|
|
7643
8999
|
Object.defineProperty(exports, "postToolEvent", { enumerable: true, get: function() {
|
|
7644
|
-
return
|
|
9000
|
+
return http_2.postToolEvent;
|
|
7645
9001
|
} });
|
|
7646
9002
|
Object.defineProperty(exports, "postToolEventsBatch", { enumerable: true, get: function() {
|
|
7647
|
-
return
|
|
9003
|
+
return http_2.postToolEventsBatch;
|
|
7648
9004
|
} });
|
|
7649
9005
|
Object.defineProperty(exports, "parseIngestResponse", { enumerable: true, get: function() {
|
|
7650
|
-
return
|
|
9006
|
+
return http_2.parseIngestResponse;
|
|
7651
9007
|
} });
|
|
7652
9008
|
Object.defineProperty(exports, "isRetryableStatus", { enumerable: true, get: function() {
|
|
7653
|
-
return
|
|
9009
|
+
return http_2.isRetryableStatus;
|
|
7654
9010
|
} });
|
|
7655
9011
|
Object.defineProperty(exports, "readInitiatives", { enumerable: true, get: function() {
|
|
7656
|
-
return
|
|
9012
|
+
return http_2.readInitiatives;
|
|
7657
9013
|
} });
|
|
7658
9014
|
Object.defineProperty(exports, "readStudyNotices", { enumerable: true, get: function() {
|
|
7659
|
-
return
|
|
9015
|
+
return http_2.readStudyNotices;
|
|
7660
9016
|
} });
|
|
7661
9017
|
Object.defineProperty(exports, "markStudyNoticeShown", { enumerable: true, get: function() {
|
|
7662
|
-
return
|
|
9018
|
+
return http_2.markStudyNoticeShown;
|
|
7663
9019
|
} });
|
|
7664
9020
|
Object.defineProperty(exports, "setStudyObjection", { enumerable: true, get: function() {
|
|
7665
|
-
return
|
|
9021
|
+
return http_2.setStudyObjection;
|
|
7666
9022
|
} });
|
|
7667
9023
|
Object.defineProperty(exports, "startStudyJoin", { enumerable: true, get: function() {
|
|
7668
|
-
return
|
|
9024
|
+
return http_2.startStudyJoin;
|
|
7669
9025
|
} });
|
|
7670
9026
|
var initiatives_1 = require_initiatives();
|
|
7671
9027
|
Object.defineProperty(exports, "INITIATIVE_COPY", { enumerable: true, get: function() {
|
|
@@ -7710,6 +9066,9 @@ var require_out3 = __commonJS({
|
|
|
7710
9066
|
return studyJoin_1.runStudyJoin;
|
|
7711
9067
|
} });
|
|
7712
9068
|
var confirmLinks_1 = require_confirmLinks();
|
|
9069
|
+
Object.defineProperty(exports, "WEEKLY_POSTER_CONNECT_URL", { enumerable: true, get: function() {
|
|
9070
|
+
return confirmLinks_1.WEEKLY_POSTER_CONNECT_URL;
|
|
9071
|
+
} });
|
|
7713
9072
|
Object.defineProperty(exports, "pairingConfirmLines", { enumerable: true, get: function() {
|
|
7714
9073
|
return confirmLinks_1.pairingConfirmLines;
|
|
7715
9074
|
} });
|