@indigoai-us/hq-cli 5.309.1 → 5.311.0
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 +18 -0
- package/assets/scaffold/core/scripts/hq-dm-bind.sh +585 -0
- package/assets/scaffold/core/scripts/jobs-validate.sh +1 -1
- package/assets/scaffold/core/scripts/work-mesh-live-bind-trusted.sh +152 -0
- package/dist/command-catalog.generated.d.ts +28 -2
- package/dist/command-catalog.generated.js +34 -2
- package/dist/commands/channels.d.ts +1 -9
- package/dist/commands/channels.js +2 -2
- package/dist/commands/company-transfer.d.ts +4 -28
- package/dist/commands/company-transfer.js +5 -49
- package/dist/commands/core-checkpoint-stop-gate-native.d.ts +34 -0
- package/dist/commands/core-checkpoint-stop-gate-native.js +713 -0
- package/dist/commands/core-checkpoint.d.ts +0 -24
- package/dist/commands/core-checkpoint.js +4 -4
- package/dist/commands/core-command-catalog.js +1 -1
- package/dist/commands/core-dm-bind-native.d.ts +32 -0
- package/dist/commands/core-dm-bind-native.js +668 -0
- package/dist/commands/core-hq-session-native.d.ts +39 -0
- package/dist/commands/core-hq-session-native.js +579 -0
- package/dist/commands/core-jobs-native.js +1 -4
- package/dist/commands/core-native-session-flag.d.ts +4 -0
- package/dist/commands/core-native-session-flag.js +7 -0
- package/dist/commands/core-native-utilities.d.ts +2 -1
- package/dist/commands/core-native-utilities.js +4 -2
- package/dist/commands/core-native-worker-skills-flag.d.ts +4 -0
- package/dist/commands/core-native-worker-skills-flag.js +7 -0
- package/dist/commands/core-work-mesh-bind-trusted-native.d.ts +32 -0
- package/dist/commands/core-work-mesh-bind-trusted-native.js +190 -0
- package/dist/commands/core-worker-lint-native.d.ts +4 -0
- package/dist/commands/core-worker-lint-native.js +160 -0
- package/dist/commands/core-worker-share-native.d.ts +5 -0
- package/dist/commands/core-worker-share-native.js +260 -0
- package/dist/commands/core-worker-skills-command.d.ts +8 -0
- package/dist/commands/core-worker-skills-command.js +33 -0
- package/dist/commands/core-worker-skills-runtime.d.ts +33 -0
- package/dist/commands/core-worker-skills-runtime.js +86 -0
- package/dist/commands/core.js +10 -2
- package/dist/commands/dm.d.ts +3 -7
- package/dist/commands/dm.js +3 -3
- package/dist/commands/integrations-import.d.ts +1 -1
- package/dist/commands/integrations-import.js +34 -19
- package/dist/commands/lanes-accounts.js +3 -1
- package/dist/commands/lanes-message.js +84 -10
- package/dist/commands/lanes-shared.d.ts +4 -1
- package/dist/commands/lanes.d.ts +4 -1
- package/dist/commands/lanes.js +48 -7
- package/dist/commands/personal-connector-settings-flag.d.ts +4 -0
- package/dist/commands/personal-connector-settings-flag.js +7 -0
- package/dist/commands/report.d.ts +1 -26
- package/dist/commands/report.js +6 -6
- package/dist/fast-core.js +15 -2
- package/dist/fast-scaffold.js +25 -2
- package/dist/index.js +8 -0
- package/dist/lib/bot/continuity.d.ts +2 -1
- package/dist/lib/bot/job-completions.d.ts +0 -2
- package/dist/lib/bot/job-completions.js +2 -2
- package/dist/lib/bot/local-config.d.ts +0 -10
- package/dist/lib/bot/local-config.js +3 -9
- package/dist/lib/bot/owner-context.d.ts +2 -6
- package/dist/lib/bot/owner-context.js +3 -3
- package/dist/lib/bot/runtime/windows.d.ts +0 -2
- package/dist/lib/bot/runtime/windows.js +1 -1
- package/dist/lib/bot/setup-explain.d.ts +0 -4
- package/dist/lib/bot/setup-explain.js +2 -2
- package/dist/lib/daemon/catalog.d.ts +3 -2
- package/dist/lib/daemon/hq-cloud.d.ts +2 -2
- package/dist/lib/daemon/hq-cloud.js +1 -1
- package/dist/lib/daemon/machine-type.d.ts +3 -4
- package/dist/lib/daemon/machine-type.js +2 -2
- package/dist/lib/daemon/remote-control.d.ts +0 -1
- package/dist/lib/daemon/remote-control.js +1 -1
- package/dist/lib/daemon/supervisor.d.ts +4 -9
- package/dist/lib/daemon/supervisor.js +5 -5
- package/dist/lib/lanes/admission-host.d.ts +3 -0
- package/dist/lib/lanes/admission-host.js +4 -0
- package/dist/lib/lanes/autopilot-registry.d.ts +62 -0
- package/dist/lib/lanes/autopilot-registry.js +192 -0
- package/dist/lib/lanes/autopilot.d.ts +2 -0
- package/dist/lib/lanes/autopilot.js +18 -5
- package/dist/lib/lanes/claude-balance.d.ts +6 -0
- package/dist/lib/lanes/claude-balance.js +17 -2
- package/dist/lib/lanes/keep-alive.d.ts +3 -0
- package/dist/lib/lanes/keep-alive.js +3 -0
- package/dist/lib/lanes/reconcile.js +14 -6
- package/dist/lib/lanes/spawn.js +2 -0
- package/dist/lib/mesh/live/daemon/credentials.d.ts +2 -17
- package/dist/lib/mesh/live/daemon/credentials.js +9 -9
- package/dist/lib/mesh/live/daemon/index.d.ts +5 -5
- package/dist/lib/mesh/live/daemon/index.js +2 -2
- package/dist/lib/mesh/live/daemon/state.d.ts +1 -1
- package/dist/lib/mesh/live/daemon/transcript-watch.d.ts +4 -11
- package/dist/lib/mesh/live/daemon/transcript-watch.js +5 -5
- package/dist/lib/work-context/company.d.ts +2 -25
- package/dist/lib/work-context/company.js +3 -3
- package/dist/lib/work-context/config.d.ts +3 -8
- package/dist/lib/work-context/config.js +2 -13
- package/dist/lib/work-context/state.d.ts +4 -13
- package/dist/lib/work-context/state.js +2 -30
- package/package.json +1 -1
|
@@ -3,14 +3,7 @@
|
|
|
3
3
|
* Never logs or persists credential material.
|
|
4
4
|
*/
|
|
5
5
|
import type { IotCredentials } from "./presign.js";
|
|
6
|
-
export declare const REALTIME_CREDENTIALS_PATH = "/v1/realtime/credentials";
|
|
7
6
|
export declare const MQTT_KEEPALIVE_SECONDS = 15;
|
|
8
|
-
/** Renew at 80% of credential lifetime. */
|
|
9
|
-
export declare const CREDENTIAL_RENEWAL_FRACTION = 0.8;
|
|
10
|
-
export declare const MIN_RENEWAL_DELAY_MS = 5000;
|
|
11
|
-
/** Long retry when the server refuses credentials (disabled / unsupported). */
|
|
12
|
-
export declare const DEFAULT_REFUSED_RETRY_MS: number;
|
|
13
|
-
export declare const REFUSED_RETRY_ENV = "HQ_MESH_DAEMON_REFUSED_RETRY_MS";
|
|
14
7
|
/**
|
|
15
8
|
* Node's setTimeout treats delays above this as ~1ms (signed 32-bit overflow).
|
|
16
9
|
* Always schedule long waits via {@link scheduleBoundedTimeout}.
|
|
@@ -18,10 +11,6 @@ export declare const REFUSED_RETRY_ENV = "HQ_MESH_DAEMON_REFUSED_RETRY_MS";
|
|
|
18
11
|
export declare const MAX_TIMER_DELAY_MS = 2147483647;
|
|
19
12
|
/** Cap any single retry so a bogus Retry-After cannot park the daemon. */
|
|
20
13
|
export declare const MAX_RETRY_DELAY_MS: number;
|
|
21
|
-
/** Contract-3 vend accepts at most this many preferred company uids. */
|
|
22
|
-
export declare const PREFERRED_COMPANY_LIMIT = 5;
|
|
23
|
-
/** Session files older than this do not count as companies in use. */
|
|
24
|
-
export declare const PREFERRED_SESSION_WINDOW_MS: number;
|
|
25
14
|
/** Preferred-set changes re-vend at most this often. */
|
|
26
15
|
export declare const PREFERRED_REVEND_MIN_MS = 60000;
|
|
27
16
|
export type CredentialVendFailureKind = "refused" | "transient";
|
|
@@ -44,14 +33,13 @@ export declare class CredentialVendError extends Error {
|
|
|
44
33
|
});
|
|
45
34
|
}
|
|
46
35
|
export declare function parseRetryAfterMs(value: string | null | undefined, nowMs?: number): number | undefined;
|
|
47
|
-
export declare function extractVendErrorCode(body: unknown): string | undefined;
|
|
48
36
|
/** True for server "not now" responses that should use the long retry. */
|
|
49
37
|
export declare function isCredentialVendRefused(status: number, code: string | undefined): boolean;
|
|
50
38
|
export declare function classifyCredentialVendFailure(status: number, body: unknown, retryAfterHeader?: string | null, nowMs?: number): CredentialVendError;
|
|
51
39
|
export declare function defaultRefusedRetryMs(env?: NodeJS.ProcessEnv): number;
|
|
52
40
|
/** ±20% jitter around the refused-retry base interval. */
|
|
53
41
|
export declare function refusedRetryDelayMs(baseMs: number, random: () => number): number;
|
|
54
|
-
|
|
42
|
+
interface PresenceCompany {
|
|
55
43
|
companyUid: string;
|
|
56
44
|
presenceTopic: string;
|
|
57
45
|
}
|
|
@@ -124,10 +112,6 @@ export declare function shouldRevendPreferredCompanies(input: {
|
|
|
124
112
|
nowMs: number;
|
|
125
113
|
minIntervalMs?: number;
|
|
126
114
|
}): boolean;
|
|
127
|
-
export declare function contract3VendBody(preferredCompanyUids: readonly string[] | undefined): {
|
|
128
|
-
contractVersion: 3;
|
|
129
|
-
preferredCompanyUids?: string[];
|
|
130
|
-
};
|
|
131
115
|
/** Plain doctor line for one company the vend left out. */
|
|
132
116
|
export declare function formatDroppedPresenceCompany(company: DroppedPresenceCompany): string;
|
|
133
117
|
export type CredentialVendPostResult = {
|
|
@@ -200,4 +184,5 @@ export declare function createPersonalRealtimeFetcher(opts: {
|
|
|
200
184
|
baseUrl?: string;
|
|
201
185
|
post?: (path: string, body: unknown) => Promise<CredentialVendPostResult>;
|
|
202
186
|
}): PersonalCredentialsFetcher;
|
|
187
|
+
export {};
|
|
203
188
|
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -9,14 +9,14 @@ import { vaultApiFetch } from "../../../../utils/vault-api.js";
|
|
|
9
9
|
import { readAgentIdentityCompanyUid } from "../../../work-context/company.js";
|
|
10
10
|
import { readDeviceConfig } from "../../../work-context/config.js";
|
|
11
11
|
import { workContextSessionsDir } from "../../../work-context/paths.js";
|
|
12
|
-
|
|
12
|
+
const REALTIME_CREDENTIALS_PATH = "/v1/realtime/credentials";
|
|
13
13
|
export const MQTT_KEEPALIVE_SECONDS = 15;
|
|
14
14
|
/** Renew at 80% of credential lifetime. */
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const CREDENTIAL_RENEWAL_FRACTION = 0.8;
|
|
16
|
+
const MIN_RENEWAL_DELAY_MS = 5_000;
|
|
17
17
|
/** Long retry when the server refuses credentials (disabled / unsupported). */
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const DEFAULT_REFUSED_RETRY_MS = 10 * 60_000;
|
|
19
|
+
const REFUSED_RETRY_ENV = "HQ_MESH_DAEMON_REFUSED_RETRY_MS";
|
|
20
20
|
/**
|
|
21
21
|
* Node's setTimeout treats delays above this as ~1ms (signed 32-bit overflow).
|
|
22
22
|
* Always schedule long waits via {@link scheduleBoundedTimeout}.
|
|
@@ -25,9 +25,9 @@ export const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
|
25
25
|
/** Cap any single retry so a bogus Retry-After cannot park the daemon. */
|
|
26
26
|
export const MAX_RETRY_DELAY_MS = 24 * 60 * 60 * 1000;
|
|
27
27
|
/** Contract-3 vend accepts at most this many preferred company uids. */
|
|
28
|
-
|
|
28
|
+
const PREFERRED_COMPANY_LIMIT = 5;
|
|
29
29
|
/** Session files older than this do not count as companies in use. */
|
|
30
|
-
|
|
30
|
+
const PREFERRED_SESSION_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
31
31
|
/** Preferred-set changes re-vend at most this often. */
|
|
32
32
|
export const PREFERRED_REVEND_MIN_MS = 60_000;
|
|
33
33
|
/**
|
|
@@ -66,7 +66,7 @@ export function parseRetryAfterMs(value, nowMs = Date.now()) {
|
|
|
66
66
|
}
|
|
67
67
|
return undefined;
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
function extractVendErrorCode(body) {
|
|
70
70
|
if (!body || typeof body !== "object" || Array.isArray(body))
|
|
71
71
|
return undefined;
|
|
72
72
|
const code = body.code;
|
|
@@ -370,7 +370,7 @@ export function shouldRevendPreferredCompanies(input) {
|
|
|
370
370
|
const min = input.minIntervalMs ?? PREFERRED_REVEND_MIN_MS;
|
|
371
371
|
return input.nowMs - input.lastVendMs >= min;
|
|
372
372
|
}
|
|
373
|
-
|
|
373
|
+
function contract3VendBody(preferredCompanyUids) {
|
|
374
374
|
const body = {
|
|
375
375
|
contractVersion: 3,
|
|
376
376
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { DAEMON_DIRNAME, DAEMON_LOG_MAX_BYTES, DAEMON_LOG_NAME, DAEMON_PID_NAME, DAEMON_STATE_NAME, LAUNCHD_LABEL, SYSTEMD_UNIT_NAME, WINDOWS_TASK_NAME, daemonDir, daemonLogPath, daemonPidPath, daemonStatePath, sessionBoardPath, } from "./paths.js";
|
|
2
2
|
export { acquirePidLock, defaultPidLockDeps, parsePidLock, pidLockStatus, readPidLock, releasePidLock, resolveDaemonDir, } from "./pid-lock.js";
|
|
3
3
|
export type { PidLockDeps, PidLockRecord, PidLockResult } from "./pid-lock.js";
|
|
4
|
-
export {
|
|
5
|
-
export type { BoundedTimeoutHandle, Contract3Bundle, CredentialRenewalErrorInfo, CredentialVendFailureKind, CredentialVendPostResult, CredentialsFetcher,
|
|
4
|
+
export { MAX_RETRY_DELAY_MS, MAX_TIMER_DELAY_MS, MQTT_KEEPALIVE_SECONDS, CredentialRenewalManager, CredentialVendError, classifyCredentialVendFailure, clampRetryDelayMs, createContract3Fetcher, defaultRefusedRetryMs, isCredentialVendRefused, normalizeContract3Bundle, parseRetryAfterMs, realTimerHost, refusedRetryDelayMs, renewalDelayMs, scheduleBoundedTimeout, } from "./credentials.js";
|
|
5
|
+
export type { BoundedTimeoutHandle, Contract3Bundle, CredentialRenewalErrorInfo, CredentialVendFailureKind, CredentialVendPostResult, CredentialsFetcher, TimerHost, } from "./credentials.js";
|
|
6
6
|
export { amzDateOf, hex, presignIotWssUrl, rfc3986Encode } from "./presign.js";
|
|
7
7
|
export type { IotCredentials } from "./presign.js";
|
|
8
8
|
export { CLOSE_LOG_ALWAYS_COUNT, CLOSE_LOG_INTERVAL_MS, CONNECT_STABLE_GRACE_MS, PresenceClient, backoffDelayMs, buildPresencePayload, defaultMqttConnect, isOwnPresenceTopic, } from "./presence.js";
|
|
9
9
|
export type { MeshMqttClientLike, MqttConnectFn, MqttConnectionState, PresenceClientOptions, PresencePayload, PresenceRefusal, } from "./presence.js";
|
|
10
10
|
export { defaultDaemonState, patchDaemonState, readDaemonState, writeDaemonState, } from "./state.js";
|
|
11
|
-
export type { DaemonStateFile
|
|
11
|
+
export type { DaemonStateFile } from "./state.js";
|
|
12
12
|
export { appendDaemonLog, daemonLogLine, ensureDaemonLog, resolveDaemonAssetDir, rotateDaemonLogIfNeeded, } from "./log.js";
|
|
13
13
|
export { BOARD_REFRESH_INTERVAL_MS, createVaultBoardReader, formatBoardMarkdown, refreshBoundSessionBoards, writeBoardMarkdown, } from "./board-refresh.js";
|
|
14
14
|
export type { BoardReader, BoardRefreshDeps, BoardStorySnapshot } from "./board-refresh.js";
|
|
@@ -22,6 +22,6 @@ export type { DaemonDoctorDeps, DaemonDoctorReport } from "./doctor.js";
|
|
|
22
22
|
export { scopeBundleToAgentIdentity, } from "./credentials.js";
|
|
23
23
|
export { FLUSH_INTERVAL_MS, DAEMON_VERSION_DRIFT_EXIT_CODE, SPOOL_DEBOUNCE_MS, runMeshDaemon, } from "./run.js";
|
|
24
24
|
export type { DaemonHandle, DaemonRunDeps } from "./run.js";
|
|
25
|
-
export {
|
|
26
|
-
export type { DiscoveredTranscript,
|
|
25
|
+
export { TRANSCRIPT_EVENT_SOURCE, TRANSCRIPT_HOOK_COVER_MS, TRANSCRIPT_MARKER, TRANSCRIPT_SESSION_END_MS, TRANSCRIPT_HOOK_QUIET_ADOPT_MS, TRANSCRIPT_TURN_QUIET_MS, TRANSCRIPT_WATCH_BACKOFF_DURATION_MS, TRANSCRIPT_WATCH_BACKOFF_ENTRIES, TRANSCRIPT_WATCH_INTERVAL_MAX_MS, TRANSCRIPT_WATCH_INTERVAL_MS, TRANSCRIPT_WATCH_REVALIDATE_MS, TranscriptWatcher, createTranscriptDiscoverCache, decodeClaudeProjectDirName, defaultTranscriptFs, discoverTranscripts, discoverTranscriptsWithMeta, isTranscriptHookCovered, nextTranscriptWatchIntervalMs, noteHookSessionsFromSpoolFile, resolveTranscriptRegistration, sessionIdFromClaudeTranscriptPath, sessionIdFromCodexTranscriptPath, sortDiscoveries, } from "./transcript-watch.js";
|
|
26
|
+
export type { DiscoveredTranscript, DiscoverTranscriptsResult, TranscriptDiscoverCache, TranscriptFs, TranscriptWatchDeps, TranscriptWatchTickResult, } from "./transcript-watch.js";
|
|
27
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DAEMON_DIRNAME, DAEMON_LOG_MAX_BYTES, DAEMON_LOG_NAME, DAEMON_PID_NAME, DAEMON_STATE_NAME, LAUNCHD_LABEL, SYSTEMD_UNIT_NAME, WINDOWS_TASK_NAME, daemonDir, daemonLogPath, daemonPidPath, daemonStatePath, sessionBoardPath, } from "./paths.js";
|
|
2
2
|
export { acquirePidLock, defaultPidLockDeps, parsePidLock, pidLockStatus, readPidLock, releasePidLock, resolveDaemonDir, } from "./pid-lock.js";
|
|
3
|
-
export {
|
|
3
|
+
export { MAX_RETRY_DELAY_MS, MAX_TIMER_DELAY_MS, MQTT_KEEPALIVE_SECONDS, CredentialRenewalManager, CredentialVendError, classifyCredentialVendFailure, clampRetryDelayMs, createContract3Fetcher, defaultRefusedRetryMs, isCredentialVendRefused, normalizeContract3Bundle, parseRetryAfterMs, realTimerHost, refusedRetryDelayMs, renewalDelayMs, scheduleBoundedTimeout, } from "./credentials.js";
|
|
4
4
|
export { amzDateOf, hex, presignIotWssUrl, rfc3986Encode } from "./presign.js";
|
|
5
5
|
export { CLOSE_LOG_ALWAYS_COUNT, CLOSE_LOG_INTERVAL_MS, CONNECT_STABLE_GRACE_MS, PresenceClient, backoffDelayMs, buildPresencePayload, defaultMqttConnect, isOwnPresenceTopic, } from "./presence.js";
|
|
6
6
|
export { defaultDaemonState, patchDaemonState, readDaemonState, writeDaemonState, } from "./state.js";
|
|
@@ -11,5 +11,5 @@ export { daemonConfigPath, findAncestorHqRoot, isInstallableHqRoot, readDaemonCo
|
|
|
11
11
|
export { UNHEALTHY_SPOOL_AGE_MS, collectDaemonDoctor, formatCliIdentityLines, formatCliMismatchLine, formatDaemonDoctor, listHqBinariesOnPath, } from "./doctor.js";
|
|
12
12
|
export { scopeBundleToAgentIdentity, } from "./credentials.js";
|
|
13
13
|
export { FLUSH_INTERVAL_MS, DAEMON_VERSION_DRIFT_EXIT_CODE, SPOOL_DEBOUNCE_MS, runMeshDaemon, } from "./run.js";
|
|
14
|
-
export {
|
|
14
|
+
export { TRANSCRIPT_EVENT_SOURCE, TRANSCRIPT_HOOK_COVER_MS, TRANSCRIPT_MARKER, TRANSCRIPT_SESSION_END_MS, TRANSCRIPT_HOOK_QUIET_ADOPT_MS, TRANSCRIPT_TURN_QUIET_MS, TRANSCRIPT_WATCH_BACKOFF_DURATION_MS, TRANSCRIPT_WATCH_BACKOFF_ENTRIES, TRANSCRIPT_WATCH_INTERVAL_MAX_MS, TRANSCRIPT_WATCH_INTERVAL_MS, TRANSCRIPT_WATCH_REVALIDATE_MS, TranscriptWatcher, createTranscriptDiscoverCache, decodeClaudeProjectDirName, defaultTranscriptFs, discoverTranscripts, discoverTranscriptsWithMeta, isTranscriptHookCovered, nextTranscriptWatchIntervalMs, noteHookSessionsFromSpoolFile, resolveTranscriptRegistration, sessionIdFromClaudeTranscriptPath, sessionIdFromCodexTranscriptPath, sortDiscoveries, } from "./transcript-watch.js";
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -5,7 +5,7 @@ import * as fs from "node:fs";
|
|
|
5
5
|
import type { MqttConnectionState } from "./presence.js";
|
|
6
6
|
import type { FlushSummary } from "../flush.js";
|
|
7
7
|
import type { DroppedPresenceCompany } from "./credentials.js";
|
|
8
|
-
|
|
8
|
+
interface PresenceRefusalState {
|
|
9
9
|
code: string;
|
|
10
10
|
status: number;
|
|
11
11
|
nextRetryAt: string;
|
|
@@ -51,8 +51,6 @@ export declare const TRANSCRIPT_WATCH_INTERVAL_MAX_MS = 120000;
|
|
|
51
51
|
export declare const TRANSCRIPT_WATCH_BACKOFF_ENTRIES = 2000;
|
|
52
52
|
/** Double the interval when a tick takes longer than this many ms. */
|
|
53
53
|
export declare const TRANSCRIPT_WATCH_BACKOFF_DURATION_MS = 500;
|
|
54
|
-
/** Hard cap on entries examined (dir stats, readdir children, file stats) per tick. */
|
|
55
|
-
export declare const TRANSCRIPT_WATCH_ENTRY_CAP = 20000;
|
|
56
54
|
/**
|
|
57
55
|
* Even when a directory mtime matches the cache, force a full relist (readdir +
|
|
58
56
|
* re-stat) after this many ms so content appends and coarse mtime granularity
|
|
@@ -62,11 +60,6 @@ export declare const TRANSCRIPT_WATCH_REVALIDATE_MS: number;
|
|
|
62
60
|
export declare const TRANSCRIPT_TURN_QUIET_MS = 5000;
|
|
63
61
|
export declare const TRANSCRIPT_SESSION_END_MS: number;
|
|
64
62
|
export declare const TRANSCRIPT_HOOK_COVER_MS = 60000;
|
|
65
|
-
/** Retry unavailable transcript-start reconciliation without hot-looping. */
|
|
66
|
-
export declare const TRANSCRIPT_START_RETRY_BASE_MS = 30000;
|
|
67
|
-
export declare const TRANSCRIPT_START_RETRY_MAX_MS = 120000;
|
|
68
|
-
/** Ignore cold transcripts whose mtime is older than this on first sight. */
|
|
69
|
-
export declare const TRANSCRIPT_FRESH_MS: number;
|
|
70
63
|
/**
|
|
71
64
|
* Hook-covered sessions skipped as "stale" on first sight never got a quiet
|
|
72
65
|
* session_end (live: skippedHook=411, ended=0). Adopt them for this long after
|
|
@@ -75,7 +68,6 @@ export declare const TRANSCRIPT_FRESH_MS: number;
|
|
|
75
68
|
*/
|
|
76
69
|
export declare const TRANSCRIPT_HOOK_QUIET_ADOPT_MS: number;
|
|
77
70
|
export declare const TRANSCRIPT_MARKER: "from transcript";
|
|
78
|
-
export declare const TRANSCRIPT_ADAPTER_VERSION: string;
|
|
79
71
|
/** Network `source` stamped on every synthesized event (AMEND-001). */
|
|
80
72
|
export declare const TRANSCRIPT_EVENT_SOURCE: "transcript";
|
|
81
73
|
/** Fs surface used by the watcher — intentionally no open/readFile. */
|
|
@@ -91,7 +83,7 @@ export interface TranscriptFs {
|
|
|
91
83
|
existsSync: (p: string) => boolean;
|
|
92
84
|
}
|
|
93
85
|
export declare const defaultTranscriptFs: TranscriptFs;
|
|
94
|
-
|
|
86
|
+
type TranscriptKind = "claude" | "codex";
|
|
95
87
|
export interface DiscoveredTranscript {
|
|
96
88
|
path: string;
|
|
97
89
|
sessionId: string;
|
|
@@ -166,7 +158,7 @@ export interface TranscriptWatchTickResult {
|
|
|
166
158
|
skippedConcurrent: boolean;
|
|
167
159
|
}
|
|
168
160
|
/** Per-directory mtime + child cache for incremental discovery. */
|
|
169
|
-
|
|
161
|
+
interface TranscriptDirCacheEntry {
|
|
170
162
|
mtimeMs: number;
|
|
171
163
|
files: DiscoveredTranscript[];
|
|
172
164
|
subdirs: string[];
|
|
@@ -176,7 +168,7 @@ export interface TranscriptDirCacheEntry {
|
|
|
176
168
|
export interface TranscriptDiscoverCache {
|
|
177
169
|
dirs: Map<string, TranscriptDirCacheEntry>;
|
|
178
170
|
}
|
|
179
|
-
|
|
171
|
+
interface DiscoverScanMeta {
|
|
180
172
|
entriesExamined: number;
|
|
181
173
|
dirsListed: number;
|
|
182
174
|
dirsSkipped: number;
|
|
@@ -318,4 +310,5 @@ export declare function nextTranscriptWatchIntervalMs(currentMs: number, opts: {
|
|
|
318
310
|
entriesExamined: number;
|
|
319
311
|
durationMs: number;
|
|
320
312
|
}): number;
|
|
313
|
+
export {};
|
|
321
314
|
//# sourceMappingURL=transcript-watch.d.ts.map
|
|
@@ -58,7 +58,7 @@ export const TRANSCRIPT_WATCH_BACKOFF_ENTRIES = 2_000;
|
|
|
58
58
|
/** Double the interval when a tick takes longer than this many ms. */
|
|
59
59
|
export const TRANSCRIPT_WATCH_BACKOFF_DURATION_MS = 500;
|
|
60
60
|
/** Hard cap on entries examined (dir stats, readdir children, file stats) per tick. */
|
|
61
|
-
|
|
61
|
+
const TRANSCRIPT_WATCH_ENTRY_CAP = 20_000;
|
|
62
62
|
/**
|
|
63
63
|
* Even when a directory mtime matches the cache, force a full relist (readdir +
|
|
64
64
|
* re-stat) after this many ms so content appends and coarse mtime granularity
|
|
@@ -69,10 +69,10 @@ export const TRANSCRIPT_TURN_QUIET_MS = 5_000;
|
|
|
69
69
|
export const TRANSCRIPT_SESSION_END_MS = 10 * 60_000;
|
|
70
70
|
export const TRANSCRIPT_HOOK_COVER_MS = 60_000;
|
|
71
71
|
/** Retry unavailable transcript-start reconciliation without hot-looping. */
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const TRANSCRIPT_START_RETRY_BASE_MS = 30_000;
|
|
73
|
+
const TRANSCRIPT_START_RETRY_MAX_MS = 120_000;
|
|
74
74
|
/** Ignore cold transcripts whose mtime is older than this on first sight. */
|
|
75
|
-
|
|
75
|
+
const TRANSCRIPT_FRESH_MS = TRANSCRIPT_SESSION_END_MS;
|
|
76
76
|
/**
|
|
77
77
|
* Hook-covered sessions skipped as "stale" on first sight never got a quiet
|
|
78
78
|
* session_end (live: skippedHook=411, ended=0). Adopt them for this long after
|
|
@@ -81,7 +81,7 @@ export const TRANSCRIPT_FRESH_MS = TRANSCRIPT_SESSION_END_MS;
|
|
|
81
81
|
*/
|
|
82
82
|
export const TRANSCRIPT_HOOK_QUIET_ADOPT_MS = 2 * 60 * 60 * 1000;
|
|
83
83
|
export const TRANSCRIPT_MARKER = "from transcript";
|
|
84
|
-
|
|
84
|
+
const TRANSCRIPT_ADAPTER_VERSION = CLI_VERSION;
|
|
85
85
|
/** Network `source` stamped on every synthesized event (AMEND-001). */
|
|
86
86
|
export const TRANSCRIPT_EVENT_SOURCE = "transcript";
|
|
87
87
|
export const defaultTranscriptFs = {
|
|
@@ -20,14 +20,12 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import type { TrustedExplicitContext } from "./contract.js";
|
|
22
22
|
import { type SessionStateFile } from "./state.js";
|
|
23
|
-
|
|
23
|
+
type CompanyResolutionSource = "trusted_explicit" | "existing_scope" | "session_meta" | "repo_map" | "device_default" | "deterministic_cwd" | "deterministic_remote";
|
|
24
24
|
export interface ResolvedCompany {
|
|
25
25
|
slug?: string;
|
|
26
26
|
uid?: string;
|
|
27
27
|
source: CompanyResolutionSource;
|
|
28
28
|
}
|
|
29
|
-
/** Pointer to the US-017B correction client (never auto-switches). */
|
|
30
|
-
export declare const COMPANY_CORRECTION_PATH_PREFIX = "hq mesh context correct --session";
|
|
31
29
|
export declare function companyCorrectionPath(sessionId: string): string;
|
|
32
30
|
export type CompanyResolution = {
|
|
33
31
|
status: "resolved";
|
|
@@ -72,18 +70,6 @@ export interface CompanyResolveInput {
|
|
|
72
70
|
/** Env naming the on-box identity.json (fleet agent boxes). */
|
|
73
71
|
export declare const HQ_AGENT_IDENTITY_FILE_ENV = "HQ_AGENT_IDENTITY_FILE";
|
|
74
72
|
export declare const DEFAULT_AGENT_IDENTITY_FILE = "/var/lib/hq-agent/identity.json";
|
|
75
|
-
/**
|
|
76
|
-
* Read `companyUid` from the agent identity file when
|
|
77
|
-
* `HQ_AGENT_IDENTITY_FILE` is set, or the conventional fleet path otherwise.
|
|
78
|
-
* Missing/unreadable/malformed → undefined
|
|
79
|
-
* (never throws; never logs file contents).
|
|
80
|
-
*/
|
|
81
|
-
export interface AgentIdentityCompany {
|
|
82
|
-
uid?: string;
|
|
83
|
-
slug?: string;
|
|
84
|
-
}
|
|
85
|
-
/** Company uid and slug from the fleet identity file. Missing file → undefined. */
|
|
86
|
-
export declare function readAgentIdentityCompany(env?: NodeJS.ProcessEnv): AgentIdentityCompany | undefined;
|
|
87
73
|
export declare function readAgentIdentityCompanyUid(env?: NodeJS.ProcessEnv): string | undefined;
|
|
88
74
|
/**
|
|
89
75
|
* Company named for a machine session.
|
|
@@ -126,15 +112,6 @@ export declare function projectIdFromCwd(cwd: string | undefined, hqRoot?: strin
|
|
|
126
112
|
* Read company_slug from workspace/sessions/<sid>/meta.yaml (best-effort, no yaml dep).
|
|
127
113
|
*/
|
|
128
114
|
export declare function readMetaCompanySlug(sessionId: string, hqRoot: string | undefined): string | undefined;
|
|
129
|
-
/**
|
|
130
|
-
* Deterministic mapping: exactly one of cwd companies/{slug} or remote owner.
|
|
131
|
-
* Multiple distinct signals that disagree → no deterministic mapping (needs_company
|
|
132
|
-
* unless a higher-precedence source exists). Matching signals collapse to one.
|
|
133
|
-
*/
|
|
134
|
-
export declare function resolveDeterministicCompany(input: {
|
|
135
|
-
cwd?: string;
|
|
136
|
-
hqRoot?: string;
|
|
137
|
-
remoteOwnerSlug?: string | null;
|
|
138
|
-
}): ResolvedCompany | null;
|
|
139
115
|
export declare function resolveCompany(input: CompanyResolveInput): CompanyResolution;
|
|
116
|
+
export {};
|
|
140
117
|
//# sourceMappingURL=company.d.ts.map
|
|
@@ -23,7 +23,7 @@ import * as path from "node:path";
|
|
|
23
23
|
import { getDefaultCompany, getRepoCompany } from "./config.js";
|
|
24
24
|
import { authoritativeCompanyFromState, readSessionState, } from "./state.js";
|
|
25
25
|
/** Pointer to the US-017B correction client (never auto-switches). */
|
|
26
|
-
|
|
26
|
+
const COMPANY_CORRECTION_PATH_PREFIX = "hq mesh context correct --session";
|
|
27
27
|
export function companyCorrectionPath(sessionId) {
|
|
28
28
|
return `${COMPANY_CORRECTION_PATH_PREFIX} ${sessionId}`;
|
|
29
29
|
}
|
|
@@ -58,7 +58,7 @@ function readAgentIdentityRecord(env) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
/** Company uid and slug from the fleet identity file. Missing file → undefined. */
|
|
61
|
-
|
|
61
|
+
function readAgentIdentityCompany(env = process.env) {
|
|
62
62
|
const raw = readAgentIdentityRecord(env);
|
|
63
63
|
if (!raw)
|
|
64
64
|
return undefined;
|
|
@@ -209,7 +209,7 @@ export function readMetaCompanySlug(sessionId, hqRoot) {
|
|
|
209
209
|
* Multiple distinct signals that disagree → no deterministic mapping (needs_company
|
|
210
210
|
* unless a higher-precedence source exists). Matching signals collapse to one.
|
|
211
211
|
*/
|
|
212
|
-
|
|
212
|
+
function resolveDeterministicCompany(input) {
|
|
213
213
|
const fromCwd = companySlugFromCwd(input.cwd, input.hqRoot);
|
|
214
214
|
const fromRemote = normalizeSlug(input.remoteOwnerSlug ?? undefined);
|
|
215
215
|
if (fromCwd && fromRemote && fromCwd.toLowerCase() !== fromRemote.toLowerCase()) {
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import { type WindowsAclCheckOptions } from "./windows-acl.js";
|
|
7
|
-
|
|
8
|
-
export declare const DEVICE_CONFIG_SCHEMA_VERSION: 1;
|
|
7
|
+
declare const DEVICE_CONFIG_SCHEMA_VERSION: 1;
|
|
9
8
|
export interface DeviceDefaultCompany {
|
|
10
9
|
slug: string;
|
|
11
10
|
uid?: string;
|
|
@@ -44,7 +43,7 @@ export interface RepoCompanyMapping {
|
|
|
44
43
|
uid?: string;
|
|
45
44
|
updatedAt: string;
|
|
46
45
|
}
|
|
47
|
-
|
|
46
|
+
type RepoCompanyMap = Record<string, RepoCompanyMapping>;
|
|
48
47
|
export interface WorkContextDeviceConfig {
|
|
49
48
|
schemaVersion: typeof DEVICE_CONFIG_SCHEMA_VERSION;
|
|
50
49
|
/** Explicit device default. Never copied from activeCompany. */
|
|
@@ -77,7 +76,6 @@ export interface DeviceConfigDeps {
|
|
|
77
76
|
validateMembership?: (slug: string) => Promise<MembershipValidationResult> | MembershipValidationResult;
|
|
78
77
|
now?: () => Date;
|
|
79
78
|
}
|
|
80
|
-
export declare const CONFIG_LOCK_STALE_MS = 30000;
|
|
81
79
|
/** Acquire an interprocess config lock; exported for direct lock regression tests. */
|
|
82
80
|
export declare function acquireDeviceConfigLock(root: string, options?: {
|
|
83
81
|
timeoutMs?: number;
|
|
@@ -132,8 +130,5 @@ export declare function setAutoDefaultCompany(membership: DefaultCompanyMembersh
|
|
|
132
130
|
afterCompareAndSwap?: () => void;
|
|
133
131
|
}): WorkContextDeviceConfig;
|
|
134
132
|
export declare function setRepairHeldWithDefault(enabled: boolean, deps: Pick<DeviceConfigDeps, "root" | "now">): WorkContextDeviceConfig;
|
|
135
|
-
|
|
136
|
-
export declare function deviceConfigDepsFromHome(home?: string, extras?: Partial<DeviceConfigDeps>): DeviceConfigDeps;
|
|
137
|
-
/** Re-export for callers that stamp contractVersion on related state. */
|
|
138
|
-
export { WORK_CONTEXT_CONTRACT_VERSION };
|
|
133
|
+
export {};
|
|
139
134
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -6,13 +6,11 @@ import * as fs from "node:fs";
|
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import { atomicWriteJson, ensureOwnerDir, resolveRealTarget } from "./atomic.js";
|
|
8
8
|
import { DefaultCompanyUnavailableError, UnsafeConfigPathError, WorkContextError, } from "./errors.js";
|
|
9
|
-
import { workContextConfigPath
|
|
9
|
+
import { workContextConfigPath } from "./paths.js";
|
|
10
10
|
import { assertWindowsOwnerOnlyAcl } from "./windows-acl.js";
|
|
11
|
-
|
|
12
|
-
export const DEVICE_CONFIG_SCHEMA_VERSION = 1;
|
|
11
|
+
const DEVICE_CONFIG_SCHEMA_VERSION = 1;
|
|
13
12
|
const CONFIG_LOCK_TIMEOUT_MS = 5_000;
|
|
14
13
|
const CONFIG_LOCK_RETRY_MS = 10;
|
|
15
|
-
export const CONFIG_LOCK_STALE_MS = 30_000;
|
|
16
14
|
function waitForConfigLock(ms) {
|
|
17
15
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
18
16
|
}
|
|
@@ -497,13 +495,4 @@ export function setRepairHeldWithDefault(enabled, deps) {
|
|
|
497
495
|
return next;
|
|
498
496
|
});
|
|
499
497
|
}
|
|
500
|
-
/** Convenience: build deps from HOME / injectable root. */
|
|
501
|
-
export function deviceConfigDepsFromHome(home, extras = {}) {
|
|
502
|
-
return {
|
|
503
|
-
root: extras.root ?? workContextRoot(home),
|
|
504
|
-
...extras,
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
/** Re-export for callers that stamp contractVersion on related state. */
|
|
508
|
-
export { WORK_CONTEXT_CONTRACT_VERSION };
|
|
509
498
|
//# sourceMappingURL=config.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ClassificationState } from "./contract.js";
|
|
6
6
|
import { WORK_CONTEXT_CONTRACT_VERSION } from "./contract.js";
|
|
7
|
-
|
|
7
|
+
type DecisionOptionKind = "bind_existing" | "create_project" | "create_task" | "untracked" | "keep_default" | "override_evidence";
|
|
8
8
|
export interface SessionDecisionOption {
|
|
9
9
|
optionId: string;
|
|
10
10
|
label?: string;
|
|
@@ -27,9 +27,9 @@ export interface SessionDecision {
|
|
|
27
27
|
/** Local-only origin of the session state writer (never sent on the wire). */
|
|
28
28
|
export type SessionEventSource = "hook" | "transcript";
|
|
29
29
|
/** Local-only harness label when network schema cannot carry it (US-018). */
|
|
30
|
-
|
|
30
|
+
type LocalHarnessLabel = "claude-desktop" | "codex";
|
|
31
31
|
/** Local tracking for an in-flight or completed cross-company migrate (US-017B). */
|
|
32
|
-
|
|
32
|
+
interface SessionMigrationRecord {
|
|
33
33
|
operationId: string;
|
|
34
34
|
digest: string;
|
|
35
35
|
sourceCompanyUid: string;
|
|
@@ -133,14 +133,6 @@ export interface AcknowledgedRegisterBinding {
|
|
|
133
133
|
taskId?: string;
|
|
134
134
|
receiptId: string;
|
|
135
135
|
}
|
|
136
|
-
/** Allowlisted keys that may appear in the durable state projection. */
|
|
137
|
-
export declare const SESSION_STATE_ALLOWLIST: Set<string>;
|
|
138
|
-
/**
|
|
139
|
-
* Serialize a session-state read/modify/write with every state writer. Atomic
|
|
140
|
-
* rename protects readers from torn files, but only this shared lock protects
|
|
141
|
-
* a writer that has to verify the current binding before changing it.
|
|
142
|
-
*/
|
|
143
|
-
export declare function withSessionStateLock<T>(sessionId: string, root: string, fn: () => T): T;
|
|
144
136
|
export declare function readSessionState(sessionId: string, root: string): SessionStateFile | null;
|
|
145
137
|
export declare function writeSessionState(state: SessionStateFile, root: string): string;
|
|
146
138
|
/**
|
|
@@ -148,8 +140,6 @@ export declare function writeSessionState(state: SessionStateFile, root: string)
|
|
|
148
140
|
* lock used by ordinary session writers. Returning null declines the write.
|
|
149
141
|
*/
|
|
150
142
|
export declare function updateSessionState(sessionId: string, root: string, update: (current: SessionStateFile | null) => SessionStateFile | null): SessionStateFile | null;
|
|
151
|
-
/** Strip any non-allowlisted fields before durable write. */
|
|
152
|
-
export declare function projectSessionState(state: SessionStateFile): SessionStateFile;
|
|
153
143
|
/**
|
|
154
144
|
* Merge prior local fields into a new state write so PostToolUse bumps and
|
|
155
145
|
* reconcile updates do not clobber an acknowledged company binding.
|
|
@@ -201,4 +191,5 @@ export declare function authoritativeCompanyFromState(state: SessionStateFile |
|
|
|
201
191
|
* Carrying it forward makes the server drop every later session-event batch.
|
|
202
192
|
*/
|
|
203
193
|
export declare function applyOperatorProjectBinding(state: SessionStateFile, projectId: string, now?: () => Date): SessionStateFile;
|
|
194
|
+
export {};
|
|
204
195
|
//# sourceMappingURL=state.d.ts.map
|
|
@@ -8,34 +8,6 @@ import { WORK_CONTEXT_CONTRACT_VERSION } from "./contract.js";
|
|
|
8
8
|
import { atomicWriteJson, ensureOwnerDir, resolveRealTarget } from "./atomic.js";
|
|
9
9
|
import { NotTrackingError, UnsafeConfigPathError } from "./errors.js";
|
|
10
10
|
import { isSafeWorkContextSegment, workContextSessionPath, workContextSessionsDir, } from "./paths.js";
|
|
11
|
-
/** Allowlisted keys that may appear in the durable state projection. */
|
|
12
|
-
export const SESSION_STATE_ALLOWLIST = new Set([
|
|
13
|
-
"contractVersion",
|
|
14
|
-
"sessionId",
|
|
15
|
-
"companyUid",
|
|
16
|
-
"companySlug",
|
|
17
|
-
"contextStatus",
|
|
18
|
-
"projectId",
|
|
19
|
-
"taskId",
|
|
20
|
-
"bindingEpisodeId",
|
|
21
|
-
"version",
|
|
22
|
-
"decision",
|
|
23
|
-
"migration",
|
|
24
|
-
"untrackedReceipt",
|
|
25
|
-
"toolWrites",
|
|
26
|
-
"startedAt",
|
|
27
|
-
"hasTurn",
|
|
28
|
-
"source",
|
|
29
|
-
"localHarness",
|
|
30
|
-
"transcriptMarker",
|
|
31
|
-
"companyConfidence",
|
|
32
|
-
"projectBindReason",
|
|
33
|
-
"projectCandidates",
|
|
34
|
-
"projectGate",
|
|
35
|
-
"projectHint",
|
|
36
|
-
"presenceLeave",
|
|
37
|
-
"updatedAt",
|
|
38
|
-
]);
|
|
39
11
|
const SESSION_STATE_LOCK_TIMEOUT_MS = 5_000;
|
|
40
12
|
const SESSION_STATE_LOCK_RETRY_MS = 10;
|
|
41
13
|
function waitForSessionStateLock(ms) {
|
|
@@ -72,7 +44,7 @@ function reclaimStaleSessionStateLock(lockPath) {
|
|
|
72
44
|
* rename protects readers from torn files, but only this shared lock protects
|
|
73
45
|
* a writer that has to verify the current binding before changing it.
|
|
74
46
|
*/
|
|
75
|
-
|
|
47
|
+
function withSessionStateLock(sessionId, root, fn) {
|
|
76
48
|
if (!isSafeWorkContextSegment(sessionId)) {
|
|
77
49
|
throw new NotTrackingError(`Unsafe session id for state file: ${sessionId}`, "NOT_TRACKING");
|
|
78
50
|
}
|
|
@@ -192,7 +164,7 @@ export function updateSessionState(sessionId, root, update) {
|
|
|
192
164
|
});
|
|
193
165
|
}
|
|
194
166
|
/** Strip any non-allowlisted fields before durable write. */
|
|
195
|
-
|
|
167
|
+
function projectSessionState(state) {
|
|
196
168
|
const out = {
|
|
197
169
|
contractVersion: WORK_CONTEXT_CONTRACT_VERSION,
|
|
198
170
|
sessionId: state.sessionId,
|