dsh-antigravity-auth 0.1.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/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +168 -0
- package/README.zh.md +159 -0
- package/cordis.patch.yml +12 -0
- package/lib/capability-lifecycle--tgGKajs.js +1896 -0
- package/lib/client.cjs +2123 -0
- package/lib/client.cjs.map +1 -0
- package/lib/image.js +564 -0
- package/lib/index.js +176 -0
- package/lib/invariant.js +2 -0
- package/lib/live-gate-runner.js +542 -0
- package/lib/live-gates.js +97 -0
- package/lib/llm-adapter.js +916 -0
- package/lib/media-admission.js +206 -0
- package/lib/private-failure-B9vzUkQ7.js +23 -0
- package/lib/private-transport-urF138qW.js +641 -0
- package/lib/private-transport.js +2 -0
- package/lib/project-context.js +133 -0
- package/lib/quota.js +283 -0
- package/lib/replay.js +156 -0
- package/lib/rpc-contract-BFWfdKKs.js +491 -0
- package/lib/rpc-contract.js +2 -0
- package/lib/safe-text-AlEyN8q_.js +12 -0
- package/lib/search.js +259 -0
- package/lib/status-D0-em3Ru.js +125 -0
- package/lib/types/auth-service.d.ts +64 -0
- package/lib/types/auth-service.d.ts.map +1 -0
- package/lib/types/auth-store.d.ts +45 -0
- package/lib/types/auth-store.d.ts.map +1 -0
- package/lib/types/bootstrap-service.d.ts +6 -0
- package/lib/types/bootstrap-service.d.ts.map +1 -0
- package/lib/types/capability-gates.d.ts +19 -0
- package/lib/types/capability-gates.d.ts.map +1 -0
- package/lib/types/capability-lifecycle.d.ts +26 -0
- package/lib/types/capability-lifecycle.d.ts.map +1 -0
- package/lib/types/client/AntigravityAuthSettings.d.ts +19 -0
- package/lib/types/client/AntigravityAuthSettings.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +18 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/locales.d.ts +121 -0
- package/lib/types/client/locales.d.ts.map +1 -0
- package/lib/types/client/styles.d.ts +4 -0
- package/lib/types/client/styles.d.ts.map +1 -0
- package/lib/types/credential-coordinator.d.ts +84 -0
- package/lib/types/credential-coordinator.d.ts.map +1 -0
- package/lib/types/image.d.ts +39 -0
- package/lib/types/image.d.ts.map +1 -0
- package/lib/types/index.d.ts +21 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/invariant.d.ts +3 -0
- package/lib/types/invariant.d.ts.map +1 -0
- package/lib/types/live-gate-attachments.d.ts +6 -0
- package/lib/types/live-gate-attachments.d.ts.map +1 -0
- package/lib/types/live-gate-auth.d.ts +5 -0
- package/lib/types/live-gate-auth.d.ts.map +1 -0
- package/lib/types/live-gate-image.d.ts +5 -0
- package/lib/types/live-gate-image.d.ts.map +1 -0
- package/lib/types/live-gate-llm.d.ts +10 -0
- package/lib/types/live-gate-llm.d.ts.map +1 -0
- package/lib/types/live-gate-outcome.d.ts +8 -0
- package/lib/types/live-gate-outcome.d.ts.map +1 -0
- package/lib/types/live-gate-runner.d.ts +15 -0
- package/lib/types/live-gate-runner.d.ts.map +1 -0
- package/lib/types/live-gate-search.d.ts +5 -0
- package/lib/types/live-gate-search.d.ts.map +1 -0
- package/lib/types/live-gate-video.d.ts +8 -0
- package/lib/types/live-gate-video.d.ts.map +1 -0
- package/lib/types/live-gates.d.ts +25 -0
- package/lib/types/live-gates.d.ts.map +1 -0
- package/lib/types/llm-adapter.d.ts +65 -0
- package/lib/types/llm-adapter.d.ts.map +1 -0
- package/lib/types/login-types.d.ts +36 -0
- package/lib/types/login-types.d.ts.map +1 -0
- package/lib/types/media-admission.d.ts +54 -0
- package/lib/types/media-admission.d.ts.map +1 -0
- package/lib/types/model-catalog.d.ts +19 -0
- package/lib/types/model-catalog.d.ts.map +1 -0
- package/lib/types/oauth-flow.d.ts +87 -0
- package/lib/types/oauth-flow.d.ts.map +1 -0
- package/lib/types/private-failure.d.ts +6 -0
- package/lib/types/private-failure.d.ts.map +1 -0
- package/lib/types/private-transport-error.d.ts +13 -0
- package/lib/types/private-transport-error.d.ts.map +1 -0
- package/lib/types/private-transport.d.ts +48 -0
- package/lib/types/private-transport.d.ts.map +1 -0
- package/lib/types/project-context.d.ts +30 -0
- package/lib/types/project-context.d.ts.map +1 -0
- package/lib/types/quota.d.ts +43 -0
- package/lib/types/quota.d.ts.map +1 -0
- package/lib/types/raw-http.d.ts +11 -0
- package/lib/types/raw-http.d.ts.map +1 -0
- package/lib/types/replay.d.ts +30 -0
- package/lib/types/replay.d.ts.map +1 -0
- package/lib/types/rpc-contract.d.ts +33 -0
- package/lib/types/rpc-contract.d.ts.map +1 -0
- package/lib/types/rpc-vocabulary.d.ts +7 -0
- package/lib/types/rpc-vocabulary.d.ts.map +1 -0
- package/lib/types/rpc.d.ts +11 -0
- package/lib/types/rpc.d.ts.map +1 -0
- package/lib/types/safe-text.d.ts +3 -0
- package/lib/types/safe-text.d.ts.map +1 -0
- package/lib/types/search.d.ts +42 -0
- package/lib/types/search.d.ts.map +1 -0
- package/lib/types/status.d.ts +62 -0
- package/lib/types/status.d.ts.map +1 -0
- package/lib/types/video.d.ts +42 -0
- package/lib/types/video.d.ts.map +1 -0
- package/lib/types/wire-identity.d.ts +49 -0
- package/lib/types/wire-identity.d.ts.map +1 -0
- package/lib/video.js +320 -0
- package/lib/wire-identity.js +162 -0
- package/package.json +189 -0
- package/scripts/live-gates.mjs +4 -0
package/lib/search.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { i as createAntigravityAuthService, t as mountCapabilityLifecycle } from "./capability-lifecycle--tgGKajs.js";
|
|
2
|
+
import { d as privateStatusError, l as createPrivateTransport, m as PrivateTransportError, n as DEFAULT_PRIVATE_IDLE_TIMEOUT_MS, o as DEFAULT_PRIVATE_TOTAL_TIMEOUT_MS, t as DEFAULT_PRIVATE_FRAME_BYTES, u as iteratePrivateSse } from "./private-transport-urF138qW.js";
|
|
3
|
+
import { ANTIGRAVITY_WIRE_ORIGIN } from "./wire-identity.js";
|
|
4
|
+
import { t as classifyPrivateFailure } from "./private-failure-B9vzUkQ7.js";
|
|
5
|
+
import { resolveModelWithTier } from "@cortexkit/antigravity-auth-core";
|
|
6
|
+
import z from "@deepseek-ai/schemastery";
|
|
7
|
+
import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
|
|
8
|
+
import { WebError } from "@deepseek-ai/dsh-web";
|
|
9
|
+
//#region src/search.ts
|
|
10
|
+
const name = "antigravity-search";
|
|
11
|
+
const inject = ["web", "antigravityAuth"];
|
|
12
|
+
const ANTIGRAVITY_SEARCH_PROVIDER_ID = "antigravity";
|
|
13
|
+
const ANTIGRAVITY_SEARCH_ENDPOINT = `${ANTIGRAVITY_WIRE_ORIGIN}/v1internal:generateContent`;
|
|
14
|
+
const ANTIGRAVITY_SEARCH_MODEL = "antigravity-gemini-3.7-flash";
|
|
15
|
+
const ANTIGRAVITY_SEARCH_SETTINGS_NAMESPACE = settingsNamespace("antigravity-search");
|
|
16
|
+
const Config = z.object({
|
|
17
|
+
enabled: z.boolean().default(true),
|
|
18
|
+
model: z.string().default(ANTIGRAVITY_SEARCH_MODEL),
|
|
19
|
+
maxResults: z.number().step(1).min(1).max(50).default(10)
|
|
20
|
+
});
|
|
21
|
+
var AntigravitySearchProvider = class {
|
|
22
|
+
options;
|
|
23
|
+
id = ANTIGRAVITY_SEARCH_PROVIDER_ID;
|
|
24
|
+
enabled;
|
|
25
|
+
transport;
|
|
26
|
+
constructor(options) {
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.enabled = options.enabled ?? (() => options.settings?.().enabled ?? true);
|
|
29
|
+
this.transport = options.transport ?? createPrivateTransport();
|
|
30
|
+
}
|
|
31
|
+
available() {
|
|
32
|
+
return this.enabled();
|
|
33
|
+
}
|
|
34
|
+
async search(request, signal) {
|
|
35
|
+
if (!this.enabled()) throw new WebError("Antigravity Web Search is disabled by its capability gate", "ANTIGRAVITY_SEARCH_DISABLED");
|
|
36
|
+
if (signal?.aborted === true) throw new WebError("Antigravity Web Search was cancelled", "ANTIGRAVITY_SEARCH_CANCELLED");
|
|
37
|
+
if (typeof request.query !== "string" || request.query.trim().length === 0 || request.query.length > 16384) throw new WebError("Antigravity Web Search requires a bounded query", "ANTIGRAVITY_SEARCH_INVALID_QUERY");
|
|
38
|
+
const settings = this.options.settings?.() ?? {
|
|
39
|
+
enabled: true,
|
|
40
|
+
model: "antigravity-gemini-3.7-flash",
|
|
41
|
+
maxResults: 10
|
|
42
|
+
};
|
|
43
|
+
const configuredMax = boundedInteger(settings.maxResults, 1, 50);
|
|
44
|
+
const requestedMax = request.maxResults === void 0 ? configuredMax : boundedInteger(request.maxResults, 1, 50);
|
|
45
|
+
const maxResults = Math.min(configuredMax, requestedMax);
|
|
46
|
+
const credential = await this.options.auth.credential(signal);
|
|
47
|
+
if (credential === void 0) throw new WebError("Antigravity Web Search requires a logged-in account", "ANTIGRAVITY_SEARCH_AUTH_REQUIRED");
|
|
48
|
+
const response = await this.transport.request({
|
|
49
|
+
url: ANTIGRAVITY_SEARCH_ENDPOINT,
|
|
50
|
+
accessToken: credential.accessToken,
|
|
51
|
+
body: JSON.stringify(buildGroundedSearchPayload(request.query.trim(), credential, settings.model)),
|
|
52
|
+
...signal === void 0 ? {} : { signal }
|
|
53
|
+
}).catch((error) => {
|
|
54
|
+
throw toWebError(error);
|
|
55
|
+
});
|
|
56
|
+
const statusError = privateStatusError(response.status);
|
|
57
|
+
if (statusError !== void 0) {
|
|
58
|
+
await response.body?.cancel().catch(() => {});
|
|
59
|
+
throw toWebError(statusError);
|
|
60
|
+
}
|
|
61
|
+
const sources = [];
|
|
62
|
+
const seen = /* @__PURE__ */ new Set();
|
|
63
|
+
const content = [];
|
|
64
|
+
let truncated = false;
|
|
65
|
+
try {
|
|
66
|
+
for await (const event of iteratePrivateSse(response, {
|
|
67
|
+
...signal === void 0 ? {} : { signal },
|
|
68
|
+
idleTimeoutMs: DEFAULT_PRIVATE_IDLE_TIMEOUT_MS,
|
|
69
|
+
totalTimeoutMs: DEFAULT_PRIVATE_TOTAL_TIMEOUT_MS,
|
|
70
|
+
maxBytes: this.options.maxResponseBytes ?? 8388608,
|
|
71
|
+
maxFrameBytes: DEFAULT_PRIVATE_FRAME_BYTES
|
|
72
|
+
})) {
|
|
73
|
+
if (event.data.trim() === "[DONE]") continue;
|
|
74
|
+
const value = parseJson(event.data);
|
|
75
|
+
truncated ||= collectSearchFacts(value, content, sources, seen, maxResults);
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
throw toWebError(error);
|
|
79
|
+
}
|
|
80
|
+
if (sources.length === 0) throw new WebError("Antigravity Search returned no validated grounding sources", "ANTIGRAVITY_SEARCH_NO_SOURCES");
|
|
81
|
+
return {
|
|
82
|
+
...content.length === 0 ? {} : { content: content.join("").slice(0, 65536) },
|
|
83
|
+
sources,
|
|
84
|
+
truncated
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function buildGroundedSearchPayload(query, credential, model = ANTIGRAVITY_SEARCH_MODEL) {
|
|
89
|
+
return {
|
|
90
|
+
project: credential.projectId,
|
|
91
|
+
model: resolveModelWithTier(model, { cli_first: false }).actualModel,
|
|
92
|
+
request: {
|
|
93
|
+
contents: [{
|
|
94
|
+
role: "user",
|
|
95
|
+
parts: [{ text: query }]
|
|
96
|
+
}],
|
|
97
|
+
tools: [{ googleSearch: {} }],
|
|
98
|
+
systemInstruction: { parts: [{ text: "Return a concise grounded answer with only sources supplied by the provider." }] }
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Mount only the public Web Search seam; no fetch provider is registered. */
|
|
103
|
+
function apply(ctx, config = {
|
|
104
|
+
enabled: true,
|
|
105
|
+
model: ANTIGRAVITY_SEARCH_MODEL,
|
|
106
|
+
maxResults: 10
|
|
107
|
+
}) {
|
|
108
|
+
if (ctx === void 0) return;
|
|
109
|
+
const candidate = ctx;
|
|
110
|
+
if (candidate.web === void 0) return;
|
|
111
|
+
let current = () => config;
|
|
112
|
+
let lifecycle;
|
|
113
|
+
installSettingsSection(ctx, ANTIGRAVITY_SEARCH_SETTINGS_NAMESPACE, Config, config, {
|
|
114
|
+
setSource: (source) => {
|
|
115
|
+
current = source;
|
|
116
|
+
lifecycle?.sync();
|
|
117
|
+
},
|
|
118
|
+
onChange: () => {
|
|
119
|
+
lifecycle?.sync();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
const provided = candidate.get?.("antigravityAuth");
|
|
123
|
+
const auth = isAuthService(provided) ? provided : createAntigravityAuthService();
|
|
124
|
+
lifecycle = mountCapabilityLifecycle({
|
|
125
|
+
ctx,
|
|
126
|
+
auth,
|
|
127
|
+
id: "search",
|
|
128
|
+
enabled: () => current().enabled,
|
|
129
|
+
register: () => candidate.web.registerSearchProvider(new AntigravitySearchProvider({
|
|
130
|
+
auth,
|
|
131
|
+
settings: current
|
|
132
|
+
})),
|
|
133
|
+
ownsAuth: auth !== provided,
|
|
134
|
+
label: "antigravity-search: provider lifecycle"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function collectSearchFacts(value, content, sources, seen, maxResults) {
|
|
138
|
+
if (!isRecord(value)) return false;
|
|
139
|
+
const root = isRecord(value.response) ? value.response : value;
|
|
140
|
+
const texts = [findText(root)];
|
|
141
|
+
const metadataValues = [
|
|
142
|
+
root.groundingMetadata,
|
|
143
|
+
root.grounding_metadata,
|
|
144
|
+
value.groundingMetadata
|
|
145
|
+
];
|
|
146
|
+
if (Array.isArray(root.candidates)) {
|
|
147
|
+
if (root.candidates.length > 512) throw new WebError("Antigravity Search returned too many candidates", "ANTIGRAVITY_SEARCH_PROTOCOL_DRIFT");
|
|
148
|
+
for (const candidate of root.candidates) {
|
|
149
|
+
if (!isRecord(candidate)) continue;
|
|
150
|
+
texts.push(findText(candidate));
|
|
151
|
+
if (isRecord(candidate.content)) texts.push(findText(candidate.content));
|
|
152
|
+
metadataValues.push(candidate.groundingMetadata, candidate.grounding_metadata);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
for (const text of texts) appendBounded(content, text);
|
|
156
|
+
let truncated = false;
|
|
157
|
+
for (const rawMetadata of metadataValues) {
|
|
158
|
+
if (!isRecord(rawMetadata)) continue;
|
|
159
|
+
const chunks = rawMetadata.groundingChunks ?? rawMetadata.grounding_chunks;
|
|
160
|
+
if (!Array.isArray(chunks)) continue;
|
|
161
|
+
if (chunks.length > 4096) throw new WebError("Antigravity Search returned too many grounding sources", "ANTIGRAVITY_SEARCH_PROTOCOL_DRIFT");
|
|
162
|
+
for (const chunk of chunks) {
|
|
163
|
+
if (!isRecord(chunk)) continue;
|
|
164
|
+
const web = isRecord(chunk.web) ? chunk.web : isRecord(chunk.webSource) ? chunk.webSource : void 0;
|
|
165
|
+
if (web === void 0 || typeof web.uri !== "string" || !isHttpUrl(web.uri)) continue;
|
|
166
|
+
const url = web.uri;
|
|
167
|
+
if (seen.has(url)) continue;
|
|
168
|
+
if (sources.length >= maxResults) {
|
|
169
|
+
truncated = true;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
seen.add(url);
|
|
173
|
+
const title = safeSourceText(web.title, 1024);
|
|
174
|
+
const snippet = safeSourceText(web.snippet, 4096);
|
|
175
|
+
sources.push({
|
|
176
|
+
url,
|
|
177
|
+
...title === void 0 ? {} : { title },
|
|
178
|
+
...snippet === void 0 ? {} : { snippet }
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return truncated;
|
|
183
|
+
}
|
|
184
|
+
function appendBounded(output, value) {
|
|
185
|
+
if (value === void 0 || value.length === 0) return;
|
|
186
|
+
const used = output.reduce((total, item) => total + item.length, 0);
|
|
187
|
+
if (used < 65536) output.push(value.slice(0, 65536 - used));
|
|
188
|
+
}
|
|
189
|
+
function findText(value) {
|
|
190
|
+
const parts = Array.isArray(value.parts) ? value.parts : isRecord(value.content) && Array.isArray(value.content.parts) ? value.content.parts : [];
|
|
191
|
+
const output = [];
|
|
192
|
+
let length = 0;
|
|
193
|
+
for (const part of parts) {
|
|
194
|
+
if (!isRecord(part) || typeof part.text !== "string" || hasControl(part.text)) continue;
|
|
195
|
+
const text = part.text.slice(0, 65536 - length);
|
|
196
|
+
output.push(text);
|
|
197
|
+
length += text.length;
|
|
198
|
+
if (length >= 65536) break;
|
|
199
|
+
}
|
|
200
|
+
return output.length === 0 ? void 0 : output.join("");
|
|
201
|
+
}
|
|
202
|
+
function safeSourceText(value, max) {
|
|
203
|
+
return typeof value === "string" && value.length > 0 && value.length <= max && !hasControl(value) ? value : void 0;
|
|
204
|
+
}
|
|
205
|
+
function hasControl(value) {
|
|
206
|
+
for (const character of value) {
|
|
207
|
+
const code = character.charCodeAt(0);
|
|
208
|
+
if (code < 32 || code === 127) return true;
|
|
209
|
+
}
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
function parseJson(value) {
|
|
213
|
+
const normalized = value.trim().replace(/^\)\]\}'(?:\r?\n)?/u, "");
|
|
214
|
+
try {
|
|
215
|
+
return JSON.parse(normalized);
|
|
216
|
+
} catch {
|
|
217
|
+
throw new WebError("Antigravity Search returned malformed provider data", "ANTIGRAVITY_SEARCH_PROTOCOL_DRIFT");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const SEARCH_FAILURE_CODES = {
|
|
221
|
+
authentication: "ANTIGRAVITY_SEARCH_AUTH_REQUIRED",
|
|
222
|
+
forbidden: "ANTIGRAVITY_SEARCH_FORBIDDEN",
|
|
223
|
+
"rate-limited": "ANTIGRAVITY_SEARCH_RATE_LIMITED",
|
|
224
|
+
cancelled: "ANTIGRAVITY_SEARCH_CANCELLED",
|
|
225
|
+
timeout: "ANTIGRAVITY_SEARCH_TIMEOUT",
|
|
226
|
+
"attribution-rejected": "ANTIGRAVITY_SEARCH_PROTOCOL_DRIFT",
|
|
227
|
+
"protocol-drift": "ANTIGRAVITY_SEARCH_PROTOCOL_DRIFT",
|
|
228
|
+
"response-limit": "ANTIGRAVITY_SEARCH_PROTOCOL_DRIFT",
|
|
229
|
+
"request-limit": "ANTIGRAVITY_SEARCH_PROTOCOL_DRIFT",
|
|
230
|
+
upstream: "ANTIGRAVITY_SEARCH_FAILED",
|
|
231
|
+
network: "ANTIGRAVITY_SEARCH_FAILED",
|
|
232
|
+
failed: "ANTIGRAVITY_SEARCH_FAILED"
|
|
233
|
+
};
|
|
234
|
+
function toWebError(error) {
|
|
235
|
+
if (error instanceof WebError) return error;
|
|
236
|
+
if (error instanceof PrivateTransportError) return new WebError("The Antigravity Search request failed safely", SEARCH_FAILURE_CODES[classifyPrivateFailure(error)]);
|
|
237
|
+
return new WebError("The Antigravity Search request failed safely", "ANTIGRAVITY_SEARCH_FAILED");
|
|
238
|
+
}
|
|
239
|
+
function isAuthService(value) {
|
|
240
|
+
return isRecord(value) && typeof value.credential === "function" && typeof value.status === "function";
|
|
241
|
+
}
|
|
242
|
+
function isHttpUrl(value) {
|
|
243
|
+
if (value.length === 0 || value.length > 8192 || value.trim() !== value || hasControl(value)) return false;
|
|
244
|
+
try {
|
|
245
|
+
const url = new URL(value);
|
|
246
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.username.length === 0 && url.password.length === 0;
|
|
247
|
+
} catch {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function boundedInteger(value, min, max) {
|
|
252
|
+
if (!Number.isSafeInteger(value) || value < min || value > max) throw new WebError("Antigravity Search result limit is invalid", "ANTIGRAVITY_SEARCH_INVALID_QUERY");
|
|
253
|
+
return value;
|
|
254
|
+
}
|
|
255
|
+
function isRecord(value) {
|
|
256
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
export { ANTIGRAVITY_SEARCH_ENDPOINT, ANTIGRAVITY_SEARCH_MODEL, ANTIGRAVITY_SEARCH_PROVIDER_ID, ANTIGRAVITY_SEARCH_SETTINGS_NAMESPACE, AntigravitySearchProvider, Config, apply, buildGroundedSearchPayload, inject, name };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
//#region src/status.ts
|
|
2
|
+
const ANTIGRAVITY_PLUGIN_ID = "dsh-antigravity-auth";
|
|
3
|
+
const CAPABILITY_ROW_IDS = [
|
|
4
|
+
"auth-llm",
|
|
5
|
+
"search",
|
|
6
|
+
"image",
|
|
7
|
+
"video"
|
|
8
|
+
];
|
|
9
|
+
const LLM_FAMILY_IDS = [
|
|
10
|
+
"gemini",
|
|
11
|
+
"claude",
|
|
12
|
+
"gpt-oss"
|
|
13
|
+
];
|
|
14
|
+
const CAPABILITY_GATE_OUTCOMES = [
|
|
15
|
+
"passed",
|
|
16
|
+
"unauthenticated",
|
|
17
|
+
"rate-limited",
|
|
18
|
+
"cancelled",
|
|
19
|
+
"attribution-rejected",
|
|
20
|
+
"protocol-drift",
|
|
21
|
+
"unsupported-video",
|
|
22
|
+
"failed"
|
|
23
|
+
];
|
|
24
|
+
const CAPABILITY_DEFINITIONS = Object.freeze(CAPABILITY_ROW_IDS.map((id) => Object.freeze({
|
|
25
|
+
id,
|
|
26
|
+
state: "disabled",
|
|
27
|
+
reasonCode: "unauthenticated"
|
|
28
|
+
})));
|
|
29
|
+
const PROJECT_DISCOVERY_FAILURES = /* @__PURE__ */ new Set([
|
|
30
|
+
"project-unavailable",
|
|
31
|
+
"project-authentication-failed",
|
|
32
|
+
"project-forbidden",
|
|
33
|
+
"project-rate-limited",
|
|
34
|
+
"project-offline",
|
|
35
|
+
"project-malformed",
|
|
36
|
+
"project-protocol-drift"
|
|
37
|
+
]);
|
|
38
|
+
function createStatusView(riskAcknowledged, login, credential, revoke, gates = {}) {
|
|
39
|
+
return Object.freeze({
|
|
40
|
+
pluginId: ANTIGRAVITY_PLUGIN_ID,
|
|
41
|
+
phase: "bootstrap",
|
|
42
|
+
privateSelfUse: true,
|
|
43
|
+
singleAccount: true,
|
|
44
|
+
riskAcknowledgementRequired: true,
|
|
45
|
+
riskAcknowledged,
|
|
46
|
+
login: Object.freeze({ ...login }),
|
|
47
|
+
...credential === void 0 ? {} : { credential: Object.freeze({ ...credential }) },
|
|
48
|
+
...revoke === void 0 ? {} : { revoke: Object.freeze({ ...revoke }) },
|
|
49
|
+
capabilities: Object.freeze(capabilitiesFor(login, gates).map((capability) => Object.freeze({ ...capability })))
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function capabilitiesFor(login, gates) {
|
|
53
|
+
if (!login.projectAvailable && (login.configured || login.errorCode !== void 0 && PROJECT_DISCOVERY_FAILURES.has(login.errorCode))) return CAPABILITY_DEFINITIONS.map((capability) => ({
|
|
54
|
+
id: capability.id,
|
|
55
|
+
state: "disabled",
|
|
56
|
+
reasonCode: "project-unavailable"
|
|
57
|
+
}));
|
|
58
|
+
if (!login.projectAvailable) return CAPABILITY_DEFINITIONS;
|
|
59
|
+
if (gates.gate0?.outcome !== "passed") return CAPABILITY_ROW_IDS.map((id) => gate0Status(id, gates.gate0));
|
|
60
|
+
return CAPABILITY_ROW_IDS.map((id) => gateStatus(id, id === "auth-llm" ? llmFamilyResult(gates) : gates.capabilities?.[id]));
|
|
61
|
+
}
|
|
62
|
+
function llmFamilyResult(gates) {
|
|
63
|
+
const results = LLM_FAMILY_IDS.map((family) => gates.llmFamilies?.[family]);
|
|
64
|
+
const failure = results.find((result) => result !== void 0 && result.outcome !== "passed");
|
|
65
|
+
if (failure !== void 0) return failure;
|
|
66
|
+
if (results.some((result) => result?.outcome !== "passed")) return void 0;
|
|
67
|
+
return results.reduce((latest, result) => latest === void 0 || Date.parse(result.checkedAt) > Date.parse(latest.checkedAt) ? result : latest, void 0);
|
|
68
|
+
}
|
|
69
|
+
function gate0Status(id, result) {
|
|
70
|
+
if (result?.outcome === "failed" || result?.outcome === "attribution-rejected") return {
|
|
71
|
+
id,
|
|
72
|
+
state: "disabled",
|
|
73
|
+
reasonCode: "gate-0-failed"
|
|
74
|
+
};
|
|
75
|
+
return gateStatus(id, result);
|
|
76
|
+
}
|
|
77
|
+
function gateStatus(id, result) {
|
|
78
|
+
if (result === void 0) return {
|
|
79
|
+
id,
|
|
80
|
+
state: "poc-pending",
|
|
81
|
+
reasonCode: "gate-not-run"
|
|
82
|
+
};
|
|
83
|
+
if (result.outcome === "passed") return {
|
|
84
|
+
id,
|
|
85
|
+
state: "available",
|
|
86
|
+
reasonCode: "capability-ready"
|
|
87
|
+
};
|
|
88
|
+
if (result.outcome === "protocol-drift") return {
|
|
89
|
+
id,
|
|
90
|
+
state: "protocol-drift",
|
|
91
|
+
reasonCode: "protocol-drift"
|
|
92
|
+
};
|
|
93
|
+
if (result.outcome === "attribution-rejected") return {
|
|
94
|
+
id,
|
|
95
|
+
state: "disabled",
|
|
96
|
+
reasonCode: "gate-0-failed"
|
|
97
|
+
};
|
|
98
|
+
if (result.outcome === "unauthenticated") return {
|
|
99
|
+
id,
|
|
100
|
+
state: "disabled",
|
|
101
|
+
reasonCode: "unauthenticated"
|
|
102
|
+
};
|
|
103
|
+
if (result.outcome === "rate-limited") return {
|
|
104
|
+
id,
|
|
105
|
+
state: "disabled",
|
|
106
|
+
reasonCode: "rate-limited"
|
|
107
|
+
};
|
|
108
|
+
if (result.outcome === "cancelled") return {
|
|
109
|
+
id,
|
|
110
|
+
state: "disabled",
|
|
111
|
+
reasonCode: "cancelled"
|
|
112
|
+
};
|
|
113
|
+
if (result.outcome === "unsupported-video") return {
|
|
114
|
+
id,
|
|
115
|
+
state: "disabled",
|
|
116
|
+
reasonCode: "unsupported-video"
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
id,
|
|
120
|
+
state: "disabled",
|
|
121
|
+
reasonCode: "gate-failed"
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { createStatusView as a, LLM_FAMILY_IDS as i, CAPABILITY_GATE_OUTCOMES as n, CAPABILITY_ROW_IDS as r, ANTIGRAVITY_PLUGIN_ID as t };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Host-side Antigravity risk gate, OAuth coordinator, and credential commit boundary. */
|
|
2
|
+
import type { AntigravityAuthStore } from './auth-store.ts';
|
|
3
|
+
import { type CredentialCoordinatorOptions, type HostCredential } from './credential-coordinator.ts';
|
|
4
|
+
import type { OAuthFlowCompletionResult, OAuthFlowOptions } from './oauth-flow.ts';
|
|
5
|
+
import type { ProjectDiscoveryOptions } from './project-context.ts';
|
|
6
|
+
import type { AntigravityStatusView, BootstrapStatusService, RiskAcknowledgementResult, LoginActionResult, LoginStartResult, CapabilityGateEvidence, LlmFamilyId } from './status.ts';
|
|
7
|
+
import { type QuotaServiceOptions } from './quota.ts';
|
|
8
|
+
import { type CapabilityGateRegistry } from './capability-gates.ts';
|
|
9
|
+
import type { CapabilityGateOutcome, CapabilityRowId } from './status.ts';
|
|
10
|
+
export interface AntigravityAuthServiceOptions {
|
|
11
|
+
readonly store?: AntigravityAuthStore;
|
|
12
|
+
readonly storePath?: string;
|
|
13
|
+
readonly flowOptions?: Omit<OAuthFlowOptions, 'commit' | 'validateProject'>;
|
|
14
|
+
/** Inject a complete private transport only for deterministic Host tests. */
|
|
15
|
+
readonly projectOptions?: ProjectDiscoveryOptions;
|
|
16
|
+
readonly credentialOptions?: Omit<CredentialCoordinatorOptions, 'store'>;
|
|
17
|
+
readonly quotaOptions?: Omit<QuotaServiceOptions, 'auth'>;
|
|
18
|
+
readonly gates?: CapabilityGateRegistry;
|
|
19
|
+
readonly gatePath?: string;
|
|
20
|
+
readonly autoActivateGates?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export type { HostCredential } from './credential-coordinator.ts';
|
|
23
|
+
export declare class AntigravityAuthService implements BootstrapStatusService {
|
|
24
|
+
private readonly store;
|
|
25
|
+
private readonly credentials;
|
|
26
|
+
private readonly flow;
|
|
27
|
+
private readonly quota;
|
|
28
|
+
private readonly gates;
|
|
29
|
+
private readonly autoActivate;
|
|
30
|
+
private riskAcknowledged;
|
|
31
|
+
private activeFlowGeneration;
|
|
32
|
+
private disposed;
|
|
33
|
+
private readonly statusListeners;
|
|
34
|
+
constructor(options?: AntigravityAuthServiceOptions);
|
|
35
|
+
status(): Promise<AntigravityStatusView>;
|
|
36
|
+
acknowledgeRisk(): Promise<RiskAcknowledgementResult>;
|
|
37
|
+
/** Observe value-safe gate changes so capability rows can register without polling secrets. */
|
|
38
|
+
watchStatus(listener: () => void): () => void;
|
|
39
|
+
recordGate0(outcome: CapabilityGateOutcome): Promise<void>;
|
|
40
|
+
recordLlmFamilyGate(family: LlmFamilyId, outcome: CapabilityGateOutcome): Promise<void>;
|
|
41
|
+
recordCapabilityGate(id: CapabilityRowId, outcome: CapabilityGateOutcome): Promise<void>;
|
|
42
|
+
capabilityGateEvidence(): Promise<CapabilityGateEvidence>;
|
|
43
|
+
gate0Passed(): Promise<boolean>;
|
|
44
|
+
capabilityAvailable(id: CapabilityRowId): Promise<boolean>;
|
|
45
|
+
startLogin(): Promise<LoginStartResult>;
|
|
46
|
+
completeCallback(callbackUrl: string): Promise<OAuthFlowCompletionResult>;
|
|
47
|
+
cancelLogin(): Promise<LoginActionResult>;
|
|
48
|
+
credential(signal?: AbortSignal, options?: {
|
|
49
|
+
readonly forceRefresh?: boolean;
|
|
50
|
+
}): Promise<HostCredential | undefined>;
|
|
51
|
+
usage(signal?: AbortSignal, force?: boolean): Promise<import('./quota.ts').QuotaStatusView>;
|
|
52
|
+
logout(): Promise<import('./credential-coordinator.ts').LogoutResult>;
|
|
53
|
+
revoke(confirmed: boolean, signal?: AbortSignal): Promise<import('./credential-coordinator.ts').RevokeActionResult>;
|
|
54
|
+
dispose(): Promise<void>;
|
|
55
|
+
private commitCredential;
|
|
56
|
+
private notifyStatus;
|
|
57
|
+
private gateEvidenceFor;
|
|
58
|
+
private autoActivateGates;
|
|
59
|
+
private requireRecord;
|
|
60
|
+
private readRecord;
|
|
61
|
+
}
|
|
62
|
+
export declare function createAntigravityAuthService(options?: AntigravityAuthServiceOptions): AntigravityAuthService;
|
|
63
|
+
export declare function maskEmail(value: string | undefined): string | undefined;
|
|
64
|
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eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAK1D,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAWvC,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IASzE,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAUzC,UAAU,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAIpH,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,OAAO,YAAY,EAAE,eAAe,CAAC;IAIzF,MAAM,IAAI,OAAO,CAAC,OAAO,6BAA6B,EAAE,YAAY,CAAC;IAcrE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,6BAA6B,EAAE,kBAAkB,CAAC;IAQnH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAQhB,gBAAgB;IAmC9B,OAAO,CAAC,YAAY;YAMN,eAAe;YAiBf,iBAAiB;YAcjB,aAAa;YAMb,UAAU;CAOzB;AAMD,wBAAgB,4BAA4B,CAAC,OAAO,GAAE,6BAAkC,GAAG,sBAAsB,CAEhH;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQvE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Owner-only, versioned, single-account refresh-token persistence. */
|
|
2
|
+
export declare const AUTH_RECORD_VERSION: 1;
|
|
3
|
+
export interface AuthRecordDraft {
|
|
4
|
+
readonly refreshToken: string;
|
|
5
|
+
readonly projectId: string;
|
|
6
|
+
readonly email?: string;
|
|
7
|
+
/** Keep the same lineage for a refresh; a new login omits it to fence older work. */
|
|
8
|
+
readonly lineage?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AntigravityAuthRecord {
|
|
11
|
+
readonly version: typeof AUTH_RECORD_VERSION;
|
|
12
|
+
readonly refreshToken: string;
|
|
13
|
+
readonly projectId: string;
|
|
14
|
+
readonly email?: string;
|
|
15
|
+
readonly revision: number;
|
|
16
|
+
readonly updatedAt: string;
|
|
17
|
+
/** A per-login lineage fence; absent only on records written by older versions. */
|
|
18
|
+
readonly lineage?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface AuthStoreOptions {
|
|
21
|
+
readonly now?: () => number;
|
|
22
|
+
}
|
|
23
|
+
export interface AntigravityAuthStore {
|
|
24
|
+
read(): Promise<AntigravityAuthRecord | undefined>;
|
|
25
|
+
commit(draft: AuthRecordDraft): Promise<AntigravityAuthRecord>;
|
|
26
|
+
compareAndCommit(expectedRevision: number, draft: AuthRecordDraft, expectedLineage?: string): Promise<AntigravityAuthRecord | undefined>;
|
|
27
|
+
/** Clear only when the observed record is still the same account lineage. */
|
|
28
|
+
clearIfCurrent(expectedRevision: number, expectedLineage?: string): Promise<boolean>;
|
|
29
|
+
clear(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export type AuthStoreErrorCode = 'AUTH_STORE_CORRUPT' | 'AUTH_STORE_UNSUPPORTED_VERSION' | 'AUTH_STORE_UNSAFE_PERMISSIONS' | 'AUTH_STORE_CONFLICT' | 'AUTH_STORE_IO';
|
|
32
|
+
export declare class AuthStoreError extends Error {
|
|
33
|
+
readonly code: AuthStoreErrorCode;
|
|
34
|
+
constructor(code: AuthStoreErrorCode, message: string);
|
|
35
|
+
}
|
|
36
|
+
/** Resolve the plugin-owned default path without reading it. */
|
|
37
|
+
export declare function defaultAuthStorePath(env?: NodeJS.ProcessEnv, home?: string | undefined, platform?: NodeJS.Platform): string;
|
|
38
|
+
/** Create one store whose public API never exposes an access token field. */
|
|
39
|
+
export declare function createAuthStore(path: string, options?: AuthStoreOptions): AntigravityAuthStore;
|
|
40
|
+
/** An offline store useful for tests and process-local bootstrap fixtures. */
|
|
41
|
+
export declare function createMemoryAuthStore(initial?: AntigravityAuthRecord, options?: AuthStoreOptions): AntigravityAuthStore;
|
|
42
|
+
export declare function readAuthRecord(path: string): Promise<AntigravityAuthRecord | undefined>;
|
|
43
|
+
export declare function writeAuthRecord(path: string, record: AntigravityAuthRecord): Promise<void>;
|
|
44
|
+
export declare function makeAuthRecord(draft: AuthRecordDraft, revision: number, now?: number): AntigravityAuthRecord;
|
|
45
|
+
//# sourceMappingURL=auth-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../src/auth-store.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAOvE,eAAO,MAAM,mBAAmB,EAAG,CAAU,CAAA;AAO7C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,qFAAqF;IACrF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,mBAAmB,CAAA;IAC5C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,oBAAoB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AAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BhG;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,qBAAqB,CAEhH"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Offline-friendly Host service factory used by tests and embedding code. */
|
|
2
|
+
import type { AntigravityAuthService, AntigravityAuthServiceOptions } from './auth-service.ts';
|
|
3
|
+
/** Use an in-memory store unless the caller explicitly selects a persistent path/store. */
|
|
4
|
+
export declare function createBootstrapStatusService(options?: AntigravityAuthServiceOptions): AntigravityAuthService;
|
|
5
|
+
export type { AntigravityAuthService, AntigravityAuthServiceOptions };
|
|
6
|
+
//# sourceMappingURL=bootstrap-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap-service.d.ts","sourceRoot":"","sources":["../../src/bootstrap-service.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAI9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AAE9F,2FAA2F;AAC3F,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,6BAAkC,GAC1C,sBAAsB,CAMxB;AAED,YAAY,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Value-free live-gate evidence used to keep capability registration honest. */
|
|
2
|
+
import { type CapabilityGateEvidence, type CapabilityGateOutcome, type CapabilityRowId, type LlmFamilyId } from './status.ts';
|
|
3
|
+
type PersistedCapabilityId = Exclude<CapabilityRowId, 'auth-llm'>;
|
|
4
|
+
export interface CapabilityGateRegistry {
|
|
5
|
+
read(): Promise<CapabilityGateEvidence>;
|
|
6
|
+
recordGate0(subject: string, outcome: CapabilityGateOutcome): Promise<CapabilityGateEvidence>;
|
|
7
|
+
recordLlmFamily(subject: string, family: LlmFamilyId, outcome: CapabilityGateOutcome): Promise<CapabilityGateEvidence>;
|
|
8
|
+
recordCapability(subject: string, id: PersistedCapabilityId, outcome: CapabilityGateOutcome): Promise<CapabilityGateEvidence>;
|
|
9
|
+
clear(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export interface FileCapabilityGateOptions {
|
|
12
|
+
readonly now?: () => number;
|
|
13
|
+
}
|
|
14
|
+
/** Resolve a gate record next to the plugin-owned auth record without reading either. */
|
|
15
|
+
export declare function defaultCapabilityGatePath(authStorePath: string): string;
|
|
16
|
+
export declare function createMemoryCapabilityGates(initial?: CapabilityGateEvidence, now?: () => number): CapabilityGateRegistry;
|
|
17
|
+
export declare function createFileCapabilityGates(path: string, options?: FileCapabilityGateOptions): CapabilityGateRegistry;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=capability-gates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-gates.d.ts","sourceRoot":"","sources":["../../src/capability-gates.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAIjF,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAE1B,KAAK,eAAe,EACpB,KAAK,WAAW,EACjB,MAAM,aAAa,CAAA;AAMpB,KAAK,qBAAqB,GAAG,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;AAEjE,MAAM,WAAW,sBAAsB;IACrC,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAA;IACvC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAC7F,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;IACtH,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAC7H,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAC5B;AAED,yFAAyF;AACzF,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,sBAA2B,EACpC,GAAG,GAAE,MAAM,MAAyB,GACnC,sBAAsB,CAoBxB;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,yBAA8B,GACtC,sBAAsB,CAgDxB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Shared race-safe registration lifecycle for one independently gated capability row. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { AntigravityStatusView, CapabilityRowId } from './status.ts';
|
|
4
|
+
export interface CapabilityStatusSource {
|
|
5
|
+
status(): Promise<AntigravityStatusView>;
|
|
6
|
+
watchStatus?(listener: () => void): () => void;
|
|
7
|
+
dispose?(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface CapabilityLifecycleOptions {
|
|
10
|
+
readonly ctx: Context;
|
|
11
|
+
readonly auth: CapabilityStatusSource;
|
|
12
|
+
readonly id: CapabilityRowId;
|
|
13
|
+
readonly enabled: () => boolean;
|
|
14
|
+
readonly register: () => (() => void) | undefined;
|
|
15
|
+
readonly ownsAuth?: boolean;
|
|
16
|
+
readonly cleanup?: () => void | Promise<void>;
|
|
17
|
+
readonly label: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CapabilityLifecycle {
|
|
20
|
+
sync(): void;
|
|
21
|
+
refresh(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/** Register a capability set atomically and dispose every owned member best-effort. */
|
|
24
|
+
export declare function registerCapabilitySet<T>(values: readonly T[], register: (value: T) => () => void): () => void;
|
|
25
|
+
export declare function mountCapabilityLifecycle(options: CapabilityLifecycleOptions): CapabilityLifecycle;
|
|
26
|
+
//# sourceMappingURL=capability-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-lifecycle.d.ts","sourceRoot":"","sources":["../../src/capability-lifecycle.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAE1F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEzE,MAAM,WAAW,sBAAsB;IACrC,MAAM,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACxC,WAAW,CAAC,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;IAC9C,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,QAAQ,CAAC,EAAE,EAAE,eAAe,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAA;IACjD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,IAAI,IAAI,CAAA;IACZ,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AAED,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,IAAI,GACjC,MAAM,IAAI,CAcZ;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,0BAA0B,GAAG,mBAAmB,CAiDjG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Settings shell for value-safe Antigravity login status. */
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { SettingsScope } from '@deepseek-ai/dsh-client-runtime/client';
|
|
4
|
+
import type { AntigravityAuthRpcClient } from '../rpc-contract.ts';
|
|
5
|
+
import type { AntigravitySearchSettings } from '../search.ts';
|
|
6
|
+
import type { AntigravityImageSettings } from '../image.ts';
|
|
7
|
+
import type { AntigravityVideoSettings } from '../video.ts';
|
|
8
|
+
import type { AntigravityAuthKey } from './locales.ts';
|
|
9
|
+
export interface AntigravityAuthSettingsProps {
|
|
10
|
+
rpc: AntigravityAuthRpcClient;
|
|
11
|
+
t: (key: AntigravityAuthKey) => string;
|
|
12
|
+
subscribe: (listener: () => void) => () => void;
|
|
13
|
+
searchScope?: SettingsScope<AntigravitySearchSettings>;
|
|
14
|
+
imageScope?: SettingsScope<AntigravityImageSettings>;
|
|
15
|
+
videoScope?: SettingsScope<AntigravityVideoSettings>;
|
|
16
|
+
}
|
|
17
|
+
/** One navigable settings section; credentials remain Host-only and actions use typed RPC. */
|
|
18
|
+
export declare function AntigravityAuthSettings({ rpc, t, subscribe, searchScope, imageScope, videoScope }: AntigravityAuthSettingsProps): ReactNode;
|
|
19
|
+
//# sourceMappingURL=AntigravityAuthSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AntigravityAuthSettings.d.ts","sourceRoot":"","sources":["../../../src/client/AntigravityAuthSettings.tsx"],"names":[],"mappings":"AAAA,8DAA8D;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAElE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAO3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAGtD,MAAM,WAAW,4BAA4B;IAC3C,GAAG,EAAE,wBAAwB,CAAA;IAC7B,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,MAAM,CAAA;IACtC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAA;IAC/C,WAAW,CAAC,EAAE,aAAa,CAAC,yBAAyB,CAAC,CAAA;IACtD,UAAU,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAA;IACpD,UAAU,CAAC,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAA;CACrD;AAuBD,8FAA8F;AAC9F,wBAAgB,uBAAuB,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,4BAA4B,GAAG,SAAS,CA2T3I"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Browser half of the private Antigravity bootstrap capability bundle. */
|
|
2
|
+
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
|
|
3
|
+
import { type AntigravityAuthKey } from './locales.ts';
|
|
4
|
+
export { AntigravityAuthSettings } from './AntigravityAuthSettings.tsx';
|
|
5
|
+
export type { AntigravityAuthSettingsProps } from './AntigravityAuthSettings.tsx';
|
|
6
|
+
export { en, zh } from './locales.ts';
|
|
7
|
+
export type { AntigravityAuthKey } from './locales.ts';
|
|
8
|
+
/** Client services required by the settings section and its loopback RPC. */
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
11
|
+
interface LocaleNamespaceMap {
|
|
12
|
+
/** Copy for the Antigravity bootstrap settings section. */
|
|
13
|
+
'settings.antigravityAuth': AntigravityAuthKey;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Register one disposable settings section and no capability controls. */
|
|
17
|
+
export declare function apply(ctx: ClientContext): void;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,wCAAwC,CAAA;AAO1F,OAAO,EAAU,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAQ9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AACvE,YAAY,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AACjF,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AACrC,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEtD,6EAA6E;AAC7E,eAAO,MAAM,MAAM,UAAqD,CAAA;AAExE,OAAO,QAAQ,kCAAkC,CAAC;IAChD,UAAU,kBAAkB;QAC1B,2DAA2D;QAC3D,0BAA0B,EAAE,kBAAkB,CAAA;KAC/C;CACF;AAED,2EAA2E;AAC3E,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA2B9C"}
|