@cortexkit/opencode-antigravity-auth 3.0.34 → 3.0.36
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/dist/cli.js +413 -182
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +196 -69
- package/dist/index.js +506 -245
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +217 -90
- package/dist/server.js +1185 -860
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/auth-menu/accounts.js +9 -3
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.js +14 -5
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +11 -8
- package/dist/src/common-auth-embedded/claustrum/custody.js +26 -15
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +2 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +7 -0
- package/dist/src/common-auth-embedded/claustrum/host.d.ts +8 -0
- package/dist/src/common-auth-embedded/claustrum/host.js +113 -0
- package/dist/src/common-auth-embedded/claustrum/hub.d.ts +5 -1
- package/dist/src/common-auth-embedded/claustrum/hub.js +5 -2
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +2 -1
- package/dist/src/common-auth-embedded/claustrum/index.js +2 -1
- package/dist/src/common-auth-embedded/opencode2/install.js +42 -9
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +3 -1
- package/dist/src/common-auth-embedded/setup/command.js +8 -4
- package/dist/src/common-auth-embedded/setup/enroll.js +3 -0
- package/dist/src/common-auth-embedded/source-output.json +68 -52
- package/dist/src/ga/rpc/protocol.d.ts +1 -0
- package/dist/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/src/ga/rpc/protocol.js +4 -1
- package/dist/src/ga/rpc/protocol.js.map +1 -1
- package/dist/src/ga/server/auth.d.ts.map +1 -1
- package/dist/src/ga/server/auth.js +27 -4
- package/dist/src/ga/server/auth.js.map +1 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +5 -1
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts +22 -58
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +161 -248
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +4 -4
- package/dist/src/plugin/auth-loader.js +1 -1
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.js +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts +1 -0
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +87 -51
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +2 -2
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/shared/source-sidebar.js +1 -1
- package/dist/src/plugin/shared/source-sidebar.js.map +1 -1
- package/dist/src/plugin/vault-activation.d.ts.map +1 -1
- package/dist/src/plugin/vault-activation.js +10 -2
- package/dist/src/plugin/vault-activation.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +25 -3
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/runtime-layout.js +3 -3
- package/dist/src/runtime-layout.js.map +1 -1
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/setup.js +8 -5
- package/dist/src/setup.js.map +1 -1
- package/dist/tui-build-map.json +1 -1
- package/dist/tui-ga-build-map.json +5 -5
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +11 -8
- package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +2 -0
- package/dist/types/src/common-auth-embedded/claustrum/host.d.ts +8 -0
- package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +5 -1
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +3 -1
- package/dist/types/src/ga/rpc/protocol.d.ts +1 -0
- package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/types/src/ga/server/auth.d.ts.map +1 -1
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts +1 -0
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-activation.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/types/src/setup.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/auth-menu/accounts.js +9 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
- package/src/common-auth-embedded/claustrum/consumer.js +14 -5
- package/src/common-auth-embedded/claustrum/custody.d.ts +11 -8
- package/src/common-auth-embedded/claustrum/custody.js +26 -15
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +2 -0
- package/src/common-auth-embedded/claustrum/enrollment.js +7 -0
- package/src/common-auth-embedded/claustrum/host.d.ts +8 -0
- package/src/common-auth-embedded/claustrum/host.js +113 -0
- package/src/common-auth-embedded/claustrum/hub.d.ts +5 -1
- package/src/common-auth-embedded/claustrum/hub.js +5 -2
- package/src/common-auth-embedded/claustrum/index.d.ts +2 -1
- package/src/common-auth-embedded/claustrum/index.js +2 -1
- package/src/common-auth-embedded/opencode2/install.js +42 -9
- package/src/common-auth-embedded/opencode2/types.d.ts +3 -1
- package/src/common-auth-embedded/setup/command.js +8 -4
- package/src/common-auth-embedded/setup/enroll.js +3 -0
- package/src/common-auth-embedded/source-output.json +68 -52
- package/src/tui-ga-compiled/host-ga.js +133 -241
- package/src/tui-ga-raw/host-ga.tsx +222 -315
package/dist/cli.js
CHANGED
|
@@ -12406,7 +12406,7 @@ var init_pull = __esm({
|
|
|
12406
12406
|
const locks = new LockStack(ctx.lockDefaults, ctx.lockEnv);
|
|
12407
12407
|
const progress = { writes: 0 };
|
|
12408
12408
|
try {
|
|
12409
|
-
const
|
|
12409
|
+
const request2 = await withTransaction(ctx, locks, progress, { operation: "pull", rowId: id }, async (tx) => {
|
|
12410
12410
|
if (tx.reservation(id) !== void 0)
|
|
12411
12411
|
return void 0;
|
|
12412
12412
|
await tx.completeTorn();
|
|
@@ -12431,14 +12431,14 @@ var init_pull = __esm({
|
|
|
12431
12431
|
};
|
|
12432
12432
|
}, { completeTorn: false });
|
|
12433
12433
|
await locks.releaseAll();
|
|
12434
|
-
if (!
|
|
12434
|
+
if (!request2) {
|
|
12435
12435
|
this.firedAtLoad.delete(id);
|
|
12436
12436
|
return;
|
|
12437
12437
|
}
|
|
12438
12438
|
await ctx.hold?.("pull-before-request", id);
|
|
12439
12439
|
let observation;
|
|
12440
12440
|
try {
|
|
12441
|
-
observation = await this.hook?.(
|
|
12441
|
+
observation = await this.hook?.(request2);
|
|
12442
12442
|
} catch (cause) {
|
|
12443
12443
|
throw new PoolOperationError({
|
|
12444
12444
|
operation: "pull",
|
|
@@ -12452,8 +12452,8 @@ var init_pull = __esm({
|
|
|
12452
12452
|
}
|
|
12453
12453
|
const publish = rt.publishQuota ?? ((rowId2, attribution, value) => recordQuota(rt, rowId2, attribution, value));
|
|
12454
12454
|
await publish(id, {
|
|
12455
|
-
credentialEpoch:
|
|
12456
|
-
...
|
|
12455
|
+
credentialEpoch: request2.credentialEpoch,
|
|
12456
|
+
...request2.identity !== void 0 ? { identity: request2.identity } : {}
|
|
12457
12457
|
}, observation);
|
|
12458
12458
|
} catch (error) {
|
|
12459
12459
|
this.firedAtLoad.delete(id);
|
|
@@ -15093,12 +15093,12 @@ function coerceValues(knobs, raw) {
|
|
|
15093
15093
|
}
|
|
15094
15094
|
return { values };
|
|
15095
15095
|
}
|
|
15096
|
-
function findAction(sections,
|
|
15097
|
-
const section = sections.find((entry) => entry.id ===
|
|
15096
|
+
function findAction(sections, request2) {
|
|
15097
|
+
const section = sections.find((entry) => entry.id === request2.sectionId);
|
|
15098
15098
|
if (!section)
|
|
15099
15099
|
return void 0;
|
|
15100
|
-
const actions =
|
|
15101
|
-
return actions?.find((action) => action.id ===
|
|
15100
|
+
const actions = request2.itemId === void 0 ? section.content.actions : section.content.items?.find((item) => item.id === request2.itemId)?.actions;
|
|
15101
|
+
return actions?.find((action) => action.id === request2.actionId);
|
|
15102
15102
|
}
|
|
15103
15103
|
function createCommandMenu(options) {
|
|
15104
15104
|
const logger2 = options.logger ?? createLogger2("commands");
|
|
@@ -15178,10 +15178,10 @@ function createCommandMenu(options) {
|
|
|
15178
15178
|
const own = ownInvocation(invocation, redact3);
|
|
15179
15179
|
return dialogPayload(options.command, options.title, await sections(own), seam);
|
|
15180
15180
|
},
|
|
15181
|
-
async apply(
|
|
15181
|
+
async apply(request2, invocation) {
|
|
15182
15182
|
const own = ownInvocation(invocation, redact3);
|
|
15183
15183
|
const finish = async (outcome2) => applyResult(options.command, options.title, await sections(own), outcome2, seam);
|
|
15184
|
-
const action =
|
|
15184
|
+
const action = request2.command === options.command ? findAction(await sections(own), request2) : void 0;
|
|
15185
15185
|
if (!action)
|
|
15186
15186
|
return finish({
|
|
15187
15187
|
ok: false,
|
|
@@ -15189,14 +15189,14 @@ function createCommandMenu(options) {
|
|
|
15189
15189
|
text: "That action is no longer available."
|
|
15190
15190
|
});
|
|
15191
15191
|
const confirmation = confirmationOf(action);
|
|
15192
|
-
if (confirmation &&
|
|
15192
|
+
if (confirmation && request2.confirmed !== true)
|
|
15193
15193
|
return finish({
|
|
15194
15194
|
ok: false,
|
|
15195
15195
|
code: "needs-confirmation",
|
|
15196
15196
|
text: confirmation.message,
|
|
15197
15197
|
needsConfirmation: true
|
|
15198
15198
|
});
|
|
15199
|
-
const coerced = coerceValues(action.knobs ?? [],
|
|
15199
|
+
const coerced = coerceValues(action.knobs ?? [], request2.values);
|
|
15200
15200
|
if ("problem" in coerced)
|
|
15201
15201
|
return finish({
|
|
15202
15202
|
ok: false,
|
|
@@ -15207,7 +15207,7 @@ function createCommandMenu(options) {
|
|
|
15207
15207
|
try {
|
|
15208
15208
|
const result = await action.run({
|
|
15209
15209
|
values: coerced.values,
|
|
15210
|
-
...
|
|
15210
|
+
...request2.itemId !== void 0 ? { itemId: request2.itemId } : {},
|
|
15211
15211
|
invocation: own
|
|
15212
15212
|
});
|
|
15213
15213
|
outcome = typeof result === "string" ? { ok: true, text: result } : {
|
|
@@ -15219,8 +15219,8 @@ function createCommandMenu(options) {
|
|
|
15219
15219
|
const failure = projectFailure(error);
|
|
15220
15220
|
logger2.warn("command menu action failed", {
|
|
15221
15221
|
command: options.command,
|
|
15222
|
-
section:
|
|
15223
|
-
action:
|
|
15222
|
+
section: request2.sectionId,
|
|
15223
|
+
action: request2.actionId,
|
|
15224
15224
|
code: failure.code,
|
|
15225
15225
|
error: redact3(error instanceof Error ? error.message : String(error))
|
|
15226
15226
|
});
|
|
@@ -15506,6 +15506,219 @@ var init_commands = __esm({
|
|
|
15506
15506
|
}
|
|
15507
15507
|
});
|
|
15508
15508
|
|
|
15509
|
+
// ../core/dist/common-auth-embedded/claustrum/errors.js
|
|
15510
|
+
var ClaustrumConsumerError;
|
|
15511
|
+
var init_errors2 = __esm({
|
|
15512
|
+
"../core/dist/common-auth-embedded/claustrum/errors.js"() {
|
|
15513
|
+
"use strict";
|
|
15514
|
+
ClaustrumConsumerError = class extends Error {
|
|
15515
|
+
kind;
|
|
15516
|
+
constructor(kind, message) {
|
|
15517
|
+
super(message);
|
|
15518
|
+
this.name = "ClaustrumConsumerError";
|
|
15519
|
+
this.kind = kind;
|
|
15520
|
+
}
|
|
15521
|
+
};
|
|
15522
|
+
}
|
|
15523
|
+
});
|
|
15524
|
+
|
|
15525
|
+
// ../core/dist/common-auth-embedded/claustrum/availability.js
|
|
15526
|
+
import { ClaustrumCredentialError } from "@cortexkit/claustrum-client";
|
|
15527
|
+
import { SocketClosedError, SocketTimeoutError, SubcCallError } from "@cortexkit/subc-client";
|
|
15528
|
+
function classifyVaultFailure(error) {
|
|
15529
|
+
if (error instanceof ClaustrumUnreachableError || error instanceof SocketClosedError || error instanceof SocketTimeoutError)
|
|
15530
|
+
return "unreachable";
|
|
15531
|
+
const code2 = error instanceof ClaustrumCredentialError || error instanceof SubcCallError ? error.code : error instanceof Error && "code" in error ? error.code : void 0;
|
|
15532
|
+
if (typeof code2 !== "string" || !Object.hasOwn(VAULT_FAILURE_CLASSES, code2))
|
|
15533
|
+
return "answered";
|
|
15534
|
+
return VAULT_FAILURE_CLASSES[code2];
|
|
15535
|
+
}
|
|
15536
|
+
var VAULT_FAILURE_CLASSES, ClaustrumUnreachableError;
|
|
15537
|
+
var init_availability = __esm({
|
|
15538
|
+
"../core/dist/common-auth-embedded/claustrum/availability.js"() {
|
|
15539
|
+
"use strict";
|
|
15540
|
+
init_errors2();
|
|
15541
|
+
VAULT_FAILURE_CLASSES = Object.freeze({
|
|
15542
|
+
ECONNREFUSED: "unreachable",
|
|
15543
|
+
ENOENT: "unreachable",
|
|
15544
|
+
ECONNRESET: "unreachable",
|
|
15545
|
+
EPIPE: "unreachable",
|
|
15546
|
+
ETIMEDOUT: "unreachable",
|
|
15547
|
+
transport_error: "unreachable",
|
|
15548
|
+
unavailable: "unreachable",
|
|
15549
|
+
timeout: "unreachable",
|
|
15550
|
+
route_closed: "unreachable",
|
|
15551
|
+
daemon_draining: "unreachable",
|
|
15552
|
+
connection_closed: "unreachable",
|
|
15553
|
+
connection_dropped: "unreachable",
|
|
15554
|
+
request_deadline: "unreachable",
|
|
15555
|
+
deadline_exceeded_no_drop_observed: "unreachable",
|
|
15556
|
+
module_reloading: "unreachable",
|
|
15557
|
+
module_warming: "unreachable",
|
|
15558
|
+
target_unavailable: "unreachable",
|
|
15559
|
+
module_timeout: "unreachable",
|
|
15560
|
+
invalid_response: "answered",
|
|
15561
|
+
invalid_record_version: "answered",
|
|
15562
|
+
invalid_expiry: "answered",
|
|
15563
|
+
invalid_status: "answered",
|
|
15564
|
+
invalid_params: "answered",
|
|
15565
|
+
ttl_unsatisfiable: "answered",
|
|
15566
|
+
not_found: "answered",
|
|
15567
|
+
enrollment_revoked: "answered",
|
|
15568
|
+
enrollment_invalid: "answered",
|
|
15569
|
+
grant_denied: "answered",
|
|
15570
|
+
credential_unavailable: "answered",
|
|
15571
|
+
needs_reauth: "answered",
|
|
15572
|
+
declined: "answered",
|
|
15573
|
+
disabled: "answered",
|
|
15574
|
+
identity_changed: "answered",
|
|
15575
|
+
closed: "answered",
|
|
15576
|
+
client_closed: "answered",
|
|
15577
|
+
pending_exists: "answered",
|
|
15578
|
+
pending_queue_full: "answered",
|
|
15579
|
+
already_consumed: "answered",
|
|
15580
|
+
superseded: "answered",
|
|
15581
|
+
stale_generation: "answered",
|
|
15582
|
+
missing_identity: "answered",
|
|
15583
|
+
invalid_control_body: "answered",
|
|
15584
|
+
unknown_module: "answered",
|
|
15585
|
+
module_removed: "answered",
|
|
15586
|
+
capability_denied: "answered",
|
|
15587
|
+
unknown_channel: "unreachable",
|
|
15588
|
+
stale_route_epoch: "unreachable",
|
|
15589
|
+
capability_forbidden: "answered",
|
|
15590
|
+
capability_unprovided: "answered",
|
|
15591
|
+
capability_ambiguous: "answered",
|
|
15592
|
+
invalid_capability_identifier: "answered",
|
|
15593
|
+
binary_body_required: "answered",
|
|
15594
|
+
binary_call_requires_call_binary: "answered",
|
|
15595
|
+
corr_exhausted: "answered",
|
|
15596
|
+
late_route_cleanup_failed: "answered",
|
|
15597
|
+
reverse_request_capability_not_declared: "answered",
|
|
15598
|
+
stale_route_handle: "answered",
|
|
15599
|
+
reverse_request_unhandled: "answered",
|
|
15600
|
+
handler_error: "answered",
|
|
15601
|
+
health_error: "answered",
|
|
15602
|
+
duplicate_module_id: "answered",
|
|
15603
|
+
route_rejected: "answered",
|
|
15604
|
+
lock_busy: "answered",
|
|
15605
|
+
owner_invalid: "answered",
|
|
15606
|
+
renewal_failed: "answered",
|
|
15607
|
+
unsupported_platform: "answered",
|
|
15608
|
+
EACCES: "answered",
|
|
15609
|
+
EPERM: "answered",
|
|
15610
|
+
ERR_PRIVATE_FILES_SECURITY: "answered"
|
|
15611
|
+
});
|
|
15612
|
+
ClaustrumUnreachableError = class extends ClaustrumConsumerError {
|
|
15613
|
+
constructor() {
|
|
15614
|
+
super("unavailable", "Claustrum scoped operation unavailable");
|
|
15615
|
+
this.name = "ClaustrumUnreachableError";
|
|
15616
|
+
}
|
|
15617
|
+
};
|
|
15618
|
+
}
|
|
15619
|
+
});
|
|
15620
|
+
|
|
15621
|
+
// ../core/dist/common-auth-embedded/claustrum/host.js
|
|
15622
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError2 } from "@cortexkit/claustrum-client";
|
|
15623
|
+
function isVaultHostClient(client) {
|
|
15624
|
+
return hostClients.has(client);
|
|
15625
|
+
}
|
|
15626
|
+
function hasVaultHost() {
|
|
15627
|
+
return process.env.CORTEXKIT_VAULT_HOST === "thalamus";
|
|
15628
|
+
}
|
|
15629
|
+
function hostError(error) {
|
|
15630
|
+
if (typeof error !== "object" || error === null)
|
|
15631
|
+
return error;
|
|
15632
|
+
const value = error;
|
|
15633
|
+
if (typeof value.code === "string" && (value.class === "transient" || value.class === "permanent" || value.class === "auth_required" || value.class === "context_overflow") && (value.action === "gone" || value.action === "reauth" || value.action === "retry" || value.action === "reduce_and_retry"))
|
|
15634
|
+
return new ClaustrumCredentialError2(value.code, value.class, value.action);
|
|
15635
|
+
if (value.name === "ClaustrumUnreachableError" || typeof value.code === "string" && classifyVaultFailure(Object.assign(new Error(), { code: value.code })) === "unreachable")
|
|
15636
|
+
return new ClaustrumUnreachableError();
|
|
15637
|
+
return error;
|
|
15638
|
+
}
|
|
15639
|
+
function call(operation) {
|
|
15640
|
+
try {
|
|
15641
|
+
return operation();
|
|
15642
|
+
} catch (error) {
|
|
15643
|
+
throw hostError(error);
|
|
15644
|
+
}
|
|
15645
|
+
}
|
|
15646
|
+
async function request(operation) {
|
|
15647
|
+
try {
|
|
15648
|
+
return await operation();
|
|
15649
|
+
} catch (error) {
|
|
15650
|
+
throw hostError(error);
|
|
15651
|
+
}
|
|
15652
|
+
}
|
|
15653
|
+
function wrapHostClient(client) {
|
|
15654
|
+
const watchScoped = client.watchScoped?.bind(client);
|
|
15655
|
+
const reportUsageScoped = client.reportUsageScoped?.bind(client);
|
|
15656
|
+
return {
|
|
15657
|
+
listScoped: (...args) => request(() => client.listScoped(...args)),
|
|
15658
|
+
getScoped: (...args) => request(() => client.getScoped(...args)),
|
|
15659
|
+
reportAuthFailureScoped: (...args) => request(() => client.reportAuthFailureScoped(...args)),
|
|
15660
|
+
close: () => call(() => client.close()),
|
|
15661
|
+
...watchScoped && {
|
|
15662
|
+
watchScoped: (...args) => {
|
|
15663
|
+
const watch = call(() => watchScoped(...args));
|
|
15664
|
+
return {
|
|
15665
|
+
stop: () => call(() => watch.stop()),
|
|
15666
|
+
closed: request(async () => {
|
|
15667
|
+
const end = await watch.closed;
|
|
15668
|
+
return end.kind === "refused" || end.kind === "transport_lost" ? { ...end, error: hostError(end.error) } : end;
|
|
15669
|
+
})
|
|
15670
|
+
};
|
|
15671
|
+
}
|
|
15672
|
+
},
|
|
15673
|
+
...reportUsageScoped && {
|
|
15674
|
+
reportUsageScoped: (...args) => request(() => reportUsageScoped(...args))
|
|
15675
|
+
},
|
|
15676
|
+
...client.insula && {
|
|
15677
|
+
insula: wrapInsula(client.insula)
|
|
15678
|
+
}
|
|
15679
|
+
};
|
|
15680
|
+
}
|
|
15681
|
+
function wrapInsula(transport) {
|
|
15682
|
+
const watchUsage = transport.watchUsage?.bind(transport);
|
|
15683
|
+
return {
|
|
15684
|
+
connectionFile: transport.connectionFile,
|
|
15685
|
+
getUsage: () => request(() => transport.getUsage()),
|
|
15686
|
+
...watchUsage && {
|
|
15687
|
+
watchUsage: (...args) => {
|
|
15688
|
+
const watch = call(() => watchUsage(...args));
|
|
15689
|
+
return {
|
|
15690
|
+
stop: () => call(() => watch.stop()),
|
|
15691
|
+
closed: request(() => watch.closed)
|
|
15692
|
+
};
|
|
15693
|
+
}
|
|
15694
|
+
}
|
|
15695
|
+
};
|
|
15696
|
+
}
|
|
15697
|
+
function connectVaultHost(pluginId) {
|
|
15698
|
+
if (!hasVaultHost() || !pluginId)
|
|
15699
|
+
throw new ClaustrumUnreachableError();
|
|
15700
|
+
try {
|
|
15701
|
+
const accessor = globalThis[/* @__PURE__ */ Symbol.for("cortexkit.vault")];
|
|
15702
|
+
if (typeof accessor !== "function")
|
|
15703
|
+
throw new ClaustrumUnreachableError();
|
|
15704
|
+
const client = wrapHostClient(accessor(pluginId));
|
|
15705
|
+
hostClients.add(client);
|
|
15706
|
+
return client;
|
|
15707
|
+
} catch {
|
|
15708
|
+
throw new ClaustrumUnreachableError();
|
|
15709
|
+
}
|
|
15710
|
+
}
|
|
15711
|
+
var VAULT_HOST_STATUS, VAULT_HOST_CONNECT_REFUSAL, hostClients;
|
|
15712
|
+
var init_host = __esm({
|
|
15713
|
+
"../core/dist/common-auth-embedded/claustrum/host.js"() {
|
|
15714
|
+
"use strict";
|
|
15715
|
+
init_availability();
|
|
15716
|
+
VAULT_HOST_STATUS = "Served by Thalamus";
|
|
15717
|
+
VAULT_HOST_CONNECT_REFUSAL = "This host gets its vault accounts from Thalamus, so it can't connect to the vault itself.";
|
|
15718
|
+
hostClients = /* @__PURE__ */ new WeakSet();
|
|
15719
|
+
}
|
|
15720
|
+
});
|
|
15721
|
+
|
|
15509
15722
|
// ../core/dist/common-auth-embedded/auth-menu/doctor.js
|
|
15510
15723
|
async function runDoctorChecks(checks) {
|
|
15511
15724
|
const findings = [];
|
|
@@ -16276,7 +16489,7 @@ function deleteAllAction(options) {
|
|
|
16276
16489
|
};
|
|
16277
16490
|
}
|
|
16278
16491
|
async function accountMenuActions(options) {
|
|
16279
|
-
return actionsFor(options, await options.custody?.() === true);
|
|
16492
|
+
return actionsFor(options, hasVaultHost() || await options.custody?.() === true);
|
|
16280
16493
|
}
|
|
16281
16494
|
function actionsFor(options, custody) {
|
|
16282
16495
|
const doctor = options.doctor?.length ? [doctorAction({ checks: options.doctor })] : [];
|
|
@@ -16301,7 +16514,8 @@ function actionsFor(options, custody) {
|
|
|
16301
16514
|
];
|
|
16302
16515
|
}
|
|
16303
16516
|
async function runAccountMenu(options) {
|
|
16304
|
-
const
|
|
16517
|
+
const hosted = hasVaultHost();
|
|
16518
|
+
const custody = hosted || await options.custody?.() === true;
|
|
16305
16519
|
const actions = actionsFor(options, custody);
|
|
16306
16520
|
const [read, status] = await Promise.all([
|
|
16307
16521
|
readRows(options.store),
|
|
@@ -16310,7 +16524,11 @@ async function runAccountMenu(options) {
|
|
|
16310
16524
|
return runMenu({
|
|
16311
16525
|
title: options.title,
|
|
16312
16526
|
subtitle: custody ? "Accounts come from the vault; select an action" : "Select an account action",
|
|
16313
|
-
status: [
|
|
16527
|
+
status: [
|
|
16528
|
+
...status,
|
|
16529
|
+
...hosted ? [VAULT_HOST_STATUS] : [],
|
|
16530
|
+
...accountLines(read)
|
|
16531
|
+
],
|
|
16314
16532
|
actions,
|
|
16315
16533
|
...options.terminal ? { terminal: options.terminal } : {}
|
|
16316
16534
|
});
|
|
@@ -16319,6 +16537,7 @@ var MENU_DISABLE_REASON, STATUS_ACCOUNT_LINES;
|
|
|
16319
16537
|
var init_accounts = __esm({
|
|
16320
16538
|
"../core/dist/common-auth-embedded/auth-menu/accounts.js"() {
|
|
16321
16539
|
"use strict";
|
|
16540
|
+
init_host();
|
|
16322
16541
|
init_quota();
|
|
16323
16542
|
init_store();
|
|
16324
16543
|
init_doctor();
|
|
@@ -16410,118 +16629,6 @@ var init_auth_menu = __esm({
|
|
|
16410
16629
|
}
|
|
16411
16630
|
});
|
|
16412
16631
|
|
|
16413
|
-
// ../core/dist/common-auth-embedded/claustrum/errors.js
|
|
16414
|
-
var ClaustrumConsumerError;
|
|
16415
|
-
var init_errors2 = __esm({
|
|
16416
|
-
"../core/dist/common-auth-embedded/claustrum/errors.js"() {
|
|
16417
|
-
"use strict";
|
|
16418
|
-
ClaustrumConsumerError = class extends Error {
|
|
16419
|
-
kind;
|
|
16420
|
-
constructor(kind, message) {
|
|
16421
|
-
super(message);
|
|
16422
|
-
this.name = "ClaustrumConsumerError";
|
|
16423
|
-
this.kind = kind;
|
|
16424
|
-
}
|
|
16425
|
-
};
|
|
16426
|
-
}
|
|
16427
|
-
});
|
|
16428
|
-
|
|
16429
|
-
// ../core/dist/common-auth-embedded/claustrum/availability.js
|
|
16430
|
-
import { ClaustrumCredentialError } from "@cortexkit/claustrum-client";
|
|
16431
|
-
import { SocketClosedError, SocketTimeoutError, SubcCallError } from "@cortexkit/subc-client";
|
|
16432
|
-
function classifyVaultFailure(error) {
|
|
16433
|
-
if (error instanceof ClaustrumUnreachableError || error instanceof SocketClosedError || error instanceof SocketTimeoutError)
|
|
16434
|
-
return "unreachable";
|
|
16435
|
-
const code2 = error instanceof ClaustrumCredentialError || error instanceof SubcCallError ? error.code : error instanceof Error && "code" in error ? error.code : void 0;
|
|
16436
|
-
if (typeof code2 !== "string" || !Object.hasOwn(VAULT_FAILURE_CLASSES, code2))
|
|
16437
|
-
return "answered";
|
|
16438
|
-
return VAULT_FAILURE_CLASSES[code2];
|
|
16439
|
-
}
|
|
16440
|
-
var VAULT_FAILURE_CLASSES, ClaustrumUnreachableError;
|
|
16441
|
-
var init_availability = __esm({
|
|
16442
|
-
"../core/dist/common-auth-embedded/claustrum/availability.js"() {
|
|
16443
|
-
"use strict";
|
|
16444
|
-
init_errors2();
|
|
16445
|
-
VAULT_FAILURE_CLASSES = Object.freeze({
|
|
16446
|
-
ECONNREFUSED: "unreachable",
|
|
16447
|
-
ENOENT: "unreachable",
|
|
16448
|
-
ECONNRESET: "unreachable",
|
|
16449
|
-
EPIPE: "unreachable",
|
|
16450
|
-
ETIMEDOUT: "unreachable",
|
|
16451
|
-
transport_error: "unreachable",
|
|
16452
|
-
unavailable: "unreachable",
|
|
16453
|
-
timeout: "unreachable",
|
|
16454
|
-
route_closed: "unreachable",
|
|
16455
|
-
daemon_draining: "unreachable",
|
|
16456
|
-
connection_closed: "unreachable",
|
|
16457
|
-
connection_dropped: "unreachable",
|
|
16458
|
-
request_deadline: "unreachable",
|
|
16459
|
-
deadline_exceeded_no_drop_observed: "unreachable",
|
|
16460
|
-
module_reloading: "unreachable",
|
|
16461
|
-
module_warming: "unreachable",
|
|
16462
|
-
target_unavailable: "unreachable",
|
|
16463
|
-
module_timeout: "unreachable",
|
|
16464
|
-
invalid_response: "answered",
|
|
16465
|
-
invalid_record_version: "answered",
|
|
16466
|
-
invalid_expiry: "answered",
|
|
16467
|
-
invalid_status: "answered",
|
|
16468
|
-
invalid_params: "answered",
|
|
16469
|
-
ttl_unsatisfiable: "answered",
|
|
16470
|
-
not_found: "answered",
|
|
16471
|
-
enrollment_revoked: "answered",
|
|
16472
|
-
enrollment_invalid: "answered",
|
|
16473
|
-
grant_denied: "answered",
|
|
16474
|
-
credential_unavailable: "answered",
|
|
16475
|
-
needs_reauth: "answered",
|
|
16476
|
-
declined: "answered",
|
|
16477
|
-
disabled: "answered",
|
|
16478
|
-
identity_changed: "answered",
|
|
16479
|
-
closed: "answered",
|
|
16480
|
-
client_closed: "answered",
|
|
16481
|
-
pending_exists: "answered",
|
|
16482
|
-
pending_queue_full: "answered",
|
|
16483
|
-
already_consumed: "answered",
|
|
16484
|
-
superseded: "answered",
|
|
16485
|
-
stale_generation: "answered",
|
|
16486
|
-
missing_identity: "answered",
|
|
16487
|
-
invalid_control_body: "answered",
|
|
16488
|
-
unknown_module: "answered",
|
|
16489
|
-
module_removed: "answered",
|
|
16490
|
-
capability_denied: "answered",
|
|
16491
|
-
unknown_channel: "unreachable",
|
|
16492
|
-
stale_route_epoch: "unreachable",
|
|
16493
|
-
capability_forbidden: "answered",
|
|
16494
|
-
capability_unprovided: "answered",
|
|
16495
|
-
capability_ambiguous: "answered",
|
|
16496
|
-
invalid_capability_identifier: "answered",
|
|
16497
|
-
binary_body_required: "answered",
|
|
16498
|
-
binary_call_requires_call_binary: "answered",
|
|
16499
|
-
corr_exhausted: "answered",
|
|
16500
|
-
late_route_cleanup_failed: "answered",
|
|
16501
|
-
reverse_request_capability_not_declared: "answered",
|
|
16502
|
-
stale_route_handle: "answered",
|
|
16503
|
-
reverse_request_unhandled: "answered",
|
|
16504
|
-
handler_error: "answered",
|
|
16505
|
-
health_error: "answered",
|
|
16506
|
-
duplicate_module_id: "answered",
|
|
16507
|
-
route_rejected: "answered",
|
|
16508
|
-
lock_busy: "answered",
|
|
16509
|
-
owner_invalid: "answered",
|
|
16510
|
-
renewal_failed: "answered",
|
|
16511
|
-
unsupported_platform: "answered",
|
|
16512
|
-
EACCES: "answered",
|
|
16513
|
-
EPERM: "answered",
|
|
16514
|
-
ERR_PRIVATE_FILES_SECURITY: "answered"
|
|
16515
|
-
});
|
|
16516
|
-
ClaustrumUnreachableError = class extends ClaustrumConsumerError {
|
|
16517
|
-
constructor() {
|
|
16518
|
-
super("unavailable", "Claustrum scoped operation unavailable");
|
|
16519
|
-
this.name = "ClaustrumUnreachableError";
|
|
16520
|
-
}
|
|
16521
|
-
};
|
|
16522
|
-
}
|
|
16523
|
-
});
|
|
16524
|
-
|
|
16525
16632
|
// ../core/dist/common-auth-embedded/claustrum/watch.js
|
|
16526
16633
|
var SAFETY_POLL_MS, WATCH_RETRY_MS, RESUBSCRIBE_BACKOFF_MS, ChangeNoticeReader, CoalescedRead, ScopedRosterWatch;
|
|
16527
16634
|
var init_watch = __esm({
|
|
@@ -16746,7 +16853,7 @@ function insulaUsageTransport(options) {
|
|
|
16746
16853
|
timer = setTimeout(() => reject(new Error("insula usage timeout")), 3e3);
|
|
16747
16854
|
timer.unref?.();
|
|
16748
16855
|
});
|
|
16749
|
-
const
|
|
16856
|
+
const request2 = (async () => {
|
|
16750
16857
|
client = options.connector ? await options.connector({
|
|
16751
16858
|
connectionFile: options.connectionFile,
|
|
16752
16859
|
handshakeTimeoutMs: Math.min(options.handshakeTimeoutMs ?? 3e3, 3e3)
|
|
@@ -16762,7 +16869,7 @@ function insulaUsageTransport(options) {
|
|
|
16762
16869
|
return await client.request(route, { method: "usage.get", params: {} });
|
|
16763
16870
|
})();
|
|
16764
16871
|
try {
|
|
16765
|
-
return await Promise.race([
|
|
16872
|
+
return await Promise.race([request2, timeout]);
|
|
16766
16873
|
} finally {
|
|
16767
16874
|
expired = true;
|
|
16768
16875
|
clearTimeout(timer);
|
|
@@ -17175,9 +17282,9 @@ import { createHash as createHash5, randomBytes as randomBytes2, randomUUID as r
|
|
|
17175
17282
|
import { constants as fsConstants } from "node:fs";
|
|
17176
17283
|
import { chmod as chmod2, mkdir as mkdir8, open as open6, readFile as readFile6, realpath as realpath3, rename as rename7, stat as stat5, unlink as unlink6 } from "node:fs/promises";
|
|
17177
17284
|
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve7 } from "node:path";
|
|
17178
|
-
import { ClaustrumCredentialError as
|
|
17285
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError3, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
|
|
17179
17286
|
function classifyEnrollmentError(error) {
|
|
17180
|
-
if (!(error instanceof
|
|
17287
|
+
if (!(error instanceof ClaustrumCredentialError3))
|
|
17181
17288
|
return void 0;
|
|
17182
17289
|
if (TERMINAL_ENROLLMENT_CODES.has(error.code))
|
|
17183
17290
|
return { code: error.code, disposition: "terminal" };
|
|
@@ -17530,6 +17637,11 @@ async function enrollmentAuthority(paths, proposedName) {
|
|
|
17530
17637
|
}
|
|
17531
17638
|
return "local";
|
|
17532
17639
|
}
|
|
17640
|
+
async function vaultAuthority(paths, proposedName) {
|
|
17641
|
+
if (hasVaultHost())
|
|
17642
|
+
return "host";
|
|
17643
|
+
return enrollmentAuthority(paths, proposedName);
|
|
17644
|
+
}
|
|
17533
17645
|
async function readClaustrumEnrollmentToken(tokenPath) {
|
|
17534
17646
|
const value = await readBoundedJson(tokenPath);
|
|
17535
17647
|
if (value === void 0)
|
|
@@ -17643,6 +17755,7 @@ var init_enrollment = __esm({
|
|
|
17643
17755
|
init_fs();
|
|
17644
17756
|
init_private_files();
|
|
17645
17757
|
init_errors2();
|
|
17758
|
+
init_host();
|
|
17646
17759
|
ENROLLMENT_SCHEMA = 1;
|
|
17647
17760
|
ENROLLMENT_FILE_MAX_BYTES = 16 * 1024;
|
|
17648
17761
|
ENROLLMENT_LOCK_TTL_MS = 3e4;
|
|
@@ -17958,7 +18071,7 @@ var init_shutdown = __esm({
|
|
|
17958
18071
|
});
|
|
17959
18072
|
|
|
17960
18073
|
// ../core/dist/common-auth-embedded/claustrum/usage.js
|
|
17961
|
-
import { ClaustrumCredentialError as
|
|
18074
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError4 } from "@cortexkit/claustrum-client";
|
|
17962
18075
|
function plain(value) {
|
|
17963
18076
|
return value !== null && typeof value === "object" && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
17964
18077
|
}
|
|
@@ -18064,7 +18177,7 @@ var init_usage = __esm({
|
|
|
18064
18177
|
#log(error) {
|
|
18065
18178
|
let code2 = "transport_error";
|
|
18066
18179
|
try {
|
|
18067
|
-
if (error instanceof
|
|
18180
|
+
if (error instanceof ClaustrumCredentialError4)
|
|
18068
18181
|
code2 = /^[a-z][a-z0-9_]{0,63}$/.test(error.code) ? error.code : code2;
|
|
18069
18182
|
if (this.#errors.has(code2))
|
|
18070
18183
|
return;
|
|
@@ -18094,7 +18207,7 @@ var init_usage = __esm({
|
|
|
18094
18207
|
|
|
18095
18208
|
// ../core/dist/common-auth-embedded/claustrum/custody.js
|
|
18096
18209
|
import { channel } from "node:diagnostics_channel";
|
|
18097
|
-
import { ClaustrumCredentialError as
|
|
18210
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError5 } from "@cortexkit/claustrum-client";
|
|
18098
18211
|
function isScopedCredentialRotation(served, current) {
|
|
18099
18212
|
return current !== void 0 && !current.fromKeptReceipt && !served.fromKeptReceipt && current.credentialId === served.credentialId && current.accountIdentity === served.accountIdentity && current.recordVersion !== served.recordVersion;
|
|
18100
18213
|
}
|
|
@@ -18221,6 +18334,7 @@ var init_custody = __esm({
|
|
|
18221
18334
|
init_availability();
|
|
18222
18335
|
init_enrollment();
|
|
18223
18336
|
init_errors2();
|
|
18337
|
+
init_host();
|
|
18224
18338
|
init_host_slot();
|
|
18225
18339
|
init_shutdown();
|
|
18226
18340
|
init_usage();
|
|
@@ -18260,15 +18374,21 @@ var init_custody = __esm({
|
|
|
18260
18374
|
#onDrainTimeout;
|
|
18261
18375
|
#disposing;
|
|
18262
18376
|
constructor(options) {
|
|
18377
|
+
if (hasVaultHost() && options.client && !isVaultHostClient(options.client))
|
|
18378
|
+
throw new ClaustrumUnreachableError();
|
|
18263
18379
|
const tokenPath = options.tokenPath;
|
|
18264
18380
|
if (options.readToken) {
|
|
18265
18381
|
this.#readToken = options.readToken;
|
|
18266
18382
|
} else if (tokenPath) {
|
|
18267
18383
|
this.#readToken = () => readClaustrumEnrollmentToken(tokenPath);
|
|
18384
|
+
} else if (hasVaultHost()) {
|
|
18385
|
+
this.#readToken = async () => {
|
|
18386
|
+
throw new ClaustrumConsumerError("not-enrolled", "Claustrum enrollment token path is required");
|
|
18387
|
+
};
|
|
18268
18388
|
} else {
|
|
18269
18389
|
throw new ClaustrumConsumerError("not-enrolled", "Claustrum enrollment token path is required");
|
|
18270
18390
|
}
|
|
18271
|
-
this.#client = options.client;
|
|
18391
|
+
this.#client = options.client ?? connectVaultHost(options.pluginId);
|
|
18272
18392
|
this.#family = options.family;
|
|
18273
18393
|
this.#parseIdentity = options.parseIdentity;
|
|
18274
18394
|
this.#requireAssertion = options.requireAssertion ?? false;
|
|
@@ -18280,7 +18400,7 @@ var init_custody = __esm({
|
|
|
18280
18400
|
this.#usage = new ScopedUsageReporter({
|
|
18281
18401
|
client: this.#client,
|
|
18282
18402
|
owns: (id) => this.#usageServed.has(id),
|
|
18283
|
-
token: async () => checkedEnrollmentToken(await this.#readToken()),
|
|
18403
|
+
token: async () => hasVaultHost() ? "" : checkedEnrollmentToken(await this.#readToken()),
|
|
18284
18404
|
logger: this.#logger,
|
|
18285
18405
|
setTimeout: this.#setTimeout,
|
|
18286
18406
|
clearTimeout: this.#clearTimeout
|
|
@@ -18291,7 +18411,7 @@ var init_custody = __esm({
|
|
|
18291
18411
|
if (this.#closed || this.#outage)
|
|
18292
18412
|
return;
|
|
18293
18413
|
this.#outage = true;
|
|
18294
|
-
this.#outageError = error instanceof
|
|
18414
|
+
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError();
|
|
18295
18415
|
this.#logger.warn("serving kept vault receipt", { reason: "unreachable" });
|
|
18296
18416
|
this.#scheduleProbe();
|
|
18297
18417
|
}
|
|
@@ -18341,6 +18461,8 @@ var init_custody = __esm({
|
|
|
18341
18461
|
}
|
|
18342
18462
|
async #token(signal) {
|
|
18343
18463
|
this.#check(signal);
|
|
18464
|
+
if (hasVaultHost())
|
|
18465
|
+
return "";
|
|
18344
18466
|
if (phaseDiagnostics.hasSubscribers)
|
|
18345
18467
|
phaseDiagnostics.publish({
|
|
18346
18468
|
logger: this.#logger,
|
|
@@ -18384,7 +18506,7 @@ var init_custody = __esm({
|
|
|
18384
18506
|
this.transportLost(error);
|
|
18385
18507
|
else
|
|
18386
18508
|
this.reachable();
|
|
18387
|
-
if (error instanceof
|
|
18509
|
+
if (error instanceof ClaustrumCredentialError5)
|
|
18388
18510
|
throw error;
|
|
18389
18511
|
if (classifyVaultFailure(error) === "unreachable")
|
|
18390
18512
|
throw new ClaustrumUnreachableError();
|
|
@@ -18603,7 +18725,7 @@ var init_custody = __esm({
|
|
|
18603
18725
|
if (kept.since === null)
|
|
18604
18726
|
kept.since = this.#now();
|
|
18605
18727
|
const attempt = Object.freeze(Object.defineProperty({ ...kept.attempt, fromKeptReceipt: true }, "accessToken", { value: kept.attempt.accessToken, enumerable: false }));
|
|
18606
|
-
this.#provenance.set(attempt, token);
|
|
18728
|
+
this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token, client: this.#client });
|
|
18607
18729
|
this.#keptAttempts.set(attempt, routeId);
|
|
18608
18730
|
return attempt;
|
|
18609
18731
|
}
|
|
@@ -18664,22 +18786,22 @@ var init_custody = __esm({
|
|
|
18664
18786
|
recordVersion: served.recordVersion,
|
|
18665
18787
|
expiresAtMs
|
|
18666
18788
|
}, "accessToken", { value: accessToken, enumerable: false }));
|
|
18667
|
-
this.#provenance.set(attempt, token);
|
|
18789
|
+
this.#provenance.set(attempt, { token, client: this.#client });
|
|
18668
18790
|
return attempt;
|
|
18669
18791
|
}
|
|
18670
18792
|
/**
|
|
18671
18793
|
* Report that a send this consumer actually made was rejected. Only a 401
|
|
18672
18794
|
* is reported (the vault refuses 429, 402 and 5xx reports), addressed by
|
|
18673
18795
|
* credential id with the exact record version that send was served, and
|
|
18674
|
-
*
|
|
18675
|
-
* custody did not issue is refused rather than reported.
|
|
18796
|
+
* sent through the client and enrollment token that authorized it. A receipt
|
|
18797
|
+
* this custody did not issue is refused rather than reported.
|
|
18676
18798
|
*/
|
|
18677
18799
|
async reportFailure(attempt, status, reporterSource) {
|
|
18678
18800
|
if (status !== 401)
|
|
18679
18801
|
return;
|
|
18680
18802
|
this.#check();
|
|
18681
|
-
const
|
|
18682
|
-
if (!
|
|
18803
|
+
const provenance = this.#provenance.get(attempt);
|
|
18804
|
+
if (!provenance)
|
|
18683
18805
|
throw new ClaustrumConsumerError("no-receipt", "Claustrum failure report requires an original dispatch receipt");
|
|
18684
18806
|
const keptRoute = this.#keptAttempts.get(attempt);
|
|
18685
18807
|
if (keptRoute !== void 0) {
|
|
@@ -18696,9 +18818,9 @@ var init_custody = __esm({
|
|
|
18696
18818
|
const pending = this.#reports.get(attempt);
|
|
18697
18819
|
if (pending)
|
|
18698
18820
|
return pending;
|
|
18699
|
-
const report = this.#call(() =>
|
|
18821
|
+
const report = this.#call(() => provenance.client.reportAuthFailureScoped({
|
|
18700
18822
|
credentialId: attempt.credentialId,
|
|
18701
|
-
enrollmentToken: token,
|
|
18823
|
+
enrollmentToken: provenance.token,
|
|
18702
18824
|
providerStatus: 401,
|
|
18703
18825
|
recordVersion: attempt.recordVersion,
|
|
18704
18826
|
reporterSource
|
|
@@ -19718,6 +19840,7 @@ var init_consumer = __esm({
|
|
|
19718
19840
|
init_custody();
|
|
19719
19841
|
init_enrollment();
|
|
19720
19842
|
init_errors2();
|
|
19843
|
+
init_host();
|
|
19721
19844
|
init_insula();
|
|
19722
19845
|
init_quota_writer2();
|
|
19723
19846
|
init_roster();
|
|
@@ -19780,6 +19903,8 @@ var init_consumer = __esm({
|
|
|
19780
19903
|
return pending;
|
|
19781
19904
|
}
|
|
19782
19905
|
async #active() {
|
|
19906
|
+
if (hasVaultHost())
|
|
19907
|
+
return true;
|
|
19783
19908
|
return await this.#options.isCustodyActive?.() ?? true;
|
|
19784
19909
|
}
|
|
19785
19910
|
#wait(pending, signal) {
|
|
@@ -19830,7 +19955,7 @@ var init_consumer = __esm({
|
|
|
19830
19955
|
#boundedConnect(attempt) {
|
|
19831
19956
|
const setTimer = this.#options.setTimeoutImpl ?? setTimeout;
|
|
19832
19957
|
const clearTimer = this.#options.clearTimeoutImpl ?? clearTimeout;
|
|
19833
|
-
const pending = this.#options.connect().then((client) => {
|
|
19958
|
+
const pending = (!hasVaultHost() && this.#options.connect ? this.#options.connect() : Promise.resolve().then(() => connectVaultHost(this.#options.pluginId))).then((client) => {
|
|
19834
19959
|
if (this.#shutdown.signal.aborted || attempt.timedOut) {
|
|
19835
19960
|
client.close();
|
|
19836
19961
|
if (!attempt.timedOut)
|
|
@@ -20083,7 +20208,8 @@ var init_consumer = __esm({
|
|
|
20083
20208
|
if (!this.#options.insula || this.#shutdown.signal.aborted || !await this.#active())
|
|
20084
20209
|
return;
|
|
20085
20210
|
try {
|
|
20086
|
-
|
|
20211
|
+
if (!hasVaultHost())
|
|
20212
|
+
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
20087
20213
|
await this.#getCustody();
|
|
20088
20214
|
await this.#insula?.source.refresh((this.#options.now ?? Date.now)());
|
|
20089
20215
|
} catch {
|
|
@@ -20099,7 +20225,8 @@ var init_consumer = __esm({
|
|
|
20099
20225
|
if (!this.#options.insula || this.#shutdown.signal.aborted || !await this.#active())
|
|
20100
20226
|
return void 0;
|
|
20101
20227
|
try {
|
|
20102
|
-
|
|
20228
|
+
if (!hasVaultHost())
|
|
20229
|
+
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
20103
20230
|
return this.#normalizeInsulaQuota(receipt2.assertedAccountIdentity);
|
|
20104
20231
|
} catch {
|
|
20105
20232
|
return void 0;
|
|
@@ -20114,7 +20241,8 @@ var init_consumer = __esm({
|
|
|
20114
20241
|
if (!this.#options.insula || this.#shutdown.signal.aborted || !await this.#active())
|
|
20115
20242
|
return void 0;
|
|
20116
20243
|
try {
|
|
20117
|
-
|
|
20244
|
+
if (!hasVaultHost())
|
|
20245
|
+
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
20118
20246
|
const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
20119
20247
|
const row = roster?.rows.find((entry) => entry.routeId === routeId);
|
|
20120
20248
|
return this.#normalizeInsulaQuota(row?.accountIdentity);
|
|
@@ -20128,7 +20256,8 @@ var init_consumer = __esm({
|
|
|
20128
20256
|
if (!options || this.#shutdown.signal.aborted || !await this.#active())
|
|
20129
20257
|
return { miss: "unreachable" };
|
|
20130
20258
|
try {
|
|
20131
|
-
|
|
20259
|
+
if (!hasVaultHost())
|
|
20260
|
+
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
20132
20261
|
const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
20133
20262
|
const account = roster?.rows.find((row) => row.routeId === routeId)?.accountIdentity;
|
|
20134
20263
|
if (!account || !this.#insula)
|
|
@@ -20632,6 +20761,7 @@ var init_hub = __esm({
|
|
|
20632
20761
|
init_custody();
|
|
20633
20762
|
init_enrollment();
|
|
20634
20763
|
init_errors2();
|
|
20764
|
+
init_host();
|
|
20635
20765
|
init_roster();
|
|
20636
20766
|
init_shutdown();
|
|
20637
20767
|
init_watch();
|
|
@@ -20861,7 +20991,7 @@ var init_hub = __esm({
|
|
|
20861
20991
|
const entry = { generation, timedOut: false };
|
|
20862
20992
|
const connectTimeoutMs = this.#options.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
|
|
20863
20993
|
let timer;
|
|
20864
|
-
const connect3 = this.#options.connect().then((client) => {
|
|
20994
|
+
const connect3 = (!hasVaultHost() && this.#options.connect ? this.#options.connect() : Promise.resolve().then(() => connectVaultHost(this.#options.pluginId))).then((client) => {
|
|
20865
20995
|
if (entry.timedOut) {
|
|
20866
20996
|
client.close();
|
|
20867
20997
|
throw unreachableConnect2();
|
|
@@ -21036,7 +21166,7 @@ var init_hub = __esm({
|
|
|
21036
21166
|
* runs the inactive transition; nothing else does.
|
|
21037
21167
|
*/
|
|
21038
21168
|
async #readAuthority() {
|
|
21039
|
-
const active2 = await this.#options.isCustodyActive?.() ?? true;
|
|
21169
|
+
const active2 = hasVaultHost() || (await this.#options.isCustodyActive?.() ?? true);
|
|
21040
21170
|
if (this.#shutdown.signal.aborted)
|
|
21041
21171
|
return false;
|
|
21042
21172
|
const was = this.#active;
|
|
@@ -21543,7 +21673,7 @@ __export(claustrum_exports, {
|
|
|
21543
21673
|
ChangeNoticeReader: () => ChangeNoticeReader,
|
|
21544
21674
|
ClaustrumConsumer: () => ClaustrumConsumer,
|
|
21545
21675
|
ClaustrumConsumerError: () => ClaustrumConsumerError,
|
|
21546
|
-
ClaustrumCredentialError: () =>
|
|
21676
|
+
ClaustrumCredentialError: () => ClaustrumCredentialError6,
|
|
21547
21677
|
ClaustrumDiscoveryHub: () => ClaustrumDiscoveryHub,
|
|
21548
21678
|
ClaustrumEnrollmentManager: () => ClaustrumEnrollmentManager,
|
|
21549
21679
|
ClaustrumScopedCustody: () => ClaustrumScopedCustody,
|
|
@@ -21559,6 +21689,8 @@ __export(claustrum_exports, {
|
|
|
21559
21689
|
ScopedRosterWatch: () => ScopedRosterWatch,
|
|
21560
21690
|
TERMINAL_ENROLLMENT_CODES: () => TERMINAL_ENROLLMENT_CODES,
|
|
21561
21691
|
VAULT_FAILURE_CLASSES: () => VAULT_FAILURE_CLASSES,
|
|
21692
|
+
VAULT_HOST_CONNECT_REFUSAL: () => VAULT_HOST_CONNECT_REFUSAL,
|
|
21693
|
+
VAULT_HOST_STATUS: () => VAULT_HOST_STATUS,
|
|
21562
21694
|
WATCH_RETRY_MS: () => WATCH_RETRY_MS,
|
|
21563
21695
|
acceptAccount: () => acceptAccount,
|
|
21564
21696
|
acceptVaultRoute: () => acceptVaultRoute,
|
|
@@ -21570,6 +21702,7 @@ __export(claustrum_exports, {
|
|
|
21570
21702
|
classifyVaultFailure: () => classifyVaultFailure,
|
|
21571
21703
|
connectClaustrumEnrollmentClient: () => connectClaustrumEnrollmentClient,
|
|
21572
21704
|
connectClaustrumScopedClient: () => connectClaustrumScopedClient,
|
|
21705
|
+
connectVaultHost: () => connectVaultHost,
|
|
21573
21706
|
custodyPlaceholder: () => custodyPlaceholder,
|
|
21574
21707
|
custodyPlaceholderKey: () => custodyPlaceholderKey,
|
|
21575
21708
|
decideScopedRetryAfter401: () => decideScopedRetryAfter401,
|
|
@@ -21596,11 +21729,12 @@ __export(claustrum_exports, {
|
|
|
21596
21729
|
reorderVaultRoster: () => reorderVaultRoster,
|
|
21597
21730
|
resetClaustrumEnrollmentState: () => resetClaustrumEnrollmentState,
|
|
21598
21731
|
resolveVaultPrimary: () => resolveVaultPrimary,
|
|
21732
|
+
vaultAuthority: () => vaultAuthority,
|
|
21599
21733
|
vaultRosterSeed: () => vaultRosterSeed,
|
|
21600
21734
|
vaultRoutingRows: () => vaultRoutingRows
|
|
21601
21735
|
});
|
|
21602
21736
|
import { ClaustrumClient } from "@cortexkit/claustrum-client";
|
|
21603
|
-
import { ClaustrumCredentialError as
|
|
21737
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError6 } from "@cortexkit/claustrum-client";
|
|
21604
21738
|
async function connectClaustrumScopedClient(options) {
|
|
21605
21739
|
const { connectTimeoutMs, ...client } = options;
|
|
21606
21740
|
const limit = connectTimeoutMs ?? SCOPED_CONNECT_TIMEOUT_MS;
|
|
@@ -21637,6 +21771,7 @@ var init_claustrum = __esm({
|
|
|
21637
21771
|
init_custody();
|
|
21638
21772
|
init_enrollment();
|
|
21639
21773
|
init_errors2();
|
|
21774
|
+
init_host();
|
|
21640
21775
|
init_host_slot();
|
|
21641
21776
|
init_hub();
|
|
21642
21777
|
init_insula();
|
|
@@ -23253,9 +23388,9 @@ var init_vault_account_source = __esm({
|
|
|
23253
23388
|
});
|
|
23254
23389
|
|
|
23255
23390
|
// ../core/dist/vault-enrollment-authority.js
|
|
23256
|
-
async function
|
|
23391
|
+
async function vaultAuthority2(paths, proposedName, reader) {
|
|
23257
23392
|
try {
|
|
23258
|
-
return await (reader ?? await loadCommonAuthClaustrum()).
|
|
23393
|
+
return await (reader ?? await loadCommonAuthClaustrum()).vaultAuthority(paths, proposedName);
|
|
23259
23394
|
} catch {
|
|
23260
23395
|
return "unreadable";
|
|
23261
23396
|
}
|
|
@@ -24923,7 +25058,7 @@ async function localAccountStoreAuthorized() {
|
|
|
24923
25058
|
if (folder?.refusal) return false;
|
|
24924
25059
|
const claustrum = await loadCommonAuthClaustrum();
|
|
24925
25060
|
const vaultDir = folder ? folder.vaultDir : decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
|
|
24926
|
-
return await
|
|
25061
|
+
return await vaultAuthority2(
|
|
24927
25062
|
claustrum.hostEnrollmentPaths({
|
|
24928
25063
|
stateDir: vaultDir,
|
|
24929
25064
|
host: OPENCODE_VAULT_HOST
|
|
@@ -27117,11 +27252,11 @@ function callbackParams(callbackUrl, expected) {
|
|
|
27117
27252
|
if (expected && state !== expected) throw new Error("OAuth state mismatch");
|
|
27118
27253
|
return { code: code2, state };
|
|
27119
27254
|
}
|
|
27120
|
-
async function performOAuthLogin(
|
|
27255
|
+
async function performOAuthLogin(request2, deps) {
|
|
27121
27256
|
const listener = await deps.startListener();
|
|
27122
27257
|
try {
|
|
27123
|
-
const authorization = await deps.authorize(
|
|
27124
|
-
if (!
|
|
27258
|
+
const authorization = await deps.authorize(request2.projectId ?? "");
|
|
27259
|
+
if (!request2.noBrowser && !request2.isHeadless) {
|
|
27125
27260
|
await deps.openBrowser(authorization.url);
|
|
27126
27261
|
}
|
|
27127
27262
|
const params = callbackParams(
|
|
@@ -27131,7 +27266,7 @@ async function performOAuthLogin(request, deps) {
|
|
|
27131
27266
|
const result = await deps.exchange(params.code, params.state);
|
|
27132
27267
|
if (result.type === "failed") throw new Error(result.error);
|
|
27133
27268
|
await deps.upsert(result);
|
|
27134
|
-
|
|
27269
|
+
request2.accounts.push(result);
|
|
27135
27270
|
return result;
|
|
27136
27271
|
} finally {
|
|
27137
27272
|
await listener.close().catch(() => {
|
|
@@ -27932,13 +28067,13 @@ async function startOAuthListener({
|
|
|
27932
28067
|
rejectCallback(new Error("Timed out waiting for OAuth callback"));
|
|
27933
28068
|
}, timeoutMs);
|
|
27934
28069
|
timeoutHandle.unref?.();
|
|
27935
|
-
const server = createServer((
|
|
27936
|
-
if (!
|
|
28070
|
+
const server = createServer((request2, response) => {
|
|
28071
|
+
if (!request2.url) {
|
|
27937
28072
|
response.writeHead(400, { "Content-Type": "text/plain" });
|
|
27938
28073
|
response.end("Invalid request");
|
|
27939
28074
|
return;
|
|
27940
28075
|
}
|
|
27941
|
-
const url = new URL(
|
|
28076
|
+
const url = new URL(request2.url, origin);
|
|
27942
28077
|
if (url.pathname !== callbackPath) {
|
|
27943
28078
|
response.writeHead(404, { "Content-Type": "text/plain" });
|
|
27944
28079
|
response.end("Not found");
|
|
@@ -28252,7 +28387,7 @@ import { createHash as createHash12, randomBytes as randomBytes3, randomUUID as
|
|
|
28252
28387
|
import { constants as fsConstants2 } from "node:fs";
|
|
28253
28388
|
import { chmod as chmod5, mkdir as mkdir14, open as open10, readFile as readFile12, realpath as realpath4, rename as rename12, stat as stat13, unlink as unlink11 } from "node:fs/promises";
|
|
28254
28389
|
import { basename as basename5, dirname as dirname19, extname as extname2, isAbsolute as isAbsolute4, join as join18, resolve as resolve19 } from "node:path";
|
|
28255
|
-
import { ClaustrumCredentialError as
|
|
28390
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
28256
28391
|
|
|
28257
28392
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
28258
28393
|
import { lstat as lstat7, stat as stat11 } from "node:fs/promises";
|
|
@@ -29179,6 +29314,90 @@ var ClaustrumConsumerError2 = class extends Error {
|
|
|
29179
29314
|
}
|
|
29180
29315
|
};
|
|
29181
29316
|
|
|
29317
|
+
// src/common-auth-embedded/claustrum/host.js
|
|
29318
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError8 } from "@cortexkit/claustrum-client";
|
|
29319
|
+
|
|
29320
|
+
// src/common-auth-embedded/claustrum/availability.js
|
|
29321
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError7 } from "@cortexkit/claustrum-client";
|
|
29322
|
+
import { SocketClosedError as SocketClosedError2, SocketTimeoutError as SocketTimeoutError2, SubcCallError as SubcCallError2 } from "@cortexkit/subc-client";
|
|
29323
|
+
var VAULT_FAILURE_CLASSES2 = Object.freeze({
|
|
29324
|
+
ECONNREFUSED: "unreachable",
|
|
29325
|
+
ENOENT: "unreachable",
|
|
29326
|
+
ECONNRESET: "unreachable",
|
|
29327
|
+
EPIPE: "unreachable",
|
|
29328
|
+
ETIMEDOUT: "unreachable",
|
|
29329
|
+
transport_error: "unreachable",
|
|
29330
|
+
unavailable: "unreachable",
|
|
29331
|
+
timeout: "unreachable",
|
|
29332
|
+
route_closed: "unreachable",
|
|
29333
|
+
daemon_draining: "unreachable",
|
|
29334
|
+
connection_closed: "unreachable",
|
|
29335
|
+
connection_dropped: "unreachable",
|
|
29336
|
+
request_deadline: "unreachable",
|
|
29337
|
+
deadline_exceeded_no_drop_observed: "unreachable",
|
|
29338
|
+
module_reloading: "unreachable",
|
|
29339
|
+
module_warming: "unreachable",
|
|
29340
|
+
target_unavailable: "unreachable",
|
|
29341
|
+
module_timeout: "unreachable",
|
|
29342
|
+
invalid_response: "answered",
|
|
29343
|
+
invalid_record_version: "answered",
|
|
29344
|
+
invalid_expiry: "answered",
|
|
29345
|
+
invalid_status: "answered",
|
|
29346
|
+
invalid_params: "answered",
|
|
29347
|
+
ttl_unsatisfiable: "answered",
|
|
29348
|
+
not_found: "answered",
|
|
29349
|
+
enrollment_revoked: "answered",
|
|
29350
|
+
enrollment_invalid: "answered",
|
|
29351
|
+
grant_denied: "answered",
|
|
29352
|
+
credential_unavailable: "answered",
|
|
29353
|
+
needs_reauth: "answered",
|
|
29354
|
+
declined: "answered",
|
|
29355
|
+
disabled: "answered",
|
|
29356
|
+
identity_changed: "answered",
|
|
29357
|
+
closed: "answered",
|
|
29358
|
+
client_closed: "answered",
|
|
29359
|
+
pending_exists: "answered",
|
|
29360
|
+
pending_queue_full: "answered",
|
|
29361
|
+
already_consumed: "answered",
|
|
29362
|
+
superseded: "answered",
|
|
29363
|
+
stale_generation: "answered",
|
|
29364
|
+
missing_identity: "answered",
|
|
29365
|
+
invalid_control_body: "answered",
|
|
29366
|
+
unknown_module: "answered",
|
|
29367
|
+
module_removed: "answered",
|
|
29368
|
+
capability_denied: "answered",
|
|
29369
|
+
unknown_channel: "unreachable",
|
|
29370
|
+
stale_route_epoch: "unreachable",
|
|
29371
|
+
capability_forbidden: "answered",
|
|
29372
|
+
capability_unprovided: "answered",
|
|
29373
|
+
capability_ambiguous: "answered",
|
|
29374
|
+
invalid_capability_identifier: "answered",
|
|
29375
|
+
binary_body_required: "answered",
|
|
29376
|
+
binary_call_requires_call_binary: "answered",
|
|
29377
|
+
corr_exhausted: "answered",
|
|
29378
|
+
late_route_cleanup_failed: "answered",
|
|
29379
|
+
reverse_request_capability_not_declared: "answered",
|
|
29380
|
+
stale_route_handle: "answered",
|
|
29381
|
+
reverse_request_unhandled: "answered",
|
|
29382
|
+
handler_error: "answered",
|
|
29383
|
+
health_error: "answered",
|
|
29384
|
+
duplicate_module_id: "answered",
|
|
29385
|
+
route_rejected: "answered",
|
|
29386
|
+
lock_busy: "answered",
|
|
29387
|
+
owner_invalid: "answered",
|
|
29388
|
+
renewal_failed: "answered",
|
|
29389
|
+
unsupported_platform: "answered",
|
|
29390
|
+
EACCES: "answered",
|
|
29391
|
+
EPERM: "answered",
|
|
29392
|
+
ERR_PRIVATE_FILES_SECURITY: "answered"
|
|
29393
|
+
});
|
|
29394
|
+
|
|
29395
|
+
// src/common-auth-embedded/claustrum/host.js
|
|
29396
|
+
var VAULT_HOST_CONNECT_REFUSAL2 = "This host gets its vault accounts from Thalamus, so it can't connect to the vault itself.";
|
|
29397
|
+
function hasVaultHost2() {
|
|
29398
|
+
return process.env.CORTEXKIT_VAULT_HOST === "thalamus";
|
|
29399
|
+
}
|
|
29400
|
+
|
|
29182
29401
|
// src/common-auth-embedded/claustrum/enrollment.js
|
|
29183
29402
|
var ENROLLMENT_SCHEMA2 = 1;
|
|
29184
29403
|
var ENROLLMENT_FILE_MAX_BYTES2 = 16 * 1024;
|
|
@@ -29202,7 +29421,7 @@ var RETRYABLE_ENROLLMENT_CODES2 = /* @__PURE__ */ new Set([
|
|
|
29202
29421
|
"pending_queue_full"
|
|
29203
29422
|
]);
|
|
29204
29423
|
function classifyEnrollmentError2(error) {
|
|
29205
|
-
if (!(error instanceof
|
|
29424
|
+
if (!(error instanceof ClaustrumCredentialError9))
|
|
29206
29425
|
return void 0;
|
|
29207
29426
|
if (TERMINAL_ENROLLMENT_CODES2.has(error.code))
|
|
29208
29427
|
return { code: error.code, disposition: "terminal" };
|
|
@@ -29526,7 +29745,7 @@ async function readEnrollmentStatus2(paths, proposedName) {
|
|
|
29526
29745
|
}
|
|
29527
29746
|
return { status: statusFromState2(state), usesProposedName: false };
|
|
29528
29747
|
}
|
|
29529
|
-
async function
|
|
29748
|
+
async function enrollmentAuthority2(paths, proposedName) {
|
|
29530
29749
|
let status;
|
|
29531
29750
|
try {
|
|
29532
29751
|
status = await readClaustrumEnrollmentStatus2(paths, proposedName);
|
|
@@ -29551,6 +29770,11 @@ async function enrollmentAuthority3(paths, proposedName) {
|
|
|
29551
29770
|
}
|
|
29552
29771
|
return "local";
|
|
29553
29772
|
}
|
|
29773
|
+
async function vaultAuthority3(paths, proposedName) {
|
|
29774
|
+
if (hasVaultHost2())
|
|
29775
|
+
return "host";
|
|
29776
|
+
return enrollmentAuthority2(paths, proposedName);
|
|
29777
|
+
}
|
|
29554
29778
|
function statusFromState2(state) {
|
|
29555
29779
|
if (state.phase === "pending") {
|
|
29556
29780
|
return {
|
|
@@ -30519,6 +30743,8 @@ function approveCommand(requestId, name) {
|
|
|
30519
30743
|
return `ck auth enroll approve --request-id ${requestId} --name ${name}`;
|
|
30520
30744
|
}
|
|
30521
30745
|
async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
30746
|
+
if (hasVaultHost2())
|
|
30747
|
+
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
30522
30748
|
const { name, paths: input } = plugin.vault.hosts[host];
|
|
30523
30749
|
const paths = hostEnrollmentPaths2(input);
|
|
30524
30750
|
await fence();
|
|
@@ -31002,8 +31228,8 @@ async function enrollmentReport(plugin, hosts, recorded) {
|
|
|
31002
31228
|
let outcome = recorded.get(host) ?? "not-enrolled";
|
|
31003
31229
|
if (outcome === "unknown") {
|
|
31004
31230
|
const { name, paths } = plugin.vault.hosts[host];
|
|
31005
|
-
const authority = await
|
|
31006
|
-
if (authority === "vault")
|
|
31231
|
+
const authority = await vaultAuthority3(hostEnrollmentPaths2(paths), name).catch(() => "unreadable");
|
|
31232
|
+
if (authority === "vault" || authority === "host")
|
|
31007
31233
|
outcome = "enrolled";
|
|
31008
31234
|
else if (authority === "local")
|
|
31009
31235
|
outcome = "not-enrolled";
|
|
@@ -31014,6 +31240,8 @@ async function enrollmentReport(plugin, hosts, recorded) {
|
|
|
31014
31240
|
}
|
|
31015
31241
|
async function runSetup(plugin, argv = [], io = {}) {
|
|
31016
31242
|
const options = parseSetupFlags(argv);
|
|
31243
|
+
if (hasVaultHost2())
|
|
31244
|
+
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
31017
31245
|
validatePlugin(plugin);
|
|
31018
31246
|
const terminal = io.terminal ?? processTerminal2();
|
|
31019
31247
|
const detection = await detectHosts(plugin, io);
|
|
@@ -31245,7 +31473,7 @@ async function readNativeAuth(path2) {
|
|
|
31245
31473
|
}
|
|
31246
31474
|
async function assertLocalOpenCodeLogin(legacyPath, generation) {
|
|
31247
31475
|
const claustrum = await loadCommonAuthClaustrum();
|
|
31248
|
-
if (await claustrum.
|
|
31476
|
+
if (await claustrum.vaultAuthority(
|
|
31249
31477
|
claustrum.hostEnrollmentPaths({
|
|
31250
31478
|
stateDir: openCodeVaultDir(legacyPath),
|
|
31251
31479
|
host: "opencode"
|
|
@@ -31278,7 +31506,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
31278
31506
|
await assertSetupHostsStopped();
|
|
31279
31507
|
const claustrum = await loadCommonAuthClaustrum();
|
|
31280
31508
|
const stateDir = host === "opencode" ? openCodeVaultDir(resolve20(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
31281
|
-
if (await claustrum.
|
|
31509
|
+
if (await claustrum.vaultAuthority(
|
|
31282
31510
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
31283
31511
|
`antigravity-auth-${host}`
|
|
31284
31512
|
) !== expectedAuthority)
|
|
@@ -31325,7 +31553,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
31325
31553
|
paths: { stateDir: piDir, host: "pi" }
|
|
31326
31554
|
}
|
|
31327
31555
|
};
|
|
31328
|
-
const authority = (host) => claustrum.
|
|
31556
|
+
const authority = (host) => claustrum.vaultAuthority(
|
|
31329
31557
|
claustrum.hostEnrollmentPaths(hosts[host].paths),
|
|
31330
31558
|
hosts[host].name
|
|
31331
31559
|
);
|
|
@@ -31491,7 +31719,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
31491
31719
|
);
|
|
31492
31720
|
return;
|
|
31493
31721
|
}
|
|
31494
|
-
if (await authority(host)
|
|
31722
|
+
if (!["host", "vault"].includes(await authority(host)))
|
|
31495
31723
|
throw new Error("Vault access must be approved before activation.");
|
|
31496
31724
|
if (host === "opencode") {
|
|
31497
31725
|
if (context.opencodeGeneration === "2") {
|
|
@@ -31524,7 +31752,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
31524
31752
|
},
|
|
31525
31753
|
migrate: async (host, context) => {
|
|
31526
31754
|
if (context.mode === "local") await assertLocal(host, context);
|
|
31527
|
-
else if (await authority(host)
|
|
31755
|
+
else if (!["host", "vault"].includes(await authority(host)))
|
|
31528
31756
|
throw new Error("Vault access must remain approved during setup.");
|
|
31529
31757
|
if (host === "opencode") {
|
|
31530
31758
|
const current = await authority(host);
|
|
@@ -31590,6 +31818,9 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
31590
31818
|
};
|
|
31591
31819
|
}
|
|
31592
31820
|
async function runPluginSetup(argv, deps, migrateOpenCode, io = {}) {
|
|
31821
|
+
const claustrum = await loadCommonAuthClaustrum();
|
|
31822
|
+
if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
|
|
31823
|
+
throw new Error(claustrum.VAULT_HOST_CONNECT_REFUSAL);
|
|
31593
31824
|
const plugin = await createSetupPlugin(
|
|
31594
31825
|
deps,
|
|
31595
31826
|
migrateOpenCode,
|
|
@@ -32028,7 +32259,7 @@ function createDefaultCliDependencies() {
|
|
|
32028
32259
|
isHeadless: () => Boolean(
|
|
32029
32260
|
process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.OPENCODE_HEADLESS
|
|
32030
32261
|
),
|
|
32031
|
-
performLogin: async (
|
|
32262
|
+
performLogin: async (request2, openBrowser, host, context) => {
|
|
32032
32263
|
if (host === "pi" && !context)
|
|
32033
32264
|
throw new Error(
|
|
32034
32265
|
"Pi setup requires its detected native agent directory."
|
|
@@ -32043,7 +32274,7 @@ function createDefaultCliDependencies() {
|
|
|
32043
32274
|
context?.opencodeGeneration
|
|
32044
32275
|
);
|
|
32045
32276
|
try {
|
|
32046
|
-
return await performOAuthLogin(
|
|
32277
|
+
return await performOAuthLogin(request2, {
|
|
32047
32278
|
authorize: authorizeAntigravity,
|
|
32048
32279
|
exchange: exchangeAntigravity,
|
|
32049
32280
|
startListener: startOAuthListener,
|
|
@@ -32061,7 +32292,7 @@ function createDefaultCliDependencies() {
|
|
|
32061
32292
|
await persistCliStoreLogin(
|
|
32062
32293
|
repository,
|
|
32063
32294
|
result,
|
|
32064
|
-
|
|
32295
|
+
request2.startFresh && request2.accounts.length === 0
|
|
32065
32296
|
);
|
|
32066
32297
|
}
|
|
32067
32298
|
});
|