sneakoscope 8.0.2 → 8.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +47 -23
  2. package/config/skills-hash-ledger.v1.json +1 -1
  3. package/crates/sks-core/Cargo.lock +1 -1
  4. package/crates/sks-core/Cargo.toml +1 -1
  5. package/dist/bin/fast-inline.js +55 -13
  6. package/dist/bin/sks-dispatch.js +1 -1
  7. package/dist/cli/command-manifest-lite.js +4 -0
  8. package/dist/cli/command-registry.js +4 -0
  9. package/dist/cli/install-helpers-codex-lb-chain.js +187 -0
  10. package/dist/cli/install-helpers-codex-lb-config.js +74 -8
  11. package/dist/cli/install-helpers.js +89 -44
  12. package/dist/commands/codex-lb.js +117 -19
  13. package/dist/commands/doctor.js +697 -37
  14. package/dist/config/skills-manifest.json +3 -2
  15. package/dist/core/agents/agent-runner-codex-exec.js +5 -3
  16. package/dist/core/codex/codex-config-guard.js +238 -52
  17. package/dist/core/codex-adapter.js +5 -3
  18. package/dist/core/codex-app/menubar/constants.js +10 -1
  19. package/dist/core/codex-app/menubar/global-install.js +288 -0
  20. package/dist/core/codex-app/menubar/installer.js +79 -14
  21. package/dist/core/codex-app/menubar/launch-agent.js +267 -45
  22. package/dist/core/codex-app/menubar/paths.js +3 -0
  23. package/dist/core/codex-app/menubar/rollback.js +55 -7
  24. package/dist/core/codex-app/menubar/status.js +75 -4
  25. package/dist/core/codex-control/codex-0139-image-path-real-probe.js +3 -1
  26. package/dist/core/codex-control/codex-0139-web-search-probe.js +3 -1
  27. package/dist/core/codex-control/codex-app-server-runtime-env.js +13 -4
  28. package/dist/core/codex-control/codex-app-server-v2-client.js +3 -3
  29. package/dist/core/codex-exec-output-schema.js +4 -1
  30. package/dist/core/codex-lb/codex-lb-env.js +63 -72
  31. package/dist/core/codex-lb/codex-lb-setup.js +15 -2
  32. package/dist/core/codex-lb/desktop-center-credentials.js +517 -58
  33. package/dist/core/codex-lb/desktop-controller.js +153 -24
  34. package/dist/core/codex-lb/routing-truth.js +327 -0
  35. package/dist/core/codex-native/core-skill-manifest.js +1 -1
  36. package/dist/core/commands/basic-cli.js +7 -1
  37. package/dist/core/commands/qa-loop-command.js +3 -1
  38. package/dist/core/commands/telegram-command.js +241 -0
  39. package/dist/core/config-adopt/config-adopt-command.js +35 -0
  40. package/dist/core/config-adopt/config-adopt.js +346 -0
  41. package/dist/core/config-adopt/index.js +3 -0
  42. package/dist/core/doctor/command-alias-cleanup.js +4 -1
  43. package/dist/core/doctor/current-project-guidance-nested.js +37 -6
  44. package/dist/core/doctor/current-project-guidance.js +11 -6
  45. package/dist/core/doctor/doctor-readiness-matrix.js +14 -0
  46. package/dist/core/doctor/retired-managed-residue-private.js +1 -1
  47. package/dist/core/doctor/sks-menubar-doctor.js +4 -0
  48. package/dist/core/feature-fixtures.js +8 -0
  49. package/dist/core/hooks-runtime/hook-context.js +9 -0
  50. package/dist/core/hooks-runtime/managed-skill-admission.js +54 -4
  51. package/dist/core/hooks-runtime/official-subagent-lifecycle.js +69 -1
  52. package/dist/core/hooks-runtime/subagent-skill-availability-contract.js +2 -2
  53. package/dist/core/hooks-runtime/subagent-skill-availability-evidence.js +3 -3
  54. package/dist/core/hooks-runtime/subagent-skill-availability-guards.js +43 -5
  55. package/dist/core/hooks-runtime/subagent-skill-availability.js +64 -30
  56. package/dist/core/hooks-runtime/subagent-stop-hook.js +15 -2
  57. package/dist/core/hooks-runtime.js +148 -4
  58. package/dist/core/imagegen/imagegen-capability.js +46 -0
  59. package/dist/core/imagegen/require-imagegen.js +2 -2
  60. package/dist/core/init/skills.js +17 -3
  61. package/dist/core/install/installed-package-smoke.js +8 -2
  62. package/dist/core/naruto/hardware-capacity-probe.js +9 -3
  63. package/dist/core/naruto/naruto-concurrency-governor.js +68 -24
  64. package/dist/core/perf/import-graph-budget.js +0 -1
  65. package/dist/core/product-design-app-server.js +13 -1
  66. package/dist/core/release/package-size-budget.js +2 -2
  67. package/dist/core/release/release-pack-receipt.js +1 -2
  68. package/dist/core/routes/dollar-manifest-lite.js +1 -1
  69. package/dist/core/routes.js +1 -1
  70. package/dist/core/security/private-credential-file.js +209 -0
  71. package/dist/core/subagents/agent-catalog.js +17 -32
  72. package/dist/core/subagents/naruto-help-contract.js +5 -5
  73. package/dist/core/subagents/official-subagent-config.js +16 -6
  74. package/dist/core/subagents/official-subagent-preparation.js +34 -15
  75. package/dist/core/subagents/official-subagent-prompt.js +4 -4
  76. package/dist/core/subagents/official-subagent-runner.js +27 -4
  77. package/dist/core/subagents/thread-budget.js +19 -12
  78. package/dist/core/subagents/wave-lifecycle.js +18 -6
  79. package/dist/core/telegram/access.js +54 -0
  80. package/dist/core/telegram/client.js +144 -0
  81. package/dist/core/telegram/confirmation.js +37 -0
  82. package/dist/core/telegram/doctor.js +151 -0
  83. package/dist/core/telegram/index.js +9 -0
  84. package/dist/core/telegram/keychain.js +265 -0
  85. package/dist/core/telegram/liveness.js +109 -0
  86. package/dist/core/telegram/poller.js +90 -0
  87. package/dist/core/telegram/redaction.js +15 -0
  88. package/dist/core/telegram/types.js +1 -0
  89. package/dist/core/update/update-diagnostics.js +52 -0
  90. package/dist/core/update/update-migration-state.js +5 -1
  91. package/dist/core/update/update-operation.js +2 -1
  92. package/dist/core/update/update-stage-diagnostics.js +38 -0
  93. package/dist/core/update/update-status.js +2 -9
  94. package/dist/core/update-check.js +147 -31
  95. package/dist/core/version.js +1 -1
  96. package/dist/core/zellij/zellij-launcher.js +23 -4
  97. package/dist/native/sks-menubar/Sources/AppDelegate.swift +13 -0
  98. package/dist/native/sks-menubar/Sources/AppIdentity.swift +7 -0
  99. package/dist/native/sks-menubar/Sources/OperationCoordinator.swift +3 -2
  100. package/dist/native/sks-menubar/Sources/ProvidersConnectTest.swift +115 -0
  101. package/dist/native/sks-menubar/Sources/ProvidersFastMode.swift +17 -0
  102. package/dist/native/sks-menubar/Sources/ProvidersRoutingTruth.swift +190 -0
  103. package/dist/native/sks-menubar/Sources/ProvidersViewController.swift +100 -59
  104. package/dist/native/sks-menubar/Sources/SingletonInstanceGuard.swift +328 -0
  105. package/dist/native/sks-menubar/Sources/TelegramPrivateFileStore.swift +320 -0
  106. package/dist/native/sks-menubar/Sources/TelegramPrivateFileSupport.swift +303 -0
  107. package/dist/native/sks-menubar/Sources/TelegramProcessGateway.swift +238 -0
  108. package/dist/native/sks-menubar/Sources/TelegramRuntimeSupport.swift +56 -0
  109. package/dist/native/sks-menubar/Sources/TelegramSupport.swift +56 -0
  110. package/dist/native/sks-menubar/Sources/TelegramTransport.swift +474 -0
  111. package/dist/native/sks-menubar/Sources/main.swift +15 -1
  112. package/dist/native/sks-menubar/Tests/OperationCoordinatorTests.swift +4 -3
  113. package/dist/native/sks-menubar/Tests/ProvidersViewControllerTests.swift +129 -0
  114. package/dist/native/sks-menubar/Tests/SingletonInstanceGuardTests.swift +183 -0
  115. package/dist/native/sks-menubar/Tests/TelegramRuntimeSmokeTests.swift +267 -0
  116. package/dist/native/sks-menubar/Tests/TelegramRuntimeTests.swift +222 -0
  117. package/dist/scripts/codex-lb-fast-mode-truth-check.js +1 -1
  118. package/dist/scripts/codex-lb-fast-ui-preservation-check.js +1 -1
  119. package/dist/scripts/current-command-surface-check.js +2 -4
  120. package/dist/scripts/official-subagent-workflow-check.js +1 -1
  121. package/dist/scripts/packlist-performance-check.js +1 -2
  122. package/package.json +1 -1
