@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
|
@@ -9,9 +9,10 @@ import { KnowledgeIngestionService } from "../knowledge/ingestion-service.js";
|
|
|
9
9
|
import { ConnectedKnowledgePipeline } from "../knowledge/connected-knowledge-pipeline.js";
|
|
10
10
|
import { LocalFolderKnowledgeSourceAdapter } from "../knowledge/local-folder-adapter.js";
|
|
11
11
|
import "../knowledge/index.js";
|
|
12
|
+
import { normalizeConnectedSourceResult } from "./connected-source-normalizers.js";
|
|
12
13
|
import { createHash } from "node:crypto";
|
|
13
|
-
//#region src/connectors/
|
|
14
|
-
const
|
|
14
|
+
//#region src/connectors/connected-source-ingestion.ts
|
|
15
|
+
const COMPOSIO_CONNECTED_SOURCE_TOOLKITS = new Set([
|
|
15
16
|
"gmail",
|
|
16
17
|
"googlecalendar",
|
|
17
18
|
"googledrive",
|
|
@@ -27,34 +28,6 @@ const COMPOSIO_MEMORY_SOURCE_TOOLKITS = new Set([
|
|
|
27
28
|
"one_drive",
|
|
28
29
|
"excel"
|
|
29
30
|
]);
|
|
30
|
-
const EXTERNAL_ID_KEYS = [
|
|
31
|
-
"id",
|
|
32
|
-
"messageId",
|
|
33
|
-
"message_id",
|
|
34
|
-
"threadId",
|
|
35
|
-
"thread_id",
|
|
36
|
-
"eventId",
|
|
37
|
-
"event_id",
|
|
38
|
-
"pageId",
|
|
39
|
-
"page_id",
|
|
40
|
-
"fileId",
|
|
41
|
-
"file_id"
|
|
42
|
-
];
|
|
43
|
-
const OCCURRED_AT_KEYS = [
|
|
44
|
-
"occurredAt",
|
|
45
|
-
"createdAt",
|
|
46
|
-
"created_at",
|
|
47
|
-
"date",
|
|
48
|
-
"timestamp",
|
|
49
|
-
"startTime",
|
|
50
|
-
"start_time"
|
|
51
|
-
];
|
|
52
|
-
const UPDATED_AT_KEYS = [
|
|
53
|
-
"updatedAt",
|
|
54
|
-
"updated_at",
|
|
55
|
-
"modifiedTime",
|
|
56
|
-
"modified_time"
|
|
57
|
-
];
|
|
58
31
|
const SENSITIVE_KEY_RE = /(?:^|_)(?:api_?key|token|secret|password|passwd|authorization|credential|private_?key)(?:$|_)/i;
|
|
59
32
|
const INLINE_SECRET_PATTERNS = [
|
|
60
33
|
/\bsk-[A-Za-z0-9_-]{8,}\b/g,
|
|
@@ -65,34 +38,6 @@ const INLINE_SECRET_PATTERNS = [
|
|
|
65
38
|
function asRecord(value) {
|
|
66
39
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
67
40
|
}
|
|
68
|
-
function resultRows(value) {
|
|
69
|
-
if (Array.isArray(value)) return value;
|
|
70
|
-
const record = asRecord(value);
|
|
71
|
-
if (!record) return [value];
|
|
72
|
-
for (const key of [
|
|
73
|
-
"items",
|
|
74
|
-
"messages",
|
|
75
|
-
"results",
|
|
76
|
-
"events",
|
|
77
|
-
"files",
|
|
78
|
-
"pages",
|
|
79
|
-
"data"
|
|
80
|
-
]) if (Array.isArray(record[key])) return record[key];
|
|
81
|
-
return [value];
|
|
82
|
-
}
|
|
83
|
-
function stringField(record, keys) {
|
|
84
|
-
for (const key of keys) {
|
|
85
|
-
const value = record?.[key];
|
|
86
|
-
if (typeof value === "string" && value.trim()) return value.trim();
|
|
87
|
-
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function timestampField(record, keys) {
|
|
91
|
-
const value = stringField(record, keys);
|
|
92
|
-
if (!value) return void 0;
|
|
93
|
-
const parsed = Date.parse(value);
|
|
94
|
-
return Number.isFinite(parsed) ? new Date(parsed).toISOString() : void 0;
|
|
95
|
-
}
|
|
96
41
|
function sanitizeSourceValue(value, depth = 0) {
|
|
97
42
|
if (depth > 12) return "[MaxDepth]";
|
|
98
43
|
if (typeof value === "string") return INLINE_SECRET_PATTERNS.reduce((text, pattern) => text.replace(pattern, "[REDACTED]"), value);
|
|
@@ -101,22 +46,6 @@ function sanitizeSourceValue(value, depth = 0) {
|
|
|
101
46
|
if (!record) return value;
|
|
102
47
|
return Object.fromEntries(Object.entries(record).map(([key, nested]) => [key, SENSITIVE_KEY_RE.test(key) ? "[REDACTED]" : sanitizeSourceValue(nested, depth + 1)]));
|
|
103
48
|
}
|
|
104
|
-
function itemTypeFor(toolkit, actionId) {
|
|
105
|
-
if (toolkit === "gmail" || toolkit === "outlook") return "email";
|
|
106
|
-
if (toolkit === "googlecalendar" || actionId.includes("CALENDAR")) return "calendar_event";
|
|
107
|
-
if (toolkit === "slack" || toolkit === "microsoft_teams") return "conversation_message";
|
|
108
|
-
if (toolkit === "github") return "development_activity";
|
|
109
|
-
if (toolkit === "linear" || toolkit === "jira") return "work_item";
|
|
110
|
-
if ([
|
|
111
|
-
"googledrive",
|
|
112
|
-
"googledocs",
|
|
113
|
-
"googlesheets",
|
|
114
|
-
"notion",
|
|
115
|
-
"one_drive",
|
|
116
|
-
"excel"
|
|
117
|
-
].includes(toolkit)) return "document";
|
|
118
|
-
return "connector_item";
|
|
119
|
-
}
|
|
120
49
|
function boundedPersonValue(value, maxLength = 320) {
|
|
121
50
|
return typeof value === "string" ? value.trim().slice(0, maxLength) : "";
|
|
122
51
|
}
|
|
@@ -176,21 +105,27 @@ function peopleSignals(entities) {
|
|
|
176
105
|
]).filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean);
|
|
177
106
|
return [...new Set(values)].slice(0, 50);
|
|
178
107
|
}
|
|
108
|
+
function connectionIdentities(identity) {
|
|
109
|
+
return [...new Set(Object.values(identity).filter((value) => typeof value === "string").map((value) => value.trim().toLowerCase()).filter(Boolean))];
|
|
110
|
+
}
|
|
179
111
|
function resultToSourceItems(input) {
|
|
180
|
-
return
|
|
181
|
-
const record =
|
|
112
|
+
return normalizeConnectedSourceResult(input).slice(0, 200).map((entity) => {
|
|
113
|
+
const record = entity.value;
|
|
182
114
|
const people = personEntities(record);
|
|
183
|
-
const
|
|
115
|
+
const ownerIdentities = connectionIdentities(input.connectionIdentity);
|
|
116
|
+
const observedIdentities = peopleSignals(people).map((value) => value.toLowerCase());
|
|
117
|
+
const actorAttributed = entity.metadata.actorAttributed === true || input.toolkit === "gmail" || input.toolkit === "googlecalendar" || input.toolkit === "github" && observedIdentities.some((value) => ownerIdentities.includes(value));
|
|
118
|
+
const serialized = JSON.stringify(sanitizeSourceValue(entity.value), null, 2);
|
|
184
119
|
const normalizedText = serialized.length > 8e3 ? `${serialized.slice(0, 8e3)}\n…` : serialized;
|
|
185
120
|
const contentHash = createHash("sha256").update(serialized).digest("hex");
|
|
186
|
-
const externalId = stringField(record, EXTERNAL_ID_KEYS) ?? `${input.actionId}:${index}`;
|
|
187
121
|
return {
|
|
188
122
|
sourceInstanceId: input.sourceInstanceId,
|
|
189
|
-
|
|
190
|
-
|
|
123
|
+
collectionScope: input.collectionScope,
|
|
124
|
+
externalId: entity.externalId,
|
|
125
|
+
itemType: entity.itemType,
|
|
191
126
|
authorRole: "third_party",
|
|
192
|
-
occurredAt:
|
|
193
|
-
sourceUpdatedAt:
|
|
127
|
+
occurredAt: entity.occurredAt,
|
|
128
|
+
sourceUpdatedAt: entity.sourceUpdatedAt,
|
|
194
129
|
contentHash,
|
|
195
130
|
normalizedText,
|
|
196
131
|
metadata: {
|
|
@@ -201,12 +136,15 @@ function resultToSourceItems(input) {
|
|
|
201
136
|
people: peopleSignals(people),
|
|
202
137
|
personEntities: people,
|
|
203
138
|
agentId: input.agentId,
|
|
204
|
-
workspaceId: input.workspaceId
|
|
139
|
+
workspaceId: input.workspaceId,
|
|
140
|
+
...entity.metadata,
|
|
141
|
+
ownerIdentities,
|
|
142
|
+
actorAttributed
|
|
205
143
|
},
|
|
206
144
|
sensitivity: "personal",
|
|
207
145
|
retentionClass: "bounded",
|
|
208
146
|
synthesisPipeline: "connected_knowledge",
|
|
209
|
-
synthesisStatus: "
|
|
147
|
+
synthesisStatus: input.streamKind === "inventory" ? "ignored" : entity.synthesisStatus
|
|
210
148
|
};
|
|
211
149
|
});
|
|
212
150
|
}
|
|
@@ -236,7 +174,7 @@ var ComposioKnowledgeSourceAdapter = class {
|
|
|
236
174
|
curated: true,
|
|
237
175
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
238
176
|
},
|
|
239
|
-
args: this.input.arguments,
|
|
177
|
+
args: this.input.buildArguments?.(pull) ?? this.input.arguments,
|
|
240
178
|
confirmed: true
|
|
241
179
|
});
|
|
242
180
|
if (execution.decision !== "allowed") throw new Error(execution.reason);
|
|
@@ -244,25 +182,28 @@ var ComposioKnowledgeSourceAdapter = class {
|
|
|
244
182
|
items: resultToSourceItems({
|
|
245
183
|
result: execution.result,
|
|
246
184
|
sourceInstanceId: pull.instanceId,
|
|
185
|
+
collectionScope: pull.collectionScope,
|
|
186
|
+
streamKind: this.input.streamKind,
|
|
247
187
|
connectorId: this.input.connectorId,
|
|
248
188
|
connectionId: this.input.connection.id,
|
|
249
189
|
actionId: this.input.actionId,
|
|
250
190
|
toolkit: this.input.toolkit,
|
|
251
191
|
agentId: this.input.agentId,
|
|
252
|
-
workspaceId: this.input.workspaceId
|
|
192
|
+
workspaceId: this.input.workspaceId,
|
|
193
|
+
connectionIdentity: this.input.connection.identity
|
|
253
194
|
}),
|
|
254
195
|
nextCursor: (/* @__PURE__ */ new Date()).toISOString(),
|
|
255
196
|
warnings: []
|
|
256
197
|
};
|
|
257
198
|
}
|
|
258
199
|
};
|
|
259
|
-
async function
|
|
200
|
+
async function ingestComposioConnectedSource(input) {
|
|
260
201
|
const definition = getConnectorDefinition(input.connectorId);
|
|
261
|
-
if (definition?.runtime.type !== "composio" || definition.runtime.role !== "toolkit") throw new Error("
|
|
202
|
+
if (definition?.runtime.type !== "composio" || definition.runtime.role !== "toolkit") throw new Error("Connected source ingestion requires a Composio toolkit connector.");
|
|
262
203
|
const toolkit = definition.runtime.toolkit;
|
|
263
|
-
if (!
|
|
204
|
+
if (!COMPOSIO_CONNECTED_SOURCE_TOOLKITS.has(toolkit)) throw new Error(`Connected source ingestion is not supported for the ${toolkit} connector.`);
|
|
264
205
|
const risk = scopeForComposioAction(input.actionId);
|
|
265
|
-
if (risk.toolkit !== toolkit || risk.scope !== "read" || !risk.curated) throw new Error("
|
|
206
|
+
if (risk.toolkit !== toolkit || risk.scope !== "read" || !risk.curated) throw new Error("Connected source ingestion only accepts a verified read action for the selected connector.");
|
|
266
207
|
const connectorId = definition.id;
|
|
267
208
|
const installation = getConnectorInstallation(`${connectorId}-local-owner`);
|
|
268
209
|
if (!installation?.enabled) throw new Error("Connector installation is not enabled.");
|
|
@@ -272,15 +213,18 @@ async function syncComposioResultToMemory(input) {
|
|
|
272
213
|
connectorId
|
|
273
214
|
}).filter((connection) => connection.status === "active");
|
|
274
215
|
const connection = input.connectionId ? activeConnections.find((candidate) => candidate.id === input.connectionId) : activeConnections.find((candidate) => candidate.isDefault) ?? activeConnections[0];
|
|
275
|
-
if (!connection) throw new Error("No active connector account is available for
|
|
216
|
+
if (!connection) throw new Error("No active connector account is available for connected source ingestion.");
|
|
276
217
|
const adapter = input.adapter ?? new ComposioSessionsAdapter();
|
|
277
218
|
const workspaceId = getWorkspacePath(input.config);
|
|
278
219
|
const sourceInstanceId = `composio:${connectorId}:${connection.id}`;
|
|
279
220
|
const sourceAdapter = new ComposioKnowledgeSourceAdapter({
|
|
280
221
|
connectorId,
|
|
222
|
+
collectionScope: input.collectionScope,
|
|
223
|
+
streamKind: input.streamKind,
|
|
281
224
|
connection,
|
|
282
225
|
actionId: input.actionId,
|
|
283
226
|
arguments: input.arguments ?? {},
|
|
227
|
+
buildArguments: input.buildArguments,
|
|
284
228
|
agentId: input.agentId,
|
|
285
229
|
toolkit,
|
|
286
230
|
workspaceId,
|
|
@@ -289,27 +233,30 @@ async function syncComposioResultToMemory(input) {
|
|
|
289
233
|
});
|
|
290
234
|
const syncRun = await new KnowledgeIngestionService(new Map([[sourceAdapter.kind, sourceAdapter]])).sync({
|
|
291
235
|
adapterKind: sourceAdapter.kind,
|
|
292
|
-
instanceId: sourceInstanceId
|
|
236
|
+
instanceId: sourceInstanceId,
|
|
237
|
+
collectionScope: input.collectionScope
|
|
293
238
|
});
|
|
294
|
-
if (syncRun.status === "failed" || syncRun.status === "cancelled") throw new Error(syncRun.error ?? `
|
|
239
|
+
if (syncRun.status === "failed" || syncRun.status === "cancelled") throw new Error(syncRun.error ?? `Connected source ingestion ${syncRun.status}.`);
|
|
295
240
|
const pipeline = new ConnectedKnowledgePipeline({
|
|
296
241
|
agentId: input.agentId,
|
|
297
242
|
workspaceId
|
|
298
243
|
});
|
|
299
|
-
|
|
244
|
+
const recordIds = [];
|
|
300
245
|
for (let batch = 0; batch < 10; batch += 1) {
|
|
301
246
|
const synthesis = await pipeline.processPending(sourceInstanceId);
|
|
302
|
-
|
|
247
|
+
recordIds.push(...synthesis.recordIds);
|
|
303
248
|
if (synthesis.claimed === 0) break;
|
|
304
249
|
}
|
|
305
|
-
if (!recordId) throw new Error("Connector result did not contain any synthesizable knowledge.");
|
|
306
250
|
return {
|
|
307
|
-
recordId,
|
|
308
251
|
connectorId,
|
|
309
|
-
actionId: input.actionId
|
|
252
|
+
actionId: input.actionId,
|
|
253
|
+
sourceInstanceId,
|
|
254
|
+
itemsSeen: syncRun.itemsSeen,
|
|
255
|
+
itemsIndexed: syncRun.itemsCreated + syncRun.itemsUpdated,
|
|
256
|
+
recordIds
|
|
310
257
|
};
|
|
311
258
|
}
|
|
312
|
-
async function
|
|
259
|
+
async function ingestLocalFolderSource(input) {
|
|
313
260
|
const definition = getConnectorDefinition(input.connectorId);
|
|
314
261
|
if (definition?.runtime.type !== "memorySource" || definition.runtime.sourceKind !== "local-folder") throw new Error("Local folder sync requires a local-folder memory source connector.");
|
|
315
262
|
const instance = getConnectorInstance(input.config, definition.id);
|
|
@@ -320,7 +267,8 @@ async function syncLocalFolderToMemory(input) {
|
|
|
320
267
|
const adapter = new LocalFolderKnowledgeSourceAdapter(rootPath);
|
|
321
268
|
const syncRun = await new KnowledgeIngestionService(new Map([[adapter.kind, adapter]])).sync({
|
|
322
269
|
adapterKind: adapter.kind,
|
|
323
|
-
instanceId: sourceInstanceId
|
|
270
|
+
instanceId: sourceInstanceId,
|
|
271
|
+
collectionScope: "files"
|
|
324
272
|
});
|
|
325
273
|
if (syncRun.status === "failed" || syncRun.status === "cancelled") throw new Error(syncRun.error ?? `Local folder sync ${syncRun.status}.`);
|
|
326
274
|
const pipeline = new ConnectedKnowledgePipeline({
|
|
@@ -340,4 +288,4 @@ async function syncLocalFolderToMemory(input) {
|
|
|
340
288
|
};
|
|
341
289
|
}
|
|
342
290
|
//#endregion
|
|
343
|
-
export {
|
|
291
|
+
export { COMPOSIO_CONNECTED_SOURCE_TOOLKITS, ingestComposioConnectedSource, ingestLocalFolderSource };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { KnowledgeSynthesisStatus } from '../knowledge/types.js';
|
|
2
|
+
export type ConnectedSourceEntity = {
|
|
3
|
+
externalId: string;
|
|
4
|
+
itemType: string;
|
|
5
|
+
occurredAt?: string;
|
|
6
|
+
sourceUpdatedAt?: string;
|
|
7
|
+
value: Record<string, unknown>;
|
|
8
|
+
metadata: Record<string, unknown>;
|
|
9
|
+
synthesisStatus: KnowledgeSynthesisStatus;
|
|
10
|
+
};
|
|
11
|
+
export declare function normalizeConnectedSourceResult(input: {
|
|
12
|
+
toolkit: string;
|
|
13
|
+
actionId: string;
|
|
14
|
+
result: unknown;
|
|
15
|
+
}): ConnectedSourceEntity[];
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
//#region src/connectors/connected-source-normalizers.ts
|
|
2
|
+
function record(value) {
|
|
3
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
4
|
+
}
|
|
5
|
+
function text(row, ...keys) {
|
|
6
|
+
for (const key of keys) {
|
|
7
|
+
const value = row?.[key];
|
|
8
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
9
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function time(value) {
|
|
13
|
+
const nested = record(value);
|
|
14
|
+
const candidate = typeof value === "string" || typeof value === "number" ? value : text(nested, "dateTime", "date", "time", "timestamp");
|
|
15
|
+
if (candidate === void 0) return void 0;
|
|
16
|
+
const numeric = typeof candidate === "number" ? candidate : Number(candidate);
|
|
17
|
+
const parsed = Number.isFinite(numeric) && String(candidate).length >= 10 ? new Date(numeric < 1e10 ? numeric * 1e3 : numeric) : new Date(String(candidate));
|
|
18
|
+
return Number.isFinite(parsed.getTime()) ? parsed.toISOString() : void 0;
|
|
19
|
+
}
|
|
20
|
+
function payload(result) {
|
|
21
|
+
const envelope = record(result);
|
|
22
|
+
if (!envelope || envelope.error) return void 0;
|
|
23
|
+
return record(envelope.data) ?? envelope;
|
|
24
|
+
}
|
|
25
|
+
function rows(data, ...keys) {
|
|
26
|
+
for (const key of keys) {
|
|
27
|
+
const value = data?.[key];
|
|
28
|
+
if (Array.isArray(value)) return value.map(record).filter((item) => Boolean(item));
|
|
29
|
+
}
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
function compact(value) {
|
|
33
|
+
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0 && item !== null && item !== ""));
|
|
34
|
+
}
|
|
35
|
+
function normalizeGmail(result) {
|
|
36
|
+
return rows(payload(result), "messages").flatMap((message) => {
|
|
37
|
+
const externalId = text(message, "id", "messageId", "message_id");
|
|
38
|
+
if (!externalId) return [];
|
|
39
|
+
const occurredAt = time(message.internalDate ?? message.internal_date ?? message.date ?? message.timestamp);
|
|
40
|
+
return [{
|
|
41
|
+
externalId,
|
|
42
|
+
itemType: "email",
|
|
43
|
+
occurredAt,
|
|
44
|
+
sourceUpdatedAt: occurredAt,
|
|
45
|
+
value: compact({
|
|
46
|
+
id: externalId,
|
|
47
|
+
threadId: text(message, "threadId", "thread_id"),
|
|
48
|
+
subject: text(message, "subject"),
|
|
49
|
+
sender: message.sender ?? message.from,
|
|
50
|
+
recipients: message.recipients ?? message.to,
|
|
51
|
+
date: occurredAt,
|
|
52
|
+
labels: message.labelIds ?? message.label_ids ?? message.labels,
|
|
53
|
+
snippet: text(message, "snippet", "preview")
|
|
54
|
+
}),
|
|
55
|
+
metadata: {
|
|
56
|
+
observationKind: "message",
|
|
57
|
+
logicalEventKey: `gmail:message:${externalId}`
|
|
58
|
+
},
|
|
59
|
+
synthesisStatus: "pending"
|
|
60
|
+
}];
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function normalizeCalendar(result) {
|
|
64
|
+
return rows(payload(result), "items", "events").flatMap((event) => {
|
|
65
|
+
const externalId = text(event, "id", "eventId", "event_id");
|
|
66
|
+
if (!externalId) return [];
|
|
67
|
+
const occurredAt = time(event.start ?? event.startTime ?? event.start_time);
|
|
68
|
+
return [{
|
|
69
|
+
externalId,
|
|
70
|
+
itemType: "calendar_event",
|
|
71
|
+
occurredAt,
|
|
72
|
+
sourceUpdatedAt: time(event.updated ?? event.updatedAt ?? event.updated_at),
|
|
73
|
+
value: compact({
|
|
74
|
+
id: externalId,
|
|
75
|
+
title: text(event, "summary", "title", "name"),
|
|
76
|
+
start: occurredAt,
|
|
77
|
+
end: time(event.end ?? event.endTime ?? event.end_time),
|
|
78
|
+
organizer: event.organizer,
|
|
79
|
+
attendees: event.attendees,
|
|
80
|
+
status: event.status,
|
|
81
|
+
recurrence: event.recurrence
|
|
82
|
+
}),
|
|
83
|
+
metadata: {
|
|
84
|
+
observationKind: "calendar_event",
|
|
85
|
+
logicalEventKey: `googlecalendar:event:${externalId}`
|
|
86
|
+
},
|
|
87
|
+
synthesisStatus: "pending"
|
|
88
|
+
}];
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function repositoryName(row) {
|
|
92
|
+
const explicit = text(record(row.repository) ?? record(row.repo), "full_name", "name") ?? text(row, "repository_full_name", "full_name", "repo");
|
|
93
|
+
if (explicit) return explicit;
|
|
94
|
+
return (text(row, "repository_url", "html_url")?.match(/(?:repos\/|github\.com\/)([^/]+\/[^/#]+)(?:\/|$)/))?.[1];
|
|
95
|
+
}
|
|
96
|
+
function normalizeGitHub(result, actionId) {
|
|
97
|
+
const data = payload(result);
|
|
98
|
+
if (actionId === "GITHUB_LIST_REPOSITORIES_FOR_THE_AUTHENTICATED_USER") return rows(data, "repositories").flatMap((repository) => {
|
|
99
|
+
const externalId = text(repository, "id", "node_id", "full_name");
|
|
100
|
+
const fullName = text(repository, "full_name");
|
|
101
|
+
if (!externalId || !fullName) return [];
|
|
102
|
+
return [{
|
|
103
|
+
externalId,
|
|
104
|
+
itemType: "repository",
|
|
105
|
+
occurredAt: time(repository.created_at),
|
|
106
|
+
sourceUpdatedAt: time(repository.updated_at),
|
|
107
|
+
value: compact({
|
|
108
|
+
id: externalId,
|
|
109
|
+
fullName,
|
|
110
|
+
description: text(repository, "description"),
|
|
111
|
+
visibility: repository.visibility,
|
|
112
|
+
language: repository.language,
|
|
113
|
+
archived: repository.archived
|
|
114
|
+
}),
|
|
115
|
+
metadata: {
|
|
116
|
+
observationKind: "inventory",
|
|
117
|
+
logicalEventKey: `github:repository:${externalId}`,
|
|
118
|
+
subjectKey: fullName.toLowerCase(),
|
|
119
|
+
actorAttributed: false
|
|
120
|
+
},
|
|
121
|
+
synthesisStatus: "ignored"
|
|
122
|
+
}];
|
|
123
|
+
});
|
|
124
|
+
return rows(data, "commits", "pull_requests", "issues", "items").flatMap((activity) => {
|
|
125
|
+
const rawId = text(activity, "id", "node_id", "sha", "number");
|
|
126
|
+
if (!rawId) return [];
|
|
127
|
+
const subjectKey = repositoryName(activity);
|
|
128
|
+
const externalId = subjectKey ? `${subjectKey}:${rawId}` : rawId;
|
|
129
|
+
const occurredAt = time(activity.committed_at ?? activity.created_at ?? activity.updated_at);
|
|
130
|
+
return [{
|
|
131
|
+
externalId: `${actionId}:${externalId}`,
|
|
132
|
+
itemType: "development_activity",
|
|
133
|
+
occurredAt,
|
|
134
|
+
sourceUpdatedAt: time(activity.updated_at) ?? occurredAt,
|
|
135
|
+
value: compact({
|
|
136
|
+
id: externalId,
|
|
137
|
+
repository: subjectKey,
|
|
138
|
+
title: text(activity, "title", "message", "name"),
|
|
139
|
+
author: activity.author ?? activity.user ?? activity.actor,
|
|
140
|
+
state: activity.state,
|
|
141
|
+
occurredAt
|
|
142
|
+
}),
|
|
143
|
+
metadata: {
|
|
144
|
+
observationKind: "activity",
|
|
145
|
+
logicalEventKey: `github:${actionId.toLowerCase()}:${externalId}`,
|
|
146
|
+
subjectKey
|
|
147
|
+
},
|
|
148
|
+
synthesisStatus: "pending"
|
|
149
|
+
}];
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function normalizeWorkItems(result, toolkit) {
|
|
153
|
+
return rows(payload(result), "issues", "items", "results").flatMap((item) => {
|
|
154
|
+
const externalId = text(item, "id", "identifier", "key");
|
|
155
|
+
if (!externalId) return [];
|
|
156
|
+
const occurredAt = time(item.createdAt ?? item.created_at);
|
|
157
|
+
return [{
|
|
158
|
+
externalId,
|
|
159
|
+
itemType: "work_item",
|
|
160
|
+
occurredAt,
|
|
161
|
+
sourceUpdatedAt: time(item.updatedAt ?? item.updated_at) ?? occurredAt,
|
|
162
|
+
value: compact({
|
|
163
|
+
id: externalId,
|
|
164
|
+
title: text(item, "title", "summary", "name"),
|
|
165
|
+
project: item.project ?? item.team,
|
|
166
|
+
assignee: item.assignee,
|
|
167
|
+
creator: item.creator ?? item.reporter,
|
|
168
|
+
state: item.state ?? item.status
|
|
169
|
+
}),
|
|
170
|
+
metadata: {
|
|
171
|
+
observationKind: "work_item",
|
|
172
|
+
logicalEventKey: `${toolkit}:work-item:${externalId}`
|
|
173
|
+
},
|
|
174
|
+
synthesisStatus: "pending"
|
|
175
|
+
}];
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function normalizeConnectedSourceResult(input) {
|
|
179
|
+
if (input.toolkit === "gmail") return normalizeGmail(input.result);
|
|
180
|
+
if (input.toolkit === "googlecalendar") return normalizeCalendar(input.result);
|
|
181
|
+
if (input.toolkit === "github") return normalizeGitHub(input.result, input.actionId);
|
|
182
|
+
if (input.toolkit === "linear" || input.toolkit === "jira") return normalizeWorkItems(input.result, input.toolkit);
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
export { normalizeConnectedSourceResult };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/connectors/connector-identity.ts
|
|
2
|
+
function object(value) {
|
|
3
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
4
|
+
return value;
|
|
5
|
+
}
|
|
6
|
+
function payload(value) {
|
|
7
|
+
const root = object(value);
|
|
8
|
+
return object(root.data ?? root.result ?? root);
|
|
9
|
+
}
|
|
10
|
+
function text(row, keys) {
|
|
11
|
+
for (const key of keys) {
|
|
12
|
+
const value = row[key];
|
|
13
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function normalizeConnectorIdentity(toolkit, result) {
|
|
17
|
+
const row = payload(result);
|
|
18
|
+
if (toolkit === "github") return {
|
|
19
|
+
username: text(row, ["login", "username"]),
|
|
20
|
+
displayName: text(row, ["name"]),
|
|
21
|
+
email: text(row, ["email"]),
|
|
22
|
+
avatarUrl: text(row, ["avatar_url"]),
|
|
23
|
+
profileUrl: text(row, ["html_url"])
|
|
24
|
+
};
|
|
25
|
+
if (toolkit === "gmail") return { email: text(row, ["emailAddress", "email"]) };
|
|
26
|
+
throw new Error(`Identity normalization is not defined for ${toolkit}.`);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { normalizeConnectorIdentity };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Config } from '../config/schema.js';
|
|
2
|
+
import type { MemoryManager } from '../agent/memory/manager.js';
|
|
3
|
+
import { type ConnectorLearningJob } from '../storage/sqlite/index.js';
|
|
4
|
+
import { ComposioSessionsAdapter } from './composio-sessions.js';
|
|
5
|
+
export type ConnectorLearningCoordinator = {
|
|
6
|
+
enqueueConnection(connectionId: string, request?: {
|
|
7
|
+
mode?: 'bootstrap' | 'incremental';
|
|
8
|
+
reason?: 'manual' | 'event' | 'schedule';
|
|
9
|
+
idempotencyKey?: string;
|
|
10
|
+
nextRunAt?: number;
|
|
11
|
+
}): ConnectorLearningJob | null;
|
|
12
|
+
enqueueToolkit(toolkit: string): ConnectorLearningJob[];
|
|
13
|
+
setPaused(connectionId: string, paused: boolean): number;
|
|
14
|
+
runNow(): Promise<void>;
|
|
15
|
+
stop(): void;
|
|
16
|
+
};
|
|
17
|
+
export declare function startConnectorLearningCoordinator(options: {
|
|
18
|
+
getConfig: () => Config;
|
|
19
|
+
resolveAgentId: () => string;
|
|
20
|
+
getMemoryManager: () => MemoryManager;
|
|
21
|
+
emit?: (type: string, payload: unknown) => void;
|
|
22
|
+
intervalMs?: number;
|
|
23
|
+
initialDelayMs?: number;
|
|
24
|
+
composioAdapter?: ComposioSessionsAdapter;
|
|
25
|
+
}): ConnectorLearningCoordinator;
|