@indigoai-us/hq-cli 5.345.219 → 5.345.221
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/CHANGELOG.md +170 -0
- package/dist/command-catalog.generated.d.ts +169 -3
- package/dist/command-catalog.generated.js +206 -3
- package/dist/commands/auth.js +4 -1
- package/dist/commands/bot-runtime.d.ts +18 -5
- package/dist/commands/bot-runtime.js +29 -12
- package/dist/commands/bot.d.ts +85 -0
- package/dist/commands/bot.js +245 -16
- package/dist/commands/cloud.d.ts +16 -0
- package/dist/commands/cloud.js +112 -102
- package/dist/commands/core-checkpoint-native.d.ts +13 -0
- package/dist/commands/core-checkpoint-native.js +167 -52
- package/dist/commands/core-hook-registration-plan.js +5 -4
- package/dist/commands/core-stop-autosave.d.ts +21 -0
- package/dist/commands/core-stop-autosave.js +300 -0
- package/dist/commands/core.js +2 -0
- package/dist/commands/daemon.d.ts +5 -0
- package/dist/commands/daemon.js +52 -9
- package/dist/commands/doctor-usage.d.ts +5 -0
- package/dist/commands/doctor-usage.js +25 -0
- package/dist/commands/env.d.ts +49 -4
- package/dist/commands/env.js +355 -5
- package/dist/commands/integrations.js +84 -3
- package/dist/commands/lanes-shared.d.ts +3 -0
- package/dist/commands/lanes.d.ts +3 -0
- package/dist/commands/lanes.js +87 -3
- package/dist/commands/packs.js +23 -0
- package/dist/commands/pkg-update.d.ts +6 -0
- package/dist/commands/pkg-update.js +15 -7
- package/dist/commands/run.js +55 -45
- package/dist/commands/sources.js +4 -3
- package/dist/commands/sync-core.d.ts +1 -0
- package/dist/commands/sync-core.js +77 -3
- package/dist/commands/whoami.js +96 -80
- package/dist/lib/bot/config.d.ts +17 -0
- package/dist/lib/bot/config.js +13 -0
- package/dist/lib/bot/fleet-cron.js +29 -4
- package/dist/lib/bot/fleet-local.d.ts +30 -2
- package/dist/lib/bot/fleet-local.js +60 -1
- package/dist/lib/bot/grok-login-scope.d.ts +36 -0
- package/dist/lib/bot/grok-login-scope.js +93 -0
- package/dist/lib/bot/inflight.d.ts +9 -0
- package/dist/lib/bot/jobs/hot-signal-sync.d.ts +51 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +90 -9
- package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
- package/dist/lib/bot/legacy-provider-login.js +28 -22
- package/dist/lib/bot/run.d.ts +29 -5
- package/dist/lib/bot/run.js +203 -1
- package/dist/lib/bot/runtime-sign-in-check.js +6 -1
- package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
- package/dist/lib/bot/signals-try-now.d.ts +76 -0
- package/dist/lib/bot/signals-try-now.js +111 -0
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +22 -3
- package/dist/lib/capacity/collectors/claude-oauth.js +78 -22
- package/dist/lib/capacity/scheduler.d.ts +8 -0
- package/dist/lib/capacity/scheduler.js +5 -2
- package/dist/lib/core-utils/sentry-report.js +2 -0
- package/dist/lib/daemon/machine-checks.d.ts +22 -1
- package/dist/lib/daemon/machine-checks.js +54 -12
- package/dist/lib/daemon/run.js +71 -8
- package/dist/lib/daemon/runtime-notifications.d.ts +7 -0
- package/dist/lib/daemon/runtime-notifications.js +50 -0
- package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
- package/dist/lib/daemon/stop-autosave-lock.js +166 -0
- package/dist/lib/daemon/stop-autosave.d.ts +28 -0
- package/dist/lib/daemon/stop-autosave.js +111 -0
- package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
- package/dist/lib/daemon/stop-diagnostics.js +136 -0
- package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
- package/dist/lib/daemon/stop-job-executor.js +126 -0
- package/dist/lib/daemon/stop-jobs.d.ts +93 -0
- package/dist/lib/daemon/stop-jobs.js +599 -0
- package/dist/lib/doctor/checks/fleet-hook-core.d.ts +9 -1
- package/dist/lib/doctor/checks/fleet-hook-core.js +39 -15
- package/dist/lib/doctor/checks/host-core.js +1 -1
- package/dist/lib/environment/access-probes.d.ts +234 -0
- package/dist/lib/environment/access-probes.js +918 -0
- package/dist/lib/environment/profile.d.ts +15 -2
- package/dist/lib/environment/profile.js +55 -20
- package/dist/lib/environment/rfc3339.d.ts +8 -0
- package/dist/lib/environment/rfc3339.js +26 -0
- package/dist/lib/environment/work-requirements.d.ts +169 -0
- package/dist/lib/environment/work-requirements.js +389 -0
- package/dist/lib/hook-engine/coverage.d.ts +137 -7
- package/dist/lib/hook-engine/coverage.js +1424 -4
- package/dist/lib/hook-engine/fleet-registration.d.ts +17 -5
- package/dist/lib/hook-engine/fleet-registration.js +53 -17
- package/dist/lib/hook-engine/git-stop-config.json +513 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +311 -0
- package/dist/lib/hook-engine/reconcile.js +2 -2
- package/dist/lib/hot-channels/alert.d.ts +10 -1
- package/dist/lib/hot-channels/alert.js +38 -8
- package/dist/lib/hot-channels/signals-claude-login.d.ts +53 -0
- package/dist/lib/hot-channels/signals-claude-login.js +96 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +143 -17
- package/dist/lib/hot-channels/signals-pass.js +324 -17
- package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
- package/dist/lib/hot-channels/signals-runtime.js +82 -0
- package/dist/lib/install/hook-target.js +1 -1
- package/dist/lib/lanes/host-capacity.d.ts +26 -2
- package/dist/lib/lanes/host-capacity.js +17 -2
- package/dist/lib/lanes/host-compute.d.ts +90 -0
- package/dist/lib/lanes/host-compute.js +185 -0
- package/dist/lib/lanes/index.d.ts +2 -0
- package/dist/lib/lanes/index.js +1 -0
- package/dist/lib/lanes/reconcile.js +22 -1
- package/dist/lib/lanes/resource-usage.d.ts +155 -0
- package/dist/lib/lanes/resource-usage.js +589 -0
- package/dist/lib/lanes/run-size.d.ts +46 -0
- package/dist/lib/lanes/run-size.js +197 -0
- package/dist/lib/lanes/store.js +27 -0
- package/dist/lib/lanes/throttle.d.ts +36 -1
- package/dist/lib/lanes/throttle.js +47 -10
- package/dist/lib/lanes/types.d.ts +40 -0
- package/dist/lib/lanes/types.js +2 -2
- package/dist/lib/lanes/watcher.js +13 -4
- package/dist/lib/lanes/worker-process.d.ts +25 -2
- package/dist/lib/lanes/worker-process.js +71 -19
- package/dist/lib/placement/match.d.ts +192 -0
- package/dist/lib/placement/match.js +667 -0
- package/dist/lib/safe-store.d.ts +14 -0
- package/dist/lib/safe-store.js +77 -4
- package/dist/lib/search-index/index.d.ts +88 -4
- package/dist/lib/search-index/index.js +299 -25
- package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
- package/dist/lib/search-index/max-doc-bytes.js +48 -23
- package/dist/lib/signals/codex-lockdown.d.ts +79 -0
- package/dist/lib/signals/codex-lockdown.js +271 -0
- package/dist/lib/signals/codex-login.d.ts +37 -0
- package/dist/lib/signals/codex-login.js +83 -0
- package/dist/lib/signals/engine.d.ts +28 -0
- package/dist/lib/signals/engine.js +77 -0
- package/dist/lib/signals/reply.d.ts +48 -0
- package/dist/lib/signals/reply.js +94 -12
- package/dist/lib/signals/run-record.js +6 -1
- package/dist/lib/signals/settings.d.ts +5 -0
- package/dist/lib/signals/settings.js +2 -0
- package/dist/lib/signals/steps/adapters.js +6 -0
- package/dist/lib/signals/steps/extract.d.ts +135 -12
- package/dist/lib/signals/steps/extract.js +416 -84
- package/dist/lib/signals/steps/types.d.ts +21 -0
- package/dist/lib/sync-core/engine-home.d.ts +41 -2
- package/dist/lib/sync-core/engine-home.js +132 -19
- package/dist/lib/sync-core/reconcile.js +1 -1
- package/dist/lib/sync-core/release-compare.d.ts +7 -0
- package/dist/lib/sync-core/release-compare.js +16 -0
- package/dist/lib/sync-core/release.d.ts +2 -1
- package/dist/lib/sync-core/release.js +2 -10
- package/dist/lib/sync-core/rollout-state.d.ts +2 -1
- package/dist/lib/sync-core/rollout-state.js +5 -2
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/run/schema-env-overrides.d.ts +24 -0
- package/dist/run/schema-env-overrides.js +72 -0
- package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
- package/dist/utils/auth-session-check.d.ts +16 -0
- package/dist/utils/auth-session-check.js +16 -0
- package/dist/utils/client-health-contract.d.ts +6 -0
- package/dist/utils/client-health-contract.js +13 -0
- package/dist/utils/client-health.d.ts +7 -0
- package/dist/utils/client-health.js +22 -1
- package/dist/utils/command-usage.d.ts +40 -0
- package/dist/utils/command-usage.js +61 -0
- package/dist/utils/duplicate-command-usage.d.ts +72 -0
- package/dist/utils/duplicate-command-usage.js +125 -0
- package/dist/utils/host-registration.d.ts +1 -1
- package/dist/utils/host-registration.js +6 -1
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/sentry-fingerprint.js +9 -0
- package/dist/utils/windows-bash.d.ts +2 -0
- package/dist/utils/windows-bash.js +2 -1
- package/package.json +15 -10
- package/scripts/bench-core-compare.mjs +313 -0
- package/scripts/bench-core.mjs +399 -12
- package/scripts/check-function-manifest.mjs +121 -7
- package/dist/commands/__fixtures__/access-vault.d.ts +0 -95
- package/dist/commands/__fixtures__/access-vault.js +0 -166
- package/dist/commands/__fixtures__/make-tar.d.ts +0 -38
- package/dist/commands/__fixtures__/make-tar.js +0 -102
- package/dist/commands/secrets-public-types.test-d.d.ts +0 -2
- package/dist/commands/secrets-public-types.test-d.js +0 -18
- package/dist/lib/decisions/fixtures/us001.d.ts +0 -137
- package/dist/lib/decisions/fixtures/us001.js +0 -21
- package/dist/lib/doctor/__testing__/fake-hq-tree.d.ts +0 -226
- package/dist/lib/doctor/__testing__/fake-hq-tree.js +0 -408
- package/dist/lib/doctor/__testing__/run-doctor.d.ts +0 -8
- package/dist/lib/doctor/__testing__/run-doctor.js +0 -69
- package/dist/lib/fingerprint/fixtures.d.ts +0 -19
- package/dist/lib/fingerprint/fixtures.js +0 -61
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.d.ts +0 -33
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.js +0 -53
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.d.ts +0 -38
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.js +0 -64
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.d.ts +0 -2
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.js +0 -10
- package/dist/lib/test-utils/isolated-flag-company-context.d.ts +0 -3
- package/dist/lib/test-utils/isolated-flag-company-context.js +0 -18
- package/scripts/hook-engine-manifest.mjs +0 -22
- package/scripts/mesh-daemon-if-stale.mjs +0 -20
package/dist/commands/lanes.js
CHANGED
|
@@ -67,7 +67,9 @@ export { OUTPOST_DIR, OUTPOST_ID_PATH, readOutpostIdentity } from "../lib/lanes/
|
|
|
67
67
|
import { buildOutpostCapacityCommand, buildOutpostIdentityBackfillCommand, buildOutpostLaneCommand, buildOutpostQuestionListCommand, buildOutpostPickupCommand, createOutpostsClient, dispatchErrorMessage, dispatchOutpostPickup, buildOutpostLaneListCommand, buildOutpostLegacyLaneUlidListCommand, REMOTE_LANE_READ_ENV, outpostRejectedEffortOption, parseOutpostPickupPayload, PICKUP_WAIT_MS, stageOutpostPayload, } from "../lib/lanes/outpost-dispatch.js";
|
|
68
68
|
import { outpostHireSummaryCacheKey, OUTPOST_HIRE_SUMMARY_CACHE_TTL_MS, readOutpostHireSummaryCache, readOutpostHireSummaryCacheIncludingStale, writeOutpostHireSummaryCache, } from "../lib/lanes/outpost-hire-cache.js";
|
|
69
69
|
import { buildHostCapacitySnapshot, chooseHostForLane, hostCapacitySnapshotToWire, parseHostCapacitySnapshot, } from "../lib/lanes/host-capacity.js";
|
|
70
|
+
import { readHostCompute } from "../lib/lanes/host-compute.js";
|
|
70
71
|
import { resolveCanonicalHost } from "../lib/lanes/canonical-host.js";
|
|
72
|
+
import { parseLaneRunSize, runSizeMediansByRepo } from "../lib/lanes/run-size.js";
|
|
71
73
|
import { readInstanceIdFromDisk } from "../lib/lanes/machine-identity.js";
|
|
72
74
|
import { BALANCE_MOVABLE_STATES, selectClaudeAccount, } from "../lib/lanes/claude-balance.js";
|
|
73
75
|
import { parseUserYaml } from "../utils/user-yaml-error.js";
|
|
@@ -84,11 +86,12 @@ import { applyLoopDisposition, loopDispositionSnapshot } from "../lib/lanes/loop
|
|
|
84
86
|
import { listLaneReviews } from "../lib/lanes/reviews.js";
|
|
85
87
|
import { effectiveAccountHome } from "../lib/lanes/account-home.js";
|
|
86
88
|
import { remoteControlSelectionConfig, remoteControlSessionHome } from "../lib/lanes/remote-control-lane.js";
|
|
87
|
-
import { AccountResolutionError, compareLaneQueueOrder, LANE_PROVIDERS, LANE_STATES, QUESTION_STATUSES, SENIOR_KINDS, accountStatus, appendCappedHistory, canonicalizeHome, createLane, decideAdmission, defaultLivenessDeps, defaultSystemdUserDir, defaultThrottleDeps, installReconcileTimer, providerPathEnv, probeDrainHookRegistration, isLanesError, isLaneVersionConflict, isTerminalLaneState, isFinishedResumableHireChild, childrenHoldingHireGrantCarve, laneHoldsHireGrantCarve, assignedChildHireGrants, hireGrantCapacityError, planHireGrantBackfill, terminalChildResumeHireGrantError, withHireGrantAdmission, laneStoryLedgerEnabled, syncLaneToProjectStoryLedger, removeLaneFromProjectStoryLedger, validateProjectStories, buildLaneStatusSnapshot, formatLaneStatusHuman, expandLocalLaneIdPrefix, listLaneIds, listQuestionIds, loadLanesConfig, laneRunsHere, MAX_LANE_DEPTH, MONITOR_ERROR_EXIT_CODE, readLiveMonitorEvidence, resolveMachineIdentity as lookupMachineIdentity, loadLivenessIndex, parseLaneProvider, isLaneProvider, parseLaneRecord, parseLaneState, parseQuestionRecord, parseSeniorKind, readAllLanes, readLane, sanitizeHostComponent, retryUpdateLane, syncLaneRecordFromOwner, readQuestion, resolveAccount, resolveLaneWorker, ignoredWorkerProfileFields, loadWorkerProfile, loadWorkerProfileWithRegistry, registryWorkerRecord, runReconcilePass, DEAD_HOST_MS, sessionLiveness, tryReadLane, uninstallReconcileTimer, updateLane, updateQuestion, dropboxDir, laneDeliveryMechanism, hasActiveAdmissionReservation, hasActivePendingResume, hasRecordedSessionId, hasEarlierEligibleQueuedLane, laneAdmissionCapReason, providerSupportsSessionResume, providerSessionPortable, isFailedQuotaKeepAliveLane, sessionNotPortableMessage, withLaneAdmissionLock, withAllLaneAdmissionLocks, readWorkerRunResult, resumeCommandRefusal, withLaneHireLocks, raiseLaneQuestion, sha256Text, } from "../lib/lanes/index.js";
|
|
89
|
+
import { AccountResolutionError, compareLaneQueueOrder, LANE_PROVIDERS, LANE_STATES, QUESTION_STATUSES, SENIOR_KINDS, accountStatus, appendCappedHistory, canonicalizeHome, createLane, mintLaneId, decideAdmission, defaultLivenessDeps, defaultSystemdUserDir, defaultThrottleDeps, installReconcileTimer, providerPathEnv, probeDrainHookRegistration, isLanesError, isLaneVersionConflict, isTerminalLaneState, isFinishedResumableHireChild, childrenHoldingHireGrantCarve, laneHoldsHireGrantCarve, assignedChildHireGrants, hireGrantCapacityError, planHireGrantBackfill, terminalChildResumeHireGrantError, withHireGrantAdmission, laneStoryLedgerEnabled, syncLaneToProjectStoryLedger, removeLaneFromProjectStoryLedger, validateProjectStories, buildLaneStatusSnapshot, formatLaneStatusHuman, expandLocalLaneIdPrefix, listLaneIds, listQuestionIds, loadLanesConfig, laneRunsHere, MAX_LANE_DEPTH, MONITOR_ERROR_EXIT_CODE, readLiveMonitorEvidence, resolveMachineIdentity as lookupMachineIdentity, loadLivenessIndex, parseLaneProvider, isLaneProvider, parseLaneRecord, parseLaneState, parseQuestionRecord, parseSeniorKind, readAllLanes, readLane, sanitizeHostComponent, retryUpdateLane, syncLaneRecordFromOwner, readQuestion, resolveAccount, resolveLaneWorker, ignoredWorkerProfileFields, loadWorkerProfile, loadWorkerProfileWithRegistry, registryWorkerRecord, runReconcilePass, DEAD_HOST_MS, sessionLiveness, tryReadLane, uninstallReconcileTimer, updateLane, updateQuestion, dropboxDir, laneDeliveryMechanism, hasActiveAdmissionReservation, hasActivePendingResume, hasRecordedSessionId, hasEarlierEligibleQueuedLane, laneAdmissionCapReason, providerSupportsSessionResume, providerSessionPortable, isFailedQuotaKeepAliveLane, sessionNotPortableMessage, withLaneAdmissionLock, withAllLaneAdmissionLocks, readWorkerRunResult, resumeCommandRefusal, withLaneHireLocks, raiseLaneQuestion, sha256Text, } from "../lib/lanes/index.js";
|
|
88
90
|
import { admitQueuedNow } from "../lib/lanes/reconcile.js";
|
|
89
91
|
import { laneStories, storyWarning, } from "../lib/lanes/stories.js";
|
|
90
92
|
import { resolveLaneKeepAlive } from "../lib/lanes/profile.js";
|
|
91
93
|
import { laneCompanyUidSource, resolveLaneCompany } from "../lib/lanes/lane-company.js";
|
|
94
|
+
import { deriveWorkRequirements, withRepairedCompany } from "../lib/environment/work-requirements.js";
|
|
92
95
|
import { doneKeepAliveVerdict, hasPendingKeepAliveWork, keepAliveNextCheckAtMs, keepAliveExclusion, keepAliveSupersededBy, loadRetiredLaneEntries, matchesRetiredLaneEntry, LANE_SUPERSESSION_LINEAGE_AWARE_FLAG, loadRetiredLaneIds, } from "../lib/lanes/keep-alive.js";
|
|
93
96
|
import { questionBodyAbsPath, resolveQuestionCompanyWithFallback, resolveProjectQuestionCompany, } from "../lib/lanes/questions.js";
|
|
94
97
|
import { assertQuestionBodySecretSafe } from "../lib/lanes/questions.js";
|
|
@@ -422,6 +425,49 @@ function defaultSleep(ms) {
|
|
|
422
425
|
function resolveCallerPath(callerCwd, filePath) {
|
|
423
426
|
return path.resolve(callerCwd, filePath);
|
|
424
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* hq-work-requirements.v1 for a lane created with no declaration (PS-002):
|
|
430
|
+
* the lane's company as resolveLaneCompany resolves it (company, mesh
|
|
431
|
+
* company, project company), else the caller's session lock, engines any,
|
|
432
|
+
* the repo the caller is in, on_no_fit conductor-harness.
|
|
433
|
+
*
|
|
434
|
+
* The derivation never breaks lane create: on any failure the lane is
|
|
435
|
+
* created without work_requirements and a warning is written to stderr.
|
|
436
|
+
*/
|
|
437
|
+
function derivedLaneWorkRequirements(ctx, hqRoot, lane) {
|
|
438
|
+
try {
|
|
439
|
+
const resolved = resolveLaneCompany(hqRoot, lane);
|
|
440
|
+
const derive = ctx.deriveWorkRequirements ?? deriveWorkRequirements;
|
|
441
|
+
return {
|
|
442
|
+
work_requirements: derive({
|
|
443
|
+
hqRoot,
|
|
444
|
+
cwd: ctx.callerCwd(),
|
|
445
|
+
env: ctx.env,
|
|
446
|
+
origin: { kind: "lane", ref: lane.lane_id },
|
|
447
|
+
company: resolved.company?.slug ?? null,
|
|
448
|
+
}),
|
|
449
|
+
work_requirements_source: "derived",
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
catch (error) {
|
|
453
|
+
process.stderr.write(`${JSON.stringify({
|
|
454
|
+
event: "lanes.work_requirements.derive_failed",
|
|
455
|
+
lane_id: lane.lane_id,
|
|
456
|
+
error: error instanceof Error ? error.name : "UnknownError",
|
|
457
|
+
action: "lane created without work_requirements",
|
|
458
|
+
})}\n`);
|
|
459
|
+
return {};
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* The derived requirements after hq lanes repair-company sets the lane's
|
|
464
|
+
* company. A declared document is left as it is.
|
|
465
|
+
*/
|
|
466
|
+
function repairedWorkRequirements(current, company) {
|
|
467
|
+
if (current.work_requirements_source !== "derived" || !current.work_requirements)
|
|
468
|
+
return {};
|
|
469
|
+
return { work_requirements: withRepairedCompany(current.work_requirements, company.slug) };
|
|
470
|
+
}
|
|
425
471
|
function resolveDeps(deps = {}) {
|
|
426
472
|
const env = deps.env ?? process.env;
|
|
427
473
|
const cwd = deps.cwd ?? (() => process.cwd());
|
|
@@ -511,6 +557,7 @@ function resolveDeps(deps = {}) {
|
|
|
511
557
|
lanePlacementEnabled: deps.lanePlacementEnabled ?? defaultLanePlacementEnabled,
|
|
512
558
|
storyLedgerEnabled: deps.storyLedgerEnabled ?? laneStoryLedgerEnabled,
|
|
513
559
|
focusGuardEnabled: deps.focusGuardEnabled,
|
|
560
|
+
deriveWorkRequirements: deps.deriveWorkRequirements,
|
|
514
561
|
isSsmOwnerDispatch: deps.isSsmOwnerDispatch ?? (() => isSsmRunCommandProcess()),
|
|
515
562
|
withGrantHireLocks: deps.withGrantHireLocks ?? withLaneHireLocks,
|
|
516
563
|
withAdmissionLock: deps.withAdmissionLock ?? withLaneAdmissionLock,
|
|
@@ -1600,7 +1647,7 @@ async function readOutpostCapacityUncached(ctx, outpostId, waitMs = CAPACITY_PRO
|
|
|
1600
1647
|
catch (err) {
|
|
1601
1648
|
throw new LanesError("outpost_capacity_unavailable", `Outpost ${outpostId} returned invalid capacity JSON: ${dispatchErrorMessage(err)}`, { outpost_id: outpostId });
|
|
1602
1649
|
}
|
|
1603
|
-
const snapshot = parseHostCapacitySnapshot(raw);
|
|
1650
|
+
const snapshot = parseHostCapacitySnapshot(raw, ctx.now());
|
|
1604
1651
|
if (snapshot.host.kind !== "outpost" || snapshot.host.id !== outpostId) {
|
|
1605
1652
|
throw new LanesError("outpost_capacity_identity_mismatch", `Capacity response from Outpost ${outpostId} identified a different host`, { requested_outpost_id: outpostId, reported_host: snapshot.host });
|
|
1606
1653
|
}
|
|
@@ -2000,6 +2047,7 @@ async function refreshRemoteLaneMirrors(ctx, hqRoot, records, parentLaneIds, opt
|
|
|
2000
2047
|
const envelopeSummary = isTerminalLaneState(owner.state)
|
|
2001
2048
|
? owner.envelope_summary
|
|
2002
2049
|
: undefined;
|
|
2050
|
+
const ownerRunSize = parseLaneRunSize(owner.run_size);
|
|
2003
2051
|
const before = readLane(hqRoot, mirror.lane_id);
|
|
2004
2052
|
if (before.host.kind !== "outpost" || before.host.id !== outpostId ||
|
|
2005
2053
|
!originMatchesThisHost(before) ||
|
|
@@ -2031,7 +2079,10 @@ async function refreshRemoteLaneMirrors(ctx, hqRoot, records, parentLaneIds, opt
|
|
|
2031
2079
|
before.story_complete !== owner.story_complete ||
|
|
2032
2080
|
before.story_complete_reason !== owner.story_complete_reason ||
|
|
2033
2081
|
before.story_status !== owner.story_status ||
|
|
2034
|
-
before.terminal_reason !== owner.terminal_reason
|
|
2082
|
+
before.terminal_reason !== owner.terminal_reason ||
|
|
2083
|
+
// A missing or malformed owner size never forces a rewrite: the
|
|
2084
|
+
// update below keeps the mirror's size in that case.
|
|
2085
|
+
(ownerRunSize !== undefined && JSON.stringify(before.run_size) !== JSON.stringify(ownerRunSize))));
|
|
2035
2086
|
if (!needsUpdate) {
|
|
2036
2087
|
result.updated.set(mirror.lane_id, before);
|
|
2037
2088
|
continue;
|
|
@@ -2063,6 +2114,8 @@ async function refreshRemoteLaneMirrors(ctx, hqRoot, records, parentLaneIds, opt
|
|
|
2063
2114
|
story_status: owner.story_status,
|
|
2064
2115
|
terminal_reason: owner.terminal_reason,
|
|
2065
2116
|
terminal_details: owner.terminal_details,
|
|
2117
|
+
// PS-011: the owner host measured the runs; the mirror keeps its size.
|
|
2118
|
+
...(ownerRunSize !== undefined ? { run_size: ownerRunSize } : {}),
|
|
2066
2119
|
} : {}),
|
|
2067
2120
|
};
|
|
2068
2121
|
});
|
|
@@ -4536,7 +4589,10 @@ async function runCreate(ctx, opts) {
|
|
|
4536
4589
|
}
|
|
4537
4590
|
const queuedReason = admission.action === "queue" ? admission.reason : undefined;
|
|
4538
4591
|
const admissionReservedAt = admission.action === "start" ? ctx.now().toISOString() : undefined;
|
|
4592
|
+
// Minted here, as createLane would, so the derived requirements can name the lane.
|
|
4593
|
+
const laneId = mintLaneId();
|
|
4539
4594
|
const laneInit = {
|
|
4595
|
+
lane_id: laneId,
|
|
4540
4596
|
company,
|
|
4541
4597
|
...(opts.signalMetadata ? { signal: opts.signalMetadata, signal_link: opts.signalLink } : {}),
|
|
4542
4598
|
...(company === null && meshCompany
|
|
@@ -4632,6 +4688,12 @@ async function runCreate(ctx, opts) {
|
|
|
4632
4688
|
...(originHostSource !== undefined
|
|
4633
4689
|
? { origin_host_source: originHostSource }
|
|
4634
4690
|
: {}),
|
|
4691
|
+
...derivedLaneWorkRequirements(ctx, hqRoot, {
|
|
4692
|
+
lane_id: laneId,
|
|
4693
|
+
company,
|
|
4694
|
+
mesh_company: company === null && meshCompany ? meshCompany : undefined,
|
|
4695
|
+
project_id: project,
|
|
4696
|
+
}),
|
|
4635
4697
|
attribution_history: [],
|
|
4636
4698
|
};
|
|
4637
4699
|
if (senior.kind === "lane" && senior.id) {
|
|
@@ -6410,6 +6472,7 @@ async function runList(ctx, opts) {
|
|
|
6410
6472
|
? (await loadHostCapacitySnapshots(ctx, hqRoot, undefined, allLanes)).entries
|
|
6411
6473
|
.map((entry) => "schema_version" in entry ? hostCapacitySnapshotToWire(entry) : entry)
|
|
6412
6474
|
: undefined;
|
|
6475
|
+
const runSizeByRepo = runSizeMediansByRepo(selectedLanes);
|
|
6413
6476
|
const result = {
|
|
6414
6477
|
ok: true,
|
|
6415
6478
|
action: "list",
|
|
@@ -6418,6 +6481,8 @@ async function runList(ctx, opts) {
|
|
|
6418
6481
|
? { unverified_remote_lanes: [...remoteRefresh.unverifiedRemote.keys()] }
|
|
6419
6482
|
: {}),
|
|
6420
6483
|
...(host_capacity !== undefined ? { host_capacity } : {}),
|
|
6484
|
+
// PS-011: per-repo medians over the listed lanes that carry a run_size.
|
|
6485
|
+
...(runSizeByRepo.length > 0 ? { run_size_by_repo: runSizeByRepo } : {}),
|
|
6421
6486
|
};
|
|
6422
6487
|
if (opts.human)
|
|
6423
6488
|
console.log(formatLaneListHuman(lanes));
|
|
@@ -6571,6 +6636,14 @@ async function runCapacity(ctx) {
|
|
|
6571
6636
|
hostname,
|
|
6572
6637
|
now,
|
|
6573
6638
|
quotaState: loadQuotaState(hqRoot),
|
|
6639
|
+
// Read only, like the rest of this command: os.cpus, loadavg, the memory
|
|
6640
|
+
// gate's reading and statfs on the HQ root.
|
|
6641
|
+
compute: readHostCompute({
|
|
6642
|
+
deps: ctx.throttleDeps,
|
|
6643
|
+
diskPath: hqRoot,
|
|
6644
|
+
...(ctx.statfs !== undefined ? { statfs: ctx.statfs } : {}),
|
|
6645
|
+
now,
|
|
6646
|
+
}),
|
|
6574
6647
|
});
|
|
6575
6648
|
printJson({
|
|
6576
6649
|
...hostCapacitySnapshotToWire(snapshot),
|
|
@@ -6837,6 +6910,8 @@ async function runShow(ctx, laneId, hasPendingQuestionForLane, resolveLaneTarget
|
|
|
6837
6910
|
failed_resume_history: lane.failed_resume_history ?? [],
|
|
6838
6911
|
pending_resume: lane.pending_resume ?? null,
|
|
6839
6912
|
last_run_usage: lane.last_run_usage ?? null,
|
|
6913
|
+
// PS-011: work size and placement summed over the lane's measured runs.
|
|
6914
|
+
run_size: lane.run_size ?? null,
|
|
6840
6915
|
model: lane.model ?? null,
|
|
6841
6916
|
effort: lane.effort ?? null,
|
|
6842
6917
|
effort_source: lane.effort_source ?? null,
|
|
@@ -8871,6 +8946,7 @@ async function repairCompanyOnOwner(ctx, laneId, opts, emitResult = true) {
|
|
|
8871
8946
|
return {
|
|
8872
8947
|
...current,
|
|
8873
8948
|
company,
|
|
8949
|
+
...repairedWorkRequirements(current, company),
|
|
8874
8950
|
company_history: appendCappedHistory(current.company_history ?? [], {
|
|
8875
8951
|
from: null,
|
|
8876
8952
|
to: company,
|
|
@@ -9543,7 +9619,9 @@ async function runCreateSubagent(ctx, opts) {
|
|
|
9543
9619
|
}
|
|
9544
9620
|
const taskBrief = fs.readFileSync(briefAbs, "utf8");
|
|
9545
9621
|
const createdAt = ctx.now().toISOString();
|
|
9622
|
+
const laneId = mintLaneId();
|
|
9546
9623
|
const lane = createLane(hqRoot, {
|
|
9624
|
+
lane_id: laneId,
|
|
9547
9625
|
company,
|
|
9548
9626
|
...(opts.signalMetadata ? { signal: opts.signalMetadata, signal_link: opts.signalLink } : {}),
|
|
9549
9627
|
...(company === null && meshCompany ? { mesh_company: meshCompany } : {}),
|
|
@@ -9574,6 +9652,12 @@ async function runCreateSubagent(ctx, opts) {
|
|
|
9574
9652
|
...(cliEffort !== undefined ? { effort: cliEffort } : {}),
|
|
9575
9653
|
effort_source: cliEffort !== undefined ? "cli" : "none",
|
|
9576
9654
|
host: subagentLaneHost(ctx),
|
|
9655
|
+
...derivedLaneWorkRequirements(ctx, hqRoot, {
|
|
9656
|
+
lane_id: laneId,
|
|
9657
|
+
company,
|
|
9658
|
+
mesh_company: company === null && meshCompany ? meshCompany : undefined,
|
|
9659
|
+
project_id: project,
|
|
9660
|
+
}),
|
|
9577
9661
|
attribution_history: [],
|
|
9578
9662
|
created_at: createdAt,
|
|
9579
9663
|
updated_at: createdAt,
|
package/dist/commands/packs.js
CHANGED
|
@@ -22,6 +22,7 @@ import { codexTargets } from '../lib/install/codex-targets.js';
|
|
|
22
22
|
import * as path from 'path';
|
|
23
23
|
import * as readline from 'readline';
|
|
24
24
|
import { spawnSync } from 'child_process';
|
|
25
|
+
import { Option } from 'commander';
|
|
25
26
|
import chalk from 'chalk';
|
|
26
27
|
import semverSatisfies from 'semver/functions/satisfies.js';
|
|
27
28
|
import { findHqRoot } from '../utils/manifest.js';
|
|
@@ -442,6 +443,20 @@ export function registerPacksListCommand(parent) {
|
|
|
442
443
|
}
|
|
443
444
|
});
|
|
444
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* `packs update` options that only apply to content packs. Each is a usage
|
|
448
|
+
* error together with `--registry`, which takes none of them.
|
|
449
|
+
*/
|
|
450
|
+
const CONTENT_PACK_UPDATE_OPTIONS = [
|
|
451
|
+
'json',
|
|
452
|
+
'hqRoot',
|
|
453
|
+
'checkOnly',
|
|
454
|
+
'refresh',
|
|
455
|
+
'yes',
|
|
456
|
+
'allowHooks',
|
|
457
|
+
'allowMcp',
|
|
458
|
+
'branch',
|
|
459
|
+
];
|
|
445
460
|
export function registerPacksCommand(parent) {
|
|
446
461
|
const packs = parent.command('packs').description('Content-pack lifecycle (install via `hq install`)');
|
|
447
462
|
registerPacksListCommand(packs);
|
|
@@ -456,7 +471,15 @@ export function registerPacksCommand(parent) {
|
|
|
456
471
|
.option('--allow-hooks', 'Install pack hooks without prompting')
|
|
457
472
|
.option('--allow-mcp', 'Register pack MCP servers without prompting')
|
|
458
473
|
.option('--branch', 'Follow the source branch instead of SHA-pinning')
|
|
474
|
+
.addOption(new Option('--registry', 'Update installed registry packages instead (same as `hq packages update [slug]`; [name] is the package slug)').conflicts([...CONTENT_PACK_UPDATE_OPTIONS]))
|
|
459
475
|
.action(async (name, opts) => {
|
|
476
|
+
if (opts.registry) {
|
|
477
|
+
// Exactly the `hq packages update [slug]` path: same function, lease,
|
|
478
|
+
// checks, output and exit status.
|
|
479
|
+
const { runPackageUpdateCommand } = await import('./pkg-update.js');
|
|
480
|
+
await runPackageUpdateCommand(name);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
460
483
|
try {
|
|
461
484
|
const results = await runUpdate(name, opts);
|
|
462
485
|
if (wantsJson(opts)) {
|
|
@@ -7,5 +7,11 @@
|
|
|
7
7
|
import { Command } from 'commander';
|
|
8
8
|
import { type ResidentCommandLeaseOptions } from '../utils/resident-package-preload.js';
|
|
9
9
|
export declare function registerPackageUpdateCommand(parent: Command): void;
|
|
10
|
+
/**
|
|
11
|
+
* The whole `hq packages update [slug]` action: lease, registry check,
|
|
12
|
+
* integrity checks, output and exit status. `hq packs update --registry [slug]`
|
|
13
|
+
* calls this same function so the two commands cannot drift apart.
|
|
14
|
+
*/
|
|
15
|
+
export declare function runPackageUpdateCommand(slug?: string): Promise<void>;
|
|
10
16
|
export declare function runPackageUpdateWithLease<T>(run: () => Promise<T>, leaseOptions?: ResidentCommandLeaseOptions): Promise<T>;
|
|
11
17
|
//# sourceMappingURL=pkg-update.d.ts.map
|
|
@@ -21,15 +21,23 @@ export function registerPackageUpdateCommand(parent) {
|
|
|
21
21
|
.command('update [slug]')
|
|
22
22
|
.description('Check for and apply package updates')
|
|
23
23
|
.action(async (slug) => {
|
|
24
|
-
|
|
25
|
-
await runPackageUpdateWithLease(() => updatePackages(slug));
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
console.error(chalk.red('Update failed:'), error instanceof Error ? error.message : 'Unknown error');
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
24
|
+
await runPackageUpdateCommand(slug);
|
|
31
25
|
});
|
|
32
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* The whole `hq packages update [slug]` action: lease, registry check,
|
|
29
|
+
* integrity checks, output and exit status. `hq packs update --registry [slug]`
|
|
30
|
+
* calls this same function so the two commands cannot drift apart.
|
|
31
|
+
*/
|
|
32
|
+
export async function runPackageUpdateCommand(slug) {
|
|
33
|
+
try {
|
|
34
|
+
await runPackageUpdateWithLease(() => updatePackages(slug));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error(chalk.red('Update failed:'), error instanceof Error ? error.message : 'Unknown error');
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
33
41
|
export function runPackageUpdateWithLease(run, leaseOptions) {
|
|
34
42
|
return runResidentCommandWithPackageLease("pkg-update", run, leaseOptions);
|
|
35
43
|
}
|
package/dist/commands/run.js
CHANGED
|
@@ -12,6 +12,7 @@ import { vaultApiFetch, getCompanyUid } from '../utils/vault-api.js';
|
|
|
12
12
|
import { discoverSchemas } from '../run/discover-schemas.js';
|
|
13
13
|
import { installHqPlugin, itemIsOptional, prewarmHqSecrets } from '../run/hq-plugin.js';
|
|
14
14
|
import { assertEnvGraphLoaded, resolveEnvValuesOrThrow, EnvGraphLoadError, EnvResolutionError, } from '../run/env-graph-guard.js';
|
|
15
|
+
import { clearInheritedSchemaOverrides, schemaDeclaredKeys, withoutInheritedSchemaEnv, } from '../run/schema-env-overrides.js';
|
|
15
16
|
import { hadFatalRejection } from '../unhandled-rejection-boundary.js';
|
|
16
17
|
import { withRunSecretReadTelemetry } from './run-feature-telemetry.js';
|
|
17
18
|
import { isHqCliChild, releaseChildWrapperPackageUseLeaseAfterStart } from '../utils/child-wrapper-lease.js';
|
|
@@ -196,52 +197,61 @@ export function registerRunCommand(program) {
|
|
|
196
197
|
}
|
|
197
198
|
else {
|
|
198
199
|
let state;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
// feedback_d5698e57: inherited process.env must not replace schema
|
|
201
|
+
// hq() values. Varlock treats process.env as overrides; secrets exec
|
|
202
|
+
// injects last. Drop schema keys from the env and from the graph's
|
|
203
|
+
// override set so the vault (or .env.local) wins. Keep them unset
|
|
204
|
+
// through resolve so a later process.env re-read cannot restore them.
|
|
205
|
+
const declaredKeys = schemaDeclaredKeys(paths);
|
|
206
|
+
resolvedEnv = await withoutInheritedSchemaEnv(declaredKeys, async () => {
|
|
207
|
+
const graph = await internal.loadEnvGraph({
|
|
208
|
+
entryFilePaths: paths,
|
|
209
|
+
// hq run owns its short-lived in-memory resolution. Varlock's default
|
|
210
|
+
// cache auto-detection can write ~/.config/varlock and initialize
|
|
211
|
+
// the native local-encryption helper, neither of which belongs on
|
|
212
|
+
// this command path.
|
|
213
|
+
skipCache: true,
|
|
214
|
+
afterInit: async (g) => { state = installHqPlugin(g, pluginOpts); },
|
|
215
|
+
});
|
|
216
|
+
clearInheritedSchemaOverrides(graph, declaredKeys);
|
|
217
|
+
// Refuse to resolve a graph varlock never finished loading (a malformed
|
|
218
|
+
// .env.schema / .env.local): resolving an unprocessed item whose key is
|
|
219
|
+
// also in process.env reaches varlock's `expected dataType to be set`
|
|
220
|
+
// invariant as a FLOATED, never-settling rejection — the CLI then exits
|
|
221
|
+
// 0 with the command never run (HQ-CLI-W). Run this BEFORE prewarm so a
|
|
222
|
+
// bad file can never trigger a secret fetch.
|
|
223
|
+
assertEnvGraphLoaded(graph);
|
|
224
|
+
await prewarmHqSecrets(graph, pluginOpts, state);
|
|
225
|
+
// Defence in depth: convert a floated resolution rejection into a thrown
|
|
226
|
+
// error instead of hanging on varlock's never-settling promise, in case
|
|
227
|
+
// the shape-dependent guard above ever silently degrades.
|
|
228
|
+
await resolveEnvValuesOrThrow(graph);
|
|
229
|
+
// varlock's item.errors includes warning-severity entries (isWarning),
|
|
230
|
+
// e.g. "Value is very short! Is it actually sensitive?" for a short
|
|
231
|
+
// sensitive value. Print those and carry on; only real errors are fatal.
|
|
232
|
+
const schemaItems = Object.entries(graph.configSchema);
|
|
233
|
+
const itemMessages = (wantWarnings) => schemaItems.flatMap(([k, item]) => (item.errors ?? [])
|
|
234
|
+
.filter((e) => Boolean(e?.isWarning) === wantWarnings)
|
|
235
|
+
.filter((e) => {
|
|
236
|
+
if (wantWarnings)
|
|
237
|
+
return true;
|
|
238
|
+
if (!itemIsOptional(item))
|
|
239
|
+
return true;
|
|
240
|
+
const msg = e?.message ?? '';
|
|
241
|
+
return !/No read permission|does not exist in company|not returned by vault/.test(msg);
|
|
242
|
+
})
|
|
243
|
+
.map((e) => ` ${k}: ${e?.message ?? String(e)}`));
|
|
244
|
+
const warningMsgs = itemMessages(true);
|
|
245
|
+
if (warningMsgs.length > 0) {
|
|
246
|
+
process.stderr.write(`Warning: env var checks reported warnings:\n${warningMsgs.join('\n')}\n`);
|
|
247
|
+
}
|
|
248
|
+
const errorMsgs = itemMessages(false);
|
|
249
|
+
if (errorMsgs.length > 0) {
|
|
250
|
+
process.stderr.write(`Error: failed to resolve env vars:\n${errorMsgs.join('\n')}\n`);
|
|
251
|
+
process.exit(1);
|
|
252
|
+
}
|
|
253
|
+
return graph.getResolvedEnvObject();
|
|
207
254
|
});
|
|
208
|
-
// Refuse to resolve a graph varlock never finished loading (a malformed
|
|
209
|
-
// .env.schema / .env.local): resolving an unprocessed item whose key is
|
|
210
|
-
// also in process.env reaches varlock's `expected dataType to be set`
|
|
211
|
-
// invariant as a FLOATED, never-settling rejection — the CLI then exits
|
|
212
|
-
// 0 with the command never run (HQ-CLI-W). Run this BEFORE prewarm so a
|
|
213
|
-
// bad file can never trigger a secret fetch.
|
|
214
|
-
assertEnvGraphLoaded(graph);
|
|
215
|
-
await prewarmHqSecrets(graph, pluginOpts, state);
|
|
216
|
-
// Defence in depth: convert a floated resolution rejection into a thrown
|
|
217
|
-
// error instead of hanging on varlock's never-settling promise, in case
|
|
218
|
-
// the shape-dependent guard above ever silently degrades.
|
|
219
|
-
await resolveEnvValuesOrThrow(graph);
|
|
220
|
-
// varlock's item.errors includes warning-severity entries (isWarning),
|
|
221
|
-
// e.g. "Value is very short! Is it actually sensitive?" for a short
|
|
222
|
-
// sensitive value. Print those and carry on; only real errors are fatal.
|
|
223
|
-
const schemaItems = Object.entries(graph.configSchema);
|
|
224
|
-
const itemMessages = (wantWarnings) => schemaItems.flatMap(([k, item]) => (item.errors ?? [])
|
|
225
|
-
.filter((e) => Boolean(e?.isWarning) === wantWarnings)
|
|
226
|
-
.filter((e) => {
|
|
227
|
-
if (wantWarnings)
|
|
228
|
-
return true;
|
|
229
|
-
if (!itemIsOptional(item))
|
|
230
|
-
return true;
|
|
231
|
-
const msg = e?.message ?? '';
|
|
232
|
-
return !/No read permission|does not exist in company|not returned by vault/.test(msg);
|
|
233
|
-
})
|
|
234
|
-
.map((e) => ` ${k}: ${e?.message ?? String(e)}`));
|
|
235
|
-
const warningMsgs = itemMessages(true);
|
|
236
|
-
if (warningMsgs.length > 0) {
|
|
237
|
-
process.stderr.write(`Warning: env var checks reported warnings:\n${warningMsgs.join('\n')}\n`);
|
|
238
|
-
}
|
|
239
|
-
const errorMsgs = itemMessages(false);
|
|
240
|
-
if (errorMsgs.length > 0) {
|
|
241
|
-
process.stderr.write(`Error: failed to resolve env vars:\n${errorMsgs.join('\n')}\n`);
|
|
242
|
-
process.exit(1);
|
|
243
|
-
}
|
|
244
|
-
resolvedEnv = graph.getResolvedEnvObject();
|
|
245
255
|
}
|
|
246
256
|
const varCount = Object.keys(resolvedEnv).length;
|
|
247
257
|
process.stderr.write(`Loaded ${varCount} env vars from .env.schema (company: ${slug})\n`);
|
package/dist/commands/sources.js
CHANGED
|
@@ -37,6 +37,8 @@ import { createSignalsAlertChannelPoster, raiseSignalsFailureAlerts } from "../l
|
|
|
37
37
|
import { audienceKey } from "../lib/hot-channels/audience.js";
|
|
38
38
|
import { appendRunLedgerEntry, ledgerDay, readRunLedger, RUN_TRIGGERS, summarizeRunLedger, } from "../lib/hot-channels/ledger.js";
|
|
39
39
|
import { createClaudeSignalsPass, DEFAULT_MAX_SIGNAL_DOCS, readPendingSignals, SignalsPassError, } from "../lib/hot-channels/signals-pass.js";
|
|
40
|
+
import { recordSignalsPassClaudeLogin } from "../lib/hot-channels/signals-claude-login.js";
|
|
41
|
+
import { executiveSignalsRuntimeOptions } from "../lib/hot-channels/signals-runtime.js";
|
|
40
42
|
import { backlogRunResult, parseSince, queueSignalsRedo, selectSignalsRedo, SignalsRedoUsageError, } from "../lib/hot-channels/signals-redo.js";
|
|
41
43
|
import { assertSafeSegment } from "../lib/hot-channels/landing.js";
|
|
42
44
|
import { acquireSyncLock, SYNC_LOCK_BUSY_REASON } from "../lib/hot-channels/sync-lock.js";
|
|
@@ -48,7 +50,6 @@ import { S3Client } from "@aws-sdk/client-s3";
|
|
|
48
50
|
import { resolveCanonicalPersonUid } from "./cloud.js";
|
|
49
51
|
import { botsRoot as defaultBotsRoot } from "../lib/bot/paths.js";
|
|
50
52
|
// The same main-bot runtime the signals engine's extract step uses.
|
|
51
|
-
import { defaultResolveBotRuntime } from "../lib/signals/steps/extract.js";
|
|
52
53
|
import { ensureHotSignalSyncJob } from "../lib/bot/jobs/hot-signal-sync.js";
|
|
53
54
|
import { resolveExecutiveBot } from "../lib/bot/executive.js";
|
|
54
55
|
import { companyOfHotSignalSyncJob, fleetCronOps } from "../lib/bot/fleet-cron.js";
|
|
@@ -607,7 +608,7 @@ export async function runSync(options, overrides = {}) {
|
|
|
607
608
|
...(overrides.registry ? { registry: overrides.registry } : {}),
|
|
608
609
|
...(overrides.now ? { now: overrides.now } : {}),
|
|
609
610
|
...(overrides.createSelections ? { createSelections: overrides.createSelections } : {}),
|
|
610
|
-
signalsGenerated: overrides.signalsGenerated ?? createClaudeSignalsPass({ hqRoot: options.hqRoot, company,
|
|
611
|
+
signalsGenerated: overrides.signalsGenerated ?? createClaudeSignalsPass({ hqRoot: options.hqRoot, company, ...executiveSignalsRuntimeOptions(), onClaudeLogin: recordSignalsPassClaudeLogin }),
|
|
611
612
|
// The CLI has no owner-DM sender: the terminal is the primary alert here.
|
|
612
613
|
signalsAlert: {
|
|
613
614
|
sendOwnerDm: async (text) => {
|
|
@@ -723,7 +724,7 @@ export async function runSignalsRedo(options, overrides = {}) {
|
|
|
723
724
|
});
|
|
724
725
|
const pass = overrides.createPass
|
|
725
726
|
? overrides.createPass(maxDocs)
|
|
726
|
-
: createClaudeSignalsPass({ hqRoot: options.hqRoot, company, maxDocs,
|
|
727
|
+
: createClaudeSignalsPass({ hqRoot: options.hqRoot, company, maxDocs, ...executiveSignalsRuntimeOptions(), onClaudeLogin: recordSignalsPassClaudeLogin });
|
|
727
728
|
for (const channel of channels) {
|
|
728
729
|
try {
|
|
729
730
|
report.signalsWritten += await pass(backlogRunResult(channel), { beforeWrite: lock.assertHeld });
|
|
@@ -15,6 +15,7 @@ export interface SyncCoreCommandDeps {
|
|
|
15
15
|
arch: string;
|
|
16
16
|
out: (line: string) => void;
|
|
17
17
|
err: (line: string) => void;
|
|
18
|
+
now?: () => Date;
|
|
18
19
|
}
|
|
19
20
|
export declare function runSyncCoreReconcile(opts: SyncCoreReconcileCommandOptions, d?: SyncCoreCommandDeps): Promise<SyncCoreReconcileResult>;
|
|
20
21
|
export interface SyncCoreManifestCommandOptions {
|
|
@@ -2,6 +2,7 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { ensureSyncCoreBinary, readSyncCorePin } from "../lib/sync-core/release.js";
|
|
5
|
+
import { readEngineStatus } from "../lib/sync-core/engine-home.js";
|
|
5
6
|
import { readCompanyRolloutFlag } from "../lib/sync-core/flag.js";
|
|
6
7
|
import { reconcileSyncCore } from "../lib/sync-core/reconcile.js";
|
|
7
8
|
import { engineOwnedManifestScopes, manifestScopeArg } from "../lib/sync-core/manifest-scopes.js";
|
|
@@ -109,10 +110,81 @@ export async function runSyncCoreManifest(opts, d = defaultDeps()) {
|
|
|
109
110
|
process.exitCode = 1;
|
|
110
111
|
return results;
|
|
111
112
|
}
|
|
113
|
+
function ago(at, now) {
|
|
114
|
+
const ms = now.getTime() - Date.parse(at);
|
|
115
|
+
if (!Number.isFinite(ms) || ms < 0)
|
|
116
|
+
return "";
|
|
117
|
+
const minutes = Math.floor(ms / 60_000);
|
|
118
|
+
if (minutes < 1)
|
|
119
|
+
return " (under a minute ago)";
|
|
120
|
+
if (minutes < 120)
|
|
121
|
+
return ` (${minutes} minute${minutes === 1 ? "" : "s"} ago)`;
|
|
122
|
+
const hours = Math.floor(minutes / 60);
|
|
123
|
+
if (hours < 48)
|
|
124
|
+
return ` (${hours} hours ago)`;
|
|
125
|
+
return ` (${Math.floor(hours / 24)} days ago)`;
|
|
126
|
+
}
|
|
127
|
+
function engineStatusLines(engine, full, now) {
|
|
128
|
+
if (!engine)
|
|
129
|
+
return [" no engine status yet (the engine has not written status.json)"];
|
|
130
|
+
const lines = [];
|
|
131
|
+
const live = engine.cycle;
|
|
132
|
+
if (live) {
|
|
133
|
+
const progress = live.phase === "planning"
|
|
134
|
+
? ""
|
|
135
|
+
: `: ${live.uploadsDone} of ${live.uploadsTotal} uploads, ${live.downloadsDone} of ${live.downloadsTotal} downloads, ${live.failed} failed`;
|
|
136
|
+
lines.push(` cycle running since ${live.startedAt}${ago(live.startedAt, now)}, ${live.phase}${progress}`);
|
|
137
|
+
if (live.currentPath)
|
|
138
|
+
lines.push(` moving ${live.currentPath}`);
|
|
139
|
+
if (live.stale && live.updatedAt) {
|
|
140
|
+
lines.push(` no progress written since ${live.updatedAt}${ago(live.updatedAt, now)}; the engine may have stopped in the middle of this cycle`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const c = engine.lastCycle;
|
|
144
|
+
if (c) {
|
|
145
|
+
const extras = [
|
|
146
|
+
...(c.unsupported > 0 ? [`${c.unsupported} unsupported`] : []),
|
|
147
|
+
...(c.skipped > 0 ? [`${c.skipped} skipped`] : []),
|
|
148
|
+
...(c.transferFailures > 0 ? [`${c.transferFailures} failed transfer${c.transferFailures === 1 ? "" : "s"}`] : []),
|
|
149
|
+
];
|
|
150
|
+
lines.push(` last cycle ${c.at}${ago(c.at, now)}${c.fullVault ? "" : ", one-file canary"}: ${c.planned} planned, ${c.completed} completed, ${c.pending} pending, ${c.held} held, ${c.notApplied} not applied${extras.length > 0 ? `, ${extras.join(", ")}` : ""}; ${c.success ? "everything planned was applied" : "work is left"}`);
|
|
151
|
+
if (c.listed > 0) {
|
|
152
|
+
lines.push(` listed work${c.truncated ? ` (first ${c.listed} items only)` : ""}: ${c.uploads} uploads, ${c.downloads} downloads, ${c.deletes} deletes, ${c.conflicts} conflict or merge copies, ${c.deferred} deferred`);
|
|
153
|
+
}
|
|
154
|
+
if (c.transfersQueued)
|
|
155
|
+
lines.push(` ${c.transfersQueued} transfer${c.transfersQueued === 1 ? "" : "s"} left for the next cycle`);
|
|
156
|
+
if (c.requestPauseUntil)
|
|
157
|
+
lines.push(` paused by the request limit until ${c.requestPauseUntil}`);
|
|
158
|
+
if (c.requestBreakerUntil)
|
|
159
|
+
lines.push(` slowed down by the request breaker until ${c.requestBreakerUntil}`);
|
|
160
|
+
if (c.transferWaitUntil)
|
|
161
|
+
lines.push(` waiting until ${c.transferWaitUntil} before sending again, after transfers failed in transit`);
|
|
162
|
+
if (c.snapshotWaitUntil)
|
|
163
|
+
lines.push(` waiting until ${c.snapshotWaitUntil} to read the vault again`);
|
|
164
|
+
}
|
|
165
|
+
else if (full && !live) {
|
|
166
|
+
lines.push(" no finished cycle yet");
|
|
167
|
+
}
|
|
168
|
+
const running = [
|
|
169
|
+
...(engine.engineVersion ? [`hq-syncd ${engine.engineVersion}`] : []),
|
|
170
|
+
...(engine.startedAt ? [`started ${engine.startedAt}`] : []),
|
|
171
|
+
...(engine.requests24h !== undefined ? [`${engine.requests24h} requests in the last 24 hours`] : []),
|
|
172
|
+
];
|
|
173
|
+
if (running.length > 0)
|
|
174
|
+
lines.push(` ${running.join(", ")}`);
|
|
175
|
+
return lines;
|
|
176
|
+
}
|
|
112
177
|
export function runSyncCoreStatus(opts, d = defaultDeps()) {
|
|
113
178
|
const state = readSyncCoreRolloutState(d.home);
|
|
114
179
|
if (opts.json) {
|
|
115
|
-
d.
|
|
180
|
+
const jsonNow = (d.now ?? (() => new Date()))();
|
|
181
|
+
d.out(JSON.stringify(state && {
|
|
182
|
+
...state,
|
|
183
|
+
vaults: state.vaults.map((vault) => {
|
|
184
|
+
const engine = readEngineStatus(vault.engineHome, vault.uid, jsonNow);
|
|
185
|
+
return engine ? { ...vault, engine } : vault;
|
|
186
|
+
}),
|
|
187
|
+
}, null, 2));
|
|
116
188
|
return;
|
|
117
189
|
}
|
|
118
190
|
if (!state) {
|
|
@@ -120,16 +192,18 @@ export function runSyncCoreStatus(opts, d = defaultDeps()) {
|
|
|
120
192
|
return;
|
|
121
193
|
}
|
|
122
194
|
const switches = readVaultSyncSwitches(d.home);
|
|
195
|
+
const now = (d.now ?? (() => new Date()))();
|
|
123
196
|
d.out(`engine ${state.release} at ${state.binaryPath}, last read ${state.readAt}`);
|
|
124
197
|
if (state.error)
|
|
125
198
|
d.out(`warning: ${state.error}`);
|
|
126
199
|
for (const vault of state.vaults) {
|
|
127
200
|
const legacyOff = vault.kind === "personal" ? switches.personalOff : switches.offCompanies.has(vault.slug ?? "");
|
|
128
201
|
d.out(` ${vault.uid} ${vault.kind}${vault.slug ? ` ${vault.slug}` : ""} ${vault.phase === "full" ? "full" : "read-only"} legacy sync ${legacyOff ? "off" : "still on"} home ${vault.engineHome}`);
|
|
202
|
+
for (const line of engineStatusLines(readEngineStatus(vault.engineHome, vault.uid, now), vault.phase === "full", now))
|
|
203
|
+
d.out(line);
|
|
129
204
|
if (vault.firstCycle) {
|
|
130
205
|
const c = vault.firstCycle;
|
|
131
|
-
d.out(` first full cycle ${c.at}: ${c.planned} planned, ${c.completed} completed, ${c.pending} pending, ${c.held} held, ${c.notApplied} not applied`);
|
|
132
|
-
d.out(` listed work${c.truncated ? ` (first ${c.listed} items only)` : ""}: ${c.uploads} uploads, ${c.downloads} downloads, ${c.deletes} deletes, ${c.conflicts} conflict or merge copies, ${c.deferred} deferred`);
|
|
206
|
+
d.out(` first full cycle ${c.at} (recorded at the switch): ${c.planned} planned, ${c.completed} completed, ${c.pending} pending, ${c.held} held, ${c.notApplied} not applied`);
|
|
133
207
|
}
|
|
134
208
|
}
|
|
135
209
|
for (const skip of state.skipped ?? [])
|