@indigoai-us/hq-cli 5.345.238 → 5.345.242
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 +74 -0
- package/assets/scaffold/core/scripts/hq-delegate-grant.sh +170 -8
- package/assets/scaffold/core/scripts/hq-delegate-publish.sh +21 -1
- package/assets/scaffold/core/scripts/hq-delegate-repo.sh +7 -1
- package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
- package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
- package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
- package/dist/command-catalog.generated.d.ts +212 -10
- package/dist/command-catalog.generated.js +260 -10
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/cloud-off-gate.d.ts +9 -8
- package/dist/commands/cloud-off-gate.js +41 -40
- package/dist/commands/cloud.d.ts +17 -2
- package/dist/commands/cloud.js +126 -24
- package/dist/commands/core-delegate-w1b.js +333 -27
- package/dist/commands/core-delegate.d.ts +2 -1
- package/dist/commands/core-delegate.js +209 -48
- package/dist/commands/core-handoff.js +1 -1
- package/dist/commands/core-job-model-auth.d.ts +95 -0
- package/dist/commands/core-job-model-auth.js +247 -0
- package/dist/commands/core-job-run-native.js +280 -12
- package/dist/commands/core.js +1 -0
- package/dist/commands/deploy-comments.js +8 -2
- package/dist/commands/deploy-events.d.ts +40 -0
- package/dist/commands/deploy-events.js +300 -0
- package/dist/commands/doctor.d.ts +4 -4
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/feedback.js +2 -3
- package/dist/commands/files-browse.js +2 -0
- package/dist/commands/files.js +4 -0
- package/dist/commands/integrations-core.d.ts +11 -0
- package/dist/commands/integrations-core.js +15 -1
- package/dist/commands/keyed-sync-pull.d.ts +12 -0
- package/dist/commands/keyed-sync-pull.js +151 -0
- package/dist/commands/lanes-link.js +2 -2
- package/dist/commands/lanes-loop.d.ts +2 -2
- package/dist/commands/lanes-loop.js +5 -5
- package/dist/commands/lanes-questions.js +1 -1
- package/dist/commands/lanes-stories.js +1 -1
- package/dist/commands/lanes.js +80 -14
- package/dist/commands/library-add.d.ts +5 -2
- package/dist/commands/library-add.js +22 -9
- package/dist/commands/mcp-registration.d.ts +4 -18
- package/dist/commands/mcp-registration.js +9 -29
- package/dist/commands/mesh.d.ts +4 -0
- package/dist/commands/mesh.js +25 -5
- package/dist/commands/pack-install.d.ts +2 -3
- package/dist/commands/pack-install.js +6 -8
- package/dist/commands/rescue.d.ts +3 -2
- package/dist/commands/rescue.js +48 -34
- package/dist/commands/search.d.ts +6 -0
- package/dist/commands/search.js +24 -4
- package/dist/commands/secrets.d.ts +3 -4
- package/dist/commands/secrets.js +3 -20
- package/dist/commands/sources.js +6 -2
- package/dist/commands/sync-core.d.ts +8 -0
- package/dist/commands/sync-core.js +43 -0
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1830 -1468
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/bot/api.d.ts +2 -1
- package/dist/lib/bot/api.js +2 -15
- package/dist/lib/capacity/accounts.d.ts +1 -1
- package/dist/lib/capacity/accounts.js +1 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
- package/dist/lib/capacity/freshness.d.ts +1 -1
- package/dist/lib/capacity/freshness.js +1 -1
- package/dist/lib/capacity/route.js +1 -1
- package/dist/lib/core-utils/delegate-helper-paths.d.ts +26 -0
- package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
- package/dist/lib/daemon/catalog.d.ts +3 -0
- package/dist/lib/daemon/hook-requests.d.ts +1 -1
- package/dist/lib/daemon/hook-requests.js +4 -2
- package/dist/lib/daemon/jq-provision.d.ts +63 -0
- package/dist/lib/daemon/jq-provision.js +155 -0
- package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
- package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
- package/dist/lib/daemon/mesh-owner.d.ts +4 -0
- package/dist/lib/daemon/mesh-owner.js +20 -0
- package/dist/lib/daemon/ops/policy.d.ts +3 -0
- package/dist/lib/daemon/ops/policy.js +32 -4
- package/dist/lib/daemon/run.js +17 -22
- package/dist/lib/daemon/server.d.ts +6 -0
- package/dist/lib/daemon/server.js +5 -0
- package/dist/lib/daemon/verified-jq.d.ts +96 -0
- package/dist/lib/daemon/verified-jq.js +337 -0
- package/dist/lib/doctor/checks/jq.js +16 -0
- package/dist/lib/doctor/deep/executor.d.ts +7 -0
- package/dist/lib/doctor/deep/executor.js +1 -1
- package/dist/lib/doctor/deep/parity.js +1 -27
- package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
- package/dist/lib/doctor/deep/sandbox.js +3 -19
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
- package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
- package/dist/lib/doctor/fixtures/discover.js +1 -1
- package/dist/lib/doctor/json-output.d.ts +1 -1
- package/dist/lib/doctor/registry.d.ts +6 -7
- package/dist/lib/doctor/registry.js +6 -7
- package/dist/lib/doctor/report.d.ts +9 -10
- package/dist/lib/doctor/report.js +4 -4
- package/dist/lib/environment/work-requirements.d.ts +1 -1
- package/dist/lib/environment/work-requirements.js +1 -1
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/hook-engine/coverage.js +11 -3
- package/dist/lib/hook-engine/git-stop-config.json +510 -510
- package/dist/lib/hook-engine/native-precompact-compatibility.json +443 -443
- package/dist/lib/hook-engine/native-stop-compatibility.json +359 -359
- package/dist/lib/hot-channels/adapters/meetings.d.ts +1 -16
- package/dist/lib/hot-channels/adapters/meetings.js +3 -28
- package/dist/lib/hot-channels/adapters/slack.d.ts +3 -1
- package/dist/lib/hot-channels/adapters/slack.js +4 -1
- package/dist/lib/hot-channels/contract.d.ts +14 -0
- package/dist/lib/hot-channels/fleet-complete.d.ts +18 -2
- package/dist/lib/hot-channels/fleet-complete.js +29 -4
- package/dist/lib/hot-channels/meeting-source-ref.d.ts +17 -0
- package/dist/lib/hot-channels/meeting-source-ref.js +32 -0
- package/dist/lib/hot-channels/prompts/signals-pass.md +6 -1
- package/dist/lib/hot-channels/run.d.ts +10 -0
- package/dist/lib/hot-channels/run.js +34 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +27 -0
- package/dist/lib/hot-channels/signals-pass.js +57 -2
- package/dist/lib/hot-channels/signals-runtime.js +3 -2
- package/dist/lib/jq/install.d.ts +27 -0
- package/dist/lib/jq/install.js +156 -0
- package/dist/lib/lanes/accounts.js +2 -2
- package/dist/lib/lanes/claude-balance.d.ts +6 -0
- package/dist/lib/lanes/claude-balance.js +124 -0
- package/dist/lib/lanes/grants.js +15 -2
- package/dist/lib/lanes/hq-root.d.ts +1 -1
- package/dist/lib/lanes/hq-root.js +1 -1
- package/dist/lib/lanes/links.d.ts +1 -1
- package/dist/lib/lanes/liveness.d.ts +3 -0
- package/dist/lib/lanes/liveness.js +61 -7
- package/dist/lib/lanes/models.d.ts +1 -1
- package/dist/lib/lanes/models.js +1 -1
- package/dist/lib/lanes/outpost-dispatch.d.ts +1 -1
- package/dist/lib/lanes/outpost-dispatch.js +13 -13
- package/dist/lib/lanes/outpost-pruner-install.js +1 -1
- package/dist/lib/lanes/questions.d.ts +1 -1
- package/dist/lib/lanes/questions.js +2 -2
- package/dist/lib/lanes/spawn.js +4 -6
- package/dist/lib/lanes/store.d.ts +13 -2
- package/dist/lib/lanes/store.js +13 -5
- package/dist/lib/lanes/types.d.ts +7 -7
- package/dist/lib/lanes/types.js +1 -1
- package/dist/lib/lanes/watcher-main.js +1 -1
- package/dist/lib/lanes/watcher.d.ts +1 -1
- package/dist/lib/lanes/watcher.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor.js +7 -1
- package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
- package/dist/lib/mesh/live/daemon/install.js +10 -0
- package/dist/lib/mesh/live/daemon/run.js +17 -0
- package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
- package/dist/lib/mesh/live/emit-retry.js +57 -4
- package/dist/lib/mesh/live/emit.js +25 -4
- package/dist/lib/mesh/live/flush.d.ts +2 -0
- package/dist/lib/mesh/live/flush.js +21 -8
- package/dist/lib/mesh/live/spool.d.ts +9 -1
- package/dist/lib/mesh/live/spool.js +41 -29
- package/dist/lib/onboarding/cli/onboard.js +5 -0
- package/dist/lib/signals/sanitize.d.ts +19 -0
- package/dist/lib/signals/sanitize.js +103 -7
- package/dist/lib/signals/steps/upload.d.ts +40 -1
- package/dist/lib/signals/steps/upload.js +122 -6
- package/dist/lib/sync-core/access-refresh.d.ts +29 -0
- package/dist/lib/sync-core/access-refresh.js +97 -0
- package/dist/lib/sync-core/company-adoption.d.ts +33 -0
- package/dist/lib/sync-core/company-adoption.js +223 -0
- package/dist/lib/sync-core/engine-home.d.ts +1 -0
- package/dist/lib/sync-core/engine-owned.d.ts +13 -0
- package/dist/lib/sync-core/engine-owned.js +38 -0
- package/dist/lib/sync-core/hand-back.d.ts +17 -0
- package/dist/lib/sync-core/hand-back.js +23 -0
- package/dist/lib/sync-core/post-apply-reindex.d.ts +33 -0
- package/dist/lib/sync-core/post-apply-reindex.js +149 -0
- package/dist/lib/sync-core/reconcile.d.ts +10 -0
- package/dist/lib/sync-core/reconcile.js +117 -12
- package/dist/lib/sync-core/rollout-state.d.ts +11 -1
- package/dist/lib/sync-core/rollout-state.js +40 -4
- package/dist/lib/vault-sync-switches.d.ts +14 -0
- package/dist/lib/vault-sync-switches.js +22 -0
- package/dist/lib/windows/jq.d.ts +4 -0
- package/dist/lib/windows/jq.js +10 -39
- package/dist/lib/workers-registry/index.d.ts +1 -1
- package/dist/lib/workers-registry/index.js +8 -12
- package/dist/utils/callback-port-busy.d.ts +2 -2
- package/dist/utils/callback-port-busy.js +2 -2
- package/dist/utils/cli-network-lifecycle.js +1 -0
- package/dist/utils/client-health-contract.d.ts +2 -0
- package/dist/utils/client-health-contract.js +1 -1
- package/dist/utils/client-health.js +1 -9
- package/dist/utils/cognito-config.js +5 -0
- package/dist/utils/cognito-session.d.ts +4 -6
- package/dist/utils/cognito-session.js +4 -24
- package/dist/utils/github-tag-fallback.d.ts +16 -0
- package/dist/utils/github-tag-fallback.js +126 -0
- package/dist/utils/incomplete-install-error.js +1 -11
- package/dist/utils/install-tree-torn.d.ts +11 -0
- package/dist/utils/install-tree-torn.js +1 -1
- package/dist/utils/resident-package-preload.js +2 -1
- package/dist/utils/version-report.d.ts +2 -1
- package/dist/utils/version-report.js +40 -27
- package/docs/anywhere-runtime.md +8 -0
- package/package.json +9 -9
|
@@ -32,7 +32,7 @@ async function readHookInput() {
|
|
|
32
32
|
function commandError(error) {
|
|
33
33
|
const code = error instanceof LaneLinkError ? error.code : "internal";
|
|
34
34
|
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
-
process.stderr.write(`hq
|
|
35
|
+
process.stderr.write(`hq runners link: ${message}\n`);
|
|
36
36
|
writeJson({ error: code, message });
|
|
37
37
|
process.exitCode = 1;
|
|
38
38
|
}
|
|
@@ -82,7 +82,7 @@ export function registerLanesLinkCommand(lanes) {
|
|
|
82
82
|
writeJson(result.output);
|
|
83
83
|
}
|
|
84
84
|
catch (error) {
|
|
85
|
-
process.stderr.write(`hq
|
|
85
|
+
process.stderr.write(`hq runners link _deliver: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
86
86
|
// Hook failures are fail-open; queued messages remain available if delivery failed.
|
|
87
87
|
}
|
|
88
88
|
});
|
|
@@ -10,7 +10,7 @@ import type { LaneRecord } from "../lib/lanes/types.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function settleLoopLaneIdle(hqRoot: string, laneId: string): LaneRecord;
|
|
12
12
|
/**
|
|
13
|
-
* The next phase resumes the provider session, which `hq
|
|
13
|
+
* The next phase resumes the provider session, which `hq runners resume` only
|
|
14
14
|
* accepts from a resumable state. An idle loop lane sits in `running` with no
|
|
15
15
|
* worker, so it is handed to resume as the `done` lane the phase left.
|
|
16
16
|
*/
|
|
@@ -44,7 +44,7 @@ export interface LoopControllerDeps {
|
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* terminal_reason values for interrupts HQ issues itself. An operator
|
|
47
|
-
* interrupt (`hq
|
|
47
|
+
* interrupt (`hq runners interrupt`) records `operator_interrupt`; these keep a
|
|
48
48
|
* system recovery from looking like an operator action in the lane record.
|
|
49
49
|
*/
|
|
50
50
|
export declare const LOOP_CONTROLLER_RECOVERY_REASON = "loop_controller_recovery";
|
|
@@ -28,7 +28,7 @@ export function settleLoopLaneIdle(hqRoot, laneId) {
|
|
|
28
28
|
return casLoopLaneState(hqRoot, laneId, "done", "running");
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* The next phase resumes the provider session, which `hq
|
|
31
|
+
* The next phase resumes the provider session, which `hq runners resume` only
|
|
32
32
|
* accepts from a resumable state. An idle loop lane sits in `running` with no
|
|
33
33
|
* worker, so it is handed to resume as the `done` lane the phase left.
|
|
34
34
|
*/
|
|
@@ -94,7 +94,7 @@ function casLoopLaneState(hqRoot, laneId, from, to) {
|
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* terminal_reason values for interrupts HQ issues itself. An operator
|
|
97
|
-
* interrupt (`hq
|
|
97
|
+
* interrupt (`hq runners interrupt`) records `operator_interrupt`; these keep a
|
|
98
98
|
* system recovery from looking like an operator action in the lane record.
|
|
99
99
|
*/
|
|
100
100
|
export const LOOP_CONTROLLER_RECOVERY_REASON = "loop_controller_recovery";
|
|
@@ -166,7 +166,7 @@ export async function runLaneLoopController(ctx, laneId, deps) {
|
|
|
166
166
|
// no longer be loaded or cancelled.
|
|
167
167
|
const ignoreEnvelopeStory = envelopeStory !== undefined && !current.story_id && !!current.no_story_reason;
|
|
168
168
|
if (ignoreEnvelopeStory) {
|
|
169
|
-
process.stderr.write(`hq
|
|
169
|
+
process.stderr.write(`hq runners: ignoring envelope story_id ${envelopeStory} for no-story lane ${laneId}\n`);
|
|
170
170
|
}
|
|
171
171
|
const storyId = envelopeStory !== undefined && !ignoreEnvelopeStory ? envelopeStory : current.story_id;
|
|
172
172
|
if (storyId !== current.story_id) {
|
|
@@ -281,7 +281,7 @@ export async function runLaneLoopController(ctx, laneId, deps) {
|
|
|
281
281
|
catch (error) {
|
|
282
282
|
// Transient admission refusal before any engine launched (for
|
|
283
283
|
// example a store lock timeout). The envelope is already active, so keep it
|
|
284
|
-
// and park the lane as queued with a reason `hq
|
|
284
|
+
// and park the lane as queued with a reason `hq runners show`
|
|
285
285
|
// displays; the next admission launches this phase from
|
|
286
286
|
// pending_resume and the wait below picks up its result.
|
|
287
287
|
if (!(error instanceof LanesError) ||
|
|
@@ -298,7 +298,7 @@ export async function runLaneLoopController(ctx, laneId, deps) {
|
|
|
298
298
|
let interruptPromise;
|
|
299
299
|
const abortPhase = () => {
|
|
300
300
|
interruptPromise = deps.interruptLane(laneId, "loop phase deadline exceeded", { preserveLoopQueue: true, terminalReason: LOOP_PHASE_DEADLINE_REASON }).catch((error) => {
|
|
301
|
-
process.stderr.write(`hq
|
|
301
|
+
process.stderr.write(`hq runners: could not interrupt stalled loop phase ${laneId}: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
302
302
|
});
|
|
303
303
|
};
|
|
304
304
|
signal.addEventListener("abort", abortPhase, { once: true });
|
|
@@ -940,7 +940,7 @@ export function createLaneQuestionsHandlers(deps) {
|
|
|
940
940
|
});
|
|
941
941
|
if (isLoopStallQuestion) {
|
|
942
942
|
if (!loopStallResult && !retryingSameLoopAnswer) {
|
|
943
|
-
process.stderr.write(`hq
|
|
943
|
+
process.stderr.write(`hq runners: loop phase for question ${questionId} was already re-enqueued; recording answer as superseded\n`);
|
|
944
944
|
printJson({ ok: true, action: "questions.answer", lane_id: askingLane.lane_id, question: updated, loop_action: "superseded" });
|
|
945
945
|
return;
|
|
946
946
|
}
|
|
@@ -143,7 +143,7 @@ export function createLaneStoryHandlers(deps) {
|
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
catch (rollbackErr) {
|
|
146
|
-
process.stderr.write(`hq
|
|
146
|
+
process.stderr.write(`hq runners: story transition rollback failed for ${next.lane_id}/${projectId}/${storyId}: ${rollbackErr instanceof Error ? rollbackErr.message : String(rollbackErr)}\n`);
|
|
147
147
|
}
|
|
148
148
|
throw err;
|
|
149
149
|
}
|
package/dist/commands/lanes.js
CHANGED
|
@@ -65,14 +65,14 @@ import { createOutpostRegistryWorkerApprovalContext, parseOutpostRegistryWorkerA
|
|
|
65
65
|
import { OUTPOST_DIR, OUTPOST_ID_PATH, readOutpostIdentity, resolveAdmissionHost, } from "../lib/lanes/admission-host.js";
|
|
66
66
|
export { OUTPOST_DIR, OUTPOST_ID_PATH, readOutpostIdentity } from "../lib/lanes/admission-host.js";
|
|
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
|
-
import { assertCompanyOutpostBelongsTo, companyAwareExecPort, companyOutpostAccessRequired, companyOutpostNeedsCompany, companyOutpostNotLaneReady, companyOutpostRefusal, CompanyOutpostTargets, isCompanyOutpostId, isCompanyOutpostRefusal, isNoCompanyOutposts, listCompanyOutpostCandidates, readyCompanyOutpostIds, } from "../lib/lanes/company-outposts.js";
|
|
68
|
+
import { assertCompanyOutpostBelongsTo, companyAwareExecPort, companyOutpostAccessRequired, companyOutpostNeedsCompany, companyOutpostNotLaneReady, companyOutpostRefusal, CompanyOutpostTargets, companyUidOfFirstOutpostId, isCompanyOutpostId, isCompanyOutpostRefusal, isNoCompanyOutposts, listCompanyOutpostCandidates, readyCompanyOutpostIds, } from "../lib/lanes/company-outposts.js";
|
|
69
69
|
import { outpostHireSummaryCacheKey, OUTPOST_HIRE_SUMMARY_CACHE_TTL_MS, readOutpostHireSummaryCache, readOutpostHireSummaryCacheIncludingStale, writeOutpostHireSummaryCache, } from "../lib/lanes/outpost-hire-cache.js";
|
|
70
70
|
import { buildHostCapacitySnapshot, chooseHostForLane, hostCapacitySnapshotToWire, parseHostCapacitySnapshot, } from "../lib/lanes/host-capacity.js";
|
|
71
71
|
import { readHostCompute } from "../lib/lanes/host-compute.js";
|
|
72
72
|
import { resolveCanonicalHost } from "../lib/lanes/canonical-host.js";
|
|
73
73
|
import { parseLaneRunSize, runSizeMediansByRepo } from "../lib/lanes/run-size.js";
|
|
74
74
|
import { readInstanceIdFromDisk } from "../lib/lanes/machine-identity.js";
|
|
75
|
-
import { BALANCE_MOVABLE_STATES, selectClaudeAccount, } from "../lib/lanes/claude-balance.js";
|
|
75
|
+
import { BALANCE_MOVABLE_STATES, selectClaudeAccount, selectCompanyOutpostClaudeAccount, } from "../lib/lanes/claude-balance.js";
|
|
76
76
|
import { parseUserYaml } from "../utils/user-yaml-error.js";
|
|
77
77
|
import { backfillOutpostIdentityMarker as backfillOutpostIdentityMarkerImpl, createOutpostIdentityMarkerIfMissing, validateOutpostIdentityId, } from "../lib/lanes/outpost-identity.js";
|
|
78
78
|
import { vaultApiFetch } from "../utils/vault-api.js";
|
|
@@ -1647,6 +1647,8 @@ async function readOutpostCapacityUncached(ctx, outpostId, waitMs = CAPACITY_PRO
|
|
|
1647
1647
|
});
|
|
1648
1648
|
}
|
|
1649
1649
|
catch (err) {
|
|
1650
|
+
if (isCompanyOutpostRefusal(err))
|
|
1651
|
+
throw err;
|
|
1650
1652
|
throw new LanesError("outpost_capacity_unavailable", `Could not read capacity from Outpost ${outpostId}: ${dispatchErrorMessage(err)}`, { outpost_id: outpostId });
|
|
1651
1653
|
}
|
|
1652
1654
|
if (result.done !== true || result.status !== "Success" || result.exitCode !== 0) {
|
|
@@ -2202,9 +2204,25 @@ async function resolveCommandLaneTarget(ctx, laneId, options = {}) {
|
|
|
2202
2204
|
(hostSuffix && sanitizeHostComponent(hostSuffix) !== hostSuffix)) {
|
|
2203
2205
|
throw commandLaneNotFound(laneId, options.outpostHint === true);
|
|
2204
2206
|
}
|
|
2207
|
+
const requestedCompanyOutpost = options.outpostId !== undefined && isCompanyOutpostId(options.outpostId.trim())
|
|
2208
|
+
? options.outpostId.trim()
|
|
2209
|
+
: undefined;
|
|
2210
|
+
if (requestedCompanyOutpost !== undefined) {
|
|
2211
|
+
const companySlug = options.company?.trim();
|
|
2212
|
+
const ownerUid = companyUidOfFirstOutpostId(requestedCompanyOutpost);
|
|
2213
|
+
if (!companySlug && ownerUid === undefined)
|
|
2214
|
+
throw companyOutpostNeedsCompany(requestedCompanyOutpost);
|
|
2215
|
+
const company = companySlug
|
|
2216
|
+
? await ctx.resolveCompany(companySlug)
|
|
2217
|
+
: await ctx.resolveActiveCompany(ownerUid);
|
|
2218
|
+
if (!company) {
|
|
2219
|
+
throw new LanesError("company_outpost_not_a_member", `Only current members of the company that owns Outpost ${requestedCompanyOutpost} can use it.`, { outpost_id: requestedCompanyOutpost, company_uid: ownerUid });
|
|
2220
|
+
}
|
|
2221
|
+
await assertKnownLaneOutpost(ctx, requestedCompanyOutpost, company);
|
|
2222
|
+
}
|
|
2205
2223
|
let rawOutpostRoutes;
|
|
2206
2224
|
try {
|
|
2207
|
-
rawOutpostRoutes = await ctx.listOutpostRoutes();
|
|
2225
|
+
rawOutpostRoutes = requestedCompanyOutpost !== undefined ? [] : await ctx.listOutpostRoutes();
|
|
2208
2226
|
}
|
|
2209
2227
|
catch (err) {
|
|
2210
2228
|
throw new LanesError("outpost_list_unavailable", `Could not resolve registered Outposts for lane ${laneId}: ${dispatchErrorMessage(err)}`, { lane_id: laneId });
|
|
@@ -2239,7 +2257,7 @@ async function resolveCommandLaneTarget(ctx, laneId, options = {}) {
|
|
|
2239
2257
|
if (options.outpostId !== undefined && !requestedOutpostId) {
|
|
2240
2258
|
throw new LanesError("outpost_id_invalid", "--outpost must be a registered Outpost id", { lane_id: laneId });
|
|
2241
2259
|
}
|
|
2242
|
-
if (requestedOutpostId !== undefined && !outpostIds.includes(requestedOutpostId)) {
|
|
2260
|
+
if (requestedOutpostId !== undefined && requestedCompanyOutpost === undefined && !outpostIds.includes(requestedOutpostId)) {
|
|
2243
2261
|
throw new LanesError("outpost_not_registered", `Outpost ${requestedOutpostId} is not registered`, { lane_id: laneId, outpost_id: requestedOutpostId });
|
|
2244
2262
|
}
|
|
2245
2263
|
const hostRoutes = hostlessUlidLookup
|
|
@@ -2360,6 +2378,34 @@ function commandLaneNotFound(laneId, outpostHint, details = {}) {
|
|
|
2360
2378
|
: "";
|
|
2361
2379
|
return new LanesError("lane_not_found", `Could not resolve lane ${laneId}: no matching local record or reachable registered Outpost owner record was found${hint}`, { lane_id: laneId, ...details });
|
|
2362
2380
|
}
|
|
2381
|
+
async function loadCompanyOutpostBalanceHost(ctx, outpostId) {
|
|
2382
|
+
const host = { kind: "outpost", id: outpostId };
|
|
2383
|
+
let capacity;
|
|
2384
|
+
try {
|
|
2385
|
+
capacity = await readOutpostCapacity(ctx, outpostId, outpostSingleLaneWaitMs(ctx.env));
|
|
2386
|
+
}
|
|
2387
|
+
catch (err) {
|
|
2388
|
+
if (isCompanyOutpostRefusal(err))
|
|
2389
|
+
throw err;
|
|
2390
|
+
const reason = isLanesError(err) ? err.error : "outpost_capacity_unavailable";
|
|
2391
|
+
throw new LanesError("claude_account_balance_target_host_unavailable", `Cannot verify Claude accounts on target host outpost:${outpostId}: ${dispatchErrorMessage(err)}`, { requested_placement: null, target_host: host, unavailable_hosts: [{ host, reason }] });
|
|
2392
|
+
}
|
|
2393
|
+
try {
|
|
2394
|
+
const lanes = await readOutpostLaneRecords(ctx, outpostId, { snapshot: true });
|
|
2395
|
+
return {
|
|
2396
|
+
capacity,
|
|
2397
|
+
lanes: lanes.filter((lane) => lane.host.kind === "outpost" && lane.host.id === outpostId),
|
|
2398
|
+
laneListAvailable: true,
|
|
2399
|
+
};
|
|
2400
|
+
}
|
|
2401
|
+
catch (err) {
|
|
2402
|
+
if (isCompanyOutpostRefusal(err))
|
|
2403
|
+
throw err;
|
|
2404
|
+
if (isLanesError(err) && err.error === "outpost_lane_list_invalid")
|
|
2405
|
+
throw err;
|
|
2406
|
+
return { capacity, lanes: [], laneListAvailable: false };
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2363
2409
|
async function loadClaudeBalanceHostSnapshots(ctx, hqRoot, config, options = {}) {
|
|
2364
2410
|
const localHost = laneHostFromCtx(ctx);
|
|
2365
2411
|
const localLanes = loadAllLanes(hqRoot);
|
|
@@ -3925,7 +3971,17 @@ async function runCreate(ctx, opts) {
|
|
|
3925
3971
|
let autoAccountPick;
|
|
3926
3972
|
let autoChosenProvider;
|
|
3927
3973
|
let autoChosenAccount;
|
|
3928
|
-
|
|
3974
|
+
const requestedCompanyOutpostTarget = (opts.outpost !== undefined && isCompanyOutpostId(opts.outpost.trim())) ||
|
|
3975
|
+
(requestedPlacement?.kind === "outpost" && isCompanyOutpostId(requestedPlacement.id));
|
|
3976
|
+
if (opts.account !== undefined && opts.account.trim() === "auto" && requestedCompanyOutpostTarget) {
|
|
3977
|
+
autoAccountPick = {
|
|
3978
|
+
why: "the lane runs on a company Outpost, so the account is chosen among the accounts signed in on that Outpost",
|
|
3979
|
+
headroom: 0,
|
|
3980
|
+
score: UNKNOWN_USAGE_SCORE,
|
|
3981
|
+
};
|
|
3982
|
+
opts = { ...opts, account: undefined };
|
|
3983
|
+
}
|
|
3984
|
+
else if (opts.account !== undefined && opts.account.trim() === "auto") {
|
|
3929
3985
|
const ledgerOptions = capacityOptionsFromEnv(ctx.env);
|
|
3930
3986
|
// feedback_9e444a9f / feedback_86552798: with no ledger yet (capacity was
|
|
3931
3987
|
// never enabled), or a ledger with no reading for any lane account, there
|
|
@@ -4388,9 +4444,10 @@ async function runCreate(ctx, opts) {
|
|
|
4388
4444
|
});
|
|
4389
4445
|
pinnedAccount = resolved.id;
|
|
4390
4446
|
}
|
|
4447
|
+
const targetsCompanyOutpost = outpostId !== undefined && isCompanyOutpostId(outpostId);
|
|
4391
4448
|
// PS-006: refuse a pinned login held by another person before any model
|
|
4392
4449
|
// check reads its home.
|
|
4393
|
-
if (pinnedAccount !== undefined)
|
|
4450
|
+
if (pinnedAccount !== undefined && !targetsCompanyOutpost)
|
|
4394
4451
|
refuseHeldPinnedAccount(provider, pinnedAccount, config);
|
|
4395
4452
|
if (outpostId !== undefined &&
|
|
4396
4453
|
profile !== undefined &&
|
|
@@ -4541,14 +4598,10 @@ async function runCreate(ctx, opts) {
|
|
|
4541
4598
|
const accountCompany = resolveLaneCompany(hqRoot, { lane_id: "pending-create", company, mesh_company: meshCompany ?? undefined, project_id: project }).company;
|
|
4542
4599
|
const allowedAccounts = Object.keys(config.providers[provider].accounts).filter((id) => (candidateAccounts === undefined || candidateAccounts.includes(id)) &&
|
|
4543
4600
|
accountMatchesCompany(config.providers[provider].accounts[id], accountCompany, config.providers[provider].accounts));
|
|
4544
|
-
if (pinnedAccount !== undefined)
|
|
4545
|
-
refuseHeldPinnedAccount(provider, pinnedAccount, config);
|
|
4546
|
-
if (pinnedAccount !== undefined && !accountMatchesCompany(config.providers[provider].accounts[pinnedAccount], accountCompany, config.providers[provider].accounts)) {
|
|
4601
|
+
if (pinnedAccount !== undefined && !targetsCompanyOutpost && !accountMatchesCompany(config.providers[provider].accounts[pinnedAccount], accountCompany, config.providers[provider].accounts)) {
|
|
4547
4602
|
throw new LanesError("account_company_mismatch", `Account ${pinnedAccount} does not belong to the lane company`, { provider, account: pinnedAccount });
|
|
4548
4603
|
}
|
|
4549
|
-
|
|
4550
|
-
// creates pick theirs on the Outpost, so they are not refused locally.
|
|
4551
|
-
if (pinnedAccount === undefined && (outpostId === undefined || provider === "claude")) {
|
|
4604
|
+
if (pinnedAccount === undefined && !targetsCompanyOutpost && (outpostId === undefined || provider === "claude")) {
|
|
4552
4605
|
const mismatch = companyMismatchError({
|
|
4553
4606
|
provider,
|
|
4554
4607
|
providerAccounts: config.providers[provider].accounts,
|
|
@@ -4559,7 +4612,18 @@ async function runCreate(ctx, opts) {
|
|
|
4559
4612
|
throw mismatch;
|
|
4560
4613
|
}
|
|
4561
4614
|
let accountSelection;
|
|
4562
|
-
if (provider === "claude") {
|
|
4615
|
+
if (provider === "claude" && targetsCompanyOutpost) {
|
|
4616
|
+
const target = await loadCompanyOutpostBalanceHost(ctx, outpostId);
|
|
4617
|
+
const selected = selectCompanyOutpostClaudeAccount({
|
|
4618
|
+
target,
|
|
4619
|
+
requestedPlacement: placementToApply ?? null,
|
|
4620
|
+
...(company ? { company } : {}),
|
|
4621
|
+
...(explicitBalanceAccount !== undefined && autoAccountPick === undefined ? { explicitAccount: explicitBalanceAccount } : {}),
|
|
4622
|
+
});
|
|
4623
|
+
pinnedAccount = selected.account;
|
|
4624
|
+
accountSelection = { ...selected, selected_at: ctx.now().toISOString() };
|
|
4625
|
+
}
|
|
4626
|
+
else if (provider === "claude") {
|
|
4563
4627
|
const persistedLocalHost = outpostId === undefined && placementHostOverride === undefined
|
|
4564
4628
|
? localStableHost(ctx)
|
|
4565
4629
|
: undefined;
|
|
@@ -4686,7 +4750,7 @@ async function runCreate(ctx, opts) {
|
|
|
4686
4750
|
...(allowedAccounts !== undefined ? { allowedAccounts } : {}),
|
|
4687
4751
|
}).id;
|
|
4688
4752
|
}
|
|
4689
|
-
const accountCfg = pinnedAccount !== undefined
|
|
4753
|
+
const accountCfg = pinnedAccount !== undefined && !targetsCompanyOutpost
|
|
4690
4754
|
? config.providers[provider].accounts[pinnedAccount]
|
|
4691
4755
|
: undefined;
|
|
4692
4756
|
const model = resolveLaneModel({
|
|
@@ -7661,6 +7725,7 @@ async function runGrant(ctx, laneId, opts) {
|
|
|
7661
7725
|
const target = await resolveCommandLaneTarget(ctx, laneId, {
|
|
7662
7726
|
outpostHint: true,
|
|
7663
7727
|
outpostId: opts.outpost,
|
|
7728
|
+
...(opts.company !== undefined ? { company: opts.company } : {}),
|
|
7664
7729
|
});
|
|
7665
7730
|
const initial = target.lane;
|
|
7666
7731
|
const callerAuthorization = callerSeniorAuthorization(ctx, initial.senior);
|
|
@@ -11322,6 +11387,7 @@ export function registerRunnersCommand(parent, deps = {}) {
|
|
|
11322
11387
|
.argument("<lane-id>", "Lane id")
|
|
11323
11388
|
.requiredOption("--hire <n>", "Non-negative safe integer hire grant")
|
|
11324
11389
|
.option("--outpost <id>", "Confirm the registered Outpost hosting a native lane")
|
|
11390
|
+
.option("--company <slug>", "Company that owns the --outpost company Outpost")
|
|
11325
11391
|
.action(wrap(async (laneId, opts) => {
|
|
11326
11392
|
await runGrant(ctx, laneId, opts);
|
|
11327
11393
|
}));
|
|
@@ -128,8 +128,11 @@ export declare function runLibraryAdd(inputs: readonly string[], options: Librar
|
|
|
128
128
|
*/
|
|
129
129
|
export declare function ensureLibraryInSyncScope(company: LibraryCompany, dirRel: string, placeholderPaths: readonly string[], deps: Pick<LibraryAddDeps, "hqRoot" | "syncScope" | "addPin">): Promise<LibrarySyncScopeNote | undefined>;
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
131
|
+
* Resolve the company's sync scope for the library pin note. A failed call
|
|
132
|
+
* is reported as that call's own error, so the note names the real cause.
|
|
133
|
+
* Since hq-cloud 6.18.117 {@link resolvePullScope} fails closed itself; it
|
|
134
|
+
* throws a SyncScopeLookupError whose message is a sync skip line, which
|
|
135
|
+
* would read wrongly in a pin note.
|
|
133
136
|
*/
|
|
134
137
|
export declare function resolveLibrarySyncScope(client: Required<PullScopeClient>, company: LibraryCompany, hqRoot: string): Promise<PullScope>;
|
|
135
138
|
export interface LibraryTagResult {
|
|
@@ -419,8 +419,11 @@ export async function ensureLibraryInSyncScope(company, dirRel, placeholderPaths
|
|
|
419
419
|
return { status: "pinned", pins: missing };
|
|
420
420
|
}
|
|
421
421
|
/**
|
|
422
|
-
*
|
|
423
|
-
*
|
|
422
|
+
* Resolve the company's sync scope for the library pin note. A failed call
|
|
423
|
+
* is reported as that call's own error, so the note names the real cause.
|
|
424
|
+
* Since hq-cloud 6.18.117 {@link resolvePullScope} fails closed itself; it
|
|
425
|
+
* throws a SyncScopeLookupError whose message is a sync skip line, which
|
|
426
|
+
* would read wrongly in a pin note.
|
|
424
427
|
*/
|
|
425
428
|
export async function resolveLibrarySyncScope(client, company, hqRoot) {
|
|
426
429
|
let failure;
|
|
@@ -428,13 +431,23 @@ export async function resolveLibrarySyncScope(client, company, hqRoot) {
|
|
|
428
431
|
failure ??= err;
|
|
429
432
|
throw err;
|
|
430
433
|
});
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
434
|
+
const rethrowFailure = () => {
|
|
435
|
+
if (failure !== undefined)
|
|
436
|
+
throw failure instanceof Error ? failure : new Error(String(failure));
|
|
437
|
+
};
|
|
438
|
+
let scope;
|
|
439
|
+
try {
|
|
440
|
+
scope = await resolvePullScope({
|
|
441
|
+
listMyMemberships: () => watch(client.listMyMemberships()),
|
|
442
|
+
getMembershipSyncConfig: (id) => watch(client.getMembershipSyncConfig(id)),
|
|
443
|
+
listMyExplicitGrants: (uid) => watch(client.listMyExplicitGrants(uid)),
|
|
444
|
+
}, company.uid, company.slug, hqRoot);
|
|
445
|
+
}
|
|
446
|
+
catch (err) {
|
|
447
|
+
rethrowFailure();
|
|
448
|
+
throw err;
|
|
449
|
+
}
|
|
450
|
+
rethrowFailure();
|
|
438
451
|
return scope;
|
|
439
452
|
}
|
|
440
453
|
async function writeAssetPlaceholder(p, options, deps, dirAbs) {
|
|
@@ -121,20 +121,6 @@ export declare class PartialRegistrationError extends McpRegistrationError {
|
|
|
121
121
|
readonly backupDir: string | undefined;
|
|
122
122
|
constructor(message: string, backupDir?: string);
|
|
123
123
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Thrown by not-yet-implemented seams (the US-007/US-008 Claude/Codex emitters).
|
|
126
|
-
* Carries a stable `code` so callers/tests can identify it without string-
|
|
127
|
-
* matching the message, and a `story` for at-a-glance attribution. KEPT from the
|
|
128
|
-
* US-005 seam: the merge EMITTERS are still pending after US-006 (which ships the
|
|
129
|
-
* safe-write substrate beneath them).
|
|
130
|
-
*/
|
|
131
|
-
export declare class NotImplementedError extends Error {
|
|
132
|
-
/** Stable, machine-checkable discriminator. */
|
|
133
|
-
readonly code: "NotImplemented";
|
|
134
|
-
/** The PRD story that lands the real implementation. */
|
|
135
|
-
readonly story: string;
|
|
136
|
-
constructor(message: string, story?: string);
|
|
137
|
-
}
|
|
138
124
|
/** Roots the substrate's view of the filesystem; everything is derived from `home`. */
|
|
139
125
|
export interface SafeWriteEnv {
|
|
140
126
|
/** The user home directory. Tests MUST pass a tmpdir here. */
|
|
@@ -677,10 +663,10 @@ export declare function isMcpRegistrationEnabled(env?: Readonly<Record<string, s
|
|
|
677
663
|
* `pack-install` routes `wire:'merge'` keys to). For each declared server name it
|
|
678
664
|
* loads + shape-checks the manifest, then fans out via {@link registerServer}.
|
|
679
665
|
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
* supplied loader so this stays decoupled from
|
|
683
|
-
* fully testable in isolation.
|
|
666
|
+
* It wires the Claude/JSON surface (US-007) and the Codex/TOML surface (US-008);
|
|
667
|
+
* on a host without Codex the Codex surface is a first-class skip. Manifests are
|
|
668
|
+
* loaded with a caller-supplied loader so this stays decoupled from
|
|
669
|
+
* `pack-install`'s payload layout and fully testable in isolation.
|
|
684
670
|
*
|
|
685
671
|
* @param pkg the pack name (e.g. `hq-pack-vyg-shopify`) — stamped as provenance
|
|
686
672
|
* @param names the bare server names from `contributes.mcp`
|
|
@@ -134,25 +134,6 @@ export class PartialRegistrationError extends McpRegistrationError {
|
|
|
134
134
|
this.backupDir = backupDir;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
/**
|
|
138
|
-
* Thrown by not-yet-implemented seams (the US-007/US-008 Claude/Codex emitters).
|
|
139
|
-
* Carries a stable `code` so callers/tests can identify it without string-
|
|
140
|
-
* matching the message, and a `story` for at-a-glance attribution. KEPT from the
|
|
141
|
-
* US-005 seam: the merge EMITTERS are still pending after US-006 (which ships the
|
|
142
|
-
* safe-write substrate beneath them).
|
|
143
|
-
*/
|
|
144
|
-
export class NotImplementedError extends Error {
|
|
145
|
-
/** Stable, machine-checkable discriminator. */
|
|
146
|
-
code = 'NotImplemented';
|
|
147
|
-
/** The PRD story that lands the real implementation. */
|
|
148
|
-
story;
|
|
149
|
-
constructor(message, story = 'US-007') {
|
|
150
|
-
super(message);
|
|
151
|
-
this.name = 'NotImplementedError';
|
|
152
|
-
this.story = story;
|
|
153
|
-
Object.setPrototypeOf(this, NotImplementedError.prototype);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
137
|
/** Resolve the env, defaulting `home` to the real `os.homedir()` for production callers. */
|
|
157
138
|
export function resolveEnv(env) {
|
|
158
139
|
const home = env?.home ?? os.homedir();
|
|
@@ -1078,12 +1059,11 @@ function restoreSafely(realTarget, backupDir) {
|
|
|
1078
1059
|
// merges exactly ONE `mcpServers.<name>` entry into the PINNED single Claude
|
|
1079
1060
|
// surface (top-level `~/.claude.json` `mcpServers`) via {@link writeConfigAtomic}.
|
|
1080
1061
|
//
|
|
1081
|
-
// The Codex/TOML emitter is US-008
|
|
1082
|
-
// {@link registerServer} fan-out
|
|
1083
|
-
//
|
|
1084
|
-
//
|
|
1085
|
-
//
|
|
1086
|
-
// desired-state-convergence).
|
|
1062
|
+
// The Codex/TOML emitter is {@link registerCodexServer} (US-008). The
|
|
1063
|
+
// {@link registerServer} fan-out runs both arms; on a host without Codex the
|
|
1064
|
+
// Codex arm is a first-class skip (the substrate's {@link isCodexInstalled}
|
|
1065
|
+
// branch), never a crash and never a fabricated `~/.codex`. Each surface
|
|
1066
|
+
// self-heals on re-run (US-006 desired-state convergence).
|
|
1087
1067
|
//
|
|
1088
1068
|
// SECRET SAFETY (the hard rule from the PRD authModel / US-002 AC):
|
|
1089
1069
|
// - `${secret:NAME}` resolves ONLY here, at emit, via the injected
|
|
@@ -1491,10 +1471,10 @@ export function isMcpRegistrationEnabled(env = process.env) {
|
|
|
1491
1471
|
* `pack-install` routes `wire:'merge'` keys to). For each declared server name it
|
|
1492
1472
|
* loads + shape-checks the manifest, then fans out via {@link registerServer}.
|
|
1493
1473
|
*
|
|
1494
|
-
*
|
|
1495
|
-
*
|
|
1496
|
-
* supplied loader so this stays decoupled from
|
|
1497
|
-
* fully testable in isolation.
|
|
1474
|
+
* It wires the Claude/JSON surface (US-007) and the Codex/TOML surface (US-008);
|
|
1475
|
+
* on a host without Codex the Codex surface is a first-class skip. Manifests are
|
|
1476
|
+
* loaded with a caller-supplied loader so this stays decoupled from
|
|
1477
|
+
* `pack-install`'s payload layout and fully testable in isolation.
|
|
1498
1478
|
*
|
|
1499
1479
|
* @param pkg the pack name (e.g. `hq-pack-vyg-shopify`) — stamped as provenance
|
|
1500
1480
|
* @param names the bare server names from `contributes.mcp`
|
package/dist/commands/mesh.d.ts
CHANGED
|
@@ -92,6 +92,10 @@ export declare function runDaemonStatus(opts: {
|
|
|
92
92
|
/** launchctl/systemctl runner for the loaded probe (tests inject). */
|
|
93
93
|
run?: RunCommand;
|
|
94
94
|
uid?: number;
|
|
95
|
+
hqDaemonMesh?: () => {
|
|
96
|
+
daemonPid: number;
|
|
97
|
+
pid?: number;
|
|
98
|
+
} | null;
|
|
95
99
|
}): Promise<void>;
|
|
96
100
|
/** Work Mesh health report: `hq daemon doctor` (and the retiring `hq mesh daemon doctor`). */
|
|
97
101
|
export declare function runMeshDaemonDoctor(opts: {
|
package/dist/commands/mesh.js
CHANGED
|
@@ -35,7 +35,7 @@ import { appendHeldLine } from "../lib/mesh/live/spool.js";
|
|
|
35
35
|
import { createEmitPoster, buildMeshEmitEvent } from "../lib/mesh/live/emit-client.js";
|
|
36
36
|
import { enrichSessionEndEvent } from "../lib/mesh/live/report-summary.js";
|
|
37
37
|
import { emitEvents, formatEmitRejectionLines } from "../lib/mesh/live/emit.js";
|
|
38
|
-
import { readEmitRetry, writeEmitRetry } from "../lib/mesh/live/emit-retry.js";
|
|
38
|
+
import { appendEmitRetry, readEmitRetry, writeEmitRetry } from "../lib/mesh/live/emit-retry.js";
|
|
39
39
|
import { generateUlid } from "../lib/mesh/live/ulid.js";
|
|
40
40
|
import { readLegacyBacklogForMode } from "../lib/mesh/live/emit-replay.js";
|
|
41
41
|
import { resolveMeshEmitMode, writeMeshConfigMode, } from "../lib/mesh/live/daemon/mode.js";
|
|
@@ -63,7 +63,7 @@ import { deriveRemoteOwnerSlug, deriveRepoIdentityKey, } from "../lib/work-conte
|
|
|
63
63
|
import { promptRepoCompany, } from "../lib/work-context/repo-prompt.js";
|
|
64
64
|
import { requeueQuarantinedOutbox } from "../lib/work-context/outbox.js";
|
|
65
65
|
import { handOffInstallHere } from "../lib/daemon/handoff.js";
|
|
66
|
-
import { repairServiceUnitsFromOtherHome } from "../lib/daemon/mesh-owner.js";
|
|
66
|
+
import { hqDaemonMeshService, repairServiceUnitsFromOtherHome } from "../lib/daemon/mesh-owner.js";
|
|
67
67
|
import { runResidentCommandWithPackageLease } from "../utils/resident-package-preload.js";
|
|
68
68
|
import { exitCli } from "../utils/exit-after-worker.js";
|
|
69
69
|
export function formatCheckLines(threads, company, projectId) {
|
|
@@ -1166,7 +1166,16 @@ async function runPrdSync(opts) {
|
|
|
1166
1166
|
console.error(line);
|
|
1167
1167
|
}
|
|
1168
1168
|
const blocked = new Set(emitted.rejections.map((row) => row.eventId));
|
|
1169
|
-
|
|
1169
|
+
let retryPending;
|
|
1170
|
+
try {
|
|
1171
|
+
retryPending = readEmitRetry(meshRoot);
|
|
1172
|
+
}
|
|
1173
|
+
catch (err) {
|
|
1174
|
+
// Unknown which events still wait for retry: advance none of them.
|
|
1175
|
+
console.error(`work-mesh: prd-sync could not read the emit retry file; no stories advanced: ${(err instanceof Error ? err.message : String(err)).slice(0, 120)}`);
|
|
1176
|
+
retryPending = events;
|
|
1177
|
+
}
|
|
1178
|
+
for (const pending of retryPending) {
|
|
1170
1179
|
const id = typeof pending.eventId === "string" ? pending.eventId : "";
|
|
1171
1180
|
if (id)
|
|
1172
1181
|
blocked.add(id);
|
|
@@ -2630,8 +2639,18 @@ async function runSessionEnqueue(cliKind, opts) {
|
|
|
2630
2639
|
token = null;
|
|
2631
2640
|
}
|
|
2632
2641
|
if (!token) {
|
|
2633
|
-
|
|
2634
|
-
|
|
2642
|
+
let pending;
|
|
2643
|
+
try {
|
|
2644
|
+
pending = readEmitRetry(meshRoot);
|
|
2645
|
+
}
|
|
2646
|
+
catch (err) {
|
|
2647
|
+
// Never replace a retry file that could not be read; add this event to it.
|
|
2648
|
+
console.error(`work-mesh: emit retry file unreadable; appending without rewrite: ${(err instanceof Error ? err.message : String(err)).slice(0, 120)}`);
|
|
2649
|
+
pending = null;
|
|
2650
|
+
}
|
|
2651
|
+
const written = pending
|
|
2652
|
+
? writeEmitRetry(meshRoot, [...pending, event]).written
|
|
2653
|
+
: appendEmitRetry(meshRoot, [event]);
|
|
2635
2654
|
if (opts.json) {
|
|
2636
2655
|
console.log(JSON.stringify({ ok: true, action: "emit", kind, deferred: true, retryDepth: written }, null, 2));
|
|
2637
2656
|
return;
|
|
@@ -3340,6 +3359,7 @@ export async function runDaemonStatus(opts, deps = {}) {
|
|
|
3340
3359
|
platform: deps.platform ?? detectPlatform(),
|
|
3341
3360
|
paths,
|
|
3342
3361
|
isLoaded: daemonServiceIsLoaded(deps.run ?? defaultRunCommand, deps.uid),
|
|
3362
|
+
hqDaemonMesh: (deps.hqDaemonMesh ?? (() => hqDaemonMeshService(paths.home)))(),
|
|
3343
3363
|
});
|
|
3344
3364
|
const state = readDaemonState(paths.daemonDir);
|
|
3345
3365
|
const presenceRefusal = state?.presenceRefusal ?? null;
|
|
@@ -271,9 +271,8 @@ export declare function computeArtifactHash(tarballBytes: Uint8Array): string;
|
|
|
271
271
|
*/
|
|
272
272
|
export declare function verifyArtifact(input: VerifyArtifactInput): void;
|
|
273
273
|
/**
|
|
274
|
-
* Parse + shape-validate one pack's per-server MCP manifest (`mcp/{item}.json`)
|
|
275
|
-
*
|
|
276
|
-
* test (and US-006's registration engine) can call it directly.
|
|
274
|
+
* Parse + shape-validate one pack's per-server MCP manifest (`mcp/{item}.json`).
|
|
275
|
+
* EXPORTED so the acceptance test (and US-006's registration engine) can call it directly.
|
|
277
276
|
*
|
|
278
277
|
* Throws an `Error` (whose message names the pack-relative payload path, e.g.
|
|
279
278
|
* `mcp/foo.json`) when the file does not parse as JSON or violates a transport
|
|
@@ -864,13 +864,12 @@ export function verifyArtifact(input) {
|
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
// ---------------------------------------------------------------------------
|
|
867
|
-
// MCP per-server manifest validation (US-005
|
|
868
|
-
// `validate_mcp_manifest` arm in core/scripts/scan-packages.sh).
|
|
867
|
+
// MCP per-server manifest validation (US-005).
|
|
869
868
|
//
|
|
870
869
|
// The `mcp` contributes key is `wire: 'merge'` — its per-server manifests are
|
|
871
870
|
// NEVER symlinked; they are validated here and (US-006) merged into the agent
|
|
872
|
-
// configs via registerMcpServers. This function
|
|
873
|
-
// rules hand
|
|
871
|
+
// configs via registerMcpServers. This function implements the transport
|
|
872
|
+
// rules by hand against the draft-07 schema
|
|
874
873
|
// (repos/public/knowledge-hq-core/mcp-manifest.schema.json). There is no `ajv`
|
|
875
874
|
// dependency in hq-cli; the schema file is single-source documentation, so the
|
|
876
875
|
// rules are replicated here (dependency-free, robust if the schema is absent).
|
|
@@ -900,9 +899,8 @@ function checkStringMap(errs, label, value) {
|
|
|
900
899
|
}
|
|
901
900
|
}
|
|
902
901
|
/**
|
|
903
|
-
* Parse + shape-validate one pack's per-server MCP manifest (`mcp/{item}.json`)
|
|
904
|
-
*
|
|
905
|
-
* test (and US-006's registration engine) can call it directly.
|
|
902
|
+
* Parse + shape-validate one pack's per-server MCP manifest (`mcp/{item}.json`).
|
|
903
|
+
* EXPORTED so the acceptance test (and US-006's registration engine) can call it directly.
|
|
906
904
|
*
|
|
907
905
|
* Throws an `Error` (whose message names the pack-relative payload path, e.g.
|
|
908
906
|
* `mcp/foo.json`) when the file does not parse as JSON or violates a transport
|
|
@@ -1110,7 +1108,7 @@ export function validateManifest(payloadDir, hqVersion, options = {}) {
|
|
|
1110
1108
|
}
|
|
1111
1109
|
// The `mcp` key (wire: 'merge') is NOT existsSync-only: after the file is
|
|
1112
1110
|
// confirmed present it must PARSE + SHAPE-validate against the per-server
|
|
1113
|
-
// MCP schema (US-005)
|
|
1111
|
+
// MCP schema (US-005) via validateMcpManifest. Other
|
|
1114
1112
|
// (symlink) keys keep their existsSync-only behavior. We dispatch on the
|
|
1115
1113
|
// ROUTE from the single-source table (not a hardcoded key) so the merge
|
|
1116
1114
|
// path is table-driven; the merge itself (registering into the agent
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import { Command } from 'commander';
|
|
23
23
|
import { retrustCodexHooksAfterRescue } from '../utils/hook-trust.js';
|
|
24
24
|
import { repairDanglingReleaseLinks } from '../lib/doctor/checks/release-links.js';
|
|
25
|
+
import { type GitHubLookupDeps } from '../utils/github-tag-fallback.js';
|
|
25
26
|
export interface RescueTarget {
|
|
26
27
|
source: string;
|
|
27
28
|
/** undefined → let the script apply its own default ref (`main`). */
|
|
@@ -62,8 +63,8 @@ export declare function retrustHooksAfterRescue(hqRoot: string, retrust?: typeof
|
|
|
62
63
|
*/
|
|
63
64
|
export declare function repairReleaseLinksAfterRescue(hqRoot: string, repair?: typeof repairDanglingReleaseLinks): void;
|
|
64
65
|
/** Latest release tag for a repo, e.g. `v12.3.0`. Throws on failure. */
|
|
65
|
-
export declare function getLatestReleaseTag(repo: string, token?: string): Promise<string>;
|
|
66
|
+
export declare function getLatestReleaseTag(repo: string, token?: string, deps?: GitHubLookupDeps): Promise<string>;
|
|
66
67
|
/** Resolve a tag to its commit SHA, dereferencing annotated tags. */
|
|
67
|
-
export declare function resolveTagSha(repo: string, tag: string, token?: string): Promise<string>;
|
|
68
|
+
export declare function resolveTagSha(repo: string, tag: string, token?: string, deps?: GitHubLookupDeps): Promise<string>;
|
|
68
69
|
export declare function registerRescueCommand(program: Command): void;
|
|
69
70
|
//# sourceMappingURL=rescue.d.ts.map
|