@@ -0,0 +1,52 @@
1
+ import os from 'node:os';
2
+ export function deepestUpdateErrorCause(error) {
3
+ let current = error;
4
+ const seen = new Set();
5
+ for (let depth = 0; depth < 16; depth += 1) {
6
+ if (!current || typeof current !== 'object')
7
+ break;
8
+ if (seen.has(current))
9
+ break;
10
+ seen.add(current);
11
+ let cause;
12
+ try {
13
+ cause = current.cause;
14
+ }
15
+ catch {
16
+ break;
17
+ }
18
+ if (cause === undefined || cause === null || cause === current)
19
+ break;
20
+ current = cause;
21
+ }
22
+ return current;
23
+ }
24
+ export function publicUpdateError(error, env = process.env, maxLength = 400) {
25
+ const deepest = deepestUpdateErrorCause(error);
26
+ let value = updateErrorText(deepest)
27
+ || updateErrorText(error)
28
+ || 'update status refresh failed';
29
+ value = value.replace(/[\r\n]+/g, ' ');
30
+ const home = env.HOME || os.homedir();
31
+ if (home)
32
+ value = value.replaceAll(home, '~');
33
+ return value
34
+ .replace(/sk-(?:proj|or-v1|clb)?-?[A-Za-z0-9_-]{12,}/g, '[redacted]')
35
+ .replace(/(api[_-]?key|secret|token|authorization)\s*[:=]\s*[^\s"',}]+/gi, '$1=[redacted]')
36
+ .slice(0, Math.max(1, maxLength));
37
+ }
38
+ function updateErrorText(value) {
39
+ if (value instanceof Error)
40
+ return value.message;
41
+ if (typeof value === 'string')
42
+ return value;
43
+ if (typeof value === 'number' || typeof value === 'bigint' || typeof value === 'boolean') {
44
+ return String(value);
45
+ }
46
+ if (value && typeof value === 'object') {
47
+ const message = value.message;
48
+ if (typeof message === 'string')
49
+ return message;
50
+ }
51
+ return '';
52
+ }
@@ -313,7 +313,11 @@ async function runCurrentPublicSurfaceReconcileStage(root) {
313
313
  ...(retiredBindings.status === 'quarantined' ? ['retired_remote_bridge_bindings_quarantined'] : [])
314
314
  ],
315
315
  blockers,
316
- warnings: [...retiredLaunchAgent.warnings, ...retiredBindings.warnings],
316
+ warnings: [
317
+ ...(publicSurface.warnings || []),
318
+ ...retiredLaunchAgent.warnings,
319
+ ...retiredBindings.warnings
320
+ ],
317
321
  detail: {
318
322
  removed_skill_count: Number(publicSurface.cleanup?.removed_count || 0),
319
323
  quarantined_skill_collision_count: Number(publicSurface.cleanup?.preserved_user_collision_count || 0),
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import { createHash } from 'node:crypto';
5
5
  import { spawnSync } from 'node:child_process';
6
6
  import { canonicalFilesystemPath, randomId, sameFilesystemPath, writeJsonAtomic } from '../fsx.js';
7
+ import { publicUpdateError } from './update-diagnostics.js';
7
8
  export const UPDATE_OPERATION_SCHEMA = 'sks.update-operation.v1';
8
9
  const ROLLBACK_RECEIPT_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;
9
10
  const ROLLBACK_RECEIPT_SCAN_MAX_DIRECTORY_ENTRIES = 4096;
@@ -97,7 +98,7 @@ export class UpdateOperationRecorder {
97
98
  await this.flush();
98
99
  this.receipt.state = input.state;
99
100
  this.receipt.result_status = input.resultStatus;
100
- this.receipt.public_error = input.error ? publicString(input.error, this.env) : null;
101
+ this.receipt.public_error = input.error ? publicUpdateError(input.error, this.env, 500) : null;
101
102
  this.receipt.updated_at = new Date().toISOString();
102
103
  await writePrivateJson(this.receiptPath, this.receipt);
103
104
  const confirmedInstall = this.receipt.kind === 'update'
@@ -0,0 +1,38 @@
1
+ import path from 'node:path';
2
+ import { formatUpdateBlockerWithRemedy } from '../config-adopt/config-adopt.js';
3
+ const MAX_STAGE_BLOCKERS = 16;
4
+ const MAX_BLOCKER_LENGTH = 500;
5
+ export function updateStageFailureDiagnostics(stage, projectRoot) {
6
+ if (stage.ok)
7
+ return [];
8
+ const detail = stage.detail || {};
9
+ const explicitBlockers = [
10
+ ...normalizeBlockers(detail.required_blockers),
11
+ ...normalizeBlockers(detail.blockers),
12
+ ...normalizeBlockers(detail.blocker)
13
+ ];
14
+ const blockers = explicitBlockers.length
15
+ ? explicitBlockers
16
+ : [
17
+ ...normalizeSafeFallback(detail.reason),
18
+ ...normalizeSafeFallback(detail.error)
19
+ ];
20
+ if (!blockers.length)
21
+ return [];
22
+ const configPath = typeof detail.config_path === 'string' && detail.config_path.trim()
23
+ ? detail.config_path
24
+ : path.join(typeof detail.root === 'string' && detail.root.trim() ? detail.root : projectRoot, '.codex', 'config.toml');
25
+ return [...new Set(blockers)]
26
+ .slice(0, MAX_STAGE_BLOCKERS)
27
+ .map((blocker) => formatUpdateBlockerWithRemedy(blocker, configPath))
28
+ .filter(Boolean);
29
+ }
30
+ function normalizeBlockers(value) {
31
+ const values = Array.isArray(value) ? value : typeof value === 'string' ? [value] : [];
32
+ return values
33
+ .map((entry) => String(entry || '').replace(/[\r\n]+/g, ' ').trim().slice(0, MAX_BLOCKER_LENGTH))
34
+ .filter(Boolean);
35
+ }
36
+ function normalizeSafeFallback(value) {
37
+ return normalizeBlockers(value).filter((entry) => /^[A-Za-z0-9_.:-]{1,200}$/.test(entry));
38
+ }
@@ -3,6 +3,7 @@ import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { readJson, writeJsonAtomic } from '../fsx.js';
5
5
  import { compareSemVer, isSemVerUpdateAvailable } from './semver.js';
6
+ import { publicUpdateError } from './update-diagnostics.js';
6
7
  export const SKS_UPDATE_STATUS_SCHEMA = 'sks.update-status.v3';
7
8
  export const DEFAULT_UPDATE_STATUS_TTL_MS = 6 * 60 * 60 * 1000;
8
9
  export const MAX_UPDATE_STATUS_JITTER_MS = 15 * 60 * 1000;
@@ -294,15 +295,7 @@ function updateChecksDisabled(env) {
294
295
  || env.SKS_UPDATE_NOTICE === '0';
295
296
  }
296
297
  function publicError(error, env) {
297
- let value = error instanceof Error ? error.message : String(error || 'update status refresh failed');
298
- value = value.replace(/[\r\n]+/g, ' ');
299
- const home = env.HOME || os.homedir();
300
- if (home)
301
- value = value.replaceAll(home, '~');
302
- value = value
303
- .replace(/sk-(?:proj|or-v1|clb)?-?[A-Za-z0-9_-]{12,}/g, '[redacted]')
304
- .replace(/(api[_-]?key|secret|token|authorization)\s*[:=]\s*[^\s"',}]+/gi, '$1=[redacted]');
305
- return value.slice(0, 400);
298
+ return publicUpdateError(error, env);
306
299
  }
307
300
  function parsedTime(value) {
308
301
  const parsed = Date.parse(String(value || ''));
@@ -13,6 +13,7 @@ import { compareSemVer, extractSemVer, parseSemVer } from './update/semver.js';
13
13
  import { countUpdates, emptyUpdateStatus, resolveSksUpdateStatus, UpdateStatusRefreshError } from './update/update-status.js';
14
14
  import { acquireUpdateOperationLock, authorizeUpdateRollback, buildUpdateNowCommand, buildUpdateRollbackCommand, canonicalUpdateRegistry, UpdateOperationRecorder, updateOperationLastInstallPath, updateReceiptHasConfirmedGlobalInstall } from './update/update-operation.js';
15
15
  import { runTemporaryInstallSmoke } from './update/temporary-install-smoke.js';
16
+ import { updateStageFailureDiagnostics } from './update/update-stage-diagnostics.js';
16
17
  import { ui as cliUi, withHeartbeat } from '../cli/cli-theme.js';
17
18
  const DEFAULT_REGISTRY = 'https://registry.npmjs.org/';
18
19
  const DOCTOR_OWNED_UPDATE_MIGRATION_SINCE = '8.0.2';
@@ -275,6 +276,7 @@ export const UPDATE_STAGE_ORDER = [
275
276
  'native_capability_setup',
276
277
  'menubar_rebuild',
277
278
  'menubar_signature_verify',
279
+ 'menubar_version_probe',
278
280
  'update_finalize_doctor',
279
281
  'final_self_verification',
280
282
  'snapshot_refresh'
@@ -566,7 +568,7 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
566
568
  operationRecorder.recordStage(id, false, status, detail);
567
569
  await operationRecorder.flush();
568
570
  };
569
- const finalize = async (result) => {
571
+ const finalize = async (result, operationError = result.error) => {
570
572
  result.temporary_install_smoke = temporaryInstallSmoke;
571
573
  result.operation_receipt_path = operationRecorder.receiptPath;
572
574
  const finished = await operationRecorder.finish({
@@ -574,7 +576,7 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
574
576
  ? 'terminal_uncertain'
575
577
  : result.ok ? (activeRollbackAuthorization ? 'rolled_back' : 'succeeded') : 'failed',
576
578
  resultStatus: result.status,
577
- error: result.error
579
+ error: operationError
578
580
  });
579
581
  operationFinished = true;
580
582
  if (finished.state === 'terminal_uncertain' && result.status !== 'terminal_uncertain') {
@@ -790,7 +792,14 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
790
792
  }).catch(() => null);
791
793
  let migrationCurrent = isUpdateMigrationReceiptCurrent(receipt);
792
794
  recordMigrationReceiptStage(stage, 'hook_trust_repair', receipt, 'hook-trust-refresh');
793
- stage('project_receipt', migrationCurrent, migrationCurrent ? 'current' : 'failed', { root: projectReceiptRoot });
795
+ stage('project_receipt', migrationCurrent, migrationCurrent ? 'current' : 'failed', {
796
+ root: projectReceiptRoot,
797
+ receipt_status: receipt?.status || null,
798
+ receipt_version: receipt?.sks_version || null,
799
+ required_blockers: receipt?.required_blockers || [],
800
+ optional_warnings: receipt?.optional_warnings || [],
801
+ installation_epoch_sha256: receipt?.installation_epoch_sha256 || null
802
+ });
794
803
  recordMigrationReceiptStage(stage, 'global_skills_reconcile', receipt, 'skills-reconcile');
795
804
  stage('native_capability_setup', true, 'skipped_current', { reason: 'package_already_current' });
796
805
  const sksMenuBar = migrationCurrent
@@ -804,6 +813,7 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
804
813
  env
805
814
  });
806
815
  stage('menubar_signature_verify', menuVerification.ok, menuVerification.status, menuVerification.detail);
816
+ stage('menubar_version_probe', menuVerification.versionProbe.ok, menuVerification.versionProbe.status, menuVerification.versionProbe.detail);
807
817
  const currentFinalizeDoctor = await runUpdateFinalizeDoctor({
808
818
  root: projectReceiptRoot,
809
819
  env: nestedProcessEnv,
@@ -813,7 +823,9 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
813
823
  entrypoint: currentFinalizeDoctor.entrypoint,
814
824
  args: currentFinalizeDoctor.args,
815
825
  exit_code: currentFinalizeDoctor.exit_code,
816
- timed_out: currentFinalizeDoctor.timed_out
826
+ timed_out: currentFinalizeDoctor.timed_out,
827
+ required_blockers: currentFinalizeDoctor.required_blockers,
828
+ optional_warnings: currentFinalizeDoctor.optional_warnings
817
829
  });
818
830
  const finalCurrentReceipt = await readProjectUpdateMigrationReceipt(projectReceiptRoot);
819
831
  if (finalCurrentReceipt)
@@ -833,6 +845,16 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
833
845
  && snapshotOk
834
846
  && currentStageFailures.length === 0
835
847
  && !currentMenuBarTerminalUncertain;
848
+ const currentError = currentOk ? null : currentMenuBarTerminalUncertain
849
+ ? 'Menu Bar launch or rollback completion could not be confirmed'
850
+ : currentFinalizeDoctor.ok
851
+ ? currentStageFailures.length
852
+ ? `current-version repair verification failed: ${currentStageFailures.join(',')}`
853
+ : 'current-version repair verification failed'
854
+ : 'current-version repair verification failed: update_finalize_doctor';
855
+ const currentOperationError = currentError && currentStageFailures.length
856
+ ? requiredUpdateStageFailureError(currentError, stages, currentStageFailures, projectReceiptRoot)
857
+ : currentError;
836
858
  return finalize(buildUpdateNowResult({
837
859
  packageName,
838
860
  from: check.current,
@@ -857,14 +879,8 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
857
879
  migrationCurrent,
858
880
  sksMenuBar,
859
881
  stages,
860
- error: currentOk ? null : currentMenuBarTerminalUncertain
861
- ? 'Menu Bar launch or rollback completion could not be confirmed'
862
- : currentFinalizeDoctor.ok
863
- ? currentStageFailures.length
864
- ? `current-version repair verification failed: ${currentStageFailures.join(',')}`
865
- : 'current-version repair verification failed'
866
- : 'current-version repair verification failed: update_finalize_doctor'
867
- }));
882
+ error: currentError
883
+ }), currentOperationError);
868
884
  }
869
885
  const oldDoctorTimeoutOverride = Number.parseInt(env.SKS_UPDATE_OLD_DOCTOR_TIMEOUT_MS || '', 10);
870
886
  const oldDoctorTimeoutMs = Number.isFinite(oldDoctorTimeoutOverride) && oldDoctorTimeoutOverride > 0
@@ -1008,7 +1024,13 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
1008
1024
  timeoutMs: updateDoctorTimeoutMs(env),
1009
1025
  maxOutputBytes: 32 * 1024
1010
1026
  }), 60_000);
