@volter/supercode-interchange 0.1.14 → 0.1.16
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/discovery.mjs +6 -2
- package/index.d.ts +2 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
- package/session-codex-display.mjs +8 -4
package/discovery.mjs
CHANGED
|
@@ -3,7 +3,9 @@ import { readLatestCandidates, readFileTopics } from './previews.mjs';
|
|
|
3
3
|
import { nativeTrim } from './text.mjs';
|
|
4
4
|
|
|
5
5
|
/** Preview refusal preserves the native metadata row. The owner can retain
|
|
6
|
-
* the exact failed source in diagnostics; it never invents message content.
|
|
6
|
+
* the exact failed source in diagnostics; it never invents message content.
|
|
7
|
+
* A query that shows no message (`include_latest_candidates: false`, with no
|
|
8
|
+
* topics asked) opens no file: its row is the index's own. */
|
|
7
9
|
export async function enrichDescriptor(query, descriptor, { codexTopics, metrics, previewFailure } = {}) {
|
|
8
10
|
const row = { ...descriptor };
|
|
9
11
|
const take = async (read) => {
|
|
@@ -17,7 +19,7 @@ export async function enrichDescriptor(query, descriptor, { codexTopics, metrics
|
|
|
17
19
|
if (topics.length) row.preview_candidates = topics;
|
|
18
20
|
else delete row.preview_candidates;
|
|
19
21
|
}
|
|
20
|
-
const latest = await take(() => readLatestCandidates(row.locator, metrics));
|
|
22
|
+
const latest = query.include_latest_candidates === false ? [] : await take(() => readLatestCandidates(row.locator, metrics));
|
|
21
23
|
if (latest.length) row.latest_message_candidates = latest;
|
|
22
24
|
else delete row.latest_message_candidates;
|
|
23
25
|
return row;
|
|
@@ -25,6 +27,8 @@ export async function enrichDescriptor(query, descriptor, { codexTopics, metrics
|
|
|
25
27
|
|
|
26
28
|
/** Bounded enrichment belongs to returned/current-window rows. Metadata
|
|
27
29
|
* maintenance never invokes this function, including unchanged warm queries. */
|
|
30
|
+
export const readsPreviews = (query) => query.include_latest_candidates !== false || Boolean(query.include_topic_candidates);
|
|
31
|
+
|
|
28
32
|
export async function enrichIndexPage(query, rows, options) {
|
|
29
33
|
const result = [];
|
|
30
34
|
for (const row of rows) result.push(await enrichDescriptor(query, row, options));
|
package/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface DiscoveryQuery {
|
|
|
29
29
|
workspace?: string | null; workspace_subtree?: boolean; workspace_family?: string | null;
|
|
30
30
|
updated_after_ms?: number | null; updated_before_ms?: number | null;
|
|
31
31
|
query?: string | null; search_previews?: boolean; cursor?: string | null; limit?: number | null;
|
|
32
|
-
include_topic_candidates?: boolean; include_child_sessions?: boolean;
|
|
32
|
+
include_topic_candidates?: boolean; include_latest_candidates?: boolean; include_child_sessions?: boolean;
|
|
33
33
|
root_session_id?: string | null; profile?: string | null;
|
|
34
34
|
}
|
|
35
35
|
export interface DiscoveryReceipt {
|
|
@@ -110,6 +110,7 @@ export interface DiscoveryEnrichmentOptions extends MetadataProjectionOptions {
|
|
|
110
110
|
lateClaudeName?: (name: string) => Promise<string | null>;
|
|
111
111
|
}
|
|
112
112
|
export function enrichDescriptor(query: DiscoveryQuery, descriptor: SessionDescriptor, options?: DiscoveryEnrichmentOptions): Promise<SessionDescriptor>;
|
|
113
|
+
export function readsPreviews(query: DiscoveryQuery): boolean;
|
|
113
114
|
export function enrichIndexPage(query: DiscoveryQuery, descriptors: SessionDescriptor[], options?: DiscoveryEnrichmentOptions): Promise<SessionDescriptor[]>;
|
|
114
115
|
export function discoverFromIndex(query: DiscoveryQuery, descriptors: Iterable<SessionDescriptor>, options?: DiscoveryEnrichmentOptions): Promise<DiscoveryPage>;
|
|
115
116
|
export function nativeTrim(value: string): string;
|
package/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ export { readForeignStore } from './foreign-store.mjs';
|
|
|
14
14
|
export { readHermesStore } from './hermes-store.mjs';
|
|
15
15
|
export { readOrchestratorStore } from './orchestrator-store.mjs';
|
|
16
16
|
export { codexNamesPath, readCodexNames, readCodexHistory, readClaudeTitles } from './native-ledgers.mjs';
|
|
17
|
-
export { enrichDescriptor, enrichIndexPage, discoverFromIndex } from './discovery.mjs';
|
|
17
|
+
export { enrichDescriptor, enrichIndexPage, readsPreviews, discoverFromIndex } from './discovery.mjs';
|
|
18
18
|
export { nativeInteger } from './native-json.mjs';
|
|
19
19
|
export { nativeTrim } from './text.mjs';
|
|
20
20
|
export { RetainedMetadataProjection, filedUnderOwnKey } from './retained-projection.mjs';
|
package/package.json
CHANGED
|
@@ -15,6 +15,9 @@ export function fromCodexDisplayStr(text, messageLimit) {
|
|
|
15
15
|
if (!Number.isSafeInteger(messageLimit) || messageLimit < 0) throw new RangeError('invalid Codex display message limit');
|
|
16
16
|
const session = createSession('codex'), { meta, messages } = session, precedingUsers = [], canonicalTexts = new Set();
|
|
17
17
|
const retain = Math.min(Number.MAX_SAFE_INTEGER, Math.max(messageLimit, 1) + 64);
|
|
18
|
+
// The item ids and event texts the kept messages may hold: a record that names neither replaces nothing and looks
|
|
19
|
+
// through no message, so a read with no bound on its messages (a display anchor's) is linear in what it reads.
|
|
20
|
+
const displayItems = new Set(), eventTexts = new Set();
|
|
18
21
|
let paginated = false, recordCount = 0, total = 0;
|
|
19
22
|
for (const line of nonEmptyLines(text)) {
|
|
20
23
|
recordCount++;
|
|
@@ -24,12 +27,13 @@ export function fromCodexDisplayStr(text, messageLimit) {
|
|
|
24
27
|
else if (kind === 'event_msg' && paginated && type === 'item_completed') {
|
|
25
28
|
const item = field(payload, 'item'), id = stringField(item, 'id');
|
|
26
29
|
if (id != null) {
|
|
27
|
-
const position = messages.findIndex((message) => message.metadata.codex_display_item === id), projected = [];
|
|
30
|
+
const held = displayItems.has(id), position = held ? messages.findIndex((message) => message.metadata.codex_display_item === id) : -1, projected = [];
|
|
28
31
|
pushCodexDisplayItem(item, projected);
|
|
29
32
|
for (const message of projected) message.metadata.codex_display_item = id;
|
|
33
|
+
if (projected.length) displayItems.add(id);
|
|
30
34
|
stampCodexMessages(projected, 0, timestamp);
|
|
31
35
|
let removed = 0;
|
|
32
|
-
for (let index = messages.length - 1; index >= 0; index--) if (messages[index].metadata.codex_display_item === id) { messages.splice(index, 1); removed++; }
|
|
36
|
+
if (held) for (let index = messages.length - 1; index >= 0; index--) if (messages[index].metadata.codex_display_item === id) { messages.splice(index, 1); removed++; }
|
|
33
37
|
total = Math.max(0, total - removed) + projected.length;
|
|
34
38
|
const at = Math.min(position === -1 ? messages.length : position, messages.length);
|
|
35
39
|
for (let index = 0; index < projected.length; index++) messages.splice(at + index, 0, projected[index]);
|
|
@@ -47,7 +51,7 @@ export function fromCodexDisplayStr(text, messageLimit) {
|
|
|
47
51
|
const isAssistant = type === 'message' && stringField(payload, 'role') === 'assistant';
|
|
48
52
|
const assistantText = isAssistant ? extractTextContent(payload, 'content') : null;
|
|
49
53
|
if (assistantText != null && nativeTrim(assistantText) !== '') {
|
|
50
|
-
const duplicate = messages.findLastIndex((message) => Object.hasOwn(message.metadata, 'codex_event_message') && message.content === assistantText);
|
|
54
|
+
const duplicate = eventTexts.has(assistantText) ? messages.findLastIndex((message) => Object.hasOwn(message.metadata, 'codex_event_message') && message.content === assistantText) : -1;
|
|
51
55
|
if (duplicate !== -1) { messages.splice(duplicate, 1); total = Math.max(0, total - 1); }
|
|
52
56
|
canonicalTexts.add(nativeTrim(assistantText));
|
|
53
57
|
}
|
|
@@ -62,7 +66,7 @@ export function fromCodexDisplayStr(text, messageLimit) {
|
|
|
62
66
|
const text = extractTextContent(payload, 'message');
|
|
63
67
|
if (nativeTrim(text) !== '' && !canonicalTexts.has(nativeTrim(text))) {
|
|
64
68
|
const before = messages.length; pushCodexAssistant(messages, text); total++;
|
|
65
|
-
messages.at(-1).metadata.codex_event_message = 'true';
|
|
69
|
+
messages.at(-1).metadata.codex_event_message = 'true'; eventTexts.add(messages.at(-1).content);
|
|
66
70
|
const phase = stringField(payload, 'phase'); if (phase != null) messages.at(-1).metadata.phase = phase;
|
|
67
71
|
stampCodexMessages(messages, before, timestamp);
|
|
68
72
|
}
|