rivet-design 0.23.0 → 0.23.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/dist/agent-variants/contracts.d.ts +330 -330
- package/dist/agent-variants/workItemInput.d.ts +192 -192
- package/dist/config/proxy.d.ts +0 -2
- package/dist/config/proxy.d.ts.map +1 -1
- package/dist/config/proxy.js +1 -10
- package/dist/config/proxy.js.map +1 -1
- package/dist/routes/git.d.ts +0 -1
- package/dist/routes/git.d.ts.map +1 -1
- package/dist/routes/git.js +2 -7
- package/dist/routes/git.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -5
- package/dist/server.js.map +1 -1
- package/dist/services/AuthService.d.ts +2 -2
- package/dist/services/CommitMessageGenerator.d.ts +1 -5
- package/dist/services/CommitMessageGenerator.d.ts.map +1 -1
- package/dist/services/CommitMessageGenerator.js +9 -38
- package/dist/services/CommitMessageGenerator.js.map +1 -1
- package/dist/services/IntegrationsClient.d.ts +3 -3
- package/dist/services/LocalGitService.d.ts +0 -3
- package/dist/services/LocalGitService.d.ts.map +1 -1
- package/dist/services/LocalGitService.js +0 -41
- package/dist/services/LocalGitService.js.map +1 -1
- package/dist/services/PRTitleGenerator.d.ts +2 -8
- package/dist/services/PRTitleGenerator.d.ts.map +1 -1
- package/dist/services/PRTitleGenerator.js +12 -74
- package/dist/services/PRTitleGenerator.js.map +1 -1
- package/dist/services/SessionService.d.ts +1 -4
- package/dist/services/SessionService.d.ts.map +1 -1
- package/dist/services/SessionService.js +5 -16
- package/dist/services/SessionService.js.map +1 -1
- package/dist/services/profiles/DesignProfiles.d.ts +30 -30
- package/dist/services/profiles/ProfileImports.d.ts +1 -1
- package/dist/services/profiles/ProfilePlanning.d.ts +4 -4
- package/dist/services/profiles/ReferenceReader.d.ts +3 -3
- package/dist/services/profiles/profileContext.d.ts +1 -1
- package/dist/storage/profiles/ProfilePlans.d.ts +15 -15
- package/dist/storage/profiles/ProfileRecords.d.ts +11 -11
- package/dist/storage/profiles/planSchema.d.ts +4 -4
- package/dist/storage/profiles/schema.d.ts +7 -7
- package/dist/types/cosmos-profile.d.ts +6 -6
- package/dist/types/cosmos.d.ts +10 -10
- package/dist/types/design-profile.d.ts +17 -17
- package/dist/types/guidance-references.d.ts +6 -6
- package/dist/types/guidance.d.ts +80 -80
- package/dist/types/reference-connectors.d.ts +10 -10
- package/dist/types/reference-onboarding.d.ts +63 -63
- package/dist/types/reference-pages.d.ts +10 -10
- package/dist/types/variant-reference.d.ts +4 -4
- package/package.json +2 -1
- package/src/ui/dist/assets/{LibraryEntry-B9ZkJUtN.js → LibraryEntry-BUwOgHmJ.js} +1 -1
- package/src/ui/dist/assets/main-DQKavyjz.js +435 -0
- package/src/ui/dist/index.html +1 -1
- package/dist/prompts/gitPrompts.d.ts +0 -4
- package/dist/prompts/gitPrompts.d.ts.map +0 -1
- package/dist/prompts/gitPrompts.js +0 -61
- package/dist/prompts/gitPrompts.js.map +0 -1
- package/dist/services/GatewayClient.d.ts +0 -44
- package/dist/services/GatewayClient.d.ts.map +0 -1
- package/dist/services/GatewayClient.js +0 -204
- package/dist/services/GatewayClient.js.map +0 -1
- package/src/ui/dist/assets/main-Dls3YqrM.js +0 -435
package/src/ui/dist/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
|
8
8
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
9
9
|
<title>Rivet - The visual editor for design</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/main-
|
|
10
|
+
<script type="module" crossorigin src="/assets/main-DQKavyjz.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/main-CXP-A-qy.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const buildCommitMessagePrompt: (instruction: string, filesChanged: string[], truncatedDiff: string) => string;
|
|
2
|
-
export declare const buildPRTitlePrompt: (truncatedLog: string, filesChanged: string[]) => string;
|
|
3
|
-
export declare const buildPRDescriptionPrompt: (truncatedLog: string, filesChanged: string[], truncatedDiff: string) => string;
|
|
4
|
-
//# sourceMappingURL=gitPrompts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gitPrompts.d.ts","sourceRoot":"","sources":["../../src/prompts/gitPrompts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,GACnC,aAAa,MAAM,EACnB,cAAc,MAAM,EAAE,EACtB,eAAe,MAAM,KACpB,MAgBa,CAAC;AAEjB,eAAO,MAAM,kBAAkB,GAC7B,cAAc,MAAM,EACpB,cAAc,MAAM,EAAE,KACrB,MAeO,CAAC;AAEX,eAAO,MAAM,wBAAwB,GACnC,cAAc,MAAM,EACpB,cAAc,MAAM,EAAE,EACtB,eAAe,MAAM,KACpB,MAoBa,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildPRDescriptionPrompt = exports.buildPRTitlePrompt = exports.buildCommitMessagePrompt = void 0;
|
|
4
|
-
const buildCommitMessagePrompt = (instruction, filesChanged, truncatedDiff) => `You are writing a git commit message. Given the user's instruction and the git diff, write a concise commit message.
|
|
5
|
-
|
|
6
|
-
Rules:
|
|
7
|
-
- Single line only, max 50 characters
|
|
8
|
-
- Imperative mood (e.g. "Add", "Fix", "Update")
|
|
9
|
-
- No quotes around the message
|
|
10
|
-
- No conventional commit prefixes (no "feat:", "fix:", etc.)
|
|
11
|
-
- If the diff is large, focus on the most important change
|
|
12
|
-
|
|
13
|
-
User instruction: ${instruction}
|
|
14
|
-
|
|
15
|
-
Files changed: ${filesChanged.join(', ')}
|
|
16
|
-
|
|
17
|
-
Diff:
|
|
18
|
-
${truncatedDiff}
|
|
19
|
-
|
|
20
|
-
Commit message:`;
|
|
21
|
-
exports.buildCommitMessagePrompt = buildCommitMessagePrompt;
|
|
22
|
-
const buildPRTitlePrompt = (truncatedLog, filesChanged) => `You are writing a GitHub pull request title. Given the commit messages and files changed, write a concise PR title.
|
|
23
|
-
|
|
24
|
-
Rules:
|
|
25
|
-
- Max 72 characters
|
|
26
|
-
- No quotes around the title
|
|
27
|
-
- No conventional commit prefixes (no "feat:", "fix:", etc.)
|
|
28
|
-
- Summarize the overall change, not individual commits
|
|
29
|
-
- Use imperative mood (e.g. "Add", "Fix", "Update")
|
|
30
|
-
- Return ONLY the title, nothing else
|
|
31
|
-
|
|
32
|
-
Commit messages:
|
|
33
|
-
${truncatedLog}
|
|
34
|
-
|
|
35
|
-
Files changed: ${filesChanged.join(', ')}
|
|
36
|
-
|
|
37
|
-
PR title:`;
|
|
38
|
-
exports.buildPRTitlePrompt = buildPRTitlePrompt;
|
|
39
|
-
const buildPRDescriptionPrompt = (truncatedLog, filesChanged, truncatedDiff) => `You are writing a GitHub pull request description. Given the commit messages, files changed, and diff, write a clear and useful PR description.
|
|
40
|
-
|
|
41
|
-
Rules:
|
|
42
|
-
- Use markdown formatting
|
|
43
|
-
- Start with a brief summary paragraph of what the PR does (2-3 sentences max)
|
|
44
|
-
- Then add a "## Changes" section with bullet points for key changes
|
|
45
|
-
- If there are notable implementation details, add a brief "## Notes" section
|
|
46
|
-
- Keep it concise — no filler, no boilerplate sections that aren't relevant
|
|
47
|
-
- Do NOT include a title (that's generated separately)
|
|
48
|
-
- End with: "Made with [Rivet](https://rivet.design)"
|
|
49
|
-
- Return ONLY the description, nothing else
|
|
50
|
-
|
|
51
|
-
Commit messages:
|
|
52
|
-
${truncatedLog}
|
|
53
|
-
|
|
54
|
-
Files changed: ${filesChanged.join(', ')}
|
|
55
|
-
|
|
56
|
-
Diff:
|
|
57
|
-
${truncatedDiff}
|
|
58
|
-
|
|
59
|
-
PR description:`;
|
|
60
|
-
exports.buildPRDescriptionPrompt = buildPRDescriptionPrompt;
|
|
61
|
-
//# sourceMappingURL=gitPrompts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gitPrompts.js","sourceRoot":"","sources":["../../src/prompts/gitPrompts.ts"],"names":[],"mappings":";;;AAAO,MAAM,wBAAwB,GAAG,CACtC,WAAmB,EACnB,YAAsB,EACtB,aAAqB,EACb,EAAE,CAAC;;;;;;;;;oBASO,WAAW;;iBAEd,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGtC,aAAa;;gBAEC,CAAC;AApBJ,QAAA,wBAAwB,4BAoBpB;AAEV,MAAM,kBAAkB,GAAG,CAChC,YAAoB,EACpB,YAAsB,EACd,EAAE,CAAC;;;;;;;;;;;EAWX,YAAY;;iBAEG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;UAE9B,CAAC;AAlBE,QAAA,kBAAkB,sBAkBpB;AAEJ,MAAM,wBAAwB,GAAG,CACtC,YAAoB,EACpB,YAAsB,EACtB,aAAqB,EACb,EAAE,CAAC;;;;;;;;;;;;;EAaX,YAAY;;iBAEG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGtC,aAAa;;gBAEC,CAAC;AAxBJ,QAAA,wBAAwB,4BAwBpB"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
type GatewayRequestOptions = {
|
|
2
|
-
model: string;
|
|
3
|
-
maxTokens: number;
|
|
4
|
-
temperature: number;
|
|
5
|
-
prompt: string;
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
};
|
|
8
|
-
export type GatewayImageMediaType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif';
|
|
9
|
-
export type GatewayImageContent = {
|
|
10
|
-
mediaType: GatewayImageMediaType;
|
|
11
|
-
data: string;
|
|
12
|
-
};
|
|
13
|
-
type GatewayToolUseOptions = {
|
|
14
|
-
model: string;
|
|
15
|
-
maxTokens: number;
|
|
16
|
-
temperature: number;
|
|
17
|
-
system: string;
|
|
18
|
-
prompt: string;
|
|
19
|
-
tool: {
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
input_schema: Record<string, unknown>;
|
|
23
|
-
strict?: boolean;
|
|
24
|
-
};
|
|
25
|
-
cacheSystemPrompt?: boolean;
|
|
26
|
-
images?: GatewayImageContent[];
|
|
27
|
-
timeoutMs?: number;
|
|
28
|
-
};
|
|
29
|
-
export declare const asReasonText: (value: unknown) => string;
|
|
30
|
-
export declare class GatewayClient {
|
|
31
|
-
private configManager;
|
|
32
|
-
private gatewayUrl;
|
|
33
|
-
private proxyUrl;
|
|
34
|
-
constructor(gatewayUrl?: string, proxyUrl?: string);
|
|
35
|
-
sendMessage(options: GatewayRequestOptions): Promise<string>;
|
|
36
|
-
sendToolUse<TInput>(options: GatewayToolUseOptions): Promise<TInput>;
|
|
37
|
-
scoreImage<TInput>(options: GatewayToolUseOptions & {
|
|
38
|
-
images: GatewayImageContent[];
|
|
39
|
-
}): Promise<TInput>;
|
|
40
|
-
private postMessages;
|
|
41
|
-
private refreshAccessToken;
|
|
42
|
-
}
|
|
43
|
-
export {};
|
|
44
|
-
//# sourceMappingURL=GatewayClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayClient.d.ts","sourceRoot":"","sources":["../../src/services/GatewayClient.ts"],"names":[],"mappings":"AAOA,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC/B,WAAW,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,CAAC;AAE1D,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,qBAAqB,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAsBF,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,MAsB7C,CAAC;AAEF,qBAAa,aAAa;IACxB,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAS;gBAEb,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAK5C,WAAW,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB5D,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAyCpE,UAAU,CAAC,MAAM,EACrB,OAAO,EAAE,qBAAqB,GAAG;QAAE,MAAM,EAAE,mBAAmB,EAAE,CAAA;KAAE,GACjE,OAAO,CAAC,MAAM,CAAC;YAIJ,YAAY;YAmFZ,kBAAkB;CAoCjC"}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GatewayClient = exports.asReasonText = void 0;
|
|
4
|
-
const authUpdate_1 = require("./authUpdate");
|
|
5
|
-
const logger_1 = require("../utils/logger");
|
|
6
|
-
const ConfigManager_1 = require("./ConfigManager");
|
|
7
|
-
const proxy_1 = require("../config/proxy");
|
|
8
|
-
const log = (0, logger_1.createLogger)('GatewayClient');
|
|
9
|
-
const buildUserContent = (prompt, images) => {
|
|
10
|
-
if (!images || images.length === 0) {
|
|
11
|
-
return prompt;
|
|
12
|
-
}
|
|
13
|
-
return [
|
|
14
|
-
...images.map((image) => ({
|
|
15
|
-
type: 'image',
|
|
16
|
-
source: {
|
|
17
|
-
type: 'base64',
|
|
18
|
-
media_type: image.mediaType,
|
|
19
|
-
data: image.data,
|
|
20
|
-
},
|
|
21
|
-
})),
|
|
22
|
-
{ type: 'text', text: prompt },
|
|
23
|
-
];
|
|
24
|
-
};
|
|
25
|
-
const asReasonText = (value) => {
|
|
26
|
-
if (typeof value === 'string') {
|
|
27
|
-
return value;
|
|
28
|
-
}
|
|
29
|
-
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
30
|
-
return String(value);
|
|
31
|
-
}
|
|
32
|
-
if (value && typeof value === 'object') {
|
|
33
|
-
const candidate = value;
|
|
34
|
-
if (typeof candidate.message === 'string') {
|
|
35
|
-
return candidate.message;
|
|
36
|
-
}
|
|
37
|
-
if (typeof candidate.error === 'string') {
|
|
38
|
-
return candidate.error;
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
return JSON.stringify(value);
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
return '';
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return '';
|
|
48
|
-
};
|
|
49
|
-
exports.asReasonText = asReasonText;
|
|
50
|
-
class GatewayClient {
|
|
51
|
-
configManager = (0, ConfigManager_1.getConfigManager)();
|
|
52
|
-
gatewayUrl;
|
|
53
|
-
proxyUrl;
|
|
54
|
-
constructor(gatewayUrl, proxyUrl) {
|
|
55
|
-
this.gatewayUrl = gatewayUrl || proxy_1.GATEWAY_URL;
|
|
56
|
-
this.proxyUrl = proxyUrl || proxy_1.PROXY_URL;
|
|
57
|
-
}
|
|
58
|
-
async sendMessage(options) {
|
|
59
|
-
const result = await this.postMessages({
|
|
60
|
-
model: options.model,
|
|
61
|
-
max_tokens: options.maxTokens,
|
|
62
|
-
temperature: options.temperature,
|
|
63
|
-
messages: [{ role: 'user', content: options.prompt }],
|
|
64
|
-
}, 0, { timeoutMs: options.timeoutMs });
|
|
65
|
-
const content = result.content?.[0]?.text;
|
|
66
|
-
if (!content) {
|
|
67
|
-
throw new Error('No response content from LLM');
|
|
68
|
-
}
|
|
69
|
-
return content;
|
|
70
|
-
}
|
|
71
|
-
async sendToolUse(options) {
|
|
72
|
-
const systemContent = options.cacheSystemPrompt
|
|
73
|
-
? [
|
|
74
|
-
{
|
|
75
|
-
type: 'text',
|
|
76
|
-
text: options.system,
|
|
77
|
-
cache_control: { type: 'ephemeral' },
|
|
78
|
-
},
|
|
79
|
-
]
|
|
80
|
-
: options.system;
|
|
81
|
-
const result = await this.postMessages({
|
|
82
|
-
model: options.model,
|
|
83
|
-
max_tokens: options.maxTokens,
|
|
84
|
-
temperature: options.temperature,
|
|
85
|
-
system: systemContent,
|
|
86
|
-
messages: [
|
|
87
|
-
{
|
|
88
|
-
role: 'user',
|
|
89
|
-
content: buildUserContent(options.prompt, options.images),
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
tools: [options.tool],
|
|
93
|
-
tool_choice: { type: 'tool', name: options.tool.name },
|
|
94
|
-
}, 0, {
|
|
95
|
-
enableCaching: options.cacheSystemPrompt,
|
|
96
|
-
timeoutMs: options.timeoutMs,
|
|
97
|
-
});
|
|
98
|
-
const toolUse = result.content?.find((b) => b.type === 'tool_use');
|
|
99
|
-
if (!toolUse || toolUse.input === undefined) {
|
|
100
|
-
throw new Error('Model did not return a tool_use block');
|
|
101
|
-
}
|
|
102
|
-
return toolUse.input;
|
|
103
|
-
}
|
|
104
|
-
async scoreImage(options) {
|
|
105
|
-
return this.sendToolUse(options);
|
|
106
|
-
}
|
|
107
|
-
async postMessages(body, retryCount, options) {
|
|
108
|
-
const authToken = this.configManager.getAuthToken();
|
|
109
|
-
if (!authToken) {
|
|
110
|
-
throw new Error('Not authenticated. Please run `rivet login` to authenticate.');
|
|
111
|
-
}
|
|
112
|
-
const headers = {
|
|
113
|
-
Authorization: `Bearer ${authToken}`,
|
|
114
|
-
'Content-Type': 'application/json',
|
|
115
|
-
'anthropic-version': '2023-06-01',
|
|
116
|
-
};
|
|
117
|
-
if (options?.enableCaching) {
|
|
118
|
-
headers['anthropic-beta'] = 'prompt-caching-2024-07-31';
|
|
119
|
-
}
|
|
120
|
-
const abortController = options?.timeoutMs
|
|
121
|
-
? new AbortController()
|
|
122
|
-
: undefined;
|
|
123
|
-
const timeout = abortController
|
|
124
|
-
? setTimeout(() => abortController.abort(), options?.timeoutMs)
|
|
125
|
-
: undefined;
|
|
126
|
-
let response;
|
|
127
|
-
try {
|
|
128
|
-
response = await fetch(`${this.gatewayUrl}/v1/messages`, {
|
|
129
|
-
method: 'POST',
|
|
130
|
-
headers,
|
|
131
|
-
body: JSON.stringify({ ...body, service_tier: 'auto' }),
|
|
132
|
-
signal: abortController?.signal,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
if (timeout) {
|
|
137
|
-
clearTimeout(timeout);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (response.status === 401 && retryCount === 0) {
|
|
141
|
-
const errBody = await response.json().catch(() => ({}));
|
|
142
|
-
const reason = (0, exports.asReasonText)(errBody.message ?? errBody.error ?? errBody);
|
|
143
|
-
if (reason.includes('SPEND_LIMIT_EXCEEDED:')) {
|
|
144
|
-
throw new Error(reason);
|
|
145
|
-
}
|
|
146
|
-
log.warn('Token expired, attempting to refresh...');
|
|
147
|
-
const isRefreshed = await this.refreshAccessToken();
|
|
148
|
-
if (isRefreshed) {
|
|
149
|
-
return this.postMessages(body, retryCount + 1, options);
|
|
150
|
-
}
|
|
151
|
-
throw new Error('Authentication expired. Please run `rivet logout` and `rivet login` to re-authenticate.');
|
|
152
|
-
}
|
|
153
|
-
if (response.status === 429) {
|
|
154
|
-
const error = await response.json().catch(() => ({}));
|
|
155
|
-
const reason = (0, exports.asReasonText)(error.message ?? error.error ?? error);
|
|
156
|
-
if (reason.includes('SPEND_LIMIT_EXCEEDED:')) {
|
|
157
|
-
throw new Error(reason);
|
|
158
|
-
}
|
|
159
|
-
throw new Error(reason || 'Rate limit exceeded. Please try again shortly.');
|
|
160
|
-
}
|
|
161
|
-
if (!response.ok) {
|
|
162
|
-
const errorText = await response
|
|
163
|
-
.text()
|
|
164
|
-
.catch(() => 'Unable to read error');
|
|
165
|
-
throw new Error(`Gateway request failed (${response.status}): ${errorText}`);
|
|
166
|
-
}
|
|
167
|
-
return response.json();
|
|
168
|
-
}
|
|
169
|
-
async refreshAccessToken() {
|
|
170
|
-
const updateAuth = (0, authUpdate_1.captureAuthUpdate)(this.configManager);
|
|
171
|
-
const refreshToken = this.configManager.getRefreshToken();
|
|
172
|
-
if (!refreshToken) {
|
|
173
|
-
log.warn('No refresh token available');
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
try {
|
|
177
|
-
log.info('Refreshing access token...');
|
|
178
|
-
const response = await fetch(`${this.proxyUrl}/api/auth/refresh`, {
|
|
179
|
-
method: 'POST',
|
|
180
|
-
headers: {
|
|
181
|
-
'Content-Type': 'application/json',
|
|
182
|
-
},
|
|
183
|
-
body: JSON.stringify({ refreshToken }),
|
|
184
|
-
});
|
|
185
|
-
if (!response.ok) {
|
|
186
|
-
log.warn('Token refresh failed');
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
const result = await response.json();
|
|
190
|
-
if (result.success && result.token) {
|
|
191
|
-
updateAuth(result);
|
|
192
|
-
log.info('Access token refreshed successfully');
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
log.warn('Error refreshing token:', error);
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
exports.GatewayClient = GatewayClient;
|
|
204
|
-
//# sourceMappingURL=GatewayClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayClient.js","sourceRoot":"","sources":["../../src/services/GatewayClient.ts"],"names":[],"mappings":";;;AAAA,6CAAiD;AACjD,4CAA+C;AAC/C,mDAAmD;AACnD,2CAAyD;AAEzD,MAAM,GAAG,GAAG,IAAA,qBAAY,EAAC,eAAe,CAAC,CAAC;AAmC1C,MAAM,gBAAgB,GAAG,CACvB,MAAc,EACd,MAA8B,EACW,EAAE;IAC3C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO;QACL,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACxB,IAAI,EAAE,OAAO;YACb,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,KAAK,CAAC,SAAS;gBAC3B,IAAI,EAAE,KAAK,CAAC,IAAI;aACjB;SACF,CAAC,CAAC;QACH,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;KAC/B,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,YAAY,GAAG,CAAC,KAAc,EAAU,EAAE;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,SAAS,GAAG,KAA+C,CAAC;QAClE,IAAI,OAAO,SAAS,CAAC,O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