@xopcai/xopc 0.0.314 → 0.0.316
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/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BFkjfurL.js → agent-avatar-dicebear-XIyH14Sn.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DJl_o7Xf.js +1 -0
- package/dist/gateway/static/root/assets/agents-CGFhxPFv.js +1 -0
- package/dist/gateway/static/root/assets/{api-BYhRsTAc.js → api-Dy056n2_.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B4kihr-A.js → app-management-settings-panel-Dp7Fcj2Z.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-N9sYmNOx.js → appearance-settings-CSUffLjx.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BMcy10_s.js → apps-page-DtIcKfJG.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-k_SuYWyV.js → archive-plugin-D3SdndlF.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DRv5QWUK.js → attachment-load-BgxXYRkd.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CkJV3DN0.js → automations-page-krhofMgL.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-EbpneB06.js +7 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Dg3h3TA7.js → binary-plugins-w6lazTqo.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DVhdHntT.js → block-editor-CxHqPODE.js} +5 -5
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BMRYUW8_.js → browser-automation-inputs-hNdEgfGG.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-Byv6-FY2.js → browser-automations-page-BYsGJ_xs.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-CP_c5q0V.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-ljW3s3vv.js +8 -0
- package/dist/gateway/static/root/assets/channels-settings-CR9SRgFp.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-D4AHa51o.js → chat-terminal-dock-medSiQoQ.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-eXPe500D.js → computer-settings-page-DJxO0CfY.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-BQTFlq_k.js → connector-service-page-WaoUqr8a.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-KIi15pQl.js +2 -0
- package/dist/gateway/static/root/assets/{date-picker-7MtovynY.js → date-picker-DalDr0E6.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Bj_xkXID.js → dependency-picker-ONChq2Yr.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CTmba9zH.js → desktop-pet-b1a37SVn.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DNM_BlWN.js → desktop-pet-settings-CwqZxGv4.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-C_MNpS30.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-J_olaL7e.js → extension-debug-page-CGthPGca.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-pK5RvqN8.js → extension-page-CExNJs0G.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BwroEN08.js → extension-settings-page-DBfxzKR8.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-FuJTIg_a.js → gateway-config-swr-DFjsI4QK.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BlpheZrf.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CKg_gu8_.js → gateway-startup-retry-oRRqSoe9.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-BvdT-uaI.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-Bo6NZ7zb.js → image-generation-api-CyDy_Sxu.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-C8-hX8gS.js → imports-page-Dnp2hmFL.js} +1 -1
- package/dist/gateway/static/root/assets/index-BYKatjhB.css +1 -0
- package/dist/gateway/static/root/assets/index-DhCnwCI9.js +89 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BkBEjUZD.js → keyboard-shortcuts-settings-1DUcGrYh.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-BW2-80Og.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CrbKIixo.js → local-apps-page-C7_2zyV_.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CvGwNbml.js → locale-store-D6VmRI5e.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DBHlZts9.js → logs-page-Cbr7bPM6.js} +2 -2
- package/dist/gateway/static/root/assets/management-settings-G7GcFx2_.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-nXo5nrsv.js → markdown-view-B5MfZeKH.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-upxXJ-4l.js → media-plugins-IbcEpV96.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BCqLsIZK.js +3 -0
- package/dist/gateway/static/root/assets/note-detail-panel-C4DiKkDf.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-DgHQmpVq.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-DUyA-K4L.js → page-context-capture-button-B5rZ_F0R.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-Cl-NFPNr.js → page-tabs-B84Yghg5.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DX81PwJ3.js → preview-open-alternatives-CaEtDmZO.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CrfIGwm8.js → product-open-page-BK9z5b-v.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-Qj8Xb9qS.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-nM9a9XNS.js → projects-page-BOp6swwM.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-CHxgohY0.js → registry-api-sOL6E5LU.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-yb8l4ppq.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-D3dLOW04.js → runtime-tools-settings-panel-BAvzw1T0.js} +1 -1
- package/dist/gateway/static/root/assets/scenes-page-CiAgb7hf.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-ZxuIvD2_.js → schema-form-Dytkw9RZ.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-43hcOW84.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-C414vr2V.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-TZRfg4yo.js → settings-form-section-DBJlmKQV.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-a8qcJpdZ.js → settings-page-C9GbP-ZG.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-BfvlRT9q.js → settings-page-layout-OvBOGen7.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BCMym4xj.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DCt1pTWB.js → share-preview-page-D-sx26yN.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-EdNGhsuF.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DYYM1qVn.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-BIOcg44X.js → skills-page-Cgrfnet5.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-CgZdzT4I.js → skills-page.utils-COPGVfmB.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-_YaRncA6.js → system-settings-panel-B9tptggE.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-BrsM6Xmm.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-uOupJOoS.js → tunnel-api-qb33IFGP.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BezzHBLE.js → use-autosave-DfhqCGRX.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-Sg94U7zz.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BmYifdwL.js → voice-api-key-field-taBVzvtI.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-D_5Q2_A3.js → voice-config-api-B4yjd1Kb.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-4DmyEckJ.js → work-discovery-overlay-DWGTB3Uk.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DeZe8bTZ.js → workflow-run-setup-panel-CP58uTNh.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Clka1xiQ.js +6 -0
- package/dist/gateway/static/root/index.html +8 -8
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +18 -17
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/embedded/run-turn.js +28 -15
- package/dist/src/agent/embedded/system-prompt-override.js +14 -3
- package/dist/src/agent/embedded/xopc-stream-bridge.js +13 -2
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-gateway.d.ts +39 -0
- package/dist/src/agent/mcp/bundle-mcp-gateway.js +32 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +11 -0
- package/dist/src/agent/mcp/bundle-mcp-types.d.ts +2 -1
- package/dist/src/agent/mcp/mcp-resource-id.d.ts +6 -0
- package/dist/src/agent/mcp/mcp-resource-id.js +19 -0
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/memory/context-budget.js +1 -1
- package/dist/src/agent/orchestration/agent-turn-policy.d.ts +2 -2
- package/dist/src/agent/prompt/agent-system-prompt.d.ts +3 -0
- package/dist/src/agent/prompt/agent-system-prompt.js +16 -0
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/source-context/browser-tab.d.ts +3 -0
- package/dist/src/agent/source-context/browser-tab.js +29 -0
- package/dist/src/agent/source-context/file-context.d.ts +3 -0
- package/dist/src/agent/source-context/file-context.js +64 -0
- package/dist/src/agent/source-context/index.d.ts +4 -0
- package/dist/src/agent/source-context/index.js +5 -1
- package/dist/src/agent/source-context/injector.js +1 -1
- package/dist/src/agent/source-context/mcp-resource-context.d.ts +8 -0
- package/dist/src/agent/source-context/mcp-resource-context.js +30 -0
- package/dist/src/agent/source-context/session-context.d.ts +8 -0
- package/dist/src/agent/source-context/session-context.js +33 -0
- package/dist/src/agent/source-context/types.d.ts +9 -3
- package/dist/src/agent/source-context/types.js +3 -2
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tools/knowledge-memory-tool.js +1 -0
- package/dist/src/agent-config/schema.d.ts +8 -8
- package/dist/src/ai-assist/text-assist.js +3 -2
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/oauth/xopc-cloud.js +1 -1
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/channels/index.js +1 -1
- package/dist/src/channels/manager.js +1 -1
- package/dist/src/chat-commands/agent-edit.js +1 -1
- package/dist/src/cli/commands/agent.js +1 -1
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +3 -3
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +2 -2
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/computer/runtime.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.d.ts +8 -8
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/schema.d.ts +5 -5
- package/dist/src/config/schema.js +1 -1
- package/dist/src/connectors/connected-source-ingestion.d.ts +1 -0
- package/dist/src/connectors/connected-source-ingestion.js +1 -0
- package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
- package/dist/src/connectors/connected-source-understanding.js +91 -31
- package/dist/src/connectors/content-enrichment.d.ts +1 -0
- package/dist/src/connectors/content-enrichment.js +3 -1
- package/dist/src/connectors/learning-coordinator.js +24 -24
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/chat-stream/mapper.js +12 -6
- package/dist/src/gateway/chat-stream/protocol.d.ts +2 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +2 -2
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/agent-stream.js +2 -2
- package/dist/src/gateway/hono/routes/browser.js +32 -0
- package/dist/src/gateway/hono/routes/connectors.js +1 -1
- package/dist/src/gateway/hono/routes/devices.js +0 -16
- package/dist/src/gateway/hono/routes/endpoint-tools.js +86 -30
- package/dist/src/gateway/hono/routes/mcp.js +32 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +6 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +4 -4
- package/dist/src/gateway/hono/routes/user-model-refresh.js +2 -2
- package/dist/src/gateway/service/agent-runner.d.ts +1 -1
- package/dist/src/gateway/service/agent-runner.js +2 -2
- package/dist/src/gateway/service/app-context-access.d.ts +0 -4
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -1
- package/dist/src/gateway/service/session-input-coordinator.js +3 -3
- package/dist/src/gateway/service.js +47 -10
- package/dist/src/gateway/workspace-file-search.js +25 -12
- package/dist/src/knowledge/ingestion-service.d.ts +5 -2
- package/dist/src/knowledge/ingestion-service.js +24 -15
- package/dist/src/knowledge-memory/domain.d.ts +1 -1
- package/dist/src/notes/service.js +1 -1
- package/dist/src/platform/client.d.ts +2 -2
- package/dist/src/platform/contracts.d.ts +2 -2
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/extension-stream-bridge.js +6 -4
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-call.js +3 -3
- package/dist/src/providers/model-catalog-persistence.js +1 -1
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/presentation.js +4 -3
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/session/client-history.d.ts +2 -1
- package/dist/src/session/client-history.js +3 -2
- package/dist/src/storage/sqlite/context-extraction-repository.d.ts +1 -2
- package/dist/src/storage/sqlite/context-extraction-repository.js +1 -9
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.d.ts +15 -1
- package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +39 -6
- package/dist/src/storage/sqlite/index.d.ts +2 -3
- package/dist/src/storage/sqlite/index.js +3 -4
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/knowledge-repository.js +3 -0
- package/dist/src/storage/sqlite/migrations/200_connected_work_threads.sql +92 -0
- package/dist/src/storage/sqlite/migrations/201_connector_extraction_audit.sql +127 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +4 -4
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +1 -1
- package/dist/src/tui/backends/embedded-backend.js +2 -2
- package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
- package/dist/src/tui/tui-commands.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +2 -2
- package/dist/src/user-context/domain.d.ts +0 -13
- package/dist/src/user-context/sources/index.js +2 -2
- package/dist/src/user-context/sources/repository.d.ts +10 -0
- package/dist/src/user-context/sources/repository.js +19 -4
- package/dist/src/user-context/sources/types.d.ts +1 -0
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/work-discovery/service.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +6 -6
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BdOZ6q8Z.js +0 -1
- package/dist/gateway/static/root/assets/agents-CCcavsHq.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BEa2doeR.js +0 -7
- package/dist/gateway/static/root/assets/browser-settings-page-DRCHGFpO.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-mxRP0gl0.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-DBt_6GsB.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BKeBWwcI.js +0 -2
- package/dist/gateway/static/root/assets/device-pairing-wizard-C2XE0QhT.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CLLDp23J.js +0 -1
- package/dist/gateway/static/root/assets/home-page-B5Epb1PH.js +0 -1
- package/dist/gateway/static/root/assets/index-14F1yGJI.js +0 -89
- package/dist/gateway/static/root/assets/index-cB7rWIDY.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-6jC3vQpY.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-DsUWLu5m.js +0 -1
- package/dist/gateway/static/root/assets/messages-B_AwRroN.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-0Q9TOtJG.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-D0NmcwNw.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-BVfVrYmn.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C8b_k88G.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-DEowreZV.js +0 -2
- package/dist/gateway/static/root/assets/sessions-page-B_nPhera.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BqhIOuus.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CRj5Ruqn.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BNbXPk--.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CNMCLbav.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-CAcfAG-c.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-BFFeneDq.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-Sv4hEc6W.js +0 -6
- package/dist/src/storage/sqlite/context-relation-repository.d.ts +0 -50
- package/dist/src/storage/sqlite/context-relation-repository.js +0 -98
|
@@ -7,17 +7,17 @@ import { getInteractionState } from "../storage/sqlite/interaction-state-reposit
|
|
|
7
7
|
import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
|
|
8
8
|
import "../storage/sqlite/index.js";
|
|
9
9
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
10
|
-
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
11
10
|
import { expandWorkspacePathString, init_workspace_path } from "../config/workspace-path.js";
|
|
12
11
|
import { init_agent_scope, resolveAgentProfileDir } from "./agent-scope.js";
|
|
12
|
+
import { init_paths, resolveBundledSkillsDir } from "../config/paths.js";
|
|
13
|
+
import { CredentialResolver, init_credentials } from "../auth/credentials.js";
|
|
13
14
|
import { getConversationRouting } from "../storage/sqlite/conversation-repository.js";
|
|
14
15
|
import { init_session_key } from "../routing/session-key.js";
|
|
15
|
-
import { resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
16
|
-
import { init_paths, resolveBundledSkillsDir } from "../config/paths.js";
|
|
17
16
|
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../auth/sync-provider-auth.js";
|
|
18
|
-
import { CredentialResolver, init_credentials } from "../auth/credentials.js";
|
|
19
17
|
import { getApiKeySync, getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
|
|
20
18
|
import { createExtensionAwareStreamFn } from "../providers/extension-stream-bridge.js";
|
|
19
|
+
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
20
|
+
import { resolveEffectiveAgentProfile, resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
21
21
|
import { extractTextContent } from "./context/workspace.js";
|
|
22
22
|
import { buildExecutionScopeContextForPrompt } from "./context/execution-scope.js";
|
|
23
23
|
import { clearBootstrapSnapshot } from "./bootstrap/bootstrap-cache.js";
|
|
@@ -32,6 +32,7 @@ import { isValidSkillEnvVarName } from "./skills/required-env-vars.js";
|
|
|
32
32
|
import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "./skills/workspace-skills-dir.js";
|
|
33
33
|
import { loadSkillsLock } from "./skills/hub-lock.js";
|
|
34
34
|
import { isUnderManagedSkillsDir } from "./skills/managed-store.js";
|
|
35
|
+
import { replaceAgentSystemPrompt } from "./prompt/agent-system-prompt.js";
|
|
35
36
|
import { evictAllEmbeddedSessionRunners, evictEmbeddedSessionRunner } from "./embedded/session-runner.js";
|
|
36
37
|
import { createAgentTurnPolicy } from "./orchestration/agent-turn-policy.js";
|
|
37
38
|
import { resolveUserContextSessionAccess } from "../user-context/access-policy.js";
|
|
@@ -424,13 +425,13 @@ var AgentManager = class {
|
|
|
424
425
|
const nextRegisteredToolNames = [...originalRegisteredToolNames, ...newTools.map((tool) => tool.name)];
|
|
425
426
|
inst.agent.state.tools = newTools.length > 0 ? sortToolsForPromptCache([...originalTools, ...newTools]) : originalTools;
|
|
426
427
|
inst.registeredToolNames = nextRegisteredToolNames;
|
|
427
|
-
inst.agent
|
|
428
|
+
replaceAgentSystemPrompt(inst.agent, this.buildSystemPromptForInstance(inst, nextRegisteredToolNames, requested));
|
|
428
429
|
try {
|
|
429
430
|
return await run();
|
|
430
431
|
} finally {
|
|
431
432
|
inst.agent.state.tools = originalTools;
|
|
432
433
|
inst.registeredToolNames = originalRegisteredToolNames;
|
|
433
|
-
inst.agent
|
|
434
|
+
replaceAgentSystemPrompt(inst.agent, originalSystemPrompt);
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
437
|
buildSystemPromptForInstance(instance, registeredToolNames = instance.registeredToolNames, activeCapabilityNames = this.activeCapabilityNames(instance)) {
|
|
@@ -662,17 +663,17 @@ var AgentManager = class {
|
|
|
662
663
|
thinkingLevel: this.config.thinkingLevel ?? "medium",
|
|
663
664
|
activeProjectContext: instance.activeProjectContext
|
|
664
665
|
});
|
|
665
|
-
instance.agent
|
|
666
|
+
replaceAgentSystemPrompt(instance.agent, newPrompt);
|
|
666
667
|
}
|
|
667
668
|
log.info({ agents: this.agents.size }, "Skill toggles applied; system prompt updated");
|
|
668
669
|
this.scheduleSkillsUpdated("config");
|
|
669
670
|
}
|
|
670
671
|
refreshActionTrustPolicy() {
|
|
671
|
-
for (const instance of this.agents.values()) instance.agent
|
|
672
|
+
for (const instance of this.agents.values()) replaceAgentSystemPrompt(instance.agent, this.buildSystemPromptForInstance(instance));
|
|
672
673
|
log.info({ agents: this.agents.size }, "Action trust policy applied to active agents");
|
|
673
674
|
}
|
|
674
675
|
refreshUserProfileContext() {
|
|
675
|
-
for (const instance of this.agents.values()) instance.agent
|
|
676
|
+
for (const instance of this.agents.values()) replaceAgentSystemPrompt(instance.agent, this.buildSystemPromptForInstance(instance));
|
|
676
677
|
log.info({ agents: this.agents.size }, "User profile applied to active agents");
|
|
677
678
|
}
|
|
678
679
|
/**
|
|
@@ -737,7 +738,7 @@ var AgentManager = class {
|
|
|
737
738
|
thinkingLevel: this.config.thinkingLevel ?? "medium",
|
|
738
739
|
activeProjectContext: instance.activeProjectContext
|
|
739
740
|
});
|
|
740
|
-
instance.agent
|
|
741
|
+
replaceAgentSystemPrompt(instance.agent, newPrompt);
|
|
741
742
|
}
|
|
742
743
|
log.info({ agents: this.agents.size }, "Skills refreshed; system prompt updated");
|
|
743
744
|
}
|
|
@@ -861,7 +862,7 @@ var AgentManager = class {
|
|
|
861
862
|
const modelRef = instance.effectiveProfile.primaryModelRef?.trim() || this.defaultModel;
|
|
862
863
|
const thinkingLevel = this.config.thinkingLevel ?? "medium";
|
|
863
864
|
const activeProjectContext = this.buildExecutionScopeContext(conversationId);
|
|
864
|
-
instance.agent
|
|
865
|
+
replaceAgentSystemPrompt(instance.agent, rt.systemPromptBuilder.build(contextFiles, {
|
|
865
866
|
externalMemoryInstructions: this.buildExternalMemoryInstructions(conversationId, rt),
|
|
866
867
|
workspaceOverride: resolvedWorkspacePath,
|
|
867
868
|
profileMarkdownPathRoot: resolveAgentProfileDir(cfg, instance.effectiveProfile.agentId),
|
|
@@ -874,7 +875,7 @@ var AgentManager = class {
|
|
|
874
875
|
thinkingLevel,
|
|
875
876
|
extraSystemPrompt: trimmed,
|
|
876
877
|
activeProjectContext
|
|
877
|
-
});
|
|
878
|
+
}));
|
|
878
879
|
instance.activeProjectContext = activeProjectContext;
|
|
879
880
|
}
|
|
880
881
|
/**
|
|
@@ -1000,7 +1001,7 @@ var AgentManager = class {
|
|
|
1000
1001
|
toolExecution: "parallel",
|
|
1001
1002
|
streamFn: createExtensionAwareStreamFn(),
|
|
1002
1003
|
getApiKey: (provider) => this.resolveApiKeyWithCache(provider),
|
|
1003
|
-
|
|
1004
|
+
finishTurn: (context) => turnPolicy.shouldStopAfterTurn(context) ? { action: "end" } : void 0,
|
|
1004
1005
|
beforeToolCall: turnPolicy.beforeToolCall,
|
|
1005
1006
|
afterToolCall: turnPolicy.afterToolCall
|
|
1006
1007
|
});
|
|
@@ -1160,7 +1161,7 @@ var AgentManager = class {
|
|
|
1160
1161
|
const contextFiles = this.resolveContextFilesForSession(instance.conversationId, instance.effectiveProfile);
|
|
1161
1162
|
const modelRef = instance.effectiveProfile.primaryModelRef?.trim() || this.defaultModel;
|
|
1162
1163
|
const thinkingLevel = instance.agent.state.thinkingLevel ?? this.config.thinkingLevel ?? "medium";
|
|
1163
|
-
instance.agent
|
|
1164
|
+
replaceAgentSystemPrompt(instance.agent, rt.systemPromptBuilder.build(contextFiles, {
|
|
1164
1165
|
externalMemoryInstructions: this.buildExternalMemoryInstructions(instance.conversationId, rt),
|
|
1165
1166
|
workspaceOverride: resolvedWorkspacePath,
|
|
1166
1167
|
profileMarkdownPathRoot: resolveAgentProfileDir(cfg, instance.effectiveProfile.agentId),
|
|
@@ -1172,7 +1173,7 @@ var AgentManager = class {
|
|
|
1172
1173
|
agentId: instance.effectiveProfile.agentId,
|
|
1173
1174
|
thinkingLevel,
|
|
1174
1175
|
activeProjectContext: nextProjectContext
|
|
1175
|
-
});
|
|
1176
|
+
}));
|
|
1176
1177
|
instance.activeProjectContext = nextProjectContext;
|
|
1177
1178
|
instance.interactionStateVersion = interactionStateVersion;
|
|
1178
1179
|
instance.userContextAccessVersion = userContextAccessVersion;
|
|
@@ -1200,7 +1201,7 @@ var AgentManager = class {
|
|
|
1200
1201
|
const contextFiles = this.resolveContextFilesForSession(conversationId, instance.effectiveProfile);
|
|
1201
1202
|
const thinkingLevel = instance.agent.state.thinkingLevel ?? this.config.thinkingLevel ?? "medium";
|
|
1202
1203
|
const activeProjectContext = this.buildExecutionScopeContext(conversationId);
|
|
1203
|
-
instance.agent
|
|
1204
|
+
replaceAgentSystemPrompt(instance.agent, rt.systemPromptBuilder.build(contextFiles, {
|
|
1204
1205
|
externalMemoryInstructions: this.buildExternalMemoryInstructions(conversationId, rt),
|
|
1205
1206
|
workspaceOverride: resolvedWorkspacePath,
|
|
1206
1207
|
profileMarkdownPathRoot: resolveAgentProfileDir(cfg, instance.effectiveProfile.agentId),
|
|
@@ -1212,7 +1213,7 @@ var AgentManager = class {
|
|
|
1212
1213
|
agentId: instance.effectiveProfile.agentId,
|
|
1213
1214
|
thinkingLevel,
|
|
1214
1215
|
activeProjectContext
|
|
1215
|
-
});
|
|
1216
|
+
}));
|
|
1216
1217
|
instance.activeProjectContext = activeProjectContext;
|
|
1217
1218
|
log.info({
|
|
1218
1219
|
conversationId,
|
|
@@ -4,10 +4,10 @@ import { finishContextExtractionRun } from "../../storage/sqlite/context-extract
|
|
|
4
4
|
import { getSessionMetadata } from "../../storage/sqlite/session-read-repository.js";
|
|
5
5
|
import { loadCompactionSourceSnapshot } from "../../storage/sqlite/transcript-repository.js";
|
|
6
6
|
import "../../storage/sqlite/index.js";
|
|
7
|
-
import { extractProfileAgentId } from "../../config/agent-profile.js";
|
|
8
7
|
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../../auth/sync-provider-auth.js";
|
|
9
8
|
import { getApiKeySync, init_providers, resolveModel } from "../../providers/index.js";
|
|
10
9
|
import { createExtensionAwareStreamFn } from "../../providers/extension-stream-bridge.js";
|
|
10
|
+
import { extractProfileAgentId } from "../../config/agent-profile.js";
|
|
11
11
|
import { extractTextContent } from "../context/workspace.js";
|
|
12
12
|
import { listUserAssertions } from "../../user-model/repository.js";
|
|
13
13
|
import { readAgentMessageContent } from "../memory/agent-message-access.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { init_paths, resolveModelsJsonPath } from "../../config/paths.js";
|
|
2
|
-
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../../auth/sync-provider-auth.js";
|
|
3
2
|
import { CredentialResolver, init_credentials } from "../../auth/credentials.js";
|
|
3
|
+
import { init_sync_provider_auth, resolveProviderApiKeySync } from "../../auth/sync-provider-auth.js";
|
|
4
4
|
import { XopcModelCredentialStore, init_model_credential_store } from "../../auth/model-credential-store.js";
|
|
5
5
|
import { init_register_bundled_oauth_flows, registerBundledOAuthFlows } from "../../providers/register-bundled-oauth-flows.js";
|
|
6
6
|
import { init_register_runtime_providers, registerRuntimeProviders } from "../../providers/register-runtime-providers.js";
|
|
@@ -2,9 +2,9 @@ import { createLogger } from "../../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { parseTurnOutcome } from "../../../packages/gateway-contract/src/turn-outcome.js";
|
|
4
4
|
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
5
|
-
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
6
5
|
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
7
6
|
import { appendDynamicPromptSection } from "../prompt/cache-boundary.js";
|
|
7
|
+
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
8
8
|
import { runWithEmbeddedExecutionSession } from "./execution-context.js";
|
|
9
9
|
import { resolveAgentTurnTimeoutMs } from "../orchestration/run-agent-turn-with-timeout.js";
|
|
10
10
|
import { resolvePromptCachePolicy } from "../../providers/prompt-cache-plan.js";
|
|
@@ -24,6 +24,7 @@ import { markTurnToolResult } from "../memory/turn-provenance.js";
|
|
|
24
24
|
import { RepositoryInstructions } from "../coding/repository-instructions.js";
|
|
25
25
|
import { RunVerification } from "../coding/run-verification.js";
|
|
26
26
|
import { withDelegationScope } from "../orchestration/delegation-scope.js";
|
|
27
|
+
import { getCurrentSystemPrompt, getCurrentTools } from "@earendil-works/pi-ai";
|
|
27
28
|
//#region src/agent/embedded/run-turn.ts
|
|
28
29
|
init_connection_wait_repository();
|
|
29
30
|
init_logger();
|
|
@@ -107,7 +108,7 @@ async function maybeRecoverContextOverflow(params) {
|
|
|
107
108
|
policy: params.policy,
|
|
108
109
|
budget: {
|
|
109
110
|
contextWindow: params.model.contextWindow ?? 128e3,
|
|
110
|
-
systemPrompt: params.
|
|
111
|
+
systemPrompt: params.systemPrompt,
|
|
111
112
|
tools: params.agent.state.tools,
|
|
112
113
|
reserveTokens: params.policy.reserveTokens,
|
|
113
114
|
triggerThreshold: params.policy.triggerThreshold,
|
|
@@ -202,11 +203,13 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
202
203
|
timestamp: Date.now()
|
|
203
204
|
}]
|
|
204
205
|
};
|
|
206
|
+
let effectiveSystemPrompt = getCurrentSystemPrompt(effectiveContext.messages);
|
|
207
|
+
let effectiveTools = getCurrentTools(effectiveContext.messages);
|
|
205
208
|
const projection = projectContextForModel({
|
|
206
209
|
messages: effectiveContext.messages,
|
|
207
210
|
contextWindow: streamModel.contextWindow ?? 128e3,
|
|
208
|
-
systemPrompt:
|
|
209
|
-
tools:
|
|
211
|
+
systemPrompt: effectiveSystemPrompt,
|
|
212
|
+
tools: effectiveTools,
|
|
210
213
|
reserveTokens: compactionPolicy.reserveTokens,
|
|
211
214
|
minToolResultKeepChars: compactionPolicy.minToolResultKeepChars,
|
|
212
215
|
canCompact: false,
|
|
@@ -217,6 +220,8 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
217
220
|
...effectiveContext,
|
|
218
221
|
messages: projection.messages
|
|
219
222
|
};
|
|
223
|
+
effectiveSystemPrompt = getCurrentSystemPrompt(effectiveContext.messages);
|
|
224
|
+
effectiveTools = getCurrentTools(effectiveContext.messages);
|
|
220
225
|
log.warn({
|
|
221
226
|
conversationId,
|
|
222
227
|
runId,
|
|
@@ -229,8 +234,8 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
229
234
|
const assessed = assessContext({
|
|
230
235
|
messages: effectiveContext.messages,
|
|
231
236
|
contextWindow: streamModel.contextWindow ?? 128e3,
|
|
232
|
-
systemPrompt:
|
|
233
|
-
tools:
|
|
237
|
+
systemPrompt: effectiveSystemPrompt,
|
|
238
|
+
tools: effectiveTools,
|
|
234
239
|
reserveTokens: compactionPolicy.reserveTokens,
|
|
235
240
|
minToolResultKeepChars: compactionPolicy.minToolResultKeepChars
|
|
236
241
|
}, compactionPolicy.maxActiveTranscriptBytes);
|
|
@@ -239,10 +244,12 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
239
244
|
...effectiveContext,
|
|
240
245
|
messages: assessed.messages
|
|
241
246
|
};
|
|
247
|
+
effectiveSystemPrompt = getCurrentSystemPrompt(effectiveContext.messages);
|
|
248
|
+
effectiveTools = getCurrentTools(effectiveContext.messages);
|
|
242
249
|
const promptCacheSnapshot = buildPromptCacheSnapshot({
|
|
243
250
|
model: streamModel,
|
|
244
|
-
systemPrompt:
|
|
245
|
-
tools:
|
|
251
|
+
systemPrompt: effectiveSystemPrompt,
|
|
252
|
+
tools: effectiveTools,
|
|
246
253
|
reasoning: options?.reasoning
|
|
247
254
|
});
|
|
248
255
|
const promptCacheChanges = observePromptCacheSnapshot(conversationId, promptCacheSnapshot);
|
|
@@ -251,18 +258,18 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
251
258
|
runId,
|
|
252
259
|
reusedRunner: reused,
|
|
253
260
|
modelRef: `${streamModel.provider}/${streamModel.id}`,
|
|
254
|
-
systemPromptLength:
|
|
255
|
-
messageCount: effectiveContext.messages.length,
|
|
261
|
+
systemPromptLength: effectiveSystemPrompt.length,
|
|
262
|
+
messageCount: effectiveContext.messages.filter((message) => message.role !== "system").length,
|
|
256
263
|
transcriptRepaired: hygienicMessages !== sourceMessages,
|
|
257
|
-
toolCount:
|
|
264
|
+
toolCount: effectiveTools.length,
|
|
258
265
|
lastUserMessagePreview: getLastUserMessagePreview(effectiveContext.messages),
|
|
259
266
|
loopWarningInjected: !!loopGuard.injection,
|
|
260
267
|
promptCache: promptCacheSnapshot,
|
|
261
268
|
promptCacheChanges,
|
|
262
269
|
...process.env.XOPC_LOG_LLM_PAYLOAD === "true" ? { effectiveContext: {
|
|
263
|
-
systemPrompt:
|
|
264
|
-
messages: effectiveContext.messages,
|
|
265
|
-
tools:
|
|
270
|
+
systemPrompt: effectiveSystemPrompt,
|
|
271
|
+
messages: effectiveContext.messages.filter((message) => message.role !== "system"),
|
|
272
|
+
tools: effectiveTools
|
|
266
273
|
} } : {}
|
|
267
274
|
}, "Sending messages to AI");
|
|
268
275
|
return streamFnWithXopcExtensions(streamModel, effectiveContext, { ...options });
|
|
@@ -339,9 +346,13 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
339
346
|
});
|
|
340
347
|
return checked;
|
|
341
348
|
};
|
|
342
|
-
session.agent.
|
|
349
|
+
const baseFinishTurn = session.agent.finishTurn;
|
|
350
|
+
session.agent.finishTurn = async (context, signal) => {
|
|
351
|
+
const baseDecision = await baseFinishTurn?.(context, signal);
|
|
352
|
+
if (baseDecision && baseDecision.action === "end") return { action: "end" };
|
|
343
353
|
policyStopped ||= params.turnPolicy?.shouldStopAfterTurn(context) ?? false;
|
|
344
|
-
|
|
354
|
+
if (policyStopped || connectionStopped || clarificationStopped) return { action: "end" };
|
|
355
|
+
if (baseDecision && baseDecision.action === "continue") return { action: "continue" };
|
|
345
356
|
};
|
|
346
357
|
unsubscribe = subscribeEmbeddedSessionEvents(session, (event) => {
|
|
347
358
|
if (event.type === "message_end" && event.message.role === "assistant") recordPromptCacheTouch(conversationId, resolvedModel, event.message.usage);
|
|
@@ -392,6 +403,7 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
392
403
|
conversationId,
|
|
393
404
|
transcriptRuntime,
|
|
394
405
|
policy: compactionPolicy,
|
|
406
|
+
systemPrompt: [systemPrompt, rootInstructions].filter(Boolean).join("\n\n"),
|
|
395
407
|
abortSignal: runAbortSignal,
|
|
396
408
|
onEvent
|
|
397
409
|
});
|
|
@@ -443,6 +455,7 @@ async function runXopcEmbeddedTurn(params) {
|
|
|
443
455
|
lastAssistantText: lastAssistantPlainText(session)
|
|
444
456
|
};
|
|
445
457
|
} finally {
|
|
458
|
+
session.agent.finishTurn = baseFinishTurn;
|
|
446
459
|
runAbortSignal.removeEventListener("abort", abortListener);
|
|
447
460
|
}
|
|
448
461
|
} catch (err) {
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
import { replaceAgentSystemPrompt } from "../prompt/agent-system-prompt.js";
|
|
1
2
|
//#region src/agent/embedded/system-prompt-override.ts
|
|
2
3
|
function applySystemPromptOverrideToSession(session, override) {
|
|
3
4
|
const prompt = override.trim();
|
|
4
|
-
session.agent.state.systemPrompt = prompt;
|
|
5
5
|
const mutableSession = session;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const applyOverride = (options) => {
|
|
7
|
+
if (options) options.forceSystemPrompt = prompt;
|
|
8
|
+
};
|
|
9
|
+
applyOverride(mutableSession._baseSystemPromptOptions);
|
|
10
|
+
applyOverride(mutableSession._runSystemPromptOptions);
|
|
11
|
+
const originalRebuild = mutableSession._xopcOriginalRebuildSystemPrompt ?? mutableSession._rebuildSystemPrompt?.bind(session);
|
|
12
|
+
if (originalRebuild && !mutableSession._xopcOriginalRebuildSystemPrompt) mutableSession._xopcOriginalRebuildSystemPrompt = originalRebuild;
|
|
13
|
+
if (originalRebuild) mutableSession._rebuildSystemPrompt = (toolNames) => {
|
|
14
|
+
const result = originalRebuild(toolNames);
|
|
15
|
+
applyOverride(mutableSession._baseSystemPromptOptions);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
replaceAgentSystemPrompt(session.agent, prompt);
|
|
8
19
|
}
|
|
9
20
|
//#endregion
|
|
10
21
|
export { applySystemPromptOverrideToSession };
|
|
@@ -2,6 +2,7 @@ import "../../providers/constants.js";
|
|
|
2
2
|
import { init_providers } from "../../providers/index.js";
|
|
3
3
|
import { createExtensionAwareStreamFn } from "../../providers/extension-stream-bridge.js";
|
|
4
4
|
import { preparePromptCacheContext, withPromptCachePayloadTransform } from "../../providers/prompt-cache-payload.js";
|
|
5
|
+
import { getCurrentSystemPrompt, getCurrentTools, normalizeContext } from "@earendil-works/pi-ai";
|
|
5
6
|
//#region src/agent/embedded/xopc-stream-bridge.ts
|
|
6
7
|
init_providers();
|
|
7
8
|
/**
|
|
@@ -16,8 +17,18 @@ init_providers();
|
|
|
16
17
|
function wrapStreamFnForXopcExtensions(originalStreamFn, promptCachePolicy) {
|
|
17
18
|
const extensionStreamFn = createExtensionAwareStreamFn();
|
|
18
19
|
return ((model, context, options) => {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const promptContext = {
|
|
21
|
+
systemPrompt: getCurrentSystemPrompt(context.messages),
|
|
22
|
+
tools: getCurrentTools(context.messages)
|
|
23
|
+
};
|
|
24
|
+
const preparedContext = preparePromptCacheContext(model, promptContext);
|
|
25
|
+
const providerContext = preparedContext.systemPrompt === promptContext.systemPrompt ? context : normalizeContext({
|
|
26
|
+
systemPrompt: preparedContext.systemPrompt,
|
|
27
|
+
tools: promptContext.tools,
|
|
28
|
+
messages: context.messages.filter((message) => message.role !== "system")
|
|
29
|
+
});
|
|
30
|
+
if (model.baseUrl === "extension://provider-plugin") return extensionStreamFn(model, providerContext, options);
|
|
31
|
+
return originalStreamFn(model, providerContext, withPromptCachePayloadTransform(model, promptContext, options, promptCachePolicy));
|
|
21
32
|
});
|
|
22
33
|
}
|
|
23
34
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAgentDefaultImageModelConfig, getAgentDefaultModelRef, init_schema, parseModelRef } from "../../config/schema.js";
|
|
2
2
|
import { init_agent_scope, resolveDefaultAgentId } from "../agent-scope.js";
|
|
3
|
-
import { resolveEffectiveAgentConfigForAgent } from "../../config/agent-profile.js";
|
|
4
3
|
import { getDefaultModelSync, getModelsByProvider, init_providers, isProviderConfiguredSync, resolveModel } from "../../providers/index.js";
|
|
4
|
+
import { resolveEffectiveAgentConfigForAgent } from "../../config/agent-profile.js";
|
|
5
5
|
import { resolveAgentModelFallbackValues, resolveAgentModelPrimaryValue } from "../../config/model-input.js";
|
|
6
6
|
import { buildCapabilityPlansForConfig } from "../../capabilities/readiness/from-config.js";
|
|
7
7
|
import "../../capabilities/readiness/index.js";
|
|
@@ -6,6 +6,9 @@ export type McpGatewayToolEntry = {
|
|
|
6
6
|
readOnly: boolean;
|
|
7
7
|
};
|
|
8
8
|
export type McpGatewayResourceEntry = {
|
|
9
|
+
id: string;
|
|
10
|
+
version: string;
|
|
11
|
+
serverId: string;
|
|
9
12
|
uri: string;
|
|
10
13
|
name: string;
|
|
11
14
|
title?: string;
|
|
@@ -27,6 +30,42 @@ export type McpGatewayCapabilitySummary = {
|
|
|
27
30
|
resources: McpGatewayResourceEntry[];
|
|
28
31
|
prompts: McpGatewayPromptEntry[];
|
|
29
32
|
};
|
|
33
|
+
export declare function listBundleMcpResourcesForGateway(params: {
|
|
34
|
+
workspaceDir: string;
|
|
35
|
+
cfg?: Config;
|
|
36
|
+
}): Promise<McpGatewayResourceEntry[]>;
|
|
37
|
+
export declare function readBundleMcpResourceForGateway(params: {
|
|
38
|
+
workspaceDir: string;
|
|
39
|
+
cfg?: Config;
|
|
40
|
+
sourceId: string;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
resource: McpGatewayResourceEntry;
|
|
43
|
+
contents: {
|
|
44
|
+
[x: string]: unknown;
|
|
45
|
+
contents: ({
|
|
46
|
+
uri: string;
|
|
47
|
+
text: string;
|
|
48
|
+
mimeType?: string;
|
|
49
|
+
_meta?: {
|
|
50
|
+
[x: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
uri: string;
|
|
54
|
+
blob: string;
|
|
55
|
+
mimeType?: string;
|
|
56
|
+
_meta?: {
|
|
57
|
+
[x: string]: unknown;
|
|
58
|
+
};
|
|
59
|
+
})[];
|
|
60
|
+
_meta?: {
|
|
61
|
+
[x: string]: unknown;
|
|
62
|
+
progressToken?: string | number;
|
|
63
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
64
|
+
taskId: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
}>;
|
|
30
69
|
export declare function listBundleMcpServerToolsForGateway(params: {
|
|
31
70
|
workspaceDir: string;
|
|
32
71
|
cfg?: Config;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mcpToolPolicyId } from "./bundle-mcp-policy.js";
|
|
2
2
|
import { createSessionMcpRuntime } from "./bundle-mcp-runtime.js";
|
|
3
|
+
import { decodeMcpResourceId, encodeMcpResourceId } from "./mcp-resource-id.js";
|
|
3
4
|
import crypto from "node:crypto";
|
|
4
5
|
//#region src/agent/mcp/bundle-mcp-gateway.ts
|
|
5
6
|
function mapTools(tools, serverId) {
|
|
@@ -12,6 +13,12 @@ function mapTools(tools, serverId) {
|
|
|
12
13
|
}
|
|
13
14
|
function mapResources(resources, serverId) {
|
|
14
15
|
return resources.filter((resource) => resource.serverName === serverId).map((resource) => ({
|
|
16
|
+
id: encodeMcpResourceId({
|
|
17
|
+
serverId: resource.serverName,
|
|
18
|
+
uri: resource.uri
|
|
19
|
+
}),
|
|
20
|
+
version: crypto.createHash("sha256").update(JSON.stringify(resource)).digest("hex"),
|
|
21
|
+
serverId: resource.serverName,
|
|
15
22
|
uri: resource.uri,
|
|
16
23
|
name: resource.name,
|
|
17
24
|
title: resource.title,
|
|
@@ -19,6 +26,30 @@ function mapResources(resources, serverId) {
|
|
|
19
26
|
mimeType: resource.mimeType
|
|
20
27
|
}));
|
|
21
28
|
}
|
|
29
|
+
async function listBundleMcpResourcesForGateway(params) {
|
|
30
|
+
const catalog = await loadCatalog(params);
|
|
31
|
+
return Object.keys(catalog.servers).sort().flatMap((serverId) => mapResources(catalog.resources, serverId));
|
|
32
|
+
}
|
|
33
|
+
async function readBundleMcpResourceForGateway(params) {
|
|
34
|
+
const identity = decodeMcpResourceId(params.sourceId);
|
|
35
|
+
if (!identity) throw new Error("Invalid MCP resource id");
|
|
36
|
+
const runtime = createSessionMcpRuntime({
|
|
37
|
+
sessionId: `mcp-resource:${crypto.randomUUID()}`,
|
|
38
|
+
workspaceDir: params.workspaceDir,
|
|
39
|
+
cfg: params.cfg
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
const resource = (await runtime.getCatalog()).resources.find((item) => item.serverName === identity.serverId && item.uri === identity.uri);
|
|
43
|
+
if (!resource) throw new Error("MCP resource is unavailable");
|
|
44
|
+
const contents = await runtime.readResource(identity.serverId, identity.uri);
|
|
45
|
+
return {
|
|
46
|
+
resource: mapResources([resource], identity.serverId)[0],
|
|
47
|
+
contents
|
|
48
|
+
};
|
|
49
|
+
} finally {
|
|
50
|
+
await runtime.dispose();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
22
53
|
function mapPrompts(prompts, serverId) {
|
|
23
54
|
return prompts.filter((prompt) => prompt.serverName === serverId).map((prompt) => ({
|
|
24
55
|
name: prompt.name,
|
|
@@ -58,4 +89,4 @@ async function listBundleMcpServerCapabilitiesForGateway(params) {
|
|
|
58
89
|
};
|
|
59
90
|
}
|
|
60
91
|
//#endregion
|
|
61
|
-
export { listBundleMcpServerCapabilitiesForGateway, listBundleMcpServerToolsForGateway };
|
|
92
|
+
export { listBundleMcpResourcesForGateway, listBundleMcpServerCapabilitiesForGateway, listBundleMcpServerToolsForGateway, readBundleMcpResourceForGateway };
|
|
@@ -329,6 +329,17 @@ function createSessionMcpRuntime(params) {
|
|
|
329
329
|
maxTotalTimeout: session.requestTimeoutMs
|
|
330
330
|
});
|
|
331
331
|
},
|
|
332
|
+
async readResource(serverName, uri, signal) {
|
|
333
|
+
failIfDisposed();
|
|
334
|
+
if (!(await getCatalog()).resources.some((resource) => resource.serverName === serverName && resource.uri === uri)) throw new Error(`bundle-mcp resource "${uri}" is not available from server "${serverName}"`);
|
|
335
|
+
const session = sessions.get(serverName);
|
|
336
|
+
if (!session) throw new Error(`bundle-mcp server "${serverName}" is not connected`);
|
|
337
|
+
return session.client.readResource({ uri }, {
|
|
338
|
+
signal,
|
|
339
|
+
timeout: session.requestTimeoutMs,
|
|
340
|
+
maxTotalTimeout: session.requestTimeoutMs
|
|
341
|
+
});
|
|
342
|
+
},
|
|
332
343
|
async dispose() {
|
|
333
344
|
if (disposed) return;
|
|
334
345
|
disposed = true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CallToolResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
1
|
+
import type { CallToolResult, ReadResourceResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
2
2
|
import type { JsonSchemaType } from "@modelcontextprotocol/sdk/validation/types.js";
|
|
3
3
|
import type { Config } from "../../config/schema.js";
|
|
4
4
|
export type McpServerCatalog = {
|
|
@@ -53,6 +53,7 @@ export type SessionMcpRuntime = {
|
|
|
53
53
|
getCatalog: () => Promise<McpToolCatalog>;
|
|
54
54
|
markUsed: () => void;
|
|
55
55
|
callTool: (serverName: string, toolName: string, input: unknown, signal?: AbortSignal) => Promise<CallToolResult>;
|
|
56
|
+
readResource: (serverName: string, uri: string, signal?: AbortSignal) => Promise<ReadResourceResult>;
|
|
56
57
|
dispose: () => Promise<void>;
|
|
57
58
|
};
|
|
58
59
|
export type SessionMcpRuntimeManager = {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/agent/mcp/mcp-resource-id.ts
|
|
2
|
+
function encodeMcpResourceId(identity) {
|
|
3
|
+
return Buffer.from(JSON.stringify(identity), "utf8").toString("base64url");
|
|
4
|
+
}
|
|
5
|
+
function decodeMcpResourceId(sourceId) {
|
|
6
|
+
try {
|
|
7
|
+
const value = JSON.parse(Buffer.from(sourceId, "base64url").toString("utf8"));
|
|
8
|
+
if (typeof value.serverId !== "string" || !value.serverId.trim()) return null;
|
|
9
|
+
if (typeof value.uri !== "string" || !value.uri.trim()) return null;
|
|
10
|
+
return {
|
|
11
|
+
serverId: value.serverId,
|
|
12
|
+
uri: value.uri
|
|
13
|
+
};
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { decodeMcpResourceId, encodeMcpResourceId };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_paths, resolveMcpOAuthPath } from "../../../config/paths.js";
|
|
2
1
|
import { init_write_file_atomic, writeTextAtomic } from "../../../infra/write-file-atomic.js";
|
|
2
|
+
import { init_paths, resolveMcpOAuthPath } from "../../../config/paths.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { readFile, rm } from "node:fs/promises";
|
|
5
5
|
//#region src/agent/mcp/oauth/mcp-oauth-store.ts
|
|
@@ -45,7 +45,7 @@ function evaluateContextBudget(input) {
|
|
|
45
45
|
const hardLimitTokens = Math.max(1024, contextWindow - reserveTokens);
|
|
46
46
|
const triggerThreshold = Math.min(.98, Math.max(.1, input.triggerThreshold ?? .8));
|
|
47
47
|
const triggerTokens = Math.min(hardLimitTokens, Math.floor(contextWindow * triggerThreshold));
|
|
48
|
-
const transcriptTokens = estimateMessagesTokens(input.messages);
|
|
48
|
+
const transcriptTokens = estimateMessagesTokens(input.systemPrompt === void 0 ? input.messages : input.messages.filter((message) => message.role !== "system"));
|
|
49
49
|
const systemPromptTokens = estimateTextTokens(input.systemPrompt ?? "");
|
|
50
50
|
const currentUserTokens = input.currentUserMessage ? estimateMessageTokens(input.currentUserMessage) : 0;
|
|
51
51
|
const toolSchemaTokens = estimateToolSchemaTokens(input.tools ?? []);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AfterToolCallContext, BeforeToolCallContext, BeforeToolCallResult
|
|
1
|
+
import type { AfterToolCallContext, AgentTurnContext, BeforeToolCallContext, BeforeToolCallResult } from '@earendil-works/pi-agent-core';
|
|
2
2
|
export interface AgentTurnPolicy {
|
|
3
3
|
reset(): void;
|
|
4
4
|
beforeToolCall(context: BeforeToolCallContext, signal?: AbortSignal): Promise<BeforeToolCallResult | undefined>;
|
|
5
5
|
afterToolCall(context: AfterToolCallContext): Promise<undefined>;
|
|
6
|
-
shouldStopAfterTurn(context:
|
|
6
|
+
shouldStopAfterTurn(context: AgentTurnContext): boolean;
|
|
7
7
|
}
|
|
8
8
|
export interface AgentTurnPolicyOptions {
|
|
9
9
|
maxTurns?: number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getCurrentSystemMessage } from "@earendil-works/pi-ai";
|
|
2
|
+
//#region src/agent/prompt/agent-system-prompt.ts
|
|
3
|
+
/** Replace the replayed prompt while preserving the transcript's current tool declarations. */
|
|
4
|
+
function replaceAgentSystemPrompt(agent, systemPrompt) {
|
|
5
|
+
const messages = agent.state.messages;
|
|
6
|
+
const current = getCurrentSystemMessage(messages);
|
|
7
|
+
const systemMessage = {
|
|
8
|
+
role: "system",
|
|
9
|
+
content: systemPrompt,
|
|
10
|
+
...current?.toolsAdded ? { toolsAdded: current.toolsAdded } : {},
|
|
11
|
+
timestamp: current?.timestamp ?? Date.now()
|
|
12
|
+
};
|
|
13
|
+
agent.state.messages = [systemMessage, ...messages.filter((message) => message.role !== "system")];
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { replaceAgentSystemPrompt };
|
|
@@ -2,11 +2,11 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { parseNoteAttachmentTarget } from "../notes/attachment-ref.js";
|
|
4
4
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
5
|
-
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
6
5
|
import { init_agent_scope, resolveAgentHomeDir, resolveDefaultAgentId } from "./agent-scope.js";
|
|
7
6
|
import { init_agent_session_key, resolveAgentIdFromConversationId } from "../routing/agent-session-key.js";
|
|
8
|
-
import { extractProfileAgentId } from "../config/agent-profile.js";
|
|
9
7
|
import { init_providers, resolveModel } from "../providers/index.js";
|
|
8
|
+
import { applyConfigOverrides } from "../config/runtime-overrides.js";
|
|
9
|
+
import { extractProfileAgentId } from "../config/agent-profile.js";
|
|
10
10
|
import { extractTextContent } from "./context/workspace.js";
|
|
11
11
|
import { effectiveWorkspacePathForSession } from "../session/session-workspace.js";
|
|
12
12
|
import { getProjectForSession } from "../projects/workspace.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
3
|
import { init_workspace_defaults, resolveDefaultAgentWorkspaceDir } from "../../config/workspace-defaults.js";
|
|
4
|
-
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
5
4
|
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
5
|
+
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
6
6
|
import { getExecutionEnvironmentForSession } from "../../execution-environments/subject.js";
|
|
7
7
|
import { effectiveWorkspacePathForSession, projectWorkspacePath } from "../../session/session-workspace.js";
|
|
8
8
|
import { getProjectForSession } from "../../projects/workspace.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { init_paths, resolveSkillsLockPath } from "../../config/paths.js";
|
|
2
1
|
import { init_write_file_atomic, writeTextAtomicSync } from "../../infra/write-file-atomic.js";
|
|
2
|
+
import { init_paths, resolveSkillsLockPath } from "../../config/paths.js";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
//#region src/agent/skills/hub-lock.ts
|
|
5
5
|
/**
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BrowserObservation } from '@xopcai/browser-control-contract';
|
|
2
|
+
import type { AgentSourceContext } from './types.js';
|
|
3
|
+
export declare function buildBrowserTabAgentContext(sourceId: string, observation: BrowserObservation, expectedVersion?: string): AgentSourceContext | null;
|