1011
- stage('new_version_doctor', newVersionDoctor.ok, newVersionDoctor.status, { entrypoint: newBinary, exit_code: newVersionDoctor.exit_code, timeout_ms: updateDoctorTimeoutMs(env), timed_out: newVersionDoctor.timedOut });
1027
+ stage('new_version_doctor', newVersionDoctor.ok, newVersionDoctor.status, {
1028
+ entrypoint: newBinary,
1029
+ exit_code: newVersionDoctor.exit_code,
1030
+ timeout_ms: updateDoctorTimeoutMs(env),
1031
+ timed_out: newVersionDoctor.timedOut,
1032
+ required_blockers: newVersionDoctor.required_blockers
1033
+ });
1012
1034
  }
1013
1035
  if (newBinary && newVersionDoctor?.ok) {
1014
1036
  const doctorReceipt = await readProjectUpdateMigrationReceipt(projectReceiptRoot);
@@ -1048,6 +1070,8 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
1048
1070
  via: receiptResult.via,
1049
1071
  expected_version: installVersion,
1050
1072
  receipt_version: projectReceipt?.sks_version || null,
1073
+ required_blockers: projectReceipt?.required_blockers || [],
1074
+ optional_warnings: projectReceipt?.optional_warnings || [],
1051
1075
  error: receiptResult.error
1052
1076
  });
1053
1077
  recordMigrationReceiptStage(stage, 'global_skills_reconcile', projectReceipt, 'skills-reconcile');
@@ -1073,6 +1097,7 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
1073
1097
  });
1074
1098
  menubarVerified = menuVerification.ok;
1075
1099
  stage('menubar_signature_verify', menuVerification.ok, menuVerification.status, menuVerification.detail);
1100
+ stage('menubar_version_probe', menuVerification.versionProbe.ok, menuVerification.versionProbe.status, menuVerification.versionProbe.detail);
1076
1101
  }
1077
1102
  }
1078
1103
  }
@@ -1089,7 +1114,9 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
1089
1114
  entrypoint: finalizeDoctor.entrypoint,
1090
1115
  args: finalizeDoctor.args,
1091
1116
  exit_code: finalizeDoctor.exit_code,
1092
- timed_out: finalizeDoctor.timed_out
1117
+ timed_out: finalizeDoctor.timed_out,
1118
+ required_blockers: finalizeDoctor.required_blockers,
1119
+ optional_warnings: finalizeDoctor.optional_warnings
1093
1120
  } : {})
1094
1121
  });
1095
1122
  if (finalizeDoctor) {
@@ -1122,6 +1149,7 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
1122
1149
  });
1123
1150
  const executionStageIds = UPDATE_STAGE_ORDER.filter((id) => !['update_finalize_doctor', 'final_self_verification', 'snapshot_refresh'].includes(id));
