chore: update deps and pi model discovery
This commit is contained in:
parent
85dd070dea
commit
08ed62852a
32 changed files with 1424 additions and 1419 deletions
|
|
@ -10,8 +10,8 @@ read_when:
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<picture>
|
<picture>
|
||||||
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/openclaw/openclaw/main/docs/assets/openclaw-logo-text-dark.png">
|
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/openclaw/openclaw/main/docs/assets/openclaw-logo-text-dark.png" />
|
||||||
<img src="https://raw.githubusercontent.com/openclaw/openclaw/main/docs/assets/openclaw-logo-text.png" alt="OpenClaw" width="500">
|
<img src="https://raw.githubusercontent.com/openclaw/openclaw/main/docs/assets/openclaw-logo-text.png" alt="OpenClaw" width="500" />
|
||||||
</picture>
|
</picture>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@matrix-org/matrix-sdk-crypto-nodejs": "^0.4.0",
|
"@matrix-org/matrix-sdk-crypto-nodejs": "^0.4.0",
|
||||||
"markdown-it": "14.1.0",
|
|
||||||
"@vector-im/matrix-bot-sdk": "0.8.0-element.3",
|
"@vector-im/matrix-bot-sdk": "0.8.0-element.3",
|
||||||
"music-metadata": "^11.10.6",
|
"markdown-it": "14.1.0",
|
||||||
|
"music-metadata": "^11.11.1",
|
||||||
"zod": "^4.3.6"
|
"zod": "^4.3.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lancedb/lancedb": "^0.23.0",
|
"@lancedb/lancedb": "^0.23.0",
|
||||||
"@sinclair/typebox": "0.34.47",
|
"@sinclair/typebox": "0.34.47",
|
||||||
"openai": "^6.16.0"
|
"openai": "^6.17.0"
|
||||||
},
|
},
|
||||||
"openclaw": {
|
"openclaw": {
|
||||||
"extensions": [
|
"extensions": [
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@microsoft/agents-hosting": "^1.2.2",
|
"@microsoft/agents-hosting": "^1.2.3",
|
||||||
"@microsoft/agents-hosting-express": "^1.2.2",
|
"@microsoft/agents-hosting-express": "^1.2.3",
|
||||||
"@microsoft/agents-hosting-extensions-teams": "^1.2.2",
|
"@microsoft/agents-hosting-extensions-teams": "^1.2.3",
|
||||||
"openclaw": "workspace:*",
|
|
||||||
"express": "^5.2.1",
|
"express": "^5.2.1",
|
||||||
|
"openclaw": "workspace:*",
|
||||||
"proper-lockfile": "^4.1.2"
|
"proper-lockfile": "^4.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"nostr-tools": "^2.22.1",
|
||||||
"openclaw": "workspace:*",
|
"openclaw": "workspace:*",
|
||||||
"nostr-tools": "^2.20.0",
|
|
||||||
"zod": "^4.3.6"
|
"zod": "^4.3.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
"@twurple/api": "^8.0.3",
|
"@twurple/api": "^8.0.3",
|
||||||
"@twurple/auth": "^8.0.3",
|
"@twurple/auth": "^8.0.3",
|
||||||
"@twurple/chat": "^8.0.3",
|
"@twurple/chat": "^8.0.3",
|
||||||
"zod": "^4.3.5"
|
"zod": "^4.3.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"openclaw": "workspace:*"
|
"openclaw": "workspace:*"
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,6 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"openclaw": "workspace:*",
|
"openclaw": "workspace:*",
|
||||||
"undici": "7.19.0"
|
"undici": "7.19.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "OpenClaw Zalo Personal Account plugin via zca-cli",
|
"description": "OpenClaw Zalo Personal Account plugin via zca-cli",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"openclaw": "workspace:*",
|
"@sinclair/typebox": "0.34.47",
|
||||||
"@sinclair/typebox": "0.34.47"
|
"openclaw": "workspace:*"
|
||||||
},
|
},
|
||||||
"openclaw": {
|
"openclaw": {
|
||||||
"extensions": [
|
"extensions": [
|
||||||
|
|
|
||||||
30
package.json
30
package.json
|
|
@ -155,9 +155,9 @@
|
||||||
"packageManager": "pnpm@10.23.0",
|
"packageManager": "pnpm@10.23.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@agentclientprotocol/sdk": "0.13.1",
|
"@agentclientprotocol/sdk": "0.13.1",
|
||||||
"@aws-sdk/client-bedrock": "^3.975.0",
|
"@aws-sdk/client-bedrock": "^3.980.0",
|
||||||
"@buape/carbon": "0.14.0",
|
"@buape/carbon": "0.14.0",
|
||||||
"@clack/prompts": "^0.11.0",
|
"@clack/prompts": "^1.0.0",
|
||||||
"@grammyjs/runner": "^2.0.3",
|
"@grammyjs/runner": "^2.0.3",
|
||||||
"@grammyjs/transformer-throttler": "^1.2.1",
|
"@grammyjs/transformer-throttler": "^1.2.1",
|
||||||
"@homebridge/ciao": "^1.3.4",
|
"@homebridge/ciao": "^1.3.4",
|
||||||
|
|
@ -176,12 +176,12 @@
|
||||||
"body-parser": "^2.2.2",
|
"body-parser": "^2.2.2",
|
||||||
"chalk": "^5.6.2",
|
"chalk": "^5.6.2",
|
||||||
"chokidar": "^5.0.0",
|
"chokidar": "^5.0.0",
|
||||||
"chromium-bidi": "13.0.1",
|
"chromium-bidi": "13.1.0",
|
||||||
"cli-highlight": "^2.1.11",
|
"cli-highlight": "^2.1.11",
|
||||||
"commander": "^14.0.2",
|
"commander": "^14.0.3",
|
||||||
"croner": "^9.1.0",
|
"croner": "^9.1.0",
|
||||||
"detect-libc": "^2.1.2",
|
"detect-libc": "^2.1.2",
|
||||||
"discord-api-types": "^0.38.37",
|
"discord-api-types": "^0.38.38",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"express": "^5.2.1",
|
"express": "^5.2.1",
|
||||||
"file-type": "^21.3.0",
|
"file-type": "^21.3.0",
|
||||||
|
|
@ -196,21 +196,21 @@
|
||||||
"node-edge-tts": "^1.2.9",
|
"node-edge-tts": "^1.2.9",
|
||||||
"osc-progress": "^0.3.0",
|
"osc-progress": "^0.3.0",
|
||||||
"pdfjs-dist": "^5.4.530",
|
"pdfjs-dist": "^5.4.530",
|
||||||
"playwright-core": "1.58.0",
|
"playwright-core": "1.58.1",
|
||||||
"proper-lockfile": "^4.1.2",
|
"proper-lockfile": "^4.1.2",
|
||||||
"qrcode-terminal": "^0.12.0",
|
"qrcode-terminal": "^0.12.0",
|
||||||
"sharp": "^0.34.5",
|
"sharp": "^0.34.5",
|
||||||
"sqlite-vec": "0.1.7-alpha.2",
|
"sqlite-vec": "0.1.7-alpha.2",
|
||||||
"tar": "7.5.4",
|
"tar": "7.5.4",
|
||||||
"tslog": "^4.10.2",
|
"tslog": "^4.10.2",
|
||||||
"undici": "^7.19.0",
|
"undici": "^7.19.2",
|
||||||
"ws": "^8.19.0",
|
"ws": "^8.19.0",
|
||||||
"yaml": "^2.8.2",
|
"yaml": "^2.8.2",
|
||||||
"zod": "^4.3.6"
|
"zod": "^4.3.6"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@napi-rs/canvas": "^0.1.88",
|
"@napi-rs/canvas": "^0.1.89",
|
||||||
"node-llama-cpp": "3.15.0"
|
"node-llama-cpp": "3.15.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@grammyjs/types": "^3.23.0",
|
"@grammyjs/types": "^3.23.0",
|
||||||
|
|
@ -220,21 +220,21 @@
|
||||||
"@types/body-parser": "^1.19.6",
|
"@types/body-parser": "^1.19.6",
|
||||||
"@types/express": "^5.0.6",
|
"@types/express": "^5.0.6",
|
||||||
"@types/markdown-it": "^14.1.2",
|
"@types/markdown-it": "^14.1.2",
|
||||||
"@types/node": "^25.0.10",
|
"@types/node": "^25.1.0",
|
||||||
"@types/proper-lockfile": "^4.1.4",
|
"@types/proper-lockfile": "^4.1.4",
|
||||||
"@types/qrcode-terminal": "^0.12.2",
|
"@types/qrcode-terminal": "^0.12.2",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"@typescript/native-preview": "7.0.0-dev.20260124.1",
|
"@typescript/native-preview": "7.0.0-dev.20260130.1",
|
||||||
"@vitest/coverage-v8": "^4.0.18",
|
"@vitest/coverage-v8": "^4.0.18",
|
||||||
"docx-preview": "^0.3.7",
|
"docx-preview": "^0.3.7",
|
||||||
"lit": "^3.3.2",
|
"lit": "^3.3.2",
|
||||||
"lucide": "^0.563.0",
|
"lucide": "^0.563.0",
|
||||||
"ollama": "^0.6.3",
|
"ollama": "^0.6.3",
|
||||||
"oxfmt": "0.26.0",
|
"oxfmt": "0.27.0",
|
||||||
"oxlint": "^1.41.0",
|
"oxlint": "^1.42.0",
|
||||||
"oxlint-tsgolint": "^0.11.1",
|
"oxlint-tsgolint": "^0.11.4",
|
||||||
"quicktype-core": "^23.2.6",
|
"quicktype-core": "^23.2.6",
|
||||||
"rolldown": "1.0.0-rc.1",
|
"rolldown": "1.0.0-rc.2",
|
||||||
"signal-utils": "^0.21.1",
|
"signal-utils": "^0.21.1",
|
||||||
"tsx": "^4.21.0",
|
"tsx": "^4.21.0",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
|
|
|
||||||
2651
pnpm-lock.yaml
2651
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
|
@ -4,7 +4,7 @@ import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
|
||||||
import { type Api, completeSimple, type Model } from "@mariozechner/pi-ai";
|
import { type Api, completeSimple, type Model } from "@mariozechner/pi-ai";
|
||||||
import { discoverAuthStorage, discoverModels } from "@mariozechner/pi-coding-agent";
|
import { discoverAuthStorage, discoverModels } from "./pi-model-discovery.js";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { isTruthyEnvValue } from "../infra/env.js";
|
import { isTruthyEnvValue } from "../infra/env.js";
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
// Lazy-load pi-coding-agent model metadata so we can infer context windows when
|
// Lazy-load pi-coding-agent model metadata so we can infer context windows when
|
||||||
// the agent reports a model id. This includes custom models.json entries.
|
// the agent reports a model id. This includes custom models.json entries.
|
||||||
|
|
||||||
import { join } from "node:path";
|
|
||||||
|
|
||||||
import { loadConfig } from "../config/config.js";
|
import { loadConfig } from "../config/config.js";
|
||||||
import { resolveOpenClawAgentDir } from "./agent-paths.js";
|
import { resolveOpenClawAgentDir } from "./agent-paths.js";
|
||||||
import { ensureOpenClawModelsJson } from "./models-config.js";
|
import { ensureOpenClawModelsJson } from "./models-config.js";
|
||||||
|
|
@ -12,12 +10,12 @@ type ModelEntry = { id: string; contextWindow?: number };
|
||||||
const MODEL_CACHE = new Map<string, number>();
|
const MODEL_CACHE = new Map<string, number>();
|
||||||
const loadPromise = (async () => {
|
const loadPromise = (async () => {
|
||||||
try {
|
try {
|
||||||
const { AuthStorage, ModelRegistry } = await import("@mariozechner/pi-coding-agent");
|
const { discoverAuthStorage, discoverModels } = await import("./pi-model-discovery.js");
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
await ensureOpenClawModelsJson(cfg);
|
await ensureOpenClawModelsJson(cfg);
|
||||||
const agentDir = resolveOpenClawAgentDir();
|
const agentDir = resolveOpenClawAgentDir();
|
||||||
const authStorage = new AuthStorage(join(agentDir, "auth.json"));
|
const authStorage = discoverAuthStorage(agentDir);
|
||||||
const modelRegistry = new ModelRegistry(authStorage, join(agentDir, "models.json"));
|
const modelRegistry = discoverModels(authStorage, agentDir);
|
||||||
const models = modelRegistry.getAll() as ModelEntry[];
|
const models = modelRegistry.getAll() as ModelEntry[];
|
||||||
for (const m of models) {
|
for (const m of models) {
|
||||||
if (!m?.id) continue;
|
if (!m?.id) continue;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import {
|
||||||
resetModelCatalogCacheForTest,
|
resetModelCatalogCacheForTest,
|
||||||
} from "./model-catalog.js";
|
} from "./model-catalog.js";
|
||||||
|
|
||||||
type PiSdkModule = typeof import("@mariozechner/pi-coding-agent");
|
type PiSdkModule = typeof import("./pi-model-discovery.js");
|
||||||
|
|
||||||
vi.mock("./models-config.js", () => ({
|
vi.mock("./models-config.js", () => ({
|
||||||
ensureOpenClawModelsJson: vi.fn().mockResolvedValue({ agentDir: "/tmp", wrote: false }),
|
ensureOpenClawModelsJson: vi.fn().mockResolvedValue({ agentDir: "/tmp", wrote: false }),
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ type DiscoveredModel = {
|
||||||
input?: Array<"text" | "image">;
|
input?: Array<"text" | "image">;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PiSdkModule = typeof import("@mariozechner/pi-coding-agent");
|
type PiSdkModule = typeof import("./pi-model-discovery.js");
|
||||||
|
|
||||||
let modelCatalogPromise: Promise<ModelCatalogEntry[]> | null = null;
|
let modelCatalogPromise: Promise<ModelCatalogEntry[]> | null = null;
|
||||||
let hasLoggedModelCatalogError = false;
|
let hasLoggedModelCatalogError = false;
|
||||||
const defaultImportPiSdk = () => import("@mariozechner/pi-coding-agent");
|
const defaultImportPiSdk = () => import("./pi-model-discovery.js");
|
||||||
let importPiSdk = defaultImportPiSdk;
|
let importPiSdk = defaultImportPiSdk;
|
||||||
|
|
||||||
export function resetModelCatalogCacheForTest() {
|
export function resetModelCatalogCacheForTest() {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { type Api, completeSimple, type Model } from "@mariozechner/pi-ai";
|
import { type Api, completeSimple, type Model } from "@mariozechner/pi-ai";
|
||||||
import { discoverAuthStorage, discoverModels } from "@mariozechner/pi-coding-agent";
|
import { discoverAuthStorage, discoverModels } from "./pi-model-discovery.js";
|
||||||
import { Type } from "@sinclair/typebox";
|
import { Type } from "@sinclair/typebox";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { loadConfig } from "../config/config.js";
|
import { loadConfig } from "../config/config.js";
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,17 @@ export async function compactEmbeddedPiSessionDirect(
|
||||||
await resourceLoader.reload();
|
await resourceLoader.reload();
|
||||||
|
|
||||||
let session: Awaited<ReturnType<typeof createAgentSession>>["session"];
|
let session: Awaited<ReturnType<typeof createAgentSession>>["session"];
|
||||||
|
const resourceLoader = new DefaultResourceLoader({
|
||||||
|
cwd: resolvedWorkspace,
|
||||||
|
agentDir,
|
||||||
|
settingsManager,
|
||||||
|
additionalExtensionPaths,
|
||||||
|
systemPromptOverride: systemPrompt,
|
||||||
|
skillsOverride: () => ({ skills: [], diagnostics: [] }),
|
||||||
|
agentsFilesOverride: () => ({ agentsFiles: [] }),
|
||||||
|
});
|
||||||
|
await resourceLoader.reload();
|
||||||
|
|
||||||
({ session } = await createAgentSession({
|
({ session } = await createAgentSession({
|
||||||
cwd: resolvedWorkspace,
|
cwd: resolvedWorkspace,
|
||||||
agentDir,
|
agentDir,
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-coding-agent", () => ({
|
vi.mock("../pi-model-discovery.js", () => ({
|
||||||
AuthStorage: class {
|
discoverAuthStorage: vi.fn(() => ({ mocked: true })),
|
||||||
mocked = true;
|
discoverModels: vi.fn(() => ({ find: vi.fn(() => null) })),
|
||||||
},
|
|
||||||
ModelRegistry: class {
|
|
||||||
find() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
import { join } from "node:path";
|
|
||||||
|
|
||||||
import type { Api, Model } from "@mariozechner/pi-ai";
|
import type { Api, Model } from "@mariozechner/pi-ai";
|
||||||
import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
import {
|
||||||
|
discoverAuthStorage,
|
||||||
|
discoverModels,
|
||||||
|
type AuthStorage,
|
||||||
|
type ModelRegistry,
|
||||||
|
} from "../pi-model-discovery.js";
|
||||||
|
|
||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
import type { ModelDefinitionConfig } from "../../config/types.js";
|
import type { ModelDefinitionConfig } from "../../config/types.js";
|
||||||
|
|
@ -59,8 +62,8 @@ export function resolveModel(
|
||||||
modelRegistry: ModelRegistry;
|
modelRegistry: ModelRegistry;
|
||||||
} {
|
} {
|
||||||
const resolvedAgentDir = agentDir ?? resolveOpenClawAgentDir();
|
const resolvedAgentDir = agentDir ?? resolveOpenClawAgentDir();
|
||||||
const authStorage = new AuthStorage(join(resolvedAgentDir, "auth.json"));
|
const authStorage = discoverAuthStorage(resolvedAgentDir);
|
||||||
const modelRegistry = new ModelRegistry(authStorage, join(resolvedAgentDir, "models.json"));
|
const modelRegistry = discoverModels(authStorage, resolvedAgentDir);
|
||||||
const model = modelRegistry.find(provider, modelId) as Model<Api> | null;
|
const model = modelRegistry.find(provider, modelId) as Model<Api> | null;
|
||||||
if (!model) {
|
if (!model) {
|
||||||
const providers = cfg?.models?.providers ?? {};
|
const providers = cfg?.models?.providers ?? {};
|
||||||
|
|
|
||||||
|
|
@ -458,11 +458,10 @@ export async function runEmbeddedAttempt(
|
||||||
settingsManager,
|
settingsManager,
|
||||||
additionalExtensionPaths,
|
additionalExtensionPaths,
|
||||||
noSkills: true,
|
noSkills: true,
|
||||||
systemPromptOverride: () => systemPrompt(""),
|
systemPromptOverride: systemPrompt,
|
||||||
agentsFilesOverride: () => ({ agentsFiles: [] }),
|
agentsFilesOverride: () => ({ agentsFiles: [] }),
|
||||||
});
|
});
|
||||||
await resourceLoader.reload();
|
await resourceLoader.reload();
|
||||||
|
|
||||||
({ session } = await createAgentSession({
|
({ session } = await createAgentSession({
|
||||||
cwd: resolvedWorkspace,
|
cwd: resolvedWorkspace,
|
||||||
agentDir,
|
agentDir,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
||||||
import type { Api, AssistantMessage, ImageContent, Model } from "@mariozechner/pi-ai";
|
import type { Api, AssistantMessage, ImageContent, Model } from "@mariozechner/pi-ai";
|
||||||
import type { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
import type { AuthStorage, ModelRegistry } from "../../pi-model-discovery.js";
|
||||||
|
|
||||||
import type { ReasoningLevel, ThinkLevel, VerboseLevel } from "../../../auto-reply/thinking.js";
|
import type { ReasoningLevel, ThinkLevel, VerboseLevel } from "../../../auto-reply/thinking.js";
|
||||||
import type { OpenClawConfig } from "../../../config/config.js";
|
import type { OpenClawConfig } from "../../../config/config.js";
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export function buildEmbeddedSystemPrompt(params: {
|
||||||
|
|
||||||
export function createSystemPromptOverride(
|
export function createSystemPromptOverride(
|
||||||
systemPrompt: string,
|
systemPrompt: string,
|
||||||
): (defaultPrompt: string) => string {
|
): (defaultPrompt?: string) => string {
|
||||||
const trimmed = systemPrompt.trim();
|
const trimmed = systemPrompt.trim();
|
||||||
return () => trimmed;
|
return () => trimmed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
src/agents/pi-model-discovery.ts
Normal file
14
src/agents/pi-model-discovery.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
|
import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
||||||
|
|
||||||
|
// Compatibility helpers for pi-coding-agent 0.50+ (discover* helpers removed).
|
||||||
|
export function discoverAuthStorage(agentDir: string): AuthStorage {
|
||||||
|
return new AuthStorage(path.join(agentDir, "auth.json"));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function discoverModels(authStorage: AuthStorage, agentDir: string): ModelRegistry {
|
||||||
|
return new ModelRegistry(authStorage, path.join(agentDir, "models.json"));
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { AuthStorage, ModelRegistry };
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
complete,
|
complete,
|
||||||
type Model,
|
type Model,
|
||||||
} from "@mariozechner/pi-ai";
|
} from "@mariozechner/pi-ai";
|
||||||
import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
import { discoverAuthStorage, discoverModels } from "../pi-model-discovery.js";
|
||||||
import { Type } from "@sinclair/typebox";
|
import { Type } from "@sinclair/typebox";
|
||||||
|
|
||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
|
|
@ -233,8 +233,8 @@ async function runImagePrompt(params: {
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
await ensureOpenClawModelsJson(effectiveCfg, params.agentDir);
|
await ensureOpenClawModelsJson(effectiveCfg, params.agentDir);
|
||||||
const authStorage = new AuthStorage(path.join(params.agentDir, "auth.json"));
|
const authStorage = discoverAuthStorage(params.agentDir);
|
||||||
const modelRegistry = new ModelRegistry(authStorage, path.join(params.agentDir, "models.json"));
|
const modelRegistry = discoverModels(authStorage, params.agentDir);
|
||||||
|
|
||||||
const result = await runWithImageModelFallback({
|
const result = await runWithImageModelFallback({
|
||||||
cfg: effectiveCfg,
|
cfg: effectiveCfg,
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,9 @@ export async function applyAuthChoiceOAuth(
|
||||||
});
|
});
|
||||||
|
|
||||||
spin.stop("Chutes OAuth complete");
|
spin.stop("Chutes OAuth complete");
|
||||||
const email = typeof creds.email === "string" ? creds.email.trim() : "";
|
const email =
|
||||||
const profileId = `chutes:${email || "default"}`;
|
typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default";
|
||||||
|
const profileId = `chutes:${email}`;
|
||||||
|
|
||||||
await writeOAuthCredentials("chutes", creds, params.agentDir);
|
await writeOAuthCredentials("chutes", creds, params.agentDir);
|
||||||
nextConfig = applyAuthProfileConfig(nextConfig, {
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ vi.mock("../agents/model-auth.js", () => ({
|
||||||
getCustomProviderApiKey,
|
getCustomProviderApiKey,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-coding-agent", () => ({
|
vi.mock("../agents/pi-model-discovery.js", () => ({
|
||||||
AuthStorage,
|
discoverAuthStorage,
|
||||||
ModelRegistry,
|
discoverModels,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function makeRuntime() {
|
function makeRuntime() {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
import { join } from "node:path";
|
|
||||||
|
|
||||||
import type { Api, Model } from "@mariozechner/pi-ai";
|
import type { Api, Model } from "@mariozechner/pi-ai";
|
||||||
import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
import { discoverAuthStorage, discoverModels } from "../../agents/pi-model-discovery.js";
|
||||||
|
|
||||||
import { resolveOpenClawAgentDir } from "../../agents/agent-paths.js";
|
import { resolveOpenClawAgentDir } from "../../agents/agent-paths.js";
|
||||||
import type { AuthProfileStore } from "../../agents/auth-profiles.js";
|
import type { AuthProfileStore } from "../../agents/auth-profiles.js";
|
||||||
|
|
@ -43,8 +41,8 @@ const hasAuthForProvider = (provider: string, cfg: OpenClawConfig, authStore: Au
|
||||||
export async function loadModelRegistry(cfg: OpenClawConfig) {
|
export async function loadModelRegistry(cfg: OpenClawConfig) {
|
||||||
await ensureOpenClawModelsJson(cfg);
|
await ensureOpenClawModelsJson(cfg);
|
||||||
const agentDir = resolveOpenClawAgentDir();
|
const agentDir = resolveOpenClawAgentDir();
|
||||||
const authStorage = new AuthStorage(join(agentDir, "auth.json"));
|
const authStorage = discoverAuthStorage(agentDir);
|
||||||
const registry = new ModelRegistry(authStorage, join(agentDir, "models.json"));
|
const registry = discoverModels(authStorage, agentDir);
|
||||||
const models = registry.getAll() as Model<Api>[];
|
const models = registry.getAll() as Model<Api>[];
|
||||||
const availableModels = registry.getAvailable() as Model<Api>[];
|
const availableModels = registry.getAvailable() as Model<Api>[];
|
||||||
const availableKeys = new Set(availableModels.map((model) => modelKey(model.provider, model.id)));
|
const availableKeys = new Set(availableModels.map((model) => modelKey(model.provider, model.id)));
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ export async function writeOAuthCredentials(
|
||||||
creds: OAuthCredentials,
|
creds: OAuthCredentials,
|
||||||
agentDir?: string,
|
agentDir?: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// Write to resolved agent dir so gateway finds credentials on startup.
|
const email =
|
||||||
const email = typeof creds.email === "string" ? creds.email.trim() : "";
|
typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default";
|
||||||
upsertAuthProfile({
|
upsertAuthProfile({
|
||||||
profileId: `${provider}:${email || "default"}`,
|
profileId: `${provider}:${email}`,
|
||||||
credential: {
|
credential: {
|
||||||
type: "oauth",
|
type: "oauth",
|
||||||
provider,
|
provider,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
|
|
||||||
import type { Api, Model } from "@mariozechner/pi-ai";
|
import type { Api, Model } from "@mariozechner/pi-ai";
|
||||||
import { discoverAuthStorage, discoverModels } from "@mariozechner/pi-coding-agent";
|
import { discoverAuthStorage, discoverModels } from "../agents/pi-model-discovery.js";
|
||||||
import { describe, it } from "vitest";
|
import { describe, it } from "vitest";
|
||||||
import { resolveOpenClawAgentDir } from "../agents/agent-paths.js";
|
import { resolveOpenClawAgentDir } from "../agents/agent-paths.js";
|
||||||
import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js";
|
import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js";
|
||||||
|
|
|
||||||
|
|
@ -227,9 +227,9 @@ export const testIsNixMode = hoisted.testIsNixMode;
|
||||||
export const sessionStoreSaveDelayMs = hoisted.sessionStoreSaveDelayMs;
|
export const sessionStoreSaveDelayMs = hoisted.sessionStoreSaveDelayMs;
|
||||||
export const embeddedRunMock = hoisted.embeddedRunMock;
|
export const embeddedRunMock = hoisted.embeddedRunMock;
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-coding-agent", async () => {
|
vi.mock("../agents/pi-model-discovery.js", async () => {
|
||||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-coding-agent")>(
|
const actual = await vi.importActual<typeof import("../agents/pi-model-discovery.js")>(
|
||||||
"@mariozechner/pi-coding-agent",
|
"../agents/pi-model-discovery.js",
|
||||||
);
|
);
|
||||||
|
|
||||||
class MockModelRegistry extends actual.ModelRegistry {
|
class MockModelRegistry extends actual.ModelRegistry {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import { join } from "node:path";
|
|
||||||
|
|
||||||
import type { Api, AssistantMessage, Context, Model } from "@mariozechner/pi-ai";
|
import type { Api, AssistantMessage, Context, Model } from "@mariozechner/pi-ai";
|
||||||
import { complete } from "@mariozechner/pi-ai";
|
import { complete } from "@mariozechner/pi-ai";
|
||||||
import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
import { discoverAuthStorage, discoverModels } from "../../agents/pi-model-discovery.js";
|
||||||
|
|
||||||
import { getApiKeyForModel, requireApiKey } from "../../agents/model-auth.js";
|
import { getApiKeyForModel, requireApiKey } from "../../agents/model-auth.js";
|
||||||
import { ensureOpenClawModelsJson } from "../../agents/models-config.js";
|
import { ensureOpenClawModelsJson } from "../../agents/models-config.js";
|
||||||
|
|
@ -14,8 +12,8 @@ export async function describeImageWithModel(
|
||||||
params: ImageDescriptionRequest,
|
params: ImageDescriptionRequest,
|
||||||
): Promise<ImageDescriptionResult> {
|
): Promise<ImageDescriptionResult> {
|
||||||
await ensureOpenClawModelsJson(params.cfg, params.agentDir);
|
await ensureOpenClawModelsJson(params.cfg, params.agentDir);
|
||||||
const authStorage = new AuthStorage(join(params.agentDir, "auth.json"));
|
const authStorage = discoverAuthStorage(params.agentDir);
|
||||||
const modelRegistry = new ModelRegistry(authStorage, join(params.agentDir, "models.json"));
|
const modelRegistry = discoverModels(authStorage, params.agentDir);
|
||||||
const model = modelRegistry.find(params.provider, params.model) as Model<Api> | null;
|
const model = modelRegistry.find(params.provider, params.model) as Model<Api> | null;
|
||||||
if (!model) {
|
if (!model) {
|
||||||
throw new Error(`Unknown model: ${params.provider}/${params.model}`);
|
throw new Error(`Unknown model: ${params.provider}/${params.model}`);
|
||||||
|
|
|
||||||
|
|
@ -58,15 +58,17 @@ export function createClackPrompter(): WizardPrompter {
|
||||||
initialValues: params.initialValues,
|
initialValues: params.initialValues,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
text: async (params) =>
|
text: async (params) => {
|
||||||
guardCancel(
|
const validate = params.validate;
|
||||||
|
return guardCancel(
|
||||||
await text({
|
await text({
|
||||||
message: stylePromptMessage(params.message),
|
message: stylePromptMessage(params.message),
|
||||||
initialValue: params.initialValue,
|
initialValue: params.initialValue,
|
||||||
placeholder: params.placeholder,
|
placeholder: params.placeholder,
|
||||||
validate: params.validate,
|
validate: validate ? (value) => validate(value ?? "") : undefined,
|
||||||
}),
|
}),
|
||||||
),
|
);
|
||||||
|
},
|
||||||
confirm: async (params) =>
|
confirm: async (params) =>
|
||||||
guardCancel(
|
guardCancel(
|
||||||
await confirm({
|
await confirm({
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitest/browser-playwright": "4.0.18",
|
"@vitest/browser-playwright": "4.0.18",
|
||||||
"playwright": "^1.58.0",
|
"playwright": "^1.58.1",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"vitest": "4.0.18"
|
"vitest": "4.0.18"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue