@vellumai/assistant 0.12.5 → 0.12.6-dev.202609292116.41f7caa
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/.env.example +2 -0
- package/ARCHITECTURE.md +26 -3
- package/docs/automatic-done.md +32 -0
- package/docs/desktop-browser-cli.md +3 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +2 -1
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/mcp-oauth.test.ts +53 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/mcp-oauth.ts +60 -0
- package/node_modules/@vellumai/environments/src/shell.test.ts +13 -1
- package/node_modules/@vellumai/environments/src/shell.ts +22 -1
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +2 -1
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/mcp-oauth.test.ts +53 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/mcp-oauth.ts +60 -0
- package/node_modules/@vellumai/gateway-client/src/__tests__/status-contracts.test.ts +39 -0
- package/node_modules/@vellumai/gateway-client/src/gateway-ipc-contracts.ts +25 -0
- package/node_modules/@vellumai/service-contracts/package.json +2 -1
- package/node_modules/@vellumai/service-contracts/src/__tests__/mcp-oauth.test.ts +53 -0
- package/node_modules/@vellumai/service-contracts/src/index.ts +1 -0
- package/node_modules/@vellumai/service-contracts/src/mcp-oauth.ts +60 -0
- package/openapi.yaml +270 -10
- package/package.json +1 -1
- package/src/__tests__/agent-loop.test.ts +76 -0
- package/src/__tests__/anthropic-provider.test.ts +2 -0
- package/src/__tests__/byok-default-profile-ensure.test.ts +7 -0
- package/src/__tests__/config-get-vision-flag.test.ts +1 -1
- package/src/__tests__/config-loader-validation-reset-notice.test.ts +2 -2
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +160 -154
- package/src/__tests__/conversation-evictor.test.ts +54 -0
- package/src/__tests__/conversation-pairing.test.ts +112 -0
- package/src/__tests__/document-append-idempotency.test.ts +13 -0
- package/src/__tests__/document-create-dedupe.test.ts +13 -0
- package/src/__tests__/document-find-replace.test.ts +13 -0
- package/src/__tests__/document-revision-history.test.ts +390 -0
- package/src/__tests__/document-revision.test.ts +425 -0
- package/src/__tests__/document-tool-security.test.ts +13 -0
- package/src/__tests__/document-update-default-surface.test.ts +13 -0
- package/src/__tests__/emit-signal-routing-intent.test.ts +270 -0
- package/src/__tests__/gateway-flag-listener.test.ts +59 -6
- package/src/__tests__/headless-browser-navigate.test.ts +20 -30
- package/src/__tests__/host-cu-proxy.test.ts +79 -0
- package/src/__tests__/host-cu-routes-targeted.test.ts +14 -5
- package/src/__tests__/host-shell-tool.test.ts +6 -2
- package/src/__tests__/identity-routes.test.ts +4 -3
- package/src/__tests__/list-messages-client-message-id.test.ts +43 -0
- package/src/__tests__/llm-catalog-parity.test.ts +4 -4
- package/src/__tests__/llm-schema.test.ts +1 -1
- package/src/__tests__/notification-platform-adapter.test.ts +83 -1
- package/src/__tests__/oauth2-gateway-transport.test.ts +2 -0
- package/src/__tests__/openai-provider.test.ts +38 -11
- package/src/__tests__/pricing.test.ts +11 -0
- package/src/__tests__/public-ingress-urls.test.ts +26 -0
- package/src/__tests__/retry-thinking-tool-choice.test.ts +47 -0
- package/src/__tests__/skill-execute-input.test.ts +11 -0
- package/src/__tests__/tool-approval-handler.test.ts +4 -0
- package/src/__tests__/tool-preview-lifecycle.test.ts +26 -0
- package/src/__tests__/usage-attribution.test.ts +31 -0
- package/src/__tests__/workspace-migration-133-collapse-provider-connections.test.ts +3 -3
- package/src/__tests__/workspace-migration-160-repair-retired-fireworks-model-ids.test.ts +262 -0
- package/src/__tests__/workspace-migration-161-repair-retired-fireworks-glm-5p2-model-id.test.ts +233 -0
- package/src/acp/agent-process.ts +6 -1
- package/src/acp/client-handler.ts +6 -1
- package/src/agent/loop-unparseable-tool-retry.test.ts +333 -0
- package/src/agent/loop.ts +161 -17
- package/src/api/events/document-editor-show.ts +5 -0
- package/src/api/events/document-editor-update.ts +10 -0
- package/src/api/events/tool-result.ts +1 -0
- package/src/calls/__tests__/call-controller.test.ts +273 -1
- package/src/calls/__tests__/media-stream-server-integration.test.ts +40 -0
- package/src/calls/__tests__/media-stream-stt-session.test.ts +33 -0
- package/src/calls/__tests__/voice-session-bridge.test.ts +54 -0
- package/src/calls/call-constants.ts +10 -0
- package/src/calls/call-controller.ts +359 -25
- package/src/calls/channel-admission-reader.ts +15 -9
- package/src/calls/media-stream-server.ts +18 -0
- package/src/calls/media-stream-stt-session.ts +30 -9
- package/src/calls/twilio-provider.ts +14 -31
- package/src/calls/voice-session-bridge.ts +18 -1
- package/src/cli/commands/browser.ts +1 -2
- package/src/cli/lib/__tests__/plugin-artifact.test.ts +23 -0
- package/src/cli/lib/__tests__/plugin-catalog-visibility.test.ts +2 -0
- package/src/cli/lib/__tests__/plugin-details.test.ts +16 -0
- package/src/cli/lib/bundled-marketplace.json +54 -2
- package/src/cli/lib/inspect-plugin.ts +15 -15
- package/src/cli/lib/list-installed-plugins.ts +29 -28
- package/src/cli/lib/plugin-artifact.ts +74 -63
- package/src/cli/lib/plugin-catalog-visibility.ts +1 -0
- package/src/cli/lib/plugin-details.ts +27 -42
- package/src/cli/lib/plugin-marketplace.ts +6 -8
- package/src/cli/lib/plugin-surfaces.ts +8 -7
- package/src/cli.ts +1 -3
- package/src/config/__tests__/chat-settings.test.ts +121 -0
- package/src/config/assistant-feature-flags.ts +28 -23
- package/src/config/bundled-skills/computer-use/SKILL.md +20 -0
- package/src/config/bundled-skills/computer-use/TOOLS.json +11 -11
- package/src/config/chat-settings.ts +100 -0
- package/src/config/default-profile-catalog.ts +1 -1
- package/src/config/feature-flag-cache.ts +7 -25
- package/src/config/feature-flag-registry.json +9 -9
- package/src/config/loader.ts +5 -1
- package/src/config/profile-text-generation.ts +25 -21
- package/src/config/schemas/conversations.ts +14 -0
- package/src/config/schemas/llm.ts +1 -0
- package/src/config/schemas/notifications.ts +8 -1
- package/src/contacts/gateway-channel-read.ts +1 -1
- package/src/conversations/__tests__/auto-archive-activity.test.ts +136 -0
- package/src/conversations/__tests__/auto-archive.test.ts +304 -0
- package/src/conversations/auto-archive-activity.ts +61 -0
- package/src/conversations/auto-archive.ts +201 -0
- package/src/daemon/computer-use-observation.test.ts +81 -0
- package/src/daemon/computer-use-observation.ts +23 -0
- package/src/daemon/conversation-agent-loop-handlers.ts +18 -2
- package/src/daemon/conversation-agent-loop.ts +14 -6
- package/src/daemon/conversation-evictor.ts +50 -16
- package/src/daemon/conversation-messaging.ts +4 -0
- package/src/daemon/conversation-process.ts +15 -0
- package/src/daemon/conversation-queue-manager.ts +2 -0
- package/src/daemon/conversation.ts +2 -0
- package/src/daemon/doordash-steps.ts +1 -3
- package/src/daemon/handlers/__tests__/config-a2a-accept.test.ts +43 -1
- package/src/daemon/handlers/__tests__/config-channels.test.ts +1 -1
- package/src/daemon/handlers/config-a2a.ts +75 -2
- package/src/daemon/handlers/shared.ts +13 -2
- package/src/daemon/host-cu-proxy.ts +34 -3
- package/src/daemon/lifecycle.ts +15 -2
- package/src/daemon/process-message.ts +5 -0
- package/src/daemon/shutdown-handlers.ts +3 -0
- package/src/daemon/turn-finalization.ts +4 -0
- package/src/desktop/desktop-browser-endpoint.ts +11 -2
- package/src/desktop/desktop-chrome-policy.test.ts +1 -0
- package/src/desktop/desktop-chrome-policy.ts +7 -1
- package/src/desktop/desktop-computer-use.test.ts +14 -4
- package/src/desktop/desktop-session-manager.ts +5 -3
- package/src/documents/document-revisions-store.ts +153 -0
- package/src/documents/document-store.ts +471 -133
- package/src/followups/followup-store.ts +0 -4
- package/src/i18n/__tests__/i18n.test.ts +25 -0
- package/src/i18n/assistant-text.ts +18 -0
- package/src/i18n/index.ts +1 -0
- package/src/i18n/messages.ts +11 -0
- package/src/inbound/__tests__/oauth-callback-url.test.ts +25 -2
- package/src/inbound/oauth-callback-url.ts +30 -1
- package/src/inbound/public-ingress-urls.ts +12 -2
- package/src/ipc/gateway-client.test.ts +40 -0
- package/src/ipc/gateway-client.ts +12 -29
- package/src/ipc/gateway-flag-listener.ts +7 -10
- package/src/live-voice/__tests__/live-voice-agent-turn.test.ts +71 -0
- package/src/live-voice/__tests__/live-voice-flux-turn-end.test.ts +83 -0
- package/src/live-voice/__tests__/protocol.test.ts +77 -0
- package/src/live-voice/__tests__/share-targets.test.ts +163 -0
- package/src/live-voice/live-voice-session.ts +23 -6
- package/src/live-voice/protocol.ts +22 -0
- package/src/live-voice/share-targets.ts +225 -0
- package/src/mcp/__tests__/mcp-oauth-client-registration.test.ts +144 -3
- package/src/mcp/__tests__/mcp-oauth-provider.test.ts +2 -0
- package/src/mcp/client.ts +1 -19
- package/src/mcp/mcp-oauth-provider.ts +66 -49
- package/src/media/openrouter-image-service.ts +39 -22
- package/src/monitoring/__tests__/oom-inheritance-sweep.test.ts +86 -0
- package/src/monitoring/__tests__/oom-kill-reporter.test.ts +374 -0
- package/src/monitoring/control.ts +2 -1
- package/src/monitoring/oom-inheritance-sweep.ts +96 -0
- package/src/monitoring/oom-kill-reporter.ts +469 -0
- package/src/monitoring/resource-sampler.ts +30 -0
- package/src/notifications/README.md +53 -4
- package/src/notifications/__tests__/assistant-initiated-thread.test.ts +254 -0
- package/src/notifications/__tests__/broadcaster.test.ts +558 -6
- package/src/notifications/__tests__/completion-policy.test.ts +37 -0
- package/src/notifications/__tests__/from-me-alert-integration.test.ts +192 -0
- package/src/notifications/adapters/platform.ts +14 -0
- package/src/notifications/assistant-initiated-thread.ts +101 -0
- package/src/notifications/broadcaster.ts +94 -16
- package/src/notifications/chat-reply-policy.ts +11 -0
- package/src/notifications/completion-policy.ts +12 -2
- package/src/notifications/conversation-pairing.ts +15 -70
- package/src/notifications/emit-signal.ts +34 -3
- package/src/notifications/types.ts +2 -0
- package/src/oauth/connect-orchestrator.ts +1 -2
- package/src/persistence/__tests__/conversation-auto-archive.test.ts +330 -0
- package/src/persistence/conversation-auto-archive.ts +170 -0
- package/src/persistence/conversation-crud.ts +2 -1
- package/src/persistence/conversation-queries.ts +15 -8
- package/src/persistence/embeddings/embed.test.ts +96 -0
- package/src/persistence/embeddings/embed.ts +20 -2
- package/src/persistence/embeddings/embedding-gemini.test.ts +39 -3
- package/src/persistence/embeddings/embedding-gemini.ts +39 -1
- package/src/persistence/embeddings/embedding-local.ts +6 -0
- package/src/persistence/embeddings/qdrant-manager.ts +5 -0
- package/src/persistence/job-utils.ts +10 -0
- package/src/persistence/migrations/384-add-document-revision.test.ts +83 -0
- package/src/persistence/migrations/384-add-document-revision.ts +21 -0
- package/src/persistence/migrations/385-create-document-revisions.test.ts +67 -0
- package/src/persistence/migrations/385-create-document-revisions.ts +28 -0
- package/src/persistence/migrations/386-conversations-last-reopened-at.ts +10 -0
- package/src/persistence/migrations/__tests__/386-conversations-last-reopened-at.test.ts +32 -0
- package/src/persistence/schema/conversations.ts +1 -0
- package/src/persistence/schema/documents.ts +20 -0
- package/src/persistence/steps.ts +6 -0
- package/src/platform/managed-speech.ts +42 -46
- package/src/plugin-api/vision-support.test.ts +21 -21
- package/src/plugins/defaults/empty-response/hooks/post-model-call.ts +11 -6
- package/src/providers/__tests__/dispatch-connection-routing.test.ts +1 -1
- package/src/providers/__tests__/search-provider-catalog.test.ts +8 -0
- package/src/providers/__tests__/unparseable-tool-args.test.ts +25 -0
- package/src/providers/anthropic/client.ts +1 -1
- package/src/providers/fireworks/client.test.ts +168 -0
- package/src/providers/fireworks/client.ts +24 -0
- package/src/providers/inference/adapter-factory.ts +6 -0
- package/src/providers/ionet/client.test.ts +143 -0
- package/src/providers/ionet/client.ts +37 -0
- package/src/providers/model-catalog.ts +141 -84
- package/src/providers/model-intents.ts +4 -4
- package/src/providers/openai/chat-completions-provider.ts +33 -2
- package/src/providers/retry.ts +56 -4
- package/src/providers/search-provider-catalog.ts +10 -0
- package/src/providers/types.ts +10 -2
- package/src/providers/unparseable-tool-args.ts +29 -5
- package/src/providers/usage-tracking.ts +5 -3
- package/src/runtime/assistant-event-hub.ts +23 -0
- package/src/runtime/auth/__tests__/guard-tests.test.ts +0 -7
- package/src/runtime/auth/__tests__/route-policy.test.ts +1 -1
- package/src/runtime/channel-reply-delivery.ts +2 -0
- package/src/runtime/channel-retry-sweep.ts +1 -2
- package/src/runtime/http-types.ts +3 -0
- package/src/runtime/migrations/__tests__/vbundle-streaming-validator.test.ts +35 -10
- package/src/runtime/migrations/__tests__/vbundle-validator-v1-schema.test.ts +48 -0
- package/src/runtime/migrations/vbundle-builder.ts +19 -3
- package/src/runtime/migrations/vbundle-streaming-importer.ts +14 -19
- package/src/runtime/migrations/vbundle-streaming-validator.ts +14 -7
- package/src/runtime/migrations/vbundle-validator.ts +54 -1
- package/src/runtime/pending-interactions.ts +20 -2
- package/src/runtime/routes/__tests__/contact-routes.test.ts +5 -3
- package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +36 -0
- package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +375 -2
- package/src/runtime/routes/__tests__/inference-send-routes.test.ts +1 -1
- package/src/runtime/routes/__tests__/user-route-dispatcher.test.ts +12 -0
- package/src/runtime/routes/contact-routes.ts +2 -2
- package/src/runtime/routes/conversation-list-routes.ts +10 -2
- package/src/runtime/routes/conversation-query-routes.ts +48 -10
- package/src/runtime/routes/conversation-routes.ts +7 -0
- package/src/runtime/routes/documents-routes.ts +185 -47
- package/src/runtime/routes/events-routes.ts +1 -3
- package/src/runtime/routes/host-app-control-routes.ts +1 -0
- package/src/runtime/routes/host-bash-routes.ts +1 -0
- package/src/runtime/routes/host-browser-routes.ts +15 -0
- package/src/runtime/routes/host-cu-routes.ts +4 -1
- package/src/runtime/routes/host-file-routes.ts +1 -0
- package/src/runtime/routes/host-proxy-result-binding.test.ts +83 -0
- package/src/runtime/routes/host-proxy-result-binding.ts +25 -0
- package/src/runtime/routes/host-transfer-routes.ts +1 -0
- package/src/runtime/routes/identity-routes.ts +3 -3
- package/src/runtime/routes/inbound-stages/background-dispatch.ts +4 -0
- package/src/runtime/routes/integrations/a2a.ts +4 -1
- package/src/runtime/routes/migration-routes.ts +3 -1
- package/src/runtime/routes/notification-routes.ts +1 -2
- package/src/runtime/routes/ui-snapshot-routes.test.ts +1 -0
- package/src/runtime/routes/user-route-dispatcher.ts +5 -1
- package/src/runtime/verification-templates.ts +1 -2
- package/src/sequence/analytics.ts +0 -4
- package/src/sequence/engine.ts +1 -11
- package/src/sequence/guardrails.ts +1 -6
- package/src/sequence/importer.ts +0 -8
- package/src/sequence/store.ts +0 -10
- package/src/signals/user-message.ts +0 -6
- package/src/skills/catalog-install.ts +52 -23
- package/src/tools/browser/browser-execution.ts +20 -23
- package/src/tools/browser/cdp-client/cdp-inspect/ws-transport.ts +1 -3
- package/src/tools/document/document-tool.ts +13 -11
- package/src/tools/executor.ts +1 -2
- package/src/tools/host-terminal/host-shell.ts +4 -2
- package/src/tools/network/__tests__/web-search.test.ts +105 -0
- package/src/tools/network/web-fetch.ts +2 -4
- package/src/tools/network/web-search.ts +239 -12
- package/src/tools/shared/filesystem/format-diff.ts +1 -2
- package/src/tools/shared/shell-output.test.ts +42 -0
- package/src/tools/shared/shell-output.ts +27 -4
- package/src/tools/skills/execute.ts +10 -7
- package/src/tools/terminal/shell.ts +3 -3
- package/src/tools/tool-approval-handler.ts +9 -1
- package/src/tools/ui-surface/visual-validation.ts +1 -2
- package/src/usage/attribution.ts +18 -1
- package/src/util/__tests__/oom-priority.test.ts +55 -0
- package/src/util/__tests__/worker-memory.test.ts +16 -0
- package/src/util/debounce.ts +0 -4
- package/src/util/oom-priority.ts +79 -0
- package/src/util/platform.ts +0 -2
- package/src/util/plugin-manifest.ts +5 -7
- package/src/util/pricing.ts +25 -0
- package/src/util/worker-memory.ts +9 -3
- package/src/util/worker-process.ts +8 -0
- package/src/workspace/byok-default-profile-ensure.ts +11 -0
- package/src/workspace/hatched-date.ts +11 -4
- package/src/workspace/migrations/160-repair-retired-fireworks-model-ids.ts +209 -0
- package/src/workspace/migrations/161-repair-retired-fireworks-glm-5p2-model-id.ts +197 -0
- package/src/workspace/migrations/registry.ts +4 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { Database } from "bun:sqlite";
|
|
4
|
+
|
|
5
|
+
import type { WorkspaceMigration } from "./types.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Repair the retired Fireworks GLM 5.2 model ID in workspace LLM config.
|
|
9
|
+
*
|
|
10
|
+
* `accounts/fireworks/models/glm-5p2` is on the Fireworks serverless
|
|
11
|
+
* decommission list, with `accounts/fireworks/models/glm-5p3` as the named
|
|
12
|
+
* successor at the same per-token pricing. Existing configs can pin the ID
|
|
13
|
+
* in `llm.default`, `llm.callSites.*`, and `llm.profiles.*`.
|
|
14
|
+
*
|
|
15
|
+
* Repair those leaves only on an exact stale match. GLM 5.3 reasoning is
|
|
16
|
+
* always on, so a repaired fragment that sets `effort: "none"` runs through
|
|
17
|
+
* the provider's handling for thinking-only models.
|
|
18
|
+
*
|
|
19
|
+
* Provider guard: the stale ID belongs to the `fireworks` provider and also
|
|
20
|
+
* appears in managed profiles stamped `provider: "vellum"` (which route
|
|
21
|
+
* Fireworks-account model IDs through the managed proxy). Under the entries
|
|
22
|
+
* model (migration 145) `provider` can also hold a `provider_connections`
|
|
23
|
+
* entry name whose row kind drives dispatch. A fragment is repaired when
|
|
24
|
+
* its `provider` is `"fireworks"`, `"vellum"`, absent, or an entry name
|
|
25
|
+
* whose row kind is one of those. Any other provider is left untouched: an
|
|
26
|
+
* `openai-compatible` endpoint may legitimately serve a model by the stale
|
|
27
|
+
* name.
|
|
28
|
+
*/
|
|
29
|
+
export const repairRetiredFireworksGlm5p2ModelIdMigration: WorkspaceMigration =
|
|
30
|
+
{
|
|
31
|
+
id: "161-repair-retired-fireworks-glm-5p2-model-id",
|
|
32
|
+
description:
|
|
33
|
+
"Repair retired Fireworks accounts/fireworks/models/glm-5p2 model ID in workspace LLM config",
|
|
34
|
+
run(workspaceDir: string): void {
|
|
35
|
+
const configPath = join(workspaceDir, "config.json");
|
|
36
|
+
if (!existsSync(configPath)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Read outside the parse catch: a transient filesystem error (EIO,
|
|
41
|
+
// EACCES) must reach the runner so the migration retries, while
|
|
42
|
+
// malformed JSON is a permanent state this migration cannot repair.
|
|
43
|
+
const rawText = readFileSync(configPath, "utf-8");
|
|
44
|
+
|
|
45
|
+
let config: Record<string, unknown>;
|
|
46
|
+
try {
|
|
47
|
+
const raw = JSON.parse(rawText);
|
|
48
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
config = raw as Record<string, unknown>;
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const llm = readObject(config.llm);
|
|
57
|
+
if (llm === null) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Entry rows load lazily: only a stale fragment whose provider is
|
|
62
|
+
// neither a repairable vendor nor absent needs them. An unreadable DB
|
|
63
|
+
// then fails the run (retried next boot) rather than checkpointing a
|
|
64
|
+
// pass that skips entry-bound profiles.
|
|
65
|
+
let rows: Map<string, string> | null | undefined;
|
|
66
|
+
const isRepairableProvider = (provider: unknown): boolean => {
|
|
67
|
+
if (provider === undefined) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
if (typeof provider !== "string") {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (REPAIRABLE_PROVIDERS.has(provider)) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
if (rows === undefined) {
|
|
77
|
+
rows = readConnectionRows(workspaceDir);
|
|
78
|
+
}
|
|
79
|
+
if (rows === null) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
"provider_connections is not readable; retrying the model-ID repair on the next run",
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const kind = rows.get(provider);
|
|
85
|
+
return kind !== undefined && REPAIRABLE_PROVIDERS.has(kind);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
let changed = false;
|
|
89
|
+
|
|
90
|
+
changed =
|
|
91
|
+
repairFragment(readObject(llm.default), isRepairableProvider) ||
|
|
92
|
+
changed;
|
|
93
|
+
|
|
94
|
+
const callSites = readObject(llm.callSites);
|
|
95
|
+
if (callSites !== null) {
|
|
96
|
+
for (const rawConfig of Object.values(callSites)) {
|
|
97
|
+
changed =
|
|
98
|
+
repairFragment(readObject(rawConfig), isRepairableProvider) ||
|
|
99
|
+
changed;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const profiles = readObject(llm.profiles);
|
|
104
|
+
if (profiles !== null) {
|
|
105
|
+
for (const rawProfile of Object.values(profiles)) {
|
|
106
|
+
changed =
|
|
107
|
+
repairFragment(readObject(rawProfile), isRepairableProvider) ||
|
|
108
|
+
changed;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!changed) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Write-then-rename so an interrupted write cannot leave config.json
|
|
117
|
+
// truncated: a torn in-place write would parse as invalid JSON on the
|
|
118
|
+
// retry, which the catch above treats as "nothing to do", letting the
|
|
119
|
+
// runner checkpoint the migration as completed against a corrupt file.
|
|
120
|
+
const tmpPath = `${configPath}.migration-161.tmp`;
|
|
121
|
+
writeFileSync(tmpPath, JSON.stringify(config, null, 2) + "\n");
|
|
122
|
+
renameSync(tmpPath, configPath);
|
|
123
|
+
},
|
|
124
|
+
// The exact-match rewrite is idempotent, so a transient failure (full
|
|
125
|
+
// disk, I/O error) is safe to retry on later startups.
|
|
126
|
+
retryFailedCheckpoint: true,
|
|
127
|
+
down(_workspaceDir: string): void {
|
|
128
|
+
// Forward-only: reintroducing a retired model ID would break
|
|
129
|
+
// Fireworks calls.
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
// Helpers: self-contained per workspace migrations AGENTS.md
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
const REPLACEMENT_BY_STALE_MODEL_ID = new Map([
|
|
138
|
+
["accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/glm-5p3"],
|
|
139
|
+
]);
|
|
140
|
+
const REPAIRABLE_PROVIDERS = new Set(["fireworks", "vellum"]);
|
|
141
|
+
|
|
142
|
+
function repairFragment(
|
|
143
|
+
fragment: Record<string, unknown> | null,
|
|
144
|
+
isRepairableProvider: (provider: unknown) => boolean,
|
|
145
|
+
): boolean {
|
|
146
|
+
if (fragment === null) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
if (typeof fragment.model !== "string") {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const replacement = REPLACEMENT_BY_STALE_MODEL_ID.get(fragment.model);
|
|
153
|
+
if (replacement === undefined) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (!isRepairableProvider(fragment.provider)) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
fragment.model = replacement;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Connection name -> provider kind, or null when the DB or table is not
|
|
165
|
+
* readable. The caller fails the run on null: entry-name providers must be
|
|
166
|
+
* judged against real rows, never guessed. An absent DB file is a real
|
|
167
|
+
* state (no rows, so every entry name is dangling and stays untouched).
|
|
168
|
+
*/
|
|
169
|
+
function readConnectionRows(workspaceDir: string): Map<string, string> | null {
|
|
170
|
+
const dbPath = join(workspaceDir, "data", "db", "assistant.db");
|
|
171
|
+
if (!existsSync(dbPath)) {
|
|
172
|
+
return new Map();
|
|
173
|
+
}
|
|
174
|
+
let db: Database;
|
|
175
|
+
try {
|
|
176
|
+
db = new Database(dbPath);
|
|
177
|
+
} catch {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
const rows = db
|
|
182
|
+
.query(`SELECT name, provider FROM provider_connections`)
|
|
183
|
+
.all() as Array<{ name: string; provider: string }>;
|
|
184
|
+
return new Map(rows.map((r) => [r.name, r.provider]));
|
|
185
|
+
} catch {
|
|
186
|
+
return null;
|
|
187
|
+
} finally {
|
|
188
|
+
db.close();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function readObject(value: unknown): Record<string, unknown> | null {
|
|
193
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
return value as Record<string, unknown>;
|
|
197
|
+
}
|
|
@@ -157,6 +157,8 @@ import { extractWorkspaceMcpJsonMigration } from "./156-extract-workspace-mcp-js
|
|
|
157
157
|
import { addDesktopFilesLauncherMigration } from "./157-add-desktop-files-launcher.js";
|
|
158
158
|
import { repointOpencodeHostProviderFragmentsMigration } from "./158-repoint-opencode-host-provider-fragments.js";
|
|
159
159
|
import { renameCollidingJevProfileNameMigration } from "./159-rename-colliding-jev-profile-name.js";
|
|
160
|
+
import { repairRetiredFireworksModelIdsMigration } from "./160-repair-retired-fireworks-model-ids.js";
|
|
161
|
+
import { repairRetiredFireworksGlm5p2ModelIdMigration } from "./161-repair-retired-fireworks-glm-5p2-model-id.js";
|
|
160
162
|
import { migrateToWorkspaceVolumeMigration } from "./migrate-to-workspace-volume.js";
|
|
161
163
|
import type { WorkspaceMigration } from "./types.js";
|
|
162
164
|
|
|
@@ -329,4 +331,6 @@ export const WORKSPACE_MIGRATIONS: WorkspaceMigration[] = [
|
|
|
329
331
|
addDesktopFilesLauncherMigration,
|
|
330
332
|
repointOpencodeHostProviderFragmentsMigration,
|
|
331
333
|
renameCollidingJevProfileNameMigration,
|
|
334
|
+
repairRetiredFireworksModelIdsMigration,
|
|
335
|
+
repairRetiredFireworksGlm5p2ModelIdMigration,
|
|
332
336
|
];
|