@indigoai-us/hq-cli 5.345.215-beta.0 → 5.345.215

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 (124) hide show
  1. package/CHANGELOG.md +65 -1
  2. package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
  3. package/dist/command-catalog.generated.d.ts +46 -6
  4. package/dist/command-catalog.generated.js +53 -6
  5. package/dist/commands/bot.js +64 -6
  6. package/dist/commands/capacity.d.ts +4 -1
  7. package/dist/commands/capacity.js +46 -10
  8. package/dist/commands/cloud.js +1 -1
  9. package/dist/commands/core-delegate-w1b.js +15 -1
  10. package/dist/commands/core-policy.js +67 -8
  11. package/dist/commands/daemon.js +5 -0
  12. package/dist/commands/files-browse.d.ts +11 -4
  13. package/dist/commands/files-browse.js +21 -4
  14. package/dist/commands/files.d.ts +1 -1
  15. package/dist/commands/files.js +25 -11
  16. package/dist/commands/integrations-auth-rules.d.ts +27 -0
  17. package/dist/commands/integrations-auth-rules.js +79 -0
  18. package/dist/commands/integrations-import.js +124 -12
  19. package/dist/commands/lanes.js +2 -2
  20. package/dist/commands/mesh.d.ts +2 -0
  21. package/dist/commands/mesh.js +60 -35
  22. package/dist/commands/sync-held.js +5 -2
  23. package/dist/lazy-commands.js +3 -5
  24. package/dist/lib/bot/fleet-cron.d.ts +8 -0
  25. package/dist/lib/bot/fleet-cron.js +35 -3
  26. package/dist/lib/bot/fleet-daemon.d.ts +46 -0
  27. package/dist/lib/bot/fleet-daemon.js +99 -1
  28. package/dist/lib/bot/probe.js +7 -1
  29. package/dist/lib/bot/run.js +20 -1
  30. package/dist/lib/bot/runtime/codex.js +1 -1
  31. package/dist/lib/bot/runtime/grok-acp.d.ts +5 -1
  32. package/dist/lib/bot/runtime/grok-acp.js +6 -3
  33. package/dist/lib/bot/runtime/index.js +19 -9
  34. package/dist/lib/bot/runtime/messages-stream.js +2 -2
  35. package/dist/lib/bot/runtime/types.d.ts +15 -0
  36. package/dist/lib/bot/runtime/types.js +9 -0
  37. package/dist/lib/bot/runtime-failure.d.ts +23 -0
  38. package/dist/lib/bot/runtime-failure.js +43 -1
  39. package/dist/lib/capacity/accounts.d.ts +8 -0
  40. package/dist/lib/capacity/accounts.js +19 -0
  41. package/dist/lib/capacity/available.d.ts +154 -0
  42. package/dist/lib/capacity/available.js +905 -0
  43. package/dist/lib/capacity/codex-availability.d.ts +14 -1
  44. package/dist/lib/capacity/codex-availability.js +26 -1
  45. package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
  46. package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
  47. package/dist/lib/capacity/collectors/codex.js +10 -7
  48. package/dist/lib/capacity/ledger.d.ts +37 -1
  49. package/dist/lib/capacity/ledger.js +207 -30
  50. package/dist/lib/capacity/project.d.ts +26 -0
  51. package/dist/lib/capacity/project.js +137 -8
  52. package/dist/lib/capacity/refusal-rows.d.ts +31 -0
  53. package/dist/lib/capacity/refusal-rows.js +61 -0
  54. package/dist/lib/capacity/refusal.d.ts +53 -2
  55. package/dist/lib/capacity/refusal.js +284 -65
  56. package/dist/lib/capacity/route.js +46 -11
  57. package/dist/lib/capacity/widget.d.ts +12 -1
  58. package/dist/lib/capacity/widget.js +91 -3
  59. package/dist/lib/daemon/resolver.d.ts +2 -0
  60. package/dist/lib/daemon/resolver.js +3 -0
  61. package/dist/lib/daemon/run.d.ts +9 -0
  62. package/dist/lib/daemon/run.js +54 -1
  63. package/dist/lib/daemon/server.d.ts +2 -0
  64. package/dist/lib/daemon/server.js +10 -1
  65. package/dist/lib/daemon/tcc-eperm.d.ts +153 -0
  66. package/dist/lib/daemon/tcc-eperm.js +310 -0
  67. package/dist/lib/delivery/admission.d.ts +86 -0
  68. package/dist/lib/delivery/admission.js +148 -0
  69. package/dist/lib/delivery/artifacts.d.ts +7 -1
  70. package/dist/lib/delivery/artifacts.js +29 -10
  71. package/dist/lib/delivery/attempt-id.d.ts +13 -0
  72. package/dist/lib/delivery/attempt-id.js +16 -0
  73. package/dist/lib/delivery/disposable-target.d.ts +42 -0
  74. package/dist/lib/delivery/disposable-target.js +111 -0
  75. package/dist/lib/delivery/effects.d.ts +136 -0
  76. package/dist/lib/delivery/effects.js +541 -0
  77. package/dist/lib/delivery/enrollment.d.ts +21 -17
  78. package/dist/lib/delivery/enrollment.js +83 -5
  79. package/dist/lib/delivery/escalations.d.ts +51 -0
  80. package/dist/lib/delivery/escalations.js +60 -0
  81. package/dist/lib/delivery/lease.d.ts +80 -0
  82. package/dist/lib/delivery/lease.js +134 -0
  83. package/dist/lib/delivery/migrations.d.ts +120 -4
  84. package/dist/lib/delivery/migrations.js +215 -15
  85. package/dist/lib/delivery/mqtt.d.ts +2 -0
  86. package/dist/lib/delivery/mqtt.js +7 -0
  87. package/dist/lib/delivery/reconciler.d.ts +65 -1
  88. package/dist/lib/delivery/reconciler.js +224 -13
  89. package/dist/lib/delivery/rpc/client.d.ts +22 -0
  90. package/dist/lib/delivery/rpc/client.js +159 -0
  91. package/dist/lib/delivery/rpc/port.d.ts +40 -0
  92. package/dist/lib/delivery/rpc/port.js +16 -0
  93. package/dist/lib/delivery/rpc/server.d.ts +30 -0
  94. package/dist/lib/delivery/rpc/server.js +205 -0
  95. package/dist/lib/delivery/rpc/wire.d.ts +85 -0
  96. package/dist/lib/delivery/rpc/wire.js +143 -0
  97. package/dist/lib/delivery/store.d.ts +2 -0
  98. package/dist/lib/delivery/store.js +4 -0
  99. package/dist/lib/delivery/windows-service-install.d.ts +262 -0
  100. package/dist/lib/delivery/windows-service-install.js +892 -0
  101. package/dist/lib/delivery/workers/macos.d.ts +16 -1
  102. package/dist/lib/delivery/workers/macos.js +54 -12
  103. package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
  104. package/dist/lib/delivery/workers/windows-service-live.js +711 -0
  105. package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
  106. package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
  107. package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
  108. package/dist/lib/delivery/workers/windows-service.js +584 -0
  109. package/dist/lib/delivery/workers/windows.d.ts +32 -22
  110. package/dist/lib/delivery/workers/windows.js +50 -64
  111. package/dist/lib/hot-channels/adapters/meetings.d.ts +15 -0
  112. package/dist/lib/hot-channels/adapters/meetings.js +36 -3
  113. package/dist/lib/hot-channels/signals-pass.d.ts +10 -0
  114. package/dist/lib/hot-channels/signals-pass.js +71 -2
  115. package/dist/lib/hot-channels/signals-redo.js +10 -2
  116. package/dist/lib/lanes/watcher.js +35 -0
  117. package/dist/lib/signals/steps/extract.js +40 -4
  118. package/dist/schemas/hq-available-ai.v1.schema.json +76 -0
  119. package/dist/utils/catalog-runtime-paths.d.ts +34 -0
  120. package/dist/utils/catalog-runtime-paths.js +53 -0
  121. package/dist/utils/files-browse-acl.js +1 -1
  122. package/package.json +7 -7
  123. package/dist/lib/delivery/workers/windows-boundary.d.ts +0 -453
  124. package/dist/lib/delivery/workers/windows-boundary.js +0 -693
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Attempt ids as path segments (US-011 slice 4 B).
3
+ *
4
+ * A worker uses the attempt id as a directory name, and since slice 4 B a
5
+ * worker may choose the id it claims with. Every id that is chosen by a
6
+ * worker, stored for one, or answered to one must therefore be a safe name:
7
+ * 1 to 128 letters, digits, dot, underscore or dash, starting with a letter
8
+ * or digit, and without "..".
9
+ */
10
+ /** The longest id a worker may choose; the stored id adds a 14-character worker scope. */
11
+ export declare const MAX_CHOSEN_ATTEMPT_ID = 100;
12
+ export declare function isSafeAttemptId(id: unknown): id is string;
13
+ //# sourceMappingURL=attempt-id.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Attempt ids as path segments (US-011 slice 4 B).
3
+ *
4
+ * A worker uses the attempt id as a directory name, and since slice 4 B a
5
+ * worker may choose the id it claims with. Every id that is chosen by a
6
+ * worker, stored for one, or answered to one must therefore be a safe name:
7
+ * 1 to 128 letters, digits, dot, underscore or dash, starting with a letter
8
+ * or digit, and without "..".
9
+ */
10
+ const SAFE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
11
+ /** The longest id a worker may choose; the stored id adds a 14-character worker scope. */
12
+ export const MAX_CHOSEN_ATTEMPT_ID = 100;
13
+ export function isSafeAttemptId(id) {
14
+ return typeof id === "string" && SAFE.test(id) && !id.includes("..");
15
+ }
16
+ //# sourceMappingURL=attempt-id.js.map
@@ -0,0 +1,42 @@
1
+ export interface ApplyRequest {
2
+ deploymentId: string;
3
+ tenantId: string;
4
+ environment: string;
5
+ fence: number;
6
+ digest: string;
7
+ bytes: Buffer;
8
+ }
9
+ export type ApplyOutcome = {
10
+ kind: "applied";
11
+ fence: number;
12
+ digest: string;
13
+ } | {
14
+ kind: "rejected";
15
+ detail: string;
16
+ } | {
17
+ kind: "unknown";
18
+ detail: string;
19
+ };
20
+ export type Observation = {
21
+ kind: "applied";
22
+ fence: number;
23
+ digest: string;
24
+ } | {
25
+ kind: "absent";
26
+ floor: number;
27
+ };
28
+ export interface DeploymentTarget {
29
+ readonly targetId: string;
30
+ apply(req: ApplyRequest, timeoutMs: number): Promise<ApplyOutcome>;
31
+ observe(req: {
32
+ deploymentId: string;
33
+ tenantId: string;
34
+ environment: string;
35
+ fence: number;
36
+ }, timeoutMs: number): Promise<Observation>;
37
+ }
38
+ export declare function disposableTarget(opts: {
39
+ targetId: string;
40
+ baseUrl: string;
41
+ }): DeploymentTarget;
42
+ //# sourceMappingURL=disposable-target.d.ts.map
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Deployment target client (US-009).
3
+ *
4
+ * A DeploymentTarget applies one artifact to one tenant/environment under a
5
+ * fence, and answers what it actually applied. The target, not the deployer,
6
+ * is the last check on a stale effect: it refuses any fence at or below the
7
+ * highest it has seen for that environment.
8
+ *
9
+ * apply() returns one of three outcomes and never guesses:
10
+ * - applied: the target answered with the fence and digest it applied.
11
+ * - rejected: the target refused (stale fence, digest mismatch); nothing was applied.
12
+ * - unknown: no answer (timeout, dropped connection, crash). The effect may
13
+ * or may not have happened; the caller must reconcile before any retry.
14
+ *
15
+ * observe() is the reconcile query. It first raises the environment's fence
16
+ * floor to the given fence, so a request still in transit with that fence or
17
+ * lower cannot land after the answer, then reports whether the deployment was
18
+ * applied. If the target cannot be reached it throws TARGET_UNREACHABLE and
19
+ * the caller keeps the outcome unknown.
20
+ *
21
+ * disposableTarget() talks HTTP to the disposable app of the delivery
22
+ * harness and only to a loopback address: this story deploys to disposable
23
+ * local targets only.
24
+ */
25
+ import { DeliveryStoreError } from "./migrations.js";
26
+ const LOOPBACK = new Set(["127.0.0.1", "[::1]", "localhost"]);
27
+ function describe(err) {
28
+ if (err instanceof Error) {
29
+ const cause = err.cause;
30
+ const c = cause instanceof Error ? `: ${cause.message}` : "";
31
+ return `${err.name}: ${err.message}${c}`;
32
+ }
33
+ return String(err);
34
+ }
35
+ export function disposableTarget(opts) {
36
+ const url = new URL(opts.baseUrl);
37
+ if (url.protocol !== "http:" || !LOOPBACK.has(url.hostname)) {
38
+ throw new DeliveryStoreError("INVALID_RECORD", {
39
+ found: `deployment target ${opts.baseUrl}`,
40
+ expected: "an http loopback address of a disposable target",
41
+ action: "Deploy only to a disposable local target. Nothing was sent.",
42
+ });
43
+ }
44
+ const base = url.origin;
45
+ return {
46
+ targetId: opts.targetId,
47
+ async apply(req, timeoutMs) {
48
+ let res;
49
+ let body;
50
+ try {
51
+ res = await fetch(`${base}/deploy`, {
52
+ method: "POST",
53
+ headers: { "content-type": "application/json" },
54
+ body: JSON.stringify({
55
+ deploymentId: req.deploymentId,
56
+ tenantId: req.tenantId,
57
+ environment: req.environment,
58
+ fence: req.fence,
59
+ digest: req.digest,
60
+ bytes: req.bytes.toString("base64"),
61
+ }),
62
+ signal: AbortSignal.timeout(timeoutMs),
63
+ });
64
+ body = (await res.json());
65
+ }
66
+ catch (err) {
67
+ return { kind: "unknown", detail: `no answer from ${opts.targetId} (${describe(err)})` };
68
+ }
69
+ if (res.status === 200 && body.applied === true) {
70
+ if (body.fence !== req.fence || body.digest !== req.digest || body.deploymentId !== req.deploymentId) {
71
+ return { kind: "unknown", detail: `target answered for another effect: ${JSON.stringify(body)}` };
72
+ }
73
+ return { kind: "applied", fence: req.fence, digest: req.digest };
74
+ }
75
+ if (res.status === 409 || res.status === 400)
76
+ return { kind: "rejected", detail: `target refused (${res.status}): ${JSON.stringify(body)}` };
77
+ return { kind: "unknown", detail: `unexpected target answer ${res.status}: ${JSON.stringify(body)}` };
78
+ },
79
+ async observe(req, timeoutMs) {
80
+ let res;
81
+ let body;
82
+ try {
83
+ res = await fetch(`${base}/deploy/reconcile`, {
84
+ method: "POST",
85
+ headers: { "content-type": "application/json" },
86
+ body: JSON.stringify(req),
87
+ signal: AbortSignal.timeout(timeoutMs),
88
+ });
89
+ body = (await res.json());
90
+ }
91
+ catch (err) {
92
+ throw unreachable(opts.targetId, describe(err));
93
+ }
94
+ if (res.status === 200 && body.state === "applied" && typeof body.fence === "number" && typeof body.digest === "string") {
95
+ return { kind: "applied", fence: body.fence, digest: body.digest };
96
+ }
97
+ if (res.status === 200 && body.state === "absent" && typeof body.floor === "number" && body.floor >= req.fence) {
98
+ return { kind: "absent", floor: body.floor };
99
+ }
100
+ throw unreachable(opts.targetId, `unexpected answer ${res.status}: ${JSON.stringify(body)}`);
101
+ },
102
+ };
103
+ }
104
+ function unreachable(targetId, detail) {
105
+ return new DeliveryStoreError("TARGET_UNREACHABLE", {
106
+ found: `target ${targetId} could not be queried (${detail})`,
107
+ expected: "the target's answer on whether the deployment was applied",
108
+ action: "The outcome stays unknown and no retry is allowed. Bring the target back and reconcile again.",
109
+ });
110
+ }
111
+ //# sourceMappingURL=disposable-target.js.map
@@ -0,0 +1,136 @@
1
+ import { type DeployPolicy, type DeployRequest } from "./admission.js";
2
+ import type { ArtifactStore } from "./artifacts.js";
3
+ import type { CredentialSource } from "./credentials.js";
4
+ import type { ApplyOutcome, DeploymentTarget } from "./disposable-target.js";
5
+ import type { AdminScope, DeliveryAccess } from "./enrollment.js";
6
+ import { type WorkerIdentity } from "./identity.js";
7
+ import { type DeploymentDecision, type DeploymentObservation, type DeploymentSnapshot, type DeploymentStatus, type StoredDeployPolicy } from "./migrations.js";
8
+ export interface DeploymentManagerOptions {
9
+ access: DeliveryAccess;
10
+ artifacts: ArtifactStore;
11
+ target: DeploymentTarget;
12
+ /** Bound on each target call, in ms. Default 5000. */
13
+ timeoutMs?: number;
14
+ /**
15
+ * Longest an in-flight deployment may hold its environment, in ms from requestedAt. Past it
16
+ * the deployment is lease-lost (unknown) and must be reconciled. Must exceed timeoutMs.
17
+ * Default: env HQ_DELIVERY_DEPLOY_MAX_HOLD_MS, else DEFAULT_DEPLOY_MAX_HOLD_MS (15 minutes).
18
+ */
19
+ maxHoldMs?: number;
20
+ ids?: () => string;
21
+ /** Provenance signing key (the US-008 key ref): signs stored policies and deployment snapshots. */
22
+ signing: {
23
+ ref: string;
24
+ source: CredentialSource;
25
+ };
26
+ /**
27
+ * Company admin credentials for setPolicy: the credential at refPrefix + "/" + tenantId
28
+ * authenticates an admin of that company. Workers never hold it.
29
+ */
30
+ policyAdmin: {
31
+ refPrefix: string;
32
+ source: CredentialSource;
33
+ };
34
+ }
35
+ /** What a worker holds between request and publish. */
36
+ export interface DeploymentTicket {
37
+ deploymentId: string;
38
+ tenantId: string;
39
+ environment: string;
40
+ fence: number;
41
+ digest: string;
42
+ attemptId: string;
43
+ workerId: string;
44
+ /** Controller epoch that issued the fence. */
45
+ epoch: number;
46
+ targetId: string;
47
+ /** Verified artifact bytes from ArtifactStore.read(). */
48
+ bytes: Buffer;
49
+ }
50
+ export interface DeploymentView {
51
+ deploymentId: string;
52
+ tenantId: string;
53
+ environment: string;
54
+ artifactId: string;
55
+ digest: string;
56
+ workerId: string;
57
+ attemptId: string;
58
+ targetId: string | null;
59
+ fence: number | null;
60
+ /** An in-flight deployment from an earlier controller epoch, or whose worker lost its attempt, shows as unknown. */
61
+ status: DeploymentStatus;
62
+ snapshot: DeploymentSnapshot;
63
+ snapshotDigest: string;
64
+ /** True when snapshotSignature verifies with the signing key. */
65
+ snapshotVerified: boolean;
66
+ decision: DeploymentDecision | null;
67
+ observation: DeploymentObservation | null;
68
+ requestedAt: string;
69
+ requestedEpoch: number;
70
+ resolvedAt: string | null;
71
+ }
72
+ /** Default max hold of an in-flight deployment: 15 minutes, well above the request-perform-publish time of a live worker. */
73
+ export declare const DEFAULT_DEPLOY_MAX_HOLD_MS: number;
74
+ /** Environment variable that overrides the default max hold, in whole ms. */
75
+ export declare const DEPLOY_MAX_HOLD_ENV = "HQ_DELIVERY_DEPLOY_MAX_HOLD_MS";
76
+ export declare function openDeploymentManager(opts: DeploymentManagerOptions): DeploymentManager;
77
+ export declare class DeploymentManager {
78
+ private readonly access;
79
+ private readonly artifacts;
80
+ private readonly target;
81
+ private readonly timeoutMs;
82
+ /** Longest an in-flight deployment holds its environment, in ms from requestedAt. */
83
+ readonly maxHoldMs: number;
84
+ private readonly ids;
85
+ private readonly signing;
86
+ private readonly policyAdmin;
87
+ constructor(opts: DeploymentManagerOptions);
88
+ /**
89
+ * Admit a deployment and issue its fence. Throws DEPLOY_BLOCKED after
90
+ * recording the decision, ENV_BUSY or DEPLOY_OUTCOME_UNKNOWN when the
91
+ * environment has an open deployment, INVALID_RECORD for a malformed request.
92
+ */
93
+ request(identity: WorkerIdentity, raw: DeployRequest): DeploymentTicket;
94
+ /** Send the fenced effect to the target. Worker side: writes nothing to the store. */
95
+ perform(ticket: DeploymentTicket): Promise<ApplyOutcome>;
96
+ /**
97
+ * Record the outcome of a performed effect. Refuses a stale publisher
98
+ * (STALE_PUBLICATION) and then leaves the deployment unknown.
99
+ */
100
+ publish(identity: WorkerIdentity, ticket: DeploymentTicket, outcome: ApplyOutcome): DeploymentView;
101
+ /** request, perform and publish. Returns the recorded outcome; unknown means reconcile next. */
102
+ deploy(identity: WorkerIdentity, req: DeployRequest): Promise<DeploymentView>;
103
+ /**
104
+ * Resolve an unknown deployment from the target's actual state. The target
105
+ * raises its fence floor to this deployment's fence before answering.
106
+ * Throws TARGET_UNREACHABLE (the outcome stays unknown) if it cannot ask.
107
+ */
108
+ reconcile(scope: AdminScope, deploymentId: string): Promise<DeploymentView>;
109
+ /** Deployments and decisions of the companies in scope, oldest first. */
110
+ deployments(scope: AdminScope): DeploymentView[];
111
+ private record;
112
+ private view;
113
+ /**
114
+ * Set a company's deploy policy. The caller must present that company's
115
+ * admin credential (the value at policyAdmin.refPrefix/<tenantId> in the
116
+ * credential source); the scope alone is not trusted. The version must
117
+ * increase. The stored record is signed with the provenance signing key.
118
+ */
119
+ setPolicy(admin: {
120
+ scope: AdminScope;
121
+ token: string;
122
+ }, policy: DeployPolicy): StoredDeployPolicy;
123
+ /** The stored policy of a company in scope (the first in scope by default), or null. */
124
+ policy(scope: AdminScope, tenantId?: string): (StoredDeployPolicy & {
125
+ policy: DeployPolicy;
126
+ verified: boolean;
127
+ }) | null;
128
+ private key;
129
+ private sign;
130
+ private verifies;
131
+ private policyVerifies;
132
+ private toView;
133
+ /** True while the worker that requested `d` still holds its deploy attempt in the current epoch. */
134
+ private held;
135
+ }
136
+ //# sourceMappingURL=effects.d.ts.map