1124
1151
  const executionStageFailures = requiredUpdateStageFailures(stages, executionStageIds);
1152
+ const allStageFailures = requiredUpdateStageFailures(stages, UPDATE_STAGE_ORDER);
1125
1153
  const baseOk = installOk && Boolean(newBinary) && newVersionDoctor?.ok === true
1126
1154
  && migrationCurrent && menubarVerified && executionStageFailures.length === 0;
1127
1155
  const ok = baseOk && verifyOk && snapshotOk;
@@ -1130,6 +1158,23 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
1130
1158
  const status = terminalUncertain
1131
1159
  ? 'terminal_uncertain'
1132
1160
  : ok ? 'updated' : baseOk ? 'updated_with_issues' : 'failed';
1161
+ const stageFailureError = executionStageFailures.length
1162
+ ? requiredUpdateStageFailureError(`required update stages failed: ${executionStageFailures.join(',')}`, stages, executionStageFailures, projectReceiptRoot)
1163
+ : null;
1164
+ const resultError = terminalUncertain
1165
+ ? menuBarTerminalUncertain
1166
+ ? 'Menu Bar launch or rollback completion could not be confirmed'
1167
+ : 'global install timed out; package side-effect completion is uncertain'
1168
+ : ok ? null
1169
+ : stageFailureError
1170
+ ? stageFailureError.message
1171
+ : status === 'updated_with_issues'
1172
+ ? verificationError(verification, finalizeDoctor)
1173
+ : updateNowError(install, newBinary, newVersionDoctor, migrationCurrent);
1174
+ const resultOperationError = stageFailureError
1175
+ || (resultError && allStageFailures.length
1176
+ ? requiredUpdateStageFailureError(resultError, stages, allStageFailures, projectReceiptRoot)
1177
+ : resultError);
1133
1178
  return finalize(buildUpdateNowResult({
1134
1179
  packageName,
1135
1180
  from: check.current,
@@ -1155,17 +1200,8 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
1155
1200
  sksMenuBar,
1156
1201
  stages,
1157
1202
  verification,
1158
- error: terminalUncertain
1159
- ? menuBarTerminalUncertain
1160
- ? 'Menu Bar launch or rollback completion could not be confirmed'
1161
- : 'global install timed out; package side-effect completion is uncertain'
1162
- : ok ? null
1163
- : executionStageFailures.length
1164
- ? `required update stages failed: ${executionStageFailures.join(',')}`
1165
- : status === 'updated_with_issues'
1166
- ? verificationError(verification, finalizeDoctor)
1167
- : updateNowError(install, newBinary, newVersionDoctor, migrationCurrent)
1168
- }));
1203
+ error: resultError
1204
+ }), resultOperationError);
1169
1205
  }
