@xopcai/xopc 0.0.162 → 0.0.163
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/README.md +4 -2
- package/README.zh-CN.md +4 -2
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-hpcNv9MZ.js → activity-store-Xj95LzTv.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Zf9UQEmQ.js → agent-avatar-dicebear-C-QeUFwU.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DVKlWKJE.js +2 -0
- package/dist/gateway/static/root/assets/{api-Dnatri09.js → api-BTLmAm1_.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BBTR9wJP.js → app-management-settings-panel-zc6Gf-S5.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-C2zpLCHD.js → appearance-settings-0fMLnOWn.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BZXEJDIV.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-9eR_ODY1.js → archive-plugin-DOiR_E21.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DPuWYUeX.js → attachment-load-BxmYl1D1.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-Dw49OJRl.js → automation-suggestion-card-BhZOirad.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-B8CnkoXv.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BdkJpDFm.js → binary-plugins-DTTKsvgk.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CAi7SXYU.js → block-editor-C7se7iqg.js} +31 -31
- package/dist/gateway/static/root/assets/browser-settings-page-BCPWKI9V.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-Dx6wkGz1.js → browser-workflow-inputs-kxmStCcv.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-Skertc-A.js → browser-workflows-page-CwYf9OM_.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C7lr_mX2.js +2 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-CNFl7dM3.js → capability-presets-api-BZKh2cWX.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Ble9kHRu.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-DYQyGDw4.js → channel-recipient-api-r7tdbnJE.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-CtQQQHrv.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-_VirfMKW.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-Bng6kxYF.js → connector-logo-BpnQYAxA.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-BXWJSJeY.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-B86W4a5c.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BVUyefSd.js → desktop-pet-settings-uv8Grtgk.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DjSZAPz_.js → directory-picker-path-field-C4TTvf7p.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CAZk2AM4.js → dreaming-settings-CzJAUPvM.js} +2 -2
- package/dist/gateway/static/root/assets/{extension-debug-page-C2F6vTTd.js → extension-debug-page-Ci2mOYUt.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-AnIt4bn4.js → extension-page-DeXdmhXQ.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-C93vaOsU.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-DLFyZv33.js → gateway-config-api-C31Hlblp.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DnQAA-qq.js → gateway-settings-D3zS6RZh.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DbzLyJ3R.js → gateway-startup-retry-CSRvCqxh.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-DrnKFC6M.js → goal-create-dialog-CWp2b7__.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-Dtm29FxD.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-REmr3QCr.js → goals-config-api-D4wYNRrf.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-jMzBJs6e.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-Dz0F3uRO.js → goals-settings-Bx2jVvhQ.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CQFY5gYs.js → heartbeat-settings-BEIF1eXy.js} +1 -1
- package/dist/gateway/static/root/assets/index-BXtJvaQl.css +1 -0
- package/dist/gateway/static/root/assets/{index-C8JkTS6d.js → index-HZdBKfk_.js} +70 -70
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BnOQXU5k.js → keyboard-shortcuts-settings-DOEDpvTM.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CseW9jD3.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-KsOtWOyM.js → local-apps-page-B0OpGpxv.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-0lpYdNDr.js → locale-store-Ys6RP7Be.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DVqPbth5.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-D5GRg10r.js → markdown-split-CEZwysCH.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C1ryULGs.js → media-plugins-CpGKE7B0.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BzI9Wx30.js +5 -0
- package/dist/gateway/static/root/assets/{notes-page-CIeZ1_DT.js → notes-page-CdiuDZ5a.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-mrc3xtpn.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-Caj1-E_X.js → page-tabs-BkH5AVV2.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DKwEce-9.js → preview-open-alternatives-CQai8f9D.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B90ZskkN.js → product-open-page-B2kSdB2b.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CfhPJLkH.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BfMoKjdm.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CrDtcsZ9.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BDYt53uQ.js → save-bar-controls-NGYnO7n7.js} +1 -1
- package/dist/gateway/static/root/assets/schedule-field-nLOphnv3.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-D7oCARF7.js → schema-form-D0e90ndE.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-D3DbF3dV.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BZp0O2dH.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CARTHCxH.js → settings-form-section-X2Sl-EAk.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DEwYqESe.js → settings-loading-skeleton-DOnUabm7.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B6vVdHeQ.js → settings-page-C4UUNi1n.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-D3srt5Bi.js → settings-page-layout-C1yYqbT6.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-84iao4DZ.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-Ck9SxiXw.js → share-preview-page-Cfy_pH7V.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DtcwQvRG.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-L7j5Gc8Z.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-1Ps8PjsP.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-DLBUQSk2.js → system-settings-panel-Da81RJ6G.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-C1oaqeD2.js → theme-store-DflSp9o4.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-BIkOW-2L.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-Divbg_C4.js → typed-models-lib--HptwFcD.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CP9a_rAf.js → use-channel-catalog-CMHY4ZfW.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-BYAAs2iW.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-nvIZerol.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-J35JkJ7_.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-C4wYDYqV.js +1 -0
- package/dist/gateway/static/root/assets/work-page-DMvitV6c.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DbDPYQwB.js → workflow-run-setup-panel-D96MHABy.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-JMN0nMbM.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/client-error-format.d.ts +1 -1
- package/dist/src/agent/client-error-format.js +6 -2
- package/dist/src/agent/embedded/run-for-session.js +38 -31
- package/dist/src/agent/embedded/session-runner.d.ts +1 -0
- package/dist/src/agent/embedded/session-runner.js +12 -4
- package/dist/src/agent/failover-error.d.ts +1 -1
- package/dist/src/agent/image/generation/openai-compatible-image-provider.d.ts +2 -6
- package/dist/src/agent/image/generation/openai-compatible-image-provider.js +1 -3
- package/dist/src/agent/image/generation/provider-registry.d.ts +5 -46
- package/dist/src/agent/image/generation/provider-registry.js +24 -73
- package/dist/{extensions/dashscope/src/image-generation-provider.d.ts → src/agent/image/generation/providers/dashscope.d.ts} +3 -6
- package/dist/{extensions/dashscope/src/image-generation-provider.js → src/agent/image/generation/providers/dashscope.js} +36 -59
- package/dist/{extensions/fal/src/image-generation-provider.d.ts → src/agent/image/generation/providers/fal.d.ts} +1 -1
- package/dist/{extensions/fal/src/image-generation-provider.js → src/agent/image/generation/providers/fal.js} +19 -29
- package/dist/{extensions/google/src/image-generation-provider.d.ts → src/agent/image/generation/providers/google.d.ts} +2 -2
- package/dist/{extensions/google/src/image-generation-provider.js → src/agent/image/generation/providers/google.js} +23 -30
- package/dist/{extensions/minimax/src/image-generation-provider.d.ts → src/agent/image/generation/providers/minimax.d.ts} +2 -5
- package/dist/{extensions/minimax/src/image-generation-provider.js → src/agent/image/generation/providers/minimax.js} +35 -51
- package/dist/{extensions/openai/src/image-generation-provider.d.ts → src/agent/image/generation/providers/openai.d.ts} +2 -2
- package/dist/{extensions/openai/src/image-generation-provider.js → src/agent/image/generation/providers/openai.js} +13 -38
- package/dist/src/agent/image/generation/runtime-types.d.ts +1 -0
- package/dist/src/agent/image/generation/runtime.d.ts +1 -3
- package/dist/src/agent/image/generation/runtime.js +6 -6
- package/dist/src/agent/image/generation/types.d.ts +23 -3
- package/dist/src/agent/image/index.d.ts +1 -1
- package/dist/src/agent/image/index.js +2 -2
- package/dist/src/agent/media-generation/runtime-shared.d.ts +2 -0
- package/dist/src/agent/media-generation/runtime-shared.js +1 -0
- package/dist/src/agent/tools/factory.js +4 -1
- package/dist/src/agent/tools/image-generate-tool.d.ts +2 -0
- package/dist/src/agent/tools/image-generate-tool.js +14 -7
- package/dist/src/auth/sync-provider-auth.d.ts +3 -0
- package/dist/src/auth/sync-provider-auth.js +12 -1
- package/dist/src/cli/commands/models.js +2 -5
- package/dist/src/cli/commands/onboard/model.js +3 -2
- package/dist/src/cli/commands/setup-shared/types.d.ts +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/models-json.d.ts +6 -0
- package/dist/src/config/models-json.js +2 -6
- package/dist/src/config/schema.d.ts +26 -15
- package/dist/src/config/schema.js +23 -12
- package/dist/src/gateway/hono/app.js +12 -6
- package/dist/src/gateway/hono/lib/safe-providers-config.d.ts +0 -3
- package/dist/src/gateway/hono/lib/safe-providers-config.js +1 -3
- package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +4 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +8 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -11
- package/dist/src/gateway/hono/routes/deps.d.ts +1 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +9 -2
- package/dist/src/gateway/hono/routes/models.js +151 -129
- package/dist/src/gateway/image-generation-setup.d.ts +40 -0
- package/dist/src/gateway/image-generation-setup.js +130 -0
- package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
- package/dist/src/gateway/rate-limit/buckets.js +12 -0
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +10 -0
- package/dist/src/media-shared/http/private-network.d.ts +1 -1
- package/dist/src/media-shared/http/private-network.js +1 -1
- package/dist/src/providers/auth-runtime/resolve-api-key.d.ts +2 -4
- package/dist/src/providers/auth-runtime/resolve-api-key.js +2 -4
- package/dist/src/providers/auth-runtime/resolve-auth.d.ts +3 -4
- package/dist/src/providers/auth-runtime/resolve-auth.js +18 -18
- package/dist/src/providers/domestic-presets.d.ts +22 -0
- package/dist/src/providers/domestic-presets.js +25 -0
- package/dist/src/providers/model-catalog-store.d.ts +71 -0
- package/dist/src/providers/model-catalog-store.js +102 -0
- package/dist/src/providers/model-catalog-sync-service.d.ts +41 -0
- package/dist/src/providers/model-catalog-sync-service.js +142 -0
- package/dist/src/providers/model-reference-auditor.d.ts +14 -0
- package/dist/src/providers/model-reference-auditor.js +71 -0
- package/dist/src/providers/model-registry.d.ts +4 -1
- package/dist/src/providers/model-registry.js +35 -2
- package/dist/src/providers/presentation.js +2 -0
- package/dist/src/providers/xopc-cloud-connection.d.ts +51 -0
- package/dist/src/providers/xopc-cloud-connection.js +196 -0
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/index.js +2 -2
- package/dist/src/session/session-title.d.ts +2 -0
- package/dist/src/session/session-title.js +24 -3
- package/package.json +5 -7
- package/dist/extensions/dashscope/src/index.d.ts +0 -4
- package/dist/extensions/dashscope/src/index.js +0 -2
- package/dist/extensions/dashscope/xopc.extension.json +0 -15
- package/dist/extensions/fal/src/index.d.ts +0 -4
- package/dist/extensions/fal/src/index.js +0 -2
- package/dist/extensions/fal/xopc.extension.json +0 -14
- package/dist/extensions/google/src/index.d.ts +0 -4
- package/dist/extensions/google/src/index.js +0 -2
- package/dist/extensions/google/xopc.extension.json +0 -14
- package/dist/extensions/minimax/src/index.d.ts +0 -4
- package/dist/extensions/minimax/src/index.js +0 -2
- package/dist/extensions/minimax/xopc.extension.json +0 -15
- package/dist/extensions/openai/src/index.d.ts +0 -4
- package/dist/extensions/openai/src/index.js +0 -2
- package/dist/extensions/openai/xopc.extension.json +0 -14
- package/dist/gateway/static/root/assets/agents-DfVkZlHc.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-BMtAa4Ra.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-BiSAMYTr.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-DHmaEJS2.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-B5wSgf4f.js +0 -2
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DyvFZwBj.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-BBKEqDZn.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-Drk110ve.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-HpgaUDQ1.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-Bpf6oegd.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-CLSc6682.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-Cw1hpJkZ.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-BDGkTVma.js +0 -2
- package/dist/gateway/static/root/assets/index-hmrG55qg.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Bdef1b7F.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-CwLPgrWh.js +0 -7
- package/dist/gateway/static/root/assets/messages-BwQ3WssU.js +0 -5
- package/dist/gateway/static/root/assets/notes-workbench-Cf06q19x.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-SHTurM4t.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BcC2qUAw.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-6vGefBHv.js +0 -1
- package/dist/gateway/static/root/assets/schedule-field-Bcdni4Pj.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-C5014a53.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CDY3ZI1K.js +0 -1
- package/dist/gateway/static/root/assets/settings-collapsible-section-6eNF8Jey.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-z-rF0Hdg.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-CHZFXE_d.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-B7p2QNXt.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-ncw3tX9P.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-iYfeSLKI.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-CrwkicvT.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BQWxyPg8.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-50ZzGay5.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DPqEahx7.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-C3eIC5HZ.js +0 -11
- package/dist/src/agent/image/generation/bundled-registry.d.ts +0 -18
- package/dist/src/agent/image/generation/bundled-registry.js +0 -35
- package/dist/src/agent/image/generation/bundled.d.ts +0 -10
- package/dist/src/agent/image/generation/bundled.js +0 -15
- package/dist/src/agent/image/generation/image-provider-ui.d.ts +0 -20
- package/dist/src/agent/image/generation/image-provider-ui.js +0 -1
- package/dist/src/gateway/image-capabilities.d.ts +0 -28
- package/dist/src/gateway/image-capabilities.js +0 -78
- package/dist/src/generated/bundled-image-generation-providers.d.ts +0 -14
- package/dist/src/generated/bundled-image-generation-providers.js +0 -17
|
@@ -5,6 +5,7 @@ import { resolveModelsJsonPath } from "../config/paths.js";
|
|
|
5
5
|
import { init_resolve_config_value, resolveConfigValue, resolveHeaders } from "../config/resolve-config-value.js";
|
|
6
6
|
import { getDefaultModelValues, init_models_json, validateModelsConfig } from "../config/models-json.js";
|
|
7
7
|
import { getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
8
|
+
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
8
9
|
import { existsSync, readFileSync } from "fs";
|
|
9
10
|
import { getModels, getProviders } from "@earendil-works/pi-ai/compat";
|
|
10
11
|
//#region src/providers/model-registry.ts
|
|
@@ -94,6 +95,7 @@ var init_model_registry = __esmMin((() => {
|
|
|
94
95
|
init_models_json();
|
|
95
96
|
init_logger();
|
|
96
97
|
init_env_keys();
|
|
98
|
+
init_model_catalog_store();
|
|
97
99
|
log = createLogger("ModelRegistry");
|
|
98
100
|
ModelRegistry = class {
|
|
99
101
|
models = [];
|
|
@@ -103,8 +105,9 @@ var init_model_registry = __esmMin((() => {
|
|
|
103
105
|
prewarmPromise = null;
|
|
104
106
|
_availableModelsCache;
|
|
105
107
|
_authStatusCache = /* @__PURE__ */ new Map();
|
|
106
|
-
constructor(modelsJsonPath = resolveModelsJsonPath()) {
|
|
108
|
+
constructor(modelsJsonPath = resolveModelsJsonPath(), catalogStore = getModelCatalogStore()) {
|
|
107
109
|
this.modelsJsonPath = modelsJsonPath;
|
|
110
|
+
this.catalogStore = catalogStore;
|
|
108
111
|
}
|
|
109
112
|
isLoaded() {
|
|
110
113
|
return this.loaded;
|
|
@@ -213,13 +216,41 @@ var init_model_registry = __esmMin((() => {
|
|
|
213
216
|
}
|
|
214
217
|
this.customProviderApiKeys = apiKeyConfigs;
|
|
215
218
|
const builtInModels = this.loadBuiltInModels(overrides, modelOverrides);
|
|
216
|
-
|
|
219
|
+
const remoteModels = this.loadRemoteModels();
|
|
220
|
+
this.models = this.mergeCustomModels(this.mergeCustomModels(builtInModels, remoteModels), customModels);
|
|
217
221
|
log.debug({
|
|
218
222
|
builtIn: builtInModels.length,
|
|
223
|
+
remote: remoteModels.length,
|
|
219
224
|
custom: customModels.length,
|
|
220
225
|
total: this.models.length
|
|
221
226
|
}, "Models loaded");
|
|
222
227
|
}
|
|
228
|
+
loadRemoteModels() {
|
|
229
|
+
let sources;
|
|
230
|
+
try {
|
|
231
|
+
sources = this.catalogStore.load().sources;
|
|
232
|
+
} catch (err) {
|
|
233
|
+
log.warn({ err }, "Failed to load remote model catalog");
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
return Object.values(sources).flatMap((source) => source.models.filter((model) => model.availability === "available").map((model) => ({
|
|
237
|
+
id: model.id,
|
|
238
|
+
name: model.name,
|
|
239
|
+
api: source.api,
|
|
240
|
+
provider: source.providerId,
|
|
241
|
+
baseUrl: source.baseUrl,
|
|
242
|
+
reasoning: false,
|
|
243
|
+
input: ["text"],
|
|
244
|
+
cost: {
|
|
245
|
+
input: 0,
|
|
246
|
+
output: 0,
|
|
247
|
+
cacheRead: 0,
|
|
248
|
+
cacheWrite: 0
|
|
249
|
+
},
|
|
250
|
+
contextWindow: 128e3,
|
|
251
|
+
maxTokens: model.maxOutputTokens ?? 16384
|
|
252
|
+
})));
|
|
253
|
+
}
|
|
223
254
|
/**
|
|
224
255
|
* Load built-in models and apply provider/model overrides
|
|
225
256
|
*/
|
|
@@ -282,6 +313,7 @@ var init_model_registry = __esmMin((() => {
|
|
|
282
313
|
const modelOverrides = /* @__PURE__ */ new Map();
|
|
283
314
|
const apiKeyConfigs = /* @__PURE__ */ new Map();
|
|
284
315
|
for (const [providerName, providerConfig] of Object.entries(config.providers)) {
|
|
316
|
+
if (providerName === "xopc-cloud") continue;
|
|
285
317
|
if (providerConfig.baseUrl || providerConfig.headers || providerConfig.apiKey) overrides.set(providerName, {
|
|
286
318
|
baseUrl: providerConfig.baseUrl,
|
|
287
319
|
headers: providerConfig.headers,
|
|
@@ -309,6 +341,7 @@ var init_model_registry = __esmMin((() => {
|
|
|
309
341
|
const models = [];
|
|
310
342
|
const defaults = getDefaultModelValues();
|
|
311
343
|
for (const [providerName, providerConfig] of Object.entries(config.providers)) {
|
|
344
|
+
if (providerName === "xopc-cloud") continue;
|
|
312
345
|
const modelDefs = providerConfig.models ?? [];
|
|
313
346
|
if (modelDefs.length === 0) continue;
|
|
314
347
|
for (const modelDef of modelDefs) {
|
|
@@ -5,6 +5,7 @@ import { getDomesticProviderPreset, getDomesticProviderPresetIds } from "./domes
|
|
|
5
5
|
init_providers();
|
|
6
6
|
init_plugin_registry();
|
|
7
7
|
const FEATURED_PROVIDER_ORDER = [
|
|
8
|
+
"xopc-cloud",
|
|
8
9
|
"deepseek",
|
|
9
10
|
"openai",
|
|
10
11
|
"anthropic",
|
|
@@ -34,6 +35,7 @@ const FEATURED_PROVIDER_ORDER = [
|
|
|
34
35
|
"minimax-cn"
|
|
35
36
|
];
|
|
36
37
|
const PROVIDER_HINTS = {
|
|
38
|
+
"xopc-cloud": "Official XOPC model service with models discovered from your account.",
|
|
37
39
|
openai: "Frontier OpenAI models from the official API.",
|
|
38
40
|
anthropic: "Claude models for coding, long context, and reasoning.",
|
|
39
41
|
xai: "Grok models from xAI.",
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type CredentialResolver } from '../auth/credentials.js';
|
|
2
|
+
import { type ModelCatalogStore } from './model-catalog-store.js';
|
|
3
|
+
export interface XopcCloudConnectionOptions {
|
|
4
|
+
fetchImpl?: typeof fetch;
|
|
5
|
+
consoleUrl?: string;
|
|
6
|
+
routerUrl?: string;
|
|
7
|
+
deviceIdPath?: string;
|
|
8
|
+
catalogStore?: ModelCatalogStore;
|
|
9
|
+
credentials?: Pick<CredentialResolver, 'saveApiKey' | 'revealGatewayStoredApiKey' | 'deleteProfile'>;
|
|
10
|
+
refreshModels?: () => void;
|
|
11
|
+
now?: () => number;
|
|
12
|
+
}
|
|
13
|
+
export type XopcCloudPollResult = {
|
|
14
|
+
status: 'pending';
|
|
15
|
+
} | {
|
|
16
|
+
status: 'connected';
|
|
17
|
+
modelCount: number;
|
|
18
|
+
models: string[];
|
|
19
|
+
recommendedModel: string | null;
|
|
20
|
+
};
|
|
21
|
+
export declare class XopcCloudHttpError extends Error {
|
|
22
|
+
readonly status: number;
|
|
23
|
+
readonly code?: string;
|
|
24
|
+
constructor(message: string, status: number, code?: string);
|
|
25
|
+
}
|
|
26
|
+
export declare class XopcCloudConnectionService {
|
|
27
|
+
private readonly pending;
|
|
28
|
+
private readonly fetchImpl;
|
|
29
|
+
private readonly consoleUrl;
|
|
30
|
+
private readonly routerUrl;
|
|
31
|
+
private readonly deviceIdPath;
|
|
32
|
+
private readonly catalogStore;
|
|
33
|
+
private readonly credentials;
|
|
34
|
+
private readonly refreshModels;
|
|
35
|
+
private readonly now;
|
|
36
|
+
constructor(options?: XopcCloudConnectionOptions);
|
|
37
|
+
start(clientType: 'electron' | 'web' | 'cli'): Promise<{
|
|
38
|
+
requestId: string;
|
|
39
|
+
authorizationUrl: string;
|
|
40
|
+
expiresIn: number;
|
|
41
|
+
pollInterval: number;
|
|
42
|
+
}>;
|
|
43
|
+
poll(requestId: string): Promise<XopcCloudPollResult>;
|
|
44
|
+
refreshCatalog(): Promise<{
|
|
45
|
+
status: 'disconnected' | 'unchanged' | 'updated';
|
|
46
|
+
modelCount?: number;
|
|
47
|
+
}>;
|
|
48
|
+
private getOrCreateDeviceId;
|
|
49
|
+
private fetchCatalog;
|
|
50
|
+
private install;
|
|
51
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { init_paths_state, resolveStateDir } from "../config/paths-state.js";
|
|
2
|
+
import { init_write_file_atomic, writeTextAtomicSync } from "../infra/write-file-atomic.js";
|
|
3
|
+
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
4
|
+
import { getModelRegistry, init_model_registry } from "./model-registry.js";
|
|
5
|
+
import { getCredentialResolver, init_credentials } from "../auth/credentials.js";
|
|
6
|
+
import { hostname } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
10
|
+
//#region src/providers/xopc-cloud-connection.ts
|
|
11
|
+
init_credentials();
|
|
12
|
+
init_paths_state();
|
|
13
|
+
init_write_file_atomic();
|
|
14
|
+
init_model_catalog_store();
|
|
15
|
+
init_model_registry();
|
|
16
|
+
const DEFAULT_CONSOLE_URL = "https://console.xopc.ai";
|
|
17
|
+
const DEFAULT_ROUTER_URL = "https://router.xopc.ai/v1";
|
|
18
|
+
const CONNECTION_TTL_MS = 5 * 6e4;
|
|
19
|
+
var XopcCloudHttpError = class extends Error {
|
|
20
|
+
constructor(message, status, code) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.status = status;
|
|
23
|
+
this.code = code;
|
|
24
|
+
this.name = "XopcCloudHttpError";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function normalizedBaseUrl(value) {
|
|
28
|
+
return value.trim().replace(/\/+$/, "");
|
|
29
|
+
}
|
|
30
|
+
function parseJson(value, message) {
|
|
31
|
+
if (!value || typeof value !== "object") throw new Error(message);
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
var XopcCloudConnectionService = class {
|
|
35
|
+
pending = /* @__PURE__ */ new Map();
|
|
36
|
+
fetchImpl;
|
|
37
|
+
consoleUrl;
|
|
38
|
+
routerUrl;
|
|
39
|
+
deviceIdPath;
|
|
40
|
+
catalogStore;
|
|
41
|
+
credentials;
|
|
42
|
+
refreshModels;
|
|
43
|
+
now;
|
|
44
|
+
constructor(options = {}) {
|
|
45
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
46
|
+
this.consoleUrl = normalizedBaseUrl(options.consoleUrl ?? process.env.XOPC_CONSOLE_URL ?? DEFAULT_CONSOLE_URL);
|
|
47
|
+
this.routerUrl = normalizedBaseUrl(options.routerUrl ?? process.env.XOPC_MODEL_ROUTER_URL ?? DEFAULT_ROUTER_URL);
|
|
48
|
+
this.deviceIdPath = options.deviceIdPath ?? join(resolveStateDir(), "xopc-cloud-device.json");
|
|
49
|
+
this.catalogStore = options.catalogStore ?? getModelCatalogStore();
|
|
50
|
+
this.credentials = options.credentials ?? getCredentialResolver();
|
|
51
|
+
this.refreshModels = options.refreshModels ?? (() => getModelRegistry().refresh());
|
|
52
|
+
this.now = options.now ?? Date.now;
|
|
53
|
+
}
|
|
54
|
+
async start(clientType) {
|
|
55
|
+
const verifier = randomBytes(32).toString("base64url");
|
|
56
|
+
const codeChallenge = createHash("sha256").update(verifier).digest("base64url");
|
|
57
|
+
const response = await this.fetchImpl(`${this.consoleUrl}/api/v1/models/connect/requests`, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: { "content-type": "application/json" },
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
codeChallenge,
|
|
62
|
+
deviceId: this.getOrCreateDeviceId(),
|
|
63
|
+
deviceName: hostname() || "XOPC device",
|
|
64
|
+
clientType
|
|
65
|
+
}),
|
|
66
|
+
signal: AbortSignal.timeout(15e3)
|
|
67
|
+
});
|
|
68
|
+
const body = parseJson(await response.json().catch(() => null), "XOPC Console returned an invalid response");
|
|
69
|
+
if (!response.ok || typeof body.requestId !== "string" || typeof body.authorizationUrl !== "string") throw new Error("Unable to start XOPC model connection");
|
|
70
|
+
const authorizationUrl = new URL(body.authorizationUrl);
|
|
71
|
+
if (authorizationUrl.origin !== new URL(this.consoleUrl).origin) throw new Error("XOPC Console returned an unsafe authorization URL");
|
|
72
|
+
const expiresIn = typeof body.expiresIn === "number" ? body.expiresIn : CONNECTION_TTL_MS / 1e3;
|
|
73
|
+
this.pending.set(body.requestId, {
|
|
74
|
+
verifier,
|
|
75
|
+
expiresAt: this.now() + expiresIn * 1e3
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
requestId: body.requestId,
|
|
79
|
+
authorizationUrl: authorizationUrl.href,
|
|
80
|
+
expiresIn,
|
|
81
|
+
pollInterval: typeof body.pollInterval === "number" ? body.pollInterval : 2
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async poll(requestId) {
|
|
85
|
+
const pending = this.pending.get(requestId);
|
|
86
|
+
if (!pending) throw new Error("Connection request is not active");
|
|
87
|
+
if (pending.expiresAt <= this.now()) {
|
|
88
|
+
this.pending.delete(requestId);
|
|
89
|
+
throw new Error("Connection request expired");
|
|
90
|
+
}
|
|
91
|
+
const tokenResponse = await this.fetchImpl(`${this.consoleUrl}/api/v1/models/connect/token`, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: { "content-type": "application/json" },
|
|
94
|
+
body: JSON.stringify({
|
|
95
|
+
requestId,
|
|
96
|
+
codeVerifier: pending.verifier
|
|
97
|
+
}),
|
|
98
|
+
signal: AbortSignal.timeout(15e3)
|
|
99
|
+
});
|
|
100
|
+
if (tokenResponse.status === 202) return { status: "pending" };
|
|
101
|
+
const token = parseJson(await tokenResponse.json().catch(() => null), "XOPC Console returned an invalid token response");
|
|
102
|
+
if (!tokenResponse.ok || token.providerId !== "xopc-cloud" || typeof token.apiKey !== "string") throw new Error("Unable to complete XOPC model connection");
|
|
103
|
+
const catalog = await this.fetchCatalog(token.apiKey);
|
|
104
|
+
if (!catalog) throw new Error("XOPC model catalog was not available");
|
|
105
|
+
await this.install(token.apiKey, catalog, true);
|
|
106
|
+
this.pending.delete(requestId);
|
|
107
|
+
return {
|
|
108
|
+
status: "connected",
|
|
109
|
+
modelCount: catalog.models.length,
|
|
110
|
+
models: catalog.models.map((model) => model.id),
|
|
111
|
+
recommendedModel: catalog.recommendedModel
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async refreshCatalog() {
|
|
115
|
+
const apiKey = await this.credentials.revealGatewayStoredApiKey("xopc-cloud");
|
|
116
|
+
if (!apiKey) return { status: "disconnected" };
|
|
117
|
+
const previous = this.catalogStore.getSource("xopc-cloud");
|
|
118
|
+
const catalog = await this.fetchCatalog(apiKey, previous?.etag);
|
|
119
|
+
if (!catalog) {
|
|
120
|
+
if (previous) this.catalogStore.saveSource("xopc-cloud", {
|
|
121
|
+
...previous,
|
|
122
|
+
lastSuccessAt: this.now()
|
|
123
|
+
});
|
|
124
|
+
return { status: "unchanged" };
|
|
125
|
+
}
|
|
126
|
+
await this.install(apiKey, catalog, false);
|
|
127
|
+
return {
|
|
128
|
+
status: "updated",
|
|
129
|
+
modelCount: catalog.models.length
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
getOrCreateDeviceId() {
|
|
133
|
+
if (existsSync(this.deviceIdPath)) try {
|
|
134
|
+
const value = JSON.parse(readFileSync(this.deviceIdPath, "utf8"));
|
|
135
|
+
if (typeof value.deviceId === "string" && value.deviceId.length >= 16) return value.deviceId;
|
|
136
|
+
} catch {}
|
|
137
|
+
const deviceId = randomBytes(32).toString("base64url");
|
|
138
|
+
writeTextAtomicSync(this.deviceIdPath, JSON.stringify({ deviceId }), { mode: 384 });
|
|
139
|
+
return deviceId;
|
|
140
|
+
}
|
|
141
|
+
async fetchCatalog(apiKey, etag) {
|
|
142
|
+
const headers = new Headers({ authorization: `Bearer ${apiKey}` });
|
|
143
|
+
if (etag) headers.set("if-none-match", etag);
|
|
144
|
+
const response = await this.fetchImpl(`${this.routerUrl}/catalog`, {
|
|
145
|
+
headers,
|
|
146
|
+
signal: AbortSignal.timeout(15e3)
|
|
147
|
+
});
|
|
148
|
+
if (response.status === 304) return null;
|
|
149
|
+
const rawBody = await response.json().catch(() => null);
|
|
150
|
+
if (!response.ok) {
|
|
151
|
+
const body = rawBody && typeof rawBody === "object" ? rawBody : null;
|
|
152
|
+
const errorBody = body?.error && typeof body.error === "object" ? body.error : null;
|
|
153
|
+
const code = typeof errorBody?.code === "string" ? errorBody.code : void 0;
|
|
154
|
+
throw new XopcCloudHttpError(response.status === 401 || response.status === 403 ? "XOPC Model Service authorization expired. Reconnect the service." : "Unable to load the XOPC model catalog", response.status, code);
|
|
155
|
+
}
|
|
156
|
+
const catalog = parseJson(rawBody, "XOPC model catalog returned an invalid response");
|
|
157
|
+
if (!Array.isArray(catalog.models)) throw new Error("Unable to load the XOPC model catalog");
|
|
158
|
+
const models = catalog.models.flatMap((item) => {
|
|
159
|
+
if (!item || typeof item !== "object") return [];
|
|
160
|
+
const value = item;
|
|
161
|
+
if (typeof value.id !== "string" || !value.id.trim() || value.id.includes("/")) return [];
|
|
162
|
+
return [{
|
|
163
|
+
id: value.id,
|
|
164
|
+
name: typeof value.name === "string" && value.name.trim() ? value.name : value.id,
|
|
165
|
+
maxOutputTokens: typeof value.maxOutputTokens === "number" && value.maxOutputTokens > 0 ? value.maxOutputTokens : null
|
|
166
|
+
}];
|
|
167
|
+
});
|
|
168
|
+
if (models.length === 0) throw new Error("No XOPC models are currently available");
|
|
169
|
+
return {
|
|
170
|
+
models,
|
|
171
|
+
recommendedModel: typeof catalog.recommendedModel === "string" ? catalog.recommendedModel : null,
|
|
172
|
+
etag: response.headers.get("etag")
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async install(apiKey, catalog, saveCredential) {
|
|
176
|
+
const previousKey = await this.credentials.revealGatewayStoredApiKey("xopc-cloud");
|
|
177
|
+
if (saveCredential) await this.credentials.saveApiKey("xopc-cloud", apiKey, { envVar: null });
|
|
178
|
+
try {
|
|
179
|
+
this.catalogStore.replaceSourceModels("xopc-cloud", {
|
|
180
|
+
providerId: "xopc-cloud",
|
|
181
|
+
baseUrl: this.routerUrl,
|
|
182
|
+
api: "openai-completions",
|
|
183
|
+
etag: catalog.etag,
|
|
184
|
+
recommendedModel: catalog.recommendedModel,
|
|
185
|
+
lastSuccessAt: this.now()
|
|
186
|
+
}, catalog.models);
|
|
187
|
+
} catch (err) {
|
|
188
|
+
if (saveCredential) if (previousKey) await this.credentials.saveApiKey("xopc-cloud", previousKey, { envVar: null });
|
|
189
|
+
else await this.credentials.deleteProfile("xopc-cloud:default");
|
|
190
|
+
throw err;
|
|
191
|
+
}
|
|
192
|
+
this.refreshModels();
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
//#endregion
|
|
196
|
+
export { XopcCloudConnectionService, XopcCloudHttpError };
|
|
@@ -17,7 +17,7 @@ export { initSessionTurn, type InitSessionTurnOptions, type InitSessionTurnResul
|
|
|
17
17
|
export { DEFAULT_RESET_TRIGGERS, RESET_OVERLAP_COMMANDS, bareResetAckMessage, matchResetTriggers, resolveResetTriggers, shouldSkipResetOverlapCommand, stripLeadingEnvelopeTimestamp, type ResetTriggerMatch, } from './reset-triggers.js';
|
|
18
18
|
export type { CompactionConfig, CompactionResult } from '../agent/memory/compaction.js';
|
|
19
19
|
export type { WindowConfig } from '../agent/memory/window.js';
|
|
20
|
-
export { maybeSetProvisionalSessionTitle, maybeRefineSessionTitleWithLlm, generateSessionTitleFromMessages, sanitizeSessionTitle, provisionalTitleFromUserText, fallbackTitleFromMessages, getSessionTitleSource, shouldRefineSessionTitleWithLlm, isWebchatSessionKey, shouldAutoTitleSessionKey, type SessionTitleSource, } from './session-title.js';
|
|
20
|
+
export { maybeSetProvisionalSessionTitle, maybeRefineSessionTitleWithLlm, generateSessionTitleFromMessages, sanitizeSessionTitle, sanitizeGeneratedSessionTitle, provisionalTitleFromUserText, fallbackTitleFromMessages, getSessionTitleSource, shouldRefineSessionTitleWithLlm, isWebchatSessionKey, shouldAutoTitleSessionKey, type SessionTitleSource, } from './session-title.js';
|
|
21
21
|
export { messagesToClientHistory, flattenMessageContent, type ClientHistoryMessage } from './client-history.js';
|
|
22
22
|
export { XOPC_SESSION_TRANSCRIPT_TYPE, CURRENT_SESSION_TRANSCRIPT_VERSION, } from './transcript-format.js';
|
|
23
23
|
export { buildSessionContextForLlm, isTranscriptContextEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray, type TranscriptStoredRow, type XopcTranscriptContextEntry, } from './session-context-for-llm.js';
|
|
@@ -2,7 +2,7 @@ import { SessionStatus } from "./types.js";
|
|
|
2
2
|
import { buildSessionContextForLlm, isTranscriptContextEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
3
3
|
import { effectiveWorkspacePathForSession, normalizeWorkingDirectoryInput, projectWorkspacePath } from "./session-workspace.js";
|
|
4
4
|
import { emitSessionTranscriptUpdate, onSessionTranscriptUpdate } from "./transcript-events.js";
|
|
5
|
-
import { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm } from "./session-title.js";
|
|
5
|
+
import { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeGeneratedSessionTitle, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm } from "./session-title.js";
|
|
6
6
|
import { normalizeCompactionCheckpointId } from "./compaction-checkpoints.js";
|
|
7
7
|
import { flattenMessageContent, messagesToClientHistory } from "./client-history.js";
|
|
8
8
|
import { SessionStore } from "./store.js";
|
|
@@ -18,4 +18,4 @@ import { resolveSession, resolveSessionKeyForRequest } from "./resolve-session.j
|
|
|
18
18
|
import { DEFAULT_RESET_TRIGGERS, RESET_OVERLAP_COMMANDS, bareResetAckMessage, matchResetTriggers, resolveResetTriggers, shouldSkipResetOverlapCommand, stripLeadingEnvelopeTimestamp } from "./reset-triggers.js";
|
|
19
19
|
import { initSessionTurn } from "./init-session-turn.js";
|
|
20
20
|
import { CURRENT_SESSION_TRANSCRIPT_VERSION, XOPC_SESSION_TRANSCRIPT_TYPE } from "./transcript-format.js";
|
|
21
|
-
export { CURRENT_SESSION_TRANSCRIPT_VERSION, DEFAULT_IDLE_MINUTES, DEFAULT_RESET_AT_HOUR, DEFAULT_RESET_MODE, DEFAULT_RESET_TRIGGERS, RESET_OVERLAP_COMMANDS, SessionConfigStore, SessionIndex, SessionStatus, SessionStore, XOPC_SESSION_TRANSCRIPT_TYPE, applySessionPatchToMetadata, bareResetAckMessage, buildSessionContextForLlm, effectiveWorkspacePathForSession, emitSessionTranscriptUpdate, evaluateSessionFreshness, fallbackTitleFromMessages, flattenMessageContent, generateSessionTitleFromMessages, getSessionTitleSource, initSessionTurn, isTranscriptContextEntry, isWebchatSessionKey, matchResetTriggers, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, mergeLlmMessagesPreservingContextRows, messagesToClientHistory, normalizeCompactionCheckpointId, normalizeWorkingDirectoryInput, onSessionTranscriptUpdate, projectWorkspacePath, provisionalTitleFromUserText, resolveChannelResetConfig, resolveDailyResetAtMs, resolveEffectiveReasoningLevel, resolveEffectiveThinkingLevel, resolveReasoningLevel, resolveResetTriggers, resolveSession, resolveSessionKeyForRequest, resolveSessionLifecycleTimestamps, resolveSessionResetPolicy, resolveSessionResetType, resolveThinkingLevel, resolveVerboseLevel, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm, shouldSkipResetOverlapCommand, shouldSkipWebchatInboundByAbortCutoff, stripLeadingEnvelopeTimestamp, transcriptRowsFromJsonArray };
|
|
21
|
+
export { CURRENT_SESSION_TRANSCRIPT_VERSION, DEFAULT_IDLE_MINUTES, DEFAULT_RESET_AT_HOUR, DEFAULT_RESET_MODE, DEFAULT_RESET_TRIGGERS, RESET_OVERLAP_COMMANDS, SessionConfigStore, SessionIndex, SessionStatus, SessionStore, XOPC_SESSION_TRANSCRIPT_TYPE, applySessionPatchToMetadata, bareResetAckMessage, buildSessionContextForLlm, effectiveWorkspacePathForSession, emitSessionTranscriptUpdate, evaluateSessionFreshness, fallbackTitleFromMessages, flattenMessageContent, generateSessionTitleFromMessages, getSessionTitleSource, initSessionTurn, isTranscriptContextEntry, isWebchatSessionKey, matchResetTriggers, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, mergeLlmMessagesPreservingContextRows, messagesToClientHistory, normalizeCompactionCheckpointId, normalizeWorkingDirectoryInput, onSessionTranscriptUpdate, projectWorkspacePath, provisionalTitleFromUserText, resolveChannelResetConfig, resolveDailyResetAtMs, resolveEffectiveReasoningLevel, resolveEffectiveThinkingLevel, resolveReasoningLevel, resolveResetTriggers, resolveSession, resolveSessionKeyForRequest, resolveSessionLifecycleTimestamps, resolveSessionResetPolicy, resolveSessionResetType, resolveThinkingLevel, resolveVerboseLevel, sanitizeGeneratedSessionTitle, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm, shouldSkipResetOverlapCommand, shouldSkipWebchatInboundByAbortCutoff, stripLeadingEnvelopeTimestamp, transcriptRowsFromJsonArray };
|
|
@@ -7,6 +7,8 @@ export declare function isWebchatSessionKey(sessionKey: string): boolean;
|
|
|
7
7
|
/** Whether to run LLM/fallback session naming for this key (excludes cron, heartbeat). */
|
|
8
8
|
export declare function shouldAutoTitleSessionKey(sessionKey: string): boolean;
|
|
9
9
|
export declare function sanitizeSessionTitle(raw: string): string;
|
|
10
|
+
/** Strip leading reasoning blocks emitted as raw text by some model providers. */
|
|
11
|
+
export declare function sanitizeGeneratedSessionTitle(raw: string): string;
|
|
10
12
|
export type SessionTitleSource = 'provisional' | 'llm' | 'user';
|
|
11
13
|
export declare function getSessionTitleSource(meta: {
|
|
12
14
|
customData?: Record<string, unknown>;
|
|
@@ -86,6 +86,23 @@ function sanitizeSessionTitle(raw) {
|
|
|
86
86
|
if (s.length > MAX_TITLE_LEN) s = s.slice(0, MAX_TITLE_LEN - 1).trimEnd() + "…";
|
|
87
87
|
return s;
|
|
88
88
|
}
|
|
89
|
+
/** Strip leading reasoning blocks emitted as raw text by some model providers. */
|
|
90
|
+
function sanitizeGeneratedSessionTitle(raw) {
|
|
91
|
+
let s = raw.trim();
|
|
92
|
+
while (s) {
|
|
93
|
+
const opening = s.match(/^<\s*(think|analysis|reasoning)\s*>/i);
|
|
94
|
+
if (!opening) break;
|
|
95
|
+
const tag = opening[1]?.toLowerCase();
|
|
96
|
+
if (!tag) return "";
|
|
97
|
+
const remainder = s.slice(opening[0].length);
|
|
98
|
+
const closing = new RegExp(`<\\s*\\/\\s*${tag}\\s*>`, "i").exec(remainder);
|
|
99
|
+
if (!closing) return "";
|
|
100
|
+
s = remainder.slice(closing.index + closing[0].length).trim();
|
|
101
|
+
}
|
|
102
|
+
s = s.replace(/^(?:<\s*\/\s*(?:think|analysis|reasoning)\s*>\s*)+/i, "").trim();
|
|
103
|
+
if (/^<\s*\/?\s*(?:think|analysis|reasoning)\s*>$/i.test(s)) return "";
|
|
104
|
+
return sanitizeSessionTitle(s);
|
|
105
|
+
}
|
|
89
106
|
function getSessionTitleSource(meta) {
|
|
90
107
|
const raw = meta?.customData?.titleSource;
|
|
91
108
|
if (raw === "provisional" || raw === "llm" || raw === "user") return raw;
|
|
@@ -159,7 +176,7 @@ Title:`,
|
|
|
159
176
|
if (Array.isArray(result.content)) {
|
|
160
177
|
for (const c of result.content) if (c && typeof c === "object" && c.type === "text") text += String(c.text || "");
|
|
161
178
|
}
|
|
162
|
-
const cleaned =
|
|
179
|
+
const cleaned = sanitizeGeneratedSessionTitle(text);
|
|
163
180
|
return cleaned.length > 0 ? cleaned : null;
|
|
164
181
|
} catch (err) {
|
|
165
182
|
log.warn({ err }, "Session title LLM call failed");
|
|
@@ -171,7 +188,11 @@ function shouldRefineSessionTitleWithLlm(meta) {
|
|
|
171
188
|
if (!meta) return false;
|
|
172
189
|
const source = getSessionTitleSource(meta);
|
|
173
190
|
if (source === "user") return false;
|
|
174
|
-
if (meta.name?.trim())
|
|
191
|
+
if (meta.name?.trim()) {
|
|
192
|
+
if (source === "provisional") return true;
|
|
193
|
+
if (source === "llm") return sanitizeGeneratedSessionTitle(meta.name).length === 0;
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
175
196
|
return true;
|
|
176
197
|
}
|
|
177
198
|
function canAutoWriteTitle(meta) {
|
|
@@ -269,4 +290,4 @@ async function maybeRefineSessionTitleWithLlm(sessionStore, sessionKey, modelRef
|
|
|
269
290
|
}
|
|
270
291
|
}
|
|
271
292
|
//#endregion
|
|
272
|
-
export { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm };
|
|
293
|
+
export { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeGeneratedSessionTitle, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xopcai/xopc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.163",
|
|
4
4
|
"description": "Local-first AI system that remembers context, coordinates AI, and sustains long-term progress.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -176,12 +176,10 @@
|
|
|
176
176
|
"scripts": {
|
|
177
177
|
"assets:brand": "node scripts/generate-brand-assets.mjs",
|
|
178
178
|
"assets:brand:check": "node scripts/generate-brand-assets.mjs --check",
|
|
179
|
-
"generate:bundled-image-providers": "node scripts/generate-bundled-image-providers.mjs",
|
|
180
|
-
"generate:bundled": "pnpm run generate:bundled-image-providers",
|
|
181
179
|
"build:node": "node scripts/tsdown-build.mjs",
|
|
182
180
|
"build:types": "tsc -p tsconfig.dts.json",
|
|
183
|
-
"build:ci": "pnpm run
|
|
184
|
-
"build": "pnpm run
|
|
181
|
+
"build:ci": "pnpm run build:node && pnpm run build:web",
|
|
182
|
+
"build": "pnpm run build:node && pnpm run build:types && pnpm run build:web",
|
|
185
183
|
"docker:build": "sh -c 'docker buildx version >/dev/null 2>&1 || { echo \"Docker buildx is required. Install it with: brew install docker-buildx && mkdir -p ~/.docker/cli-plugins && ln -sf $(brew --prefix)/opt/docker-buildx/bin/docker-buildx ~/.docker/cli-plugins/docker-buildx\" >&2; exit 1; }; DOCKER_BUILDKIT=1 docker build --build-arg XOPC_APT_MIRROR=\"${XOPC_APT_MIRROR:-}\" -t xopc:local .'",
|
|
186
184
|
"docker:run": "docker run --rm -it -p 18790:18790 -v ${HOME}/.xopc:/home/node/.xopc xopc:local",
|
|
187
185
|
"docker:compose:up": "sh -c 'if docker compose version >/dev/null 2>&1; then DOCKER_BUILDKIT=1 docker compose up --build xopc-gateway; else COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose up --build xopc-gateway; fi'",
|
|
@@ -202,7 +200,7 @@
|
|
|
202
200
|
"dev:init": "sh -c 'mkdir -p \"$HOME/.xopc-dev\" && XOPC_STATE_DIR=\"$HOME/.xopc-dev\" XOPC_CONFIG_PATH=\"$HOME/.xopc-dev/xopc.json\" XOPC_CONFIG=\"$HOME/.xopc-dev/xopc.json\" XOPC_LOG_DIR=\"$HOME/.xopc-dev/logs\" XOPC_LOG_LEVEL=info tsx src/cli/bin.ts init \"$@\"' --",
|
|
203
201
|
"dev:gateway": "sh -c 'mkdir -p \"$HOME/.xopc-dev\" && XOPC_STATE_DIR=\"$HOME/.xopc-dev\" XOPC_CONFIG_PATH=\"$HOME/.xopc-dev/xopc.json\" XOPC_CONFIG=\"$HOME/.xopc-dev/xopc.json\" XOPC_LOG_DIR=\"$HOME/.xopc-dev/logs\" XOPC_LOG_LEVEL=info tsx src/cli/bin.ts gateway \"$@\"' --",
|
|
204
202
|
"start": "node dist/src/cli/bin.js",
|
|
205
|
-
"test": "vitest run src extensions/telegram/src extensions/feishu/src extensions/weixin/src
|
|
203
|
+
"test": "vitest run src extensions/telegram/src extensions/feishu/src extensions/weixin/src",
|
|
206
204
|
"test:skills": "vitest run src/agent/skills/__tests__",
|
|
207
205
|
"test:skills:regression": "./scripts/test-skills.sh",
|
|
208
206
|
"test:skills:all": "npm run test:skills && npm run test:skills:regression",
|
|
@@ -250,7 +248,7 @@
|
|
|
250
248
|
"electron:build:artifacts": "pnpm run electron:native:build && pnpm run electron:vite:build:package && pnpm run electron:server:build && pnpm run electron:extensions:build",
|
|
251
249
|
"electron:frpc:download": "node --import tsx/esm scripts/download-frpc-binaries.mjs",
|
|
252
250
|
"electron:frpc:download:all": "node --import tsx/esm scripts/download-frpc-binaries.mjs --all",
|
|
253
|
-
"electron:build": "pnpm run
|
|
251
|
+
"electron:build": "pnpm run build:node && pnpm run build:web && pnpm run electron:build:artifacts && pnpm run electron:package",
|
|
254
252
|
"electron:preview": "cross-env ELECTRON_ENTRY=out/main/index.js electron-vite preview"
|
|
255
253
|
}
|
|
256
254
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bundled DashScope (Alibaba) image-generation extension entry.
|
|
3
|
-
*/
|
|
4
|
-
export { buildDashScopeCnImageGenerationProvider, buildDashScopeIntlImageGenerationProvider, generateDashScopeImages, resolveDashScopeImageGenerationUrl, mapSizeToDashScopeFormat, mapSizeToWan27Format, isWan27ImageModel, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_MODELS, type DashScopeImageRegion, } from './image-generation-provider.js';
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_IMAGE_MODELS, buildDashScopeCnImageGenerationProvider, buildDashScopeIntlImageGenerationProvider, generateDashScopeImages, isWan27ImageModel, mapSizeToDashScopeFormat, mapSizeToWan27Format, resolveDashScopeImageGenerationUrl } from "./image-generation-provider.js";
|
|
2
|
-
export { DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_IMAGE_MODELS, buildDashScopeCnImageGenerationProvider, buildDashScopeIntlImageGenerationProvider, generateDashScopeImages, isWan27ImageModel, mapSizeToDashScopeFormat, mapSizeToWan27Format, resolveDashScopeImageGenerationUrl };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "dashscope",
|
|
3
|
-
"name": "DashScope (Alibaba)",
|
|
4
|
-
"description": "Image generation via Alibaba Model Studio (DashScope). Configure the China or international provider under Settings → Images.",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"kind": "image-generation",
|
|
7
|
-
"main": "src/index.js",
|
|
8
|
-
"autoEnableWhenConfiguredProviders": [
|
|
9
|
-
"dashscope-cn",
|
|
10
|
-
"dashscope-intl"
|
|
11
|
-
],
|
|
12
|
-
"engines": {
|
|
13
|
-
"xopc": ">=0.0.106 <1.0.0"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { FAL_DEFAULT_IMAGE_MODEL, FAL_IMAGE_MODELS, buildFalImageGenerationProvider, generateFalImages, resolveFalBaseUrl } from "./image-generation-provider.js";
|
|
2
|
-
export { FAL_DEFAULT_IMAGE_MODEL, FAL_IMAGE_MODELS, buildFalImageGenerationProvider, generateFalImages, resolveFalBaseUrl };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "fal",
|
|
3
|
-
"name": "Fal.ai",
|
|
4
|
-
"description": "Image generation via Fal.ai queue API. Configure API keys and queue base URL under Settings → Images, or here — both edit the same providers.fal entry.",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"kind": "image-generation",
|
|
7
|
-
"main": "src/index.js",
|
|
8
|
-
"autoEnableWhenConfiguredProviders": [
|
|
9
|
-
"fal"
|
|
10
|
-
],
|
|
11
|
-
"engines": {
|
|
12
|
-
"xopc": ">=0.0.106 <1.0.0"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { GOOGLE_DEFAULT_IMAGE_MODEL, GOOGLE_IMAGE_MODELS, buildGoogleImageGenerationProvider, generateGoogleImages, resolveGoogleBaseUrl } from "./image-generation-provider.js";
|
|
2
|
-
export { GOOGLE_DEFAULT_IMAGE_MODEL, GOOGLE_IMAGE_MODELS, buildGoogleImageGenerationProvider, generateGoogleImages, resolveGoogleBaseUrl };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "google",
|
|
3
|
-
"name": "Google Gemini (images)",
|
|
4
|
-
"description": "Gemini image generation and editing. Configure API keys and optional base URL under Settings → Images, or here — both edit the same providers.google entry.",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"kind": "image-generation",
|
|
7
|
-
"main": "src/index.js",
|
|
8
|
-
"autoEnableWhenConfiguredProviders": [
|
|
9
|
-
"google"
|
|
10
|
-
],
|
|
11
|
-
"engines": {
|
|
12
|
-
"xopc": ">=0.0.106 <1.0.0"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bundled MiniMax image-generation extension entry.
|
|
3
|
-
*/
|
|
4
|
-
export { buildMinimaxCnImageGenerationProvider, buildMinimaxImageGenerationProvider, generateMinimaxImages, resolveMinimaxBaseUrl, mapSizeToMinimaxAspectRatio, MINIMAX_DEFAULT_IMAGE_MODEL, MINIMAX_IMAGE_MODELS, type MinimaxAspectRatio, } from './image-generation-provider.js';
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { MINIMAX_DEFAULT_IMAGE_MODEL, MINIMAX_IMAGE_MODELS, buildMinimaxCnImageGenerationProvider, buildMinimaxImageGenerationProvider, generateMinimaxImages, mapSizeToMinimaxAspectRatio, resolveMinimaxBaseUrl } from "./image-generation-provider.js";
|
|
2
|
-
export { MINIMAX_DEFAULT_IMAGE_MODEL, MINIMAX_IMAGE_MODELS, buildMinimaxCnImageGenerationProvider, buildMinimaxImageGenerationProvider, generateMinimaxImages, mapSizeToMinimaxAspectRatio, resolveMinimaxBaseUrl };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "minimax",
|
|
3
|
-
"name": "MiniMax (images)",
|
|
4
|
-
"description": "MiniMax image generation. Configure the China or international provider under Settings → Images.",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"kind": "image-generation",
|
|
7
|
-
"main": "src/index.js",
|
|
8
|
-
"autoEnableWhenConfiguredProviders": [
|
|
9
|
-
"minimax",
|
|
10
|
-
"minimax-cn"
|
|
11
|
-
],
|
|
12
|
-
"engines": {
|
|
13
|
-
"xopc": ">=0.0.106 <1.0.0"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "openai",
|
|
3
|
-
"name": "OpenAI (images)",
|
|
4
|
-
"description": "DALL·E / GPT image APIs. Configure API keys and optional base URL under Settings → Images, or here — both edit the same providers.openai entry.",
|
|
5
|
-
"version": "1.0.0",
|
|
6
|
-
"kind": "image-generation",
|
|
7
|
-
"main": "src/index.js",
|
|
8
|
-
"autoEnableWhenConfiguredProviders": [
|
|
9
|
-
"openai"
|
|
10
|
-
],
|
|
11
|
-
"engines": {
|
|
12
|
-
"xopc": ">=0.0.106 <1.0.0"
|
|
13
|
-
}
|
|
14
|
-
}
|