@centerforagenticai/pi-multi-account 0.1.1
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/LICENSE +21 -0
- package/NOTICE +29 -0
- package/README.md +999 -0
- package/config/models/pi-multi-account.v1.json +32 -0
- package/config/subscription-plans.v1.json +122 -0
- package/package.json +76 -0
- package/packages/pi-anthropic-oauth/LICENSE +21 -0
- package/packages/pi-anthropic-oauth/package.json +54 -0
- package/packages/pi-anthropic-oauth/src/auth.ts +396 -0
- package/packages/pi-anthropic-oauth/src/context.ts +116 -0
- package/packages/pi-anthropic-oauth/src/convert.ts +303 -0
- package/packages/pi-anthropic-oauth/src/index.ts +37 -0
- package/packages/pi-anthropic-oauth/src/prompt.ts +137 -0
- package/packages/pi-anthropic-oauth/src/stream.ts +476 -0
- package/packages/pi-antigravity/LICENSE +21 -0
- package/packages/pi-antigravity/package.json +77 -0
- package/packages/pi-antigravity/src/auth/index.ts +14 -0
- package/packages/pi-antigravity/src/auth/oauth.ts +442 -0
- package/packages/pi-antigravity/src/client/client.ts +561 -0
- package/packages/pi-antigravity/src/client/index.ts +1 -0
- package/packages/pi-antigravity/src/context.ts +110 -0
- package/packages/pi-antigravity/src/diagnostics/diagnostics.ts +96 -0
- package/packages/pi-antigravity/src/diagnostics/index.ts +1 -0
- package/packages/pi-antigravity/src/image/image.ts +336 -0
- package/packages/pi-antigravity/src/image/index.ts +1 -0
- package/packages/pi-antigravity/src/index.ts +280 -0
- package/packages/pi-antigravity/src/models/discovery.ts +154 -0
- package/packages/pi-antigravity/src/models/grouping.ts +424 -0
- package/packages/pi-antigravity/src/models/index.ts +3 -0
- package/packages/pi-antigravity/src/models/models.ts +500 -0
- package/packages/pi-antigravity/src/stream/index.ts +1 -0
- package/packages/pi-antigravity/src/stream/stream.ts +1478 -0
- package/packages/pi-antigravity/src/types/enums.ts +42 -0
- package/packages/pi-antigravity/src/types/index.ts +2 -0
- package/packages/pi-antigravity/src/types/types.ts +292 -0
- package/packages/pi-antigravity/src/usage/index.ts +1 -0
- package/packages/pi-antigravity/src/usage/usage.ts +416 -0
- package/packages/pi-antigravity/src/utils/http.ts +91 -0
- package/packages/pi-antigravity/src/utils/index.ts +3 -0
- package/packages/pi-antigravity/src/utils/security.ts +73 -0
- package/packages/pi-antigravity/src/utils/util.ts +132 -0
- package/scripts/multi-account.mjs +44 -0
- package/src/account-labels.ts +223 -0
- package/src/account-plan-assignment.ts +340 -0
- package/src/account-rate-history.ts +372 -0
- package/src/anthropic-adaptive-stream.ts +531 -0
- package/src/anthropic-alias-stream.ts +140 -0
- package/src/anthropic-context-compat.ts +80 -0
- package/src/api-pricing.ts +579 -0
- package/src/bounded-file-lines.ts +97 -0
- package/src/catalog-rebinding.ts +177 -0
- package/src/catalog-registration-probe.ts +111 -0
- package/src/codex-adapter.ts +345 -0
- package/src/codex-model-defaults.ts +785 -0
- package/src/command-completions.ts +404 -0
- package/src/commands.ts +2000 -0
- package/src/compaction.ts +14 -0
- package/src/config.ts +1317 -0
- package/src/continuation.ts +569 -0
- package/src/cooldowns.ts +110 -0
- package/src/cost-digest-store.ts +332 -0
- package/src/cost-digest.ts +1044 -0
- package/src/cost-history.ts +251 -0
- package/src/cost-period-closer.ts +160 -0
- package/src/cost-report-json.ts +318 -0
- package/src/cost-report-reader.ts +368 -0
- package/src/cost-report-render.ts +207 -0
- package/src/cost-report.ts +1104 -0
- package/src/coverage-attestation.ts +397 -0
- package/src/credential-lifecycle.ts +169 -0
- package/src/credential-refresh.ts +248 -0
- package/src/declaration-notice-marker.ts +238 -0
- package/src/diagnostic-store.ts +276 -0
- package/src/diagnostics.ts +309 -0
- package/src/discovery.ts +471 -0
- package/src/duration.ts +13 -0
- package/src/error-classification.ts +256 -0
- package/src/fuzzy.ts +15 -0
- package/src/group-policy.ts +81 -0
- package/src/history-store.ts +897 -0
- package/src/index.ts +5572 -0
- package/src/lifecycle.ts +378 -0
- package/src/logical-dispatch.ts +279 -0
- package/src/logical-model-selector.ts +254 -0
- package/src/logical-model-switcher.ts +430 -0
- package/src/logical-provider-attribution.ts +544 -0
- package/src/logical-provider.ts +1237 -0
- package/src/logical-route-indicator.ts +215 -0
- package/src/machine-lease.ts +445 -0
- package/src/model-support.ts +66 -0
- package/src/models-declaration.ts +1091 -0
- package/src/openai-adapter.ts +117 -0
- package/src/openrouter-budget.ts +304 -0
- package/src/openrouter-fallback.ts +146 -0
- package/src/period-boundaries.ts +376 -0
- package/src/pi-anthropic-oauth.d.ts +6 -0
- package/src/preflight.ts +253 -0
- package/src/pricing-cache.ts +235 -0
- package/src/project-identity.ts +100 -0
- package/src/provider-registration.ts +942 -0
- package/src/rate-formula.ts +163 -0
- package/src/recovery-engine.ts +853 -0
- package/src/recovery-output.ts +837 -0
- package/src/recovery-plan.ts +239 -0
- package/src/report-range.ts +203 -0
- package/src/route-resolver.ts +789 -0
- package/src/routing-config-transaction.ts +232 -0
- package/src/routing.ts +1163 -0
- package/src/runtime-state.ts +630 -0
- package/src/session-account-groups.ts +284 -0
- package/src/session-restore.ts +287 -0
- package/src/shared-usage.ts +1392 -0
- package/src/standalone-cli.ts +720 -0
- package/src/status-view.ts +578 -0
- package/src/subscription-plan-catalog.ts +346 -0
- package/src/tier-model-resolver.ts +46 -0
- package/src/upstream-anthropic.ts +315 -0
- package/src/upstream-antigravity.ts +327 -0
- package/src/usage-fetch.ts +1634 -0
- package/src/usage.ts +1026 -0
- package/src/vendor.ts +87 -0
- package/src/warmer.ts +231 -0
- package/src/watchdog.ts +219 -0
- package/src/window-history.ts +270 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export enum ThinkingEffort {
|
|
2
|
+
Off = "off",
|
|
3
|
+
Minimal = "minimal",
|
|
4
|
+
Low = "low",
|
|
5
|
+
Medium = "medium",
|
|
6
|
+
High = "high",
|
|
7
|
+
Xhigh = "xhigh",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export enum ToolChoice {
|
|
11
|
+
Auto = "auto",
|
|
12
|
+
None = "none",
|
|
13
|
+
Any = "any",
|
|
14
|
+
Required = "required",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export enum GeminiToolCallingMode {
|
|
18
|
+
None = "NONE",
|
|
19
|
+
Any = "ANY",
|
|
20
|
+
Auto = "AUTO",
|
|
21
|
+
Validated = "VALIDATED",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export enum GeminiRole {
|
|
25
|
+
User = "user",
|
|
26
|
+
Model = "model",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export enum AntigravityRequestType {
|
|
30
|
+
Agent = "agent",
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export enum AntigravityUserAgent {
|
|
34
|
+
Antigravity = "antigravity",
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export enum StopReason {
|
|
38
|
+
Stop = "stop",
|
|
39
|
+
Length = "length",
|
|
40
|
+
ToolUse = "toolUse",
|
|
41
|
+
Error = "error",
|
|
42
|
+
}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import type { Server } from "node:http";
|
|
2
|
+
import type {
|
|
3
|
+
OAuthCredentials,
|
|
4
|
+
SimpleStreamOptions,
|
|
5
|
+
TextContent,
|
|
6
|
+
ThinkingContent,
|
|
7
|
+
ToolCall,
|
|
8
|
+
} from "@earendil-works/pi-ai";
|
|
9
|
+
import type {
|
|
10
|
+
AntigravityRequestType,
|
|
11
|
+
AntigravityUserAgent,
|
|
12
|
+
GeminiRole,
|
|
13
|
+
GeminiToolCallingMode,
|
|
14
|
+
ThinkingEffort,
|
|
15
|
+
ToolChoice,
|
|
16
|
+
} from "./enums.js";
|
|
17
|
+
|
|
18
|
+
// OAuth & Auth Types
|
|
19
|
+
export type AntigravityOAuthCredentials = OAuthCredentials & {
|
|
20
|
+
projectId?: string;
|
|
21
|
+
email?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type AntigravityApiKey = {
|
|
25
|
+
token: string;
|
|
26
|
+
projectId: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type DynamicModelInfo = {
|
|
30
|
+
id: string;
|
|
31
|
+
experiments?: string[];
|
|
32
|
+
apiProvider?: string;
|
|
33
|
+
modelProvider?: string;
|
|
34
|
+
model?: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type CallbackServer = {
|
|
38
|
+
server: Server;
|
|
39
|
+
waitForCode: () => Promise<{ code: string; state: string }>;
|
|
40
|
+
cleanup: () => void;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Model Types
|
|
44
|
+
export type AntigravityRouting = {
|
|
45
|
+
off?: string;
|
|
46
|
+
routing?: Partial<Record<ThinkingEffort, string>>;
|
|
47
|
+
defaultRequestId?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Stream & API Types
|
|
51
|
+
export const ANTIGRAVITY_API = "antigravity-api" as const;
|
|
52
|
+
export type AntigravityApi = typeof ANTIGRAVITY_API;
|
|
53
|
+
|
|
54
|
+
export type AntigravityStreamOptions = Omit<SimpleStreamOptions, "toolChoice"> & {
|
|
55
|
+
toolChoice?: ToolChoice | `${ToolChoice}`;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type GeminiTextPart = { text: string; thoughtSignature?: string };
|
|
59
|
+
export type GeminiInlineDataPart = { inlineData: { mimeType: string; data: string } };
|
|
60
|
+
export type GeminiThoughtPart = {
|
|
61
|
+
thought: true;
|
|
62
|
+
text: string;
|
|
63
|
+
thoughtSignature?: string;
|
|
64
|
+
};
|
|
65
|
+
export type GeminiFunctionCallPart = {
|
|
66
|
+
functionCall: {
|
|
67
|
+
name: string;
|
|
68
|
+
args: Record<string, unknown>;
|
|
69
|
+
id?: string;
|
|
70
|
+
};
|
|
71
|
+
thoughtSignature?: string;
|
|
72
|
+
};
|
|
73
|
+
export type GeminiFunctionResponsePart = {
|
|
74
|
+
functionResponse: {
|
|
75
|
+
name: string;
|
|
76
|
+
response: { error: string } | { output: string };
|
|
77
|
+
id?: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export type GeminiPart =
|
|
81
|
+
| GeminiTextPart
|
|
82
|
+
| GeminiInlineDataPart
|
|
83
|
+
| GeminiThoughtPart
|
|
84
|
+
| GeminiFunctionCallPart
|
|
85
|
+
| GeminiFunctionResponsePart;
|
|
86
|
+
|
|
87
|
+
export type GeminiContent = {
|
|
88
|
+
role: GeminiRole;
|
|
89
|
+
parts: GeminiPart[];
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type GeminiFunctionDeclaration = {
|
|
93
|
+
name: string;
|
|
94
|
+
description: string;
|
|
95
|
+
parameters?: unknown;
|
|
96
|
+
parametersJsonSchema?: unknown;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type GeminiToolConfig = {
|
|
100
|
+
functionCallingConfig: {
|
|
101
|
+
mode: GeminiToolCallingMode;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export type ThinkingWire = {
|
|
106
|
+
includeThoughts: boolean;
|
|
107
|
+
thinkingBudget: number;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type GeminiGenerationConfig = {
|
|
111
|
+
temperature?: number;
|
|
112
|
+
maxOutputTokens?: number;
|
|
113
|
+
thinkingConfig?: ThinkingWire;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type GeminiRequestBody = {
|
|
117
|
+
contents: GeminiContent[];
|
|
118
|
+
systemInstruction: {
|
|
119
|
+
role: GeminiRole.User;
|
|
120
|
+
parts: GeminiTextPart[];
|
|
121
|
+
};
|
|
122
|
+
generationConfig?: GeminiGenerationConfig;
|
|
123
|
+
tools?: { functionDeclarations: GeminiFunctionDeclaration[] }[];
|
|
124
|
+
toolConfig?: GeminiToolConfig;
|
|
125
|
+
sessionId?: string;
|
|
126
|
+
labels?: Record<string, string>;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type AntigravityGenerateRequest = {
|
|
130
|
+
project: string;
|
|
131
|
+
model: string;
|
|
132
|
+
request: GeminiRequestBody;
|
|
133
|
+
requestType: AntigravityRequestType.Agent;
|
|
134
|
+
userAgent: AntigravityUserAgent.Antigravity;
|
|
135
|
+
requestId: string;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type StreamPart = {
|
|
139
|
+
text?: string;
|
|
140
|
+
thought?: boolean;
|
|
141
|
+
thoughtSignature?: string;
|
|
142
|
+
functionCall?: {
|
|
143
|
+
id?: string;
|
|
144
|
+
name?: string;
|
|
145
|
+
args?: Record<string, unknown>;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export type StreamUsageMetadata = {
|
|
150
|
+
promptTokenCount?: number;
|
|
151
|
+
cachedContentTokenCount?: number;
|
|
152
|
+
candidatesTokenCount?: number;
|
|
153
|
+
thoughtsTokenCount?: number;
|
|
154
|
+
totalTokenCount?: number;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type StreamCandidate = {
|
|
158
|
+
content?: { parts?: StreamPart[] };
|
|
159
|
+
finishReason?: string;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export type StreamResponseData = {
|
|
163
|
+
candidates?: StreamCandidate[];
|
|
164
|
+
usageMetadata?: StreamUsageMetadata;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export type StreamChunk = StreamResponseData & {
|
|
168
|
+
error?: { message?: string };
|
|
169
|
+
response?: StreamResponseData;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export type LooseImageBlock = {
|
|
173
|
+
type: "image";
|
|
174
|
+
data?: string;
|
|
175
|
+
mimeType?: string;
|
|
176
|
+
mediaType?: string;
|
|
177
|
+
source?: { data?: string; mediaType?: string };
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export type ContentBlock = TextContent | ThinkingContent | ToolCall | LooseImageBlock;
|
|
181
|
+
|
|
182
|
+
export type ActiveTextBlock = TextContent;
|
|
183
|
+
export type ActiveThinkingBlock = ThinkingContent;
|
|
184
|
+
export type ActiveBlock = ActiveTextBlock | ActiveThinkingBlock;
|
|
185
|
+
|
|
186
|
+
// Usage & Quota Types
|
|
187
|
+
export type QuotaBucket = {
|
|
188
|
+
bucketId: string;
|
|
189
|
+
displayName: string;
|
|
190
|
+
window?: string;
|
|
191
|
+
resetTime?: string;
|
|
192
|
+
description?: string;
|
|
193
|
+
remainingFraction: number;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export type QuotaGroup = {
|
|
197
|
+
displayName: string;
|
|
198
|
+
description?: string;
|
|
199
|
+
buckets: QuotaBucket[];
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export type ModelQuotaRow = {
|
|
203
|
+
modelId: string;
|
|
204
|
+
displayName?: string;
|
|
205
|
+
remainingFraction?: number;
|
|
206
|
+
resetTime?: string;
|
|
207
|
+
modelProvider?: string;
|
|
208
|
+
supportsThinking?: boolean;
|
|
209
|
+
supportsImages?: boolean;
|
|
210
|
+
recommended?: boolean;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export type TierInfo = {
|
|
214
|
+
id?: string;
|
|
215
|
+
name?: string;
|
|
216
|
+
description?: string;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export type AccountUsage = {
|
|
220
|
+
projectId: string;
|
|
221
|
+
endpoint: string;
|
|
222
|
+
email?: string;
|
|
223
|
+
productTier?: TierInfo;
|
|
224
|
+
paidTier?: TierInfo;
|
|
225
|
+
planLabel?: string;
|
|
226
|
+
groups: QuotaGroup[];
|
|
227
|
+
groupDescription?: string;
|
|
228
|
+
/** Set when the (subscription-gated) quota-summary RPC was unavailable, e.g. free-tier SUBSCRIPTION_REQUIRED. */
|
|
229
|
+
quotaSummaryError?: string;
|
|
230
|
+
models: ModelQuotaRow[];
|
|
231
|
+
defaultAgentModelId?: string;
|
|
232
|
+
fetchedAt: number;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export type ApiErrorBody = {
|
|
236
|
+
error?: { message?: string };
|
|
237
|
+
raw?: string;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export type QuotaBucketRaw = {
|
|
241
|
+
bucketId?: unknown;
|
|
242
|
+
displayName?: unknown;
|
|
243
|
+
window?: unknown;
|
|
244
|
+
resetTime?: unknown;
|
|
245
|
+
description?: unknown;
|
|
246
|
+
remainingFraction?: unknown;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export type QuotaGroupRaw = {
|
|
250
|
+
displayName?: unknown;
|
|
251
|
+
description?: unknown;
|
|
252
|
+
buckets?: QuotaBucketRaw[];
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export type QuotaSummaryRaw = {
|
|
256
|
+
description?: unknown;
|
|
257
|
+
groups?: QuotaGroupRaw[];
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export type ModelInfoRaw = {
|
|
261
|
+
isInternal?: unknown;
|
|
262
|
+
displayName?: unknown;
|
|
263
|
+
label?: unknown;
|
|
264
|
+
modelName?: unknown;
|
|
265
|
+
model?: unknown;
|
|
266
|
+
modelProvider?: unknown;
|
|
267
|
+
apiProvider?: unknown;
|
|
268
|
+
supportsThinking?: unknown;
|
|
269
|
+
supportsImages?: unknown;
|
|
270
|
+
recommended?: unknown;
|
|
271
|
+
quotaInfo?: {
|
|
272
|
+
remainingFraction?: unknown;
|
|
273
|
+
resetTime?: unknown;
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export type AvailableModelsRaw = {
|
|
278
|
+
models?: Record<string, ModelInfoRaw>;
|
|
279
|
+
defaultAgentModelId?: unknown;
|
|
280
|
+
defaultAgentModel?: unknown;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export type TierRaw = {
|
|
284
|
+
id?: unknown;
|
|
285
|
+
name?: unknown;
|
|
286
|
+
description?: unknown;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export type LoadCodeAssistRaw = {
|
|
290
|
+
currentTier?: TierRaw;
|
|
291
|
+
paidTier?: TierRaw;
|
|
292
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./usage.js";
|