@band-ai/sdk 0.1.2
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/CodexAdapter-A1k_LMdZ.d.ts +1278 -0
- package/dist/CodexAdapter-BbZD-nBd.d.cts +1278 -0
- package/dist/adapters.cjs +10643 -0
- package/dist/adapters.d.cts +217 -0
- package/dist/adapters.d.ts +217 -0
- package/dist/adapters.js +92 -0
- package/dist/backends-BnOLsG7w.d.cts +20 -0
- package/dist/backends-C4n6cKOf.d.ts +20 -0
- package/dist/chunk-3BKAC4OZ.js +44 -0
- package/dist/chunk-5CXIMAH2.js +52 -0
- package/dist/chunk-6AJA2OPC.js +3682 -0
- package/dist/chunk-A3TDK6GP.js +6674 -0
- package/dist/chunk-AVVDPXP4.js +39 -0
- package/dist/chunk-EDPKUUJL.js +177 -0
- package/dist/chunk-FUODYQRE.js +2562 -0
- package/dist/chunk-GVEQ3RAH.js +373 -0
- package/dist/chunk-INA6YZTZ.js +88 -0
- package/dist/chunk-IZPV6QS6.js +115 -0
- package/dist/chunk-LY55KYVI.js +0 -0
- package/dist/chunk-NIAQBANR.js +577 -0
- package/dist/chunk-OD2G5LFQ.js +78 -0
- package/dist/chunk-SFVKOEQH.js +103 -0
- package/dist/chunk-SG4WLD2H.js +1093 -0
- package/dist/chunk-YR3BOQNW.js +39 -0
- package/dist/chunk-ZZJRRBPQ.js +82 -0
- package/dist/claude-CcnQ5OUC.d.ts +53 -0
- package/dist/claude-CwTAxhwI.d.cts +53 -0
- package/dist/config.cjs +164 -0
- package/dist/config.d.cts +19 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +9 -0
- package/dist/converters.cjs +1086 -0
- package/dist/converters.d.cts +143 -0
- package/dist/converters.d.ts +143 -0
- package/dist/converters.js +468 -0
- package/dist/core.cjs +185 -0
- package/dist/core.d.cts +22 -0
- package/dist/core.d.ts +22 -0
- package/dist/core.js +24 -0
- package/dist/customTools-BzF0IISO.d.cts +10 -0
- package/dist/customTools-BzF0IISO.d.ts +10 -0
- package/dist/dtos-DUpbIu8k.d.cts +163 -0
- package/dist/dtos-DUpbIu8k.d.ts +163 -0
- package/dist/history-ByessXNq.d.ts +24 -0
- package/dist/history-i6yN7neC.d.cts +24 -0
- package/dist/index.cjs +13914 -0
- package/dist/index.d.cts +63 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +198 -0
- package/dist/linear.cjs +2207 -0
- package/dist/linear.d.cts +167 -0
- package/dist/linear.d.ts +167 -0
- package/dist/linear.js +2139 -0
- package/dist/logger-CABQOnlR.d.cts +21 -0
- package/dist/logger-CABQOnlR.d.ts +21 -0
- package/dist/mcp-claude.cjs +584 -0
- package/dist/mcp-claude.d.cts +4 -0
- package/dist/mcp-claude.d.ts +4 -0
- package/dist/mcp-claude.js +11 -0
- package/dist/mcp.cjs +1247 -0
- package/dist/mcp.d.cts +97 -0
- package/dist/mcp.d.ts +97 -0
- package/dist/mcp.js +27 -0
- package/dist/opencode-BBcDchcN.d.cts +159 -0
- package/dist/opencode-DthQQUsZ.d.ts +159 -0
- package/dist/pagination-BPiys10t.d.cts +25 -0
- package/dist/pagination-CcDkVFxK.d.ts +25 -0
- package/dist/protocols-CInhtFpA.d.cts +116 -0
- package/dist/protocols-DrhzOH6K.d.ts +116 -0
- package/dist/rest.cjs +1159 -0
- package/dist/rest.d.cts +144 -0
- package/dist/rest.d.ts +144 -0
- package/dist/rest.js +18 -0
- package/dist/runtime.cjs +5353 -0
- package/dist/runtime.d.cts +276 -0
- package/dist/runtime.d.ts +276 -0
- package/dist/runtime.js +274 -0
- package/dist/schemas-BpEBkq5V.d.cts +592 -0
- package/dist/schemas-vos1AaBc.d.ts +592 -0
- package/dist/sdk-HJUVSSWA.js +10 -0
- package/dist/simpleAdapter-9OE_p6QW.d.ts +29 -0
- package/dist/simpleAdapter-DqhvjsGr.d.cts +29 -0
- package/dist/testing.cjs +217 -0
- package/dist/testing.d.cts +126 -0
- package/dist/testing.d.ts +126 -0
- package/dist/testing.js +186 -0
- package/dist/types-7jVzOeOP.d.ts +446 -0
- package/dist/types-CSHFipIc.d.cts +331 -0
- package/dist/types-CovcHpYf.d.cts +446 -0
- package/dist/types-CxII3XkA.d.ts +331 -0
- package/package.json +189 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-CovcHpYf.cjs';
|
|
2
|
+
export { A as AgentConfig, b as ContactEventCallback, d as ContactEventStrategy, e as ConversationContext, H as HistoryProvider, M as MessageHandler, h as SYNTHETIC_CONTACT_EVENTS_SENDER_ID, i as SYNTHETIC_CONTACT_EVENTS_SENDER_NAME, j as SYNTHETIC_SENDER_TYPE, S as SessionConfig, k as ensureHandlePrefix } from './types-CovcHpYf.cjs';
|
|
3
|
+
import { L as Logger } from './logger-CABQOnlR.cjs';
|
|
4
|
+
import { A as AdapterToolsProtocol, a as AgentToolsProtocol, h as AgentToolsCapabilities, C as ContactTools } from './protocols-CInhtFpA.cjs';
|
|
5
|
+
import { e as AgentToolsRestApi, f as ChatMessagingRestApi, g as ChatRoomRestApi, h as ContactRestApi } from './types-CSHFipIc.cjs';
|
|
6
|
+
import { b as ThenvoiLink, c as ExecutionContext } from './schemas-BpEBkq5V.cjs';
|
|
7
|
+
export { d as ALL_TOOL_NAMES, A as AgentRuntime, B as BASE_TOOL_NAMES, C as CHAT_TOOL_NAMES, e as CONTACT_TOOL_NAMES, D as DefaultPreprocessor, E as ExecutionContextOptions, f as ExecutionState, M as MCP_TOOL_PREFIX, g as MEMORY_TOOL_NAMES, h as MessageRetryTracker, P as PlatformRuntime, T as TOOL_MODELS, i as getToolDescription, m as mcpToolNames } from './schemas-BpEBkq5V.cjs';
|
|
8
|
+
import { M as MetadataMap, P as ParticipantRecord, a as MentionInput, T as ToolOperationResult, c as PaginatedList, d as PeerRecord, b as ToolSchemaRecord, L as ListContactsArgs, C as ContactRecord, A as AddContactArgs, R as RemoveContactArgs, e as ListContactRequestsArgs, f as ContactRequestsResult, g as RespondContactRequestArgs, h as ListMemoriesArgs, i as MemoryRecord, S as StoreMemoryArgs, m as ToolModelMessage } from './dtos-DUpbIu8k.cjs';
|
|
9
|
+
import 'zod';
|
|
10
|
+
import './pagination-BPiys10t.cjs';
|
|
11
|
+
|
|
12
|
+
declare const HUB_ROOM_SYSTEM_PROMPT = "## OVERRIDE: Contact Management Mode\n\nThis is your CONTACTS HUB - a dedicated room for managing contact requests.\n\n**IMPORTANT: Do NOT delegate or add participants here.** You handle contact events DIRECTLY using the contact tools below. Do NOT call thenvoi_lookup_peers() or thenvoi_add_participant() in this room.\n\n## Your Role\n\n1. **Review incoming contact requests** - When you see a [Contact Request] message, evaluate it\n2. **Take action** - Use the contact tools to respond:\n - `thenvoi_respond_contact_request(action=\"approve\", request_id=\"...\")` to accept\n - `thenvoi_respond_contact_request(action=\"reject\", request_id=\"...\")` to decline\n3. **Report your decision** - Send a thought event explaining what you did\n\n## Example\n\n[Contact Events]: [Contact Request] Alice (@alice) wants to connect.\nRequest ID: abc-123\n\nYour response:\n1. thenvoi_send_event(\"Received contact request from Alice. Approving.\", message_type=\"thought\")\n2. thenvoi_respond_contact_request(action=\"approve\", request_id=\"abc-123\")\n3. thenvoi_send_event(\"Approved contact request from Alice (@alice)\", message_type=\"thought\")\n\n## Contact Tools (use these, NOT participant tools)\n- `thenvoi_respond_contact_request(action, request_id)` - Approve/reject requests\n- `thenvoi_list_contact_requests()` - List pending requests\n- `thenvoi_list_contacts()` - List current contacts";
|
|
13
|
+
type ContactHandlerRestApi = Partial<AgentToolsRestApi> & Pick<ChatMessagingRestApi, "createChatEvent"> & Pick<ChatRoomRestApi, "createChat"> & Partial<Pick<ContactRestApi, "listContactRequests">>;
|
|
14
|
+
interface ContactEventHandlerOptions {
|
|
15
|
+
config: ContactEventConfig;
|
|
16
|
+
rest: ContactHandlerRestApi;
|
|
17
|
+
logger?: Logger;
|
|
18
|
+
onBroadcast?: (message: string) => void;
|
|
19
|
+
onHubEvent?: (roomId: string, event: MessageEvent) => Promise<void>;
|
|
20
|
+
onHubInit?: (roomId: string, systemPrompt: string) => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
declare class ContactEventHandler {
|
|
23
|
+
private readonly config;
|
|
24
|
+
private readonly rest;
|
|
25
|
+
private readonly logger;
|
|
26
|
+
private readonly onBroadcast?;
|
|
27
|
+
private readonly onHubEvent?;
|
|
28
|
+
private readonly onHubInit?;
|
|
29
|
+
private readonly dedup;
|
|
30
|
+
private readonly dedupOrder;
|
|
31
|
+
private syntheticIdCounter;
|
|
32
|
+
private readonly requestCache;
|
|
33
|
+
private hubRoomId;
|
|
34
|
+
private hubRoomInitPromise;
|
|
35
|
+
constructor(options: ContactEventHandlerOptions);
|
|
36
|
+
handle(event: ContactEvent, tools?: AdapterToolsProtocol): Promise<void>;
|
|
37
|
+
private handleCallback;
|
|
38
|
+
private handleHubRoom;
|
|
39
|
+
private initHubRoom;
|
|
40
|
+
formatEventMessage(event: ContactEvent): Promise<string>;
|
|
41
|
+
private formatBroadcast;
|
|
42
|
+
private enrichUpdateEvent;
|
|
43
|
+
private fetchRequestDetails;
|
|
44
|
+
private cacheRequestInfo;
|
|
45
|
+
private buildDedupKey;
|
|
46
|
+
private recordDedup;
|
|
47
|
+
private rollbackDedup;
|
|
48
|
+
private buildHandlerError;
|
|
49
|
+
private resolveRetryable;
|
|
50
|
+
private logFailure;
|
|
51
|
+
private serializeError;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type ExecutionHandler = (context: ExecutionContext, event: PlatformEvent) => Promise<void>;
|
|
55
|
+
interface ExecutionOptions {
|
|
56
|
+
roomId: string;
|
|
57
|
+
link: ThenvoiLink;
|
|
58
|
+
context: ExecutionContext;
|
|
59
|
+
onExecute: ExecutionHandler;
|
|
60
|
+
onFailure?: (error: unknown, event: PlatformEvent) => void | Promise<void>;
|
|
61
|
+
logger?: Logger;
|
|
62
|
+
}
|
|
63
|
+
declare class Execution {
|
|
64
|
+
private readonly roomId;
|
|
65
|
+
private readonly link;
|
|
66
|
+
private readonly context;
|
|
67
|
+
private readonly retryTracker;
|
|
68
|
+
private readonly onExecute;
|
|
69
|
+
private readonly onFailure?;
|
|
70
|
+
private readonly logger;
|
|
71
|
+
private readonly eventQueue;
|
|
72
|
+
private readonly waiters;
|
|
73
|
+
private readonly idleWaiters;
|
|
74
|
+
private readonly drainedWsMessageIds;
|
|
75
|
+
private readonly syncProcessedIds;
|
|
76
|
+
private processTask;
|
|
77
|
+
private firstWsMessageId;
|
|
78
|
+
private syncComplete;
|
|
79
|
+
private running;
|
|
80
|
+
private inFlight;
|
|
81
|
+
constructor(options: ExecutionOptions);
|
|
82
|
+
enqueue(event: PlatformEvent): Promise<void>;
|
|
83
|
+
bootstrapMessage(message: PlatformMessage): Promise<void>;
|
|
84
|
+
isIdle(): boolean;
|
|
85
|
+
waitForIdle(timeoutMs?: number): Promise<boolean>;
|
|
86
|
+
stop(timeoutMs?: number): Promise<boolean>;
|
|
87
|
+
waitUntilStopped(): Promise<void>;
|
|
88
|
+
private processLoop;
|
|
89
|
+
private recoverStaleProcessingMessages;
|
|
90
|
+
private synchronizeWithNext;
|
|
91
|
+
private executeSyncMessage;
|
|
92
|
+
private executeEvent;
|
|
93
|
+
private nextQueuedEvent;
|
|
94
|
+
private notifyIfIdle;
|
|
95
|
+
private resolveEventWaiters;
|
|
96
|
+
private markMessageFailed;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface RoomPresenceOptions {
|
|
100
|
+
link: ThenvoiLink;
|
|
101
|
+
roomFilter?: (room: MetadataMap) => boolean;
|
|
102
|
+
autoSubscribeExistingRooms?: boolean;
|
|
103
|
+
logger?: Logger;
|
|
104
|
+
}
|
|
105
|
+
type RoomPresenceJoinHandler = (roomId: string, payload: MetadataMap) => Promise<void>;
|
|
106
|
+
type RoomPresenceLeaveHandler = (roomId: string) => Promise<void>;
|
|
107
|
+
type RoomPresenceEventHandler = (roomId: string, event: PlatformEvent) => Promise<void>;
|
|
108
|
+
type RoomPresenceContactHandler = (event: ContactEvent) => Promise<void>;
|
|
109
|
+
declare class RoomPresence {
|
|
110
|
+
readonly rooms: Set<string>;
|
|
111
|
+
onRoomJoined: RoomPresenceJoinHandler | null;
|
|
112
|
+
onRoomLeft: RoomPresenceLeaveHandler | null;
|
|
113
|
+
onRoomEvent: RoomPresenceEventHandler | null;
|
|
114
|
+
onContactEvent: RoomPresenceContactHandler | null;
|
|
115
|
+
private readonly link;
|
|
116
|
+
private readonly roomFilter?;
|
|
117
|
+
private readonly autoSubscribeExistingRooms;
|
|
118
|
+
private readonly logger;
|
|
119
|
+
private eventController;
|
|
120
|
+
private eventTask;
|
|
121
|
+
private contactsSubscribed;
|
|
122
|
+
constructor(options: RoomPresenceOptions);
|
|
123
|
+
start(): Promise<void>;
|
|
124
|
+
stop(): Promise<void>;
|
|
125
|
+
private consumeEvents;
|
|
126
|
+
private handleRoomAdded;
|
|
127
|
+
private handleRoomRemoved;
|
|
128
|
+
private subscribeExistingRooms;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface AgentToolsOptions {
|
|
132
|
+
roomId: string;
|
|
133
|
+
rest: AgentToolsRestApi;
|
|
134
|
+
participants?: ParticipantRecord[];
|
|
135
|
+
capabilities?: Partial<AgentToolsCapabilities>;
|
|
136
|
+
}
|
|
137
|
+
declare class AgentTools implements AgentToolsProtocol {
|
|
138
|
+
readonly roomId: string;
|
|
139
|
+
readonly capabilities: Readonly<AgentToolsCapabilities>;
|
|
140
|
+
private readonly rest;
|
|
141
|
+
private participants;
|
|
142
|
+
private readonly adapterTools;
|
|
143
|
+
private readonly toolHandlers;
|
|
144
|
+
constructor(options: AgentToolsOptions);
|
|
145
|
+
getAdapterTools(): AdapterToolsProtocol;
|
|
146
|
+
sendMessage(content: string, mentions?: MentionInput): Promise<ToolOperationResult>;
|
|
147
|
+
sendEvent(content: string, messageType: string, metadata?: MetadataMap): Promise<ToolOperationResult>;
|
|
148
|
+
createChatroom(taskId?: string): Promise<string>;
|
|
149
|
+
addParticipant(name: string, role?: string): Promise<ToolOperationResult>;
|
|
150
|
+
removeParticipant(name: string): Promise<ToolOperationResult>;
|
|
151
|
+
lookupPeers(page?: number, pageSize?: number): Promise<PaginatedList<PeerRecord>>;
|
|
152
|
+
getParticipants(): Promise<ParticipantRecord[]>;
|
|
153
|
+
private fetchParticipants;
|
|
154
|
+
private syncParticipants;
|
|
155
|
+
executeToolCall(toolName: string, arguments_: MetadataMap): Promise<unknown>;
|
|
156
|
+
getToolSchemas(format: "openai" | "anthropic", options?: {
|
|
157
|
+
includeMemory?: boolean;
|
|
158
|
+
}): ToolSchemaRecord[];
|
|
159
|
+
getAnthropicToolSchemas(options?: {
|
|
160
|
+
includeMemory?: boolean;
|
|
161
|
+
}): ToolSchemaRecord[];
|
|
162
|
+
getOpenAIToolSchemas(options?: {
|
|
163
|
+
includeMemory?: boolean;
|
|
164
|
+
}): ToolSchemaRecord[];
|
|
165
|
+
listContacts(request?: ListContactsArgs): Promise<PaginatedList<ContactRecord>>;
|
|
166
|
+
addContact(request: AddContactArgs): Promise<ToolOperationResult>;
|
|
167
|
+
removeContact(request: RemoveContactArgs): Promise<ToolOperationResult>;
|
|
168
|
+
listContactRequests(request?: ListContactRequestsArgs): Promise<ContactRequestsResult>;
|
|
169
|
+
respondContactRequest(request: RespondContactRequestArgs): Promise<ToolOperationResult>;
|
|
170
|
+
listMemories(args?: ListMemoriesArgs): Promise<PaginatedList<MemoryRecord>>;
|
|
171
|
+
storeMemory(args: StoreMemoryArgs): Promise<MemoryRecord>;
|
|
172
|
+
getMemory(memoryId: string): Promise<MemoryRecord>;
|
|
173
|
+
supersedeMemory(memoryId: string): Promise<ToolOperationResult>;
|
|
174
|
+
archiveMemory(memoryId: string): Promise<ToolOperationResult>;
|
|
175
|
+
private resolveMentions;
|
|
176
|
+
private lookupPeerByName;
|
|
177
|
+
private normalizeMentionHandle;
|
|
178
|
+
private replaceParticipants;
|
|
179
|
+
private buildAdapterTools;
|
|
180
|
+
private bindAdapterToolMethod;
|
|
181
|
+
private buildToolHandlers;
|
|
182
|
+
private buildMessagingToolHandlers;
|
|
183
|
+
private buildContactToolHandlers;
|
|
184
|
+
private buildMemoryToolHandlers;
|
|
185
|
+
private toRemoveContactArgs;
|
|
186
|
+
private toRespondContactRequestArgs;
|
|
187
|
+
private toListMemoriesArgs;
|
|
188
|
+
private toStoreMemoryArgs;
|
|
189
|
+
private normalizeOptionalString;
|
|
190
|
+
private normalizeRequiredString;
|
|
191
|
+
private normalizeOptionalNumber;
|
|
192
|
+
private normalizeOptionalMetadata;
|
|
193
|
+
private normalizeMentionInput;
|
|
194
|
+
private normalizeOptionalMemoryScope;
|
|
195
|
+
private normalizeOptionalMemorySystem;
|
|
196
|
+
private normalizeOptionalMemoryType;
|
|
197
|
+
private normalizeOptionalMemorySegment;
|
|
198
|
+
private normalizeOptionalMemoryStatus;
|
|
199
|
+
private normalizeOptionalStoreMemoryScope;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
declare class ContactToolsImpl implements ContactTools {
|
|
203
|
+
private readonly rest;
|
|
204
|
+
constructor(rest: ContactRestApi);
|
|
205
|
+
listContacts(request?: ListContactsArgs): Promise<PaginatedList<ContactRecord>>;
|
|
206
|
+
addContact(request: AddContactArgs): Promise<ToolOperationResult>;
|
|
207
|
+
removeContact(request: RemoveContactArgs): Promise<ToolOperationResult>;
|
|
208
|
+
listContactRequests(request?: ListContactRequestsArgs): Promise<ContactRequestsResult>;
|
|
209
|
+
respondContactRequest(request: RespondContactRequestArgs): Promise<ToolOperationResult>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare const CHAT_EVENT_TYPES: readonly ["tool_call", "tool_result", "thought", "error", "task"];
|
|
213
|
+
type ChatEventType = (typeof CHAT_EVENT_TYPES)[number];
|
|
214
|
+
declare const CHAT_MESSAGE_TYPES: readonly ["text", "tool_call", "tool_result", "thought", "error", "task"];
|
|
215
|
+
type ChatMessageType = (typeof CHAT_MESSAGE_TYPES)[number];
|
|
216
|
+
declare function isChatEventType(value: string): value is ChatEventType;
|
|
217
|
+
declare function assertChatEventType(value: string): asserts value is ChatEventType;
|
|
218
|
+
|
|
219
|
+
declare function replaceUuidMentions(content: string, participants: Array<Record<string, unknown>>): string;
|
|
220
|
+
declare function formatMessageForLlm(message: Record<string, unknown>, participants?: Array<Record<string, unknown>>): ToolModelMessage;
|
|
221
|
+
declare function formatHistoryForLlm(messages: Array<Record<string, unknown>>, options?: {
|
|
222
|
+
excludeId?: string;
|
|
223
|
+
participants?: Array<Record<string, unknown>>;
|
|
224
|
+
}): ToolModelMessage[];
|
|
225
|
+
declare function buildParticipantsMessage(participants: Array<Record<string, unknown>>): string;
|
|
226
|
+
|
|
227
|
+
declare const BASE_INSTRUCTIONS = "\n## Environment\n\nMulti-participant chat. Messages show sender: [Name]: content.\nMessages prefixed with [System]: are platform updates (participant changes, contact updates, etc.) \u2014 not messages from users.\nUse `thenvoi_send_message(content, mentions)` to respond. Plain text output is not delivered.\nMentions use handles: @<username> for users, @<username>/<agent-name> for agents.\n\n## CRITICAL: Delegate When You Cannot Help Directly\n\nYou have NO internet access and NO real-time data. When asked about weather, news, stock prices,\nor any current information you cannot answer directly:\n\n1. Call `thenvoi_lookup_peers()` to find available specialized agents\n2. If a relevant agent exists, call `thenvoi_add_participant(name)` to add them\n3. Ask that agent using `thenvoi_send_message(question, mentions=[agent_handle])`\n4. Wait for their response and relay it back to the user\n\nNEVER say \"I can't do that\" without first checking if another agent can help via `thenvoi_lookup_peers()`.\n\n## CRITICAL: Do NOT Remove Agents Automatically\n\nAfter adding an agent to help with a task:\n1. Ask your question and wait for their response\n2. Relay their response back to the original requester\n3. **Do NOT remove the agent** - they stay silent unless mentioned and may be useful for follow-ups\n\nOnly remove agents if the user explicitly requests it.\n\n## CRITICAL: Always Relay Information Back to the Requester\n\nWhen someone asks you to get information from another agent:\n1. Ask the other agent for the information\n2. When you receive the response, IMMEDIATELY relay it back to the ORIGINAL REQUESTER\n3. Do NOT just thank the helper agent - the requester is waiting for their answer!\n\n## IMPORTANT: Always Share Your Thinking\n\nYou MUST call `thenvoi_send_event(content, message_type=\"thought\")` BEFORE every action.\nThis is required so users can see your reasoning process.\n\n## Examples\n\n### Simple question - answer directly\n[John Doe]: What's 2+2?\n-> thenvoi_send_event(\"Simple arithmetic, answering directly.\", message_type=\"thought\")\n-> thenvoi_send_message(\"4\", mentions=[\"@john\"])\n\n### User asks about weather (you cannot answer directly)\n[John Doe]: What's the weather in Tokyo?\n-> thenvoi_send_event(\"I can't check weather directly. Looking for a Weather Agent.\", message_type=\"thought\")\n-> thenvoi_lookup_peers()\n-> thenvoi_send_event(\"Found Weather Agent. Adding to room.\", message_type=\"thought\")\n-> thenvoi_add_participant(\"Weather Agent\")\n-> thenvoi_send_message(\"What's the weather in Tokyo?\", mentions=[\"@john/weather-agent\"])\n\n[Weather Agent]: Tokyo is 15\u00B0C and cloudy.\n-> thenvoi_send_event(\"Got weather response. Relaying back to John Doe.\", message_type=\"thought\")\n-> thenvoi_send_message(\"The weather in Tokyo is 15\u00B0C and cloudy.\", mentions=[\"@john\"])\n\n### No suitable agent available\n[John Doe]: What's the stock price of AAPL?\n-> thenvoi_send_event(\"I can't check stock prices. Looking for a Stock Agent.\", message_type=\"thought\")\n-> thenvoi_lookup_peers()\n-> thenvoi_send_event(\"No stock agent available. Must inform user.\", message_type=\"thought\")\n-> thenvoi_send_message(\"I don't have access to stock prices, and there's no specialized agent available to help with that.\", mentions=[\"@john\"])\n\n### Follow-up question in same conversation\n[John Doe]: What about London?\n-> thenvoi_send_event(\"Follow-up weather question. Asking Weather Agent.\", message_type=\"thought\")\n-> thenvoi_send_message(\"What's the weather in London?\", mentions=[\"@john/weather-agent\"])\n\n[Weather Agent]: London is 8\u00B0C and rainy.\n-> thenvoi_send_event(\"Got London weather. Relaying to John Doe.\", message_type=\"thought\")\n-> thenvoi_send_message(\"London is 8\u00B0C and rainy.\", mentions=[\"@john\"])\n";
|
|
228
|
+
declare const TEMPLATES: Record<string, string>;
|
|
229
|
+
interface RenderSystemPromptOptions {
|
|
230
|
+
agentName?: string;
|
|
231
|
+
agentDescription?: string;
|
|
232
|
+
customSection?: string;
|
|
233
|
+
template?: string;
|
|
234
|
+
includeBaseInstructions?: boolean;
|
|
235
|
+
}
|
|
236
|
+
declare function renderSystemPrompt(options?: RenderSystemPromptOptions): string;
|
|
237
|
+
|
|
238
|
+
declare class ParticipantTracker {
|
|
239
|
+
private participantsList;
|
|
240
|
+
private lastSent;
|
|
241
|
+
private loaded;
|
|
242
|
+
get participants(): Array<Record<string, unknown>>;
|
|
243
|
+
get isLoaded(): boolean;
|
|
244
|
+
setLoaded(participants: Array<Record<string, unknown>>): void;
|
|
245
|
+
add(participant: Record<string, unknown>): boolean;
|
|
246
|
+
remove(participantId: string): boolean;
|
|
247
|
+
changed(): boolean;
|
|
248
|
+
markSent(): void;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
interface StoppableAgent {
|
|
252
|
+
stop(timeoutMs?: number | null): Promise<boolean>;
|
|
253
|
+
run(options?: {
|
|
254
|
+
shutdownTimeoutMs?: number | null;
|
|
255
|
+
signals?: boolean;
|
|
256
|
+
}): Promise<void>;
|
|
257
|
+
}
|
|
258
|
+
interface GracefulShutdownOptions {
|
|
259
|
+
timeoutMs?: number | null;
|
|
260
|
+
onSignal?: (signal: NodeJS.Signals) => void;
|
|
261
|
+
}
|
|
262
|
+
declare class GracefulShutdown {
|
|
263
|
+
private readonly agent;
|
|
264
|
+
private readonly timeoutMs;
|
|
265
|
+
private readonly onSignal?;
|
|
266
|
+
private readonly handlers;
|
|
267
|
+
private shuttingDown;
|
|
268
|
+
constructor(agent: StoppableAgent, options?: GracefulShutdownOptions);
|
|
269
|
+
registerSignals(): void;
|
|
270
|
+
unregisterSignals(): void;
|
|
271
|
+
withSignals<T>(fn: () => Promise<T>): Promise<T>;
|
|
272
|
+
private shutdown;
|
|
273
|
+
}
|
|
274
|
+
declare function runWithGracefulShutdown(agent: StoppableAgent, options?: GracefulShutdownOptions): Promise<void>;
|
|
275
|
+
|
|
276
|
+
export { AgentTools, BASE_INSTRUCTIONS, CHAT_EVENT_TYPES, CHAT_MESSAGE_TYPES, type ChatEventType, type ChatMessageType, ContactEventConfig, ContactEventHandler, ContactToolsImpl, Execution, ExecutionContext, type ExecutionHandler, GracefulShutdown, HUB_ROOM_SYSTEM_PROMPT, ParticipantTracker, PlatformMessage, type RenderSystemPromptOptions, RoomPresence, TEMPLATES, assertChatEventType, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, isChatEventType, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { c as ContactEventConfig, g as MessageEvent, C as ContactEvent, f as PlatformEvent, P as PlatformMessage } from './types-7jVzOeOP.js';
|
|
2
|
+
export { A as AgentConfig, b as ContactEventCallback, d as ContactEventStrategy, e as ConversationContext, H as HistoryProvider, M as MessageHandler, h as SYNTHETIC_CONTACT_EVENTS_SENDER_ID, i as SYNTHETIC_CONTACT_EVENTS_SENDER_NAME, j as SYNTHETIC_SENDER_TYPE, S as SessionConfig, k as ensureHandlePrefix } from './types-7jVzOeOP.js';
|
|
3
|
+
import { L as Logger } from './logger-CABQOnlR.js';
|
|
4
|
+
import { A as AdapterToolsProtocol, a as AgentToolsProtocol, h as AgentToolsCapabilities, C as ContactTools } from './protocols-DrhzOH6K.js';
|
|
5
|
+
import { e as AgentToolsRestApi, f as ChatMessagingRestApi, g as ChatRoomRestApi, h as ContactRestApi } from './types-CxII3XkA.js';
|
|
6
|
+
import { b as ThenvoiLink, c as ExecutionContext } from './schemas-vos1AaBc.js';
|
|
7
|
+
export { d as ALL_TOOL_NAMES, A as AgentRuntime, B as BASE_TOOL_NAMES, C as CHAT_TOOL_NAMES, e as CONTACT_TOOL_NAMES, D as DefaultPreprocessor, E as ExecutionContextOptions, f as ExecutionState, M as MCP_TOOL_PREFIX, g as MEMORY_TOOL_NAMES, h as MessageRetryTracker, P as PlatformRuntime, T as TOOL_MODELS, i as getToolDescription, m as mcpToolNames } from './schemas-vos1AaBc.js';
|
|
8
|
+
import { M as MetadataMap, P as ParticipantRecord, a as MentionInput, T as ToolOperationResult, c as PaginatedList, d as PeerRecord, b as ToolSchemaRecord, L as ListContactsArgs, C as ContactRecord, A as AddContactArgs, R as RemoveContactArgs, e as ListContactRequestsArgs, f as ContactRequestsResult, g as RespondContactRequestArgs, h as ListMemoriesArgs, i as MemoryRecord, S as StoreMemoryArgs, m as ToolModelMessage } from './dtos-DUpbIu8k.js';
|
|
9
|
+
import 'zod';
|
|
10
|
+
import './pagination-CcDkVFxK.js';
|
|
11
|
+
|
|
12
|
+
declare const HUB_ROOM_SYSTEM_PROMPT = "## OVERRIDE: Contact Management Mode\n\nThis is your CONTACTS HUB - a dedicated room for managing contact requests.\n\n**IMPORTANT: Do NOT delegate or add participants here.** You handle contact events DIRECTLY using the contact tools below. Do NOT call thenvoi_lookup_peers() or thenvoi_add_participant() in this room.\n\n## Your Role\n\n1. **Review incoming contact requests** - When you see a [Contact Request] message, evaluate it\n2. **Take action** - Use the contact tools to respond:\n - `thenvoi_respond_contact_request(action=\"approve\", request_id=\"...\")` to accept\n - `thenvoi_respond_contact_request(action=\"reject\", request_id=\"...\")` to decline\n3. **Report your decision** - Send a thought event explaining what you did\n\n## Example\n\n[Contact Events]: [Contact Request] Alice (@alice) wants to connect.\nRequest ID: abc-123\n\nYour response:\n1. thenvoi_send_event(\"Received contact request from Alice. Approving.\", message_type=\"thought\")\n2. thenvoi_respond_contact_request(action=\"approve\", request_id=\"abc-123\")\n3. thenvoi_send_event(\"Approved contact request from Alice (@alice)\", message_type=\"thought\")\n\n## Contact Tools (use these, NOT participant tools)\n- `thenvoi_respond_contact_request(action, request_id)` - Approve/reject requests\n- `thenvoi_list_contact_requests()` - List pending requests\n- `thenvoi_list_contacts()` - List current contacts";
|
|
13
|
+
type ContactHandlerRestApi = Partial<AgentToolsRestApi> & Pick<ChatMessagingRestApi, "createChatEvent"> & Pick<ChatRoomRestApi, "createChat"> & Partial<Pick<ContactRestApi, "listContactRequests">>;
|
|
14
|
+
interface ContactEventHandlerOptions {
|
|
15
|
+
config: ContactEventConfig;
|
|
16
|
+
rest: ContactHandlerRestApi;
|
|
17
|
+
logger?: Logger;
|
|
18
|
+
onBroadcast?: (message: string) => void;
|
|
19
|
+
onHubEvent?: (roomId: string, event: MessageEvent) => Promise<void>;
|
|
20
|
+
onHubInit?: (roomId: string, systemPrompt: string) => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
declare class ContactEventHandler {
|
|
23
|
+
private readonly config;
|
|
24
|
+
private readonly rest;
|
|
25
|
+
private readonly logger;
|
|
26
|
+
private readonly onBroadcast?;
|
|
27
|
+
private readonly onHubEvent?;
|
|
28
|
+
private readonly onHubInit?;
|
|
29
|
+
private readonly dedup;
|
|
30
|
+
private readonly dedupOrder;
|
|
31
|
+
private syntheticIdCounter;
|
|
32
|
+
private readonly requestCache;
|
|
33
|
+
private hubRoomId;
|
|
34
|
+
private hubRoomInitPromise;
|
|
35
|
+
constructor(options: ContactEventHandlerOptions);
|
|
36
|
+
handle(event: ContactEvent, tools?: AdapterToolsProtocol): Promise<void>;
|
|
37
|
+
private handleCallback;
|
|
38
|
+
private handleHubRoom;
|
|
39
|
+
private initHubRoom;
|
|
40
|
+
formatEventMessage(event: ContactEvent): Promise<string>;
|
|
41
|
+
private formatBroadcast;
|
|
42
|
+
private enrichUpdateEvent;
|
|
43
|
+
private fetchRequestDetails;
|
|
44
|
+
private cacheRequestInfo;
|
|
45
|
+
private buildDedupKey;
|
|
46
|
+
private recordDedup;
|
|
47
|
+
private rollbackDedup;
|
|
48
|
+
private buildHandlerError;
|
|
49
|
+
private resolveRetryable;
|
|
50
|
+
private logFailure;
|
|
51
|
+
private serializeError;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type ExecutionHandler = (context: ExecutionContext, event: PlatformEvent) => Promise<void>;
|
|
55
|
+
interface ExecutionOptions {
|
|
56
|
+
roomId: string;
|
|
57
|
+
link: ThenvoiLink;
|
|
58
|
+
context: ExecutionContext;
|
|
59
|
+
onExecute: ExecutionHandler;
|
|
60
|
+
onFailure?: (error: unknown, event: PlatformEvent) => void | Promise<void>;
|
|
61
|
+
logger?: Logger;
|
|
62
|
+
}
|
|
63
|
+
declare class Execution {
|
|
64
|
+
private readonly roomId;
|
|
65
|
+
private readonly link;
|
|
66
|
+
private readonly context;
|
|
67
|
+
private readonly retryTracker;
|
|
68
|
+
private readonly onExecute;
|
|
69
|
+
private readonly onFailure?;
|
|
70
|
+
private readonly logger;
|
|
71
|
+
private readonly eventQueue;
|
|
72
|
+
private readonly waiters;
|
|
73
|
+
private readonly idleWaiters;
|
|
74
|
+
private readonly drainedWsMessageIds;
|
|
75
|
+
private readonly syncProcessedIds;
|
|
76
|
+
private processTask;
|
|
77
|
+
private firstWsMessageId;
|
|
78
|
+
private syncComplete;
|
|
79
|
+
private running;
|
|
80
|
+
private inFlight;
|
|
81
|
+
constructor(options: ExecutionOptions);
|
|
82
|
+
enqueue(event: PlatformEvent): Promise<void>;
|
|
83
|
+
bootstrapMessage(message: PlatformMessage): Promise<void>;
|
|
84
|
+
isIdle(): boolean;
|
|
85
|
+
waitForIdle(timeoutMs?: number): Promise<boolean>;
|
|
86
|
+
stop(timeoutMs?: number): Promise<boolean>;
|
|
87
|
+
waitUntilStopped(): Promise<void>;
|
|
88
|
+
private processLoop;
|
|
89
|
+
private recoverStaleProcessingMessages;
|
|
90
|
+
private synchronizeWithNext;
|
|
91
|
+
private executeSyncMessage;
|
|
92
|
+
private executeEvent;
|
|
93
|
+
private nextQueuedEvent;
|
|
94
|
+
private notifyIfIdle;
|
|
95
|
+
private resolveEventWaiters;
|
|
96
|
+
private markMessageFailed;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
interface RoomPresenceOptions {
|
|
100
|
+
link: ThenvoiLink;
|
|
101
|
+
roomFilter?: (room: MetadataMap) => boolean;
|
|
102
|
+
autoSubscribeExistingRooms?: boolean;
|
|
103
|
+
logger?: Logger;
|
|
104
|
+
}
|
|
105
|
+
type RoomPresenceJoinHandler = (roomId: string, payload: MetadataMap) => Promise<void>;
|
|
106
|
+
type RoomPresenceLeaveHandler = (roomId: string) => Promise<void>;
|
|
107
|
+
type RoomPresenceEventHandler = (roomId: string, event: PlatformEvent) => Promise<void>;
|
|
108
|
+
type RoomPresenceContactHandler = (event: ContactEvent) => Promise<void>;
|
|
109
|
+
declare class RoomPresence {
|
|
110
|
+
readonly rooms: Set<string>;
|
|
111
|
+
onRoomJoined: RoomPresenceJoinHandler | null;
|
|
112
|
+
onRoomLeft: RoomPresenceLeaveHandler | null;
|
|
113
|
+
onRoomEvent: RoomPresenceEventHandler | null;
|
|
114
|
+
onContactEvent: RoomPresenceContactHandler | null;
|
|
115
|
+
private readonly link;
|
|
116
|
+
private readonly roomFilter?;
|
|
117
|
+
private readonly autoSubscribeExistingRooms;
|
|
118
|
+
private readonly logger;
|
|
119
|
+
private eventController;
|
|
120
|
+
private eventTask;
|
|
121
|
+
private contactsSubscribed;
|
|
122
|
+
constructor(options: RoomPresenceOptions);
|
|
123
|
+
start(): Promise<void>;
|
|
124
|
+
stop(): Promise<void>;
|
|
125
|
+
private consumeEvents;
|
|
126
|
+
private handleRoomAdded;
|
|
127
|
+
private handleRoomRemoved;
|
|
128
|
+
private subscribeExistingRooms;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface AgentToolsOptions {
|
|
132
|
+
roomId: string;
|
|
133
|
+
rest: AgentToolsRestApi;
|
|
134
|
+
participants?: ParticipantRecord[];
|
|
135
|
+
capabilities?: Partial<AgentToolsCapabilities>;
|
|
136
|
+
}
|
|
137
|
+
declare class AgentTools implements AgentToolsProtocol {
|
|
138
|
+
readonly roomId: string;
|
|
139
|
+
readonly capabilities: Readonly<AgentToolsCapabilities>;
|
|
140
|
+
private readonly rest;
|
|
141
|
+
private participants;
|
|
142
|
+
private readonly adapterTools;
|
|
143
|
+
private readonly toolHandlers;
|
|
144
|
+
constructor(options: AgentToolsOptions);
|
|
145
|
+
getAdapterTools(): AdapterToolsProtocol;
|
|
146
|
+
sendMessage(content: string, mentions?: MentionInput): Promise<ToolOperationResult>;
|
|
147
|
+
sendEvent(content: string, messageType: string, metadata?: MetadataMap): Promise<ToolOperationResult>;
|
|
148
|
+
createChatroom(taskId?: string): Promise<string>;
|
|
149
|
+
addParticipant(name: string, role?: string): Promise<ToolOperationResult>;
|
|
150
|
+
removeParticipant(name: string): Promise<ToolOperationResult>;
|
|
151
|
+
lookupPeers(page?: number, pageSize?: number): Promise<PaginatedList<PeerRecord>>;
|
|
152
|
+
getParticipants(): Promise<ParticipantRecord[]>;
|
|
153
|
+
private fetchParticipants;
|
|
154
|
+
private syncParticipants;
|
|
155
|
+
executeToolCall(toolName: string, arguments_: MetadataMap): Promise<unknown>;
|
|
156
|
+
getToolSchemas(format: "openai" | "anthropic", options?: {
|
|
157
|
+
includeMemory?: boolean;
|
|
158
|
+
}): ToolSchemaRecord[];
|
|
159
|
+
getAnthropicToolSchemas(options?: {
|
|
160
|
+
includeMemory?: boolean;
|
|
161
|
+
}): ToolSchemaRecord[];
|
|
162
|
+
getOpenAIToolSchemas(options?: {
|
|
163
|
+
includeMemory?: boolean;
|
|
164
|
+
}): ToolSchemaRecord[];
|
|
165
|
+
listContacts(request?: ListContactsArgs): Promise<PaginatedList<ContactRecord>>;
|
|
166
|
+
addContact(request: AddContactArgs): Promise<ToolOperationResult>;
|
|
167
|
+
removeContact(request: RemoveContactArgs): Promise<ToolOperationResult>;
|
|
168
|
+
listContactRequests(request?: ListContactRequestsArgs): Promise<ContactRequestsResult>;
|
|
169
|
+
respondContactRequest(request: RespondContactRequestArgs): Promise<ToolOperationResult>;
|
|
170
|
+
listMemories(args?: ListMemoriesArgs): Promise<PaginatedList<MemoryRecord>>;
|
|
171
|
+
storeMemory(args: StoreMemoryArgs): Promise<MemoryRecord>;
|
|
172
|
+
getMemory(memoryId: string): Promise<MemoryRecord>;
|
|
173
|
+
supersedeMemory(memoryId: string): Promise<ToolOperationResult>;
|
|
174
|
+
archiveMemory(memoryId: string): Promise<ToolOperationResult>;
|
|
175
|
+
private resolveMentions;
|
|
176
|
+
private lookupPeerByName;
|
|
177
|
+
private normalizeMentionHandle;
|
|
178
|
+
private replaceParticipants;
|
|
179
|
+
private buildAdapterTools;
|
|
180
|
+
private bindAdapterToolMethod;
|
|
181
|
+
private buildToolHandlers;
|
|
182
|
+
private buildMessagingToolHandlers;
|
|
183
|
+
private buildContactToolHandlers;
|
|
184
|
+
private buildMemoryToolHandlers;
|
|
185
|
+
private toRemoveContactArgs;
|
|
186
|
+
private toRespondContactRequestArgs;
|
|
187
|
+
private toListMemoriesArgs;
|
|
188
|
+
private toStoreMemoryArgs;
|
|
189
|
+
private normalizeOptionalString;
|
|
190
|
+
private normalizeRequiredString;
|
|
191
|
+
private normalizeOptionalNumber;
|
|
192
|
+
private normalizeOptionalMetadata;
|
|
193
|
+
private normalizeMentionInput;
|
|
194
|
+
private normalizeOptionalMemoryScope;
|
|
195
|
+
private normalizeOptionalMemorySystem;
|
|
196
|
+
private normalizeOptionalMemoryType;
|
|
197
|
+
private normalizeOptionalMemorySegment;
|
|
198
|
+
private normalizeOptionalMemoryStatus;
|
|
199
|
+
private normalizeOptionalStoreMemoryScope;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
declare class ContactToolsImpl implements ContactTools {
|
|
203
|
+
private readonly rest;
|
|
204
|
+
constructor(rest: ContactRestApi);
|
|
205
|
+
listContacts(request?: ListContactsArgs): Promise<PaginatedList<ContactRecord>>;
|
|
206
|
+
addContact(request: AddContactArgs): Promise<ToolOperationResult>;
|
|
207
|
+
removeContact(request: RemoveContactArgs): Promise<ToolOperationResult>;
|
|
208
|
+
listContactRequests(request?: ListContactRequestsArgs): Promise<ContactRequestsResult>;
|
|
209
|
+
respondContactRequest(request: RespondContactRequestArgs): Promise<ToolOperationResult>;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare const CHAT_EVENT_TYPES: readonly ["tool_call", "tool_result", "thought", "error", "task"];
|
|
213
|
+
type ChatEventType = (typeof CHAT_EVENT_TYPES)[number];
|
|
214
|
+
declare const CHAT_MESSAGE_TYPES: readonly ["text", "tool_call", "tool_result", "thought", "error", "task"];
|
|
215
|
+
type ChatMessageType = (typeof CHAT_MESSAGE_TYPES)[number];
|
|
216
|
+
declare function isChatEventType(value: string): value is ChatEventType;
|
|
217
|
+
declare function assertChatEventType(value: string): asserts value is ChatEventType;
|
|
218
|
+
|
|
219
|
+
declare function replaceUuidMentions(content: string, participants: Array<Record<string, unknown>>): string;
|
|
220
|
+
declare function formatMessageForLlm(message: Record<string, unknown>, participants?: Array<Record<string, unknown>>): ToolModelMessage;
|
|
221
|
+
declare function formatHistoryForLlm(messages: Array<Record<string, unknown>>, options?: {
|
|
222
|
+
excludeId?: string;
|
|
223
|
+
participants?: Array<Record<string, unknown>>;
|
|
224
|
+
}): ToolModelMessage[];
|
|
225
|
+
declare function buildParticipantsMessage(participants: Array<Record<string, unknown>>): string;
|
|
226
|
+
|
|
227
|
+
declare const BASE_INSTRUCTIONS = "\n## Environment\n\nMulti-participant chat. Messages show sender: [Name]: content.\nMessages prefixed with [System]: are platform updates (participant changes, contact updates, etc.) \u2014 not messages from users.\nUse `thenvoi_send_message(content, mentions)` to respond. Plain text output is not delivered.\nMentions use handles: @<username> for users, @<username>/<agent-name> for agents.\n\n## CRITICAL: Delegate When You Cannot Help Directly\n\nYou have NO internet access and NO real-time data. When asked about weather, news, stock prices,\nor any current information you cannot answer directly:\n\n1. Call `thenvoi_lookup_peers()` to find available specialized agents\n2. If a relevant agent exists, call `thenvoi_add_participant(name)` to add them\n3. Ask that agent using `thenvoi_send_message(question, mentions=[agent_handle])`\n4. Wait for their response and relay it back to the user\n\nNEVER say \"I can't do that\" without first checking if another agent can help via `thenvoi_lookup_peers()`.\n\n## CRITICAL: Do NOT Remove Agents Automatically\n\nAfter adding an agent to help with a task:\n1. Ask your question and wait for their response\n2. Relay their response back to the original requester\n3. **Do NOT remove the agent** - they stay silent unless mentioned and may be useful for follow-ups\n\nOnly remove agents if the user explicitly requests it.\n\n## CRITICAL: Always Relay Information Back to the Requester\n\nWhen someone asks you to get information from another agent:\n1. Ask the other agent for the information\n2. When you receive the response, IMMEDIATELY relay it back to the ORIGINAL REQUESTER\n3. Do NOT just thank the helper agent - the requester is waiting for their answer!\n\n## IMPORTANT: Always Share Your Thinking\n\nYou MUST call `thenvoi_send_event(content, message_type=\"thought\")` BEFORE every action.\nThis is required so users can see your reasoning process.\n\n## Examples\n\n### Simple question - answer directly\n[John Doe]: What's 2+2?\n-> thenvoi_send_event(\"Simple arithmetic, answering directly.\", message_type=\"thought\")\n-> thenvoi_send_message(\"4\", mentions=[\"@john\"])\n\n### User asks about weather (you cannot answer directly)\n[John Doe]: What's the weather in Tokyo?\n-> thenvoi_send_event(\"I can't check weather directly. Looking for a Weather Agent.\", message_type=\"thought\")\n-> thenvoi_lookup_peers()\n-> thenvoi_send_event(\"Found Weather Agent. Adding to room.\", message_type=\"thought\")\n-> thenvoi_add_participant(\"Weather Agent\")\n-> thenvoi_send_message(\"What's the weather in Tokyo?\", mentions=[\"@john/weather-agent\"])\n\n[Weather Agent]: Tokyo is 15\u00B0C and cloudy.\n-> thenvoi_send_event(\"Got weather response. Relaying back to John Doe.\", message_type=\"thought\")\n-> thenvoi_send_message(\"The weather in Tokyo is 15\u00B0C and cloudy.\", mentions=[\"@john\"])\n\n### No suitable agent available\n[John Doe]: What's the stock price of AAPL?\n-> thenvoi_send_event(\"I can't check stock prices. Looking for a Stock Agent.\", message_type=\"thought\")\n-> thenvoi_lookup_peers()\n-> thenvoi_send_event(\"No stock agent available. Must inform user.\", message_type=\"thought\")\n-> thenvoi_send_message(\"I don't have access to stock prices, and there's no specialized agent available to help with that.\", mentions=[\"@john\"])\n\n### Follow-up question in same conversation\n[John Doe]: What about London?\n-> thenvoi_send_event(\"Follow-up weather question. Asking Weather Agent.\", message_type=\"thought\")\n-> thenvoi_send_message(\"What's the weather in London?\", mentions=[\"@john/weather-agent\"])\n\n[Weather Agent]: London is 8\u00B0C and rainy.\n-> thenvoi_send_event(\"Got London weather. Relaying to John Doe.\", message_type=\"thought\")\n-> thenvoi_send_message(\"London is 8\u00B0C and rainy.\", mentions=[\"@john\"])\n";
|
|
228
|
+
declare const TEMPLATES: Record<string, string>;
|
|
229
|
+
interface RenderSystemPromptOptions {
|
|
230
|
+
agentName?: string;
|
|
231
|
+
agentDescription?: string;
|
|
232
|
+
customSection?: string;
|
|
233
|
+
template?: string;
|
|
234
|
+
includeBaseInstructions?: boolean;
|
|
235
|
+
}
|
|
236
|
+
declare function renderSystemPrompt(options?: RenderSystemPromptOptions): string;
|
|
237
|
+
|
|
238
|
+
declare class ParticipantTracker {
|
|
239
|
+
private participantsList;
|
|
240
|
+
private lastSent;
|
|
241
|
+
private loaded;
|
|
242
|
+
get participants(): Array<Record<string, unknown>>;
|
|
243
|
+
get isLoaded(): boolean;
|
|
244
|
+
setLoaded(participants: Array<Record<string, unknown>>): void;
|
|
245
|
+
add(participant: Record<string, unknown>): boolean;
|
|
246
|
+
remove(participantId: string): boolean;
|
|
247
|
+
changed(): boolean;
|
|
248
|
+
markSent(): void;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
interface StoppableAgent {
|
|
252
|
+
stop(timeoutMs?: number | null): Promise<boolean>;
|
|
253
|
+
run(options?: {
|
|
254
|
+
shutdownTimeoutMs?: number | null;
|
|
255
|
+
signals?: boolean;
|
|
256
|
+
}): Promise<void>;
|
|
257
|
+
}
|
|
258
|
+
interface GracefulShutdownOptions {
|
|
259
|
+
timeoutMs?: number | null;
|
|
260
|
+
onSignal?: (signal: NodeJS.Signals) => void;
|
|
261
|
+
}
|
|
262
|
+
declare class GracefulShutdown {
|
|
263
|
+
private readonly agent;
|
|
264
|
+
private readonly timeoutMs;
|
|
265
|
+
private readonly onSignal?;
|
|
266
|
+
private readonly handlers;
|
|
267
|
+
private shuttingDown;
|
|
268
|
+
constructor(agent: StoppableAgent, options?: GracefulShutdownOptions);
|
|
269
|
+
registerSignals(): void;
|
|
270
|
+
unregisterSignals(): void;
|
|
271
|
+
withSignals<T>(fn: () => Promise<T>): Promise<T>;
|
|
272
|
+
private shutdown;
|
|
273
|
+
}
|
|
274
|
+
declare function runWithGracefulShutdown(agent: StoppableAgent, options?: GracefulShutdownOptions): Promise<void>;
|
|
275
|
+
|
|
276
|
+
export { AgentTools, BASE_INSTRUCTIONS, CHAT_EVENT_TYPES, CHAT_MESSAGE_TYPES, type ChatEventType, type ChatMessageType, ContactEventConfig, ContactEventHandler, ContactToolsImpl, Execution, ExecutionContext, type ExecutionHandler, GracefulShutdown, HUB_ROOM_SYSTEM_PROMPT, ParticipantTracker, PlatformMessage, type RenderSystemPromptOptions, RoomPresence, TEMPLATES, assertChatEventType, buildParticipantsMessage, formatHistoryForLlm, formatMessageForLlm, isChatEventType, renderSystemPrompt, replaceUuidMentions, runWithGracefulShutdown };
|