@opengeni/contracts 1.1.0 → 1.2.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/atlassian.js +2 -1
- package/dist/{chunk-VSM752ZW.js → chunk-L73LKLKP.js} +25 -4
- package/dist/chunk-L73LKLKP.js.map +1 -0
- package/dist/{chunk-6GXQBK6J.js → chunk-QZPIUG3I.js} +2 -2
- package/dist/chunk-XSBEB2HQ.js +146 -0
- package/dist/chunk-XSBEB2HQ.js.map +1 -0
- package/dist/connect.js +2 -1
- package/dist/connect.js.map +1 -1
- package/dist/connection-authority.js +3 -2
- package/dist/google-drive.js +2 -1
- package/dist/google-drive.js.map +1 -1
- package/dist/host-mcp-bindings.js +3 -2
- package/dist/host-mcp-bindings.js.map +1 -1
- package/dist/index.d.ts +48 -0
- package/dist/index.js +6 -1
- package/dist/model-display.d.ts +3 -0
- package/dist/model-display.js +9 -126
- package/dist/model-display.js.map +1 -1
- package/dist/personal-github.js +2 -1
- package/dist/personal-github.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +24 -0
- package/src/model-display.ts +13 -0
- package/dist/chunk-VSM752ZW.js.map +0 -1
- /package/dist/{chunk-6GXQBK6J.js.map → chunk-QZPIUG3I.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -6496,11 +6496,30 @@ export type GitHubAppApiPort = {
|
|
|
6496
6496
|
limit: number;
|
|
6497
6497
|
}) => Promise<GitHubAppRepositoryBranchPage>;
|
|
6498
6498
|
};
|
|
6499
|
+
export declare const PromotionalCreditScope: z.ZodObject<{
|
|
6500
|
+
label: z.ZodString;
|
|
6501
|
+
eligibleModelIds: z.ZodArray<z.ZodString>;
|
|
6502
|
+
}, z.core.$strip>;
|
|
6503
|
+
export type PromotionalCreditScope = z.infer<typeof PromotionalCreditScope>;
|
|
6504
|
+
export declare const PromotionalCreditBalance: z.ZodObject<{
|
|
6505
|
+
label: z.ZodString;
|
|
6506
|
+
eligibleModelIds: z.ZodArray<z.ZodString>;
|
|
6507
|
+
grantId: z.ZodString;
|
|
6508
|
+
remainingMicros: z.ZodNumber;
|
|
6509
|
+
}, z.core.$strip>;
|
|
6510
|
+
export type PromotionalCreditBalance = z.infer<typeof PromotionalCreditBalance>;
|
|
6499
6511
|
export declare const BillingBalance: z.ZodObject<{
|
|
6500
6512
|
accountId: z.ZodString;
|
|
6501
6513
|
balanceMicros: z.ZodNumber;
|
|
6502
6514
|
currency: z.ZodLiteral<"usd">;
|
|
6503
6515
|
updatedAt: z.ZodString;
|
|
6516
|
+
generalBalanceMicros: z.ZodOptional<z.ZodNumber>;
|
|
6517
|
+
promotionalCredits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
6518
|
+
label: z.ZodString;
|
|
6519
|
+
eligibleModelIds: z.ZodArray<z.ZodString>;
|
|
6520
|
+
grantId: z.ZodString;
|
|
6521
|
+
remainingMicros: z.ZodNumber;
|
|
6522
|
+
}, z.core.$strip>>>;
|
|
6504
6523
|
}, z.core.$strip>;
|
|
6505
6524
|
export type BillingBalance = z.infer<typeof BillingBalance>;
|
|
6506
6525
|
export declare const CreateCheckoutRequest: z.ZodObject<{
|
|
@@ -6515,6 +6534,10 @@ export declare const CreateCheckoutResponse: z.ZodObject<{
|
|
|
6515
6534
|
checkoutSessionId: z.ZodString;
|
|
6516
6535
|
url: z.ZodString;
|
|
6517
6536
|
amountUsd: z.ZodOptional<z.ZodNumber>;
|
|
6537
|
+
promotionalScope: z.ZodOptional<z.ZodObject<{
|
|
6538
|
+
label: z.ZodString;
|
|
6539
|
+
eligibleModelIds: z.ZodArray<z.ZodString>;
|
|
6540
|
+
}, z.core.$strip>>;
|
|
6518
6541
|
}, z.core.$strip>;
|
|
6519
6542
|
export type CreateCheckoutResponse = z.infer<typeof CreateCheckoutResponse>;
|
|
6520
6543
|
/**
|
|
@@ -6537,12 +6560,23 @@ export declare const BillingCheckoutStatus: z.ZodObject<{
|
|
|
6537
6560
|
amountMicros: z.ZodNumber;
|
|
6538
6561
|
currency: z.ZodLiteral<"usd">;
|
|
6539
6562
|
free: z.ZodBoolean;
|
|
6563
|
+
promotionalScope: z.ZodOptional<z.ZodObject<{
|
|
6564
|
+
label: z.ZodString;
|
|
6565
|
+
eligibleModelIds: z.ZodArray<z.ZodString>;
|
|
6566
|
+
}, z.core.$strip>>;
|
|
6540
6567
|
}, z.core.$strip>;
|
|
6541
6568
|
balance: z.ZodNullable<z.ZodObject<{
|
|
6542
6569
|
accountId: z.ZodString;
|
|
6543
6570
|
balanceMicros: z.ZodNumber;
|
|
6544
6571
|
currency: z.ZodLiteral<"usd">;
|
|
6545
6572
|
updatedAt: z.ZodString;
|
|
6573
|
+
generalBalanceMicros: z.ZodOptional<z.ZodNumber>;
|
|
6574
|
+
promotionalCredits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
6575
|
+
label: z.ZodString;
|
|
6576
|
+
eligibleModelIds: z.ZodArray<z.ZodString>;
|
|
6577
|
+
grantId: z.ZodString;
|
|
6578
|
+
remainingMicros: z.ZodNumber;
|
|
6579
|
+
}, z.core.$strip>>>;
|
|
6546
6580
|
}, z.core.$strip>>;
|
|
6547
6581
|
}, z.core.$strip>;
|
|
6548
6582
|
export type BillingCheckoutStatus = z.infer<typeof BillingCheckoutStatus>;
|
|
@@ -40748,6 +40782,7 @@ export declare const ClientModel: z.ZodObject<{
|
|
|
40748
40782
|
id: z.ZodString;
|
|
40749
40783
|
label: z.ZodString;
|
|
40750
40784
|
shortLabel: z.ZodOptional<z.ZodString>;
|
|
40785
|
+
logoUrl: z.ZodOptional<z.ZodString>;
|
|
40751
40786
|
provider: z.ZodString;
|
|
40752
40787
|
providerLabel: z.ZodString;
|
|
40753
40788
|
api: z.ZodEnum<{
|
|
@@ -41039,6 +41074,7 @@ export declare const WorkspaceModelCatalogModel: z.ZodObject<{
|
|
|
41039
41074
|
id: z.ZodString;
|
|
41040
41075
|
label: z.ZodString;
|
|
41041
41076
|
shortLabel: z.ZodOptional<z.ZodString>;
|
|
41077
|
+
logoUrl: z.ZodOptional<z.ZodString>;
|
|
41042
41078
|
provider: z.ZodString;
|
|
41043
41079
|
providerLabel: z.ZodString;
|
|
41044
41080
|
api: z.ZodEnum<{
|
|
@@ -41284,6 +41320,11 @@ export declare const WorkspaceModelCatalogModel: z.ZodObject<{
|
|
|
41284
41320
|
}>;
|
|
41285
41321
|
checkedAt: z.ZodNullable<z.ZodString>;
|
|
41286
41322
|
}, z.core.$strict>;
|
|
41323
|
+
creditFunding: z.ZodOptional<z.ZodEnum<{
|
|
41324
|
+
general: "general";
|
|
41325
|
+
promotional: "promotional";
|
|
41326
|
+
unavailable: "unavailable";
|
|
41327
|
+
}>>;
|
|
41287
41328
|
policyAllowed: z.ZodOptional<z.ZodBoolean>;
|
|
41288
41329
|
availability: z.ZodObject<{
|
|
41289
41330
|
status: z.ZodEnum<{
|
|
@@ -41343,6 +41384,7 @@ export declare const WorkspaceModelCatalogResponse: z.ZodObject<{
|
|
|
41343
41384
|
id: z.ZodString;
|
|
41344
41385
|
label: z.ZodString;
|
|
41345
41386
|
shortLabel: z.ZodOptional<z.ZodString>;
|
|
41387
|
+
logoUrl: z.ZodOptional<z.ZodString>;
|
|
41346
41388
|
provider: z.ZodString;
|
|
41347
41389
|
providerLabel: z.ZodString;
|
|
41348
41390
|
api: z.ZodEnum<{
|
|
@@ -41588,6 +41630,11 @@ export declare const WorkspaceModelCatalogResponse: z.ZodObject<{
|
|
|
41588
41630
|
}>;
|
|
41589
41631
|
checkedAt: z.ZodNullable<z.ZodString>;
|
|
41590
41632
|
}, z.core.$strict>;
|
|
41633
|
+
creditFunding: z.ZodOptional<z.ZodEnum<{
|
|
41634
|
+
general: "general";
|
|
41635
|
+
promotional: "promotional";
|
|
41636
|
+
unavailable: "unavailable";
|
|
41637
|
+
}>>;
|
|
41591
41638
|
policyAllowed: z.ZodOptional<z.ZodBoolean>;
|
|
41592
41639
|
availability: z.ZodObject<{
|
|
41593
41640
|
status: z.ZodEnum<{
|
|
@@ -41672,6 +41719,7 @@ export declare const ClientConfig: z.ZodObject<{
|
|
|
41672
41719
|
id: z.ZodString;
|
|
41673
41720
|
label: z.ZodString;
|
|
41674
41721
|
shortLabel: z.ZodOptional<z.ZodString>;
|
|
41722
|
+
logoUrl: z.ZodOptional<z.ZodString>;
|
|
41675
41723
|
provider: z.ZodString;
|
|
41676
41724
|
providerLabel: z.ZodString;
|
|
41677
41725
|
api: z.ZodEnum<{
|
package/dist/index.js
CHANGED
|
@@ -1179,6 +1179,8 @@ import {
|
|
|
1179
1179
|
PromoteTaskNoteInstructionPolicyRequest,
|
|
1180
1180
|
PromoteTaskNoteKnowledgeRequest,
|
|
1181
1181
|
PromoteTaskNotePreferenceRequest,
|
|
1182
|
+
PromotionalCreditBalance,
|
|
1183
|
+
PromotionalCreditScope,
|
|
1182
1184
|
ProposeRigChangeRequest,
|
|
1183
1185
|
ProposeWorkspaceInstructionPolicyRequest,
|
|
1184
1186
|
ProposeWorkspaceKnowledgeClaimRequest,
|
|
@@ -2172,7 +2174,7 @@ import {
|
|
|
2172
2174
|
workspaceLearningPolicyRouterContext,
|
|
2173
2175
|
workspaceLearningSourceKey,
|
|
2174
2176
|
workspaceSlackReactionChannelAllowed
|
|
2175
|
-
} from "./chunk-
|
|
2177
|
+
} from "./chunk-L73LKLKP.js";
|
|
2176
2178
|
import {
|
|
2177
2179
|
COMPUTER_SCREENSHOT_MAX_BYTES,
|
|
2178
2180
|
COMPUTER_SCREENSHOT_MAX_DIMENSION,
|
|
@@ -2271,6 +2273,7 @@ import {
|
|
|
2271
2273
|
WorkspaceCreditGrant,
|
|
2272
2274
|
WorkspaceUsageResponse
|
|
2273
2275
|
} from "./chunk-EK7NDGFR.js";
|
|
2276
|
+
import "./chunk-XSBEB2HQ.js";
|
|
2274
2277
|
import {
|
|
2275
2278
|
OPENGENI_DELIVERY_ID_HEADER,
|
|
2276
2279
|
OPENGENI_EVENT_ID_HEADER,
|
|
@@ -3957,6 +3960,8 @@ export {
|
|
|
3957
3960
|
PromoteTaskNoteInstructionPolicyRequest,
|
|
3958
3961
|
PromoteTaskNoteKnowledgeRequest,
|
|
3959
3962
|
PromoteTaskNotePreferenceRequest,
|
|
3963
|
+
PromotionalCreditBalance,
|
|
3964
|
+
PromotionalCreditScope,
|
|
3960
3965
|
ProposeRigChangeRequest,
|
|
3961
3966
|
ProposeWorkspaceInstructionPolicyRequest,
|
|
3962
3967
|
ProposeWorkspaceKnowledgeClaimRequest,
|
package/dist/model-display.d.ts
CHANGED
|
@@ -13,11 +13,14 @@ export type ModelVendor = "openai" | "anthropic" | "xai" | "google" | "meta" | "
|
|
|
13
13
|
export type ModelDisplayInput = string | {
|
|
14
14
|
id: string;
|
|
15
15
|
label?: string | null | undefined;
|
|
16
|
+
logoUrl?: string | null | undefined;
|
|
16
17
|
upstreamModelId?: string | null | undefined;
|
|
17
18
|
deployment?: {
|
|
18
19
|
upstreamModelId?: string | null | undefined;
|
|
19
20
|
} | null | undefined;
|
|
20
21
|
};
|
|
22
|
+
/** Catalog maker logo; remote images must use HTTPS without embedded credentials. */
|
|
23
|
+
export declare function modelLogoUrl(input: ModelDisplayInput): string | null;
|
|
21
24
|
/** The upstream model slug without routing prefixes or `:variant` suffixes. */
|
|
22
25
|
export declare function modelSlug(value: string): string;
|
|
23
26
|
/** `claude-opus-5-5` → `Claude Opus 5.5`, `codex/gpt-6.1-sol` → `GPT-6.1 Sol`. */
|
package/dist/model-display.js
CHANGED
|
@@ -1,133 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
llama: "Llama",
|
|
10
|
-
deepseek: "DeepSeek",
|
|
11
|
-
qwen: "Qwen",
|
|
12
|
-
glm: "GLM",
|
|
13
|
-
kimi: "Kimi",
|
|
14
|
-
mistral: "Mistral",
|
|
15
|
-
codestral: "Codestral",
|
|
16
|
-
devstral: "Devstral",
|
|
17
|
-
magistral: "Magistral",
|
|
18
|
-
nemotron: "Nemotron",
|
|
19
|
-
oss: "OSS"
|
|
20
|
-
};
|
|
21
|
-
function modelSlug(value) {
|
|
22
|
-
const last = value.split("/").filter(Boolean).at(-1) ?? value;
|
|
23
|
-
return last.replace(/:[^:]*$/, "") || last;
|
|
24
|
-
}
|
|
25
|
-
function upstreamOf(input) {
|
|
26
|
-
return input.upstreamModelId?.trim() || input.deployment?.upstreamModelId?.trim() || null;
|
|
27
|
-
}
|
|
28
|
-
function titleToken(token, index) {
|
|
29
|
-
const lower = token.toLowerCase();
|
|
30
|
-
const word = WORDS[lower];
|
|
31
|
-
if (word) return word;
|
|
32
|
-
if (index === 0 && /^o\d+$/.test(lower)) return lower;
|
|
33
|
-
if (/^\d+(?:\.\d+)?[bkmt]$/.test(lower) || /^[a-z]\d+[a-z\d]*$/.test(lower)) {
|
|
34
|
-
return lower.toUpperCase();
|
|
35
|
-
}
|
|
36
|
-
if (/^\d/.test(token)) return lower;
|
|
37
|
-
return lower.charAt(0).toUpperCase() + lower.slice(1);
|
|
38
|
-
}
|
|
39
|
-
function humanizeModelSlug(value) {
|
|
40
|
-
const slug = modelSlug(value.trim()).replace(/[-_](?:\d{8}|\d{4}-\d{2}-\d{2})$/, "").replace(/[-_]latest$/i, "");
|
|
41
|
-
const raw = slug.split(/[-_\s]+/).filter(Boolean);
|
|
42
|
-
if (raw.length === 0) return value.trim() || value;
|
|
43
|
-
const tokens = [];
|
|
44
|
-
for (const token of raw) {
|
|
45
|
-
const previous = tokens.at(-1);
|
|
46
|
-
if (previous !== void 0 && /^\d{1,2}$/.test(token) && /^\d{1,2}$/.test(previous)) {
|
|
47
|
-
tokens[tokens.length - 1] = `${previous}.${token}`;
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
tokens.push(token);
|
|
51
|
-
}
|
|
52
|
-
const words = tokens.map(titleToken);
|
|
53
|
-
if (words[0] === "GPT" && words.length > 1 && /^\d/.test(words[1])) {
|
|
54
|
-
return [`GPT-${words[1]}`, ...words.slice(2)].join(" ");
|
|
55
|
-
}
|
|
56
|
-
return words.join(" ");
|
|
57
|
-
}
|
|
58
|
-
function isRawModelLabel(label, ids = []) {
|
|
59
|
-
const text = label.trim();
|
|
60
|
-
if (!text) return true;
|
|
61
|
-
return ids.some((id) => {
|
|
62
|
-
if (!id) return false;
|
|
63
|
-
const segments = id.trim().split("/").filter(Boolean);
|
|
64
|
-
return segments.some((_, index) => {
|
|
65
|
-
const tail = segments.slice(index).join("/");
|
|
66
|
-
return tail === text || modelSlug(tail) === text;
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function modelDisplayName(input) {
|
|
71
|
-
if (typeof input === "string") {
|
|
72
|
-
return input.trim() && !/\s/.test(input.trim()) ? humanizeModelSlug(input) : input;
|
|
73
|
-
}
|
|
74
|
-
const upstream = upstreamOf(input);
|
|
75
|
-
const label = input.label?.trim();
|
|
76
|
-
if (label && !isRawModelLabel(label, [input.id, upstream])) return label;
|
|
77
|
-
return humanizeModelSlug(upstream ?? label ?? input.id);
|
|
78
|
-
}
|
|
79
|
-
var VENDOR_PATTERNS = [
|
|
80
|
-
["anthropic", /^claude\b/],
|
|
81
|
-
["openai", /^(?:gpt|chatgpt|o\d+|codex|dall-e|sora|text-embedding|whisper)\b/],
|
|
82
|
-
["xai", /^grok\b/],
|
|
83
|
-
["google", /^(?:gemini|gemma)\b/],
|
|
84
|
-
["meta", /^llama\b/],
|
|
85
|
-
["mistral", /^(?:mistral|codestral|devstral|magistral|ministral|pixtral)\b/],
|
|
86
|
-
["deepseek", /^deepseek\b/],
|
|
87
|
-
["moonshot", /^(?:kimi|moonshot)\b/],
|
|
88
|
-
["qwen", /^(?:qwen|qwq)\b/],
|
|
89
|
-
["zhipu", /^glm\b/],
|
|
90
|
-
["nvidia", /^nemotron\b/]
|
|
91
|
-
];
|
|
92
|
-
var VENDOR_SEGMENTS = {
|
|
93
|
-
anthropic: "anthropic",
|
|
94
|
-
openai: "openai",
|
|
95
|
-
"x-ai": "xai",
|
|
96
|
-
xai: "xai",
|
|
97
|
-
google: "google",
|
|
98
|
-
"meta-llama": "meta",
|
|
99
|
-
mistralai: "mistral",
|
|
100
|
-
deepseek: "deepseek",
|
|
101
|
-
moonshotai: "moonshot",
|
|
102
|
-
qwen: "qwen",
|
|
103
|
-
"z-ai": "zhipu",
|
|
104
|
-
nvidia: "nvidia"
|
|
105
|
-
};
|
|
106
|
-
function vendorFromSlug(slug) {
|
|
107
|
-
for (const [vendor, pattern] of VENDOR_PATTERNS) if (pattern.test(slug)) return vendor;
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
function modelVendor(input) {
|
|
111
|
-
const ids = typeof input === "string" ? [input] : [upstreamOf(input), input.id];
|
|
112
|
-
for (const id of ids) {
|
|
113
|
-
if (!id) continue;
|
|
114
|
-
const lower = id.trim().toLowerCase();
|
|
115
|
-
if (lower.startsWith("codex/")) return "openai";
|
|
116
|
-
if (lower.startsWith("supergrok/")) return "xai";
|
|
117
|
-
const vendor = vendorFromSlug(modelSlug(lower));
|
|
118
|
-
if (vendor) return vendor;
|
|
119
|
-
const segment = lower.split("/").filter(Boolean).at(-2);
|
|
120
|
-
if (segment && Object.hasOwn(VENDOR_SEGMENTS, segment)) return VENDOR_SEGMENTS[segment];
|
|
121
|
-
}
|
|
122
|
-
if (typeof input !== "string" && input.label) {
|
|
123
|
-
return vendorFromSlug(input.label.trim().toLowerCase().replace(/\s+/g, "-"));
|
|
124
|
-
}
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
humanizeModelSlug,
|
|
3
|
+
isRawModelLabel,
|
|
4
|
+
modelDisplayName,
|
|
5
|
+
modelLogoUrl,
|
|
6
|
+
modelSlug,
|
|
7
|
+
modelVendor
|
|
8
|
+
} from "./chunk-XSBEB2HQ.js";
|
|
127
9
|
export {
|
|
128
10
|
humanizeModelSlug,
|
|
129
11
|
isRawModelLabel,
|
|
130
12
|
modelDisplayName,
|
|
13
|
+
modelLogoUrl,
|
|
131
14
|
modelSlug,
|
|
132
15
|
modelVendor
|
|
133
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/model-display.ts"],"sourcesContent":["/**\n * One display identity for a model everywhere outside the Models settings page.\n *\n * Catalog ids carry routing facts (`codex/`, `organization-claude-subscription/`,\n * `workspace-openrouter/anthropic/...`) and custom models may have no curated\n * label. People should only ever see the model itself: `GPT-6.1 Sol`,\n * `Claude Opus 5.5`. The same upstream model therefore renders identically\n * whether an organization or a workspace connection serves it.\n *\n * Pure and dependency-free so the API, SDK, React package and web app share it.\n */\n\nexport type ModelVendor =\n | \"openai\"\n | \"anthropic\"\n | \"xai\"\n | \"google\"\n | \"meta\"\n | \"mistral\"\n | \"deepseek\"\n | \"moonshot\"\n | \"qwen\"\n | \"zhipu\"\n | \"nvidia\";\n\nexport type ModelDisplayInput =\n | string\n | {\n id: string;\n label?: string | null | undefined;\n upstreamModelId?: string | null | undefined;\n deployment?: { upstreamModelId?: string | null | undefined } | null | undefined;\n };\n\nconst WORDS: Readonly<Record<string, string>> = {\n gpt: \"GPT\",\n chatgpt: \"ChatGPT\",\n claude: \"Claude\",\n grok: \"Grok\",\n gemini: \"Gemini\",\n gemma: \"Gemma\",\n llama: \"Llama\",\n deepseek: \"DeepSeek\",\n qwen: \"Qwen\",\n glm: \"GLM\",\n kimi: \"Kimi\",\n mistral: \"Mistral\",\n codestral: \"Codestral\",\n devstral: \"Devstral\",\n magistral: \"Magistral\",\n nemotron: \"Nemotron\",\n oss: \"OSS\",\n};\n\n/** The upstream model slug without routing prefixes or `:variant` suffixes. */\nexport function modelSlug(value: string): string {\n const last = value.split(\"/\").filter(Boolean).at(-1) ?? value;\n return last.replace(/:[^:]*$/, \"\") || last;\n}\n\nfunction upstreamOf(input: Exclude<ModelDisplayInput, string>): string | null {\n return input.upstreamModelId?.trim() || input.deployment?.upstreamModelId?.trim() || null;\n}\n\nfunction titleToken(token: string, index: number): string {\n const lower = token.toLowerCase();\n const word = WORDS[lower];\n if (word) return word;\n // OpenAI reasoning series stay lowercase: o3, o4 Mini.\n if (index === 0 && /^o\\d+$/.test(lower)) return lower;\n // Sizes and lettered versions read as identifiers: 120B, V4, K3, A12B.\n if (/^\\d+(?:\\.\\d+)?[bkmt]$/.test(lower) || /^[a-z]\\d+[a-z\\d]*$/.test(lower)) {\n return lower.toUpperCase();\n }\n if (/^\\d/.test(token)) return lower;\n return lower.charAt(0).toUpperCase() + lower.slice(1);\n}\n\n/** `claude-opus-5-5` → `Claude Opus 5.5`, `codex/gpt-6.1-sol` → `GPT-6.1 Sol`. */\nexport function humanizeModelSlug(value: string): string {\n const slug = modelSlug(value.trim())\n // Snapshot dates are release detail, not a different model name.\n .replace(/[-_](?:\\d{8}|\\d{4}-\\d{2}-\\d{2})$/, \"\")\n .replace(/[-_]latest$/i, \"\");\n const raw = slug.split(/[-_\\s]+/).filter(Boolean);\n if (raw.length === 0) return value.trim() || value;\n // Consecutive short numbers are one version: 5-5 → 5.5, 3-5 → 3.5. Longer\n // numbers are snapshots (gpt-4-1106-preview), never a minor version.\n const tokens: string[] = [];\n for (const token of raw) {\n const previous = tokens.at(-1);\n if (previous !== undefined && /^\\d{1,2}$/.test(token) && /^\\d{1,2}$/.test(previous)) {\n tokens[tokens.length - 1] = `${previous}.${token}`;\n continue;\n }\n tokens.push(token);\n }\n const words = tokens.map(titleToken);\n // OpenAI's own spelling joins family and version: GPT-6.1, GPT-4o.\n if (words[0] === \"GPT\" && words.length > 1 && /^\\d/.test(words[1]!)) {\n return [`GPT-${words[1]}`, ...words.slice(2)].join(\" \");\n }\n return words.join(\" \");\n}\n\n/**\n * True when a catalog label is only the model's identifier: empty, or exactly\n * its id, upstream id, or any trailing path of them (`claude-opus-4-8`,\n * `anthropic/claude-sonnet-4.6`). Any other label is a curated name and wins.\n */\nexport function isRawModelLabel(\n label: string,\n ids: readonly (string | null | undefined)[] = [],\n): boolean {\n const text = label.trim();\n if (!text) return true;\n return ids.some((id) => {\n if (!id) return false;\n const segments = id.trim().split(\"/\").filter(Boolean);\n return segments.some((_, index) => {\n const tail = segments.slice(index).join(\"/\");\n return tail === text || modelSlug(tail) === text;\n });\n });\n}\n\n/**\n * The clean name to show for a model: its curated catalog label when it has\n * one, otherwise a readable form of the upstream model id. Never a routing\n * prefix, connection id or connection scope.\n */\nexport function modelDisplayName(input: ModelDisplayInput): string {\n if (typeof input === \"string\") {\n // A bare id is humanized; text with spaces is already a name (\"Workspace default\").\n return input.trim() && !/\\s/.test(input.trim()) ? humanizeModelSlug(input) : input;\n }\n const upstream = upstreamOf(input);\n const label = input.label?.trim();\n if (label && !isRawModelLabel(label, [input.id, upstream])) return label;\n return humanizeModelSlug(upstream ?? label ?? input.id);\n}\n\nconst VENDOR_PATTERNS: ReadonlyArray<readonly [ModelVendor, RegExp]> = [\n [\"anthropic\", /^claude\\b/],\n [\"openai\", /^(?:gpt|chatgpt|o\\d+|codex|dall-e|sora|text-embedding|whisper)\\b/],\n [\"xai\", /^grok\\b/],\n [\"google\", /^(?:gemini|gemma)\\b/],\n [\"meta\", /^llama\\b/],\n [\"mistral\", /^(?:mistral|codestral|devstral|magistral|ministral|pixtral)\\b/],\n [\"deepseek\", /^deepseek\\b/],\n [\"moonshot\", /^(?:kimi|moonshot)\\b/],\n [\"qwen\", /^(?:qwen|qwq)\\b/],\n [\"zhipu\", /^glm\\b/],\n [\"nvidia\", /^nemotron\\b/],\n];\n\n/** OpenRouter / Gateway vendor path segments (`anthropic/claude-…`). */\nconst VENDOR_SEGMENTS: Readonly<Record<string, ModelVendor>> = {\n anthropic: \"anthropic\",\n openai: \"openai\",\n \"x-ai\": \"xai\",\n xai: \"xai\",\n google: \"google\",\n \"meta-llama\": \"meta\",\n mistralai: \"mistral\",\n deepseek: \"deepseek\",\n moonshotai: \"moonshot\",\n qwen: \"qwen\",\n \"z-ai\": \"zhipu\",\n nvidia: \"nvidia\",\n};\n\nfunction vendorFromSlug(slug: string): ModelVendor | null {\n for (const [vendor, pattern] of VENDOR_PATTERNS) if (pattern.test(slug)) return vendor;\n return null;\n}\n\n/** Who makes the model, for its logo. Null when it cannot be told. */\nexport function modelVendor(input: ModelDisplayInput): ModelVendor | null {\n const ids = typeof input === \"string\" ? [input] : [upstreamOf(input), input.id];\n for (const id of ids) {\n if (!id) continue;\n const lower = id.trim().toLowerCase();\n if (lower.startsWith(\"codex/\")) return \"openai\";\n if (lower.startsWith(\"supergrok/\")) return \"xai\";\n const vendor = vendorFromSlug(modelSlug(lower));\n if (vendor) return vendor;\n const segment = lower.split(\"/\").filter(Boolean).at(-2);\n if (segment && Object.hasOwn(VENDOR_SEGMENTS, segment)) return VENDOR_SEGMENTS[segment]!;\n }\n if (typeof input !== \"string\" && input.label) {\n return vendorFromSlug(input.label.trim().toLowerCase().replace(/\\s+/g, \"-\"));\n }\n return null;\n}\n"],"mappings":";AAkCA,IAAM,QAA0C;AAAA,EAC9C,KAAK;AAAA,EACL,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,SAAS;AAAA,EACT,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,KAAK;AACP;AAGO,SAAS,UAAU,OAAuB;AAC/C,QAAM,OAAO,MAAM,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,GAAG,EAAE,KAAK;AACxD,SAAO,KAAK,QAAQ,WAAW,EAAE,KAAK;AACxC;AAEA,SAAS,WAAW,OAA0D;AAC5E,SAAO,MAAM,iBAAiB,KAAK,KAAK,MAAM,YAAY,iBAAiB,KAAK,KAAK;AACvF;AAEA,SAAS,WAAW,OAAe,OAAuB;AACxD,QAAM,QAAQ,MAAM,YAAY;AAChC,QAAM,O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AAQ;AAAA,EACR,QAAQ;AACV;AAEA,SAAS,eAAe,MAAkC;AACxD,aAAW,CAAC,QAAQ,OAAO,KAAK,gBAAiB,KAAI,QAAQ,KAAK,IAAI,EAAG,QAAO;AAChF,SAAO;AACT;AAGO,SAAS,YAAY,OAA8C;AACxE,QAAM,MAAM,OAAO,UAAU,WAAW,CAAC,KAAK,IAAI,CAAC,WAAW,KAAK,GAAG,MAAM,EAAE;AAC9E,aAAW,MAAM,KAAK;AACpB,QAAI,CAAC,GAAI;AACT,UAAM,QAAQ,GAAG,KAAK,EAAE,YAAY;AACpC,QAAI,MAAM,WAAW,QAAQ,EAAG,QAAO;AACvC,QAAI,MAAM,WAAW,YAAY,EAAG,QAAO;AAC3C,UAAM,SAAS,eAAe,UAAU,KAAK,CAAC;AAC9C,QAAI,OAAQ,QAAO;AACnB,UAAM,UAAU,MAAM,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,GAAG,EAAE;AACtD,QAAI,WAAW,OAAO,OAAO,iBAAiB,OAAO,EAAG,QAAO,gBAAgB,OAAO;AAAA,EACxF;AACA,MAAI,OAAO,UAAU,YAAY,MAAM,OAAO;AAC5C,WAAO,eAAe,MAAM,MAAM,KAAK,EAAE,YAAY,EAAE,QAAQ,QAAQ,GAAG,CAAC;AAAA,EAC7E;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/personal-github.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConnectionMetadata
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L73LKLKP.js";
|
|
4
4
|
import "./chunk-5IXYF6XN.js";
|
|
5
5
|
import "./chunk-NRMCVHAU.js";
|
|
6
6
|
import "./chunk-WYBDERIY.js";
|
|
7
7
|
import "./chunk-4JGHSSB7.js";
|
|
8
8
|
import "./chunk-EK7NDGFR.js";
|
|
9
|
+
import "./chunk-XSBEB2HQ.js";
|
|
9
10
|
import "./chunk-O77VSFYZ.js";
|
|
10
11
|
import "./chunk-NVJMJWLL.js";
|
|
11
12
|
import "./chunk-SIOU2K4U.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/personal-github.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport { ConnectionMetadata } from \"./index\";\n\nexport const PERSONAL_GITHUB_PROVIDER_DOMAIN = \"github.com\" as const;\nexport const PERSONAL_GITHUB_PROVIDER_FAMILY = \"github\" as const;\nexport const PERSONAL_GITHUB_CREDENTIAL_ROLE = \"opengeni_github_personal\" as const;\nexport const PERSONAL_GITHUB_CONNECTION_SURFACE_ID = \"github:personal\" as const;\nexport const PERSONAL_GITHUB_REQUESTED_SCOPES = [\"repo\"] as const;\nexport const PERSONAL_GITHUB_AUTHORIZATION_URL =\n \"https://github.com/login/oauth/authorize\" as const;\nexport const PERSONAL_GITHUB_TOKEN_URL = \"https://github.com/login/oauth/access_token\" as const;\nexport const PERSONAL_GITHUB_USER_URL = \"https://api.github.com/user\" as const;\nexport const PERSONAL_GITHUB_API_ORIGIN = \"https://api.github.com\" as const;\nexport const PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX = 100 as const;\n\nexport const PersonalGitHubRepositoryId = z.string().regex(/^[1-9]\\d*$/u);\nexport type PersonalGitHubRepositoryId = z.infer<typeof PersonalGitHubRepositoryId>;\n\nexport const PersonalGitHubRepositoryAccess = z.enum([\"read\", \"write\"]);\nexport type PersonalGitHubRepositoryAccess = z.infer<typeof PersonalGitHubRepositoryAccess>;\n\nexport const PersonalGitHubRepositoryPermissions = z\n .object({\n pull: z.boolean(),\n push: z.boolean(),\n admin: z.boolean(),\n maintain: z.boolean(),\n triage: z.boolean(),\n })\n .strict();\nexport type PersonalGitHubRepositoryPermissions = z.infer<\n typeof PersonalGitHubRepositoryPermissions\n>;\n\nexport const PersonalGitHubRepositoryVisibility = z.enum([\"public\", \"private\", \"internal\"]);\nexport type PersonalGitHubRepositoryVisibility = z.infer<typeof PersonalGitHubRepositoryVisibility>;\n\nconst PersonalGitHubRepositoryFullName = z\n .string()\n .min(3)\n .max(140)\n .regex(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\\/[A-Za-z0-9_.-]{1,100}$/u);\n\nexport function canonicalPersonalGitHubRepositoryUrl(fullName: string): string {\n return `https://github.com/${fullName}`;\n}\n\n/** A bounded, credential-free projection verified directly against GitHub. */\nexport const PersonalGitHubRepository = z\n .object({\n repositoryId: PersonalGitHubRepositoryId,\n fullName: PersonalGitHubRepositoryFullName,\n canonicalUrl: z.string().url().max(512),\n defaultBranch: z.string().min(1).max(255),\n visibility: PersonalGitHubRepositoryVisibility,\n private: z.boolean(),\n archived: z.boolean(),\n disabled: z.boolean(),\n permissions: PersonalGitHubRepositoryPermissions,\n })\n .strict()\n .superRefine((repository, context) => {\n if (repository.canonicalUrl !== canonicalPersonalGitHubRepositoryUrl(repository.fullName)) {\n context.addIssue({\n code: \"custom\",\n path: [\"canonicalUrl\"],\n message: \"canonicalUrl must be derived from fullName\",\n });\n }\n if (repository.private !== (repository.visibility === \"private\")) {\n context.addIssue({\n code: \"custom\",\n path: [\"private\"],\n message: \"private must agree with visibility\",\n });\n }\n });\nexport type PersonalGitHubRepository = z.infer<typeof PersonalGitHubRepository>;\n\nexport const PersonalGitHubSelectedRepository = PersonalGitHubRepository.safeExtend({\n selectedAccess: PersonalGitHubRepositoryAccess,\n selectionGeneration: z.number().int().positive(),\n selectedAt: z.string().datetime({ offset: true }),\n lastVerifiedAt: z.string().datetime({ offset: true }),\n}).strict();\nexport type PersonalGitHubSelectedRepository = z.infer<typeof PersonalGitHubSelectedRepository>;\n\nexport const PersonalGitHubRepositorySelectionState = z\n .object({\n connectionAuthorityGeneration: z.number().int().positive(),\n credentialBindingId: z.string().uuid(),\n providerPrincipalId: PersonalGitHubRepositoryId,\n selectionGeneration: z.number().int().nonnegative(),\n repositories: z\n .array(PersonalGitHubSelectedRepository)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n })\n .strict();\nexport type PersonalGitHubRepositorySelectionState = z.infer<\n typeof PersonalGitHubRepositorySelectionState\n>;\n\nexport const ListPersonalGitHubRepositoriesQuery = z\n .object({\n cursor: z.coerce.number().int().positive().max(10_000).default(1),\n limit: z.coerce.number().int().min(1).max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX).default(50),\n })\n .strict();\nexport type ListPersonalGitHubRepositoriesQuery = z.infer<\n typeof ListPersonalGitHubRepositoriesQuery\n>;\n\nexport const PersonalGitHubRepositoryCatalogItem = PersonalGitHubRepository.safeExtend({\n selectedAccess: PersonalGitHubRepositoryAccess.nullable(),\n}).strict();\nexport type PersonalGitHubRepositoryCatalogItem = z.infer<\n typeof PersonalGitHubRepositoryCatalogItem\n>;\n\nexport const ListPersonalGitHubRepositoriesResponse = z\n .object({\n repositories: z\n .array(PersonalGitHubRepositoryCatalogItem)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n nextCursor: z.number().int().positive().nullable(),\n selection: PersonalGitHubRepositorySelectionState,\n })\n .strict();\nexport type ListPersonalGitHubRepositoriesResponse = z.infer<\n typeof ListPersonalGitHubRepositoriesResponse\n>;\n\nexport const PersonalGitHubRepositorySelectionInput = z\n .object({\n repositoryId: PersonalGitHubRepositoryId,\n fullName: PersonalGitHubRepositoryFullName,\n access: PersonalGitHubRepositoryAccess,\n })\n .strict();\nexport type PersonalGitHubRepositorySelectionInput = z.infer<\n typeof PersonalGitHubRepositorySelectionInput\n>;\n\nexport const ReplacePersonalGitHubRepositorySelectionsRequest = z\n .object({\n expectedConnectionAuthorityGeneration: z.number().int().positive(),\n expectedSelectionGeneration: z.number().int().nonnegative(),\n idempotencyKey: z.string().trim().min(1).max(200),\n repositories: z\n .array(PersonalGitHubRepositorySelectionInput)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n })\n .strict()\n .superRefine((request, context) => {\n const repositoryIds = new Set<string>();\n const fullNames = new Set<string>();\n request.repositories.forEach((repository, index) => {\n const normalizedFullName = repository.fullName.toLowerCase();\n if (repositoryIds.has(repository.repositoryId)) {\n context.addIssue({\n code: \"custom\",\n path: [\"repositories\", index, \"repositoryId\"],\n message: \"repositoryId must be unique\",\n });\n }\n if (fullNames.has(normalizedFullName)) {\n context.addIssue({\n code: \"custom\",\n path: [\"repositories\", index, \"fullName\"],\n message: \"fullName must be unique\",\n });\n }\n repositoryIds.add(repository.repositoryId);\n fullNames.add(normalizedFullName);\n });\n });\nexport type ReplacePersonalGitHubRepositorySelectionsRequest = z.infer<\n typeof ReplacePersonalGitHubRepositorySelectionsRequest\n>;\n\nexport const VerifyPersonalGitHubRepositorySelectionsRequest = z\n .object({\n expectedConnectionAuthorityGeneration: z.number().int().positive(),\n expectedSelectionGeneration: z.number().int().nonnegative(),\n idempotencyKey: z.string().trim().min(1).max(200),\n })\n .strict();\nexport type VerifyPersonalGitHubRepositorySelectionsRequest = z.infer<\n typeof VerifyPersonalGitHubRepositorySelectionsRequest\n>;\n\n/**\n * Owner-visible, credential-free metadata for one dedicated personal GitHub\n * OAuth connection. Repository selections are a separate authority and never\n * live in this credential record.\n */\nexport const PersonalGitHubConnectionMetadata = z\n .object({\n credentialRole: z.literal(PERSONAL_GITHUB_CREDENTIAL_ROLE),\n providerFamily: z.literal(PERSONAL_GITHUB_PROVIDER_FAMILY),\n providerPrincipalId: z.string().regex(/^\\d+$/u),\n githubUserId: z.string().regex(/^\\d+$/u),\n githubLogin: z.string().min(1).max(100),\n oauthEnvironment: z.string().min(1).max(128),\n oauthClientMarker: z.string().regex(/^[a-f0-9]{32}$/u),\n credentialBindingId: z.string().uuid(),\n connectedAt: z.string().datetime({ offset: true }),\n lastVerifiedAt: z.string().datetime({ offset: true }),\n disconnectedAt: z.string().datetime({ offset: true }).nullable().optional(),\n refreshTokenExpiresAt: z.string().datetime({ offset: true }).nullable().optional(),\n })\n .passthrough();\nexport type PersonalGitHubConnectionMetadata = z.infer<typeof PersonalGitHubConnectionMetadata>;\n\nexport const PersonalGitHubOAuthStartRequest = z\n .object({\n /** Existing exact connection generation to re-authorize in place. */\n connectionId: z.string().uuid().optional(),\n /** Same-workspace UI path restored after the callback. */\n returnPath: z.string().min(1).max(2048).optional(),\n })\n .strict();\nexport type PersonalGitHubOAuthStartRequest = z.infer<typeof PersonalGitHubOAuthStartRequest>;\n\nexport const PersonalGitHubOAuthStartResponse = z\n .object({\n authorizationUrl: z.string().url(),\n expiresAt: z.string().datetime({ offset: true }),\n })\n .strict();\nexport type PersonalGitHubOAuthStartResponse = z.infer<typeof PersonalGitHubOAuthStartResponse>;\n\nexport const PersonalGitHubConnectionStatusResponse = z\n .object({\n enabled: z.boolean(),\n connection: ConnectionMetadata.nullable(),\n reviewUrl: z.string().url().nullable(),\n })\n .strict();\nexport type PersonalGitHubConnectionStatusResponse = z.infer<\n typeof PersonalGitHubConnectionStatusResponse\n>;\n\nexport const PersonalGitHubDisconnectRequest = z\n .object({\n expectedVersion: z.number().int().positive(),\n idempotencyKey: z.string().trim().min(1).max(200),\n })\n .strict();\nexport type PersonalGitHubDisconnectRequest = z.infer<typeof PersonalGitHubDisconnectRequest>;\n\nexport function isPersonalGitHubConnection(\n connection: Pick<z.infer<typeof ConnectionMetadata>, \"providerDomain\" | \"kind\" | \"metadata\">,\n): boolean {\n return (\n connection.providerDomain.toLowerCase() === PERSONAL_GITHUB_PROVIDER_DOMAIN &&\n connection.kind === \"oauth2\" &&\n PersonalGitHubConnectionMetadata.safeParse(connection.metadata).success\n );\n}\n\nexport function hasReservedPersonalGitHubMetadata(\n metadata: Record<string, unknown> | undefined,\n): boolean {\n return metadata?.credentialRole === PERSONAL_GITHUB_CREDENTIAL_ROLE;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS;AAIX,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AACxC,IAAM,wCAAwC;AAC9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AyC,EACnD,OAAO;AAAA,EACN,SAAS,EAAE,QAAQ;AAAA,EACnB,YAAY,mBAAmB,SAAS;AAAA,EACxC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AACvC,CAAC,EACA,OAAO;AAKH,IAAM,kCAAkC,EAC5C,OAAO;AAAA,EACN,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAC3C,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAClD,CAAC,EACA,OAAO;AAGH,SAAS,2BACd,YACS;AACT,SACE,WAAW,eAAe,YAAY,MAAM,mCAC5C,WAAW,SAAS,YACpB,iCAAiC,UAAU,WAAW,QAAQ,EAAE;AAEpE;AAEO,SAAS,kCACd,UACS;AACT,SAAO,UAAU,mBAAmB;AACtC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/personal-github.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport { ConnectionMetadata } from \"./index\";\n\nexport const PERSONAL_GITHUB_PROVIDER_DOMAIN = \"github.com\" as const;\nexport const PERSONAL_GITHUB_PROVIDER_FAMILY = \"github\" as const;\nexport const PERSONAL_GITHUB_CREDENTIAL_ROLE = \"opengeni_github_personal\" as const;\nexport const PERSONAL_GITHUB_CONNECTION_SURFACE_ID = \"github:personal\" as const;\nexport const PERSONAL_GITHUB_REQUESTED_SCOPES = [\"repo\"] as const;\nexport const PERSONAL_GITHUB_AUTHORIZATION_URL =\n \"https://github.com/login/oauth/authorize\" as const;\nexport const PERSONAL_GITHUB_TOKEN_URL = \"https://github.com/login/oauth/access_token\" as const;\nexport const PERSONAL_GITHUB_USER_URL = \"https://api.github.com/user\" as const;\nexport const PERSONAL_GITHUB_API_ORIGIN = \"https://api.github.com\" as const;\nexport const PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX = 100 as const;\n\nexport const PersonalGitHubRepositoryId = z.string().regex(/^[1-9]\\d*$/u);\nexport type PersonalGitHubRepositoryId = z.infer<typeof PersonalGitHubRepositoryId>;\n\nexport const PersonalGitHubRepositoryAccess = z.enum([\"read\", \"write\"]);\nexport type PersonalGitHubRepositoryAccess = z.infer<typeof PersonalGitHubRepositoryAccess>;\n\nexport const PersonalGitHubRepositoryPermissions = z\n .object({\n pull: z.boolean(),\n push: z.boolean(),\n admin: z.boolean(),\n maintain: z.boolean(),\n triage: z.boolean(),\n })\n .strict();\nexport type PersonalGitHubRepositoryPermissions = z.infer<\n typeof PersonalGitHubRepositoryPermissions\n>;\n\nexport const PersonalGitHubRepositoryVisibility = z.enum([\"public\", \"private\", \"internal\"]);\nexport type PersonalGitHubRepositoryVisibility = z.infer<typeof PersonalGitHubRepositoryVisibility>;\n\nconst PersonalGitHubRepositoryFullName = z\n .string()\n .min(3)\n .max(140)\n .regex(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\\/[A-Za-z0-9_.-]{1,100}$/u);\n\nexport function canonicalPersonalGitHubRepositoryUrl(fullName: string): string {\n return `https://github.com/${fullName}`;\n}\n\n/** A bounded, credential-free projection verified directly against GitHub. */\nexport const PersonalGitHubRepository = z\n .object({\n repositoryId: PersonalGitHubRepositoryId,\n fullName: PersonalGitHubRepositoryFullName,\n canonicalUrl: z.string().url().max(512),\n defaultBranch: z.string().min(1).max(255),\n visibility: PersonalGitHubRepositoryVisibility,\n private: z.boolean(),\n archived: z.boolean(),\n disabled: z.boolean(),\n permissions: PersonalGitHubRepositoryPermissions,\n })\n .strict()\n .superRefine((repository, context) => {\n if (repository.canonicalUrl !== canonicalPersonalGitHubRepositoryUrl(repository.fullName)) {\n context.addIssue({\n code: \"custom\",\n path: [\"canonicalUrl\"],\n message: \"canonicalUrl must be derived from fullName\",\n });\n }\n if (repository.private !== (repository.visibility === \"private\")) {\n context.addIssue({\n code: \"custom\",\n path: [\"private\"],\n message: \"private must agree with visibility\",\n });\n }\n });\nexport type PersonalGitHubRepository = z.infer<typeof PersonalGitHubRepository>;\n\nexport const PersonalGitHubSelectedRepository = PersonalGitHubRepository.safeExtend({\n selectedAccess: PersonalGitHubRepositoryAccess,\n selectionGeneration: z.number().int().positive(),\n selectedAt: z.string().datetime({ offset: true }),\n lastVerifiedAt: z.string().datetime({ offset: true }),\n}).strict();\nexport type PersonalGitHubSelectedRepository = z.infer<typeof PersonalGitHubSelectedRepository>;\n\nexport const PersonalGitHubRepositorySelectionState = z\n .object({\n connectionAuthorityGeneration: z.number().int().positive(),\n credentialBindingId: z.string().uuid(),\n providerPrincipalId: PersonalGitHubRepositoryId,\n selectionGeneration: z.number().int().nonnegative(),\n repositories: z\n .array(PersonalGitHubSelectedRepository)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n })\n .strict();\nexport type PersonalGitHubRepositorySelectionState = z.infer<\n typeof PersonalGitHubRepositorySelectionState\n>;\n\nexport const ListPersonalGitHubRepositoriesQuery = z\n .object({\n cursor: z.coerce.number().int().positive().max(10_000).default(1),\n limit: z.coerce.number().int().min(1).max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX).default(50),\n })\n .strict();\nexport type ListPersonalGitHubRepositoriesQuery = z.infer<\n typeof ListPersonalGitHubRepositoriesQuery\n>;\n\nexport const PersonalGitHubRepositoryCatalogItem = PersonalGitHubRepository.safeExtend({\n selectedAccess: PersonalGitHubRepositoryAccess.nullable(),\n}).strict();\nexport type PersonalGitHubRepositoryCatalogItem = z.infer<\n typeof PersonalGitHubRepositoryCatalogItem\n>;\n\nexport const ListPersonalGitHubRepositoriesResponse = z\n .object({\n repositories: z\n .array(PersonalGitHubRepositoryCatalogItem)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n nextCursor: z.number().int().positive().nullable(),\n selection: PersonalGitHubRepositorySelectionState,\n })\n .strict();\nexport type ListPersonalGitHubRepositoriesResponse = z.infer<\n typeof ListPersonalGitHubRepositoriesResponse\n>;\n\nexport const PersonalGitHubRepositorySelectionInput = z\n .object({\n repositoryId: PersonalGitHubRepositoryId,\n fullName: PersonalGitHubRepositoryFullName,\n access: PersonalGitHubRepositoryAccess,\n })\n .strict();\nexport type PersonalGitHubRepositorySelectionInput = z.infer<\n typeof PersonalGitHubRepositorySelectionInput\n>;\n\nexport const ReplacePersonalGitHubRepositorySelectionsRequest = z\n .object({\n expectedConnectionAuthorityGeneration: z.number().int().positive(),\n expectedSelectionGeneration: z.number().int().nonnegative(),\n idempotencyKey: z.string().trim().min(1).max(200),\n repositories: z\n .array(PersonalGitHubRepositorySelectionInput)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n })\n .strict()\n .superRefine((request, context) => {\n const repositoryIds = new Set<string>();\n const fullNames = new Set<string>();\n request.repositories.forEach((repository, index) => {\n const normalizedFullName = repository.fullName.toLowerCase();\n if (repositoryIds.has(repository.repositoryId)) {\n context.addIssue({\n code: \"custom\",\n path: [\"repositories\", index, \"repositoryId\"],\n message: \"repositoryId must be unique\",\n });\n }\n if (fullNames.has(normalizedFullName)) {\n context.addIssue({\n code: \"custom\",\n path: [\"repositories\", index, \"fullName\"],\n message: \"fullName must be unique\",\n });\n }\n repositoryIds.add(repository.repositoryId);\n fullNames.add(normalizedFullName);\n });\n });\nexport type ReplacePersonalGitHubRepositorySelectionsRequest = z.infer<\n typeof ReplacePersonalGitHubRepositorySelectionsRequest\n>;\n\nexport const VerifyPersonalGitHubRepositorySelectionsRequest = z\n .object({\n expectedConnectionAuthorityGeneration: z.number().int().positive(),\n expectedSelectionGeneration: z.number().int().nonnegative(),\n idempotencyKey: z.string().trim().min(1).max(200),\n })\n .strict();\nexport type VerifyPersonalGitHubRepositorySelectionsRequest = z.infer<\n typeof VerifyPersonalGitHubRepositorySelectionsRequest\n>;\n\n/**\n * Owner-visible, credential-free metadata for one dedicated personal GitHub\n * OAuth connection. Repository selections are a separate authority and never\n * live in this credential record.\n */\nexport const PersonalGitHubConnectionMetadata = z\n .object({\n credentialRole: z.literal(PERSONAL_GITHUB_CREDENTIAL_ROLE),\n providerFamily: z.literal(PERSONAL_GITHUB_PROVIDER_FAMILY),\n providerPrincipalId: z.string().regex(/^\\d+$/u),\n githubUserId: z.string().regex(/^\\d+$/u),\n githubLogin: z.string().min(1).max(100),\n oauthEnvironment: z.string().min(1).max(128),\n oauthClientMarker: z.string().regex(/^[a-f0-9]{32}$/u),\n credentialBindingId: z.string().uuid(),\n connectedAt: z.string().datetime({ offset: true }),\n lastVerifiedAt: z.string().datetime({ offset: true }),\n disconnectedAt: z.string().datetime({ offset: true }).nullable().optional(),\n refreshTokenExpiresAt: z.string().datetime({ offset: true }).nullable().optional(),\n })\n .passthrough();\nexport type PersonalGitHubConnectionMetadata = z.infer<typeof PersonalGitHubConnectionMetadata>;\n\nexport const PersonalGitHubOAuthStartRequest = z\n .object({\n /** Existing exact connection generation to re-authorize in place. */\n connectionId: z.string().uuid().optional(),\n /** Same-workspace UI path restored after the callback. */\n returnPath: z.string().min(1).max(2048).optional(),\n })\n .strict();\nexport type PersonalGitHubOAuthStartRequest = z.infer<typeof PersonalGitHubOAuthStartRequest>;\n\nexport const PersonalGitHubOAuthStartResponse = z\n .object({\n authorizationUrl: z.string().url(),\n expiresAt: z.string().datetime({ offset: true }),\n })\n .strict();\nexport type PersonalGitHubOAuthStartResponse = z.infer<typeof PersonalGitHubOAuthStartResponse>;\n\nexport const PersonalGitHubConnectionStatusResponse = z\n .object({\n enabled: z.boolean(),\n connection: ConnectionMetadata.nullable(),\n reviewUrl: z.string().url().nullable(),\n })\n .strict();\nexport type PersonalGitHubConnectionStatusResponse = z.infer<\n typeof PersonalGitHubConnectionStatusResponse\n>;\n\nexport const PersonalGitHubDisconnectRequest = z\n .object({\n expectedVersion: z.number().int().positive(),\n idempotencyKey: z.string().trim().min(1).max(200),\n })\n .strict();\nexport type PersonalGitHubDisconnectRequest = z.infer<typeof PersonalGitHubDisconnectRequest>;\n\nexport function isPersonalGitHubConnection(\n connection: Pick<z.infer<typeof ConnectionMetadata>, \"providerDomain\" | \"kind\" | \"metadata\">,\n): boolean {\n return (\n connection.providerDomain.toLowerCase() === PERSONAL_GITHUB_PROVIDER_DOMAIN &&\n connection.kind === \"oauth2\" &&\n PersonalGitHubConnectionMetadata.safeParse(connection.metadata).success\n );\n}\n\nexport function hasReservedPersonalGitHubMetadata(\n metadata: Record<string, unknown> | undefined,\n): boolean {\n return metadata?.credentialRole === PERSONAL_GITHUB_CREDENTIAL_ROLE;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS;AAIX,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AACxC,IAAM,wCAAwC;AAC9C,IAAM,mCAAmC,CAAC,MAAM;AAChD,IAAM,oCACX;AACK,IAAM,4BAA4B;AAClC,IAAM,2BAA2B;AACjC,IAAM,6BAA6B;AACnC,IAAM,yCAAyC;AAE/C,IAAM,6BAA6B,EAAE,OAAO,EAAE,MAAM,aAAa;AAGjE,IAAM,iCAAiC,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC;AAG/D,IAAM,sCAAsC,EAChD,OAAO;AAAA,EACN,MAAM,EAAE,QAAQ;AAAA,EAChB,MAAM,EAAE,QAAQ;AAAA,EAChB,OAAO,EAAE,QAAQ;AAAA,EACjB,UAAU,EAAE,QAAQ;AAAA,EACpB,QAAQ,EAAE,QAAQ;AACpB,CAAC,EACA,OAAO;AAKH,IAAM,qCAAqC,EAAE,KAAK,CAAC,UAAU,WAAW,UAAU,CAAC;AAG1F,IAAM,mCAAmC,EACtC,OAAO,EACP,IAAI,CAAC,EACL,IAAI,GAAG,EACP,MAAM,6DAA6D;AAE/D,SAAS,qCAAqC,UAA0B;AAC7E,SAAO,sBAAsB,QAAQ;AACvC;AAGO,IAAM,2BAA2B,EACrC,OAAO;AAAA,EACN,cAAc;AAAA,EACd,UAAU;AAAA,EACV,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG;AAAA,EACtC,eAAe,EAAE,OAAO,EAAE,IAA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,CAAC,EACA,YAAY;AAGR,IAAM,kCAAkC,EAC5C,OAAO;AAAA;AAAA,EAEN,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA;AAAA,EAEzC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,IAAI,EAAE,SAAS;AACnD,CAAC,EACA,OAAO;AAGH,IAAM,mCAAmC,EAC7C,OAAO;AAAA,EACN,kBAAkB,EAAE,OAAO,EAAE,IAAI;AAAA,EACjC,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,KAAK,CAAC;AACjD,CAAC,EACA,OAAO;AAGH,IAAM,yCAAyC,EACnD,OAAO;AAAA,EACN,SAAS,EAAE,QAAQ;AAAA,EACnB,YAAY,mBAAmB,SAAS;AAAA,EACxC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AACvC,CAAC,EACA,OAAO;AAKH,IAAM,kCAAkC,EAC5C,OAAO;AAAA,EACN,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAC3C,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAClD,CAAC,EACA,OAAO;AAGH,SAAS,2BACd,YACS;AACT,SACE,WAAW,eAAe,YAAY,MAAM,mCAC5C,WAAW,SAAS,YACpB,iCAAiC,UAAU,WAAW,QAAQ,EAAE;AAEpE;AAEO,SAAS,kCACd,UACS;AACT,SAAO,UAAU,mBAAmB;AACtC;","names":[]}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modelLogoUrl } from "./model-display";
|
|
1
2
|
import {
|
|
2
3
|
ClaudeProviderAccountAuthoritySnapshotV1,
|
|
3
4
|
WORKSPACE_CLAUDE_PROVIDER_ACCOUNT_AUTHORITY_SNAPSHOT_V1,
|
|
@@ -5003,11 +5004,26 @@ export type GitHubAppApiPort = {
|
|
|
5003
5004
|
}) => Promise<GitHubAppRepositoryBranchPage>;
|
|
5004
5005
|
};
|
|
5005
5006
|
|
|
5007
|
+
export const PromotionalCreditScope = z.object({
|
|
5008
|
+
label: z.string().trim().min(1).max(120),
|
|
5009
|
+
eligibleModelIds: z.array(z.string().trim().min(1).max(200)).min(1).max(40),
|
|
5010
|
+
});
|
|
5011
|
+
export type PromotionalCreditScope = z.infer<typeof PromotionalCreditScope>;
|
|
5012
|
+
|
|
5013
|
+
export const PromotionalCreditBalance = PromotionalCreditScope.extend({
|
|
5014
|
+
grantId: z.string().uuid(),
|
|
5015
|
+
remainingMicros: z.number().int().nonnegative(),
|
|
5016
|
+
});
|
|
5017
|
+
export type PromotionalCreditBalance = z.infer<typeof PromotionalCreditBalance>;
|
|
5018
|
+
|
|
5006
5019
|
export const BillingBalance = z.object({
|
|
5007
5020
|
accountId: z.string().uuid(),
|
|
5008
5021
|
balanceMicros: z.number().int(),
|
|
5009
5022
|
currency: z.literal("usd"),
|
|
5010
5023
|
updatedAt: z.string(),
|
|
5024
|
+
/** General credits, including unrestricted legacy grants. May be negative after use. */
|
|
5025
|
+
generalBalanceMicros: z.number().int().optional(),
|
|
5026
|
+
promotionalCredits: z.array(PromotionalCreditBalance).optional(),
|
|
5011
5027
|
});
|
|
5012
5028
|
export type BillingBalance = z.infer<typeof BillingBalance>;
|
|
5013
5029
|
|
|
@@ -5038,6 +5054,7 @@ export const CreateCheckoutResponse = z.object({
|
|
|
5038
5054
|
url: z.string().url(),
|
|
5039
5055
|
/** The credits this checkout grants once it completes. */
|
|
5040
5056
|
amountUsd: z.number().optional(),
|
|
5057
|
+
promotionalScope: PromotionalCreditScope.optional(),
|
|
5041
5058
|
});
|
|
5042
5059
|
export type CreateCheckoutResponse = z.infer<typeof CreateCheckoutResponse>;
|
|
5043
5060
|
|
|
@@ -5055,6 +5072,7 @@ export const BillingCheckoutStatus = z.object({
|
|
|
5055
5072
|
currency: z.literal("usd"),
|
|
5056
5073
|
/** True when a coupon covered the whole checkout, so nothing was charged. */
|
|
5057
5074
|
free: z.boolean(),
|
|
5075
|
+
promotionalScope: PromotionalCreditScope.optional(),
|
|
5058
5076
|
}),
|
|
5059
5077
|
balance: BillingBalance.nullable(),
|
|
5060
5078
|
});
|
|
@@ -18109,6 +18127,10 @@ export const ClientModel = /* @__PURE__ */ defineModelContractSchema(() =>
|
|
|
18109
18127
|
label: z.string(),
|
|
18110
18128
|
/** Optional curated compact label for dense UI (e.g. mobile composer). */
|
|
18111
18129
|
shortLabel: z.string().min(1).max(64).optional(),
|
|
18130
|
+
logoUrl: z
|
|
18131
|
+
.string()
|
|
18132
|
+
.refine((value) => modelLogoUrl({ id: "", logoUrl: value }) !== null)
|
|
18133
|
+
.optional(),
|
|
18112
18134
|
provider: z.string(), // provider id
|
|
18113
18135
|
providerLabel: z.string(),
|
|
18114
18136
|
api: z.enum(["responses", "chat", "anthropic-messages"]),
|
|
@@ -18229,6 +18251,8 @@ export const WorkspaceModelCatalogModel =
|
|
|
18229
18251
|
/* @__PURE__ */ defineModelContractSchema(() =>
|
|
18230
18252
|
ClientModel.extend({
|
|
18231
18253
|
credentialReadiness: ModelCredentialReadinessV1,
|
|
18254
|
+
/** Current funding status, without exposing the organization's balance. */
|
|
18255
|
+
creditFunding: z.enum(["promotional", "general", "unavailable"]).optional(),
|
|
18232
18256
|
/** Exact workspace-policy verdict without exposing provider identity. */
|
|
18233
18257
|
policyAllowed: z.boolean().optional(),
|
|
18234
18258
|
availability: ModelAvailabilityV1,
|
package/src/model-display.ts
CHANGED
|
@@ -28,10 +28,23 @@ export type ModelDisplayInput =
|
|
|
28
28
|
| {
|
|
29
29
|
id: string;
|
|
30
30
|
label?: string | null | undefined;
|
|
31
|
+
logoUrl?: string | null | undefined;
|
|
31
32
|
upstreamModelId?: string | null | undefined;
|
|
32
33
|
deployment?: { upstreamModelId?: string | null | undefined } | null | undefined;
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
/** Catalog maker logo; remote images must use HTTPS without embedded credentials. */
|
|
37
|
+
export function modelLogoUrl(input: ModelDisplayInput): string | null {
|
|
38
|
+
const value = typeof input === "string" ? undefined : input.logoUrl;
|
|
39
|
+
if (!value || value.length > 2048 || value !== value.trim()) return null;
|
|
40
|
+
try {
|
|
41
|
+
const url = new URL(value);
|
|
42
|
+
return url.protocol === "https:" && !url.username && !url.password ? value : null;
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
35
48
|
const WORDS: Readonly<Record<string, string>> = {
|
|
36
49
|
gpt: "GPT",
|
|
37
50
|
chatgpt: "ChatGPT",
|