@xopcai/xopc 0.0.215 → 0.0.218
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 -4
- package/README.zh-CN.md +4 -4
- 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-k-mNF_Dq.js → activity-store-DF2dYXG1.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-0Am1Zsai.js → agent-avatar-dicebear-Dw9rF5o1.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Dj86bHkl.js +68 -0
- package/dist/gateway/static/root/assets/{api-BjN2udFQ.js → api-_H0Bam-t.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-D-M6GN-8.js +1 -0
- package/dist/gateway/static/root/assets/{appearance-settings-CoB0hGf9.js → appearance-settings-XDhmzdIc.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-sfO835uz.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BczSorEI.js → archive-plugin-DZCOhXch.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-D1SDGB0m.js → attachment-load-Bjb0FH2B.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BTgWPOP6.js → automations-page-D4N3ZDhu.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-PptuZgoo.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-6tFOQHNC.js → binary-plugins-uXPt0s47.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Cm7txOU2.js → block-editor-gukkIEro.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-BoCmzMFV.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-Coz8pWzP.js → browser-workflow-inputs-DAhdS-XZ.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-DJGD7LOd.js → browser-workflows-page-LKjYzXS_.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DhkJsU8Z.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BF3G84qe.js → capability-presets-api-BBUkH833.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-v85bB-Lt.js → capability-presets-settings-panel-Dm7T61fE.js} +2 -2
- package/dist/gateway/static/root/assets/{channel-recipient-api-8Uz95P40.js → channel-recipient-api-E5mo8M3a.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-dG6UFVqt.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-DgJxfNyK.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DioZkaaj.js → chat-terminal-dock-CT5yoSMD.js} +2 -2
- package/dist/gateway/static/root/assets/circle-check-C23XjkUj.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-BC6Ft9SU.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-BTNvqkwt.js → cron-expression-BGNuaqvI.js} +1 -1
- package/dist/gateway/static/root/assets/date-picker-k7mkklMU.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-PlfH-GH8.js → dependency-picker-DZVSgLXH.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-C3nO_ocM.js → desktop-pet-p9EZyGzV.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-Bw4cCFzI.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BIqsbDII.js → directory-picker-path-field-Cbst7IXR.js} +1 -1
- package/dist/gateway/static/root/assets/electron-env-DH5wF8X8.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-C1o3Jn7L.js → extension-debug-page-Cd4BMKm_.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Drjulq3q.js → extension-page-CzEGCkOa.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-XsMPJFYn.js → extension-settings-page-C1PAKSy2.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-D9xHVpb9.js → gateway-config-api-Bch9vO6t.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-l2w9ecXl.js → gateway-config-swr-DNrttVr2.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BaVojQd4.js → gateway-settings-DkDxZFGG.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-XUzMGmLZ.js → gateway-startup-retry-B1vD3vRb.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-dQH2-fGh.js → heartbeat-settings-DXNMxy5b.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-CMqS6l_m.js → home-page-CYcpVFNT.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-CDoOrDMq.js → image-generation-api-BTR0Wk_k.js} +1 -1
- package/dist/gateway/static/root/assets/index-Dgb1R07E.css +2 -0
- package/dist/gateway/static/root/assets/index-DlOYwVFK.js +108 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-CYlS4RGA.js +1 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-BFrgPwGE.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-8w0FZ7TD.js → local-apps-page-CNppYVew.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-BIOMAhmR.js → locale-store-gf9Bg2gb.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-FiVowm1N.js → logs-page-CPweLw3k.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-DdYouU4o.js → management-settings-IYk9xLgt.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-D_kDeT-f.js → markdown-split-D8e6pRMH.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-BMDQYc6E.js → markdown-view-D0fiJjBQ.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BDgbIz9p.js → media-plugins-CCq6TtEf.js} +1 -1
- package/dist/gateway/static/root/assets/messages-B9WQcZ1V.js +3 -0
- package/dist/gateway/static/root/assets/{notes-api-lKPk0Voa.js → notes-api-BBtWnlUU.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-Bw2MQ4M8.js → notes-page-BKe1xa3U.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-wieRAd1y.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-B7dlng5v.js → page-tabs-Bsluqyfb.js} +1 -1
- package/dist/gateway/static/root/assets/preview-open-alternatives-BrpTWv44.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page--m0DziFF.js → product-open-page-DXe5iWI6.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-Cww6V7HJ.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-D0LKhCCw.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BFwvRxBn.js → registry-api-xj5gOva_.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Sf4Pde6Z.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-6QadzIxb.js → runtime-tools-settings-panel-BJTvmBCA.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-ChJycivC.js → schema-form-DvGBa_7R.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-S5gvgfu5.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-B3XvdEy8.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DRazyNED.js → settings-form-section-CiGFtdD8.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CdEdSb5L.js → settings-loading-skeleton-sbef7GTm.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BL0rlziB.js → settings-page-BNGxxXZe.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CGU_Mxjr.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-CKK5swgV.js → share-preview-page-C1523ij3.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-k0UQ8WxO.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DQ1GvL1w.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-OuHd9GcN.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-4_15-T3G.js → skills-page.utils-Ditgz7Vo.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-CERqCsz2.js +1 -0
- package/dist/gateway/static/root/assets/tab-completion-input-D64VNmiA.js +1 -0
- package/dist/gateway/static/root/assets/tab-completion-input.utils-BP3NH_du.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-BnRNL2sn.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BrbF9cgL.js → theme-store-DgSjes3O.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-CzB0r79r.js → typed-models-lib-abEJNkCO.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-D_fuJIDo.js → use-autosave-Bp_qFZkl.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-Cnkaiky5.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-hbzDfErG.js +1 -0
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CSgiFeW2.js → work-discovery-overlay-DZVib-04.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DstMFHA8.js → workflow-run-setup-panel-C2RKay1p.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-B_VlcKiK.js +5 -0
- package/dist/gateway/static/root/index.html +13 -11
- package/dist/package.js +1 -1
- package/dist/packages/realtime-client/src/index.js +17 -2
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/background-review/prompts.d.ts +1 -1
- package/dist/src/agent/background-review/prompts.js +4 -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/ipc/inbox.js +1 -1
- package/dist/src/agent/memory/create-memory-manager.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-runtime/index.js +1 -1
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/connectors/connected-source-ingestion.js +21 -4
- package/dist/src/connectors/connected-source-normalizers.js +51 -4
- package/dist/src/connectors/connected-source-understanding.d.ts +19 -0
- package/dist/src/connectors/connected-source-understanding.js +132 -0
- package/dist/src/connectors/content-enrichment.d.ts +1 -0
- package/dist/src/connectors/content-enrichment.js +11 -7
- package/dist/src/connectors/learning-coordinator.js +55 -4
- package/dist/src/connectors/learning-recipes.js +2 -2
- package/dist/src/document-understanding/extract.d.ts +1 -1
- package/dist/src/document-understanding/extract.js +54 -1
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- 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 +1 -1
- package/dist/src/gateway/hono/lib/static-ui.js +1 -0
- package/dist/src/gateway/hono/oauth-async.d.ts +4 -0
- package/dist/src/gateway/hono/oauth-async.js +24 -1
- package/dist/src/gateway/hono/oauth.js +14 -1
- package/dist/src/gateway/hono/routes/config.js +3 -0
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/public-gateway.js +16 -0
- package/dist/src/gateway/hono/routes/understanding-sources.js +25 -7
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +2 -2
- package/dist/src/gateway/rate-limit/buckets.d.ts +1 -1
- package/dist/src/gateway/rate-limit/buckets.js +2 -2
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service.js +10 -12
- package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +41 -0
- package/dist/src/gateway/xopc-cloud-capability-setup.js +142 -0
- 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/register-runtime-providers.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/user-context/sources/catalog.js +9 -2
- package/dist/src/user-context/sources/local-source-contract.d.ts +1 -1
- package/dist/src/user-context/sources/local-source-contract.js +1 -0
- package/dist/src/user-context/understanding-writing.d.ts +1 -0
- package/dist/src/user-context/understanding-writing.js +4 -0
- package/dist/src/voice/language-profile.d.ts +0 -2
- package/dist/src/voice/language-profile.js +2 -30
- package/dist/src/voice/local/provider-switch.d.ts +4 -0
- package/dist/src/voice/local/provider-switch.js +36 -0
- package/dist/src/work-discovery/analyzer.d.ts +6 -0
- package/dist/src/work-discovery/analyzer.js +181 -57
- package/dist/src/work-discovery/index.js +1 -1
- package/dist/src/work-discovery/probe.js +20 -0
- package/dist/src/work-discovery/service.d.ts +9 -0
- package/dist/src/work-discovery/service.js +18 -6
- package/dist/src/work-discovery/types.d.ts +5 -0
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/agents-BhWSwa4h.js +0 -68
- package/dist/gateway/static/root/assets/app-management-settings-panel-BCHmLiA7.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-DloObQ8z.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-CbOSi-Uh.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-UhIguuT0.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BPe2vu-c.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-Dj3wNboO.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-NfU9X-P5.js +0 -1
- package/dist/gateway/static/root/assets/connectors-api-DHBX8LgY.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-B8Z692Fe.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-wMj_1toq.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-BZSODwlA.js +0 -1
- package/dist/gateway/static/root/assets/index-BDwfvp1w.css +0 -2
- package/dist/gateway/static/root/assets/index-CjbvsIPf.js +0 -108
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-so_XFXVC.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Dp1zGjrI.js +0 -2
- package/dist/gateway/static/root/assets/messages-CbbZKEfO.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-DpMDd8Sm.js +0 -4
- package/dist/gateway/static/root/assets/preview-open-alternatives-Bzi2ia11.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-D8AglzWN.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-D0X6kb12.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-MxuXgfuY.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-DGZbtPXx.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DLg_9-bb.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-D-nQiA7z.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-IDLLIYA5.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-C_ivBD5y.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-t0eKREk9.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-CERY3Drp.js +0 -1
- package/dist/gateway/static/root/assets/tab-completion-input-B-VsxKhC.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CS9BX5BO.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-BvBzRI8P.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-ztq8iQAp.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-XD3Pmm1p.js +0 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAgentDefaultImageModelConfig, getAgentDefaultModelRef, init_schema, parseModelRef } from "../../config/schema.js";
|
|
2
2
|
import { init_agent_scope, resolveDefaultAgentId } from "../agent-scope.js";
|
|
3
|
-
import { resolveEffectiveAgentManifestForAgent } from "../../config/agent-profile.js";
|
|
4
3
|
import { getDefaultModelSync, getModelsByProvider, init_providers, isProviderConfiguredSync, resolveModel } from "../../providers/index.js";
|
|
4
|
+
import { resolveEffectiveAgentManifestForAgent } from "../../config/agent-profile.js";
|
|
5
5
|
import { resolveAgentModelFallbackValues, resolveAgentModelPrimaryValue } from "../../config/model-input.js";
|
|
6
6
|
import { buildCapabilityPlansForConfig } from "../../capabilities/readiness/from-config.js";
|
|
7
7
|
import "../../capabilities/readiness/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { init_paths, resolveAgentDir } from "../../config/paths.js";
|
|
4
3
|
import { init_write_file_atomic, writeTextAtomic } from "../../infra/write-file-atomic.js";
|
|
4
|
+
import { init_paths, resolveAgentDir } from "../../config/paths.js";
|
|
5
5
|
import { join } from "path";
|
|
6
6
|
import { existsSync, watch } from "fs";
|
|
7
7
|
import { mkdir, readFile, readdir, rename } from "fs/promises";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { buildMemoryRuntime } from "../../agent-runtime/memory-runtime.js";
|
|
1
2
|
import { isMemorySubsystemEnabled } from "./memory-config.js";
|
|
2
3
|
import { BuiltinMemoryProvider } from "./builtin-provider.js";
|
|
3
4
|
import { MemoryManager } from "./manager.js";
|
|
4
5
|
import { loadMemoryPluginProviders } from "./plugin-discovery.js";
|
|
5
|
-
import { buildMemoryRuntime } from "../../agent-runtime/memory-runtime.js";
|
|
6
6
|
//#region src/agent/memory/create-memory-manager.ts
|
|
7
7
|
function createMemoryManagerFromConfig(config) {
|
|
8
8
|
const routing = resolveMemoryManagerOptions(config);
|
|
@@ -3,10 +3,10 @@ import { init_logger } from "../utils/logger.js";
|
|
|
3
3
|
import { getUserProfile } from "../storage/sqlite/user-context-repository.js";
|
|
4
4
|
import { parseNoteAttachmentTarget } from "../notes/attachment-ref.js";
|
|
5
5
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
6
|
-
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
7
6
|
import { init_agent_scope, resolveAgentHomeDir, resolveDefaultAgentId } from "./agent-scope.js";
|
|
8
|
-
import { extractProfileAgentId } from "../config/agent-profile.js";
|
|
9
7
|
import { init_providers, resolveModel } from "../providers/index.js";
|
|
8
|
+
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
9
|
+
import { extractProfileAgentId } from "../config/agent-profile.js";
|
|
10
10
|
import { extractTextContent } from "./context/workspace.js";
|
|
11
11
|
import { effectiveWorkspacePathForSession } from "../session/session-workspace.js";
|
|
12
12
|
import { getProjectForSession } from "../projects/workspace.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { init_workspace_defaults, resolveDefaultAgentWorkspaceDir } from "../../config/workspace-defaults.js";
|
|
4
|
-
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
5
4
|
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
5
|
+
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
6
6
|
import { effectiveWorkspacePathForSession, projectWorkspacePath } from "../../session/session-workspace.js";
|
|
7
7
|
import { getProjectForSession } from "../../projects/workspace.js";
|
|
8
8
|
import { resolveCompactionPolicy } from "../memory/compaction-policy.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_paths, resolveSkillsLockPath } from "../../config/paths.js";
|
|
2
1
|
import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
|
|
2
|
+
import { init_paths, resolveSkillsLockPath } from "../../config/paths.js";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
//#region src/agent/skills/hub-lock.ts
|
|
5
5
|
/**
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { extractAssistantText, getAssistantMessageErrorReason, stripCodeFences } from "../../providers/model-response.js";
|
|
3
4
|
import { getAgentDefaultModelRef, init_schema } from "../../config/schema.js";
|
|
4
|
-
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
5
5
|
import { getApiKey, init_providers, resolveModel } from "../../providers/index.js";
|
|
6
|
+
import { completeWithResolvedCredentials } from "../../providers/model-call.js";
|
|
7
|
+
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
6
8
|
import { TaskRepository } from "../../tasks/task-repository.js";
|
|
7
9
|
import { TaskConversationRepository } from "../../tasks/task-conversation-repository.js";
|
|
8
10
|
import { TaskRunRepository } from "../../tasks/task-run-repository.js";
|
|
9
|
-
import { completeWithResolvedCredentials } from "../../providers/model-call.js";
|
|
10
11
|
import { TaskApplicationService } from "../../tasks/task-application-service.js";
|
|
11
|
-
import { extractAssistantText, getAssistantMessageErrorReason, stripCodeFences } from "../../providers/model-response.js";
|
|
12
12
|
//#region src/agent/tasks/task-judge-service.ts
|
|
13
13
|
init_schema();
|
|
14
14
|
init_providers();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
2
1
|
import { checkBoundary } from "./boundary-guard.js";
|
|
3
2
|
import { resolveModelRole } from "./model-router.js";
|
|
4
3
|
import { buildRuntimeToolRegistry } from "./tool-registry.js";
|
|
4
|
+
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
5
5
|
import { resolveWorkflow, validateWorkflowForRuntime } from "./workflow-runtime.js";
|
|
6
6
|
import { buildAgentRuntimeProfile } from "./runtime-profile.js";
|
|
7
7
|
import { appendAgentRunEvent, createAgentRunTrace, finishAgentRunTrace, hashEffectiveManifest } from "./run-trace.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildAgentManifestPromptSection } from "../agent-manifest/prompt.js";
|
|
2
2
|
import "../agent-manifest/index.js";
|
|
3
|
-
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
4
3
|
import { checkBoundary } from "./boundary-guard.js";
|
|
5
4
|
import { resolveModelRole } from "./model-router.js";
|
|
6
5
|
import { buildRuntimeToolRegistry } from "./tool-registry.js";
|
|
6
|
+
import { buildMemoryRuntime } from "./memory-runtime.js";
|
|
7
7
|
import { resolveWorkflow, validateWorkflowForRuntime } from "./workflow-runtime.js";
|
|
8
8
|
//#region src/agent-runtime/runtime-profile.ts
|
|
9
9
|
function buildAgentRuntimeProfile(params) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
+
import { getAssistantMessageErrorReason, stripCodeFences } from "../providers/model-response.js";
|
|
3
4
|
import { getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
|
|
4
5
|
import { createExtensionAwareStreamFn } from "../providers/extension-stream-bridge.js";
|
|
5
6
|
import { isLocalModelBaseUrl, resolveModelCallApiKey, resolveModelCallOptions } from "../providers/model-call.js";
|
|
6
|
-
import { getAssistantMessageErrorReason, stripCodeFences } from "../providers/model-response.js";
|
|
7
7
|
//#region src/ai-assist/text-assist.ts
|
|
8
8
|
init_providers();
|
|
9
9
|
init_logger();
|
|
@@ -1,10 +1,10 @@
|
|
|
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 { init_paths, resolveAgentAuthProfilesPath, resolveAuthProfilesPath, resolveCredentialsDir, resolveOAuthPath } from "../config/paths.js";
|
|
5
4
|
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
6
|
-
import {
|
|
5
|
+
import { init_paths, resolveAgentAuthProfilesPath, resolveAuthProfilesPath, resolveCredentialsDir, resolveOAuthPath } from "../config/paths.js";
|
|
7
6
|
import { getApiKeyFromEnv, init_env_keys } from "../providers/env-keys.js";
|
|
7
|
+
import { getOAuthProviderDefinition, init_registry } from "./oauth/registry.js";
|
|
8
8
|
import { init_oauth_provider_lock, withOAuthProviderLock } from "./oauth-provider-lock.js";
|
|
9
9
|
import { dirname, join } from "path";
|
|
10
10
|
import { mkdir, readFile, readdir, rm } from "fs/promises";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_paths, resolveCredentialsDir } from "../../config/paths.js";
|
|
2
1
|
import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
|
|
2
|
+
import { init_paths, resolveCredentialsDir } from "../../config/paths.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { chmodSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
5
5
|
//#region src/auth/profiles/store.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
3
2
|
import { init_paths, resolveAgentAuthProfilesPath, resolveAuthProfilesPath, resolveOAuthPath } from "../config/paths.js";
|
|
4
|
-
import { init_loader, loadConfig } from "../config/loader.js";
|
|
5
3
|
import { init_registry, isOAuthOnlyProvider } from "./oauth/registry.js";
|
|
4
|
+
import { init_loader, loadConfig } from "../config/loader.js";
|
|
5
|
+
import { getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
7
|
//#region src/auth/sync-provider-auth.ts
|
|
8
8
|
/**
|
|
@@ -2,8 +2,8 @@ import { PACKAGE_VERSION, init_package_version } from "../../package-version.js"
|
|
|
2
2
|
import { createLogger } from "../../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../../utils/logger.js";
|
|
4
4
|
import { assertCacheDir, init_cache_dir_policy } from "../cache-dir-policy.js";
|
|
5
|
-
import { init_paths, resolveBinDir } from "../../config/paths.js";
|
|
6
5
|
import { init_write_file_atomic, writeTextAtomic } from "../../infra/write-file-atomic.js";
|
|
6
|
+
import { init_paths, resolveBinDir } from "../../config/paths.js";
|
|
7
7
|
import { resolvePackageRoot } from "../../infra/update-check.js";
|
|
8
8
|
import { dirname, join } from "node:path";
|
|
9
9
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAgentDefaultModelRef, init_schema, parseModelRef } from "../../../../config/schema.js";
|
|
2
|
-
import { init_loader, loadConfig } from "../../../../config/loader.js";
|
|
3
2
|
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "../../../../providers/env-keys.js";
|
|
3
|
+
import { init_loader, loadConfig } from "../../../../config/loader.js";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
//#region src/cli/commands/doctor/checks/provider-auth.ts
|
|
6
6
|
init_loader();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getAgentDefaultModelRef, init_schema } from "../../config/schema.js";
|
|
2
|
-
import { loadConfig, saveConfig } from "../../config/loader.js";
|
|
3
2
|
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
3
|
+
import { loadConfig, saveConfig } from "../../config/loader.js";
|
|
4
4
|
import { getAllModels, getAvailableModels, getConfiguredProviders, getProviderAuthState, getProviderDisplayName, init_providers, isProviderConfigured, providerSupportsApiKey, providerSupportsOAuth, resolveModel } from "../../providers/index.js";
|
|
5
5
|
import { formatExamples, register } from "../registry.js";
|
|
6
6
|
import { getContextWithOpts } from "../context.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { init_agent_scope, normalizeAgentId, resolveAgentWorkspaceDir } from "../agent/agent-scope.js";
|
|
2
1
|
import { resolveEffectiveAgentManifest } from "../agent-manifest/resolver.js";
|
|
3
2
|
import "../agent-manifest/index.js";
|
|
3
|
+
import { init_agent_scope, normalizeAgentId, resolveAgentWorkspaceDir } from "../agent/agent-scope.js";
|
|
4
4
|
import { init_session_key, parseSessionKey } from "../routing/session-key.js";
|
|
5
5
|
import { agentExists, getDefaultAgentId, init_resolve_route } from "../routing/resolve-route.js";
|
|
6
6
|
//#region src/config/agent-profile.ts
|
package/dist/src/config/index.js
CHANGED
|
@@ -2,15 +2,15 @@ import { ENV_VARS, XOPC_DB_FILENAME, resolveHomeDir, resolveStateDir, resolveXop
|
|
|
2
2
|
import { TelegramAccountConfigSchema, TelegramConfigSchema, TelegramGroupConfigSchema, TelegramTopicConfigSchema } from "../../extensions/telegram/src/config-schema.js";
|
|
3
3
|
import { WeixinAccountConfigSchema, WeixinConfigSchema } from "../../extensions/weixin/src/config-schema.js";
|
|
4
4
|
import { AgentImageGenerationModelSchema, AgentModelRefSchema, AgentModelsSchema, AgentTypedModelRoleSchema, AgentsConfigSchema, BindingMatchSchema, BindingRuleSchema, BindingsConfigSchema, BrowserConfigSchema, ChannelsConfigSchema, CommandsConfigSchema, ConfigSchema, ConnectorsConfigSchema, ExperimentalConfigSchema, ExtensionSecurityConfigSchema, ExtensionSlotsConfigSchema, ExtensionsConfigSchema, GatewayAuthRateLimitSchema, GatewayAuthSchema, GatewayBindModeSchema, GatewayChannelConnectDeferModeSchema, GatewayConfigSchema, GatewayModeSchema, GatewayRemoteSchema, GatewaySecuritySchema, GatewayTailscaleConsentSchema, GatewayTailscaleSchema, GatewayTlsSchema, GatewayTrustedProxySchema, GatewayWebchatConfigSchema, HeartbeatConfigSchema, McpConfigSchema, McpServerSchema, MediaUnderstandingCapabilitiesSchema, MediaUnderstandingModelSchema, MessagesConfigSchema, ModelCatalogConfigSchema, ModelsDevConfigSchema, ProviderAuthConfigSchema, ProviderAzureConfigSchema, ProviderRequestOverridesSchema, ProvidersConfigSchema, RuntimeToolsConfigSchema, STTConfigSchema, STTFallbackConfigSchema, STTProviderConfigSchema, SearchProviderEntrySchema, SessionConfigSchema, SessionDmScopeSchema, SessionResetByTypeSchema, SessionResetConfigSchema, SessionResetModeSchema, SessionScopeSchema, SessionStorageConfigSchema, TTSConfigSchema, TTSEdgeConfigSchema, TTSFallbackConfigSchema, TTSModelOverridesConfigSchema, TTSProviderConfigSchema, TTSSummarizationConfigSchema, ToolsConfigSchema, ToolsMediaAudioConfigSchema, ToolsMediaConfigSchema, TuiConfigSchema, TunnelConfigSchema, TunnelConsentSchema, UpdateAutoConfigSchema, UpdateConfigSchema, VoiceConfigSchema, VoiceRefinementConfigSchema, WebSearchConfigSchema, WebToolsConfigSchema, WebsiteBlocklistSchema, WorkspaceConfigSchema, WorkspaceImportConfigSchema, getAgentDefaultImageGenerationModelConfig, getAgentDefaultImageModelConfig, getAgentDefaultModelRef, init_schema, parseModelRef } from "./schema.js";
|
|
5
|
-
import {
|
|
5
|
+
import { clearConfigValueCache, getAllowedCommands, getCacheStats, init_resolve_config_value, resolveConfigValue, resolveHeaders, testApiKeyResolution } from "./resolve-config-value.js";
|
|
6
6
|
import { expandWorkspacePathString, init_workspace_path, normalizeWorkspaceDir, resolveWorkspaceRoot } from "./workspace-path.js";
|
|
7
7
|
import { resolveDefaultAgentWorkspaceDir } from "./workspace-defaults.js";
|
|
8
8
|
import { resolveAgentDir as resolveAgentDir$1, resolveAgentHomeDir as resolveAgentHomeDir$1, resolveAgentWorkspaceDir } from "../agent/agent-scope.js";
|
|
9
|
-
import { extractProfileAgentId, resolveEffectiveAgentManifestForAgent, resolveEffectiveAgentManifestForSession, resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "./agent-profile.js";
|
|
10
9
|
import { FILENAMES, WORKSPACE_FILES, existsSync, hasBundledExtensionManifest, init_paths, resolveAgentAuthProfilesPath, resolveAgentDir, resolveAgentHomeDir, resolveAgentProfileDir, resolveAgentProfileMarkdownPath, resolveAuthProfilesPath, resolveBinDir, resolveBundledExtensionsDir, resolveBundledSkillsDir, resolveConfigPath, resolveCredentialsDir, resolveExtensionSdkPath, resolveExtensionsDir, resolveExtensionsLockPath, resolveInboxDir, resolveInboxMessagePath, resolveInboxPendingDir, resolveInboxProcessedDir, resolveLogPath, resolveLogsDir, resolveModelsJsonPath, resolveNodeBinDir, resolveNodeBinPath, resolveNodeToolsDir, resolveNpmBinPath, resolveOAuthPath, resolvePidPath, resolveSkillPath, resolveSkillsCachePath, resolveSkillsDir, resolveSkillsLockPath, resolveSocketPath, resolveStatusPath, resolveToolsDir, resolveWorkspaceExtensionsDir, resolveWorkspaceFile, resolveWorkspaceStateDir, resolveWorkspaceStatePath, resolveXopcBinPath } from "./paths.js";
|
|
11
|
-
import { init_loader, loadConfig, saveConfig } from "./loader.js";
|
|
12
|
-
import { clearConfigValueCache, getAllowedCommands, getCacheStats, init_resolve_config_value, resolveConfigValue, resolveHeaders, testApiKeyResolution } from "./resolve-config-value.js";
|
|
13
10
|
import { CustomModelSchema, ImageGenerationCapabilitiesSchema, ImageGenerationModelSchema, ImageGenerationProviderSchema, ModelOverrideSchema, ModelsJsonSchema, OpenAICompatSchema, OpenAICompletionsCompatSchema, OpenAIResponsesCompatSchema, OpenRouterRoutingSchema, ProviderConfigSchema, VercelGatewayRoutingSchema, getDefaultModelValues, init_models_json, loadModelsJson, modelsJsonExists, saveModelsJson, validateModelsConfig } from "./models-json.js";
|
|
11
|
+
import { init_loader, loadConfig, saveConfig } from "./loader.js";
|
|
12
|
+
import { applyConfigOverrides, getConfigOverrides, resetConfigOverrides, setConfigOverride, unsetConfigOverride } from "./runtime-overrides.js";
|
|
13
|
+
import { extractProfileAgentId, resolveEffectiveAgentManifestForAgent, resolveEffectiveAgentManifestForSession, resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "./agent-profile.js";
|
|
14
14
|
import { canonicalizeConfiguredMcpServer, isKnownCliMcpTypeAlias, normalizeConfiguredMcpServers, resolveXopcMcpTransportAlias } from "./mcp-config-normalize.js";
|
|
15
15
|
import { formatThinkingLevels, listThinkingLevels, normalizeElevatedMode, normalizeReasoningLevel, normalizeThinkLevel, normalizeVerboseLevel, thinkLevelToNumber } from "../agent/transcript/thinking-types.js";
|
|
16
16
|
import { getWorkspacePath } from "./workspace-path-helpers.js";
|
|
@@ -2,8 +2,8 @@ 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
4
|
import { ConfigSchema, init_schema } from "./schema.js";
|
|
5
|
-
import { init_paths, resolveConfigPath } from "./paths.js";
|
|
6
5
|
import { init_write_file_atomic, writeTextAtomic } from "../infra/write-file-atomic.js";
|
|
6
|
+
import { init_paths, resolveConfigPath } from "./paths.js";
|
|
7
7
|
import { assertChannelPluginConfigs, init_validate_channel_configs } from "./validate-channel-configs.js";
|
|
8
8
|
import { dirname } from "path";
|
|
9
9
|
import { existsSync, mkdirSync, promises, readFileSync } from "fs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { init_paths, resolveModelsJsonPath } from "./paths.js";
|
|
3
2
|
import { init_write_file_atomic, writeTextAtomicSync } from "../infra/write-file-atomic.js";
|
|
3
|
+
import { init_paths, resolveModelsJsonPath } from "./paths.js";
|
|
4
4
|
import { existsSync, readFileSync } from "fs";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/config/models-json.ts
|
|
@@ -31,6 +31,9 @@ function asRecord(value) {
|
|
|
31
31
|
function boundedPersonValue(value, maxLength = 320) {
|
|
32
32
|
return typeof value === "string" ? value.trim().slice(0, maxLength) : "";
|
|
33
33
|
}
|
|
34
|
+
function normalizedEmail(value) {
|
|
35
|
+
return /<([^<>\s]+@[^<>\s]+)>/.exec(value)?.[1]?.toLowerCase() ?? value.toLowerCase();
|
|
36
|
+
}
|
|
34
37
|
function personEntities(record) {
|
|
35
38
|
if (!record) return [];
|
|
36
39
|
const extractPerson = (value, role) => {
|
|
@@ -39,7 +42,7 @@ function personEntities(record) {
|
|
|
39
42
|
if (!normalized) return [];
|
|
40
43
|
return normalized.includes("@") ? [{
|
|
41
44
|
role,
|
|
42
|
-
email: normalized
|
|
45
|
+
email: normalizedEmail(normalized)
|
|
43
46
|
}] : [{
|
|
44
47
|
role,
|
|
45
48
|
name: normalized
|
|
@@ -91,6 +94,20 @@ function peopleSignals(entities) {
|
|
|
91
94
|
function connectionIdentities(identity) {
|
|
92
95
|
return [...new Set(Object.values(identity).filter((value) => typeof value === "string").map((value) => value.trim().toLowerCase()).filter(Boolean))];
|
|
93
96
|
}
|
|
97
|
+
function hasOwnerAttribution(toolkit, people, ownerIdentities) {
|
|
98
|
+
const attributableRoles = toolkit === "gmail" ? new Set(["sender", "from"]) : toolkit === "googlecalendar" ? new Set(["organizer"]) : new Set([
|
|
99
|
+
"author",
|
|
100
|
+
"user",
|
|
101
|
+
"username",
|
|
102
|
+
"owner",
|
|
103
|
+
"owners"
|
|
104
|
+
]);
|
|
105
|
+
return people.filter((person) => attributableRoles.has(person.role)).flatMap((person) => [
|
|
106
|
+
person.email,
|
|
107
|
+
person.username,
|
|
108
|
+
person.name
|
|
109
|
+
]).filter((value) => Boolean(value)).some((value) => ownerIdentities.includes(value.trim().toLowerCase()));
|
|
110
|
+
}
|
|
94
111
|
function resultPayload(value) {
|
|
95
112
|
const root = asRecord(value) ?? {};
|
|
96
113
|
return asRecord(root.data) ?? root;
|
|
@@ -119,10 +136,10 @@ function resultToSourceItems(input) {
|
|
|
119
136
|
const record = entity.value;
|
|
120
137
|
const people = personEntities(record);
|
|
121
138
|
const ownerIdentities = connectionIdentities(input.connectionIdentity);
|
|
122
|
-
const
|
|
123
|
-
const actorAttributed = entity.metadata.actorAttributed === true || input.toolkit === "gmail" || input.toolkit === "googlecalendar" || ["github", "googledrive"].includes(input.toolkit) && observedIdentities.some((value) => ownerIdentities.includes(value));
|
|
139
|
+
const actorAttributed = entity.metadata.actorAttributed === true || hasOwnerAttribution(input.toolkit, people, ownerIdentities);
|
|
124
140
|
const serialized = JSON.stringify(sanitizeConnectedSourceValue(entity.value), null, 2);
|
|
125
|
-
const
|
|
141
|
+
const contentChars = typeof entity.value.content === "string" ? 24e3 : 8e3;
|
|
142
|
+
const normalizedText = serialized.length > contentChars ? `${serialized.slice(0, contentChars)}\n…` : serialized;
|
|
126
143
|
const contentHash = createHash("sha256").update(serialized).digest("hex");
|
|
127
144
|
return {
|
|
128
145
|
sourceInstanceId: input.sourceInstanceId,
|
|
@@ -32,11 +32,57 @@ function rows(data, ...keys) {
|
|
|
32
32
|
function compact(value) {
|
|
33
33
|
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0 && item !== null && item !== ""));
|
|
34
34
|
}
|
|
35
|
+
const MAX_EMAIL_CONTENT_CHARS = 24e3;
|
|
36
|
+
function gmailHeaders(message) {
|
|
37
|
+
const messagePayload = record(message.payload);
|
|
38
|
+
const values = Array.isArray(messagePayload?.headers) ? messagePayload.headers : [];
|
|
39
|
+
const headers = /* @__PURE__ */ new Map();
|
|
40
|
+
for (const value of values) {
|
|
41
|
+
const header = record(value);
|
|
42
|
+
const name = text(header, "name")?.toLowerCase();
|
|
43
|
+
const headerValue = text(header, "value");
|
|
44
|
+
if (name && headerValue) headers.set(name, headerValue);
|
|
45
|
+
}
|
|
46
|
+
return headers;
|
|
47
|
+
}
|
|
48
|
+
function decodeGmailBody(value) {
|
|
49
|
+
if (typeof value !== "string" || !value.trim() || value.length > 256e3) return void 0;
|
|
50
|
+
try {
|
|
51
|
+
return Buffer.from(value.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8").trim() || void 0;
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function stripHtml(value) {
|
|
57
|
+
return value.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, " ").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, " ").replace(/<[^>]+>/g, " ").replace(/ /gi, " ").replace(/&/gi, "&").replace(/</gi, "<").replace(/>/gi, ">").replace(/\s+/g, " ").trim();
|
|
58
|
+
}
|
|
59
|
+
function gmailContent(message) {
|
|
60
|
+
const direct = text(message, "plainText", "plain_text", "text", "content", "body");
|
|
61
|
+
if (direct) return direct.slice(0, MAX_EMAIL_CONTENT_CHARS);
|
|
62
|
+
const plain = [];
|
|
63
|
+
const html = [];
|
|
64
|
+
const visit = (value, depth = 0) => {
|
|
65
|
+
if (depth > 10 || plain.join("").length >= MAX_EMAIL_CONTENT_CHARS) return;
|
|
66
|
+
const part = record(value);
|
|
67
|
+
if (!part) return;
|
|
68
|
+
const mimeType = text(part, "mimeType", "mime_type")?.toLowerCase();
|
|
69
|
+
const decoded = decodeGmailBody(record(part.body)?.data);
|
|
70
|
+
if (decoded) {
|
|
71
|
+
if (mimeType === "text/html") html.push(stripHtml(decoded));
|
|
72
|
+
else if (!mimeType || mimeType === "text/plain") plain.push(decoded);
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(part.parts)) for (const nested of part.parts) visit(nested, depth + 1);
|
|
75
|
+
};
|
|
76
|
+
visit(message.payload);
|
|
77
|
+
const content = (plain.length ? plain : html).filter(Boolean).join("\n\n").trim();
|
|
78
|
+
return content ? content.slice(0, MAX_EMAIL_CONTENT_CHARS) : void 0;
|
|
79
|
+
}
|
|
35
80
|
function normalizeGmail(result) {
|
|
36
81
|
return rows(payload(result), "messages").flatMap((message) => {
|
|
37
82
|
const externalId = text(message, "id", "messageId", "message_id");
|
|
38
83
|
if (!externalId) return [];
|
|
39
84
|
const occurredAt = time(message.internalDate ?? message.internal_date ?? message.date ?? message.timestamp);
|
|
85
|
+
const headers = gmailHeaders(message);
|
|
40
86
|
return [{
|
|
41
87
|
externalId,
|
|
42
88
|
itemType: "email",
|
|
@@ -45,12 +91,13 @@ function normalizeGmail(result) {
|
|
|
45
91
|
value: compact({
|
|
46
92
|
id: externalId,
|
|
47
93
|
threadId: text(message, "threadId", "thread_id"),
|
|
48
|
-
subject: text(message, "subject"),
|
|
49
|
-
sender: message.sender ?? message.from,
|
|
50
|
-
recipients: message.recipients ?? message.to,
|
|
94
|
+
subject: text(message, "subject") ?? headers.get("subject"),
|
|
95
|
+
sender: message.sender ?? message.from ?? headers.get("from"),
|
|
96
|
+
recipients: message.recipients ?? message.to ?? headers.get("to"),
|
|
51
97
|
date: occurredAt,
|
|
52
98
|
labels: message.labelIds ?? message.label_ids ?? message.labels,
|
|
53
|
-
snippet: text(message, "snippet", "preview")
|
|
99
|
+
snippet: text(message, "snippet", "preview"),
|
|
100
|
+
content: gmailContent(message)
|
|
54
101
|
}),
|
|
55
102
|
metadata: {
|
|
56
103
|
observationKind: "message",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MemoryManager } from '../agent/memory/manager.js';
|
|
2
|
+
import type { Config } from '../config/schema.js';
|
|
3
|
+
import type { KnowledgeSourceItem } from '../knowledge/types.js';
|
|
4
|
+
import type { UnderstandingSourceItem } from '../user-context/sources/types.js';
|
|
5
|
+
import { analyzeUnderstandingSources } from '../work-discovery/analyzer.js';
|
|
6
|
+
export declare function connectedItemsForUnderstanding(items: KnowledgeSourceItem[]): UnderstandingSourceItem[];
|
|
7
|
+
export declare function deriveConnectedSourceUnderstanding(input: {
|
|
8
|
+
config: Config;
|
|
9
|
+
agentId: string;
|
|
10
|
+
sourceInstanceId: string;
|
|
11
|
+
sourceRunId: string;
|
|
12
|
+
memoryManager: MemoryManager;
|
|
13
|
+
analyze?: typeof analyzeUnderstandingSources;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
created: number;
|
|
16
|
+
focusCount: number;
|
|
17
|
+
status: 'completed' | 'partial' | 'failed';
|
|
18
|
+
error?: string;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { listKnowledgeSourceItems } from "../storage/sqlite/knowledge-repository.js";
|
|
2
|
+
import "../storage/sqlite/index.js";
|
|
3
|
+
import { upsertUserFocus } from "../user-context/sources/repository.js";
|
|
4
|
+
import { analyzeUnderstandingSources } from "../work-discovery/analyzer.js";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
//#region src/connectors/connected-source-understanding.ts
|
|
7
|
+
const MAX_CONNECTED_ITEMS = 150;
|
|
8
|
+
function normalizedValue(item) {
|
|
9
|
+
if (!item.normalizedText) return {};
|
|
10
|
+
try {
|
|
11
|
+
const value = JSON.parse(item.normalizedText);
|
|
12
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
13
|
+
} catch {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function text(value) {
|
|
18
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
19
|
+
}
|
|
20
|
+
function itemType(itemType) {
|
|
21
|
+
if (itemType === "email") return "mail";
|
|
22
|
+
if (itemType === "calendar_event") return "calendar_event";
|
|
23
|
+
if (itemType === "external_task") return "task";
|
|
24
|
+
if (itemType === "development_activity" || itemType === "repository") return "code_activity";
|
|
25
|
+
return "document";
|
|
26
|
+
}
|
|
27
|
+
function timestamp(value) {
|
|
28
|
+
if (!value) return void 0;
|
|
29
|
+
const parsed = Date.parse(value);
|
|
30
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
31
|
+
}
|
|
32
|
+
function contentPriority(item) {
|
|
33
|
+
const value = normalizedValue(item);
|
|
34
|
+
if (item.itemType === "connected_content") return 3;
|
|
35
|
+
if (text(value.content)) return 2;
|
|
36
|
+
return 1;
|
|
37
|
+
}
|
|
38
|
+
function connectedItemsForUnderstanding(items) {
|
|
39
|
+
return [...items].sort((left, right) => contentPriority(right) - contentPriority(left)).slice(0, MAX_CONNECTED_ITEMS).flatMap((item) => {
|
|
40
|
+
const value = normalizedValue(item);
|
|
41
|
+
const title = text(value.title) ?? text(value.subject) ?? text(value.fullName) ?? text(value.repository) ?? `${text(item.metadata.toolkit) ?? "Connected source"} ${item.itemType}`;
|
|
42
|
+
const normalizedText = item.normalizedText?.trim();
|
|
43
|
+
if (!title && !normalizedText) return [];
|
|
44
|
+
return [{
|
|
45
|
+
id: item.id,
|
|
46
|
+
sourceId: "connected-work",
|
|
47
|
+
type: itemType(item.itemType),
|
|
48
|
+
title,
|
|
49
|
+
...normalizedText ? { text: normalizedText.slice(0, 24e3) } : {},
|
|
50
|
+
...text(item.metadata.toolkit) ? { group: text(item.metadata.toolkit) } : {},
|
|
51
|
+
...timestamp(item.occurredAt) ? { occurredAt: timestamp(item.occurredAt) } : {},
|
|
52
|
+
...timestamp(item.sourceUpdatedAt) ? { modifiedAt: timestamp(item.sourceUpdatedAt) } : {},
|
|
53
|
+
ownerAttribution: item.metadata.actorAttributed === true ? "user" : "shared",
|
|
54
|
+
sensitivity: item.sensitivity,
|
|
55
|
+
evidenceRef: `knowledge-source://${item.id}`
|
|
56
|
+
}];
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function understandingKind(category) {
|
|
60
|
+
if (category === "preference") return "preference";
|
|
61
|
+
if (category === "workflow") return "routine";
|
|
62
|
+
if (category === "focus") return "current_state";
|
|
63
|
+
return "project_context";
|
|
64
|
+
}
|
|
65
|
+
function understandingCandidate(candidate) {
|
|
66
|
+
const normalized = candidate.statement.toLocaleLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
67
|
+
return {
|
|
68
|
+
kind: understandingKind(candidate.category),
|
|
69
|
+
content: candidate.statement,
|
|
70
|
+
canonicalKey: `connected-semantic:${candidate.category}:${createHash("sha256").update(normalized).digest("hex").slice(0, 20)}`,
|
|
71
|
+
confidence: candidate.confidence === "high" ? .9 : candidate.confidence === "medium" ? .72 : .55,
|
|
72
|
+
importance: candidate.category === "focus" ? .8 : .68,
|
|
73
|
+
explicitness: "inferred",
|
|
74
|
+
durability: candidate.category === "focus" ? "ephemeral" : candidate.category === "workflow" ? "recurring" : "durable",
|
|
75
|
+
sensitivity: "personal",
|
|
76
|
+
disclosurePolicy: "referenceable"
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function hasLongVerbatimOverlap(value, sourceTexts, minimumLength = 32) {
|
|
80
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
81
|
+
if (normalized.length < minimumLength) return false;
|
|
82
|
+
return sourceTexts.some((source) => source.replace(/\s+/g, " ").includes(normalized));
|
|
83
|
+
}
|
|
84
|
+
async function deriveConnectedSourceUnderstanding(input) {
|
|
85
|
+
const items = connectedItemsForUnderstanding(listKnowledgeSourceItems({
|
|
86
|
+
agentId: input.agentId,
|
|
87
|
+
sourceInstanceId: input.sourceInstanceId,
|
|
88
|
+
includeDeleted: false,
|
|
89
|
+
limit: MAX_CONNECTED_ITEMS
|
|
90
|
+
}));
|
|
91
|
+
if (!items.length) return {
|
|
92
|
+
created: 0,
|
|
93
|
+
focusCount: 0,
|
|
94
|
+
status: "completed"
|
|
95
|
+
};
|
|
96
|
+
const analysis = await (input.analyze ?? analyzeUnderstandingSources)({
|
|
97
|
+
config: input.config,
|
|
98
|
+
items
|
|
99
|
+
});
|
|
100
|
+
const rawTexts = items.flatMap((item) => item.text ? [item.text] : []);
|
|
101
|
+
const profileCandidates = analysis.profileCandidates.filter((candidate) => !hasLongVerbatimOverlap(candidate.statement, rawTexts));
|
|
102
|
+
const sourceItemIds = [...new Set([...profileCandidates.flatMap((candidate) => candidate.evidenceRefs ?? []), ...analysis.workThreadCandidates.flatMap((candidate) => candidate.evidenceRefs)].map((ref) => ref.startsWith("knowledge-source://") ? ref.slice(19) : ""))].filter(Boolean).slice(0, 20);
|
|
103
|
+
const reviewed = profileCandidates.length ? await input.memoryManager.applyUnderstandingCandidates(profileCandidates.map(understandingCandidate), {
|
|
104
|
+
agentId: input.agentId,
|
|
105
|
+
sourceItemIds,
|
|
106
|
+
sourceText: "Bounded semantic synthesis from explicitly connected work sources.",
|
|
107
|
+
source: {
|
|
108
|
+
provider: "connected-sources",
|
|
109
|
+
sourceInstanceId: input.sourceInstanceId
|
|
110
|
+
},
|
|
111
|
+
reviewSource: "background"
|
|
112
|
+
}) : { created: 0 };
|
|
113
|
+
const focuses = analysis.workThreadCandidates.filter((candidate) => !hasLongVerbatimOverlap(candidate.title, rawTexts) && !hasLongVerbatimOverlap(candidate.summary, rawTexts)).map((candidate) => upsertUserFocus({
|
|
114
|
+
canonicalKey: `connected-focus:${candidate.topicKey}`,
|
|
115
|
+
title: candidate.title,
|
|
116
|
+
summary: candidate.summary,
|
|
117
|
+
horizon: candidate.horizon,
|
|
118
|
+
status: "candidate",
|
|
119
|
+
confidence: candidate.confidence === "high" ? .9 : candidate.confidence === "medium" ? .72 : .55,
|
|
120
|
+
evidenceRefs: candidate.evidenceRefs,
|
|
121
|
+
sourceRunId: input.sourceRunId
|
|
122
|
+
}));
|
|
123
|
+
const sourceStatus = analysis.sourceStatuses.find((item) => item.sourceId === "connected-work");
|
|
124
|
+
return {
|
|
125
|
+
created: reviewed.created,
|
|
126
|
+
focusCount: focuses.length,
|
|
127
|
+
status: sourceStatus?.status ?? "failed",
|
|
128
|
+
...sourceStatus?.error ? { error: sourceStatus.error } : {}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { connectedItemsForUnderstanding, deriveConnectedSourceUnderstanding };
|
|
@@ -19,6 +19,7 @@ export type ConnectedContentReadResult = {
|
|
|
19
19
|
};
|
|
20
20
|
export declare function listConnectedContentCandidates(options: {
|
|
21
21
|
agentId: string;
|
|
22
|
+
sourceInstanceId?: string;
|
|
22
23
|
limit?: number;
|
|
23
24
|
}): ConnectedContentCandidate[];
|
|
24
25
|
export declare function readConnectedContent(input: {
|
|
@@ -43,13 +43,16 @@ function candidateFor(item) {
|
|
|
43
43
|
const value = normalizedRecord(item);
|
|
44
44
|
const title = text(value.title) ?? text(value.subject);
|
|
45
45
|
if (!title) return void 0;
|
|
46
|
-
if (toolkit === "gmail" && item.itemType === "email")
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
if (toolkit === "gmail" && item.itemType === "email") {
|
|
47
|
+
if (text(value.content)) return void 0;
|
|
48
|
+
return {
|
|
49
|
+
sourceItemId: item.id,
|
|
50
|
+
sourceInstanceId: item.sourceInstanceId,
|
|
51
|
+
toolkit,
|
|
52
|
+
title,
|
|
53
|
+
occurredAt: item.occurredAt
|
|
54
|
+
};
|
|
55
|
+
}
|
|
53
56
|
const mimeType = text(item.metadata.mimeType) ?? text(value.mimeType);
|
|
54
57
|
if (toolkit === "googledrive" && item.itemType === "cloud_document" && mimeType && (mimeType === GOOGLE_DOCUMENT_MIME || DOWNLOADABLE_TEXT_MIMES.has(mimeType))) return {
|
|
55
58
|
sourceItemId: item.id,
|
|
@@ -64,6 +67,7 @@ function listConnectedContentCandidates(options) {
|
|
|
64
67
|
const limit = Math.max(1, Math.min(20, options.limit ?? 10));
|
|
65
68
|
const items = listKnowledgeSourceItems({
|
|
66
69
|
agentId: options.agentId,
|
|
70
|
+
...options.sourceInstanceId ? { sourceInstanceId: options.sourceInstanceId } : {},
|
|
67
71
|
includeDeleted: false,
|
|
68
72
|
limit: 500
|
|
69
73
|
});
|