@cortexkit/opencode-openai-auth 1.10.0 → 1.11.0
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/bin.js +8 -8
- package/dist/{codex-request-BLzSBegI.d.ts → codex-request-DFeGDzpN.d.ts} +2 -2
- package/dist/index-0kpq9310.js +76 -0
- package/dist/{index-361xxyg2.js → index-2p3st53v.js} +2 -2
- package/dist/{index-dcyhv7eh.js → index-3x7q1rj8.js} +2 -2
- package/dist/{index-mkda7acs.js → index-4daebegf.js} +1 -1
- package/dist/{index-w37815v4.js → index-4rzatybc.js} +1 -1
- package/dist/{index-mf3dqvbn.js → index-7at0fc03.js} +2 -2
- package/dist/{index-fd3f8vw2.js → index-afpxnan1.js} +2 -2
- package/dist/{index-29ztc0ay.js → index-bxxjwt4q.js} +2 -2
- package/dist/index-cy6km6cz.js +64 -0
- package/dist/{index-17rh67pr.js → index-d5v2rn54.js} +1 -1
- package/dist/{index-95z5dpe1.js → index-dp68014q.js} +2 -2
- package/dist/index-h2z9jb3g.js +91 -0
- package/dist/{index-dkhy2peg.js → index-smzgsx6x.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/token-util-e49kkftr.js +1 -0
- package/dist/{token-pd3t5f20.js → token-wgntcjq1.js} +1 -1
- package/dist/tui-preferences.js +1 -1
- package/dist/v2/server.d.ts +1 -1
- package/dist/v2/server.js +2 -2
- package/package.json +4 -4
- package/src/tui-compiled/raw/shared/0f77ebc3c914c9c6-custody.js +26 -15
- package/src/tui-compiled/raw/shared/169b2b4bf30909bc-consumer.js +14 -5
- package/src/tui-compiled/raw/shared/352d228be2832bd4-hub.js +5 -2
- package/src/tui-compiled/raw/shared/94f53cfd572ba4bb-availability.js +2 -0
- package/src/tui-compiled/raw/shared/b9588ad4725c1d10-enrollment.js +7 -0
- package/src/tui-compiled/raw/shared/c97089ed4243981c-host.js +113 -0
- package/src/tui-compiled/raw/shared/e8d3c8da776ef9cd-index.js +2 -1
- package/src/tui-compiled/runtime/shared/0f77ebc3c914c9c6-custody.js +26 -15
- package/src/tui-compiled/runtime/shared/169b2b4bf30909bc-consumer.js +14 -5
- package/src/tui-compiled/runtime/shared/352d228be2832bd4-hub.js +5 -2
- package/src/tui-compiled/runtime/shared/94f53cfd572ba4bb-availability.js +2 -0
- package/src/tui-compiled/runtime/shared/b9588ad4725c1d10-enrollment.js +7 -0
- package/src/tui-compiled/runtime/shared/c97089ed4243981c-host.js +113 -0
- package/src/tui-compiled/runtime/shared/e8d3c8da776ef9cd-index.js +2 -1
- package/dist/index-3p1tc2e2.js +0 -91
- package/dist/index-3r9thx6n.js +0 -76
- package/dist/index-ya96m6wr.js +0 -64
- package/dist/token-util-807rzwws.js +0 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ClaustrumCredentialError } from "@cortexkit/claustrum-client";
|
|
2
|
+
import { ClaustrumUnreachableError, classifyVaultFailure, } from "./94f53cfd572ba4bb-availability.js";
|
|
3
|
+
export const VAULT_HOST_STATUS = 'Served by Thalamus';
|
|
4
|
+
export const VAULT_HOST_CONNECT_REFUSAL = "This host gets its vault accounts from Thalamus, so it can't connect to the vault itself.";
|
|
5
|
+
// Object identity prevents a native client from carrying the host's empty token argument.
|
|
6
|
+
const hostClients = new WeakSet();
|
|
7
|
+
export function isVaultHostClient(client) {
|
|
8
|
+
return hostClients.has(client);
|
|
9
|
+
}
|
|
10
|
+
/** The spawn marker, not a global installed by another plugin, selects authority. */
|
|
11
|
+
export function hasVaultHost() {
|
|
12
|
+
return process.env.CORTEXKIT_VAULT_HOST === 'thalamus';
|
|
13
|
+
}
|
|
14
|
+
function hostError(error) {
|
|
15
|
+
if (typeof error !== 'object' || error === null)
|
|
16
|
+
return error;
|
|
17
|
+
const value = error;
|
|
18
|
+
if (typeof value.code === 'string' &&
|
|
19
|
+
(value.class === 'transient' ||
|
|
20
|
+
value.class === 'permanent' ||
|
|
21
|
+
value.class === 'auth_required' ||
|
|
22
|
+
value.class === 'context_overflow') &&
|
|
23
|
+
(value.action === 'gone' ||
|
|
24
|
+
value.action === 'reauth' ||
|
|
25
|
+
value.action === 'retry' ||
|
|
26
|
+
value.action === 'reduce_and_retry'))
|
|
27
|
+
return new ClaustrumCredentialError(value.code, value.class, value.action);
|
|
28
|
+
if (value.name === 'ClaustrumUnreachableError' ||
|
|
29
|
+
(typeof value.code === 'string' &&
|
|
30
|
+
classifyVaultFailure(Object.assign(new Error(), { code: value.code })) ===
|
|
31
|
+
'unreachable'))
|
|
32
|
+
return new ClaustrumUnreachableError();
|
|
33
|
+
return error;
|
|
34
|
+
}
|
|
35
|
+
function call(operation) {
|
|
36
|
+
try {
|
|
37
|
+
return operation();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw hostError(error);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function request(operation) {
|
|
44
|
+
try {
|
|
45
|
+
return await operation();
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw hostError(error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Normalize only the host boundary; native clients keep their strict error identity. */
|
|
52
|
+
function wrapHostClient(client) {
|
|
53
|
+
const watchScoped = client.watchScoped?.bind(client);
|
|
54
|
+
const reportUsageScoped = client.reportUsageScoped?.bind(client);
|
|
55
|
+
return {
|
|
56
|
+
listScoped: (...args) => request(() => client.listScoped(...args)),
|
|
57
|
+
getScoped: (...args) => request(() => client.getScoped(...args)),
|
|
58
|
+
reportAuthFailureScoped: (...args) => request(() => client.reportAuthFailureScoped(...args)),
|
|
59
|
+
close: () => call(() => client.close()),
|
|
60
|
+
...(watchScoped && {
|
|
61
|
+
watchScoped: (...args) => {
|
|
62
|
+
const watch = call(() => watchScoped(...args));
|
|
63
|
+
return {
|
|
64
|
+
stop: () => call(() => watch.stop()),
|
|
65
|
+
closed: request(async () => {
|
|
66
|
+
const end = await watch.closed;
|
|
67
|
+
return end.kind === 'refused' || end.kind === 'transport_lost'
|
|
68
|
+
? { ...end, error: hostError(end.error) }
|
|
69
|
+
: end;
|
|
70
|
+
}),
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
...(reportUsageScoped && {
|
|
75
|
+
reportUsageScoped: (...args) => request(() => reportUsageScoped(...args)),
|
|
76
|
+
}),
|
|
77
|
+
...(client.insula && {
|
|
78
|
+
insula: wrapInsula(client.insula),
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function wrapInsula(transport) {
|
|
83
|
+
const watchUsage = transport.watchUsage?.bind(transport);
|
|
84
|
+
return {
|
|
85
|
+
connectionFile: transport.connectionFile,
|
|
86
|
+
getUsage: () => request(() => transport.getUsage()),
|
|
87
|
+
...(watchUsage && {
|
|
88
|
+
watchUsage: (...args) => {
|
|
89
|
+
const watch = call(() => watchUsage(...args));
|
|
90
|
+
return {
|
|
91
|
+
stop: () => call(() => watch.stop()),
|
|
92
|
+
closed: request(() => watch.closed),
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** Read at connect time so a bridge installed after the auth plugin can recover. */
|
|
99
|
+
export function connectVaultHost(pluginId) {
|
|
100
|
+
if (!hasVaultHost() || !pluginId)
|
|
101
|
+
throw new ClaustrumUnreachableError();
|
|
102
|
+
try {
|
|
103
|
+
const accessor = globalThis[Symbol.for('cortexkit.vault')];
|
|
104
|
+
if (typeof accessor !== 'function')
|
|
105
|
+
throw new ClaustrumUnreachableError();
|
|
106
|
+
const client = wrapHostClient(accessor(pluginId));
|
|
107
|
+
hostClients.add(client);
|
|
108
|
+
return client;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
throw new ClaustrumUnreachableError();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -10,8 +10,9 @@ export { ClaustrumCredentialError, } from "@cortexkit/claustrum-client";
|
|
|
10
10
|
export { ClaustrumUnreachableError, classifyVaultFailure, VAULT_FAILURE_CLASSES, } from "./94f53cfd572ba4bb-availability.js";
|
|
11
11
|
export { ClaustrumConsumer, DEFAULT_CONNECT_TIMEOUT_MS, } from "./169b2b4bf30909bc-consumer.js";
|
|
12
12
|
export { ClaustrumScopedCustody, decideScopedRetryAfter401, isScopedCredentialRotation, KEPT_RECEIPT_MARGIN_MS, SERVING_MARGIN_MS, } from "./0f77ebc3c914c9c6-custody.js";
|
|
13
|
-
export { ClaustrumEnrollmentManager, classifyEnrollmentError, connectClaustrumEnrollmentClient, disconnectClaustrumEnrollment, enrollmentAuthority, enrollmentName, getClaustrumEnrollmentPaths, hostEnrollmentPaths, RETRYABLE_ENROLLMENT_CODES, readClaustrumEnrollmentStatus, readClaustrumEnrollmentToken, resetClaustrumEnrollmentState, TERMINAL_ENROLLMENT_CODES, } from "./b9588ad4725c1d10-enrollment.js";
|
|
13
|
+
export { ClaustrumEnrollmentManager, classifyEnrollmentError, connectClaustrumEnrollmentClient, disconnectClaustrumEnrollment, enrollmentAuthority, enrollmentName, getClaustrumEnrollmentPaths, hostEnrollmentPaths, RETRYABLE_ENROLLMENT_CODES, readClaustrumEnrollmentStatus, readClaustrumEnrollmentToken, resetClaustrumEnrollmentState, TERMINAL_ENROLLMENT_CODES, vaultAuthority, } from "./b9588ad4725c1d10-enrollment.js";
|
|
14
14
|
export { ClaustrumConsumerError, } from "./ca0fccaba1d87af4-errors.js";
|
|
15
|
+
export { connectVaultHost, hasVaultHost, VAULT_HOST_CONNECT_REFUSAL, VAULT_HOST_STATUS, } from "./c97089ed4243981c-host.js";
|
|
15
16
|
export { assertHostSlotMatchesMode, assertNotCustodyPlaceholder, CUSTODY_PLACEHOLDER_PREFIX, classifyHostSlot, custodyPlaceholder, custodyPlaceholderKey, isCustodyPlaceholder, isCustodyPlaceholderValue, } from "./d9d2892a4c371301-host-slot.js";
|
|
16
17
|
export { ClaustrumDiscoveryHub, } from "./352d228be2832bd4-hub.js";
|
|
17
18
|
export { acquireInsulaQuotaSource, } from "./d0f0b6be200311af-insula.js";
|