@xopcai/xopc 0.0.359 → 0.0.361
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CnmHVy1D.js → activity-store-tpFInIoh.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D-yhlYSG.js → agent-avatar-dicebear-DUhFW_Go.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BNILmgey.js +1 -0
- package/dist/gateway/static/root/assets/agent-plugin-dialog-CnWci4JJ.js +1 -0
- package/dist/gateway/static/root/assets/agents-CKS5LUUs.js +66 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-BtnYiq7O.js → agents-admin-api-CiAjB2iQ.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CiSdkzuX.js → app-management-settings-panel-DEig00YU.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-SdlCHKg8.js → appearance-settings-CccnRRrL.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-ntyBe6mP.js → apps-page-CkT6UNZW.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-DZCN9m71.js → archive-plugin-CIlmZBe5.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DU0R5C65.js → automations-page-8kZugDcf.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-3V54ShL0.js +7 -0
- package/dist/gateway/static/root/assets/{binary-plugins-U63xxRgh.js → binary-plugins-BuQiee_b.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CLejMPkV.js → block-editor-BFFRbsKX.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-MmkUGn9W.js → browser-automation-inputs-CWujpdCx.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BjGswNM0.js → browser-automations-page-HVXiBKXE.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-DpxAXNvM.js +3 -0
- package/dist/gateway/static/root/assets/{capabilities-BXG_5wIg.js → capabilities-CngwB2JU.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-Bigu28Z6.js → capabilities-RMlKKfGF.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-BBi4ef3u.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-IxszGl-Q.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-B0Xiav_-.js → capability-header-actions-BLOIJvIZ.js} +1 -1
- package/dist/gateway/static/root/assets/channels-Ced5nFBc.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-C9pMFB6k.js → chat-terminal-dock-BskUzDCS.js} +2 -2
- package/dist/gateway/static/root/assets/computer-settings-page-De-pjlvn.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-OyQKwHNr.js → connector-service-page-Qc1mVfp9.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-CPqeY1x5.js +2 -0
- package/dist/gateway/static/root/assets/{constants-Co2_smKQ.js → constants-Dy8Gw0sF.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-DxGsweV_.js → date-picker-7ppMIGfQ.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-D9ZfAJwn.js → dependency-picker-DfYC22si.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DFgK1z5i.js → desktop-pet-GKEfqHDF.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CyFW0raW.js → desktop-pet-settings-qoFZBKe9.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-C6Co5dT3.js → device-pairing-wizard-D8sTDd5s.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-2nrl6Exh.js → directory-picker-path-field-BC87CZa2.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BodxNAys.js → extension-debug-page-VxCq29jC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DMb2YFlb.js → extension-page-DypBVBTt.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-aigS3RJu.js → extension-provider-wlvxPese.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-D3hvXtxi.js → extension-settings-page-DzzkBN9y.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-DsXySQVF.js → fallback-models-s4qTRcPJ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-EZxaKXdC.js → gateway-config-swr-ZM72jovc.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-DBRa17u3.js → gateway-realtime-B-hrykag.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-B6B1fw_K.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-CubM1m6Z.js → gateway-settings--M7ZH_37.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Wtxq_y2f.js → gateway-startup-retry-DjWuTj8B.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-KFs5suD1.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-Bnl0CH4n.js → image-generation-api-C9cwrqCr.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-Czzsa_Eu.js → imports-page-BKy0ImXk.js} +1 -1
- package/dist/gateway/static/root/assets/{index-DUgsBdV3.css → index-B7AHDHSO.css} +1 -1
- package/dist/gateway/static/root/assets/index-C0JT9Ja4.js +106 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DqsFlXlp.js → keyboard-shortcuts-settings-CexiL-Ey.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-BcDFXc1k.js → local-app-workbench-page-CcU1OLWQ.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-BaxqXA1-.js → local-apps-page-BcLijQx4.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-CeHhcudO.js → local-session-drafts-C7QjBMNp.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-ChN_vjs2.js → locale-store-5sV3dDRG.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DmJjZ0Uk.js → logs-page-48nrZNQe.js} +2 -2
- package/dist/gateway/static/root/assets/management-settings-B_gzl_Vh.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-DKlJx4eo.js → markdown-view-V0f5NW7D.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-JWzrPQwt.js → media-plugins-_obxSZmT.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-CnM6Qfr7.js → messages-CaURu8bb.js} +2 -2
- package/dist/gateway/static/root/assets/models-hub-cache-Cs3E5pEA.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-BLvVlQG8.js → note-detail-panel-B9AeX98W.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-api-D8nvWMMC.js → notes-api-CBnMq6Nc.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-CKTTfxw-.js +8 -0
- package/dist/gateway/static/root/assets/{oauth-api-BXn1a9qx.js → oauth-api-Bu2RoLF2.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-gL3453SU.js → page-context-capture-button-BsxBAWD_.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-Cfl1FR3i.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-Dw8JPizo.js → product-open-page-D1ARqS3r.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-Zg4KZ0vK.js → project-detail-page-Cro1OE8P.js} +1 -1
- package/dist/gateway/static/root/assets/projects-page-CdEmmBCz.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BM_81rLe.js → registry-api-j1rNFkP2.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C9_ea_4p.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BLNXzyeh.js → runtime-tools-settings-panel-DtmQbC72.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-D868Zuj9.js → scenes-page-DeFdMf2q.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-5z33VTce.js → schema-form-ByEHHW6n.js} +1 -1
- package/dist/gateway/static/root/assets/{send-session-input-OaBPDJ9E.js → send-session-input-CO_vUCb8.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-UkGomZfv.js → session-api-CYPGi01d.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-BdJThQQ6.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-CV0JlaXS.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-D9sW0hKa.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-BG_dOYMq.js → settings-page-CHKsZFAN.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-DNj1hD_H.js → setup-status-panel-CC58OVOe.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-BvSRHs1P.js → share-link-dialog-ZOdnHkmb.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-M_rAQR60.js → share-preview-page-BPDWUuH_.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-DwqLga5H.js → shares-api-T5gR8yqz.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DaXvdH8c.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-BBaKs-Xx.js → skill-api-CHCLMcfO.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-C1hzIawD.js → skill-reload-api-C-RoiUJi.js} +1 -1
- package/dist/gateway/static/root/assets/skills-page-a9UQQnqn.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-DKjsZo49.js → system-settings-panel-Dho_dlBS.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DSvaiKGb.js → task-detail-page-B5JyH4z7.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DTYk7Gll.js → theme-store-CEl74p7l.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-DR8Qu6R_.js → tunnel-api-BDqCyf8G.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-CAIqAduR.js → usage-page-DKwKfszc.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-R3hEHQQq.js → use-autosave-D09eZTLp.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-CUaywGe0.js → use-composer-attachments-CkvJM8Km.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-D809I8ur.js → use-file-preview-expanded-J3HnG8OH.js} +2 -2
- package/dist/gateway/static/root/assets/user-model-page-BsgADrGL.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-C-AF-IcO.js → voice-api-key-field-DH-to9Rd.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CxGsCDoW.js → voice-config-api-CmCfVy3H.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-wGFcle2p.js → work-discovery-overlay-x1vZDBhu.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CewS2IbN.js → workflow-run-setup-panel-DGatvmK1.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DgNy6mBQ.js +6 -0
- package/dist/gateway/static/root/assets/{workspace-api-BtXzxf_w.js → workspace-api-DzPw92Kx.js} +2 -2
- package/dist/gateway/static/root/index.html +29 -30
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/index.js +2 -0
- package/dist/packages/gateway-contract/src/task-result-delivery.js +30 -0
- package/dist/src/agent/context/workspace-templates/SOUL.md +2 -0
- package/dist/src/agent/embedded/run-for-session.js +70 -4
- package/dist/src/agent/external-tools/gateway-tools.js +41 -1
- package/dist/src/agent/inbound/attachment-pipeline.js +13 -0
- package/dist/src/agent/memory/compaction-policy.d.ts +4 -0
- package/dist/src/agent/memory/compaction-policy.js +3 -0
- package/dist/src/agent/memory/idle-compaction-scheduler.d.ts +28 -0
- package/dist/src/agent/memory/idle-compaction-scheduler.js +127 -0
- package/dist/src/agent/prompt/sections/behavior.js +4 -1
- package/dist/src/agent/prompt/sections/memory-skills.js +2 -0
- package/dist/src/agent/service/process-direct-one-shot.js +1 -0
- package/dist/src/agent/service/process-direct-streaming.js +1 -0
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/session/session-config-service.js +11 -3
- package/dist/src/agent/tools/delegation-policy.js +1 -0
- package/dist/src/agent/tools/factory.js +48 -8
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/media-read-tool.d.ts +5 -1
- package/dist/src/agent/tools/media-read-tool.js +44 -5
- package/dist/src/agent/tools/personal-preference-tool.js +11 -0
- package/dist/src/agent/tools/personal-read-tool.d.ts +3 -0
- package/dist/src/agent/tools/personal-read-tool.js +155 -0
- package/dist/src/agent/tools/personal-request-result-tool.d.ts +22 -0
- package/dist/src/agent/tools/personal-request-result-tool.js +84 -0
- package/dist/src/agent/tools/personal-request-tool.d.ts +3 -0
- package/dist/src/agent/tools/personal-request-tool.js +100 -0
- package/dist/src/agent/tools/personal-task-tool.d.ts +6 -0
- package/dist/src/agent/tools/personal-task-tool.js +13 -11
- package/dist/src/agent/tools/read.d.ts +3 -0
- package/dist/src/agent/tools/read.js +26 -8
- package/dist/src/agent/tools/session-search-tool.d.ts +1 -0
- package/dist/src/agent/tools/session-search-tool.js +39 -5
- package/dist/src/agent/tools/tool-media.js +2 -3
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/templates.js +4 -0
- package/dist/src/config/schema.d.ts +10 -0
- package/dist/src/connectors/connection-recovery-service.d.ts +2 -0
- package/dist/src/connectors/connection-recovery-service.js +23 -5
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +10 -0
- package/dist/src/gateway/hono/routes/media.js +4 -3
- package/dist/src/gateway/hono/routes/personal-agent.js +69 -1
- package/dist/src/gateway/hono/routes/sessions.js +1 -1
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/media-access.js +2 -2
- package/dist/src/gateway/service/agent-runner.js +1 -0
- package/dist/src/gateway/service/session-command-service.js +1 -1
- package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -0
- package/dist/src/gateway/service/session-input-coordinator.js +2 -0
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +45 -4
- package/dist/src/media/index.js +2 -2
- package/dist/src/media/session-references.d.ts +2 -0
- package/dist/src/media/session-references.js +22 -2
- package/dist/src/media/store.d.ts +1 -0
- package/dist/src/media/store.js +7 -2
- package/dist/src/personal-agent/capability-service.d.ts +14 -0
- package/dist/src/personal-agent/capability-service.js +63 -0
- package/dist/src/personal-agent/communication.d.ts +4 -0
- package/dist/src/personal-agent/communication.js +24 -0
- package/dist/src/personal-agent/model-config.d.ts +5 -0
- package/dist/src/personal-agent/model-config.js +59 -0
- package/dist/src/personal-agent/policy.d.ts +1 -1
- package/dist/src/personal-agent/policy.js +6 -0
- package/dist/src/personal-agent/repository.d.ts +1 -0
- package/dist/src/personal-agent/repository.js +3 -1
- package/dist/src/personal-agent/request-delivery.d.ts +4 -0
- package/dist/src/personal-agent/request-delivery.js +159 -0
- package/dist/src/personal-agent/request-repository.d.ts +33 -0
- package/dist/src/personal-agent/request-repository.js +71 -0
- package/dist/src/personal-agent/request-result.d.ts +21 -0
- package/dist/src/personal-agent/request-result.js +45 -0
- package/dist/src/personal-agent/request-service.d.ts +18 -0
- package/dist/src/personal-agent/request-service.js +308 -0
- package/dist/src/personal-agent/service.js +32 -7
- package/dist/src/session/client-history.d.ts +2 -1
- package/dist/src/session/client-history.js +40 -0
- package/dist/src/session/compact-history.js +9 -5
- package/dist/src/session/config-store.js +2 -1
- package/dist/src/session/session-context-for-llm.js +55 -0
- package/dist/src/session/store.d.ts +12 -1
- package/dist/src/session/store.js +35 -0
- package/dist/src/session/types.d.ts +2 -0
- package/dist/src/storage/sqlite/connection-wait-repository.d.ts +5 -1
- package/dist/src/storage/sqlite/connection-wait-repository.js +38 -8
- package/dist/src/storage/sqlite/migrations/231_task_result_deliveries.sql +32 -0
- package/dist/src/storage/sqlite/migrations/232_personal_requests.sql +28 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-repository.js +33 -0
- package/dist/src/storage/sqlite/transcript-repository.d.ts +4 -1
- package/dist/src/storage/sqlite/transcript-repository.js +15 -1
- package/dist/src/tasks/task-application-service.d.ts +1 -0
- package/dist/src/tasks/task-application-service.js +7 -0
- package/dist/src/tasks/task-context-assembler.js +1 -0
- package/dist/src/tasks/task-main-update-decision-service.js +1 -1
- package/dist/src/tasks/task-main-update-delivery.js +32 -1
- package/dist/src/tasks/task-result-delivery-repository.d.ts +18 -0
- package/dist/src/tasks/task-result-delivery-repository.js +144 -0
- package/dist/src/tasks/task-result-delivery-service.d.ts +4 -0
- package/dist/src/tasks/task-result-delivery-service.js +128 -0
- package/dist/src/tasks/task-run-coordinator.js +6 -1
- package/dist/src/tasks/task-run-dispatcher.d.ts +1 -0
- package/dist/src/tasks/task-run-dispatcher.js +22 -3
- package/dist/src/user-context/config.d.ts +48 -0
- package/dist/src/user-context/config.js +23 -3
- package/dist/src/voice/realtime/runtime.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CYq-3pbE.js +0 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-Cx3UbhqT.js +0 -1
- package/dist/gateway/static/root/assets/agents-Ce9uvui7.js +0 -66
- package/dist/gateway/static/root/assets/automations-workspace-BaHJml4R.js +0 -7
- package/dist/gateway/static/root/assets/browser-settings-page-DBcYssNQ.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-page-CsTpcrPP.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BXlVwnMr.js +0 -8
- package/dist/gateway/static/root/assets/channels-TPqwcbZ4.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-BJOn14Ow.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DBWH5bVr.js +0 -2
- package/dist/gateway/static/root/assets/gateway-realtime-store-7glMlD2l.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CQ9y_LMT.js +0 -1
- package/dist/gateway/static/root/assets/index-DUU_2HF0.js +0 -106
- package/dist/gateway/static/root/assets/management-settings-1O7zsu4t.js +0 -1
- package/dist/gateway/static/root/assets/model-display-name-DXhO9rcM.js +0 -1
- package/dist/gateway/static/root/assets/models-hub-cache-DnIOzcvn.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-AWU_G61i.js +0 -8
- package/dist/gateway/static/root/assets/personal-page-BPy5m3QR.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B33uj1lz.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BZoUVzgS.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-BK5IvdGz.js +0 -16
- package/dist/gateway/static/root/assets/sessions-page-Du7ueBFc.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CaxCsIIZ.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Cr_Ut6FE.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DU7fV5pc.js +0 -2
- package/dist/gateway/static/root/assets/user-model-page-C--t6SLp.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-CxfsWFL5.js +0 -6
|
@@ -3,7 +3,9 @@ import { createLogger } from "../../utils/logger/index.js";
|
|
|
3
3
|
import { init_logger } from "../../utils/logger.js";
|
|
4
4
|
import { isXopcDatabaseOpen } from "../../storage/sqlite/connection.js";
|
|
5
5
|
import { getBrowserTabBinding, init_browser_tab_binding_repository } from "../../storage/sqlite/browser-tab-binding-repository.js";
|
|
6
|
+
import { init_request_repository, personalRequestForExecution } from "../../personal-agent/request-repository.js";
|
|
6
7
|
import { getSessionMetadata } from "../../storage/sqlite/session-read-repository.js";
|
|
8
|
+
import { patchSessionMetadata } from "../../storage/sqlite/session-repository.js";
|
|
7
9
|
import { getSessionTaskPlan, setSessionTaskPlan } from "../../storage/sqlite/session-task-plan-repository.js";
|
|
8
10
|
import { init_sqlite } from "../../storage/sqlite/index.js";
|
|
9
11
|
import { init_agent_scope, resolveDefaultAgentId } from "../agent-scope.js";
|
|
@@ -60,8 +62,11 @@ import { createDesktopPetTool } from "./desktop-pet-tool.js";
|
|
|
60
62
|
import { createManagedJobTool } from "./managed-job-tool.js";
|
|
61
63
|
import { createImageTool } from "./image-tool.js";
|
|
62
64
|
import { createImageGenerateTool } from "./image-generate-tool.js";
|
|
65
|
+
import { createPersonalReadTool } from "./personal-read-tool.js";
|
|
63
66
|
import "./index.js";
|
|
64
67
|
import { createPersonalTaskTool } from "./personal-task-tool.js";
|
|
68
|
+
import { createPersonalRequestTools } from "./personal-request-tool.js";
|
|
69
|
+
import { createPersonalRequestConnectionTool, createPersonalRequestResultTool } from "./personal-request-result-tool.js";
|
|
65
70
|
import { createPersonalPreferenceTool } from "./personal-preference-tool.js";
|
|
66
71
|
import { resolveUserContextSessionAccess } from "../../user-context/access-policy.js";
|
|
67
72
|
import { createBrowserUseTool } from "./browser/tool/browser-use-tool.js";
|
|
@@ -77,6 +82,7 @@ import "../capabilities/index.js";
|
|
|
77
82
|
import { sortToolsForPromptCache } from "./cache-stability.js";
|
|
78
83
|
//#region src/agent/tools/factory.ts
|
|
79
84
|
init_agent_scope();
|
|
85
|
+
init_request_repository();
|
|
80
86
|
init_browser_tab_binding_repository();
|
|
81
87
|
init_logger();
|
|
82
88
|
init_sqlite();
|
|
@@ -211,7 +217,7 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
211
217
|
const getMemMgr = options?.getMemoryManager ?? this.deps.getMemoryManager;
|
|
212
218
|
const getSkillMgr = options?.getSkillManager;
|
|
213
219
|
const disabled = options?.disabledTools;
|
|
214
|
-
|
|
220
|
+
let allowed = options?.toolAllowlist ? new Set(options.toolAllowlist) : void 0;
|
|
215
221
|
const personalToolsConfigured = Boolean(allowed?.has("personal_task") || allowed?.has("personal_preference"));
|
|
216
222
|
const primary = getPrimary?.();
|
|
217
223
|
const modelHasVision = primary?.input?.includes("image") ?? false;
|
|
@@ -231,6 +237,22 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
231
237
|
const agentId = options?.agentId;
|
|
232
238
|
const resolvedAgentId = agentId ?? (cfg ? resolveDefaultAgentId() : "main");
|
|
233
239
|
const currentConversationId = () => options?.conversationId ?? this.deps.getCurrentContext?.()?.conversationId;
|
|
240
|
+
const executionConversationId = currentConversationId();
|
|
241
|
+
const personalExecution = executionConversationId ? personalRequestForExecution(executionConversationId) : void 0;
|
|
242
|
+
const personalExecutionMarker = executionConversationId && isXopcDatabaseOpen() ? getSessionMetadata(executionConversationId)?.customData?.personalReadRequestId : void 0;
|
|
243
|
+
if (personalExecution && executionConversationId && personalExecutionMarker !== personalExecution.requestId) patchSessionMetadata(executionConversationId, { customData: {
|
|
244
|
+
...getSessionMetadata(executionConversationId)?.customData,
|
|
245
|
+
personalReadRequestId: personalExecution.requestId
|
|
246
|
+
} });
|
|
247
|
+
if (personalExecution || personalExecutionMarker) {
|
|
248
|
+
allowed = new Set([
|
|
249
|
+
"xopc_tool_search",
|
|
250
|
+
"xopc_tool_describe",
|
|
251
|
+
"xopc_tool_execute"
|
|
252
|
+
].filter((name) => !allowed || allowed.has(name)));
|
|
253
|
+
allowed.add("personal_request_result");
|
|
254
|
+
allowed.add("personal_request_connection");
|
|
255
|
+
}
|
|
234
256
|
const deliveryContext = () => {
|
|
235
257
|
if (currentConversationId() && getSessionMetadata(currentConversationId())?.sessionType === "heartbeat") throw new Error("Heartbeat notifications must be returned in the final response for policy-controlled delivery.");
|
|
236
258
|
return this.deps.getCurrentContext();
|
|
@@ -258,7 +280,14 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
258
280
|
canAccessMemory: () => currentAccess().knowledge
|
|
259
281
|
});
|
|
260
282
|
const optionalTools = [imageTool, imageGenerateTool].filter((t) => t != null);
|
|
261
|
-
const readTool = createReadFileTool(workspace, {
|
|
283
|
+
const readTool = createReadFileTool(workspace, {
|
|
284
|
+
profileMarkdownRoot: options?.profileMarkdownRoot,
|
|
285
|
+
...personalToolsConfigured ? {
|
|
286
|
+
defaultMaxLines: 150,
|
|
287
|
+
maxOutputBytes: 8e3,
|
|
288
|
+
maxReadBytes: 12e3
|
|
289
|
+
} : {}
|
|
290
|
+
});
|
|
262
291
|
const writeTool = createWriteFileTool(workspace, { profileMarkdownRoot: options?.profileMarkdownRoot });
|
|
263
292
|
const applyPatchTool = createApplyPatchTool(workspace);
|
|
264
293
|
const listDir = createListDirTool(workspace);
|
|
@@ -374,7 +403,11 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
374
403
|
})] : [],
|
|
375
404
|
createSendMediaTool(workspace, bus, deliveryContext),
|
|
376
405
|
createPublishArtifactsTool(workspace),
|
|
377
|
-
createReadMediaTool(
|
|
406
|
+
createReadMediaTool(personalToolsConfigured ? {
|
|
407
|
+
textOnly: true,
|
|
408
|
+
maxChars: 8e3,
|
|
409
|
+
maxReadBytes: 12e3
|
|
410
|
+
} : void 0),
|
|
378
411
|
...isShareToolAvailable(cfg) ? [createCreateShareTool({
|
|
379
412
|
workspace,
|
|
380
413
|
getConfig: () => this.deps.getConfig?.()
|
|
@@ -440,6 +473,7 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
440
473
|
getCurrentConversationId: () => this.deps.getCurrentContext()?.conversationId
|
|
441
474
|
})] : [],
|
|
442
475
|
...this.deps.getSessionStore && getPrimary ? [createSessionSearchTool({
|
|
476
|
+
localOnly: personalToolsConfigured,
|
|
443
477
|
getSessionStore: this.deps.getSessionStore,
|
|
444
478
|
getPrimaryModel: getPrimary,
|
|
445
479
|
getCurrentConversationId: () => this.deps.getCurrentContext()?.conversationId,
|
|
@@ -451,10 +485,15 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
451
485
|
getProjectService: this.deps.getProjectService
|
|
452
486
|
})] : [],
|
|
453
487
|
...browserEnabled && this.deps.getBrowserAutomationService ? [createBrowserAutomationTool({ getBrowserAutomationService: this.deps.getBrowserAutomationService })] : [],
|
|
454
|
-
...this.deps.getAutomationService || this.deps.getSceneAccess || this.deps.getProjectService || this.deps.getNotesService || this.deps.getLocalAppService || this.deps.getChatPreviewService || this.deps.dispatchTaskEvents || this.deps.dispatchTaskRuns ? [createXopcUseTool(productToolDeps), ...personalToolsConfigured ? [
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
488
|
+
...this.deps.getAutomationService || this.deps.getSceneAccess || this.deps.getProjectService || this.deps.getNotesService || this.deps.getLocalAppService || this.deps.getChatPreviewService || this.deps.dispatchTaskEvents || this.deps.dispatchTaskRuns ? [createXopcUseTool(productToolDeps), ...personalToolsConfigured ? [
|
|
489
|
+
createPersonalTaskTool(productToolDeps),
|
|
490
|
+
createPersonalReadTool(productToolDeps),
|
|
491
|
+
...createPersonalRequestTools(productToolDeps),
|
|
492
|
+
createPersonalPreferenceTool({
|
|
493
|
+
getCurrentConversationId: () => this.deps.getCurrentContext()?.conversationId,
|
|
494
|
+
onAgentCatalogMutate: this.deps.onAgentCatalogMutate
|
|
495
|
+
})
|
|
496
|
+
] : []] : [],
|
|
458
497
|
...cfg?.computer.enabled && this.deps.endpointTools ? [createComputerUseTool({
|
|
459
498
|
runtime: this.ensureComputerRuntime(),
|
|
460
499
|
context: () => {
|
|
@@ -528,7 +567,8 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
528
567
|
});
|
|
529
568
|
}
|
|
530
569
|
})] : [],
|
|
531
|
-
...optionalTools
|
|
570
|
+
...optionalTools,
|
|
571
|
+
...personalExecution ? [createPersonalRequestResultTool(currentConversationId), createPersonalRequestConnectionTool(currentConversationId)] : []
|
|
532
572
|
];
|
|
533
573
|
if ([
|
|
534
574
|
"read_file",
|
|
@@ -42,3 +42,4 @@ export { createImageTool, resolveImageModelConfigForTool } from './image-tool.js
|
|
|
42
42
|
export { createImageGenerateTool, resolveImageGenerationModelConfigForTool } from './image-generate-tool.js';
|
|
43
43
|
export { truncateHead, truncateTail, truncateLine, formatSize, type TruncationResult, type TruncationOptions, DEFAULT_MAX_LINES, DEFAULT_MAX_BYTES, GREP_MAX_LINE_LENGTH, } from './truncate.js';
|
|
44
44
|
export { normalizeToLF, restoreLineEndings, normalizeForFuzzyMatch, fuzzyFindText, stripBom, generateDiffString, type FuzzyMatchResult, } from './edit-diff.js';
|
|
45
|
+
export { createPersonalReadTool } from './personal-read-tool.js';
|
|
@@ -45,4 +45,5 @@ import { createDesktopPetTool } from "./desktop-pet-tool.js";
|
|
|
45
45
|
import { createManagedJobTool } from "./managed-job-tool.js";
|
|
46
46
|
import { createImageTool } from "./image-tool.js";
|
|
47
47
|
import { createImageGenerateTool, resolveImageGenerationModelConfigForTool } from "./image-generate-tool.js";
|
|
48
|
-
|
|
48
|
+
import { createPersonalReadTool } from "./personal-read-tool.js";
|
|
49
|
+
export { BrowserRuntime, DEFAULT_DELEGATE_TOOLS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DEFAULT_TOOL_METADATA, DEFAULT_WEB_EXTRACT_MAX_LENGTH, DELEGATE_BLOCKED_TOOLS, GREP_MAX_LINE_LENGTH, MAX_RAW_HTML_CHARS_FOR_WEB_EXTRACT, TodoStore, ToolConcurrencyController, assertBrowserUrlAllowed, createApplyPatchTool, createAutomationTool, createBrowserAutomationTool, createClarifyTool, createCreateShareTool, createDataBatchTool, createDelegateTool, createDesktopPetTool, createExecCommandTool, createFindTool, createGrepTool, createImageGenerateTool, createImageTool, createKnowledgeGetTool, createKnowledgeSearchTool, createKnowledgeWriteTool, createListDirTool, createManagedJobTool, createMemoryMaintenanceTool, createMessageTool, createPersonalReadTool, createPublishArtifactsTool, createReadFileTool, createReadMediaTool, createSendMediaTool, createSessionRecallTool, createSessionSearchTool, createSessionStatusTool, createSkillInstallTool, createSkillManageTool, createSkillViewTool, createSkillsListTool, createSkillsMarketplaceSearchTool, createTodoTool, createToolManualTool, createUpdatePlanTool, createUserContextGetTool, createUserContextSearchTool, createUserContextUpdateTool, createWebExtractTool, createWebFetchTool, createWebSearchTool, createWorkflowManageTool, createWorkflowTool, createWriteFileTool, createXopcUseTool, findTool, formatSize, fuzzyFindText, generateDiffString, getToolMetadata, grepTool, isShareToolAvailable, listDirTool, normalizeForFuzzyMatch, normalizeToLF, resolveImageGenerationModelConfigForTool, resolveImageModelConfigForTool, resolveToolLockMode, restoreLineEndings, stripBom, stripHtmlBoilerplate, truncateHead, truncateLine, truncateTail, writeFileTool };
|
|
@@ -15,12 +15,14 @@ function clampMaxBytes(raw) {
|
|
|
15
15
|
if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return DEFAULT_MAX_BYTES;
|
|
16
16
|
return Math.min(Math.floor(raw), HARD_MAX_BYTES);
|
|
17
17
|
}
|
|
18
|
-
function createReadMediaTool() {
|
|
18
|
+
function createReadMediaTool(options) {
|
|
19
19
|
return {
|
|
20
20
|
name: "read_media",
|
|
21
21
|
label: "Read Media Attachment",
|
|
22
22
|
description: "Read an attachment by media:// URI. Use this for xopc-media-uri attachments in user messages.",
|
|
23
23
|
parameters: ReadMediaSchema,
|
|
24
|
+
supportsParallel: true,
|
|
25
|
+
idempotent: true,
|
|
24
26
|
async execute(_toolCallId, params, _signal) {
|
|
25
27
|
const uri = typeof params.uri === "string" ? params.uri.trim() : "";
|
|
26
28
|
if (!uri) return {
|
|
@@ -34,7 +36,7 @@ function createReadMediaTool() {
|
|
|
34
36
|
}
|
|
35
37
|
};
|
|
36
38
|
try {
|
|
37
|
-
const { buffer, path } = await readMediaReference(uri, clampMaxBytes(params.maxBytes));
|
|
39
|
+
const { buffer, path } = await readMediaReference(uri, Math.min(clampMaxBytes(params.maxBytes), options?.maxReadBytes ?? HARD_MAX_BYTES));
|
|
38
40
|
const mimeType = mimeTypeFromMediaPath(path);
|
|
39
41
|
const metadata = {
|
|
40
42
|
ok: true,
|
|
@@ -43,14 +45,35 @@ function createReadMediaTool() {
|
|
|
43
45
|
size: buffer.byteLength,
|
|
44
46
|
path
|
|
45
47
|
};
|
|
46
|
-
if (isLikelyText(mimeType))
|
|
48
|
+
if (isLikelyText(mimeType)) {
|
|
49
|
+
const fullText = buffer.toString("utf8");
|
|
50
|
+
const maxChars = options?.maxChars ?? fullText.length;
|
|
51
|
+
const truncated = fullText.length > maxChars;
|
|
52
|
+
return {
|
|
53
|
+
content: [{
|
|
54
|
+
type: "text",
|
|
55
|
+
text: fullText.slice(0, maxChars) + (truncated ? "\n[Attachment truncated; delegate full analysis to a specialist.]" : "")
|
|
56
|
+
}],
|
|
57
|
+
details: {
|
|
58
|
+
...metadata,
|
|
59
|
+
kind: "text",
|
|
60
|
+
truncated,
|
|
61
|
+
...truncated && options?.textOnly ? {
|
|
62
|
+
requiresSpecialist: true,
|
|
63
|
+
reason: "large_attachment"
|
|
64
|
+
} : {}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (options?.textOnly) return {
|
|
47
69
|
content: [{
|
|
48
70
|
type: "text",
|
|
49
|
-
text:
|
|
71
|
+
text: "Binary attachment: delegate document parsing or media analysis to a specialist."
|
|
50
72
|
}],
|
|
51
73
|
details: {
|
|
52
74
|
...metadata,
|
|
53
|
-
kind: "
|
|
75
|
+
kind: "binary",
|
|
76
|
+
requiresSpecialist: true
|
|
54
77
|
}
|
|
55
78
|
};
|
|
56
79
|
return {
|
|
@@ -68,6 +91,22 @@ function createReadMediaTool() {
|
|
|
68
91
|
}
|
|
69
92
|
};
|
|
70
93
|
} catch (err) {
|
|
94
|
+
if (options?.textOnly && err?.code === "MEDIA_READ_LIMIT") {
|
|
95
|
+
const size = err.size;
|
|
96
|
+
return {
|
|
97
|
+
content: [{
|
|
98
|
+
type: "text",
|
|
99
|
+
text: `Attachment is large (${size} bytes; local read limit ${options.maxReadBytes ?? HARD_MAX_BYTES} bytes). Tell the user briefly, then delegate reading and processing with this URI: ${uri}`
|
|
100
|
+
}],
|
|
101
|
+
details: {
|
|
102
|
+
ok: true,
|
|
103
|
+
uri,
|
|
104
|
+
size,
|
|
105
|
+
requiresSpecialist: true,
|
|
106
|
+
reason: "large_attachment"
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
71
110
|
const message = err instanceof Error ? err.message : String(err);
|
|
72
111
|
return {
|
|
73
112
|
content: [{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { applyUserProfilePatch } from "../../user-model/profile.js";
|
|
1
2
|
import { getPersonalAgentByConversation } from "../../personal-agent/repository.js";
|
|
2
3
|
import { PersonalPreferencesSchema, updatePersonalProfileRecord } from "../../personal-agent/service.js";
|
|
3
4
|
import { Type } from "@sinclair/typebox";
|
|
@@ -28,6 +29,16 @@ function createPersonalPreferenceTool(deps) {
|
|
|
28
29
|
...personal.preferences,
|
|
29
30
|
[input.field]: input.value.trim()
|
|
30
31
|
});
|
|
32
|
+
if (input.field === "addressAs") {
|
|
33
|
+
applyUserProfilePatch({ callName: next.addressAs ?? "" });
|
|
34
|
+
return {
|
|
35
|
+
content: [{
|
|
36
|
+
type: "text",
|
|
37
|
+
text: "Saved the preferred name in the shared user profile. It takes effect on the next reply."
|
|
38
|
+
}],
|
|
39
|
+
details: {}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
31
42
|
if (!await updatePersonalProfileRecord(personal.ownerId, personal.revision, personal.displayName, next, personal.appearance)) throw new Error("Preference changed concurrently; read the current profile and try again");
|
|
32
43
|
deps.onAgentCatalogMutate?.();
|
|
33
44
|
return {
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { CapabilityDispatcher } from "../../capabilities/runtime/dispatcher.js";
|
|
2
|
+
import { registerNoteReadCapabilities } from "../../notes/capabilities/read.js";
|
|
3
|
+
import { registerProjectReadCapabilities } from "../../projects/capabilities/read.js";
|
|
4
|
+
import { registerAutomationReadCapabilities } from "../../automations/capabilities/read.js";
|
|
5
|
+
import { Type } from "@sinclair/typebox";
|
|
6
|
+
//#region src/agent/tools/personal-read-tool.ts
|
|
7
|
+
const schema = Type.Object({
|
|
8
|
+
kind: Type.Union([
|
|
9
|
+
Type.Literal("note"),
|
|
10
|
+
Type.Literal("project"),
|
|
11
|
+
Type.Literal("automation")
|
|
12
|
+
]),
|
|
13
|
+
command: Type.Union([Type.Literal("list"), Type.Literal("get")]),
|
|
14
|
+
id: Type.Optional(Type.String()),
|
|
15
|
+
search: Type.Optional(Type.String({ maxLength: 500 })),
|
|
16
|
+
projectId: Type.Optional(Type.String()),
|
|
17
|
+
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
18
|
+
limit: Type.Optional(Type.Integer({
|
|
19
|
+
minimum: 1,
|
|
20
|
+
maximum: 10
|
|
21
|
+
}))
|
|
22
|
+
});
|
|
23
|
+
const fields = [
|
|
24
|
+
"id",
|
|
25
|
+
"name",
|
|
26
|
+
"title",
|
|
27
|
+
"status",
|
|
28
|
+
"kind",
|
|
29
|
+
"projectId",
|
|
30
|
+
"description",
|
|
31
|
+
"markdown",
|
|
32
|
+
"objective",
|
|
33
|
+
"enabled",
|
|
34
|
+
"createdAt",
|
|
35
|
+
"updatedAt",
|
|
36
|
+
"createdAtMs",
|
|
37
|
+
"updatedAtMs",
|
|
38
|
+
"trigger",
|
|
39
|
+
"action",
|
|
40
|
+
"state"
|
|
41
|
+
];
|
|
42
|
+
/** Small projections keep local reads from expanding the next model request. */
|
|
43
|
+
function compact(value, textLimit) {
|
|
44
|
+
if (!value || typeof value !== "object") return {};
|
|
45
|
+
const source = value;
|
|
46
|
+
const result = {};
|
|
47
|
+
const truncatedFields = [];
|
|
48
|
+
for (const key of fields) {
|
|
49
|
+
const entry = source[key];
|
|
50
|
+
if (typeof entry === "string") {
|
|
51
|
+
result[key] = entry.slice(0, textLimit);
|
|
52
|
+
if (entry.length > textLimit) truncatedFields.push(key);
|
|
53
|
+
} else if (typeof entry === "number" || typeof entry === "boolean" || entry === null) result[key] = entry;
|
|
54
|
+
else if (entry && typeof entry === "object" && !Array.isArray(entry)) result[key] = Object.fromEntries(Object.entries(entry).slice(0, 12).filter(([, item]) => [
|
|
55
|
+
"string",
|
|
56
|
+
"number",
|
|
57
|
+
"boolean"
|
|
58
|
+
].includes(typeof item) || item === null).map(([field, item]) => [field, typeof item === "string" ? item.slice(0, 200) : item]));
|
|
59
|
+
}
|
|
60
|
+
if (truncatedFields.length) result.truncatedFields = truncatedFields;
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
function createPersonalReadTool(deps) {
|
|
64
|
+
const dispatcher = new CapabilityDispatcher();
|
|
65
|
+
if (deps.getNotesService) registerNoteReadCapabilities(dispatcher, () => {
|
|
66
|
+
const notes = deps.getNotesService();
|
|
67
|
+
if (!notes) throw new Error("Notes service unavailable");
|
|
68
|
+
return notes;
|
|
69
|
+
});
|
|
70
|
+
const projects = deps.getProjectService?.();
|
|
71
|
+
if (projects) registerProjectReadCapabilities(dispatcher, projects);
|
|
72
|
+
const automations = deps.getAutomationService?.();
|
|
73
|
+
if (automations) registerAutomationReadCapabilities(dispatcher, automations, projects);
|
|
74
|
+
return {
|
|
75
|
+
name: "personal_read",
|
|
76
|
+
label: "Read local objects",
|
|
77
|
+
description: "Read local notes, projects or automation state. Only list/get; bounded excerpts, no network or model calls. Use personal_task for delegated tasks.",
|
|
78
|
+
parameters: schema,
|
|
79
|
+
supportsParallel: true,
|
|
80
|
+
idempotent: true,
|
|
81
|
+
async execute(_id, raw, signal) {
|
|
82
|
+
const input = raw;
|
|
83
|
+
if (![
|
|
84
|
+
"note",
|
|
85
|
+
"project",
|
|
86
|
+
"automation"
|
|
87
|
+
].includes(input.kind) || !["list", "get"].includes(input.command)) throw new Error("Only local note/project/automation list/get is supported");
|
|
88
|
+
if (input.command === "get" && !input.id?.trim()) throw new Error("id is required");
|
|
89
|
+
if (input.kind === "automation" && input.search) throw new Error("Automation search is unsupported; use list");
|
|
90
|
+
const operation = `xopc.${input.kind === "note" ? "notes" : input.kind === "project" ? "projects" : "automations"}.${input.command}`;
|
|
91
|
+
const limit = Math.min(10, Math.max(1, input.limit ?? 5));
|
|
92
|
+
const offset = Math.max(0, input.offset ?? 0);
|
|
93
|
+
const args = input.command === "get" ? { id: input.id } : input.kind === "automation" ? { ...input.projectId ? { projectId: input.projectId } : {} } : {
|
|
94
|
+
limit,
|
|
95
|
+
offset,
|
|
96
|
+
...input.search ? { search: input.search } : {},
|
|
97
|
+
...input.kind === "note" && input.projectId ? { projectId: input.projectId } : {}
|
|
98
|
+
};
|
|
99
|
+
const result = await dispatcher.call(operation, args, {
|
|
100
|
+
principalId: `agent:${deps.getCurrentAgentId?.() ?? "main"}`,
|
|
101
|
+
surface: "agent",
|
|
102
|
+
scopes: ["workspace.read", "automations.read"],
|
|
103
|
+
allowedCapabilities: [operation],
|
|
104
|
+
authorize: deps.authorizeCapability ?? (() => true),
|
|
105
|
+
signal
|
|
106
|
+
});
|
|
107
|
+
let payload;
|
|
108
|
+
if (input.command === "get") payload = {
|
|
109
|
+
kind: input.kind,
|
|
110
|
+
item: compact(result[input.kind], 6e3),
|
|
111
|
+
excerpts: true
|
|
112
|
+
};
|
|
113
|
+
else {
|
|
114
|
+
const rows = result.items ?? [];
|
|
115
|
+
const selected = input.kind === "automation" ? rows.slice(offset, offset + limit) : rows;
|
|
116
|
+
payload = {
|
|
117
|
+
kind: input.kind,
|
|
118
|
+
items: selected.map((row) => compact(row, 200)),
|
|
119
|
+
offset,
|
|
120
|
+
total: result.total ?? rows.length,
|
|
121
|
+
nextOffset: selected.length === limit ? offset + selected.length : void 0,
|
|
122
|
+
excerpts: true
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const serialized = JSON.stringify(payload);
|
|
126
|
+
const requiresSpecialist = input.command === "get" && (serialized.length > 12e3 || Boolean(payload.item?.truncatedFields));
|
|
127
|
+
if (requiresSpecialist) payload = {
|
|
128
|
+
...payload,
|
|
129
|
+
requiresSpecialist: true,
|
|
130
|
+
reason: "large_object",
|
|
131
|
+
id: input.id,
|
|
132
|
+
guidance: "Briefly tell the user the material is large, then delegate full reading and processing using this object kind and ID."
|
|
133
|
+
};
|
|
134
|
+
const output = JSON.stringify(payload);
|
|
135
|
+
return {
|
|
136
|
+
content: [{
|
|
137
|
+
type: "text",
|
|
138
|
+
text: output.length <= 12e3 ? output : JSON.stringify({
|
|
139
|
+
kind: input.kind,
|
|
140
|
+
excerpt: output.slice(0, 1e4),
|
|
141
|
+
truncated: true,
|
|
142
|
+
requiresSpecialist: true,
|
|
143
|
+
id: input.id
|
|
144
|
+
})
|
|
145
|
+
}],
|
|
146
|
+
details: {
|
|
147
|
+
localOnly: true,
|
|
148
|
+
requiresSpecialist: requiresSpecialist || output.length > 12e3
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { createPersonalReadTool };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AgentTool } from '@earendil-works/pi-agent-core';
|
|
2
|
+
declare const Schema: import("@sinclair/typebox").TObject<{
|
|
3
|
+
summary: import("@sinclair/typebox").TString;
|
|
4
|
+
coverage: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
5
|
+
from: import("@sinclair/typebox").TString;
|
|
6
|
+
to: import("@sinclair/typebox").TString;
|
|
7
|
+
scannedCount: import("@sinclair/typebox").TInteger;
|
|
8
|
+
partial: import("@sinclair/typebox").TBoolean;
|
|
9
|
+
}>>;
|
|
10
|
+
items: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
11
|
+
messageId: import("@sinclair/typebox").TString;
|
|
12
|
+
subject: import("@sinclair/typebox").TString;
|
|
13
|
+
sender: import("@sinclair/typebox").TString;
|
|
14
|
+
receivedAt: import("@sinclair/typebox").TString;
|
|
15
|
+
importanceReason: import("@sinclair/typebox").TString;
|
|
16
|
+
suggestedAction: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
17
|
+
openUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
18
|
+
}>>;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function createPersonalRequestResultTool(conversationId: () => string | undefined): AgentTool<typeof Schema>;
|
|
21
|
+
export declare function createPersonalRequestConnectionTool(conversationId: () => string | undefined): AgentTool;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { getSqliteDatabase, init_transaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
+
import { TaskRunRepository, init_task_run_repository } from "../../tasks/task-run-repository.js";
|
|
3
|
+
import { init_request_repository, personalRequestForExecution } from "../../personal-agent/request-repository.js";
|
|
4
|
+
import { PersonalRequestResultSchema } from "../../personal-agent/request-result.js";
|
|
5
|
+
import { Type } from "@sinclair/typebox";
|
|
6
|
+
//#region src/agent/tools/personal-request-result-tool.ts
|
|
7
|
+
init_transaction();
|
|
8
|
+
init_request_repository();
|
|
9
|
+
init_task_run_repository();
|
|
10
|
+
const Schema = Type.Object({
|
|
11
|
+
summary: Type.String({
|
|
12
|
+
minLength: 1,
|
|
13
|
+
maxLength: 8e3
|
|
14
|
+
}),
|
|
15
|
+
coverage: Type.Optional(Type.Object({
|
|
16
|
+
from: Type.String(),
|
|
17
|
+
to: Type.String(),
|
|
18
|
+
scannedCount: Type.Integer({ minimum: 0 }),
|
|
19
|
+
partial: Type.Boolean()
|
|
20
|
+
})),
|
|
21
|
+
items: Type.Array(Type.Object({
|
|
22
|
+
messageId: Type.String(),
|
|
23
|
+
subject: Type.String(),
|
|
24
|
+
sender: Type.String(),
|
|
25
|
+
receivedAt: Type.String(),
|
|
26
|
+
importanceReason: Type.String(),
|
|
27
|
+
suggestedAction: Type.Optional(Type.String()),
|
|
28
|
+
openUrl: Type.Optional(Type.String())
|
|
29
|
+
}), { maxItems: 50 })
|
|
30
|
+
});
|
|
31
|
+
function createPersonalRequestResultTool(conversationId) {
|
|
32
|
+
return {
|
|
33
|
+
name: "personal_request_result",
|
|
34
|
+
label: "Publish connected-app result",
|
|
35
|
+
parameters: Schema,
|
|
36
|
+
description: "Publish the read-only Personal request result to its originating main chat. For mail, include actual message IDs, senders, dates, importance reasons, Gmail or Outlook links, and query coverage. partial must be true when the requested range was not fully searched. Do not invent messages or claim an empty inbox after an incomplete search.",
|
|
37
|
+
async execute(_id, params) {
|
|
38
|
+
const id = conversationId();
|
|
39
|
+
const request = id ? personalRequestForExecution(id) : void 0;
|
|
40
|
+
if (!request || [
|
|
41
|
+
"cancelled",
|
|
42
|
+
"completed",
|
|
43
|
+
"failed"
|
|
44
|
+
].includes(request.state)) throw new Error("No active Personal request");
|
|
45
|
+
const result = PersonalRequestResultSchema.parse(params);
|
|
46
|
+
if (["composio-gmail", "composio-outlook"].includes(request.connectorId) && !result.coverage) throw new Error("Mail results require query coverage, including partial failures");
|
|
47
|
+
if (result.coverage && Date.parse(result.coverage.from) >= Date.parse(result.coverage.to)) throw new Error("Invalid coverage range");
|
|
48
|
+
if (result.coverage && request.parameters.timeRange && (Date.parse(result.coverage.from) > Date.parse(request.parameters.timeRange.from) || Date.parse(result.coverage.to) < Date.parse(request.parameters.timeRange.to))) result.coverage.partial = true;
|
|
49
|
+
const run = request.taskId ? new TaskRunRepository().getActiveRoot(request.taskId) : void 0;
|
|
50
|
+
if (!run || run.conversationId !== id) throw new Error("Task execution changed");
|
|
51
|
+
getSqliteDatabase().prepare("UPDATE personal_requests SET result_json = ?, result_run_id = ?, updated_at = ? WHERE request_id = ?").run(JSON.stringify(result), run.id, Date.now(), request.requestId);
|
|
52
|
+
return {
|
|
53
|
+
content: [{
|
|
54
|
+
type: "text",
|
|
55
|
+
text: "Result saved for delivery to the originating chat after this Task completes."
|
|
56
|
+
}],
|
|
57
|
+
details: {}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function createPersonalRequestConnectionTool(conversationId) {
|
|
63
|
+
return {
|
|
64
|
+
name: "personal_request_connection",
|
|
65
|
+
label: "Restore connected-app access",
|
|
66
|
+
parameters: Type.Object({}),
|
|
67
|
+
description: "If the selected account is disconnected or expired, pause this Personal request and show reconnection in the originating main chat. Do not use this for missing tool schemas or unsupported operations. Stop work after the connection requirement is saved.",
|
|
68
|
+
async execute() {
|
|
69
|
+
const id = conversationId();
|
|
70
|
+
if (!id) throw new Error("No active conversation");
|
|
71
|
+
const { requirePersonalWorkerConnection, publishPersonalRequest } = await import("../../personal-agent/request-service.js");
|
|
72
|
+
publishPersonalRequest(requirePersonalWorkerConnection(id));
|
|
73
|
+
return {
|
|
74
|
+
content: [{
|
|
75
|
+
type: "text",
|
|
76
|
+
text: "Waiting for the selected app account to be reconnected in the main chat. Stop this turn; the Task will resume automatically."
|
|
77
|
+
}],
|
|
78
|
+
details: {}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { createPersonalRequestConnectionTool, createPersonalRequestResultTool };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { getPersonalRequest, init_request_repository, listPersonalRequests } from "../../personal-agent/request-repository.js";
|
|
2
|
+
import { isPersonalConversation } from "../../personal-agent/repository.js";
|
|
3
|
+
import { personalCapabilities } from "../../personal-agent/capability-service.js";
|
|
4
|
+
import { cancelPersonalRequest, personalRequestSnapshot, publishPersonalRequest, submitPersonalRequest } from "../../personal-agent/request-service.js";
|
|
5
|
+
import { Type } from "@sinclair/typebox";
|
|
6
|
+
//#region src/agent/tools/personal-request-tool.ts
|
|
7
|
+
init_request_repository();
|
|
8
|
+
const CapabilitySchema = Type.Object({
|
|
9
|
+
query: Type.String({
|
|
10
|
+
minLength: 1,
|
|
11
|
+
maxLength: 500
|
|
12
|
+
}),
|
|
13
|
+
accountId: Type.Optional(Type.String())
|
|
14
|
+
});
|
|
15
|
+
const RequestSchema = Type.Object({
|
|
16
|
+
command: Type.Union([
|
|
17
|
+
"submit",
|
|
18
|
+
"get",
|
|
19
|
+
"list",
|
|
20
|
+
"cancel"
|
|
21
|
+
].map((command) => Type.Literal(command))),
|
|
22
|
+
requestId: Type.Optional(Type.String()),
|
|
23
|
+
connectorId: Type.Optional(Type.String()),
|
|
24
|
+
agentId: Type.Optional(Type.String()),
|
|
25
|
+
accountId: Type.Optional(Type.String()),
|
|
26
|
+
objective: Type.Optional(Type.String({
|
|
27
|
+
minLength: 1,
|
|
28
|
+
maxLength: 4e3
|
|
29
|
+
})),
|
|
30
|
+
idempotencyKey: Type.Optional(Type.String({
|
|
31
|
+
minLength: 1,
|
|
32
|
+
maxLength: 200
|
|
33
|
+
})),
|
|
34
|
+
timeRange: Type.Optional(Type.Object({
|
|
35
|
+
from: Type.String(),
|
|
36
|
+
to: Type.String(),
|
|
37
|
+
timezone: Type.String(),
|
|
38
|
+
expression: Type.String()
|
|
39
|
+
}))
|
|
40
|
+
});
|
|
41
|
+
function createPersonalRequestTools(deps) {
|
|
42
|
+
const conversation = () => {
|
|
43
|
+
const id = deps.getCurrentConversationId?.();
|
|
44
|
+
if (!id || !isPersonalConversation(id)) throw new Error("Personal conversation is required");
|
|
45
|
+
return id;
|
|
46
|
+
};
|
|
47
|
+
const result = (value) => ({
|
|
48
|
+
content: [{
|
|
49
|
+
type: "text",
|
|
50
|
+
text: JSON.stringify(value)
|
|
51
|
+
}],
|
|
52
|
+
details: {}
|
|
53
|
+
});
|
|
54
|
+
return [{
|
|
55
|
+
name: "personal_capability",
|
|
56
|
+
label: "Connected app availability",
|
|
57
|
+
parameters: CapabilitySchema,
|
|
58
|
+
description: "Check connected-app capabilities, account connection state and specialist Agents locally. For Gmail or other supported apps, check here before delegating. ready is a local preflight; the worker still validates live tools. No remote search or authorization is performed.",
|
|
59
|
+
async execute(_id, input) {
|
|
60
|
+
return result(personalCapabilities(conversation(), input.query, input.accountId));
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
name: "personal_request",
|
|
64
|
+
label: "Connected app request",
|
|
65
|
+
parameters: RequestSchema,
|
|
66
|
+
description: "Submit a read-only connected-app request using exact connectorId and agentId from personal_capability. Preserves the objective, displays connection or account selection in this main chat, and starts a specialist Task automatically once connected. Return quickly after submission. Never claim data was read until the Task result arrives. Resolve absolute query dates and include timeRange. If mail has no user-specified range, the host returns an explicit last-7-days default; mention that range in your confirmation. Use get/list for status, cancel only when the user requests it.",
|
|
67
|
+
async execute(toolCallId, input) {
|
|
68
|
+
const conversationId = conversation();
|
|
69
|
+
if (input.command === "list") return result(listPersonalRequests(conversationId).map(personalRequestSnapshot));
|
|
70
|
+
if (input.command === "submit") {
|
|
71
|
+
if (!input.objective?.trim() || !input.connectorId || !input.agentId) throw new Error("objective, connectorId and agentId are required");
|
|
72
|
+
const request = submitPersonalRequest({
|
|
73
|
+
conversationId,
|
|
74
|
+
connectorId: input.connectorId,
|
|
75
|
+
agentId: input.agentId,
|
|
76
|
+
accountId: input.accountId,
|
|
77
|
+
objective: input.objective.trim(),
|
|
78
|
+
timeRange: input.timeRange,
|
|
79
|
+
idempotencyKey: input.idempotencyKey ?? toolCallId
|
|
80
|
+
});
|
|
81
|
+
publishPersonalRequest(request);
|
|
82
|
+
deps.dispatchTaskRuns?.();
|
|
83
|
+
return result(personalRequestSnapshot(request));
|
|
84
|
+
}
|
|
85
|
+
const request = input.requestId ? getPersonalRequest(input.requestId) : void 0;
|
|
86
|
+
if (!request || request.conversationId !== conversationId) throw new Error("Request does not belong to this conversation");
|
|
87
|
+
if (input.command === "cancel") {
|
|
88
|
+
const cancelled = cancelPersonalRequest(request);
|
|
89
|
+
publishPersonalRequest(cancelled);
|
|
90
|
+
return result({
|
|
91
|
+
...cancelled,
|
|
92
|
+
executionStopConfirmed: false
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return result(personalRequestSnapshot(request));
|
|
96
|
+
}
|
|
97
|
+
}];
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { createPersonalRequestTools };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentTool } from '@earendil-works/pi-agent-core';
|
|
2
|
+
import { type EffectiveAgentConfig } from '../../agent-config/index.js';
|
|
2
3
|
import { type XopcUseToolDeps } from './xopc-use-tool.js';
|
|
3
4
|
declare const PersonalTaskSchema: import("@sinclair/typebox").TObject<{
|
|
4
5
|
command: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"agents">, import("@sinclair/typebox").TLiteral<"create">, import("@sinclair/typebox").TLiteral<"list">, import("@sinclair/typebox").TLiteral<"get">, import("@sinclair/typebox").TLiteral<"instruct">, import("@sinclair/typebox").TLiteral<"answer">]>;
|
|
@@ -15,6 +16,11 @@ declare const PersonalTaskSchema: import("@sinclair/typebox").TObject<{
|
|
|
15
16
|
requiredTools: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
16
17
|
idempotencyKey: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
17
18
|
}>;
|
|
19
|
+
export declare function getAvailablePersonalAgentTools(config: EffectiveAgentConfig, deps: XopcUseToolDeps): string[];
|
|
20
|
+
export declare function personalAgentModelAvailability(config: EffectiveAgentConfig): {
|
|
21
|
+
available: boolean;
|
|
22
|
+
reason?: string;
|
|
23
|
+
};
|
|
18
24
|
export declare function buildPersonalTaskBrief(input: {
|
|
19
25
|
title?: string;
|
|
20
26
|
objective: string;
|