@hue-run/sdk 0.3.2 → 0.4.1
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/CLI.md +270 -47
- package/ENVIRONMENTS.md +10 -0
- package/README.md +19 -3
- package/dist/client.d.ts +5 -5
- package/dist/client.js +13 -6
- package/dist/environment/tools.d.ts +6 -1
- package/dist/environment/tools.js +7 -1
- package/dist/environment/types.d.ts +6 -1
- package/dist/receipt.js +36 -8
- package/dist/setup/application.d.ts +74 -0
- package/dist/setup/application.js +766 -0
- package/dist/setup/backend.d.ts +229 -0
- package/dist/setup/backend.js +855 -0
- package/dist/setup/checkpoint.js +100 -30
- package/dist/setup/cli.js +20 -4
- package/dist/setup/configure.d.ts +13 -0
- package/dist/setup/configure.js +454 -0
- package/dist/setup/credential.d.ts +2 -0
- package/dist/setup/credential.js +9 -0
- package/dist/setup/detect.js +4 -1
- package/dist/setup/installation.d.ts +118 -0
- package/dist/setup/installation.js +605 -0
- package/dist/setup/lock.d.ts +2 -0
- package/dist/setup/lock.js +38 -0
- package/dist/setup/machine.d.ts +1 -10
- package/dist/setup/machine.js +8 -7
- package/dist/setup/render.d.ts +3 -1
- package/dist/setup/render.js +209 -6
- package/dist/setup/runner.d.ts +26 -76
- package/dist/setup/runner.js +320 -45
- package/dist/setup/socket.d.ts +7 -0
- package/dist/setup/socket.js +144 -0
- package/dist/setup/source.d.ts +9 -0
- package/dist/setup/source.js +269 -0
- package/dist/setup/types.d.ts +16 -9
- package/dist/setup/types.js +1 -1
- package/dist/setup.d.ts +6 -2
- package/dist/setup.js +3 -0
- package/dist/types.d.ts +24 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/setup-events.schema.json +16 -9
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import type { TraceReceipt } from "../types.js";
|
|
2
|
+
import { type SetupFileChange } from "./configure.js";
|
|
3
|
+
import { type SetupCommandRunner } from "./application.js";
|
|
4
|
+
import type { SetupProjectDetection } from "./types.js";
|
|
5
|
+
import { FileSetupInstallationStore, type SetupInstallationRecord, type SetupStoredCredential } from "./installation.js";
|
|
6
|
+
/** Read-only public setup availability and fixed anonymous bounds. */
|
|
7
|
+
export interface SetupPreflightStatus {
|
|
8
|
+
/** Frozen HTTP protocol version, independent of public event version. */
|
|
9
|
+
protocolVersion: 1;
|
|
10
|
+
/** Whether anonymous provisioning is currently enabled. */
|
|
11
|
+
state: "available" | "inactive";
|
|
12
|
+
/** Server-enforced metadata projection for all setup keys. */
|
|
13
|
+
capturePolicy: "metadata-only-v1";
|
|
14
|
+
/** Lifetime anonymous storage bounds. */
|
|
15
|
+
limits: {
|
|
16
|
+
/** Maximum stored traces. */
|
|
17
|
+
traces: 100;
|
|
18
|
+
/** Maximum stored spans. */
|
|
19
|
+
spans: 1000;
|
|
20
|
+
/** Maximum sanitized stored bytes. */
|
|
21
|
+
bytes: 2097152;
|
|
22
|
+
};
|
|
23
|
+
/** Fixed anonymous write and retention windows. */
|
|
24
|
+
lifetime: {
|
|
25
|
+
/** Ingestion expires one day after provisioning. */
|
|
26
|
+
expiresAfterSeconds: 86400;
|
|
27
|
+
/** Unclaimed data is purged eight days after provisioning. */
|
|
28
|
+
purgeAfterSeconds: 691200;
|
|
29
|
+
};
|
|
30
|
+
/** Published disclosure, not an executable acceptance gate. */
|
|
31
|
+
privacyNotice: {
|
|
32
|
+
/** Canonical public privacy page. */
|
|
33
|
+
url: "https://hue.run/privacy";
|
|
34
|
+
/** Published notice effective date. */
|
|
35
|
+
effectiveDate: "2026-08-24";
|
|
36
|
+
};
|
|
37
|
+
/** Canonical public security information. */
|
|
38
|
+
securityUrl: "https://trust.hue.run/";
|
|
39
|
+
}
|
|
40
|
+
/** Non-secret descriptor for the current one-time browser handoff. */
|
|
41
|
+
export interface SetupClaimHandoff {
|
|
42
|
+
/** Persisted lowercase UUIDv4; not the bearer capability. */
|
|
43
|
+
id: string;
|
|
44
|
+
/** One-time handoff lifecycle state. */
|
|
45
|
+
state: "pending" | "consumed" | "expired" | "revoked";
|
|
46
|
+
/** Original fixed handoff deadline. */
|
|
47
|
+
expiresAt: string;
|
|
48
|
+
/** Distinct browser session deadline after successful exchange. */
|
|
49
|
+
sessionExpiresAt: string | null;
|
|
50
|
+
}
|
|
51
|
+
/** Strictly validated Setup HTTP protocol v1 installation status. */
|
|
52
|
+
export interface SetupInstallationStatus {
|
|
53
|
+
/** Setup protocol version. */
|
|
54
|
+
protocolVersion: 1;
|
|
55
|
+
/** Project/origin-scoped lowercase UUIDv4. */
|
|
56
|
+
installationId: string;
|
|
57
|
+
/** Server lifecycle state; expired and purged are terminal. */
|
|
58
|
+
state: "active" | "claimed" | "expired" | "purged";
|
|
59
|
+
/** Isolated trial project, or null only when the protocol permits no project. */
|
|
60
|
+
project: {
|
|
61
|
+
/** Project identifier retained across account claim. */
|
|
62
|
+
id: string;
|
|
63
|
+
/** Organization currently owning the project. */
|
|
64
|
+
organizationId: string;
|
|
65
|
+
} | null;
|
|
66
|
+
/** Current anonymous or post-claim credential generation. */
|
|
67
|
+
credentialVersion: 0 | 1;
|
|
68
|
+
/** Server-enforced setup telemetry policy. */
|
|
69
|
+
capturePolicy: "metadata-only-v1";
|
|
70
|
+
/** Trial expiry timestamp, or null after claim. */
|
|
71
|
+
expiresAt: string | null;
|
|
72
|
+
/** Fixed anonymous lifetime limits. */
|
|
73
|
+
limits: {
|
|
74
|
+
/** Maximum anonymous traces. */
|
|
75
|
+
traces: 100;
|
|
76
|
+
/** Maximum anonymous spans. */
|
|
77
|
+
spans: 1000;
|
|
78
|
+
/** Maximum anonymous canonical stored bytes. */
|
|
79
|
+
bytes: 2097152;
|
|
80
|
+
};
|
|
81
|
+
/** Anonymous lifetime usage counters. */
|
|
82
|
+
usage: {
|
|
83
|
+
/** Accepted trace count. */
|
|
84
|
+
traces: number;
|
|
85
|
+
/** Accepted span count. */
|
|
86
|
+
spans: number;
|
|
87
|
+
/** Accepted canonical stored bytes. */
|
|
88
|
+
bytes: number;
|
|
89
|
+
};
|
|
90
|
+
/** Non-secret current one-time browser handoff descriptor. */
|
|
91
|
+
claimHandoff: SetupClaimHandoff | null;
|
|
92
|
+
/** Same-origin telemetry and receipt routes fixed by protocol v1. */
|
|
93
|
+
endpoints: {
|
|
94
|
+
/** Relative OTLP/HTTP traces route. */
|
|
95
|
+
otlp: "/api/v1/otlp/v1/traces";
|
|
96
|
+
/** Relative exact-receipt route template. */
|
|
97
|
+
receipt: "/api/v1/setup/traces/{traceId}/receipt";
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** Installation status plus one idempotently recovered telemetry credential. */
|
|
101
|
+
export interface SetupCredentialResult extends SetupInstallationStatus {
|
|
102
|
+
/** Telemetry-only credential for the requested generation. */
|
|
103
|
+
credential: SetupStoredCredential & {
|
|
104
|
+
/** Closed capability set enforced for setup-issued keys. */
|
|
105
|
+
capabilities: ["setup_telemetry_write"];
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** Exact receipt evidence for one real metadata-only setup probe. */
|
|
109
|
+
export interface SetupProbeEvidence {
|
|
110
|
+
/** External trace identifier sent by the probe. */
|
|
111
|
+
traceId: string;
|
|
112
|
+
/** External span identifier required in the receipt. */
|
|
113
|
+
spanId: string;
|
|
114
|
+
/** Validated positive receipt containing the exact identifiers. */
|
|
115
|
+
receipt: TraceReceipt;
|
|
116
|
+
}
|
|
117
|
+
/** Exact receipt evidence from a request through the repository's existing application. */
|
|
118
|
+
export interface SetupApplicationEvidence extends SetupProbeEvidence {
|
|
119
|
+
/** Closed evidence source; synthetic setup probes can never satisfy application verification. */
|
|
120
|
+
source: "existing-application-request";
|
|
121
|
+
}
|
|
122
|
+
/** @deprecated Use SetupInstallationStatus. Retained as an exported compatibility name. */
|
|
123
|
+
export type SetupBackendTrial = SetupInstallationStatus;
|
|
124
|
+
/** @deprecated Use SetupProbeEvidence. Retained as an exported compatibility name. */
|
|
125
|
+
export type SetupBackendReceipt = SetupProbeEvidence;
|
|
126
|
+
/** Non-secret account-claim state; bearer handoffs are never part of public adapter results. */
|
|
127
|
+
export type SetupBackendClaim = {
|
|
128
|
+
/** Browser owner action is still required. */
|
|
129
|
+
status: "required";
|
|
130
|
+
/** Installation identity associated with the claim. */
|
|
131
|
+
claimId: string;
|
|
132
|
+
/** Capability-free indication that the browser handoff is stored owner-only. */
|
|
133
|
+
handoff: "owner-local";
|
|
134
|
+
} | {
|
|
135
|
+
/** Browser claim and local reconciliation completed. */
|
|
136
|
+
status: "completed";
|
|
137
|
+
/** Installation identity associated with the claim. */
|
|
138
|
+
claimId: string;
|
|
139
|
+
};
|
|
140
|
+
/** Sanitized setup failure with a stable local or protocol code. */
|
|
141
|
+
export declare class SetupBackendError extends Error {
|
|
142
|
+
/** Stable local code or exact `SETUP_*` server code. */
|
|
143
|
+
readonly code: "invalid_origin" | "transport" | "invalid_response" | "unverified" | `SETUP_${string}`;
|
|
144
|
+
/** Validated HTTP status when the failure came from the server. */
|
|
145
|
+
readonly status?: number | undefined;
|
|
146
|
+
/** Bounded server-requested retry delay, when provided. */
|
|
147
|
+
readonly retryAfterMillis?: number | undefined;
|
|
148
|
+
constructor(
|
|
149
|
+
/** Stable local code or exact `SETUP_*` server code. */
|
|
150
|
+
code: "invalid_origin" | "transport" | "invalid_response" | "unverified" | `SETUP_${string}`, message: string,
|
|
151
|
+
/** Validated HTTP status when the failure came from the server. */
|
|
152
|
+
status?: number | undefined,
|
|
153
|
+
/** Bounded server-requested retry delay, when provided. */
|
|
154
|
+
retryAfterMillis?: number | undefined, options?: ErrorOptions);
|
|
155
|
+
}
|
|
156
|
+
/** Construction options for the real Setup HTTP protocol v1 adapter. */
|
|
157
|
+
export interface SetupBackendAdapterOptions {
|
|
158
|
+
/** Project directory that owns the installation identity and managed configuration. */
|
|
159
|
+
projectRoot: string;
|
|
160
|
+
/** HTTPS Hue origin, or an explicit loopback HTTP origin for isolated tests. */
|
|
161
|
+
origin?: string;
|
|
162
|
+
/** Injectable Fetch implementation used by synthetic loopback tests. */
|
|
163
|
+
fetch?: typeof globalThis.fetch;
|
|
164
|
+
/** Per-request deadline in milliseconds. */
|
|
165
|
+
requestTimeoutMillis?: number;
|
|
166
|
+
/** Total receipt polling deadline in milliseconds. */
|
|
167
|
+
receiptTimeoutMillis?: number;
|
|
168
|
+
/** Injectable owner-browser opener used only by isolated tests. */
|
|
169
|
+
openBrowser?: (localHandoffUrl: string) => Promise<void>;
|
|
170
|
+
/** Injectable fixed-argv package-manager runner used only by isolated tests. */
|
|
171
|
+
commandRunner?: SetupCommandRunner;
|
|
172
|
+
}
|
|
173
|
+
/** Real implementation of the frozen Setup HTTP protocol v1. */
|
|
174
|
+
export declare class SetupBackendAdapter {
|
|
175
|
+
/** Exact normalized Hue origin used by every request. */
|
|
176
|
+
readonly origin: string;
|
|
177
|
+
/** Project/origin-scoped owner-only installation store. */
|
|
178
|
+
readonly store: FileSetupInstallationStore;
|
|
179
|
+
private readonly fetcher;
|
|
180
|
+
private readonly requestTimeoutMillis;
|
|
181
|
+
private readonly receiptTimeoutMillis;
|
|
182
|
+
private readonly browserOpener;
|
|
183
|
+
private readonly commandRunner?;
|
|
184
|
+
private installation?;
|
|
185
|
+
private applicationPlan?;
|
|
186
|
+
private installationStatus?;
|
|
187
|
+
/** Discards cached facts after the command-wide lock has been acquired. */
|
|
188
|
+
resetLocalCache(): void;
|
|
189
|
+
constructor(options: SetupBackendAdapterOptions);
|
|
190
|
+
/** Persists installation UUID and proof before returning control to any network operation. */
|
|
191
|
+
prepare(): Promise<SetupInstallationRecord>;
|
|
192
|
+
/** Reads local state without creating files or contacting Hue. */
|
|
193
|
+
localInstallation(): Promise<SetupInstallationRecord | undefined>;
|
|
194
|
+
private readJson;
|
|
195
|
+
private publicPreflightRequest;
|
|
196
|
+
private request;
|
|
197
|
+
/** Creates once or recovers the same installation. At most two provision writes occur per invocation. */
|
|
198
|
+
provision(signal?: AbortSignal): Promise<SetupInstallationStatus>;
|
|
199
|
+
/** Reads and validates the current installation status without provisioning. */
|
|
200
|
+
status(signal?: AbortSignal): Promise<SetupInstallationStatus>;
|
|
201
|
+
/** Requests or recovers one proof-bound handoff and opens only its owner-local file URL. */
|
|
202
|
+
prepareClaimHandoff(status: SetupInstallationStatus, openBrowser: boolean, restart?: boolean, signal?: AbortSignal): Promise<{
|
|
203
|
+
/** Whether the owner-local handoff file was opened without echoing its URL. */
|
|
204
|
+
opened: boolean;
|
|
205
|
+
/** Last observed non-secret handoff state. */
|
|
206
|
+
state: SetupClaimHandoff["state"];
|
|
207
|
+
/** Whether explicit owner restart is necessary rather than browser-session resume. */
|
|
208
|
+
restartRequired: boolean;
|
|
209
|
+
}>;
|
|
210
|
+
/** Retrieves an idempotent generation and persists it before it can be used by project config. */
|
|
211
|
+
credentials(credentialVersion: 0 | 1, signal?: AbortSignal): Promise<SetupCredentialResult>;
|
|
212
|
+
/** Installs the exact Hue runtime through the one unambiguous project package manager. */
|
|
213
|
+
installRuntime(project: SetupProjectDetection): Promise<boolean>;
|
|
214
|
+
/** Writes secret-free config and an owned middleware block into the recognized application. */
|
|
215
|
+
configure(project: SetupProjectDetection): Promise<SetupFileChange[]>;
|
|
216
|
+
/** Fails before mutation on unsafe project state, then reads public technical availability. */
|
|
217
|
+
preflight(project: SetupProjectDetection, signal?: AbortSignal, checkAvailability?: boolean): Promise<SetupPreflightStatus | undefined>;
|
|
218
|
+
/** Runs one request through the recognized existing app and privately checkpoints its IDs. */
|
|
219
|
+
exerciseApplication(project: SetupProjectDetection, signal?: AbortSignal): Promise<void>;
|
|
220
|
+
private verifyStoredApplication;
|
|
221
|
+
/** Verifies only IDs emitted by the existing application request; it never creates a probe. */
|
|
222
|
+
verifyApplication(signal?: AbortSignal): Promise<SetupApplicationEvidence | undefined>;
|
|
223
|
+
private validateReceiptProject;
|
|
224
|
+
private verifyStoredProbe;
|
|
225
|
+
/** Exports one real metadata-only span, awaits flush, and verifies its exact stored IDs. */
|
|
226
|
+
verifyProbe(signal?: AbortSignal): Promise<SetupProbeEvidence | undefined>;
|
|
227
|
+
/** Confirms a superseded telemetry key cannot read the newly verified receipt. */
|
|
228
|
+
verifyRevokedCredential(oldApiKey: string, evidence: SetupProbeEvidence, signal?: AbortSignal): Promise<void>;
|
|
229
|
+
}
|