@bastani/atomic 0.9.37 → 0.9.38-alpha.2
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 +24 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +6 -0
- package/dist/builtin/workflows/builtin/{chunk-rhkg3d8e.js → chunk-3n2bnz64.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-3xffzzbg.js → chunk-ad83gc5p.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-7fvrnzhb.js → chunk-x6az1sxp.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-8c3ae7tt.js → chunk-ymwq372z.js} +1 -1
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +7 -0
- package/dist/builtin/workflows/src/index.js +7 -0
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +19 -5
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +2 -2
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-retry.js +1 -1
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +4 -6
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +13 -8
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +3 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage-backends.d.ts +2 -0
- package/dist/core/auth-storage-backends.d.ts.map +1 -1
- package/dist/core/auth-storage-backends.js +12 -0
- package/dist/core/auth-storage-backends.js.map +1 -1
- package/dist/core/auth-storage.d.ts +5 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +46 -12
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/export-html/template-js/message-tools.js +20 -7
- package/dist/core/export-html/template-js/tree-filter-render.js +1 -9
- package/dist/core/export-html/template.js +21 -16
- package/dist/core/model-config.d.ts +9 -9
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +3 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts +2 -0
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +47 -143
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-patterns.d.ts +48 -22
- package/dist/core/model-resolver-patterns.d.ts.map +1 -1
- package/dist/core/model-resolver-patterns.js +154 -105
- package/dist/core/model-resolver-patterns.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts +6 -9
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +51 -53
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-resolver-types.d.ts +0 -6
- package/dist/core/model-resolver-types.d.ts.map +1 -1
- package/dist/core/model-resolver-types.js.map +1 -1
- package/dist/core/model-resolver.d.ts +3 -2
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts +9 -2
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +121 -10
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime.d.ts +6 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +103 -2
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +6 -2
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/retry-policy.d.ts +5 -2
- package/dist/core/retry-policy.d.ts.map +1 -1
- package/dist/core/retry-policy.js +4 -3
- package/dist/core/retry-policy.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +3 -0
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.js +95 -74
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +1 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/tools/malformed-tool-arguments.d.ts +3 -0
- package/dist/core/tools/malformed-tool-arguments.d.ts.map +1 -0
- package/dist/core/tools/malformed-tool-arguments.js +23 -0
- package/dist/core/tools/malformed-tool-arguments.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +2 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +19 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session-options.d.ts.map +1 -1
- package/dist/main-session-options.js +1 -0
- package/dist/main-session-options.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +2 -9
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/docs/docs.json +2 -1
- package/docs/extensions/events.md +4 -0
- package/docs/extensions/ui.md +10 -0
- package/docs/llama-cpp.md +2 -0
- package/docs/models/reference.md +7 -0
- package/docs/nvidia-rtx-llama-cpp.md +101 -0
- package/docs/prompt-templates.md +2 -0
- package/docs/providers.md +9 -1
- package/docs/reference/cli.md +3 -3
- package/docs/sessions.md +4 -0
- package/docs/settings.md +3 -3
- package/docs/tools.md +2 -0
- package/docs/workflows/api-reference.md +2 -0
- package/examples/extensions/minimal-mode.ts +1 -8
- package/examples/extensions/subagent/display.ts +4 -6
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
- package/schemas/models.schema.json +5 -5
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { normalizeProviderId, } from "@bastani/pi-ai";
|
|
6
6
|
import { join } from "path";
|
|
7
|
+
import { isDeepStrictEqual } from "util";
|
|
7
8
|
import { getAgentConfigPaths, getAgentDir } from "../config.js";
|
|
8
9
|
import { raceWithAbortSignal } from "../utils/abort.js";
|
|
9
10
|
import { stripBom } from "../utils/text.js";
|
|
@@ -13,6 +14,7 @@ import { resolveConfigValue } from "./resolve-config-value.js";
|
|
|
13
14
|
export { FileAuthStorageBackend, InMemoryAuthStorageBackend, } from "./auth-storage-backends.js";
|
|
14
15
|
export class AuthStorage {
|
|
15
16
|
data = {};
|
|
17
|
+
loadedVersion;
|
|
16
18
|
storage;
|
|
17
19
|
constructor(storage) {
|
|
18
20
|
this.storage = storage;
|
|
@@ -36,25 +38,51 @@ export class AuthStorage {
|
|
|
36
38
|
}
|
|
37
39
|
return normalizeProviderKeys(JSON.parse(stripBom(content)));
|
|
38
40
|
}
|
|
41
|
+
readStorageContent() {
|
|
42
|
+
if (this.storage.read)
|
|
43
|
+
return this.storage.read();
|
|
44
|
+
let content;
|
|
45
|
+
this.storage.withLock((current) => {
|
|
46
|
+
content = current;
|
|
47
|
+
return { result: undefined };
|
|
48
|
+
});
|
|
49
|
+
return content;
|
|
50
|
+
}
|
|
39
51
|
/**
|
|
40
52
|
* Reload credentials from storage.
|
|
41
53
|
*/
|
|
42
54
|
reload() {
|
|
55
|
+
this.loadFromStorage(this.readStorageVersion());
|
|
56
|
+
}
|
|
57
|
+
reloadIfChanged() {
|
|
58
|
+
if (!this.storage.version && !this.storage.read)
|
|
59
|
+
return false;
|
|
60
|
+
const version = this.readStorageVersion();
|
|
61
|
+
if (version !== undefined && version === this.loadedVersion)
|
|
62
|
+
return false;
|
|
63
|
+
return this.loadFromStorage(version);
|
|
64
|
+
}
|
|
65
|
+
readStorageVersion() {
|
|
43
66
|
try {
|
|
44
|
-
|
|
45
|
-
if (this.storage.read) {
|
|
46
|
-
content = this.storage.read();
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
this.storage.withLock((current) => {
|
|
50
|
-
content = current;
|
|
51
|
-
return { result: undefined };
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
this.data = this.parseStorageData(content);
|
|
67
|
+
return this.storage.version?.();
|
|
55
68
|
}
|
|
56
69
|
catch {
|
|
57
|
-
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
loadFromStorage(version) {
|
|
74
|
+
try {
|
|
75
|
+
const next = this.parseStorageData(this.readStorageContent());
|
|
76
|
+
this.loadedVersion = version;
|
|
77
|
+
if (isDeepStrictEqual(next, this.data))
|
|
78
|
+
return false;
|
|
79
|
+
this.data = next;
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error instanceof SyntaxError)
|
|
84
|
+
this.loadedVersion = version;
|
|
85
|
+
return false;
|
|
58
86
|
}
|
|
59
87
|
}
|
|
60
88
|
/** Read the current in-memory credential snapshot without triggering refresh or I/O. */
|
|
@@ -63,6 +91,7 @@ export class AuthStorage {
|
|
|
63
91
|
}
|
|
64
92
|
async read(provider, options) {
|
|
65
93
|
options?.signal?.throwIfAborted();
|
|
94
|
+
this.reloadIfChanged();
|
|
66
95
|
const credential = this.peek(provider);
|
|
67
96
|
if (credential?.type !== "api_key")
|
|
68
97
|
return credential;
|
|
@@ -86,6 +115,7 @@ export class AuthStorage {
|
|
|
86
115
|
this.data = this.parseStorageData(snapshot.next);
|
|
87
116
|
if (snapshot.result !== undefined)
|
|
88
117
|
this.data[provider] = snapshot.result;
|
|
118
|
+
this.loadedVersion = undefined;
|
|
89
119
|
return snapshot.result;
|
|
90
120
|
}
|
|
91
121
|
let persistedData;
|
|
@@ -106,6 +136,7 @@ export class AuthStorage {
|
|
|
106
136
|
const result = signal === undefined ? await operation : await raceWithAbortSignal(operation, signal);
|
|
107
137
|
if (persistedData)
|
|
108
138
|
this.data = persistedData;
|
|
139
|
+
this.loadedVersion = undefined;
|
|
109
140
|
return result;
|
|
110
141
|
}
|
|
111
142
|
async delete(provider) {
|
|
@@ -115,6 +146,7 @@ export class AuthStorage {
|
|
|
115
146
|
await this.storage.deleteProviderAsync(LEGACY_AZURE_PROVIDER);
|
|
116
147
|
const content = await this.storage.deleteProviderAsync(provider);
|
|
117
148
|
this.data = this.parseStorageData(content);
|
|
149
|
+
this.loadedVersion = undefined;
|
|
118
150
|
return;
|
|
119
151
|
}
|
|
120
152
|
let persistedData;
|
|
@@ -126,10 +158,12 @@ export class AuthStorage {
|
|
|
126
158
|
});
|
|
127
159
|
if (persistedData)
|
|
128
160
|
this.data = persistedData;
|
|
161
|
+
this.loadedVersion = undefined;
|
|
129
162
|
}
|
|
130
163
|
/** List credential metadata without resolving configured key values. */
|
|
131
164
|
async list(options) {
|
|
132
165
|
options?.signal?.throwIfAborted();
|
|
166
|
+
this.reloadIfChanged();
|
|
133
167
|
return Object.entries(this.data).map(([providerId, credential]) => ({ providerId, type: credential.type }));
|
|
134
168
|
}
|
|
135
169
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-storage.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;IACnB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/**\n * CredentialStore implementation backed by auth.json.\n * Provider auth orchestration belongs to ModelRuntime and pi-ai Models.\n */\n\nimport {\n\ttype AuthOperationOptions,\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\tnormalizeProviderId,\n} from \"@bastani/pi-ai\";\nimport { join } from \"path\";\nimport { getAgentConfigPaths, getAgentDir } from \"../config.js\";\nimport { raceWithAbortSignal } from \"../utils/abort.js\";\nimport { stripBom } from \"../utils/text.ts\";\nimport {\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n} from \"./auth-storage-backends.ts\";\nimport { LEGACY_AZURE_PROVIDER, normalizeProviderKeys } from \"./azure-provider-compat.js\";\nimport { resolveConfigValue } from \"./resolve-config-value.ts\";\n\nexport {\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n} from \"./auth-storage-backends.ts\";\n\nexport type AuthStorageData = Record<string, Credential>;\n\nexport class AuthStorage implements CredentialStore {\n\tprivate data: AuthStorageData = {};\n\tprivate storage: AuthStorageBackend;\n\n\tprivate constructor(storage: AuthStorageBackend) {\n\t\tthis.storage = storage;\n\t\tthis.reload();\n\t}\n\n\tstatic create(authPath?: string | string[]): AuthStorage {\n\t\tconst paths =\n\t\t\tauthPath === undefined ? getAgentConfigPaths(\"auth.json\") : Array.isArray(authPath) ? authPath : [authPath];\n\t\treturn new AuthStorage(new FileAuthStorageBackend(paths[0] ?? join(getAgentDir(), \"auth.json\"), paths));\n\t}\n\n\tstatic fromStorage(storage: AuthStorageBackend): AuthStorage {\n\t\treturn new AuthStorage(storage);\n\t}\n\n\tstatic inMemory(data: AuthStorageData = {}): AuthStorage {\n\t\tconst storage = new InMemoryAuthStorageBackend();\n\t\tstorage.withLock(() => ({ result: undefined, next: JSON.stringify(data, null, 2) }));\n\t\treturn AuthStorage.fromStorage(storage);\n\t}\n\n\tprivate parseStorageData(content: string | undefined): AuthStorageData {\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\treturn normalizeProviderKeys(JSON.parse(stripBom(content)) as AuthStorageData);\n\t}\n\n\t/**\n\t * Reload credentials from storage.\n\t */\n\treload(): void {\n\t\ttry {\n\t\t\tlet content: string | undefined;\n\t\t\tif (this.storage.read) {\n\t\t\t\tcontent = this.storage.read();\n\t\t\t} else {\n\t\t\t\tthis.storage.withLock((current) => {\n\t\t\t\t\tcontent = current;\n\t\t\t\t\treturn { result: undefined };\n\t\t\t\t});\n\t\t\t}\n\t\t\tthis.data = this.parseStorageData(content);\n\t\t} catch {\n\t\t\t// Preserve the last valid in-memory snapshot.\n\t\t}\n\t}\n\n\t/** Read the current in-memory credential snapshot without triggering refresh or I/O. */\n\tpeek(provider: string): Credential | undefined {\n\t\treturn this.data[normalizeProviderId(provider)];\n\t}\n\n\tasync read(provider: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst credential = this.peek(provider);\n\t\tif (credential?.type !== \"api_key\") return credential;\n\t\tif (credential.key === undefined) return credential;\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync modify(\n\t\tprovider: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\tprovider = normalizeProviderId(provider);\n\t\tconst signal = options?.signal;\n\t\tsignal?.throwIfAborted();\n\t\tif (this.storage.modifyProviderAsync) {\n\t\t\tconst operation = this.storage.modifyProviderAsync(\n\t\t\t\tprovider,\n\t\t\t\tasync (current) => {\n\t\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\t\tconst pending = fn(current);\n\t\t\t\t\tconst next = signal === undefined ? await pending : await raceWithAbortSignal(pending, signal);\n\t\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\t\treturn next;\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst snapshot = signal === undefined ? await operation : await raceWithAbortSignal(operation, signal);\n\t\t\tthis.data = this.parseStorageData(snapshot.next);\n\t\t\tif (snapshot.result !== undefined) this.data[provider] = snapshot.result;\n\t\t\treturn snapshot.result;\n\t\t}\n\t\tlet persistedData: AuthStorageData | undefined;\n\t\tconst operation = this.storage.withLockAsync(async (content) => {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst pending = fn(currentData[provider]);\n\t\t\tconst next = signal === undefined ? await pending : await raceWithAbortSignal(pending, signal);\n\t\t\tsignal?.throwIfAborted();\n\t\t\tif (next === undefined) {\n\t\t\t\tpersistedData = currentData;\n\t\t\t\treturn { result: currentData[provider] };\n\t\t\t}\n\n\t\t\tconst merged: AuthStorageData = { ...currentData, [provider]: next };\n\t\t\tpersistedData = merged;\n\t\t\treturn { result: next, next: JSON.stringify(merged, null, 2) };\n\t\t});\n\t\tconst result = signal === undefined ? await operation : await raceWithAbortSignal(operation, signal);\n\t\tif (persistedData) this.data = persistedData;\n\t\treturn result;\n\t}\n\n\tasync delete(provider: string): Promise<void> {\n\t\tprovider = normalizeProviderId(provider);\n\t\tif (this.storage.deleteProviderAsync) {\n\t\t\tif (provider === \"azure\") await this.storage.deleteProviderAsync(LEGACY_AZURE_PROVIDER);\n\t\t\tconst content = await this.storage.deleteProviderAsync(provider);\n\t\t\tthis.data = this.parseStorageData(content);\n\t\t\treturn;\n\t\t}\n\t\tlet persistedData: AuthStorageData | undefined;\n\t\tawait this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tdelete currentData[provider];\n\t\t\tpersistedData = currentData;\n\t\t\treturn { result: undefined, next: JSON.stringify(currentData, null, 2) };\n\t\t});\n\t\tif (persistedData) this.data = persistedData;\n\t}\n\n\t/** List credential metadata without resolving configured key values. */\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\toptions?.signal?.throwIfAborted();\n\t\treturn Object.entries(this.data).map(([providerId, credential]) => ({ providerId, type: credential.type }));\n\t}\n}\n\n/**\n * Read credentials without acquiring a lock, creating auth.json, or allowing a\n * refresh to persist a mutation. `auth check --no-refresh` uses this store.\n * It resolves configured key values, including `!command`, like `AuthStorage`.\n * Unlike `AuthStorage.reload()`, malformed data fails closed so the probe can\n * report invalid auth state instead of silently treating it as no credentials.\n */\nexport class ReadOnlyAuthStorage implements CredentialStore {\n\tprivate data: AuthStorageData | undefined;\n\tprivate readonly storage: FileAuthStorageBackend;\n\n\tconstructor(authPath?: string | string[]) {\n\t\tconst paths =\n\t\t\tauthPath === undefined ? getAgentConfigPaths(\"auth.json\") : Array.isArray(authPath) ? authPath : [authPath];\n\t\tthis.storage = new FileAuthStorageBackend(paths[0] ?? join(getAgentDir(), \"auth.json\"), paths);\n\t}\n\n\tprivate load(): AuthStorageData {\n\t\tif (this.data !== undefined) return this.data;\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tconst content = this.storage.read();\n\t\t\tparsed = content === undefined ? {} : JSON.parse(stripBom(content));\n\t\t} catch (error) {\n\t\t\t// The no-refresh path must not turn a corrupt auth file into an empty\n\t\t\t// credential set. Surface invalid state without touching the file.\n\t\t\tthrow new Error(`Failed to read auth.json: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\n\t\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\t\tthrow new Error(\"Invalid auth.json: expected an object\");\n\t\t}\n\t\tfor (const [providerId, credential] of Object.entries(parsed)) {\n\t\t\tif (typeof credential !== \"object\" || credential === null || Array.isArray(credential)) {\n\t\t\t\tthrow new Error(`Invalid auth.json credential for provider \"${providerId}\"`);\n\t\t\t}\n\t\t\tconst value = credential as Record<string, unknown>;\n\t\t\tif (value.type === \"api_key\") {\n\t\t\t\tconst env = value.env;\n\t\t\t\tconst validKey = value.key === undefined || typeof value.key === \"string\";\n\t\t\t\tconst validEnv =\n\t\t\t\t\tenv === undefined ||\n\t\t\t\t\t(typeof env === \"object\" &&\n\t\t\t\t\t\tenv !== null &&\n\t\t\t\t\t\t!Array.isArray(env) &&\n\t\t\t\t\t\tObject.values(env).every((entry) => typeof entry === \"string\"));\n\t\t\t\tif (validKey && validEnv) continue;\n\t\t\t} else if (\n\t\t\t\tvalue.type === \"oauth\" &&\n\t\t\t\ttypeof value.access === \"string\" &&\n\t\t\t\ttypeof value.refresh === \"string\" &&\n\t\t\t\ttypeof value.expires === \"number\" &&\n\t\t\t\tNumber.isFinite(value.expires)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new Error(`Invalid auth.json credential for provider \"${providerId}\"`);\n\t\t}\n\n\t\tthis.data = normalizeProviderKeys(parsed as AuthStorageData);\n\t\treturn this.data;\n\t}\n\n\t/** Raw configured values for privacy screening; never execute API-key commands. */\n\tpeek(providerId: string): Credential | undefined {\n\t\treturn this.load()[normalizeProviderId(providerId)];\n\t}\n\n\tasync read(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst credential = this.peek(providerId);\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (!credential) return undefined;\n\t\tif (credential.type !== \"api_key\" || credential.key === undefined) {\n\t\t\treturn structuredClone(credential);\n\t\t}\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst credentials = Object.entries(this.load()).map(([providerId, credential]) => ({\n\t\t\tproviderId,\n\t\t\ttype: credential.type,\n\t\t}));\n\t\toptions?.signal?.throwIfAborted();\n\t\treturn credentials;\n\t}\n\n\tasync modify(\n\t\t_providerId: string,\n\t\t_fn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\t_options?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\tthrow new Error(\"Read-only credential storage cannot modify auth.json\");\n\t}\n\n\tasync delete(_providerId: string, _options?: AuthOperationOptions): Promise<void> {\n\t\tthrow new Error(\"Read-only credential storage cannot modify auth.json\");\n\t}\n}\n\n/** Read one persisted provider credential using Atomic's layered auth.json paths. */\nexport function readStoredCredential(providerId: string, authPath?: string | string[]): Credential | undefined {\n\tconst paths =\n\t\tauthPath === undefined ? getAgentConfigPaths(\"auth.json\") : Array.isArray(authPath) ? authPath : [authPath];\n\tconst storage = new FileAuthStorageBackend(paths[0] ?? join(getAgentDir(), \"auth.json\"), paths);\n\ttry {\n\t\tlet credential: Credential | undefined;\n\t\tstorage.withLock((content) => {\n\t\t\tcredential = content\n\t\t\t\t? normalizeProviderKeys(JSON.parse(stripBom(content)) as AuthStorageData)[normalizeProviderId(providerId)]\n\t\t\t\t: undefined;\n\t\t\treturn { result: undefined };\n\t\t});\n\t\treturn credential;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth-storage.js","sourceRoot":"","sources":["../../src/core/auth-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAKN,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAEN,sBAAsB,EACtB,0BAA0B,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,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C,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC7G,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC,CAAC;IAChG,IAAI,CAAC;QACJ,IAAI,UAAkC,CAAC;QACvC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,UAAU,GAAG,OAAO;gBACnB,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAoB,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;gBAC1G,CAAC,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACnB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["/**\n * CredentialStore implementation backed by auth.json.\n * Provider auth orchestration belongs to ModelRuntime and pi-ai Models.\n */\n\nimport {\n\ttype AuthOperationOptions,\n\ttype Credential,\n\ttype CredentialInfo,\n\ttype CredentialStore,\n\tnormalizeProviderId,\n} from \"@bastani/pi-ai\";\nimport { join } from \"path\";\nimport { isDeepStrictEqual } from \"util\";\nimport { getAgentConfigPaths, getAgentDir } from \"../config.js\";\nimport { raceWithAbortSignal } from \"../utils/abort.js\";\nimport { stripBom } from \"../utils/text.ts\";\nimport {\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n} from \"./auth-storage-backends.ts\";\nimport { LEGACY_AZURE_PROVIDER, normalizeProviderKeys } from \"./azure-provider-compat.js\";\nimport { resolveConfigValue } from \"./resolve-config-value.ts\";\n\nexport {\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n} from \"./auth-storage-backends.ts\";\n\nexport type AuthStorageData = Record<string, Credential>;\n\nexport class AuthStorage implements CredentialStore {\n\tprivate data: AuthStorageData = {};\n\tprivate loadedVersion: string | undefined;\n\tprivate storage: AuthStorageBackend;\n\n\tprivate constructor(storage: AuthStorageBackend) {\n\t\tthis.storage = storage;\n\t\tthis.reload();\n\t}\n\n\tstatic create(authPath?: string | string[]): AuthStorage {\n\t\tconst paths =\n\t\t\tauthPath === undefined ? getAgentConfigPaths(\"auth.json\") : Array.isArray(authPath) ? authPath : [authPath];\n\t\treturn new AuthStorage(new FileAuthStorageBackend(paths[0] ?? join(getAgentDir(), \"auth.json\"), paths));\n\t}\n\n\tstatic fromStorage(storage: AuthStorageBackend): AuthStorage {\n\t\treturn new AuthStorage(storage);\n\t}\n\n\tstatic inMemory(data: AuthStorageData = {}): AuthStorage {\n\t\tconst storage = new InMemoryAuthStorageBackend();\n\t\tstorage.withLock(() => ({ result: undefined, next: JSON.stringify(data, null, 2) }));\n\t\treturn AuthStorage.fromStorage(storage);\n\t}\n\n\tprivate parseStorageData(content: string | undefined): AuthStorageData {\n\t\tif (!content) {\n\t\t\treturn {};\n\t\t}\n\t\treturn normalizeProviderKeys(JSON.parse(stripBom(content)) as AuthStorageData);\n\t}\n\n\tprivate readStorageContent(): string | undefined {\n\t\tif (this.storage.read) return this.storage.read();\n\t\tlet content: string | undefined;\n\t\tthis.storage.withLock((current) => {\n\t\t\tcontent = current;\n\t\t\treturn { result: undefined };\n\t\t});\n\t\treturn content;\n\t}\n\n\t/**\n\t * Reload credentials from storage.\n\t */\n\treload(): void {\n\t\tthis.loadFromStorage(this.readStorageVersion());\n\t}\n\n\treloadIfChanged(): boolean {\n\t\tif (!this.storage.version && !this.storage.read) return false;\n\t\tconst version = this.readStorageVersion();\n\t\tif (version !== undefined && version === this.loadedVersion) return false;\n\t\treturn this.loadFromStorage(version);\n\t}\n\n\tprivate readStorageVersion(): string | undefined {\n\t\ttry {\n\t\t\treturn this.storage.version?.();\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate loadFromStorage(version: string | undefined): boolean {\n\t\ttry {\n\t\t\tconst next = this.parseStorageData(this.readStorageContent());\n\t\t\tthis.loadedVersion = version;\n\t\t\tif (isDeepStrictEqual(next, this.data)) return false;\n\t\t\tthis.data = next;\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (error instanceof SyntaxError) this.loadedVersion = version;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Read the current in-memory credential snapshot without triggering refresh or I/O. */\n\tpeek(provider: string): Credential | undefined {\n\t\treturn this.data[normalizeProviderId(provider)];\n\t}\n\n\tasync read(provider: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tthis.reloadIfChanged();\n\t\tconst credential = this.peek(provider);\n\t\tif (credential?.type !== \"api_key\") return credential;\n\t\tif (credential.key === undefined) return credential;\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync modify(\n\t\tprovider: string,\n\t\tfn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\toptions?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\tprovider = normalizeProviderId(provider);\n\t\tconst signal = options?.signal;\n\t\tsignal?.throwIfAborted();\n\t\tif (this.storage.modifyProviderAsync) {\n\t\t\tconst operation = this.storage.modifyProviderAsync(\n\t\t\t\tprovider,\n\t\t\t\tasync (current) => {\n\t\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\t\tconst pending = fn(current);\n\t\t\t\t\tconst next = signal === undefined ? await pending : await raceWithAbortSignal(pending, signal);\n\t\t\t\t\tsignal?.throwIfAborted();\n\t\t\t\t\treturn next;\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst snapshot = signal === undefined ? await operation : await raceWithAbortSignal(operation, signal);\n\t\t\tthis.data = this.parseStorageData(snapshot.next);\n\t\t\tif (snapshot.result !== undefined) this.data[provider] = snapshot.result;\n\t\t\tthis.loadedVersion = undefined;\n\t\t\treturn snapshot.result;\n\t\t}\n\t\tlet persistedData: AuthStorageData | undefined;\n\t\tconst operation = this.storage.withLockAsync(async (content) => {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tconst pending = fn(currentData[provider]);\n\t\t\tconst next = signal === undefined ? await pending : await raceWithAbortSignal(pending, signal);\n\t\t\tsignal?.throwIfAborted();\n\t\t\tif (next === undefined) {\n\t\t\t\tpersistedData = currentData;\n\t\t\t\treturn { result: currentData[provider] };\n\t\t\t}\n\n\t\t\tconst merged: AuthStorageData = { ...currentData, [provider]: next };\n\t\t\tpersistedData = merged;\n\t\t\treturn { result: next, next: JSON.stringify(merged, null, 2) };\n\t\t});\n\t\tconst result = signal === undefined ? await operation : await raceWithAbortSignal(operation, signal);\n\t\tif (persistedData) this.data = persistedData;\n\t\tthis.loadedVersion = undefined;\n\t\treturn result;\n\t}\n\n\tasync delete(provider: string): Promise<void> {\n\t\tprovider = normalizeProviderId(provider);\n\t\tif (this.storage.deleteProviderAsync) {\n\t\t\tif (provider === \"azure\") await this.storage.deleteProviderAsync(LEGACY_AZURE_PROVIDER);\n\t\t\tconst content = await this.storage.deleteProviderAsync(provider);\n\t\t\tthis.data = this.parseStorageData(content);\n\t\t\tthis.loadedVersion = undefined;\n\t\t\treturn;\n\t\t}\n\t\tlet persistedData: AuthStorageData | undefined;\n\t\tawait this.storage.withLockAsync(async (content) => {\n\t\t\tconst currentData = this.parseStorageData(content);\n\t\t\tdelete currentData[provider];\n\t\t\tpersistedData = currentData;\n\t\t\treturn { result: undefined, next: JSON.stringify(currentData, null, 2) };\n\t\t});\n\t\tif (persistedData) this.data = persistedData;\n\t\tthis.loadedVersion = undefined;\n\t}\n\n\t/** List credential metadata without resolving configured key values. */\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tthis.reloadIfChanged();\n\t\treturn Object.entries(this.data).map(([providerId, credential]) => ({ providerId, type: credential.type }));\n\t}\n}\n\n/**\n * Read credentials without acquiring a lock, creating auth.json, or allowing a\n * refresh to persist a mutation. `auth check --no-refresh` uses this store.\n * It resolves configured key values, including `!command`, like `AuthStorage`.\n * Unlike `AuthStorage.reload()`, malformed data fails closed so the probe can\n * report invalid auth state instead of silently treating it as no credentials.\n */\nexport class ReadOnlyAuthStorage implements CredentialStore {\n\tprivate data: AuthStorageData | undefined;\n\tprivate readonly storage: FileAuthStorageBackend;\n\n\tconstructor(authPath?: string | string[]) {\n\t\tconst paths =\n\t\t\tauthPath === undefined ? getAgentConfigPaths(\"auth.json\") : Array.isArray(authPath) ? authPath : [authPath];\n\t\tthis.storage = new FileAuthStorageBackend(paths[0] ?? join(getAgentDir(), \"auth.json\"), paths);\n\t}\n\n\tprivate load(): AuthStorageData {\n\t\tif (this.data !== undefined) return this.data;\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tconst content = this.storage.read();\n\t\t\tparsed = content === undefined ? {} : JSON.parse(stripBom(content));\n\t\t} catch (error) {\n\t\t\t// The no-refresh path must not turn a corrupt auth file into an empty\n\t\t\t// credential set. Surface invalid state without touching the file.\n\t\t\tthrow new Error(`Failed to read auth.json: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\n\t\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\t\tthrow new Error(\"Invalid auth.json: expected an object\");\n\t\t}\n\t\tfor (const [providerId, credential] of Object.entries(parsed)) {\n\t\t\tif (typeof credential !== \"object\" || credential === null || Array.isArray(credential)) {\n\t\t\t\tthrow new Error(`Invalid auth.json credential for provider \"${providerId}\"`);\n\t\t\t}\n\t\t\tconst value = credential as Record<string, unknown>;\n\t\t\tif (value.type === \"api_key\") {\n\t\t\t\tconst env = value.env;\n\t\t\t\tconst validKey = value.key === undefined || typeof value.key === \"string\";\n\t\t\t\tconst validEnv =\n\t\t\t\t\tenv === undefined ||\n\t\t\t\t\t(typeof env === \"object\" &&\n\t\t\t\t\t\tenv !== null &&\n\t\t\t\t\t\t!Array.isArray(env) &&\n\t\t\t\t\t\tObject.values(env).every((entry) => typeof entry === \"string\"));\n\t\t\t\tif (validKey && validEnv) continue;\n\t\t\t} else if (\n\t\t\t\tvalue.type === \"oauth\" &&\n\t\t\t\ttypeof value.access === \"string\" &&\n\t\t\t\ttypeof value.refresh === \"string\" &&\n\t\t\t\ttypeof value.expires === \"number\" &&\n\t\t\t\tNumber.isFinite(value.expires)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new Error(`Invalid auth.json credential for provider \"${providerId}\"`);\n\t\t}\n\n\t\tthis.data = normalizeProviderKeys(parsed as AuthStorageData);\n\t\treturn this.data;\n\t}\n\n\t/** Raw configured values for privacy screening; never execute API-key commands. */\n\tpeek(providerId: string): Credential | undefined {\n\t\treturn this.load()[normalizeProviderId(providerId)];\n\t}\n\n\tasync read(providerId: string, options?: AuthOperationOptions): Promise<Credential | undefined> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst credential = this.peek(providerId);\n\t\toptions?.signal?.throwIfAborted();\n\t\tif (!credential) return undefined;\n\t\tif (credential.type !== \"api_key\" || credential.key === undefined) {\n\t\t\treturn structuredClone(credential);\n\t\t}\n\t\treturn { ...credential, key: resolveConfigValue(credential.key, credential.env) };\n\t}\n\n\tasync list(options?: AuthOperationOptions): Promise<readonly CredentialInfo[]> {\n\t\toptions?.signal?.throwIfAborted();\n\t\tconst credentials = Object.entries(this.load()).map(([providerId, credential]) => ({\n\t\t\tproviderId,\n\t\t\ttype: credential.type,\n\t\t}));\n\t\toptions?.signal?.throwIfAborted();\n\t\treturn credentials;\n\t}\n\n\tasync modify(\n\t\t_providerId: string,\n\t\t_fn: (current: Credential | undefined) => Promise<Credential | undefined>,\n\t\t_options?: AuthOperationOptions,\n\t): Promise<Credential | undefined> {\n\t\tthrow new Error(\"Read-only credential storage cannot modify auth.json\");\n\t}\n\n\tasync delete(_providerId: string, _options?: AuthOperationOptions): Promise<void> {\n\t\tthrow new Error(\"Read-only credential storage cannot modify auth.json\");\n\t}\n}\n\n/** Read one persisted provider credential using Atomic's layered auth.json paths. */\nexport function readStoredCredential(providerId: string, authPath?: string | string[]): Credential | undefined {\n\tconst paths =\n\t\tauthPath === undefined ? getAgentConfigPaths(\"auth.json\") : Array.isArray(authPath) ? authPath : [authPath];\n\tconst storage = new FileAuthStorageBackend(paths[0] ?? join(getAgentDir(), \"auth.json\"), paths);\n\ttry {\n\t\tlet credential: Credential | undefined;\n\t\tstorage.withLock((content) => {\n\t\t\tcredential = content\n\t\t\t\t? normalizeProviderKeys(JSON.parse(stripBom(content)) as AuthStorageData)[normalizeProviderId(providerId)]\n\t\t\t\t: undefined;\n\t\t\treturn { result: undefined };\n\t\t});\n\t\treturn credential;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
@@ -117,6 +117,23 @@
|
|
|
117
117
|
return null;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
// Mirrors src/core/tools/render-utils.ts.
|
|
121
|
+
function parseLineNumber(value) {
|
|
122
|
+
if (typeof value === 'string' && value.trim() !== '') value = Number(value);
|
|
123
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function formatReadLineRange(offset, limit) {
|
|
127
|
+
if (offset == null && limit == null) return '';
|
|
128
|
+
const start = offset == null ? 1 : parseLineNumber(offset);
|
|
129
|
+
if (start === undefined) return '';
|
|
130
|
+
if (limit == null) return `:${start}`;
|
|
131
|
+
const count = parseLineNumber(limit);
|
|
132
|
+
if (count === undefined) return '';
|
|
133
|
+
const end = start + count - 1;
|
|
134
|
+
return `:${start}${end ? `-${end}` : ''}`;
|
|
135
|
+
}
|
|
136
|
+
|
|
120
137
|
function getLanguageFromPath(filePath) {
|
|
121
138
|
const ext = filePath.split('.').pop()?.toLowerCase();
|
|
122
139
|
const extToLang = {
|
|
@@ -241,14 +258,10 @@
|
|
|
241
258
|
}
|
|
242
259
|
case 'read': {
|
|
243
260
|
const filePath = str(args.file_path ?? args.path);
|
|
244
|
-
const
|
|
245
|
-
const limit = args.limit;
|
|
246
|
-
|
|
261
|
+
const readLineRange = formatReadLineRange(args.offset, args.limit);
|
|
247
262
|
let pathHtml = filePath === null ? invalidArg : escapeHtml(shortenPath(filePath || ''));
|
|
248
|
-
if (filePath !== null &&
|
|
249
|
-
|
|
250
|
-
const endLine = limit !== undefined ? startLine + limit - 1 : '';
|
|
251
|
-
pathHtml += `<span class="line-numbers">:${startLine}${endLine ? '-' + endLine : ''}</span>`;
|
|
263
|
+
if (filePath !== null && readLineRange) {
|
|
264
|
+
pathHtml += `<span class="line-numbers">${escapeHtml(readLineRange)}</span>`;
|
|
252
265
|
}
|
|
253
266
|
|
|
254
267
|
html += `<div class="tool-header"><span class="tool-name">read</span> <span class="tool-path">${pathHtml}</span></div>`;
|
|
@@ -292,15 +292,7 @@
|
|
|
292
292
|
switch (name) {
|
|
293
293
|
case 'read': {
|
|
294
294
|
const path = shortenPath(String(args.path || args.file_path || ''));
|
|
295
|
-
|
|
296
|
-
const limit = args.limit;
|
|
297
|
-
let display = path;
|
|
298
|
-
if (offset !== undefined || limit !== undefined) {
|
|
299
|
-
const start = offset ?? 1;
|
|
300
|
-
const end = limit !== undefined ? start + limit - 1 : '';
|
|
301
|
-
display += `:${start}${end ? `-${end}` : ''}`;
|
|
302
|
-
}
|
|
303
|
-
return `[read: ${display}]`;
|
|
295
|
+
return `[read: ${path}${formatReadLineRange(args.offset, args.limit)}]`;
|
|
304
296
|
}
|
|
305
297
|
case 'write':
|
|
306
298
|
return `[write: ${shortenPath(String(args.path || args.file_path || ''))}]`;
|
|
@@ -581,15 +581,7 @@
|
|
|
581
581
|
switch (name) {
|
|
582
582
|
case 'read': {
|
|
583
583
|
const path = shortenPath(String(args.path || args.file_path || ''));
|
|
584
|
-
|
|
585
|
-
const limit = args.limit;
|
|
586
|
-
let display = path;
|
|
587
|
-
if (offset !== undefined || limit !== undefined) {
|
|
588
|
-
const start = offset ?? 1;
|
|
589
|
-
const end = limit !== undefined ? start + limit - 1 : '';
|
|
590
|
-
display += `:${start}${end ? `-${end}` : ''}`;
|
|
591
|
-
}
|
|
592
|
-
return `[read: ${display}]`;
|
|
584
|
+
return `[read: ${path}${formatReadLineRange(args.offset, args.limit)}]`;
|
|
593
585
|
}
|
|
594
586
|
case 'write':
|
|
595
587
|
return `[write: ${shortenPath(String(args.path || args.file_path || ''))}]`;
|
|
@@ -833,6 +825,23 @@
|
|
|
833
825
|
return null;
|
|
834
826
|
}
|
|
835
827
|
|
|
828
|
+
// Mirrors src/core/tools/render-utils.ts.
|
|
829
|
+
function parseLineNumber(value) {
|
|
830
|
+
if (typeof value === 'string' && value.trim() !== '') value = Number(value);
|
|
831
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function formatReadLineRange(offset, limit) {
|
|
835
|
+
if (offset == null && limit == null) return '';
|
|
836
|
+
const start = offset == null ? 1 : parseLineNumber(offset);
|
|
837
|
+
if (start === undefined) return '';
|
|
838
|
+
if (limit == null) return `:${start}`;
|
|
839
|
+
const count = parseLineNumber(limit);
|
|
840
|
+
if (count === undefined) return '';
|
|
841
|
+
const end = start + count - 1;
|
|
842
|
+
return `:${start}${end ? `-${end}` : ''}`;
|
|
843
|
+
}
|
|
844
|
+
|
|
836
845
|
function getLanguageFromPath(filePath) {
|
|
837
846
|
const ext = filePath.split('.').pop()?.toLowerCase();
|
|
838
847
|
const extToLang = {
|
|
@@ -957,14 +966,10 @@
|
|
|
957
966
|
}
|
|
958
967
|
case 'read': {
|
|
959
968
|
const filePath = str(args.file_path ?? args.path);
|
|
960
|
-
const
|
|
961
|
-
const limit = args.limit;
|
|
962
|
-
|
|
969
|
+
const readLineRange = formatReadLineRange(args.offset, args.limit);
|
|
963
970
|
let pathHtml = filePath === null ? invalidArg : escapeHtml(shortenPath(filePath || ''));
|
|
964
|
-
if (filePath !== null &&
|
|
965
|
-
|
|
966
|
-
const endLine = limit !== undefined ? startLine + limit - 1 : '';
|
|
967
|
-
pathHtml += `<span class="line-numbers">:${startLine}${endLine ? '-' + endLine : ''}</span>`;
|
|
971
|
+
if (filePath !== null && readLineRange) {
|
|
972
|
+
pathHtml += `<span class="line-numbers">${escapeHtml(readLineRange)}</span>`;
|
|
968
973
|
}
|
|
969
974
|
|
|
970
975
|
html += `<div class="tool-header"><span class="tool-name">read</span> <span class="tool-path">${pathHtml}</span></div>`;
|
|
@@ -73,7 +73,6 @@ export declare const ModelsJsonCompatSchema: Type.TObject<{
|
|
|
73
73
|
forceAdaptiveThinking: Type.TOptional<Type.TBoolean>;
|
|
74
74
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
75
75
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
76
|
-
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
77
76
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
78
77
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
79
78
|
provider: Type.TString;
|
|
@@ -97,6 +96,7 @@ export declare const ModelsJsonCompatSchema: Type.TObject<{
|
|
|
97
96
|
supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
|
|
98
97
|
supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
|
|
99
98
|
sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
|
|
99
|
+
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
100
100
|
supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
|
|
101
101
|
supportsStrictMode: Type.TOptional<Type.TBoolean>;
|
|
102
102
|
supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
|
|
@@ -236,7 +236,6 @@ declare const ModelDefinitionSchema: Type.TObject<{
|
|
|
236
236
|
forceAdaptiveThinking: Type.TOptional<Type.TBoolean>;
|
|
237
237
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
238
238
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
239
|
-
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
240
239
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
241
240
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
242
241
|
provider: Type.TString;
|
|
@@ -260,6 +259,7 @@ declare const ModelDefinitionSchema: Type.TObject<{
|
|
|
260
259
|
supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
|
|
261
260
|
supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
|
|
262
261
|
sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
|
|
262
|
+
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
263
263
|
supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
|
|
264
264
|
supportsStrictMode: Type.TOptional<Type.TBoolean>;
|
|
265
265
|
supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
|
|
@@ -397,7 +397,6 @@ declare const ModelOverrideSchema: Type.TObject<{
|
|
|
397
397
|
forceAdaptiveThinking: Type.TOptional<Type.TBoolean>;
|
|
398
398
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
399
399
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
400
|
-
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
401
400
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
402
401
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
403
402
|
provider: Type.TString;
|
|
@@ -421,6 +420,7 @@ declare const ModelOverrideSchema: Type.TObject<{
|
|
|
421
420
|
supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
|
|
422
421
|
supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
|
|
423
422
|
sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
|
|
423
|
+
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
424
424
|
supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
|
|
425
425
|
supportsStrictMode: Type.TOptional<Type.TBoolean>;
|
|
426
426
|
supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
|
|
@@ -509,7 +509,6 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
509
509
|
forceAdaptiveThinking: Type.TOptional<Type.TBoolean>;
|
|
510
510
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
511
511
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
512
|
-
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
513
512
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
514
513
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
515
514
|
provider: Type.TString;
|
|
@@ -533,6 +532,7 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
533
532
|
supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
|
|
534
533
|
supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
|
|
535
534
|
sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
|
|
535
|
+
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
536
536
|
supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
|
|
537
537
|
supportsStrictMode: Type.TOptional<Type.TBoolean>;
|
|
538
538
|
supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
|
|
@@ -673,7 +673,6 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
673
673
|
forceAdaptiveThinking: Type.TOptional<Type.TBoolean>;
|
|
674
674
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
675
675
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
676
|
-
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
677
676
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
678
677
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
679
678
|
provider: Type.TString;
|
|
@@ -697,6 +696,7 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
697
696
|
supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
|
|
698
697
|
supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
|
|
699
698
|
sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
|
|
699
|
+
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
700
700
|
supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
|
|
701
701
|
supportsStrictMode: Type.TOptional<Type.TBoolean>;
|
|
702
702
|
supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
|
|
@@ -834,7 +834,6 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
834
834
|
forceAdaptiveThinking: Type.TOptional<Type.TBoolean>;
|
|
835
835
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
836
836
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
837
|
-
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
838
837
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
839
838
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
840
839
|
provider: Type.TString;
|
|
@@ -858,6 +857,7 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
858
857
|
supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
|
|
859
858
|
supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
|
|
860
859
|
sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
|
|
860
|
+
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
861
861
|
supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
|
|
862
862
|
supportsStrictMode: Type.TOptional<Type.TBoolean>;
|
|
863
863
|
supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
|
|
@@ -949,7 +949,6 @@ export declare const ModelsConfigSchema: Type.TObject<{
|
|
|
949
949
|
forceAdaptiveThinking: Type.TOptional<Type.TBoolean>;
|
|
950
950
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
951
951
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
952
|
-
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
953
952
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
954
953
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
955
954
|
provider: Type.TString;
|
|
@@ -973,6 +972,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
|
|
|
973
972
|
supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
|
|
974
973
|
supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
|
|
975
974
|
sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
|
|
975
|
+
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
976
976
|
supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
|
|
977
977
|
supportsStrictMode: Type.TOptional<Type.TBoolean>;
|
|
978
978
|
supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
|
|
@@ -1113,7 +1113,6 @@ export declare const ModelsConfigSchema: Type.TObject<{
|
|
|
1113
1113
|
forceAdaptiveThinking: Type.TOptional<Type.TBoolean>;
|
|
1114
1114
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
1115
1115
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
1116
|
-
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
1117
1116
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
1118
1117
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
1119
1118
|
provider: Type.TString;
|
|
@@ -1137,6 +1136,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
|
|
|
1137
1136
|
supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
|
|
1138
1137
|
supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
|
|
1139
1138
|
sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
|
|
1139
|
+
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
1140
1140
|
supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
|
|
1141
1141
|
supportsStrictMode: Type.TOptional<Type.TBoolean>;
|
|
1142
1142
|
supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
|
|
@@ -1274,7 +1274,6 @@ export declare const ModelsConfigSchema: Type.TObject<{
|
|
|
1274
1274
|
forceAdaptiveThinking: Type.TOptional<Type.TBoolean>;
|
|
1275
1275
|
allowEmptySignature: Type.TOptional<Type.TBoolean>;
|
|
1276
1276
|
supportsStrictTools: Type.TOptional<Type.TBoolean>;
|
|
1277
|
-
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
1278
1277
|
supportsMidConvoToolChanges: Type.TOptional<Type.TBoolean>;
|
|
1279
1278
|
allowedFallbackModels: Type.TOptional<Type.TArray<Type.TObject<{
|
|
1280
1279
|
provider: Type.TString;
|
|
@@ -1298,6 +1297,7 @@ export declare const ModelsConfigSchema: Type.TObject<{
|
|
|
1298
1297
|
supportsDeveloperRole: Type.TOptional<Type.TBoolean>;
|
|
1299
1298
|
supportsMidConvoSystemMessages: Type.TOptional<Type.TBoolean>;
|
|
1300
1299
|
sessionAffinityFormat: Type.TOptional<Type.TUnion<[Type.TLiteral<"openai">, Type.TLiteral<"openai-nosession">, Type.TLiteral<"openrouter">]>>;
|
|
1300
|
+
supportsMidConvoEffort: Type.TOptional<Type.TBoolean>;
|
|
1301
1301
|
supportsLongCacheRetention: Type.TOptional<Type.TBoolean>;
|
|
1302
1302
|
supportsStrictMode: Type.TOptional<Type.TBoolean>;
|
|
1303
1303
|
supportsOpenAIGrammarTools: Type.TOptional<Type.TBoolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-fallback-failures.d.ts","sourceRoot":"","sources":["../../src/core/model-fallback-failures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"model-fallback-failures.d.ts","sourceRoot":"","sources":["../../src/core/model-fallback-failures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA+EH,MAAM,MAAM,wBAAwB,GACjC,4BAA4B,GAC5B,YAAY,GACZ,sBAAsB,GACtB,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,sBAAsB,GACtB,WAAW,GACX,cAAc,GACd,SAAS,CAAC;AAEb,MAAM,MAAM,0BAA0B,GACnC,mBAAmB,GACnB,YAAY,GACZ,OAAO,GACP,YAAY,GACZ,iBAAiB,CAAC;AAErB,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACvB;AA0gBD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKnD;AAED,qEAAqE;AACrE,eAAO,MAAM,mBAAmB,qBAAe,CAAC;AAEhD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,0BAA0B,CAYtF;AAED,2EAA2E;AAC3E,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK9D;AAED,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAG/D;AASD,gFAAgF;AAChF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAcnE"}
|
|
@@ -37,12 +37,14 @@ const RETRYABLE_MODEL_FAILURE_PATTERNS = [
|
|
|
37
37
|
/timeout/i,
|
|
38
38
|
/timed\s*out/i,
|
|
39
39
|
/\b50[0-4]\b/,
|
|
40
|
-
/\
|
|
40
|
+
/\b52[0-4]\b/,
|
|
41
41
|
/provider.?returned.?error/i,
|
|
42
42
|
/server.?error/i,
|
|
43
43
|
/internal.?error/i,
|
|
44
44
|
/connection.?error/i,
|
|
45
45
|
/connection.?lost/i,
|
|
46
|
+
/connection.?reset/i,
|
|
47
|
+
/ECONNRESET/i,
|
|
46
48
|
/other side closed/i,
|
|
47
49
|
/websocket.?closed/i,
|
|
48
50
|
/websocket.?error/i,
|