@indexnetwork/protocol 8.10.0-rc.433.1 → 9.0.0-rc.435.1

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.
@@ -209,10 +209,8 @@ function buildCoreBody(ctx) {
209
209
  })), null, 2);
210
210
  const scopedIndexContext = ctx.scopedIndex
211
211
  ? renderNetworkContext({
212
- type: ctx.scopedIndex.type ?? 'community',
213
212
  title: ctx.scopedIndex.title,
214
213
  prompt: ctx.scopedIndex.prompt,
215
- metadata: ctx.scopedIndex.metadata ?? {},
216
214
  }) + `\n- **Your Role:** ${ctx.scopedMembershipRole ?? 'member'}`
217
215
  : null;
218
216
  return `
@@ -166,10 +166,8 @@ export class IntentNetworkGraphFactory {
166
166
  const network = await this.database.getNetwork(networkId);
167
167
  const renderedContext = network
168
168
  ? renderNetworkContext({
169
- type: network.type ?? 'community',
170
169
  title: network.title,
171
170
  prompt: network.prompt,
172
- metadata: network.metadata ?? {},
173
171
  })
174
172
  : null;
175
173
  const sourceName = intentForIndexing.sourceType
@@ -60,10 +60,8 @@ export function createNetworkTools(defineTool, deps) {
60
60
  const enrichWithContext = (networks) => networks.map((n) => ({
61
61
  ...n,
62
62
  renderedContext: renderNetworkContext({
63
- type: n.type ?? 'community',
64
63
  title: n.title ?? '',
65
64
  prompt: n.prompt,
66
- metadata: n.metadata ?? {},
67
65
  }),
68
66
  }));
69
67
  const readIndexes = defineTool({
@@ -183,10 +183,8 @@ async function buildNetworkContexts(entities, database) {
183
183
  if (injection?.discovery === false)
184
184
  continue;
185
185
  contexts[nid] = renderNetworkContext({
186
- type: network.type ?? 'community',
187
186
  title: network.title,
188
187
  prompt: network.prompt,
189
- metadata: network.metadata ?? {},
190
188
  });
191
189
  }
192
190
  return contexts;
@@ -76,8 +76,6 @@ export interface ResolvedToolContext {
76
76
  id: string;
77
77
  title: string;
78
78
  prompt: string | null;
79
- type?: string;
80
- metadata?: Record<string, unknown>;
81
79
  permissions?: Record<string, unknown>;
82
80
  };
83
81
  scopedMembershipRole?: "owner" | "member";
@@ -61,8 +61,6 @@ export async function resolveChatContext(params) {
61
61
  id: index.id,
62
62
  title: index.title,
63
63
  prompt: membership?.indexPrompt ?? null,
64
- type: index.type ?? 'community',
65
- metadata: index.metadata ?? {},
66
64
  permissions: index.permissions ?? {},
67
65
  };
68
66
  isOwner = owner;
@@ -1,14 +1,9 @@
1
1
  interface NetworkForRendering {
2
- type: string;
3
2
  title: string;
4
3
  prompt?: string | null;
5
- metadata: Record<string, unknown>;
6
4
  }
7
5
  /**
8
- * Render a network's metadata as structured markdown for LLM context.
9
- *
10
- * @param network - The network to render, with type, title, optional prompt, and metadata.
11
- * @returns Markdown string suitable for injection into an LLM prompt.
6
+ * Render a network as structured markdown for LLM context.
12
7
  */
13
8
  export declare function renderNetworkContext(network: NetworkForRendering): string;
14
9
  export {};
@@ -1,103 +1,10 @@
1
1
  /**
2
- * Render a network's metadata as structured markdown for LLM context.
3
- *
4
- * @param network - The network to render, with type, title, optional prompt, and metadata.
5
- * @returns Markdown string suitable for injection into an LLM prompt.
2
+ * Render a network as structured markdown for LLM context.
6
3
  */
7
4
  export function renderNetworkContext(network) {
8
- switch (network.type) {
9
- case 'event':
10
- return renderEventNetwork(network);
11
- case 'community':
12
- default:
13
- return renderCommunityNetwork(network);
14
- }
15
- }
16
- function renderCommunityNetwork(network) {
17
5
  const lines = [`## ${network.title}`];
