@origintrail-official/dkg-node-ui 10.0.22 → 10.0.24
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/README.md +4 -0
- package/dist/chat-graph-delta-subjects.d.ts +38 -0
- package/dist/chat-graph-delta-subjects.d.ts.map +1 -0
- package/dist/chat-graph-delta-subjects.js +57 -0
- package/dist/chat-graph-delta-subjects.js.map +1 -0
- package/dist/chat-history-rows.d.ts +59 -0
- package/dist/chat-history-rows.d.ts.map +1 -0
- package/dist/chat-history-rows.js +152 -0
- package/dist/chat-history-rows.js.map +1 -0
- package/dist/chat-literals.d.ts +34 -0
- package/dist/chat-literals.d.ts.map +1 -0
- package/dist/chat-literals.js +141 -0
- package/dist/chat-literals.js.map +1 -0
- package/dist/chat-memory.d.ts +1 -17
- package/dist/chat-memory.d.ts.map +1 -1
- package/dist/chat-memory.js +56 -226
- package/dist/chat-memory.js.map +1 -1
- package/dist/chat-vocabulary.d.ts +12 -0
- package/dist/chat-vocabulary.d.ts.map +1 -0
- package/dist/chat-vocabulary.js +13 -0
- package/dist/chat-vocabulary.js.map +1 -0
- package/dist-ui/assets/{3d-force-graph-DbVwxMKf.js → 3d-force-graph-DvzZZzFn.js} +1 -1
- package/dist-ui/assets/{ActivityFeed-Bfg6fmQQ.js → ActivityFeed-B5QxV1dk.js} +2 -2
- package/dist-ui/assets/{AgentHub-DyF5Pa70.js → AgentHub-BO9jGbJl.js} +1 -1
- package/dist-ui/assets/{AgentProfilePage-BPrSuKjV.js → AgentProfilePage-DJJTn1WD.js} +1 -1
- package/dist-ui/assets/{ApproveWalletsModal-Dd_tHLRP.js → ApproveWalletsModal-C2Tu29tB.js} +3 -3
- package/dist-ui/assets/{ContextGraphPrimitives-BXormriD.js → ContextGraphPrimitives-BqlTIZHy.js} +1 -1
- package/dist-ui/assets/{ConvictionDetailView-BsPTd17P.js → ConvictionDetailView-J-DAKHtP.js} +2 -2
- package/dist-ui/assets/MemoryLayerView-BOxI-_TF.js +2 -0
- package/dist-ui/assets/{MemoryStackView-BbUJ2uiM.js → MemoryStackView-BTyZZKNm.js} +1 -1
- package/dist-ui/assets/{Network-BKvJttOu.js → Network-DV9K48MH.js} +1 -1
- package/dist-ui/assets/{OnChainProvenanceCard-BV9-G1cT.js → OnChainProvenanceCard-jxk66g53.js} +1 -1
- package/dist-ui/assets/{Operations-LAhUQsnj.js → Operations-CNB1BMYg.js} +1 -1
- package/dist-ui/assets/{ProjectView-0zCSblAV.js → ProjectView-BP4vNSXI.js} +30 -30
- package/dist-ui/assets/{PublishingConviction-CF6352oT.js → PublishingConviction-DbP1i3v0.js} +2 -2
- package/dist-ui/assets/{Settings-runaZqPv.js → Settings-I6g3MQCV.js} +1 -1
- package/dist-ui/assets/{browserWalletTransaction-CBgx0i4w.js → browserWalletTransaction-CXv612Pn.js} +3 -3
- package/dist-ui/assets/{ccip-BM07w5uU.js → ccip-DY93ay8e.js} +1 -1
- package/dist-ui/assets/index-CIt7zWgM.css +1 -0
- package/dist-ui/assets/{index-CfVUpsfM.js → index-CumB6j2m.js} +3 -3
- package/dist-ui/assets/index-DW3dBcQk.js +1175 -0
- package/dist-ui/assets/{jsonld-32FQRO67-DBZOBQji.js → jsonld-32FQRO67-DKLfQ_nD.js} +2 -2
- package/dist-ui/assets/{jsonld-DOX7dKpf.js → jsonld-BgpgXlDQ.js} +1 -1
- package/dist-ui/assets/{renderer-3d-2EVDZII7-CVCpAmwB.js → renderer-3d-2EVDZII7-BCmzI8Ii.js} +2 -2
- package/dist-ui/assets/{shikiHighlighter-CzU2U2Tx.js → shikiHighlighter-BXl6qMQO.js} +4 -4
- package/dist-ui/assets/{useEntityOnChainReceipt-BvWQ6qdT.js → useEntityOnChainReceipt-CUGQNIsP.js} +1 -1
- package/dist-ui/assets/{useProjectActivity-Cxr4QGX1.js → useProjectActivity-BOgGdtS7.js} +1 -1
- package/dist-ui/index.html +2 -2
- package/package.json +4 -4
- package/dist-ui/assets/MemoryLayerView-CloJeM33.js +0 -2
- package/dist-ui/assets/index-MQh8C4aJ.js +0 -1175
- package/dist-ui/assets/index-xKO-U_eV.css +0 -1
package/README.md
CHANGED
|
@@ -49,3 +49,7 @@ pnpm build
|
|
|
49
49
|
- `@origintrail-official/dkg-core` - configuration types, event bus integration
|
|
50
50
|
- `@origintrail-official/dkg-node-store` - the daemon's protocol persistence stores (outbox, sync checkpoints, changelog cursors, KA numbers, chain log and cursors). They used to live here; this package re-exports them unchanged (from its entry point, from `dist/db.js`, and from the former `dist/chain-event-log-store.js`, `dist/chain-cursor-stores.js` and `dist/protocol-outbox-store.js` paths, which are deprecated forwarding modules: first-party code imports node-store directly) and `DashboardDB` still opens `node-ui.db` and owns the schema and every migration
|
|
51
51
|
- `@origintrail-official/dkg-graph-viz` - interactive RDF graph visualization component
|
|
52
|
+
|
|
53
|
+
### Unavailable node
|
|
54
|
+
|
|
55
|
+
If both initial status probes fail or time out, the dashboard shows a connection recovery screen and hides operational panels, including node health, balances, graphs and integration readiness. Fallback fixtures are never shown as live state. Check the daemon and use **Retry connection** to reload; detection remains latched for the current page. A `401` response still opens the existing API token prompt rather than declaring the node unavailable.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The most subjects one graph delta reads: the turn, its session and messages,
|
|
3
|
+
* and what hangs off them. Every relation query is bounded by it, and so is the
|
|
4
|
+
* set they form together, the turn's own subjects and its transitions first.
|
|
5
|
+
* Past it the subjects that survive are not chosen by any order.
|
|
6
|
+
*/
|
|
7
|
+
export declare const GRAPH_DELTA_MAX_SUBJECTS = 5000;
|
|
8
|
+
/** What a graph delta is anchored on: the session, the turn it reads and the turn's two messages. */
|
|
9
|
+
export interface GraphDeltaAnchors {
|
|
10
|
+
sessionUri: string;
|
|
11
|
+
turnUri: string;
|
|
12
|
+
userMsgUri: string;
|
|
13
|
+
assistantMsgUri: string;
|
|
14
|
+
}
|
|
15
|
+
type SelectQuery = (sparql: string) => Promise<{
|
|
16
|
+
bindings?: Array<Record<string, string>>;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* The subjects a turn's graph delta carries, in the order the delta lists them:
|
|
20
|
+
* the session, the turn and its two messages; then every transition that points
|
|
21
|
+
* at the turn (a turn that completed after it was first written keeps its
|
|
22
|
+
* messages and records the new state and the final reply on a transition node:
|
|
23
|
+
* `recordChatTurnPersistenceTransition`); then the tools the assistant used, the
|
|
24
|
+
* subjects that mention either message, and the memories extracted from the
|
|
25
|
+
* session that contain an entity a message mentions. Each subject appears once.
|
|
26
|
+
*
|
|
27
|
+
* The relations are read by independent queries, never one UNION. A read of the
|
|
28
|
+
* working-memory view can span more than one graph (a by-name read also includes
|
|
29
|
+
* the assertion's scoped child graphs, and an agent address can have several
|
|
30
|
+
* candidate layer graphs), and the query engine refuses a UNION combined with
|
|
31
|
+
* DISTINCT or LIMIT across graphs, so a single UNION query fails the whole read
|
|
32
|
+
* on such a node. A subject that is not a safe IRI is skipped. A relation that
|
|
33
|
+
* cannot be read fails the call: a delta that silently left the transitions out
|
|
34
|
+
* would show the first report of a turn that has since completed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function selectGraphDeltaSubjects(query: SelectQuery, { sessionUri, turnUri, userMsgUri, assistantMsgUri }: GraphDeltaAnchors): Promise<string[]>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=chat-graph-delta-subjects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-graph-delta-subjects.d.ts","sourceRoot":"","sources":["../src/chat-graph-delta-subjects.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,qGAAqG;AACrG,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC,CAAC;AAE7F;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,WAAW,EAClB,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,iBAAiB,GACtE,OAAO,CAAC,MAAM,EAAE,CAAC,CAyBnB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { isSafeIri } from '@origintrail-official/dkg-core';
|
|
3
|
+
import { CHAT_TURN_PERSISTENCE_TRANSITION_PREDICATE, CHAT_TURN_PERSISTENCE_TRANSITION_TYPE, DKG_ONT, RDF_TYPE, } from './chat-vocabulary.js';
|
|
4
|
+
/**
|
|
5
|
+
* The most subjects one graph delta reads: the turn, its session and messages,
|
|
6
|
+
* and what hangs off them. Every relation query is bounded by it, and so is the
|
|
7
|
+
* set they form together, the turn's own subjects and its transitions first.
|
|
8
|
+
* Past it the subjects that survive are not chosen by any order.
|
|
9
|
+
*/
|
|
10
|
+
export const GRAPH_DELTA_MAX_SUBJECTS = 5000;
|
|
11
|
+
/**
|
|
12
|
+
* The subjects a turn's graph delta carries, in the order the delta lists them:
|
|
13
|
+
* the session, the turn and its two messages; then every transition that points
|
|
14
|
+
* at the turn (a turn that completed after it was first written keeps its
|
|
15
|
+
* messages and records the new state and the final reply on a transition node:
|
|
16
|
+
* `recordChatTurnPersistenceTransition`); then the tools the assistant used, the
|
|
17
|
+
* subjects that mention either message, and the memories extracted from the
|
|
18
|
+
* session that contain an entity a message mentions. Each subject appears once.
|
|
19
|
+
*
|
|
20
|
+
* The relations are read by independent queries, never one UNION. A read of the
|
|
21
|
+
* working-memory view can span more than one graph (a by-name read also includes
|
|
22
|
+
* the assertion's scoped child graphs, and an agent address can have several
|
|
23
|
+
* candidate layer graphs), and the query engine refuses a UNION combined with
|
|
24
|
+
* DISTINCT or LIMIT across graphs, so a single UNION query fails the whole read
|
|
25
|
+
* on such a node. A subject that is not a safe IRI is skipped. A relation that
|
|
26
|
+
* cannot be read fails the call: a delta that silently left the transitions out
|
|
27
|
+
* would show the first report of a turn that has since completed.
|
|
28
|
+
*/
|
|
29
|
+
export async function selectGraphDeltaSubjects(query, { sessionUri, turnUri, userMsgUri, assistantMsgUri }) {
|
|
30
|
+
const related = async (pattern) => {
|
|
31
|
+
const result = await query(`SELECT DISTINCT ?s WHERE { ${pattern} } LIMIT ${GRAPH_DELTA_MAX_SUBJECTS}`);
|
|
32
|
+
return (result.bindings ?? []).map((binding) => String(binding.s ?? '').replace(/[<>]/g, ''));
|
|
33
|
+
};
|
|
34
|
+
const messages = `VALUES ?msg { <${userMsgUri}> <${assistantMsgUri}> }`;
|
|
35
|
+
const [transitions, tools, mentions, memories] = await Promise.all([
|
|
36
|
+
related(`
|
|
37
|
+
?s <${RDF_TYPE}> <${CHAT_TURN_PERSISTENCE_TRANSITION_TYPE}> .
|
|
38
|
+
?s <${CHAT_TURN_PERSISTENCE_TRANSITION_PREDICATE}> <${turnUri}> .`),
|
|
39
|
+
related(`<${assistantMsgUri}> <${DKG_ONT}usedTool> ?s .`),
|
|
40
|
+
related(`${messages} ?s <${DKG_ONT}mentionedIn> ?msg .`),
|
|
41
|
+
related(`
|
|
42
|
+
${messages}
|
|
43
|
+
?entity <${DKG_ONT}mentionedIn> ?msg .
|
|
44
|
+
?s <${DKG_ONT}contains> ?entity .
|
|
45
|
+
?s <${DKG_ONT}extractedFrom> <${sessionUri}> .`),
|
|
46
|
+
]);
|
|
47
|
+
const subjects = new Set([sessionUri, turnUri, userMsgUri, assistantMsgUri]);
|
|
48
|
+
for (const iri of [...transitions, ...tools, ...mentions, ...memories]) {
|
|
49
|
+
if (subjects.size >= GRAPH_DELTA_MAX_SUBJECTS)
|
|
50
|
+
break;
|
|
51
|
+
if (!iri || !isSafeIri(iri))
|
|
52
|
+
continue;
|
|
53
|
+
subjects.add(iri);
|
|
54
|
+
}
|
|
55
|
+
return [...subjects];
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=chat-graph-delta-subjects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-graph-delta-subjects.js","sourceRoot":"","sources":["../src/chat-graph-delta-subjects.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EACL,0CAA0C,EAC1C,qCAAqC,EACrC,OAAO,EACP,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAY7C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAAkB,EAClB,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAqB;IAEvE,MAAM,OAAO,GAAG,KAAK,EAAE,OAAe,EAAqB,EAAE;QAC3D,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,8BAA8B,OAAO,YAAY,wBAAwB,EAAE,CAAC,CAAC;QACxG,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAChG,CAAC,CAAC;IACF,MAAM,QAAQ,GAAG,kBAAkB,UAAU,MAAM,eAAe,KAAK,CAAC;IACxE,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACjE,OAAO,CAAC;cACE,QAAQ,MAAM,qCAAqC;cACnD,0CAA0C,MAAM,OAAO,KAAK,CAAC;QACvE,OAAO,CAAC,IAAI,eAAe,MAAM,OAAO,gBAAgB,CAAC;QACzD,OAAO,CAAC,GAAG,QAAQ,QAAQ,OAAO,qBAAqB,CAAC;QACxD,OAAO,CAAC;UACF,QAAQ;mBACC,OAAO;cACZ,OAAO;cACP,OAAO,mBAAmB,UAAU,KAAK,CAAC;KACrD,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAS,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;IACrF,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,WAAW,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;QACvE,IAAI,QAAQ,CAAC,IAAI,IAAI,wBAAwB;YAAE,MAAM;QACrD,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;YAAE,SAAS;QACtC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type ChatAttachmentRef, type ChatToolCall, type ChatTurnPersistenceDisplayState } from './chat-literals.js';
|
|
2
|
+
/** The most messages the session list returns for one session. */
|
|
3
|
+
export declare const SESSION_LIST_MESSAGE_LIMIT = 100;
|
|
4
|
+
type HistoryRow = Record<string, string>;
|
|
5
|
+
/** One message of a chat history, as the two history readers accumulate it. */
|
|
6
|
+
export interface ChatHistoryMessage {
|
|
7
|
+
uri: string;
|
|
8
|
+
author: string;
|
|
9
|
+
text: string;
|
|
10
|
+
ts: string;
|
|
11
|
+
turnId?: string;
|
|
12
|
+
persistStatus?: ChatTurnPersistenceDisplayState;
|
|
13
|
+
failureReason?: string | null;
|
|
14
|
+
attachmentRefs?: ChatAttachmentRef[];
|
|
15
|
+
toolCalls?: ChatToolCall[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The reply a turn's agent message shows once the turn completed, or `undefined`
|
|
19
|
+
* when this row does not complete it.
|
|
20
|
+
*
|
|
21
|
+
* A turn that first reported `pending` or `failed` and completed later is not
|
|
22
|
+
* written a second time: a `stored` transition records the completion and
|
|
23
|
+
* carries the final reply, and the assistant Message keeps the `schema:text`
|
|
24
|
+
* of the first report. Every reader that returns a turn's reply has to resolve
|
|
25
|
+
* it through here, so `getSession` and `getRecentChats` cannot disagree about
|
|
26
|
+
* which reply a turn ended with. `row` is one result row of a query that joins
|
|
27
|
+
* a turn to its transitions.
|
|
28
|
+
*
|
|
29
|
+
* The transition's `assistantReply` is written with `JSON.stringify`, exactly
|
|
30
|
+
* like the base `schema:text`, so it needs the same decode. Without it a
|
|
31
|
+
* stored turn (the dominant path on reload) would replace the correctly decoded
|
|
32
|
+
* base text with a literal-`\n` string and markdown would break after a refresh.
|
|
33
|
+
*/
|
|
34
|
+
export declare function completedTurnReply(row: {
|
|
35
|
+
transitionState?: string;
|
|
36
|
+
persistenceState?: string;
|
|
37
|
+
transitionAssistantReply?: string;
|
|
38
|
+
}): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The messages of ONE session from its rows, in the order each message first
|
|
41
|
+
* appears. A row that names no message URI is keyed by its author, timestamp and
|
|
42
|
+
* text, so identical anonymous rows collapse into one message.
|
|
43
|
+
*/
|
|
44
|
+
export declare function foldSessionRows(rows: readonly HistoryRow[]): ChatHistoryMessage[];
|
|
45
|
+
/**
|
|
46
|
+
* The listed messages of MANY sessions from one batched query's rows, by session
|
|
47
|
+
* URI, at most `SESSION_LIST_MESSAGE_LIMIT` per session. A message with several
|
|
48
|
+
* transitions comes back once per transition, in transition order within the rows
|
|
49
|
+
* of its message, so the latest completion wins.
|
|
50
|
+
*
|
|
51
|
+
* `null` marks a message that is not listed (its session is already at the cap,
|
|
52
|
+
* or its first row names no session): it is never built, and its later rows are
|
|
53
|
+
* skipped, so the cap counts messages, not rows. A row that names no message URI
|
|
54
|
+
* cannot be tied to a turn (the query joins a turn's transitions through the
|
|
55
|
+
* message), so each such row is its own message and never completes anything.
|
|
56
|
+
*/
|
|
57
|
+
export declare function foldListedRows(rows: readonly HistoryRow[]): Map<string, ChatHistoryMessage[]>;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=chat-history-rows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-history-rows.d.ts","sourceRoot":"","sources":["../src/chat-history-rows.ts"],"names":[],"mappings":"AAiBA,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,+BAA+B,EACrC,MAAM,oBAAoB,CAAC;AAE5B,kEAAkE;AAClE,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzC,+EAA+E;AAC/E,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,+BAA+B,CAAC;IAChD,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACrC,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,GAAG,MAAM,GAAG,SAAS,CAIrB;AA2DD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,kBAAkB,EAAE,CAajF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAoB7F"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Assembly of chat-history messages from the rows a history query returns, for
|
|
4
|
+
* the two readers of `ChatMemoryManager`: `getSession` (one session, every
|
|
5
|
+
* field) and `getRecentChats` (many sessions in one batch, `author`, `text` and
|
|
6
|
+
* `ts` only).
|
|
7
|
+
*
|
|
8
|
+
* Both queries return a message once per transition of its turn. Both readers
|
|
9
|
+
* therefore keep ONE accumulated message per message URI: the row that first
|
|
10
|
+
* names a message creates it (`historyMessageFromRow`), and every row of it,
|
|
11
|
+
* that first one included, folds its transition columns into that same object
|
|
12
|
+
* (`mergeTransitionRow`). A session holds references to those objects, so a
|
|
13
|
+
* later row's completion shows in the session's list without a second pass. The
|
|
14
|
+
* two readers share the creating and the folding helpers and differ only in how
|
|
15
|
+
* they index the messages (`foldSessionRows`, `foldListedRows`).
|
|
16
|
+
*/
|
|
17
|
+
import { decodeRdfStringLiteral } from './rdf-literal.js';
|
|
18
|
+
import { choosePersistenceStatus, normalizePersistenceStatus, parseAttachmentRefsLiteral, parseToolCallsLiteral, stripRdfLiteral, } from './chat-literals.js';
|
|
19
|
+
/** The most messages the session list returns for one session. */
|
|
20
|
+
export const SESSION_LIST_MESSAGE_LIMIT = 100;
|
|
21
|
+
/**
|
|
22
|
+
* The reply a turn's agent message shows once the turn completed, or `undefined`
|
|
23
|
+
* when this row does not complete it.
|
|
24
|
+
*
|
|
25
|
+
* A turn that first reported `pending` or `failed` and completed later is not
|
|
26
|
+
* written a second time: a `stored` transition records the completion and
|
|
27
|
+
* carries the final reply, and the assistant Message keeps the `schema:text`
|
|
28
|
+
* of the first report. Every reader that returns a turn's reply has to resolve
|
|
29
|
+
* it through here, so `getSession` and `getRecentChats` cannot disagree about
|
|
30
|
+
* which reply a turn ended with. `row` is one result row of a query that joins
|
|
31
|
+
* a turn to its transitions.
|
|
32
|
+
*
|
|
33
|
+
* The transition's `assistantReply` is written with `JSON.stringify`, exactly
|
|
34
|
+
* like the base `schema:text`, so it needs the same decode. Without it a
|
|
35
|
+
* stored turn (the dominant path on reload) would replace the correctly decoded
|
|
36
|
+
* base text with a literal-`\n` string and markdown would break after a refresh.
|
|
37
|
+
*/
|
|
38
|
+
export function completedTurnReply(row) {
|
|
39
|
+
const status = normalizePersistenceStatus(row.transitionState ?? row.persistenceState ?? '');
|
|
40
|
+
const reply = String(row.transitionAssistantReply ?? '');
|
|
41
|
+
return status === 'stored' && reply ? decodeRdfStringLiteral(reply) : undefined;
|
|
42
|
+
}
|
|
43
|
+
/** The URI a history row names its message by, or `''` when it names none. */
|
|
44
|
+
function historyRowUri(row) {
|
|
45
|
+
return String(row.m ?? '').replace(/[<>]/g, '');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A new message from the row that first names it: what the message itself says
|
|
49
|
+
* (author, text, timestamp, and the turn id and attachment refs when the row
|
|
50
|
+
* carries them). What the turn's transitions say about it comes from
|
|
51
|
+
* `mergeTransitionRow`, which the readers apply to every row of the message,
|
|
52
|
+
* this first one included.
|
|
53
|
+
*/
|
|
54
|
+
function historyMessageFromRow(row, uri) {
|
|
55
|
+
return {
|
|
56
|
+
uri,
|
|
57
|
+
author: row.author?.includes('user') ? 'user' : 'agent',
|
|
58
|
+
text: decodeRdfStringLiteral(row.text ?? ''),
|
|
59
|
+
ts: stripRdfLiteral(row.ts ?? ''),
|
|
60
|
+
turnId: stripRdfLiteral(row.turnId ?? '') || undefined,
|
|
61
|
+
attachmentRefs: parseAttachmentRefsLiteral(String(row.attachmentRefs ?? '')),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Fold what one row says about its turn into the message it belongs to: the
|
|
66
|
+
* reply a `stored` transition carries (`completedTurnReply`, the one decoding
|
|
67
|
+
* rule; the later row wins), the attachment refs and tool calls it records, and
|
|
68
|
+
* the persistence status (a transition's when the row names one, else the
|
|
69
|
+
* turn's own) and failure reason. A column a reader's query does not select
|
|
70
|
+
* reads as absent and changes nothing: `getSession` selects every column read
|
|
71
|
+
* here, the session list only `transitionState` and `transitionAssistantReply`,
|
|
72
|
+
* which is all its output needs.
|
|
73
|
+
*/
|
|
74
|
+
function mergeTransitionRow(message, row) {
|
|
75
|
+
const candidateStatus = normalizePersistenceStatus(row.transitionState ?? row.persistenceState ?? '');
|
|
76
|
+
const completedReply = completedTurnReply(row);
|
|
77
|
+
if (message.author === 'agent' && completedReply !== undefined) {
|
|
78
|
+
message.text = completedReply;
|
|
79
|
+
}
|
|
80
|
+
const transitionAttachmentRefs = parseAttachmentRefsLiteral(String(row.transitionAttachmentRefs ?? ''));
|
|
81
|
+
if (message.author === 'user' && candidateStatus === 'stored' && transitionAttachmentRefs?.length) {
|
|
82
|
+
message.attachmentRefs = transitionAttachmentRefs;
|
|
83
|
+
}
|
|
84
|
+
const transitionToolCalls = parseToolCallsLiteral(String(row.transitionToolCalls ?? ''));
|
|
85
|
+
if (message.author === 'agent' && candidateStatus === 'stored' && transitionToolCalls?.length) {
|
|
86
|
+
message.toolCalls = transitionToolCalls;
|
|
87
|
+
}
|
|
88
|
+
message.persistStatus = choosePersistenceStatus(message.persistStatus, candidateStatus);
|
|
89
|
+
const candidateReason = stripRdfLiteral(row.transitionFailureReason ?? row.failureReason ?? '').trim();
|
|
90
|
+
if (candidateStatus === 'failed' && candidateReason) {
|
|
91
|
+
message.failureReason = candidateReason;
|
|
92
|
+
}
|
|
93
|
+
if (message.persistStatus && message.persistStatus !== 'failed') {
|
|
94
|
+
message.failureReason = undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The messages of ONE session from its rows, in the order each message first
|
|
99
|
+
* appears. A row that names no message URI is keyed by its author, timestamp and
|
|
100
|
+
* text, so identical anonymous rows collapse into one message.
|
|
101
|
+
*/
|
|
102
|
+
export function foldSessionRows(rows) {
|
|
103
|
+
const messagesByUri = new Map();
|
|
104
|
+
for (const row of rows) {
|
|
105
|
+
const uri = historyRowUri(row);
|
|
106
|
+
const key = uri || `${String(row.author ?? '')}:${String(row.ts ?? '')}:${String(row.text ?? '')}`;
|
|
107
|
+
let message = messagesByUri.get(key);
|
|
108
|
+
if (!message) {
|
|
109
|
+
message = historyMessageFromRow(row, uri);
|
|
110
|
+
messagesByUri.set(key, message);
|
|
111
|
+
}
|
|
112
|
+
mergeTransitionRow(message, row);
|
|
113
|
+
}
|
|
114
|
+
return [...messagesByUri.values()];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The listed messages of MANY sessions from one batched query's rows, by session
|
|
118
|
+
* URI, at most `SESSION_LIST_MESSAGE_LIMIT` per session. A message with several
|
|
119
|
+
* transitions comes back once per transition, in transition order within the rows
|
|
120
|
+
* of its message, so the latest completion wins.
|
|
121
|
+
*
|
|
122
|
+
* `null` marks a message that is not listed (its session is already at the cap,
|
|
123
|
+
* or its first row names no session): it is never built, and its later rows are
|
|
124
|
+
* skipped, so the cap counts messages, not rows. A row that names no message URI
|
|
125
|
+
* cannot be tied to a turn (the query joins a turn's transitions through the
|
|
126
|
+
* message), so each such row is its own message and never completes anything.
|
|
127
|
+
*/
|
|
128
|
+
export function foldListedRows(rows) {
|
|
129
|
+
const messagesByUri = new Map();
|
|
130
|
+
const bySession = new Map();
|
|
131
|
+
for (const row of rows) {
|
|
132
|
+
const uri = historyRowUri(row);
|
|
133
|
+
let message = uri ? messagesByUri.get(uri) : undefined;
|
|
134
|
+
if (message === undefined) {
|
|
135
|
+
const sessionUri = String(row.session ?? '').replace(/[<>]/g, '');
|
|
136
|
+
let listed = sessionUri ? bySession.get(sessionUri) : undefined;
|
|
137
|
+
if (sessionUri && !listed)
|
|
138
|
+
bySession.set(sessionUri, (listed = []));
|
|
139
|
+
message = null;
|
|
140
|
+
if (listed && listed.length < SESSION_LIST_MESSAGE_LIMIT) {
|
|
141
|
+
message = historyMessageFromRow(row, uri);
|
|
142
|
+
listed.push(message);
|
|
143
|
+
}
|
|
144
|
+
if (uri)
|
|
145
|
+
messagesByUri.set(uri, message);
|
|
146
|
+
}
|
|
147
|
+
if (message && uri)
|
|
148
|
+
mergeTransitionRow(message, row);
|
|
149
|
+
}
|
|
150
|
+
return bySession;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=chat-history-rows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-history-rows.js","sourceRoot":"","sources":["../src/chat-history-rows.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,eAAe,GAIhB,MAAM,oBAAoB,CAAC;AAE5B,kEAAkE;AAClE,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAiB9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAIlC;IACC,MAAM,MAAM,GAAG,0BAA0B,CAAC,GAAG,CAAC,eAAe,IAAI,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC;IAC7F,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;IACzD,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAClF,CAAC;AAED,8EAA8E;AAC9E,SAAS,aAAa,CA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AAC,GAAG,EAAE,GAAG,CAAC,CAAC;gBAC1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YACD,IAAI,GAAG;gBAAE,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,OAAO,IAAI,GAAG;YAAE,kBAAkB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value parsing for chat-history rows: RDF literals, the persistence status a
|
|
3
|
+
* turn or transition reports, and the JSON literals that carry a message's
|
|
4
|
+
* attachment refs and tool calls. Pure functions over the strings a SPARQL row
|
|
5
|
+
* holds, shared by `ChatMemoryManager` (which also validates the same shapes
|
|
6
|
+
* before writing them) and the history-row assembly in `chat-history-rows.ts`.
|
|
7
|
+
*/
|
|
8
|
+
/** What a history reader shows for a turn: the persistence status of its latest report. */
|
|
9
|
+
export type ChatTurnPersistenceDisplayState = 'pending' | 'in_progress' | 'stored' | 'failed' | 'skipped';
|
|
10
|
+
export interface ChatAttachmentRef {
|
|
11
|
+
id?: string;
|
|
12
|
+
fileName: string;
|
|
13
|
+
contextGraphId: string;
|
|
14
|
+
assertionName?: string;
|
|
15
|
+
assertionUri: string;
|
|
16
|
+
fileHash: string;
|
|
17
|
+
detectedContentType?: string;
|
|
18
|
+
extractionStatus?: 'completed' | 'skipped' | 'failed';
|
|
19
|
+
tripleCount?: number;
|
|
20
|
+
rootEntity?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ChatToolCall {
|
|
23
|
+
name: string;
|
|
24
|
+
args: Record<string, unknown>;
|
|
25
|
+
result: unknown;
|
|
26
|
+
}
|
|
27
|
+
export declare function stripRdfLiteral(value: string): string;
|
|
28
|
+
export declare function normalizePersistenceStatus(value: string): ChatTurnPersistenceDisplayState | undefined;
|
|
29
|
+
export declare function choosePersistenceStatus(current: ChatTurnPersistenceDisplayState | undefined, candidate: ChatTurnPersistenceDisplayState | undefined): ChatTurnPersistenceDisplayState | undefined;
|
|
30
|
+
export declare function normalizeChatAttachmentRefs(raw: unknown): ChatAttachmentRef[] | undefined;
|
|
31
|
+
export declare function normalizeChatToolCalls(raw: unknown): ChatToolCall[] | undefined;
|
|
32
|
+
export declare function parseAttachmentRefsLiteral(value: string): ChatAttachmentRef[] | undefined;
|
|
33
|
+
export declare function parseToolCallsLiteral(value: string): ChatToolCall[] | undefined;
|
|
34
|
+
//# sourceMappingURL=chat-literals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-literals.d.ts","sourceRoot":"","sources":["../src/chat-literals.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,2FAA2F;AAC3F,MAAM,MAAM,+BAA+B,GAAG,SAAS,GAAG,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAU1G,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,+BAA+B,GAAG,SAAS,CAMrG;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,+BAA+B,GAAG,SAAS,EACpD,SAAS,EAAE,+BAA+B,GAAG,SAAS,GACrD,+BAA+B,GAAG,SAAS,CAI7C;AAgCD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAMzF;AAeD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,EAAE,GAAG,SAAS,CAM/E;AAiBD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAWzF;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,GAAG,SAAS,CAW/E"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Value parsing for chat-history rows: RDF literals, the persistence status a
|
|
4
|
+
* turn or transition reports, and the JSON literals that carry a message's
|
|
5
|
+
* attachment refs and tool calls. Pure functions over the strings a SPARQL row
|
|
6
|
+
* holds, shared by `ChatMemoryManager` (which also validates the same shapes
|
|
7
|
+
* before writing them) and the history-row assembly in `chat-history-rows.ts`.
|
|
8
|
+
*/
|
|
9
|
+
const PERSISTENCE_STATUS_RANK = {
|
|
10
|
+
skipped: 1,
|
|
11
|
+
pending: 2,
|
|
12
|
+
in_progress: 3,
|
|
13
|
+
failed: 4,
|
|
14
|
+
stored: 5,
|
|
15
|
+
};
|
|
16
|
+
export function stripRdfLiteral(value) {
|
|
17
|
+
if (!value)
|
|
18
|
+
return '';
|
|
19
|
+
const typed = value.match(/^"([\s\S]*)"(?:\^\^<[^>]+>)?(?:@[a-z-]+)?$/);
|
|
20
|
+
if (typed)
|
|
21
|
+
return typed[1];
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
export function normalizePersistenceStatus(value) {
|
|
25
|
+
const status = stripRdfLiteral(value).trim();
|
|
26
|
+
if (status === 'pending' || status === 'in_progress' || status === 'stored' || status === 'failed' || status === 'skipped') {
|
|
27
|
+
return status;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
export function choosePersistenceStatus(current, candidate) {
|
|
32
|
+
if (!candidate)
|
|
33
|
+
return current;
|
|
34
|
+
if (!current)
|
|
35
|
+
return candidate;
|
|
36
|
+
return PERSISTENCE_STATUS_RANK[candidate] > PERSISTENCE_STATUS_RANK[current] ? candidate : current;
|
|
37
|
+
}
|
|
38
|
+
function normalizeChatAttachmentRef(raw) {
|
|
39
|
+
if (!raw || typeof raw !== 'object')
|
|
40
|
+
return null;
|
|
41
|
+
const record = raw;
|
|
42
|
+
const fileName = typeof record.fileName === 'string' ? record.fileName.trim() : '';
|
|
43
|
+
const contextGraphId = typeof record.contextGraphId === 'string' ? record.contextGraphId.trim() : '';
|
|
44
|
+
const assertionUri = typeof record.assertionUri === 'string' ? record.assertionUri.trim() : '';
|
|
45
|
+
const fileHash = typeof record.fileHash === 'string' ? record.fileHash.trim() : '';
|
|
46
|
+
if (!fileName || !contextGraphId || !assertionUri || !fileHash)
|
|
47
|
+
return null;
|
|
48
|
+
const normalized = {
|
|
49
|
+
fileName,
|
|
50
|
+
contextGraphId,
|
|
51
|
+
assertionUri,
|
|
52
|
+
fileHash,
|
|
53
|
+
};
|
|
54
|
+
if (typeof record.id === 'string' && record.id.trim())
|
|
55
|
+
normalized.id = record.id.trim();
|
|
56
|
+
if (typeof record.assertionName === 'string' && record.assertionName.trim())
|
|
57
|
+
normalized.assertionName = record.assertionName.trim();
|
|
58
|
+
if (typeof record.detectedContentType === 'string' && record.detectedContentType.trim()) {
|
|
59
|
+
normalized.detectedContentType = record.detectedContentType.trim();
|
|
60
|
+
}
|
|
61
|
+
if (record.extractionStatus === 'completed' || record.extractionStatus === 'skipped' || record.extractionStatus === 'failed') {
|
|
62
|
+
normalized.extractionStatus = record.extractionStatus;
|
|
63
|
+
}
|
|
64
|
+
if (typeof record.tripleCount === 'number' && Number.isFinite(record.tripleCount) && record.tripleCount >= 0) {
|
|
65
|
+
normalized.tripleCount = record.tripleCount;
|
|
66
|
+
}
|
|
67
|
+
if (typeof record.rootEntity === 'string' && record.rootEntity.trim())
|
|
68
|
+
normalized.rootEntity = record.rootEntity.trim();
|
|
69
|
+
return normalized;
|
|
70
|
+
}
|
|
71
|
+
export function normalizeChatAttachmentRefs(raw) {
|
|
72
|
+
if (!Array.isArray(raw))
|
|
73
|
+
return undefined;
|
|
74
|
+
const refs = raw
|
|
75
|
+
.map((entry) => normalizeChatAttachmentRef(entry))
|
|
76
|
+
.filter((entry) => entry != null);
|
|
77
|
+
return refs.length > 0 ? refs : undefined;
|
|
78
|
+
}
|
|
79
|
+
function normalizeChatToolCall(raw) {
|
|
80
|
+
if (!raw || typeof raw !== 'object')
|
|
81
|
+
return null;
|
|
82
|
+
const record = raw;
|
|
83
|
+
const name = typeof record.name === 'string' && record.name.trim() ? record.name.trim() : 'unknown';
|
|
84
|
+
return {
|
|
85
|
+
name,
|
|
86
|
+
args: record.args && typeof record.args === 'object' && !Array.isArray(record.args)
|
|
87
|
+
? record.args
|
|
88
|
+
: {},
|
|
89
|
+
result: record.result,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export function normalizeChatToolCalls(raw) {
|
|
93
|
+
if (!Array.isArray(raw))
|
|
94
|
+
return undefined;
|
|
95
|
+
const calls = raw
|
|
96
|
+
.map((entry) => normalizeChatToolCall(entry))
|
|
97
|
+
.filter((entry) => entry != null);
|
|
98
|
+
return calls.length > 0 ? calls : undefined;
|
|
99
|
+
}
|
|
100
|
+
function parseNestedJsonLiteral(value) {
|
|
101
|
+
let current = value;
|
|
102
|
+
for (let depth = 0; depth < 4; depth += 1) {
|
|
103
|
+
if (typeof current !== 'string')
|
|
104
|
+
return current;
|
|
105
|
+
const trimmed = current.trim();
|
|
106
|
+
if (!trimmed)
|
|
107
|
+
return undefined;
|
|
108
|
+
try {
|
|
109
|
+
current = JSON.parse(trimmed);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return current;
|
|
116
|
+
}
|
|
117
|
+
export function parseAttachmentRefsLiteral(value) {
|
|
118
|
+
const candidates = [value, stripRdfLiteral(value)]
|
|
119
|
+
.map((candidate) => candidate.trim())
|
|
120
|
+
.filter((candidate, index, all) => candidate.length > 0 && all.indexOf(candidate) === index);
|
|
121
|
+
for (const candidate of candidates) {
|
|
122
|
+
const parsed = parseNestedJsonLiteral(candidate) ?? parseNestedJsonLiteral(JSON.stringify(candidate));
|
|
123
|
+
const normalized = normalizeChatAttachmentRefs(parsed);
|
|
124
|
+
if (normalized?.length)
|
|
125
|
+
return normalized;
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
export function parseToolCallsLiteral(value) {
|
|
130
|
+
const candidates = [value, stripRdfLiteral(value)]
|
|
131
|
+
.map((candidate) => candidate.trim())
|
|
132
|
+
.filter((candidate, index, all) => candidate.length > 0 && all.indexOf(candidate) === index);
|
|
133
|
+
for (const candidate of candidates) {
|
|
134
|
+
const parsed = parseNestedJsonLiteral(candidate) ?? parseNestedJsonLiteral(JSON.stringify(candidate));
|
|
135
|
+
const normalized = normalizeChatToolCalls(parsed);
|
|
136
|
+
if (normalized?.length)
|
|
137
|
+
return normalized;
|
|
138
|
+
}
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=chat-literals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-literals.js","sourceRoot":"","sources":["../src/chat-literals.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;GAMG;AAKH,MAAM,uBAAuB,GAAoD;IAC/E,OAA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C,SAAS,CAAC,IAAI,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;QACtG,MAAM,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,UAAU,EAAE,MAAM;YAAE,OAAO,UAAU,CAAC;IAC5C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/chat-memory.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LlmConfig } from './llm/types.js';
|
|
2
|
+
import { type ChatAttachmentRef, type ChatToolCall } from './chat-literals.js';
|
|
2
3
|
export { decodeRdfStringLiteral } from './rdf-literal.js';
|
|
3
4
|
export interface MemoryToolContext {
|
|
4
5
|
query: (sparql: string, opts?: {
|
|
@@ -154,23 +155,6 @@ export interface ImportResult {
|
|
|
154
155
|
*/
|
|
155
156
|
export declare const AGENT_CONTEXT_GRAPH = "agent-context";
|
|
156
157
|
export declare const CHAT_TURNS_ASSERTION = "chat-turns";
|
|
157
|
-
interface ChatAttachmentRef {
|
|
158
|
-
id?: string;
|
|
159
|
-
fileName: string;
|
|
160
|
-
contextGraphId: string;
|
|
161
|
-
assertionName?: string;
|
|
162
|
-
assertionUri: string;
|
|
163
|
-
fileHash: string;
|
|
164
|
-
detectedContentType?: string;
|
|
165
|
-
extractionStatus?: 'completed' | 'skipped' | 'failed';
|
|
166
|
-
tripleCount?: number;
|
|
167
|
-
rootEntity?: string;
|
|
168
|
-
}
|
|
169
|
-
interface ChatToolCall {
|
|
170
|
-
name: string;
|
|
171
|
-
args: Record<string, unknown>;
|
|
172
|
-
result: unknown;
|
|
173
|
-
}
|
|
174
158
|
export declare class ChatMemoryManager {
|
|
175
159
|
private tools;
|
|
176
160
|
private llmConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-memory.d.ts","sourceRoot":"","sources":["../src/chat-memory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,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