@cortexkit/opencode-antigravity-auth 3.0.33 → 3.0.35
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 +586 -294
- 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 +1 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +15 -4
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts +1 -0
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +41 -20
- 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/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 +1 -1
- package/dist/types/src/ga/server/index.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 +13 -5
- package/src/tui-ga-raw/host-ga.tsx +43 -19
package/dist/index.js
CHANGED
|
@@ -16352,7 +16352,7 @@ var init_pull = __esm({
|
|
|
16352
16352
|
const locks = new LockStack(ctx.lockDefaults, ctx.lockEnv);
|
|
16353
16353
|
const progress = { writes: 0 };
|
|
16354
16354
|
try {
|
|
16355
|
-
const
|
|
16355
|
+
const request2 = await withTransaction(ctx, locks, progress, { operation: "pull", rowId: id }, async (tx) => {
|
|
16356
16356
|
if (tx.reservation(id) !== void 0)
|
|
16357
16357
|
return void 0;
|
|
16358
16358
|
await tx.completeTorn();
|
|
@@ -16377,14 +16377,14 @@ var init_pull = __esm({
|
|
|
16377
16377
|
};
|
|
16378
16378
|
}, { completeTorn: false });
|
|
16379
16379
|
await locks.releaseAll();
|
|
16380
|
-
if (!
|
|
16380
|
+
if (!request2) {
|
|
16381
16381
|
this.firedAtLoad.delete(id);
|
|
16382
16382
|
return;
|
|
16383
16383
|
}
|
|
16384
16384
|
await ctx.hold?.("pull-before-request", id);
|
|
16385
16385
|
let observation;
|
|
16386
16386
|
try {
|
|
16387
|
-
observation = await this.hook?.(
|
|
16387
|
+
observation = await this.hook?.(request2);
|
|
16388
16388
|
} catch (cause) {
|
|
16389
16389
|
throw new PoolOperationError({
|
|
16390
16390
|
operation: "pull",
|
|
@@ -16398,8 +16398,8 @@ var init_pull = __esm({
|
|
|
16398
16398
|
}
|
|
16399
16399
|
const publish = rt.publishQuota ?? ((rowId2, attribution, value) => recordQuota(rt, rowId2, attribution, value));
|
|
16400
16400
|
await publish(id, {
|
|
16401
|
-
credentialEpoch:
|
|
16402
|
-
...
|
|
16401
|
+
credentialEpoch: request2.credentialEpoch,
|
|
16402
|
+
...request2.identity !== void 0 ? { identity: request2.identity } : {}
|
|
16403
16403
|
}, observation);
|
|
16404
16404
|
} catch (error) {
|
|
16405
16405
|
this.firedAtLoad.delete(id);
|
|
@@ -19039,12 +19039,12 @@ function coerceValues(knobs, raw) {
|
|
|
19039
19039
|
}
|
|
19040
19040
|
return { values };
|
|
19041
19041
|
}
|
|
19042
|
-
function findAction(sections,
|
|
19043
|
-
const section = sections.find((entry) => entry.id ===
|
|
19042
|
+
function findAction(sections, request2) {
|
|
19043
|
+
const section = sections.find((entry) => entry.id === request2.sectionId);
|
|
19044
19044
|
if (!section)
|
|
19045
19045
|
return void 0;
|
|
19046
|
-
const actions =
|
|
19047
|
-
return actions?.find((action) => action.id ===
|
|
19046
|
+
const actions = request2.itemId === void 0 ? section.content.actions : section.content.items?.find((item) => item.id === request2.itemId)?.actions;
|
|
19047
|
+
return actions?.find((action) => action.id === request2.actionId);
|
|
19048
19048
|
}
|
|
19049
19049
|
function createCommandMenu(options) {
|
|
19050
19050
|
const logger3 = options.logger ?? createLogger2("commands");
|
|
@@ -19124,10 +19124,10 @@ function createCommandMenu(options) {
|
|
|
19124
19124
|
const own = ownInvocation(invocation, redact3);
|
|
19125
19125
|
return dialogPayload(options.command, options.title, await sections(own), seam);
|
|
19126
19126
|
},
|
|
19127
|
-
async apply(
|
|
19127
|
+
async apply(request2, invocation) {
|
|
19128
19128
|
const own = ownInvocation(invocation, redact3);
|
|
19129
19129
|
const finish = async (outcome2) => applyResult(options.command, options.title, await sections(own), outcome2, seam);
|
|
19130
|
-
const action =
|
|
19130
|
+
const action = request2.command === options.command ? findAction(await sections(own), request2) : void 0;
|
|
19131
19131
|
if (!action)
|
|
19132
19132
|
return finish({
|
|
19133
19133
|
ok: false,
|
|
@@ -19135,14 +19135,14 @@ function createCommandMenu(options) {
|
|
|
19135
19135
|
text: "That action is no longer available."
|
|
19136
19136
|
});
|
|
19137
19137
|
const confirmation = confirmationOf(action);
|
|
19138
|
-
if (confirmation &&
|
|
19138
|
+
if (confirmation && request2.confirmed !== true)
|
|
19139
19139
|
return finish({
|
|
19140
19140
|
ok: false,
|
|
19141
19141
|
code: "needs-confirmation",
|
|
19142
19142
|
text: confirmation.message,
|
|
19143
19143
|
needsConfirmation: true
|
|
19144
19144
|
});
|
|
19145
|
-
const coerced = coerceValues(action.knobs ?? [],
|
|
19145
|
+
const coerced = coerceValues(action.knobs ?? [], request2.values);
|
|
19146
19146
|
if ("problem" in coerced)
|
|
19147
19147
|
return finish({
|
|
19148
19148
|
ok: false,
|
|
@@ -19153,7 +19153,7 @@ function createCommandMenu(options) {
|
|
|
19153
19153
|
try {
|
|
19154
19154
|
const result = await action.run({
|
|
19155
19155
|
values: coerced.values,
|
|
19156
|
-
...
|
|
19156
|
+
...request2.itemId !== void 0 ? { itemId: request2.itemId } : {},
|
|
19157
19157
|
invocation: own
|
|
19158
19158
|
});
|
|
19159
19159
|
outcome = typeof result === "string" ? { ok: true, text: result } : {
|
|
@@ -19165,8 +19165,8 @@ function createCommandMenu(options) {
|
|
|
19165
19165
|
const failure2 = projectFailure(error);
|
|
19166
19166
|
logger3.warn("command menu action failed", {
|
|
19167
19167
|
command: options.command,
|
|
19168
|
-
section:
|
|
19169
|
-
action:
|
|
19168
|
+
section: request2.sectionId,
|
|
19169
|
+
action: request2.actionId,
|
|
19170
19170
|
code: failure2.code,
|
|
19171
19171
|
error: redact3(error instanceof Error ? error.message : String(error))
|
|
19172
19172
|
});
|
|
@@ -19452,6 +19452,219 @@ var init_commands = __esm({
|
|
|
19452
19452
|
}
|
|
19453
19453
|
});
|
|
19454
19454
|
|
|
19455
|
+
// ../core/dist/common-auth-embedded/claustrum/errors.js
|
|
19456
|
+
var ClaustrumConsumerError;
|
|
19457
|
+
var init_errors2 = __esm({
|
|
19458
|
+
"../core/dist/common-auth-embedded/claustrum/errors.js"() {
|
|
19459
|
+
"use strict";
|
|
19460
|
+
ClaustrumConsumerError = class extends Error {
|
|
19461
|
+
kind;
|
|
19462
|
+
constructor(kind, message) {
|
|
19463
|
+
super(message);
|
|
19464
|
+
this.name = "ClaustrumConsumerError";
|
|
19465
|
+
this.kind = kind;
|
|
19466
|
+
}
|
|
19467
|
+
};
|
|
19468
|
+
}
|
|
19469
|
+
});
|
|
19470
|
+
|
|
19471
|
+
// ../core/dist/common-auth-embedded/claustrum/availability.js
|
|
19472
|
+
import { ClaustrumCredentialError } from "@cortexkit/claustrum-client";
|
|
19473
|
+
import { SocketClosedError, SocketTimeoutError, SubcCallError } from "@cortexkit/subc-client";
|
|
19474
|
+
function classifyVaultFailure(error) {
|
|
19475
|
+
if (error instanceof ClaustrumUnreachableError || error instanceof SocketClosedError || error instanceof SocketTimeoutError)
|
|
19476
|
+
return "unreachable";
|
|
19477
|
+
const code2 = error instanceof ClaustrumCredentialError || error instanceof SubcCallError ? error.code : error instanceof Error && "code" in error ? error.code : void 0;
|
|
19478
|
+
if (typeof code2 !== "string" || !Object.hasOwn(VAULT_FAILURE_CLASSES, code2))
|
|
19479
|
+
return "answered";
|
|
19480
|
+
return VAULT_FAILURE_CLASSES[code2];
|
|
19481
|
+
}
|
|
19482
|
+
var VAULT_FAILURE_CLASSES, ClaustrumUnreachableError;
|
|
19483
|
+
var init_availability = __esm({
|
|
19484
|
+
"../core/dist/common-auth-embedded/claustrum/availability.js"() {
|
|
19485
|
+
"use strict";
|
|
19486
|
+
init_errors2();
|
|
19487
|
+
VAULT_FAILURE_CLASSES = Object.freeze({
|
|
19488
|
+
ECONNREFUSED: "unreachable",
|
|
19489
|
+
ENOENT: "unreachable",
|
|
19490
|
+
ECONNRESET: "unreachable",
|
|
19491
|
+
EPIPE: "unreachable",
|
|
19492
|
+
ETIMEDOUT: "unreachable",
|
|
19493
|
+
transport_error: "unreachable",
|
|
19494
|
+
unavailable: "unreachable",
|
|
19495
|
+
timeout: "unreachable",
|
|
19496
|
+
route_closed: "unreachable",
|
|
19497
|
+
daemon_draining: "unreachable",
|
|
19498
|
+
connection_closed: "unreachable",
|
|
19499
|
+
connection_dropped: "unreachable",
|
|
19500
|
+
request_deadline: "unreachable",
|
|
19501
|
+
deadline_exceeded_no_drop_observed: "unreachable",
|
|
19502
|
+
module_reloading: "unreachable",
|
|
19503
|
+
module_warming: "unreachable",
|
|
19504
|
+
target_unavailable: "unreachable",
|
|
19505
|
+
module_timeout: "unreachable",
|
|
19506
|
+
invalid_response: "answered",
|
|
19507
|
+
invalid_record_version: "answered",
|
|
19508
|
+
invalid_expiry: "answered",
|
|
19509
|
+
invalid_status: "answered",
|
|
19510
|
+
invalid_params: "answered",
|
|
19511
|
+
ttl_unsatisfiable: "answered",
|
|
19512
|
+
not_found: "answered",
|
|
19513
|
+
enrollment_revoked: "answered",
|
|
19514
|
+
enrollment_invalid: "answered",
|
|
19515
|
+
grant_denied: "answered",
|
|
19516
|
+
credential_unavailable: "answered",
|
|
19517
|
+
needs_reauth: "answered",
|
|
19518
|
+
declined: "answered",
|
|
19519
|
+
disabled: "answered",
|
|
19520
|
+
identity_changed: "answered",
|
|
19521
|
+
closed: "answered",
|
|
19522
|
+
client_closed: "answered",
|
|
19523
|
+
pending_exists: "answered",
|
|
19524
|
+
pending_queue_full: "answered",
|
|
19525
|
+
already_consumed: "answered",
|
|
19526
|
+
superseded: "answered",
|
|
19527
|
+
stale_generation: "answered",
|
|
19528
|
+
missing_identity: "answered",
|
|
19529
|
+
invalid_control_body: "answered",
|
|
19530
|
+
unknown_module: "answered",
|
|
19531
|
+
module_removed: "answered",
|
|
19532
|
+
capability_denied: "answered",
|
|
19533
|
+
unknown_channel: "unreachable",
|
|
19534
|
+
stale_route_epoch: "unreachable",
|
|
19535
|
+
capability_forbidden: "answered",
|
|
19536
|
+
capability_unprovided: "answered",
|
|
19537
|
+
capability_ambiguous: "answered",
|
|
19538
|
+
invalid_capability_identifier: "answered",
|
|
19539
|
+
binary_body_required: "answered",
|
|
19540
|
+
binary_call_requires_call_binary: "answered",
|
|
19541
|
+
corr_exhausted: "answered",
|
|
19542
|
+
late_route_cleanup_failed: "answered",
|
|
19543
|
+
reverse_request_capability_not_declared: "answered",
|
|
19544
|
+
stale_route_handle: "answered",
|
|
19545
|
+
reverse_request_unhandled: "answered",
|
|
19546
|
+
handler_error: "answered",
|
|
19547
|
+
health_error: "answered",
|
|
19548
|
+
duplicate_module_id: "answered",
|
|
19549
|
+
route_rejected: "answered",
|
|
19550
|
+
lock_busy: "answered",
|
|
19551
|
+
owner_invalid: "answered",
|
|
19552
|
+
renewal_failed: "answered",
|
|
19553
|
+
unsupported_platform: "answered",
|
|
19554
|
+
EACCES: "answered",
|
|
19555
|
+
EPERM: "answered",
|
|
19556
|
+
ERR_PRIVATE_FILES_SECURITY: "answered"
|
|
19557
|
+
});
|
|
19558
|
+
ClaustrumUnreachableError = class extends ClaustrumConsumerError {
|
|
19559
|
+
constructor() {
|
|
19560
|
+
super("unavailable", "Claustrum scoped operation unavailable");
|
|
19561
|
+
this.name = "ClaustrumUnreachableError";
|
|
19562
|
+
}
|
|
19563
|
+
};
|
|
19564
|
+
}
|
|
19565
|
+
});
|
|
19566
|
+
|
|
19567
|
+
// ../core/dist/common-auth-embedded/claustrum/host.js
|
|
19568
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError2 } from "@cortexkit/claustrum-client";
|
|
19569
|
+
function isVaultHostClient(client) {
|
|
19570
|
+
return hostClients.has(client);
|
|
19571
|
+
}
|
|
19572
|
+
function hasVaultHost() {
|
|
19573
|
+
return process.env.CORTEXKIT_VAULT_HOST === "thalamus";
|
|
19574
|
+
}
|
|
19575
|
+
function hostError(error) {
|
|
19576
|
+
if (typeof error !== "object" || error === null)
|
|
19577
|
+
return error;
|
|
19578
|
+
const value = error;
|
|
19579
|
+
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"))
|
|
19580
|
+
return new ClaustrumCredentialError2(value.code, value.class, value.action);
|
|
19581
|
+
if (value.name === "ClaustrumUnreachableError" || typeof value.code === "string" && classifyVaultFailure(Object.assign(new Error(), { code: value.code })) === "unreachable")
|
|
19582
|
+
return new ClaustrumUnreachableError();
|
|
19583
|
+
return error;
|
|
19584
|
+
}
|
|
19585
|
+
function call(operation) {
|
|
19586
|
+
try {
|
|
19587
|
+
return operation();
|
|
19588
|
+
} catch (error) {
|
|
19589
|
+
throw hostError(error);
|
|
19590
|
+
}
|
|
19591
|
+
}
|
|
19592
|
+
async function request(operation) {
|
|
19593
|
+
try {
|
|
19594
|
+
return await operation();
|
|
19595
|
+
} catch (error) {
|
|
19596
|
+
throw hostError(error);
|
|
19597
|
+
}
|
|
19598
|
+
}
|
|
19599
|
+
function wrapHostClient(client) {
|
|
19600
|
+
const watchScoped = client.watchScoped?.bind(client);
|
|
19601
|
+
const reportUsageScoped = client.reportUsageScoped?.bind(client);
|
|
19602
|
+
return {
|
|
19603
|
+
listScoped: (...args) => request(() => client.listScoped(...args)),
|
|
19604
|
+
getScoped: (...args) => request(() => client.getScoped(...args)),
|
|
19605
|
+
reportAuthFailureScoped: (...args) => request(() => client.reportAuthFailureScoped(...args)),
|
|
19606
|
+
close: () => call(() => client.close()),
|
|
19607
|
+
...watchScoped && {
|
|
19608
|
+
watchScoped: (...args) => {
|
|
19609
|
+
const watch = call(() => watchScoped(...args));
|
|
19610
|
+
return {
|
|
19611
|
+
stop: () => call(() => watch.stop()),
|
|
19612
|
+
closed: request(async () => {
|
|
19613
|
+
const end = await watch.closed;
|
|
19614
|
+
return end.kind === "refused" || end.kind === "transport_lost" ? { ...end, error: hostError(end.error) } : end;
|
|
19615
|
+
})
|
|
19616
|
+
};
|
|
19617
|
+
}
|
|
19618
|
+
},
|
|
19619
|
+
...reportUsageScoped && {
|
|
19620
|
+
reportUsageScoped: (...args) => request(() => reportUsageScoped(...args))
|
|
19621
|
+
},
|
|
19622
|
+
...client.insula && {
|
|
19623
|
+
insula: wrapInsula(client.insula)
|
|
19624
|
+
}
|
|
19625
|
+
};
|
|
19626
|
+
}
|
|
19627
|
+
function wrapInsula(transport) {
|
|
19628
|
+
const watchUsage = transport.watchUsage?.bind(transport);
|
|
19629
|
+
return {
|
|
19630
|
+
connectionFile: transport.connectionFile,
|
|
19631
|
+
getUsage: () => request(() => transport.getUsage()),
|
|
19632
|
+
...watchUsage && {
|
|
19633
|
+
watchUsage: (...args) => {
|
|
19634
|
+
const watch = call(() => watchUsage(...args));
|
|
19635
|
+
return {
|
|
19636
|
+
stop: () => call(() => watch.stop()),
|
|
19637
|
+
closed: request(() => watch.closed)
|
|
19638
|
+
};
|
|
19639
|
+
}
|
|
19640
|
+
}
|
|
19641
|
+
};
|
|
19642
|
+
}
|
|
19643
|
+
function connectVaultHost(pluginId) {
|
|
19644
|
+
if (!hasVaultHost() || !pluginId)
|
|
19645
|
+
throw new ClaustrumUnreachableError();
|
|
19646
|
+
try {
|
|
19647
|
+
const accessor = globalThis[/* @__PURE__ */ Symbol.for("cortexkit.vault")];
|
|
19648
|
+
if (typeof accessor !== "function")
|
|
19649
|
+
throw new ClaustrumUnreachableError();
|
|
19650
|
+
const client = wrapHostClient(accessor(pluginId));
|
|
19651
|
+
hostClients.add(client);
|
|
19652
|
+
return client;
|
|
19653
|
+
} catch {
|
|
19654
|
+
throw new ClaustrumUnreachableError();
|
|
19655
|
+
}
|
|
19656
|
+
}
|
|
19657
|
+
var VAULT_HOST_STATUS, VAULT_HOST_CONNECT_REFUSAL, hostClients;
|
|
19658
|
+
var init_host = __esm({
|
|
19659
|
+
"../core/dist/common-auth-embedded/claustrum/host.js"() {
|
|
19660
|
+
"use strict";
|
|
19661
|
+
init_availability();
|
|
19662
|
+
VAULT_HOST_STATUS = "Served by Thalamus";
|
|
19663
|
+
VAULT_HOST_CONNECT_REFUSAL = "This host gets its vault accounts from Thalamus, so it can't connect to the vault itself.";
|
|
19664
|
+
hostClients = /* @__PURE__ */ new WeakSet();
|
|
19665
|
+
}
|
|
19666
|
+
});
|
|
19667
|
+
|
|
19455
19668
|
// ../core/dist/common-auth-embedded/auth-menu/doctor.js
|
|
19456
19669
|
async function runDoctorChecks(checks) {
|
|
19457
19670
|
const findings = [];
|
|
@@ -20222,7 +20435,7 @@ function deleteAllAction(options) {
|
|
|
20222
20435
|
};
|
|
20223
20436
|
}
|
|
20224
20437
|
async function accountMenuActions(options) {
|
|
20225
|
-
return actionsFor(options, await options.custody?.() === true);
|
|
20438
|
+
return actionsFor(options, hasVaultHost() || await options.custody?.() === true);
|
|
20226
20439
|
}
|
|
20227
20440
|
function actionsFor(options, custody) {
|
|
20228
20441
|
const doctor = options.doctor?.length ? [doctorAction({ checks: options.doctor })] : [];
|
|
@@ -20247,7 +20460,8 @@ function actionsFor(options, custody) {
|
|
|
20247
20460
|
];
|
|
20248
20461
|
}
|
|
20249
20462
|
async function runAccountMenu(options) {
|
|
20250
|
-
const
|
|
20463
|
+
const hosted = hasVaultHost();
|
|
20464
|
+
const custody = hosted || await options.custody?.() === true;
|
|
20251
20465
|
const actions = actionsFor(options, custody);
|
|
20252
20466
|
const [read, status] = await Promise.all([
|
|
20253
20467
|
readRows(options.store),
|
|
@@ -20256,7 +20470,11 @@ async function runAccountMenu(options) {
|
|
|
20256
20470
|
return runMenu({
|
|
20257
20471
|
title: options.title,
|
|
20258
20472
|
subtitle: custody ? "Accounts come from the vault; select an action" : "Select an account action",
|
|
20259
|
-
status: [
|
|
20473
|
+
status: [
|
|
20474
|
+
...status,
|
|
20475
|
+
...hosted ? [VAULT_HOST_STATUS] : [],
|
|
20476
|
+
...accountLines(read)
|
|
20477
|
+
],
|
|
20260
20478
|
actions,
|
|
20261
20479
|
...options.terminal ? { terminal: options.terminal } : {}
|
|
20262
20480
|
});
|
|
@@ -20265,6 +20483,7 @@ var MENU_DISABLE_REASON, STATUS_ACCOUNT_LINES;
|
|
|
20265
20483
|
var init_accounts = __esm({
|
|
20266
20484
|
"../core/dist/common-auth-embedded/auth-menu/accounts.js"() {
|
|
20267
20485
|
"use strict";
|
|
20486
|
+
init_host();
|
|
20268
20487
|
init_quota();
|
|
20269
20488
|
init_store();
|
|
20270
20489
|
init_doctor();
|
|
@@ -20356,118 +20575,6 @@ var init_auth_menu = __esm({
|
|
|
20356
20575
|
}
|
|
20357
20576
|
});
|
|
20358
20577
|
|
|
20359
|
-
// ../core/dist/common-auth-embedded/claustrum/errors.js
|
|
20360
|
-
var ClaustrumConsumerError;
|
|
20361
|
-
var init_errors2 = __esm({
|
|
20362
|
-
"../core/dist/common-auth-embedded/claustrum/errors.js"() {
|
|
20363
|
-
"use strict";
|
|
20364
|
-
ClaustrumConsumerError = class extends Error {
|
|
20365
|
-
kind;
|
|
20366
|
-
constructor(kind, message) {
|
|
20367
|
-
super(message);
|
|
20368
|
-
this.name = "ClaustrumConsumerError";
|
|
20369
|
-
this.kind = kind;
|
|
20370
|
-
}
|
|
20371
|
-
};
|
|
20372
|
-
}
|
|
20373
|
-
});
|
|
20374
|
-
|
|
20375
|
-
// ../core/dist/common-auth-embedded/claustrum/availability.js
|
|
20376
|
-
import { ClaustrumCredentialError } from "@cortexkit/claustrum-client";
|
|
20377
|
-
import { SocketClosedError, SocketTimeoutError, SubcCallError } from "@cortexkit/subc-client";
|
|
20378
|
-
function classifyVaultFailure(error) {
|
|
20379
|
-
if (error instanceof ClaustrumUnreachableError || error instanceof SocketClosedError || error instanceof SocketTimeoutError)
|
|
20380
|
-
return "unreachable";
|
|
20381
|
-
const code2 = error instanceof ClaustrumCredentialError || error instanceof SubcCallError ? error.code : error instanceof Error && "code" in error ? error.code : void 0;
|
|
20382
|
-
if (typeof code2 !== "string" || !Object.hasOwn(VAULT_FAILURE_CLASSES, code2))
|
|
20383
|
-
return "answered";
|
|
20384
|
-
return VAULT_FAILURE_CLASSES[code2];
|
|
20385
|
-
}
|
|
20386
|
-
var VAULT_FAILURE_CLASSES, ClaustrumUnreachableError;
|
|
20387
|
-
var init_availability = __esm({
|
|
20388
|
-
"../core/dist/common-auth-embedded/claustrum/availability.js"() {
|
|
20389
|
-
"use strict";
|
|
20390
|
-
init_errors2();
|
|
20391
|
-
VAULT_FAILURE_CLASSES = Object.freeze({
|
|
20392
|
-
ECONNREFUSED: "unreachable",
|
|
20393
|
-
ENOENT: "unreachable",
|
|
20394
|
-
ECONNRESET: "unreachable",
|
|
20395
|
-
EPIPE: "unreachable",
|
|
20396
|
-
ETIMEDOUT: "unreachable",
|
|
20397
|
-
transport_error: "unreachable",
|
|
20398
|
-
unavailable: "unreachable",
|
|
20399
|
-
timeout: "unreachable",
|
|
20400
|
-
route_closed: "unreachable",
|
|
20401
|
-
daemon_draining: "unreachable",
|
|
20402
|
-
connection_closed: "unreachable",
|
|
20403
|
-
connection_dropped: "unreachable",
|
|
20404
|
-
request_deadline: "unreachable",
|
|
20405
|
-
deadline_exceeded_no_drop_observed: "unreachable",
|
|
20406
|
-
module_reloading: "unreachable",
|
|
20407
|
-
module_warming: "unreachable",
|
|
20408
|
-
target_unavailable: "unreachable",
|
|
20409
|
-
module_timeout: "unreachable",
|
|
20410
|
-
invalid_response: "answered",
|
|
20411
|
-
invalid_record_version: "answered",
|
|
20412
|
-
invalid_expiry: "answered",
|
|
20413
|
-
invalid_status: "answered",
|
|
20414
|
-
invalid_params: "answered",
|
|
20415
|
-
ttl_unsatisfiable: "answered",
|
|
20416
|
-
not_found: "answered",
|
|
20417
|
-
enrollment_revoked: "answered",
|
|
20418
|
-
enrollment_invalid: "answered",
|
|
20419
|
-
grant_denied: "answered",
|
|
20420
|
-
credential_unavailable: "answered",
|
|
20421
|
-
needs_reauth: "answered",
|
|
20422
|
-
declined: "answered",
|
|
20423
|
-
disabled: "answered",
|
|
20424
|
-
identity_changed: "answered",
|
|
20425
|
-
closed: "answered",
|
|
20426
|
-
client_closed: "answered",
|
|
20427
|
-
pending_exists: "answered",
|
|
20428
|
-
pending_queue_full: "answered",
|
|
20429
|
-
already_consumed: "answered",
|
|
20430
|
-
superseded: "answered",
|
|
20431
|
-
stale_generation: "answered",
|
|
20432
|
-
missing_identity: "answered",
|
|
20433
|
-
invalid_control_body: "answered",
|
|
20434
|
-
unknown_module: "answered",
|
|
20435
|
-
module_removed: "answered",
|
|
20436
|
-
capability_denied: "answered",
|
|
20437
|
-
unknown_channel: "unreachable",
|
|
20438
|
-
stale_route_epoch: "unreachable",
|
|
20439
|
-
capability_forbidden: "answered",
|
|
20440
|
-
capability_unprovided: "answered",
|
|
20441
|
-
capability_ambiguous: "answered",
|
|
20442
|
-
invalid_capability_identifier: "answered",
|
|
20443
|
-
binary_body_required: "answered",
|
|
20444
|
-
binary_call_requires_call_binary: "answered",
|
|
20445
|
-
corr_exhausted: "answered",
|
|
20446
|
-
late_route_cleanup_failed: "answered",
|
|
20447
|
-
reverse_request_capability_not_declared: "answered",
|
|
20448
|
-
stale_route_handle: "answered",
|
|
20449
|
-
reverse_request_unhandled: "answered",
|
|
20450
|
-
handler_error: "answered",
|
|
20451
|
-
health_error: "answered",
|
|
20452
|
-
duplicate_module_id: "answered",
|
|
20453
|
-
route_rejected: "answered",
|
|
20454
|
-
lock_busy: "answered",
|
|
20455
|
-
owner_invalid: "answered",
|
|
20456
|
-
renewal_failed: "answered",
|
|
20457
|
-
unsupported_platform: "answered",
|
|
20458
|
-
EACCES: "answered",
|
|
20459
|
-
EPERM: "answered",
|
|
20460
|
-
ERR_PRIVATE_FILES_SECURITY: "answered"
|
|
20461
|
-
});
|
|
20462
|
-
ClaustrumUnreachableError = class extends ClaustrumConsumerError {
|
|
20463
|
-
constructor() {
|
|
20464
|
-
super("unavailable", "Claustrum scoped operation unavailable");
|
|
20465
|
-
this.name = "ClaustrumUnreachableError";
|
|
20466
|
-
}
|
|
20467
|
-
};
|
|
20468
|
-
}
|
|
20469
|
-
});
|
|
20470
|
-
|
|
20471
20578
|
// ../core/dist/common-auth-embedded/claustrum/watch.js
|
|
20472
20579
|
var SAFETY_POLL_MS, WATCH_RETRY_MS, RESUBSCRIBE_BACKOFF_MS, ChangeNoticeReader, CoalescedRead, ScopedRosterWatch;
|
|
20473
20580
|
var init_watch = __esm({
|
|
@@ -20692,7 +20799,7 @@ function insulaUsageTransport(options) {
|
|
|
20692
20799
|
timer = setTimeout(() => reject(new Error("insula usage timeout")), 3e3);
|
|
20693
20800
|
timer.unref?.();
|
|
20694
20801
|
});
|
|
20695
|
-
const
|
|
20802
|
+
const request2 = (async () => {
|
|
20696
20803
|
client = options.connector ? await options.connector({
|
|
20697
20804
|
connectionFile: options.connectionFile,
|
|
20698
20805
|
handshakeTimeoutMs: Math.min(options.handshakeTimeoutMs ?? 3e3, 3e3)
|
|
@@ -20708,7 +20815,7 @@ function insulaUsageTransport(options) {
|
|
|
20708
20815
|
return await client.request(route, { method: "usage.get", params: {} });
|
|
20709
20816
|
})();
|
|
20710
20817
|
try {
|
|
20711
|
-
return await Promise.race([
|
|
20818
|
+
return await Promise.race([request2, timeout]);
|
|
20712
20819
|
} finally {
|
|
20713
20820
|
expired = true;
|
|
20714
20821
|
clearTimeout(timer);
|
|
@@ -21121,9 +21228,9 @@ import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as r
|
|
|
21121
21228
|
import { constants as fsConstants } from "node:fs";
|
|
21122
21229
|
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";
|
|
21123
21230
|
import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve7 } from "node:path";
|
|
21124
|
-
import { ClaustrumCredentialError as
|
|
21231
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError3, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
|
|
21125
21232
|
function classifyEnrollmentError(error) {
|
|
21126
|
-
if (!(error instanceof
|
|
21233
|
+
if (!(error instanceof ClaustrumCredentialError3))
|
|
21127
21234
|
return void 0;
|
|
21128
21235
|
if (TERMINAL_ENROLLMENT_CODES.has(error.code))
|
|
21129
21236
|
return { code: error.code, disposition: "terminal" };
|
|
@@ -21476,6 +21583,11 @@ async function enrollmentAuthority(paths, proposedName) {
|
|
|
21476
21583
|
}
|
|
21477
21584
|
return "local";
|
|
21478
21585
|
}
|
|
21586
|
+
async function vaultAuthority(paths, proposedName) {
|
|
21587
|
+
if (hasVaultHost())
|
|
21588
|
+
return "host";
|
|
21589
|
+
return enrollmentAuthority(paths, proposedName);
|
|
21590
|
+
}
|
|
21479
21591
|
async function readClaustrumEnrollmentToken(tokenPath) {
|
|
21480
21592
|
const value = await readBoundedJson(tokenPath);
|
|
21481
21593
|
if (value === void 0)
|
|
@@ -21589,6 +21701,7 @@ var init_enrollment = __esm({
|
|
|
21589
21701
|
init_fs();
|
|
21590
21702
|
init_private_files();
|
|
21591
21703
|
init_errors2();
|
|
21704
|
+
init_host();
|
|
21592
21705
|
ENROLLMENT_SCHEMA = 1;
|
|
21593
21706
|
ENROLLMENT_FILE_MAX_BYTES = 16 * 1024;
|
|
21594
21707
|
ENROLLMENT_LOCK_TTL_MS = 3e4;
|
|
@@ -21904,7 +22017,7 @@ var init_shutdown = __esm({
|
|
|
21904
22017
|
});
|
|
21905
22018
|
|
|
21906
22019
|
// ../core/dist/common-auth-embedded/claustrum/usage.js
|
|
21907
|
-
import { ClaustrumCredentialError as
|
|
22020
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError4 } from "@cortexkit/claustrum-client";
|
|
21908
22021
|
function plain(value) {
|
|
21909
22022
|
return value !== null && typeof value === "object" && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
21910
22023
|
}
|
|
@@ -22010,7 +22123,7 @@ var init_usage = __esm({
|
|
|
22010
22123
|
#log(error) {
|
|
22011
22124
|
let code2 = "transport_error";
|
|
22012
22125
|
try {
|
|
22013
|
-
if (error instanceof
|
|
22126
|
+
if (error instanceof ClaustrumCredentialError4)
|
|
22014
22127
|
code2 = /^[a-z][a-z0-9_]{0,63}$/.test(error.code) ? error.code : code2;
|
|
22015
22128
|
if (this.#errors.has(code2))
|
|
22016
22129
|
return;
|
|
@@ -22040,7 +22153,7 @@ var init_usage = __esm({
|
|
|
22040
22153
|
|
|
22041
22154
|
// ../core/dist/common-auth-embedded/claustrum/custody.js
|
|
22042
22155
|
import { channel } from "node:diagnostics_channel";
|
|
22043
|
-
import { ClaustrumCredentialError as
|
|
22156
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError5 } from "@cortexkit/claustrum-client";
|
|
22044
22157
|
function isScopedCredentialRotation(served, current) {
|
|
22045
22158
|
return current !== void 0 && !current.fromKeptReceipt && !served.fromKeptReceipt && current.credentialId === served.credentialId && current.accountIdentity === served.accountIdentity && current.recordVersion !== served.recordVersion;
|
|
22046
22159
|
}
|
|
@@ -22167,6 +22280,7 @@ var init_custody = __esm({
|
|
|
22167
22280
|
init_availability();
|
|
22168
22281
|
init_enrollment();
|
|
22169
22282
|
init_errors2();
|
|
22283
|
+
init_host();
|
|
22170
22284
|
init_host_slot();
|
|
22171
22285
|
init_shutdown();
|
|
22172
22286
|
init_usage();
|
|
@@ -22206,15 +22320,21 @@ var init_custody = __esm({
|
|
|
22206
22320
|
#onDrainTimeout;
|
|
22207
22321
|
#disposing;
|
|
22208
22322
|
constructor(options) {
|
|
22323
|
+
if (hasVaultHost() && options.client && !isVaultHostClient(options.client))
|
|
22324
|
+
throw new ClaustrumUnreachableError();
|
|
22209
22325
|
const tokenPath = options.tokenPath;
|
|
22210
22326
|
if (options.readToken) {
|
|
22211
22327
|
this.#readToken = options.readToken;
|
|
22212
22328
|
} else if (tokenPath) {
|
|
22213
22329
|
this.#readToken = () => readClaustrumEnrollmentToken(tokenPath);
|
|
22330
|
+
} else if (hasVaultHost()) {
|
|
22331
|
+
this.#readToken = async () => {
|
|
22332
|
+
throw new ClaustrumConsumerError("not-enrolled", "Claustrum enrollment token path is required");
|
|
22333
|
+
};
|
|
22214
22334
|
} else {
|
|
22215
22335
|
throw new ClaustrumConsumerError("not-enrolled", "Claustrum enrollment token path is required");
|
|
22216
22336
|
}
|
|
22217
|
-
this.#client = options.client;
|
|
22337
|
+
this.#client = options.client ?? connectVaultHost(options.pluginId);
|
|
22218
22338
|
this.#family = options.family;
|
|
22219
22339
|
this.#parseIdentity = options.parseIdentity;
|
|
22220
22340
|
this.#requireAssertion = options.requireAssertion ?? false;
|
|
@@ -22226,7 +22346,7 @@ var init_custody = __esm({
|
|
|
22226
22346
|
this.#usage = new ScopedUsageReporter({
|
|
22227
22347
|
client: this.#client,
|
|
22228
22348
|
owns: (id) => this.#usageServed.has(id),
|
|
22229
|
-
token: async () => checkedEnrollmentToken(await this.#readToken()),
|
|
22349
|
+
token: async () => hasVaultHost() ? "" : checkedEnrollmentToken(await this.#readToken()),
|
|
22230
22350
|
logger: this.#logger,
|
|
22231
22351
|
setTimeout: this.#setTimeout,
|
|
22232
22352
|
clearTimeout: this.#clearTimeout
|
|
@@ -22237,7 +22357,7 @@ var init_custody = __esm({
|
|
|
22237
22357
|
if (this.#closed || this.#outage)
|
|
22238
22358
|
return;
|
|
22239
22359
|
this.#outage = true;
|
|
22240
|
-
this.#outageError = error instanceof
|
|
22360
|
+
this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError();
|
|
22241
22361
|
this.#logger.warn("serving kept vault receipt", { reason: "unreachable" });
|
|
22242
22362
|
this.#scheduleProbe();
|
|
22243
22363
|
}
|
|
@@ -22287,6 +22407,8 @@ var init_custody = __esm({
|
|
|
22287
22407
|
}
|
|
22288
22408
|
async #token(signal) {
|
|
22289
22409
|
this.#check(signal);
|
|
22410
|
+
if (hasVaultHost())
|
|
22411
|
+
return "";
|
|
22290
22412
|
if (phaseDiagnostics.hasSubscribers)
|
|
22291
22413
|
phaseDiagnostics.publish({
|
|
22292
22414
|
logger: this.#logger,
|
|
@@ -22330,7 +22452,7 @@ var init_custody = __esm({
|
|
|
22330
22452
|
this.transportLost(error);
|
|
22331
22453
|
else
|
|
22332
22454
|
this.reachable();
|
|
22333
|
-
if (error instanceof
|
|
22455
|
+
if (error instanceof ClaustrumCredentialError5)
|
|
22334
22456
|
throw error;
|
|
22335
22457
|
if (classifyVaultFailure(error) === "unreachable")
|
|
22336
22458
|
throw new ClaustrumUnreachableError();
|
|
@@ -22549,7 +22671,7 @@ var init_custody = __esm({
|
|
|
22549
22671
|
if (kept.since === null)
|
|
22550
22672
|
kept.since = this.#now();
|
|
22551
22673
|
const attempt = Object.freeze(Object.defineProperty({ ...kept.attempt, fromKeptReceipt: true }, "accessToken", { value: kept.attempt.accessToken, enumerable: false }));
|
|
22552
|
-
this.#provenance.set(attempt, token);
|
|
22674
|
+
this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token, client: this.#client });
|
|
22553
22675
|
this.#keptAttempts.set(attempt, routeId);
|
|
22554
22676
|
return attempt;
|
|
22555
22677
|
}
|
|
@@ -22610,22 +22732,22 @@ var init_custody = __esm({
|
|
|
22610
22732
|
recordVersion: served.recordVersion,
|
|
22611
22733
|
expiresAtMs
|
|
22612
22734
|
}, "accessToken", { value: accessToken, enumerable: false }));
|
|
22613
|
-
this.#provenance.set(attempt, token);
|
|
22735
|
+
this.#provenance.set(attempt, { token, client: this.#client });
|
|
22614
22736
|
return attempt;
|
|
22615
22737
|
}
|
|
22616
22738
|
/**
|
|
22617
22739
|
* Report that a send this consumer actually made was rejected. Only a 401
|
|
22618
22740
|
* is reported (the vault refuses 429, 402 and 5xx reports), addressed by
|
|
22619
22741
|
* credential id with the exact record version that send was served, and
|
|
22620
|
-
*
|
|
22621
|
-
* custody did not issue is refused rather than reported.
|
|
22742
|
+
* sent through the client and enrollment token that authorized it. A receipt
|
|
22743
|
+
* this custody did not issue is refused rather than reported.
|
|
22622
22744
|
*/
|
|
22623
22745
|
async reportFailure(attempt, status, reporterSource) {
|
|
22624
22746
|
if (status !== 401)
|
|
22625
22747
|
return;
|
|
22626
22748
|
this.#check();
|
|
22627
|
-
const
|
|
22628
|
-
if (!
|
|
22749
|
+
const provenance = this.#provenance.get(attempt);
|
|
22750
|
+
if (!provenance)
|
|
22629
22751
|
throw new ClaustrumConsumerError("no-receipt", "Claustrum failure report requires an original dispatch receipt");
|
|
22630
22752
|
const keptRoute = this.#keptAttempts.get(attempt);
|
|
22631
22753
|
if (keptRoute !== void 0) {
|
|
@@ -22642,9 +22764,9 @@ var init_custody = __esm({
|
|
|
22642
22764
|
const pending = this.#reports.get(attempt);
|
|
22643
22765
|
if (pending)
|
|
22644
22766
|
return pending;
|
|
22645
|
-
const report = this.#call(() =>
|
|
22767
|
+
const report = this.#call(() => provenance.client.reportAuthFailureScoped({
|
|
22646
22768
|
credentialId: attempt.credentialId,
|
|
22647
|
-
enrollmentToken: token,
|
|
22769
|
+
enrollmentToken: provenance.token,
|
|
22648
22770
|
providerStatus: 401,
|
|
22649
22771
|
recordVersion: attempt.recordVersion,
|
|
22650
22772
|
reporterSource
|
|
@@ -23664,6 +23786,7 @@ var init_consumer = __esm({
|
|
|
23664
23786
|
init_custody();
|
|
23665
23787
|
init_enrollment();
|
|
23666
23788
|
init_errors2();
|
|
23789
|
+
init_host();
|
|
23667
23790
|
init_insula();
|
|
23668
23791
|
init_quota_writer2();
|
|
23669
23792
|
init_roster();
|
|
@@ -23726,6 +23849,8 @@ var init_consumer = __esm({
|
|
|
23726
23849
|
return pending;
|
|
23727
23850
|
}
|
|
23728
23851
|
async #active() {
|
|
23852
|
+
if (hasVaultHost())
|
|
23853
|
+
return true;
|
|
23729
23854
|
return await this.#options.isCustodyActive?.() ?? true;
|
|
23730
23855
|
}
|
|
23731
23856
|
#wait(pending, signal) {
|
|
@@ -23776,7 +23901,7 @@ var init_consumer = __esm({
|
|
|
23776
23901
|
#boundedConnect(attempt) {
|
|
23777
23902
|
const setTimer = this.#options.setTimeoutImpl ?? setTimeout;
|
|
23778
23903
|
const clearTimer = this.#options.clearTimeoutImpl ?? clearTimeout;
|
|
23779
|
-
const pending = this.#options.connect().then((client) => {
|
|
23904
|
+
const pending = (!hasVaultHost() && this.#options.connect ? this.#options.connect() : Promise.resolve().then(() => connectVaultHost(this.#options.pluginId))).then((client) => {
|
|
23780
23905
|
if (this.#shutdown.signal.aborted || attempt.timedOut) {
|
|
23781
23906
|
client.close();
|
|
23782
23907
|
if (!attempt.timedOut)
|
|
@@ -24029,7 +24154,8 @@ var init_consumer = __esm({
|
|
|
24029
24154
|
if (!this.#options.insula || this.#shutdown.signal.aborted || !await this.#active())
|
|
24030
24155
|
return;
|
|
24031
24156
|
try {
|
|
24032
|
-
|
|
24157
|
+
if (!hasVaultHost())
|
|
24158
|
+
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
24033
24159
|
await this.#getCustody();
|
|
24034
24160
|
await this.#insula?.source.refresh((this.#options.now ?? Date.now)());
|
|
24035
24161
|
} catch {
|
|
@@ -24045,7 +24171,8 @@ var init_consumer = __esm({
|
|
|
24045
24171
|
if (!this.#options.insula || this.#shutdown.signal.aborted || !await this.#active())
|
|
24046
24172
|
return void 0;
|
|
24047
24173
|
try {
|
|
24048
|
-
|
|
24174
|
+
if (!hasVaultHost())
|
|
24175
|
+
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
24049
24176
|
return this.#normalizeInsulaQuota(receipt2.assertedAccountIdentity);
|
|
24050
24177
|
} catch {
|
|
24051
24178
|
return void 0;
|
|
@@ -24060,7 +24187,8 @@ var init_consumer = __esm({
|
|
|
24060
24187
|
if (!this.#options.insula || this.#shutdown.signal.aborted || !await this.#active())
|
|
24061
24188
|
return void 0;
|
|
24062
24189
|
try {
|
|
24063
|
-
|
|
24190
|
+
if (!hasVaultHost())
|
|
24191
|
+
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
24064
24192
|
const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
24065
24193
|
const row = roster?.rows.find((entry) => entry.routeId === routeId);
|
|
24066
24194
|
return this.#normalizeInsulaQuota(row?.accountIdentity);
|
|
@@ -24074,7 +24202,8 @@ var init_consumer = __esm({
|
|
|
24074
24202
|
if (!options || this.#shutdown.signal.aborted || !await this.#active())
|
|
24075
24203
|
return { miss: "unreachable" };
|
|
24076
24204
|
try {
|
|
24077
|
-
|
|
24205
|
+
if (!hasVaultHost())
|
|
24206
|
+
await readClaustrumEnrollmentToken(this.#options.tokenPath);
|
|
24078
24207
|
const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
|
|
24079
24208
|
const account = roster?.rows.find((row) => row.routeId === routeId)?.accountIdentity;
|
|
24080
24209
|
if (!account || !this.#insula)
|
|
@@ -24578,6 +24707,7 @@ var init_hub = __esm({
|
|
|
24578
24707
|
init_custody();
|
|
24579
24708
|
init_enrollment();
|
|
24580
24709
|
init_errors2();
|
|
24710
|
+
init_host();
|
|
24581
24711
|
init_roster();
|
|
24582
24712
|
init_shutdown();
|
|
24583
24713
|
init_watch();
|
|
@@ -24807,7 +24937,7 @@ var init_hub = __esm({
|
|
|
24807
24937
|
const entry = { generation, timedOut: false };
|
|
24808
24938
|
const connectTimeoutMs = this.#options.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
|
|
24809
24939
|
let timer;
|
|
24810
|
-
const connect3 = this.#options.connect().then((client) => {
|
|
24940
|
+
const connect3 = (!hasVaultHost() && this.#options.connect ? this.#options.connect() : Promise.resolve().then(() => connectVaultHost(this.#options.pluginId))).then((client) => {
|
|
24811
24941
|
if (entry.timedOut) {
|
|
24812
24942
|
client.close();
|
|
24813
24943
|
throw unreachableConnect2();
|
|
@@ -24982,7 +25112,7 @@ var init_hub = __esm({
|
|
|
24982
25112
|
* runs the inactive transition; nothing else does.
|
|
24983
25113
|
*/
|
|
24984
25114
|
async #readAuthority() {
|
|
24985
|
-
const active2 = await this.#options.isCustodyActive?.() ?? true;
|
|
25115
|
+
const active2 = hasVaultHost() || (await this.#options.isCustodyActive?.() ?? true);
|
|
24986
25116
|
if (this.#shutdown.signal.aborted)
|
|
24987
25117
|
return false;
|
|
24988
25118
|
const was = this.#active;
|
|
@@ -25489,7 +25619,7 @@ __export(claustrum_exports, {
|
|
|
25489
25619
|
ChangeNoticeReader: () => ChangeNoticeReader,
|
|
25490
25620
|
ClaustrumConsumer: () => ClaustrumConsumer,
|
|
25491
25621
|
ClaustrumConsumerError: () => ClaustrumConsumerError,
|
|
25492
|
-
ClaustrumCredentialError: () =>
|
|
25622
|
+
ClaustrumCredentialError: () => ClaustrumCredentialError6,
|
|
25493
25623
|
ClaustrumDiscoveryHub: () => ClaustrumDiscoveryHub,
|
|
25494
25624
|
ClaustrumEnrollmentManager: () => ClaustrumEnrollmentManager,
|
|
25495
25625
|
ClaustrumScopedCustody: () => ClaustrumScopedCustody,
|
|
@@ -25505,6 +25635,8 @@ __export(claustrum_exports, {
|
|
|
25505
25635
|
ScopedRosterWatch: () => ScopedRosterWatch,
|
|
25506
25636
|
TERMINAL_ENROLLMENT_CODES: () => TERMINAL_ENROLLMENT_CODES,
|
|
25507
25637
|
VAULT_FAILURE_CLASSES: () => VAULT_FAILURE_CLASSES,
|
|
25638
|
+
VAULT_HOST_CONNECT_REFUSAL: () => VAULT_HOST_CONNECT_REFUSAL,
|
|
25639
|
+
VAULT_HOST_STATUS: () => VAULT_HOST_STATUS,
|
|
25508
25640
|
WATCH_RETRY_MS: () => WATCH_RETRY_MS,
|
|
25509
25641
|
acceptAccount: () => acceptAccount,
|
|
25510
25642
|
acceptVaultRoute: () => acceptVaultRoute,
|
|
@@ -25516,6 +25648,7 @@ __export(claustrum_exports, {
|
|
|
25516
25648
|
classifyVaultFailure: () => classifyVaultFailure,
|
|
25517
25649
|
connectClaustrumEnrollmentClient: () => connectClaustrumEnrollmentClient,
|
|
25518
25650
|
connectClaustrumScopedClient: () => connectClaustrumScopedClient,
|
|
25651
|
+
connectVaultHost: () => connectVaultHost,
|
|
25519
25652
|
custodyPlaceholder: () => custodyPlaceholder,
|
|
25520
25653
|
custodyPlaceholderKey: () => custodyPlaceholderKey,
|
|
25521
25654
|
decideScopedRetryAfter401: () => decideScopedRetryAfter401,
|
|
@@ -25542,11 +25675,12 @@ __export(claustrum_exports, {
|
|
|
25542
25675
|
reorderVaultRoster: () => reorderVaultRoster,
|
|
25543
25676
|
resetClaustrumEnrollmentState: () => resetClaustrumEnrollmentState,
|
|
25544
25677
|
resolveVaultPrimary: () => resolveVaultPrimary,
|
|
25678
|
+
vaultAuthority: () => vaultAuthority,
|
|
25545
25679
|
vaultRosterSeed: () => vaultRosterSeed,
|
|
25546
25680
|
vaultRoutingRows: () => vaultRoutingRows
|
|
25547
25681
|
});
|
|
25548
25682
|
import { ClaustrumClient } from "@cortexkit/claustrum-client";
|
|
25549
|
-
import { ClaustrumCredentialError as
|
|
25683
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError6 } from "@cortexkit/claustrum-client";
|
|
25550
25684
|
async function connectClaustrumScopedClient(options) {
|
|
25551
25685
|
const { connectTimeoutMs, ...client } = options;
|
|
25552
25686
|
const limit = connectTimeoutMs ?? SCOPED_CONNECT_TIMEOUT_MS;
|
|
@@ -25583,6 +25717,7 @@ var init_claustrum = __esm({
|
|
|
25583
25717
|
init_custody();
|
|
25584
25718
|
init_enrollment();
|
|
25585
25719
|
init_errors2();
|
|
25720
|
+
init_host();
|
|
25586
25721
|
init_host_slot();
|
|
25587
25722
|
init_hub();
|
|
25588
25723
|
init_insula();
|
|
@@ -29008,6 +29143,7 @@ function admissionFromReceipt(ref, receipt2) {
|
|
|
29008
29143
|
function createAntigravityVaultAccountSource(options) {
|
|
29009
29144
|
const { claustrum } = options;
|
|
29010
29145
|
const consumer = new claustrum.ClaustrumConsumer({
|
|
29146
|
+
pluginId: "antigravity-auth",
|
|
29011
29147
|
rosterPath: options.rosterPath,
|
|
29012
29148
|
tokenPath: options.tokenPath,
|
|
29013
29149
|
family: { ...ANTIGRAVITY_VAULT_FAMILY },
|
|
@@ -29245,9 +29381,9 @@ var init_vault_account_source = __esm({
|
|
|
29245
29381
|
});
|
|
29246
29382
|
|
|
29247
29383
|
// ../core/dist/vault-enrollment-authority.js
|
|
29248
|
-
async function
|
|
29384
|
+
async function vaultAuthority2(paths, proposedName, reader) {
|
|
29249
29385
|
try {
|
|
29250
|
-
return await (reader ?? await loadCommonAuthClaustrum()).
|
|
29386
|
+
return await (reader ?? await loadCommonAuthClaustrum()).vaultAuthority(paths, proposedName);
|
|
29251
29387
|
} catch {
|
|
29252
29388
|
return "unreadable";
|
|
29253
29389
|
}
|
|
@@ -30737,6 +30873,12 @@ function createOpenCodeVaultCustody(options) {
|
|
|
30737
30873
|
const readEnrollment = async () => {
|
|
30738
30874
|
if (layoutRefusal !== void 0) return unsettled;
|
|
30739
30875
|
const claustrum = await loadClaustrum();
|
|
30876
|
+
if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
|
|
30877
|
+
return {
|
|
30878
|
+
state: "unavailable",
|
|
30879
|
+
code: "host",
|
|
30880
|
+
proposedName: OPENCODE_VAULT_ENROLLMENT_NAME
|
|
30881
|
+
};
|
|
30740
30882
|
const status = await claustrum.readClaustrumEnrollmentStatus(
|
|
30741
30883
|
await enrollmentPaths(),
|
|
30742
30884
|
OPENCODE_VAULT_ENROLLMENT_NAME
|
|
@@ -30759,6 +30901,8 @@ function createOpenCodeVaultCustody(options) {
|
|
|
30759
30901
|
const readEnrollmentSnapshot = async () => {
|
|
30760
30902
|
if (layoutRefusal !== void 0)
|
|
30761
30903
|
return { authority: "unreadable", status: unsettled };
|
|
30904
|
+
if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
|
|
30905
|
+
return { authority: "host", status: await readEnrollment() };
|
|
30762
30906
|
const enrollment = await enrollmentPaths();
|
|
30763
30907
|
const identity3 = await enrollmentFilesIdentity(enrollment);
|
|
30764
30908
|
if (identity3) {
|
|
@@ -30769,7 +30913,7 @@ function createOpenCodeVaultCustody(options) {
|
|
|
30769
30913
|
return enrollmentReading.promise;
|
|
30770
30914
|
}
|
|
30771
30915
|
const promise = (async () => {
|
|
30772
|
-
const authority = await
|
|
30916
|
+
const authority = await vaultAuthority2(
|
|
30773
30917
|
enrollment,
|
|
30774
30918
|
OPENCODE_VAULT_ENROLLMENT_NAME,
|
|
30775
30919
|
await loadClaustrum()
|
|
@@ -30841,6 +30985,7 @@ function createOpenCodeVaultCustody(options) {
|
|
|
30841
30985
|
observedAuthority = authority;
|
|
30842
30986
|
options.onAuthorityChanged?.(authority);
|
|
30843
30987
|
}
|
|
30988
|
+
if (authority === "host") return true;
|
|
30844
30989
|
if (authority !== "vault") return false;
|
|
30845
30990
|
return status.state === "approved";
|
|
30846
30991
|
},
|
|
@@ -30976,7 +31121,7 @@ function createOpenCodeVaultCustody(options) {
|
|
|
30976
31121
|
return { ok: false, reason: VAULT_ACCOUNT_REMEDY };
|
|
30977
31122
|
return {
|
|
30978
31123
|
ok: true,
|
|
30979
|
-
record: authority === "vault" ? CUSTODY_MODE : LOCAL_MODE
|
|
31124
|
+
record: authority === "vault" || authority === "host" ? CUSTODY_MODE : LOCAL_MODE
|
|
30980
31125
|
};
|
|
30981
31126
|
},
|
|
30982
31127
|
async custodySource() {
|
|
@@ -31002,10 +31147,16 @@ function createOpenCodeVaultCustody(options) {
|
|
|
31002
31147
|
};
|
|
31003
31148
|
},
|
|
31004
31149
|
async requestAccess() {
|
|
31150
|
+
const claustrum = await loadClaustrum();
|
|
31151
|
+
if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
|
|
31152
|
+
throw new OpenCodeVaultCustodyError(
|
|
31153
|
+
claustrum.VAULT_HOST_CONNECT_REFUSAL
|
|
31154
|
+
);
|
|
31005
31155
|
return connectStep(true);
|
|
31006
31156
|
},
|
|
31007
31157
|
async useVault() {
|
|
31008
31158
|
refuseUnsettled();
|
|
31159
|
+
if (process.env.CORTEXKIT_VAULT_HOST === "thalamus") return;
|
|
31009
31160
|
const enrollment = await readEnrollment();
|
|
31010
31161
|
if (enrollment.state !== "approved")
|
|
31011
31162
|
throw new OpenCodeVaultCustodyError(
|
|
@@ -31017,6 +31168,10 @@ function createOpenCodeVaultCustody(options) {
|
|
|
31017
31168
|
async useLocal() {
|
|
31018
31169
|
refuseUnsettled();
|
|
31019
31170
|
const claustrum = await loadClaustrum();
|
|
31171
|
+
if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
|
|
31172
|
+
throw new OpenCodeVaultCustodyError(
|
|
31173
|
+
claustrum.VAULT_HOST_CONNECT_REFUSAL
|
|
31174
|
+
);
|
|
31020
31175
|
const disconnected = await claustrum.disconnectClaustrumEnrollment(
|
|
31021
31176
|
await enrollmentPaths(),
|
|
31022
31177
|
OPENCODE_VAULT_ENROLLMENT_NAME
|
|
@@ -31047,6 +31202,9 @@ function createOpenCodeVaultCustody(options) {
|
|
|
31047
31202
|
build: async () => {
|
|
31048
31203
|
if (layoutRefusal !== void 0)
|
|
31049
31204
|
return { lines: [`Vault: ${layoutRefusal}`], actions: [] };
|
|
31205
|
+
const claustrum = await loadClaustrum();
|
|
31206
|
+
if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
|
|
31207
|
+
return { lines: [claustrum.VAULT_HOST_STATUS], actions: [] };
|
|
31050
31208
|
const status = await custody.status();
|
|
31051
31209
|
const lines = statusLines(status);
|
|
31052
31210
|
if (status.enrollment.state === "approved")
|
|
@@ -32175,7 +32333,7 @@ async function localAccountStoreAuthorized() {
|
|
|
32175
32333
|
if (folder?.refusal) return false;
|
|
32176
32334
|
const claustrum = await loadCommonAuthClaustrum();
|
|
32177
32335
|
const vaultDir = folder ? folder.vaultDir : decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
|
|
32178
|
-
return await
|
|
32336
|
+
return await vaultAuthority2(
|
|
32179
32337
|
claustrum.hostEnrollmentPaths({
|
|
32180
32338
|
stateDir: vaultDir,
|
|
32181
32339
|
host: OPENCODE_VAULT_HOST
|
|
@@ -34534,11 +34692,11 @@ function callbackParams(callbackUrl, expected) {
|
|
|
34534
34692
|
if (expected && state !== expected) throw new Error("OAuth state mismatch");
|
|
34535
34693
|
return { code: code2, state };
|
|
34536
34694
|
}
|
|
34537
|
-
async function performOAuthLogin(
|
|
34695
|
+
async function performOAuthLogin(request2, deps) {
|
|
34538
34696
|
const listener = await deps.startListener();
|
|
34539
34697
|
try {
|
|
34540
|
-
const authorization = await deps.authorize(
|
|
34541
|
-
if (!
|
|
34698
|
+
const authorization = await deps.authorize(request2.projectId ?? "");
|
|
34699
|
+
if (!request2.noBrowser && !request2.isHeadless) {
|
|
34542
34700
|
await deps.openBrowser(authorization.url);
|
|
34543
34701
|
}
|
|
34544
34702
|
const params = callbackParams(
|
|
@@ -34548,7 +34706,7 @@ async function performOAuthLogin(request, deps) {
|
|
|
34548
34706
|
const result = await deps.exchange(params.code, params.state);
|
|
34549
34707
|
if (result.type === "failed") throw new Error(result.error);
|
|
34550
34708
|
await deps.upsert(result);
|
|
34551
|
-
|
|
34709
|
+
request2.accounts.push(result);
|
|
34552
34710
|
return result;
|
|
34553
34711
|
} finally {
|
|
34554
34712
|
await listener.close().catch(() => {
|
|
@@ -35590,7 +35748,7 @@ function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROVIDER_ID
|
|
|
35590
35748
|
providerId,
|
|
35591
35749
|
options.fetchVia
|
|
35592
35750
|
);
|
|
35593
|
-
const fetchAccountQuota = async (account,
|
|
35751
|
+
const fetchAccountQuota = async (account, request2, purpose = "required") => {
|
|
35594
35752
|
const target = account;
|
|
35595
35753
|
const ref = target.rowRef;
|
|
35596
35754
|
if (options.mayRun && !await options.mayRun())
|
|
@@ -35599,9 +35757,9 @@ function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROVIDER_ID
|
|
|
35599
35757
|
if (!options.fetchStoreAccountQuota)
|
|
35600
35758
|
throw new Error("Store quota authorization is unavailable");
|
|
35601
35759
|
const captured = { ...target, rowRef: ref };
|
|
35602
|
-
return purpose === "advisory" ? options.fetchStoreAccountQuota(captured,
|
|
35760
|
+
return purpose === "advisory" ? options.fetchStoreAccountQuota(captured, request2, purpose) : options.fetchStoreAccountQuota(captured, request2);
|
|
35603
35761
|
}
|
|
35604
|
-
return purpose === "advisory" ? fetchPoolFileQuota(account,
|
|
35762
|
+
return purpose === "advisory" ? fetchPoolFileQuota(account, request2, purpose) : fetchPoolFileQuota(account, request2);
|
|
35605
35763
|
};
|
|
35606
35764
|
const manager = createQuotaManager({
|
|
35607
35765
|
fetchAccountQuota,
|
|
@@ -36783,13 +36941,13 @@ async function startOAuthListener({
|
|
|
36783
36941
|
rejectCallback(new Error("Timed out waiting for OAuth callback"));
|
|
36784
36942
|
}, timeoutMs);
|
|
36785
36943
|
timeoutHandle.unref?.();
|
|
36786
|
-
const server = createServer((
|
|
36787
|
-
if (!
|
|
36944
|
+
const server = createServer((request2, response) => {
|
|
36945
|
+
if (!request2.url) {
|
|
36788
36946
|
response.writeHead(400, { "Content-Type": "text/plain" });
|
|
36789
36947
|
response.end("Invalid request");
|
|
36790
36948
|
return;
|
|
36791
36949
|
}
|
|
36792
|
-
const url = new URL(
|
|
36950
|
+
const url = new URL(request2.url, origin);
|
|
36793
36951
|
if (url.pathname !== callbackPath) {
|
|
36794
36952
|
response.writeHead(404, { "Content-Type": "text/plain" });
|
|
36795
36953
|
response.end("Not found");
|
|
@@ -37103,7 +37261,7 @@ import { createHash as createHash13, randomBytes as randomBytes5, randomUUID as
|
|
|
37103
37261
|
import { constants as fsConstants2 } from "node:fs";
|
|
37104
37262
|
import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat14, unlink as unlink11 } from "node:fs/promises";
|
|
37105
37263
|
import { basename as basename5, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute4, join as join20, resolve as resolve19 } from "node:path";
|
|
37106
|
-
import { ClaustrumCredentialError as
|
|
37264
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
37107
37265
|
|
|
37108
37266
|
// src/common-auth-embedded/fs/file-read-cache.js
|
|
37109
37267
|
import { lstat as lstat7, stat as stat12 } from "node:fs/promises";
|
|
@@ -38030,6 +38188,90 @@ var ClaustrumConsumerError2 = class extends Error {
|
|
|
38030
38188
|
}
|
|
38031
38189
|
};
|
|
38032
38190
|
|
|
38191
|
+
// src/common-auth-embedded/claustrum/host.js
|
|
38192
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError8 } from "@cortexkit/claustrum-client";
|
|
38193
|
+
|
|
38194
|
+
// src/common-auth-embedded/claustrum/availability.js
|
|
38195
|
+
import { ClaustrumCredentialError as ClaustrumCredentialError7 } from "@cortexkit/claustrum-client";
|
|
38196
|
+
import { SocketClosedError as SocketClosedError2, SocketTimeoutError as SocketTimeoutError2, SubcCallError as SubcCallError2 } from "@cortexkit/subc-client";
|
|
38197
|
+
var VAULT_FAILURE_CLASSES2 = Object.freeze({
|
|
38198
|
+
ECONNREFUSED: "unreachable",
|
|
38199
|
+
ENOENT: "unreachable",
|
|
38200
|
+
ECONNRESET: "unreachable",
|
|
38201
|
+
EPIPE: "unreachable",
|
|
38202
|
+
ETIMEDOUT: "unreachable",
|
|
38203
|
+
transport_error: "unreachable",
|
|
38204
|
+
unavailable: "unreachable",
|
|
38205
|
+
timeout: "unreachable",
|
|
38206
|
+
route_closed: "unreachable",
|
|
38207
|
+
daemon_draining: "unreachable",
|
|
38208
|
+
connection_closed: "unreachable",
|
|
38209
|
+
connection_dropped: "unreachable",
|
|
38210
|
+
request_deadline: "unreachable",
|
|
38211
|
+
deadline_exceeded_no_drop_observed: "unreachable",
|
|
38212
|
+
module_reloading: "unreachable",
|
|
38213
|
+
module_warming: "unreachable",
|
|
38214
|
+
target_unavailable: "unreachable",
|
|
38215
|
+
module_timeout: "unreachable",
|
|
38216
|
+
invalid_response: "answered",
|
|
38217
|
+
invalid_record_version: "answered",
|
|
38218
|
+
invalid_expiry: "answered",
|
|
38219
|
+
invalid_status: "answered",
|
|
38220
|
+
invalid_params: "answered",
|
|
38221
|
+
ttl_unsatisfiable: "answered",
|
|
38222
|
+
not_found: "answered",
|
|
38223
|
+
enrollment_revoked: "answered",
|
|
38224
|
+
enrollment_invalid: "answered",
|
|
38225
|
+
grant_denied: "answered",
|
|
38226
|
+
credential_unavailable: "answered",
|
|
38227
|
+
needs_reauth: "answered",
|
|
38228
|
+
declined: "answered",
|
|
38229
|
+
disabled: "answered",
|
|
38230
|
+
identity_changed: "answered",
|
|
38231
|
+
closed: "answered",
|
|
38232
|
+
client_closed: "answered",
|
|
38233
|
+
pending_exists: "answered",
|
|
38234
|
+
pending_queue_full: "answered",
|
|
38235
|
+
already_consumed: "answered",
|
|
38236
|
+
superseded: "answered",
|
|
38237
|
+
stale_generation: "answered",
|
|
38238
|
+
missing_identity: "answered",
|
|
38239
|
+
invalid_control_body: "answered",
|
|
38240
|
+
unknown_module: "answered",
|
|
38241
|
+
module_removed: "answered",
|
|
38242
|
+
capability_denied: "answered",
|
|
38243
|
+
unknown_channel: "unreachable",
|
|
38244
|
+
stale_route_epoch: "unreachable",
|
|
38245
|
+
capability_forbidden: "answered",
|
|
38246
|
+
capability_unprovided: "answered",
|
|
38247
|
+
capability_ambiguous: "answered",
|
|
38248
|
+
invalid_capability_identifier: "answered",
|
|
38249
|
+
binary_body_required: "answered",
|
|
38250
|
+
binary_call_requires_call_binary: "answered",
|
|
38251
|
+
corr_exhausted: "answered",
|
|
38252
|
+
late_route_cleanup_failed: "answered",
|
|
38253
|
+
reverse_request_capability_not_declared: "answered",
|
|
38254
|
+
stale_route_handle: "answered",
|
|
38255
|
+
reverse_request_unhandled: "answered",
|
|
38256
|
+
handler_error: "answered",
|
|
38257
|
+
health_error: "answered",
|
|
38258
|
+
duplicate_module_id: "answered",
|
|
38259
|
+
route_rejected: "answered",
|
|
38260
|
+
lock_busy: "answered",
|
|
38261
|
+
owner_invalid: "answered",
|
|
38262
|
+
renewal_failed: "answered",
|
|
38263
|
+
unsupported_platform: "answered",
|
|
38264
|
+
EACCES: "answered",
|
|
38265
|
+
EPERM: "answered",
|
|
38266
|
+
ERR_PRIVATE_FILES_SECURITY: "answered"
|
|
38267
|
+
});
|
|
38268
|
+
|
|
38269
|
+
// src/common-auth-embedded/claustrum/host.js
|
|
38270
|
+
var VAULT_HOST_CONNECT_REFUSAL2 = "This host gets its vault accounts from Thalamus, so it can't connect to the vault itself.";
|
|
38271
|
+
function hasVaultHost2() {
|
|
38272
|
+
return process.env.CORTEXKIT_VAULT_HOST === "thalamus";
|
|
38273
|
+
}
|
|
38274
|
+
|
|
38033
38275
|
// src/common-auth-embedded/claustrum/enrollment.js
|
|
38034
38276
|
var ENROLLMENT_SCHEMA2 = 1;
|
|
38035
38277
|
var ENROLLMENT_FILE_MAX_BYTES2 = 16 * 1024;
|
|
@@ -38053,7 +38295,7 @@ var RETRYABLE_ENROLLMENT_CODES2 = /* @__PURE__ */ new Set([
|
|
|
38053
38295
|
"pending_queue_full"
|
|
38054
38296
|
]);
|
|
38055
38297
|
function classifyEnrollmentError2(error) {
|
|
38056
|
-
if (!(error instanceof
|
|
38298
|
+
if (!(error instanceof ClaustrumCredentialError9))
|
|
38057
38299
|
return void 0;
|
|
38058
38300
|
if (TERMINAL_ENROLLMENT_CODES2.has(error.code))
|
|
38059
38301
|
return { code: error.code, disposition: "terminal" };
|
|
@@ -38377,7 +38619,7 @@ async function readEnrollmentStatus2(paths, proposedName) {
|
|
|
38377
38619
|
}
|
|
38378
38620
|
return { status: statusFromState2(state), usesProposedName: false };
|
|
38379
38621
|
}
|
|
38380
|
-
async function
|
|
38622
|
+
async function enrollmentAuthority2(paths, proposedName) {
|
|
38381
38623
|
let status;
|
|
38382
38624
|
try {
|
|
38383
38625
|
status = await readClaustrumEnrollmentStatus2(paths, proposedName);
|
|
@@ -38402,6 +38644,11 @@ async function enrollmentAuthority3(paths, proposedName) {
|
|
|
38402
38644
|
}
|
|
38403
38645
|
return "local";
|
|
38404
38646
|
}
|
|
38647
|
+
async function vaultAuthority3(paths, proposedName) {
|
|
38648
|
+
if (hasVaultHost2())
|
|
38649
|
+
return "host";
|
|
38650
|
+
return enrollmentAuthority2(paths, proposedName);
|
|
38651
|
+
}
|
|
38405
38652
|
function statusFromState2(state) {
|
|
38406
38653
|
if (state.phase === "pending") {
|
|
38407
38654
|
return {
|
|
@@ -39370,6 +39617,8 @@ function approveCommand(requestId, name) {
|
|
|
39370
39617
|
return `ck auth enroll approve --request-id ${requestId} --name ${name}`;
|
|
39371
39618
|
}
|
|
39372
39619
|
async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
39620
|
+
if (hasVaultHost2())
|
|
39621
|
+
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
39373
39622
|
const { name, paths: input2 } = plugin.vault.hosts[host];
|
|
39374
39623
|
const paths = hostEnrollmentPaths2(input2);
|
|
39375
39624
|
await fence();
|
|
@@ -39853,8 +40102,8 @@ async function enrollmentReport(plugin, hosts, recorded) {
|
|
|
39853
40102
|
let outcome = recorded.get(host) ?? "not-enrolled";
|
|
39854
40103
|
if (outcome === "unknown") {
|
|
39855
40104
|
const { name, paths } = plugin.vault.hosts[host];
|
|
39856
|
-
const authority = await
|
|
39857
|
-
if (authority === "vault")
|
|
40105
|
+
const authority = await vaultAuthority3(hostEnrollmentPaths2(paths), name).catch(() => "unreadable");
|
|
40106
|
+
if (authority === "vault" || authority === "host")
|
|
39858
40107
|
outcome = "enrolled";
|
|
39859
40108
|
else if (authority === "local")
|
|
39860
40109
|
outcome = "not-enrolled";
|
|
@@ -39865,6 +40114,8 @@ async function enrollmentReport(plugin, hosts, recorded) {
|
|
|
39865
40114
|
}
|
|
39866
40115
|
async function runSetup(plugin, argv = [], io = {}) {
|
|
39867
40116
|
const options = parseSetupFlags(argv);
|
|
40117
|
+
if (hasVaultHost2())
|
|
40118
|
+
throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
|
|
39868
40119
|
validatePlugin(plugin);
|
|
39869
40120
|
const terminal = io.terminal ?? processTerminal2();
|
|
39870
40121
|
const detection = await detectHosts(plugin, io);
|
|
@@ -40063,7 +40314,7 @@ function createV1VaultActivationMethod(input2) {
|
|
|
40063
40314
|
instructions: "Vault access is approved. Activate it without signing in to Google.",
|
|
40064
40315
|
callback: async () => {
|
|
40065
40316
|
try {
|
|
40066
|
-
if (await input2.readAuthority()
|
|
40317
|
+
if (!["host", "vault"].includes(await input2.readAuthority()))
|
|
40067
40318
|
return { type: "failed" };
|
|
40068
40319
|
try {
|
|
40069
40320
|
const value = JSON.parse(
|
|
@@ -40079,8 +40330,14 @@ function createV1VaultActivationMethod(input2) {
|
|
|
40079
40330
|
return { type: "failed" };
|
|
40080
40331
|
}
|
|
40081
40332
|
const claustrum = await loadCommonAuthClaustrum();
|
|
40082
|
-
|
|
40083
|
-
|
|
40333
|
+
const current = await input2.readAuthority();
|
|
40334
|
+
if (!["host", "vault"].includes(current)) return { type: "failed" };
|
|
40335
|
+
if (current === "host") {
|
|
40336
|
+
const client = claustrum.connectVaultHost("antigravity-auth");
|
|
40337
|
+
await Promise.resolve(client.close()).catch(() => void 0);
|
|
40338
|
+
if (await input2.readAuthority() !== "host")
|
|
40339
|
+
return { type: "failed" };
|
|
40340
|
+
}
|
|
40084
40341
|
return {
|
|
40085
40342
|
...claustrum.custodyPlaceholder(input2.providerId),
|
|
40086
40343
|
type: "success"
|
|
@@ -40137,7 +40394,7 @@ async function readNativeAuth(path5) {
|
|
|
40137
40394
|
}
|
|
40138
40395
|
async function assertLocalOpenCodeLogin(legacyPath, generation) {
|
|
40139
40396
|
const claustrum = await loadCommonAuthClaustrum();
|
|
40140
|
-
if (await claustrum.
|
|
40397
|
+
if (await claustrum.vaultAuthority(
|
|
40141
40398
|
claustrum.hostEnrollmentPaths({
|
|
40142
40399
|
stateDir: openCodeVaultDir(legacyPath),
|
|
40143
40400
|
host: "opencode"
|
|
@@ -40170,7 +40427,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
|
|
|
40170
40427
|
await assertSetupHostsStopped();
|
|
40171
40428
|
const claustrum = await loadCommonAuthClaustrum();
|
|
40172
40429
|
const stateDir = host === "opencode" ? openCodeVaultDir(resolve20(accountFileForVault())) : getPiAntigravityVaultDir();
|
|
40173
|
-
if (await claustrum.
|
|
40430
|
+
if (await claustrum.vaultAuthority(
|
|
40174
40431
|
claustrum.hostEnrollmentPaths({ stateDir, host }),
|
|
40175
40432
|
`antigravity-auth-${host}`
|
|
40176
40433
|
) !== expectedAuthority)
|
|
@@ -40217,7 +40474,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
|
|
|
40217
40474
|
paths: { stateDir: piDir, host: "pi" }
|
|
40218
40475
|
}
|
|
40219
40476
|
};
|
|
40220
|
-
const authority = (host) => claustrum.
|
|
40477
|
+
const authority = (host) => claustrum.vaultAuthority(
|
|
40221
40478
|
claustrum.hostEnrollmentPaths(hosts[host].paths),
|
|
40222
40479
|
hosts[host].name
|
|
40223
40480
|
);
|
|
@@ -40383,7 +40640,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
40383
40640
|
);
|
|
40384
40641
|
return;
|
|
40385
40642
|
}
|
|
40386
|
-
if (await authority(host)
|
|
40643
|
+
if (!["host", "vault"].includes(await authority(host)))
|
|
40387
40644
|
throw new Error("Vault access must be approved before activation.");
|
|
40388
40645
|
if (host === "opencode") {
|
|
40389
40646
|
if (context.opencodeGeneration === "2") {
|
|
@@ -40416,7 +40673,7 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
40416
40673
|
},
|
|
40417
40674
|
migrate: async (host, context) => {
|
|
40418
40675
|
if (context.mode === "local") await assertLocal(host, context);
|
|
40419
|
-
else if (await authority(host)
|
|
40676
|
+
else if (!["host", "vault"].includes(await authority(host)))
|
|
40420
40677
|
throw new Error("Vault access must remain approved during setup.");
|
|
40421
40678
|
if (host === "opencode") {
|
|
40422
40679
|
const current = await authority(host);
|
|
@@ -40482,6 +40739,9 @@ Setup has not completed the OpenCode 2 native Google connection.
|
|
|
40482
40739
|
};
|
|
40483
40740
|
}
|
|
40484
40741
|
async function runPluginSetup(argv, deps, migrateOpenCode, io = {}) {
|
|
40742
|
+
const claustrum = await loadCommonAuthClaustrum();
|
|
40743
|
+
if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
|
|
40744
|
+
throw new Error(claustrum.VAULT_HOST_CONNECT_REFUSAL);
|
|
40485
40745
|
const plugin = await createSetupPlugin(
|
|
40486
40746
|
deps,
|
|
40487
40747
|
migrateOpenCode,
|
|
@@ -40920,7 +41180,7 @@ function createDefaultCliDependencies() {
|
|
|
40920
41180
|
isHeadless: () => Boolean(
|
|
40921
41181
|
process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.OPENCODE_HEADLESS
|
|
40922
41182
|
),
|
|
40923
|
-
performLogin: async (
|
|
41183
|
+
performLogin: async (request2, openBrowser, host, context) => {
|
|
40924
41184
|
if (host === "pi" && !context)
|
|
40925
41185
|
throw new Error(
|
|
40926
41186
|
"Pi setup requires its detected native agent directory."
|
|
@@ -40935,7 +41195,7 @@ function createDefaultCliDependencies() {
|
|
|
40935
41195
|
context?.opencodeGeneration
|
|
40936
41196
|
);
|
|
40937
41197
|
try {
|
|
40938
|
-
return await performOAuthLogin(
|
|
41198
|
+
return await performOAuthLogin(request2, {
|
|
40939
41199
|
authorize: authorizeAntigravity,
|
|
40940
41200
|
exchange: exchangeAntigravity,
|
|
40941
41201
|
startListener: startOAuthListener,
|
|
@@ -40953,7 +41213,7 @@ function createDefaultCliDependencies() {
|
|
|
40953
41213
|
await persistCliStoreLogin(
|
|
40954
41214
|
repository,
|
|
40955
41215
|
result,
|
|
40956
|
-
|
|
41216
|
+
request2.startFresh && request2.accounts.length === 0
|
|
40957
41217
|
);
|
|
40958
41218
|
}
|
|
40959
41219
|
});
|
|
@@ -42113,11 +42373,11 @@ async function startRpcServer2(options) {
|
|
|
42113
42373
|
throw new TypeError("startRpcServer needs this plugin's package version");
|
|
42114
42374
|
}
|
|
42115
42375
|
const parseApply = (value) => {
|
|
42116
|
-
const
|
|
42117
|
-
if (
|
|
42376
|
+
const request2 = options.parseApplyRequest(value);
|
|
42377
|
+
if (request2 === void 0) {
|
|
42118
42378
|
throw new RpcRequestError(400, "Invalid apply request");
|
|
42119
42379
|
}
|
|
42120
|
-
return
|
|
42380
|
+
return request2;
|
|
42121
42381
|
};
|
|
42122
42382
|
const server = await startRpcServer({
|
|
42123
42383
|
dir: options.dir,
|
|
@@ -42129,7 +42389,7 @@ async function startRpcServer2(options) {
|
|
|
42129
42389
|
applyDeadlineMs: 12e4,
|
|
42130
42390
|
timeoutMs: 0,
|
|
42131
42391
|
parsePending,
|
|
42132
|
-
apply: (async (
|
|
42392
|
+
apply: (async (request2) => options.apply(parseApply(request2))),
|
|
42133
42393
|
// Use only the asynchronous overload, including for synchronous producers.
|
|
42134
42394
|
drainAsync: (async (cursor, session) => Promise.resolve(
|
|
42135
42395
|
options.drain(cursor, session)
|
|
@@ -42449,22 +42709,22 @@ function extractAccountAccessErrorDetails(bodyText) {
|
|
|
42449
42709
|
}
|
|
42450
42710
|
function buildAccountAccessProbeRequest(projectId) {
|
|
42451
42711
|
const wireModel = "gemini-3.8-flash-low";
|
|
42452
|
-
const
|
|
42712
|
+
const request2 = {
|
|
42453
42713
|
contents: [{ role: "user", parts: [{ text: "ping" }] }],
|
|
42454
42714
|
generationConfig: { maxOutputTokens: 1, temperature: 0 }
|
|
42455
42715
|
};
|
|
42456
42716
|
const requestMetadata = buildAgyAgentRequestMetadata(
|
|
42457
42717
|
createAgyRequestSessionContext(""),
|
|
42458
|
-
|
|
42718
|
+
request2,
|
|
42459
42719
|
wireModel
|
|
42460
42720
|
);
|
|
42461
|
-
|
|
42462
|
-
|
|
42463
|
-
orderAgyRequestPayloadInPlace(
|
|
42721
|
+
request2.labels = requestMetadata.labels;
|
|
42722
|
+
request2.sessionId = requestMetadata.sessionId;
|
|
42723
|
+
orderAgyRequestPayloadInPlace(request2);
|
|
42464
42724
|
return {
|
|
42465
42725
|
project: projectId,
|
|
42466
42726
|
requestId: requestMetadata.requestId,
|
|
42467
|
-
request,
|
|
42727
|
+
request: request2,
|
|
42468
42728
|
model: wireModel,
|
|
42469
42729
|
userAgent: "antigravity",
|
|
42470
42730
|
requestType: "agent"
|
|
@@ -47751,9 +48011,9 @@ function collectToolNames(value) {
|
|
|
47751
48011
|
function bodyStructureSummary(bodyText) {
|
|
47752
48012
|
const parsed = parseBody(bodyText);
|
|
47753
48013
|
if (!parsed) return { parseable: false };
|
|
47754
|
-
const
|
|
47755
|
-
const contents = Array.isArray(
|
|
47756
|
-
const toolNames = collectToolNames(
|
|
48014
|
+
const request2 = parsed.request && typeof parsed.request === "object" ? parsed.request : void 0;
|
|
48015
|
+
const contents = Array.isArray(request2?.contents) ? request2.contents : [];
|
|
48016
|
+
const toolNames = collectToolNames(request2 ?? parsed);
|
|
47757
48017
|
return {
|
|
47758
48018
|
parseable: true,
|
|
47759
48019
|
model: typeof parsed.model === "string" ? parsed.model : void 0,
|
|
@@ -49687,15 +49947,15 @@ function assignToolIdsToContents(contents) {
|
|
|
49687
49947
|
}
|
|
49688
49948
|
const newParts = content.parts.map((part) => {
|
|
49689
49949
|
if (part && typeof part === "object" && part.functionCall) {
|
|
49690
|
-
const
|
|
49691
|
-
if (!
|
|
49692
|
-
|
|
49950
|
+
const call2 = { ...part.functionCall };
|
|
49951
|
+
if (!call2.id) {
|
|
49952
|
+
call2.id = `tool-call-${++toolCallCounter}`;
|
|
49693
49953
|
}
|
|
49694
|
-
const nameKey = typeof
|
|
49954
|
+
const nameKey = typeof call2.name === "string" ? call2.name : `tool-${toolCallCounter}`;
|
|
49695
49955
|
const queue2 = pendingCallIdsByName.get(nameKey) || [];
|
|
49696
|
-
queue2.push(
|
|
49956
|
+
queue2.push(call2.id);
|
|
49697
49957
|
pendingCallIdsByName.set(nameKey, queue2);
|
|
49698
|
-
return { ...part, functionCall:
|
|
49958
|
+
return { ...part, functionCall: call2 };
|
|
49699
49959
|
}
|
|
49700
49960
|
return part;
|
|
49701
49961
|
});
|
|
@@ -50761,14 +51021,14 @@ function normalizeNativeFunctionResponseRoles(payload) {
|
|
|
50761
51021
|
if (!Array.isArray(parts)) continue;
|
|
50762
51022
|
let signedTurn = false;
|
|
50763
51023
|
for (const part of parts) {
|
|
50764
|
-
const
|
|
50765
|
-
if (!
|
|
51024
|
+
const call2 = part?.functionCall;
|
|
51025
|
+
if (!call2) continue;
|
|
50766
51026
|
const signature = part.thoughtSignature;
|
|
50767
51027
|
if (typeof signature === "string") {
|
|
50768
51028
|
signedTurn = signature.length >= MIN_SIGNATURE_LENGTH && signature !== SKIP_THOUGHT_SIGNATURE;
|
|
50769
51029
|
}
|
|
50770
51030
|
if (signedTurn) {
|
|
50771
|
-
signedCalls.add(String(
|
|
51031
|
+
signedCalls.add(String(call2.id ?? call2.name));
|
|
50772
51032
|
}
|
|
50773
51033
|
}
|
|
50774
51034
|
}
|
|
@@ -51665,15 +51925,15 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
51665
51925
|
}
|
|
51666
51926
|
const newParts = content.parts.map((part) => {
|
|
51667
51927
|
if (part && typeof part === "object" && part.functionCall) {
|
|
51668
|
-
const
|
|
51669
|
-
if (!
|
|
51670
|
-
|
|
51928
|
+
const call2 = { ...part.functionCall };
|
|
51929
|
+
if (!call2.id) {
|
|
51930
|
+
call2.id = `tool-call-${++toolCallCounter}`;
|
|
51671
51931
|
}
|
|
51672
|
-
const nameKey = typeof
|
|
51932
|
+
const nameKey = typeof call2.name === "string" ? call2.name : `tool-${toolCallCounter}`;
|
|
51673
51933
|
const queue2 = pendingCallIdsByName.get(nameKey) || [];
|
|
51674
|
-
queue2.push(
|
|
51934
|
+
queue2.push(call2.id);
|
|
51675
51935
|
pendingCallIdsByName.set(nameKey, queue2);
|
|
51676
|
-
return { ...part, functionCall:
|
|
51936
|
+
return { ...part, functionCall: call2 };
|
|
51677
51937
|
}
|
|
51678
51938
|
return part;
|
|
51679
51939
|
});
|
|
@@ -52828,7 +53088,7 @@ function createAuthLoader({
|
|
|
52828
53088
|
const authority = await readAuthority?.() ?? "local";
|
|
52829
53089
|
assertOpen();
|
|
52830
53090
|
if (authority === "unreadable") throw new Error(unavailableMessage);
|
|
52831
|
-
if (authority === "vault") {
|
|
53091
|
+
if (authority === "vault" || authority === "host") {
|
|
52832
53092
|
currentRequestSource = "vault";
|
|
52833
53093
|
if (!createVaultFetch) throw new Error(unavailableMessage);
|
|
52834
53094
|
vaultFetchRuntime ??= createVaultFetch().catch((error) => {
|
|
@@ -53384,7 +53644,7 @@ var BackgroundVaultQuotaRefresh = class {
|
|
|
53384
53644
|
async assertActive(controller) {
|
|
53385
53645
|
controller.signal.throwIfAborted();
|
|
53386
53646
|
if (this.disposed) controller.abort();
|
|
53387
|
-
else if (await this.options.readAuthority()
|
|
53647
|
+
else if (!["host", "vault"].includes(await this.options.readAuthority()))
|
|
53388
53648
|
controller.abort({ kind: "not-active" });
|
|
53389
53649
|
controller.signal.throwIfAborted();
|
|
53390
53650
|
}
|
|
@@ -53955,7 +54215,7 @@ var HANDLED_COMMAND_SENTINEL = "ANTIGRAVITY_COMMAND_HANDLED";
|
|
|
53955
54215
|
async function sendIgnoredMessage(client, sessionID, text2) {
|
|
53956
54216
|
const session = client.session;
|
|
53957
54217
|
const promptContext = await resolvePromptContext(client, sessionID);
|
|
53958
|
-
const
|
|
54218
|
+
const request2 = {
|
|
53959
54219
|
path: { id: sessionID },
|
|
53960
54220
|
body: {
|
|
53961
54221
|
noReply: true,
|
|
@@ -53966,11 +54226,11 @@ async function sendIgnoredMessage(client, sessionID, text2) {
|
|
|
53966
54226
|
}
|
|
53967
54227
|
};
|
|
53968
54228
|
if (typeof session?.promptAsync === "function") {
|
|
53969
|
-
await session.promptAsync(
|
|
54229
|
+
await session.promptAsync(request2);
|
|
53970
54230
|
return;
|
|
53971
54231
|
}
|
|
53972
54232
|
if (typeof session?.prompt === "function") {
|
|
53973
|
-
await Promise.resolve(session.prompt(
|
|
54233
|
+
await Promise.resolve(session.prompt(request2));
|
|
53974
54234
|
return;
|
|
53975
54235
|
}
|
|
53976
54236
|
throw new Error(
|
|
@@ -54453,15 +54713,15 @@ async function askRouting(input2) {
|
|
|
54453
54713
|
timer = setTimeout(() => resolve27(void 0), deadlineMs);
|
|
54454
54714
|
timer.unref();
|
|
54455
54715
|
});
|
|
54456
|
-
const
|
|
54716
|
+
const request2 = {
|
|
54457
54717
|
provider: input2.provider,
|
|
54458
54718
|
modelId: input2.modelId
|
|
54459
54719
|
};
|
|
54460
54720
|
const cap = input2.holdWaitMaxS;
|
|
54461
54721
|
if (typeof cap === "number" && Number.isFinite(cap)) {
|
|
54462
|
-
|
|
54722
|
+
request2.hold_wait_max_s = Math.max(0, Math.floor(cap));
|
|
54463
54723
|
}
|
|
54464
|
-
const pending = accountFor.call(handle,
|
|
54724
|
+
const pending = accountFor.call(handle, request2, { deadlineMs });
|
|
54465
54725
|
if (!isObject2(pending) || typeof pending.then !== "function")
|
|
54466
54726
|
return void 0;
|
|
54467
54727
|
const answer = await Promise.race([pending, expired]);
|
|
@@ -55029,10 +55289,10 @@ var AgySessionRegistry = class {
|
|
|
55029
55289
|
}
|
|
55030
55290
|
getOrCreate(identity3) {
|
|
55031
55291
|
const key = identity3.sessionId ?? FALLBACK_SESSION_KEY;
|
|
55032
|
-
const
|
|
55292
|
+
const request2 = this.requestSessions.getOrCreate(key);
|
|
55033
55293
|
this.recordParent(key, identity3.parentSessionId);
|
|
55034
55294
|
this.pruneParentRelationships();
|
|
55035
|
-
return
|
|
55295
|
+
return request2;
|
|
55036
55296
|
}
|
|
55037
55297
|
beginRequest(identity3) {
|
|
55038
55298
|
const key = identity3.sessionId ?? FALLBACK_SESSION_KEY;
|
|
@@ -55263,15 +55523,15 @@ function isPrimaryVaultRequest(kind, headers) {
|
|
|
55263
55523
|
// src/plugin/shared/request-services.ts
|
|
55264
55524
|
var FIRST_RETRY_DELAY_MS = 1e3;
|
|
55265
55525
|
var MODEL_UNAVAILABLE_TTL_MS = 60 * 60 * 1e3;
|
|
55266
|
-
function prepareAgyWireRequest(wire,
|
|
55526
|
+
function prepareAgyWireRequest(wire, request2) {
|
|
55267
55527
|
return wire.prepare(
|
|
55268
|
-
|
|
55269
|
-
|
|
55270
|
-
|
|
55271
|
-
|
|
55272
|
-
|
|
55273
|
-
|
|
55274
|
-
|
|
55528
|
+
request2.input,
|
|
55529
|
+
request2.init,
|
|
55530
|
+
request2.accessToken,
|
|
55531
|
+
request2.projectId,
|
|
55532
|
+
request2.endpoint,
|
|
55533
|
+
request2.forceThinkingRecovery ?? false,
|
|
55534
|
+
request2.options
|
|
55275
55535
|
);
|
|
55276
55536
|
}
|
|
55277
55537
|
var TITLE_FALLBACK_MODEL = "gemini-3.8-flash-low";
|
|
@@ -58036,7 +58296,7 @@ function createSourceSidebarPublisher(options) {
|
|
|
58036
58296
|
const authority = await options.readAuthority();
|
|
58037
58297
|
let projection;
|
|
58038
58298
|
if (authority === "local") projection = await options.local();
|
|
58039
|
-
else if (authority === "vault") {
|
|
58299
|
+
else if (authority === "vault" || authority === "host") {
|
|
58040
58300
|
try {
|
|
58041
58301
|
projection = await options.vault();
|
|
58042
58302
|
} catch {
|
|
@@ -58200,7 +58460,8 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
58200
58460
|
// which decides whether its served credential needs replacement.
|
|
58201
58461
|
reporterSource: "direct",
|
|
58202
58462
|
onAuthorityChanged: (authority) => {
|
|
58203
|
-
if (authority !== "vault"
|
|
58463
|
+
if (authority !== "vault" && authority !== "host")
|
|
58464
|
+
vaultQuotaPoller?.abortTick();
|
|
58204
58465
|
scheduleSidebarPublication();
|
|
58205
58466
|
},
|
|
58206
58467
|
onRosterChanged: () => scheduleSidebarPublication()
|
|
@@ -58233,11 +58494,11 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
58233
58494
|
// the caller injected a mock transport.
|
|
58234
58495
|
fetchVia: dependencies.agyTransport,
|
|
58235
58496
|
mayRun: mayRunLocalAccounts,
|
|
58236
|
-
fetchStoreAccountQuota: async (account,
|
|
58497
|
+
fetchStoreAccountQuota: async (account, request2) => {
|
|
58237
58498
|
const service = await currentStoreQuota();
|
|
58238
58499
|
if (!service)
|
|
58239
58500
|
throw new Error("The current store quota service is unavailable");
|
|
58240
|
-
return service.fetchAccountQuota(account,
|
|
58501
|
+
return service.fetchAccountQuota(account, request2);
|
|
58241
58502
|
},
|
|
58242
58503
|
// Bind to the live AccountManager so every refresh (manual or
|
|
58243
58504
|
// background) pushes the freshly-updated quota percentages into the
|
|
@@ -58674,7 +58935,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
58674
58935
|
const { source, pool } = await currentVaultPool();
|
|
58675
58936
|
return createVaultFetchInterceptor({
|
|
58676
58937
|
assertAdmission: async () => {
|
|
58677
|
-
if (await readAuthority()
|
|
58938
|
+
if (!["host", "vault"].includes(await readAuthority()))
|
|
58678
58939
|
throw new Error(unavailableMessage);
|
|
58679
58940
|
},
|
|
58680
58941
|
client,
|
|
@@ -58788,11 +59049,11 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
58788
59049
|
dir: getRpcDir(directory),
|
|
58789
59050
|
parseApplyRequest: commandsModule.parseApplyRequest,
|
|
58790
59051
|
version: await pluginPackageVersion(),
|
|
58791
|
-
apply: async (
|
|
59052
|
+
apply: async (request2) => {
|
|
58792
59053
|
const current = await currentMenu();
|
|
58793
59054
|
if (current.kind === "unavailable") throw new Error(current.message);
|
|
58794
|
-
const invocation = menuInvocation(pushNotification,
|
|
58795
|
-
const result = await current.menu.apply(
|
|
59055
|
+
const invocation = menuInvocation(pushNotification, request2.sessionId);
|
|
59056
|
+
const result = await current.menu.apply(request2, invocation);
|
|
58796
59057
|
try {
|
|
58797
59058
|
if (await readAuthority() === "local")
|
|
58798
59059
|
await lifecycle.getAccountManager()?.refreshFromRepository();
|
|
@@ -58806,7 +59067,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
|
|
|
58806
59067
|
kind: "warning"
|
|
58807
59068
|
}
|
|
58808
59069
|
},
|
|
58809
|
-
|
|
59070
|
+
request2.sessionId
|
|
58810
59071
|
);
|
|
58811
59072
|
}
|
|
58812
59073
|
const refreshed = await currentMenu();
|