ns-kiro-core 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/LICENSE +22 -0
- package/README.md +51 -0
- package/dist/blocks.d.ts +32 -0
- package/dist/blocks.js +83 -0
- package/dist/blocks.js.map +1 -0
- package/dist/bracket-tool-parser.d.ts +11 -0
- package/dist/bracket-tool-parser.js +78 -0
- package/dist/bracket-tool-parser.js.map +1 -0
- package/dist/cost.d.ts +3 -0
- package/dist/cost.js +10 -0
- package/dist/cost.js.map +1 -0
- package/dist/debug.d.ts +6 -0
- package/dist/debug.js +63 -0
- package/dist/debug.js.map +1 -0
- package/dist/effort.d.ts +36 -0
- package/dist/effort.js +138 -0
- package/dist/effort.js.map +1 -0
- package/dist/endpoints.d.ts +8 -0
- package/dist/endpoints.js +43 -0
- package/dist/endpoints.js.map +1 -0
- package/dist/event-parser.d.ts +49 -0
- package/dist/event-parser.js +56 -0
- package/dist/event-parser.js.map +1 -0
- package/dist/history-validator.d.ts +91 -0
- package/dist/history-validator.js +370 -0
- package/dist/history-validator.js.map +1 -0
- package/dist/history.d.ts +21 -0
- package/dist/history.js +130 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/invoke-tool-parser.d.ts +16 -0
- package/dist/invoke-tool-parser.js +152 -0
- package/dist/invoke-tool-parser.js.map +1 -0
- package/dist/kiro-cli.d.ts +31 -0
- package/dist/kiro-cli.js +308 -0
- package/dist/kiro-cli.js.map +1 -0
- package/dist/kiro-ide.d.ts +12 -0
- package/dist/kiro-ide.js +74 -0
- package/dist/kiro-ide.js.map +1 -0
- package/dist/management.d.ts +34 -0
- package/dist/management.js +226 -0
- package/dist/management.js.map +1 -0
- package/dist/models.d.ts +58 -0
- package/dist/models.js +462 -0
- package/dist/models.js.map +1 -0
- package/dist/oauth.d.ts +50 -0
- package/dist/oauth.js +295 -0
- package/dist/oauth.js.map +1 -0
- package/dist/retry.d.ts +74 -0
- package/dist/retry.js +156 -0
- package/dist/retry.js.map +1 -0
- package/dist/stream.d.ts +36 -0
- package/dist/stream.js +898 -0
- package/dist/stream.js.map +1 -0
- package/dist/thinking-parser.d.ts +21 -0
- package/dist/thinking-parser.js +150 -0
- package/dist/thinking-parser.js.map +1 -0
- package/dist/token-type.d.ts +18 -0
- package/dist/token-type.js +45 -0
- package/dist/token-type.js.map +1 -0
- package/dist/tokenizer.d.ts +1 -0
- package/dist/tokenizer.js +19 -0
- package/dist/tokenizer.js.map +1 -0
- package/dist/transform.d.ts +111 -0
- package/dist/transform.js +268 -0
- package/dist/transform.js.map +1 -0
- package/dist/truncation.d.ts +3 -0
- package/dist/truncation.js +12 -0
- package/dist/truncation.js.map +1 -0
- package/dist/types.d.ts +159 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/usage.d.ts +86 -0
- package/dist/usage.js +85 -0
- package/dist/usage.js.map +1 -0
- package/package.json +31 -0
package/dist/oauth.js
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
// Kiro credentials and token refresh.
|
|
2
|
+
//
|
|
3
|
+
// Auth methods:
|
|
4
|
+
// - "idc": AWS Builder ID or IAM Identity Center (SSO)
|
|
5
|
+
// - "desktop": Google/GitHub social login via the Kiro auth service
|
|
6
|
+
// - "external-idp": enterprise OIDC (e.g. Okta)
|
|
7
|
+
// - "apikey": a long-lived `ksk_` bearer token
|
|
8
|
+
//
|
|
9
|
+
// Sessions are established by `kiro-cli login` or the Kiro IDE; this package
|
|
10
|
+
// reads and refreshes them rather than running its own interactive login.
|
|
11
|
+
import { formatSafeError } from "./debug.js";
|
|
12
|
+
import { resolveApiRegion } from "./endpoints.js";
|
|
13
|
+
import { getKiroIdeCredentials } from "./kiro-ide.js";
|
|
14
|
+
export const SSO_OIDC_ENDPOINT = "https://oidc.us-east-1.amazonaws.com";
|
|
15
|
+
export const BUILDER_ID_START_URL = "https://view.awsapps.com/start";
|
|
16
|
+
export const BUILDER_ID_PROFILE_ARN = "arn:aws:codewhisperer:us-east-1:638616132270:profile/AAAACCCCXXXX";
|
|
17
|
+
export const KIRO_DESKTOP_REFRESH_URL = "https://prod.{region}.auth.desktop.kiro.dev/refreshToken";
|
|
18
|
+
export const SSO_SCOPES = [
|
|
19
|
+
"codewhisperer:completions",
|
|
20
|
+
"codewhisperer:analysis",
|
|
21
|
+
"codewhisperer:conversations",
|
|
22
|
+
"codewhisperer:transformations",
|
|
23
|
+
"codewhisperer:taskassist",
|
|
24
|
+
];
|
|
25
|
+
const EXPIRES_BUFFER_MS = 5 * 60 * 1000;
|
|
26
|
+
export const KIRO_DESKTOP_USER_AGENT = "Kiro-Desktop/0.2.13 (darwin; arm64)";
|
|
27
|
+
export function kiroUserAgent(service, sdkVersion) {
|
|
28
|
+
return {
|
|
29
|
+
"User-Agent": `aws-sdk-js/3.714.0 os/macos/24.3.0 lang/js md/nodejs/22.14.0 api/${service}/3.714.0 exec-env/kiro-cli/2.7.0 m/E`,
|
|
30
|
+
"amz-sdk-invocation-id": "00000000-0000-0000-0000-000000000000",
|
|
31
|
+
"amz-sdk-request": `attempt=1; max=${sdkVersion}`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function kiroAuthHeaders(token) {
|
|
35
|
+
const headers = { Authorization: `Bearer ${token}` };
|
|
36
|
+
if (isApiKey(token))
|
|
37
|
+
headers.tokentype = "API_KEY";
|
|
38
|
+
return headers;
|
|
39
|
+
}
|
|
40
|
+
export function isApiKey(token) {
|
|
41
|
+
return token.startsWith("ksk_");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Validate a `ksk_` API key and resolve the profile it bills against.
|
|
45
|
+
*
|
|
46
|
+
* Unlike an SSO session this needs no browser round trip, so it is the one
|
|
47
|
+
* credential this package can establish on its own: GetProfile with an empty
|
|
48
|
+
* body returns the key's own profile, which both proves the key works and
|
|
49
|
+
* supplies the ARN every runtime request needs.
|
|
50
|
+
*/
|
|
51
|
+
export async function loginKiroWithApiKey(apiKey, onProgress) {
|
|
52
|
+
if (!apiKey.startsWith("ksk_")) {
|
|
53
|
+
throw new Error("Invalid API key format. Kiro API keys start with 'ksk_'.");
|
|
54
|
+
}
|
|
55
|
+
onProgress?.("Validating API key...");
|
|
56
|
+
// API keys are issued for the us-east-1 control plane.
|
|
57
|
+
const region = "us-east-1";
|
|
58
|
+
const managementUrl = `https://management.${resolveApiRegion(region)}.kiro.dev/`;
|
|
59
|
+
const response = await fetch(managementUrl, {
|
|
60
|
+
method: "POST",
|
|
61
|
+
headers: {
|
|
62
|
+
"Content-Type": "application/x-amz-json-1.0",
|
|
63
|
+
"X-Amz-Target": "AmazonCodeWhispererService.GetProfile",
|
|
64
|
+
...kiroAuthHeaders(apiKey),
|
|
65
|
+
...kiroUserAgent("codewhispererruntime", "F,C"),
|
|
66
|
+
},
|
|
67
|
+
body: "{}",
|
|
68
|
+
});
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
let detail = "";
|
|
71
|
+
try {
|
|
72
|
+
detail = await response.text();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
detail = "";
|
|
76
|
+
}
|
|
77
|
+
if (response.status === 401 || response.status === 403 || /Invalid token/i.test(detail)) {
|
|
78
|
+
throw new Error("API key was rejected by Kiro. Check that the key is valid and not expired.");
|
|
79
|
+
}
|
|
80
|
+
throw new Error(`Kiro GetProfile failed: ${response.status} ${response.statusText} ${detail}`.trim());
|
|
81
|
+
}
|
|
82
|
+
const data = (await response.json());
|
|
83
|
+
const profileArn = data.profile?.arn;
|
|
84
|
+
return {
|
|
85
|
+
access: apiKey,
|
|
86
|
+
refresh: `${apiKey}|apikey`,
|
|
87
|
+
expires: Date.now() + 365 * 24 * 60 * 60 * 1000,
|
|
88
|
+
clientId: "",
|
|
89
|
+
clientSecret: "",
|
|
90
|
+
region,
|
|
91
|
+
authMethod: "apikey",
|
|
92
|
+
...(profileArn ? { profileArn } : {}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function isExpired(credentials) {
|
|
96
|
+
return Date.now() >= credentials.expires;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Refresh a session and kick off a catalog refresh for its region. The catalog
|
|
100
|
+
* call is deliberately not awaited: a stale catalog degrades model metadata,
|
|
101
|
+
* while a slow one would delay every request that had to reauthenticate.
|
|
102
|
+
*/
|
|
103
|
+
export async function refreshKiroToken(credentials) {
|
|
104
|
+
const refreshed = await refreshKiroTokenInternal(credentials);
|
|
105
|
+
if (!process.env.VITEST) {
|
|
106
|
+
try {
|
|
107
|
+
const { updateKiroModelsCache } = await import("./models.js");
|
|
108
|
+
const region = resolveApiRegion(refreshed.region);
|
|
109
|
+
updateKiroModelsCache(refreshed.access, region, refreshed.profileArn).catch((error) => {
|
|
110
|
+
console.warn(`[kiro-core] Failed to refresh Kiro model catalog in ${region}: ${formatSafeError(error)}`);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
console.warn(`[kiro-core] Failed to start Kiro model catalog refresh: ${formatSafeError(error)}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return refreshed;
|
|
118
|
+
}
|
|
119
|
+
async function refreshKiroTokenInternal(credentials) {
|
|
120
|
+
const { getKiroCliCredentials, getKiroCliCredentialsAllowExpired, saveKiroCliCredentials, getKiroCliSocialToken, getKiroCliSocialTokenAllowExpired, } = await import("./kiro-cli.js");
|
|
121
|
+
const credentialAuthMethod = credentials.authMethod ?? (credentials.refresh.split("|").at(-1) === "desktop" ? "desktop" : "idc");
|
|
122
|
+
const getValidCliCredentials = () => {
|
|
123
|
+
if (credentialAuthMethod === "desktop")
|
|
124
|
+
return getKiroCliSocialToken();
|
|
125
|
+
const cliCreds = getKiroCliCredentials();
|
|
126
|
+
return cliCreds?.authMethod === "idc" ? cliCreds : undefined;
|
|
127
|
+
};
|
|
128
|
+
const getExpiredCliCredentials = () => {
|
|
129
|
+
if (credentialAuthMethod === "desktop")
|
|
130
|
+
return getKiroCliSocialTokenAllowExpired();
|
|
131
|
+
const cliCreds = getKiroCliCredentialsAllowExpired();
|
|
132
|
+
return cliCreds?.authMethod === "idc" ? cliCreds : undefined;
|
|
133
|
+
};
|
|
134
|
+
// API key credentials are long-lived bearer tokens — there is nothing to
|
|
135
|
+
// refresh. Return them unchanged so the same key keeps being used.
|
|
136
|
+
if (credentials.authMethod === "apikey" || isApiKey(credentials.access))
|
|
137
|
+
return credentials;
|
|
138
|
+
// Kiro IDE credentials are IDC credentials. Only consult them for IDC
|
|
139
|
+
// credential refresh — never replace a stored social/desktop session with
|
|
140
|
+
// the IDE's potentially unrelated account.
|
|
141
|
+
if (credentialAuthMethod === "idc") {
|
|
142
|
+
const ideCreds = getKiroIdeCredentials();
|
|
143
|
+
if (ideCreds)
|
|
144
|
+
return ideCreds;
|
|
145
|
+
}
|
|
146
|
+
// Prefer a fresh CLI token only when it belongs to the same auth family.
|
|
147
|
+
const preCheckCreds = getValidCliCredentials();
|
|
148
|
+
if (preCheckCreds)
|
|
149
|
+
return preCheckCreds;
|
|
150
|
+
try {
|
|
151
|
+
const refreshed = await refreshKiroTokenDirect(credentials);
|
|
152
|
+
// Write refreshed tokens back to kiro-cli's store so both stay in sync.
|
|
153
|
+
saveKiroCliCredentials(refreshed);
|
|
154
|
+
return refreshed;
|
|
155
|
+
}
|
|
156
|
+
catch (refreshError) {
|
|
157
|
+
// The CLI may have rotated the refresh token between the pre-check and the
|
|
158
|
+
// network call. Re-read only the matching auth family.
|
|
159
|
+
const retryCreds = getValidCliCredentials();
|
|
160
|
+
if (retryCreds)
|
|
161
|
+
return retryCreds;
|
|
162
|
+
// The CLI may have a newer refresh token with an expired access token.
|
|
163
|
+
const expiredCliCreds = getExpiredCliCredentials();
|
|
164
|
+
if (expiredCliCreds && expiredCliCreds.refresh !== credentials.refresh) {
|
|
165
|
+
try {
|
|
166
|
+
const refreshedFromCli = await refreshKiroTokenDirect(expiredCliCreds);
|
|
167
|
+
saveKiroCliCredentials(refreshedFromCli);
|
|
168
|
+
return refreshedFromCli;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// Also failed; continue to the remaining fallbacks.
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// `expires` carries a 5-minute buffer, so the actual token may still work.
|
|
175
|
+
const actualExpiry = credentials.expires + EXPIRES_BUFFER_MS;
|
|
176
|
+
if (credentials.access && Date.now() < actualExpiry) {
|
|
177
|
+
return { ...credentials, expires: actualExpiry };
|
|
178
|
+
}
|
|
179
|
+
throw refreshError;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async function refreshKiroTokenDirect(credentials) {
|
|
183
|
+
const parts = credentials.refresh.split("|");
|
|
184
|
+
const refreshToken = parts[0] ?? "";
|
|
185
|
+
const authMethod = (parts[parts.length - 1] ?? "idc");
|
|
186
|
+
const region = credentials.region || "us-east-1";
|
|
187
|
+
if (authMethod === "apikey")
|
|
188
|
+
return credentials;
|
|
189
|
+
if (authMethod === "desktop") {
|
|
190
|
+
// Kiro desktop app tokens use a different refresh endpoint.
|
|
191
|
+
const url = KIRO_DESKTOP_REFRESH_URL.replace("{region}", region);
|
|
192
|
+
const response = await fetch(url, {
|
|
193
|
+
method: "POST",
|
|
194
|
+
headers: { "Content-Type": "application/json", "User-Agent": KIRO_DESKTOP_USER_AGENT },
|
|
195
|
+
body: JSON.stringify({ refreshToken }),
|
|
196
|
+
});
|
|
197
|
+
if (!response.ok)
|
|
198
|
+
throw new Error(`Desktop token refresh failed: ${response.status}`);
|
|
199
|
+
const data = (await response.json());
|
|
200
|
+
if (!data.accessToken)
|
|
201
|
+
throw new Error("Desktop token refresh: missing accessToken");
|
|
202
|
+
return {
|
|
203
|
+
refresh: `${data.refreshToken || refreshToken}|desktop`,
|
|
204
|
+
access: data.accessToken,
|
|
205
|
+
expires: Date.now() + data.expiresIn * 1000 - EXPIRES_BUFFER_MS,
|
|
206
|
+
clientId: "",
|
|
207
|
+
clientSecret: "",
|
|
208
|
+
region,
|
|
209
|
+
authMethod: "desktop",
|
|
210
|
+
profileArn: data.profileArn || credentials.profileArn,
|
|
211
|
+
startUrl: credentials.startUrl,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
// External IdP (enterprise OIDC, e.g. Okta) — standard public-client refresh
|
|
215
|
+
// against the customer's own token endpoint. kiro-cli does the same:
|
|
216
|
+
// form-encoded grant_type/client_id/refresh_token, snake_case response, and
|
|
217
|
+
// no client secret because the OIDC app is a public PKCE client.
|
|
218
|
+
if (authMethod === "external-idp") {
|
|
219
|
+
const idpClientId = parts[1] ?? "";
|
|
220
|
+
const tokenEndpoint = parts[2] ?? "";
|
|
221
|
+
if (!tokenEndpoint)
|
|
222
|
+
throw new Error("External IdP token refresh: missing token endpoint");
|
|
223
|
+
const response = await fetch(tokenEndpoint, {
|
|
224
|
+
method: "POST",
|
|
225
|
+
headers: {
|
|
226
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
227
|
+
Accept: "application/json",
|
|
228
|
+
"User-Agent": "kiro-core",
|
|
229
|
+
},
|
|
230
|
+
body: new URLSearchParams({
|
|
231
|
+
grant_type: "refresh_token",
|
|
232
|
+
client_id: idpClientId,
|
|
233
|
+
refresh_token: refreshToken,
|
|
234
|
+
}).toString(),
|
|
235
|
+
});
|
|
236
|
+
if (!response.ok)
|
|
237
|
+
throw new Error(`External IdP token refresh failed: ${response.status}`);
|
|
238
|
+
const data = (await response.json());
|
|
239
|
+
if (!data.access_token)
|
|
240
|
+
throw new Error("External IdP token refresh: missing access_token");
|
|
241
|
+
const expiresIn = typeof data.expires_in === "number" ? data.expires_in : 3600;
|
|
242
|
+
return {
|
|
243
|
+
refresh: `${data.refresh_token || refreshToken}|${idpClientId}|${tokenEndpoint}|external-idp`,
|
|
244
|
+
access: data.access_token,
|
|
245
|
+
expires: Date.now() + expiresIn * 1000 - EXPIRES_BUFFER_MS,
|
|
246
|
+
clientId: idpClientId,
|
|
247
|
+
clientSecret: "",
|
|
248
|
+
region,
|
|
249
|
+
authMethod: "external-idp",
|
|
250
|
+
profileArn: credentials.profileArn,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
// IDC auth method — SSO OIDC refresh.
|
|
254
|
+
const clientId = parts[1] ?? "";
|
|
255
|
+
const clientSecret = parts[2] ?? "";
|
|
256
|
+
const ssoEndpoint = `https://oidc.${region}.amazonaws.com`;
|
|
257
|
+
const response = await fetch(`${ssoEndpoint}/token`, {
|
|
258
|
+
method: "POST",
|
|
259
|
+
headers: { "Content-Type": "application/json", ...kiroUserAgent("ssooidc", "E") },
|
|
260
|
+
body: JSON.stringify({ clientId, clientSecret, refreshToken, grantType: "refresh_token" }),
|
|
261
|
+
});
|
|
262
|
+
if (!response.ok)
|
|
263
|
+
throw new Error(`Token refresh failed: ${response.status}`);
|
|
264
|
+
const data = (await response.json());
|
|
265
|
+
return {
|
|
266
|
+
refresh: `${data.refreshToken}|${clientId}|${clientSecret}|idc`,
|
|
267
|
+
access: data.accessToken,
|
|
268
|
+
expires: Date.now() + data.expiresIn * 1000 - EXPIRES_BUFFER_MS,
|
|
269
|
+
clientId,
|
|
270
|
+
clientSecret,
|
|
271
|
+
region,
|
|
272
|
+
authMethod: "idc",
|
|
273
|
+
profileArn: credentials.profileArn,
|
|
274
|
+
startUrl: credentials.startUrl,
|
|
275
|
+
isEnterprise: credentials.isEnterprise,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Resolve a usable session from the stores this machine already has: the
|
|
280
|
+
* kiro-cli database first, then the Kiro IDE's token file. Expired material is
|
|
281
|
+
* accepted and refreshed rather than rejected, because a refresh token outlives
|
|
282
|
+
* its access token and rejecting here would ask the user to log in again for a
|
|
283
|
+
* session that is still good.
|
|
284
|
+
*/
|
|
285
|
+
export async function resolveKiroCredentials() {
|
|
286
|
+
const { getKiroCliCredentials, getKiroCliCredentialsAllowExpired } = await import("./kiro-cli.js");
|
|
287
|
+
const fresh = getKiroCliCredentials() ?? getKiroIdeCredentials();
|
|
288
|
+
if (fresh)
|
|
289
|
+
return fresh;
|
|
290
|
+
const stale = getKiroCliCredentialsAllowExpired();
|
|
291
|
+
if (!stale)
|
|
292
|
+
return undefined;
|
|
293
|
+
return refreshKiroToken(stale);
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=oauth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,EAAE;AACF,gBAAgB;AAChB,yDAAyD;AACzD,sEAAsE;AACtE,kDAAkD;AAClD,iDAAiD;AACjD,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,sCAAsC,CAAC;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AACrE,MAAM,CAAC,MAAM,sBAAsB,GAAG,mEAAmE,CAAC;AAC1G,MAAM,CAAC,MAAM,wBAAwB,GAAG,0DAA0D,CAAC;AACnG,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,2BAA2B;IAC3B,wBAAwB;IACxB,6BAA6B;IAC7B,+BAA+B;IAC/B,0BAA0B;CAC3B,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAqBxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,qCAAqC,CAAC;AAE7E,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,UAAkB;IAC/D,OAAO;QACL,YAAY,EAAE,oEAAoE,OAAO,sCAAsC;QAC/H,uBAAuB,EAAE,sCAAsC;Q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Maximum wait for the runtime endpoint to return HTTP response headers. */
|
|
3
|
+
export declare const REQUEST_HEADER_TIMEOUT = 90000;
|
|
4
|
+
export declare function firstTokenTimeoutForModel(modelId: string): number;
|
|
5
|
+
export declare const retryConfig: {
|
|
6
|
+
firstTokenTimeoutMs: number;
|
|
7
|
+
requestHeaderTimeoutMs: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function exponentialBackoff(attempt: number, baseMs: number, maxMs: number): number;
|
|
10
|
+
export declare const MAX_RETRY_DELAY = 10000;
|
|
11
|
+
/** Fallback used when a request-window response carries no valid server hint. */
|
|
12
|
+
export declare const REQUEST_RATE_FALLBACK_DELAY_MS = 10000;
|
|
13
|
+
/** Pull the service's exact JSON `reason` field without retaining or returning the body. */
|
|
14
|
+
export declare function extractKiroReason(errorText: string): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Read a server-advertised wait in milliseconds.
|
|
17
|
+
*
|
|
18
|
+
* `retry-after-ms` is milliseconds, numeric `retry-after` and
|
|
19
|
+
* `x-ratelimit-reset-after` are seconds, and an HTTP-date `retry-after` is
|
|
20
|
+
* relative to `nowMs`. Each header is an independent candidate, so an invalid
|
|
21
|
+
* earlier value does not hide a valid later one. A past HTTP date means retry
|
|
22
|
+
* now.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseRetryAfterMs(headers: Headers | undefined, nowMs?: number): number | undefined;
|
|
25
|
+
export declare function resolveRequestRateRetryDelay(headers: Headers | undefined, nowMs?: number): {
|
|
26
|
+
delayMs: number;
|
|
27
|
+
advertisedDelayMs?: number;
|
|
28
|
+
capped: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Machine reason codes returned by the Kiro API, plus the one prose marker the
|
|
32
|
+
* service emits without a code (`INPUT_TOO_LONG`).
|
|
33
|
+
*
|
|
34
|
+
* Single source of truth for the provider's error vocabulary: the pattern lists
|
|
35
|
+
* and predicates below are derived from it, and it is re-exported from the
|
|
36
|
+
* package entry point so consumers can classify a code without holding an error
|
|
37
|
+
* instance — e.g. reading a persisted log line. These are the service's own
|
|
38
|
+
* codes, deliberately not renamed or mapped into a provider taxonomy.
|
|
39
|
+
*/
|
|
40
|
+
export declare const KIRO_REASON_CODES: Readonly<{
|
|
41
|
+
/** Request body exceeded the service's size threshold. */
|
|
42
|
+
readonly CONTENT_LENGTH_EXCEEDS_THRESHOLD: "CONTENT_LENGTH_EXCEEDS_THRESHOLD";
|
|
43
|
+
/** Prose-only size rejection; the service sends no reason code for this one. */
|
|
44
|
+
readonly INPUT_TOO_LONG: "Input is too long";
|
|
45
|
+
/** Monthly request quota exhausted — hard limit, not transient. */
|
|
46
|
+
readonly MONTHLY_REQUEST_COUNT: "MONTHLY_REQUEST_COUNT";
|
|
47
|
+
/** Model capacity temporarily unavailable — transient, worth retrying. */
|
|
48
|
+
readonly INSUFFICIENT_MODEL_CAPACITY: "INSUFFICIENT_MODEL_CAPACITY";
|
|
49
|
+
/** Short-window request throttle — retry only within the provider budget. */
|
|
50
|
+
readonly USER_REQUEST_RATE_EXCEEDED: "USER_REQUEST_RATE_EXCEEDED";
|
|
51
|
+
/**
|
|
52
|
+
* Generic request-validation rejection, returned for a malformed body of any
|
|
53
|
+
* size (empty `content`, history referencing tools absent from the catalog).
|
|
54
|
+
* Not a size signal: classifying it as "too big" makes the caller compact a
|
|
55
|
+
* history that was never the problem, a loop it can never satisfy.
|
|
56
|
+
*/
|
|
57
|
+
readonly REQUEST_BODY_INVALID: "REQUEST_BODY_INVALID";
|
|
58
|
+
}>;
|
|
59
|
+
export type KiroReasonCode = (typeof KIRO_REASON_CODES)[keyof typeof KIRO_REASON_CODES];
|
|
60
|
+
export declare const TOO_BIG_PATTERNS: readonly string[];
|
|
61
|
+
export declare const NON_RETRYABLE_BODY_PATTERNS: readonly string[];
|
|
62
|
+
export declare const CAPACITY_PATTERN: "INSUFFICIENT_MODEL_CAPACITY";
|
|
63
|
+
export declare const CAPACITY_MAX_RETRIES = 3;
|
|
64
|
+
export declare const CAPACITY_BASE_DELAY_MS = 5000;
|
|
65
|
+
export declare const capacityRetryConfig: {
|
|
66
|
+
maxRetries: number;
|
|
67
|
+
baseDelayMs: number;
|
|
68
|
+
};
|
|
69
|
+
/** Check whether an HTTP error represents a "request too large" condition. */
|
|
70
|
+
export declare function isTooBigError(status: number, errorText: string): boolean;
|
|
71
|
+
/** Check whether the response body contains a Kiro-specific non-retryable marker. */
|
|
72
|
+
export declare function isNonRetryableBodyError(errorText: string): boolean;
|
|
73
|
+
/** Check whether the error is a transient capacity issue worth retrying. */
|
|
74
|
+
export declare function isCapacityError(errorText: string): boolean;
|
package/dist/retry.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// ABOUTME: Stream recovery helpers and Kiro-specific error classification.
|
|
2
|
+
// ABOUTME: Keeps provider-local retry logic limited to auth refresh and stream quirks.
|
|
3
|
+
import { kiroModels } from "./models.js";
|
|
4
|
+
// kiro-cli uses 5-minute read/operation timeouts (DEFAULT_TIMEOUT_DURATION)
|
|
5
|
+
// and 5-minute stalled stream grace period. 90s matches the TUI's
|
|
6
|
+
// INITIAL_RESPONSE_TIMEOUT_MS for the first event from the backend.
|
|
7
|
+
export const FIRST_TOKEN_TIMEOUT = 90_000;
|
|
8
|
+
/** Maximum wait for the runtime endpoint to return HTTP response headers. */
|
|
9
|
+
export const REQUEST_HEADER_TIMEOUT = 90_000;
|
|
10
|
+
export function firstTokenTimeoutForModel(modelId) {
|
|
11
|
+
// Allow test overrides via retryConfig.firstTokenTimeoutMs
|
|
12
|
+
if (retryConfig.firstTokenTimeoutMs !== FIRST_TOKEN_TIMEOUT) {
|
|
13
|
+
return retryConfig.firstTokenTimeoutMs;
|
|
14
|
+
}
|
|
15
|
+
const model = kiroModels.find((m) => m.id === modelId);
|
|
16
|
+
return model?.firstTokenTimeout ?? FIRST_TOKEN_TIMEOUT;
|
|
17
|
+
}
|
|
18
|
+
// Mutable config for values that tests need to override
|
|
19
|
+
export const retryConfig = {
|
|
20
|
+
firstTokenTimeoutMs: FIRST_TOKEN_TIMEOUT,
|
|
21
|
+
requestHeaderTimeoutMs: REQUEST_HEADER_TIMEOUT,
|
|
22
|
+
};
|
|
23
|
+
export function exponentialBackoff(attempt, baseMs, maxMs) {
|
|
24
|
+
return Math.min(baseMs * 2 ** attempt, maxMs);
|
|
25
|
+
}
|
|
26
|
+
export const MAX_RETRY_DELAY = 10_000;
|
|
27
|
+
/** Fallback used when a request-window response carries no valid server hint. */
|
|
28
|
+
export const REQUEST_RATE_FALLBACK_DELAY_MS = 10_000;
|
|
29
|
+
/** Pull the service's exact JSON `reason` field without retaining or returning the body. */
|
|
30
|
+
export function extractKiroReason(errorText) {
|
|
31
|
+
if (!errorText)
|
|
32
|
+
return undefined;
|
|
33
|
+
try {
|
|
34
|
+
const parsed = JSON.parse(errorText);
|
|
35
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
36
|
+
return undefined;
|
|
37
|
+
const reason = parsed.reason;
|
|
38
|
+
return typeof reason === "string" && reason.length > 0 ? reason : undefined;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Read a server-advertised wait in milliseconds.
|
|
46
|
+
*
|
|
47
|
+
* `retry-after-ms` is milliseconds, numeric `retry-after` and
|
|
48
|
+
* `x-ratelimit-reset-after` are seconds, and an HTTP-date `retry-after` is
|
|
49
|
+
* relative to `nowMs`. Each header is an independent candidate, so an invalid
|
|
50
|
+
* earlier value does not hide a valid later one. A past HTTP date means retry
|
|
51
|
+
* now.
|
|
52
|
+
*/
|
|
53
|
+
export function parseRetryAfterMs(headers, nowMs = Date.now()) {
|
|
54
|
+
const get = headers?.get?.bind(headers);
|
|
55
|
+
if (!get)
|
|
56
|
+
return undefined;
|
|
57
|
+
const milliseconds = nonNegativeNumber(get("retry-after-ms"));
|
|
58
|
+
if (milliseconds !== undefined)
|
|
59
|
+
return Math.round(milliseconds);
|
|
60
|
+
const retryAfter = get("retry-after");
|
|
61
|
+
if (retryAfter !== null && retryAfter.trim() !== "") {
|
|
62
|
+
const seconds = Number(retryAfter);
|
|
63
|
+
if (Number.isFinite(seconds)) {
|
|
64
|
+
// Numeric Retry-After is delay-seconds, never a date. In particular,
|
|
65
|
+
// do not let Date.parse reinterpret a negative delay as a year.
|
|
66
|
+
if (seconds >= 0) {
|
|
67
|
+
const delayMs = seconds * 1000;
|
|
68
|
+
if (Number.isFinite(delayMs))
|
|
69
|
+
return Math.round(delayMs);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const dateMs = Date.parse(retryAfter);
|
|
74
|
+
if (!Number.isNaN(dateMs))
|
|
75
|
+
return Math.max(0, dateMs - nowMs);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const resetAfterSeconds = nonNegativeNumber(get("x-ratelimit-reset-after"));
|
|
79
|
+
if (resetAfterSeconds !== undefined) {
|
|
80
|
+
const delayMs = resetAfterSeconds * 1000;
|
|
81
|
+
if (Number.isFinite(delayMs))
|
|
82
|
+
return Math.round(delayMs);
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
export function resolveRequestRateRetryDelay(headers, nowMs = Date.now()) {
|
|
87
|
+
const advertisedDelayMs = parseRetryAfterMs(headers, nowMs);
|
|
88
|
+
const requestedDelayMs = advertisedDelayMs ?? REQUEST_RATE_FALLBACK_DELAY_MS;
|
|
89
|
+
return {
|
|
90
|
+
delayMs: Math.min(requestedDelayMs, MAX_RETRY_DELAY),
|
|
91
|
+
...(advertisedDelayMs !== undefined ? { advertisedDelayMs } : {}),
|
|
92
|
+
capped: requestedDelayMs > MAX_RETRY_DELAY,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function nonNegativeNumber(value) {
|
|
96
|
+
if (value === null || value.trim() === "")
|
|
97
|
+
return undefined;
|
|
98
|
+
const parsed = Number(value);
|
|
99
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Machine reason codes returned by the Kiro API, plus the one prose marker the
|
|
103
|
+
* service emits without a code (`INPUT_TOO_LONG`).
|
|
104
|
+
*
|
|
105
|
+
* Single source of truth for the provider's error vocabulary: the pattern lists
|
|
106
|
+
* and predicates below are derived from it, and it is re-exported from the
|
|
107
|
+
* package entry point so consumers can classify a code without holding an error
|
|
108
|
+
* instance — e.g. reading a persisted log line. These are the service's own
|
|
109
|
+
* codes, deliberately not renamed or mapped into a provider taxonomy.
|
|
110
|
+
*/
|
|
111
|
+
export const KIRO_REASON_CODES = Object.freeze({
|
|
112
|
+
/** Request body exceeded the service's size threshold. */
|
|
113
|
+
CONTENT_LENGTH_EXCEEDS_THRESHOLD: "CONTENT_LENGTH_EXCEEDS_THRESHOLD",
|
|
114
|
+
/** Prose-only size rejection; the service sends no reason code for this one. */
|
|
115
|
+
INPUT_TOO_LONG: "Input is too long",
|
|
116
|
+
/** Monthly request quota exhausted — hard limit, not transient. */
|
|
117
|
+
MONTHLY_REQUEST_COUNT: "MONTHLY_REQUEST_COUNT",
|
|
118
|
+
/** Model capacity temporarily unavailable — transient, worth retrying. */
|
|
119
|
+
INSUFFICIENT_MODEL_CAPACITY: "INSUFFICIENT_MODEL_CAPACITY",
|
|
120
|
+
/** Short-window request throttle — retry only within the provider budget. */
|
|
121
|
+
USER_REQUEST_RATE_EXCEEDED: "USER_REQUEST_RATE_EXCEEDED",
|
|
122
|
+
/**
|
|
123
|
+
* Generic request-validation rejection, returned for a malformed body of any
|
|
124
|
+
* size (empty `content`, history referencing tools absent from the catalog).
|
|
125
|
+
* Not a size signal: classifying it as "too big" makes the caller compact a
|
|
126
|
+
* history that was never the problem, a loop it can never satisfy.
|
|
127
|
+
*/
|
|
128
|
+
REQUEST_BODY_INVALID: "REQUEST_BODY_INVALID",
|
|
129
|
+
});
|
|
130
|
+
// Size markers only — REQUEST_BODY_INVALID is excluded on purpose (see above).
|
|
131
|
+
export const TOO_BIG_PATTERNS = Object.freeze([
|
|
132
|
+
KIRO_REASON_CODES.CONTENT_LENGTH_EXCEEDS_THRESHOLD,
|
|
133
|
+
KIRO_REASON_CODES.INPUT_TOO_LONG,
|
|
134
|
+
]);
|
|
135
|
+
export const NON_RETRYABLE_BODY_PATTERNS = Object.freeze([KIRO_REASON_CODES.MONTHLY_REQUEST_COUNT]);
|
|
136
|
+
export const CAPACITY_PATTERN = KIRO_REASON_CODES.INSUFFICIENT_MODEL_CAPACITY;
|
|
137
|
+
export const CAPACITY_MAX_RETRIES = 3;
|
|
138
|
+
export const CAPACITY_BASE_DELAY_MS = 5_000;
|
|
139
|
+
// Mutable capacity config for testing
|
|
140
|
+
export const capacityRetryConfig = {
|
|
141
|
+
maxRetries: CAPACITY_MAX_RETRIES,
|
|
142
|
+
baseDelayMs: CAPACITY_BASE_DELAY_MS,
|
|
143
|
+
};
|
|
144
|
+
/** Check whether an HTTP error represents a "request too large" condition. */
|
|
145
|
+
export function isTooBigError(status, errorText) {
|
|
146
|
+
return status === 413 || (status === 400 && TOO_BIG_PATTERNS.some((p) => errorText.includes(p)));
|
|
147
|
+
}
|
|
148
|
+
/** Check whether the response body contains a Kiro-specific non-retryable marker. */
|
|
149
|
+
export function isNonRetryableBodyError(errorText) {
|
|
150
|
+
return NON_RETRYABLE_BODY_PATTERNS.some((p) => errorText.includes(p));
|
|
151
|
+
}
|
|
152
|
+
/** Check whether the error is a transient capacity issue worth retrying. */
|
|
153
|
+
export function isCapacityError(errorText) {
|
|
154
|
+
return errorText.includes(CAPACITY_PATTERN);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,uFAAuF;AAEvF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,C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,CAAC,SAAiB;IACvD,OAAO,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/stream.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type KiroModel } from "./models.js";
|
|
2
|
+
import type { KiroEffort, KiroMessage, KiroStreamEvent, KiroTool } from "./types.js";
|
|
3
|
+
/** One model call, fully assembled by the host adapter. */
|
|
4
|
+
export interface KiroStreamRequest {
|
|
5
|
+
model: KiroModel;
|
|
6
|
+
messages: KiroMessage[];
|
|
7
|
+
systemPrompt?: string;
|
|
8
|
+
tools?: KiroTool[];
|
|
9
|
+
/** Requested reasoning level; clamped against the model's own ladder. */
|
|
10
|
+
effort?: KiroEffort;
|
|
11
|
+
/** Bearer token for this call. */
|
|
12
|
+
accessToken: string;
|
|
13
|
+
/** Reused as Kiro's `conversationId`, so a session keeps one server-side thread. */
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
profileArn?: string;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the host can drop blocks it has already been handed. Hosts that can
|
|
19
|
+
* receive a {@link KiroStreamEvent} of type `reset` and discard everything
|
|
20
|
+
* before it; hosts that cannot make the core settle for the terminal
|
|
21
|
+
* behaviour instead of retrying mid-response.
|
|
22
|
+
*/
|
|
23
|
+
canDiscardEmittedBlocks?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Reset profile resolution state — exported for stream tests. */
|
|
26
|
+
export declare function resetProfileArnCache(resolved?: boolean): void;
|
|
27
|
+
/**
|
|
28
|
+
* Stream one Kiro response as neutral events.
|
|
29
|
+
*
|
|
30
|
+
* Retries live inside this generator: transport timeouts, capacity pressure,
|
|
31
|
+
* request-rate windows, 403 credential rotation, and degenerate 200s all resend
|
|
32
|
+
* without the caller seeing a partial turn — except where the response had
|
|
33
|
+
* already been streamed out, which {@link KiroStreamRequest.canDiscardEmittedBlocks}
|
|
34
|
+
* governs.
|
|
35
|
+
*/
|
|
36
|
+
export declare function streamKiro(request: KiroStreamRequest): AsyncGenerator<KiroStreamEvent>;
|