@cortexkit/opencode-antigravity-auth 3.0.31 → 3.0.33
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 +117 -36
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +8 -8
- package/dist/index.js +168 -58
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +10 -10
- package/dist/server.js +168 -58
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +6 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +47 -3
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
- package/dist/src/common-auth-embedded/routing-accessor/index.js +122 -33
- package/dist/src/common-auth-embedded/source-output.json +18 -18
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/tui-build-map.json +1 -1
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +6 -0
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
- package/package.json +2 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +6 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.js +47 -3
- package/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
- package/src/common-auth-embedded/routing-accessor/index.js +122 -33
- package/src/common-auth-embedded/source-output.json +18 -18
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
type LeaseCreationTestHooks = {
|
|
2
|
+
beforeWrite?: (path: string) => void | Promise<void>;
|
|
3
|
+
beforeLink?: (tempPath: string, lockPath: string) => void | Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
/** Test-only creation faults; not re-exported from the public fs entry point. */
|
|
6
|
+
export declare function setLeaseCreationTestHooksForTest(hooks?: LeaseCreationTestHooks): void;
|
|
1
7
|
export declare function isLostMarkerRaceError(error: unknown): boolean;
|
|
2
8
|
/** Test-only fault injection between marker mkdir and owner.json write. */
|
|
3
9
|
export interface EvictionMarkerTestHooks {
|
|
@@ -1,8 +1,50 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { lstat, mkdir, open, readFile, rename, rm, stat, } from 'node:fs/promises';
|
|
2
|
+
import { link, lstat, mkdir, open, readFile, rename, rm, stat, } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { createPrivateBytes, createPrivateDirectoryExclusive, ensurePrivateDirectory, isWindowsSharingViolation, PrivateFileError, privateOperation, readPrivateText, verifyPrivate, windowsPrivateFiles, writePrivateAtomic, } from './private-files.js';
|
|
5
5
|
import { LockOwnershipError, lockPathFor } from './with-lock.js';
|
|
6
|
+
let leaseCreationTestHooks;
|
|
7
|
+
/** Test-only creation faults; not re-exported from the public fs entry point. */
|
|
8
|
+
export function setLeaseCreationTestHooksForTest(hooks) {
|
|
9
|
+
leaseCreationTestHooks = hooks;
|
|
10
|
+
}
|
|
11
|
+
async function createExclusiveText(path, text) {
|
|
12
|
+
// Publish only a complete owner record. A crash before link leaves at most
|
|
13
|
+
// an orphaned staging file, never an ownerless lease at the lock path.
|
|
14
|
+
const tempPath = `${path}.${randomUUID()}.tmp`;
|
|
15
|
+
let handle;
|
|
16
|
+
try {
|
|
17
|
+
handle = await open(tempPath, 'wx', 0o600);
|
|
18
|
+
try {
|
|
19
|
+
if (leaseCreationTestHooks?.beforeWrite)
|
|
20
|
+
await leaseCreationTestHooks.beforeWrite(tempPath);
|
|
21
|
+
await handle.writeFile(text, 'utf8');
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
await handle.close();
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
if (leaseCreationTestHooks?.beforeLink)
|
|
28
|
+
await leaseCreationTestHooks.beforeLink(tempPath, path);
|
|
29
|
+
await link(tempPath, path);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const code = error.code;
|
|
33
|
+
if (code !== 'EPERM' &&
|
|
34
|
+
code !== 'ENOTSUP' &&
|
|
35
|
+
code !== 'EOPNOTSUPP' &&
|
|
36
|
+
code !== 'EXDEV')
|
|
37
|
+
throw error;
|
|
38
|
+
// Filesystems without hard links still use exclusive create then write.
|
|
39
|
+
// A crash can leave an incomplete lease there, but locking stays available.
|
|
40
|
+
await writeExclusiveText(path, text);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
if (handle)
|
|
45
|
+
await rm(tempPath, { force: true }).catch(() => { });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
6
48
|
/**
|
|
7
49
|
* Create a new owner-only file and write `text` into it, failing with EEXIST if
|
|
8
50
|
* the file already exists. Writing through the handle rather than path-based
|
|
@@ -11,7 +53,7 @@ import { LockOwnershipError, lockPathFor } from './with-lock.js';
|
|
|
11
53
|
* that redundant ftruncate stalls for hundreds of milliseconds, inside every
|
|
12
54
|
* lock acquisition.
|
|
13
55
|
*/
|
|
14
|
-
async function
|
|
56
|
+
async function writeExclusiveText(path, text) {
|
|
15
57
|
const handle = await open(path, 'wx', 0o600);
|
|
16
58
|
let createdStat;
|
|
17
59
|
try {
|
|
@@ -21,6 +63,8 @@ async function createExclusiveText(path, text) {
|
|
|
21
63
|
createdStat = undefined;
|
|
22
64
|
}
|
|
23
65
|
try {
|
|
66
|
+
if (leaseCreationTestHooks?.beforeWrite)
|
|
67
|
+
await leaseCreationTestHooks.beforeWrite(path);
|
|
24
68
|
await handle.writeFile(text, 'utf8');
|
|
25
69
|
}
|
|
26
70
|
catch (error) {
|
|
@@ -491,7 +535,7 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
491
535
|
if (windowsPrivateFiles)
|
|
492
536
|
await createPrivateBytes(evictOwnerPath, bytes);
|
|
493
537
|
else
|
|
494
|
-
await
|
|
538
|
+
await writeExclusiveText(evictOwnerPath, bytes);
|
|
495
539
|
}
|
|
496
540
|
catch (error) {
|
|
497
541
|
// A competing contender can rename our just-created marker directory
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional THALAMUS routing for vault mode and advisory turn notes for request
|
|
3
|
+
* shaping. Account ids are vault account ids, not local pool rows. Nothing is
|
|
4
|
+
* persisted here; plugins on routes the runner does not serve get no turn notes.
|
|
5
|
+
*/
|
|
1
6
|
/** An eligible vault route, not a local pool row. */
|
|
2
7
|
export interface RoutingCandidate {
|
|
3
8
|
/** Vault account id, not the plugin's route id. */
|
|
@@ -35,7 +40,7 @@ interface RoutingReportIdentity {
|
|
|
35
40
|
accountId: string;
|
|
36
41
|
credentialId?: string;
|
|
37
42
|
}
|
|
38
|
-
export type ReportRoutingInput = RoutingReportIdentity & ({
|
|
43
|
+
export type ReportRoutingInput = (RoutingReportIdentity & ({
|
|
39
44
|
outcome: 'served';
|
|
40
45
|
/**
|
|
41
46
|
* Pass only rate-limit headers, never the whole response headers.
|
|
@@ -56,7 +61,26 @@ export type ReportRoutingInput = RoutingReportIdentity & ({
|
|
|
56
61
|
pool?: string;
|
|
57
62
|
/** Optional reset time in epoch milliseconds. */
|
|
58
63
|
resetsAt?: number;
|
|
59
|
-
})
|
|
64
|
+
})) | {
|
|
65
|
+
sessionId: string;
|
|
66
|
+
kind: 'turn_notes_supported';
|
|
67
|
+
model: string;
|
|
68
|
+
supported: boolean;
|
|
69
|
+
} | {
|
|
70
|
+
sessionId: string;
|
|
71
|
+
kind: 'turn_note_skipped';
|
|
72
|
+
after_tool_use_id: string;
|
|
73
|
+
reason: 'anchor_missing' | 'before_user_message' | 'unsupported_model' | 'not_oauth';
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Read advisory input for request shaping, in landing order, without persisting
|
|
77
|
+
* it. If no routing handle is available or the runner does not serve the route,
|
|
78
|
+
* returns [].
|
|
79
|
+
*/
|
|
80
|
+
export declare function turnNotes(sessionId: string): readonly {
|
|
81
|
+
afterToolUseId: string;
|
|
82
|
+
text: string;
|
|
83
|
+
}[];
|
|
60
84
|
/**
|
|
61
85
|
* Ask routing for an eligible vault route. Any failure or unfamiliar answer
|
|
62
86
|
* yields undefined so the plugin can keep its own choice. This does not admit
|
|
@@ -64,9 +88,10 @@ export type ReportRoutingInput = RoutingReportIdentity & ({
|
|
|
64
88
|
*/
|
|
65
89
|
export declare function askRouting<Candidate extends RoutingCandidate>(input: AskRoutingInput<Candidate>): Promise<RoutingSelection<Candidate> | undefined>;
|
|
66
90
|
/**
|
|
67
|
-
* Report a vault request without waiting for routing. Only
|
|
68
|
-
* sent, and all accessor failures are ignored. Headers must
|
|
69
|
-
* to rate-limit headers by the caller; values are not filtered
|
|
91
|
+
* Report a vault request or turn-note event without waiting for routing. Only
|
|
92
|
+
* contract fields are sent, and all accessor failures are ignored. Headers must
|
|
93
|
+
* already be limited to rate-limit headers by the caller; values are not filtered
|
|
94
|
+
* or redacted here.
|
|
70
95
|
*/
|
|
71
96
|
export declare function reportRouting(input: ReportRoutingInput): void;
|
|
72
97
|
export {};
|
|
@@ -1,9 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Optional THALAMUS routing for vault mode and advisory turn notes for request
|
|
3
|
+
* shaping. Account ids are vault account ids, not local pool rows. Nothing is
|
|
4
|
+
* persisted here; plugins on routes the runner does not serve get no turn notes.
|
|
5
|
+
*/
|
|
3
6
|
import { routingHandle } from './handle.js';
|
|
4
7
|
function isObject(value) {
|
|
5
8
|
return typeof value === 'object' && value !== null;
|
|
6
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Read advisory input for request shaping, in landing order, without persisting
|
|
12
|
+
* it. If no routing handle is available or the runner does not serve the route,
|
|
13
|
+
* returns [].
|
|
14
|
+
*/
|
|
15
|
+
export function turnNotes(sessionId) {
|
|
16
|
+
try {
|
|
17
|
+
const handle = routingHandle(sessionId);
|
|
18
|
+
if (!handle)
|
|
19
|
+
return [];
|
|
20
|
+
const read = handle.turn_notes;
|
|
21
|
+
if (typeof read !== 'function')
|
|
22
|
+
return [];
|
|
23
|
+
const answer = read.call(handle);
|
|
24
|
+
if (isObject(answer) && typeof answer.then === 'function') {
|
|
25
|
+
void Promise.resolve(answer).catch(() => { });
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
if (!Array.isArray(answer))
|
|
29
|
+
return [];
|
|
30
|
+
const notes = [];
|
|
31
|
+
const encoder = new TextEncoder();
|
|
32
|
+
for (const entry of answer) {
|
|
33
|
+
try {
|
|
34
|
+
if (!isObject(entry) || Array.isArray(entry))
|
|
35
|
+
continue;
|
|
36
|
+
const afterToolUseId = entry.after_tool_use_id;
|
|
37
|
+
const text = entry.text;
|
|
38
|
+
if (typeof afterToolUseId !== 'string' ||
|
|
39
|
+
afterToolUseId.length === 0 ||
|
|
40
|
+
typeof text !== 'string' ||
|
|
41
|
+
// A whitespace-only note says nothing and a provider may refuse it.
|
|
42
|
+
text.trim().length === 0 ||
|
|
43
|
+
encoder.encode(text).byteLength > 16_384)
|
|
44
|
+
continue;
|
|
45
|
+
notes.push({ afterToolUseId, text });
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// One unreadable note entry must not hide its valid neighbours.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return notes;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Turn notes are optional and must not break request shaping.
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
7
58
|
function selectionFor(answer, candidates) {
|
|
8
59
|
if (!isObject(answer))
|
|
9
60
|
return undefined;
|
|
@@ -72,9 +123,10 @@ export async function askRouting(input) {
|
|
|
72
123
|
}
|
|
73
124
|
}
|
|
74
125
|
/**
|
|
75
|
-
* Report a vault request without waiting for routing. Only
|
|
76
|
-
* sent, and all accessor failures are ignored. Headers must
|
|
77
|
-
* to rate-limit headers by the caller; values are not filtered
|
|
126
|
+
* Report a vault request or turn-note event without waiting for routing. Only
|
|
127
|
+
* contract fields are sent, and all accessor failures are ignored. Headers must
|
|
128
|
+
* already be limited to rate-limit headers by the caller; values are not filtered
|
|
129
|
+
* or redacted here.
|
|
78
130
|
*/
|
|
79
131
|
export function reportRouting(input) {
|
|
80
132
|
try {
|
|
@@ -84,38 +136,75 @@ export function reportRouting(input) {
|
|
|
84
136
|
const report = handle.report;
|
|
85
137
|
if (typeof report !== 'function')
|
|
86
138
|
return;
|
|
87
|
-
const identity = {
|
|
88
|
-
account_id: input.accountId,
|
|
89
|
-
...(input.credentialId !== undefined
|
|
90
|
-
? { credential_id: input.credentialId }
|
|
91
|
-
: {}),
|
|
92
|
-
};
|
|
93
139
|
let payload;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
140
|
+
if ('kind' in input) {
|
|
141
|
+
switch (input.kind) {
|
|
142
|
+
case 'turn_notes_supported': {
|
|
143
|
+
const { model, supported } = input;
|
|
144
|
+
if (typeof model !== 'string' ||
|
|
145
|
+
model.length === 0 ||
|
|
146
|
+
typeof supported !== 'boolean')
|
|
147
|
+
return;
|
|
148
|
+
payload = {
|
|
149
|
+
kind: 'turn_notes_supported',
|
|
150
|
+
model,
|
|
151
|
+
supported,
|
|
152
|
+
};
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case 'turn_note_skipped': {
|
|
156
|
+
const { after_tool_use_id, reason } = input;
|
|
157
|
+
if (typeof after_tool_use_id !== 'string' ||
|
|
158
|
+
after_tool_use_id.length === 0 ||
|
|
159
|
+
(reason !== 'anchor_missing' &&
|
|
160
|
+
reason !== 'before_user_message' &&
|
|
161
|
+
reason !== 'unsupported_model' &&
|
|
162
|
+
reason !== 'not_oauth'))
|
|
163
|
+
return;
|
|
164
|
+
payload = {
|
|
165
|
+
kind: 'turn_note_skipped',
|
|
166
|
+
after_tool_use_id,
|
|
167
|
+
reason,
|
|
168
|
+
};
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
default:
|
|
101
172
|
return;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const identity = {
|
|
177
|
+
account_id: input.accountId,
|
|
178
|
+
...(input.credentialId !== undefined
|
|
179
|
+
? { credential_id: input.credentialId }
|
|
180
|
+
: {}),
|
|
181
|
+
};
|
|
182
|
+
switch (input.outcome) {
|
|
183
|
+
case 'served':
|
|
184
|
+
payload = { ...identity, outcome: 'served', headers: input.headers };
|
|
185
|
+
break;
|
|
186
|
+
case 'exhausted': {
|
|
187
|
+
const { window, pool } = input;
|
|
188
|
+
if (window !== '5h' && window !== '7d')
|
|
189
|
+
return;
|
|
190
|
+
// An undefined pool means the whole account, as an omitted one does.
|
|
191
|
+
if (pool !== undefined &&
|
|
192
|
+
(typeof pool !== 'string' || !/^[a-z0-9._-]{1,64}$/.test(pool)))
|
|
193
|
+
return;
|
|
194
|
+
payload = {
|
|
195
|
+
...identity,
|
|
196
|
+
outcome: 'exhausted',
|
|
197
|
+
window,
|
|
198
|
+
...(pool ? { pool } : {}),
|
|
199
|
+
...(input.resetsAt !== undefined
|
|
200
|
+
? { resets_at: input.resetsAt }
|
|
201
|
+
: {}),
|
|
202
|
+
};
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
default:
|
|
105
206
|
return;
|
|
106
|
-
payload = {
|
|
107
|
-
...identity,
|
|
108
|
-
outcome: 'exhausted',
|
|
109
|
-
window,
|
|
110
|
-
...(pool ? { pool } : {}),
|
|
111
|
-
...(input.resetsAt !== undefined
|
|
112
|
-
? { resets_at: input.resetsAt }
|
|
113
|
-
: {}),
|
|
114
|
-
};
|
|
115
|
-
break;
|
|
116
207
|
}
|
|
117
|
-
default:
|
|
118
|
-
return;
|
|
119
208
|
}
|
|
120
209
|
// A broken bridge may return a rejected promise despite its void contract.
|
|
121
210
|
const pending = report.call(handle, payload);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"package": "@cortexkit/common-auth",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.39.1",
|
|
5
5
|
"artifactStatus": "published",
|
|
6
6
|
"publicRoots": {
|
|
7
7
|
"./rpc": {
|
|
@@ -69,15 +69,15 @@
|
|
|
69
69
|
"import": "./src/quota-sidebar/index.tsx"
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
-
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.
|
|
73
|
-
"tarballSha256": "
|
|
74
|
-
"sri": "sha512-
|
|
72
|
+
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.39.1.tgz",
|
|
73
|
+
"tarballSha256": "7d4eae5c55f007b6ca1838d0e85552685cc0dac0080594d108da63f69d1c9577",
|
|
74
|
+
"sri": "sha512-Oap+vs4zKFLdFA8iUgvS3X1iOI/xZaXQyhYoDSlUBsjsCutcZZ0M0bXY9C0a16fBFgmmcReXb3Pn3+P9Bebjng==",
|
|
75
75
|
"canonicalFiles": 216,
|
|
76
|
-
"canonicalBytes":
|
|
76
|
+
"canonicalBytes": 1355096,
|
|
77
77
|
"generator": {
|
|
78
78
|
"path": "packages/opencode/scripts/embed-common-auth.ts",
|
|
79
79
|
"version": 4,
|
|
80
|
-
"sha256": "
|
|
80
|
+
"sha256": "c6a4180f5d873855ea5abaeeeaea39e2beba2309da75dfb20c4cc3d485eda38f"
|
|
81
81
|
},
|
|
82
82
|
"files": [
|
|
83
83
|
{
|
|
@@ -643,17 +643,17 @@
|
|
|
643
643
|
{
|
|
644
644
|
"source": "package/dist/fs/refresh-file-lock.d.ts",
|
|
645
645
|
"output": "fs/refresh-file-lock.d.ts",
|
|
646
|
-
"bytes":
|
|
647
|
-
"sourceSha256": "
|
|
648
|
-
"outputSha256": "
|
|
646
|
+
"bytes": 3402,
|
|
647
|
+
"sourceSha256": "fefff72fcbbcedd80d96cea0f15d7a367220af76ea8c4dfea3f81f83b9931ab1",
|
|
648
|
+
"outputSha256": "fefff72fcbbcedd80d96cea0f15d7a367220af76ea8c4dfea3f81f83b9931ab1",
|
|
649
649
|
"transform": "verbatim"
|
|
650
650
|
},
|
|
651
651
|
{
|
|
652
652
|
"source": "package/dist/fs/refresh-file-lock.js",
|
|
653
653
|
"output": "fs/refresh-file-lock.js",
|
|
654
|
-
"bytes":
|
|
655
|
-
"sourceSha256": "
|
|
656
|
-
"outputSha256": "
|
|
654
|
+
"bytes": 43780,
|
|
655
|
+
"sourceSha256": "fa0200d4f4a759a8d4380aa2535cf07d98898650cc919031b0742d241662d96f",
|
|
656
|
+
"outputSha256": "fa0200d4f4a759a8d4380aa2535cf07d98898650cc919031b0742d241662d96f",
|
|
657
657
|
"transform": "verbatim"
|
|
658
658
|
},
|
|
659
659
|
{
|
|
@@ -1795,17 +1795,17 @@
|
|
|
1795
1795
|
{
|
|
1796
1796
|
"source": "package/dist/routing-accessor/index.d.ts",
|
|
1797
1797
|
"output": "routing-accessor/index.d.ts",
|
|
1798
|
-
"bytes":
|
|
1799
|
-
"sourceSha256": "
|
|
1800
|
-
"outputSha256": "
|
|
1798
|
+
"bytes": 3941,
|
|
1799
|
+
"sourceSha256": "04f480934ab1cd05585abb816014ac37cca32ccf783e90a98dd101513edf7f04",
|
|
1800
|
+
"outputSha256": "04f480934ab1cd05585abb816014ac37cca32ccf783e90a98dd101513edf7f04",
|
|
1801
1801
|
"transform": "verbatim"
|
|
1802
1802
|
},
|
|
1803
1803
|
{
|
|
1804
1804
|
"source": "package/dist/routing-accessor/index.js",
|
|
1805
1805
|
"output": "routing-accessor/index.js",
|
|
1806
|
-
"bytes":
|
|
1807
|
-
"sourceSha256": "
|
|
1808
|
-
"outputSha256": "
|
|
1806
|
+
"bytes": 8290,
|
|
1807
|
+
"sourceSha256": "ea80ae669e1f65555e88e5c56383d6e1a5ee813de532ffade61011bb4eeea16d",
|
|
1808
|
+
"outputSha256": "ea80ae669e1f65555e88e5c56383d6e1a5ee813de532ffade61011bb4eeea16d",
|
|
1809
1809
|
"transform": "verbatim"
|
|
1810
1810
|
}
|
|
1811
1811
|
],
|
|
@@ -4,8 +4,8 @@ import { dirname, join } from 'node:path';
|
|
|
4
4
|
import { loadCommonAuthStoreModules } from '@cortexkit/antigravity-auth-core';
|
|
5
5
|
const PIN = {
|
|
6
6
|
package: '@cortexkit/common-auth',
|
|
7
|
-
version: '0.
|
|
8
|
-
tarballSha256: '
|
|
7
|
+
version: '0.39.1',
|
|
8
|
+
tarballSha256: '7d4eae5c55f007b6ca1838d0e85552685cc0dac0080594d108da63f69d1c9577',
|
|
9
9
|
};
|
|
10
10
|
async function filesBelow(root, dir) {
|
|
11
11
|
const out = [];
|
package/dist/tui-build-map.json
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
type LeaseCreationTestHooks = {
|
|
2
|
+
beforeWrite?: (path: string) => void | Promise<void>;
|
|
3
|
+
beforeLink?: (tempPath: string, lockPath: string) => void | Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
/** Test-only creation faults; not re-exported from the public fs entry point. */
|
|
6
|
+
export declare function setLeaseCreationTestHooksForTest(hooks?: LeaseCreationTestHooks): void;
|
|
1
7
|
export declare function isLostMarkerRaceError(error: unknown): boolean;
|
|
2
8
|
/** Test-only fault injection between marker mkdir and owner.json write. */
|
|
3
9
|
export interface EvictionMarkerTestHooks {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional THALAMUS routing for vault mode and advisory turn notes for request
|
|
3
|
+
* shaping. Account ids are vault account ids, not local pool rows. Nothing is
|
|
4
|
+
* persisted here; plugins on routes the runner does not serve get no turn notes.
|
|
5
|
+
*/
|
|
1
6
|
/** An eligible vault route, not a local pool row. */
|
|
2
7
|
export interface RoutingCandidate {
|
|
3
8
|
/** Vault account id, not the plugin's route id. */
|
|
@@ -35,7 +40,7 @@ interface RoutingReportIdentity {
|
|
|
35
40
|
accountId: string;
|
|
36
41
|
credentialId?: string;
|
|
37
42
|
}
|
|
38
|
-
export type ReportRoutingInput = RoutingReportIdentity & ({
|
|
43
|
+
export type ReportRoutingInput = (RoutingReportIdentity & ({
|
|
39
44
|
outcome: 'served';
|
|
40
45
|
/**
|
|
41
46
|
* Pass only rate-limit headers, never the whole response headers.
|
|
@@ -56,7 +61,26 @@ export type ReportRoutingInput = RoutingReportIdentity & ({
|
|
|
56
61
|
pool?: string;
|
|
57
62
|
/** Optional reset time in epoch milliseconds. */
|
|
58
63
|
resetsAt?: number;
|
|
59
|
-
})
|
|
64
|
+
})) | {
|
|
65
|
+
sessionId: string;
|
|
66
|
+
kind: 'turn_notes_supported';
|
|
67
|
+
model: string;
|
|
68
|
+
supported: boolean;
|
|
69
|
+
} | {
|
|
70
|
+
sessionId: string;
|
|
71
|
+
kind: 'turn_note_skipped';
|
|
72
|
+
after_tool_use_id: string;
|
|
73
|
+
reason: 'anchor_missing' | 'before_user_message' | 'unsupported_model' | 'not_oauth';
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Read advisory input for request shaping, in landing order, without persisting
|
|
77
|
+
* it. If no routing handle is available or the runner does not serve the route,
|
|
78
|
+
* returns [].
|
|
79
|
+
*/
|
|
80
|
+
export declare function turnNotes(sessionId: string): readonly {
|
|
81
|
+
afterToolUseId: string;
|
|
82
|
+
text: string;
|
|
83
|
+
}[];
|
|
60
84
|
/**
|
|
61
85
|
* Ask routing for an eligible vault route. Any failure or unfamiliar answer
|
|
62
86
|
* yields undefined so the plugin can keep its own choice. This does not admit
|
|
@@ -64,9 +88,10 @@ export type ReportRoutingInput = RoutingReportIdentity & ({
|
|
|
64
88
|
*/
|
|
65
89
|
export declare function askRouting<Candidate extends RoutingCandidate>(input: AskRoutingInput<Candidate>): Promise<RoutingSelection<Candidate> | undefined>;
|
|
66
90
|
/**
|
|
67
|
-
* Report a vault request without waiting for routing. Only
|
|
68
|
-
* sent, and all accessor failures are ignored. Headers must
|
|
69
|
-
* to rate-limit headers by the caller; values are not filtered
|
|
91
|
+
* Report a vault request or turn-note event without waiting for routing. Only
|
|
92
|
+
* contract fields are sent, and all accessor failures are ignored. Headers must
|
|
93
|
+
* already be limited to rate-limit headers by the caller; values are not filtered
|
|
94
|
+
* or redacted here.
|
|
70
95
|
*/
|
|
71
96
|
export declare function reportRouting(input: ReportRoutingInput): void;
|
|
72
97
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/opencode-antigravity-auth",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.33",
|
|
4
4
|
"description": "Google Antigravity OAuth auth plugin for OpenCode - access Gemini and Claude models using Google credentials",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"dependencies": {
|
|
131
131
|
"@cortexkit/claustrum-client": "0.15.0",
|
|
132
132
|
"@cortexkit/subc-client": "0.22.5",
|
|
133
|
-
"@cortexkit/antigravity-auth-core": "3.0.
|
|
133
|
+
"@cortexkit/antigravity-auth-core": "3.0.33",
|
|
134
134
|
"@cortexkit/private-files": "0.2.2",
|
|
135
135
|
"jsonc-parser": "^3.3.1",
|
|
136
136
|
"xdg-basedir": "^5.1.0",
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
type LeaseCreationTestHooks = {
|
|
2
|
+
beforeWrite?: (path: string) => void | Promise<void>;
|
|
3
|
+
beforeLink?: (tempPath: string, lockPath: string) => void | Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
/** Test-only creation faults; not re-exported from the public fs entry point. */
|
|
6
|
+
export declare function setLeaseCreationTestHooksForTest(hooks?: LeaseCreationTestHooks): void;
|
|
1
7
|
export declare function isLostMarkerRaceError(error: unknown): boolean;
|
|
2
8
|
/** Test-only fault injection between marker mkdir and owner.json write. */
|
|
3
9
|
export interface EvictionMarkerTestHooks {
|
|
@@ -1,8 +1,50 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { lstat, mkdir, open, readFile, rename, rm, stat, } from 'node:fs/promises';
|
|
2
|
+
import { link, lstat, mkdir, open, readFile, rename, rm, stat, } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { createPrivateBytes, createPrivateDirectoryExclusive, ensurePrivateDirectory, isWindowsSharingViolation, PrivateFileError, privateOperation, readPrivateText, verifyPrivate, windowsPrivateFiles, writePrivateAtomic, } from './private-files.js';
|
|
5
5
|
import { LockOwnershipError, lockPathFor } from './with-lock.js';
|
|
6
|
+
let leaseCreationTestHooks;
|
|
7
|
+
/** Test-only creation faults; not re-exported from the public fs entry point. */
|
|
8
|
+
export function setLeaseCreationTestHooksForTest(hooks) {
|
|
9
|
+
leaseCreationTestHooks = hooks;
|
|
10
|
+
}
|
|
11
|
+
async function createExclusiveText(path, text) {
|
|
12
|
+
// Publish only a complete owner record. A crash before link leaves at most
|
|
13
|
+
// an orphaned staging file, never an ownerless lease at the lock path.
|
|
14
|
+
const tempPath = `${path}.${randomUUID()}.tmp`;
|
|
15
|
+
let handle;
|
|
16
|
+
try {
|
|
17
|
+
handle = await open(tempPath, 'wx', 0o600);
|
|
18
|
+
try {
|
|
19
|
+
if (leaseCreationTestHooks?.beforeWrite)
|
|
20
|
+
await leaseCreationTestHooks.beforeWrite(tempPath);
|
|
21
|
+
await handle.writeFile(text, 'utf8');
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
await handle.close();
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
if (leaseCreationTestHooks?.beforeLink)
|
|
28
|
+
await leaseCreationTestHooks.beforeLink(tempPath, path);
|
|
29
|
+
await link(tempPath, path);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const code = error.code;
|
|
33
|
+
if (code !== 'EPERM' &&
|
|
34
|
+
code !== 'ENOTSUP' &&
|
|
35
|
+
code !== 'EOPNOTSUPP' &&
|
|
36
|
+
code !== 'EXDEV')
|
|
37
|
+
throw error;
|
|
38
|
+
// Filesystems without hard links still use exclusive create then write.
|
|
39
|
+
// A crash can leave an incomplete lease there, but locking stays available.
|
|
40
|
+
await writeExclusiveText(path, text);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
if (handle)
|
|
45
|
+
await rm(tempPath, { force: true }).catch(() => { });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
6
48
|
/**
|
|
7
49
|
* Create a new owner-only file and write `text` into it, failing with EEXIST if
|
|
8
50
|
* the file already exists. Writing through the handle rather than path-based
|
|
@@ -11,7 +53,7 @@ import { LockOwnershipError, lockPathFor } from './with-lock.js';
|
|
|
11
53
|
* that redundant ftruncate stalls for hundreds of milliseconds, inside every
|
|
12
54
|
* lock acquisition.
|
|
13
55
|
*/
|
|
14
|
-
async function
|
|
56
|
+
async function writeExclusiveText(path, text) {
|
|
15
57
|
const handle = await open(path, 'wx', 0o600);
|
|
16
58
|
let createdStat;
|
|
17
59
|
try {
|
|
@@ -21,6 +63,8 @@ async function createExclusiveText(path, text) {
|
|
|
21
63
|
createdStat = undefined;
|
|
22
64
|
}
|
|
23
65
|
try {
|
|
66
|
+
if (leaseCreationTestHooks?.beforeWrite)
|
|
67
|
+
await leaseCreationTestHooks.beforeWrite(path);
|
|
24
68
|
await handle.writeFile(text, 'utf8');
|
|
25
69
|
}
|
|
26
70
|
catch (error) {
|
|
@@ -491,7 +535,7 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
491
535
|
if (windowsPrivateFiles)
|
|
492
536
|
await createPrivateBytes(evictOwnerPath, bytes);
|
|
493
537
|
else
|
|
494
|
-
await
|
|
538
|
+
await writeExclusiveText(evictOwnerPath, bytes);
|
|
495
539
|
}
|
|
496
540
|
catch (error) {
|
|
497
541
|
// A competing contender can rename our just-created marker directory
|