@xopcai/xopc 0.0.170 → 0.0.172
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-CkUp1qvf.js → activity-store-C3Y-bESI.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DDuem4HM.js → agent-avatar-dicebear-CPyev9P7.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Bf_kK2Ay.js +2 -0
- package/dist/gateway/static/root/assets/{api-BnuPQhJW.js → api-B7qEr_Rw.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DdZw8Hi1.js → app-management-settings-panel-Br_9-7fs.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BN8Vk2bX.js → appearance-settings-uyLcRPai.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DXFCP5-1.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-C82MaDQj.js → archive-plugin-B19REnR5.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-uilrwSdW.js → attachment-load-DLWCC4Yi.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CkDZjAmy.js → automation-suggestion-card-ky5S5lly.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-D8pT1o2O.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-B7NTL0_T.js → binary-plugins-CtPEzLlo.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D_LDNlB-.js → block-editor-CQVR4Xij.js} +32 -32
- package/dist/gateway/static/root/assets/browser-settings-page-Bav_skKN.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-UFVUzn4v.js → browser-workflow-inputs-CimCGbhq.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CGgC0N92.js → browser-workflows-page-DewuCw3p.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BHaYYo9E.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-DUIorGUd.js → capability-presets-api-B5RTs-Az.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-PTz00nR4.js → capability-presets-settings-panel-BgchTh81.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-BYwSB8c6.js → channel-recipient-api-Czu0YzIZ.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-BP0e62wt.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-DBWKfeGe.js +1 -0
- package/dist/gateway/static/root/assets/connector-logo-Di3gnR_D.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-CC5kh0de.js +2 -0
- package/dist/gateway/static/root/assets/{desktop-pet-CkT98fPT.js → desktop-pet-D-ZUNHhn.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DkbIzdA3.js → desktop-pet-settings-C3L6AI8_.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-dBQvj1sG.js → directory-picker-path-field-Dvq4iG6P.js} +1 -1
- package/dist/gateway/static/root/assets/dreaming-settings-D9i54kWO.js +3 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-BfxoIiNo.js → extension-debug-page-BecQjU0J.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-EIJ3wIb7.js → extension-page-BeVkPSm-.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DBBec51N.js → extension-settings-page-DMoo2mKx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-4_u53Ufq.js → gateway-config-api-Bthb3_6v.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-v9kJM59H.js → gateway-settings-Bh8nPvJQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CXITih5d.js → gateway-startup-retry-D3USVm9D.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-Dp0AyDHI.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-CNt7nrdS.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-D54YQPon.js → goals-config-api-C_2QWBtb.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-Bm_NZFiZ.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-DDezXaVi.js → goals-settings-DhL643tc.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CRsIUeZN.js → heartbeat-settings-COVFwp7C.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-CY6cQUHL.js → image-generation-api-BNQlnwpU.js} +1 -1
- package/dist/gateway/static/root/assets/index-C_XSKOH6.css +1 -0
- package/dist/gateway/static/root/assets/{index-Dfq2laZe.js → index-DUasAutC.js} +67 -67
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D9k7EDdY.js → keyboard-shortcuts-settings-DfdJRJVy.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DZwkD1co.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DbaiBolh.js → local-apps-page-BvCPOgoi.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Dqp9H2Uf.js → locale-store-BP0vD37A.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DoCY0Mm9.js → logs-page-dNL0Y1dA.js} +3 -3
- package/dist/gateway/static/root/assets/{markdown-split-BGlQR-Be.js → markdown-split-YO1rDk9m.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BpaeV6f_.js → media-plugins-CU_RRf-q.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BWtP5TFz.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-Cd2HpciM.js → notes-page-CeFiOK3S.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-B8MKxpZb.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-DyimBUp_.js → page-tabs-tiHmRJUA.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BKZulEYr.js → preview-open-alternatives-CU6XgaCz.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-Bjz9BxBY.js → product-open-page-Dn4_qor4.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CWBuuX-S.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BJSsLsXH.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-DXJDb8vB.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BPTqb2_r.js → save-bar-controls-edDUIbXo.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-YN0D81Dk.js → schedule-field-DqJO_5Yb.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BmY5PSS2.js → schema-form-CMh0jzy5.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-DeHpWgxM.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-Cf-TEYUd.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-B-RhgD_p.js → settings-form-section-Bb0Bc3nJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DkPupX2B.js → settings-loading-skeleton-DQhADvz1.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-2QBMvaxj.js → settings-page-b0M5HukN.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CtrW-LD6.js → settings-page-layout-hvjtIjvh.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BFyfed_g.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BezIW1n9.js → share-preview-page-rbeaOpTg.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CYnH9sTt.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-Cr8_m-jS.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Chtc1xDO.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-WAFhKyAu.js → system-settings-panel-BHo_hgnL.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BiC0gIBa.js → theme-store-C3KnnjcU.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-D-G-uwVJ.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-WAQO3F_8.js → typed-models-lib-DtRnG-YI.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CKlfsSeU.js → use-channel-catalog-CWWItX2g.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-D7qMR26X.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BAFHF0_v.js → voice-api-key-field-BTnltQHZ.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CpqFZze9.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-t4dXpGC0.js +1 -0
- package/dist/gateway/static/root/assets/work-page-BXwDKiMZ.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-1OP4HyvS.js → workflow-run-setup-panel-D7vKChFZ.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Bos9HyqT.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +71 -24
- package/dist/src/agent/embedded/run-turn.js +68 -4
- package/dist/src/agent/inbound/inbound-loop.d.ts +0 -2
- package/dist/src/agent/inbound/inbound-loop.js +0 -2
- package/dist/src/agent/memory/builtin-provider.js +4 -4
- package/dist/src/agent/memory/compaction-planner.d.ts +16 -0
- package/dist/src/agent/memory/compaction-planner.js +152 -0
- package/dist/src/agent/memory/compaction-policy.d.ts +10 -0
- package/dist/src/agent/memory/compaction-policy.js +24 -0
- package/dist/src/agent/memory/compaction.d.ts +21 -22
- package/dist/src/agent/memory/compaction.js +220 -194
- package/dist/src/agent/memory/context-budget.d.ts +40 -0
- package/dist/src/agent/memory/context-budget.js +106 -0
- package/dist/src/agent/memory/manager.d.ts +4 -1
- package/dist/src/agent/memory/manager.js +8 -3
- package/dist/src/agent/memory/understanding/service.d.ts +2 -0
- package/dist/src/agent/memory/understanding/service.js +11 -9
- package/dist/src/agent/orchestration/context-overflow.d.ts +1 -0
- package/dist/src/agent/orchestration/context-overflow.js +19 -0
- package/dist/src/agent/orchestration/loop-guard.js +13 -9
- package/dist/src/agent/reply/post-compaction-context.d.ts +4 -0
- package/dist/src/agent/reply/post-compaction-context.js +5 -3
- package/dist/src/agent/service/process-direct-one-shot.js +1 -2
- package/dist/src/agent/service/process-direct-streaming.js +1 -2
- package/dist/src/agent/service.d.ts +1 -2
- package/dist/src/agent/service.js +16 -44
- package/dist/src/agent/session/session-inspector.js +10 -2
- package/dist/src/automations/domain/validation.d.ts +8 -8
- package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/schema.d.ts +17 -1
- package/dist/src/connectors/composio-sessions.d.ts +1 -0
- package/dist/src/connectors/composio-sessions.js +14 -5
- package/dist/src/connectors/composio-triggers.d.ts +1 -1
- package/dist/src/connectors/composio-triggers.js +4 -3
- package/dist/src/connectors/composio.js +1 -0
- package/dist/src/connectors/{connector-memory-sync.d.ts → connected-source-ingestion.d.ts} +11 -4
- package/dist/src/connectors/{connector-memory-sync.js → connected-source-ingestion.js} +49 -101
- package/dist/src/connectors/connected-source-normalizers.d.ts +15 -0
- package/dist/src/connectors/connected-source-normalizers.js +186 -0
- package/dist/src/connectors/connector-identity.d.ts +2 -0
- package/dist/src/connectors/connector-identity.js +29 -0
- package/dist/src/connectors/learning-coordinator.d.ts +25 -0
- package/dist/src/connectors/learning-coordinator.js +214 -0
- package/dist/src/connectors/learning-recipes.d.ts +22 -0
- package/dist/src/connectors/learning-recipes.js +121 -0
- package/dist/src/connectors/runtime-status.d.ts +1 -8
- package/dist/src/connectors/runtime-status.js +4 -29
- package/dist/src/gateway/hono/lib/config-payload.d.ts +23 -0
- package/dist/src/gateway/hono/lib/config-payload.js +3 -0
- package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +28 -0
- package/dist/src/gateway/hono/routes/connectors.js +76 -118
- package/dist/src/gateway/hono/routes/models.js +24 -0
- package/dist/src/gateway/hono/routes/public-gateway.js +3 -2
- package/dist/src/gateway/hono/routes/sessions.js +17 -42
- package/dist/src/gateway/hono/routes/you.js +86 -5
- package/dist/src/gateway/service/sessions-api.d.ts +2 -3
- package/dist/src/gateway/service/sessions-api.js +4 -7
- package/dist/src/gateway/service.d.ts +5 -2
- package/dist/src/gateway/service.js +16 -11
- package/dist/src/knowledge/connected-understanding-pipeline.d.ts +19 -0
- package/dist/src/knowledge/connected-understanding-pipeline.js +268 -0
- package/dist/src/knowledge/index.d.ts +1 -0
- package/dist/src/knowledge/index.js +2 -1
- package/dist/src/knowledge/ingestion-service.d.ts +6 -4
- package/dist/src/knowledge/ingestion-service.js +13 -10
- package/dist/src/knowledge/local-folder-adapter.js +1 -0
- package/dist/src/knowledge/people-graph.js +43 -110
- package/dist/src/knowledge/types.d.ts +3 -0
- package/dist/src/providers/xopc-cloud-account-service.d.ts +40 -0
- package/dist/src/providers/xopc-cloud-account-service.js +65 -0
- package/dist/src/session/index.d.ts +1 -2
- package/dist/src/session/index.js +1 -2
- package/dist/src/session/init-session-turn.d.ts +0 -1
- package/dist/src/session/init-session-turn.js +1 -2
- package/dist/src/session/manager.d.ts +11 -17
- package/dist/src/session/manager.js +11 -14
- package/dist/src/session/session-context-for-llm.d.ts +19 -1
- package/dist/src/session/session-context-for-llm.js +87 -129
- package/dist/src/session/store.d.ts +28 -23
- package/dist/src/session/store.js +94 -83
- package/dist/src/session/transcript-format.d.ts +2 -8
- package/dist/src/session/types.d.ts +8 -6
- package/dist/src/session/user-round-delete.d.ts +3 -6
- package/dist/src/session/user-round-delete.js +12 -16
- package/dist/src/storage/sqlite/connector-learning-repository.d.ts +47 -0
- package/dist/src/storage/sqlite/connector-learning-repository.js +110 -0
- package/dist/src/storage/sqlite/index.d.ts +4 -2
- package/dist/src/storage/sqlite/index.js +5 -3
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +4 -2
- package/dist/src/storage/sqlite/knowledge-repository.js +24 -13
- package/dist/src/storage/sqlite/migrations/060_remove_runtime_transcript_messages.sql +45 -0
- package/dist/src/storage/sqlite/migrations/061_drop_compaction_checkpoints.sql +2 -0
- package/dist/src/storage/sqlite/migrations/062_connector_learning_jobs.sql +27 -0
- package/dist/src/storage/sqlite/migrations/063_knowledge_collection_scopes.sql +14 -0
- package/dist/src/storage/sqlite/migrations/064_user_claims.sql +60 -0
- package/dist/src/storage/sqlite/migrations/065_knowledge_item_scope_identity.sql +116 -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/storage/sqlite/schema.sql +0 -19
- package/dist/src/storage/sqlite/transcript-repository.d.ts +6 -11
- package/dist/src/storage/sqlite/transcript-repository.js +90 -84
- package/dist/src/storage/sqlite/user-claims-repository.d.ts +101 -0
- package/dist/src/storage/sqlite/user-claims-repository.js +241 -0
- package/dist/src/user-context/config.d.ts +67 -2
- package/dist/src/user-context/config.js +36 -3
- package/dist/src/user-context/projection.d.ts +36 -1
- package/dist/src/user-context/projection.js +84 -6
- package/dist/src/work-discovery/service.js +1 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-BiaQhiQp.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-CuL8Q4yF.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-TZOluRNp.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-C-l6O68Z.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BW8c0xPp.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-h9CsE0GT.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-C058Mcfr.js +0 -1
- package/dist/gateway/static/root/assets/connector-logo-CsbegNqi.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BWALafGW.js +0 -2
- package/dist/gateway/static/root/assets/dreaming-settings-DkdnKMZx.js +0 -3
- package/dist/gateway/static/root/assets/goal-create-dialog-y2Y3p7_k.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DuzL-alv.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-OeLtfKI2.js +0 -2
- package/dist/gateway/static/root/assets/index-o4uaOGKT.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-3ssYIEK6.js +0 -2
- package/dist/gateway/static/root/assets/messages-KEk-hTFt.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-CatZNAPc.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-DJUOgqm4.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BQQAD_nu.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-fIGXTTnA.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BuU-8FCe.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DlKoeZm3.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BSUcDFnb.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Bk2-SwGJ.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-e_Fx1kVC.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-D_cCADfj.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-fqRXpNJV.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-9Ov4htPW.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-DGN2FxWv.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-HmyWSgUo.js +0 -1
- package/dist/gateway/static/root/assets/work-page-D3iKVjFq.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-B5L4SFw4.js +0 -11
- package/dist/src/agent/lifecycle/handlers/compaction.d.ts +0 -13
- package/dist/src/agent/lifecycle/handlers/compaction.js +0 -18
- package/dist/src/connectors/memory-sync-coordinator.d.ts +0 -28
- package/dist/src/connectors/memory-sync-coordinator.js +0 -162
- package/dist/src/connectors/memory-sync-profile.d.ts +0 -13
- package/dist/src/connectors/memory-sync-profile.js +0 -73
- package/dist/src/session/compaction-checkpoints.d.ts +0 -8
- package/dist/src/session/compaction-checkpoints.js +0 -19
|
@@ -19,7 +19,9 @@ export declare class UserUnderstandingService {
|
|
|
19
19
|
agentId?: string;
|
|
20
20
|
sessionKey?: string;
|
|
21
21
|
sourceItemId?: string;
|
|
22
|
+
sourceItemIds?: string[];
|
|
22
23
|
sourceText?: string;
|
|
24
|
+
source?: MemoryRecord['source'];
|
|
23
25
|
reviewSource?: 'turn' | 'background';
|
|
24
26
|
supersedesRecordIds?: string[];
|
|
25
27
|
}): Promise<Omit<UnderstandingReviewResult, 'sourceItemId'>>;
|
|
@@ -92,6 +92,7 @@ var UserUnderstandingService = class {
|
|
|
92
92
|
const contentHash = createHash("sha256").update(sourceText).digest("hex");
|
|
93
93
|
const sourceItemId = upsertKnowledgeSourceItems([{
|
|
94
94
|
sourceInstanceId: params.sessionKey ? `session:${params.sessionKey}` : "session:unknown",
|
|
95
|
+
collectionScope: "conversation",
|
|
95
96
|
externalId: contentHash,
|
|
96
97
|
itemType: "conversation_turn",
|
|
97
98
|
authorRole: "user",
|
|
@@ -136,20 +137,21 @@ var UserUnderstandingService = class {
|
|
|
136
137
|
const key = candidate.canonicalKey ?? canonicalKey(candidate.kind, content);
|
|
137
138
|
const supersedesRecordId = correctionTargets.length === 1 ? correctionTargets[0] : void 0;
|
|
138
139
|
const existing = await this.options.list(key);
|
|
139
|
-
const
|
|
140
|
-
|
|
140
|
+
const sourceItemIds = [...new Set([...context.sourceItemId ? [context.sourceItemId] : [], ...context.sourceItemIds ?? []])];
|
|
141
|
+
const evidence = (sourceItemIds.length ? sourceItemIds : [void 0]).map((sourceItemId) => ({
|
|
142
|
+
...sourceItemId ? { sourceItemId } : {},
|
|
141
143
|
relation: "supports",
|
|
142
144
|
...context.sessionKey ? { sessionKey: context.sessionKey } : {},
|
|
143
145
|
...evidenceText ? { sourceText: evidenceText } : {},
|
|
144
146
|
observedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
145
147
|
confidence: candidate.confidence
|
|
146
|
-
};
|
|
148
|
+
}));
|
|
147
149
|
if (existing[0]) {
|
|
148
150
|
deduplicated += 1;
|
|
149
151
|
recordIds.push(existing[0].id);
|
|
150
|
-
|
|
152
|
+
for (const sourceItemId of sourceItemIds) attachMemoryEvidence({
|
|
151
153
|
recordId: existing[0].id,
|
|
152
|
-
sourceItemId
|
|
154
|
+
sourceItemId,
|
|
153
155
|
relation: "supports",
|
|
154
156
|
excerpt: evidenceText,
|
|
155
157
|
confidence: candidate.confidence
|
|
@@ -166,7 +168,7 @@ var UserUnderstandingService = class {
|
|
|
166
168
|
} : void 0,
|
|
167
169
|
target: candidate.kind === "preference" ? "user" : "memory",
|
|
168
170
|
tags: [...new Set(["user-understanding", ...candidate.tags ?? []])],
|
|
169
|
-
source: { provider: "user-understanding" },
|
|
171
|
+
source: context.source ?? { provider: "user-understanding" },
|
|
170
172
|
confidence: candidate.confidence,
|
|
171
173
|
status: "candidate",
|
|
172
174
|
sensitivity,
|
|
@@ -174,7 +176,7 @@ var UserUnderstandingService = class {
|
|
|
174
176
|
durability: candidate.durability,
|
|
175
177
|
importance: candidate.importance,
|
|
176
178
|
disclosurePolicy: candidate.disclosurePolicy,
|
|
177
|
-
evidence
|
|
179
|
+
evidence,
|
|
178
180
|
validFrom: candidate.validFrom,
|
|
179
181
|
validTo: candidate.validTo,
|
|
180
182
|
reviewAfter: nextMemoryReviewAt({
|
|
@@ -194,9 +196,9 @@ var UserUnderstandingService = class {
|
|
|
194
196
|
kind: write.record.kind
|
|
195
197
|
});
|
|
196
198
|
}
|
|
197
|
-
|
|
199
|
+
for (const sourceItemId of write.record ? sourceItemIds : []) attachMemoryEvidence({
|
|
198
200
|
recordId: write.record.id,
|
|
199
|
-
sourceItemId
|
|
201
|
+
sourceItemId,
|
|
200
202
|
relation: "supports",
|
|
201
203
|
excerpt: evidenceText,
|
|
202
204
|
confidence: candidate.confidence
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isContextOverflowError(value: unknown): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/agent/orchestration/context-overflow.ts
|
|
2
|
+
const CONTEXT_OVERFLOW_PATTERNS = [
|
|
3
|
+
/context(?:_|\s|-)*(?:length|window).*(?:exceed|limit|maximum|too (?:large|long))/i,
|
|
4
|
+
/maximum context length/i,
|
|
5
|
+
/max(?:imum)? tokens?.*(?:exceed|limit)/i,
|
|
6
|
+
/too many tokens/i,
|
|
7
|
+
/prompt (?:is )?too (?:large|long)/i,
|
|
8
|
+
/request (?:is )?too large/i,
|
|
9
|
+
/input (?:is )?too (?:large|long)/i,
|
|
10
|
+
/input token count.*exceed/i,
|
|
11
|
+
/reduce (?:the )?(?:length|size) of (?:the )?(?:messages|prompt|input)/i,
|
|
12
|
+
/token limit exceeded/i
|
|
13
|
+
];
|
|
14
|
+
function isContextOverflowError(value) {
|
|
15
|
+
const message = value instanceof Error ? value.message : String(value ?? "");
|
|
16
|
+
return CONTEXT_OVERFLOW_PATTERNS.some((pattern) => pattern.test(message));
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { isContextOverflowError };
|
|
@@ -11,12 +11,16 @@ const DEFAULT_CONFIG = {
|
|
|
11
11
|
* Stable fingerprint for tool call comparison.
|
|
12
12
|
* Recursively sorts object keys; truncates long string values.
|
|
13
13
|
*/
|
|
14
|
-
function
|
|
15
|
-
return
|
|
16
|
-
if (typeof
|
|
17
|
-
if (typeof
|
|
18
|
-
return
|
|
19
|
-
})
|
|
14
|
+
function stableJson(value) {
|
|
15
|
+
return JSON.stringify(value, (_key, item) => {
|
|
16
|
+
if (typeof item === "object" && item !== null && !Array.isArray(item)) return Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b)));
|
|
17
|
+
if (typeof item === "string" && item.length > 200) return `${item.slice(0, 80)}…[${item.length}]`;
|
|
18
|
+
return item;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function fingerprint(call) {
|
|
22
|
+
const result = call.resultPreview === void 0 ? "" : `::result=${stableJson(call.resultPreview)}`;
|
|
23
|
+
return `${call.name}::${stableJson(call.params)}${result}`;
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
26
|
* Analyze recent tool calls and produce loop guard result.
|
|
@@ -70,11 +74,11 @@ function findConsecutiveRepeats(calls) {
|
|
|
70
74
|
let index = calls.length - 1;
|
|
71
75
|
while (index >= 0) {
|
|
72
76
|
const current = calls[index];
|
|
73
|
-
const fp = fingerprint(current
|
|
77
|
+
const fp = fingerprint(current);
|
|
74
78
|
let count = 1;
|
|
75
79
|
while (index - count >= 0) {
|
|
76
80
|
const prev = calls[index - count];
|
|
77
|
-
if (fingerprint(prev
|
|
81
|
+
if (fingerprint(prev) !== fp) break;
|
|
78
82
|
count++;
|
|
79
83
|
}
|
|
80
84
|
if (count >= 2) groups.push({
|
|
@@ -92,7 +96,7 @@ function findConsecutiveRepeats(calls) {
|
|
|
92
96
|
function countFrequency(calls) {
|
|
93
97
|
const map = /* @__PURE__ */ new Map();
|
|
94
98
|
for (const call of calls) {
|
|
95
|
-
const fp = fingerprint(call
|
|
99
|
+
const fp = fingerprint(call);
|
|
96
100
|
map.set(fp, (map.get(fp) ?? 0) + 1);
|
|
97
101
|
}
|
|
98
102
|
return map;
|
|
@@ -5,6 +5,8 @@ export type PostCompactionContextOptions = {
|
|
|
5
5
|
agentId?: string;
|
|
6
6
|
nowMs?: number;
|
|
7
7
|
userTimezone?: string;
|
|
8
|
+
sectionNames?: string[];
|
|
9
|
+
maxContextChars?: number;
|
|
8
10
|
};
|
|
9
11
|
export declare function readPostCompactionContextFromAgentsMd(agentsMdContent: string, options?: PostCompactionContextOptions): string | null;
|
|
10
12
|
export declare function readPostCompactionContext(params: {
|
|
@@ -13,4 +15,6 @@ export declare function readPostCompactionContext(params: {
|
|
|
13
15
|
agentId?: string;
|
|
14
16
|
nowMs?: number;
|
|
15
17
|
userTimezone?: string;
|
|
18
|
+
sectionNames?: string[];
|
|
19
|
+
maxContextChars?: number;
|
|
16
20
|
}): string | null;
|
|
@@ -53,7 +53,7 @@ function extractSections(content, sectionNames, foundNames) {
|
|
|
53
53
|
return results;
|
|
54
54
|
}
|
|
55
55
|
function readPostCompactionContextFromAgentsMd(agentsMdContent, options) {
|
|
56
|
-
const sectionNames = DEFAULT_POST_COMPACTION_SECTIONS;
|
|
56
|
+
const sectionNames = options?.sectionNames ?? DEFAULT_POST_COMPACTION_SECTIONS;
|
|
57
57
|
if (sectionNames.length === 0) return null;
|
|
58
58
|
const foundSectionNames = [];
|
|
59
59
|
const sections = extractSections(agentsMdContent, sectionNames, foundSectionNames);
|
|
@@ -62,7 +62,7 @@ function readPostCompactionContextFromAgentsMd(agentsMdContent, options) {
|
|
|
62
62
|
const timezone = options?.userTimezone?.trim() || Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
63
63
|
const nowMs = options?.nowMs ?? Date.now();
|
|
64
64
|
const dateStamp = new Intl.DateTimeFormat("en-CA", { timeZone: timezone }).format(new Date(nowMs));
|
|
65
|
-
const maxContextChars = MAX_CONTEXT_CHARS;
|
|
65
|
+
const maxContextChars = Math.max(1, options?.maxContextChars ?? MAX_CONTEXT_CHARS);
|
|
66
66
|
const combined = sections.join("\n\n").replaceAll("YYYY-MM-DD", dateStamp);
|
|
67
67
|
const safeContent = combined.length > maxContextChars ? `${combined.slice(0, maxContextChars)}\n...[truncated]...` : combined;
|
|
68
68
|
const isDefaultSections = sectionNames.length === DEFAULT_POST_COMPACTION_SECTIONS.length && sectionNames.every((name, index) => normalizeHeading(name) === normalizeHeading(DEFAULT_POST_COMPACTION_SECTIONS[index] ?? ""));
|
|
@@ -84,7 +84,9 @@ function readPostCompactionContext(params) {
|
|
|
84
84
|
cfg,
|
|
85
85
|
agentId,
|
|
86
86
|
nowMs: params.nowMs,
|
|
87
|
-
userTimezone: params.userTimezone
|
|
87
|
+
userTimezone: params.userTimezone,
|
|
88
|
+
sectionNames: params.sectionNames,
|
|
89
|
+
maxContextChars: params.maxContextChars
|
|
88
90
|
});
|
|
89
91
|
} catch {
|
|
90
92
|
return null;
|
|
@@ -17,8 +17,7 @@ async function runProcessDirect(deps, input) {
|
|
|
17
17
|
cfg: deps.config,
|
|
18
18
|
sessionKey: input.sessionKey,
|
|
19
19
|
body: input.content,
|
|
20
|
-
resetSession: deps.resetSession
|
|
21
|
-
skipImplicitExpiry: channel === "webchat"
|
|
20
|
+
resetSession: deps.resetSession
|
|
22
21
|
});
|
|
23
22
|
resetTriggeredAtInit = turn.resetTriggered;
|
|
24
23
|
if (turn.bareReset && turn.ackMessage) return turn.ackMessage;
|
|
@@ -154,8 +154,7 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
154
154
|
cfg,
|
|
155
155
|
sessionKey,
|
|
156
156
|
body: input.content,
|
|
157
|
-
resetSession: deps.resetSession
|
|
158
|
-
skipImplicitExpiry: channel === "webchat"
|
|
157
|
+
resetSession: deps.resetSession
|
|
159
158
|
});
|
|
160
159
|
resetTriggeredAtInit = turn.resetTriggered;
|
|
161
160
|
if (turn.bareReset && turn.ackMessage) {
|
|
@@ -102,7 +102,6 @@ export declare class AgentService {
|
|
|
102
102
|
private createHookRunner;
|
|
103
103
|
private createProgressManager;
|
|
104
104
|
private initializeReliabilityModules;
|
|
105
|
-
private initializeLifecycleHandlers;
|
|
106
105
|
setChannelManager(channelManager: ChannelManager): void;
|
|
107
106
|
/**
|
|
108
107
|
* Apply config after save or hot reload so the default model updates without restarting the gateway.
|
|
@@ -118,6 +117,7 @@ export declare class AgentService {
|
|
|
118
117
|
refreshSkillsAfterSkillConfigChange(): void;
|
|
119
118
|
refreshActionTrustPolicy(): void;
|
|
120
119
|
refreshUserProfileContext(): void;
|
|
120
|
+
getMemoryManager(): import("./memory/manager.js").MemoryManager;
|
|
121
121
|
getModelForSession(sessionKey: string): string;
|
|
122
122
|
switchModelForSession(sessionKey: string, modelId: string): Promise<boolean>;
|
|
123
123
|
/**
|
|
@@ -191,7 +191,6 @@ export declare class AgentService {
|
|
|
191
191
|
* Handle events from a specific session's agent
|
|
192
192
|
*/
|
|
193
193
|
private handleSessionEvent;
|
|
194
|
-
private checkAndCompact;
|
|
195
194
|
private getContextWindowForSession;
|
|
196
195
|
private dispose;
|
|
197
196
|
}
|
|
@@ -15,6 +15,7 @@ import { onSessionTranscriptUpdate } from "../session/transcript-events.js";
|
|
|
15
15
|
import { persistInboundAttachments } from "../channels/attachments/inbound-persist.js";
|
|
16
16
|
import { AgentManager } from "./agent-manager.js";
|
|
17
17
|
import { maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle } from "../session/session-title.js";
|
|
18
|
+
import { resolveCompactionPolicy } from "./memory/compaction-policy.js";
|
|
18
19
|
import { SessionStore } from "../session/store.js";
|
|
19
20
|
import { SessionConfigStore } from "../session/config-store.js";
|
|
20
21
|
import "../session/index.js";
|
|
@@ -38,7 +39,6 @@ import "./middleware/index.js";
|
|
|
38
39
|
import { TurnDiffTracker } from "./coding/turn-diff-tracker.js";
|
|
39
40
|
import { LifecycleManager } from "./lifecycle/manager.js";
|
|
40
41
|
import "./lifecycle/index.js";
|
|
41
|
-
import { CompactionLifecycleHandler } from "./lifecycle/handlers/compaction.js";
|
|
42
42
|
import { MessageRouter } from "./messaging/message-router.js";
|
|
43
43
|
import { CommandHandler } from "./messaging/command-handler.js";
|
|
44
44
|
import { StreamManager } from "./messaging/stream-manager.js";
|
|
@@ -203,10 +203,20 @@ var AgentService = class {
|
|
|
203
203
|
return this.currentContext?.sessionKey;
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
|
+
this.sessionStore.setCompactionHooks({
|
|
207
|
+
before: ({ sessionKey, messageCount, tokenCount }) => this.hookHandler.triggerWithSessionKey(sessionKey, "before_compaction", {
|
|
208
|
+
messageCount,
|
|
209
|
+
tokenCount
|
|
210
|
+
}),
|
|
211
|
+
after: ({ sessionKey, messageCount, tokenCount, compactedCount }) => this.hookHandler.triggerWithSessionKey(sessionKey, "after_compaction", {
|
|
212
|
+
messageCount,
|
|
213
|
+
tokenCount,
|
|
214
|
+
compactedCount
|
|
215
|
+
})
|
|
216
|
+
});
|
|
206
217
|
this.progressManager = this.createProgressManager();
|
|
207
218
|
this.initializeReliabilityModules();
|
|
208
219
|
this.lifecycleManager = new LifecycleManager();
|
|
209
|
-
this.initializeLifecycleHandlers();
|
|
210
220
|
this.streamManager = new StreamManager();
|
|
211
221
|
this.sessionContextManager = new SessionContextManager();
|
|
212
222
|
this.feedbackCoordinator = new FeedbackCoordinator({
|
|
@@ -400,7 +410,6 @@ var AgentService = class {
|
|
|
400
410
|
setupSessionEventHandling: (sk) => this.setupSessionEventHandling(sk),
|
|
401
411
|
sessionHydrator: this.sessionHydrator,
|
|
402
412
|
getLastAssistantPlainText: (sk) => this.getLastAssistantPlainText(sk),
|
|
403
|
-
checkAndCompact: (sk, msgs) => this.checkAndCompact(sk, msgs),
|
|
404
413
|
enqueueMaybeAutoTitleAfterPersist: (sk) => this.enqueueMaybeAutoTitleAfterPersist(sk),
|
|
405
414
|
getConfig: () => this.effectiveAppConfig(),
|
|
406
415
|
resetSession: (sk) => this.resetSession(sk),
|
|
@@ -418,19 +427,9 @@ var AgentService = class {
|
|
|
418
427
|
keepRecentMessages: 20,
|
|
419
428
|
preserveSystemMessages: true
|
|
420
429
|
};
|
|
421
|
-
const compactionConfig = {
|
|
422
|
-
enabled: true,
|
|
423
|
-
mode: "abstractive",
|
|
424
|
-
reserveTokens: 8e3,
|
|
425
|
-
triggerThreshold: .8,
|
|
426
|
-
minMessagesBeforeCompact: 10,
|
|
427
|
-
keepRecentMessages: 10,
|
|
428
|
-
evictionWindow: .2,
|
|
429
|
-
retentionWindow: 6
|
|
430
|
-
};
|
|
431
430
|
const appCfg = this.config.config;
|
|
432
431
|
if (!appCfg) throw new Error("AgentService requires config.config for session store paths");
|
|
433
|
-
return new SessionStore({ config: appCfg }, windowConfig,
|
|
432
|
+
return new SessionStore({ config: appCfg }, windowConfig, resolveCompactionPolicy(appCfg));
|
|
434
433
|
}
|
|
435
434
|
createHookRunner() {
|
|
436
435
|
if (!this.config.extensionRegistry) return void 0;
|
|
@@ -498,15 +497,6 @@ var AgentService = class {
|
|
|
498
497
|
});
|
|
499
498
|
this.contextMiddleware = new ContextMiddleware();
|
|
500
499
|
}
|
|
501
|
-
initializeLifecycleHandlers() {
|
|
502
|
-
this.lifecycleManager.on("llm_response", new CompactionLifecycleHandler({
|
|
503
|
-
minMessages: 20,
|
|
504
|
-
maxTokens: 8e3,
|
|
505
|
-
preserveReasoning: true,
|
|
506
|
-
accumulateUsage: true
|
|
507
|
-
}));
|
|
508
|
-
log.debug({ handlers: this.lifecycleManager.getRegisteredHandlers() }, "Lifecycle handlers initialized");
|
|
509
|
-
}
|
|
510
500
|
setChannelManager(channelManager) {
|
|
511
501
|
this.inboundLoop.setChannelManager(channelManager);
|
|
512
502
|
}
|
|
@@ -566,6 +556,9 @@ var AgentService = class {
|
|
|
566
556
|
refreshUserProfileContext() {
|
|
567
557
|
this.agentManager.refreshUserProfileContext();
|
|
568
558
|
}
|
|
559
|
+
getMemoryManager() {
|
|
560
|
+
return this.agentManager.getMemoryManager();
|
|
561
|
+
}
|
|
569
562
|
getModelForSession(sessionKey) {
|
|
570
563
|
return this.modelManager.getModelForSession(sessionKey);
|
|
571
564
|
}
|
|
@@ -809,27 +802,6 @@ var AgentService = class {
|
|
|
809
802
|
}
|
|
810
803
|
this.agentEventHandler.handle(event, currentContext);
|
|
811
804
|
}
|
|
812
|
-
async checkAndCompact(sessionKey, messages) {
|
|
813
|
-
const contextWindow = this.getContextWindowForSession(sessionKey);
|
|
814
|
-
const prep = this.sessionStore.prepareCompaction(sessionKey, messages, contextWindow);
|
|
815
|
-
if (!prep.needsCompaction) return;
|
|
816
|
-
log.info({
|
|
817
|
-
sessionKey,
|
|
818
|
-
reason: prep.stats?.reason,
|
|
819
|
-
usagePercent: prep.stats?.usagePercent
|
|
820
|
-
}, "Session needs compaction");
|
|
821
|
-
const result = await this.sessionStore.compact(sessionKey, messages, contextWindow, void 0, false);
|
|
822
|
-
await this.hookHandler.trigger("after_compaction", {
|
|
823
|
-
messageCount: messages.length,
|
|
824
|
-
tokenCount: result.tokensBefore,
|
|
825
|
-
compactedCount: messages.length - result.firstKeptIndex
|
|
826
|
-
});
|
|
827
|
-
log.info({
|
|
828
|
-
sessionKey,
|
|
829
|
-
tokensBefore: result.tokensBefore,
|
|
830
|
-
tokensAfter: result.tokensAfter
|
|
831
|
-
}, "Session compacted");
|
|
832
|
-
}
|
|
833
805
|
getContextWindowForSession(sessionKey) {
|
|
834
806
|
try {
|
|
835
807
|
return this.modelManager.getResolvedModelForSession(sessionKey).contextWindow ?? 128e3;
|
|
@@ -2,8 +2,10 @@ 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
4
|
import { resolveEffectiveAgentProfileForSession } from "../../config/agent-profile.js";
|
|
5
|
+
import { init_providers, resolveModel } from "../../providers/index.js";
|
|
5
6
|
import { effectiveWorkspacePathForSession, projectWorkspacePath } from "../../session/session-workspace.js";
|
|
6
7
|
import { getProjectForSession } from "../../projects/workspace.js";
|
|
8
|
+
import { resolveCompactionPolicy } from "../memory/compaction-policy.js";
|
|
7
9
|
import { resolveVerboseLevel } from "../../session/config-store.js";
|
|
8
10
|
import { resolveEffectiveReasoningLevel, resolveEffectiveThinkingLevel } from "../../session/thinking-resolve.js";
|
|
9
11
|
import "../../session/index.js";
|
|
@@ -12,6 +14,7 @@ import { formatSessionContextReport } from "../service/session-context-report.js
|
|
|
12
14
|
//#region src/agent/session/session-inspector.ts
|
|
13
15
|
init_workspace_defaults();
|
|
14
16
|
init_logger();
|
|
17
|
+
init_providers();
|
|
15
18
|
const log = createLogger("SessionInspector");
|
|
16
19
|
var SessionInspector = class {
|
|
17
20
|
opts;
|
|
@@ -37,8 +40,13 @@ var SessionInspector = class {
|
|
|
37
40
|
*/
|
|
38
41
|
async compact(sessionKey, options) {
|
|
39
42
|
const messages = await this.opts.sessionStore.load(sessionKey);
|
|
40
|
-
|
|
41
|
-
const
|
|
43
|
+
await this.ensureEffectiveSessionModel(sessionKey);
|
|
44
|
+
const policy = resolveCompactionPolicy(this.opts.getConfig());
|
|
45
|
+
const sessionModel = this.opts.modelManager.getResolvedModelForSession(sessionKey);
|
|
46
|
+
const model = policy.model ? resolveModel(policy.model) : sessionModel;
|
|
47
|
+
const primaryRef = `${model.provider}/${model.id}`;
|
|
48
|
+
const fallbackModels = this.opts.modelManager.getFallbackCandidatesForSession(sessionKey).map((candidate) => resolveModel(`${candidate.provider}/${candidate.model}`)).filter((candidate) => `${candidate.provider}/${candidate.id}` !== primaryRef);
|
|
49
|
+
const result = await this.opts.sessionStore.compact(sessionKey, messages, model, options?.instructions, options?.force ?? true, { fallbackModels });
|
|
42
50
|
if (result.compacted) this.opts.agentManager.removeAgent(sessionKey);
|
|
43
51
|
log.info({
|
|
44
52
|
sessionKey,
|
|
@@ -90,12 +90,12 @@ export declare const AutomationStateSchema: z.ZodObject<{
|
|
|
90
90
|
runningRunId: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
91
91
|
lastRunAtMs: z.ZodOptional<z.ZodNumber>;
|
|
92
92
|
lastRunStatus: z.ZodOptional<z.ZodEnum<{
|
|
93
|
+
queued: "queued";
|
|
94
|
+
running: "running";
|
|
93
95
|
failed: "failed";
|
|
94
96
|
cancelled: "cancelled";
|
|
95
97
|
timeout: "timeout";
|
|
96
98
|
succeeded: "succeeded";
|
|
97
|
-
running: "running";
|
|
98
|
-
queued: "queued";
|
|
99
99
|
}>>;
|
|
100
100
|
lastError: z.ZodOptional<z.ZodString>;
|
|
101
101
|
consecutiveFailures: z.ZodOptional<z.ZodNumber>;
|
|
@@ -185,12 +185,12 @@ export declare const AutomationSchema: z.ZodObject<{
|
|
|
185
185
|
runningRunId: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
186
186
|
lastRunAtMs: z.ZodOptional<z.ZodNumber>;
|
|
187
187
|
lastRunStatus: z.ZodOptional<z.ZodEnum<{
|
|
188
|
+
queued: "queued";
|
|
189
|
+
running: "running";
|
|
188
190
|
failed: "failed";
|
|
189
191
|
cancelled: "cancelled";
|
|
190
192
|
timeout: "timeout";
|
|
191
193
|
succeeded: "succeeded";
|
|
192
|
-
running: "running";
|
|
193
|
-
queued: "queued";
|
|
194
194
|
}>>;
|
|
195
195
|
lastError: z.ZodOptional<z.ZodString>;
|
|
196
196
|
consecutiveFailures: z.ZodOptional<z.ZodNumber>;
|
|
@@ -283,12 +283,12 @@ export declare const CreateAutomationSchema: z.ZodObject<{
|
|
|
283
283
|
runningRunId: z.ZodOptional<z.ZodPreprocess<z.ZodOptional<z.ZodString>>>;
|
|
284
284
|
lastRunAtMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
285
285
|
lastRunStatus: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
286
|
+
queued: "queued";
|
|
287
|
+
running: "running";
|
|
286
288
|
failed: "failed";
|
|
287
289
|
cancelled: "cancelled";
|
|
288
290
|
timeout: "timeout";
|
|
289
291
|
succeeded: "succeeded";
|
|
290
|
-
running: "running";
|
|
291
|
-
queued: "queued";
|
|
292
292
|
}>>>;
|
|
293
293
|
lastError: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
294
294
|
consecutiveFailures: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -331,12 +331,12 @@ export declare const UpdateAutomationSchema: z.ZodObject<{
|
|
|
331
331
|
runningRunId: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
332
332
|
lastRunAtMs: z.ZodOptional<z.ZodNumber>;
|
|
333
333
|
lastRunStatus: z.ZodOptional<z.ZodEnum<{
|
|
334
|
+
queued: "queued";
|
|
335
|
+
running: "running";
|
|
334
336
|
failed: "failed";
|
|
335
337
|
cancelled: "cancelled";
|
|
336
338
|
timeout: "timeout";
|
|
337
339
|
succeeded: "succeeded";
|
|
338
|
-
running: "running";
|
|
339
|
-
queued: "queued";
|
|
340
340
|
}>>;
|
|
341
341
|
lastError: z.ZodOptional<z.ZodString>;
|
|
342
342
|
consecutiveFailures: z.ZodOptional<z.ZodNumber>;
|
|
@@ -89,7 +89,7 @@ export declare function buildAutomationDraftResponse(draft: GeneratedAutomationD
|
|
|
89
89
|
nextRunAtMs?: number;
|
|
90
90
|
runningRunId?: string;
|
|
91
91
|
lastRunAtMs?: number;
|
|
92
|
-
lastRunStatus?: "
|
|
92
|
+
lastRunStatus?: "queued" | "running" | "failed" | "cancelled" | "timeout" | "succeeded";
|
|
93
93
|
lastError?: string;
|
|
94
94
|
consecutiveFailures?: number;
|
|
95
95
|
};
|
|
@@ -52,7 +52,7 @@ async function checkDatabaseSchema(ctx) {
|
|
|
52
52
|
id: "database-schema",
|
|
53
53
|
label: "Database schema",
|
|
54
54
|
status: "pass",
|
|
55
|
-
message: `SQLite schema v${status.dbVersion} (current release
|
|
55
|
+
message: `SQLite schema v${status.dbVersion} (current release v65).`,
|
|
56
56
|
hints: []
|
|
57
57
|
};
|
|
58
58
|
}
|
|
@@ -1552,7 +1552,23 @@ export declare const ConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
|
1552
1552
|
}>>;
|
|
1553
1553
|
}, z.core.$strict>>;
|
|
1554
1554
|
retention: z.ZodOptional<z.ZodObject<{
|
|
1555
|
-
compaction: z.ZodDefault<z.
|
|
1555
|
+
compaction: z.ZodDefault<z.ZodObject<{
|
|
1556
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
1557
|
+
triggerThreshold: z.ZodDefault<z.ZodNumber>;
|
|
1558
|
+
reserveTokens: z.ZodDefault<z.ZodNumber>;
|
|
1559
|
+
minMessagesBeforeCompact: z.ZodDefault<z.ZodNumber>;
|
|
1560
|
+
keepRecentTokens: z.ZodDefault<z.ZodNumber>;
|
|
1561
|
+
recentTurnsPreserve: z.ZodDefault<z.ZodNumber>;
|
|
1562
|
+
summaryMaxTokens: z.ZodDefault<z.ZodNumber>;
|
|
1563
|
+
summaryChunkTokens: z.ZodDefault<z.ZodNumber>;
|
|
1564
|
+
summaryTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
1565
|
+
summaryRetries: z.ZodDefault<z.ZodNumber>;
|
|
1566
|
+
qualityGuard: z.ZodDefault<z.ZodBoolean>;
|
|
1567
|
+
model: z.ZodOptional<z.ZodString>;
|
|
1568
|
+
minToolResultKeepChars: z.ZodDefault<z.ZodNumber>;
|
|
1569
|
+
maxActiveTranscriptBytes: z.ZodDefault<z.ZodNumber>;
|
|
1570
|
+
postCompactionSections: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
1571
|
+
}, z.core.$strict>>;
|
|
1556
1572
|
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
1557
1573
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
1558
1574
|
maxChars: z.ZodOptional<z.ZodNumber>;
|
|
@@ -73,6 +73,7 @@ export type ComposioSessionsClient = {
|
|
|
73
73
|
export type ComposioSessionContext = {
|
|
74
74
|
principalId: string;
|
|
75
75
|
installationScope?: string;
|
|
76
|
+
providerPrincipalId?: string;
|
|
76
77
|
toolkits?: string[];
|
|
77
78
|
connectedAccounts?: Record<string, string[]>;
|
|
78
79
|
callbackUrl?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { init_paths_state, resolveStateDir } from "../config/paths-state.js";
|
|
1
2
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
3
|
import { init_logger } from "../utils/logger.js";
|
|
3
4
|
import { appendConnectorExecutionAudit, getConnectorInstallation, listConnectorConnections, upsertConnectorConnection } from "../storage/sqlite/connector-repository.js";
|
|
@@ -7,6 +8,7 @@ import { resolve } from "node:path";
|
|
|
7
8
|
import { createHash } from "node:crypto";
|
|
8
9
|
//#region src/connectors/composio-sessions.ts
|
|
9
10
|
init_credentials();
|
|
11
|
+
init_paths_state();
|
|
10
12
|
init_logger();
|
|
11
13
|
const log = createLogger("Connectors:ComposioSessions");
|
|
12
14
|
const COMPOSIO_API_KEY_PROVIDER = "connector-composio-api-key";
|
|
@@ -22,8 +24,7 @@ function stableHash(value) {
|
|
|
22
24
|
return createHash("sha256").update(value).digest("hex").slice(0, 24);
|
|
23
25
|
}
|
|
24
26
|
function defaultInstallationScope() {
|
|
25
|
-
|
|
26
|
-
return configured ? resolve(configured) : resolve(process.cwd());
|
|
27
|
+
return resolve(resolveStateDir());
|
|
27
28
|
}
|
|
28
29
|
/** Convert local identities to stable opaque Composio user IDs without disclosing user data. */
|
|
29
30
|
function createComposioPrincipalId(principalId, installationScope = defaultInstallationScope()) {
|
|
@@ -105,7 +106,7 @@ var ComposioSessionsAdapter = class {
|
|
|
105
106
|
...context.toolkits?.length ? { toolkits: { enable: context.toolkits } } : {},
|
|
106
107
|
...context.connectedAccounts && Object.keys(context.connectedAccounts).length > 0 ? { connectedAccounts: context.connectedAccounts } : {}
|
|
107
108
|
};
|
|
108
|
-
return client.sessions.create(createComposioPrincipalId(context.principalId, context.installationScope), config);
|
|
109
|
+
return client.sessions.create(context.providerPrincipalId ?? createComposioPrincipalId(context.principalId, context.installationScope), config);
|
|
109
110
|
}
|
|
110
111
|
async listToolkitCatalog(context) {
|
|
111
112
|
const session = await this.createSession(context);
|
|
@@ -130,8 +131,10 @@ var ComposioSessionsAdapter = class {
|
|
|
130
131
|
return items;
|
|
131
132
|
}
|
|
132
133
|
async authorize(context) {
|
|
134
|
+
const providerPrincipalId = createComposioPrincipalId(context.principalId, context.installationScope);
|
|
133
135
|
const request = await (await this.createSession({
|
|
134
136
|
...context,
|
|
137
|
+
providerPrincipalId,
|
|
135
138
|
toolkits: [context.toolkit]
|
|
136
139
|
})).authorize(context.toolkit, {
|
|
137
140
|
callbackUrl: context.callbackUrl,
|
|
@@ -152,7 +155,10 @@ var ComposioSessionsAdapter = class {
|
|
|
152
155
|
principalId: context.principalId,
|
|
153
156
|
connectorId
|
|
154
157
|
}).length === 0,
|
|
155
|
-
metadata: {
|
|
158
|
+
metadata: {
|
|
159
|
+
toolkit: context.toolkit,
|
|
160
|
+
providerPrincipalId
|
|
161
|
+
}
|
|
156
162
|
});
|
|
157
163
|
return {
|
|
158
164
|
toolkit: context.toolkit,
|
|
@@ -249,9 +255,12 @@ var ComposioSessionsAdapter = class {
|
|
|
249
255
|
try {
|
|
250
256
|
const toolkit = input.action.toolkit;
|
|
251
257
|
const connectedAccounts = toolkit && input.connection ? { [toolkit]: [input.connection.providerConnectionId] } : input.context.connectedAccounts;
|
|
258
|
+
const providerPrincipalId = input.connection?.metadata.providerPrincipalId;
|
|
259
|
+
if (input.connection && (typeof providerPrincipalId !== "string" || !providerPrincipalId.trim())) throw new Error("Connected account is missing its provider identity. Reconnect the account and try again.");
|
|
252
260
|
const result = await (await this.createSession({
|
|
253
261
|
...input.context,
|
|
254
|
-
connectedAccounts
|
|
262
|
+
connectedAccounts,
|
|
263
|
+
...typeof providerPrincipalId === "string" ? { providerPrincipalId } : {}
|
|
255
264
|
})).execute(input.action.actionId, input.args ?? {}, input.connection ? { account: input.connection.providerConnectionId } : void 0);
|
|
256
265
|
appendConnectorExecutionAudit({
|
|
257
266
|
installationId: input.installation.id,
|
|
@@ -22,6 +22,6 @@ export declare function normalizeComposioTriggerPayload(payload: unknown, webhoo
|
|
|
22
22
|
trigger?: string;
|
|
23
23
|
data: Record<string, unknown>;
|
|
24
24
|
};
|
|
25
|
-
export declare function applyComposioConnectionLifecycleEvent(payload: unknown):
|
|
25
|
+
export declare function applyComposioConnectionLifecycleEvent(payload: unknown): string | undefined;
|
|
26
26
|
export declare function appendComposioTriggerEvent(config: Config, payload: unknown): Promise<ComposioTriggerArchiveEntry>;
|
|
27
27
|
export declare function listComposioTriggerEvents(config: Config, limit?: number): Promise<ComposioTriggerArchiveEntry[]>;
|
|
@@ -37,17 +37,18 @@ function normalizeComposioTriggerPayload(payload, webhookId) {
|
|
|
37
37
|
}
|
|
38
38
|
function applyComposioConnectionLifecycleEvent(payload) {
|
|
39
39
|
const normalized = normalizeComposioTriggerPayload(payload);
|
|
40
|
-
if (normalized.type !== "composio.connected_account.expired" && normalized.type !== "composio.connected_account.deleted") return;
|
|
40
|
+
if (normalized.type !== "composio.connected_account.expired" && normalized.type !== "composio.connected_account.deleted") return void 0;
|
|
41
41
|
const providerConnectionId = readString(normalized.data.id ?? normalized.data.nanoid ?? normalized.data.connected_account_id);
|
|
42
|
-
if (!providerConnectionId) return;
|
|
42
|
+
if (!providerConnectionId) return void 0;
|
|
43
43
|
const connection = listConnectorConnections().find((candidate) => candidate.provider === "composio" && candidate.providerConnectionId === providerConnectionId);
|
|
44
|
-
if (!connection) return;
|
|
44
|
+
if (!connection) return void 0;
|
|
45
45
|
upsertConnectorConnection({
|
|
46
46
|
...connection,
|
|
47
47
|
status: normalized.type.endsWith(".deleted") ? "revoked" : "expired",
|
|
48
48
|
isDefault: false,
|
|
49
49
|
lastError: normalized.type.endsWith(".deleted") ? "Connection was removed in Composio." : "Connection expired and requires authorization."
|
|
50
50
|
});
|
|
51
|
+
return connection.id;
|
|
51
52
|
}
|
|
52
53
|
async function appendComposioTriggerEvent(config, payload) {
|
|
53
54
|
const record = payload && typeof payload === "object" && !Array.isArray(payload) ? payload : {};
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import type { Config } from '../config/schema.js';
|
|
2
|
+
import { type KnowledgePullInput } from '../knowledge/index.js';
|
|
2
3
|
import { ComposioSessionsAdapter } from './composio-sessions.js';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare function
|
|
4
|
+
export declare const COMPOSIO_CONNECTED_SOURCE_TOOLKITS: Set<string>;
|
|
5
|
+
export declare function ingestComposioConnectedSource(input: {
|
|
5
6
|
config: Config;
|
|
6
7
|
connectorId: string;
|
|
8
|
+
collectionScope: string;
|
|
9
|
+
streamKind: 'activity' | 'inventory';
|
|
7
10
|
actionId: string;
|
|
8
11
|
arguments?: Record<string, unknown>;
|
|
12
|
+
buildArguments?: (pull: KnowledgePullInput) => Record<string, unknown>;
|
|
9
13
|
agentId: string;
|
|
10
14
|
connectionId?: string;
|
|
11
15
|
adapter?: ComposioSessionsAdapter;
|
|
12
16
|
}): Promise<{
|
|
13
|
-
recordId: string;
|
|
14
17
|
connectorId: string;
|
|
15
18
|
actionId: string;
|
|
19
|
+
sourceInstanceId: string;
|
|
20
|
+
itemsSeen: number;
|
|
21
|
+
itemsIndexed: number;
|
|
22
|
+
recordIds: string[];
|
|
16
23
|
}>;
|
|
17
|
-
export declare function
|
|
24
|
+
export declare function ingestLocalFolderSource(input: {
|
|
18
25
|
config: Config;
|
|
19
26
|
connectorId: string;
|
|
20
27
|
agentId: string;
|