@indigoai-us/hq-cli 5.305.0 → 5.307.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/assets/scaffold/core/scripts/audit-log.sh +384 -0
  3. package/assets/scaffold/core/scripts/git-pack-extension-check.sh +164 -0
  4. package/assets/scaffold/core/scripts/hq-pin.sh +118 -0
  5. package/assets/scaffold/core/scripts/lib/portable.sh +211 -0
  6. package/assets/scaffold/core/scripts/refresh-vault-access.sh +188 -0
  7. package/dist/command-catalog.generated.d.ts +54 -2
  8. package/dist/command-catalog.generated.js +66 -2
  9. package/dist/commands/core-audit-log-native.d.ts +9 -0
  10. package/dist/commands/core-audit-log-native.js +257 -0
  11. package/dist/commands/core-git-pack-extension-check-native.d.ts +22 -0
  12. package/dist/commands/core-git-pack-extension-check-native.js +190 -0
  13. package/dist/commands/core-native-utilities-flag.d.ts +4 -0
  14. package/dist/commands/core-native-utilities-flag.js +7 -0
  15. package/dist/commands/core-native-utilities.d.ts +28 -0
  16. package/dist/commands/core-native-utilities.js +52 -0
  17. package/dist/commands/core-pin-native.d.ts +14 -0
  18. package/dist/commands/core-pin-native.js +236 -0
  19. package/dist/commands/core-refresh-vault-access-native.d.ts +20 -0
  20. package/dist/commands/core-refresh-vault-access-native.js +229 -0
  21. package/dist/commands/core.js +15 -0
  22. package/dist/commands/daemon.js +24 -23
  23. package/dist/commands/dm.js +6 -1
  24. package/dist/commands/lanes.js +43 -1
  25. package/dist/lib/agent-kit/fallback.d.ts +0 -7
  26. package/dist/lib/agent-kit/fallback.js +4 -4
  27. package/dist/lib/agent-kit/inbox-state.d.ts +0 -2
  28. package/dist/lib/agent-kit/inbox-state.js +2 -2
  29. package/dist/lib/agent-kit/kit-config.d.ts +0 -5
  30. package/dist/lib/agent-kit/kit-config.js +5 -5
  31. package/dist/lib/agent-kit/log.d.ts +0 -1
  32. package/dist/lib/agent-kit/log.js +1 -1
  33. package/dist/lib/agent-kit/mcp/jsonrpc.d.ts +3 -12
  34. package/dist/lib/agent-kit/mcp/jsonrpc.js +4 -4
  35. package/dist/lib/agent-kit/mcp/tools.d.ts +0 -2
  36. package/dist/lib/agent-kit/mcp/tools.js +2 -2
  37. package/dist/lib/agent-kit/services.d.ts +0 -1
  38. package/dist/lib/agent-kit/services.js +1 -1
  39. package/dist/lib/checkpoint-ontology/apply.d.ts +0 -49
  40. package/dist/lib/checkpoint-ontology/apply.js +5 -5
  41. package/dist/lib/checkpoint-ontology/identity.d.ts +2 -1
  42. package/dist/lib/checkpoint-ontology/identity.js +1 -1
  43. package/dist/lib/checkpoint-ontology/multi-writer.d.ts +4 -9
  44. package/dist/lib/checkpoint-ontology/multi-writer.js +6 -6
  45. package/dist/lib/checkpoint-ontology/plan.d.ts +4 -17
  46. package/dist/lib/checkpoint-ontology/plan.js +5 -5
  47. package/dist/lib/checkpoint-ontology/queued-touches.d.ts +0 -3
  48. package/dist/lib/checkpoint-ontology/queued-touches.js +3 -3
  49. package/dist/lib/daemon/catalog.js +6 -2
  50. package/dist/lib/daemon/remote-control.d.ts +19 -8
  51. package/dist/lib/daemon/remote-control.js +62 -12
  52. package/dist/lib/daemon/supervisor.d.ts +2 -0
  53. package/dist/lib/daemon/supervisor.js +11 -0
  54. package/dist/lib/db/control-plane.js +6 -0
  55. package/dist/lib/deploy-apps.js +5 -0
  56. package/dist/startup-registration.js +9 -3
  57. package/dist/utils/install-tree-torn.d.ts +13 -6
  58. package/dist/utils/install-tree-torn.js +42 -16
  59. package/dist/utils/sentry-fingerprint.js +1 -0
  60. package/package.json +1 -1
@@ -184,8 +184,12 @@ async function defaultDispatchOutpostExec(input) {
184
184
  throw new LanesError("outpost_dispatch_failed", `Outpost exec failed: ${dispatchErrorMessage(err)}`, { outpost_id: input.outpostId, message: dispatchErrorMessage(err) });
185
185
  }
186
186
  }
