@xopcai/xopc 0.0.228 → 0.0.229
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/{agent-avatar-dicebear-CjGZBs4C.js → agent-avatar-dicebear-CsFAJTIN.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-B0NI4_NI.js → agents-DA4b6_0C.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel--SjycrXk.js → app-management-settings-panel-7KcMWuah.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-8G-TVUtg.js → appearance-settings-Cqlw7Fif.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-2NiqD-YP.js → apps-page-CsnhdGZ2.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Bx44zSpz.js → attachment-load-q4pDpqkF.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CrKAHqc0.js → automations-page-BuTqjKGX.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-Q3g9cf0h.js → automations-workspace-CD0E2ThS.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-DjDwnHAQ.js → binary-plugins-DUce1Bsc.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-7aMOKoZM.js → block-editor-D8Ejp-QR.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-DTwPkmAC.js → browser-settings-page-CY1k3MMd.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-DVLrWKz_.js → browser-workflows-page-BDvZbR9v.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-YcP4FbN7.js → capabilities-settings-panel-D1VfotHQ.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-AcPjHHia.js → capability-presets-settings-panel-DXHqRLpU.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-Ca94Q1D-.js → channels-settings-DrFL57M_.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-BR-_7KC0.js → chat-terminal-dock-h1CKexNz.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-SGxfLTd6.js → connectors-page-DUAyfFCF.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-expression-D8-c-Tkw.js → cron-expression-DlaQQOId.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-kV-Jyl9J.js → date-picker-8R1sXJKb.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-CwKcrfGj.js → dependency-picker-CWur0821.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-D9rnchu3.js → desktop-pet-Knl-zNDU.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CTs5WGzk.js → desktop-pet-settings-CAQMLVtd.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-CCl0aaDm.js → directory-picker-path-field-Caaz4Rw5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-Cau40SvC.js → extension-debug-page-B965Mc15.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BsJXdvIL.js → extension-page-C0UnkBi5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-qWqJyF7-.js → extension-settings-page-BUSIAZCR.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-BI0SELXm.js → gateway-config-api-DkH0eEgy.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-6ZdOIC7F.js → gateway-settings-BBgLDm6I.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-KBwhXeFD.js → heartbeat-settings-BtEHVXWD.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-BA2M4CLi.js → home-page-5SU2TNJj.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BX0dz1JK.js → index-BNWhgmjs.js} +8 -8
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-kHtpnyEm.js → keyboard-shortcuts-settings-CsRz8NrS.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-D2nkn09R.js → local-app-workbench-page-DYPEUgpP.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-BCXa0oUa.js → local-apps-page-CTBNUG4a.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-D3sNst0K.js → logs-page-B0P7rG2B.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-tHnlfOAQ.js → management-settings-YqUAEwQo.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-BMLqHHr5.js → markdown-split-dxpSCXb8.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DybwqTgv.js → media-plugins-CJ00i1Lg.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-C24SfF6r.js → notes-page-DEnbnkIt.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-CTdZc3ov.js → notes-workbench-DmVYu_Oc.js} +2 -2
- package/dist/gateway/static/root/assets/{product-open-page-DBfCVlJq.js → product-open-page-BHxo9U95.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-COHaEpbA.js → project-detail-page-DV2nGmsq.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-lMnST7D_.js → projects-page-BNIFwFfc.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BIRKBvO_.js → remote-access-hub-DLXqKiA_.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BPEGTip5.js → runtime-tools-settings-panel-BpQ2GI-0.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Dxlu60Td.js → schema-form-HE1G26Lx.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-CATO9G3y.js → sessions-page-DWaXf_25.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-JFCbnCL2.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-ChXh3Bwk.js → settings-form-section-CXAn0Xhy.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BCAUqIe2.js → settings-loading-skeleton-DsFu7Bcv.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-D25W9Okr.js → settings-page-C4iib9nO.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-DsN7Z4Fl.js → setup-status-panel-BA83Wr1d.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CRFnUaNb.js → share-preview-page-BOGl3s6M.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CAX0eNaP.js → shares-settings-Q2MdGaBi.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-Doy1gghe.js → skill-reload-api-cFtfVeFU.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-Cl7jjTK7.js → skills-page-CdaFtNw9.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-BiCl4nb5.js → skills-page.utils-DYaAddUL.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BuESR7ZT.js → system-settings-panel-Co7gilRd.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BRiy8NL3.js → task-detail-page-5B1pswu8.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Dg1mgJ_l.js → use-autosave-DnnZtMpA.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-CqoADNKu.js → user-context-page-Dr1FKjXv.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BDNexlVR.js → voice-api-key-field-wetUpi3i.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BHTfeaWL.js → work-discovery-overlay-tbTWASJJ.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Cf_w-NZy.js → workflow-run-setup-panel-Dy0fDs8w.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-j0P-uECz.js → workflows-page-IVP3GSkI.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-instance-gateway.d.ts +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -1
- package/dist/src/agent/agent-manager.js +18 -3
- package/dist/src/agent/background-review/prompts.d.ts +8 -2
- package/dist/src/agent/background-review/prompts.js +25 -12
- package/dist/src/agent/background-review/run-background-review.d.ts +7 -2
- package/dist/src/agent/background-review/run-background-review.js +175 -160
- package/dist/src/agent/memory/index.d.ts +1 -1
- package/dist/src/agent/memory/index.js +2 -2
- package/dist/src/agent/memory/manager.d.ts +1 -11
- package/dist/src/agent/memory/manager.js +0 -16
- package/dist/src/agent/memory/understanding/service.d.ts +0 -11
- package/dist/src/agent/memory/understanding/service.js +7 -173
- package/dist/src/agent/memory/user-context-coordinator.d.ts +1 -3
- package/dist/src/agent/memory/user-context-coordinator.js +3 -66
- package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/schema.d.ts +4 -0
- package/dist/src/config/schema.js +1 -0
- package/dist/src/connectors/connected-source-understanding.js +35 -21
- package/dist/src/connectors/learning-coordinator.js +1 -42
- package/dist/src/gateway/chat-stream/mapper.d.ts +2 -0
- package/dist/src/gateway/chat-stream/mapper.js +5 -0
- package/dist/src/gateway/hono/routes/understanding-sources.js +4 -1
- package/dist/src/gateway/hono/routes/you.js +29 -11
- package/dist/src/gateway/service/run-gateway-agent.js +5 -1
- package/dist/src/knowledge/index.d.ts +0 -1
- package/dist/src/knowledge/index.js +1 -2
- package/dist/src/notifications/planner.js +5 -1
- package/dist/src/storage/sqlite/index.d.ts +1 -1
- package/dist/src/storage/sqlite/index.js +2 -2
- package/dist/src/storage/sqlite/migrations/137_understanding_status_audit.sql +71 -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-context-repository.d.ts +16 -4
- package/dist/src/storage/sqlite/user-context-repository.js +56 -12
- package/dist/src/user-context/config.d.ts +8 -0
- package/dist/src/user-context/config.js +3 -0
- package/dist/src/user-context/consolidation.js +16 -4
- package/dist/src/user-context/extraction/executor.d.ts +22 -0
- package/dist/src/user-context/extraction/executor.js +142 -0
- package/dist/src/user-context/extraction/registry.d.ts +1 -1
- package/dist/src/user-context/extraction/registry.js +5 -34
- package/dist/src/user-context/extraction/repair.js +4 -1
- package/dist/src/user-context/extraction/semantic.d.ts +18 -0
- package/dist/src/user-context/extraction/semantic.js +148 -0
- package/dist/src/user-context/understandingQuality.js +4 -0
- package/dist/src/work-discovery/analyzer.js +9 -4
- package/dist/src/work-discovery/service.d.ts +1 -0
- package/dist/src/work-discovery/service.js +5 -4
- package/dist/src/work-discovery/types.d.ts +1 -0
- package/package.json +14 -8
- package/dist/gateway/static/root/assets/settings-advanced-gate-Cco_W41x.js +0 -1
- package/dist/src/agent/memory/understanding/correction.d.ts +0 -3
- package/dist/src/agent/memory/understanding/correction.js +0 -39
- package/dist/src/knowledge/connected-understanding-pipeline.d.ts +0 -17
- package/dist/src/knowledge/connected-understanding-pipeline.js +0 -278
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { listKnowledgeSourceItems } from "../storage/sqlite/knowledge-repository.js";
|
|
2
|
-
import "../storage/sqlite/index.js";
|
|
3
|
-
import { clusterUnderstandingSignals } from "../user-context/sources/signal-clustering.js";
|
|
4
|
-
import { personIdForIdentity, personIdentityKey, rebuildUserPeopleIndex } from "../user-context/relationships/indexer.js";
|
|
5
|
-
//#region src/knowledge/connected-understanding-pipeline.ts
|
|
6
|
-
function logicalEventKey(item) {
|
|
7
|
-
const value = item.metadata.logicalEventKey;
|
|
8
|
-
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
9
|
-
}
|
|
10
|
-
function eventTime(item) {
|
|
11
|
-
if (!item.occurredAt) return void 0;
|
|
12
|
-
const value = Date.parse(item.occurredAt);
|
|
13
|
-
return Number.isFinite(value) ? value : void 0;
|
|
14
|
-
}
|
|
15
|
-
function normalizedRecord(item) {
|
|
16
|
-
if (!item.normalizedText) return {};
|
|
17
|
-
try {
|
|
18
|
-
const value = JSON.parse(item.normalizedText);
|
|
19
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
20
|
-
} catch {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function textField(record, ...fields) {
|
|
25
|
-
for (const field of fields) {
|
|
26
|
-
const value = record[field];
|
|
27
|
-
if (typeof value === "string" && value.trim()) return value.trim();
|
|
28
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
29
|
-
const nested = value;
|
|
30
|
-
for (const nestedField of [
|
|
31
|
-
"name",
|
|
32
|
-
"full_name",
|
|
33
|
-
"fullName",
|
|
34
|
-
"title"
|
|
35
|
-
]) {
|
|
36
|
-
const nestedValue = nested[nestedField];
|
|
37
|
-
if (typeof nestedValue === "string" && nestedValue.trim()) return nestedValue.trim();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function normalizeConversationTitle(value) {
|
|
43
|
-
return value.replace(/^(?:(?:re|fwd?|回复|转发)\s*[::]\s*)+/i, "").trim();
|
|
44
|
-
}
|
|
45
|
-
function projectSignal(item) {
|
|
46
|
-
if (item.metadata.actorAttributed !== true) return void 0;
|
|
47
|
-
const observationKind = item.metadata.observationKind;
|
|
48
|
-
if (![
|
|
49
|
-
"activity",
|
|
50
|
-
"message",
|
|
51
|
-
"calendar_event",
|
|
52
|
-
"external_task",
|
|
53
|
-
"document_metadata"
|
|
54
|
-
].includes(String(observationKind))) return;
|
|
55
|
-
const title = textField(normalizedRecord(item), "subject", "title", "repository", "project", "fullName", "full_name", "name");
|
|
56
|
-
const subjectKey = typeof item.metadata.subjectKey === "string" && item.metadata.subjectKey.trim() ? item.metadata.subjectKey.trim() : void 0;
|
|
57
|
-
const displayTitle = title ? normalizeConversationTitle(title) : subjectKey;
|
|
58
|
-
if (!displayTitle) return void 0;
|
|
59
|
-
return {
|
|
60
|
-
evidenceRef: item.id,
|
|
61
|
-
sourceId: item.sourceInstanceId,
|
|
62
|
-
title: displayTitle,
|
|
63
|
-
group: typeof item.metadata.toolkit === "string" ? item.metadata.toolkit : void 0,
|
|
64
|
-
subjectKey,
|
|
65
|
-
occurredAt: eventTime(item)
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function recent(items, days) {
|
|
69
|
-
const now = Date.now();
|
|
70
|
-
const cutoff = now - days * 864e5;
|
|
71
|
-
return items.filter((item) => {
|
|
72
|
-
const time = eventTime(item);
|
|
73
|
-
return time !== void 0 && time >= cutoff && time <= now + 3e5 && logicalEventKey(item);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
function person(value) {
|
|
77
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
78
|
-
const row = value;
|
|
79
|
-
const read = (field) => typeof row[field] === "string" && row[field].trim() ? row[field].trim().slice(0, 160) : void 0;
|
|
80
|
-
const result = {
|
|
81
|
-
name: read("name"),
|
|
82
|
-
email: read("email"),
|
|
83
|
-
username: read("username")
|
|
84
|
-
};
|
|
85
|
-
return result.name || result.email || result.username ? result : void 0;
|
|
86
|
-
}
|
|
87
|
-
function relationshipObservations(items) {
|
|
88
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
89
|
-
for (const item of recent(items, 90)) {
|
|
90
|
-
if (item.metadata.actorAttributed !== true) continue;
|
|
91
|
-
const owners = new Set(Array.isArray(item.metadata.ownerIdentities) ? item.metadata.ownerIdentities.filter((value) => typeof value === "string").map((value) => value.toLowerCase()) : []);
|
|
92
|
-
const values = item.metadata.personEntities;
|
|
93
|
-
if (!Array.isArray(values)) continue;
|
|
94
|
-
for (const value of values) {
|
|
95
|
-
const signal = person(value);
|
|
96
|
-
if (!signal) continue;
|
|
97
|
-
const strongIdentity = (signal.email ?? signal.username)?.toLowerCase();
|
|
98
|
-
if (strongIdentity && owners.has(strongIdentity)) continue;
|
|
99
|
-
const label = signal.name ?? signal.email ?? signal.username;
|
|
100
|
-
const identityKey = personIdentityKey(signal, item.sourceInstanceId);
|
|
101
|
-
const personId = personIdForIdentity(signal, item.sourceInstanceId);
|
|
102
|
-
if (!identityKey || !personId) continue;
|
|
103
|
-
const entry = grouped.get(identityKey) ?? {
|
|
104
|
-
label,
|
|
105
|
-
personId,
|
|
106
|
-
events: /* @__PURE__ */ new Map()
|
|
107
|
-
};
|
|
108
|
-
const eventKey = logicalEventKey(item);
|
|
109
|
-
if (!entry.events.has(eventKey)) entry.events.set(eventKey, item);
|
|
110
|
-
grouped.set(identityKey, entry);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return [...grouped.values()].sort((left, right) => right.events.size - left.events.size).slice(0, 8).map((entry) => ({
|
|
114
|
-
class: "relationship",
|
|
115
|
-
key: `person:${entry.personId}`,
|
|
116
|
-
value: {
|
|
117
|
-
label: entry.label,
|
|
118
|
-
personId: entry.personId
|
|
119
|
-
},
|
|
120
|
-
items: [...entry.events.values()],
|
|
121
|
-
windowDays: 90
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
function routineObservations(items) {
|
|
125
|
-
const slots = /* @__PURE__ */ new Map();
|
|
126
|
-
for (const item of recent(items, 120).filter((candidate) => candidate.itemType === "calendar_event")) {
|
|
127
|
-
const date = new Date(item.occurredAt);
|
|
128
|
-
const slot = `${date.getUTCDay()}:${date.getUTCHours()}`;
|
|
129
|
-
const events = slots.get(slot) ?? /* @__PURE__ */ new Map();
|
|
130
|
-
const eventKey = logicalEventKey(item);
|
|
131
|
-
if (!events.has(eventKey)) events.set(eventKey, item);
|
|
132
|
-
slots.set(slot, events);
|
|
133
|
-
}
|
|
134
|
-
return [...slots.entries()].sort((left, right) => right[1].size - left[1].size).slice(0, 4).map(([slot, events]) => {
|
|
135
|
-
const [weekday, hour] = slot.split(":").map(Number);
|
|
136
|
-
return {
|
|
137
|
-
class: "routine",
|
|
138
|
-
key: `calendar-slot:${slot}`,
|
|
139
|
-
value: {
|
|
140
|
-
weekday,
|
|
141
|
-
hour,
|
|
142
|
-
timezone: "UTC"
|
|
143
|
-
},
|
|
144
|
-
items: [...events.values()],
|
|
145
|
-
windowDays: 120
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
function projectObservations(items) {
|
|
150
|
-
const recentItems = recent(items, 60);
|
|
151
|
-
const byId = new Map(recentItems.map((item) => [item.id, item]));
|
|
152
|
-
return clusterUnderstandingSignals(recentItems.map(projectSignal).filter((signal) => Boolean(signal))).flatMap((cluster) => {
|
|
153
|
-
const events = /* @__PURE__ */ new Map();
|
|
154
|
-
for (const signal of cluster.signals) {
|
|
155
|
-
const item = byId.get(signal.evidenceRef);
|
|
156
|
-
const eventKey = item && logicalEventKey(item);
|
|
157
|
-
if (item && eventKey && !events.has(eventKey)) events.set(eventKey, item);
|
|
158
|
-
}
|
|
159
|
-
if (![...events.values()].some((item) => item.itemType !== "calendar_event")) return [];
|
|
160
|
-
return [{
|
|
161
|
-
class: "project",
|
|
162
|
-
key: `project:${cluster.key}`,
|
|
163
|
-
value: { label: cluster.title },
|
|
164
|
-
items: [...events.values()],
|
|
165
|
-
windowDays: 60
|
|
166
|
-
}];
|
|
167
|
-
}).sort((left, right) => right.items.length - left.items.length).slice(0, 8);
|
|
168
|
-
}
|
|
169
|
-
function deriveConnectedClaimObservations(items) {
|
|
170
|
-
const active = items.filter((item) => !item.deletedAt && item.synthesisPipeline === "connected_knowledge" && item.sensitivity !== "secret" && item.sensitivity !== "regulated" && item.metadata.observationKind !== "inventory");
|
|
171
|
-
return [
|
|
172
|
-
...relationshipObservations(active),
|
|
173
|
-
...routineObservations(active),
|
|
174
|
-
...projectObservations(active)
|
|
175
|
-
];
|
|
176
|
-
}
|
|
177
|
-
function confidenceFor(observation) {
|
|
178
|
-
const days = new Set(observation.items.map((item) => item.occurredAt?.slice(0, 10)).filter(Boolean)).size;
|
|
179
|
-
return Math.min(.92, .48 + Math.min(observation.items.length, 8) * .035 + Math.min(days, 5) * .045);
|
|
180
|
-
}
|
|
181
|
-
function isDurableObservation(observation) {
|
|
182
|
-
const days = new Set(observation.items.map((item) => item.occurredAt?.slice(0, 10)).filter(Boolean)).size;
|
|
183
|
-
return observation.items.length >= 3 && days >= (observation.class === "routine" ? 3 : 2);
|
|
184
|
-
}
|
|
185
|
-
function renderConnectedObservation(observation) {
|
|
186
|
-
const label = typeof observation.value.label === "string" ? observation.value.label : "";
|
|
187
|
-
const confidence = confidenceFor(observation);
|
|
188
|
-
if (observation.class === "relationship") return {
|
|
189
|
-
kind: "relationship",
|
|
190
|
-
content: `Frequently collaborates with ${label}.`,
|
|
191
|
-
canonicalKey: `connected:${observation.key}`,
|
|
192
|
-
payload: typeof observation.value.personId === "string" ? { personId: observation.value.personId } : void 0,
|
|
193
|
-
confidence,
|
|
194
|
-
importance: .65,
|
|
195
|
-
explicitness: "inferred",
|
|
196
|
-
durability: "recurring",
|
|
197
|
-
sensitivity: "personal",
|
|
198
|
-
disclosurePolicy: "ask_before_reference"
|
|
199
|
-
};
|
|
200
|
-
if (observation.class === "project") return {
|
|
201
|
-
kind: "project_context",
|
|
202
|
-
content: `Recently contributed repeatedly to ${label}.`,
|
|
203
|
-
canonicalKey: `connected:${observation.key}`,
|
|
204
|
-
confidence,
|
|
205
|
-
importance: .72,
|
|
206
|
-
explicitness: "inferred",
|
|
207
|
-
durability: "recurring",
|
|
208
|
-
sensitivity: "personal",
|
|
209
|
-
disclosurePolicy: "referenceable"
|
|
210
|
-
};
|
|
211
|
-
const weekday = Number(observation.value.weekday);
|
|
212
|
-
const hour = Number(observation.value.hour);
|
|
213
|
-
return {
|
|
214
|
-
kind: "routine",
|
|
215
|
-
content: `Often has calendar activity on ${[
|
|
216
|
-
"Sunday",
|
|
217
|
-
"Monday",
|
|
218
|
-
"Tuesday",
|
|
219
|
-
"Wednesday",
|
|
220
|
-
"Thursday",
|
|
221
|
-
"Friday",
|
|
222
|
-
"Saturday"
|
|
223
|
-
][weekday] ?? "Unknown"} around ${String(hour).padStart(2, "0")}:00 UTC.`,
|
|
224
|
-
canonicalKey: `connected:${observation.key}`,
|
|
225
|
-
confidence,
|
|
226
|
-
importance: .58,
|
|
227
|
-
explicitness: "inferred",
|
|
228
|
-
durability: "recurring",
|
|
229
|
-
sensitivity: "personal",
|
|
230
|
-
disclosurePolicy: "referenceable"
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
var ConnectedUnderstandingPipeline = class {
|
|
234
|
-
constructor(memoryManager) {
|
|
235
|
-
this.memoryManager = memoryManager;
|
|
236
|
-
}
|
|
237
|
-
async process(agentId, extractionRunId) {
|
|
238
|
-
rebuildUserPeopleIndex();
|
|
239
|
-
const observations = deriveConnectedClaimObservations(listKnowledgeSourceItems({
|
|
240
|
-
agentId,
|
|
241
|
-
includeDeleted: false,
|
|
242
|
-
limit: 500
|
|
243
|
-
}));
|
|
244
|
-
const totals = {
|
|
245
|
-
proposed: observations.length,
|
|
246
|
-
created: 0,
|
|
247
|
-
deduplicated: 0,
|
|
248
|
-
rejected: 0,
|
|
249
|
-
createdRecords: []
|
|
250
|
-
};
|
|
251
|
-
for (const observation of observations) {
|
|
252
|
-
if (!isDurableObservation(observation)) continue;
|
|
253
|
-
const sourceInstanceIds = [...new Set(observation.items.map((item) => item.sourceInstanceId))];
|
|
254
|
-
const result = await this.memoryManager.applyUnderstandingCandidates([renderConnectedObservation(observation)], {
|
|
255
|
-
sourceItemIds: observation.items.map((item) => item.id).slice(0, 20),
|
|
256
|
-
sourceText: JSON.stringify({
|
|
257
|
-
independentEvidenceCount: observation.items.length,
|
|
258
|
-
activeDays: new Set(observation.items.map((item) => item.occurredAt?.slice(0, 10))).size,
|
|
259
|
-
windowDays: observation.windowDays
|
|
260
|
-
}),
|
|
261
|
-
source: {
|
|
262
|
-
provider: "connected-sources",
|
|
263
|
-
...sourceInstanceIds.length === 1 ? { sourceInstanceId: sourceInstanceIds[0] } : {}
|
|
264
|
-
},
|
|
265
|
-
reviewSource: "background",
|
|
266
|
-
extractionRunId
|
|
267
|
-
});
|
|
268
|
-
totals.created += result.created;
|
|
269
|
-
totals.deduplicated += result.deduplicated;
|
|
270
|
-
totals.rejected += result.rejected;
|
|
271
|
-
totals.createdRecords.push(...result.createdRecords);
|
|
272
|
-
totals.writeOutputs = [...totals.writeOutputs ?? [], ...result.writeOutputs ?? []];
|
|
273
|
-
}
|
|
274
|
-
return totals;
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
//#endregion
|
|
278
|
-
export { ConnectedUnderstandingPipeline, deriveConnectedClaimObservations, renderConnectedObservation };
|