@xopcai/xopc 0.0.171 → 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-BLz30jWq.js → activity-store-C3Y-bESI.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BKZO0EFn.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-N2qKY-WI.js → api-B7qEr_Rw.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CNZkpXCD.js → app-management-settings-panel-Br_9-7fs.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Drf5a563.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-ChVwOXE5.js → archive-plugin-B19REnR5.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BVK3Y2d9.js → attachment-load-DLWCC4Yi.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-DH4N0SYR.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-CeHY6VVP.js → binary-plugins-CtPEzLlo.js} +1 -1
- package/dist/gateway/static/root/assets/block-editor-CQVR4Xij.js +184 -0
- package/dist/gateway/static/root/assets/browser-settings-page-Bav_skKN.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-femCtfpo.js → browser-workflow-inputs-CimCGbhq.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-o0GVE_aF.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-Bx-JJC0R.js → capability-presets-api-B5RTs-Az.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-BgchTh81.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-CTw3ibx4.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-D-ZUNHhn.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CIeH4VyP.js → desktop-pet-settings-C3L6AI8_.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Ddgt6c3K.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-CJGwUaQX.js → extension-debug-page-BecQjU0J.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-B3zHKJAB.js → extension-page-BeVkPSm-.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-Cj9rrSr1.js → extension-settings-page-DMoo2mKx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-BdmtlJRP.js → gateway-config-api-Bthb3_6v.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-C2RwKIsl.js → gateway-settings-Bh8nPvJQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-mcMq_uu_.js → gateway-startup-retry-D3USVm9D.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-5Ryd_rx4.js → goal-create-dialog-Dp0AyDHI.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-CNt7nrdS.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-CAO1J4jn.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-Boj2izKZ.js → goals-settings-DhL643tc.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DbPC9a_y.js → heartbeat-settings-COVFwp7C.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-DrLCLTXn.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-vHb2z7VS.js → index-DUasAutC.js} +67 -67
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BrxfptgY.js → keyboard-shortcuts-settings-DfdJRJVy.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-BP0_Ih0e.js → local-app-workbench-page-DZwkD1co.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-DNCRlfFs.js → local-apps-page-BvCPOgoi.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CzIfXqm8.js → locale-store-BP0vD37A.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-dNL0Y1dA.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-CIUH9Lor.js → markdown-split-YO1rDk9m.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DX4AgkCs.js → media-plugins-CU_RRf-q.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-CKZuaOeG.js → messages-BWtP5TFz.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-D1KprtxL.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-DjZPJGf6.js → page-tabs-tiHmRJUA.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DNiJTpwZ.js → preview-open-alternatives-CU6XgaCz.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CNfR17-g.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-BGZFVO9S.js → save-bar-controls-edDUIbXo.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-BAZiHtds.js → schedule-field-DqJO_5Yb.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CesBcwJH.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-Bxc54BLj.js → settings-form-section-Bb0Bc3nJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CYrho7Db.js → settings-loading-skeleton-DQhADvz1.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-C03X5fkh.js → settings-page-b0M5HukN.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CZAJbv4E.js → settings-page-layout-hvjtIjvh.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-Jv8_bcOD.js → setup-status-panel-BFyfed_g.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-DSC7tKKG.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-BO89zw5H.js → system-settings-panel-BHo_hgnL.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-1OkdVC8l.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-D-_vct_y.js → typed-models-lib-DtRnG-YI.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-VlFtjlET.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-BhDk-UV_.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-uVw4Yoej.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/memory/builtin-provider.js +4 -4
- 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/service.d.ts +1 -0
- package/dist/src/agent/service.js +3 -0
- 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/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/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/you.js +86 -5
- 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/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 +3 -1
- package/dist/src/storage/sqlite/index.js +4 -2
- 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/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/user-claims-repository.d.ts +101 -0
- package/dist/src/storage/sqlite/user-claims-repository.js +241 -0
- 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-ZCIC8mhO.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-DJmgBaAm.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-Ddot8-Md.js +0 -6
- package/dist/gateway/static/root/assets/block-editor-D3GIllO3.js +0 -184
- package/dist/gateway/static/root/assets/browser-settings-page-DvETvRcg.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-ChXIYbys.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CUekXsJy.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-CkhveNsQ.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-DRTb8DBk.js +0 -1
- package/dist/gateway/static/root/assets/connector-logo-CQznQcd4.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DkSGIxWP.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-BtP-xUQ9.js +0 -1
- package/dist/gateway/static/root/assets/dreaming-settings-gd9W6SLj.js +0 -3
- package/dist/gateway/static/root/assets/goal-detail-page-DizZ6Cpl.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-Dqry_hi2.js +0 -2
- package/dist/gateway/static/root/assets/index-DEdyUjxM.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-mT48mcF4.js +0 -7
- package/dist/gateway/static/root/assets/notes-workbench-wgt2Osyk.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-CDjHvxJm.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-kJZwQXfC.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-MJdI9ek_.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BqC7GDC_.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CYwz8MfF.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-h8tGDkA3.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-D2DGvRUn.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-vqhjSMhZ.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-mtD64kFB.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-BgF0WxjM.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CP0Daig-.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-NEWZPKB_.js +0 -1
- package/dist/gateway/static/root/assets/work-page-BkWntcQh.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DRvhNQGe.js +0 -11
- 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
|
@@ -16,6 +16,7 @@ import { getAgentImageGenerationConfig, getImageGenerationCatalog, prepareImageG
|
|
|
16
16
|
import { discoverProviderModels, isProviderApiDiscoverable } from "../../../providers/model-discovery.js";
|
|
17
17
|
import { respondStartupUnavailable } from "../lib/startup-unavailable.js";
|
|
18
18
|
import { auditModelReferences } from "../../../providers/model-reference-auditor.js";
|
|
19
|
+
import { XopcCloudAccountError, XopcCloudAccountService } from "../../../providers/xopc-cloud-account-service.js";
|
|
19
20
|
//#region src/gateway/hono/routes/models.ts
|
|
20
21
|
init_models_json();
|
|
21
22
|
init_resolve_config_value();
|
|
@@ -66,6 +67,7 @@ function mapPluginModel(providerId, model, available) {
|
|
|
66
67
|
function registerModelsRoutes(authenticated, deps) {
|
|
67
68
|
const { service, strictRateLimitMiddleware } = deps;
|
|
68
69
|
const catalogSync = service.getModelCatalogSync();
|
|
70
|
+
const xopcCloudAccount = new XopcCloudAccountService();
|
|
69
71
|
authenticated.get("/api/models/catalog/status", (c) => c.json({
|
|
70
72
|
ok: true,
|
|
71
73
|
payload: catalogSync.getStatus()
|
|
@@ -90,6 +92,28 @@ function registerModelsRoutes(authenticated, deps) {
|
|
|
90
92
|
payload: result
|
|
91
93
|
});
|
|
92
94
|
});
|
|
95
|
+
authenticated.get("/api/models/xopc-cloud/account-summary", async (c) => {
|
|
96
|
+
try {
|
|
97
|
+
const summary = await xopcCloudAccount.getSummary();
|
|
98
|
+
if (!summary) return c.json({
|
|
99
|
+
ok: false,
|
|
100
|
+
error: { message: "XOPC Cloud is not configured" }
|
|
101
|
+
}, 404);
|
|
102
|
+
return c.json({
|
|
103
|
+
ok: true,
|
|
104
|
+
payload: summary
|
|
105
|
+
});
|
|
106
|
+
} catch (error) {
|
|
107
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
108
|
+
return c.json({
|
|
109
|
+
ok: false,
|
|
110
|
+
error: {
|
|
111
|
+
message,
|
|
112
|
+
...error instanceof XopcCloudAccountError && error.code ? { code: error.code } : {}
|
|
113
|
+
}
|
|
114
|
+
}, 502);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
93
117
|
authenticated.get("/api/models-json", async (c) => {
|
|
94
118
|
const path = resolveModelsJsonPath();
|
|
95
119
|
const { config, error } = loadModelsJson(path);
|
|
@@ -68,9 +68,10 @@ function registerPublicGatewayRoutes(app, service) {
|
|
|
68
68
|
data: payload
|
|
69
69
|
};
|
|
70
70
|
const normalized = normalizeComposioTriggerPayload(archivedPayload, webhookId);
|
|
71
|
-
applyComposioConnectionLifecycleEvent(archivedPayload);
|
|
71
|
+
const inactiveConnectionId = applyComposioConnectionLifecycleEvent(archivedPayload);
|
|
72
|
+
if (inactiveConnectionId) service.setConnectorLearningPaused(inactiveConnectionId, true);
|
|
72
73
|
const event = await appendComposioTriggerEvent(service.currentConfig, archivedPayload);
|
|
73
|
-
service.
|
|
74
|
+
if (normalized.toolkit) service.requestConnectorLearningForToolkit(normalized.toolkit);
|
|
74
75
|
const runs = await service.automationServiceInstance.triggerEvent({
|
|
75
76
|
type: `connector.${normalized.trigger ?? normalized.type}`,
|
|
76
77
|
source: normalized.toolkit ? `composio:${normalized.toolkit}` : "composio",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { runSqliteWriteTransaction } from "../../../storage/sqlite/transaction.js";
|
|
2
|
+
import { getUserClaim, linkUserClaimMemoryRecord, listUserClaimEvidence, listUserClaimStatsBySource, listUserClaims, removeUserClaimEvidenceForSource, setUserClaimDecision } from "../../../storage/sqlite/user-claims-repository.js";
|
|
3
|
+
import { listConnectorLearningJobs } from "../../../storage/sqlite/connector-learning-repository.js";
|
|
2
4
|
import { getRelationshipSettings, updateRelationshipSettings } from "../../../storage/sqlite/relationship-settings-repository.js";
|
|
3
5
|
import { deleteMemoryRecord, getMemoryRecord, listMemoryRecords, upsertMemoryRecord } from "../../../storage/sqlite/memory-records-repository.js";
|
|
4
6
|
import { listKnowledgeSourceItems, listKnowledgeSyncRuns } from "../../../storage/sqlite/knowledge-repository.js";
|
|
@@ -19,6 +21,7 @@ import { nextMemoryReviewAt, resolveMemoryStability } from "../../../agent/memor
|
|
|
19
21
|
import { PERSONAL_PLAYBOOK_DISABLED_TAG, PERSONAL_PLAYBOOK_ORDER_PREFIX, PERSONAL_PLAYBOOK_RULE_TAG, patchPersonalPlaybookContextTags, personalPlaybookContext } from "../../../user-context/personal-playbook.js";
|
|
20
22
|
import { listConnectorInstances } from "../../../connectors/instances.js";
|
|
21
23
|
import { uninstallConnector } from "../../../connectors/install.js";
|
|
24
|
+
import { renderUserClaim } from "../../../knowledge/connected-understanding-pipeline.js";
|
|
22
25
|
import { readUserProfileFile, writeUserProfileFile } from "../../agents-admin.js";
|
|
23
26
|
import { isUserContextMemoryKind, isUserContextRecord, projectPersonalContextSources, projectUserContextRecord, recordsDerivedFromPersonalContextSource } from "../../../user-context/projection.js";
|
|
24
27
|
import { prepareUserContextImport } from "../../../user-context/import.js";
|
|
@@ -321,10 +324,12 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
321
324
|
const trustPolicy = getUserTrustPolicy();
|
|
322
325
|
const sourceDefinitions = listConnectorCatalog();
|
|
323
326
|
const sourceInstances = listConnectorInstances(config);
|
|
324
|
-
const sources = projectPersonalContextSources(sourceDefinitions, sourceInstances,
|
|
327
|
+
const sources = projectPersonalContextSources(sourceDefinitions, sourceInstances, {
|
|
325
328
|
sourceItems: listKnowledgeSourceItems({ limit: 500 }),
|
|
326
329
|
syncRuns: listKnowledgeSyncRuns({ limit: 500 }),
|
|
327
|
-
connections: listConnectorConnections({ principalId: "local-owner" })
|
|
330
|
+
connections: listConnectorConnections({ principalId: "local-owner" }),
|
|
331
|
+
learningJobs: listConnectorLearningJobs({ limit: 500 }),
|
|
332
|
+
claimStatsBySource: listUserClaimStatsBySource()
|
|
328
333
|
});
|
|
329
334
|
const activeGoals = new GoalService().list({
|
|
330
335
|
agentId,
|
|
@@ -344,6 +349,13 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
344
349
|
},
|
|
345
350
|
...profileBundle,
|
|
346
351
|
understanding: records.map(projectUserContextRecord),
|
|
352
|
+
connectedClaims: listUserClaims({
|
|
353
|
+
agentId,
|
|
354
|
+
limit: 100
|
|
355
|
+
}).map((claim) => ({
|
|
356
|
+
...claim,
|
|
357
|
+
evidence: listUserClaimEvidence(claim.id)
|
|
358
|
+
})),
|
|
347
359
|
consentRequests: consents.filter((consent) => consent.status === "pending").flatMap((consent) => {
|
|
348
360
|
const record = recordById.get(consent.recordId);
|
|
349
361
|
return record ? [projectReferenceConsent(consent, record)] : [];
|
|
@@ -404,6 +416,64 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
404
416
|
relationship: updateRelationshipSettings(patch)
|
|
405
417
|
});
|
|
406
418
|
});
|
|
419
|
+
authenticated.patch("/api/you/claims/:id", deps.strictRateLimitMiddleware, async (c) => {
|
|
420
|
+
const body = await c.req.json().catch(() => ({}));
|
|
421
|
+
const action = body.action === "confirm" || body.action === "reject" ? body.action : void 0;
|
|
422
|
+
if (!action) return c.json({ error: "Action must be confirm or reject" }, 400);
|
|
423
|
+
const claim = runSqliteWriteTransaction(() => {
|
|
424
|
+
const updated = setUserClaimDecision(c.req.param("id"), action === "confirm" ? "confirmed" : "rejected");
|
|
425
|
+
if (!updated) return updated;
|
|
426
|
+
const existing = updated.memoryRecordId ? getMemoryRecord(updated.memoryRecordId) : void 0;
|
|
427
|
+
if (existing) preserveRecord(existing, {
|
|
428
|
+
status: action === "confirm" ? "active" : "rejected",
|
|
429
|
+
...action === "confirm" ? { reviewAfter: nextMemoryReviewAt(existing) } : {}
|
|
430
|
+
});
|
|
431
|
+
else if (action === "confirm") {
|
|
432
|
+
const candidate = renderUserClaim(updated);
|
|
433
|
+
const evidence = listUserClaimEvidence(updated.id);
|
|
434
|
+
const record = upsertMemoryRecord({
|
|
435
|
+
providerId: "connected-understanding",
|
|
436
|
+
kind: candidate.kind,
|
|
437
|
+
sourceAgentId: updated.agentId,
|
|
438
|
+
content: candidate.content,
|
|
439
|
+
canonicalKey: candidate.canonicalKey,
|
|
440
|
+
source: { provider: "connected-sources" },
|
|
441
|
+
confidence: 1,
|
|
442
|
+
status: "active",
|
|
443
|
+
sensitivity: candidate.sensitivity,
|
|
444
|
+
explicitness: "explicit",
|
|
445
|
+
durability: candidate.durability,
|
|
446
|
+
importance: candidate.importance,
|
|
447
|
+
disclosurePolicy: candidate.disclosurePolicy,
|
|
448
|
+
tags: [...new Set([
|
|
449
|
+
"user-understanding",
|
|
450
|
+
...candidate.tags ?? [],
|
|
451
|
+
"user-confirmed"
|
|
452
|
+
])],
|
|
453
|
+
evidence: evidence.map((item) => ({
|
|
454
|
+
sourceItemId: item.sourceItemId,
|
|
455
|
+
relation: item.relation === "contradicts" ? "contradicts" : "supports",
|
|
456
|
+
observedAt: item.observedAt,
|
|
457
|
+
confidence: updated.confidence
|
|
458
|
+
})),
|
|
459
|
+
reviewAfter: nextMemoryReviewAt({
|
|
460
|
+
durability: candidate.durability,
|
|
461
|
+
explicitness: "explicit"
|
|
462
|
+
})
|
|
463
|
+
});
|
|
464
|
+
linkUserClaimMemoryRecord(updated.id, record.id);
|
|
465
|
+
}
|
|
466
|
+
return getUserClaim(updated.id);
|
|
467
|
+
});
|
|
468
|
+
if (!claim) return c.json({ error: "Connected claim not found" }, 404);
|
|
469
|
+
return c.json({
|
|
470
|
+
ok: true,
|
|
471
|
+
claim: {
|
|
472
|
+
...claim,
|
|
473
|
+
evidence: listUserClaimEvidence(claim.id)
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
});
|
|
407
477
|
authenticated.get("/api/you/profile", async (c) => {
|
|
408
478
|
return c.json(await readProfileBundle(deps.service.currentConfig));
|
|
409
479
|
});
|
|
@@ -889,17 +959,28 @@ function registerYouRoutes(authenticated, deps) {
|
|
|
889
959
|
return c.json({ error: error instanceof Error ? error.message : String(error) }, 400);
|
|
890
960
|
}
|
|
891
961
|
let deletedUnderstandingCount = 0;
|
|
962
|
+
let deletedClaimCount = 0;
|
|
892
963
|
if (body.deleteDerivedUnderstanding) {
|
|
893
964
|
const sourceInstanceId = connection ? `composio:${connection.connectorId}:${connection.id}` : instanceId;
|
|
894
965
|
const targets = recordsDerivedFromPersonalContextSource(listAllUserContextRecords(ALL_MEMORY_STATUSES), sourceInstanceId);
|
|
895
966
|
runSqliteWriteTransaction(() => {
|
|
896
|
-
|
|
967
|
+
const claimRemoval = removeUserClaimEvidenceForSource(sourceInstanceId);
|
|
968
|
+
deletedClaimCount = claimRemoval.deletedClaimCount;
|
|
969
|
+
const retainedMemoryIds = new Set(claimRemoval.retainedClaims.map((claim) => claim.memoryRecordId));
|
|
970
|
+
const deleteIds = new Set([...claimRemoval.deletedMemoryRecordIds, ...targets.filter((record) => !retainedMemoryIds.has(record.id)).map((record) => record.id)]);
|
|
971
|
+
for (const recordId of deleteIds) deleteMemoryRecord(recordId);
|
|
972
|
+
for (const retained of claimRemoval.retainedClaims) {
|
|
973
|
+
if (retained.state === "active") continue;
|
|
974
|
+
const record = getMemoryRecord(retained.memoryRecordId);
|
|
975
|
+
if (record) preserveRecord(record, { status: retained.state === "rejected" ? "rejected" : "stale" });
|
|
976
|
+
}
|
|
977
|
+
deletedUnderstandingCount = deleteIds.size;
|
|
897
978
|
});
|
|
898
|
-
deletedUnderstandingCount = targets.length;
|
|
899
979
|
}
|
|
900
980
|
return c.json({
|
|
901
981
|
ok: true,
|
|
902
|
-
deletedUnderstandingCount
|
|
982
|
+
deletedUnderstandingCount,
|
|
983
|
+
deletedClaimCount
|
|
903
984
|
});
|
|
904
985
|
});
|
|
905
986
|
authenticated.patch("/api/you/understanding/:id", deps.strictRateLimitMiddleware, async (c) => {
|
|
@@ -18,6 +18,7 @@ import { GatewayMarketplaceService } from './service/marketplace-service.js';
|
|
|
18
18
|
import { GatewayAgentRunner } from './service/agent-runner.js';
|
|
19
19
|
import type { GatewayServiceConfig, ServiceEvent } from './service/types.js';
|
|
20
20
|
import { type GatewayReadinessSnapshot } from './startup-readiness.js';
|
|
21
|
+
import { type ConnectorLearningCoordinator } from '../connectors/learning-coordinator.js';
|
|
21
22
|
import { type ProductLanguage } from '../voice/language-profile.js';
|
|
22
23
|
export type { GatewayChannelStartupPhase1Metrics, GatewayChannelStartupPhase2Metrics, GatewayServiceConfig, ServiceEvent, } from './service/types.js';
|
|
23
24
|
export declare class GatewayService {
|
|
@@ -63,7 +64,7 @@ export declare class GatewayService {
|
|
|
63
64
|
private goalNotifications;
|
|
64
65
|
private mobileNotifications;
|
|
65
66
|
private connectorSupervisor;
|
|
66
|
-
private
|
|
67
|
+
private connectorLearningCoordinator;
|
|
67
68
|
private connectedKnowledgeCoordinator;
|
|
68
69
|
private stopAutomationProductEventBridge;
|
|
69
70
|
private stopSessionTranscriptAutomationEvents;
|
|
@@ -207,7 +208,9 @@ export declare class GatewayService {
|
|
|
207
208
|
requestHeartbeatNow(opts?: {
|
|
208
209
|
reason?: string;
|
|
209
210
|
}): void;
|
|
210
|
-
|
|
211
|
+
requestConnectorLearning(connectionId: string, request?: Parameters<ConnectorLearningCoordinator['enqueueConnection']>[1]): ReturnType<ConnectorLearningCoordinator['enqueueConnection']>;
|
|
212
|
+
requestConnectorLearningForToolkit(toolkit: string): ReturnType<ConnectorLearningCoordinator['enqueueToolkit']>;
|
|
213
|
+
setConnectorLearningPaused(connectionId: string, paused: boolean): number;
|
|
211
214
|
/**
|
|
212
215
|
* Register graceful shutdown used after spawning a replacement gateway process (foreground CLI server).
|
|
213
216
|
*/
|
|
@@ -44,7 +44,7 @@ import { getWorkspacePath } from "../config/workspace-path-helpers.js";
|
|
|
44
44
|
import "../config/index.js";
|
|
45
45
|
import { startConnectedKnowledgeCoordinator } from "../knowledge/coordinator.js";
|
|
46
46
|
import "../knowledge/index.js";
|
|
47
|
-
import {
|
|
47
|
+
import { startConnectorLearningCoordinator } from "../connectors/learning-coordinator.js";
|
|
48
48
|
import { startConnectorSupervisor } from "../connectors/supervisor.js";
|
|
49
49
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
50
50
|
import { reconcileDreamingAutomations } from "./dreaming-automation-reconciler.js";
|
|
@@ -159,7 +159,7 @@ var GatewayService = class {
|
|
|
159
159
|
goalNotifications = null;
|
|
160
160
|
mobileNotifications = null;
|
|
161
161
|
connectorSupervisor = null;
|
|
162
|
-
|
|
162
|
+
connectorLearningCoordinator = null;
|
|
163
163
|
connectedKnowledgeCoordinator = null;
|
|
164
164
|
stopAutomationProductEventBridge = null;
|
|
165
165
|
stopSessionTranscriptAutomationEvents = null;
|
|
@@ -713,9 +713,11 @@ var GatewayService = class {
|
|
|
713
713
|
getConfig: () => this.config,
|
|
714
714
|
saveConfig: (cfg) => this.saveConfig(cfg)
|
|
715
715
|
});
|
|
716
|
-
this.
|
|
716
|
+
this.connectorLearningCoordinator = startConnectorLearningCoordinator({
|
|
717
717
|
getConfig: () => this.config,
|
|
718
|
-
resolveAgentId: () => resolveDefaultAgentId(this.config)
|
|
718
|
+
resolveAgentId: () => resolveDefaultAgentId(this.config),
|
|
719
|
+
getMemoryManager: () => this.agentService.getMemoryManager(),
|
|
720
|
+
emit: (type, payload) => this.emit(type, payload)
|
|
719
721
|
});
|
|
720
722
|
this.connectedKnowledgeCoordinator = startConnectedKnowledgeCoordinator({ resolvePipelineOptions: () => ({
|
|
721
723
|
agentId: resolveDefaultAgentId(this.config),
|
|
@@ -841,8 +843,8 @@ var GatewayService = class {
|
|
|
841
843
|
this.heartbeatService?.stop();
|
|
842
844
|
this.connectorSupervisor?.stop();
|
|
843
845
|
this.connectorSupervisor = null;
|
|
844
|
-
this.
|
|
845
|
-
this.
|
|
846
|
+
this.connectorLearningCoordinator?.stop();
|
|
847
|
+
this.connectorLearningCoordinator = null;
|
|
846
848
|
this.connectedKnowledgeCoordinator?.stop();
|
|
847
849
|
this.connectedKnowledgeCoordinator = null;
|
|
848
850
|
await this.browserRecipeService?.shutdown();
|
|
@@ -1085,11 +1087,14 @@ var GatewayService = class {
|
|
|
1085
1087
|
requestHeartbeatNow(opts) {
|
|
1086
1088
|
this.heartbeatService?.requestNow({ reason: opts?.reason ?? "manual" });
|
|
1087
1089
|
}
|
|
1088
|
-
|
|
1089
|
-
this.
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1090
|
+
requestConnectorLearning(connectionId, request) {
|
|
1091
|
+
return this.connectorLearningCoordinator?.enqueueConnection(connectionId, request) ?? null;
|
|
1092
|
+
}
|
|
1093
|
+
requestConnectorLearningForToolkit(toolkit) {
|
|
1094
|
+
return this.connectorLearningCoordinator?.enqueueToolkit(toolkit) ?? [];
|
|
1095
|
+
}
|
|
1096
|
+
setConnectorLearningPaused(connectionId, paused) {
|
|
1097
|
+
return this.connectorLearningCoordinator?.setPaused(connectionId, paused) ?? 0;
|
|
1093
1098
|
}
|
|
1094
1099
|
/**
|
|
1095
1100
|
* Register graceful shutdown used after spawning a replacement gateway process (foreground CLI server).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { UnderstandingCandidate, UnderstandingReviewResult } from '../agent/memory/understanding/types.js';
|
|
2
|
+
import type { MemoryManager } from '../agent/memory/manager.js';
|
|
3
|
+
import { resolveUserEntity, type UserClaim, type UserClaimClass } from '../storage/sqlite/index.js';
|
|
4
|
+
import type { KnowledgeSourceItem } from './types.js';
|
|
5
|
+
export type ClaimObservation = {
|
|
6
|
+
class: UserClaimClass;
|
|
7
|
+
key: string;
|
|
8
|
+
value: Record<string, unknown>;
|
|
9
|
+
subject?: Parameters<typeof resolveUserEntity>[0];
|
|
10
|
+
items: KnowledgeSourceItem[];
|
|
11
|
+
windowDays: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function deriveConnectedClaimObservations(items: KnowledgeSourceItem[]): ClaimObservation[];
|
|
14
|
+
export declare function renderUserClaim(claim: UserClaim): UnderstandingCandidate;
|
|
15
|
+
export declare class ConnectedUnderstandingPipeline {
|
|
16
|
+
private readonly memoryManager;
|
|
17
|
+
constructor(memoryManager: MemoryManager);
|
|
18
|
+
process(sourceInstanceId: string, connectorId: string, agentId: string): Promise<UnderstandingReviewResult>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { linkUserClaimMemoryRecord, reinforceUserClaim, resolveUserEntity } from "../storage/sqlite/user-claims-repository.js";
|
|
2
|
+
import { listKnowledgeSourceItems } from "../storage/sqlite/knowledge-repository.js";
|
|
3
|
+
import "../storage/sqlite/index.js";
|
|
4
|
+
//#region src/knowledge/connected-understanding-pipeline.ts
|
|
5
|
+
function logicalEventKey(item) {
|
|
6
|
+
const value = item.metadata.logicalEventKey;
|
|
7
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
8
|
+
}
|
|
9
|
+
function eventTime(item) {
|
|
10
|
+
if (!item.occurredAt) return void 0;
|
|
11
|
+
const value = Date.parse(item.occurredAt);
|
|
12
|
+
return Number.isFinite(value) ? value : void 0;
|
|
13
|
+
}
|
|
14
|
+
function recent(items, days) {
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
const cutoff = now - days * 864e5;
|
|
17
|
+
return items.filter((item) => {
|
|
18
|
+
const time = eventTime(item);
|
|
19
|
+
return time !== void 0 && time >= cutoff && time <= now + 3e5 && logicalEventKey(item);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function person(value) {
|
|
23
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
24
|
+
const row = value;
|
|
25
|
+
const read = (field) => typeof row[field] === "string" && row[field].trim() ? row[field].trim().slice(0, 160) : void 0;
|
|
26
|
+
const result = {
|
|
27
|
+
name: read("name"),
|
|
28
|
+
email: read("email"),
|
|
29
|
+
username: read("username")
|
|
30
|
+
};
|
|
31
|
+
return result.name || result.email || result.username ? result : void 0;
|
|
32
|
+
}
|
|
33
|
+
function relationshipObservations(items) {
|
|
34
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
35
|
+
for (const item of recent(items, 90)) {
|
|
36
|
+
if (item.metadata.actorAttributed !== true) continue;
|
|
37
|
+
const owners = new Set(Array.isArray(item.metadata.ownerIdentities) ? item.metadata.ownerIdentities.filter((value) => typeof value === "string").map((value) => value.toLowerCase()) : []);
|
|
38
|
+
const values = item.metadata.personEntities;
|
|
39
|
+
if (!Array.isArray(values)) continue;
|
|
40
|
+
for (const value of values) {
|
|
41
|
+
const signal = person(value);
|
|
42
|
+
if (!signal) continue;
|
|
43
|
+
const strongIdentity = (signal.email ?? signal.username)?.toLowerCase();
|
|
44
|
+
if (strongIdentity && owners.has(strongIdentity)) continue;
|
|
45
|
+
const label = signal.name ?? signal.email ?? signal.username;
|
|
46
|
+
const handles = [
|
|
47
|
+
...signal.email ? [{
|
|
48
|
+
type: "email",
|
|
49
|
+
value: signal.email,
|
|
50
|
+
sourceScope: "global",
|
|
51
|
+
verified: true
|
|
52
|
+
}] : [],
|
|
53
|
+
...signal.username ? [{
|
|
54
|
+
type: "provider_user",
|
|
55
|
+
value: signal.username,
|
|
56
|
+
sourceScope: String(item.metadata.toolkit ?? item.sourceInstanceId),
|
|
57
|
+
verified: true
|
|
58
|
+
}] : [],
|
|
59
|
+
...signal.name ? [{
|
|
60
|
+
type: "display_name",
|
|
61
|
+
value: signal.name,
|
|
62
|
+
sourceScope: item.sourceInstanceId,
|
|
63
|
+
verified: false
|
|
64
|
+
}] : []
|
|
65
|
+
];
|
|
66
|
+
const identityKey = signal.email?.toLowerCase() ?? `${String(item.metadata.toolkit ?? item.sourceInstanceId)}:${signal.username?.toLowerCase() ?? signal.name?.toLowerCase()}`;
|
|
67
|
+
const entry = grouped.get(identityKey) ?? {
|
|
68
|
+
label,
|
|
69
|
+
handles,
|
|
70
|
+
events: /* @__PURE__ */ new Map()
|
|
71
|
+
};
|
|
72
|
+
const eventKey = logicalEventKey(item);
|
|
73
|
+
if (!entry.events.has(eventKey)) entry.events.set(eventKey, item);
|
|
74
|
+
grouped.set(identityKey, entry);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return [...grouped.values()].sort((left, right) => right.events.size - left.events.size).slice(0, 8).map((entry) => ({
|
|
78
|
+
class: "relationship",
|
|
79
|
+
key: "person",
|
|
80
|
+
value: { label: entry.label },
|
|
81
|
+
subject: {
|
|
82
|
+
type: "person",
|
|
83
|
+
canonicalLabel: entry.label,
|
|
84
|
+
handles: entry.handles
|
|
85
|
+
},
|
|
86
|
+
items: [...entry.events.values()],
|
|
87
|
+
windowDays: 90
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
function routineObservations(items) {
|
|
91
|
+
const slots = /* @__PURE__ */ new Map();
|
|
92
|
+
for (const item of recent(items, 120).filter((candidate) => candidate.itemType === "calendar_event")) {
|
|
93
|
+
const date = new Date(item.occurredAt);
|
|
94
|
+
const slot = `${date.getUTCDay()}:${date.getUTCHours()}`;
|
|
95
|
+
const events = slots.get(slot) ?? /* @__PURE__ */ new Map();
|
|
96
|
+
const eventKey = logicalEventKey(item);
|
|
97
|
+
if (!events.has(eventKey)) events.set(eventKey, item);
|
|
98
|
+
slots.set(slot, events);
|
|
99
|
+
}
|
|
100
|
+
return [...slots.entries()].sort((left, right) => right[1].size - left[1].size).slice(0, 4).map(([slot, events]) => {
|
|
101
|
+
const [weekday, hour] = slot.split(":").map(Number);
|
|
102
|
+
return {
|
|
103
|
+
class: "routine",
|
|
104
|
+
key: `calendar-slot:${slot}`,
|
|
105
|
+
value: {
|
|
106
|
+
weekday,
|
|
107
|
+
hour,
|
|
108
|
+
timezone: "UTC"
|
|
109
|
+
},
|
|
110
|
+
items: [...events.values()],
|
|
111
|
+
windowDays: 120
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function projectObservations(items) {
|
|
116
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
117
|
+
for (const item of recent(items, 60)) {
|
|
118
|
+
if (item.metadata.observationKind !== "activity" || item.metadata.actorAttributed !== true) continue;
|
|
119
|
+
const subject = typeof item.metadata.subjectKey === "string" ? item.metadata.subjectKey.trim() : "";
|
|
120
|
+
if (!subject) continue;
|
|
121
|
+
const entry = grouped.get(subject.toLowerCase()) ?? {
|
|
122
|
+
label: subject,
|
|
123
|
+
events: /* @__PURE__ */ new Map()
|
|
124
|
+
};
|
|
125
|
+
const events = entry.events;
|
|
126
|
+
const eventKey = logicalEventKey(item);
|
|
127
|
+
if (!events.has(eventKey)) events.set(eventKey, item);
|
|
128
|
+
grouped.set(subject.toLowerCase(), entry);
|
|
129
|
+
}
|
|
130
|
+
return [...grouped.entries()].sort((left, right) => right[1].events.size - left[1].events.size).slice(0, 8).map(([, entry]) => {
|
|
131
|
+
const { label: subject, events } = entry;
|
|
132
|
+
return {
|
|
133
|
+
class: "project",
|
|
134
|
+
key: "project",
|
|
135
|
+
value: { label: subject },
|
|
136
|
+
subject: {
|
|
137
|
+
type: "project",
|
|
138
|
+
canonicalLabel: subject,
|
|
139
|
+
handles: [{
|
|
140
|
+
type: "provider_user",
|
|
141
|
+
value: subject,
|
|
142
|
+
sourceScope: "project",
|
|
143
|
+
verified: true
|
|
144
|
+
}]
|
|
145
|
+
},
|
|
146
|
+
items: [...events.values()],
|
|
147
|
+
windowDays: 60
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function deriveConnectedClaimObservations(items) {
|
|
152
|
+
const active = items.filter((item) => !item.deletedAt && item.synthesisPipeline === "connected_knowledge" && item.sensitivity !== "secret" && item.sensitivity !== "regulated" && item.metadata.observationKind !== "inventory");
|
|
153
|
+
return [
|
|
154
|
+
...relationshipObservations(active),
|
|
155
|
+
...routineObservations(active),
|
|
156
|
+
...projectObservations(active)
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
function renderUserClaim(claim) {
|
|
160
|
+
const label = typeof claim.value.label === "string" ? claim.value.label : "";
|
|
161
|
+
if (claim.class === "relationship") return {
|
|
162
|
+
kind: "relationship",
|
|
163
|
+
content: `Frequently collaborates with ${label}.`,
|
|
164
|
+
canonicalKey: `claim:${claim.id}`,
|
|
165
|
+
confidence: claim.confidence,
|
|
166
|
+
importance: .65,
|
|
167
|
+
explicitness: "inferred",
|
|
168
|
+
durability: "recurring",
|
|
169
|
+
sensitivity: "personal",
|
|
170
|
+
disclosurePolicy: "ask_before_reference",
|
|
171
|
+
tags: ["connected-source", "structured-claim"]
|
|
172
|
+
};
|
|
173
|
+
if (claim.class === "project") return {
|
|
174
|
+
kind: "project_context",
|
|
175
|
+
content: `Recently contributed repeatedly to ${label}.`,
|
|
176
|
+
canonicalKey: `claim:${claim.id}`,
|
|
177
|
+
confidence: claim.confidence,
|
|
178
|
+
importance: .72,
|
|
179
|
+
explicitness: "inferred",
|
|
180
|
+
durability: "recurring",
|
|
181
|
+
sensitivity: "personal",
|
|
182
|
+
disclosurePolicy: "referenceable",
|
|
183
|
+
tags: ["connected-source", "structured-claim"]
|
|
184
|
+
};
|
|
185
|
+
const weekday = Number(claim.value.weekday);
|
|
186
|
+
const hour = Number(claim.value.hour);
|
|
187
|
+
return {
|
|
188
|
+
kind: "routine",
|
|
189
|
+
content: `Often has calendar activity on ${[
|
|
190
|
+
"Sunday",
|
|
191
|
+
"Monday",
|
|
192
|
+
"Tuesday",
|
|
193
|
+
"Wednesday",
|
|
194
|
+
"Thursday",
|
|
195
|
+
"Friday",
|
|
196
|
+
"Saturday"
|
|
197
|
+
][weekday] ?? "Unknown"} around ${String(hour).padStart(2, "0")}:00 UTC.`,
|
|
198
|
+
canonicalKey: `claim:${claim.id}`,
|
|
199
|
+
confidence: claim.confidence,
|
|
200
|
+
importance: .58,
|
|
201
|
+
explicitness: "inferred",
|
|
202
|
+
durability: "recurring",
|
|
203
|
+
sensitivity: "personal",
|
|
204
|
+
disclosurePolicy: "referenceable",
|
|
205
|
+
tags: ["connected-source", "structured-claim"]
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
var ConnectedUnderstandingPipeline = class {
|
|
209
|
+
constructor(memoryManager) {
|
|
210
|
+
this.memoryManager = memoryManager;
|
|
211
|
+
}
|
|
212
|
+
async process(sourceInstanceId, connectorId, agentId) {
|
|
213
|
+
const observations = deriveConnectedClaimObservations(listKnowledgeSourceItems({
|
|
214
|
+
sourceInstanceId,
|
|
215
|
+
includeDeleted: false,
|
|
216
|
+
limit: 500
|
|
217
|
+
}));
|
|
218
|
+
const totals = {
|
|
219
|
+
proposed: observations.length,
|
|
220
|
+
created: 0,
|
|
221
|
+
deduplicated: 0,
|
|
222
|
+
rejected: 0,
|
|
223
|
+
createdRecords: []
|
|
224
|
+
};
|
|
225
|
+
for (const observation of observations) {
|
|
226
|
+
const subject = observation.subject ? resolveUserEntity(observation.subject) : void 0;
|
|
227
|
+
const claim = reinforceUserClaim({
|
|
228
|
+
agentId,
|
|
229
|
+
class: observation.class,
|
|
230
|
+
key: subject ? `${observation.key}:${subject.id}` : observation.key,
|
|
231
|
+
subjectEntityId: subject?.id,
|
|
232
|
+
value: observation.value,
|
|
233
|
+
evidence: observation.items.map((item) => ({
|
|
234
|
+
logicalEventKey: logicalEventKey(item),
|
|
235
|
+
sourceItemId: item.id,
|
|
236
|
+
sourceInstanceId: item.sourceInstanceId,
|
|
237
|
+
relation: "supports",
|
|
238
|
+
observedAt: item.occurredAt
|
|
239
|
+
}))
|
|
240
|
+
});
|
|
241
|
+
if (claim.state !== "active") continue;
|
|
242
|
+
const result = await this.memoryManager.applyUnderstandingCandidates([renderUserClaim(claim)], {
|
|
243
|
+
agentId,
|
|
244
|
+
sourceItemIds: observation.items.map((item) => item.id).slice(0, 20),
|
|
245
|
+
sourceText: JSON.stringify({
|
|
246
|
+
claimId: claim.id,
|
|
247
|
+
independentEvidenceCount: claim.independentEvidenceCount,
|
|
248
|
+
activeDays: claim.activeDayCount,
|
|
249
|
+
windowDays: observation.windowDays
|
|
250
|
+
}),
|
|
251
|
+
source: {
|
|
252
|
+
provider: connectorId,
|
|
253
|
+
sourceInstanceId
|
|
254
|
+
},
|
|
255
|
+
reviewSource: "background"
|
|
256
|
+
});
|
|
257
|
+
const memoryRecordId = result.createdRecords[0]?.id;
|
|
258
|
+
if (memoryRecordId) linkUserClaimMemoryRecord(claim.id, memoryRecordId);
|
|
259
|
+
totals.created += result.created;
|
|
260
|
+
totals.deduplicated += result.deduplicated;
|
|
261
|
+
totals.rejected += result.rejected;
|
|
262
|
+
totals.createdRecords.push(...result.createdRecords);
|
|
263
|
+
}
|
|
264
|
+
return totals;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
//#endregion
|
|
268
|
+
export { ConnectedUnderstandingPipeline, deriveConnectedClaimObservations, renderUserClaim };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
2
|
export * from './ingestion-service.js';
|
|
3
3
|
export * from './connected-knowledge-pipeline.js';
|
|
4
|
+
export * from './connected-understanding-pipeline.js';
|
|
4
5
|
export * from './coordinator.js';
|
|
5
6
|
export * from './local-folder-adapter.js';
|
|
6
7
|
export * from './people-graph.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { KnowledgeIngestionService, SqliteKnowledgeSourceStateStore } from "./ingestion-service.js";
|
|
2
2
|
import { ConnectedKnowledgePipeline } from "./connected-knowledge-pipeline.js";
|
|
3
|
+
import { ConnectedUnderstandingPipeline, deriveConnectedClaimObservations, renderUserClaim } from "./connected-understanding-pipeline.js";
|
|
3
4
|
import { startConnectedKnowledgeCoordinator } from "./coordinator.js";
|
|
4
5
|
import { LocalFolderKnowledgeSourceAdapter } from "./local-folder-adapter.js";
|
|
5
6
|
import { buildConnectedPeopleGraph } from "./people-graph.js";
|
|
6
|
-
export { ConnectedKnowledgePipeline, KnowledgeIngestionService, LocalFolderKnowledgeSourceAdapter, SqliteKnowledgeSourceStateStore, buildConnectedPeopleGraph, startConnectedKnowledgeCoordinator };
|
|
7
|
+
export { ConnectedKnowledgePipeline, ConnectedUnderstandingPipeline, KnowledgeIngestionService, LocalFolderKnowledgeSourceAdapter, SqliteKnowledgeSourceStateStore, buildConnectedPeopleGraph, deriveConnectedClaimObservations, renderUserClaim, startConnectedKnowledgeCoordinator };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { KnowledgeSourceAdapter, KnowledgeSourceItemInput, KnowledgeSyncRun } from './types.js';
|
|
2
2
|
export interface KnowledgeSourceStateStore {
|
|
3
|
-
getCursor(instanceId: string): string | undefined;
|
|
4
|
-
setCursor(instanceId: string, cursor: string | undefined): void;
|
|
3
|
+
getCursor(instanceId: string, collectionScope: string): string | undefined;
|
|
4
|
+
setCursor(instanceId: string, collectionScope: string, cursor: string | undefined): void;
|
|
5
5
|
}
|
|
6
6
|
export declare class SqliteKnowledgeSourceStateStore implements KnowledgeSourceStateStore {
|
|
7
|
-
getCursor(instanceId: string): string | undefined;
|
|
8
|
-
setCursor(instanceId: string, cursor: string | undefined): void;
|
|
7
|
+
getCursor(instanceId: string, collectionScope: string): string | undefined;
|
|
8
|
+
setCursor(instanceId: string, collectionScope: string, cursor: string | undefined): void;
|
|
9
9
|
}
|
|
10
10
|
export declare class KnowledgeIngestionService {
|
|
11
11
|
private readonly adapters;
|
|
@@ -13,6 +13,7 @@ export declare class KnowledgeIngestionService {
|
|
|
13
13
|
constructor(adapters: ReadonlyMap<string, KnowledgeSourceAdapter>, state?: KnowledgeSourceStateStore);
|
|
14
14
|
ingest(params: {
|
|
15
15
|
instanceId: string;
|
|
16
|
+
collectionScope: string;
|
|
16
17
|
items: KnowledgeSourceItemInput[];
|
|
17
18
|
cursorAfter?: string;
|
|
18
19
|
warnings?: string[];
|
|
@@ -20,6 +21,7 @@ export declare class KnowledgeIngestionService {
|
|
|
20
21
|
sync(params: {
|
|
21
22
|
adapterKind: string;
|
|
22
23
|
instanceId: string;
|
|
24
|
+
collectionScope: string;
|
|
23
25
|
windowStart?: string;
|
|
24
26
|
signal?: AbortSignal;
|
|
25
27
|
}): Promise<KnowledgeSyncRun>;
|