@humain/humain-code 0.8.1 → 0.8.3
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 +36 -0
- package/dist/bundle/chunks/{chunk-E7OBH44W.js → chunk-2XD7TLKB.js} +6 -6
- package/dist/bundle/chunks/{chunk-3CGMVKHA.js → chunk-3E37CJCE.js} +1 -1
- package/dist/bundle/chunks/{chunk-ROFZVEFN.js → chunk-4GB7A76U.js} +77 -72
- package/dist/bundle/chunks/{chunk-P2Y2H7SD.js → chunk-6JTCRCNF.js} +2 -2
- package/dist/bundle/chunks/{chunk-6TTMNQXI.js → chunk-7LSTTCSC.js} +145 -120
- package/dist/bundle/chunks/{chunk-QRRVZYTG.js → chunk-AW24RHGJ.js} +2 -2
- package/dist/bundle/chunks/{chunk-7X6DNT45.js → chunk-B3ZLWVDA.js} +8 -6
- package/dist/bundle/chunks/{chunk-APNPBT7Y.js → chunk-BRSLXHED.js} +1 -1
- package/dist/bundle/chunks/{chunk-KONLZKPL.js → chunk-E4VUW4RI.js} +1 -1
- package/dist/bundle/chunks/{chunk-NICPFMOP.js → chunk-JKX5EGOT.js} +1 -1
- package/dist/bundle/chunks/{chunk-D3KYOSQY.js → chunk-JSHKS7VH.js} +1 -1
- package/dist/bundle/chunks/{chunk-SXOIQWNX.js → chunk-JX6YIPNK.js} +1 -1
- package/dist/bundle/chunks/{chunk-WBSGWISD.js → chunk-M5TVWJ5T.js} +5 -4
- package/dist/bundle/chunks/{chunk-XZ7FTBXS.js → chunk-MUN4ZZZP.js} +1189 -1195
- package/dist/bundle/chunks/{chunk-CQ2CE3RB.js → chunk-QFDZEUFU.js} +2 -2
- package/dist/bundle/chunks/{chunk-DD5UT56Y.js → chunk-R2KD2HFT.js} +67 -66
- package/dist/bundle/chunks/chunk-S2US54IU.js +37 -0
- package/dist/bundle/chunks/{chunk-IMUFBWEK.js → chunk-T2ZGMEMV.js} +42 -41
- package/dist/bundle/chunks/{chunk-FQ4KS5S4.js → chunk-UZOIHLNU.js} +1 -1
- package/dist/bundle/chunks/{chunk-6YVORXTX.js → chunk-VSXVZVBE.js} +253 -232
- package/dist/bundle/chunks/{chunk-P42E6YY6.js → chunk-ZAHVC5V2.js} +206 -194
- package/dist/bundle/chunks/{chunk-DJG2WUNM.js → chunk-ZSWU5KKA.js} +1 -1
- package/dist/bundle/chunks/{compat-SRCNS6OQ.js → compat-4ILE5BEC.js} +1 -1
- package/dist/bundle/chunks/{dist-TRAK7EXI.js → dist-I6CI3CG5.js} +6 -6
- package/dist/bundle/chunks/{dist-4OMLHRJE.js → dist-NXHRL2KY.js} +1 -1
- package/dist/bundle/chunks/{easter-egg-3d-VVUF3C3X.js → easter-egg-3d-VZC5WOYV.js} +1 -1
- package/dist/bundle/chunks/{entry-SRYLSS5P.js → entry-6XDR2IDE.js} +1 -1
- package/dist/bundle/chunks/{execute-I3WGGPWL.js → execute-6MEJJF2T.js} +2 -2
- package/dist/bundle/chunks/{flow-implementer-4KO3Q4B5.js → flow-implementer-XOP4MG5X.js} +4 -4
- package/dist/bundle/chunks/{inprocess-TOBRVK4C.js → inprocess-MBKFGDM2.js} +4 -4
- package/dist/bundle/chunks/{interactive-mode-BJJKPBXD.js → interactive-mode-3322RQEH.js} +2 -2
- package/dist/bundle/chunks/{session-picker-4JQEGLDD.js → session-picker-EYKCMFQR.js} +1 -1
- package/dist/bundle/chunks/{startup-ui-AKTA4NDP.js → startup-ui-7ODOR34R.js} +2 -2
- package/dist/bundle/chunks/{trace-command-7ORDQ3JS.js → trace-command-VM7FBWPE.js} +4 -4
- package/dist/bundle/chunks/{virtual-modules-3CT5BMBA.js → virtual-modules-47MGUPYN.js} +8 -8
- package/dist/bundle/cli-runtime.js +3 -3
- package/dist/bundle/index.js +8 -8
- package/dist/bundle/rpc-entry.js +3 -3
- package/dist/coordination/adapter/delivery.d.ts +27 -0
- package/dist/coordination/adapter/delivery.d.ts.map +1 -1
- package/dist/coordination/adapter/delivery.js +164 -4
- package/dist/coordination/adapter/delivery.js.map +1 -1
- package/dist/coordination/adapter/index.d.ts.map +1 -1
- package/dist/coordination/adapter/index.js +31 -5
- package/dist/coordination/adapter/index.js.map +1 -1
- package/dist/coordination/adapter/presence.d.ts +5 -0
- package/dist/coordination/adapter/presence.d.ts.map +1 -1
- package/dist/coordination/adapter/presence.js +25 -3
- package/dist/coordination/adapter/presence.js.map +1 -1
- package/dist/coordination/adapter/question-routing.d.ts +7 -0
- package/dist/coordination/adapter/question-routing.d.ts.map +1 -0
- package/dist/coordination/adapter/question-routing.js +40 -0
- package/dist/coordination/adapter/question-routing.js.map +1 -0
- package/dist/coordination/adapter/receipts.d.ts +7 -0
- package/dist/coordination/adapter/receipts.d.ts.map +1 -1
- package/dist/coordination/adapter/receipts.js +25 -2
- package/dist/coordination/adapter/receipts.js.map +1 -1
- package/dist/coordination/adapter/tool.d.ts +19 -3
- package/dist/coordination/adapter/tool.d.ts.map +1 -1
- package/dist/coordination/adapter/tool.js +93 -19
- package/dist/coordination/adapter/tool.js.map +1 -1
- package/dist/coordination/client/client.d.ts +2 -2
- package/dist/coordination/client/client.d.ts.map +1 -1
- package/dist/coordination/client/client.js +4 -0
- package/dist/coordination/client/client.js.map +1 -1
- package/dist/coordination/transport/protocol.d.ts.map +1 -1
- package/dist/coordination/transport/protocol.js +23 -0
- package/dist/coordination/transport/protocol.js.map +1 -1
- package/dist/coordination/transport/types.d.ts +11 -1
- package/dist/coordination/transport/types.d.ts.map +1 -1
- package/dist/coordination/transport/types.js.map +1 -1
- package/dist/core/model-resolver.js +2 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +14 -8
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/oauth-account-pool.d.ts +14 -0
- package/dist/core/oauth-account-pool.d.ts.map +1 -1
- package/dist/core/oauth-account-pool.js +166 -14
- package/dist/core/oauth-account-pool.js.map +1 -1
- package/dist/core/run-outcome.d.ts +1 -1
- package/dist/core/run-outcome.d.ts.map +1 -1
- package/dist/core/run-outcome.js +2 -2
- package/dist/core/run-outcome.js.map +1 -1
- package/dist/core/run-preflight.d.ts.map +1 -1
- package/dist/core/run-preflight.js +15 -8
- package/dist/core/run-preflight.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +17 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +2 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +10 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/extensions/usage/index.js +5 -5
- package/dist/extensions/usage/index.js.map +1 -1
- package/dist/humain/gateway/client.d.ts.map +1 -1
- package/dist/humain/gateway/client.js +36 -9
- package/dist/humain/gateway/client.js.map +1 -1
- package/dist/humain/gateway/http.d.ts.map +1 -1
- package/dist/humain/gateway/http.js +26 -6
- package/dist/humain/gateway/http.js.map +1 -1
- package/dist/humain/gateway/provider.d.ts.map +1 -1
- package/dist/humain/gateway/provider.js +9 -2
- package/dist/humain/gateway/provider.js.map +1 -1
- package/dist/humain/hcode/facade.d.ts +12 -1
- package/dist/humain/hcode/facade.d.ts.map +1 -1
- package/dist/humain/hcode/facade.js +35 -8
- package/dist/humain/hcode/facade.js.map +1 -1
- package/dist/humain/hcode/login-copy.d.ts.map +1 -1
- package/dist/humain/hcode/login-copy.js +10 -0
- package/dist/humain/hcode/login-copy.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +6 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +26 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +35 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +179 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/working-indicator-engine.d.ts +32 -0
- package/dist/modes/interactive/components/working-indicator-engine.d.ts.map +1 -0
- package/dist/modes/interactive/components/working-indicator-engine.js +112 -0
- package/dist/modes/interactive/components/working-indicator-engine.js.map +1 -0
- package/dist/modes/interactive/fullscreen.d.ts +13 -0
- package/dist/modes/interactive/fullscreen.d.ts.map +1 -0
- package/dist/modes/interactive/fullscreen.js +25 -0
- package/dist/modes/interactive/fullscreen.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +4 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +117 -19
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/humain-dark.json +5 -4
- package/dist/modes/interactive/theme/humain-light.json +6 -5
- package/docs/cli.md +6 -0
- package/docs/coordination.md +16 -4
- package/docs/development.md +7 -0
- package/docs/environment-variables.md +2 -1
- package/docs/providers.md +19 -5
- package/docs/settings.md +20 -0
- package/docs/usage.md +2 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schemas/settings.schema.json +29 -0
- package/dist/bundle/chunks/chunk-UEW6TUSP.js +0 -36
- package/dist/bundle/chunks/chunk-YPZPCHNV.js +0 -3
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { detectInstallMethod, ENV_OFFLINE, getAgentDir, isBunBinary, isBundledNode, VERSION } from "../../config.js";
|
|
2
|
+
import { createTraceRedactor } from "../../core/trace/redaction.js";
|
|
3
|
+
import { sanitizeForTerminal } from "../../core/trace-client/sanitize.js";
|
|
2
4
|
import { raceWithAbortSignal } from "../../utils/abort.js";
|
|
3
5
|
import { loadMetadataInstallId, readExistingMetadataInstallId } from "../metadata/identity.js";
|
|
4
6
|
import { createMetadataOwner, createNativeMetadataCatalog } from "../metadata/index.js";
|
|
@@ -7,7 +9,7 @@ import { createHcodeAccount, verifyHcodeIssuer, } from "./account.js";
|
|
|
7
9
|
import { HcodeAccountStore, sameReference } from "./account-store.js";
|
|
8
10
|
import { parseHcodeCliConfig } from "./contracts.js";
|
|
9
11
|
import { resolveHcodeEnvironment } from "./environment.js";
|
|
10
|
-
import { hcodeJson } from "./http.js";
|
|
12
|
+
import { hcodeJson, readHcodeJson } from "./http.js";
|
|
11
13
|
import { hcodeLoginStage } from "./login-failure.js";
|
|
12
14
|
import { createHcodeProvider } from "./provider.js";
|
|
13
15
|
import { createHcodeUsage } from "./usage.js";
|
|
@@ -102,14 +104,39 @@ export function createHcodeFacade(options = {}, credential) {
|
|
|
102
104
|
let probe;
|
|
103
105
|
const verifyLogin = async (signal) => {
|
|
104
106
|
let unreachable;
|
|
105
|
-
let
|
|
107
|
+
let serverFailure;
|
|
106
108
|
const tracked = async (input, init) => {
|
|
109
|
+
serverFailure = undefined;
|
|
107
110
|
unreachable = new URL(String(input)).host;
|
|
108
111
|
const response = await fetcher(input, init);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
unreachable = undefined;
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
serverFailure = { kind: "http-error", status: response.status };
|
|
115
|
+
try {
|
|
116
|
+
// Public error bodies are untrusted: bound the read and never retain headers or the raw body.
|
|
117
|
+
const body = await readHcodeJson(new Response(response.body, { headers: response.headers }), 16_384, init?.signal ?? undefined);
|
|
118
|
+
if (typeof body === "object" && body !== null && !Array.isArray(body)) {
|
|
119
|
+
if (String(input) === `${environment.origin}/api/cli/config` &&
|
|
120
|
+
response.status === 503 &&
|
|
121
|
+
"code" in body &&
|
|
122
|
+
body.code === "hcode_unavailable") {
|
|
123
|
+
serverFailure = { kind: "not-configured", environmentId: environment.id };
|
|
124
|
+
}
|
|
125
|
+
else if ("message" in body && typeof body.message === "string") {
|
|
126
|
+
const redactor = createTraceRedactor({ env: process.env });
|
|
127
|
+
// Display normalization can reconstruct a secret, so it must precede the final redaction.
|
|
128
|
+
const message = redactor
|
|
129
|
+
.redactText(sanitizeForTerminal(redactor.redactText(body.message).text).replace(/\s+/g, " ").trim())
|
|
130
|
+
.text.slice(0, 300);
|
|
131
|
+
if (message)
|
|
132
|
+
serverFailure = { kind: "http-error", status: response.status, message };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// Missing, oversized or unreadable bodies do not erase the HTTP status.
|
|
138
|
+
}
|
|
139
|
+
}
|
|
113
140
|
return response;
|
|
114
141
|
};
|
|
115
142
|
try {
|
|
@@ -124,9 +151,9 @@ export function createHcodeFacade(options = {}, credential) {
|
|
|
124
151
|
return { kind: "ready" };
|
|
125
152
|
}
|
|
126
153
|
catch {
|
|
127
|
-
if (signal.aborted || !allowed()
|
|
154
|
+
if (signal.aborted || !allowed())
|
|
128
155
|
return { kind: "unavailable" };
|
|
129
|
-
return unreachable ? { kind: "unreachable", host: unreachable } : { kind: "mismatch" };
|
|
156
|
+
return serverFailure ?? (unreachable ? { kind: "unreachable", host: unreachable } : { kind: "mismatch" });
|
|
130
157
|
}
|
|
131
158
|
};
|
|
132
159
|
const qualified = async (signal) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.js","sourceRoot":"","sources":["../../../src/humain/hcode/facade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAyB,MAAM,sBAAsB,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC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,uEAAuE,CAAC,IAAI,CAAC,UAAU,CAAC;YAAE,OAAO,IAAI,CAAC;QAC3G,OAAO;YACN,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;YACpD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC;YAC5C,UAAU;SACV,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC","sourcesContent":["// One dormant product lifetime around the existing native account, provider, usage and metadata owners.\nimport type { Credential } from \"@earendil-works/pi-ai\";\nimport { detectInstallMethod, ENV_OFFLINE, getAgentDir, isBunBinary, isBundledNode, VERSION } from \"../../config.ts\";\nimport { raceWithAbortSignal } from \"../../utils/abort.ts\";\nimport { loadMetadataInstallId, readExistingMetadataInstallId } from \"../metadata/identity.ts\";\nimport { createMetadataOwner, createNativeMetadataCatalog, type MetadataProducer } from \"../metadata/index.ts\";\nimport { observeHcodeVersion } from \"../metadata/version.ts\";\nimport {\n\tcreateHcodeAccount,\n\ttype HcodeAccountOptions,\n\ttype HcodeAccountOwner,\n\ttype HcodeIssuerProfile,\n\tverifyHcodeIssuer,\n} from \"./account.ts\";\nimport { HcodeAccountStore, sameReference } from \"./account-store.ts\";\nimport { type HcodeCliConfig, parseHcodeCliConfig } from \"./contracts.ts\";\nimport { type HcodeEnvironment, type HcodeEnvironmentName, resolveHcodeEnvironment } from \"./environment.ts\";\nimport { hcodeJson } from \"./http.ts\";\nimport { hcodeLoginStage } from \"./login-failure.ts\";\nimport type { HcodeAccountPort, HcodeAccountRef, HcodeUsagePort } from \"./ports.ts\";\nimport { createHcodeProvider, type HcodeProvider } from \"./provider.ts\";\nimport { createHcodeUsage } from \"./usage.ts\";\nimport * as wire from \"./wire.ts\";\n\nexport interface HcodeSupportSnapshot {\n\tenvironmentId: string;\n\taccountId?: string;\n\tgeneration?: string;\n\tinstallId?: string;\n}\n\n/** Whether `/login` can start a HUMAIN Code sign-in, and in plain terms why not. */\nexport type HcodeLoginReadiness =\n\t| { kind: \"ready\" }\n\t/** A request never got a non-5xx answer: DNS, connect, TLS, timeout or server error. */\n\t| { kind: \"unreachable\"; host: string }\n\t/** The server answered, but its sign-in settings don't match what this CLI accepts. */\n\t| { kind: \"mismatch\" }\n\t/** Offline, shutting down or cancelled. */\n\t| { kind: \"unavailable\" };\n\n/** Token-free account/usage access, independent of the selected model. */\nexport interface HcodeContext {\n\treadonly account: HcodeAccountPort;\n\treadonly usage: HcodeUsagePort;\n\treadonly environment: HcodeEnvironment;\n\treadonly environmentId: string;\n}\n\n/** Trusted host dependencies only; never populated from project settings, profiles or environment endpoints. */\nexport interface HcodeFacadeOptions extends HcodeAccountOptions {\n\tagentDir?: string;\n\tnetworkAllowed?: () => boolean;\n}\n\n/** The constructing ModelRuntime owns disposal; extension contexts receive only context. */\nexport interface HcodeFacade {\n\treadonly context: HcodeContext;\n\treadonly provider: HcodeProvider;\n\treadonly signal: AbortSignal;\n\treadonly metadata: MetadataProducer;\n\tobserveVersion(version: string): void;\n\tsupportSnapshot(signal: AbortSignal): Promise<HcodeSupportSnapshot>;\n\t/** Verify `/api/cli/config` and issuer discovery; callers share one check and a ready result for 5 minutes. */\n\tprobeLogin(signal: AbortSignal): Promise<HcodeLoginReadiness>;\n\t/** Email the server reported when this account signed in during this process, if any. */\n\taccountEmail(expected: HcodeAccountRef): string | undefined;\n\t/** Resolve existing replacement evidence without activating discovery or a signed-out keyring. */\n\trecover(signal: AbortSignal): Promise<void>;\n\tpersistence(expected: HcodeAccountRef): \"persistent\" | \"session\" | undefined;\n\t/** Adopts the reference another process saved or removed in generic storage; returns whether it changed. */\n\tadopt(credential: Credential | undefined): boolean;\n\t/** Other built-in environments with a saved sign-in, from local metadata only. */\n\tsignedInElsewhere(): HcodeEnvironmentName[];\n\t/** Includes host generic-reference publication in the persistent replacement commit. */\n\tlogin: HcodeAccountOwner[\"login\"];\n\t/** Remove only the observed saved binding, even before its first private action or while offline. */\n\tlogoutStored(credential: Credential | undefined, signal: AbortSignal): Promise<void>;\n\tshutdown(signal: AbortSignal): Promise<{ remoteRevocation: \"confirmed\" | \"unconfirmed\" | \"not-needed\" }>;\n\tdispose(): void;\n}\n\nconst HCODE_LOGIN_READY_CACHE_MS = 5 * 60_000;\n\n/** One shared sign-in check and the time it became ready, if it did. */\ninterface LoginProbe {\n\tresult: Promise<HcodeLoginReadiness>;\n\tcontroller: AbortController;\n\twaiters: number;\n\treadyAt?: number;\n}\n\n/** Construct once without discovery, keyring access, account refresh, balance reads or metadata identity I/O. */\nexport function createHcodeFacade(options: HcodeFacadeOptions = {}, credential?: Credential): HcodeFacade {\n\tconst environment = resolveHcodeEnvironment(options.environment);\n\tconst lifetime = new AbortController();\n\tconst listeners = new Set<(reference: HcodeAccountRef | null) => void>();\n\tconst notify = (next: HcodeAccountRef | null) => {\n\t\tfor (const listener of listeners) {\n\t\t\ttry {\n\t\t\t\tlistener(next);\n\t\t\t} catch {\n\t\t\t\t// An observer cannot suppress another consumer's generation fence.\n\t\t\t}\n\t\t}\n\t};\n\tlet reference = referenceFromCredential(credential);\n\tlet sessionReference: HcodeAccountRef | null = null;\n\t// Invalid generic storage must not become a signed-out metadata identity.\n\tlet invalidReference = credential !== undefined && reference === null;\n\tlet config: HcodeCliConfig | undefined;\n\tlet activated = options.profile !== undefined;\n\tlet shuttingDown = false;\n\tlet shutdown: Promise<{ remoteRevocation: \"confirmed\" | \"unconfirmed\" | \"not-needed\" }> | undefined;\n\tconst allowed = () =>\n\t\t!lifetime.signal.aborted &&\n\t\t!process.env[ENV_OFFLINE] &&\n\t\t!process.env.PI_OFFLINE &&\n\t\t(options.networkAllowed?.() ?? true);\n\tconst assertNetwork = (signal: AbortSignal) => {\n\t\tsignal.throwIfAborted();\n\t\tif (!allowed()) {\n\t\t\tmetadata.setNetworkAllowed(false);\n\t\t\tthrow new Error(\"HUMAIN Code network access is unavailable.\");\n\t\t}\n\t};\n\tconst fetcher: typeof fetch = (input, init = {}) => {\n\t\tconst signal = AbortSignal.any([lifetime.signal, ...(init.signal ? [init.signal] : [])]);\n\t\tassertNetwork(signal);\n\t\treturn (options.fetch ?? globalThis.fetch)(input, { ...init, signal });\n\t};\n\tconst owner = createHcodeAccount({\n\t\t...options,\n\t\tfetch: fetcher,\n\t});\n\tconst signalFor = (signal: AbortSignal) => AbortSignal.any([lifetime.signal, signal]);\n\t/** Fetch the environment's CLI config and check it against the built-in destinations and any pinned profile. */\n\tconst fetchConfig = async (\n\t\tsignal: AbortSignal,\n\t\tfetchFrom: typeof fetch,\n\t): Promise<{ next: HcodeCliConfig; profile: HcodeIssuerProfile }> => {\n\t\tconst next = parseHcodeCliConfig(await hcodeJson(fetchFrom, `${environment.origin}/api/cli/config`, { signal }));\n\t\tsignal.throwIfAborted();\n\t\tconst p = options.profile;\n\t\tif (\n\t\t\tnext.origin !== environment.origin ||\n\t\t\tnext.environmentId !== environment.id ||\n\t\t\tnext.inferenceBaseUrl !== environment.inferenceBaseUrl ||\n\t\t\t(p &&\n\t\t\t\tObject.entries(p).some(\n\t\t\t\t\t([key, value]) =>\n\t\t\t\t\t\tJSON.stringify(key === \"environmentId\" ? next.environmentId : Reflect.get(next.auth, key)) !==\n\t\t\t\t\t\tJSON.stringify(value),\n\t\t\t\t))\n\t\t)\n\t\t\tthrow new Error(\"HUMAIN Code issuer configuration is unavailable.\");\n\t\tconst { kind: _kind, ...auth } = next.auth;\n\t\treturn { next, profile: { ...auth, environmentId: environment.id } };\n\t};\n\tconst install = (next: HcodeCliConfig, profile: HcodeIssuerProfile) => {\n\t\towner.configureProfile(profile);\n\t\tconfig = next;\n\t\tactivated = true;\n\t};\n\tlet loadingConfig: Promise<void> | undefined;\n\tconst loadConfig = async (signal: AbortSignal): Promise<void> => {\n\t\tassertNetwork(signal);\n\t\tif (shuttingDown) throw new Error(\"HUMAIN Code account is unavailable.\");\n\t\tif (!loadingConfig) {\n\t\t\tconfig = undefined;\n\t\t\t// The bounded public config fetch belongs to the facade, not to any one caller.\n\t\t\tloadingConfig = fetchConfig(lifetime.signal, fetcher)\n\t\t\t\t.then(({ next, profile }) => {\n\t\t\t\t\tassertNetwork(lifetime.signal);\n\t\t\t\t\tif (shuttingDown) throw new Error(\"HUMAIN Code account changed.\");\n\t\t\t\t\tinstall(next, profile);\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tloadingConfig = undefined;\n\t\t\t\t});\n\t\t}\n\t\tawait raceWithAbortSignal(loadingConfig, signal);\n\t};\n\t// One shared check; it is cancelled only when every waiting caller has given up.\n\tlet probe: LoginProbe | undefined;\n\tconst verifyLogin = async (signal: AbortSignal): Promise<HcodeLoginReadiness> => {\n\t\tlet unreachable: string | undefined;\n\t\tlet configUnavailable = false;\n\t\tconst tracked: typeof fetch = async (input, init) => {\n\t\t\tunreachable = new URL(String(input)).host;\n\t\t\tconst response = await fetcher(input, init);\n\t\t\tif (response.status < 500) unreachable = undefined;\n\t\t\tconfigUnavailable =\n\t\t\t\tString(input) === `${environment.origin}/api/cli/config` && [401, 403, 404, 410].includes(response.status);\n\t\t\treturn response;\n\t\t};\n\t\ttry {\n\t\t\tconst { next, profile } = await fetchConfig(signal, tracked);\n\t\t\tawait verifyHcodeIssuer(profile, tracked, signal);\n\t\t\tassertNetwork(signal);\n\t\t\tif (shuttingDown) return { kind: \"unavailable\" };\n\t\t\t// A verified pre-warm may activate a dormant facade, but never replace an active profile.\n\t\t\tif (!activated && !loadingConfig) install(next, profile);\n\t\t\treturn { kind: \"ready\" };\n\t\t} catch {\n\t\t\tif (signal.aborted || !allowed() || configUnavailable) return { kind: \"unavailable\" };\n\t\t\treturn unreachable ? { kind: \"unreachable\", host: unreachable } : { kind: \"mismatch\" };\n\t\t}\n\t};\n\tconst qualified = async (signal: AbortSignal) => {\n\t\tif (shuttingDown) throw new Error(\"HUMAIN Code account is unavailable.\");\n\t\tif (!config) await loadConfig(signal);\n\t};\n\tconst activate = async (expected: HcodeAccountRef, signal: AbortSignal) => {\n\t\tsignal.throwIfAborted();\n\t\tif (expected.environmentId !== environment.id) throw new Error(\"HUMAIN Code account changed.\");\n\t\tawait owner.recover(signal);\n\t\tif (!sameReference(reference, expected)) throw new Error(\"HUMAIN Code account changed.\");\n\t\tif (!activated) await qualified(signal);\n\t\tsignal.throwIfAborted();\n\t};\n\tconst login: HcodeAccountOwner[\"login\"] = async (interaction, suppliedSignal, publish) => {\n\t\tconst signal = signalFor(\n\t\t\tinteraction.signal ? AbortSignal.any([suppliedSignal, interaction.signal]) : suppliedSignal,\n\t\t);\n\t\ttry {\n\t\t\tawait hcodeLoginStage(\"configuration\", signal, () => loadConfig(signal));\n\t\t\tconst result = await raceWithAbortSignal(owner.login({ ...interaction, signal }, signal, publish), signal);\n\t\t\tsignal.throwIfAborted();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\t// A failed sign-in must not keep showing a cached ready check.\n\t\t\tprobe = undefined;\n\t\t\tthrow error;\n\t\t}\n\t};\n\tconst account: HcodeAccountPort = {\n\t\tstatus(environmentId) {\n\t\t\treturn !lifetime.signal.aborted &&\n\t\t\t\tenvironmentId === environment.id &&\n\t\t\t\treference?.environmentId === environmentId &&\n\t\t\t\tsameReference(owner.status(environmentId), reference)\n\t\t\t\t? reference\n\t\t\t\t: null;\n\t\t},\n\t\tsubscribe(listener) {\n\t\t\tif (lifetime.signal.aborted) return () => {};\n\t\t\tlisteners.add(listener);\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(listener);\n\t\t\t};\n\t\t},\n\t\tlogin,\n\t\tasync logout(expected, suppliedSignal) {\n\t\t\tconst signal = signalFor(suppliedSignal);\n\t\t\tsignal.throwIfAborted();\n\t\t\t// Logout still removes local state offline; only the existing revocation transport is vetoed.\n\t\t\tconst observed = sameReference(reference, expected) || sameReference(sessionReference, expected);\n\t\t\ttry {\n\t\t\t\ttry {\n\t\t\t\t\tawait activate(expected, signal);\n\t\t\t\t} catch {\n\t\t\t\t\t// Qualification/revocation availability never prevents generation-fenced local logout.\n\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t}\n\t\t\t\treturn await raceWithAbortSignal(owner.logout(expected, signal), signal);\n\t\t\t} finally {\n\t\t\t\tif (observed && !owner.status(expected.environmentId)) {\n\t\t\t\t\tinvalidReference = false;\n\t\t\t\t\tsessionReference = null;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tasync authorizedFetch(expected, url, init) {\n\t\t\tconst signal = signalFor(init.signal ?? new AbortController().signal);\n\t\t\tassertNetwork(signal);\n\t\t\tawait activate(expected, signal);\n\t\t\tif (!sameReference(account.status(expected.environmentId), expected))\n\t\t\t\tthrow new Error(\"HUMAIN Code account changed.\");\n\t\t\tawait qualified(signal);\n\t\t\treturn raceWithAbortSignal(owner.authorizedFetch(expected, url, { ...init, signal }), signal);\n\t\t},\n\t};\n\tconst unsubscribe = owner.subscribe((next) => {\n\t\tif (lifetime.signal.aborted) return;\n\t\t// Losing an account is not consent to create a new signed-out metadata identity.\n\t\tif (next) invalidReference = false;\n\t\telse if (reference) invalidReference = true;\n\t\treference = next;\n\t\tif (next && owner.persistence(next) === \"session\") sessionReference = next;\n\t\tnotify(next);\n\t});\n\tconst metadataEnvironmentId = environment.id;\n\tconst metadata = createMetadataOwner(\n\t\t{\n\t\t\t...account,\n\t\t\tstatus(environmentId) {\n\t\t\t\tconst current = account.status(environmentId);\n\t\t\t\t// An unavailable or stale saved account is not a signed-out observation.\n\t\t\t\tif (invalidReference || (reference && !sameReference(current, reference)))\n\t\t\t\t\tthrow new Error(\"HUMAIN Code account changed.\");\n\t\t\t\treturn current;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tenvironmentId: metadataEnvironmentId,\n\t\t\torigin: environment.origin,\n\t\t\tnetworkAllowed: allowed(),\n\t\t\tcatalog: createNativeMetadataCatalog(),\n\t\t\tcommon: {\n\t\t\t\tversion: VERSION,\n\t\t\t\tplatform:\n\t\t\t\t\tprocess.platform === \"darwin\" || process.platform === \"linux\" || process.platform === \"win32\"\n\t\t\t\t\t\t? process.platform\n\t\t\t\t\t\t: \"other\",\n\t\t\t\tarch: process.arch === \"arm64\" || process.arch === \"x64\" ? process.arch : \"other\",\n\t\t\t\tdistribution:\n\t\t\t\t\tisBunBinary || isBundledNode ? \"binary\" : detectInstallMethod() === \"unknown\" ? \"other\" : \"npm\",\n\t\t\t},\n\t\t\tfetch: fetcher,\n\t\t\tinstallIdentity: (signal) => loadMetadataInstallId(metadataEnvironmentId, options.agentDir, signal),\n\t\t},\n\t);\n\tconst provider = createHcodeProvider(account, environment);\n\tconst refreshModels = provider.refreshModels!;\n\tprovider.refreshModels = async (input) => {\n\t\tif (input.allowNetwork) await owner.recover(signalFor(input.signal));\n\t\treturn refreshModels(input);\n\t};\n\tconst apiKey = provider.auth.apiKey!;\n\tconst resolve = apiKey.resolve;\n\tapiKey.resolve = async (input) => {\n\t\tconst expected = referenceFromCredential(input.credential);\n\t\tif (expected) await activate(expected, signalFor(input.signal));\n\t\treturn resolve(input);\n\t};\n\tconst reader = createHcodeUsage(account, environment);\n\tconst context: HcodeContext = {\n\t\taccount,\n\t\tusage: {\n\t\t\tasync read(expected, query, suppliedSignal) {\n\t\t\t\tconst signal = signalFor(suppliedSignal);\n\t\t\t\tif (expected.environmentId === environment.id) await owner.recover(signal);\n\t\t\t\treturn reader.read(expected, query, signal);\n\t\t\t},\n\t\t},\n\t\tenvironment,\n\t\tenvironmentId: environment.id,\n\t};\n\tconst dispose = () => {\n\t\tif (lifetime.signal.aborted) return;\n\t\tlifetime.abort();\n\t\towner.dispose();\n\t\tprovider.dispose();\n\t\tmetadata.dispose();\n\t\tunsubscribe();\n\t\tlisteners.clear();\n\t\treference = null;\n\t\tsessionReference = null;\n\t};\n\treturn {\n\t\tcontext,\n\t\tprovider,\n\t\tsignal: lifetime.signal,\n\t\tmetadata,\n\t\tobserveVersion(version) {\n\t\t\tobserveHcodeVersion(\n\t\t\t\tenvironment.origin,\n\t\t\t\tversion,\n\t\t\t\t{\n\t\t\t\t\tallowNetwork: allowed(),\n\t\t\t\t\toffline: false,\n\t\t\t\t\thumainOffline: process.env[ENV_OFFLINE],\n\t\t\t\t\tpiOffline: process.env.PI_OFFLINE,\n\t\t\t\t},\n\t\t\t\tlifetime.signal,\n\t\t\t);\n\t\t},\n\t\tasync supportSnapshot(suppliedSignal) {\n\t\t\tconst signal = signalFor(suppliedSignal);\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst current = account.status(environment.id);\n\t\t\tconst installId = await raceWithAbortSignal(\n\t\t\t\treadExistingMetadataInstallId(environment.id, options.agentDir ?? getAgentDir(), signal),\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst latest = account.status(environment.id);\n\t\t\tif (current ? !sameReference(latest, current) : latest !== null)\n\t\t\t\tthrow new Error(\"HUMAIN Code account changed.\");\n\t\t\treturn {\n\t\t\t\tenvironmentId: environment.id,\n\t\t\t\t...(current ? { accountId: current.accountId, generation: current.generation } : {}),\n\t\t\t\t...(installId ? { installId } : {}),\n\t\t\t};\n\t\t},\n\t\tasync probeLogin(suppliedSignal) {\n\t\t\tconst signal = signalFor(suppliedSignal);\n\t\t\tif (signal.aborted || !allowed()) return { kind: \"unavailable\" };\n\t\t\tif (probe?.readyAt !== undefined && Date.now() - probe.readyAt >= HCODE_LOGIN_READY_CACHE_MS)\n\t\t\t\tprobe = undefined;\n\t\t\tif (!probe) {\n\t\t\t\tconst controller = new AbortController();\n\t\t\t\tconst created: LoginProbe = {\n\t\t\t\t\tcontroller,\n\t\t\t\t\twaiters: 0,\n\t\t\t\t\tresult: verifyLogin(AbortSignal.any([lifetime.signal, controller.signal])).then((result) => {\n\t\t\t\t\t\t// Only a ready result is reused; failures are checked again on the next request.\n\t\t\t\t\t\tif (result.kind === \"ready\") created.readyAt = Date.now();\n\t\t\t\t\t\telse if (probe === created) probe = undefined;\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t\tprobe = created;\n\t\t\t}\n\t\t\tconst current = probe;\n\t\t\tcurrent.waiters++;\n\t\t\ttry {\n\t\t\t\treturn await raceWithAbortSignal(current.result, signal);\n\t\t\t} catch {\n\t\t\t\treturn { kind: \"unavailable\" };\n\t\t\t} finally {\n\t\t\t\tif (--current.waiters === 0 && current.readyAt === undefined) {\n\t\t\t\t\tcurrent.controller.abort();\n\t\t\t\t\tif (probe === current) probe = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\taccountEmail: (expected) => owner.email(expected),\n\t\trecover: (signal) => owner.recover(signalFor(signal)),\n\t\tpersistence: (expected) => owner.persistence(expected),\n\t\tadopt(credential) {\n\t\t\tconst next = referenceFromCredential(credential);\n\t\t\t// A session-only sign-in belongs to this process alone; never replace it from shared storage.\n\t\t\tif (lifetime.signal.aborted || sessionReference || (next ? sameReference(next, reference) : !reference))\n\t\t\t\treturn false;\n\t\t\tif (next && !owner.observeSavedReference(next)) return false;\n\t\t\treference = next;\n\t\t\tinvalidReference = credential !== undefined && next === null;\n\t\t\tnotify(account.status(environment.id));\n\t\t\treturn true;\n\t\t},\n\t\tsignedInElsewhere() {\n\t\t\treturn ([\"dev\", \"staging\", \"production\"] as const).filter((id) => {\n\t\t\t\tif (id === environment.id) return false;\n\t\t\t\ttry {\n\t\t\t\t\treturn new HcodeAccountStore({ agentDir: options.agentDir, environment: id }).status(id) !== null;\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tlogin,\n\t\tasync logoutStored(credential, signal) {\n\t\t\tconst expected = referenceFromCredential(credential);\n\t\t\tif (expected && expected.environmentId === environment.id) await account.logout(expected, signal);\n\t\t},\n\t\tshutdown(signal) {\n\t\t\tshutdown ??= (async () => {\n\t\t\t\tshuttingDown = true;\n\t\t\t\tprovider.dispose();\n\t\t\t\tmetadata.dispose();\n\t\t\t\tconst current = sessionReference ?? reference;\n\t\t\t\ttry {\n\t\t\t\t\tif (!current || owner.persistence(current) !== \"session\") return { remoteRevocation: \"not-needed\" };\n\t\t\t\t\tconst bounded = AbortSignal.any([signal, AbortSignal.timeout(3000)]);\n\t\t\t\t\treturn await raceWithAbortSignal(owner.logout(current, bounded), bounded);\n\t\t\t\t} catch {\n\t\t\t\t\treturn { remoteRevocation: \"unconfirmed\" };\n\t\t\t\t} finally {\n\t\t\t\t\tdispose();\n\t\t\t\t}\n\t\t\t})();\n\t\t\treturn shutdown;\n\t\t},\n\t\tdispose,\n\t};\n}\n\n/** Parses only the keyless, closed native-reference shape at the generic credential trust boundary. */\nexport function referenceFromCredential(credential: Credential | undefined): HcodeAccountRef | null {\n\tif (credential?.type !== \"api_key\" || credential.key !== undefined || !credential.env) return null;\n\ttry {\n\t\t// Generic credential storage is a trust boundary; it can carry only the frozen reference fields.\n\t\tconst env = wire.object(credential.env, [\"HCODE_ENVIRONMENT_ID\", \"HCODE_ACCOUNT_ID\", \"HCODE_GENERATION\"]);\n\t\tconst generation = wire.string(env.HCODE_GENERATION, 36);\n\t\tif (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(generation)) return null;\n\t\treturn {\n\t\t\tenvironmentId: wire.string(env.HCODE_ENVIRONMENT_ID),\n\t\t\taccountId: wire.string(env.HCODE_ACCOUNT_ID),\n\t\t\tgeneration,\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"facade.js","sourceRoot":"","sources":["../../../src/humain/hcode/facade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,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QACJ,iGAAiG;QACjG,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,sBAAsB,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC;QAC1G,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,uEAAuE,CAAC,IAAI,CAAC,UAAU,CAAC;YAAE,OAAO,IAAI,CAAC;QAC3G,OAAO;YACN,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;YACpD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC;YAC5C,UAAU;SACV,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC","sourcesContent":["// One dormant product lifetime around the existing native account, provider, usage and metadata owners.\nimport type { Credential } from \"@earendil-works/pi-ai\";\nimport { detectInstallMethod, ENV_OFFLINE, getAgentDir, isBunBinary, isBundledNode, VERSION } from \"../../config.ts\";\nimport { createTraceRedactor } from \"../../core/trace/redaction.ts\";\nimport { sanitizeForTerminal } from \"../../core/trace-client/sanitize.ts\";\nimport { raceWithAbortSignal } from \"../../utils/abort.ts\";\nimport { loadMetadataInstallId, readExistingMetadataInstallId } from \"../metadata/identity.ts\";\nimport { createMetadataOwner, createNativeMetadataCatalog, type MetadataProducer } from \"../metadata/index.ts\";\nimport { observeHcodeVersion } from \"../metadata/version.ts\";\nimport {\n\tcreateHcodeAccount,\n\ttype HcodeAccountOptions,\n\ttype HcodeAccountOwner,\n\ttype HcodeIssuerProfile,\n\tverifyHcodeIssuer,\n} from \"./account.ts\";\nimport { HcodeAccountStore, sameReference } from \"./account-store.ts\";\nimport { type HcodeCliConfig, parseHcodeCliConfig } from \"./contracts.ts\";\nimport { type HcodeEnvironment, type HcodeEnvironmentName, resolveHcodeEnvironment } from \"./environment.ts\";\nimport { hcodeJson, readHcodeJson } from \"./http.ts\";\nimport { hcodeLoginStage } from \"./login-failure.ts\";\nimport type { HcodeAccountPort, HcodeAccountRef, HcodeUsagePort } from \"./ports.ts\";\nimport { createHcodeProvider, type HcodeProvider } from \"./provider.ts\";\nimport { createHcodeUsage } from \"./usage.ts\";\nimport * as wire from \"./wire.ts\";\n\nexport interface HcodeSupportSnapshot {\n\tenvironmentId: string;\n\taccountId?: string;\n\tgeneration?: string;\n\tinstallId?: string;\n}\n\n/** Whether `/login` can start a HUMAIN Code sign-in, and in plain terms why not. */\nexport type HcodeLoginReadiness =\n\t| { kind: \"ready\" }\n\t/** No HTTP response: DNS, connect, TLS or timeout. */\n\t| { kind: \"unreachable\"; host: string }\n\t/** The selected environment answered that its HUMAIN Code profile is not configured. */\n\t| { kind: \"not-configured\"; environmentId: HcodeEnvironmentName }\n\t/** A reachable server rejected the request; only bounded, sanitized message text is retained. */\n\t| { kind: \"http-error\"; status: number; message?: string }\n\t/** The server answered, but its sign-in settings don't match what this CLI accepts. */\n\t| { kind: \"mismatch\" }\n\t/** Offline, shutting down or cancelled. */\n\t| { kind: \"unavailable\" };\n\n/** Token-free account/usage access, independent of the selected model. */\nexport interface HcodeContext {\n\treadonly account: HcodeAccountPort;\n\treadonly usage: HcodeUsagePort;\n\treadonly environment: HcodeEnvironment;\n\treadonly environmentId: string;\n}\n\n/** Trusted host dependencies only; never populated from project settings, profiles or environment endpoints. */\nexport interface HcodeFacadeOptions extends HcodeAccountOptions {\n\tagentDir?: string;\n\tnetworkAllowed?: () => boolean;\n}\n\n/** The constructing ModelRuntime owns disposal; extension contexts receive only context. */\nexport interface HcodeFacade {\n\treadonly context: HcodeContext;\n\treadonly provider: HcodeProvider;\n\treadonly signal: AbortSignal;\n\treadonly metadata: MetadataProducer;\n\tobserveVersion(version: string): void;\n\tsupportSnapshot(signal: AbortSignal): Promise<HcodeSupportSnapshot>;\n\t/** Verify `/api/cli/config` and issuer discovery; callers share one check and a ready result for 5 minutes. */\n\tprobeLogin(signal: AbortSignal): Promise<HcodeLoginReadiness>;\n\t/** Email the server reported when this account signed in during this process, if any. */\n\taccountEmail(expected: HcodeAccountRef): string | undefined;\n\t/** Resolve existing replacement evidence without activating discovery or a signed-out keyring. */\n\trecover(signal: AbortSignal): Promise<void>;\n\tpersistence(expected: HcodeAccountRef): \"persistent\" | \"session\" | undefined;\n\t/** Adopts the reference another process saved or removed in generic storage; returns whether it changed. */\n\tadopt(credential: Credential | undefined): boolean;\n\t/** Other built-in environments with a saved sign-in, from local metadata only. */\n\tsignedInElsewhere(): HcodeEnvironmentName[];\n\t/** Includes host generic-reference publication in the persistent replacement commit. */\n\tlogin: HcodeAccountOwner[\"login\"];\n\t/** Remove only the observed saved binding, even before its first private action or while offline. */\n\tlogoutStored(credential: Credential | undefined, signal: AbortSignal): Promise<void>;\n\tshutdown(signal: AbortSignal): Promise<{ remoteRevocation: \"confirmed\" | \"unconfirmed\" | \"not-needed\" }>;\n\tdispose(): void;\n}\n\nconst HCODE_LOGIN_READY_CACHE_MS = 5 * 60_000;\n\n/** One shared sign-in check and the time it became ready, if it did. */\ninterface LoginProbe {\n\tresult: Promise<HcodeLoginReadiness>;\n\tcontroller: AbortController;\n\twaiters: number;\n\treadyAt?: number;\n}\n\n/** Construct once without discovery, keyring access, account refresh, balance reads or metadata identity I/O. */\nexport function createHcodeFacade(options: HcodeFacadeOptions = {}, credential?: Credential): HcodeFacade {\n\tconst environment = resolveHcodeEnvironment(options.environment);\n\tconst lifetime = new AbortController();\n\tconst listeners = new Set<(reference: HcodeAccountRef | null) => void>();\n\tconst notify = (next: HcodeAccountRef | null) => {\n\t\tfor (const listener of listeners) {\n\t\t\ttry {\n\t\t\t\tlistener(next);\n\t\t\t} catch {\n\t\t\t\t// An observer cannot suppress another consumer's generation fence.\n\t\t\t}\n\t\t}\n\t};\n\tlet reference = referenceFromCredential(credential);\n\tlet sessionReference: HcodeAccountRef | null = null;\n\t// Invalid generic storage must not become a signed-out metadata identity.\n\tlet invalidReference = credential !== undefined && reference === null;\n\tlet config: HcodeCliConfig | undefined;\n\tlet activated = options.profile !== undefined;\n\tlet shuttingDown = false;\n\tlet shutdown: Promise<{ remoteRevocation: \"confirmed\" | \"unconfirmed\" | \"not-needed\" }> | undefined;\n\tconst allowed = () =>\n\t\t!lifetime.signal.aborted &&\n\t\t!process.env[ENV_OFFLINE] &&\n\t\t!process.env.PI_OFFLINE &&\n\t\t(options.networkAllowed?.() ?? true);\n\tconst assertNetwork = (signal: AbortSignal) => {\n\t\tsignal.throwIfAborted();\n\t\tif (!allowed()) {\n\t\t\tmetadata.setNetworkAllowed(false);\n\t\t\tthrow new Error(\"HUMAIN Code network access is unavailable.\");\n\t\t}\n\t};\n\tconst fetcher: typeof fetch = (input, init = {}) => {\n\t\tconst signal = AbortSignal.any([lifetime.signal, ...(init.signal ? [init.signal] : [])]);\n\t\tassertNetwork(signal);\n\t\treturn (options.fetch ?? globalThis.fetch)(input, { ...init, signal });\n\t};\n\tconst owner = createHcodeAccount({\n\t\t...options,\n\t\tfetch: fetcher,\n\t});\n\tconst signalFor = (signal: AbortSignal) => AbortSignal.any([lifetime.signal, signal]);\n\t/** Fetch the environment's CLI config and check it against the built-in destinations and any pinned profile. */\n\tconst fetchConfig = async (\n\t\tsignal: AbortSignal,\n\t\tfetchFrom: typeof fetch,\n\t): Promise<{ next: HcodeCliConfig; profile: HcodeIssuerProfile }> => {\n\t\tconst next = parseHcodeCliConfig(await hcodeJson(fetchFrom, `${environment.origin}/api/cli/config`, { signal }));\n\t\tsignal.throwIfAborted();\n\t\tconst p = options.profile;\n\t\tif (\n\t\t\tnext.origin !== environment.origin ||\n\t\t\tnext.environmentId !== environment.id ||\n\t\t\tnext.inferenceBaseUrl !== environment.inferenceBaseUrl ||\n\t\t\t(p &&\n\t\t\t\tObject.entries(p).some(\n\t\t\t\t\t([key, value]) =>\n\t\t\t\t\t\tJSON.stringify(key === \"environmentId\" ? next.environmentId : Reflect.get(next.auth, key)) !==\n\t\t\t\t\t\tJSON.stringify(value),\n\t\t\t\t))\n\t\t)\n\t\t\tthrow new Error(\"HUMAIN Code issuer configuration is unavailable.\");\n\t\tconst { kind: _kind, ...auth } = next.auth;\n\t\treturn { next, profile: { ...auth, environmentId: environment.id } };\n\t};\n\tconst install = (next: HcodeCliConfig, profile: HcodeIssuerProfile) => {\n\t\towner.configureProfile(profile);\n\t\tconfig = next;\n\t\tactivated = true;\n\t};\n\tlet loadingConfig: Promise<void> | undefined;\n\tconst loadConfig = async (signal: AbortSignal): Promise<void> => {\n\t\tassertNetwork(signal);\n\t\tif (shuttingDown) throw new Error(\"HUMAIN Code account is unavailable.\");\n\t\tif (!loadingConfig) {\n\t\t\tconfig = undefined;\n\t\t\t// The bounded public config fetch belongs to the facade, not to any one caller.\n\t\t\tloadingConfig = fetchConfig(lifetime.signal, fetcher)\n\t\t\t\t.then(({ next, profile }) => {\n\t\t\t\t\tassertNetwork(lifetime.signal);\n\t\t\t\t\tif (shuttingDown) throw new Error(\"HUMAIN Code account changed.\");\n\t\t\t\t\tinstall(next, profile);\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tloadingConfig = undefined;\n\t\t\t\t});\n\t\t}\n\t\tawait raceWithAbortSignal(loadingConfig, signal);\n\t};\n\t// One shared check; it is cancelled only when every waiting caller has given up.\n\tlet probe: LoginProbe | undefined;\n\tconst verifyLogin = async (signal: AbortSignal): Promise<HcodeLoginReadiness> => {\n\t\tlet unreachable: string | undefined;\n\t\tlet serverFailure: HcodeLoginReadiness | undefined;\n\t\tconst tracked: typeof fetch = async (input, init) => {\n\t\t\tserverFailure = undefined;\n\t\t\tunreachable = new URL(String(input)).host;\n\t\t\tconst response = await fetcher(input, init);\n\t\t\tunreachable = undefined;\n\t\t\tif (!response.ok) {\n\t\t\t\tserverFailure = { kind: \"http-error\", status: response.status };\n\t\t\t\ttry {\n\t\t\t\t\t// Public error bodies are untrusted: bound the read and never retain headers or the raw body.\n\t\t\t\t\tconst body = await readHcodeJson(\n\t\t\t\t\t\tnew Response(response.body, { headers: response.headers }),\n\t\t\t\t\t\t16_384,\n\t\t\t\t\t\tinit?.signal ?? undefined,\n\t\t\t\t\t);\n\t\t\t\t\tif (typeof body === \"object\" && body !== null && !Array.isArray(body)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tString(input) === `${environment.origin}/api/cli/config` &&\n\t\t\t\t\t\t\tresponse.status === 503 &&\n\t\t\t\t\t\t\t\"code\" in body &&\n\t\t\t\t\t\t\tbody.code === \"hcode_unavailable\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tserverFailure = { kind: \"not-configured\", environmentId: environment.id };\n\t\t\t\t\t\t} else if (\"message\" in body && typeof body.message === \"string\") {\n\t\t\t\t\t\t\tconst redactor = createTraceRedactor({ env: process.env });\n\t\t\t\t\t\t\t// Display normalization can reconstruct a secret, so it must precede the final redaction.\n\t\t\t\t\t\t\tconst message = redactor\n\t\t\t\t\t\t\t\t.redactText(\n\t\t\t\t\t\t\t\t\tsanitizeForTerminal(redactor.redactText(body.message).text).replace(/\\s+/g, \" \").trim(),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.text.slice(0, 300);\n\t\t\t\t\t\t\tif (message) serverFailure = { kind: \"http-error\", status: response.status, message };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Missing, oversized or unreadable bodies do not erase the HTTP status.\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn response;\n\t\t};\n\t\ttry {\n\t\t\tconst { next, profile } = await fetchConfig(signal, tracked);\n\t\t\tawait verifyHcodeIssuer(profile, tracked, signal);\n\t\t\tassertNetwork(signal);\n\t\t\tif (shuttingDown) return { kind: \"unavailable\" };\n\t\t\t// A verified pre-warm may activate a dormant facade, but never replace an active profile.\n\t\t\tif (!activated && !loadingConfig) install(next, profile);\n\t\t\treturn { kind: \"ready\" };\n\t\t} catch {\n\t\t\tif (signal.aborted || !allowed()) return { kind: \"unavailable\" };\n\t\t\treturn serverFailure ?? (unreachable ? { kind: \"unreachable\", host: unreachable } : { kind: \"mismatch\" });\n\t\t}\n\t};\n\tconst qualified = async (signal: AbortSignal) => {\n\t\tif (shuttingDown) throw new Error(\"HUMAIN Code account is unavailable.\");\n\t\tif (!config) await loadConfig(signal);\n\t};\n\tconst activate = async (expected: HcodeAccountRef, signal: AbortSignal) => {\n\t\tsignal.throwIfAborted();\n\t\tif (expected.environmentId !== environment.id) throw new Error(\"HUMAIN Code account changed.\");\n\t\tawait owner.recover(signal);\n\t\tif (!sameReference(reference, expected)) throw new Error(\"HUMAIN Code account changed.\");\n\t\tif (!activated) await qualified(signal);\n\t\tsignal.throwIfAborted();\n\t};\n\tconst login: HcodeAccountOwner[\"login\"] = async (interaction, suppliedSignal, publish) => {\n\t\tconst signal = signalFor(\n\t\t\tinteraction.signal ? AbortSignal.any([suppliedSignal, interaction.signal]) : suppliedSignal,\n\t\t);\n\t\ttry {\n\t\t\tawait hcodeLoginStage(\"configuration\", signal, () => loadConfig(signal));\n\t\t\tconst result = await raceWithAbortSignal(owner.login({ ...interaction, signal }, signal, publish), signal);\n\t\t\tsignal.throwIfAborted();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\t// A failed sign-in must not keep showing a cached ready check.\n\t\t\tprobe = undefined;\n\t\t\tthrow error;\n\t\t}\n\t};\n\tconst account: HcodeAccountPort = {\n\t\tstatus(environmentId) {\n\t\t\treturn !lifetime.signal.aborted &&\n\t\t\t\tenvironmentId === environment.id &&\n\t\t\t\treference?.environmentId === environmentId &&\n\t\t\t\tsameReference(owner.status(environmentId), reference)\n\t\t\t\t? reference\n\t\t\t\t: null;\n\t\t},\n\t\tsubscribe(listener) {\n\t\t\tif (lifetime.signal.aborted) return () => {};\n\t\t\tlisteners.add(listener);\n\t\t\treturn () => {\n\t\t\t\tlisteners.delete(listener);\n\t\t\t};\n\t\t},\n\t\tlogin,\n\t\tasync logout(expected, suppliedSignal) {\n\t\t\tconst signal = signalFor(suppliedSignal);\n\t\t\tsignal.throwIfAborted();\n\t\t\t// Logout still removes local state offline; only the existing revocation transport is vetoed.\n\t\t\tconst observed = sameReference(reference, expected) || sameReference(sessionReference, expected);\n\t\t\ttry {\n\t\t\t\ttry {\n\t\t\t\t\tawait activate(expected, signal);\n\t\t\t\t} catch {\n\t\t\t\t\t// Qualification/revocation availability never prevents generation-fenced local logout.\n\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t}\n\t\t\t\treturn await raceWithAbortSignal(owner.logout(expected, signal), signal);\n\t\t\t} finally {\n\t\t\t\tif (observed && !owner.status(expected.environmentId)) {\n\t\t\t\t\tinvalidReference = false;\n\t\t\t\t\tsessionReference = null;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tasync authorizedFetch(expected, url, init) {\n\t\t\tconst signal = signalFor(init.signal ?? new AbortController().signal);\n\t\t\tassertNetwork(signal);\n\t\t\tawait activate(expected, signal);\n\t\t\tif (!sameReference(account.status(expected.environmentId), expected))\n\t\t\t\tthrow new Error(\"HUMAIN Code account changed.\");\n\t\t\tawait qualified(signal);\n\t\t\treturn raceWithAbortSignal(owner.authorizedFetch(expected, url, { ...init, signal }), signal);\n\t\t},\n\t};\n\tconst unsubscribe = owner.subscribe((next) => {\n\t\tif (lifetime.signal.aborted) return;\n\t\t// Losing an account is not consent to create a new signed-out metadata identity.\n\t\tif (next) invalidReference = false;\n\t\telse if (reference) invalidReference = true;\n\t\treference = next;\n\t\tif (next && owner.persistence(next) === \"session\") sessionReference = next;\n\t\tnotify(next);\n\t});\n\tconst metadataEnvironmentId = environment.id;\n\tconst metadata = createMetadataOwner(\n\t\t{\n\t\t\t...account,\n\t\t\tstatus(environmentId) {\n\t\t\t\tconst current = account.status(environmentId);\n\t\t\t\t// An unavailable or stale saved account is not a signed-out observation.\n\t\t\t\tif (invalidReference || (reference && !sameReference(current, reference)))\n\t\t\t\t\tthrow new Error(\"HUMAIN Code account changed.\");\n\t\t\t\treturn current;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tenvironmentId: metadataEnvironmentId,\n\t\t\torigin: environment.origin,\n\t\t\tnetworkAllowed: allowed(),\n\t\t\tcatalog: createNativeMetadataCatalog(),\n\t\t\tcommon: {\n\t\t\t\tversion: VERSION,\n\t\t\t\tplatform:\n\t\t\t\t\tprocess.platform === \"darwin\" || process.platform === \"linux\" || process.platform === \"win32\"\n\t\t\t\t\t\t? process.platform\n\t\t\t\t\t\t: \"other\",\n\t\t\t\tarch: process.arch === \"arm64\" || process.arch === \"x64\" ? process.arch : \"other\",\n\t\t\t\tdistribution:\n\t\t\t\t\tisBunBinary || isBundledNode ? \"binary\" : detectInstallMethod() === \"unknown\" ? \"other\" : \"npm\",\n\t\t\t},\n\t\t\tfetch: fetcher,\n\t\t\tinstallIdentity: (signal) => loadMetadataInstallId(metadataEnvironmentId, options.agentDir, signal),\n\t\t},\n\t);\n\tconst provider = createHcodeProvider(account, environment);\n\tconst refreshModels = provider.refreshModels!;\n\tprovider.refreshModels = async (input) => {\n\t\tif (input.allowNetwork) await owner.recover(signalFor(input.signal));\n\t\treturn refreshModels(input);\n\t};\n\tconst apiKey = provider.auth.apiKey!;\n\tconst resolve = apiKey.resolve;\n\tapiKey.resolve = async (input) => {\n\t\tconst expected = referenceFromCredential(input.credential);\n\t\tif (expected) await activate(expected, signalFor(input.signal));\n\t\treturn resolve(input);\n\t};\n\tconst reader = createHcodeUsage(account, environment);\n\tconst context: HcodeContext = {\n\t\taccount,\n\t\tusage: {\n\t\t\tasync read(expected, query, suppliedSignal) {\n\t\t\t\tconst signal = signalFor(suppliedSignal);\n\t\t\t\tif (expected.environmentId === environment.id) await owner.recover(signal);\n\t\t\t\treturn reader.read(expected, query, signal);\n\t\t\t},\n\t\t},\n\t\tenvironment,\n\t\tenvironmentId: environment.id,\n\t};\n\tconst dispose = () => {\n\t\tif (lifetime.signal.aborted) return;\n\t\tlifetime.abort();\n\t\towner.dispose();\n\t\tprovider.dispose();\n\t\tmetadata.dispose();\n\t\tunsubscribe();\n\t\tlisteners.clear();\n\t\treference = null;\n\t\tsessionReference = null;\n\t};\n\treturn {\n\t\tcontext,\n\t\tprovider,\n\t\tsignal: lifetime.signal,\n\t\tmetadata,\n\t\tobserveVersion(version) {\n\t\t\tobserveHcodeVersion(\n\t\t\t\tenvironment.origin,\n\t\t\t\tversion,\n\t\t\t\t{\n\t\t\t\t\tallowNetwork: allowed(),\n\t\t\t\t\toffline: false,\n\t\t\t\t\thumainOffline: process.env[ENV_OFFLINE],\n\t\t\t\t\tpiOffline: process.env.PI_OFFLINE,\n\t\t\t\t},\n\t\t\t\tlifetime.signal,\n\t\t\t);\n\t\t},\n\t\tasync supportSnapshot(suppliedSignal) {\n\t\t\tconst signal = signalFor(suppliedSignal);\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst current = account.status(environment.id);\n\t\t\tconst installId = await raceWithAbortSignal(\n\t\t\t\treadExistingMetadataInstallId(environment.id, options.agentDir ?? getAgentDir(), signal),\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tsignal.throwIfAborted();\n\t\t\tconst latest = account.status(environment.id);\n\t\t\tif (current ? !sameReference(latest, current) : latest !== null)\n\t\t\t\tthrow new Error(\"HUMAIN Code account changed.\");\n\t\t\treturn {\n\t\t\t\tenvironmentId: environment.id,\n\t\t\t\t...(current ? { accountId: current.accountId, generation: current.generation } : {}),\n\t\t\t\t...(installId ? { installId } : {}),\n\t\t\t};\n\t\t},\n\t\tasync probeLogin(suppliedSignal) {\n\t\t\tconst signal = signalFor(suppliedSignal);\n\t\t\tif (signal.aborted || !allowed()) return { kind: \"unavailable\" };\n\t\t\tif (probe?.readyAt !== undefined && Date.now() - probe.readyAt >= HCODE_LOGIN_READY_CACHE_MS)\n\t\t\t\tprobe = undefined;\n\t\t\tif (!probe) {\n\t\t\t\tconst controller = new AbortController();\n\t\t\t\tconst created: LoginProbe = {\n\t\t\t\t\tcontroller,\n\t\t\t\t\twaiters: 0,\n\t\t\t\t\tresult: verifyLogin(AbortSignal.any([lifetime.signal, controller.signal])).then((result) => {\n\t\t\t\t\t\t// Only a ready result is reused; failures are checked again on the next request.\n\t\t\t\t\t\tif (result.kind === \"ready\") created.readyAt = Date.now();\n\t\t\t\t\t\telse if (probe === created) probe = undefined;\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t\tprobe = created;\n\t\t\t}\n\t\t\tconst current = probe;\n\t\t\tcurrent.waiters++;\n\t\t\ttry {\n\t\t\t\treturn await raceWithAbortSignal(current.result, signal);\n\t\t\t} catch {\n\t\t\t\treturn { kind: \"unavailable\" };\n\t\t\t} finally {\n\t\t\t\tif (--current.waiters === 0 && current.readyAt === undefined) {\n\t\t\t\t\tcurrent.controller.abort();\n\t\t\t\t\tif (probe === current) probe = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\taccountEmail: (expected) => owner.email(expected),\n\t\trecover: (signal) => owner.recover(signalFor(signal)),\n\t\tpersistence: (expected) => owner.persistence(expected),\n\t\tadopt(credential) {\n\t\t\tconst next = referenceFromCredential(credential);\n\t\t\t// A session-only sign-in belongs to this process alone; never replace it from shared storage.\n\t\t\tif (lifetime.signal.aborted || sessionReference || (next ? sameReference(next, reference) : !reference))\n\t\t\t\treturn false;\n\t\t\tif (next && !owner.observeSavedReference(next)) return false;\n\t\t\treference = next;\n\t\t\tinvalidReference = credential !== undefined && next === null;\n\t\t\tnotify(account.status(environment.id));\n\t\t\treturn true;\n\t\t},\n\t\tsignedInElsewhere() {\n\t\t\treturn ([\"dev\", \"staging\", \"production\"] as const).filter((id) => {\n\t\t\t\tif (id === environment.id) return false;\n\t\t\t\ttry {\n\t\t\t\t\treturn new HcodeAccountStore({ agentDir: options.agentDir, environment: id }).status(id) !== null;\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tlogin,\n\t\tasync logoutStored(credential, signal) {\n\t\t\tconst expected = referenceFromCredential(credential);\n\t\t\tif (expected && expected.environmentId === environment.id) await account.logout(expected, signal);\n\t\t},\n\t\tshutdown(signal) {\n\t\t\tshutdown ??= (async () => {\n\t\t\t\tshuttingDown = true;\n\t\t\t\tprovider.dispose();\n\t\t\t\tmetadata.dispose();\n\t\t\t\tconst current = sessionReference ?? reference;\n\t\t\t\ttry {\n\t\t\t\t\tif (!current || owner.persistence(current) !== \"session\") return { remoteRevocation: \"not-needed\" };\n\t\t\t\t\tconst bounded = AbortSignal.any([signal, AbortSignal.timeout(3000)]);\n\t\t\t\t\treturn await raceWithAbortSignal(owner.logout(current, bounded), bounded);\n\t\t\t\t} catch {\n\t\t\t\t\treturn { remoteRevocation: \"unconfirmed\" };\n\t\t\t\t} finally {\n\t\t\t\t\tdispose();\n\t\t\t\t}\n\t\t\t})();\n\t\t\treturn shutdown;\n\t\t},\n\t\tdispose,\n\t};\n}\n\n/** Parses only the keyless, closed native-reference shape at the generic credential trust boundary. */\nexport function referenceFromCredential(credential: Credential | undefined): HcodeAccountRef | null {\n\tif (credential?.type !== \"api_key\" || credential.key !== undefined || !credential.env) return null;\n\ttry {\n\t\t// Generic credential storage is a trust boundary; it can carry only the frozen reference fields.\n\t\tconst env = wire.object(credential.env, [\"HCODE_ENVIRONMENT_ID\", \"HCODE_ACCOUNT_ID\", \"HCODE_GENERATION\"]);\n\t\tconst generation = wire.string(env.HCODE_GENERATION, 36);\n\t\tif (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(generation)) return null;\n\t\treturn {\n\t\t\tenvironmentId: wire.string(env.HCODE_ENVIRONMENT_ID),\n\t\t\taccountId: wire.string(env.HCODE_ACCOUNT_ID),\n\t\t\tgeneration,\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-copy.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/login-copy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,8GAA8G;AAC9G,MAAM,MAAM,sBAAsB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,uBAAuB,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE9G,2FAA2F;AAC3F,eAAO,MAAM,4BAA4B,oPACyM,CAAC;AAyBnP,6GAA6G;AAC7G,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,uBAAuB,GAAG,SAAS,GAAG,MAAM,CAI5F;AAED,gGAAgG;AAChG,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAMtG;AAED,mEAAmE;AACnE,wBAAgB,uBAAuB,CACtC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,sBAAsB,GAC3B,MAAM,CASR;AAED,8FAA8F;AAC9F,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GAAG;IACnF,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;CACb,
|
|
1
|
+
{"version":3,"file":"login-copy.d.ts","sourceRoot":"","sources":["../../../src/humain/hcode/login-copy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,8GAA8G;AAC9G,MAAM,MAAM,sBAAsB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,uBAAuB,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE9G,2FAA2F;AAC3F,eAAO,MAAM,4BAA4B,oPACyM,CAAC;AAyBnP,6GAA6G;AAC7G,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,uBAAuB,GAAG,SAAS,GAAG,MAAM,CAI5F;AAED,gGAAgG;AAChG,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAMtG;AAED,mEAAmE;AACnE,wBAAgB,uBAAuB,CACtC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,sBAAsB,GAC3B,MAAM,CASR;AAED,8FAA8F;AAC9F,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GAAG;IACnF,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;CACb,CAsBA;AAED,uHAAuH;AACvH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAIpH"}
|
|
@@ -58,6 +58,16 @@ export function hcodeLoginAvailability(readiness) {
|
|
|
58
58
|
return { state: "ready", text: "connected" };
|
|
59
59
|
case "unreachable":
|
|
60
60
|
return { state: "failed", text: `Can't reach ${readiness.host}: check VPN/Zscaler [Retry]` };
|
|
61
|
+
case "not-configured":
|
|
62
|
+
return {
|
|
63
|
+
state: "failed",
|
|
64
|
+
text: `HUMAIN Code isn't available on ${readiness.environmentId} yet (server: hcode_unavailable). Try another environment or contact support. [Retry]`,
|
|
65
|
+
};
|
|
66
|
+
case "http-error":
|
|
67
|
+
return {
|
|
68
|
+
state: "failed",
|
|
69
|
+
text: `Sign-in server returned HTTP ${readiness.status}${readiness.message ? `: ${readiness.message}` : "."} [Retry]`,
|
|
70
|
+
};
|
|
61
71
|
case "mismatch":
|
|
62
72
|
return { state: "failed", text: "Server sign-in settings don't match this CLI version [Details]" };
|
|
63
73
|
case "unavailable":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-copy.js","sourceRoot":"","sources":["../../../src/humain/hcode/login-copy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAMpD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,4BAA4B,GACxC,iPAAiP,CAAC;AAEnP,MAAM,aAAa,GAA+E;IACjG,sBAAsB,EAAE;QACvB,MAAM,EAAE,8BAA8B;QACtC,GAAG,EAAE,kFAAkF;KACvF;IACD,4BAA4B,EAAE;QAC7B,MAAM,EAAE,wCAAwC;QAChD,GAAG,EAAE,oEAAoE;KACzE;IACD,yBAAyB,EAAE;QAC1B,MAAM,EAAE,qCAAqC;QAC7C,GAAG,EAAE,kFAAkF;KACvF;IACD,0BAA0B,EAAE;QAC3B,MAAM,EAAE,0DAA0D;QAClE,GAAG,EAAE,gEAAgE;KACrE;IACD,oBAAoB,EAAE;QACrB,MAAM,EAAE,+DAA+D;QACvE,GAAG,EAAE,6DAA6D;KAClE;CACD,CAAC;AAEF,6GAA6G;AAC7G,MAAM,UAAU,wBAAwB,CAAC,MAA2C;IACnF,IAAI,CAAC,MAAM;QAAE,OAAO,2CAA2C,CAAC;IAChE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,uCAAuC,GAAG,KAAK,GAAG,EAAE,CAAC;AAC7D,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,uBAAuB,CAAC,KAA6B;IACpE,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC1B,OAAO,EAAE,MAAM,E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sDAAsD,EAAE,CAAC;IAC3F,CAAC;AACF,CAAC;AAED,uHAAuH;AACvH,MAAM,UAAU,4BAA4B,CAAC,aAAqB,EAAE,SAA4B;IAC/F,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,OAAO,GAAG,gBAAgB,CAAC,aAAa,CAAC,sFAAsF,gBAAgB,CAAC,KAAK,CAAC,oDAAoD,KAAK,wCAAwC,CAAC;AACzP,CAAC","sourcesContent":["// Plain-language
|
|
1
|
+
{"version":3,"file":"login-copy.js","sourceRoot":"","sources":["../../../src/humain/hcode/login-copy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAMpD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,4BAA4B,GACxC,iPAAiP,CAAC;AAEnP,MAAM,aAAa,GAA+E;IACjG,sBAAsB,EAAE;QACvB,MAAM,EAAE,8BAA8B;QACtC,GAAG,EAAE,kFAAkF;KACvF;IACD,4BAA4B,EAAE;QAC7B,MAAM,EAAE,wCAAwC;QAChD,GAAG,EAAE,oEAAoE;KACzE;IACD,yBAAyB,EAAE;QAC1B,MAAM,EAAE,qCAAqC;QAC7C,GAAG,EAAE,kFAAkF;KACvF;IACD,0BAA0B,EAAE;QAC3B,MAAM,EAAE,0DAA0D;QAClE,GAAG,EAAE,gEAAgE;KACrE;IACD,oBAAoB,EAAE;QACrB,MAAM,EAAE,+DAA+D;QACvE,GAAG,EAAE,6DAA6D;KAClE;CACD,CAAC;AAEF,6GAA6G;AAC7G,MAAM,UAAU,wBAAwB,CAAC,MAA2C;IACnF,IAAI,CAAC,MAAM;QAAE,OAAO,2CAA2C,CAAC;IAChE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnD,OAAO,uCAAuC,GAAG,KAAK,GAAG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gB;YACpB,OAAO;gBACN,KAAK,EAAE,QAAQ;gBACf,IAAI,EAAE,kCAAkC,SAAS,CAAC,aAAa,uFAAuF;aACtJ,CAAC;QACH,KAAK,YAAY;YAChB,OAAO;gBACN,KAAK,EAAE,QAAQ;gBACf,IAAI,EAAE,gCAAgC,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,UAAU;aACrH,CAAC;QACH,KAAK,UAAU;YACd,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,gEAAgE,EAAE,CAAC;QACpG,KAAK,aAAa;YACjB,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,sDAAsD,EAAE,CAAC;IAC3F,CAAC;AACF,CAAC;AAED,uHAAuH;AACvH,MAAM,UAAU,4BAA4B,CAAC,aAAqB,EAAE,SAA4B;IAC/F,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,OAAO,GAAG,gBAAgB,CAAC,aAAa,CAAC,sFAAsF,gBAAgB,CAAC,KAAK,CAAC,oDAAoD,KAAK,wCAAwC,CAAC;AACzP,CAAC","sourcesContent":["// Plain-language HUMAIN Code readiness and empty-catalog copy; HTTP messages are sanitized at the facade boundary.\nimport type { HcodeCatalogEmptyReason } from \"./contracts.ts\";\nimport { hcodeDisplayName } from \"./environment.ts\";\nimport type { HcodeLoginReadiness } from \"./facade.ts\";\n\n/** Why a signed-in account has no models: Forge's reason (if it sent one), or the list couldn't be loaded. */\nexport type HcodeEmptyCatalogCause = { kind: \"empty\"; reason?: HcodeCatalogEmptyReason } | { kind: \"failed\" };\n\n/** Guidance for a direct login when the server's sign-in settings don't match this CLI. */\nexport const HCODE_LOGIN_MISMATCH_DETAILS =\n\t\"HUMAIN Code's sign-in settings (/api/cli/config or issuer discovery) don't match what this CLI version accepts. Update the CLI with `humain-code update`, or ask the HUMAIN Code platform team to check the server's CLI sign-in configuration.\";\n\nconst EMPTY_REASONS: Readonly<Record<HcodeCatalogEmptyReason, { reason: string; fix: string }>> = {\n\tno_cli_models_approved: {\n\t\treason: \"no model is approved for CLI\",\n\t\tfix: \"Ask an admin to set a model to Web + CLI or CLI only in Settings > Model Access.\",\n\t},\n\tprovider_key_not_cli_enabled: {\n\t\treason: \"the provider key isn't enabled for CLI\",\n\t\tfix: \"Ask an admin to enable CLI on the key in Settings > Provider Keys.\",\n\t},\n\tcli_capacity_unconfigured: {\n\t\treason: \"CLI capacity hasn't been configured\",\n\t\tfix: \"Ask the HUMAIN Code platform team to check the deployment's CLI capacity limits.\",\n\t},\n\tprovider_key_not_dedicated: {\n\t\treason: \"the provider key is shared or isn't approved for CLI use\",\n\t\tfix: \"Ask an admin to configure a dedicated key for HUMAIN Code CLI.\",\n\t},\n\tmodels_not_qualified: {\n\t\treason: \"this server hasn't finished CLI setup for the approved models\",\n\t\tfix: \"Ask an admin to report it to the HUMAIN Code platform team.\",\n\t},\n};\n\n/** Say why the account's catalog is empty and what to do; servers without a reason keep the generic text. */\nexport function hcodeEmptyCatalogMessage(reason: HcodeCatalogEmptyReason | undefined): string {\n\tif (!reason) return \"Your admin hasn't enabled CLI models yet.\";\n\tconst { reason: why, fix } = EMPTY_REASONS[reason];\n\treturn `No models are available in the CLI: ${why}. ${fix}`;\n}\n\n/** The short reason and who can fix it: an admin, the server's configuration or the network. */\nexport function hcodeEmptyCatalogReason(cause: HcodeEmptyCatalogCause): { reason: string; fix: string } {\n\tif (cause.kind === \"failed\")\n\t\treturn { reason: \"the model list couldn't be loaded\", fix: \"Check your network, VPN or Zscaler.\" };\n\treturn cause.reason\n\t\t? EMPTY_REASONS[cause.reason]\n\t\t: { reason: \"your admin hasn't enabled CLI models yet\", fix: \"Ask an admin to enable a model for CLI.\" };\n}\n\n/** Non-blocking notice after a sign-in that produced no models. */\nexport function hcodeEmptyCatalogNotice(\n\tenvironmentId: string,\n\temail: string | undefined,\n\tcause: HcodeEmptyCatalogCause,\n): string {\n\tconst { reason, fix } = hcodeEmptyCatalogReason(cause);\n\treturn [\n\t\t`✓ Signed in to ${hcodeDisplayName(environmentId)}${email ? ` as ${email}` : \"\"}`,\n\t\t` No models available in the CLI yet: ${reason}.`,\n\t\t` ${fix}`,\n\t\t\" You can keep using your other providers. I'll check again automatically.\",\n\t\t\" /model to retry · /login status for details\",\n\t].join(\"\\n\");\n}\n\n/** `/login` row state for a readiness check; `undefined` means the check is still running. */\nexport function hcodeLoginAvailability(readiness: HcodeLoginReadiness | undefined): {\n\tstate: \"pending\" | \"ready\" | \"failed\";\n\ttext: string;\n} {\n\tif (!readiness) return { state: \"pending\", text: \"checking connection…\" };\n\tswitch (readiness.kind) {\n\t\tcase \"ready\":\n\t\t\treturn { state: \"ready\", text: \"connected\" };\n\t\tcase \"unreachable\":\n\t\t\treturn { state: \"failed\", text: `Can't reach ${readiness.host}: check VPN/Zscaler [Retry]` };\n\t\tcase \"not-configured\":\n\t\t\treturn {\n\t\t\t\tstate: \"failed\",\n\t\t\t\ttext: `HUMAIN Code isn't available on ${readiness.environmentId} yet (server: hcode_unavailable). Try another environment or contact support. [Retry]`,\n\t\t\t};\n\t\tcase \"http-error\":\n\t\t\treturn {\n\t\t\t\tstate: \"failed\",\n\t\t\t\ttext: `Sign-in server returned HTTP ${readiness.status}${readiness.message ? `: ${readiness.message}` : \".\"} [Retry]`,\n\t\t\t};\n\t\tcase \"mismatch\":\n\t\t\treturn { state: \"failed\", text: \"Server sign-in settings don't match this CLI version [Details]\" };\n\t\tcase \"unavailable\":\n\t\t\treturn { state: \"failed\", text: \"Sign-in is not available in this environment [Retry]\" };\n\t}\n}\n\n/** Says that the saved sign-in belongs to another environment and how to use it, e.g. after starting without --env. */\nexport function hcodeSignedInElsewhereNotice(environmentId: string, elsewhere: readonly string[]): string | undefined {\n\tconst other = elsewhere[0];\n\tif (!other) return undefined;\n\treturn `${hcodeDisplayName(environmentId)}: not signed in. HUMAIN Code now defaults to production. Your saved sign-in is for ${hcodeDisplayName(other)} and was not moved: start humain-code with --env ${other} to use it, or /login to sign in here.`;\n}\n"]}
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AASH,OAAO,EAAE,KAAK,IAAI,EAA+E,MAAM,eAAe,CAAC;AAiDvH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAuBlE,OAAO,EAAwB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEjF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AA2C7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAuSpD,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,IAAI,EACZ,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,eAAe,EAAE,eAAe,GAC9B,OAAO,CAAC,cAAc,CAAC,CAuFzB;AAiID,MAAM,WAAW,WAAW;IAC3B,kBAAkB,CAAC,EAAE,eAAe,EAAE,CAAC;CACvC;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAE5D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAM/G;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,+DAAqC,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AASH,OAAO,EAAE,KAAK,IAAI,EAA+E,MAAM,eAAe,CAAC;AAiDvH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAuBlE,OAAO,EAAwB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEjF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AA2C7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAuSpD,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,IAAI,EACZ,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,eAAe,EAAE,eAAe,GAC9B,OAAO,CAAC,cAAc,CAAC,CAuFzB;AAiID,MAAM,WAAW,WAAW;IAC3B,kBAAkB,CAAC,EAAE,eAAe,EAAE,CAAC;CACvC;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAE5D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAM/G;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,+DAAqC,iBA8xBzG"}
|
package/dist/main.js
CHANGED
|
@@ -515,6 +515,8 @@ export async function main(args, options, run = takeHcodeRunBootstrap(process.en
|
|
|
515
515
|
process.exitCode = 1;
|
|
516
516
|
}
|
|
517
517
|
else {
|
|
518
|
+
// Native Run skips desktop setupCli and must configure transport before catalog discovery.
|
|
519
|
+
configureHttpDispatcher();
|
|
518
520
|
process.exitCode = await runHcodeSandbox(args, run, resolveStartupCwd);
|
|
519
521
|
}
|
|
520
522
|
return;
|