187
+ // Pickup payloads are small; 30 seconds leaves room for normal network variance.
188
+ const OUTPOST_PICKUP_PAYLOAD_TIMEOUT_MS = 30_000;
187
189
  async function defaultFetchText(url) {
188
- const res = await fetch(url);
190
+ const res = await fetch(url, {
191
+ signal: AbortSignal.timeout(OUTPOST_PICKUP_PAYLOAD_TIMEOUT_MS),
192
+ });
189
193
  if (!res.ok) {
190
194
  throw new LanesError("outpost_payload_invalid", `Failed to download pickup payload: HTTP ${res.status}`, { status: res.status });
191
195
  }
@@ -1006,6 +1010,8 @@ const OUTPOST_HIRE_SUMMARY_TIMEOUT_SECONDS = 20;
1006
1010
  const OUTPOST_HIRE_SUMMARY_WAIT_MS = 15_000;
1007
1011
  const OUTPOST_SINGLE_LANE_WAIT_ENV = "HQ_LANES_OUTPOST_SINGLE_LANE_WAIT_MS";
1008
1012
  const OUTPOST_SINGLE_LANE_WAIT_MAX_MS = 600_000;
1013
+ const LEGACY_PICKUP_SETTLEMENT_MARGIN_MS = 60_000;
1014
+ const LEGACY_PICKUP_SETTLEMENT_MIN_AGE_MS = OUTPOST_SINGLE_LANE_WAIT_MAX_MS + LEGACY_PICKUP_SETTLEMENT_MARGIN_MS;
1009
1015
  function outpostSingleLaneWaitMs(env) {
1010
1016
  const raw = env[OUTPOST_SINGLE_LANE_WAIT_ENV]?.trim() || String(PICKUP_WAIT_MS);
1011
1017
  const value = /^\d+$/.test(raw) ? Number(raw) : Number.NaN;
@@ -1363,6 +1369,25 @@ async function refreshRemoteLaneMirrors(ctx, hqRoot, records, parentLaneIds, opt
1363
1369
  !ownerIsHostedByOutpost ||
1364
1370
  (owner.company?.uid ?? null) !== (mirror.company?.uid ?? null) ||
1365
1371
  (owner.company?.slug ?? null) !== (mirror.company?.slug ?? null)) {
1372
+ if (matches.length === 0 && isLegacyFailedDispatchWithoutPickupEvidence(mirror, nowMs)) {
1373
+ const settled = retryUpdateLane(hqRoot, mirror.lane_id, "reconcile", (current) => {
1374
+ if (!isLegacyFailedDispatchWithoutPickupEvidence(current, nowMs) ||
1375
+ current.host.id !== outpostId) {
1376
+ return current;
1377
+ }
1378
+ return {
1379
+ ...current,
1380
+ terminal_details: {
1381
+ ...(current.terminal_details ?? {}),
1382
+ pickup_persisted: false,
1383
+ },
1384
+ };
1385
+ });
1386
+ if (isUndispatchedOutpostMirror(settled)) {
1387
+ result.updated.set(mirror.lane_id, settled);
1388
+ continue;
1389
+ }
1390
+ }
1366
1391
  if (matches.length === 0)
1367
1392
  result.missingOnOwner.set(mirror.lane_id, mirror);
1368
1393
  const detail = matches.length === 0
@@ -2530,6 +2555,23 @@ export function isUndispatchedOutpostMirror(lane) {
2530
2555
  lane.terminal_details?.pickup_persisted === false &&
2531
2556
  lane.last_host_report_at == null;
2532
2557
  }
2558
+ function isLegacyFailedDispatchWithoutPickupEvidence(lane, nowMs) {
2559
+ const terminalDetails = lane.terminal_details;
2560
+ const updatedAtMs = Date.parse(lane.updated_at);
2561
+ const completedFailure = (terminalDetails?.status === "Failed" ||
2562
+ terminalDetails?.status === "Cancelled" ||
2563
+ terminalDetails?.status === "TimedOut") &&
2564
+ typeof terminalDetails.exit_code === "number" &&
2565
+ Number.isSafeInteger(terminalDetails.exit_code);
2566
+ return lane.host.kind === "outpost" &&
2567
+ isTerminalLaneState(lane.state) &&
2568
+ lane.terminal_reason === DISPATCH_TERMINAL_REASON &&
2569
+ lane.last_host_report_at == null &&
2570
+ lane.terminal_details?.pickup_persisted === undefined &&
2571
+ completedFailure &&
2572
+ Number.isFinite(updatedAtMs) &&
2573
+ nowMs - updatedAtMs > LEGACY_PICKUP_SETTLEMENT_MIN_AGE_MS;
2574
+ }
2533
2575
  function parsePickupTerminalReason(value) {
2534
2576
  if (PICKUP_TERMINAL_REASONS.includes(value)) {
2535
2577
  return value;
@@ -9,10 +9,7 @@
9
9
  */
10
10
  import type { ServiceHostPaths, ServiceSetResult } from "../service-manager/index.js";
11
11
  import type { AgentKitPaths } from "./paths.js";
12
- export declare const KIT_PID_NAME = "kit.pid";
13
- export declare const KIT_FALLBACK_LOG_NAME = "kit.log";
14
12
  export declare function kitPidPath(paths: Pick<AgentKitPaths, "agentDir">): string;
15
- export declare function kitFallbackLogPath(paths: Pick<AgentKitPaths, "logsDir">): string;
16
13
  /** True when an activation error means the service manager itself is unusable. */
17
14
  export declare function isServiceManagerUnavailable(error: string | undefined): boolean;
18
15
  /**
@@ -46,10 +43,6 @@ export interface DetachedSpawn {
46
43
  unref(): void;
47
44
  };
48
45
  }
49
- export declare function fallbackCommand(host: ServiceHostPaths): {
50
- cmd: string;
51
- args: string[];
52
- };
53
46
  /** crontab line that restarts the fallback supervisor after a reboot. */
54
47
  export declare function rebootCrontabLine(paths: Pick<AgentKitPaths, "agentDir" | "logsDir">, host: ServiceHostPaths): string;
55
48
  export declare function startFallback(paths: AgentKitPaths, host: ServiceHostPaths, deps?: {
@@ -12,12 +12,12 @@ import * as fs from "node:fs";
12
12
  import * as path from "node:path";
13
13
  import { kitServiceEnv } from "./services.js";
14
14
  import { writePrivateFile } from "./private-file.js";
15
- export const KIT_PID_NAME = "kit.pid";
16
- export const KIT_FALLBACK_LOG_NAME = "kit.log";
15
+ const KIT_PID_NAME = "kit.pid";
16
+ const KIT_FALLBACK_LOG_NAME = "kit.log";
17
17
  export function kitPidPath(paths) {
18
18
  return path.join(paths.agentDir, KIT_PID_NAME);
19
19
  }
20
- export function kitFallbackLogPath(paths) {
20
+ function kitFallbackLogPath(paths) {
21
21
  return path.join(paths.logsDir, KIT_FALLBACK_LOG_NAME);
22
22
  }
23
23
  const UNAVAILABLE_PATTERNS = [
@@ -93,7 +93,7 @@ export function stopFallback(paths, kill = defaultKill) {
93
93
  fs.rmSync(kitPidPath(paths), { force: true });
94
94
  return { pid, killed };
95
95
  }
96
- export function fallbackCommand(host) {
96
+ function fallbackCommand(host) {
97
97
  return { cmd: host.nodeBinary, args: [host.hqBinary, "agent", "kit", "run", "all"] };
98
98
  }
99
99
  /** crontab line that restarts the fallback supervisor after a reboot. */
@@ -9,8 +9,6 @@
9
9
  * always drain exactly what it has not handled yet and never reply twice.
10
10
  */
11
11
  import type { AgentKitPaths } from "./paths.js";
12
- export declare const DONE_IDS_NAME = "done-ids.json";
13
- export declare const MAX_DONE_IDS = 5000;
14
12
  export interface MirroredInboxEntry {
15
13
  id: string;
16
14
  mirroredAt?: string;
@@ -11,8 +11,8 @@
11
11
  import * as fs from "node:fs";
12
12
  import * as path from "node:path";
13
13
  import { writePrivateFile } from "./private-file.js";
14
- export const DONE_IDS_NAME = "done-ids.json";
15
- export const MAX_DONE_IDS = 5000;
14
+ const DONE_IDS_NAME = "done-ids.json";
15
+ const MAX_DONE_IDS = 5000;
16
16
  const INBOX_JSONL = "inbox.jsonl";
17
17
  export function readDoneIds(paths) {
18
18
  try {
@@ -5,10 +5,6 @@
5
5
  * contract-shaped credential file and nothing else.
6
6
  */
7
7
  import { type AgentKitPaths, type KitComponent } from "./paths.js";
8
- export declare const DEFAULT_SYNC_INTERVAL_MS: number;
9
- export declare const DEFAULT_INBOX_POLL_MS = 15000;
10
- export declare const DEFAULT_HEARTBEAT_INTERVAL_MS = 60000;
11
- export declare const DEFAULT_MESH_REFRESH_MS: number;
12
8
  export interface KitConfig {
13
9
  /** Local HQ tree the company vault syncs into (companies/<slug>/ …). */
14
10
  hqRoot: string;
@@ -53,7 +49,6 @@ export interface KitConfig {
53
49
  * unhealthy, so reporting it either way would be a lie.
54
50
  */
55
51
  export declare function enabledKitComponents(config: Pick<KitConfig, "syncFiles">): readonly KitComponent[];
56
- export declare function defaultHqRoot(paths: Pick<AgentKitPaths, "agentDir">): string;
57
52
  export declare function defaultKitConfig(paths: Pick<AgentKitPaths, "agentDir">, cliVersion: string, now?: () => Date): KitConfig;
58
53
  export declare function writeKitConfig(paths: Pick<AgentKitPaths, "kitConfigPath">, config: KitConfig): void;
59
54
  /** Read kit.json, falling back to defaults for any missing/invalid field. */
@@ -8,10 +8,10 @@ import * as fs from "node:fs";
8
8
  import * as path from "node:path";
9
9
  import { KIT_COMPONENTS } from "./paths.js";
10
10
  import { writePrivateFile } from "./private-file.js";
11
- export const DEFAULT_SYNC_INTERVAL_MS = 5 * 60_000;
12
- export const DEFAULT_INBOX_POLL_MS = 15_000;
13
- export const DEFAULT_HEARTBEAT_INTERVAL_MS = 60_000;
14
- export const DEFAULT_MESH_REFRESH_MS = 5 * 60_000;
11
+ const DEFAULT_SYNC_INTERVAL_MS = 5 * 60_000;
12
+ const DEFAULT_INBOX_POLL_MS = 15_000;
13
+ const DEFAULT_HEARTBEAT_INTERVAL_MS = 60_000;
14
+ const DEFAULT_MESH_REFRESH_MS = 5 * 60_000;
15
15
  /**
16
16
  * Kit components whose health this install actually reports. `sync` drops out
17
17
  * when the vault is not mirrored to disk — there is no loop to be healthy or
@@ -20,7 +20,7 @@ export const DEFAULT_MESH_REFRESH_MS = 5 * 60_000;
20
20
  export function enabledKitComponents(config) {
21
21
  return KIT_COMPONENTS.filter((c) => c !== "sync" || config.syncFiles);
22
22
  }
23
- export function defaultHqRoot(paths) {
23
+ function defaultHqRoot(paths) {
24
24
  return path.join(paths.agentDir, "hq");
25
25
  }
26
26
  export function defaultKitConfig(paths, cliVersion, now = () => new Date()) {
@@ -4,7 +4,6 @@
4
4
  * on disk even through an error message.
5
5
  */
6
6
  import type { AgentKitPaths } from "./paths.js";
7
- export declare const KIT_LOG_MAX_BYTES: number;
8
7
  export type KitLogLevel = "info" | "warn" | "error";
9
8
  export type KitLogger = (level: KitLogLevel, message: string) => void;
10
9
  export declare function sanitizeLogLine(message: string): string;
@@ -6,7 +6,7 @@
6
6
  import * as fs from "node:fs";
7
7
  import * as path from "node:path";
8
8
  import { serviceLogPath } from "./paths.js";
9
- export const KIT_LOG_MAX_BYTES = 5 * 1024 * 1024;
9
+ const KIT_LOG_MAX_BYTES = 5 * 1024 * 1024;
10
10
  export function sanitizeLogLine(message) {
11
11
  return message
12
12
  .replace(/Bearer\s+[A-Za-z0-9._-]+/gi, "Bearer [REDACTED]")
@@ -9,14 +9,6 @@
9
9
  * pump. Every request is answered; notifications are consumed silently;
10
10
  * malformed input yields a JSON-RPC error rather than a crash.
11
11
  */
12
- export declare const MCP_PROTOCOL_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
13
- export declare const MCP_LATEST_PROTOCOL_VERSION: "2025-06-18";
14
- export interface JsonRpcRequest {
15
- jsonrpc: "2.0";
16
- id?: string | number | null;
17
- method: string;
18
- params?: unknown;
19
- }
20
12
  export interface JsonRpcResponse {
21
13
  jsonrpc: "2.0";
22
14
  id: string | number | null;
@@ -28,16 +20,14 @@ export interface JsonRpcResponse {
28
20
  };
29
21
  }
30
22
  export declare const JSONRPC_PARSE_ERROR = -32700;
31
- export declare const JSONRPC_INVALID_REQUEST = -32600;
32
23
  export declare const JSONRPC_METHOD_NOT_FOUND = -32601;
33
24
  export declare const JSONRPC_INVALID_PARAMS = -32602;
34
- export declare const JSONRPC_INTERNAL_ERROR = -32603;
35
25
  export interface McpToolDefinition {
36
26
  name: string;
37
27
  description: string;
38
28
  inputSchema: Record<string, unknown>;
39
29
  }
40
- export interface McpToolContent {
30
+ interface McpToolContent {
41
31
  type: "text";
42
32
  text: string;
43
33
  }
@@ -45,7 +35,7 @@ export interface McpToolResult {
45
35
  content: McpToolContent[];
46
36
  isError?: boolean;
47
37
  }
48
- export type McpToolHandler = (args: Record<string, unknown>) => Promise<McpToolResult>;
38
+ type McpToolHandler = (args: Record<string, unknown>) => Promise<McpToolResult>;
49
39
  export interface McpTool extends McpToolDefinition {
50
40
  handler: McpToolHandler;
51
41
  }
@@ -81,4 +71,5 @@ export declare class McpServer {
81
71
  */
82
72
  serve(input: NodeJS.ReadableStream, output: NodeJS.WritableStream): Promise<void>;
83
73
  }
74
+ export {};
84
75
  //# sourceMappingURL=jsonrpc.d.ts.map
@@ -9,13 +9,13 @@
9
9
  * pump. Every request is answered; notifications are consumed silently;
10
10
  * malformed input yields a JSON-RPC error rather than a crash.
11
11
  */
12
- export const MCP_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
13
- export const MCP_LATEST_PROTOCOL_VERSION = MCP_PROTOCOL_VERSIONS[0];
12
+ const MCP_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
13
+ const MCP_LATEST_PROTOCOL_VERSION = MCP_PROTOCOL_VERSIONS[0];
14
14
  export const JSONRPC_PARSE_ERROR = -32700;
15
- export const JSONRPC_INVALID_REQUEST = -32600;
15
+ const JSONRPC_INVALID_REQUEST = -32600;
16
16
  export const JSONRPC_METHOD_NOT_FOUND = -32601;
17
17
  export const JSONRPC_INVALID_PARAMS = -32602;
18
- export const JSONRPC_INTERNAL_ERROR = -32603;
18
+ const JSONRPC_INTERNAL_ERROR = -32603;
19
19
  export class McpToolInputError extends Error {
20
20
  constructor(message) {
21
21
  super(message);
@@ -57,8 +57,6 @@ export interface McpToolClients {
57
57
  body: unknown;
58
58
  }>;
59
59
  }
60
- export declare const MAX_TOOL_OUTPUT_CHARS = 40000;
61
- export declare const ATTACHMENTS_HINT: string;
62
60
  export declare function clampOutput(text: string, max?: number): string;
63
61
  /** Vault paths are company-anchored and must not escape. */
64
62
  export declare function assertVaultPath(p: string): string;
@@ -21,8 +21,8 @@ import { isRecipientUid } from "../../../lib/notify-recipient.js";
21
21
  import { markInboxDone, mergeAgentInbox, readDoneIds, summarizeInboxEntry } from "../inbox-state.js";
22
22
  import { AttachmentCompanyUnresolvedError, fetchChatAttachment } from "./attachments.js";
23
23
  import { errorResult, McpToolInputError, textResult } from "./jsonrpc.js";
24
- export const MAX_TOOL_OUTPUT_CHARS = 40_000;
25
- export const ATTACHMENTS_HINT = "Some messages carry files. For each entry in a message's `attachments` whose vaultPath starts with chat/attachments/, " +
24
+ const MAX_TOOL_OUTPUT_CHARS = 40_000;
25
+ const ATTACHMENTS_HINT = "Some messages carry files. For each entry in a message's `attachments` whose vaultPath starts with chat/attachments/, " +
26
26
  "call hq_attachment_fetch with that vaultPath and companyUid to download it; hq_files_read cannot open message attachments. " +
27
27
  "Anything else (a folder or shared vault path) is not a chat attachment: use hq_files_list / hq_files_read for those.";
28
28
  function str(args, key, opts = {}) {
@@ -7,7 +7,6 @@ import type { ServiceSpec } from "../service-manager/types.js";
7
7
  import type { AgentKitPaths } from "./paths.js";
8
8
  export type KitService = "sync" | "inbox" | "heartbeat";
9
9
  export declare const KIT_SERVICES: readonly KitService[];
10
- export declare const KIT_LABEL_PREFIX = "ai.getindigo.hq-agent";
11
10
  export declare function isKitService(value: string): value is KitService;
12
11
  /**
13
12
  * Environment every service inherits. HQ_MACHINE_CREDS_FILE pins hq-cloud's
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { serviceLogPath } from "./paths.js";
7
7
  export const KIT_SERVICES = ["sync", "inbox", "heartbeat"];
8
- export const KIT_LABEL_PREFIX = "ai.getindigo.hq-agent";
8
+ const KIT_LABEL_PREFIX = "ai.getindigo.hq-agent";
9
9
  export function isKitService(value) {
10
10
  return KIT_SERVICES.includes(value);
11
11
  }
@@ -8,8 +8,6 @@
8
8
  import { type DuplicateReport, type MergeBackOutcome } from "./multi-writer.js";
9
9
  import { type CompanyBriefResult } from "./company-brief.js";
10
10
  import { type SyncClientVersions } from "./sync-client.js";
11
- import { type WritableEntityType } from "./identity.js";
12
- import { type EntityIndex } from "./tree.js";
13
11
  export declare const CAPS: {
14
12
  readonly creates: 25;
15
13
  readonly updates: 100;
@@ -18,15 +16,6 @@ export declare const CAPS: {
18
16
  readonly aliasesPerCandidate: 5;
19
17
  readonly nameLength: 200;
20
18
  };
21
- export declare const MIN_CREATE_CONFIDENCE = 0.7;
22
- export interface Candidate {
23
- input: string;
24
- type: WritableEntityType;
25
- name: string;
26
- aliases: string[];
27
- confidence: number;
28
- evidence: string;
29
- }
30
19
  export interface ApplyReport {
31
20
  schema: "hq-checkpoint-ontology-report.v1";
32
21
  company: string;
@@ -109,8 +98,6 @@ export interface ApplyOptions {
109
98
  export declare class ApplyError extends Error {
110
99
  constructor(message: string);
111
100
  }
112
- /** Validate one raw candidate. Returns the candidate or a rejection reason. */
113
- export declare function parseCandidate(raw: unknown): Candidate | string;
114
101
  /**
115
102
  * checkpoint.ontology.named-evidence: true when `evidence` holds one of
116
103
  * `names` as a word, matching case. A name inside a path, domain, handle, tag
@@ -119,41 +106,5 @@ export declare function parseCandidate(raw: unknown): Candidate | string;
119
106
  * `` `indigo` ``.
120
107
  */
121
108
  export declare function evidenceNames(evidence: string, names: string[]): boolean;
122
- type Resolution = {
123
- tier: 1;
124
- target: string;
125
- duplicates: string[];
126
- } | {
127
- tier: 2;
128
- target: string;
129
- } | {
130
- tier: "ambiguous_alias";
131
- paths: string[];
132
- } | {
133
- tier: "suspect_duplicate";
134
- paths: string[];
135
- } | {
136
- tier: "type_conflict";
137
- types: string[];
138
- } | {
139
- tier: "new";
140
- };
141
- /** Design section 5.3, tiers 1 to 4. */
142
- export declare function resolveCandidate(index: EntityIndex, type: string, canonical: string): Resolution;
143
- /**
144
- * Existing entities of `type` that a new candidate probably is: one of the
145
- * candidate's aliases is already their name or alias, or, for people, every
146
- * word of their name (two words or more) is in the candidate's name
147
- * (`Chaudhry Hassaan Saleem` and `Hassaan Saleem`).
148
- */
149
- export declare function overlappingEntities(index: EntityIndex, type: string, canonical: string, aliases: string[]): string[];
150
- /**
151
- * Existing people a one-word person candidate may be: the word is the first
152
- * word of their name or of one of their aliases, and that name has two words
153
- * or more (`John` and `John Smith`). The model never sees the entity tree, so
154
- * it cannot tell a first name that the company already holds in full.
155
- */
156
- export declare function firstNameOverlap(index: EntityIndex, canonical: string): string[];
157
109
  export declare function applyOntologyRun(options: ApplyOptions): ApplyReport;
158
- export {};
159
110
  //# sourceMappingURL=apply.d.ts.map
@@ -25,7 +25,7 @@ export const CAPS = {
25
25
  aliasesPerCandidate: 5,
26
26
  nameLength: MAX_NAME_LENGTH,
27
27
  };
28
- export const MIN_CREATE_CONFIDENCE = 0.7;
28
+ const MIN_CREATE_CONFIDENCE = 0.7;
29
29
  /** Inbound links the dominant sibling must have for each one the named entity has. */
30
30
  const DOMINANT_SIBLING_RATIO = 3;
31
31
  /** Inbound links the dominant sibling must have before a redirect. */
@@ -44,7 +44,7 @@ function sha256(content) {
44
44
  return createHash("sha256").update(content).digest("hex");
45
45
  }
46
46
  /** Validate one raw candidate. Returns the candidate or a rejection reason. */
47
- export function parseCandidate(raw) {
47
+ function parseCandidate(raw) {
48
48
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
49
49
  return "not_an_object";
50
50
  const c = raw;
@@ -101,7 +101,7 @@ export function evidenceNames(evidence, names) {
101
101
  return false;
102
102
  }
103
103
  /** Design section 5.3, tiers 1 to 4. */
104
- export function resolveCandidate(index, type, canonical) {
104
+ function resolveCandidate(index, type, canonical) {
105
105
  const normalized = normalizeEntityName(canonical, type);
106
106
  const byCanonical = [...(index.canonical.get(entityKey(type, normalized)) ?? [])].sort();
107
107
  if (byCanonical.length > 0)
@@ -125,7 +125,7 @@ export function resolveCandidate(index, type, canonical) {
125
125
  * word of their name (two words or more) is in the candidate's name
126
126
  * (`Chaudhry Hassaan Saleem` and `Hassaan Saleem`).
127
127
  */
128
- export function overlappingEntities(index, type, canonical, aliases) {
128
+ function overlappingEntities(index, type, canonical, aliases) {
129
129
  const paths = new Set();
130
130
  for (const alias of aliases) {
131
131
  const normalized = normalizeEntityName(alias, type);
@@ -157,7 +157,7 @@ export function overlappingEntities(index, type, canonical, aliases) {
157
157
  * or more (`John` and `John Smith`). The model never sees the entity tree, so
158
158
  * it cannot tell a first name that the company already holds in full.
159
159
  */
160
- export function firstNameOverlap(index, canonical) {
160
+ function firstNameOverlap(index, canonical) {
161
161
  const words = normalizeEntityName(canonical, "person").split(" ");
162
162
  if (words.length !== 1 || !words[0])
163
163
  return [];
@@ -7,7 +7,7 @@
7
7
  * synced entity file with these rules, so they must match byte for byte.
8
8
  */
9
9
  /** The entity types this writer creates or updates. */
10
- export declare const WRITABLE_ENTITY_TYPES: readonly ["person", "project", "company", "concept"];
10
+ declare const WRITABLE_ENTITY_TYPES: readonly ["person", "project", "company", "concept"];
11
11
  export type WritableEntityType = (typeof WRITABLE_ENTITY_TYPES)[number];
12
12
  export declare function isWritableEntityType(value: unknown): value is WritableEntityType;
13
13
  /**
@@ -34,4 +34,5 @@ export declare function squash(normalized: string): string;
34
34
  * and are matched by tiers 1 and 2 before this filter runs.
35
35
  */
36
36
  export declare function isRejectedName(normalized: string): boolean;
37
+ export {};
37
38
  //# sourceMappingURL=identity.d.ts.map
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import { createHash } from "node:crypto";
10
10
  /** The entity types this writer creates or updates. */
11
- export const WRITABLE_ENTITY_TYPES = ["person", "project", "company", "concept"];
11
+ const WRITABLE_ENTITY_TYPES = ["person", "project", "company", "concept"];
12
12
  export function isWritableEntityType(value) {
13
13
  return typeof value === "string" && WRITABLE_ENTITY_TYPES.includes(value);
14
14
  }
@@ -16,15 +16,9 @@
16
16
  import { type OntologyCompany } from "./company.js";
17
17
  import { type SignalBackRef } from "./entity-file.js";
18
18
  import { type EntityIndex } from "./tree.js";
19
- export declare const OUTBOX_SCHEMA = "hq-ontology-outbox.v1";
20
- export declare const OUTBOX_DIR = ".hq/ontology-outbox";
21
- export declare const OUTBOX_RETENTION_MS: number;
22
- /** Where sync parks a losing local body (hq-cloud `CONFLICT_BACKUPS_DIR`). */
23
- export declare const CONFLICT_BACKUPS_DIR = ".hq/conflict-backups";
19
+ declare const OUTBOX_SCHEMA = "hq-ontology-outbox.v1";
24
20
  export declare const MERGED_BACKUPS_DIR = ".hq/conflict-backups/ontology-merged";
25
- export declare const STALE_BACKUP_MS: number;
26
- export declare const DUPLICATE_REPORT_LIMIT = 20;
27
- export interface OutboxEntry {
21
+ interface OutboxEntry {
28
22
  sha256: string;
29
23
  written_at: string;
30
24
  }
@@ -49,7 +43,7 @@ export declare function readOutbox(hqRoot: string, company: OntologyCompany): Ou
49
43
  export declare function recordOutbox(hqRoot: string, company: OntologyCompany, writes: OutboxWrite[], now: Date): {
50
44
  reset: boolean;
51
45
  };
52
- export type MergeBackResult = "merged" | "kept_both" | "stale" | "deleted" | "identity_conflict" | "invalid" | "write_error";
46
+ type MergeBackResult = "merged" | "kept_both" | "stale" | "deleted" | "identity_conflict" | "invalid" | "write_error";
53
47
  export interface MergeBackOutcome {
54
48
  /** HQ-relative path of the set-aside version. */
55
49
  backup: string;
@@ -103,4 +97,5 @@ export interface MultiWriterStart {
103
97
  export declare function startMultiWriterRun(hqRoot: string, company: OntologyCompany, now: Date): MultiWriterStart;
104
98
  /** Count merge-back outcomes by result, for one-line summaries. */
105
99
  export declare function summarizeMergeBack(outcomes: MergeBackOutcome[]): string;
100
+ export {};
106
101
  //# sourceMappingURL=multi-writer.d.ts.map
@@ -22,14 +22,14 @@ import { entitiesRoot, safeWriteFile } from "./company.js";
22
22
  import { appendBackRefs, OWNED_KEYS, parseEntityFile, patchEntityFile, validateEntityFrontmatter, } from "./entity-file.js";
23
23
  import { isWritableEntityType, squash } from "./identity.js";
24
24
  import { buildEntityIndex, indexAlias } from "./tree.js";
25
- export const OUTBOX_SCHEMA = "hq-ontology-outbox.v1";
26
- export const OUTBOX_DIR = ".hq/ontology-outbox";
27
- export const OUTBOX_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
25
+ const OUTBOX_SCHEMA = "hq-ontology-outbox.v1";
26
+ const OUTBOX_DIR = ".hq/ontology-outbox";
27
+ const OUTBOX_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
28
28
  /** Where sync parks a losing local body (hq-cloud `CONFLICT_BACKUPS_DIR`). */
29
- export const CONFLICT_BACKUPS_DIR = ".hq/conflict-backups";
29
+ const CONFLICT_BACKUPS_DIR = ".hq/conflict-backups";
30
30
  export const MERGED_BACKUPS_DIR = ".hq/conflict-backups/ontology-merged";
31
- export const STALE_BACKUP_MS = 7 * 24 * 60 * 60 * 1000;
32
- export const DUPLICATE_REPORT_LIMIT = 20;
31
+ const STALE_BACKUP_MS = 7 * 24 * 60 * 60 * 1000;
32
+ const DUPLICATE_REPORT_LIMIT = 20;
33
33
  /**
34
34
  * Keys that differ between two versions of a new entity for reasons that say
35
35
  * nothing about its content. The vault's value stands and the difference is
@@ -40,14 +40,14 @@ export declare const CANDIDATES_FILE = "ontology-candidates.json";
40
40
  export declare const REPORT_FILE = "ontology-report.json";
41
41
  export declare const PLAN_SCHEMA = "hq-checkpoint-ontology-plan.v1";
42
42
  export declare const CANDIDATES_SCHEMA = "hq-checkpoint-ontology-candidates.v1";
43
- export declare const LEDGER_SCHEMA = "hq-checkpoint-ontology-ledger.v1";
43
+ declare const LEDGER_SCHEMA = "hq-checkpoint-ontology-ledger.v1";
44
44
  export declare const BUDGET: {
45
45
  readonly maxInputs: 20;
46
46
  readonly maxTokens: 60000;
47
47
  readonly chunkTokens: 12000;
48
48
  };
49
- export type PendingReason = "session-touched";
50
- export interface LedgerEntry {
49
+ type PendingReason = "session-touched";
50
+ interface LedgerEntry {
51
51
  sha256: string;
52
52
  size: number;
53
53
  mtime_ms: number;
@@ -164,25 +164,11 @@ export type PlanOutcome = {
164
164
  };
165
165
  export declare const READ_PATH_INSTRUCTION = "When an input has read_path, read that file (relative to the run directory) instead of path, with the same line range. It is the same text with an older annotator's entity lists and entity links removed.";
166
166
  export declare const FIRST_NAME_PEOPLE_INSTRUCTION = "Name a person by the full name the input or the company's entities give. When neither gives more than a first name, name the person by that first name; do not leave them out.";
167
- export declare function ledgerPath(hqRoot: string, company: OntologyCompany): string;
168
167
  export declare function readLedger(hqRoot: string, company: OntologyCompany): Ledger | null;
169
168
  export declare function writeLedger(hqRoot: string, company: OntologyCompany, ledger: Ledger): void;
170
169
  export declare function backendPreferencePath(hqRoot: string, company: OntologyCompany): string;
171
170
  /** The grok-backend flag value the last plan recorded; false when no plan has recorded one. */
172
171
  export declare function readBackendPreference(hqRoot: string, company: OntologyCompany): boolean;
173
- /** Company-relative paths of the payload's touched files that are inside this company. */
174
- export declare function sessionTouched(hqRoot: string, company: OntologyCompany, files: unknown): Set<string>;
175
- /** 1-based line ranges, each at most `chunkTokens` tokens (bytes / 4). */
176
- export declare function chunkLines(content: string, chunkTokens: number): Array<[number, number]>;
177
- /**
178
- * Update the ledger with the current tree and return it. New or changed files
179
- * the session touched become pending; others are recorded as seen. The first
180
- * run records the entity boundary (design 14.3).
181
- */
182
- export declare function refreshLedger(company: OntologyCompany, existing: Ledger | null, touched: Set<string>): {
183
- ledger: Ledger;
184
- firstRun: boolean;
185
- };
186
172
  /**
187
173
  * The company this run's ontology step works on: the payload's own company,
188
174
  * or else the `ontology_company` the checkpoint parent picked for queued
@@ -203,4 +189,5 @@ export declare function planOntologyRun(options: PlanOptions): Promise<PlanOutco
203
189
  * segment. Returns null when the text has neither.
204
190
  */
205
191
  export declare function stripAnnotations(text: string): string | null;
192
+ export {};
206
193
  //# sourceMappingURL=plan.d.ts.map
@@ -45,7 +45,7 @@ export const CANDIDATES_FILE = "ontology-candidates.json";
45
45
  export const REPORT_FILE = "ontology-report.json";
46
46
  export const PLAN_SCHEMA = "hq-checkpoint-ontology-plan.v1";
47
47
  export const CANDIDATES_SCHEMA = "hq-checkpoint-ontology-candidates.v1";
48
- export const LEDGER_SCHEMA = "hq-checkpoint-ontology-ledger.v1";
48
+ const LEDGER_SCHEMA = "hq-checkpoint-ontology-ledger.v1";
49
49
  export const BUDGET = {
50
50
  maxInputs: 20,
51
51
  maxTokens: 60_000,
@@ -64,7 +64,7 @@ const CANDIDATE_INSTRUCTIONS = [
64
64
  function sha256File(file) {
65
65
  return createHash("sha256").update(fs.readFileSync(file)).digest("hex");
66
66
  }
67
- export function ledgerPath(hqRoot, company) {
67
+ function ledgerPath(hqRoot, company) {
68
68
  return path.join(stateRoot(hqRoot, company), "ledger.json");
69
69
  }
70
70
  export function readLedger(hqRoot, company) {
@@ -108,7 +108,7 @@ function recordBackendPreference(hqRoot, company, preferGrok) {
108
108
  safeWriteFile(hqRoot, [stateRoot(hqRoot, company)], target, `${JSON.stringify({ prefer_grok: preferGrok })}\n`);
109
109
  }
110
110
  /** Company-relative paths of the payload's touched files that are inside this company. */
111
- export function sessionTouched(hqRoot, company, files) {
111
+ function sessionTouched(hqRoot, company, files) {
112
112
  const out = new Set();
113
113
  if (!Array.isArray(files))
114
114
  return out;
@@ -124,7 +124,7 @@ export function sessionTouched(hqRoot, company, files) {
124
124
  return out;
125
125
  }
126
126
  /** 1-based line ranges, each at most `chunkTokens` tokens (bytes / 4). */
127
- export function chunkLines(content, chunkTokens) {
127
+ function chunkLines(content, chunkTokens) {
128
128
  const lines = content.split("\n");
129
129
  const maxBytes = chunkTokens * 4;
130
130
  const chunks = [];
@@ -171,7 +171,7 @@ function missingRefs(companyDir, rel) {
171
171
  * the session touched become pending; others are recorded as seen. The first
172
172
  * run records the entity boundary (design 14.3).
173
173
  */
174
- export function refreshLedger(company, existing, touched) {
174
+ function refreshLedger(company, existing, touched) {
175
175
  const firstRun = existing === null;
176
176
  const index = firstRun ? buildEntityIndex(company.dir) : null;
177
177
  const boundary = existing ? existing.boundary : entityBoundary(index);
@@ -1,7 +1,4 @@
1
1
  import { type OntologyCompany } from "./company.js";
2
- export declare const QUEUED_TOUCHES_FILE = "queued-touches.jsonl";
3
- export declare const QUEUED_TOUCHES_CLAIM_FILE = "queued-touches-claimed.jsonl";
4
- export declare const QUEUED_TOUCHES_BORROWED_FILE = "queued-touches-borrowed-at";
5
2
  export declare const MAX_QUEUED_TOUCHES = 200;
6
3
  export declare function queuedTouchesPath(hqRoot: string, slug: string): string;
7
4
  /**
@@ -16,9 +16,9 @@
16
16
  import * as fs from "node:fs";
17
17
  import * as path from "node:path";
18
18
  import { assertSafeTarget, resolveOntologyCompany, safeWriteFile, WriteBoundsError, } from "./company.js";
19
- export const QUEUED_TOUCHES_FILE = "queued-touches.jsonl";
20
- export const QUEUED_TOUCHES_CLAIM_FILE = "queued-touches-claimed.jsonl";
21
- export const QUEUED_TOUCHES_BORROWED_FILE = "queued-touches-borrowed-at";
19
+ const QUEUED_TOUCHES_FILE = "queued-touches.jsonl";
20
+ const QUEUED_TOUCHES_CLAIM_FILE = "queued-touches-claimed.jsonl";
21
+ const QUEUED_TOUCHES_BORROWED_FILE = "queued-touches-borrowed-at";
22
22
  export const MAX_QUEUED_TOUCHES = 200;
23
23
  function ontologyStateBase(hqRoot) {
24
24
  return path.join(hqRoot, "workspace", "checkpoints", "ontology");