1170
1206
  catch (error) {
1171
1207
  if (operation && !operationFinished) {
@@ -1173,7 +1209,7 @@ async function runSksUpdateNowInternal(options, rollbackAuthorization) {
1173
1209
  await operation.finish({
1174
1210
  state: 'failed',
1175
1211
  resultStatus: 'failed',
1176
- error: error instanceof Error ? error.message : String(error)
1212
+ error
1177
1213
  });
1178
1214
  operationFinished = true;
1179
1215
  }
@@ -1193,15 +1229,31 @@ function requiredUpdateStageFailures(stages, requiredIds) {
1193
1229
  return matches.length !== 1 || matches[0]?.ok !== true;
1194
1230
  });
1195
1231
  }
1232
+ function requiredUpdateStageFailureError(message, stages, failedIds, projectRoot) {
1233
+ for (const id of failedIds) {
1234
+ for (const stage of stages.filter((entry) => entry.id === id && entry.ok !== true)) {
1235
+ const rootCause = updateStageFailureDiagnostics(stage, projectRoot)[0];
1236
+ if (rootCause)
1237
+ return new Error(message, { cause: new Error(rootCause) });
1238
+ }
1239
+ }
1240
+ return new Error(message);
1241
+ }
1196
1242
  export function menuBarInstallIsTerminalUncertain(result) {
1197
1243
  return result?.status === 'terminal_uncertain'
1198
1244
  || result?.launch?.terminal_uncertain === true
1199
1245
  || result?.rollback?.status === 'terminal_uncertain';
1200
1246
  }
