@gajae-code/ai 0.13.2 → 0.14.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/CHANGELOG.md +61 -2
- package/dist/types/auth-broker/client.d.ts +9 -1
- package/dist/types/auth-broker/redact.d.ts +7 -0
- package/dist/types/auth-broker/remote-store.d.ts +50 -9
- package/dist/types/auth-broker/types.d.ts +14 -0
- package/dist/types/auth-broker/wire-schemas.d.ts +25 -0
- package/dist/types/auth-storage.d.ts +200 -6
- package/dist/types/core.d.ts +1 -0
- package/dist/types/model-cache.d.ts +4 -1
- package/dist/types/model-manager.d.ts +11 -0
- package/dist/types/provider-models/openai-compat.d.ts +5 -0
- package/dist/types/provider-models/special.d.ts +3 -0
- package/dist/types/providers/anthropic.d.ts +31 -0
- package/dist/types/providers/cursor.d.ts +9 -1
- package/dist/types/providers/kiro-codewhisperer.d.ts +8 -0
- package/dist/types/providers/mock.d.ts +8 -0
- package/dist/types/providers/register-builtins.d.ts +1 -0
- package/dist/types/providers/transform-messages.d.ts +18 -0
- package/dist/types/types.d.ts +34 -8
- package/dist/types/usage/grok-cli.d.ts +5 -0
- package/dist/types/usage.d.ts +6 -0
- package/dist/types/utils/discovery/openai-compatible.d.ts +5 -0
- package/dist/types/utils/event-stream.d.ts +4 -2
- package/dist/types/utils/fallback-transport.d.ts +10 -0
- package/dist/types/utils/http-inspector.d.ts +1 -0
- package/dist/types/utils/idle-iterator.d.ts +13 -1
- package/dist/types/utils/json-parse.d.ts +19 -0
- package/dist/types/utils/oauth/callback-server.d.ts +13 -0
- package/dist/types/utils/oauth/kiro.d.ts +71 -0
- package/dist/types/utils/oauth/types.d.ts +1 -1
- package/dist/types/utils/parse-bind.d.ts +8 -5
- package/dist/types/utils/tool-call-healing.d.ts +7 -0
- package/dist/types/utils/tool-choice-capability.d.ts +11 -0
- package/package.json +3 -2
- package/src/auth-broker/client.ts +30 -0
- package/src/auth-broker/redact.ts +15 -0
- package/src/auth-broker/refresher.ts +4 -2
- package/src/auth-broker/remote-store.ts +693 -70
- package/src/auth-broker/server.ts +57 -12
- package/src/auth-broker/types.ts +16 -0
- package/src/auth-broker/wire-schemas.ts +21 -0
- package/src/auth-gateway/server.ts +84 -19
- package/src/auth-storage.ts +985 -41
- package/src/core.ts +1 -0
- package/src/model-cache.ts +23 -4
- package/src/model-manager.ts +70 -11
- package/src/model-thinking.ts +45 -1
- package/src/models.json +9604 -1932
- package/src/openai-completions-compat.ts +2 -1
- package/src/provider-models/descriptors.ts +7 -1
- package/src/provider-models/openai-compat.ts +52 -28
- package/src/provider-models/special.ts +12 -0
- package/src/providers/amazon-bedrock.ts +2 -1
- package/src/providers/anthropic.ts +831 -27
- package/src/providers/cursor.ts +83 -3
- package/src/providers/kiro-codewhisperer.ts +572 -0
- package/src/providers/mock.ts +15 -2
- package/src/providers/ollama.ts +9 -2
- package/src/providers/openai-codex-responses.ts +16 -9
- package/src/providers/openai-completions.ts +6 -1
- package/src/providers/openai-responses-shared.ts +180 -18
- package/src/providers/register-builtins.ts +24 -2
- package/src/providers/transform-messages.ts +64 -1
- package/src/stream.ts +25 -2
- package/src/types.ts +36 -7
- package/src/usage/grok-cli.ts +86 -1
- package/src/usage.ts +7 -0
- package/src/utils/discovery/openai-compatible.ts +89 -4
- package/src/utils/event-stream.ts +11 -2
- package/src/utils/fallback-transport.ts +44 -2
- package/src/utils/http-inspector.ts +1 -0
- package/src/utils/idle-iterator.ts +29 -6
- package/src/utils/json-parse.ts +80 -0
- package/src/utils/oauth/callback-server.ts +31 -1
- package/src/utils/oauth/index.ts +14 -1
- package/src/utils/oauth/kiro.ts +448 -0
- package/src/utils/oauth/synthetic.ts +2 -3
- package/src/utils/oauth/types.ts +1 -0
- package/src/utils/parse-bind.ts +27 -0
- package/src/utils/tool-call-healing.ts +13 -2
- package/src/utils/tool-choice-capability.ts +386 -6
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
CredentialDisableRequest,
|
|
13
13
|
CredentialDisableResponse,
|
|
14
14
|
CredentialIfAbsentUploadResponse,
|
|
15
|
+
CredentialMetadataResponse,
|
|
15
16
|
CredentialRefreshRequest,
|
|
16
17
|
CredentialRefreshResponse,
|
|
17
18
|
CredentialUploadRequest,
|
|
@@ -24,6 +25,7 @@ import type {
|
|
|
24
25
|
import {
|
|
25
26
|
credentialDisableResponseSchema,
|
|
26
27
|
credentialIfAbsentUploadResponseSchema,
|
|
28
|
+
credentialMetadataResponseSchema,
|
|
27
29
|
credentialRefreshResponseSchema,
|
|
28
30
|
credentialUploadResponseSchema,
|
|
29
31
|
healthzResponseSchema,
|
|
@@ -68,6 +70,14 @@ export class AuthBrokerStreamUnsupportedError extends AuthBrokerError {
|
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
/** Thrown when a broker responds 404 to `GET /v1/credentials/metadata`. */
|
|
74
|
+
export class AuthBrokerCredentialMetadataUnsupportedError extends AuthBrokerError {
|
|
75
|
+
constructor(message = "Auth broker does not support /v1/credentials/metadata") {
|
|
76
|
+
super(message, { status: 404 });
|
|
77
|
+
this.name = "AuthBrokerCredentialMetadataUnsupportedError";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
71
81
|
export interface FetchSnapshotOptions {
|
|
72
82
|
ifGenerationGt?: number;
|
|
73
83
|
waitMs?: number;
|
|
@@ -108,6 +118,11 @@ export class AuthBrokerClient {
|
|
|
108
118
|
this.#fetch = opts.fetchImpl ?? fetch;
|
|
109
119
|
}
|
|
110
120
|
|
|
121
|
+
/** Normalized broker origin used for non-secret local presentation partitioning. */
|
|
122
|
+
get baseUrl(): string {
|
|
123
|
+
return this.#baseUrl;
|
|
124
|
+
}
|
|
125
|
+
|
|
111
126
|
healthz(signal?: AbortSignal): Promise<HealthzResponse> {
|
|
112
127
|
return this.#request("GET", "/v1/healthz", { schema: healthzResponseSchema, auth: false, signal });
|
|
113
128
|
}
|
|
@@ -115,6 +130,21 @@ export class AuthBrokerClient {
|
|
|
115
130
|
async fetchSnapshot(opts: FetchSnapshotOptions = {}): Promise<FetchSnapshotResult> {
|
|
116
131
|
return this.#fetchSnapshotResult(opts);
|
|
117
132
|
}
|
|
133
|
+
|
|
134
|
+
/** Fetches the generation-aware, secret-free credential inventory projection. */
|
|
135
|
+
async fetchCredentialMetadata(signal?: AbortSignal): Promise<CredentialMetadataResponse> {
|
|
136
|
+
try {
|
|
137
|
+
return (await this.#request("GET", "/v1/credentials/metadata", {
|
|
138
|
+
schema: credentialMetadataResponseSchema,
|
|
139
|
+
signal,
|
|
140
|
+
})) as CredentialMetadataResponse;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (error instanceof AuthBrokerError && error.status === 404) {
|
|
143
|
+
throw new AuthBrokerCredentialMetadataUnsupportedError();
|
|
144
|
+
}
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
118
148
|
async #fetchSnapshotResult(opts: FetchSnapshotOptions): Promise<FetchSnapshotResult> {
|
|
119
149
|
const query = new URLSearchParams();
|
|
120
150
|
if (opts.waitMs !== undefined) query.set("wait", String(opts.waitMs));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep provider and upstream failure text safe for less-trusted surfaces.
|
|
3
|
+
*
|
|
4
|
+
* This intentionally mirrors the bounded reason scrubber used by the account
|
|
5
|
+
* management CLI without taking a dependency on coding-agent.
|
|
6
|
+
*/
|
|
7
|
+
export function cleanReason(value: unknown): string | undefined {
|
|
8
|
+
if (value === undefined || value === null) return undefined;
|
|
9
|
+
let reason = value instanceof Error ? value.message : String(value);
|
|
10
|
+
reason = reason.replace(/bearer\s+[^\s,;]+/gi, "Bearer [redacted]");
|
|
11
|
+
reason = reason.replace(/(api[_-]?key|token|secret|authorization)[=:]\s*[^\s,;]+/gi, "$1=[redacted]");
|
|
12
|
+
reason = reason.replace(/[\r\n\t ]+/g, " ").trim();
|
|
13
|
+
if (reason.length > 256) reason = `${reason.slice(0, 253)}...`;
|
|
14
|
+
return reason || undefined;
|
|
15
|
+
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { logger } from "@gajae-code/utils";
|
|
13
13
|
import type { AuthStorage } from "../auth-storage";
|
|
14
|
+
import { cleanReason } from "./redact";
|
|
14
15
|
import { DEFAULT_REFRESH_INTERVAL_MS, DEFAULT_REFRESH_SKEW_MS } from "./types";
|
|
15
16
|
|
|
16
17
|
export interface AuthBrokerRefresherOptions {
|
|
@@ -113,8 +114,9 @@ export class AuthBrokerRefresher {
|
|
|
113
114
|
try {
|
|
114
115
|
await this.#storage.refreshCredentialById(id);
|
|
115
116
|
} catch (error) {
|
|
116
|
-
const
|
|
117
|
-
|
|
117
|
+
const rawErrorMsg = String(error);
|
|
118
|
+
const errorMsg = cleanReason(error) ?? "Unknown refresh failure";
|
|
119
|
+
if (isDefinitiveFailure(rawErrorMsg)) {
|
|
118
120
|
logger.warn("auth-broker refresh failed definitively; disabling credential", {
|
|
119
121
|
id,
|
|
120
122
|
error: errorMsg,
|