@illuma-ai/agents 1.1.4 → 1.1.5

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.
@@ -0,0 +1,49 @@
1
+ // src/utils/fileManifest.ts
2
+ //
3
+ // Utility for building a lightweight [Conversation Files] context block
4
+ // from a file manifest. Injected into the compaction windowed view so the
5
+ // LLM retains awareness of ALL conversation files, even when old messages
6
+ // (with full file content) are behind the summary.
7
+
8
+ import type { FileManifestEntry } from '@/types/graph';
9
+
10
+ /**
11
+ * Prefix marker for the file manifest block.
12
+ * Used to detect and deduplicate manifest messages across turns.
13
+ */
14
+ export const FILE_MANIFEST_PREFIX = '[Conversation Files]';
15
+
16
+ /**
17
+ * Builds a compact text block listing all files in the conversation.
18
+ * Each entry costs ~10-15 tokens, so 10 files ≈ 100-150 tokens total.
19
+ *
20
+ * The block includes retrieval hints so the LLM knows how to fetch
21
+ * full content on demand (via file_search or content_tool).
22
+ *
23
+ * @param manifest - Array of file metadata entries
24
+ * @returns Formatted text block, or empty string if manifest is empty/undefined
25
+ */
26
+ export function buildFileManifestBlock(manifest: FileManifestEntry[] | undefined): string {
27
+ if (!manifest || manifest.length === 0) {
28
+ return '';
29
+ }
30
+
31
+ const lines = manifest.map((entry) => {
32
+ const parts: string[] = [`- ${entry.filename}`];
33
+ if (entry.contentId) {
34
+ parts.push(`(content_id: ${entry.contentId})`);
35
+ }
36
+ if (entry.source) {
37
+ parts.push(`[${entry.source}]`);
38
+ }
39
+ return parts.join(' ');
40
+ });
41
+
42
+ return [
43
+ FILE_MANIFEST_PREFIX,
44
+ 'The following files have been shared in this conversation.',
45
+ 'Use file_search or content_tool read (with content_id) to retrieve full content when needed.',
46
+ '',
47
+ ...lines,
48
+ ].join('\n');
49
+ }
@@ -11,3 +11,4 @@ export * from './toolCallContinuation';
11
11
  export * from './contextPressure';
12
12
  export * from './toolDiscoveryCache';
13
13
  export * from './pruneCalibration';
14
+ export * from './fileManifest';