@xopcai/xopc 0.0.196 → 0.0.199
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-BwmdJ5pv.js → activity-store-DYVN1hRp.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B1oxPli_.js → agent-avatar-dicebear-Bt70bZjv.js} +1 -1
- package/dist/gateway/static/root/assets/agents-D19uNmJf.js +68 -0
- package/dist/gateway/static/root/assets/{api-BM1hNzjw.js → api-B8mzbAle.js} +1 -1
- package/dist/gateway/static/root/assets/app-management-settings-panel-B4x7JfL8.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-Dwdagf-Q.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-DkTiesxe.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BdE4Mati.js → archive-plugin-Cv0VXKLm.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CTzaQcLV.js → attachment-load-CgidKrXn.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-BR6qMOVr.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-B25zTNxl.js → binary-plugins-DN3CQgIq.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Cdrf2awF.js → block-editor-BwkSl1F_.js} +46 -46
- package/dist/gateway/static/root/assets/browser-settings-page-CDFQWAxI.js +8 -0
- package/dist/gateway/static/root/assets/browser-workflow-inputs-_ndaecsf.js +1 -0
- package/dist/gateway/static/root/assets/{browser-workflows-page-Wx9FrbK-.js → browser-workflows-page-C_I31wLm.js} +2 -2
- package/dist/gateway/static/root/assets/button-CSEbl4zT.js +1 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D41mssOq.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BoOzFotX.js → capability-presets-api-Dy1jZJKs.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-BXgCyuu2.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-_8IiTxRB.js → channel-recipient-api-D-9qiuio.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-DV5BhAeu.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-B4Rbh3bM.js +1 -0
- package/dist/gateway/static/root/assets/connectors-api-5FEBYguL.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-C_qkEN0T.js +2 -0
- package/dist/gateway/static/root/assets/copy-Dv6d4Dvw.js +1 -0
- package/dist/gateway/static/root/assets/cron-expression-SEFx5rnr.js +2 -0
- package/dist/gateway/static/root/assets/date-picker-D4zCUQJL.js +1 -0
- package/dist/gateway/static/root/assets/dependency-picker-DpQAxS2k.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-BOb8sEhN.js → desktop-pet-B_5G3lQl.js} +1 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-ClEyoUJe.js +1 -0
- package/dist/gateway/static/root/assets/directory-picker-path-field-AsFWmOjG.js +1 -0
- package/dist/gateway/static/root/assets/dist-BPoKqzeH.js +1 -0
- package/dist/gateway/static/root/assets/dist-DY4Af0fY.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-p83TmZFd.js → extension-debug-page-C22Y2o5l.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DMQ3ovxA.js → extension-page-C61Ikawk.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-WlWWcDFr.js +1 -0
- package/dist/gateway/static/root/assets/external-link-DjqjBmc3.js +1 -0
- package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-ByIOMQdc.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-swr-jB0hAhWO.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-CzzS9A17.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry--2njcDpC.js → gateway-startup-retry-C-fRlHCL.js} +1 -1
- package/dist/gateway/static/root/assets/globe-DSSGFWFn.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-B4A_CXUL.js +1 -0
- package/dist/gateway/static/root/assets/home-page-FVGYYPWo.js +3 -0
- package/dist/gateway/static/root/assets/index-CGbKTCST.js +152 -0
- package/dist/gateway/static/root/assets/index-CR233S0Q.css +1 -0
- package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BQb06_jl.js → keyboard-shortcuts-settings-BD_TFz0_.js} +1 -1
- package/dist/gateway/static/root/assets/loader-circle-CifKLtgG.js +1 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-BNpkigNb.js +2 -0
- package/dist/gateway/static/root/assets/local-apps-page-BwbUeLfm.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-Bjvw7jtg.js → locale-store-xULEcFVs.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DXP9OQQt.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-CW2VpqtT.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-split-Db-KrpOQ.js → markdown-split-B1M9KO16.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CHN66qs0.js → media-plugins-B_QlNdqZ.js} +1 -1
- package/dist/gateway/static/root/assets/messages-3qRsLZuX.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-CJtKZM0P.js → notes-page-BTbD4GmH.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-JRiq7QDW.js +4 -0
- package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +1 -0
- package/dist/gateway/static/root/assets/popover-select-BzdnTy3h.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-CeqtArlZ.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page--RnCc9bb.js → product-open-page-DnalBZZs.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CjWA13aE.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-jsCkScbG.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CGPJTEkM.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bg1W2__k.js → runtime-tools-settings-panel-cGkBEfg4.js} +4 -4
- package/dist/gateway/static/root/assets/schema-form-CmsrLlxu.js +1 -0
- package/dist/gateway/static/root/assets/sessions-page-BBHzziMd.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-2cGg8-9h.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-draft-Dy10ldo8.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-DUWCbaMJ.js +1 -0
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BS36Mjzz.js → settings-loading-skeleton-Bvy5rdMY.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BDSd7F9Y.js → settings-page-cZSAwsRR.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-layout-BRQNel6r.js +1 -0
- package/dist/gateway/static/root/assets/settings-shell-dialog-layer-BU3UuiJr.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-Cf06b66-.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-BzA2NCAH.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-xlNKydYY.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-C5Xu93c_.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Bvde7_i5.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-CnbJncdL.js → skills-page.utils-vXSqHR7g.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-9cQGOGCK.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-Bkno4tTe.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-DtxpMC5S.js → theme-store-CHQRiuCF.js} +1 -1
- package/dist/gateway/static/root/assets/tool-activity-R8V9l6nk.js +1 -0
- package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +1 -0
- package/dist/gateway/static/root/assets/use-autosave-7XfKULPI.js +1 -0
- package/dist/gateway/static/root/assets/user-context-page-CZ9m9aC_.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-DXr21v-3.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-overlay-CeG7g_DZ.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-CQWZD03N.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BEmugHfL.js → workflow-run-setup-panel-DSQQZP9T.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Cs-MXFJ1.js +5 -0
- package/dist/gateway/static/root/assets/working-directory-picker-modal-D-IgcHPp.js +1 -0
- package/dist/gateway/static/root/index.html +23 -8
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/tasks.js +54 -2
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/embedded/execution-context.d.ts +2 -0
- package/dist/src/agent/embedded/execution-context.js +11 -0
- package/dist/src/agent/embedded/index.d.ts +3 -1
- package/dist/src/agent/embedded/index.js +5 -3
- package/dist/src/agent/embedded/run-turn.js +15 -9
- package/dist/src/agent/embedded/session-runner.d.ts +6 -11
- package/dist/src/agent/embedded/session-runner.js +25 -36
- package/dist/src/agent/embedded/transcript-runtime.d.ts +35 -0
- package/dist/src/agent/embedded/transcript-runtime.js +66 -0
- package/dist/src/agent/embedded/types.d.ts +3 -1
- package/dist/src/agent/service.d.ts +15 -0
- package/dist/src/agent/service.js +31 -0
- package/dist/src/agent/service.types.d.ts +1 -0
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +2 -1
- package/dist/src/agent/tools/xopc-use-tool.d.ts +1 -0
- package/dist/src/agent/tools/xopc-use-tool.js +56 -6
- package/dist/src/automations/domain/validation.d.ts +40 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +4 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/rules.js +2 -2
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/app.d.ts +2 -0
- package/dist/src/gateway/hono/app.js +10 -3
- package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +4 -0
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +8 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -1
- package/dist/src/gateway/hono/routes/config.js +9 -0
- package/dist/src/gateway/hono/routes/deps.d.ts +1 -0
- package/dist/src/gateway/hono/routes/home.d.ts +1 -1
- package/dist/src/gateway/hono/routes/home.js +2 -2
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/projects.js +67 -1
- package/dist/src/gateway/hono/routes/side-chats.d.ts +3 -0
- package/dist/src/gateway/hono/routes/side-chats.js +173 -0
- package/dist/src/gateway/hono/routes/tasks.js +112 -19
- package/dist/src/gateway/host.d.ts +9 -1
- package/dist/src/gateway/host.js +22 -5
- package/dist/src/gateway/rate-limit/buckets.d.ts +3 -0
- package/dist/src/gateway/rate-limit/buckets.js +12 -0
- package/dist/src/gateway/runtime-config.js +6 -5
- package/dist/src/gateway/security/audit.js +0 -7
- package/dist/src/gateway/server.js +4 -1
- package/dist/src/gateway/service/agent-runner.d.ts +4 -0
- package/dist/src/gateway/service/agent-runner.js +15 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service.d.ts +5 -0
- package/dist/src/gateway/service.js +38 -8
- package/dist/src/gateway/side-chat/context-snapshot.d.ts +11 -0
- package/dist/src/gateway/side-chat/context-snapshot.js +108 -0
- package/dist/src/gateway/side-chat/index.d.ts +5 -0
- package/dist/src/gateway/side-chat/index.js +4 -0
- package/dist/src/gateway/side-chat/manager.d.ts +45 -0
- package/dist/src/gateway/side-chat/manager.js +198 -0
- package/dist/src/gateway/side-chat/run-service.d.ts +22 -0
- package/dist/src/gateway/side-chat/run-service.js +110 -0
- package/dist/src/gateway/side-chat/types.d.ts +61 -0
- package/dist/src/gateway/side-chat/types.js +1 -0
- package/dist/src/proactive/actions/service.d.ts +2 -0
- package/dist/src/proactive/actions/service.js +80 -0
- package/dist/src/proactive/execution/insight.js +20 -0
- package/dist/src/proactive/execution/repository.js +8 -2
- package/dist/src/proactive/execution/types.d.ts +14 -0
- package/dist/src/proactive/inbox/repository.js +59 -9
- package/dist/src/proactive/inbox/service.d.ts +2 -2
- package/dist/src/proactive/inbox/service.js +7 -2
- package/dist/src/proactive/inbox/types.d.ts +14 -0
- package/dist/src/proactive/inbox/worker.js +2 -0
- package/dist/src/proactive/scenarios/prompt-composer.js +2 -2
- package/dist/src/routing/session-key-utils.d.ts +0 -1
- package/dist/src/routing/session-key-utils.js +1 -6
- package/dist/src/routing/session-key.js +2 -2
- package/dist/src/storage/sqlite/migrations/118_task_board_rank.sql +6 -0
- package/dist/src/storage/sqlite/migrations/119_proactive_disposition.sql +13 -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/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/home-query-service.d.ts +29 -0
- package/dist/src/tasks/home-query-service.js +291 -7
- package/dist/src/tasks/index.d.ts +1 -0
- package/dist/src/tasks/index.js +5 -4
- package/dist/src/tasks/project-monitoring-service.d.ts +9 -0
- package/dist/src/tasks/project-monitoring-service.js +41 -3
- package/dist/src/tasks/project-operating-view-service.d.ts +2 -2
- package/dist/src/tasks/project-operating-view-service.js +47 -21
- package/dist/src/tasks/task-application-service.js +99 -6
- package/dist/src/tasks/task-change-events.d.ts +13 -0
- package/dist/src/tasks/task-change-events.js +29 -0
- package/dist/src/tasks/task-read-model-projector.js +2 -1
- package/dist/src/tasks/task-repository.d.ts +7 -0
- package/dist/src/tasks/task-repository.js +29 -6
- package/dist/src/tunnel/enable-lan-pairing.js +15 -26
- package/dist/src/tunnel/pair-context.js +1 -1
- package/dist/src/tunnel/pair-url.js +1 -1
- package/dist/src/tunnel/tunnel-qr.d.ts +0 -7
- package/dist/src/tunnel/tunnel-qr.js +2 -19
- package/package.json +4 -2
- package/dist/gateway/static/root/assets/agents-VoFNMGL3.js +0 -68
- package/dist/gateway/static/root/assets/app-management-settings-panel-vmuJ_Z6i.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-BMlEoe-G.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-CsNB6mv_.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-CW1YWgiX.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BMTmGMM6.js +0 -8
- package/dist/gateway/static/root/assets/browser-workflow-inputs-BsmHy0ks.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C5l85__e.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-9T2KXAs1.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-DquD4BPQ.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DPaJSYX_.js +0 -1
- package/dist/gateway/static/root/assets/connectors-api-BC-4ftOM.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-7zUxVHQg.js +0 -2
- package/dist/gateway/static/root/assets/cron-expression-BycQlU8Q.js +0 -2
- package/dist/gateway/static/root/assets/dependency-picker-BvYqHRz0.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-DStgPb82.js +0 -1
- package/dist/gateway/static/root/assets/directory-picker-path-field-DUUr9sq0.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BcSKEU8s.js +0 -1
- package/dist/gateway/static/root/assets/gateway-config-api-C-MmtCc7.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CuaRDWbg.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-Dm8TrfGa.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BYhDbUvI.js +0 -3
- package/dist/gateway/static/root/assets/index-BzPwnXho.js +0 -150
- package/dist/gateway/static/root/assets/index-CFFYvilx.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CHk4x0kR.js +0 -2
- package/dist/gateway/static/root/assets/local-apps-page-DQtsxjGs.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CDqIY72S.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-D7itDEHl.js +0 -1
- package/dist/gateway/static/root/assets/messages-DQ5X6cXp.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-epHGeKd5.js +0 -4
- package/dist/gateway/static/root/assets/page-tabs-HXweXqYE.js +0 -1
- package/dist/gateway/static/root/assets/preview-open-alternatives-Dob6Oe2l.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-BxOD5-zj.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-D-9AhrH5.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CSUNXLKM.js +0 -1
- package/dist/gateway/static/root/assets/schema-form-BI4rVt3u.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BxOUBMca.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DAvTIbgw.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-C7rzhi7x.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-layout-CTMmZcwj.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-D1v-2Ci-.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-BeCxg6eb.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-CXL1EldF.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BxwkKgVw.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CyfjEM4D.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-CAv0Yk0Y.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DGTVJs_N.js +0 -1
- package/dist/gateway/static/root/assets/typed-models-lib-DomX3Szl.js +0 -1
- package/dist/gateway/static/root/assets/use-autosave-BLc4gfG0.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-C2kQENTK.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-BijmpPjb.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-D7w2JFFq.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-XtoPgPUS.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-D_K2xOWq.js +0 -5
- package/dist/src/gateway/ensure-network-cors.d.ts +0 -3
- package/dist/src/gateway/ensure-network-cors.js +0 -23
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS, resolveLiveToolResultMaxChars, truncateToolResultMessage } from "./tool-result-truncation.js";
|
|
2
2
|
import { getRawSessionAppendMessage, guardSessionManager, installSessionToolResultGuard } from "./session-tool-result-guard.js";
|
|
3
|
+
import { acquireEmbeddedSessionRunner, buildEmbeddedRunnerFingerprint, evictAllEmbeddedSessionRunners, evictEmbeddedSessionRunner, getEmbeddedSessionRunnerIdleTtlMs, getEmbeddedSessionRunnerStats, isEmbeddedSessionRunnerEnabled, resetEmbeddedSessionRunnerForTest } from "./session-runner.js";
|
|
4
|
+
import { abortEmbeddedRun, getEmbeddedRunBySessionKey, queueEmbeddedSteer, registerEmbeddedRun } from "./runs.js";
|
|
3
5
|
import { repairAssistantUsageInSessionManager } from "./session-manager-init.js";
|
|
4
6
|
import { openSqliteHydratingSessionManager } from "./sqlite-hydrating-session-manager.js";
|
|
5
|
-
import {
|
|
6
|
-
import { abortEmbeddedRun, getEmbeddedRunBySessionKey, queueEmbeddedSteer, registerEmbeddedRun } from "./runs.js";
|
|
7
|
+
import { InMemoryTranscriptRuntime, createSqliteTranscriptRuntime } from "./transcript-runtime.js";
|
|
7
8
|
import { runXopcEmbeddedTurn } from "./run-turn.js";
|
|
9
|
+
import { getEmbeddedExecutionSession, runWithEmbeddedExecutionSession } from "./execution-context.js";
|
|
8
10
|
import { runEmbeddedTurnForSession } from "./run-for-session.js";
|
|
9
11
|
import { CURRENT_SESSION_VERSION, PiTranscriptManager } from "./pi-transcript.js";
|
|
10
|
-
export { CURRENT_SESSION_VERSION, DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS, PiTranscriptManager, abortEmbeddedRun, acquireEmbeddedSessionRunner, buildEmbeddedRunnerFingerprint, evictAllEmbeddedSessionRunners, evictEmbeddedSessionRunner, getEmbeddedRunBySessionKey, getEmbeddedSessionRunnerIdleTtlMs, getEmbeddedSessionRunnerStats, getRawSessionAppendMessage, guardSessionManager, installSessionToolResultGuard, isEmbeddedSessionRunnerEnabled, openSqliteHydratingSessionManager, queueEmbeddedSteer, registerEmbeddedRun, repairAssistantUsageInSessionManager, resetEmbeddedSessionRunnerForTest,
|
|
12
|
+
export { CURRENT_SESSION_VERSION, DEFAULT_MAX_LIVE_TOOL_RESULT_CHARS, InMemoryTranscriptRuntime, PiTranscriptManager, abortEmbeddedRun, acquireEmbeddedSessionRunner, buildEmbeddedRunnerFingerprint, createSqliteTranscriptRuntime, evictAllEmbeddedSessionRunners, evictEmbeddedSessionRunner, getEmbeddedExecutionSession, getEmbeddedRunBySessionKey, getEmbeddedSessionRunnerIdleTtlMs, getEmbeddedSessionRunnerStats, getRawSessionAppendMessage, guardSessionManager, installSessionToolResultGuard, isEmbeddedSessionRunnerEnabled, openSqliteHydratingSessionManager, queueEmbeddedSteer, registerEmbeddedRun, repairAssistantUsageInSessionManager, resetEmbeddedSessionRunnerForTest, resolveLiveToolResultMaxChars, runEmbeddedTurnForSession, runWithEmbeddedExecutionSession, runXopcEmbeddedTurn, truncateToolResultMessage };
|
|
@@ -2,13 +2,14 @@ import { createLogger } from "../../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { resolveAgentTurnTimeoutMs, runAgentTurnWithTimeout } from "../orchestration/run-agent-turn-with-timeout.js";
|
|
4
4
|
import { wrapStreamFnForXopcExtensions } from "./xopc-stream-bridge.js";
|
|
5
|
-
import { acquireEmbeddedSessionRunner
|
|
5
|
+
import { acquireEmbeddedSessionRunner } from "./session-runner.js";
|
|
6
6
|
import { getAssistantTurnErrorMessage, isAssistantTurnAborted, isAssistantTurnFailed, maybeRetryTurnAfterTransientLlmFailure, stripTrailingErrorAssistantMessages } from "../orchestration/llm-turn-retry.js";
|
|
7
7
|
import { pruneToolResultsToFit } from "../memory/context-budget.js";
|
|
8
8
|
import { abortEmbeddedRun, queueEmbeddedSteer, registerEmbeddedRun, unregisterEmbeddedRun } from "./runs.js";
|
|
9
9
|
import { lastAssistantPlainText, subscribeEmbeddedSessionEvents } from "./subscribe-session.js";
|
|
10
10
|
import { detectToolLoops } from "../orchestration/loop-guard.js";
|
|
11
11
|
import { tryApplySessionTranscriptHygiene } from "../transcript/transcript-hygiene.js";
|
|
12
|
+
import { createSqliteTranscriptRuntime } from "./transcript-runtime.js";
|
|
12
13
|
import { isContextOverflowError } from "../orchestration/context-overflow.js";
|
|
13
14
|
//#region src/agent/embedded/run-turn.ts
|
|
14
15
|
init_logger();
|
|
@@ -79,9 +80,9 @@ async function maybeRecoverContextOverflow(params) {
|
|
|
79
80
|
type: "compaction",
|
|
80
81
|
status: "started"
|
|
81
82
|
});
|
|
82
|
-
const result = await params.
|
|
83
|
+
const result = await params.transcriptRuntime.compact(messages, params.model, "Preserve the current pending user request verbatim and retain every fact needed to answer it.", true);
|
|
83
84
|
if (!result.compacted) throw new Error(`Context overflow recovery could not find a safe compaction range: ${errorMessage}`);
|
|
84
|
-
params.agent.state.messages = await params.
|
|
85
|
+
params.agent.state.messages = await params.transcriptRuntime.loadMessages();
|
|
85
86
|
params.onEvent?.({
|
|
86
87
|
type: "compaction",
|
|
87
88
|
status: "completed",
|
|
@@ -97,19 +98,24 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
97
98
|
const { sessionKey, runId, userMessage, model, tools, systemPrompt, thinkingLevel, workspaceDir, sessionStore, onEvent } = params;
|
|
98
99
|
const timeoutMs = params.timeoutMs || resolveAgentTurnTimeoutMs();
|
|
99
100
|
const resolvedModel = requireEmbeddedModel(model, params.modelRef);
|
|
100
|
-
const
|
|
101
|
+
const transcriptRuntime = params.transcriptRuntime ?? (sessionStore ? await createSqliteTranscriptRuntime({
|
|
102
|
+
sessionKey,
|
|
103
|
+
sessionStore
|
|
104
|
+
}) : void 0);
|
|
105
|
+
if (!transcriptRuntime) throw new Error("Embedded run requires a transcript runtime");
|
|
101
106
|
let runner;
|
|
102
107
|
let unsubscribe;
|
|
103
108
|
try {
|
|
104
109
|
runner = await acquireEmbeddedSessionRunner({
|
|
105
|
-
|
|
106
|
-
sessionId:
|
|
110
|
+
runtimeId: transcriptRuntime.runtimeId,
|
|
111
|
+
sessionId: transcriptRuntime.sessionId,
|
|
107
112
|
workspaceDir,
|
|
108
113
|
model: resolvedModel,
|
|
109
114
|
modelRef: params.modelRef,
|
|
110
115
|
tools,
|
|
111
116
|
systemPrompt,
|
|
112
|
-
thinkingLevel: thinkingLevel ?? "medium"
|
|
117
|
+
thinkingLevel: thinkingLevel ?? "medium",
|
|
118
|
+
transcriptRuntime
|
|
113
119
|
});
|
|
114
120
|
const { session, reused } = runner;
|
|
115
121
|
runner.piSm.setActiveTurnId?.(runId);
|
|
@@ -187,7 +193,7 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
187
193
|
});
|
|
188
194
|
const handle = {
|
|
189
195
|
sessionKey,
|
|
190
|
-
sessionId:
|
|
196
|
+
sessionId: transcriptRuntime.sessionId,
|
|
191
197
|
runId,
|
|
192
198
|
session,
|
|
193
199
|
abort: async () => {
|
|
@@ -225,7 +231,7 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
225
231
|
agent: session.agent,
|
|
226
232
|
model: resolvedModel,
|
|
227
233
|
sessionKey,
|
|
228
|
-
|
|
234
|
+
transcriptRuntime,
|
|
229
235
|
onEvent
|
|
230
236
|
});
|
|
231
237
|
}, timeoutMs);
|
|
@@ -3,6 +3,7 @@ import type { ThinkingLevel } from '@earendil-works/pi-agent-core';
|
|
|
3
3
|
import { type AgentSession } from '@earendil-works/pi-coding-agent';
|
|
4
4
|
import type { Model, Api } from '@earendil-works/pi-ai';
|
|
5
5
|
import { type GuardedPiTranscriptManager } from './session-tool-result-guard.js';
|
|
6
|
+
import type { EmbeddedTranscriptRuntime } from './transcript-runtime.js';
|
|
6
7
|
export type EmbeddedRunnerFingerprintInput = {
|
|
7
8
|
sessionId: string;
|
|
8
9
|
workspaceDir: string;
|
|
@@ -14,7 +15,7 @@ export type EmbeddedRunnerFingerprintInput = {
|
|
|
14
15
|
};
|
|
15
16
|
export declare function buildEmbeddedRunnerFingerprint(input: EmbeddedRunnerFingerprintInput): string;
|
|
16
17
|
export type AcquireEmbeddedSessionRunnerParams = {
|
|
17
|
-
|
|
18
|
+
runtimeId: string;
|
|
18
19
|
sessionId: string;
|
|
19
20
|
workspaceDir: string;
|
|
20
21
|
model: Model<Api>;
|
|
@@ -22,6 +23,7 @@ export type AcquireEmbeddedSessionRunnerParams = {
|
|
|
22
23
|
tools: AgentTool[];
|
|
23
24
|
systemPrompt: string;
|
|
24
25
|
thinkingLevel: ThinkingLevel;
|
|
26
|
+
transcriptRuntime: EmbeddedTranscriptRuntime;
|
|
25
27
|
};
|
|
26
28
|
export type AcquiredEmbeddedSessionRunner = {
|
|
27
29
|
session: AgentSession;
|
|
@@ -45,9 +47,7 @@ export interface EmbeddedSessionRunnerPoolOptions {
|
|
|
45
47
|
getIdleTtlMs?: () => number;
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
48
|
-
* Owns the per-
|
|
49
|
-
* injectable owner; {@link defaultEmbeddedSessionRunnerPool} keeps the historic
|
|
50
|
-
* module-level free functions working until every caller is migrated to DI.
|
|
50
|
+
* Owns the per-runtime pool of pi `AgentSession` runners.
|
|
51
51
|
*/
|
|
52
52
|
export declare class EmbeddedSessionRunnerPool {
|
|
53
53
|
private readonly pool;
|
|
@@ -57,7 +57,7 @@ export declare class EmbeddedSessionRunnerPool {
|
|
|
57
57
|
constructor(opts?: EmbeddedSessionRunnerPoolOptions);
|
|
58
58
|
getStats(): Readonly<EmbeddedSessionRunnerPoolStats>;
|
|
59
59
|
resetForTest(): void;
|
|
60
|
-
evict(
|
|
60
|
+
evict(runtimeId: string, reason?: string): void;
|
|
61
61
|
evictAll(reason?: string): void;
|
|
62
62
|
acquire(params: AcquireEmbeddedSessionRunnerParams): Promise<AcquiredEmbeddedSessionRunner>;
|
|
63
63
|
private clearIdleTimer;
|
|
@@ -68,11 +68,6 @@ export declare class EmbeddedSessionRunnerPool {
|
|
|
68
68
|
export declare const defaultEmbeddedSessionRunnerPool: EmbeddedSessionRunnerPool;
|
|
69
69
|
export declare function getEmbeddedSessionRunnerStats(): Readonly<EmbeddedSessionRunnerPoolStats>;
|
|
70
70
|
export declare function resetEmbeddedSessionRunnerForTest(): void;
|
|
71
|
-
export declare function evictEmbeddedSessionRunner(
|
|
71
|
+
export declare function evictEmbeddedSessionRunner(runtimeId: string, reason?: string): void;
|
|
72
72
|
export declare function evictAllEmbeddedSessionRunners(reason?: string): void;
|
|
73
73
|
export declare function acquireEmbeddedSessionRunner(params: AcquireEmbeddedSessionRunnerParams): Promise<AcquiredEmbeddedSessionRunner>;
|
|
74
|
-
/** Resolve session identity used by embedded runner acquire and turn execution. */
|
|
75
|
-
export declare function resolveEmbeddedTranscriptInputs(sessionStore: import('../../session/store.js').SessionStore, sessionKey: string): Promise<{
|
|
76
|
-
sessionId: string;
|
|
77
|
-
sessionKey: string;
|
|
78
|
-
}>;
|
|
@@ -2,7 +2,6 @@ import { createLogger } from "../../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { guardSessionManager } from "./session-tool-result-guard.js";
|
|
4
4
|
import { transformUserMessageForPersistence } from "../inbound/attachment-pipeline.js";
|
|
5
|
-
import { openSqliteHydratingSessionManager } from "./sqlite-hydrating-session-manager.js";
|
|
6
5
|
import { createEmbeddedModelRuntime, resolveEmbeddedProviderApiKeySync } from "./model-runtime.js";
|
|
7
6
|
import { wrapStreamFnForXopcExtensions } from "./xopc-stream-bridge.js";
|
|
8
7
|
import { xopcToolsToDefinitions } from "./xopc-tools-bridge.js";
|
|
@@ -46,9 +45,7 @@ function createEmbeddedSettingsManager(cwd) {
|
|
|
46
45
|
return sm;
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
|
-
* Owns the per-
|
|
50
|
-
* injectable owner; {@link defaultEmbeddedSessionRunnerPool} keeps the historic
|
|
51
|
-
* module-level free functions working until every caller is migrated to DI.
|
|
48
|
+
* Owns the per-runtime pool of pi `AgentSession` runners.
|
|
52
49
|
*/
|
|
53
50
|
var EmbeddedSessionRunnerPool = class {
|
|
54
51
|
pool = /* @__PURE__ */ new Map();
|
|
@@ -80,13 +77,13 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
80
77
|
evictions: 0
|
|
81
78
|
};
|
|
82
79
|
}
|
|
83
|
-
evict(
|
|
84
|
-
const entry = this.pool.get(
|
|
80
|
+
evict(runtimeId, reason = "explicit") {
|
|
81
|
+
const entry = this.pool.get(runtimeId);
|
|
85
82
|
if (!entry) return;
|
|
86
|
-
this.disposePooledRunner(
|
|
83
|
+
this.disposePooledRunner(runtimeId, entry, reason);
|
|
87
84
|
}
|
|
88
85
|
evictAll(reason = "dispose_all") {
|
|
89
|
-
for (const
|
|
86
|
+
for (const runtimeId of [...this.pool.keys()]) this.evict(runtimeId, reason);
|
|
90
87
|
}
|
|
91
88
|
async acquire(params) {
|
|
92
89
|
this.stats.acquires += 1;
|
|
@@ -100,7 +97,7 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
100
97
|
credentialRevision: providerCredentialRevision(params.model.provider)
|
|
101
98
|
});
|
|
102
99
|
const reuseEnabled = this.isEnabledFn();
|
|
103
|
-
const existing = this.pool.get(params.
|
|
100
|
+
const existing = this.pool.get(params.runtimeId);
|
|
104
101
|
let entry;
|
|
105
102
|
let reused = false;
|
|
106
103
|
if (reuseEnabled && existing && existing.fingerprint === fingerprint) {
|
|
@@ -111,13 +108,13 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
111
108
|
this.stats.reuses += 1;
|
|
112
109
|
applySystemPromptOverrideToSession(entry.session, params.systemPrompt);
|
|
113
110
|
entry.session.agent.streamFunction = entry.baseStreamFn;
|
|
114
|
-
log.debug({
|
|
111
|
+
log.debug({ runtimeId: params.runtimeId }, "Reusing pooled embedded session runner");
|
|
115
112
|
} else {
|
|
116
|
-
if (existing) this.disposePooledRunner(params.
|
|
113
|
+
if (existing) this.disposePooledRunner(params.runtimeId, existing, "fingerprint_mismatch");
|
|
117
114
|
entry = await this.createPooledRunner(params);
|
|
118
|
-
this.pool.set(params.
|
|
115
|
+
this.pool.set(params.runtimeId, entry);
|
|
119
116
|
this.stats.creates += 1;
|
|
120
|
-
log.debug({
|
|
117
|
+
log.debug({ runtimeId: params.runtimeId }, "Created embedded session runner");
|
|
121
118
|
}
|
|
122
119
|
return {
|
|
123
120
|
session: entry.session,
|
|
@@ -125,11 +122,11 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
125
122
|
reused,
|
|
126
123
|
release: () => {
|
|
127
124
|
if (!this.isEnabledFn()) {
|
|
128
|
-
this.disposePooledRunner(params.
|
|
125
|
+
this.disposePooledRunner(params.runtimeId, entry, "runner_disabled");
|
|
129
126
|
return;
|
|
130
127
|
}
|
|
131
128
|
entry.lastUsedAt = Date.now();
|
|
132
|
-
this.scheduleIdleEviction(params.
|
|
129
|
+
this.scheduleIdleEviction(params.runtimeId, entry);
|
|
133
130
|
}
|
|
134
131
|
};
|
|
135
132
|
}
|
|
@@ -139,37 +136,33 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
139
136
|
entry.idleTimer = null;
|
|
140
137
|
}
|
|
141
138
|
}
|
|
142
|
-
scheduleIdleEviction(
|
|
139
|
+
scheduleIdleEviction(runtimeId, entry) {
|
|
143
140
|
this.clearIdleTimer(entry);
|
|
144
141
|
const ttlMs = this.getIdleTtlMsFn();
|
|
145
142
|
entry.idleTimer = setTimeout(() => {
|
|
146
|
-
if (this.pool.get(
|
|
143
|
+
if (this.pool.get(runtimeId) === entry) this.disposePooledRunner(runtimeId, entry, "idle_ttl");
|
|
147
144
|
}, ttlMs);
|
|
148
145
|
entry.idleTimer.unref?.();
|
|
149
146
|
}
|
|
150
|
-
disposePooledRunner(
|
|
147
|
+
disposePooledRunner(runtimeId, entry, reason) {
|
|
151
148
|
this.clearIdleTimer(entry);
|
|
152
|
-
this.pool.delete(
|
|
149
|
+
this.pool.delete(runtimeId);
|
|
153
150
|
this.stats.evictions += 1;
|
|
154
151
|
try {
|
|
155
152
|
entry.piSm.flushPendingToolResults?.();
|
|
156
153
|
} catch {}
|
|
157
154
|
log.debug({
|
|
158
|
-
|
|
155
|
+
runtimeId,
|
|
159
156
|
reason
|
|
160
157
|
}, "Embedded session runner evicted");
|
|
161
158
|
}
|
|
162
159
|
async createPooledRunner(params) {
|
|
163
|
-
const {
|
|
160
|
+
const { runtimeId, sessionId, workspaceDir, model, thinkingLevel, tools, systemPrompt } = params;
|
|
164
161
|
const settingsManager = createEmbeddedSettingsManager(workspaceDir);
|
|
165
|
-
const piSm = guardSessionManager(
|
|
166
|
-
sessionKey,
|
|
167
|
-
sessionId,
|
|
168
|
-
cwd: workspaceDir
|
|
169
|
-
}), {
|
|
170
|
-
sessionKey,
|
|
162
|
+
const piSm = guardSessionManager(params.transcriptRuntime.openSessionManager(workspaceDir), {
|
|
163
|
+
sessionKey: params.transcriptRuntime.persistent ? runtimeId : void 0,
|
|
171
164
|
contextWindowTokens: model.contextWindow ?? 128e3,
|
|
172
|
-
transformMessageForPersistence: (message) => transformUserMessageForPersistence(
|
|
165
|
+
transformMessageForPersistence: params.transcriptRuntime.persistent ? (message) => transformUserMessageForPersistence(runtimeId, message) : void 0
|
|
173
166
|
});
|
|
174
167
|
const toolDefs = xopcToolsToDefinitions(tools);
|
|
175
168
|
const toolNames = tools.map((t) => t.name);
|
|
@@ -197,7 +190,7 @@ var EmbeddedSessionRunnerPool = class {
|
|
|
197
190
|
const baseStreamFn = wrapStreamFnForXopcExtensions(session.agent.streamFunction);
|
|
198
191
|
session.agent.streamFunction = baseStreamFn;
|
|
199
192
|
return {
|
|
200
|
-
|
|
193
|
+
runtimeId,
|
|
201
194
|
fingerprint: buildEmbeddedRunnerFingerprint({
|
|
202
195
|
sessionId,
|
|
203
196
|
workspaceDir,
|
|
@@ -223,8 +216,8 @@ function getEmbeddedSessionRunnerStats() {
|
|
|
223
216
|
function resetEmbeddedSessionRunnerForTest() {
|
|
224
217
|
defaultEmbeddedSessionRunnerPool.resetForTest();
|
|
225
218
|
}
|
|
226
|
-
function evictEmbeddedSessionRunner(
|
|
227
|
-
defaultEmbeddedSessionRunnerPool.evict(
|
|
219
|
+
function evictEmbeddedSessionRunner(runtimeId, reason = "explicit") {
|
|
220
|
+
defaultEmbeddedSessionRunnerPool.evict(runtimeId, reason);
|
|
228
221
|
}
|
|
229
222
|
function evictAllEmbeddedSessionRunners(reason = "dispose_all") {
|
|
230
223
|
defaultEmbeddedSessionRunnerPool.evictAll(reason);
|
|
@@ -232,9 +225,5 @@ function evictAllEmbeddedSessionRunners(reason = "dispose_all") {
|
|
|
232
225
|
function acquireEmbeddedSessionRunner(params) {
|
|
233
226
|
return defaultEmbeddedSessionRunnerPool.acquire(params);
|
|
234
227
|
}
|
|
235
|
-
/** Resolve session identity used by embedded runner acquire and turn execution. */
|
|
236
|
-
async function resolveEmbeddedTranscriptInputs(sessionStore, sessionKey) {
|
|
237
|
-
return sessionStore.resolveTranscriptPath(sessionKey);
|
|
238
|
-
}
|
|
239
228
|
//#endregion
|
|
240
|
-
export { EmbeddedSessionRunnerPool, acquireEmbeddedSessionRunner, buildEmbeddedRunnerFingerprint, defaultEmbeddedSessionRunnerPool, evictAllEmbeddedSessionRunners, evictEmbeddedSessionRunner, getEmbeddedSessionRunnerIdleTtlMs, getEmbeddedSessionRunnerStats, isEmbeddedSessionRunnerEnabled, resetEmbeddedSessionRunnerForTest
|
|
229
|
+
export { EmbeddedSessionRunnerPool, acquireEmbeddedSessionRunner, buildEmbeddedRunnerFingerprint, defaultEmbeddedSessionRunnerPool, evictAllEmbeddedSessionRunners, evictEmbeddedSessionRunner, getEmbeddedSessionRunnerIdleTtlMs, getEmbeddedSessionRunnerStats, isEmbeddedSessionRunnerEnabled, resetEmbeddedSessionRunnerForTest };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AgentMessage } from '@earendil-works/pi-agent-core';
|
|
2
|
+
import { SessionManager } from '@earendil-works/pi-coding-agent';
|
|
3
|
+
import type { Api, Model } from '@earendil-works/pi-ai';
|
|
4
|
+
import { type CompactionExecutionOptions, type CompactionResult } from '../memory/compaction.js';
|
|
5
|
+
import type { SessionStore } from '../../session/store.js';
|
|
6
|
+
export interface EmbeddedTranscriptRuntime {
|
|
7
|
+
readonly runtimeId: string;
|
|
8
|
+
readonly sessionId: string;
|
|
9
|
+
readonly persistent: boolean;
|
|
10
|
+
openSessionManager(cwd: string): SessionManager;
|
|
11
|
+
loadMessages(): Promise<AgentMessage[]>;
|
|
12
|
+
compact(messages: AgentMessage[], model: Model<Api>, instructions?: string, force?: boolean, options?: CompactionExecutionOptions): Promise<CompactionResult>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createSqliteTranscriptRuntime(params: {
|
|
15
|
+
sessionKey: string;
|
|
16
|
+
sessionStore: SessionStore;
|
|
17
|
+
}): Promise<EmbeddedTranscriptRuntime>;
|
|
18
|
+
export declare class InMemoryTranscriptRuntime implements EmbeddedTranscriptRuntime {
|
|
19
|
+
readonly persistent = false;
|
|
20
|
+
readonly runtimeId: string;
|
|
21
|
+
readonly sessionId: string;
|
|
22
|
+
private readonly sessionManager;
|
|
23
|
+
private readonly compactor;
|
|
24
|
+
private baselineEntryCount;
|
|
25
|
+
constructor(params: {
|
|
26
|
+
runtimeId: string;
|
|
27
|
+
cwd: string;
|
|
28
|
+
initialMessages?: readonly AgentMessage[];
|
|
29
|
+
});
|
|
30
|
+
openSessionManager(_cwd: string): SessionManager;
|
|
31
|
+
loadMessages(): Promise<AgentMessage[]>;
|
|
32
|
+
captureBaseline(): void;
|
|
33
|
+
loadConversationMessages(): AgentMessage[];
|
|
34
|
+
compact(messages: AgentMessage[], model: Model<Api>, instructions?: string, force?: boolean, options?: CompactionExecutionOptions): Promise<CompactionResult>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SessionCompactor } from "../memory/compaction.js";
|
|
2
|
+
import { openSqliteHydratingSessionManager } from "./sqlite-hydrating-session-manager.js";
|
|
3
|
+
import crypto from "node:crypto";
|
|
4
|
+
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
//#region src/agent/embedded/transcript-runtime.ts
|
|
6
|
+
async function createSqliteTranscriptRuntime(params) {
|
|
7
|
+
const identity = await params.sessionStore.resolveTranscriptPath(params.sessionKey);
|
|
8
|
+
return {
|
|
9
|
+
runtimeId: params.sessionKey,
|
|
10
|
+
sessionId: identity.sessionId,
|
|
11
|
+
persistent: true,
|
|
12
|
+
openSessionManager: (cwd) => openSqliteHydratingSessionManager({
|
|
13
|
+
sessionKey: params.sessionKey,
|
|
14
|
+
sessionId: identity.sessionId,
|
|
15
|
+
cwd
|
|
16
|
+
}),
|
|
17
|
+
loadMessages: () => params.sessionStore.load(params.sessionKey),
|
|
18
|
+
compact: (messages, model, instructions, force, options) => params.sessionStore.compact(params.sessionKey, messages, model, instructions, force, options)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
var InMemoryTranscriptRuntime = class {
|
|
22
|
+
persistent = false;
|
|
23
|
+
runtimeId;
|
|
24
|
+
sessionId;
|
|
25
|
+
sessionManager;
|
|
26
|
+
compactor = new SessionCompactor();
|
|
27
|
+
baselineEntryCount = 0;
|
|
28
|
+
constructor(params) {
|
|
29
|
+
this.runtimeId = params.runtimeId;
|
|
30
|
+
this.sessionId = crypto.randomUUID();
|
|
31
|
+
this.sessionManager = SessionManager.inMemory(params.cwd, { id: this.sessionId });
|
|
32
|
+
for (const message of params.initialMessages ?? []) if (message.role === "compactionSummary") this.sessionManager.appendCustomMessageEntry("side-chat-parent-compaction", `The parent conversation was compacted into this summary:\n\n${message.summary}`, false);
|
|
33
|
+
else if (message.role === "branchSummary") this.sessionManager.appendCustomMessageEntry("side-chat-parent-branch", `The parent conversation includes this branch summary:\n\n${message.summary}`, false);
|
|
34
|
+
else this.sessionManager.appendMessage(message);
|
|
35
|
+
this.captureBaseline();
|
|
36
|
+
}
|
|
37
|
+
openSessionManager(_cwd) {
|
|
38
|
+
return this.sessionManager;
|
|
39
|
+
}
|
|
40
|
+
async loadMessages() {
|
|
41
|
+
return [...this.sessionManager.buildSessionContext().messages];
|
|
42
|
+
}
|
|
43
|
+
captureBaseline() {
|
|
44
|
+
this.baselineEntryCount = this.sessionManager.getBranch().length;
|
|
45
|
+
}
|
|
46
|
+
loadConversationMessages() {
|
|
47
|
+
return this.sessionManager.getBranch().slice(this.baselineEntryCount).flatMap((entry) => entry.type === "message" ? [entry.message] : []);
|
|
48
|
+
}
|
|
49
|
+
async compact(messages, model, instructions, force, options) {
|
|
50
|
+
const result = await this.compactor.compact(messages, model, instructions, force, options);
|
|
51
|
+
if (!result.compacted) return result;
|
|
52
|
+
const firstKept = this.sessionManager.getBranch().filter((entry) => entry.type === "message")[result.firstKeptIndex];
|
|
53
|
+
if (!firstKept) return {
|
|
54
|
+
...result,
|
|
55
|
+
compacted: false
|
|
56
|
+
};
|
|
57
|
+
this.sessionManager.appendCompaction(result.summary, firstKept.id, result.tokensBefore, {
|
|
58
|
+
plannerVersion: result.plannerVersion,
|
|
59
|
+
summaryModelRef: result.summaryModelRef,
|
|
60
|
+
qualityAudit: result.qualityAudit
|
|
61
|
+
});
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { InMemoryTranscriptRuntime, createSqliteTranscriptRuntime };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentMessage, AgentToolResult, ThinkingLevel } from '@earendil-works/pi-agent-core';
|
|
2
2
|
import type { AssistantMessageEvent, Model, Api, CacheRetention, ImageContent } from '@earendil-works/pi-ai';
|
|
3
3
|
import type { SessionStore } from '../../session/store.js';
|
|
4
|
+
import type { EmbeddedTranscriptRuntime } from './transcript-runtime.js';
|
|
4
5
|
export type EmbeddedStreamEvent = {
|
|
5
6
|
type: 'agent_start';
|
|
6
7
|
runId?: string;
|
|
@@ -93,7 +94,8 @@ export type RunXopcEmbeddedTurnParams = {
|
|
|
93
94
|
thinkingLevel?: ThinkingLevel;
|
|
94
95
|
cacheRetention?: CacheRetention;
|
|
95
96
|
workspaceDir: string;
|
|
96
|
-
sessionStore
|
|
97
|
+
sessionStore?: SessionStore;
|
|
98
|
+
transcriptRuntime?: EmbeddedTranscriptRuntime;
|
|
97
99
|
timeoutMs: number;
|
|
98
100
|
abortSignal?: AbortSignal;
|
|
99
101
|
onEvent?: (event: EmbeddedStreamEvent) => void;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { ThinkingLevel } from '@earendil-works/pi-agent-core';
|
|
1
2
|
import type { MessageBus } from '../infra/bus/index.js';
|
|
2
3
|
import { type Config } from '../config/schema.js';
|
|
3
4
|
import type { ChannelManager } from '../channels/manager.js';
|
|
4
5
|
import { SessionStore } from '../session/index.js';
|
|
6
|
+
import type { EmbeddedStreamEvent, RunXopcEmbeddedTurnResult } from './embedded/types.js';
|
|
7
|
+
import type { EmbeddedTranscriptRuntime } from './embedded/transcript-runtime.js';
|
|
5
8
|
import { OutboundCoordinator } from './messaging/index.js';
|
|
6
9
|
import { TurnDispatcher } from './inbound/turn-dispatcher.js';
|
|
7
10
|
import { SessionConfigService, SessionHydrator, SessionInspector } from './session/index.js';
|
|
@@ -114,6 +117,18 @@ export declare class AgentService {
|
|
|
114
117
|
refreshUserProfileContext(): void;
|
|
115
118
|
getMemoryManager(): import("./memory/manager.js").MemoryManager;
|
|
116
119
|
getModelForSession(sessionKey: string): string;
|
|
120
|
+
/** Run a full tool-capable turn against a caller-owned, non-persistent transcript. */
|
|
121
|
+
runEphemeralTurn(params: {
|
|
122
|
+
executionSessionKey: string;
|
|
123
|
+
parentSessionKey: string;
|
|
124
|
+
runId: string;
|
|
125
|
+
content: string;
|
|
126
|
+
modelRef: string;
|
|
127
|
+
thinkingLevel?: ThinkingLevel;
|
|
128
|
+
transcriptRuntime: EmbeddedTranscriptRuntime;
|
|
129
|
+
abortSignal?: AbortSignal;
|
|
130
|
+
onEvent?: (event: EmbeddedStreamEvent) => void;
|
|
131
|
+
}): Promise<RunXopcEmbeddedTurnResult>;
|
|
117
132
|
switchModelForSession(sessionKey: string, modelId: string): Promise<boolean>;
|
|
118
133
|
/**
|
|
119
134
|
* Clears per-session model override so the next turn uses the configured agent default
|
|
@@ -6,9 +6,11 @@ import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
|
6
6
|
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
7
7
|
import { init_agent_scope, resolveAgentHomeDir, resolveDefaultAgentId } from "./agent-scope.js";
|
|
8
8
|
import { extractProfileAgentId } from "../config/agent-profile.js";
|
|
9
|
+
import { init_providers, resolveModel } from "../providers/index.js";
|
|
9
10
|
import { extractTextContent } from "./context/workspace.js";
|
|
10
11
|
import { effectiveWorkspacePathForSession } from "../session/session-workspace.js";
|
|
11
12
|
import { getProjectForSession } from "../projects/workspace.js";
|
|
13
|
+
import { resolveAgentTurnTimeoutMs } from "./orchestration/run-agent-turn-with-timeout.js";
|
|
12
14
|
import { resolveResponseLanguageForSession } from "./prompt/response-language.js";
|
|
13
15
|
import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "./skills/workspace-skills-dir.js";
|
|
14
16
|
import { removeSkillsLockEntry } from "./skills/hub-lock.js";
|
|
@@ -42,6 +44,8 @@ import "./middleware/index.js";
|
|
|
42
44
|
import { TurnDiffTracker } from "./coding/turn-diff-tracker.js";
|
|
43
45
|
import { LifecycleManager } from "./lifecycle/manager.js";
|
|
44
46
|
import "./lifecycle/index.js";
|
|
47
|
+
import { runXopcEmbeddedTurn } from "./embedded/run-turn.js";
|
|
48
|
+
import { runWithEmbeddedExecutionSession } from "./embedded/execution-context.js";
|
|
45
49
|
import { MessageRouter } from "./messaging/message-router.js";
|
|
46
50
|
import { CommandHandler } from "./messaging/command-handler.js";
|
|
47
51
|
import { StreamManager } from "./messaging/stream-manager.js";
|
|
@@ -68,6 +72,7 @@ import { readFile } from "node:fs/promises";
|
|
|
68
72
|
init_schema();
|
|
69
73
|
init_logger();
|
|
70
74
|
init_agent_scope();
|
|
75
|
+
init_providers();
|
|
71
76
|
const log = createLogger("AgentService");
|
|
72
77
|
function assistantMessageText(message) {
|
|
73
78
|
const content = message.content;
|
|
@@ -231,6 +236,7 @@ var AgentService = class {
|
|
|
231
236
|
getNotesService: config.getNotesService,
|
|
232
237
|
getProjectService: config.getProjectService,
|
|
233
238
|
getLocalAppService: config.getLocalAppService,
|
|
239
|
+
dispatchTaskEvents: config.dispatchTaskEvents,
|
|
234
240
|
dispatchTaskRuns: config.dispatchTaskRuns,
|
|
235
241
|
getWorkflowRunService: config.getWorkflowRunService,
|
|
236
242
|
onSkillsUpdated: config.onSkillsUpdated,
|
|
@@ -563,6 +569,31 @@ var AgentService = class {
|
|
|
563
569
|
getModelForSession(sessionKey) {
|
|
564
570
|
return this.modelManager.getModelForSession(sessionKey);
|
|
565
571
|
}
|
|
572
|
+
/** Run a full tool-capable turn against a caller-owned, non-persistent transcript. */
|
|
573
|
+
async runEphemeralTurn(params) {
|
|
574
|
+
const agent = this.agentManager.getOrCreateAgent(params.parentSessionKey);
|
|
575
|
+
const workspaceDir = this.agentManager.getResolvedWorkspaceForSession(params.parentSessionKey);
|
|
576
|
+
const model = resolveModel(params.modelRef);
|
|
577
|
+
return runWithEmbeddedExecutionSession(params.executionSessionKey, () => runXopcEmbeddedTurn({
|
|
578
|
+
sessionKey: params.executionSessionKey,
|
|
579
|
+
runId: params.runId,
|
|
580
|
+
userMessage: {
|
|
581
|
+
role: "user",
|
|
582
|
+
content: params.content,
|
|
583
|
+
timestamp: Date.now()
|
|
584
|
+
},
|
|
585
|
+
model,
|
|
586
|
+
modelRef: params.modelRef,
|
|
587
|
+
tools: agent.state.tools,
|
|
588
|
+
systemPrompt: agent.state.systemPrompt ?? "",
|
|
589
|
+
thinkingLevel: params.thinkingLevel ?? agent.state.thinkingLevel,
|
|
590
|
+
workspaceDir,
|
|
591
|
+
transcriptRuntime: params.transcriptRuntime,
|
|
592
|
+
timeoutMs: resolveAgentTurnTimeoutMs(this.effectiveAppConfig(), params.parentSessionKey),
|
|
593
|
+
abortSignal: params.abortSignal,
|
|
594
|
+
onEvent: params.onEvent
|
|
595
|
+
}));
|
|
596
|
+
}
|
|
566
597
|
async switchModelForSession(sessionKey, modelId) {
|
|
567
598
|
if (!await this.modelManager.switchModelForSession(sessionKey, modelId)) return false;
|
|
568
599
|
await this.sessionConfigStore.update(sessionKey, { modelOverride: modelId });
|
|
@@ -33,6 +33,7 @@ export interface AgentServiceConfig {
|
|
|
33
33
|
getNotesService?: () => NotesService | undefined;
|
|
34
34
|
getProjectService?: () => ProjectService | undefined;
|
|
35
35
|
getLocalAppService?: () => LocalAppService | undefined;
|
|
36
|
+
dispatchTaskEvents?: () => void;
|
|
36
37
|
dispatchTaskRuns?: () => void;
|
|
37
38
|
/**
|
|
38
39
|
* Gateway: reuse the gateway `SessionManager` store so web API and agent share one index + files.
|
|
@@ -57,6 +57,8 @@ export interface ToolFactoryDeps {
|
|
|
57
57
|
getNotesService?: () => NotesService | undefined;
|
|
58
58
|
getProjectService?: () => ProjectService | undefined;
|
|
59
59
|
getLocalAppService?: () => LocalAppService | undefined;
|
|
60
|
+
/** Gateway: publishes durable Task change notifications. */
|
|
61
|
+
dispatchTaskEvents?: () => void;
|
|
60
62
|
/** Gateway: queues Task execution for xopc_use task start/resume/verify actions. */
|
|
61
63
|
dispatchTaskRuns?: () => void;
|
|
62
64
|
/** Gateway: starts persisted workflow runs (dedicated chat session per run). */
|
|
@@ -305,7 +305,7 @@ var AgentToolsFactory = class {
|
|
|
305
305
|
})] : [],
|
|
306
306
|
...this.deps.getAutomationService ? [createAutomationTool({ getAutomationService: this.deps.getAutomationService })] : [],
|
|
307
307
|
...browserEnabled && this.deps.getBrowserRecipeService ? [createBrowserRecipeTool({ getBrowserRecipeService: this.deps.getBrowserRecipeService })] : [],
|
|
308
|
-
...this.deps.getAutomationService || this.deps.getProjectService || this.deps.getNotesService || this.deps.getLocalAppService || this.deps.dispatchTaskRuns ? [createXopcUseTool({
|
|
308
|
+
...this.deps.getAutomationService || this.deps.getProjectService || this.deps.getNotesService || this.deps.getLocalAppService || this.deps.dispatchTaskEvents || this.deps.dispatchTaskRuns ? [createXopcUseTool({
|
|
309
309
|
getConfig: () => this.deps.getConfig?.(),
|
|
310
310
|
getCurrentAgentId: () => options.agentId,
|
|
311
311
|
getCurrentSessionKey: () => this.deps.getCurrentContext()?.sessionKey,
|
|
@@ -313,6 +313,7 @@ var AgentToolsFactory = class {
|
|
|
313
313
|
getNotesService: this.deps.getNotesService,
|
|
314
314
|
getProjectService: this.deps.getProjectService,
|
|
315
315
|
getLocalAppService: this.deps.getLocalAppService,
|
|
316
|
+
dispatchTaskEvents: this.deps.dispatchTaskEvents,
|
|
316
317
|
dispatchTaskRuns: this.deps.dispatchTaskRuns
|
|
317
318
|
})] : [],
|
|
318
319
|
...browserEnabled ? [createBrowserUseTool({
|
|
@@ -26,6 +26,7 @@ export interface XopcUseToolDeps {
|
|
|
26
26
|
getNotesService?: () => NotesService | undefined;
|
|
27
27
|
getProjectService?: () => ProjectService | undefined;
|
|
28
28
|
getLocalAppService?: () => LocalAppService | undefined;
|
|
29
|
+
dispatchTaskEvents?: () => void;
|
|
29
30
|
dispatchTaskRuns?: () => void;
|
|
30
31
|
}
|
|
31
32
|
type XopcUseDetails = {
|