@indigoai-us/hq-cli 5.306.0 → 5.308.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 +10 -0
- package/assets/scaffold/core/scripts/audit-log.sh +384 -0
- package/assets/scaffold/core/scripts/git-pack-extension-check.sh +164 -0
- package/assets/scaffold/core/scripts/hq-pin.sh +118 -0
- package/assets/scaffold/core/scripts/lib/portable.sh +211 -0
- package/assets/scaffold/core/scripts/refresh-vault-access.sh +188 -0
- package/assets/scaffold/core/scripts/resolve-company.sh +199 -0
- package/dist/command-catalog.generated.d.ts +65 -0
- package/dist/command-catalog.generated.js +80 -0
- package/dist/commands/core-audit-log-native.d.ts +9 -0
- package/dist/commands/core-audit-log-native.js +257 -0
- package/dist/commands/core-git-pack-extension-check-native.d.ts +22 -0
- package/dist/commands/core-git-pack-extension-check-native.js +190 -0
- package/dist/commands/core-native-utilities-flag.d.ts +4 -0
- package/dist/commands/core-native-utilities-flag.js +7 -0
- package/dist/commands/core-native-utilities.d.ts +28 -0
- package/dist/commands/core-native-utilities.js +52 -0
- package/dist/commands/core-pin-native.d.ts +14 -0
- package/dist/commands/core-pin-native.js +236 -0
- package/dist/commands/core-refresh-vault-access-native.d.ts +20 -0
- package/dist/commands/core-refresh-vault-access-native.js +229 -0
- package/dist/commands/core-resolve-company-command.d.ts +4 -0
- package/dist/commands/core-resolve-company-command.js +42 -0
- package/dist/commands/core-resolve-company-native.d.ts +28 -0
- package/dist/commands/core-resolve-company-native.js +408 -0
- package/dist/commands/core.js +18 -0
- package/dist/commands/dm.js +6 -1
- package/dist/commands/lanes.js +43 -1
- package/dist/fast-scaffold.js +12 -0
- package/dist/lib/agent-kit/fallback.d.ts +0 -7
- package/dist/lib/agent-kit/fallback.js +4 -4
- package/dist/lib/agent-kit/inbox-state.d.ts +0 -2
- package/dist/lib/agent-kit/inbox-state.js +2 -2
- package/dist/lib/agent-kit/kit-config.d.ts +0 -5
- package/dist/lib/agent-kit/kit-config.js +5 -5
- package/dist/lib/agent-kit/log.d.ts +0 -1
- package/dist/lib/agent-kit/log.js +1 -1
- package/dist/lib/agent-kit/mcp/jsonrpc.d.ts +3 -12
- package/dist/lib/agent-kit/mcp/jsonrpc.js +4 -4
- package/dist/lib/agent-kit/mcp/tools.d.ts +0 -2
- package/dist/lib/agent-kit/mcp/tools.js +2 -2
- package/dist/lib/agent-kit/services.d.ts +0 -1
- package/dist/lib/agent-kit/services.js +1 -1
- package/dist/lib/checkpoint-ontology/apply.d.ts +0 -49
- package/dist/lib/checkpoint-ontology/apply.js +5 -5
- package/dist/lib/checkpoint-ontology/identity.d.ts +2 -1
- package/dist/lib/checkpoint-ontology/identity.js +1 -1
- package/dist/lib/checkpoint-ontology/multi-writer.d.ts +4 -9
- package/dist/lib/checkpoint-ontology/multi-writer.js +6 -6
- package/dist/lib/checkpoint-ontology/plan.d.ts +4 -17
- package/dist/lib/checkpoint-ontology/plan.js +5 -5
- package/dist/lib/checkpoint-ontology/queued-touches.d.ts +0 -3
- package/dist/lib/checkpoint-ontology/queued-touches.js +3 -3
- package/dist/lib/db/control-plane.js +6 -0
- package/dist/lib/deploy-apps.js +5 -0
- package/package.json +1 -1
|
@@ -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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
15
|
+
const JSONRPC_INVALID_REQUEST = -32600;
|
|
16
16
|
export const JSONRPC_METHOD_NOT_FOUND = -32601;
|
|
17
17
|
export const JSONRPC_INVALID_PARAMS = -32602;
|
|
18
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
29
|
+
const CONFLICT_BACKUPS_DIR = ".hq/conflict-backups";
|
|
30
30
|
export const MERGED_BACKUPS_DIR = ".hq/conflict-backups/ontology-merged";
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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");
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { planGateErrorFromPayload } from "../../utils/plan-gate-error.js";
|
|
2
|
+
// Provision may allocate remote resources, so allow two minutes and never retry.
|
|
3
|
+
const DB_PROVISION_TIMEOUT_MS = 120_000;
|
|
4
|
+
// Status is a read-only probe; 15 seconds is longer than its normal response time.
|
|
5
|
+
const DB_STATUS_TIMEOUT_MS = 15_000;
|
|
2
6
|
function assertNoPostgresUrl(label, text) {
|
|
3
7
|
if (/postgres:\/\//i.test(text) || /postgresql:\/\//i.test(text)) {
|
|
4
8
|
throw new Error(`${label}: control plane returned a connection string (refusing to surface)`);
|
|
@@ -22,6 +26,7 @@ export class ControlPlaneDbClient {
|
|
|
22
26
|
"Content-Type": "application/json",
|
|
23
27
|
},
|
|
24
28
|
body: JSON.stringify(input),
|
|
29
|
+
signal: AbortSignal.timeout(DB_PROVISION_TIMEOUT_MS),
|
|
25
30
|
});
|
|
26
31
|
const text = await res.text();
|
|
27
32
|
assertNoPostgresUrl("provision", text);
|
|
@@ -53,6 +58,7 @@ export class ControlPlaneDbClient {
|
|
|
53
58
|
const res = await this.fetchImpl(url, {
|
|
54
59
|
method: "GET",
|
|
55
60
|
headers: { Authorization: `Bearer ${token}` },
|
|
61
|
+
signal: AbortSignal.timeout(DB_STATUS_TIMEOUT_MS),
|
|
56
62
|
});
|
|
57
63
|
const text = await res.text();
|
|
58
64
|
assertNoPostgresUrl("status", text);
|
package/dist/lib/deploy-apps.js
CHANGED
|
@@ -7,6 +7,7 @@ export const MAX_DEPLOY_APPS_PAGES = 100;
|
|
|
7
7
|
*/
|
|
8
8
|
export async function listDeployApps(fetchPage) {
|
|
9
9
|
const apps = [];
|
|
10
|
+
const seenCursors = new Set();
|
|
10
11
|
let cursor;
|
|
11
12
|
for (let page = 0; page < MAX_DEPLOY_APPS_PAGES; page += 1) {
|
|
12
13
|
const result = await fetchPage(cursor);
|
|
@@ -17,6 +18,10 @@ export async function listDeployApps(fetchPage) {
|
|
|
17
18
|
if (typeof result.nextCursor !== "string" || result.nextCursor.length === 0) {
|
|
18
19
|
throw new Error("hq-deploy returned an invalid apps-list cursor.");
|
|
19
20
|
}
|
|
21
|
+
if (seenCursors.has(result.nextCursor)) {
|
|
22
|
+
throw new Error("hq-deploy returned a repeated apps list cursor.");
|
|
23
|
+
}
|
|
24
|
+
seenCursors.add(result.nextCursor);
|
|
20
25
|
cursor = result.nextCursor;
|
|
21
26
|
}
|
|
22
27
|
throw new Error(`hq-deploy apps list exceeded the ${MAX_DEPLOY_APPS_PAGES}-page safety cap.`);
|