@band-ai/sdk 0.1.10 → 0.2.0
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/README.md +54 -54
- package/dist/{ClaudeSDKAdapter-DfjaI5ke.d.cts → ClaudeSDKAdapter-BY4zEbCl.d.cts} +12 -10
- package/dist/{ClaudeSDKAdapter-DonPGJ43.d.ts → ClaudeSDKAdapter-Cna5P1dR.d.ts} +12 -10
- package/dist/{acp-server-NZAeg-WO.d.ts → acp-server-CiUqN3G3.d.ts} +2 -2
- package/dist/{acp-server-CUBXIiG6.d.cts → acp-server-Dlj7D563.d.cts} +2 -2
- package/dist/adapters.cjs +250 -183
- package/dist/adapters.d.cts +21 -19
- package/dist/adapters.d.ts +21 -19
- package/dist/adapters.js +65 -44
- package/dist/backends-D-dBdDm-.d.ts +27 -0
- package/dist/backends-ZLxmQrTZ.d.cts +27 -0
- package/dist/{chunk-2BHHR6YW.js → chunk-4IAXZBXX.js} +62 -23
- package/dist/{chunk-SG4WLD2H.js → chunk-EAI2M3WM.js} +38 -94
- package/dist/{chunk-YR3BOQNW.js → chunk-JY75VSQK.js} +7 -7
- package/dist/{chunk-RDM4TE4B.js → chunk-LBWKISBS.js} +19 -1
- package/dist/{chunk-FP237EAG.js → chunk-N2QTUMGO.js} +112 -195
- package/dist/{chunk-J3M3PFFY.js → chunk-NMZLX7TP.js} +35 -31
- package/dist/{chunk-6RXWL6TC.js → chunk-NT7TBFX2.js} +1 -1
- package/dist/{chunk-MLROFDKR.js → chunk-RV76SKFT.js} +39 -33
- package/dist/{chunk-XA4N2JPH.js → chunk-TLBCKDQO.js} +23 -23
- package/dist/{chunk-IZPV6QS6.js → chunk-WL2HNJZ6.js} +38 -11
- package/dist/{chunk-DNPVCR3S.js → chunk-WLCM2OXG.js} +31 -31
- package/dist/config.cjs +40 -13
- package/dist/config.d.cts +7 -1
- package/dist/config.d.ts +7 -1
- package/dist/config.js +2 -2
- package/dist/converters.cjs +61 -61
- package/dist/converters.d.cts +5 -5
- package/dist/converters.d.ts +5 -5
- package/dist/converters.js +4 -4
- package/dist/core.cjs +8 -8
- package/dist/core.d.cts +9 -9
- package/dist/core.d.ts +9 -9
- package/dist/core.js +3 -3
- package/dist/{dtos-Dd_fTfLn.d.cts → dtos-B8KU_q4d.d.cts} +2 -2
- package/dist/{dtos-Dd_fTfLn.d.ts → dtos-B8KU_q4d.d.ts} +2 -2
- package/dist/index.cjs +459 -504
- package/dist/index.d.cts +16 -15
- package/dist/index.d.ts +16 -15
- package/dist/index.js +15 -13
- package/dist/linear.cjs +74 -74
- package/dist/linear.d.cts +14 -14
- package/dist/linear.d.ts +14 -14
- package/dist/linear.js +72 -72
- package/dist/mcp-claude.cjs +37 -36
- package/dist/mcp-claude.d.cts +3 -3
- package/dist/mcp-claude.d.ts +3 -3
- package/dist/mcp-claude.js +7 -6
- package/dist/mcp.cjs +103 -62
- package/dist/mcp.d.cts +29 -16
- package/dist/mcp.d.ts +29 -16
- package/dist/mcp.js +14 -14
- package/dist/{opencode--iA5-KYk.d.cts → opencode-2YdscIc1.d.cts} +5 -5
- package/dist/{opencode-YNacv-eJ.d.ts → opencode-Bld62x5t.d.ts} +5 -5
- package/dist/{pagination-BBLsYLhT.d.ts → pagination-BgEx-HeL.d.ts} +2 -2
- package/dist/{pagination-CqidD-L_.d.cts → pagination-DqdkQArT.d.cts} +2 -2
- package/dist/{protocols-BF6jamIl.d.ts → protocols-Bwwcql0h.d.ts} +1 -1
- package/dist/{protocols-D2bTrQ_t.d.cts → protocols-Bz1rxcUg.d.cts} +1 -1
- package/dist/rest.cjs +41 -97
- package/dist/rest.d.cts +7 -7
- package/dist/rest.d.ts +7 -7
- package/dist/rest.js +2 -2
- package/dist/runtime.cjs +293 -464
- package/dist/runtime.d.cts +16 -28
- package/dist/runtime.d.ts +16 -28
- package/dist/runtime.js +12 -63
- package/dist/{schemas-CI0qgcp_.d.cts → schemas-BotL3ZLH.d.cts} +40 -54
- package/dist/{schemas-B1Fd3oUM.d.ts → schemas-DBsC4J1g.d.ts} +40 -54
- package/dist/{sdk-D2rTDU_o.d.cts → sdk-BTciSLRQ.d.cts} +5 -5
- package/dist/{sdk-CyqN1W5g.d.ts → sdk-qKJtMma_.d.ts} +5 -5
- package/dist/{simpleAdapter-qQt-tSz4.d.ts → simpleAdapter--wznuoOw.d.ts} +1 -1
- package/dist/{simpleAdapter-C_f-01Cu.d.cts → simpleAdapter-BpT4XbZC.d.cts} +1 -1
- package/dist/testing.d.cts +3 -3
- package/dist/testing.d.ts +3 -3
- package/dist/{types-DNySTI_8.d.ts → types-BTN_ZETM.d.ts} +2 -2
- package/dist/{types-D3AsUnd0.d.ts → types-BgYFd_Yw.d.cts} +5 -5
- package/dist/{types-DtMms5Fi.d.cts → types-BivGO7I9.d.ts} +5 -5
- package/dist/{types-CKqrhGB1.d.cts → types-D958TC71.d.cts} +2 -2
- package/package.json +6 -5
- package/dist/backends-DYtEhCZG.d.cts +0 -25
- package/dist/backends-oYAb7EU-.d.ts +0 -25
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
buildSingleContextRegistrations,
|
|
4
4
|
buildZodShape,
|
|
5
5
|
resolveSingleRoomTools
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NT7TBFX2.js";
|
|
7
7
|
import {
|
|
8
|
+
MCP_SERVER_NAME,
|
|
8
9
|
mcpToolNames
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RV76SKFT.js";
|
|
10
11
|
|
|
11
12
|
// src/mcp/stdio.ts
|
|
12
|
-
var
|
|
13
|
+
var BandMcpStdioServer = class {
|
|
13
14
|
options;
|
|
14
15
|
registrations;
|
|
15
16
|
mcpServer = null;
|
|
@@ -38,7 +39,7 @@ var ThenvoiMcpStdioServer = class {
|
|
|
38
39
|
const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
39
40
|
const { z } = await import("zod");
|
|
40
41
|
const mcpServer = new McpServer({
|
|
41
|
-
name: this.options.name ??
|
|
42
|
+
name: this.options.name ?? MCP_SERVER_NAME,
|
|
42
43
|
version: "1.0.0"
|
|
43
44
|
});
|
|
44
45
|
registerTools(mcpServer, z, this.registrations);
|
|
@@ -68,13 +69,33 @@ function registerTools(mcpServer, z, registrations) {
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
// src/mcp/auth.ts
|
|
73
|
+
import { randomBytes, timingSafeEqual } from "crypto";
|
|
74
|
+
function generateAuthToken() {
|
|
75
|
+
return randomBytes(32).toString("hex");
|
|
76
|
+
}
|
|
77
|
+
function isAuthorizedRequest(authorizationHeader, authToken) {
|
|
78
|
+
if (!authToken) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
if (!authorizationHeader) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const expected = Buffer.from(`Bearer ${authToken}`);
|
|
85
|
+
const actual = Buffer.from(authorizationHeader);
|
|
86
|
+
if (expected.length !== actual.length) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return timingSafeEqual(expected, actual);
|
|
90
|
+
}
|
|
91
|
+
|
|
71
92
|
// src/mcp/server.ts
|
|
72
93
|
var PORT_RANGE_START = 5e4;
|
|
73
94
|
var PORT_RANGE_END = 6e4;
|
|
74
95
|
var MCP_SERVER_VERSION = "1.0.0";
|
|
75
96
|
var SESSION_IDLE_TTL_MS = 15 * 60 * 1e3;
|
|
76
97
|
var SESSION_SWEEP_INTERVAL_MS = 60 * 1e3;
|
|
77
|
-
var
|
|
98
|
+
var BandMcpServer = class {
|
|
78
99
|
options;
|
|
79
100
|
registrations;
|
|
80
101
|
httpServer = null;
|
|
@@ -118,7 +139,7 @@ var ThenvoiMcpServer = class {
|
|
|
118
139
|
const http = await import("http");
|
|
119
140
|
const { randomUUID } = await import("crypto");
|
|
120
141
|
const { z } = await import("zod");
|
|
121
|
-
const serverName = this.options.name ??
|
|
142
|
+
const serverName = this.options.name ?? MCP_SERVER_NAME;
|
|
122
143
|
const app = express();
|
|
123
144
|
app.use(express.json());
|
|
124
145
|
app.get("/healthz", (_req, res) => {
|
|
@@ -126,6 +147,10 @@ var ThenvoiMcpServer = class {
|
|
|
126
147
|
});
|
|
127
148
|
const handleMcpRequest = async (req, res) => {
|
|
128
149
|
try {
|
|
150
|
+
if (!isAuthorizedRequest(req.headers.authorization, this.options.authToken)) {
|
|
151
|
+
sendMcpError(res, 401, "Unauthorized");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
129
154
|
const sessionId = getSessionIdHeader(req.headers["mcp-session-id"]);
|
|
130
155
|
let session = sessionId ? this.sessions.get(sessionId) : void 0;
|
|
131
156
|
if (!session) {
|
|
@@ -303,7 +328,7 @@ var PORT_RANGE_START2 = 5e4;
|
|
|
303
328
|
var PORT_RANGE_END2 = 6e4;
|
|
304
329
|
var SESSION_IDLE_TTL_MS2 = 15 * 60 * 1e3;
|
|
305
330
|
var SESSION_SWEEP_INTERVAL_MS2 = 60 * 1e3;
|
|
306
|
-
var
|
|
331
|
+
var BandMcpSseServer = class {
|
|
307
332
|
options;
|
|
308
333
|
registrations;
|
|
309
334
|
httpServer = null;
|
|
@@ -350,10 +375,14 @@ var ThenvoiMcpSseServer = class {
|
|
|
350
375
|
app.get("/healthz", (_req, res) => {
|
|
351
376
|
res.json({ status: "ok" });
|
|
352
377
|
});
|
|
353
|
-
app.get("/sse", async (
|
|
378
|
+
app.get("/sse", async (req, res) => {
|
|
379
|
+
if (!isAuthorizedRequest(req.headers.authorization, this.options.authToken)) {
|
|
380
|
+
res.status(401).send("Unauthorized");
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
354
383
|
const transport = new SSEServerTransport("/messages", res);
|
|
355
384
|
const mcpServer = new McpServer({
|
|
356
|
-
name: this.options.name ??
|
|
385
|
+
name: this.options.name ?? MCP_SERVER_NAME,
|
|
357
386
|
version: "1.0.0"
|
|
358
387
|
});
|
|
359
388
|
registerTools3(mcpServer, z, this.registrations);
|
|
@@ -375,6 +404,10 @@ var ThenvoiMcpSseServer = class {
|
|
|
375
404
|
});
|
|
376
405
|
});
|
|
377
406
|
app.post("/messages", async (req, res) => {
|
|
407
|
+
if (!isAuthorizedRequest(req.headers.authorization, this.options.authToken)) {
|
|
408
|
+
res.status(401).send("Unauthorized");
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
378
411
|
const sessionId = typeof req.query.sessionId === "string" ? req.query.sessionId : null;
|
|
379
412
|
if (!sessionId) {
|
|
380
413
|
res.status(400).send("Missing sessionId");
|
|
@@ -488,15 +521,15 @@ function checkPort2(http, port) {
|
|
|
488
521
|
}
|
|
489
522
|
|
|
490
523
|
// src/mcp/backends.ts
|
|
491
|
-
async function
|
|
524
|
+
async function createBandMcpBackend(options) {
|
|
492
525
|
const registrationOptions = {
|
|
493
526
|
enableMemoryTools: options.enableMemoryTools,
|
|
494
527
|
enableContactTools: true,
|
|
495
528
|
additionalTools: options.additionalTools
|
|
496
529
|
};
|
|
497
530
|
if (options.kind === "sdk") {
|
|
498
|
-
const {
|
|
499
|
-
const server2 =
|
|
531
|
+
const { createBandSdkMcpServer } = await import("./mcp-claude.js");
|
|
532
|
+
const server2 = createBandSdkMcpServer({
|
|
500
533
|
getToolsForRoom: options.getToolsForRoom,
|
|
501
534
|
multiRoom: options.multiRoom,
|
|
502
535
|
enableMemoryTools: options.enableMemoryTools,
|
|
@@ -513,7 +546,7 @@ async function createThenvoiMcpBackend(options) {
|
|
|
513
546
|
const registrations = options.multiRoom === false ? buildSingleContextRegistrations(resolvedTools, registrationOptions) : buildRoomScopedRegistrations(resolvedTools, registrationOptions);
|
|
514
547
|
const allowedTools = mcpToolNames(new Set(registrations.map((registration) => registration.name)));
|
|
515
548
|
if (options.kind === "stdio") {
|
|
516
|
-
const server2 = new
|
|
549
|
+
const server2 = new BandMcpStdioServer({
|
|
517
550
|
tools: resolvedTools,
|
|
518
551
|
enableMemoryTools: options.enableMemoryTools,
|
|
519
552
|
enableContactTools: true,
|
|
@@ -529,40 +562,45 @@ async function createThenvoiMcpBackend(options) {
|
|
|
529
562
|
}
|
|
530
563
|
};
|
|
531
564
|
}
|
|
565
|
+
const authToken = generateAuthToken();
|
|
532
566
|
if (options.kind === "sse") {
|
|
533
|
-
const server2 = new
|
|
567
|
+
const server2 = new BandMcpSseServer({
|
|
534
568
|
tools: resolvedTools,
|
|
535
569
|
enableMemoryTools: options.enableMemoryTools,
|
|
536
570
|
enableContactTools: true,
|
|
537
|
-
additionalTools: options.additionalTools
|
|
571
|
+
additionalTools: options.additionalTools,
|
|
572
|
+
authToken
|
|
538
573
|
});
|
|
539
574
|
await server2.start();
|
|
540
575
|
return {
|
|
541
576
|
kind: "sse",
|
|
542
577
|
server: server2,
|
|
543
578
|
allowedTools,
|
|
579
|
+
authToken,
|
|
544
580
|
stop: async () => {
|
|
545
581
|
await server2.stop();
|
|
546
582
|
}
|
|
547
583
|
};
|
|
548
584
|
}
|
|
549
|
-
const server = new
|
|
585
|
+
const server = new BandMcpServer({
|
|
550
586
|
tools: resolvedTools,
|
|
551
587
|
enableMemoryTools: options.enableMemoryTools,
|
|
552
588
|
enableContactTools: true,
|
|
553
|
-
additionalTools: options.additionalTools
|
|
589
|
+
additionalTools: options.additionalTools,
|
|
590
|
+
authToken
|
|
554
591
|
});
|
|
555
592
|
await server.start();
|
|
556
593
|
return {
|
|
557
594
|
kind: "http",
|
|
558
595
|
server,
|
|
559
596
|
allowedTools,
|
|
597
|
+
authToken,
|
|
560
598
|
stop: async () => {
|
|
561
599
|
await server.stop();
|
|
562
600
|
}
|
|
563
601
|
};
|
|
564
602
|
}
|
|
565
|
-
function
|
|
603
|
+
function getBandSdkMcpServerConfig(backend) {
|
|
566
604
|
if (backend.kind !== "sdk") {
|
|
567
605
|
throw new Error(`Expected sdk MCP backend, received ${backend.kind}`);
|
|
568
606
|
}
|
|
@@ -570,9 +608,10 @@ function getThenvoiSdkMcpServerConfig(backend) {
|
|
|
570
608
|
}
|
|
571
609
|
|
|
572
610
|
export {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
611
|
+
generateAuthToken,
|
|
612
|
+
BandMcpStdioServer,
|
|
613
|
+
BandMcpServer,
|
|
614
|
+
BandMcpSseServer,
|
|
615
|
+
createBandMcpBackend,
|
|
616
|
+
getBandSdkMcpServerConfig
|
|
578
617
|
};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
UnsupportedFeatureError,
|
|
11
11
|
ValidationError
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-JY75VSQK.js";
|
|
13
13
|
|
|
14
14
|
// src/client/rest/pagination.ts
|
|
15
15
|
var DEFAULT_PAGE_SIZE = 100;
|
|
@@ -187,6 +187,7 @@ function toNonNegativeInteger(value) {
|
|
|
187
187
|
var DEFAULT_REQUEST_OPTIONS = {
|
|
188
188
|
maxRetries: 3
|
|
189
189
|
};
|
|
190
|
+
var MESSAGE_SEND_MAX_RETRIES = 2;
|
|
190
191
|
|
|
191
192
|
// src/client/rest/responseNormalization.ts
|
|
192
193
|
function asMetadataMap(value) {
|
|
@@ -217,54 +218,16 @@ function normalizeContactRequestsResult(result) {
|
|
|
217
218
|
}
|
|
218
219
|
|
|
219
220
|
// src/client/rest/FernRestAdapter.ts
|
|
220
|
-
function mergeOptions(options) {
|
|
221
|
+
function mergeOptions(options, maxRetries) {
|
|
221
222
|
return {
|
|
222
223
|
...DEFAULT_REQUEST_OPTIONS,
|
|
224
|
+
...maxRetries !== void 0 ? { maxRetries } : {},
|
|
223
225
|
...options
|
|
224
226
|
};
|
|
225
227
|
}
|
|
226
|
-
var AGENT_ME_RETRY_LIMIT = 4;
|
|
227
|
-
var AGENT_ME_RETRY_BASE_DELAY_MS = 2e3;
|
|
228
|
-
var MESSAGE_SEND_RETRY_LIMIT = 3;
|
|
229
|
-
var MESSAGE_SEND_RETRY_BASE_DELAY_MS = 500;
|
|
230
228
|
function asMetadataMap2(value) {
|
|
231
229
|
return asOptionalRecord(value);
|
|
232
230
|
}
|
|
233
|
-
function extractHttpStatus(error) {
|
|
234
|
-
const record = asOptionalRecord(error);
|
|
235
|
-
if (!record) {
|
|
236
|
-
return void 0;
|
|
237
|
-
}
|
|
238
|
-
const response = asOptionalRecord(record.response);
|
|
239
|
-
const status = record.statusCode ?? record.status ?? response?.statusCode ?? response?.status;
|
|
240
|
-
return typeof status === "number" ? status : void 0;
|
|
241
|
-
}
|
|
242
|
-
function isFernRateLimitError(error) {
|
|
243
|
-
return extractHttpStatus(error) === 429;
|
|
244
|
-
}
|
|
245
|
-
async function sleep(ms) {
|
|
246
|
-
await new Promise((resolveDelay) => setTimeout(resolveDelay, ms));
|
|
247
|
-
}
|
|
248
|
-
function computeRetryDelayMs(baseDelayMs, attempt) {
|
|
249
|
-
const backoff = baseDelayMs * 2 ** (attempt - 1);
|
|
250
|
-
const jitter = Math.floor(Math.random() * Math.max(1, Math.floor(backoff / 4)));
|
|
251
|
-
return backoff + jitter;
|
|
252
|
-
}
|
|
253
|
-
async function withRateLimitRetry(operation, options) {
|
|
254
|
-
let lastError;
|
|
255
|
-
for (let attempt = 1; attempt <= options.retryLimit; attempt += 1) {
|
|
256
|
-
try {
|
|
257
|
-
return await operation();
|
|
258
|
-
} catch (error) {
|
|
259
|
-
lastError = error;
|
|
260
|
-
if (!isFernRateLimitError(error) || attempt === options.retryLimit) {
|
|
261
|
-
throw error;
|
|
262
|
-
}
|
|
263
|
-
await sleep(computeRetryDelayMs(options.baseDelayMs, attempt));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
throw lastError instanceof Error ? lastError : new Error("Rate-limit retry exhausted without a terminal error.");
|
|
267
|
-
}
|
|
268
231
|
function requireNonEmptyStringField(value, field, source) {
|
|
269
232
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
270
233
|
throw new Error(`Invalid ${source} response: expected non-empty string AgentIdentity.${field}`);
|
|
@@ -472,28 +435,21 @@ var FernRestAdapter = class {
|
|
|
472
435
|
this.client = client;
|
|
473
436
|
}
|
|
474
437
|
async getAgentMe(options) {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
"profile.getMyProfile"
|
|
491
|
-
);
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
retryLimit: AGENT_ME_RETRY_LIMIT,
|
|
495
|
-
baseDelayMs: AGENT_ME_RETRY_BASE_DELAY_MS
|
|
496
|
-
}
|
|
438
|
+
const requestOptions = mergeOptions(options);
|
|
439
|
+
if (this.client.agentApiIdentity?.getAgentMe) {
|
|
440
|
+
const response = await this.client.agentApiIdentity.getAgentMe(requestOptions);
|
|
441
|
+
return normalizeAgentIdentityEnvelope(response, "agentApiIdentity.getAgentMe");
|
|
442
|
+
}
|
|
443
|
+
const profileClient = this.client.myProfile ?? this.client.humanApiProfile;
|
|
444
|
+
if (!profileClient?.getMyProfile) {
|
|
445
|
+
throw new UnsupportedFeatureError(
|
|
446
|
+
"Fern client missing agentApiIdentity.getAgentMe or humanApiProfile.getMyProfile"
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
const profile = await profileClient.getMyProfile(requestOptions);
|
|
450
|
+
return normalizeLegacyProfileIdentity(
|
|
451
|
+
normalizeLegacyProfileEnvelope(profile),
|
|
452
|
+
"profile.getMyProfile"
|
|
497
453
|
);
|
|
498
454
|
}
|
|
499
455
|
async createChatMessage(chatId, message, options) {
|
|
@@ -501,45 +457,33 @@ var FernRestAdapter = class {
|
|
|
501
457
|
if (!api) {
|
|
502
458
|
throw new UnsupportedFeatureError("Fern client missing chat message creation endpoint");
|
|
503
459
|
}
|
|
504
|
-
const response = await
|
|
505
|
-
|
|
506
|
-
chatId,
|
|
507
|
-
{
|
|
508
|
-
message: {
|
|
509
|
-
content: message.content,
|
|
510
|
-
message_type: message.messageType,
|
|
511
|
-
metadata: message.metadata,
|
|
512
|
-
mentions: message.mentions
|
|
513
|
-
}
|
|
514
|
-
},
|
|
515
|
-
mergeOptions(options)
|
|
516
|
-
),
|
|
460
|
+
const response = await api(
|
|
461
|
+
chatId,
|
|
517
462
|
{
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
463
|
+
message: {
|
|
464
|
+
content: message.content,
|
|
465
|
+
message_type: message.messageType,
|
|
466
|
+
metadata: message.metadata,
|
|
467
|
+
mentions: message.mentions
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
mergeOptions(options, MESSAGE_SEND_MAX_RETRIES)
|
|
521
471
|
);
|
|
522
472
|
return normalizeToolOperationResult(response);
|
|
523
473
|
}
|
|
524
474
|
async createChatEvent(chatId, event, options) {
|
|
525
475
|
const createAgentChatEvent = this.client.agentApiEvents?.createAgentChatEvent?.bind(this.client.agentApiEvents);
|
|
526
476
|
if (createAgentChatEvent) {
|
|
527
|
-
const response = await
|
|
528
|
-
|
|
529
|
-
chatId,
|
|
530
|
-
{
|
|
531
|
-
event: {
|
|
532
|
-
content: event.content,
|
|
533
|
-
message_type: event.messageType,
|
|
534
|
-
metadata: event.metadata
|
|
535
|
-
}
|
|
536
|
-
},
|
|
537
|
-
mergeOptions(options)
|
|
538
|
-
),
|
|
477
|
+
const response = await createAgentChatEvent(
|
|
478
|
+
chatId,
|
|
539
479
|
{
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
480
|
+
event: {
|
|
481
|
+
content: event.content,
|
|
482
|
+
message_type: event.messageType,
|
|
483
|
+
metadata: event.metadata
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
mergeOptions(options, MESSAGE_SEND_MAX_RETRIES)
|
|
543
487
|
);
|
|
544
488
|
return normalizeToolOperationResult(response);
|
|
545
489
|
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
// src/core/errors.ts
|
|
2
|
-
var
|
|
2
|
+
var BandSdkError = class extends Error {
|
|
3
3
|
constructor(message, cause) {
|
|
4
4
|
super(message, cause !== void 0 ? { cause } : void 0);
|
|
5
|
-
this.name = "
|
|
5
|
+
this.name = "BandSdkError";
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
|
-
var UnsupportedFeatureError = class extends
|
|
8
|
+
var UnsupportedFeatureError = class extends BandSdkError {
|
|
9
9
|
constructor(message) {
|
|
10
10
|
super(message);
|
|
11
11
|
this.name = "UnsupportedFeatureError";
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
var ValidationError = class extends
|
|
14
|
+
var ValidationError = class extends BandSdkError {
|
|
15
15
|
constructor(message, cause) {
|
|
16
16
|
super(message, cause);
|
|
17
17
|
this.name = "ValidationError";
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
var TransportError = class extends
|
|
20
|
+
var TransportError = class extends BandSdkError {
|
|
21
21
|
constructor(message, cause) {
|
|
22
22
|
super(message, cause);
|
|
23
23
|
this.name = "TransportError";
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
var RuntimeStateError = class extends
|
|
26
|
+
var RuntimeStateError = class extends BandSdkError {
|
|
27
27
|
constructor(message) {
|
|
28
28
|
super(message);
|
|
29
29
|
this.name = "RuntimeStateError";
|
|
@@ -31,7 +31,7 @@ var RuntimeStateError = class extends ThenvoiSdkError {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export {
|
|
34
|
-
|
|
34
|
+
BandSdkError,
|
|
35
35
|
UnsupportedFeatureError,
|
|
36
36
|
ValidationError,
|
|
37
37
|
TransportError,
|
|
@@ -57,6 +57,22 @@ function formatHistoryForLlm(messages, options) {
|
|
|
57
57
|
const participants = options?.participants;
|
|
58
58
|
return messages.filter((message) => String(message.id ?? "") !== excludeId).map((message) => formatMessageForLlm(message, participants));
|
|
59
59
|
}
|
|
60
|
+
function toParticipantRecord(fields) {
|
|
61
|
+
return {
|
|
62
|
+
id: fields.id,
|
|
63
|
+
name: fields.name ?? "unknown",
|
|
64
|
+
type: fields.type ?? "unknown",
|
|
65
|
+
handle: fields.handle ?? null
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function toParticipantRecordFromRest(participant) {
|
|
69
|
+
return {
|
|
70
|
+
id: participant.id,
|
|
71
|
+
name: participant.name,
|
|
72
|
+
type: participant.type,
|
|
73
|
+
handle: participant.handle ?? null
|
|
74
|
+
};
|
|
75
|
+
}
|
|
60
76
|
function buildParticipantsMessage(participants) {
|
|
61
77
|
if (participants.length === 0) {
|
|
62
78
|
return "## Current Participants\nNo other participants in this room.";
|
|
@@ -72,7 +88,7 @@ function buildParticipantsMessage(participants) {
|
|
|
72
88
|
}
|
|
73
89
|
lines.push("");
|
|
74
90
|
lines.push(
|
|
75
|
-
"IMPORTANT: In
|
|
91
|
+
"IMPORTANT: In band_send_message mentions, always use the exact handle shown above (e.g. '@john' for users, '@john/weather-agent' for agents), NOT the display name. Handles are lowercase with no spaces."
|
|
76
92
|
);
|
|
77
93
|
return lines.join("\n");
|
|
78
94
|
}
|
|
@@ -86,5 +102,7 @@ export {
|
|
|
86
102
|
replaceUuidMentions,
|
|
87
103
|
formatMessageForLlm,
|
|
88
104
|
formatHistoryForLlm,
|
|
105
|
+
toParticipantRecord,
|
|
106
|
+
toParticipantRecordFromRest,
|
|
89
107
|
buildParticipantsMessage
|
|
90
108
|
};
|