1201
1247
  async function runUpdateFinalizeDoctor(opts) {
1202
- const env = opts.env.SKS_TEST_FINALIZE_DOCTOR_FAIL === '1'
1203
- ? { ...opts.env, SKS_TEST_DOCTOR_FAIL: '1' }
1204
- : opts.env;
1248
+ const env = opts.env.SKS_TEST_FINALIZE_DOCTOR_USER_CONFIG_PRESERVED === '1'
1249
+ ? {
1250
+ ...opts.env,
1251
+ SKS_TEST_DOCTOR_FAIL: undefined,
1252
+ SKS_TEST_DOCTOR_USER_CONFIG_PRESERVED: '1'
1253
+ }
1254
+ : opts.env.SKS_TEST_FINALIZE_DOCTOR_FAIL === '1'
1255
+ ? { ...opts.env, SKS_TEST_DOCTOR_FAIL: '1' }
1256
+ : opts.env;
1205
1257
  return updateHeartbeat(opts.machineOutput, 'update finalize doctor', runPackageLocalDoctor({
1206
1258
  root: opts.root,
1207
1259
  ...(opts.entrypoint ? { entrypoint: opts.entrypoint } : {}),
@@ -1614,10 +1666,42 @@ function buildUpdateNowResult(input) {
1614
1666
  }
1615
1667
  async function verifyUpdateMenuBar(input) {
1616
1668
  if (process.platform !== 'darwin' || input.env.SKS_UPDATE_SKIP_SKS_MENUBAR === '1') {
1617
- return { ok: true, status: 'skipped', detail: { reason: process.platform !== 'darwin' ? 'not_macos' : 'SKS_UPDATE_SKIP_SKS_MENUBAR=1' } };
1669
+ const reason = process.platform !== 'darwin' ? 'not_macos' : 'SKS_UPDATE_SKIP_SKS_MENUBAR=1';
1670
+ return {
1671
+ ok: true,
1672
+ status: 'skipped',
1673
+ detail: { reason },
1674
+ versionProbe: {
1675
+ ok: true,
1676
+ status: 'skipped',
1677
+ detail: {
1678
+ running_version: null,
1679
+ running_pid: null,
1680
+ expected_version: input.expectedVersion,
1681
+ probe_ok: true,
1682
+ reason
1683
+ }
1684
+ }
1685
+ };
1618
1686
  }
1619
1687
  if (!input.install || input.install.ok === false) {
1620
- return { ok: false, status: 'install_failed', detail: { blockers: input.install?.blockers || ['menubar_install_missing'] } };
1688
+ const blockers = input.install?.blockers || ['menubar_install_missing'];
1689
+ return {
1690
+ ok: false,
1691
+ status: 'install_failed',
1692
+ detail: { blockers },
1693
+ versionProbe: {
1694
+ ok: false,
1695
+ status: 'install_failed',
1696
+ detail: {
1697
+ running_version: null,
1698
+ running_pid: null,
1699
+ expected_version: input.expectedVersion,
1700
+ probe_ok: false,
1701
+ blockers
1702
+ }
1703
+ }
1704
+ };
1621
1705
  }
1622
1706
  const status = await inspectSksMenuBarStatus({
1623
1707
  ...(input.home === undefined ? {} : { home: input.home }),
@@ -1629,6 +1713,25 @@ async function verifyUpdateMenuBar(input) {
1629
1713
  const signatureOk = status?.signature.checked === true && status.signature.ok === true;
1630
1714
  const resourcesOk = resources?.checked === true && resources.ok === true;
1631
1715
  const ok = status?.installed === true && versionOk && signatureOk && resourcesOk;
1716
+ const runningProcess = status?.running_process || input.install.running_process;
1717
+ const probe = status?.menubar_version_probe || input.install.menubar_version_probe;
1718
+ const launchExpected = input.install.launch?.requested === true;
1719
+ const restartDeferred = input.env.SKS_UPDATE_DEFER_MENUBAR_RESTART === '1';
1720
+ const runningVersion = runningProcess?.package_version || probe?.running_version || null;
1721
+ const runningPid = runningProcess?.pid || probe?.pid || null;
1722
+ const runningProcessOk = runningProcess?.ok === true && runningPid !== null;
1723
+ const runningVersionOk = runningVersion === input.expectedVersion;
1724
+ const probeOk = probe?.ok === true && runningProcessOk && runningVersionOk;
1725
+ const versionProbeOk = !launchExpected || probeOk;
1726
+ const versionProbeStatus = !launchExpected
1727
+ ? restartDeferred ? 'restart_deferred' : 'launch_not_requested'
1728
+ : !runningProcessOk
1729
+ ? 'running_process_missing'
1730
+ : !runningVersionOk
1731
+ ? 'running_version_mismatch'
1732
+ : probe?.ok !== true
1733
+ ? 'probe_failed'
1734
+ : 'verified';
1632
1735
  return {
1633
1736
  ok,
1634
1737
  status: ok ? 'verified' : 'failed',
@@ -1640,6 +1743,19 @@ async function verifyUpdateMenuBar(input) {
1640
1743
  resources_ok: resourcesOk,
1641
1744
  missing_resources: resources?.missing || [],
1642
1745
  mismatched_resources: resources?.mismatched || []
1746
+ },
1747
+ versionProbe: {
1748
+ ok: versionProbeOk,
1749
+ status: versionProbeStatus,
1750
+ detail: {
1751
+ running_version: runningVersion,
1752
+ running_pid: runningPid,
1753
+ expected_version: input.expectedVersion,
1754
+ probe_ok: probeOk,
1755
+ launch_expected: launchExpected,
1756
+ restart_deferred: restartDeferred,
1757
+ probe_error: probe?.error || runningProcess?.error || null
1758
+ }
1643
1759
  }
1644
1760
  };
1645
1761
  }
@@ -1 +1 @@
1
- export const PACKAGE_VERSION = '8.0.2';
1
+ export const PACKAGE_VERSION = '8.0.3';
@@ -3,6 +3,7 @@ import { spawnSync } from 'node:child_process';
3
3
  import { appendJsonl, nowIso, sha256, writeJsonAtomic } from '../fsx.js';
4
4
  import { inspectCodexLbCliLaunchRecovery } from '../codex-control/codex-lb-launch-recovery.js';
5
5
  import { codexLbToolOutputRecoveryNotChecked } from '../codex-lb/codex-lb-tool-output-recovery.js';
6
+ import { prepareCodexAppServerRuntimeEnv } from '../codex-control/codex-app-server-runtime-env.js';
6
7
  import { checkZellijCapability } from './zellij-capability.js';
7
8
  import { estimateZellijSocketPathLength, formatZellijCommand, resolveZellijProcessEnvMeta, runZellij, ZELLIJ_UNIX_SOCKET_PATH_LIMIT } from './zellij-command.js';
8
9
  import { writeZellijLayout } from './zellij-layout-builder.js';
@@ -16,16 +17,20 @@ export async function launchZellijLayout(opts = {}) {
16
17
  const missionId = String(opts.missionId || `M-${Date.now().toString(36)}`);
17
18
  const ledgerRoot = path.resolve(opts.ledgerRoot || path.join(root, '.sneakoscope', 'missions', missionId, 'agents'));
18
19
  const sessionName = sanitizeZellijSessionName(opts.session || `sks-${missionId}`);
20
+ const kind = opts.kind || 'naruto';
21
+ const requestedCodexArgs = opts.codexArgs || [];
22
+ const shouldLaunchCodex = kind === 'mad' || requestedCodexArgs.length > 0;
23
+ const layoutLaunchEnv = await prepareZellijCodexLaunchEnv(opts, shouldLaunchCodex);
19
24
  const layoutInput = {
20
25
  missionId,
21
26
  sessionName,
22
27
  ledgerRoot,
23
28
  cwd: opts.cwd || root,
24
- kind: opts.kind || 'naruto',
29
+ kind,
25
30
  slotCount: opts.slotCount ?? 1,
26
31
  title: `SKS ${opts.kind || 'naruto'} ${missionId}`,
27
- codexArgs: opts.codexArgs || [],
28
- launchEnv: opts.launchEnv || {}
32
+ codexArgs: requestedCodexArgs,
33
+ launchEnv: layoutLaunchEnv
29
34
  };
30
35
  if (opts.codexBin)
31
36
  layoutInput.codexBin = opts.codexBin;
@@ -35,7 +40,7 @@ export async function launchZellijLayout(opts = {}) {
35
40
  const clipboard = await writeZellijClipboardConfig(root, missionId);
36
41
  const createCommand = ['attach', '--create-background', sessionName, 'options', '--default-layout', layout.layout_path, ...clipboard.optionFlags];
37
42
  const attachCommand = ['attach', sessionName];
38
- const launchProcessEnv = launchRecoveryEnv(opts.launchEnv);
43
+ const launchProcessEnv = launchRecoveryEnv(layoutLaunchEnv);
39
44
  const zellijEnv = resolveZellijProcessEnvMeta(launchProcessEnv);
40
45
  const willCreateSession = opts.dryRun !== true && capability.status === 'ok';
41
46
  const codexLaunchRecovery = layout.main_pane_kind === 'codex_interactive' && willCreateSession
@@ -188,6 +193,20 @@ function launchRecoveryEnv(launchEnv) {
188
193
  }
189
194
  return env;
190
195
  }
196
+ async function prepareZellijCodexLaunchEnv(opts, shouldLaunchCodex) {
197
+ if (!shouldLaunchCodex)
198
+ return { ...(opts.launchEnv || {}) };
199
+ const launchEnv = { ...(opts.launchEnv || {}) };
200
+ delete launchEnv.CODEX_LB_API_KEY;
201
+ delete launchEnv.CODEX_LB_BASE_URL;
202
+ const prepare = opts.prepareCodexRuntimeEnvImpl || prepareCodexAppServerRuntimeEnv;
203
+ const runtimeEnv = await prepare({ env: launchRecoveryEnv(opts.launchEnv) });
204
+ if (runtimeEnv.CODEX_LB_API_KEY)
205
+ launchEnv.CODEX_LB_API_KEY = runtimeEnv.CODEX_LB_API_KEY;
206
+ if (runtimeEnv.CODEX_LB_BASE_URL)
207
+ launchEnv.CODEX_LB_BASE_URL = runtimeEnv.CODEX_LB_BASE_URL;
208
+ return launchEnv;
209
+ }
191
210
  export async function launchMadZellijUi(args = [], opts = {}) {
192
211
  const session = readOption(args, '--session', opts.session || readOption(args, '--workspace', null));
193
212
  const launchOpts = {
@@ -1,11 +1,18 @@
1
1
  import Cocoa
2
2
 
3
3
  final class AppDelegate: NSObject, NSApplicationDelegate {
4
+ private let singletonGuard: SingletonInstanceGuard
4
5
  private var processClient: ProcessClient!
5
6
  private var operations: OperationCoordinator!
6
7
  private var notifications: NotificationCoordinator!
7
8
  private var controlCenter: ControlCenterWindowController!
8
9
  private var statusItemController: StatusItemController!
10
+ private var telegramService: TelegramMenuBarService?
11
+
12
+ init(singletonGuard: SingletonInstanceGuard) {
13
+ self.singletonGuard = singletonGuard
14
+ super.init()
15
+ }
9
16
 
10
17
  func applicationDidFinishLaunching(_ notification: Notification) {
11
18
  NSApp.setActivationPolicy(.accessory)
@@ -14,6 +21,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
14
21
  // never reaches NSTextField/NSTextView responders without an explicit menu.
15
22
  AppIdentity.installStandardEditMenu()
16
23
  processClient = ProcessClient(actionScript: AppRuntime.actionScript, logPath: AppRuntime.lastActionLogPath, projectRoot: AppRuntime.projectRoot)
24
+ telegramService = TelegramRuntimeFactory.make(processClient: processClient)
25
+ _ = telegramService?.start()
17
26
  operations = OperationCoordinator(directory: AppRuntime.operationDirectory)
18
27
  notifications = NotificationCoordinator()
19
28
  controlCenter = ControlCenterWindowController(
@@ -39,8 +48,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
39
48
  }
40
49
 
41
50
  func applicationWillTerminate(_ notification: Notification) {
51
+ if telegramService?.stopAndWait(timeout: 2) == false {
52
+ fputs("SKS Telegram bounded stop timed out; liveness will become stale.\n", stderr)
53
+ }
42
54
  statusItemController?.stop()
43
55
  processClient?.terminateAll()
56
+ singletonGuard.releaseRuntimeStateIfOwned()
44
57
  }
45
58
 
46
59
  func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
@@ -1,6 +1,13 @@
1
1
  import Cocoa
2
2
 
3
3
  enum AppIdentity {
4
+ static let bundleIdentifier = "com.sneakoscope.sks-menubar"
5
+
6
+ static var buildVersion: String {
7
+ Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
8
+ ?? AppRuntime.packageVersion
9
+ }
10
+
4
11
  static func configure() {
5
12
  if let url = Bundle.main.url(forResource: "AppIcon", withExtension: "icns"),
6
13
  let image = NSImage(contentsOf: url) {
@@ -92,11 +92,12 @@ final class OperationCoordinator {
92
92
  "preflight", "download_or_registry_check", "temporary_install_smoke", "global_install",
93
93
  "resolve_new_binary", "version_probe", "new_version_doctor", "hook_trust_repair",
94
94
  "project_receipt", "global_skills_reconcile", "native_capability_setup", "menubar_rebuild",
95
- "menubar_signature_verify", "update_finalize_doctor", "final_self_verification", "snapshot_refresh"
95
+ "menubar_signature_verify", "menubar_version_probe", "update_finalize_doctor",
96
+ "final_self_verification", "snapshot_refresh"
96
97
  ]
97
98
  static let postUpdateReconciliationStages = [
98
99
  "hook_trust_repair", "project_receipt", "global_skills_reconcile",
99
- "native_capability_setup", "update_finalize_doctor", "final_self_verification",
100
+ "native_capability_setup", "menubar_version_probe", "update_finalize_doctor", "final_self_verification",
100
101
  "snapshot_refresh"
101
102
  ]
102
103
  private let directory: URL