@xopcai/xopc 0.0.163 → 0.0.164
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-Xj95LzTv.js → activity-store-DkALQFJT.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-C-QeUFwU.js → agent-avatar-dicebear-RpxkQtQ3.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CxpwxMPE.js +2 -0
- package/dist/gateway/static/root/assets/{api-BTLmAm1_.js → api-DPIXEcIq.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-zc6Gf-S5.js → app-management-settings-panel-DLdjfMXB.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-0fMLnOWn.js → appearance-settings-C89-uxkq.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-k-tZbaRB.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DOiR_E21.js → archive-plugin-CqbH5geE.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BxmYl1D1.js → attachment-load-CeU4Qiot.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-BhZOirad.js → automation-suggestion-card-WiOuqXq9.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Bdn3dgC_.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DTTKsvgk.js → binary-plugins-C5TdzrhJ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C7se7iqg.js → block-editor-BjvWhphG.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-GsVTGfGs.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-kxmStCcv.js → browser-workflow-inputs-DXmzQ3nk.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CwYf9OM_.js → browser-workflows-page-C1-ptRe4.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-6d4kVjzl.js +2 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BZKh2cWX.js → capability-presets-api-C0pVlUyc.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DCxy5Ls_.js +2 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-r7tdbnJE.js → channel-recipient-api-B5rLegwk.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Bg3P8k0f.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-DZZq0upi.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-BpnQYAxA.js → connector-logo-CuI5w4qM.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-6UR7yhIZ.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-BvG8vDXZ.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-uv8Grtgk.js → desktop-pet-settings-CR__kZ8C.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-C4TTvf7p.js → directory-picker-path-field-BblWMz3e.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CzJAUPvM.js → dreaming-settings-DHMPugDE.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-Ci2mOYUt.js → extension-debug-page-ByVY1gZg.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DeXdmhXQ.js → extension-page-DLCKKtbK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-C93vaOsU.js → extension-settings-page-M-rhlFBC.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-C31Hlblp.js → gateway-config-api-DZHqhbXH.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-D3zS6RZh.js → gateway-settings-CZswIehx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CSRvCqxh.js → gateway-startup-retry-ulwTJovP.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-TbyRfDas.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-B-QBVOf2.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-D4wYNRrf.js → goals-config-api-DMxG6f0N.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BGxki8BR.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-Bx2jVvhQ.js → goals-settings-G-w1gCYD.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-BEIF1eXy.js → heartbeat-settings-Csb90R59.js} +1 -1
- package/dist/gateway/static/root/assets/{index-HZdBKfk_.js → index-CGwuxvzr.js} +70 -70
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DOEDpvTM.js → keyboard-shortcuts-settings-C_Bl3YOr.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-BR2tBhO3.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-B0OpGpxv.js → local-apps-page-_8Rv-tSk.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Ys6RP7Be.js → locale-store-C_ax27uc.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CwF0C_Z2.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-CEZwysCH.js → markdown-split-CZnZS6gq.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CpGKE7B0.js → media-plugins-C2XLYC6G.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-BzI9Wx30.js → messages-C96Zjb0V.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-CdiuDZ5a.js → notes-page-BkuZxTFo.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-CD4FADi7.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-BkH5AVV2.js → page-tabs-DR2FGC4E.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CQai8f9D.js → preview-open-alternatives-B65O8wBL.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-B2kSdB2b.js → product-open-page-Cag-utLH.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-COKtUblD.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-QYmqanBN.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BU_gBU0f.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-NGYnO7n7.js → save-bar-controls-DCWpFnPc.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-nLOphnv3.js → schedule-field-ClacZdvE.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-D0e90ndE.js → schema-form-BVlbEipU.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-u-Pjbzfm.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-1Yck1PKq.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-X2Sl-EAk.js → settings-form-section-GSNlQWSW.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DOnUabm7.js → settings-loading-skeleton-08Ae5sB_.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-C4UUNi1n.js → settings-page-BseJD4I-.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-C1yYqbT6.js → settings-page-layout-bSliH-Y3.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CGRhJVlt.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-Cfy_pH7V.js → share-preview-page-C114OpTx.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BRFpWFgI.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-cVjU2GnN.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CoMTjtRT.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Da81RJ6G.js → system-settings-panel-El8cDcTY.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DflSp9o4.js → theme-store-D37XLD_C.js} +1 -1
- package/dist/gateway/static/root/assets/{time-picker-BIkOW-2L.js → time-picker-CU7hhD8T.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib--HptwFcD.js → typed-models-lib-kToxD7Rc.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CMHY4ZfW.js → use-channel-catalog-DBh0dOC9.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-C0xYCSXB.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-nvIZerol.js → voice-api-key-field-DzEpwYaU.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-DakZqR85.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CswqPbTT.js +1 -0
- package/dist/gateway/static/root/assets/work-page-DYRXEk8m.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D96MHABy.js → workflow-run-setup-panel-BwSxyVMM.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CiLSYGuN.js +11 -0
- package/dist/gateway/static/root/index.html +6 -6
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/model-runtime.d.ts +4 -0
- package/dist/src/agent/embedded/model-runtime.js +49 -0
- package/dist/src/agent/embedded/session-runner.js +3 -3
- package/dist/src/auth/credentials.js +45 -2
- package/dist/src/auth/index.js +2 -1
- package/dist/src/auth/oauth/anthropic.js +27 -24
- package/dist/src/auth/oauth/github-copilot.js +20 -15
- package/dist/src/auth/oauth/google-antigravity.js +9 -2
- package/dist/src/auth/oauth/google-gemini-cli.js +9 -2
- package/dist/src/auth/oauth/google-oauth/google-antigravity.js +47 -40
- package/dist/src/auth/oauth/google-oauth/google-gemini-cli.js +48 -41
- package/dist/src/auth/oauth/google-oauth/oauth-page.js +7 -2
- package/dist/src/auth/oauth/google-oauth/pkce.js +4 -1
- package/dist/src/auth/oauth/index.d.ts +2 -0
- package/dist/src/auth/oauth/index.js +24 -10
- package/dist/src/auth/oauth/kimi-coding.js +76 -71
- package/dist/src/auth/oauth/minimax-cn.js +78 -73
- package/dist/src/auth/oauth/minimax.js +78 -73
- package/dist/src/auth/oauth/openai-codex.js +31 -25
- package/dist/src/auth/oauth/pkce.js +4 -1
- package/dist/src/auth/oauth/registry.d.ts +13 -0
- package/dist/src/auth/oauth/registry.js +65 -0
- package/dist/src/auth/oauth/xopc-cloud.d.ts +2 -0
- package/dist/src/auth/oauth/xopc-cloud.js +101 -0
- package/dist/src/auth/sync-provider-auth.js +5 -0
- package/dist/src/cli/utils/oauth-providers.d.ts +3 -26
- package/dist/src/cli/utils/oauth-providers.js +6 -80
- package/dist/src/config/models-json.js +8 -0
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/oauth-async.js +3 -19
- package/dist/src/gateway/hono/oauth.js +3 -19
- package/dist/src/gateway/hono/routes/models.js +1 -55
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/providers/domestic-presets.d.ts +0 -20
- package/dist/src/providers/domestic-presets.js +0 -25
- package/dist/src/providers/index.js +9 -0
- package/dist/src/providers/model-catalog-store.d.ts +20 -58
- package/dist/src/providers/model-catalog-store.js +18 -57
- package/dist/src/providers/model-catalog-sync-service.d.ts +3 -4
- package/dist/src/providers/model-catalog-sync-service.js +3 -13
- package/dist/src/providers/model-registry.js +0 -2
- package/dist/src/providers/xopc-cloud-model-source.d.ts +30 -0
- package/dist/src/providers/xopc-cloud-model-source.js +68 -0
- package/dist/src/work-discovery/analyzer.js +27 -14
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-DVKlWKJE.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-BZXEJDIV.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-B8CnkoXv.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BCPWKI9V.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C7lr_mX2.js +0 -2
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Ble9kHRu.js +0 -2
- package/dist/gateway/static/root/assets/channels-settings-CtQQQHrv.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-_VirfMKW.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BXWJSJeY.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-B86W4a5c.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-CWp2b7__.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-Dtm29FxD.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-jMzBJs6e.js +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-CseW9jD3.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DVqPbth5.js +0 -7
- package/dist/gateway/static/root/assets/notes-workbench-mrc3xtpn.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-CfhPJLkH.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BfMoKjdm.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CrDtcsZ9.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-D3DbF3dV.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BZp0O2dH.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-84iao4DZ.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DtcwQvRG.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-L7j5Gc8Z.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-1Ps8PjsP.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-BYAAs2iW.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-J35JkJ7_.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-C4wYDYqV.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DMvitV6c.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-JMN0nMbM.js +0 -11
- package/dist/src/agent/embedded/xopc-auth-storage.d.ts +0 -19
- package/dist/src/agent/embedded/xopc-auth-storage.js +0 -40
- package/dist/src/providers/xopc-cloud-connection.d.ts +0 -51
- package/dist/src/providers/xopc-cloud-connection.js +0 -196
|
@@ -1,62 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
recommendedModel: z.ZodNullable<z.ZodString>;
|
|
20
|
-
lastSuccessAt: z.ZodNumber;
|
|
21
|
-
models: z.ZodArray<z.ZodObject<{
|
|
22
|
-
id: z.ZodString;
|
|
23
|
-
name: z.ZodString;
|
|
24
|
-
availability: z.ZodEnum<{
|
|
25
|
-
available: "available";
|
|
26
|
-
unavailable: "unavailable";
|
|
27
|
-
}>;
|
|
28
|
-
maxOutputTokens: z.ZodNullable<z.ZodNumber>;
|
|
29
|
-
}, z.core.$strip>>;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
declare const ModelCatalogSchema: z.ZodObject<{
|
|
32
|
-
sources: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
33
|
-
providerId: z.ZodString;
|
|
34
|
-
baseUrl: z.ZodString;
|
|
35
|
-
api: z.ZodEnum<{
|
|
36
|
-
"openai-completions": "openai-completions";
|
|
37
|
-
"openai-responses": "openai-responses";
|
|
38
|
-
}>;
|
|
39
|
-
etag: z.ZodNullable<z.ZodString>;
|
|
40
|
-
recommendedModel: z.ZodNullable<z.ZodString>;
|
|
41
|
-
lastSuccessAt: z.ZodNumber;
|
|
42
|
-
models: z.ZodArray<z.ZodObject<{
|
|
43
|
-
id: z.ZodString;
|
|
44
|
-
name: z.ZodString;
|
|
45
|
-
availability: z.ZodEnum<{
|
|
46
|
-
available: "available";
|
|
47
|
-
unavailable: "unavailable";
|
|
48
|
-
}>;
|
|
49
|
-
maxOutputTokens: z.ZodNullable<z.ZodNumber>;
|
|
50
|
-
}, z.core.$strip>>;
|
|
51
|
-
}, z.core.$strip>>;
|
|
52
|
-
}, z.core.$strip>;
|
|
53
|
-
export type CatalogModel = z.infer<typeof CatalogModelSchema>;
|
|
54
|
-
export type CatalogSource = z.infer<typeof CatalogSourceSchema>;
|
|
55
|
-
export type ModelCatalogSnapshot = z.infer<typeof ModelCatalogSchema>;
|
|
1
|
+
export interface CatalogModel {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
availability: 'available' | 'unavailable';
|
|
5
|
+
maxOutputTokens: number | null;
|
|
6
|
+
}
|
|
7
|
+
export interface CatalogSource {
|
|
8
|
+
providerId: string;
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
api: 'openai-completions' | 'openai-responses';
|
|
11
|
+
etag: string | null;
|
|
12
|
+
recommendedModel: string | null;
|
|
13
|
+
lastSuccessAt: number;
|
|
14
|
+
models: CatalogModel[];
|
|
15
|
+
}
|
|
16
|
+
export interface ModelCatalogSnapshot {
|
|
17
|
+
sources: Record<string, CatalogSource>;
|
|
18
|
+
}
|
|
56
19
|
export type AvailableCatalogModel = Omit<CatalogModel, 'availability'>;
|
|
57
20
|
export declare class ModelCatalogStore {
|
|
58
|
-
private
|
|
59
|
-
constructor(path?: string);
|
|
21
|
+
private sources;
|
|
60
22
|
load(): ModelCatalogSnapshot;
|
|
61
23
|
getSource(sourceId: string): CatalogSource | undefined;
|
|
62
24
|
saveSource(sourceId: string, source: CatalogSource): void;
|
|
@@ -65,7 +27,7 @@ export declare class ModelCatalogStore {
|
|
|
65
27
|
addedCount: number;
|
|
66
28
|
unavailableCount: number;
|
|
67
29
|
};
|
|
30
|
+
private cloneSource;
|
|
68
31
|
}
|
|
69
32
|
export declare function getModelCatalogStore(): ModelCatalogStore;
|
|
70
33
|
export declare function resetModelCatalogStore(): void;
|
|
71
|
-
export {};
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { init_paths_state, resolveStateDir } from "../config/paths-state.js";
|
|
3
|
-
import { createLogger } from "../utils/logger/index.js";
|
|
4
|
-
import { init_logger } from "../utils/logger.js";
|
|
5
|
-
import { init_write_file_atomic, writeTextAtomicSync } from "../infra/write-file-atomic.js";
|
|
6
|
-
import { join } from "node:path";
|
|
7
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
8
|
-
import { z } from "zod";
|
|
9
2
|
//#region src/providers/model-catalog-store.ts
|
|
10
3
|
function getModelCatalogStore() {
|
|
11
4
|
globalModelCatalogStore ??= new ModelCatalogStore();
|
|
@@ -14,65 +7,27 @@ function getModelCatalogStore() {
|
|
|
14
7
|
function resetModelCatalogStore() {
|
|
15
8
|
globalModelCatalogStore = void 0;
|
|
16
9
|
}
|
|
17
|
-
var
|
|
10
|
+
var ModelCatalogStore, globalModelCatalogStore;
|
|
18
11
|
var init_model_catalog_store = __esmMin((() => {
|
|
19
|
-
init_paths_state();
|
|
20
|
-
init_write_file_atomic();
|
|
21
|
-
init_logger();
|
|
22
|
-
log = createLogger("ModelCatalogStore");
|
|
23
|
-
CatalogModelSchema = z.object({
|
|
24
|
-
id: z.string().min(1),
|
|
25
|
-
name: z.string().min(1),
|
|
26
|
-
availability: z.enum(["available", "unavailable"]),
|
|
27
|
-
maxOutputTokens: z.number().positive().nullable()
|
|
28
|
-
});
|
|
29
|
-
CatalogSourceSchema = z.object({
|
|
30
|
-
providerId: z.string().min(1),
|
|
31
|
-
baseUrl: z.string().url(),
|
|
32
|
-
api: z.enum(["openai-completions", "openai-responses"]),
|
|
33
|
-
etag: z.string().nullable(),
|
|
34
|
-
recommendedModel: z.string().nullable(),
|
|
35
|
-
lastSuccessAt: z.number().int().nonnegative(),
|
|
36
|
-
models: z.array(CatalogModelSchema)
|
|
37
|
-
});
|
|
38
|
-
ModelCatalogSchema = z.object({ sources: z.record(z.string(), CatalogSourceSchema) });
|
|
39
12
|
ModelCatalogStore = class {
|
|
40
|
-
|
|
41
|
-
this.path = path;
|
|
42
|
-
}
|
|
13
|
+
sources = {};
|
|
43
14
|
load() {
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
const parsed = ModelCatalogSchema.safeParse(JSON.parse(readFileSync(this.path, "utf8")));
|
|
47
|
-
if (parsed.success) return parsed.data;
|
|
48
|
-
log.warn({
|
|
49
|
-
path: this.path,
|
|
50
|
-
errorMessage: parsed.error.message
|
|
51
|
-
}, "Ignoring invalid model catalog snapshot");
|
|
52
|
-
} catch (err) {
|
|
53
|
-
log.warn({
|
|
54
|
-
err,
|
|
55
|
-
path: this.path
|
|
56
|
-
}, "Ignoring unreadable model catalog snapshot");
|
|
57
|
-
}
|
|
58
|
-
return { sources: {} };
|
|
15
|
+
return { sources: Object.fromEntries(Object.entries(this.sources).map(([id, source]) => [id, this.cloneSource(source)])) };
|
|
59
16
|
}
|
|
60
17
|
getSource(sourceId) {
|
|
61
|
-
|
|
18
|
+
const source = this.sources[sourceId];
|
|
19
|
+
return source ? this.cloneSource(source) : void 0;
|
|
62
20
|
}
|
|
63
21
|
saveSource(sourceId, source) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} });
|
|
69
|
-
writeTextAtomicSync(this.path, `${JSON.stringify(next, null, 2)}\n`, { mode: 384 });
|
|
22
|
+
this.sources = {
|
|
23
|
+
...this.sources,
|
|
24
|
+
[sourceId]: this.cloneSource(source)
|
|
25
|
+
};
|
|
70
26
|
}
|
|
71
27
|
removeSource(sourceId) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
writeTextAtomicSync(this.path, `${JSON.stringify({ sources }, null, 2)}\n`, { mode: 384 });
|
|
28
|
+
if (!this.sources[sourceId]) return false;
|
|
29
|
+
const { [sourceId]: _removed, ...sources } = this.sources;
|
|
30
|
+
this.sources = sources;
|
|
76
31
|
return true;
|
|
77
32
|
}
|
|
78
33
|
replaceSourceModels(sourceId, source, models) {
|
|
@@ -95,6 +50,12 @@ var init_model_catalog_store = __esmMin((() => {
|
|
|
95
50
|
unavailableCount: unavailable.length
|
|
96
51
|
};
|
|
97
52
|
}
|
|
53
|
+
cloneSource(source) {
|
|
54
|
+
return {
|
|
55
|
+
...source,
|
|
56
|
+
models: source.models.map((model) => ({ ...model }))
|
|
57
|
+
};
|
|
58
|
+
}
|
|
98
59
|
};
|
|
99
60
|
}));
|
|
100
61
|
//#endregion
|
|
@@ -2,7 +2,7 @@ import type { Config } from '../config/schema.js';
|
|
|
2
2
|
import { type ModelsJsonConfig } from '../config/models-json.js';
|
|
3
3
|
import { type ModelCatalogStore } from './model-catalog-store.js';
|
|
4
4
|
import { discoverProviderModels } from './model-discovery.js';
|
|
5
|
-
import {
|
|
5
|
+
import { XopcCloudModelSource } from './xopc-cloud-model-source.js';
|
|
6
6
|
export interface ModelCatalogSyncStatus {
|
|
7
7
|
running: boolean;
|
|
8
8
|
refreshing: boolean;
|
|
@@ -21,7 +21,7 @@ export declare class ModelCatalogSyncService {
|
|
|
21
21
|
constructor(options?: {
|
|
22
22
|
intervalMs?: number;
|
|
23
23
|
onUpdated?: (modelCount: number) => void;
|
|
24
|
-
xopcCloud?:
|
|
24
|
+
xopcCloud?: XopcCloudModelSource;
|
|
25
25
|
getConfig?: () => Config;
|
|
26
26
|
catalogStore?: ModelCatalogStore;
|
|
27
27
|
loadProviders?: () => ModelsJsonConfig['providers'];
|
|
@@ -32,8 +32,7 @@ export declare class ModelCatalogSyncService {
|
|
|
32
32
|
start(): void;
|
|
33
33
|
stop(): void;
|
|
34
34
|
getStatus(): ModelCatalogSyncStatus;
|
|
35
|
-
|
|
36
|
-
refreshNow(): Promise<Awaited<ReturnType<XopcCloudConnectionService['refreshCatalog']>>>;
|
|
35
|
+
refreshNow(): Promise<Awaited<ReturnType<XopcCloudModelSource['refresh']>>>;
|
|
37
36
|
refreshAll(): Promise<{
|
|
38
37
|
updatedSources: string[];
|
|
39
38
|
}>;
|
|
@@ -4,7 +4,7 @@ import { init_models_json, loadModelsJson } from "../config/models-json.js";
|
|
|
4
4
|
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
5
5
|
import { getModelRegistry, init_model_registry } from "./model-registry.js";
|
|
6
6
|
import { discoverProviderModels, isProviderApiDiscoverable } from "./model-discovery.js";
|
|
7
|
-
import {
|
|
7
|
+
import { XopcCloudModelSource } from "./xopc-cloud-model-source.js";
|
|
8
8
|
//#region src/providers/model-catalog-sync-service.ts
|
|
9
9
|
init_logger();
|
|
10
10
|
init_models_json();
|
|
@@ -23,11 +23,7 @@ var ModelCatalogSyncService = class {
|
|
|
23
23
|
};
|
|
24
24
|
constructor(options = {}) {
|
|
25
25
|
this.options = options;
|
|
26
|
-
this.xopcCloud = options.xopcCloud ?? new
|
|
27
|
-
try {
|
|
28
|
-
const lastSuccessAt = getModelCatalogStore().getSource("xopc-cloud")?.lastSuccessAt;
|
|
29
|
-
if (lastSuccessAt !== void 0) this.status.lastSuccessAt = lastSuccessAt;
|
|
30
|
-
} catch {}
|
|
26
|
+
this.xopcCloud = options.xopcCloud ?? new XopcCloudModelSource();
|
|
31
27
|
}
|
|
32
28
|
start() {
|
|
33
29
|
if (this.status.running) return;
|
|
@@ -47,21 +43,15 @@ var ModelCatalogSyncService = class {
|
|
|
47
43
|
getStatus() {
|
|
48
44
|
return { ...this.status };
|
|
49
45
|
}
|
|
50
|
-
getXopcCloudConnection() {
|
|
51
|
-
return this.xopcCloud;
|
|
52
|
-
}
|
|
53
46
|
refreshNow() {
|
|
54
47
|
if (this.refreshPromise) return this.refreshPromise;
|
|
55
48
|
this.status.refreshing = true;
|
|
56
49
|
this.status.lastAttemptAt = Date.now();
|
|
57
|
-
this.refreshPromise = this.xopcCloud.
|
|
50
|
+
this.refreshPromise = this.xopcCloud.refresh().then((result) => {
|
|
58
51
|
if (result.status === "updated") {
|
|
59
52
|
this.status.lastSuccessAt = Date.now();
|
|
60
53
|
this.status.lastError = void 0;
|
|
61
54
|
this.options.onUpdated?.(result.modelCount ?? 0);
|
|
62
|
-
} else if (result.status === "unchanged") {
|
|
63
|
-
this.status.lastSuccessAt = Date.now();
|
|
64
|
-
this.status.lastError = void 0;
|
|
65
55
|
}
|
|
66
56
|
return result;
|
|
67
57
|
}).catch((err) => {
|
|
@@ -313,7 +313,6 @@ var init_model_registry = __esmMin((() => {
|
|
|
313
313
|
const modelOverrides = /* @__PURE__ */ new Map();
|
|
314
314
|
const apiKeyConfigs = /* @__PURE__ */ new Map();
|
|
315
315
|
for (const [providerName, providerConfig] of Object.entries(config.providers)) {
|
|
316
|
-
if (providerName === "xopc-cloud") continue;
|
|
317
316
|
if (providerConfig.baseUrl || providerConfig.headers || providerConfig.apiKey) overrides.set(providerName, {
|
|
318
317
|
baseUrl: providerConfig.baseUrl,
|
|
319
318
|
headers: providerConfig.headers,
|
|
@@ -341,7 +340,6 @@ var init_model_registry = __esmMin((() => {
|
|
|
341
340
|
const models = [];
|
|
342
341
|
const defaults = getDefaultModelValues();
|
|
343
342
|
for (const [providerName, providerConfig] of Object.entries(config.providers)) {
|
|
344
|
-
if (providerName === "xopc-cloud") continue;
|
|
345
343
|
const modelDefs = providerConfig.models ?? [];
|
|
346
344
|
if (modelDefs.length === 0) continue;
|
|
347
345
|
for (const modelDef of modelDefs) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type CredentialResolver } from '../auth/credentials.js';
|
|
2
|
+
import { type ModelCatalogStore } from './model-catalog-store.js';
|
|
3
|
+
export type XopcCloudModelRefreshResult = {
|
|
4
|
+
status: 'skipped';
|
|
5
|
+
reason: 'not_configured';
|
|
6
|
+
} | {
|
|
7
|
+
status: 'updated';
|
|
8
|
+
modelCount: number;
|
|
9
|
+
models: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare class XopcCloudModelError extends Error {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly code?: string;
|
|
14
|
+
constructor(message: string, status: number, code?: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class XopcCloudModelSource {
|
|
17
|
+
private readonly fetchImpl;
|
|
18
|
+
private readonly routerUrl;
|
|
19
|
+
private readonly credentials;
|
|
20
|
+
private readonly catalogStore;
|
|
21
|
+
private readonly refreshModels;
|
|
22
|
+
constructor(options?: {
|
|
23
|
+
fetchImpl?: typeof fetch;
|
|
24
|
+
routerUrl?: string;
|
|
25
|
+
credentials?: Pick<CredentialResolver, 'resolveApiKey'>;
|
|
26
|
+
catalogStore?: ModelCatalogStore;
|
|
27
|
+
refreshModels?: () => void;
|
|
28
|
+
});
|
|
29
|
+
refresh(): Promise<XopcCloudModelRefreshResult>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
2
|
+
import { getModelRegistry, init_model_registry } from "./model-registry.js";
|
|
3
|
+
import { getCredentialResolver, init_credentials } from "../auth/credentials.js";
|
|
4
|
+
//#region src/providers/xopc-cloud-model-source.ts
|
|
5
|
+
init_credentials();
|
|
6
|
+
init_model_catalog_store();
|
|
7
|
+
init_model_registry();
|
|
8
|
+
const DEFAULT_ROUTER_URL = "https://router.xopc.ai/v1";
|
|
9
|
+
var XopcCloudModelError = class extends Error {
|
|
10
|
+
constructor(message, status, code) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.name = "XopcCloudModelError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var XopcCloudModelSource = class {
|
|
18
|
+
fetchImpl;
|
|
19
|
+
routerUrl;
|
|
20
|
+
credentials;
|
|
21
|
+
catalogStore;
|
|
22
|
+
refreshModels;
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
25
|
+
this.routerUrl = (options.routerUrl ?? process.env.XOPC_MODEL_ROUTER_URL ?? DEFAULT_ROUTER_URL).replace(/\/+$/, "");
|
|
26
|
+
this.credentials = options.credentials ?? getCredentialResolver();
|
|
27
|
+
this.catalogStore = options.catalogStore ?? getModelCatalogStore();
|
|
28
|
+
this.refreshModels = options.refreshModels ?? (() => getModelRegistry().refresh());
|
|
29
|
+
}
|
|
30
|
+
async refresh() {
|
|
31
|
+
const accessToken = await this.credentials.resolveApiKey("xopc-cloud");
|
|
32
|
+
if (!accessToken) return {
|
|
33
|
+
status: "skipped",
|
|
34
|
+
reason: "not_configured"
|
|
35
|
+
};
|
|
36
|
+
const response = await this.fetchImpl(`${this.routerUrl}/models`, {
|
|
37
|
+
headers: {
|
|
38
|
+
authorization: `Bearer ${accessToken}`,
|
|
39
|
+
accept: "application/json"
|
|
40
|
+
},
|
|
41
|
+
signal: AbortSignal.timeout(3e4)
|
|
42
|
+
});
|
|
43
|
+
const body = await response.json().catch(() => null);
|
|
44
|
+
if (!response.ok) throw new XopcCloudModelError(typeof body?.error?.message === "string" ? body.error.message : `XOPC model discovery failed (${response.status})`, response.status, typeof body?.error?.code === "string" ? body.error.code : void 0);
|
|
45
|
+
if (!Array.isArray(body?.data)) throw new XopcCloudModelError("XOPC model discovery returned an invalid response", response.status, "invalid_response");
|
|
46
|
+
const models = [...new Set(body.data.map((model) => model.id).filter((id) => typeof id === "string" && id.length > 0))];
|
|
47
|
+
this.catalogStore.replaceSourceModels("xopc-cloud", {
|
|
48
|
+
providerId: "xopc-cloud",
|
|
49
|
+
baseUrl: this.routerUrl,
|
|
50
|
+
api: "openai-completions",
|
|
51
|
+
etag: response.headers.get("x-xopc-model-catalog-version"),
|
|
52
|
+
recommendedModel: models[0] ?? null,
|
|
53
|
+
lastSuccessAt: Date.now()
|
|
54
|
+
}, models.map((id) => ({
|
|
55
|
+
id,
|
|
56
|
+
name: id,
|
|
57
|
+
maxOutputTokens: null
|
|
58
|
+
})));
|
|
59
|
+
this.refreshModels();
|
|
60
|
+
return {
|
|
61
|
+
status: "updated",
|
|
62
|
+
modelCount: models.length,
|
|
63
|
+
models
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { XopcCloudModelError, XopcCloudModelSource };
|
|
@@ -7,6 +7,7 @@ init_schema();
|
|
|
7
7
|
init_providers();
|
|
8
8
|
const MAX_MODEL_CONTEXT_CHARS = 12e4;
|
|
9
9
|
const MAX_PERSONAL_CONTEXT_CHARS = 1e5;
|
|
10
|
+
const WORK_ANALYSIS_MAX_TOKENS = 6e3;
|
|
10
11
|
function extractText(content) {
|
|
11
12
|
if (typeof content === "string") return content;
|
|
12
13
|
if (!Array.isArray(content)) return "";
|
|
@@ -17,16 +18,24 @@ function extractText(content) {
|
|
|
17
18
|
}).join("");
|
|
18
19
|
}
|
|
19
20
|
function parseJson(raw) {
|
|
20
|
-
const
|
|
21
|
+
const candidates = [];
|
|
22
|
+
for (const match of raw.matchAll(/```json\s*([\s\S]*?)```/gi)) if (match[1]) candidates.push(match[1]);
|
|
23
|
+
candidates.push(raw.trim());
|
|
24
|
+
for (const match of raw.matchAll(/```(?:[^\n]*)?\s*([\s\S]*?)```/g)) if (match[1]) candidates.push(match[1]);
|
|
21
25
|
const start = raw.indexOf("{");
|
|
22
26
|
const end = raw.lastIndexOf("}");
|
|
23
|
-
|
|
24
|
-
try {
|
|
27
|
+
if (start >= 0 && end > start) candidates.push(raw.slice(start, end + 1));
|
|
28
|
+
for (const candidate of new Set(candidates)) try {
|
|
25
29
|
const value = JSON.parse(candidate);
|
|
26
|
-
|
|
27
|
-
} catch {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
if (value && typeof value === "object" && !Array.isArray(value)) return value;
|
|
31
|
+
} catch {}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function invalidJsonError(label, response, raw) {
|
|
35
|
+
const outputChars = raw.length;
|
|
36
|
+
if (response.stopReason === "length") return /* @__PURE__ */ new Error(`${label} response was truncated before completing valid JSON (outputChars=${outputChars})`);
|
|
37
|
+
if (response.stopReason === "error" && typeof response.errorMessage === "string") return /* @__PURE__ */ new Error(`${label} model request failed: ${response.errorMessage}`);
|
|
38
|
+
return /* @__PURE__ */ new Error(`${label} did not return valid JSON (stopReason=${String(response.stopReason)}, outputChars=${outputChars})`);
|
|
30
39
|
}
|
|
31
40
|
function strings(value, max) {
|
|
32
41
|
return Array.isArray(value) ? value.filter((item) => typeof item === "string" && item.trim().length > 0).slice(0, max).map((item) => item.trim()) : [];
|
|
@@ -152,7 +161,7 @@ async function analyzeWorkContext(input) {
|
|
|
152
161
|
};
|
|
153
162
|
const model = resolveModel(modelRef);
|
|
154
163
|
const compactSnapshot = snapshotForModel(input.snapshot);
|
|
155
|
-
const
|
|
164
|
+
const response = await completeWithResolvedCredentials(model, { messages: [{
|
|
156
165
|
role: "user",
|
|
157
166
|
content: [
|
|
158
167
|
"You help a user resume real work in one explicitly selected local folder.",
|
|
@@ -188,11 +197,13 @@ async function analyzeWorkContext(input) {
|
|
|
188
197
|
].join("\n"),
|
|
189
198
|
timestamp: Date.now()
|
|
190
199
|
}] }, {
|
|
191
|
-
maxTokens:
|
|
200
|
+
maxTokens: WORK_ANALYSIS_MAX_TOKENS,
|
|
192
201
|
temperature: .1,
|
|
193
202
|
signal: input.signal
|
|
194
|
-
})
|
|
195
|
-
|
|
203
|
+
});
|
|
204
|
+
const raw = extractText(response.content);
|
|
205
|
+
const parsed = parseJson(raw);
|
|
206
|
+
if (!parsed) throw invalidJsonError("Analysis", response, raw);
|
|
196
207
|
if (parsed.lowConfidence === true) return {
|
|
197
208
|
modelRef,
|
|
198
209
|
result: lowConfidenceResult(input.snapshot, typeof parsed.contextQuestion === "string" ? parsed.contextQuestion.trim().slice(0, 500) : void 0)
|
|
@@ -266,7 +277,7 @@ async function analyzePersonalContext(input) {
|
|
|
266
277
|
input.workContext ? `Work-directory understanding from the same one-shot investigation:\n${JSON.stringify(input.workContext)}` : "",
|
|
267
278
|
JSON.stringify(items)
|
|
268
279
|
].join("\n");
|
|
269
|
-
const
|
|
280
|
+
const response = await completeWithResolvedCredentials(resolveModel(modelRef), { messages: [{
|
|
270
281
|
role: "user",
|
|
271
282
|
content: prompt,
|
|
272
283
|
timestamp: Date.now()
|
|
@@ -274,8 +285,10 @@ async function analyzePersonalContext(input) {
|
|
|
274
285
|
maxTokens: 1500,
|
|
275
286
|
temperature: .1,
|
|
276
287
|
signal: input.signal
|
|
277
|
-
})
|
|
278
|
-
|
|
288
|
+
});
|
|
289
|
+
const raw = extractText(response.content);
|
|
290
|
+
const parsed = parseJson(raw);
|
|
291
|
+
if (!parsed) throw invalidJsonError("Personal context analysis", response, raw);
|
|
279
292
|
const profileCandidates = Array.isArray(parsed.profileCandidates) ? parsed.profileCandidates.map(validateProfileCandidate).filter((value) => Boolean(value)).slice(0, 6) : [];
|
|
280
293
|
const allowedRefs = new Set(items.map((item) => item.ref));
|
|
281
294
|
return {
|
package/package.json
CHANGED