18
6
  if (network.prompt) {
19
7
  lines.push('', network.prompt);
20
8
  }
21
9
  return lines.join('\n');
22
10
  }
23
- function renderEventNetwork(network) {
24
- const meta = network.metadata;
25
- const startDate = typeof meta.startDate === 'string' ? meta.startDate : undefined;
26
- const endDate = typeof meta.endDate === 'string' ? meta.endDate : undefined;
27
- const location = typeof meta.location === 'string' ? meta.location : undefined;
28
- const timezone = typeof meta.timezone === 'string' ? meta.timezone : undefined;
29
- const themes = Array.isArray(meta.themes) ? meta.themes.filter((t) => typeof t === 'string') : [];
30
- const events = Array.isArray(meta.events) ? normalizeEvents(meta.events) : [];
31
- const lines = [`## ${network.title}`];
32
- if (network.prompt) {
33
- lines.push('', network.prompt);
34
- }
35
- lines.push('');
36
- lines.push('- **Type:** Event');
37
- const dateRange = startDate && endDate ? formatDateRange(startDate, endDate) : undefined;
38
- if (dateRange) {
39
- lines.push(`- **Dates:** ${dateRange}`);
40
- }
41
- if (location) {
42
- lines.push(`- **Location:** ${location}`);
43
- }
44
- if (timezone) {
45
- lines.push(`- **Timezone:** ${timezone}`);
46
- }
47
- if (themes.length > 0) {
48
- lines.push(`- **Themes:** ${themes.join(', ')}`);
49
- }
50
- lines.push('');
51
- const upcoming = getUpcomingEvents(events, 7);
52
- if (upcoming.length === 0) {
53
- lines.push('No upcoming events in the next 7 days.');
54
- }
55
- else {
56
- lines.push('### Upcoming Events (next 7 days)');
57
- lines.push('| Time | Event | Location |');
58
- lines.push('|------|-------|----------|');
59
- for (const evt of upcoming) {
60
- const time = formatEventTime(evt.startTime);
61
- const loc = escapeTableCell(evt.location ?? '');
62
- const title = escapeTableCell(evt.title);
63
- lines.push(`| ${time} | ${title} | ${loc} |`);
64
- }
65
- }
66
- return lines.join('\n');
67
- }
68
- function formatDateRange(start, end) {
69
- const s = new Date(start);
70
- const e = new Date(end);
71
- if (isNaN(s.getTime()) || isNaN(e.getTime()))
72
- return undefined;
73
- const opts = { month: 'long', day: 'numeric', year: 'numeric', timeZone: 'UTC' };
74
- return `${s.toLocaleDateString('en-US', opts)} – ${e.toLocaleDateString('en-US', opts)}`;
75
- }
76
- function formatEventTime(iso) {
77
- const d = new Date(iso);
78
- if (isNaN(d.getTime()))
79
- return iso;
80
- return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' }) +
81
- ', ' +
82
- d.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', timeZone: 'UTC' });
83
- }
84
- function escapeTableCell(value) {
85
- return value.replace(/\|/g, '\\|').replace(/\n/g, ' ');
86
- }
87
- function normalizeEvents(raw) {
88
- return raw.filter((e) => {
89
- if (typeof e !== 'object' || e === null)
90
- return false;
91
- const obj = e;
92
- return typeof obj.title === 'string' && typeof obj.startTime === 'string' && typeof obj.endTime === 'string';
93
- });
94
- }
95
- function getUpcomingEvents(events, windowDays) {
96
- const now = Date.now();
97
- const windowEnd = now + windowDays * 24 * 60 * 60 * 1000;
98
- return events
99
- .map((e) => ({ e, t: new Date(e.startTime).getTime() }))
100
- .filter(({ t }) => !isNaN(t) && t >= now && t <= windowEnd)
101
- .sort((a, b) => a.t - b.t)
102
- .map(({ e }) => e);
103
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/protocol",
3
- "version": "8.10.0-rc.433.1",
3
+ "version": "9.0.0-rc.435.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",