@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
package/dist/testing.cjs
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/testing/index.ts
|
|
21
|
+
var testing_exports = {};
|
|
22
|
+
__export(testing_exports, {
|
|
23
|
+
FakeAgentTools: () => FakeAgentTools,
|
|
24
|
+
StubRestApi: () => StubRestApi
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(testing_exports);
|
|
27
|
+
|
|
28
|
+
// src/contracts/protocols.ts
|
|
29
|
+
var DEFAULT_AGENT_TOOLS_CAPABILITIES = {
|
|
30
|
+
peers: true,
|
|
31
|
+
contacts: true,
|
|
32
|
+
memory: true
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/testing/FakeAgentTools.ts
|
|
36
|
+
var FakeAgentTools = class {
|
|
37
|
+
capabilities = {
|
|
38
|
+
...DEFAULT_AGENT_TOOLS_CAPABILITIES,
|
|
39
|
+
peers: true,
|
|
40
|
+
contacts: true,
|
|
41
|
+
memory: true
|
|
42
|
+
};
|
|
43
|
+
messagesSent = [];
|
|
44
|
+
eventsSent = [];
|
|
45
|
+
participantsAdded = [];
|
|
46
|
+
participantsRemoved = [];
|
|
47
|
+
toolCalls = [];
|
|
48
|
+
messageCounter = 0;
|
|
49
|
+
eventCounter = 0;
|
|
50
|
+
failOn;
|
|
51
|
+
errorFactory;
|
|
52
|
+
constructor(options) {
|
|
53
|
+
this.failOn = new Set(options?.failOn ?? []);
|
|
54
|
+
this.errorFactory = options?.errorFactory ?? ((method) => new Error(`FakeAgentTools configured failure for ${String(method)}`));
|
|
55
|
+
}
|
|
56
|
+
async sendMessage(content, mentions) {
|
|
57
|
+
this.maybeFail("sendMessage");
|
|
58
|
+
this.messagesSent.push({ content, mentions });
|
|
59
|
+
const id = `msg-${this.messageCounter++}`;
|
|
60
|
+
return { id, status: "sent" };
|
|
61
|
+
}
|
|
62
|
+
async sendEvent(content, messageType, metadata) {
|
|
63
|
+
this.maybeFail("sendEvent");
|
|
64
|
+
this.eventsSent.push({ content, messageType, metadata });
|
|
65
|
+
const id = `evt-${this.eventCounter++}`;
|
|
66
|
+
return { id, status: "sent" };
|
|
67
|
+
}
|
|
68
|
+
async addParticipant(name, role) {
|
|
69
|
+
this.maybeFail("addParticipant");
|
|
70
|
+
this.participantsAdded.push({ name, role });
|
|
71
|
+
return { status: "ok" };
|
|
72
|
+
}
|
|
73
|
+
async removeParticipant(name) {
|
|
74
|
+
this.maybeFail("removeParticipant");
|
|
75
|
+
this.participantsRemoved.push(name);
|
|
76
|
+
return { status: "ok" };
|
|
77
|
+
}
|
|
78
|
+
async getParticipants() {
|
|
79
|
+
this.maybeFail("getParticipants");
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
async createChatroom(_taskId) {
|
|
83
|
+
this.maybeFail("createChatroom");
|
|
84
|
+
return `room-${Date.now()}`;
|
|
85
|
+
}
|
|
86
|
+
async lookupPeers(_page, _pageSize) {
|
|
87
|
+
this.maybeFail("lookupPeers");
|
|
88
|
+
return { data: [] };
|
|
89
|
+
}
|
|
90
|
+
getToolSchemas(_format, _options) {
|
|
91
|
+
this.maybeFail("getToolSchemas");
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
getAnthropicToolSchemas(_options) {
|
|
95
|
+
this.maybeFail("getAnthropicToolSchemas");
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
getOpenAIToolSchemas(_options) {
|
|
99
|
+
this.maybeFail("getOpenAIToolSchemas");
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
async executeToolCall(toolName, arguments_) {
|
|
103
|
+
this.maybeFail("executeToolCall");
|
|
104
|
+
this.toolCalls.push({ toolName, arguments: arguments_ });
|
|
105
|
+
return { status: "ok" };
|
|
106
|
+
}
|
|
107
|
+
// Contact stubs
|
|
108
|
+
async listContacts(_request) {
|
|
109
|
+
this.maybeFail("listContacts");
|
|
110
|
+
return { data: [] };
|
|
111
|
+
}
|
|
112
|
+
async addContact(_request) {
|
|
113
|
+
this.maybeFail("addContact");
|
|
114
|
+
return { status: "ok" };
|
|
115
|
+
}
|
|
116
|
+
async removeContact(_request) {
|
|
117
|
+
this.maybeFail("removeContact");
|
|
118
|
+
return { status: "ok" };
|
|
119
|
+
}
|
|
120
|
+
async listContactRequests(_request) {
|
|
121
|
+
this.maybeFail("listContactRequests");
|
|
122
|
+
return { received: [], sent: [] };
|
|
123
|
+
}
|
|
124
|
+
async respondContactRequest(_request) {
|
|
125
|
+
this.maybeFail("respondContactRequest");
|
|
126
|
+
return { status: "ok" };
|
|
127
|
+
}
|
|
128
|
+
// Memory stubs
|
|
129
|
+
async listMemories(_args) {
|
|
130
|
+
this.maybeFail("listMemories");
|
|
131
|
+
return { data: [] };
|
|
132
|
+
}
|
|
133
|
+
async storeMemory(args) {
|
|
134
|
+
this.maybeFail("storeMemory");
|
|
135
|
+
return { ...args, id: "mem-0", status: "active" };
|
|
136
|
+
}
|
|
137
|
+
async getMemory(memoryId) {
|
|
138
|
+
this.maybeFail("getMemory");
|
|
139
|
+
return { id: memoryId, status: "active" };
|
|
140
|
+
}
|
|
141
|
+
async supersedeMemory(_memoryId) {
|
|
142
|
+
this.maybeFail("supersedeMemory");
|
|
143
|
+
return { status: "ok" };
|
|
144
|
+
}
|
|
145
|
+
async archiveMemory(_memoryId) {
|
|
146
|
+
this.maybeFail("archiveMemory");
|
|
147
|
+
return { status: "ok" };
|
|
148
|
+
}
|
|
149
|
+
reset() {
|
|
150
|
+
this.messagesSent.length = 0;
|
|
151
|
+
this.eventsSent.length = 0;
|
|
152
|
+
this.participantsAdded.length = 0;
|
|
153
|
+
this.participantsRemoved.length = 0;
|
|
154
|
+
this.toolCalls.length = 0;
|
|
155
|
+
this.messageCounter = 0;
|
|
156
|
+
this.eventCounter = 0;
|
|
157
|
+
}
|
|
158
|
+
maybeFail(method) {
|
|
159
|
+
if (this.failOn.has(method)) {
|
|
160
|
+
throw this.errorFactory(method);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/testing/StubRestApi.ts
|
|
166
|
+
var StubRestApi = class {
|
|
167
|
+
async getAgentMe() {
|
|
168
|
+
return { id: "stub-agent", name: "Stub Agent", description: null };
|
|
169
|
+
}
|
|
170
|
+
async createChatMessage() {
|
|
171
|
+
return { ok: true };
|
|
172
|
+
}
|
|
173
|
+
async createChatEvent() {
|
|
174
|
+
return { ok: true };
|
|
175
|
+
}
|
|
176
|
+
async createChat() {
|
|
177
|
+
return { id: "stub-room" };
|
|
178
|
+
}
|
|
179
|
+
async listChatParticipants() {
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
async addChatParticipant() {
|
|
183
|
+
return { ok: true };
|
|
184
|
+
}
|
|
185
|
+
async removeChatParticipant() {
|
|
186
|
+
return { ok: true };
|
|
187
|
+
}
|
|
188
|
+
async markMessageProcessing() {
|
|
189
|
+
return { ok: true };
|
|
190
|
+
}
|
|
191
|
+
async markMessageProcessed() {
|
|
192
|
+
return { ok: true };
|
|
193
|
+
}
|
|
194
|
+
async markMessageFailed() {
|
|
195
|
+
return { ok: true };
|
|
196
|
+
}
|
|
197
|
+
async listChats() {
|
|
198
|
+
return {
|
|
199
|
+
data: [],
|
|
200
|
+
metadata: { page: 1, pageSize: 100, totalCount: 0, totalPages: 1 }
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
async listPeers() {
|
|
204
|
+
return {
|
|
205
|
+
data: [],
|
|
206
|
+
metadata: { page: 1, pageSize: 100, totalCount: 0, totalPages: 1 }
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
async getNextMessage() {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
214
|
+
0 && (module.exports = {
|
|
215
|
+
FakeAgentTools,
|
|
216
|
+
StubRestApi
|
|
217
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { A as AdapterToolsProtocol, d as PeerLookupTools, C as ContactTools, M as MemoryTools, h as AgentToolsCapabilities } from './protocols-CInhtFpA.cjs';
|
|
2
|
+
import { a as MentionInput, M as MetadataMap, T as ToolOperationResult, P as ParticipantRecord, 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 } from './dtos-DUpbIu8k.cjs';
|
|
3
|
+
import { R as RestApi } from './types-CSHFipIc.cjs';
|
|
4
|
+
|
|
5
|
+
interface CapturedMessage {
|
|
6
|
+
content: string;
|
|
7
|
+
mentions?: MentionInput;
|
|
8
|
+
}
|
|
9
|
+
interface CapturedEvent {
|
|
10
|
+
content: string;
|
|
11
|
+
messageType: string;
|
|
12
|
+
metadata?: MetadataMap;
|
|
13
|
+
}
|
|
14
|
+
interface CapturedParticipant {
|
|
15
|
+
name: string;
|
|
16
|
+
role?: string;
|
|
17
|
+
}
|
|
18
|
+
interface CapturedToolCall {
|
|
19
|
+
toolName: string;
|
|
20
|
+
arguments: MetadataMap;
|
|
21
|
+
}
|
|
22
|
+
type FakeToolMethod = keyof AdapterToolsProtocol;
|
|
23
|
+
interface FakeAgentToolsOptions {
|
|
24
|
+
failOn?: Iterable<FakeToolMethod>;
|
|
25
|
+
errorFactory?: (method: FakeToolMethod) => Error;
|
|
26
|
+
}
|
|
27
|
+
declare class FakeAgentTools implements AdapterToolsProtocol, PeerLookupTools, ContactTools, MemoryTools {
|
|
28
|
+
readonly capabilities: Readonly<AgentToolsCapabilities>;
|
|
29
|
+
messagesSent: CapturedMessage[];
|
|
30
|
+
eventsSent: CapturedEvent[];
|
|
31
|
+
participantsAdded: CapturedParticipant[];
|
|
32
|
+
participantsRemoved: string[];
|
|
33
|
+
toolCalls: CapturedToolCall[];
|
|
34
|
+
private messageCounter;
|
|
35
|
+
private eventCounter;
|
|
36
|
+
private readonly failOn;
|
|
37
|
+
private readonly errorFactory;
|
|
38
|
+
constructor(options?: FakeAgentToolsOptions);
|
|
39
|
+
sendMessage(content: string, mentions?: MentionInput): Promise<ToolOperationResult>;
|
|
40
|
+
sendEvent(content: string, messageType: string, metadata?: MetadataMap): Promise<ToolOperationResult>;
|
|
41
|
+
addParticipant(name: string, role?: string): Promise<ToolOperationResult>;
|
|
42
|
+
removeParticipant(name: string): Promise<ToolOperationResult>;
|
|
43
|
+
getParticipants(): Promise<ParticipantRecord[]>;
|
|
44
|
+
createChatroom(_taskId?: string): Promise<string>;
|
|
45
|
+
lookupPeers(_page?: number, _pageSize?: number): Promise<PaginatedList<PeerRecord>>;
|
|
46
|
+
getToolSchemas(_format: "openai" | "anthropic", _options?: {
|
|
47
|
+
includeMemory?: boolean;
|
|
48
|
+
}): ToolSchemaRecord[];
|
|
49
|
+
getAnthropicToolSchemas(_options?: {
|
|
50
|
+
includeMemory?: boolean;
|
|
51
|
+
}): ToolSchemaRecord[];
|
|
52
|
+
getOpenAIToolSchemas(_options?: {
|
|
53
|
+
includeMemory?: boolean;
|
|
54
|
+
}): ToolSchemaRecord[];
|
|
55
|
+
executeToolCall(toolName: string, arguments_: MetadataMap): Promise<unknown>;
|
|
56
|
+
listContacts(_request?: ListContactsArgs): Promise<PaginatedList<ContactRecord>>;
|
|
57
|
+
addContact(_request: AddContactArgs): Promise<ToolOperationResult>;
|
|
58
|
+
removeContact(_request: RemoveContactArgs): Promise<ToolOperationResult>;
|
|
59
|
+
listContactRequests(_request?: ListContactRequestsArgs): Promise<ContactRequestsResult>;
|
|
60
|
+
respondContactRequest(_request: RespondContactRequestArgs): Promise<ToolOperationResult>;
|
|
61
|
+
listMemories(_args?: ListMemoriesArgs): Promise<PaginatedList<MemoryRecord>>;
|
|
62
|
+
storeMemory(args: StoreMemoryArgs): Promise<MemoryRecord>;
|
|
63
|
+
getMemory(memoryId: string): Promise<MemoryRecord>;
|
|
64
|
+
supersedeMemory(_memoryId: string): Promise<ToolOperationResult>;
|
|
65
|
+
archiveMemory(_memoryId: string): Promise<ToolOperationResult>;
|
|
66
|
+
reset(): void;
|
|
67
|
+
private maybeFail;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* No-op REST API implementation for local development and examples.
|
|
72
|
+
* Returns sensible defaults for all methods without making real API calls.
|
|
73
|
+
*/
|
|
74
|
+
declare class StubRestApi implements RestApi {
|
|
75
|
+
getAgentMe(): Promise<{
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
description: null;
|
|
79
|
+
}>;
|
|
80
|
+
createChatMessage(): Promise<{
|
|
81
|
+
ok: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
createChatEvent(): Promise<{
|
|
84
|
+
ok: boolean;
|
|
85
|
+
}>;
|
|
86
|
+
createChat(): Promise<{
|
|
87
|
+
id: string;
|
|
88
|
+
}>;
|
|
89
|
+
listChatParticipants(): Promise<never[]>;
|
|
90
|
+
addChatParticipant(): Promise<{
|
|
91
|
+
ok: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
removeChatParticipant(): Promise<{
|
|
94
|
+
ok: boolean;
|
|
95
|
+
}>;
|
|
96
|
+
markMessageProcessing(): Promise<{
|
|
97
|
+
ok: boolean;
|
|
98
|
+
}>;
|
|
99
|
+
markMessageProcessed(): Promise<{
|
|
100
|
+
ok: boolean;
|
|
101
|
+
}>;
|
|
102
|
+
markMessageFailed(): Promise<{
|
|
103
|
+
ok: boolean;
|
|
104
|
+
}>;
|
|
105
|
+
listChats(): Promise<{
|
|
106
|
+
data: never[];
|
|
107
|
+
metadata: {
|
|
108
|
+
page: number;
|
|
109
|
+
pageSize: number;
|
|
110
|
+
totalCount: number;
|
|
111
|
+
totalPages: number;
|
|
112
|
+
};
|
|
113
|
+
}>;
|
|
114
|
+
listPeers(): Promise<{
|
|
115
|
+
data: never[];
|
|
116
|
+
metadata: {
|
|
117
|
+
page: number;
|
|
118
|
+
pageSize: number;
|
|
119
|
+
totalCount: number;
|
|
120
|
+
totalPages: number;
|
|
121
|
+
};
|
|
122
|
+
}>;
|
|
123
|
+
getNextMessage(): Promise<null>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { FakeAgentTools, type FakeAgentToolsOptions, StubRestApi };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { A as AdapterToolsProtocol, d as PeerLookupTools, C as ContactTools, M as MemoryTools, h as AgentToolsCapabilities } from './protocols-DrhzOH6K.js';
|
|
2
|
+
import { a as MentionInput, M as MetadataMap, T as ToolOperationResult, P as ParticipantRecord, 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 } from './dtos-DUpbIu8k.js';
|
|
3
|
+
import { R as RestApi } from './types-CxII3XkA.js';
|
|
4
|
+
|
|
5
|
+
interface CapturedMessage {
|
|
6
|
+
content: string;
|
|
7
|
+
mentions?: MentionInput;
|
|
8
|
+
}
|
|
9
|
+
interface CapturedEvent {
|
|
10
|
+
content: string;
|
|
11
|
+
messageType: string;
|
|
12
|
+
metadata?: MetadataMap;
|
|
13
|
+
}
|
|
14
|
+
interface CapturedParticipant {
|
|
15
|
+
name: string;
|
|
16
|
+
role?: string;
|
|
17
|
+
}
|
|
18
|
+
interface CapturedToolCall {
|
|
19
|
+
toolName: string;
|
|
20
|
+
arguments: MetadataMap;
|
|
21
|
+
}
|
|
22
|
+
type FakeToolMethod = keyof AdapterToolsProtocol;
|
|
23
|
+
interface FakeAgentToolsOptions {
|
|
24
|
+
failOn?: Iterable<FakeToolMethod>;
|
|
25
|
+
errorFactory?: (method: FakeToolMethod) => Error;
|
|
26
|
+
}
|
|
27
|
+
declare class FakeAgentTools implements AdapterToolsProtocol, PeerLookupTools, ContactTools, MemoryTools {
|
|
28
|
+
readonly capabilities: Readonly<AgentToolsCapabilities>;
|
|
29
|
+
messagesSent: CapturedMessage[];
|
|
30
|
+
eventsSent: CapturedEvent[];
|
|
31
|
+
participantsAdded: CapturedParticipant[];
|
|
32
|
+
participantsRemoved: string[];
|
|
33
|
+
toolCalls: CapturedToolCall[];
|
|
34
|
+
private messageCounter;
|
|
35
|
+
private eventCounter;
|
|
36
|
+
private readonly failOn;
|
|
37
|
+
private readonly errorFactory;
|
|
38
|
+
constructor(options?: FakeAgentToolsOptions);
|
|
39
|
+
sendMessage(content: string, mentions?: MentionInput): Promise<ToolOperationResult>;
|
|
40
|
+
sendEvent(content: string, messageType: string, metadata?: MetadataMap): Promise<ToolOperationResult>;
|
|
41
|
+
addParticipant(name: string, role?: string): Promise<ToolOperationResult>;
|
|
42
|
+
removeParticipant(name: string): Promise<ToolOperationResult>;
|
|
43
|
+
getParticipants(): Promise<ParticipantRecord[]>;
|
|
44
|
+
createChatroom(_taskId?: string): Promise<string>;
|
|
45
|
+
lookupPeers(_page?: number, _pageSize?: number): Promise<PaginatedList<PeerRecord>>;
|
|
46
|
+
getToolSchemas(_format: "openai" | "anthropic", _options?: {
|
|
47
|
+
includeMemory?: boolean;
|
|
48
|
+
}): ToolSchemaRecord[];
|
|
49
|
+
getAnthropicToolSchemas(_options?: {
|
|
50
|
+
includeMemory?: boolean;
|
|
51
|
+
}): ToolSchemaRecord[];
|
|
52
|
+
getOpenAIToolSchemas(_options?: {
|
|
53
|
+
includeMemory?: boolean;
|
|
54
|
+
}): ToolSchemaRecord[];
|
|
55
|
+
executeToolCall(toolName: string, arguments_: MetadataMap): Promise<unknown>;
|
|
56
|
+
listContacts(_request?: ListContactsArgs): Promise<PaginatedList<ContactRecord>>;
|
|
57
|
+
addContact(_request: AddContactArgs): Promise<ToolOperationResult>;
|
|
58
|
+
removeContact(_request: RemoveContactArgs): Promise<ToolOperationResult>;
|
|
59
|
+
listContactRequests(_request?: ListContactRequestsArgs): Promise<ContactRequestsResult>;
|
|
60
|
+
respondContactRequest(_request: RespondContactRequestArgs): Promise<ToolOperationResult>;
|
|
61
|
+
listMemories(_args?: ListMemoriesArgs): Promise<PaginatedList<MemoryRecord>>;
|
|
62
|
+
storeMemory(args: StoreMemoryArgs): Promise<MemoryRecord>;
|
|
63
|
+
getMemory(memoryId: string): Promise<MemoryRecord>;
|
|
64
|
+
supersedeMemory(_memoryId: string): Promise<ToolOperationResult>;
|
|
65
|
+
archiveMemory(_memoryId: string): Promise<ToolOperationResult>;
|
|
66
|
+
reset(): void;
|
|
67
|
+
private maybeFail;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* No-op REST API implementation for local development and examples.
|
|
72
|
+
* Returns sensible defaults for all methods without making real API calls.
|
|
73
|
+
*/
|
|
74
|
+
declare class StubRestApi implements RestApi {
|
|
75
|
+
getAgentMe(): Promise<{
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
description: null;
|
|
79
|
+
}>;
|
|
80
|
+
createChatMessage(): Promise<{
|
|
81
|
+
ok: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
createChatEvent(): Promise<{
|
|
84
|
+
ok: boolean;
|
|
85
|
+
}>;
|
|
86
|
+
createChat(): Promise<{
|
|
87
|
+
id: string;
|
|
88
|
+
}>;
|
|
89
|
+
listChatParticipants(): Promise<never[]>;
|
|
90
|
+
addChatParticipant(): Promise<{
|
|
91
|
+
ok: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
removeChatParticipant(): Promise<{
|
|
94
|
+
ok: boolean;
|
|
95
|
+
}>;
|
|
96
|
+
markMessageProcessing(): Promise<{
|
|
97
|
+
ok: boolean;
|
|
98
|
+
}>;
|
|
99
|
+
markMessageProcessed(): Promise<{
|
|
100
|
+
ok: boolean;
|
|
101
|
+
}>;
|
|
102
|
+
markMessageFailed(): Promise<{
|
|
103
|
+
ok: boolean;
|
|
104
|
+
}>;
|
|
105
|
+
listChats(): Promise<{
|
|
106
|
+
data: never[];
|
|
107
|
+
metadata: {
|
|
108
|
+
page: number;
|
|
109
|
+
pageSize: number;
|
|
110
|
+
totalCount: number;
|
|
111
|
+
totalPages: number;
|
|
112
|
+
};
|
|
113
|
+
}>;
|
|
114
|
+
listPeers(): Promise<{
|
|
115
|
+
data: never[];
|
|
116
|
+
metadata: {
|
|
117
|
+
page: number;
|
|
118
|
+
pageSize: number;
|
|
119
|
+
totalCount: number;
|
|
120
|
+
totalPages: number;
|
|
121
|
+
};
|
|
122
|
+
}>;
|
|
123
|
+
getNextMessage(): Promise<null>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { FakeAgentTools, type FakeAgentToolsOptions, StubRestApi };
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_AGENT_TOOLS_CAPABILITIES
|
|
3
|
+
} from "./chunk-3BKAC4OZ.js";
|
|
4
|
+
|
|
5
|
+
// src/testing/FakeAgentTools.ts
|
|
6
|
+
var FakeAgentTools = class {
|
|
7
|
+
capabilities = {
|
|
8
|
+
...DEFAULT_AGENT_TOOLS_CAPABILITIES,
|
|
9
|
+
peers: true,
|
|
10
|
+
contacts: true,
|
|
11
|
+
memory: true
|
|
12
|
+
};
|
|
13
|
+
messagesSent = [];
|
|
14
|
+
eventsSent = [];
|
|
15
|
+
participantsAdded = [];
|
|
16
|
+
participantsRemoved = [];
|
|
17
|
+
toolCalls = [];
|
|
18
|
+
messageCounter = 0;
|
|
19
|
+
eventCounter = 0;
|
|
20
|
+
failOn;
|
|
21
|
+
errorFactory;
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.failOn = new Set(options?.failOn ?? []);
|
|
24
|
+
this.errorFactory = options?.errorFactory ?? ((method) => new Error(`FakeAgentTools configured failure for ${String(method)}`));
|
|
25
|
+
}
|
|
26
|
+
async sendMessage(content, mentions) {
|
|
27
|
+
this.maybeFail("sendMessage");
|
|
28
|
+
this.messagesSent.push({ content, mentions });
|
|
29
|
+
const id = `msg-${this.messageCounter++}`;
|
|
30
|
+
return { id, status: "sent" };
|
|
31
|
+
}
|
|
32
|
+
async sendEvent(content, messageType, metadata) {
|
|
33
|
+
this.maybeFail("sendEvent");
|
|
34
|
+
this.eventsSent.push({ content, messageType, metadata });
|
|
35
|
+
const id = `evt-${this.eventCounter++}`;
|
|
36
|
+
return { id, status: "sent" };
|
|
37
|
+
}
|
|
38
|
+
async addParticipant(name, role) {
|
|
39
|
+
this.maybeFail("addParticipant");
|
|
40
|
+
this.participantsAdded.push({ name, role });
|
|
41
|
+
return { status: "ok" };
|
|
42
|
+
}
|
|
43
|
+
async removeParticipant(name) {
|
|
44
|
+
this.maybeFail("removeParticipant");
|
|
45
|
+
this.participantsRemoved.push(name);
|
|
46
|
+
return { status: "ok" };
|
|
47
|
+
}
|
|
48
|
+
async getParticipants() {
|
|
49
|
+
this.maybeFail("getParticipants");
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
async createChatroom(_taskId) {
|
|
53
|
+
this.maybeFail("createChatroom");
|
|
54
|
+
return `room-${Date.now()}`;
|
|
55
|
+
}
|
|
56
|
+
async lookupPeers(_page, _pageSize) {
|
|
57
|
+
this.maybeFail("lookupPeers");
|
|
58
|
+
return { data: [] };
|
|
59
|
+
}
|
|
60
|
+
getToolSchemas(_format, _options) {
|
|
61
|
+
this.maybeFail("getToolSchemas");
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
getAnthropicToolSchemas(_options) {
|
|
65
|
+
this.maybeFail("getAnthropicToolSchemas");
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
getOpenAIToolSchemas(_options) {
|
|
69
|
+
this.maybeFail("getOpenAIToolSchemas");
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
async executeToolCall(toolName, arguments_) {
|
|
73
|
+
this.maybeFail("executeToolCall");
|
|
74
|
+
this.toolCalls.push({ toolName, arguments: arguments_ });
|
|
75
|
+
return { status: "ok" };
|
|
76
|
+
}
|
|
77
|
+
// Contact stubs
|
|
78
|
+
async listContacts(_request) {
|
|
79
|
+
this.maybeFail("listContacts");
|
|
80
|
+
return { data: [] };
|
|
81
|
+
}
|
|
82
|
+
async addContact(_request) {
|
|
83
|
+
this.maybeFail("addContact");
|
|
84
|
+
return { status: "ok" };
|
|
85
|
+
}
|
|
86
|
+
async removeContact(_request) {
|
|
87
|
+
this.maybeFail("removeContact");
|
|
88
|
+
return { status: "ok" };
|
|
89
|
+
}
|
|
90
|
+
async listContactRequests(_request) {
|
|
91
|
+
this.maybeFail("listContactRequests");
|
|
92
|
+
return { received: [], sent: [] };
|
|
93
|
+
}
|
|
94
|
+
async respondContactRequest(_request) {
|
|
95
|
+
this.maybeFail("respondContactRequest");
|
|
96
|
+
return { status: "ok" };
|
|
97
|
+
}
|
|
98
|
+
// Memory stubs
|
|
99
|
+
async listMemories(_args) {
|
|
100
|
+
this.maybeFail("listMemories");
|
|
101
|
+
return { data: [] };
|
|
102
|
+
}
|
|
103
|
+
async storeMemory(args) {
|
|
104
|
+
this.maybeFail("storeMemory");
|
|
105
|
+
return { ...args, id: "mem-0", status: "active" };
|
|
106
|
+
}
|
|
107
|
+
async getMemory(memoryId) {
|
|
108
|
+
this.maybeFail("getMemory");
|
|
109
|
+
return { id: memoryId, status: "active" };
|
|
110
|
+
}
|
|
111
|
+
async supersedeMemory(_memoryId) {
|
|
112
|
+
this.maybeFail("supersedeMemory");
|
|
113
|
+
return { status: "ok" };
|
|
114
|
+
}
|
|
115
|
+
async archiveMemory(_memoryId) {
|
|
116
|
+
this.maybeFail("archiveMemory");
|
|
117
|
+
return { status: "ok" };
|
|
118
|
+
}
|
|
119
|
+
reset() {
|
|
120
|
+
this.messagesSent.length = 0;
|
|
121
|
+
this.eventsSent.length = 0;
|
|
122
|
+
this.participantsAdded.length = 0;
|
|
123
|
+
this.participantsRemoved.length = 0;
|
|
124
|
+
this.toolCalls.length = 0;
|
|
125
|
+
this.messageCounter = 0;
|
|
126
|
+
this.eventCounter = 0;
|
|
127
|
+
}
|
|
128
|
+
maybeFail(method) {
|
|
129
|
+
if (this.failOn.has(method)) {
|
|
130
|
+
throw this.errorFactory(method);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/testing/StubRestApi.ts
|
|
136
|
+
var StubRestApi = class {
|
|
137
|
+
async getAgentMe() {
|
|
138
|
+
return { id: "stub-agent", name: "Stub Agent", description: null };
|
|
139
|
+
}
|
|
140
|
+
async createChatMessage() {
|
|
141
|
+
return { ok: true };
|
|
142
|
+
}
|
|
143
|
+
async createChatEvent() {
|
|
144
|
+
return { ok: true };
|
|
145
|
+
}
|
|
146
|
+
async createChat() {
|
|
147
|
+
return { id: "stub-room" };
|
|
148
|
+
}
|
|
149
|
+
async listChatParticipants() {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
async addChatParticipant() {
|
|
153
|
+
return { ok: true };
|
|
154
|
+
}
|
|
155
|
+
async removeChatParticipant() {
|
|
156
|
+
return { ok: true };
|
|
157
|
+
}
|
|
158
|
+
async markMessageProcessing() {
|
|
159
|
+
return { ok: true };
|
|
160
|
+
}
|
|
161
|
+
async markMessageProcessed() {
|
|
162
|
+
return { ok: true };
|
|
163
|
+
}
|
|
164
|
+
async markMessageFailed() {
|
|
165
|
+
return { ok: true };
|
|
166
|
+
}
|
|
167
|
+
async listChats() {
|
|
168
|
+
return {
|
|
169
|
+
data: [],
|
|
170
|
+
metadata: { page: 1, pageSize: 100, totalCount: 0, totalPages: 1 }
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
async listPeers() {
|
|
174
|
+
return {
|
|
175
|
+
data: [],
|
|
176
|
+
metadata: { page: 1, pageSize: 100, totalCount: 0, totalPages: 1 }
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
async getNextMessage() {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
export {
|
|
184
|
+
FakeAgentTools,
|
|
185
|
+
StubRestApi
|
|
186
|
+
};
|