@xopcai/xopc 0.0.253 → 0.0.255
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/dist/background.js +59 -13
- package/dist/browser-ext/dist/content.js +0 -5
- package/dist/browser-ext/manifest.json +2 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CeS1bgXP.js → activity-store-DvjK5FEm.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BdF3HhCW.js → agent-avatar-dicebear-Cqspzbf_.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CL3Mi-uM.js +1 -0
- package/dist/gateway/static/root/assets/agents-odqXmGhA.js +1 -0
- package/dist/gateway/static/root/assets/{api-zMPeC0yU.js → api-CsYi3heY.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BaAFln8W.js → app-management-settings-panel-Gd4a5hdE.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CXvsoBlw.js → appearance-settings-CZ6KOnbd.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DyBDoCam.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-C0o_mVQI.js → archive-plugin-y82Rwhjm.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-B5Ry3tGL.js → attachment-load-D46SGNpv.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DY5QAEQd.js → automations-page-wilciIZ1.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-8U86Umig.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BydpEgBA.js → binary-plugins-CuMkNNCe.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D0CpUOMo.js → block-editor-DFnPsrxI.js} +44 -44
- package/dist/gateway/static/root/assets/{browser-automation-inputs-DzbTsGI6.js → browser-automation-inputs-hlmcSp4p.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-D7fZYjni.js → browser-automations-page-OjZvbARU.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-DOUG84qV.js +8 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CG73Mwi8.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-MDywEWWM.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-BGGRTkn6.js → channels-status-swr-D1HHFzkE.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-_CP4nvlg.js → chat-terminal-dock-Ce_T9BPq.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-D29p6Zvm.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-g2U8Rllf.js → cron-expression-BRrCwYyD.js} +1 -1
- package/dist/gateway/static/root/assets/date-picker-C35RuuWW.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-D-0gcbbM.js → dependency-picker-4pNXVcRM.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-D7kvWQ9H.js → desktop-pet-settings-BvV1UA5g.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Cl3JRIu6.js → desktop-pet-z91GYnPf.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DtP2tJHY.js → extension-debug-page-CkVF5HvV.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CphZDdoT.js → extension-page-DW0zQGaB.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CsxVLV4-.js → extension-settings-page-BLQhizZ3.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BW3Bx-aV.js → gateway-config-swr-02BBC1mK.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DxBZ05dX.js → gateway-settings-rAXx8FGP.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DAq74TZe.js → gateway-startup-retry-XZnY6621.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-BaW_r1t9.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BoTS8-Z9.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-MPuaXDRs.js → image-generation-api-CIcKz4Xs.js} +1 -1
- package/dist/gateway/static/root/assets/index-DsonmRCH.css +2 -0
- package/dist/gateway/static/root/assets/index-PksHo9hS.js +74 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CfhaTqgE.js → keyboard-shortcuts-settings-yfaGz6SE.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CR6asX7L.js → local-app-workbench-page-B3flRQH1.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-g01W3kEK.js → local-apps-page-Cp-nEtgV.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-BkeaPZpn.js → locale-store-VsboRLD7.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DkqsRCri.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-DeGxJF_Z.js → management-settings-24_JyDPk.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-Ca7BRBLL.js → markdown-view-CPXhy6nh.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-FmOhmzlD.js → media-plugins-CwLvIb9r.js} +1 -1
- package/dist/gateway/static/root/assets/messages-DngsF_Kx.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-BXNbn05L.js → mobile-pairing-wizard-BbJCDv57.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-OklYXK7y.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-BjfgJIQw.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-pyukZ1PJ.js → page-tabs-0YXn9Gkl.js} +1 -1
- package/dist/gateway/static/root/assets/popover-select-CKBYnT3c.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-slFHoMUe.js → preview-open-alternatives-2jVV5kfZ.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CXa3FNNk.js → product-open-page-D7p0NfTK.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-rLNM2mP0.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-D6jY2ZWl.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-CviQoUBf.js → registry-api-DlTWbXQA.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CZZg0kXc.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-O9D9o7-O.js → runtime-tools-settings-panel-B-NDgmJ4.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-8FesicnL.js → schema-form-DZYeBS1v.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BvuxJegi.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BAQHP4mB.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CBic9TFH.js → settings-form-section-zy5UMvPk.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-Xz66_Mjg.js → settings-page-CTuipbJq.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BkWoc5j5.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page--JpjwB58.js → share-preview-page-D3Uawo_h.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-B2doziIn.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-D2ymjqG5.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-fVKExKv5.js → skills-page-DDbabz7p.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-Yv9u3uJp.js → skills-page.utils-DkGhbiMa.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CCWjVdc2.js → system-settings-panel-Fc-WbX6-.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-7w7eB9nB.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BtkaVpMm.js → theme-store-vdB57bTn.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-C__W9BaN.js → tunnel-api-DZ0evABj.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Dow9RRcq.js → use-autosave-Ckof_m7e.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CcNCyrXZ.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CvF3lEyx.js → voice-api-key-field-CnmtpWlq.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-BEUVAyM6.js → voice-config-api-OA04c71t.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-B9PDfReq.js → work-discovery-overlay-sxvsDIC3.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-CUCfBpPF.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-Bp-nvnLa.js +5 -0
- package/dist/gateway/static/root/index.html +11 -11
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +17 -2
- package/dist/src/agent/tools/browser/tool/schemas.d.ts +85 -1
- package/dist/src/agent/tools/browser/tool/schemas.js +212 -5
- package/dist/src/agent/tools/create-share-tool.js +39 -1
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/oauth/xopc-cloud.js +1 -1
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/drivers/extension-driver.d.ts +4 -4
- package/dist/src/browser/drivers/extension-driver.js +20 -8
- package/dist/src/browser/drivers/playwright-driver.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.d.ts +3 -0
- package/dist/src/browser/providers/browser-ext-install.js +19 -4
- package/dist/src/browser/providers/extension.d.ts +14 -1
- package/dist/src/browser/providers/extension.js +89 -11
- package/dist/src/browser/providers/playwright-install.js +8 -12
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/tunnel.js +3 -3
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/device-routes.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +2 -2
- package/dist/src/gateway/hono/routes/browser.js +149 -27
- package/dist/src/gateway/hono/routes/lazy-bundles.js +3 -3
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +1 -1
- package/dist/src/gateway/hono/routes/shares.js +404 -7
- package/dist/src/gateway/hono/routes/site-shares.js +19 -13
- package/dist/src/gateway/hono/routes/tunnel.js +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +2 -2
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/sessions-api.js +1 -1
- package/dist/src/gateway/service.js +13 -13
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/model-thinking.js +57 -20
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/remote-access/exposure-manager.js +1 -1
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +1 -1
- package/dist/src/share/hosted-note-publication.d.ts +22 -0
- package/dist/src/share/hosted-note-publication.js +96 -0
- package/dist/src/share/hosted-session-share.d.ts +86 -7
- package/dist/src/share/hosted-session-share.js +72 -15
- package/dist/src/share/hosted-static-site-publication.d.ts +16 -0
- package/dist/src/share/hosted-static-site-publication.js +108 -0
- package/dist/src/share/hosted-static-site-publish.d.ts +23 -0
- package/dist/src/share/hosted-static-site-publish.js +53 -0
- package/dist/src/share/note-share-service.d.ts +1 -0
- package/dist/src/share/note-share-service.js +4 -4
- package/dist/src/share/share-url.d.ts +1 -1
- package/dist/src/share/share-url.js +14 -9
- package/dist/src/tasks/home-query-service.js +2 -2
- package/dist/src/tui/backends/embedded-backend.js +2 -2
- package/dist/src/tui/tui-agent-events.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/tunnel/index.js +1 -1
- package/dist/src/tunnel/tunnel-service.js +1 -1
- package/dist/src/voice/realtime/agentEngine.js +17 -0
- package/dist/src/voice/realtime/memory-context.js +1 -1
- package/dist/src/voice/realtime/playback-echo.d.ts +2 -0
- package/dist/src/voice/realtime/playback-echo.js +15 -0
- package/dist/src/work-discovery/service.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +2 -2
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Bs34Kp0K.js +0 -1
- package/dist/gateway/static/root/assets/agents-DARlgjTm.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-BhgvfBJT.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BzX4lILP.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BBdMqxl0.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D_WfftDW.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-bdRLT9KA.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CPDjU5wU.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-SmVlhtj_.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DWcKsIoZ.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BdvLZKQZ.js +0 -1
- package/dist/gateway/static/root/assets/index-C7RDs6S-.js +0 -74
- package/dist/gateway/static/root/assets/index-Cu8xqZQ9.css +0 -2
- package/dist/gateway/static/root/assets/logs-page-ZP4QTWoC.js +0 -2
- package/dist/gateway/static/root/assets/messages-C72stReU.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-EeVeF4II.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-D7bMff96.js +0 -8
- package/dist/gateway/static/root/assets/popover-select-C-Hj-nXR.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-BDF88VdN.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DeTD6pu1.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CxKrdQ6a.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DUFJN-2t.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CcSYDjaH.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-C6DuwrP5.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-CovcdHSC.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CrHagTsE.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-I8hueJnG.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-CU6nxmoM.js +0 -2
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-kWGFkhjz.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-B4Is5E42.js +0 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, shouldSilence, stripHeartbeatToken } from "./tokens.js";
|
|
2
|
-
import { appendCronEventLines } from "./event-prompt.js";
|
|
3
2
|
import { isWithinActiveHours } from "./active-hours.js";
|
|
4
3
|
import { isHeartbeatContentEmpty } from "./content-check.js";
|
|
4
|
+
import { appendCronEventLines } from "./event-prompt.js";
|
|
5
5
|
import { createHeartbeatWake } from "./wake.js";
|
|
6
6
|
export { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, appendCronEventLines, createHeartbeatWake, isHeartbeatContentEmpty, isWithinActiveHours, shouldSilence, stripHeartbeatToken };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_sync_provider_auth, resolveProviderApiKeyForAgentSync } from "../../auth/sync-provider-auth.js";
|
|
2
1
|
import { getApiKeyFromEnv, init_env_keys } from "../env-keys.js";
|
|
2
|
+
import { init_sync_provider_auth, resolveProviderApiKeyForAgentSync } from "../../auth/sync-provider-auth.js";
|
|
3
3
|
import { getDefaultAuthProfileStore } from "./auth-profile-store.js";
|
|
4
4
|
//#region src/providers/auth-runtime/resolve-auth.ts
|
|
5
5
|
init_env_keys();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __esmMin, __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
3
|
-
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
4
|
-
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
5
3
|
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
6
4
|
import { init_model_ref, splitProviderModelRef } from "./model-ref.js";
|
|
7
5
|
import { ModelRegistry, getModelRegistry, init_model_registry, prewarmModelRegistry, resetModelRegistry } from "./model-registry.js";
|
|
6
|
+
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
8
7
|
import { CredentialResolver, hasCredentials, init_credentials } from "../auth/credentials.js";
|
|
8
|
+
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
9
9
|
import { EXTENSION_PROVIDER_BASE_URL, init_constants } from "./constants.js";
|
|
10
10
|
import { applyOfficialModelMetadataCorrections, getSupplementalModels, init_model_supplements } from "./model-supplements.js";
|
|
11
11
|
import { getProviderRegistry, init_plugin_registry } from "./plugin-registry.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { createLogger } from "../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
|
-
import { resolveModelsJsonPath } from "../config/paths.js";
|
|
5
4
|
import { init_resolve_config_value, resolveConfigValue, resolveHeaders } from "../config/resolve-config-value.js";
|
|
5
|
+
import { resolveModelsJsonPath } from "../config/paths.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
8
|
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { getSupportedThinkingLevels } from "@earendil-works/pi-ai";
|
|
2
2
|
//#region src/providers/model-thinking.ts
|
|
3
|
+
const TOGGLE_THINKING_FORMATS = new Set([
|
|
4
|
+
"zai",
|
|
5
|
+
"qwen",
|
|
6
|
+
"qwen-chat-template",
|
|
7
|
+
"chat-template",
|
|
8
|
+
"deepseek",
|
|
9
|
+
"together",
|
|
10
|
+
"baseten",
|
|
11
|
+
"string-thinking"
|
|
12
|
+
]);
|
|
13
|
+
function preferredEnabledLevel(options) {
|
|
14
|
+
return options.includes("high") ? "high" : options.find((option) => option !== "off");
|
|
15
|
+
}
|
|
3
16
|
/** Use the same capability metadata as the provider runtime. */
|
|
4
17
|
function getModelThinking(model) {
|
|
5
18
|
const base = { supportsAdaptive: false };
|
|
@@ -10,29 +23,53 @@ function getModelThinking(model) {
|
|
|
10
23
|
initialValue: "off"
|
|
11
24
|
};
|
|
12
25
|
const compat = model.compat;
|
|
13
|
-
const binaryFormat = [
|
|
14
|
-
"zai",
|
|
15
|
-
"qwen",
|
|
16
|
-
"qwen-chat-template",
|
|
17
|
-
"chat-template"
|
|
18
|
-
].includes(compat?.thinkingFormat ?? "");
|
|
19
|
-
const binaryProvider = model.provider === "zai" || model.provider === "z.ai";
|
|
20
|
-
if ((binaryFormat || binaryProvider) && compat?.supportsReasoningEffort !== true) return {
|
|
21
|
-
...base,
|
|
22
|
-
mode: "toggle",
|
|
23
|
-
options: ["off", "high"],
|
|
24
|
-
initialValue: "high"
|
|
25
|
-
};
|
|
26
|
-
if (compat?.supportsReasoningEffort === false) return {
|
|
27
|
-
...base,
|
|
28
|
-
mode: "unknown",
|
|
29
|
-
options: ["off"],
|
|
30
|
-
initialValue: "off"
|
|
31
|
-
};
|
|
32
26
|
const options = getSupportedThinkingLevels(model);
|
|
27
|
+
const enabledLevel = preferredEnabledLevel(options);
|
|
28
|
+
if ((TOGGLE_THINKING_FORMATS.has(compat?.thinkingFormat ?? "") || model.provider === "zai" || model.provider === "z.ai") && compat?.supportsReasoningEffort !== true && enabledLevel) {
|
|
29
|
+
if (options.includes("off")) return {
|
|
30
|
+
...base,
|
|
31
|
+
mode: "toggle",
|
|
32
|
+
options: ["off", enabledLevel],
|
|
33
|
+
initialValue: enabledLevel
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
...base,
|
|
37
|
+
mode: "fixed",
|
|
38
|
+
options: [enabledLevel],
|
|
39
|
+
initialValue: enabledLevel
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (compat?.supportsReasoningEffort === false) {
|
|
43
|
+
if (enabledLevel) return {
|
|
44
|
+
...base,
|
|
45
|
+
mode: "fixed",
|
|
46
|
+
options: [enabledLevel],
|
|
47
|
+
initialValue: enabledLevel
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
...base,
|
|
51
|
+
mode: "none",
|
|
52
|
+
options: ["off"],
|
|
53
|
+
initialValue: "off"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (options.length === 1) {
|
|
57
|
+
const only = options[0] ?? "off";
|
|
58
|
+
return only === "off" ? {
|
|
59
|
+
...base,
|
|
60
|
+
mode: "none",
|
|
61
|
+
options: ["off"],
|
|
62
|
+
initialValue: "off"
|
|
63
|
+
} : {
|
|
64
|
+
...base,
|
|
65
|
+
mode: "fixed",
|
|
66
|
+
options: [only],
|
|
67
|
+
initialValue: only
|
|
68
|
+
};
|
|
69
|
+
}
|
|
33
70
|
return {
|
|
34
71
|
...base,
|
|
35
|
-
mode:
|
|
72
|
+
mode: "levels",
|
|
36
73
|
options,
|
|
37
74
|
initialValue: options.includes("medium") ? "medium" : options[0] ?? "off"
|
|
38
75
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { getOAuthProviderDefinition, init_registry } from "../auth/oauth/registry.js";
|
|
3
2
|
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
3
|
+
import { getOAuthProviderDefinition, init_registry } from "../auth/oauth/registry.js";
|
|
4
4
|
import { XOPC_CLOUD_PROVIDER_ID, init_xopc_cloud_config, resolveXopcModelRouterUrl } from "./xopc-cloud-config.js";
|
|
5
5
|
//#region src/providers/register-runtime-providers.ts
|
|
6
6
|
function registerRuntimeProvider(modelRuntime, source) {
|
|
@@ -2,9 +2,9 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { isTailscaleInstalled } from "../infra/tailscale.js";
|
|
4
4
|
import { resolveGatewayBindMode } from "../config/gateway-bind.js";
|
|
5
|
+
import { getTunnelService } from "../tunnel/tunnel-service.js";
|
|
5
6
|
import { collectExposureConflicts } from "./exposure-guards.js";
|
|
6
7
|
import { getTailscaleExposureState, maybeStartTailscaleFromConfig, stopTailscaleExposure } from "../gateway/tailscale-lifecycle.js";
|
|
7
|
-
import { getTunnelService } from "../tunnel/tunnel-service.js";
|
|
8
8
|
import { getTunnelConsentState } from "../tunnel/consent.js";
|
|
9
9
|
import { maybeAutoStartTunnelFromConfig } from "../tunnel/gateway-lifecycle.js";
|
|
10
10
|
//#region src/remote-access/exposure-manager.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildSessionContextForLlm, isTranscriptContextEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
2
2
|
import { SessionStatus } from "./types.js";
|
|
3
3
|
import { effectiveWorkspacePathForSession, normalizeWorkingDirectoryInput, projectWorkspacePath } from "./session-workspace.js";
|
|
4
|
+
import { flattenMessageContent, messagesToClientHistory } from "./client-history.js";
|
|
4
5
|
import { emitSessionTranscriptUpdate, onSessionTranscriptUpdate } from "./transcript-events.js";
|
|
5
6
|
import { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeGeneratedSessionTitle, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm } from "./session-title.js";
|
|
6
|
-
import { flattenMessageContent, messagesToClientHistory } from "./client-history.js";
|
|
7
7
|
import { SessionStore } from "./store.js";
|
|
8
8
|
import { applySessionPatchToMetadata } from "./patch-metadata.js";
|
|
9
9
|
import { SessionIndex } from "./manager.js";
|
|
@@ -12,6 +12,7 @@ import { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompact
|
|
|
12
12
|
import { getSessionConfig, setSessionConfig } from "../storage/sqlite/config-repository.js";
|
|
13
13
|
import "../storage/sqlite/index.js";
|
|
14
14
|
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
15
|
+
import { transcriptRowsToClientHistory } from "./client-history.js";
|
|
15
16
|
import { SessionCompactor } from "../agent/memory/compaction.js";
|
|
16
17
|
import { resolveUserContextSessionAccess } from "../user-context/access-policy.js";
|
|
17
18
|
import { readPostCompactionContext } from "../agent/reply/post-compaction-context.js";
|
|
@@ -19,7 +20,6 @@ import { resolveCompactionPolicy } from "../agent/memory/compaction-policy.js";
|
|
|
19
20
|
import { promoteCompactionLedger } from "../agent/memory/compaction-promotion.js";
|
|
20
21
|
import { SlidingWindow } from "../agent/memory/window.js";
|
|
21
22
|
import { isAppendOnlyLlmTranscriptMessage } from "./transcript-stats.js";
|
|
22
|
-
import { transcriptRowsToClientHistory } from "./client-history.js";
|
|
23
23
|
import { backfillStructuredTurnOutcomes } from "./turn-outcome-projector.js";
|
|
24
24
|
import { computeTranscriptUserRoundDeleteRange } from "./user-round-delete.js";
|
|
25
25
|
//#region src/session/store.ts
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HostedPublicationSnapshot } from './hosted-session-share.js';
|
|
2
|
+
import { type NoteShareSource } from './note-share-service.js';
|
|
3
|
+
export interface HostedNotePublicationSnapshot extends HostedPublicationSnapshot {
|
|
4
|
+
kind: 'note_document';
|
|
5
|
+
sourceNoteId: string;
|
|
6
|
+
sourceVersion: number;
|
|
7
|
+
title: string;
|
|
8
|
+
attachmentCount: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class HostedNotePublicationBuilder {
|
|
11
|
+
private readonly notes;
|
|
12
|
+
constructor(notes: NoteShareSource);
|
|
13
|
+
build(noteId: string, input: {
|
|
14
|
+
expectedNoteVersion?: number;
|
|
15
|
+
attachmentIds?: string[];
|
|
16
|
+
description?: string;
|
|
17
|
+
}): Promise<HostedNotePublicationSnapshot>;
|
|
18
|
+
}
|
|
19
|
+
export declare class HostedNoteVersionConflictError extends Error {
|
|
20
|
+
readonly currentVersion: number;
|
|
21
|
+
constructor(currentVersion: number);
|
|
22
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { collectReferencedAttachmentIds } from "../notes/note-attachment-sync.js";
|
|
2
|
+
import { projectPublicNoteMarkdown } from "./note-share-service.js";
|
|
3
|
+
import { createReadStream } from "node:fs";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { stat } from "node:fs/promises";
|
|
6
|
+
//#region src/share/hosted-note-publication.ts
|
|
7
|
+
const MAX_ATTACHMENTS = 20;
|
|
8
|
+
const MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
9
|
+
const MAX_TOTAL_BYTES = 100 * 1024 * 1024;
|
|
10
|
+
const MAX_MARKDOWN_BYTES = 5 * 1024 * 1024;
|
|
11
|
+
var HostedNotePublicationBuilder = class {
|
|
12
|
+
constructor(notes) {
|
|
13
|
+
this.notes = notes;
|
|
14
|
+
}
|
|
15
|
+
async build(noteId, input) {
|
|
16
|
+
const note = await this.notes.getNote(noteId);
|
|
17
|
+
if (!note) throw new Error("Note not found");
|
|
18
|
+
if (input.expectedNoteVersion !== void 0 && note.updatedAt !== input.expectedNoteVersion) throw new HostedNoteVersionConflictError(note.updatedAt);
|
|
19
|
+
const referenced = collectReferencedAttachmentIds(note);
|
|
20
|
+
const attachments = new Map((note.attachments ?? []).map((attachment) => [attachment.id, attachment]));
|
|
21
|
+
for (const id of referenced) if (!attachments.has(id)) throw new Error(`Referenced attachment is missing: ${id}`);
|
|
22
|
+
const selected = input.attachmentIds === void 0 ? [...referenced] : [...new Set(input.attachmentIds)];
|
|
23
|
+
if (selected.length > MAX_ATTACHMENTS) throw new Error("Note has too many attachments to publish");
|
|
24
|
+
for (const id of selected) if (!referenced.has(id)) throw new Error(`Attachment is not referenced by this Note: ${id}`);
|
|
25
|
+
const selectedSet = new Set(selected);
|
|
26
|
+
const markdown = rewritePublicationAssets(projectPublicNoteMarkdown(note, selectedSet), note, selectedSet);
|
|
27
|
+
if (Buffer.byteLength(markdown, "utf8") > MAX_MARKDOWN_BYTES) throw new Error("Note Markdown exceeds publishing limit");
|
|
28
|
+
const assets = [];
|
|
29
|
+
const manifestAttachments = [];
|
|
30
|
+
let totalBytes = Buffer.byteLength(markdown, "utf8");
|
|
31
|
+
for (const id of selected) {
|
|
32
|
+
const attachment = attachments.get(id);
|
|
33
|
+
if (attachment.size > MAX_ATTACHMENT_BYTES) throw new Error(`Attachment exceeds publishing limit: ${attachment.fileName}`);
|
|
34
|
+
totalBytes += attachment.size;
|
|
35
|
+
if (totalBytes > MAX_TOTAL_BYTES) throw new Error("Note publication exceeds total size limit");
|
|
36
|
+
const resolved = await this.notes.getAttachmentPath(note.id, id);
|
|
37
|
+
if (!resolved) throw new Error(`Attachment is missing: ${attachment.fileName}`);
|
|
38
|
+
const current = await stat(resolved.filePath);
|
|
39
|
+
if (!current.isFile() || current.size !== attachment.size) throw new Error(`Attachment changed or is missing: ${attachment.fileName}`);
|
|
40
|
+
assets.push({
|
|
41
|
+
id,
|
|
42
|
+
path: resolved.filePath,
|
|
43
|
+
size: attachment.size
|
|
44
|
+
});
|
|
45
|
+
manifestAttachments.push({
|
|
46
|
+
id,
|
|
47
|
+
fileName: attachment.fileName,
|
|
48
|
+
mimeType: attachment.mimeType,
|
|
49
|
+
size: attachment.size,
|
|
50
|
+
sha256: await sha256File(resolved.filePath)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
kind: "note_document",
|
|
55
|
+
sourceNoteId: note.id,
|
|
56
|
+
sourceVersion: note.updatedAt,
|
|
57
|
+
title: note.title?.trim() || "Untitled Note",
|
|
58
|
+
attachmentCount: assets.length,
|
|
59
|
+
assets,
|
|
60
|
+
manifest: {
|
|
61
|
+
schemaVersion: 1,
|
|
62
|
+
kind: "note_document",
|
|
63
|
+
title: note.title?.trim() || "Untitled Note",
|
|
64
|
+
snapshotAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
65
|
+
...input.description?.trim() ? { description: input.description.trim() } : {},
|
|
66
|
+
markdown,
|
|
67
|
+
attachments: manifestAttachments
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var HostedNoteVersionConflictError = class extends Error {
|
|
73
|
+
constructor(currentVersion) {
|
|
74
|
+
super("Note changed after the publication preview was reviewed");
|
|
75
|
+
this.currentVersion = currentVersion;
|
|
76
|
+
this.name = "HostedNoteVersionConflictError";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
function rewritePublicationAssets(markdown, note, selected) {
|
|
80
|
+
return markdown.replace(/xopc-attachment:\/\/notes\/([^/\s)]+)\/([^\s)]+)/gi, (match, rawNoteId, rawAttachmentId) => {
|
|
81
|
+
try {
|
|
82
|
+
const noteId = decodeURIComponent(rawNoteId);
|
|
83
|
+
const attachmentId = decodeURIComponent(rawAttachmentId);
|
|
84
|
+
return noteId === note.id && selected.has(attachmentId) ? `xopc-publication-asset://${attachmentId}` : match;
|
|
85
|
+
} catch {
|
|
86
|
+
return match;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async function sha256File(filePath) {
|
|
91
|
+
const hash = createHash("sha256");
|
|
92
|
+
for await (const chunk of createReadStream(filePath)) hash.update(chunk);
|
|
93
|
+
return hash.digest("hex");
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { HostedNotePublicationBuilder, HostedNoteVersionConflictError };
|
|
@@ -3,6 +3,7 @@ import { type SessionShareMessage, type SessionShareToolActivity } from './sessi
|
|
|
3
3
|
import { type SessionShareSource } from './session-share-service.js';
|
|
4
4
|
export interface HostedSessionShareManifest {
|
|
5
5
|
schemaVersion: 1;
|
|
6
|
+
kind: 'session_document';
|
|
6
7
|
title: string;
|
|
7
8
|
snapshotAt: string;
|
|
8
9
|
description?: string;
|
|
@@ -49,7 +50,17 @@ export interface HostedShareResult {
|
|
|
49
50
|
viewCount: number;
|
|
50
51
|
snapshotRevision: number;
|
|
51
52
|
}
|
|
52
|
-
type
|
|
53
|
+
export type HostedPublicationKind = 'session_document' | 'note_document' | 'static_site';
|
|
54
|
+
export interface HostedPublicationSnapshot {
|
|
55
|
+
kind: HostedPublicationKind;
|
|
56
|
+
manifest: unknown;
|
|
57
|
+
assets: Array<{
|
|
58
|
+
id: string;
|
|
59
|
+
path: string;
|
|
60
|
+
size: number;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
export type HostedPublicationSummary = {
|
|
53
64
|
id: string;
|
|
54
65
|
title: string;
|
|
55
66
|
description: string | null;
|
|
@@ -60,8 +71,42 @@ type OwnerShare = {
|
|
|
60
71
|
viewCount: number;
|
|
61
72
|
createdAt: string;
|
|
62
73
|
updatedAt: string;
|
|
74
|
+
kind: HostedPublicationKind;
|
|
75
|
+
deliveryMode: 'hosted_snapshot';
|
|
76
|
+
owner: {
|
|
77
|
+
type: 'user' | 'workspace';
|
|
78
|
+
id: string;
|
|
79
|
+
};
|
|
80
|
+
workspaceId: string;
|
|
81
|
+
createdByPrincipalId: string;
|
|
63
82
|
};
|
|
64
|
-
|
|
83
|
+
type OwnerShare = HostedPublicationSummary;
|
|
84
|
+
export interface HostedPublicationCapabilities {
|
|
85
|
+
protocolVersion: string;
|
|
86
|
+
kinds: string[];
|
|
87
|
+
deliveryModes: string[];
|
|
88
|
+
accessModes: string[];
|
|
89
|
+
upload: {
|
|
90
|
+
direct: boolean;
|
|
91
|
+
multipart: boolean;
|
|
92
|
+
resumable: boolean;
|
|
93
|
+
streaming: boolean;
|
|
94
|
+
};
|
|
95
|
+
security?: {
|
|
96
|
+
contentScanning: boolean;
|
|
97
|
+
quarantineBeforeActivation: boolean;
|
|
98
|
+
};
|
|
99
|
+
lifecycle: {
|
|
100
|
+
revisions: boolean;
|
|
101
|
+
revoke: boolean;
|
|
102
|
+
asynchronousDeletion: boolean;
|
|
103
|
+
};
|
|
104
|
+
publishing: {
|
|
105
|
+
allowed: boolean;
|
|
106
|
+
managedBy: 'platform_admin';
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export declare class HostedPublicationPublisher {
|
|
65
110
|
private readonly credentials;
|
|
66
111
|
private readonly fetchImpl;
|
|
67
112
|
private readonly baseUrl;
|
|
@@ -70,23 +115,54 @@ export declare class HostedSessionSharePublisher {
|
|
|
70
115
|
ttlMs: number;
|
|
71
116
|
maxViews: number | null;
|
|
72
117
|
}): Promise<HostedShareResult>;
|
|
118
|
+
createPublication(snapshot: HostedPublicationSnapshot, lifecycle: {
|
|
119
|
+
ttlMs: number;
|
|
120
|
+
maxViews: number | null;
|
|
121
|
+
}): Promise<HostedShareResult>;
|
|
73
122
|
refresh(shareId: string, expectedRevision: number, publicUrl: string, snapshot: HostedSessionShareSnapshot): Promise<HostedShareResult>;
|
|
74
|
-
|
|
123
|
+
refreshPublication(shareId: string, expectedRevision: number, publicUrl: string, snapshot: HostedPublicationSnapshot): Promise<HostedShareResult>;
|
|
124
|
+
listPublications(): Promise<HostedPublicationSummary[]>;
|
|
125
|
+
capabilities(): Promise<HostedPublicationCapabilities>;
|
|
75
126
|
revoke(shareId: string): Promise<void>;
|
|
127
|
+
revokePublication(shareId: string): Promise<void>;
|
|
128
|
+
listRevisions(shareId: string): Promise<Array<{
|
|
129
|
+
revision: number;
|
|
130
|
+
createdAt: string;
|
|
131
|
+
current: boolean;
|
|
132
|
+
}>>;
|
|
133
|
+
rollbackPublication(shareId: string, expectedRevision: number, targetRevision: number): Promise<HostedPublicationSummary>;
|
|
76
134
|
private uploadAssets;
|
|
77
135
|
private request;
|
|
78
136
|
}
|
|
79
137
|
export declare class HostedShareAuthorizationError extends Error {
|
|
80
138
|
constructor();
|
|
81
139
|
}
|
|
140
|
+
export declare class HostedShareRemoteError extends Error {
|
|
141
|
+
readonly status: number;
|
|
142
|
+
readonly code?: string;
|
|
143
|
+
constructor(message: string, status: number, code?: string);
|
|
144
|
+
}
|
|
145
|
+
export type HostedPublicationSource = {
|
|
146
|
+
kind: 'session' | 'note' | 'static_site';
|
|
147
|
+
id: string;
|
|
148
|
+
version: string;
|
|
149
|
+
};
|
|
82
150
|
export interface HostedShareBinding extends HostedShareResult {
|
|
83
|
-
|
|
84
|
-
|
|
151
|
+
kind: HostedPublicationKind;
|
|
152
|
+
source: HostedPublicationSource;
|
|
153
|
+
revisionSources: Record<string, HostedPublicationSource>;
|
|
154
|
+
workspaceContext?: {
|
|
155
|
+
workspaceRoot?: string;
|
|
156
|
+
sessionKey?: string;
|
|
157
|
+
agentId?: string;
|
|
158
|
+
};
|
|
159
|
+
sessionId?: string;
|
|
160
|
+
cutoffSeq?: number;
|
|
85
161
|
title: string;
|
|
86
162
|
description: string | null;
|
|
87
|
-
messageCount
|
|
163
|
+
messageCount?: number;
|
|
88
164
|
attachmentCount: number;
|
|
89
|
-
includeToolActivities
|
|
165
|
+
includeToolActivities?: boolean;
|
|
90
166
|
attachmentIds: string[];
|
|
91
167
|
createdAt: string;
|
|
92
168
|
updatedAt: string;
|
|
@@ -95,7 +171,10 @@ export interface HostedShareBinding extends HostedShareResult {
|
|
|
95
171
|
export declare class HostedShareBindingStore {
|
|
96
172
|
private readonly state;
|
|
97
173
|
list(sessionId: string): Promise<HostedShareBinding[]>;
|
|
174
|
+
listBySource(kind: HostedPublicationSource['kind'], id: string): Promise<HostedShareBinding[]>;
|
|
175
|
+
listAll(): Promise<HostedShareBinding[]>;
|
|
98
176
|
upsert(binding: HostedShareBinding): Promise<void>;
|
|
177
|
+
markRevoked(id: string): Promise<void>;
|
|
99
178
|
reconcile(remote: OwnerShare[]): Promise<void>;
|
|
100
179
|
}
|
|
101
180
|
export {};
|
|
@@ -9,7 +9,7 @@ import { SessionShareSnapshotConflictError } from "./session-share-service.js";
|
|
|
9
9
|
import { basename } from "node:path";
|
|
10
10
|
import { createReadStream } from "node:fs";
|
|
11
11
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
12
|
-
import {
|
|
12
|
+
import { stat } from "node:fs/promises";
|
|
13
13
|
//#region src/share/hosted-session-share.ts
|
|
14
14
|
init_credentials();
|
|
15
15
|
init_resolution();
|
|
@@ -82,6 +82,7 @@ var HostedSessionShareBuilder = class {
|
|
|
82
82
|
cutoffSeq: source.snapshot.lastSeq,
|
|
83
83
|
manifest: {
|
|
84
84
|
schemaVersion: 1,
|
|
85
|
+
kind: "session_document",
|
|
85
86
|
title: (source.metadata.name?.trim() || "Shared conversation").slice(0, 200),
|
|
86
87
|
snapshotAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
87
88
|
...input.description?.trim() ? { description: input.description.trim().slice(0, 1e3) } : {},
|
|
@@ -105,7 +106,7 @@ var HostedSessionShareBuilder = class {
|
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
108
|
};
|
|
108
|
-
var
|
|
109
|
+
var HostedPublicationPublisher = class {
|
|
109
110
|
baseUrl;
|
|
110
111
|
constructor(baseUrl = process.env.XOPC_SHARE_URL ?? resolveConnectedPlatformEndpoint("shareApi") ?? DEFAULT_SHARE_URL, credentials = new CredentialResolver(), fetchImpl = fetch) {
|
|
111
112
|
this.credentials = credentials;
|
|
@@ -113,23 +114,38 @@ var HostedSessionSharePublisher = class {
|
|
|
113
114
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
114
115
|
}
|
|
115
116
|
async create(snapshot, lifecycle) {
|
|
117
|
+
return this.createPublication({
|
|
118
|
+
kind: "session_document",
|
|
119
|
+
manifest: snapshot.manifest,
|
|
120
|
+
assets: snapshot.assets
|
|
121
|
+
}, lifecycle);
|
|
122
|
+
}
|
|
123
|
+
async createPublication(snapshot, lifecycle) {
|
|
116
124
|
const publicToken = randomBytes(32).toString("base64url");
|
|
117
|
-
const draft = await this.request("/api/v1/
|
|
125
|
+
const draft = await this.request("/api/v1/publications", {
|
|
118
126
|
method: "POST",
|
|
119
127
|
headers: { "Idempotency-Key": `xopc-${randomUUID()}` },
|
|
120
128
|
body: JSON.stringify({
|
|
129
|
+
kind: snapshot.kind,
|
|
121
130
|
publicToken,
|
|
122
131
|
manifest: snapshot.manifest,
|
|
123
132
|
...lifecycle
|
|
124
133
|
})
|
|
125
134
|
});
|
|
126
135
|
await this.uploadAssets(draft, snapshot.assets);
|
|
127
|
-
const finalized = await this.request(`/api/v1/
|
|
136
|
+
const finalized = await this.request(`/api/v1/publications/${encodeURIComponent(draft.shareId)}/uploads/${encodeURIComponent(draft.uploadId)}/finalize`, { method: "POST" });
|
|
128
137
|
if (!draft.publicUrl) throw new Error("Hosted Share did not return a public URL");
|
|
129
138
|
return toResult(finalized.item, draft.publicUrl);
|
|
130
139
|
}
|
|
131
140
|
async refresh(shareId, expectedRevision, publicUrl, snapshot) {
|
|
132
|
-
|
|
141
|
+
return this.refreshPublication(shareId, expectedRevision, publicUrl, {
|
|
142
|
+
kind: "session_document",
|
|
143
|
+
manifest: snapshot.manifest,
|
|
144
|
+
assets: snapshot.assets
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async refreshPublication(shareId, expectedRevision, publicUrl, snapshot) {
|
|
148
|
+
const draft = await this.request(`/api/v1/publications/${encodeURIComponent(shareId)}/revisions`, {
|
|
133
149
|
method: "POST",
|
|
134
150
|
headers: { "Idempotency-Key": `xopc-${randomUUID()}` },
|
|
135
151
|
body: JSON.stringify({
|
|
@@ -138,28 +154,47 @@ var HostedSessionSharePublisher = class {
|
|
|
138
154
|
})
|
|
139
155
|
});
|
|
140
156
|
await this.uploadAssets(draft, snapshot.assets);
|
|
141
|
-
return toResult((await this.request(`/api/v1/
|
|
157
|
+
return toResult((await this.request(`/api/v1/publications/${encodeURIComponent(shareId)}/uploads/${encodeURIComponent(draft.uploadId)}/finalize`, { method: "POST" })).item, publicUrl);
|
|
142
158
|
}
|
|
143
|
-
async
|
|
144
|
-
return (await this.request("/api/v1/
|
|
159
|
+
async listPublications() {
|
|
160
|
+
return (await this.request("/api/v1/publications")).items;
|
|
161
|
+
}
|
|
162
|
+
async capabilities() {
|
|
163
|
+
return this.request("/api/v1/publications/capabilities");
|
|
145
164
|
}
|
|
146
165
|
async revoke(shareId) {
|
|
147
|
-
await this.
|
|
166
|
+
await this.revokePublication(shareId);
|
|
167
|
+
}
|
|
168
|
+
async revokePublication(shareId) {
|
|
169
|
+
await this.request(`/api/v1/publications/${encodeURIComponent(shareId)}`, { method: "DELETE" });
|
|
170
|
+
}
|
|
171
|
+
async listRevisions(shareId) {
|
|
172
|
+
return (await this.request(`/api/v1/publications/${encodeURIComponent(shareId)}/revisions`)).items;
|
|
173
|
+
}
|
|
174
|
+
async rollbackPublication(shareId, expectedRevision, targetRevision) {
|
|
175
|
+
return (await this.request(`/api/v1/publications/${encodeURIComponent(shareId)}/rollback`, {
|
|
176
|
+
method: "POST",
|
|
177
|
+
body: JSON.stringify({
|
|
178
|
+
expectedRevision,
|
|
179
|
+
targetRevision
|
|
180
|
+
})
|
|
181
|
+
})).item;
|
|
148
182
|
}
|
|
149
183
|
async uploadAssets(draft, assets) {
|
|
150
184
|
const uploads = new Map(draft.assetUploads.map((upload) => [upload.assetId, upload.uploadUrl]));
|
|
151
185
|
for (const asset of assets) {
|
|
152
186
|
const uploadUrl = uploads.get(asset.id);
|
|
153
187
|
if (!uploadUrl) throw new Error(`Hosted Share did not accept attachment: ${asset.id}`);
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
188
|
+
const current = await stat(asset.path);
|
|
189
|
+
if (!current.isFile() || current.size !== asset.size) throw new Error(`Attachment changed during upload: ${asset.id}`);
|
|
156
190
|
await this.request(uploadUrl, {
|
|
157
191
|
method: "PUT",
|
|
158
192
|
headers: {
|
|
159
|
-
"Content-Length": String(
|
|
193
|
+
"Content-Length": String(asset.size),
|
|
160
194
|
"Content-Type": "application/octet-stream"
|
|
161
195
|
},
|
|
162
|
-
body:
|
|
196
|
+
body: createReadStream(asset.path),
|
|
197
|
+
duplex: "half"
|
|
163
198
|
});
|
|
164
199
|
}
|
|
165
200
|
}
|
|
@@ -180,7 +215,7 @@ var HostedSessionSharePublisher = class {
|
|
|
180
215
|
});
|
|
181
216
|
const body = await response.json().catch(() => ({}));
|
|
182
217
|
if (response.status === 401) throw new HostedShareAuthorizationError();
|
|
183
|
-
if (!response.ok) throw new
|
|
218
|
+
if (!response.ok) throw new HostedShareRemoteError(body.error?.message || `Hosted Share request failed (${response.status})`, response.status, body.error?.code);
|
|
184
219
|
return body;
|
|
185
220
|
}
|
|
186
221
|
};
|
|
@@ -190,14 +225,36 @@ var HostedShareAuthorizationError = class extends Error {
|
|
|
190
225
|
this.name = "HostedShareAuthorizationError";
|
|
191
226
|
}
|
|
192
227
|
};
|
|
228
|
+
var HostedShareRemoteError = class extends Error {
|
|
229
|
+
constructor(message, status, code) {
|
|
230
|
+
super(message);
|
|
231
|
+
this.status = status;
|
|
232
|
+
this.code = code;
|
|
233
|
+
this.name = "HostedShareRemoteError";
|
|
234
|
+
}
|
|
235
|
+
};
|
|
193
236
|
var HostedShareBindingStore = class {
|
|
194
237
|
state = new DurableState("hosted-share-bindings");
|
|
195
238
|
async list(sessionId) {
|
|
196
239
|
return this.state.values().filter((item) => item.sessionId === sessionId).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
197
240
|
}
|
|
241
|
+
async listBySource(kind, id) {
|
|
242
|
+
return this.state.values().filter((item) => item.source.kind === kind && item.source.id === id).sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
243
|
+
}
|
|
244
|
+
async listAll() {
|
|
245
|
+
return this.state.values().sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
246
|
+
}
|
|
198
247
|
async upsert(binding) {
|
|
199
248
|
this.state.set(binding.id, binding);
|
|
200
249
|
}
|
|
250
|
+
async markRevoked(id) {
|
|
251
|
+
const binding = this.state.get(id);
|
|
252
|
+
if (binding) this.state.set(id, {
|
|
253
|
+
...binding,
|
|
254
|
+
revoked: true,
|
|
255
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
256
|
+
});
|
|
257
|
+
}
|
|
201
258
|
async reconcile(remote) {
|
|
202
259
|
const byId = new Map(remote.map((item) => [item.id, item]));
|
|
203
260
|
requireXopcDatabase();
|
|
@@ -242,4 +299,4 @@ async function checksumFile(path) {
|
|
|
242
299
|
return hash.digest("hex");
|
|
243
300
|
}
|
|
244
301
|
//#endregion
|
|
245
|
-
export {
|
|
302
|
+
export { HostedPublicationPublisher, HostedSessionShareBuilder, HostedShareAuthorizationError, HostedShareBindingStore, HostedShareRemoteError };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HostedPublicationSnapshot } from './hosted-session-share.js';
|
|
2
|
+
export interface HostedStaticSitePublicationSnapshot extends HostedPublicationSnapshot {
|
|
3
|
+
kind: 'static_site';
|
|
4
|
+
rootDir: string;
|
|
5
|
+
title: string;
|
|
6
|
+
fileCount: number;
|
|
7
|
+
totalBytes: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class HostedStaticSitePublicationBuilder {
|
|
10
|
+
build(workspaceRoot: string, input: {
|
|
11
|
+
path: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
spaFallback?: boolean;
|
|
15
|
+
}): Promise<HostedStaticSitePublicationSnapshot>;
|
|
16
|
+
}
|