@takara-ai/miru-code 1.7.3 → 1.7.5
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/package.json +1 -1
- package/src/embeddings/openai.ts +9 -2
- package/src/mcp/auth-tool.ts +5 -4
package/package.json
CHANGED
package/src/embeddings/openai.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CredentialsError } from "../auth/errors.ts";
|
|
1
2
|
import { mapPool, resolveWorkerConcurrency } from "../concurrency.ts";
|
|
2
3
|
import { loadStoredCredentials } from "../credentials.ts";
|
|
3
4
|
import { envFirstString, envOptionalInt, resolveEmbeddingApiKey } from "../env.ts";
|
|
@@ -330,7 +331,7 @@ export interface EmbeddingClient {
|
|
|
330
331
|
export const EMBEDDING_AUTH_ERROR_MESSAGE =
|
|
331
332
|
"Not authorized. Check your API key and/or token balance.";
|
|
332
333
|
|
|
333
|
-
class EmbeddingApiError extends Error {
|
|
334
|
+
export class EmbeddingApiError extends Error {
|
|
334
335
|
readonly status: number;
|
|
335
336
|
readonly body: string;
|
|
336
337
|
|
|
@@ -339,7 +340,13 @@ class EmbeddingApiError extends Error {
|
|
|
339
340
|
status === 401 || status === 403
|
|
340
341
|
? EMBEDDING_AUTH_ERROR_MESSAGE
|
|
341
342
|
: `Embedding API error ${status}: ${body.slice(0, 500)}`;
|
|
342
|
-
|
|
343
|
+
// A 401/403 means the existing credential cannot authorize embeddings. Preserve
|
|
344
|
+
// the HTTP details while marking it recoverable so MCP tools can offer the
|
|
345
|
+
// device-code flow instead of leaving agents to fall back to shell commands.
|
|
346
|
+
super(
|
|
347
|
+
message,
|
|
348
|
+
status === 401 || status === 403 ? { cause: new CredentialsError(message) } : undefined,
|
|
349
|
+
);
|
|
343
350
|
this.name = "EmbeddingApiError";
|
|
344
351
|
this.status = status;
|
|
345
352
|
this.body = body;
|
package/src/mcp/auth-tool.ts
CHANGED
|
@@ -19,13 +19,14 @@ const CHECK_HINT =
|
|
|
19
19
|
|
|
20
20
|
/** Appended to credentials failures so an agent knows Miru's own recovery step. */
|
|
21
21
|
const RECOVERY_HINT =
|
|
22
|
-
'Miru
|
|
23
|
-
'device-login page
|
|
22
|
+
'Miru could not authorize its current credentials. Call the `auth` tool with action "start" ' +
|
|
23
|
+
'to open the Takara device-login page, then action "check" once the user approves. If access ' +
|
|
24
|
+
"is still denied after signing in, check the account token balance.";
|
|
24
25
|
|
|
25
26
|
const AUTH_TOOL_DESCRIPTION =
|
|
26
27
|
"Sign in with Takara credentials via device-code login — no terminal required. " +
|
|
27
|
-
"Only call this in direct response to a tool error mentioning missing
|
|
28
|
-
"credentials — never speculatively, since it starts a real sign-in prompt for the " +
|
|
28
|
+
"Only call this in direct response to a tool error mentioning missing, expired, rejected, or " +
|
|
29
|
+
"invalid credentials — never speculatively, since it starts a real sign-in prompt for the " +
|
|
29
30
|
'user. Call with no arguments (or action "start") to begin: it opens the device-login ' +
|
|
30
31
|
`page in the user's browser and returns that URL plus a short code. ${CHECK_HINT}`;
|
|
31
32
|
|